one liner if none else python code example
Example 1: python if not none in one line
v = get_value()
x = v if v is not None
Example 2: python if not none in one line
#if X is None, do nothing
>>> x = ''
>>> x if x and x>0 else None
#if x is not None, print it
>>> x = 1
>>> x if x and x>0 else None
1