Conditional iteration

at at at tuko.nl
Wed Dec 13 13:29:48 EST 2006


Forget 'pythonic'.

I just need to get work done and I see this type of conditional iteration
showing up many times obscuring my code because of the additional
indentation.

In line with previous syntax improvements made in Python my proposal (or
obvious variants) seems a logical next step. Unless of course nobody
appreciates it. That's the discussion I'd like to have here in the forum.

All the best
@



Roberto Bonvallet 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,




More information about the Python-list mailing list