y=if x>High: 2 elif x<Low: 1 else: 0
holger krekel
pyth at devel.trillke.net
Wed May 22 17:48:20 EDT 2002
gr wrote:
> Hi,
> is there a simple possiblity to "teach" Python:
>
> y=if x>High: 2 elif x<Low: 1 else: 0
don't let anyone see this :-)
> instead of
>
> if x>High:
> y=2
> elif x<Low:
> y=1
> else:
> y=0
this works...
y = x<Low and 1 or x>High and 2 or 0
but don't show it around too much, either :-)
the if-elif-else is usually understood best.
holger
More information about the Python-list
mailing list