How can I tell when a string is in fact a number?

Dale Strickland-Clark dale at out-think.NOSPAMco.uk
Mon Nov 6 09:55:36 EST 2000


Thomas Gagne <tgagne at ix.netcom.com> wrote:

>Wouldn't it make better sense to return a boolean?  Is it possible to modify
>the String class to include a method, isNumber, that returns true or false?

1 and 0 are Python's boolean values.

>>> 1==1
1
>>> 1==0
0
>>> not 1
0
>>> not 0
1
>>> 
--
Dale Strickland-Clark
Out-Think Ltd
Business Technology Consultants





More information about the Python-list mailing list