----- 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
- How to test if object is an integer? MrPink
- Re: How to test if object is an integer? Chris Angelico
- Re: How to test if object is an integer? Mathias Lafeldt
- Re: How to test if object is an integer? Noah Hall
- Re: How to test if object is an integer? Ian Kelly
- Re: How to test if object is an integer? Yingjie Lan
- Re: How to test if object is an integer? Roy Smith
- Re: How to test if object is an integer? Chris Kaynor
- Re: How to test if object is an integer? Ian Kelly
- Re: How to test if object is an integer? Steven D'Aprano
- Re: How to test if object is an integer? 惜悯
- Re: How to test if object is an integer? Chris Angelico
- Re: How to test if object is an integer? Chris Rebert
- Re: How to test if object is an integer? Terry Reedy
- Re: How to test if object is an integer? Ben Finney
- Re: How to test if object is an integer? Terry Reedy