[Tutor] urllib confusion

Joel Goldstick joel.goldstick at gmail.com
Fri Nov 21 23:38:57 CET 2014


On Fri, Nov 21, 2014 at 4:37 PM, Clayton Kirkwood <crk at godblessthe.us> wrote:
> Hi all.
>
>
>
> Got a general problem with url work. I’ve struggled through a lot of code
> which uses urllib.[parse,request]* and urllib2. First q: I read someplace in
> urllib documentation which makes it sound like either urllib or urllib2
> modules are being deprecated in 3.5. Don’t know if it’s only part or whole.

The names of the modules changed I believe in v3.x.

But you can save yourself a lot of trouble by using the excelent 3rd
party package called requests:
http://docs.python-requests.org/en/latest/

Also, please use plaintext for your questions.  That way everyone can
read them, and the indentation won't get mangled
>
> I’ve read through a lot that says that urllib..urlopen needs urlencode,
> and/or encode(‘utf-8’) for byte conversion, but I’ve seen plenty of examples
> where nothing is being encoded either way. I also have a sneeking suspicious
> that urllib2 code does all of the encoding. I’ve read that if things aren’t
> encoded that I will get TypeError, yet I’ve seen plenty of examples where
> there is no error and no encoding.
>
>
>
> Why do so many examples seem to not encode? And not get TypeError? And yes,
> for those of you who are about to suggest it, I have tried a lot of things
> and read for many hours.
>
>
>
> Thanks,
>
>
>
> Clayton
>
>
>
>
>
>
>
> You can tell the caliber of a man by his gun--c. kirkwood
>
>
>
>
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
>



-- 
Joel Goldstick
http://joelgoldstick.com


More information about the Tutor mailing list