python one line variable assignment if value null code example
Example 1: 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
Example 2: python if not none in one line
v = get_value()
x = v if v is not None