TypeError: object() takes no parameters after defining __new__

In Python 3.3 and later, if you’re overriding both __new__ and __init__, you need to avoid passing any extra arguments to the object methods you’re overriding. If you only override one of those methods, it’s allowed to pass extra arguments to the other one (since that usually happens without your help).

So, to fix your class, change the __new__ method like so:

def __new__(cls, nom, prenom):
    print("Appel de la méthode __new__ de la classe {}".format(cls))
    return object.__new__(cls) # don't pass extra arguments here!

Leave a Comment