pre-check for string-to-number conversion

18k11tm001 at sneakemail.com 18k11tm001 at sneakemail.com
Fri Feb 11 18:14:52 EST 2005


I am reading an ASCII data file and converting some of the strings to
integers or floats. However, some of the data is corrupted and the
conversion doesn't work. I know that I can us exceptions, but they
don't seem like the cleanest and simplest solution to me. I would like
to simply perform a pre-check before I do the conversion, but I can't
figure out how to do it. I see that strings have a function called
isdigit(), but that simply checks whether all characters in the string
are digits -- not what I need. Any suggestions? Thanks.




More information about the Python-list mailing list