Trinary operator?

Cimarron Taylor cimarron+google at taylors.org
Sat Apr 20 17:35:33 EDT 2002


"Philipp Lenssen" <lenssen at hitnet.rwth-aachen.de> wrote in message news:<a9kci2$dv0$1 at nets3.rz.RWTH-Aachen.DE>...
> Not that it's a big deal since there's many ways to do that, but can I use
> something like
>     verboseGender = (gender == 'm') ? 'male' : 'female'
> in Python?

Will this do what you want?

verboseGender = ('female','male')[gender=='m']

Cim



More information about the Python-list mailing list