Proposed PEP for a Conditional Expression
Michael Chermside
mcherm at destiny.com
Tue Sep 18 10:53:32 EDT 2001
> What do you think about this idiom?
>
>>>> a=5; b=2
>>>> c=5*[2,3][a==b]
>>>> c
> 10
>>>> a=2
>>>> c=5*[2,3][a==b]
>>>> c
> 15
>
> Of course it doesn't solve the PEP problem's:
>>>> def toto(x):
> ... print "toto"
> ... return x+1
> ...
>>>> c=5*[toto(2),toto(3)][a==b]
> toto
> toto
>
> But for const expressions, do you think it's obfucassed Python?
>
Yes, actually, I do. It certainly doesn't "say what it means".
-- Michael Chermside
More information about the Python-list
mailing list