Using regular expressions (because you asked):
>>> import re
>>> if re.match('\d+', temp[0]): print "it a number!"
Otherwise, try to parse as int and catch the exception:
>>> int(temp[0])
Of course, all this gets a little more complicated if you want floats, negatives, scientific notation, etc. I will leave this as an exercise for the seeker :)
source
share