----- Original Message -----
> From: Noah Hall <enali...@gmail.com>
> To: MrPink <tdsimp...@gmail.com>
> Cc: python-list@python.org
> Sent: Tuesday, October 18, 2011 4:44 AM
> Subject: Re: How to test if object is an integer?

> There's the isdigit method, for example -
> 
>>>>  str = "1324325"
>>>>  str.isdigit()
> True
>>>>  str = "1232.34"
>>>>  str.isdigit()
> False
>>>>  str = "I am a string, not an int!"
>>>>  str.isdigit()
> False
>

There are some corner cases to be considered with this approach:
1. negative integers: '-3'
2. strings starting with '0': '03'
3. strings starting with one '+': '+3'
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to