Python - Check if a string is convertible to an integer

To check if a string is convertible to an integer, use this following built-in function:

mystring.isdigit()

=> True: mystring can be converted to an integer.
=> False: mystring cannot be converted to an integer.

Reference: http://stackoverflow.com/questions/5606585/python-test-if-value-can-be-converted-to-an-int-in-a-list-comprehension

Comments