PEP 308: A PEP Writer's Experience - PRO

holger krekel pyth at devel.trillke.net
Sun Feb 9 18:29:22 EST 2003


Roy Smith wrote:
> b_mcerlean at yahoo.com (Brian McErlean) wrote:
> > >    x > y and x or y
> > 
> > Yes, but this is really a strawman.  To be fair, you should argue
> > against the "right" way of doing this, which (other than the trivial
> > max() for this example) is:
> > 
> > if x > y:
> >     result = x
> > else:
> >     result = y
> 
> I'm probably going to hate myself in the morning, but I'm forced to 
> admit that, in some ways, the long-winded way (which I've been 
> advocating) is inferior.

sure, but it really serves the purpose trying to find better
examples than how to spell 

    result = max(x,y)

<wink>.  Andrew Dalke for example analyzed 15 examples from
C-code where actually 11 could be written much nicer in Python
than with a ternary op and the other 4 weren't that clear. 

regards,

    holger





More information about the Python-list mailing list