Shouldn't urlopen "files" be iterable?
Grant Edwards
grante at visi.com
Sat Sep 29 14:48:07 EDT 2001
On Sat, 29 Sep 2001 20:29:51 +0200, Magnus Lie Hetland <mlh at idi.ntnu.no> wrote:
>"Jarno J Virtanen" <jajvirta at cc.helsinki.fi> wrote in message
>news:slrn9raqcm.k93.jajvirta at sirppi.helsinki.fi...
>> 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():
>> ...
>
>No, my good man... I did not forget <wink>. readlines()
>would require me to download the whole thing in one
>go, and that isn't necessarily what I want.
How do you request part of a file via HTTP?
--
Grant Edwards grante Yow! Why was I BORN?
at
visi.com
More information about the Python-list
mailing list