help with str()

Robert M. Emmons RobMEmmons at cs.com
Sun Apr 18 06:38:32 EDT 2004


> 
> No dice. In every case, I get the following error:
> 
> Traceback (most recent call last):
>   File "headhunter.py", line 317, in ?
>     response, poster = n.xhdr("from", 
> first_available_message+"-"+str(last_message))
> TypeError: 'str' object is not callable
> 
> I have tried everything I could think of and there is only one 
> possibility still left that I can think of. My theory is this: by using 
> the int() function, I am typing the numbers in the last_message 
> assignment to type integer, and str() is expecting type float, or 
> something.

str() will work on ints.  str() will even work on classes if you have 
the right special method handler defined.

You might want to verify that displaying the value of "str" gives you 
something like <built-in fucntion str>.  You can do this by using "print 
str".  Might be fun to try also "print str(str)" and print "repr(str)". 
  You should get the same thing for these others.

Why I say that is that it is possible to assign something in your code 
to str then it's no-longer associated with the built-in function you 
want, then it might not be callable.  You could have done this in your 
function, or in the global scope for example.

Rob

Rob



More information about the Python-list mailing list