A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2000-January/001884.html below:

[Python-Dev] Adding C ternary select (a?b:c) to Python?

[Python-Dev] Adding C ternary select (a?b:c) to Python?Jim Fulton jim@digicool.com
Sun, 30 Jan 2000 08:52:32 -0500
Guido van Rossum wrote:
> 
> Dear developers,
> 
> Eric Raymond has sent me the following patch, which adds conditional
> expressions to Python.  I'd like to hear opinions on whether this is a
> good thing to add to Python, and whether this is the right syntax.

Yee ha! I think that this is a great idea. 

I'm surprised that using the colon doesn't cause problems.
I'm not a grammer lawyer, and don't care that much. I very 
much would like to see a conditional expression. I wouldn't
object if it was spelled differently than C's.

> I am a bit skeptical about whether this is sufficiently Pythonic, but
> on the other hand there have always been requests for such a feature,
> and the existing solutions are ugly:
> 
>   a and b or c
> 
> only works when you know for sure that b will never be false, and
> 
>   (a and [b] or [c])[0]
> 
> is dead ugly...

Yup.

   (a and (b,) or (c,))[0]

is even worse. ;)

Jim

--
Jim Fulton           mailto:jim@digicool.com
Technical Director   (888) 344-4332              Python Powered!
Digital Creations    http://www.digicool.com     http://www.python.org

Under US Code Title 47, Sec.227(b)(1)(C), Sec.227(a)(2)(B) This email
address may not be added to any commercial mail list with out my
permission.  Violation of my privacy with advertising or SPAM will
result in a suit for a MINIMUM of $500 damages/incident, $1500 for
repeats.



RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4