3 ms·
Well, it's not really Python's behaviour, just the behaviour of that type. You can always use your own type: class I(int): def __nonzero__(self): r
by icebraining 13y ago
Well, it's not really Python's behaviour, just the behaviour of that type. You can always use your own type:
class I(int):
def __nonzero__(self):
return True
def is_digit_char(s):
try:
return I(s)
except (ValueError, TypeError):
return None
>>> if is_digit_char('0'): print "True"
True