Re: TypeError: 'module object is not callable'
- From: "Diez B. Roggisch" <deets@xxxxxxxxxxxxx>
- Date: Mon, 03 Sep 2007 11:06:41 +0200
christophertidy@xxxxxxxxxxx wrote:
Hi
I am new to Python and have recieved this error message when trying to
instantiate an object from a class from another file within the same
directory and wondered what I have done wrong.
I have a Step.py class:
class Step(object)
def __init__(self, sName):
"Initialise a new Step instance"
self.sName = sName
self.depSteps = []
self.remDepSteps = []
self.isCompleted = 0
Then I have created a new file within the same directory called
main.py:
import Step
a = Step("magn")
The following however generates the error
Traceback (most recent call last):
File "main.py", line 3, in ?
a = Step("magn")
TypeError: 'module' object is not callable
If anyone could help point me in the right direction, how to fix this
problem it would be much appreciated.
Do you by any chance come from a java-background?
Your actual problem is simply solved by this:
import Step
Step.Step("magn")
That's because Step.py is a module, and _not_ the class - there is no
file-class-correspondence as it is in e.g. Java.
Diez
.
- References:
- TypeError: 'module object is not callable'
- From: christophertidy
- TypeError: 'module object is not callable'
- Prev by Date: Re: TypeError: 'module object is not callable'
- Next by Date: Re: Weird gcc errors while installing "MySQL-python" module
- Previous by thread: Re: TypeError: 'module object is not callable'
- Index(es):
Relevant Pages
|