comprehensions was Re: Switch statements again

John Roth johnroth at ameritech.net
Sun Jan 19 12:30:06 EST 2003


"Beni Cherniavsky" <cben at techunix.technion.ac.il> wrote in message
news:Pine.GSO.4.44_heb2.09.0301191441590.20859-100000 at techunix.technion.
ac.il...
> On 2003-01-17, Tim Peters wrote:
>
>
> > but then I never expected anyone to do
> >
> >   (f() and [g()] or [h()])[0]
> >
> > in real life either <0.5 wink>.
> >
> That should be written ``f() and g() else h()`` <wink>.

Actually not. Tim, as usual, has it right. The way
you wrote it fails if g() evaluates to a false value.
That's been the standard problem with this construct.

The way Tim has it, [g()] cannot evaluate to
a false value. It's always a 1 element list which
by definition is true.

John Roth
>
> lets-add-x,y-for-x-in-possible-syntaxes-for-y-in-possible-uses ly
y'rs,
>     Beni Cherniavsky <cben at tx.technion.ac.il>
>






More information about the Python-list mailing list