string.digits, string.letters? How?
Chris Gonnerman
chris.gonnerman at newcenturycomputers.net
Wed Oct 17 12:52:40 EDT 2001
----- Original Message -----
From: "Paul Lim" <paullim 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?
Your thinking is very muddy. 'digits' is in fact a string variable,
not a callable, so you can't use the (...) form after it (as you
can plainly see).
The variable 'i' isn't set in your code, either, so if digits
were a function (or other callable) you'd still have an error.
Please try telling us what precisely you are trying to do?
> Thank you very much.
You're welcome, for whatever my answer is worth.
More information about the Python-list
mailing list