toddrjen at gmail.com
Thu Sep 24 20:21:14 CEST 2015
On Sep 24, 2015 18:59, "Chris Angelico" <rosuav at gmail.com> wrote:
> On Fri, Sep 25, 2015 at 2:54 AM, Todd <toddrjen at gmail.com> wrote:
> > Using list indexing with booleans in place of a ternary operator.
> > a = False
> > b = [var2, var1][a]
> > Instead of:
> > b = var1 if a else var2
> Be careful - these are not semantically identical. The first one
> evaluates both var1 and var2, while the second will evaluate only the
> one it needs. This might be significant if they're not simple names.
True, but the code I saw doing this was just choosing between simple float
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-list