(a==b) ? 'Yes' : 'No'

gentlestone tibor.beck at hotmail.com
Tue Mar 30 17:40:56 CEST 2010


Hi, how can I write the popular C/JAVA syntax in Python?

Java example:
    return (a==b) ? 'Yes' : 'No'

My first idea is:
    return ('No','Yes')[bool(a==b)]

Is there a more elegant/common python expression for this?




More information about the Python-list mailing list