TypeError: object is not callable

Matthew Dixon Cowles matt at mondoinfo.com
Wed Jun 6 21:00:50 EDT 2001


On 7 Jun 2001 00:43:10 GMT, Gustaf Liljegren <gustafl at algonet.se>
wrote:

>I have done a class which is in placed in a directory within
>sys.path, and the class works as intended when I test it by adding
>some main() code in it. But when I call it from another module I get
>this strange error "TypeError: object is not callable". No way I can
>get the same error in Idle...

>From the docs, it seems that it has something to do with the
>constructor, so here is the constructor:

>class Friend:
>  def __init__(self, id, file):
>    self.id = id
>    self.name = ""
>    self.emails = []
>    self.file = file
>    self.load()

Gustaf,
It's hard to be sure what the problem is without seeing an example
that fails but if the problem in in the constructor, it seems likely
that it's in the last line since that's the only place that you're
trying to call something. If self.load is something other than a
method there, you'll get the error message you mention. You might try
printing self.load (note no parentheses) just before that line.

Regards,
Matt



More information about the Python-list mailing list