Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #47962

Re: Must we include urllib just to decode a URL-encoded string, when using Requests?

References <CAKDXFkO6t9dkYTrughGL4DzBfAOypia7w34hkmFAN9xext9TWA@mail.gmail.com> <kpcgvj$m7p$1@ger.gmane.org> <CAKDXFkOYUgb-Sw=MK3SpSNPUAO+ubt248E9KX39aK8T7+=ZcUQ@mail.gmail.com> <kpchpg$vh1$1@ger.gmane.org>
Date 2013-06-13 16:41 +0300
Subject Re: Must we include urllib just to decode a URL-encoded string, when using Requests?
From Dotan Cohen <dotancohen@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.3194.1371131291.3114.python-list@python.org> (permalink)

Show all headers | View raw


On Thu, Jun 13, 2013 at 4:34 PM, Robert Kern <robert.kern@gmail.com> wrote:
>> I'm pretty sure that Requests will use either urllib or urllib2,
>> depending on what is available on the server.
>
> No, it doesn't. It gets its quote() function from urllib always.
>

I see, thanks. Then that is what I will do as well!

>> I would like to use
>> whatever Requests is currently using, rather than import the other.
>> Can I tell which library Requests is currently using and use that?
>
>
> The only thing I can think that you are talking about is the difference
> between Python 2 and Python 3. In Python 2, it's urllib.quote() and in
> Python 3, it's urllib.parse.quote(), but that's a Python-version issue, not
> something to do with requests, per se. requests does have a compatibility
> layer, internally, that pastes over those issues, but I don't think that is
> intended to be a stable public API that you should rely on. You should
> handle that kind of switch yourself if you care about compatibility across
> both versions of Python.
>
> https://github.com/kennethreitz/requests/blob/master/requests/compat.py#L86
>

Great, thank you Robert. I see that Requests is calling both urllib
and urllib2. For some reason I thought that is rather wasteful and
should be avoided. I was probably wrong!

--
Dotan Cohen

http://gibberish.co.il
http://what-is-what.com

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: Must we include urllib just to decode a URL-encoded string, when using Requests? Dotan Cohen <dotancohen@gmail.com> - 2013-06-13 16:41 +0300

csiph-web