Best way to check if string is an integer?
martin at marcher.name
Tue Apr 8 22:33:17 CEST 2008
arg, as posted earlier:
int("10.0") fails, it will of course work with float("1E+1") sorry for
On Tue, Apr 8, 2008 at 10:32 PM, Martin Marcher <martin at marcher.name> wrote:
> int() does miss some stuff:
> >>> 1E+1
> >>> int("1E+1")
> 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?
> You are not free to read this message,
> by doing so, you have violated my licence
> and are required to urinate publicly. Thank you.
You are not free to read this message,
by doing so, you have violated my licence
and are required to urinate publicly. Thank you.
More information about the Python-list