while (a=b()) ...
Aahz Maruch
aahz at netcom.com
Sat May 15 12:38:20 EDT 1999
In article <015401be9eeb$5e130300$f29b12c2 at pythonware.com>,
Fredrik Lundh <fredrik at pythonware.com> wrote:
>Aahz Maruch <aahz at netcom.com> wrote:
>>
>> What does this give you that
>>
>> for line in f.readline()
>> frobulate(line)
>>
>> does not? (Assuming the necessary semantic changes to permit this to
>> work *well*.)
>
>fwiw, this already works well. it does exactly
>what it's supposed to do -- that is, iterate over
>the character sequence returned by the call
>to readline.
It works "correctly" from a Python perspective, but it doesn't do what a
cursory glance would expect from someone who doesn't know Python. In
any event, I should have written
for line in f.readlines()
But even that is beside the point. The point is that it's currently a
bit harder than it should be to build such iterator idioms in the
general case; fix that and we get rid of most of the whiners.
--
--- Aahz (@netcom.com)
Hugs and backrubs -- I break Rule 6 <*> http://www.rahul.net/aahz/
Androgynous poly kinky vanilla queer het
'It's odd, and a little unsettling, to reflect upon the fact that English is
the only major language in which "I" is capitalized; in many other languages
"You" is capitalized and the "i" is lower case.' -- Sydney J. Harris
More information about the Python-list
mailing list