[issue7399] Possible bug in Python Tutorial
David Henretty
report at bugs.python.org
Thu Nov 26 17:30:26 CET 2009
New submission from David Henretty <dhenretty at a2etech.com>:
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
----------
assignee: georg.brandl
components: Documentation
messages: 95749
nosy: dh, georg.brandl
severity: normal
status: open
title: Possible bug in Python Tutorial
type: compile error
versions: Python 3.1
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue7399>
_______________________________________
More information about the Python-bugs-list
mailing list