I recently came across this question.
import Object class Visitor(Object): def __init__(self): super(Visitor,self).__init__() def visit(self, obj): pass def getIsDone(self): return False isDone = property(fget =lambda self:self.getIsDone())
I get this error:
TypeError: module.__init__() takes at most 2 arguments (3 given)
and its answer:
class A:pass print(A) #outputs <class '__main__.A'> import urllib print(urllib) #outputs <module 'urllib' from '/usr/lib/python3.2/urllib/__init__.py'>
Your error is happening because Object is a module, not a class. So your inheritance is screwy.
Change your import statement to:
from Object import ClassName
and your class definition to:
class Visitor(ClassName):
or
change your class definition to:
class Visitor(Object.ClassName): etc
I'm not really satisfied with this answer as I'm not really sure how I get from that error message to the conclusion that I am accidentally inheriting from a module instead of a class. I was wondering if somebody could elaborate on why this error is occurring and what exactly the arguments being given are? When the python interpreter comes across code like this:
class Employee(Person)
what is happening? What exactly does the answerer mean by my inheritance is screwy? Thanks for any explanations or references to resources.