For review: PEP 308 - If-then-else expression
John La Rooy
nospampls.jlr at doctor.com
Mon Feb 10 16:06:06 EST 2003
On Mon, 10 Feb 2003 12:26:34 +0100
holger krekel <pyth at devel.trillke.net> wrote:
>
> > >> If you parenthesize it:
> >
> > >> (if debug: sys.stderr.write('got here\n') else: None)
> >
> > >> then the "if" is no longer the first token in the statement, so it
> > >> introduces an if-expression. No problem.
>
> Special cases aren't special enough ...
>
> We all like Python's easy grammar and uniformity, don't we?
>
> holger
>
Indeed. Could we perhaps consider making if an expression in every case and
have it evaluate to the last expression in the block so we could write
print if x>0:
### possibly several lines of code here...
...
f(x)
else:
### and here too...
...
f(-x)
John
More information about the Python-list
mailing list