Last Updated: February 25, 2016
·
372
· maligree

Condition as an index

So apparently this works..

 >>> ['VERSION_1', 'VERSION_2'][ ver == 2 ]
'VERSION_2'

Why? Because:

>>> ['mallory', 'tim'][False]
'mallory'
>>> ['mallory', 'tim'][True]
'tim'

But use only when showing off, maybe.