PEP 308: I liked the original proposal better

Andrew Bennetts andrew-pythonlist at puzzling.org
Fri Feb 14 20:49:39 EST 2003


On Fri, Feb 14, 2003 at 08:53:22AM -0500, Mel Wilson wrote:
> In article <mailman.1045199224.19020.python-list at python.org>,
> Andrew Bennetts <andrew-pythonlist at puzzling.org> wrote:
> >On Fri, Feb 14, 2003 at 12:56:39PM +0800, Simon Wittber (Maptek) wrote:
> >>
> >> Greg Ewing wrote:
> >>
> >> >I'd like to put in a plea for re-instatement of the original proposal
> >> >
> >> >    x if C else y
> >> >
> >> >which I found to be particularly elegant.
> >>
> >> I have to agree. From my point of view this is the most pythonic
> >> solution.
> >>
> >> Yes, the test is in the middle of the expression. The argument "This is
> >> not the way other languages do ternary expressions" is not a valid
> >> argument against its use. Python is about about doing things the Right
> >> Way, not the common accepted way.
> >
> >Sure, but the Python I know also tends to be about doing things the
> >Left-to-Right way ;)
> 
> How do you program Python without assignment statements?

I still consider that to be left-to-right.  I can read
    x = 4
or even 
    x = quux(foo().bar() + baz())
from left-to-right, without having to stop in the middle and go "oh, there's
an 'if', back-track and re-read".

I realise this is a rather fuzzy notion of left-to-right.  The real point I
was trying to make was that
    x if C else y
is just inside-out to me.  Not merely backwards, but inside-out.  I don't
like it, and I certainly don't believe that it is the Right Way.

In every other respect, that proposal is simple and clean, but I just can't
get over the out-of-order thing.  It's probably the best proposal that I've
seen, but I will vote against it.

-Andrew.






More information about the Python-list mailing list