generator expressions and new ternary operator

Discussion in 'Python' started by zipher, Sep 13, 2004.

  1. zipher

    zipher Guest

    It seems the debate over PEP 308 (if-then-else expression) occurred
    prior to the arrival of generator expressions.

    Mightn't this new latter syntax be the ticket to a "one obvious way"
    to write a ternary expression in python?

    >>> (foo(i) if i==42 else bar(i)) # i==42 ? foo(i) : bar(i)


    zipher
     
    zipher, Sep 13, 2004
    #1
    1. Advertising

  2. zipher <zondervanz <at> gmail.com> writes:
    >
    > Mightn't this new latter syntax be the ticket to a "one obvious way"
    > to write a ternary expression in python?
    >
    > >>> (foo(i) if i==42 else bar(i)) # i==42 ? foo(i) : bar(i)

    >


    I really shouldn't respond to this because the debate over a ternary operator
    already went on *way* too long... But this proposal completely confuses me...

    Why would we want something that isn't a generator expression to look anything
    like one?

    Steve
     
    Steven Bethard, Sep 13, 2004
    #2
    1. Advertising

  3. zipher

    Gerrit Guest

    zipher wrote:
    > It seems the debate over PEP 308 (if-then-else expression) occurred
    > prior to the arrival of generator expressions.
    >
    > Mightn't this new latter syntax be the ticket to a "one obvious way"
    > to write a ternary expression in python?
    >
    > >>> (foo(i) if i==42 else bar(i)) # i==42 ? foo(i) : bar(i)


    No. This has been suggested, and been rejected. And since generator
    expressions have nothing to do with ternary expressions, it is not a
    reason to re-do the discussion. There are literally thousands of
    messages in the archives, including sub-threads discussing exactly this
    syntax. By the time you've (re-)read them all, we'll be way beyond
    Python 3.0 ;-)

    yours,
    Gerrit.

    --
    Weather in Twenthe, Netherlands 13/09 08:25:
    14.0°C Broken clouds mostly cloudy wind 4.5 m/s S (57 m above NAP)
    --
    Gerrit Holl - 2nd year student of Applied Physics, Twente University, NL.
    Experiences with Asperger's Syndrome:
    EN http://topjaklont.student.utwente.nl/english/
    NL http://topjaklont.student.utwente.nl/
     
    Gerrit, Sep 13, 2004
    #3
    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. Roger Leigh

    ternary operator and ostreams

    Roger Leigh, Jan 16, 2004, in forum: C++
    Replies:
    6
    Views:
    686
    Roger Leigh
    Jan 19, 2004
  2. Paul E Johnson

    union, ternary operator, and C. What a mess!

    Paul E Johnson, Oct 17, 2003, in forum: C Programming
    Replies:
    3
    Views:
    485
    Ed Morton
    Oct 17, 2003
  3. Tor
    Replies:
    3
    Views:
    357
    Erik Max Francis
    Jul 8, 2003
  4. Bob Gailer
    Replies:
    16
    Views:
    604
    Mark Jackson
    Jul 8, 2003
  5. John Hunter
    Replies:
    1
    Views:
    338
    Grant Edwards
    Jul 7, 2003
Loading...

Share This Page