1-line idiom to replace if blocks

Terry Reedy tjreedy at udel.edu
Tue Jan 21 13:54:03 CET 2003


"Jonathan P." <jbperez808 at yahoo.com> wrote in message
news:3e2cf624 at post.usenet.com...
> **** Post for FREE via your newsreader at post.usenet.com ****
>
> I hate code that takes up too many lines and
> have come up with the ff. idiom to replace
> many 4 line if statements:
>
> result=[value-if-false,value-if-true][condition]
>
> This idea could also be applied as a compact
> switch block replacement in certain cases.

If you google the newsgroup for 'conditional expression' you can find
dozens of posts on this topic, including several by me.
Terry J. Reedy

http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&group=comp.lang.pyt
hon






More information about the Python-list mailing list