On 20/12/05, Suresh Jeevanandam <[EMAIL PROTECTED]> wrote:
Hi,
        I have a string like,
        s1 = '12e3'
        s2 = 'junk'

        Now before converting these values to float, I want to check if they
are valid numbers.

        s1.isdigit returns False.

        Is there any other function which would return True for s1 and False
for s2.

float()  itself can do the checking for you. 
 
>>> for n in ['12e3','junk']:
...     try:
...         float(n)
...     except:
...         print "not valid: ",  n
...        
12000.0
not valid: junk
>>>
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to