Holy crap, a year and no update. In an attempt to get things going again, here's a simple post of something I keep looking up online.
Python has no ternary operator (?: in C++)
Instead, use an and-or construction:
In : True and 'a' or 'b'
In : False and 'a' or 'b'
Replace True and False with the condition:
In : (1==1) and 'a' or 'b'
In : (1==0) and 'a' or 'b'
One failure of this method is then 'a' or 'b' can evaluate as boolean values. Examples of this behavior:
In : True and True or False
In : True and False or True
In : True and 1 or 0
In : True and 0 or 1
In : True and 'a' or ''
In : True and '' or 'a'
So you see that if the first return value evaluates as false, the second value is returned. I'll post a solution or workaround later, when I find one.