Re: anything new on the ternary operator?

Discussion in 'Python' started by Bob Gailer, Jul 7, 2003.

  1. Bob Gailer

    Bob Gailer Guest

    At 10:59 PM 7/6/2003 +0200, Tor wrote:

    >What's the current status on the ternary operator that may or may not be
    >added to python. Haven't heard much about that since the vote was announced
    >for a couple of months ago. What's the best way to follow that dicussion?
    >Or are we just waiting for the developers to make their decision?


    Last I heard it was killed by Guido, which makes me wonder why we spent so
    much time discussing and voting. If he did not want it I wish he had killed
    it at the start. I thought the vote was to determine the best choice, and I
    was looking forward to having it.

    <grumble>Makes me wonder about the whole PEP process. Why bother! </grumble>

    Bob Gailer

    303 442 2625


    ---
    Outgoing mail is certified Virus Free.
    Checked by AVG anti-virus system (http://www.grisoft.com).
    Version: 6.0.492 / Virus Database: 291 - Release Date: 6/24/2003
    Bob Gailer, Jul 7, 2003
    #1
    1. Advertising

  2. Bob Gailer

    Aahz Guest

    In article <>,
    Bob Gailer <> wrote:
    >At 10:59 PM 7/6/2003 +0200, Tor wrote:
    >>
    >>What's the current status on the ternary operator that may or may not
    >>be added to python. Haven't heard much about that since the vote was
    >>announced for a couple of months ago. What's the best way to follow
    >>that dicussion? Or are we just waiting for the developers to make
    >>their decision?

    >
    >Last I heard it was killed by Guido, which makes me wonder why we spent
    >so much time discussing and voting. If he did not want it I wish he had
    >killed it at the start. I thought the vote was to determine the best
    >choice, and I was looking forward to having it.


    Guido made clear before the vote that only a clear statement from the
    community would drive the addition of the ternary operator. Given that
    the vote did not present a clear result, he did what he said he'd do.
    How's that a prbolem?
    --
    Aahz () <*> http://www.pythoncraft.com/

    "Not everything in life has a clue in front of it...." --JMS
    Aahz, Jul 7, 2003
    #2
    1. Advertising

  3. "Bob Gailer" <> wrote

    > I was looking forward to having it.


    "Sean Ross" <> wrote

    > - (if C: x else: y) won the vote


    I'm still learning python, so don't flame too much :)

    What is superior about using the proposed ternary operator instead of using
    the 'and' and 'or' operators to simulate inline logic?
    Russell Reagan, Jul 7, 2003
    #3
  4. Bob Gailer

    Ben Finney Guest

    On Mon, 07 Jul 2003 02:13:15 GMT, Russell Reagan wrote:
    > What is superior about using the proposed ternary operator instead of
    > using the 'and' and 'or' operators to simulate inline logic?


    The "cond and expr1 or expr2" does not always function as expected for a
    ternary if-then-else operator. The PEP for the ternary operator
    explains:

    "A common way to emulate an if-then-else expression is:

    <condition> and <expression1> or <expression2>

    However, this doesn't work the same way: it returns <expression2>
    when <expression1> is false! See FAQ 4.16 for alternatives that
    work -- however, they are pretty ugly and require much more effort
    to understand."
    <http://www.python.org/peps/pep-0308.html>

    FAQ 4.16 is here:
    <http://www.python.org/cgi-bin/faqw.py?req=show&file=faq04.016.htp>

    --
    \ "I wish I had a dollar for every time I spent a dollar, because |
    `\ then, yahoo!, I'd have all my money back." -- Jack Handey |
    _o__) |
    http://bignose.squidly.org/ 9CFE12B0 791A4267 887F520C B7AC2E51 BD41714B
    Ben Finney, Jul 7, 2003
    #4
  5. Russell Reagan wrote:

    > What is superior about using the proposed ternary operator instead of
    > using
    > the 'and' and 'or' operators to simulate inline logic?


    Because the and/or technique doesn't quite work. Instead of rehashing
    this topic again, I'd recommend you check out the PEP 308 on the
    conditional operator which goes through all the details:

    http://www.python.org/peps/pep-0308.html

    --
    Erik Max Francis && && http://www.alcyone.com/max/
    __ San Jose, CA, USA && 37 20 N 121 53 W && &tSftDotIotE
    / \ She glanced at her watch ... It was 9:23.
    \__/ James Clavell
    Erik Max Francis, Jul 7, 2003
    #5
  6. Bob Gailer

    Peter Hansen Guest

    Bob Gailer wrote:
    >
    > Last I heard it was killed by Guido, which makes me wonder why we spent so
    > much time discussing and voting. If he did not want it I wish he had killed
    > it at the start. I thought the vote was to determine the best choice, and I
    > was looking forward to having it.
    >
    > <grumble>Makes me wonder about the whole PEP process. Why bother! </grumble>


    From the PEP (http://python.org/peps/pep-0308.html) :

    This is the community's one chance: if this PEP is approved with a clear
    majority, it will be implemented in Python 2.4. ... If the community can't
    decide, the BDFL will reject the PEP.

    Also, reading PEP 1 "PEP Purpose and Guidelines", I see nothing in there to
    suggest that the process was not followed, and lots of things that point out
    that the BDFL's ruling is still the only thing that matters, in the end.
    Those dissenting will be required to start their own fork of Python, then
    shot. ;-)

    PEP 1 also answers your question about "why we spent so much time discussing
    and voting"...

    -Peter
    Peter Hansen, Jul 7, 2003
    #6
  7. Bob Gailer

    Andreas Jung Guest

    --On Montag, 7. Juli 2003 2:13 Uhr +0000 Russell Reagan <>
    wrote:

    > "Bob Gailer" <> wrote
    >
    >> I was looking forward to having it.

    >
    > "Sean Ross" <> wrote
    >
    >> - (if C: x else: y) won the vote

    >
    > I'm still learning python, so don't flame too much :)
    >
    > What is superior about using the proposed ternary operator instead of
    > using the 'and' and 'or' operators to simulate inline logic?


    Please stop the discussion. The ternary operator is dead (which is a very
    good thing)
    because GvR made the decision.

    -aj
    Andreas Jung, Jul 7, 2003
    #7
  8. Bob Gailer

    Paul Rudin Guest

    >>>>> "Aahz" == Aahz <> writes:

    > Guido made clear before the vote that only a clear statement
    > from the community would drive the addition of the ternary
    > operator. Given that the vote did not present a clear result,
    > he did what he said he'd do. How's that a prbolem?


    I don't know the details of this process; but personally I think a
    ternary operator would be a very good thing - and don't care about the
    syntax too much. Maybe the right think to vote on was simply a yes/no
    to "Do you want a ternary operator?".

    Maybe the problem is perhaps that disagreement over the competing
    syntactical suggestions obscures the fact that a majority would prefer
    to see some ternary operator rather than none?
    Paul Rudin, Jul 7, 2003
    #8
  9. Bob Gailer

    Moshe Zadka Guest

    On Mon, 07 Jul 2003, Erik Max Francis <> wrote:

    > Bob's phrasing of it was obviously overly confrontational, but I do find
    > it at least a little unfortunate that the final decision on PEP 308 only
    > came indirectly (meaning not as any form of widespread public
    > announcement, but rather as a side point in a presentation at a local
    > conference)


    I'm sorry, I was going to let this slide by, but this comment made it
    impossible. How the hell do you figure EuroPython, the biggest Python
    conference in Europe and largely equivalent to the size of PyCon, is a
    "local" conference?

    By and large, I think EuroPython holds half the heritage of the venerable
    IPCs, being way more international than PyCon. Announcements of new
    developments are often done at conferences, especially the larger ones.
    It has been said multiple times that Guido is likely to make an announcement
    in EuroPython, and it was pretty easy to get the answer out on c.l.py soon
    afterwards. While the PEP will eventually be updated, I am glad Guido thought
    it was a higher priority to get 2.3b2 out the door in the little time he had
    between EP and OSCON.

    > There isn't a problem that PEPs and such voting processes are worthless
    > -- obviously the BDFL has the final say -- but perhaps it would have
    > been a little nicer to get an official position on the subject earlier.


    Guido said that he wanted to let the discussion simmer down before he made
    an official pronouncement. He also *did* consider the vote: if you remember,
    there were a few interpretations. Guido chose the one who enforced
    Condorset(sp?) semantics on the results, an arguably sane position considering
    other free software projects use this voting method. According to this
    interpretation, the vote resulted in "don't change".

    --
    Moshe Zadka -- http://moshez.org/
    Buffy: I don't like you hanging out with someone that... short.
    Riley: Yeah, a lot of young people nowadays are experimenting with shortness.
    Agile Programming Language -- http://www.python.org/
    Moshe Zadka, Jul 7, 2003
    #9
  10. Moshe Zadka <> wrote previously:
    |I'm sorry, I was going to let this slide by, but this comment made it
    |impossible. How the hell do you figure EuroPython, the biggest Python
    |conference in Europe and largely equivalent to the size of PyCon, is a
    |"local" conference?

    Yeah, but Donald Rumsfeld has let us 'merkins know that Old Europe is
    now irrelevant. What could be more clear?

    --
    mertz@ | The specter of free information is haunting the `Net! All the
    gnosis | powers of IP- and crypto-tyranny have entered into an unholy
    ..cx | alliance...ideas have nothing to lose but their chains. Unite
    | against "intellectual property" and anti-privacy regimes!
    -------------------------------------------------------------------------
    Lulu of the Lotus-Eaters, Jul 7, 2003
    #10
  11. Bob Gailer

    Andrew Dalke Guest

    Moshe Zadka:
    > Well, to be quite honest, there were some "New Europe" attendees. The
    > most excellent Lithuanians, and yours truly.


    As well as some of us 'mericans. 6, if I interpreted the stats correctly.

    Andrew
    Andrew Dalke, Jul 7, 2003
    #11
  12. Moshe Zadka wrote:

    > I'm sorry, I was going to let this slide by, but this comment made it
    > impossible. How the hell do you figure EuroPython, the biggest Python
    > conference in Europe and largely equivalent to the size of PyCon, is a
    > "local" conference?


    After I posted that, I figured someone would probably take exception to
    that term in order to stir things up. "Local" was merely meant to mean
    that it is located in a particular area on the planet Earth which it is
    less convenient for certain other people to attend. Yes, of course
    that's true for every possible choice of locations. It was not meant as
    a slight. (And, to trump your next response, yes, I know you do not
    hail from Europe.)

    The point is the decision wasn't announced publicly, in this
    list/newsgroup (which reaches a much wider audience of Python users,
    wouldn't you say?) or on the python.org Web site (which reaches an even
    wider audience); it was mentioned in one presentation in a conference.
    If you didn't attend to the conference, or _did_ attend the conference
    and didn't happen to attend his presentation, you wouldn't have heard
    about it except indirectly, which is precisely what's happening for many
    of us here.

    After all, as I write this, the PEP _still_ has not been updated with
    the decision.

    > Guido said that he wanted to let the discussion simmer down before he
    > made
    > an official pronouncement.


    Sure, but did it really take six months to mull it over?

    --
    Erik Max Francis && && http://www.alcyone.com/max/
    __ San Jose, CA, USA && 37 20 N 121 53 W && &tSftDotIotE
    / \ We're here to preserve democracy, not to practice it.
    \__/ Capt. Frank Rasmey
    Erik Max Francis, Jul 7, 2003
    #12
  13. Erik Max Francis <> writes:

    > There's not much doubt that the conditional operator will not be making
    > it into Python in the future, but just because the BDFL has made a
    > decree (although a significantly delayed one), it's a little naive to
    > think that discussion of it will not continue. This clause was in the
    > PEP ("the subject better not come up again"), but I'm not sure how this
    > clause will really have much effect.


    Slightly astonishingly, this does really seem to work. Consider PEP 666.

    Cheers,
    M.

    --
    If I didn't have my part-time performance art income to help pay
    the bills, I could never afford to support my programming
    lifestyle. -- Jeff Bauer, 21 Apr 2000
    Michael Hudson, Jul 8, 2003
    #13

  14. >> [The consensus in EP was that Israel was in Europe]


    Alia> Sorry, I am confused: isn't Israel in the Middle East?

    Sure, but what continent is the the Middle East in, Europe, Asia or Africa?
    I had to make the same decision in Musi-Cal. I decided that Israel was part
    of Europe. The decision wasn't entirely arbitrary. Most concert dates we
    list for Asia are in Japan, Korea or Hong Kong. There are almost never any
    African concert dates listed. Israel was close enough to Europe that it
    made sense to group it there.

    Skip
    Skip Montanaro, Jul 8, 2003
    #14
  15. Bob Gailer

    Moshe Zadka Guest

    On Tue, 8 Jul 2003, Skip Montanaro <> wrote:

    > Sure, but what continent is the the Middle East in, Europe, Asia or Africa?
    > I had to make the same decision in Musi-Cal. I decided that Israel was part
    > of Europe. The decision wasn't entirely arbitrary. Most concert dates we
    > list for Asia are in Japan, Korea or Hong Kong. There are almost never any
    > African concert dates listed. Israel was close enough to Europe that it
    > made sense to group it there.


    Of course, for a music thingy it makes double the sense -- we're on the
    Eurovision, which may effect concert dates.
    [Of course, some may think grouping the eurovision with music is worse
    than grouping Israel with Europe :)]
    --
    Moshe Zadka -- http://moshez.org/
    Buffy: I don't like you hanging out with someone that... short.
    Riley: Yeah, a lot of young people nowadays are experimenting with shortness.
    Agile Programming Language -- http://www.python.org/
    Moshe Zadka, Jul 8, 2003
    #15
  16. Bob Gailer

    Robin Becker Guest

    In article <>, Fredrik
    Lundh <> writes
    ......
    >if we'd known that you folks would end up this bitter, we would
    >have given you one point ;-)
    >
    ></F>

    ..... even though I helped in recording the awful 'Puppet On A String'
    back in the dark ages, not getting any points is a high point in
    Britain's Eurovision career. With any luck we can consign this awfulness
    to the dustbin of history. Perhaps we can make Guantanamo part of Europe
    and send it there for a quickie death sentence.
    --
    Robin Becker
    Robin Becker, Jul 8, 2003
    #16
  17. Bob Gailer

    Mark Jackson Guest

    Robin Becker <> writes:

    > the Middle East is certainly not in Europe at least according to
    > classical authors, historians & geographers. Asia begins across the
    > Hellespont so asiatic Turkey, Iraq, Syria, Palestine are not in Europe
    > and neither is the Israeli territory. I suspect Israelis would prefer to
    > be in America so that they wouldn't have to take part in the Eurovision
    > song contest.


    I'm sure there must be an opt-out clause for Eurovision contests - I
    certainly don't recall Israeli teams competing in It's a Knockout /
    Jeux Sans Frontieres back in 1977.

    On the other hand as part of America they might have gotten roped into
    Almost Anything Goes.

    --
    Mark Jackson - http://www.alumni.caltech.edu/~mjackson
    It is necessary to be slightly underemployed if you want to
    do something significant. - James D. Watson
    Mark Jackson, Jul 8, 2003
    #17
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jacob

    ternary operator error

    Jacob, Jun 30, 2003, in forum: Java
    Replies:
    12
    Views:
    4,708
    pete kirkham
    Jul 2, 2003
  2. Tor
    Replies:
    3
    Views:
    325
    Erik Max Francis
    Jul 8, 2003
  3. John Hunter
    Replies:
    1
    Views:
    319
    Grant Edwards
    Jul 7, 2003
  4. zipher
    Replies:
    2
    Views:
    347
    Gerrit
    Sep 13, 2004
  5. Replies:
    24
    Views:
    628
    shailendra
    Oct 19, 2005
Loading...

Share This Page