(test?return_true:return_false)

Mikael Schönenberg micke at strakt.com
Thu Jan 23 16:45:52 CET 2003


On 23 Jan 2003, Daniel wrote:

> 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'))

http://www.python.org/cgi-bin/faqw.py?req=show&file=faq04.016.htp

:)

/micke







More information about the Python-list mailing list