This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author dh
Recipients dh, georg.brandl
Date 2009-11-26.16:30:24
SpamBayes Score 8.467536e-07
Marked as misclassified No
Message-id <1259253026.9.0.615339023248.issue7399@psf.upfronthosting.co.za>
In-reply-to
Content
Hi,

In the v3.1.1 Python Tutorial (section 10.7 - Internet Access), the 
sample code (shown below) results in the following error :-

from urllib.request import urlopen
for line in urlopen('http://tycho.usno.navy.mil/cgi-bin/timer.pl'):
     if 'EST' in line or 'EDT' in line:
         print(line)

Traceback (most recent call last):
  File "<stdin>", line 2, in <module>
TypeError: Type str doesn't support the buffer API

I presume this has something to do with the assumed type of the 
variable 'line', but I am very new to Python.

Replacing the 'if' line with the following DOES work :-

     if 'EST' in str(line) or 'EDT' in str(line):

Can anyone confirm / explain this ?

Thanks,

DH
History
Date User Action Args
2009-11-26 16:30:27dhsetrecipients: + dh, georg.brandl
2009-11-26 16:30:26dhsetmessageid: <1259253026.9.0.615339023248.issue7399@psf.upfronthosting.co.za>
2009-11-26 16:30:25dhlinkissue7399 messages
2009-11-26 16:30:24dhcreate