Inline Conditionals?
Adonis
adonisv at DELETETHISTEXTearthlink.net
Tue Aug 24 19:22:27 EDT 2004
"Joshua Ginsberg" <joshg at brainstorminternet.net> wrote in message
news:mailman.2307.1093385983.5135.python-list at python.org...
> Is there any plan to include inline conditionals in Python? For example:
>
> def isNegative(x):
> return x < 0 ? True : False
>
> Thanks!
>
> -jag
>
> --
> Joshua Ginsberg <joshg at brainstorminternet.net>
> Brainstorm Internet Network Operations
>
How about something like:
>>> def iif(condition, true=True, false=False):
... if condition:
... return true
... return false
...
>>> iif('foo' == 'bar', 'w00t', 'l33t')
'l33t'
>>> iif('bar' == 'bar', 'w00t', 'l33t')
'w00t'
>>> iif('bar' == 'bar')
True
>>> iif('foo' == 'bar')
False
>>>
Hope this helps.
Adonis
More information about the Python-list
mailing list