isFloat: Without Exception-Handling

Chad Netzer cnetzer at
Sat Oct 5 03:05:19 CEST 2002

On Friday 04 October 2002 17:59, I wrote:

> This works better, but does extra work:

Duh, Chad!  Just change "and" to "or":

def isFloat(s):
    try: return float(s) or True
    except (ValueError, TypeError), e: return False


Chad Netzer
cnetzer at

More information about the Python-list mailing list