I\'ve got an Nonetype value x, it\'s generally a number, but could be None. I want to divide it by a number, but Python raises:
Nonetype
x
None
In some situations it is helpful to have a function to convert None to int zero:
def nz(value): ''' Convert None to int zero else return value. ''' if value == None: return 0 return value