isnumeric (mhlib.py)

Richard van de Stadt stadt at cs.utwente.nl
Thu Jan 4 09:39:38 EST 2001


Hi,

I needed a function to check if a string is a number.
mhlib contains a function called isnumeric(), so I
used that one. This is how it determines if a string
is a number:

numericprog = re.compile('^[1-9][0-9]*$')
def isnumeric(str):
    return numericprog.match(str) is not None

However, this way, '0' is not regarded as a number.
Is that what isnumeric is supposed to do?

I don't know what the meaning of isnumeric for mh is,
but why isn't numericprog simply like this:

numericprog = re.compile('^[0-9]*$')

Richard.



More information about the Python-list mailing list