How can I tell when a string is in fact a number?
Joshua Muskovitz
josh at open.com
Mon Nov 6 14:44:11 EST 2000
More information about the Python-list mailing list
Mon Nov 6 14:44:11 EST 2000
- Previous message (by thread): How can I tell when a string is in fact a number?
- Next message (by thread): How can I tell when a string is in fact a number?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
> Here's another whimsical solution (to the digits-only problem), > with _peculiar_ failings... > > def isanum(str): > l=list(str) > l.sort() > return l[0]>='0' and l[-1]<='9' > > Apart from little defects such as being O(N log N), and breaking > for the empty-string, I wonder if there's any Python implementation > where this will really fall apart (EBCDIC...?). I believe that even in EBCDIC, digits form a contiguous part of the encoding space. And thanks for pointing out that the question and the reference implementation were inconsistent. I think I've had too many years of this sort of work -- I only look at the reference implementation! :-) -- josh -----= 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! =-----
- Previous message (by thread): How can I tell when a string is in fact a number?
- Next message (by thread): How can I tell when a string is in fact a number?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list