Conditional iteration

Roberto Bonvallet Roberto.Bonvallet at cern.ch
Thu Dec 14 06:37:26 EST 2006


at wrote:
> I think by approving
> 
> a = b if condition else c
> 
> used to avloind
> 
> if condition:
>        a = b
> else:
>        a = c
> 
> which is dealing with same psychological problem, Guido also recognizes some
> need...

GvR did not introduce the new conditional syntax because he felt it was
needed or just to avoid typing a couple of extra lines.  He did it just to
avoid people keep using the ugly and error-prone "a and b or c" idiom.  See
the related PEP:  http://www.python.org/dev/peps/pep-0308/

-- 
Roberto Bonvallet



More information about the Python-list mailing list