PEP 308 - ternary operator
Erik Max Francis
max at alcyone.com
Sun Feb 16 17:40:40 CET 2003
Wolfgang Strobl wrote:
> I'm not quite shure whether this is old news or not, but I haven't
> the following mentioned here.
> Jason Orendorffs entry, a tiny version of "Collossal Cave",
> http://www0.us.ioccc.org/2001/jason.c resp http://www.ioccc.org/
> got a "best of show" award in the latest International Obfuscated C
> Code Contest. IMHO, a great part of its obfuscation is owed to Cs
> ternary operator. For example, the state machine that runs the game is
> a single loop evaluating a single expression composed of a rats nest
> thirty six ?: and thirty six logical ors - without a single bracket!
So? Do you really think people would write such things in production
Any structure _can_ be used to obfuscate. If it is, it's not the fault
of the structure, it's the fault of the programmer (or benefit, if
they're making an entry into an IOXCC contest).
This is hardly a compelling argument against the conditional operator
being added to Python, even if takes the same form as in C; not only is
this is perhaps the greatest abuse of C's conditional operator ever
created, but it's been done _deliberately_. The fact that such things
_can_ be written as entries into a contest where the purpose is to write
as obnoxious code as possible is hardly evidence that they will in real
Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/
__ San Jose, CA, USA / 37 20 N 121 53 W / &tSftDotIotE
/ \ There are countless planets, like many island Earths ...
\__/ Konstantin Tsiolkovsky
Maths reference / http://www.alcyone.com/max/reference/maths/
A mathematics reference.
More information about the Python-list