PEP 308: some candidate uses cases from live code

Andrew Koenig ark at research.att.com
Sun Feb 9 23:52:11 EST 2003


Tony> With the ?: syntax the rearrangement above becomes:

Tony> sy = d0.year - (d0.month < 7 ? 1 : 0)

I'd prefer

        sy = d0.month < 7? d0.year - 1: d0.year

despite duplicating d0.year because I would rather duplicate
d0.year than subtract 0 from it.  But it's not a strong preference.

Tony> For me, that a killer problem of PEP308's proposed syntax; with the
Tony> condition in the middle,  reading *and* refactoring the code becomes
Tony> harder! That is why I cannot vote simply for PEP308.

Tony> The only syntaxes I'd like to see are:

Tony>    condition "?" then-expr ":" else-expr
 
Tony>    condition "?" then-expr "else" else-expr

Why not

        "if" condition: then-expr "else" ":" else-expr

?

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




More information about the Python-list mailing list