Conditional iteration

at at at tuko.nl
Thu Dec 14 12:59:21 EST 2006


Dear Diez,

True, I was just mentioning a workaround for a typical case.

Kind regards,

Arjan

Diez B. Roggisch wrote:

>> Is it redundant according to your criteria, yes I would say:
>> 
>> a = {True: a, False: c}[condition]
>> 
>> or
>> 
>> a = [c, a][condition]
>> 
>> would yield exactly the same even in one sentence....
> 
> Obviously it is _not_ the exact same.
> 
> 
> def fac(n):
>   return n * fac(n-1) if n else 1
> 
> 
> Try that with your recipes above.
> 
> Diez




More information about the Python-list mailing list