Question For Language Lawyers - WAS: Re: Combining colon statements on one line?

Dan Bishop danb_83 at yahoo.com
Tue Jul 20 01:39:04 EDT 2004


"Delaney, Timothy C (Timothy)" <tdelaney at avaya.com> wrote in message news:<mailman.604.1090285226.5135.python-list at python.org>...
> Tim Daneliuk wrote:
> 
> > Phil Frost wrote:
> >> newdate = date + (1000,2000)[ date < 500 ]
> > 
> > OK, this is clever
> 
> I'd disagree that this is clever - I'd say that this is a PITA. In
...
> Even with TDD, it's simple to end up with the values transposed. And if
> you get it right, people still have to think "is this right" every time
> they look at it, because it's the opposite of what they expect.
> 
> The sooner this "cute" trick dies out, the better IMO.

I wish PEP 308 had passed; a ternary operator would be much preferable
to the ugly hacks that get used to emulate the ternary operator.



More information about the Python-list mailing list