News for hackers. Stuff that matters.
Re:Lisp after Python after Lisp by vang3lis on Wednesday March 11, 2009 @04:57PM (#512607)
on python - not anymore, since 2.5 (probably earlier) you can do:

(x if cond else y) which is essentially (cond ? x : y)

Re:Lisp after Python after Lisp by jimbokun on Wednesday March 11, 2009 @05:02PM (#512621)
Definite improvement! Thanks for the information.
Re:Lisp after Python after Lisp by jcausey on Wednesday March 11, 2009 @05:20PM (#512648)
The previous ternary hack in Python (which was still relatively elegant) was:

a = ("False", "True")[condition]

It's a little fugly -- but if you know the basic semantics of Python, it's quite readable. It is nice that we have a proper ternary now, though.

Re:Lisp after Python after Lisp by EliAndrewC on Wednesday March 11, 2009 @05:26PM (#512653)
Actually I think the more common hack was

    a = cond and x or y
which had the downside that if the second part (in this case x) evaluates to False then a ends up equal to y even through that's not what you were trying to do. Sometimes this is a problem and sometimes not, but it's been irrelevant for the past few years.
Re:Lisp after Python after Lisp by jcausey on Wednesday March 11, 2009 @05:46PM (#512682)
Very true. I've seen that hack before, but I guess I mentally settled on my first example (probably due to the irksome possibility of x=0\False).

Unfortunately, there were probably more hacks than our two examples. Thank goodness Guido (etc) settled on a real ternary semantic -- we were heading into Perl more-than-9000-ways-to-do-something territory!