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

Joshua Muskovitz josh at open.com
Tue Nov 7 16:37:21 EST 2000


> are quite readable if one understands even the basics of RE -- any
> old-time user of VI, for example (but most good/powerful editors

Heh, I guess I hide my age well -- I was using vi (for DOS!) back when
Windows 1.0 was just coming out and ethernet via coax was exciting!  :-)
And back then, sed and grep were my friends.  I just don't get as much
mileage out of them any more.

> OTOH, lambda and reduce (there was no use of filter in the solution
> you had posted) are somewhat more mysterious to many users - even

Fair enough -- I just haven't gotten around to needing re yet for anything
I'm working on, so it's syntax is still a bit unfamiliar...  :-)

> Btw, I don't think there _was_ any presented solution using
> filter, though it IS in fact a pretty natural approach...:
>
> def isanum(str):
>     return not filter(lambda x: not x in string.digits, str)

Cool!  And I meant to say "reduce" not "filter".  I always confuse these for
some reason.

-- j




-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----==  Over 80,000 Newsgroups - 16 Different Servers! =-----



More information about the Python-list mailing list