Requests: HTTP for Humans
docs.python-requests.org
docs.python-requests.org
This looks like another reason to believe that if you build a better solution, even when the space is well-covered, that you can still win adoption, so maybe, a lot of people can stop worrying about being second.
Indeed.
Looks like he just co-opted the theme (Pocoo might have it available somewhere, but I couldn't find it). Nothing wrong with that, it's a great theme.
https://github.com/kennethreitz/kr-sphinx-themes
The original is here: https://github.com/mitsuhiko/flask-sphinx-themesRequests is hosted on a site called Read the Docs, which does documentation hosting for Sphinx projects: http://readthedocs.org/
Sphinx has become the defacto documentation tool for Python projects, and a lot of other projets as well. Notably a number of PHP projects, and Varnish the web cache use it also.
http://www.pocoo.org/projects/#project-hub shows all of their projects. Pocoo significantly improves the lives of all Python developers. Thanks pocoo team!
It does highlight my biggest gripe about Python, though. I love the language, but the class library is hit-and-miss, and anything to do with HTTP is a pretty big miss. httplib, urllib, urllib2, cookielib -- yuck. I like that Requests has a nice API, but it's still built on top of pretty bad class libs underneath. (And the Requests API does expose some warts, like having to use cookielib's CookieJars.)
I'd really love to see someone's take on a clean break from the standard modules with a simple, maleable API.
(Here's the URL for the project: http://benoitc.github.com/restkit/)
Disclosure: I'm listed in the requests AUTHORS file but can claim credit for, oh, about 0.0001% of the awesomeness.
1. http://code.google.com/p/httplib2/issues/detail?id=96 is a good example: an annoying bug which affect many people, there was a fix available for months, which worked great when I applied it in a fork and pounded a couple TB of data through it, but it took over a year to make it into trunk and even longer to make it onto PyPI where any other project which required "httplib2" would get the working version.
The simple example on the home page should have one more line of code that shows that you use r.content to get to the content that came back from the request. That would seem to be the most common use case.
Thanks for teaching me what the documentation failed to—it's neither in the front page example, or in the API documentation for Response.
Also, I can't believe it includes PATCH support. Surprising, but good, to see that out in the wild.
here's the api for a generic request, get is right under it: https://github.com/kennethreitz/requests/blob/develop/reques...
It will likely be very call+result oriented at first (no interaction w/ a running process)
sshc = psutil.Process(pid)
sshc.get_connections()
It allows you to upconvert process ids, and it has its own wrapper of Popen that returns Process objects. It also seems to have well thought out windows compatibility, if that matters to you.:D <- My face when I found it.
Python's urllib2 isn't that bad for the simple stuff shown in your links, but it's a mess when you have to try to log in somewhere. Seeing in the example that logging in is as straightforward as
requests.get('https://api.github.com', auth=('user', 'pass'))
just blew me away.https://github.com/kennethreitz/requests/commit/773630b0109c...
and wondering what "from .status_codes import codes" does?
Specifically the fact that it's not "status_codes" and has a dot prepended. Is that something special in Python (guessing no) or some convention that is used? Just curious.
The relevant bit:
"When specifying what module to import you do not have to specify the absolute name of the module. When a module or package is contained within another package it is possible to make a relative import within the same top package without having to mention the package name. By using leading dots in the specified module or package after from you can specify how high to traverse up the current package hierarchy without specifying exact names. One leading dot means the current package where the module making the import exists. Two dots means up one package level. Three dots is up two levels, etc. So if you execute from . import mod from a module in the pkg package then you will end up importing pkg.mod. If you execute from ..subpkg2 import mod from within pkg.subpkg1 you will import pkg.subpkg2.mod. The specification for relative imports is contained within PEP 328."
Cool stuff.
This is the kind of stuff that I would love to see in the Python standard library.
I think the parent poster is looking for a client API that is nicer to use than java.net.Url and/or the various versions of HTTPClient
The link I provided was to an example of using restlet on the client side. I would agree that the api is not as human friendly as it could be but it does describe interactions in a restful which is why I suggested it would be a good starting point for writing a friendly api.
That means it's pretty elegant and nice :)