Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > generator expressions and new ternary operator

Reply
Thread Tools

generator expressions and new ternary operator

 
 
zipher
Guest
Posts: n/a
 
      09-13-2004
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
 
Reply With Quote
 
 
 
 
Steven Bethard
Guest
Posts: n/a
 
      09-13-2004
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

 
Reply With Quote
 
 
 
 
Gerrit
Guest
Posts: n/a
 
      09-13-2004
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/
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
ternary operator and ostreams Roger Leigh C++ 6 01-19-2004 07:02 PM
union, ternary operator, and C. What a mess! Paul E Johnson C Programming 3 10-17-2003 03:44 AM
Re: anything new on the ternary operator? Bob Gailer Python 16 07-08-2003 10:50 PM
anything new on the ternary operator? Tor Python 3 07-08-2003 10:46 PM
Re: anything new on the ternary operator? John Hunter Python 1 07-07-2003 05:31 PM



Advertisments