i will be comparing two values like this:\
value1>value2
i know that value2 is always an integer, but sometimes value1 is None or a string, how do force the comparison ONLY if value1 is numerical?
value1 is a decimal
i will be comparing two values like this:\
value1>value2
i know that value2 is always an integer, but sometimes value1 is None or a string, how do force the comparison ONLY if value1 is numerical?
value1 is a decimal
try:
value1 > value2
except TypeError:
pass
if isinstance( value2, int ):
value1 > value2
This latter is unpythonic, because this type of comparison is unpythonic. You should filter your data first.