(test) ? a:b
alister.nospam.ware at ntlworld.com
Fri Oct 24 22:58:13 CEST 2014
On Fri, 24 Oct 2014 10:20:30 -0700, Dan Stromberg wrote:
> On Fri, Oct 24, 2014 at 1:38 AM, Steven D'Aprano
> <steve+comp.lang.python at pearwood.info> wrote:
>> I don't get why that's considered hard to read.
>> So why is it hard to read when the index is a flag?
>> value = [f, g][cond]()
> It's clear to you, it's clear to me, but is it clear to everyone? I
> very much doubt it.
I had to mentally step through this before it became apparent what it was
doing, can see places where it could be usefull (a switch replacement)
but it is not instantly obvious
a = <value> if <condition> else <another Value>
is instantly obvious (at least to a native English speaker anyway)
> Also, you've gone to the trouble of def'ing two functions here - you may
> as well do a function for the if/else.
"Humor is a drug which it's the fashion to abuse."
-- William Gilbert
More information about the Python-list