Conditional iteration

Diez B. Roggisch deets at nospam.web.de
Thu Dec 14 05:19:16 EST 2006


> 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