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.
Written by maligree
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Python
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#