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

Andrew Koenig ark at research.att.com
Sat Feb 8 19:37:50 CET 2003


AD> David Eppstein pointed out one, with

AD>    if i < 0:
AD>     col = None
AD>   else:
AD>     col = cols[i]

AD> which is nicely expressed as

AD>   col = cols[i] if i < 0 else None

Except that you flipped the conditions -- I think you meant to write

        col = None if i < 0 else cols[i]

or, probably better:

        col = cols[i] if i >= 0 else None

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




More information about the Python-list mailing list