Why TypeError: 'str' object is not callable?
Kent Johnson
kent at kentsjohnson.com
Wed Mar 22 15:34:32 EST 2006
Carl J. Van Arsdall wrote:
> Randall Parker wrote:
>>
>>Getting:
>>TypeError: 'str' object is not callable
>>
>>on this line:
>>
>>
>
> You have a boo boo
>
>
>>TmpErrMsg1 = "State machine %s " (StateMachineName)
>>
>
> Should be
>
> TmpErrMsg1 = "State machine %s " %(StateMachineName)
And the reason for the error message is, when you write
a(b)
Python interprets this as, call the object a, passing the parameter b.
If a is a string - a 'str' object - Python attempts to call the string.
Strings are not callable so you get the error message you see.
Kent
More information about the Python-list
mailing list