[Info] PEP 308 accepted - new conditional expressions

Antoon Pardon apardon at forel.vub.ac.be
Tue Oct 11 03:36:41 EDT 2005


Op 2005-10-10, Terry Hancock schreef <hancock at anansispaceworks.com>:
> On Sunday 09 October 2005 07:50 am, phil hunt wrote:
>> On Fri, 7 Oct 2005 01:05:12 -0500, Terry Hancock <hancock at anansispaceworks.com> wrote:
>> >GvR's syntax has the advantage of making grammatical sense in English (i.e.
>> >reading it as written pretty much makes sense).
>> 
>> I know, let's re-write Python to make it more like COBOL! That's 
>> bound to be a winner!
>
> Whereas the "natural order" of "condition affirmative negative" is natural
> for what reason?  That it is so in C?
>
> I don't find that so compelling either, frankly.  Why should it really
> matter in the end?  I've always found C's order (and punctuation) confusing,
> I have to look it up practically everytime I use it or have to read it 
> (which correlates to it being used very rarely, with causality in both
> directions).
>
> Given that situation, choosing a form which is easy to read is surely
> an advantage, and, since it is the way that Python has handled logic
> in the past, it makes sense to continue doing so.

Personnaly I would think some consistency between conditional
expressions and conditional statements would have been a good
thing. I haven't seen a discussion where the following kind of
if statement was discussed.

do:
  return a[0]
if a[0] < a[1] else:
  return a[1[

> No doubt, ANY choice of ternary operator for Python will be
> criticized, and no doubt, ANY choice would nevertheless be
> usable.

Agreed, I think having it is more important than what form
it comes in. My preference has more to do with consistency
with the statement.

> OTOH, I think this choice is consistent with the rest of Python's
> design. The general choice to use keyword operators for LOGIC
> and symbolic operators for MATH is retained, and so long as we're
> describing the logic in words, it makes sense for the wording
> to sound natural.
>
> Consistency certainly does make it easier for me to remember.

I think that a consistency within the language would have
made more sense than consistency with someone's mother
tongue. When I program I program in python or some other
programming language. Not in english, dutch, french or
some other natural language.

But for me this is just style talk. I don't care that much
for style, I'm more concerned with functionality and I'm
glad this functionality will become available.

-- 
Antoon Pardon



More information about the Python-list mailing list