check to see if value can be an integer instead of string

nephish at xit.net nephish at xit.net
Tue Jan 17 21:02:52 EST 2006


Hello there,
i need a way to check to see if a certain value can be an integer. I
have looked at is int(), but what is comming out is a string that may
be an integer. i mean, it will be formatted as a string, but i need to
know if it is possible to be expressed as an integer.

like this

var = some var passed to my script
if var can be an integer :
    do this
else:
    change it to an integer and do something else with it.

whats the best way to do this ?

thanks, shawn




More information about the Python-list mailing list