string.digits, string.letters? How?

gang li gangli at msn.com
Wed Oct 17 18:34:51 EDT 2001


Paul Lim <paullim at starhub.net.sg> wrote in message news:<3BCDCC6F.16954B08 at starhub.net.sg>...
> Hi again to all,
> 
> I am a newbie in Python and please really pardon me for my trivial
> question.
> 
> How can we use the digits, letters variable in the string modules?
> 
> I have the following snippet of my code
> 
> # Import library modules
> # ======================
> 
> import sys
> from string import lower, find, atoi, digits, letters
> 
> if digits(sys.argv[i+1]):
>    print "Invalid argument"
> 
> but i get the error message
>   File "test.py", line 32, in ?
>     if digits(sys.argv[i+1]):
> TypeError: object is not callable: '0123456789'
> 
> What is wrong?
> 
> Thank you very much.
> 
> Sincerely
> Paul

try:
   long(sys.argv[i+1])
   print "Invalid argument"
except ValueError:
   pass



More information about the Python-list mailing list