Most common cause: misspelled __init__()
The usual cause of this error is that the __init__() method has been misspelled, usually by forgetting one of the two leading or trailing underscores:
>>> class A:
def __init_(self, x, y):
self.x = x
self.y = y
>>> A(10, 20)
Traceback (most recent call last):
File "<pyshell#33>", line 1, in <module>
A(10, 20)
TypeError: object() takes no parameters
Less common cause: mis-indentiation
The other cause is mis-indentation where the __init__() method is not indented to be inside of the class definition:
>>> class B:
"""Example class"""
>>> def __init__(self, p, q):
self.p = p
self.q = q
>>> B(30, 40)
Traceback (most recent call last):
File "<pyshell#41>", line 1, in <module>
B(30, 40)
TypeError: object() takes no parameters