[Tutor] Callable? Whats callable?

Lloyd Hugh Allen lha2@columbia.edu
Sun, 26 Aug 2001 11:41:31 -0400


"epoch7" on Sun, 26 Aug 2001 11:24:16 wrote:
> I'm new to programming, python, and even this list! So hopefullt someone =
> could give me a hand with my first program.
> 
>....
>(program)
> y =3D """%s""" (x)
>(more program)
>....
>
> here's the error i get:=20
> Traceback (most recent call last):
>   File "F:\Python21\reusage.py", line 10, in ?
>     y =3D """%s""" (x)
> TypeError: object of type 'string' is not callable

If you want %s to have the value of x formatted as a string, use

y = """%s""" %x

or 

y = """%s""" %(x)

Since this string fits on one line, feel free to use single " or '
instead of triple.

If you want to reference the xth character of a string, then you use
square brackets (that's not what it looks that you're trying to call
"""%s""" as a function, which you can't do, because it's not a function.

Please, please, please do not post as html. It junks up the messages
with garbage characters for we folks who read the list in digest form
(as well as possible some of those *nix folk).

Thanks, good luck.

-LHA