TypeError: 'module object is not callable'

Wildemar Wildenburger lasses_weil at klapptsowieso.net
Mon Sep 3 07:34:36 EDT 2007


christophertidy at hotmail.com wrote:
> Thank you for your help that seems to have done the trick.
> You are correct Diez B. Roggisch that I come from a java background!
> 
> I have a new tiny problem I can't understand either.
> Withing Step.py I have the following method
> 
> def isCompleted(self):
>     "Check whether data step has been processed"
>     return self.isCompleted
> 
Java, ey? ;)

Why do you write a method that jut returns a variable anyway? Forget 
that. Python doesn't need getters and setters.



> Then within main.py I simply wish to print the value of isCompleted
> which I try to do by the following
> print 'Magn completed status is',a.isCompleted()
> 
> Which returns the following error:
>     a.isCompleted()
> TypeError: 'int' object is not callable
> 
That is (I think) because you have two things called "isCompleted" in 
your class: The variable of type int (which BTW had better been of type 
bool) and the method.
As I said, just scrap the method. In Python it's perfectly OK to expose 
variables in the API. If you still want getters and setters, use look 
into properties.

/W



More information about the Python-list mailing list