FW: [Python-Dev] conditional expressions?

Paul Moore gustav at morpheus.demon.co.uk
Tue Oct 16 18:00:49 EDT 2001


On Tue, 16 Oct 2001 13:29:09 -0400, "Steve Holden" <sholden at holdenweb.com>
wrote:

>I particularly shudder for the newbie who must read something like the
>following (untested code warning: I'm not building an interpreter that can
>handle this stuff, because I'm hoping it will disappear <0.75 wink>):
>
>l = if a then [i for i in l1 if i % 2] else [i for i in l2 if not i % 2]
>
>Of course, this might also be cast as:
>
>l = [i for i in (if a then l1 else l2) if (if a then i % 2 else not i % 2)]

I shudder at the thought of having to maintain code written by anyone who thinks
that this sort of construct is reasonable. Whether or not it's in the language.
Someone psychotic enough to consider writing this sort of thing is presumably
already having a field day with lambda. Heck, someone could do serious damage to
maintainability with nothing more than the basic operators and some precedence
rules...

you-can-abuse-anything-if-you-try-hard-enough-ly y'rs
Paul.



More information about the Python-list mailing list