[Python-ideas] "While" suggestion
stavros at korokithakis.net
Thu Jul 3 17:44:59 CEST 2008
That is true, but in this particular usage there's no iterator that
would do what we wanted... I agree that it approaches the realm of the
"for" statement, though.
Thomas Lee wrote:
> Facundo Batista wrote:
>> 2008/7/3 George Sakkis <george.sakkis at gmail.com>:
>>> There is already an idiom for this, although admittedly not obvious or
>>> for data in iter(lambda: my_file.read(1024), ''):
>>> or in 2.5+:
>>> from functools import partial
>>> for data in iter(partial(my_file.read,1024), ''):
>> Yes, but note that these feels like workarounds.
>> One thing that I love in Python is that you can learn a concept, and
>> apply it a lot of times.
>> So, suppose I'm learning Python and find that I can do this...
>> with_stmt ::= "with" expression ["as" target] ":" suite
>> ...why can't I do this?:
>> while_stmt ::= "while" expression ["as" target] ":" suite
> I'm -1on the while .. as syntax myself.
> Something about this syntax feels wrong ... it's effectively a for loop
> looking for a reason not to use an iterator.
> You might be right about it being more consistent though.
> Python-ideas mailing list
> Python-ideas at python.org
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 143 bytes
Desc: not available
More information about the Python-ideas