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

Alex Martelli aleaxit at yahoo.com
Tue Nov 7 15:05:55 EST 2000


"Quinn Dunkan" <quinn at spew.ugcs.caltech.edu> wrote in message
news:slrn90gfkp.d3s.quinn at spew.ugcs.caltech.edu...
    [snip]
> Well, people seem to be having a lot of fun with this one, but I'm sort of
> surprised that no one has pointed out my solution-of-choice yet:
>
> s.isdigit() # python 2

Darn -- I hadn't pointed it out for the very simple reason that
I didn't know about it!  It had clearly escaped my attention
when looking through the Python 2 enhancements.  Thanks for
pointing it out, though this spoils all the fun we were having
in rewriting it...!-)


Alex






More information about the Python-list mailing list