[Tutor] Symbol re question

lonetwin lonetwin@yahoo.com
Wed, 19 Sep 2001 11:26:14 +0530


Hi Rob,

> Alright, this should be easy and it's being a pain... I just want to find
> out if my string is all numbers.
>
> So I run...
> if ((re.match("[0-9]+", mystring)) != None):
> <...snip...>
> to.  What'm I overlooking?
>
> -Rob

 How about :
================================================================
Python 2.0 (#1, Apr 11 2001, 19:18:08) 
[GCC 2.96 20000731 (Linux-Mandrake 8.0 2.96-0.48mdk)] on linux-i386
Type "copyright", "credits" or "license" for more information.
>>> import string
>>> for c in '43':
...     if c not in string.digits:
...             print 'fail'
...     else:
...             print 'pass'
... 
pass
pass
================================================================

I had done this once....just a thought,

-- 
Peace
Steve