Conditional iteration
Neil Cerutti
horpner at yahoo.com
Wed Dec 13 10:30:04 EST 2006
On 2006-12-13, Roberto Bonvallet <Roberto.Bonvallet at cern.ch> wrote:
> at wrote:
>> More pythonic in view would be:
>>
>> for x in [-2, -1, 0, 1, 2, 3, 4] if x > 0:
>> ... more code ...
>
> Pythonic? Do you realize that Python hasn't even adopted
> well-known statements like 'switch' and 'do while' because they
> would be redundant?
>
> This could be more convenient to you, but certainly not
> pythonic. Cheers,
I tried it once myself. It seemed like a feasible thing that
might work in Python. It didn't annoy me that it didn't work, but
it did seem natural to me given the syntax of comprehensions.
--
Neil Cerutti
More information about the Python-list
mailing list