Is there a shorter form for something like:
if v or v == 0:
v can be None or an int. If it is not None or 0, go in.
What about:
if v is not None:
# code
To test it:
l = [None, 0, 13, -123]
for i in l:
if i is not None:
print i
Ouput:
0
13
-123
None and 0 all represent false, other int except zero are represent true. If you just don't want false,you can use:
if not v:
pass
if not v is when it is false - the opposite of If you just don't want false
if v? (but your code example contradicts your explanation somewhat...)v = None.