Date Tags python

This trick is neat and potentially useful although maybe not very Pythonic:

txt = "two"
val = (
        1 if txt == "one" else
        2 if txt == "two" else
        3 if txt == "three" else
        0)
print val

The following form can be used instead:

txt = "three"
val = \
        1 if txt == "one" else \
        2 if txt == "two" else \
        3 if txt == "three" else \
        0
print val

Hi, I am Jeff Rimko!
A computer engineer and software developer in the greater Pittsburgh, Pennsylvania area.