(test?return_true:return_false)

Peter Abel p-abel at t-online.de
Thu Jan 23 16:16:35 EST 2003


backwardthinker at juno.com (Daniel) wrote in message news:<1d4cf4c3.0301230735.489c525f at posting.google.com>...
> Is there a python equivalent to the (test?return_true:return_false)
> function?  It's present in a number of other languages, so I was
> hoping there would be something similar.  If test evaluates to true,
> then the 1st value is returned.  If false... the 2nd value.
> 
> For a dumb example, something to the effect of: print 'Search complete
> (%d match%s found)'%(matches,(matches==1?'':'es'))
> 
> Thanks,
> Daniel

See the "and-or trick in dive into python"
at http://diveintopython.org/apihelper_andor.html
Peter




More information about the Python-list mailing list