Shouldn't urlopen "files" be iterable?

Jarno J Virtanen jajvirta at cc.helsinki.fi
Sat Sep 29 02:26:42 EDT 2001


Sat, 29 Sep 2001 00:33:33 +0200 Magnus Lie Hetland wrote:
> I just tried to do
> 
>   for line in urlopen(url): ...
> 
> but it didn't work... Shouldn't the urllib "files"
> behave like other files? (Using 2.2a2)

Yeah, you just forgot ".readlines()", e.g.:

for line in urllib.urlopen(url).readlines():
    ...



More information about the Python-list mailing list