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

Fredrik Lundh fredrik at effbot.org
Mon Nov 6 13:51:45 EST 2000


Julio Flores Schwarzbeck wrote:
>
> def isnum(data): # needs string module to be loaded in
>      for x in range(len(data)):
>          if not (data[x] in tuple(string.digits) or data[x] in '.'):
>              return 0
>      return 1

ouch.

</F>





More information about the Python-list mailing list