TypeError

LeoDeBeo leodebeo at hotmail.com
Mon Aug 27 18:37:36 EDT 2001


Martijn wrote:

> Hi,
> 
> I`ve got this error every time I want to use my classes and I can`t
> figure out what`s wrong. My code is ok and I`ve used some examples from
> a book to check it but I get the same error message.This is what happends:
> 
>  >>> import MyClassFile
>  >>> m = MyClassFunction()
> Traceback (innermost last)
> File "<stdin>"
> TypeError: Call of nonfunction (type module)
> 
> I also tried:
> 
>  >>> import MyClassFile
>  >>> m = MyClassFile.MyClassFunction()
> 
> And finaly :
> 
>  >>> from MyClassfile import *
>  >>> m = MyClassFunction()
> 
> Both give me the same errors. What am i doing wrong ?!? I am using Linux
> btw.
> 
> 
> Thanx in advance,
> 
> 
> Martijn
> 
> 
when importing your MyClassFile all function and class definitions are 
executed once. Those functions and class definitions are then available 
within your programs.
but if you want to instantiate a class you need to create an instance from 
the class template

did you first instantiate your class??
it looks like you're calling a method of a class which you didn't 
instantiate
assign an instance of the class to a  variable like this:

x= 'name of the class'() 
eg if your class is called MyClass
x= MyClass()






More information about the Python-list mailing list