with positive integers you could use
>>> '16'.isdigit() True
it doesn't work with negative integers though. suppose you could try the following:
>>> s = '-17' >>> s.startswith('-') and s[1:].isdigit() True
it won't work with
'16.0' format, which is similar to
int casting in this sense.
def check_int(s): if s in ('-', '+'): return s[1:].isdigit() return s.isdigit()