python3 urlopen(...).read() returns bytes

2008-12-22 Thread Glenn G. Chappell
I just ran 2to3 on a py2.5 script that does pattern matching on the text of a web page. The resulting script crashed, because when I did f = urllib.request.urlopen(url) text = f.read() then "text" is a bytes object, not a string, and so I can't do a regexp on it. Of course, this is easy

Re: python3 urlopen(...).read() returns bytes

2008-12-22 Thread Glenn G. Chappell
Okay, so I guess I didn't really *get* the whole unicode/text/binary thing. Maybe I still don't, but I think I'm getting closer. Thanks to everyone who replied. On Dec 22, 1:41 pm, ajaksu wrote: > On Dec 22, 8:25 pm, Christian Heimes wrote: > That said, a "decode to declared HTTP header encoding