the PHP ternary operator equivalent on Python

bonono at gmail.com bonono at gmail.com
Wed Nov 23 10:37:21 EST 2005


Luis M. Gonzalez wrote:
> This could be done easier this way:
>
> L = [('even','odd')[n%2] for n in range(8)]

That is even/odd, his(created to demonstrate the uglies of ternary) has
4 states, zero, -/+ then even/odd.




More information about the Python-list mailing list