Requests, Python HTTP for Humans, reached v1.0
kennethreitz.org
kennethreitz.org
I've been using it a lot recently (though I've never had to go too deep into it). I'm impressed with the simplification and removal of code in this release. If only that was a goal for every project :)
[1] http://www.gnu.org/licenses/license-list.html#apache2
[2] http://wiki.python.org/moin/PythonSoftwareFoundationLicenseF...
"The entire codebase has been rearchitected"
I hope there are a few tests to check for regressions? ;)(I just noticed it is at 1.0.2 now. I think I'm going to have to give this a couple weeks before I upgrade any of my projects.)
Then 1.0 happens. I have now moved requests to the "thoroughly test before upgrade" pile.
In open source, it's harder because all of that is open, which means there is a conflict between x.0 means "release" and x.0 means "development is just beginning. It probably should mean the latter.
But then having a big "It's 1.0 and fabulous!" blog post is the wrong thing to do. It probably should have been "It's 1.0; be careful!" I don't see how you can have it both ways. Linus took care of that with odd/even versioning, but I think you need a huge project for people to pay enough attention to understand unless it became a de facto standard (which it hasn't in over a decade, so it's unlikely to).
(BTW, I am very grateful for the work you've put into this. Requests is truly a model API. My comments are much more meta about versioning and open source in general (using this project as an example) and should in no way be construed as saying I think you are doing something wrong.)
I've never really had this impression before. Do you think people would have been holding off on using a library like this because it was at 0.14 before? I'm curious where this impression comes from.
Details seem relatively scant. But maybe that's because response.json() is the only feature I'm using that changed...
session.config['verbose'] = sys.stderr
I couldn't find anything about it in the API docs.Need to show how to use it in the docs still.
In any case, thank you! I will use Requests as an example to follow.
Any hints on how to solve these incompatibilities between HTTPie and Requests v1.0 appreciated: https://github.com/jkbr/httpie/issues/113.
Requests is great by the way, had already written some code to abstract away the urllib/urllib2 mess but this module is so much more complete (of course) and cleaner.
A good example is C#/.NET issues (and somewhat java) where you have .length .Length and .Length() and .Size() and .Count() and so on. It makes changing a data type an exercise in annoyance, and on the one hand there is a decent argument about semantic meaning of the name, on the other hand, tracking each and every subtle use of "I need to know how many things I'm dealing with" in several different ways becomes an exercise in yak shaving.
As for the specific of .json - A lot of python web frameworks provide a .json attribute/property to the request structure, so I presume the earlier version of Requests was mirroring that for conceptual continuity.
I'm not sure why java uses .length for arrays and .size() for collections ... but could it be that it was for similar reasons?
"Requests is SEXY AWESOME!" "No wait, it's crap, complex, hard-to-follow code. But the NEW version is SEXY AWESOME!" (...at least until the next release, I suppose)
That is no longer the case.
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?
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 :)
Regardless, httplib2 seems to have lots of other technical advantages over httplib - have you considered using it?
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.
"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 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.
If the developer interface was elegant, and the library itself ran very well without any errors, is anything actually gained by making the internal code elegant?
What happens if the new version, while more elegant internally, has a new complex bug in it (such as a race condition, that only triggers once every billion requests)? Still worthwhile to fix up the inelegant code that was working correctly?
(Disclaimer: I feel it's better to clean it up regardless, but I have a feeling a study would show something different in terms of lost productivity...)
The new code is also much easier to debug and pleasure to work with. Bugs will be significantly easier to fix :)
Then it's easier to find. All software has bugs, readability is one important part of fixing them.
That last part is borderline. Some wouldn't call it part of the interface, but I do, because if there are problems then interface users end up wrapping the interface with another interface to work around those problems.
I therefore argue that the "more elegant but buggier" internals don't have the same interface, even if the API calls look the same.
As to why it should be more elegant? There are at least four parts here . How does the developer, or any interface user, review the code to see if there is a complex bug inside? That is, your scenario about the bug in the elegant code also applies to the inelegant. And how easy is it to carry out extensions to the project in the old code base vs. the new, even if those new features aren't yet implemented?
Third, the type of person who strives for an elegant interface also probably strives for elegant internals. Fourth, there are people who don't like closed boxes, and want to understand some of the insides of a package before they use it. If the insides don't look good, then they might be adverse to using it.
A term for the negative aspects of this tendency to clean up internal code is called "gold plating." A positive term is "technical debt", as in the inelegant code incurs a debt which must be paid off in the future by cleaning up the code.
If this is no longer the case, then this indeed is a fantastic change - looking forward to diving in soon.
http://dpaste.com/hold/847350/
xlwt3 development stopped: http://pypi.python.org/pypi/xlwt3/0.1.2
Maybe xlwt3 could be replace by openpyxl? http://pypi.python.org/pypi/openpyxl/1.6.1
Once that's done, someone has volunteered to add Python 3 support to xlwt as well. openpyxl isn't a direct replacement: it uses the XML-based xlsx format, whereas xlrd/xlwt use the binary xls format.
I love Kenneth Reitz and admire his skill but "come on, man."
I'm grateful for the love and care you've put into libraries like 'requests'. When I've been toiling away at a program for hours and it winds up resembling something like spaghetti mixed with beer shits, I find that if I stop and study some of your code, I am instantly a better programmer.
http://docs.python-requests.org/en/v1.0.0/
> I’m going to get @kennethreitz’s Python requests module tattooed on my body, somehow. The whole thing. — Matt DeBoard