Conditional iteration
Colin J. Williams
cjw at sympatico.ca
Sat Dec 16 11:00:07 EST 2006
at wrote:
> Dear Carl,
>
> Well, all I can say that for me as a user it would make sense...
>
> Curiosity: in what sense is it redundant?
> All solution/workarounds I have seen so far involve creation of new lists
> (subsets) adding to more processing/computation/memory usage. Redundant
> suggests that you know alternatives that don't do that.
>
> Does Guido ever change his mind?
Yes, he was opposed to conditional expressions at one time. I like the
scheme he came up with.
In the present context, Paul Rubin suggested new syntax:
Use:
for x in (x in [-2, -1, 0, 1, 2, 3, 4] if x > 0):
... more code ...
Colin W.
>
> Cheers,
>
> @
>
>
> Carl Banks wrote:
>
>> at wrote:
>>> I am not looking for a work around but more interest if other people
>>> might judge this syntax would come in handy?
>> Of course people have expressed interest in this in the past, but it's
>> not going to happen. There's a way to nest for and if statements, and
>> a different way to nest for and if clauses in listcomps, and the two
>> methods are considered distinct. Although Guido has said that saving
>> indentation levels is important, he hasn't said anything (that I'm
>> aware of) that suggests it's important enough to add this complexity
>> and redundancy to the language. Sorry.
>>
>>
>> Carl Banks
>
More information about the Python-list
mailing list