How can I tell when a string is in fact a number?
Fredrik Lundh
fredrik at effbot.org
Mon Nov 6 03:19:08 EST 2000
Joshua wrote:
> Why use re at all?
maybe because it's designed for this very purpose, and
is faster than any other solution?
> def isanum(str):
> import string
> return reduce(lambda x, y: x and y in string.digits, str, str != "")
...while map/filter/reduce on lambda expressions are
known to be slow.
> why-does-everyone-always-try-to-present-a-solution-to-
> something-other-than-the-original-problem'ly yrs,
really? I probably have a really lousy newsfeed, because
I couldn't find a single off-topic reply...
</F>
More information about the Python-list
mailing list