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

Andrew Dalke adalke at mindspring.com
Fri Feb 7 21:58:10 EST 2003


David Eppstein:
> I on the other hand think the order is one of the better parts of the
> proposal.  Just because it's not the same as C, doesn't make it bad...
> Try thinking about it, playing with it, before reacting so quickly.

I elsewhere (but towards the end of a longish post) pointed out
that I will frequently write

x = None
if s.find("spam") > -1:
    x = "spammity spam!"

The quick rewrite of this to the ...if..else.. expression is

x = None if s.find("spam") > -1 "spammity spam!"

which is wrong and gets things exactly backwards.

I believe a few people will get it wrong because of this,
either translating to or from a if/else statement.

                    Andrew
                    dalke at dalkescientific.com







More information about the Python-list mailing list