473,320 Members | 1,695 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

generator expressions and new ternary operator

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
Jul 18 '05 #1
2 1839
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

Jul 18 '05 #2
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/
Jul 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

72
by: Raymond Hettinger | last post by:
Peter Norvig's creative thinking triggered renewed interest in PEP 289. That led to a number of contributors helping to re-work the pep details into a form that has been well received on the...
23
by: Mike Meyer | last post by:
Ok, we've added list comprehensions to the language, and seen that they were good. We've added generator expressions to the language, and seen that they were good as well. I'm left a bit...
62
by: Reinhold Birkenfeld | last post by:
Hi, after Guido's pronouncement yesterday, in one of the next versions of Python there will be a conditional expression with the following syntax: X if C else Y which is the same as today's...
10
by: nimmi_srivastav | last post by:
Below you will see an example of a nested conditional expression that this colleague of mine loves. He claims that it is more efficient that a multi-level if-else-if structure. Moreover, our...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.