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

Andrew Koenig ark at research.att.com
Mon Feb 10 00:39:08 EST 2003


holger> this makes the parsing process ambigous because an expression
holger> can also be a statement. With

holger>     if y<5: "Yep"    ...

holger> the parser would still have no idea at "Yep" what 
holger> it is dealing with.  And i'd probably think that

holger>     if if y<5: yep() else: 0:

holger> is the result of some editor-accident :-)

Part of the suggestion is that when "if" is the first token of
a statement, the statement is an if-statement.

So when the parser sees a statement that begins with

            if y<5: "Yep" ...

it knows that "Yep" must be the first token of a suite.

-- 
Andrew Koenig, ark at research.att.com, http://www.research.att.com/info/ark




More information about the Python-list mailing list