Best way to check if string is an integer?
steve at holdenweb.com
Tue Apr 8 23:40:31 CEST 2008
Martin Marcher wrote:
> int() does miss some stuff:
> Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
> ValueError: invalid literal for int() with base 10: '1E+1'
> I wonder how you parse this?
> I honestly thought until right now int() would understand that and
> wanted to show that case as ease of use, I was wrong, so how do you
> actually cast this type of input to an integer?
int(float("1E+1")) # untested
Steve Holden +1 571 484 6266 +1 800 494 3119
Holden Web LLC http://www.holdenweb.com/
More information about the Python-list