6 ms·
Dude you are my hero. I've printed requests source code and use it as an example of great python code. You and guys like Armin Ronacher are the reason why I us
by Goranek 14y ago
Dude you are my hero.
I've printed requests source code and use it as an example of great python code.
You and guys like Armin Ronacher are the reason why I use and like Python so much !!!
(when jerking stops)
Question: I have a feeling that with Requests you're just hiding the problem and not trying to solve it (Urllib is still in the back). Shouldn't urllib(1,2,3...) be rewritten instead?
- jevinskie 14y agoProbably, but rewriting a core module (this would be urllib4!?) is a lot harder (politically at least) than creating a 3rd party wrapper module.
- kenneth_reitz 14y agoThanks! Urllib isn't used at all, actually. Internally, I use a project called 'urllib3', but it's totally unrelated to urlilb. It's name is actually a joke. It is essentially a light wrapper around httplib that provides connection pooling :)
- ak217 14y agoBy the way, I found a bug in httplib where, when sending a request body, if the peer closes the socket early with an error (HTTP/1.1 compliant behavior), the request will time out instead of returning the correct error information. To my knowledge, this is also present in httplib2. This is because the socket write in both libraries is blocking (which seems simply wrong). I'm hoping to send a patch sometime soon. Regardless, httplib2 seems to have lots of other technical advantages over httplib - have you considered using it?
- kenneth_reitz 14y agohttp://code.google.com/p/httplib2/source/browse/python2/httplib2/__init__.py#1598 http://code.google.com/p/httplib2/source/browse/python2/http... The entire process of sending a Request is wrapped in a 'try/except Exception' block. wtf. It also just aimlessly retries failed requests. This is not configurable. Httplib2 is terrible. I actually created Requests partially in spite of it.
- ak217 14y agoMakes sense, thanks. I'll have to work on patching up httplib, then.
- RyanMcGreal 14y agohttplib2 is not thread-safe. That pretty much makes it a deal-breaker, even if the API is a significant improvement over the standard library (though not over requests).
- Goranek 14y agoWell that's a different story then :) Good job!
- ak217 14y agoI really respect both Kenneth and Armin for their work, but I find that Armin sometimes puts way too much trust in magic :)
- the_mitsuhiko 14y agoWhere did I do that?
- ak217 14y agohttp://dev.pocoo.org/~mitsuhiko/didntknow.pdf http://dev.pocoo.org/~mitsuhiko/didntknow.pdf "Custom Ducks" and "Cached Properties" terrify me a bit. Not Pythonic (as in, not easily readable). But on the whole, I take that back. I was looking through your talks and realized that was the only place I got that feeling, and also found http://dev.pocoo.org/~mitsuhiko/badideas.pdf http://dev.pocoo.org/~mitsuhiko/badideas.pdf which takes a stand against magic. Edit: I still think arguments would be better (more explicit/readable) than globals (request, etc.) in Flask, but it's your module and I know you've considered the reasons to make it that way. And globals don't exactly qualify as magic.
- asksol 14y agoI love cached_property, and I don't see what makes it unpythonic. I don't consider it magic, it's just a small addition to the built-in property descriptor, and it makes the often repeated code easier to read. I'm sure it will be a common idiom very soon.
- eric_bullington 14y agoAre you perhaps confusing Armin with the creator of another Python web framework? One of the things I love about werkzeug and Flask is the relative absence of magic. Compared to many other popular web frameworks, his projects are extremely Pythonic.
- ak217 14y agoNo, I mean the right Armin. See the other reply though. I only got that feeling once when looking through his talks, and I otherwise take that sentiment back.