For review: PEP 308 - If-then-else expression

Erik Max Francis max at alcyone.com
Tue Feb 11 02:08:35 EST 2003


Andrew Koenig wrote:

> In my grammar proposal, I'm defining it that way: Any statement that
> begins with "if" is an if-statement, not an if-expression treated
> as a statement.

This is also my proposal.  The so-called Corner Case is unimportant and
it's perfectly fine if it's rejected.  That means the addition of the
conditional operator, but no changes to how statements (particularly if
statements) are handled.

	if C: x else: y

as a standalone statement would be an error, because the parser would
think you're starting a statement, not a conditional operator.  If
that's really what you meant, put it in parentheses, or write it as a
true if...else statement.

> I'm skeptical that this is possible, but if you can figure out a way
> to
> do it, that would be fine with me.

Same here.  I'm pretty much ambivalent about the Corner Case; the path
of least resistance is leaving it illegal, which is fine with me.

There's no ambiguity here, there's no changes to existing grammar.  One
new, unambiguous type of expression involving a conditional operator is
added; that is all.

-- 
 Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/
 __ San Jose, CA, USA / 37 20 N 121 53 W / &tSftDotIotE
/  \ There I was / There I was / Splitting atoms with my desire
\__/ Lamya
    Computer science / http://www.alcyone.com/max/reference/compsci/
 A computer science reference.




More information about the Python-list mailing list