What is the correct way to implement the standard behaviour of __new__ in Python so that no functionality is broken?
I used
class Test:
def __new__(cls, *args, **kwargs):
return object.__new__(cls, *args, **kwargs)
t=Test()
which on some Python versions throws DepreciationWarnings. On the internet I had seen something with super() or with type(). What are the differences and which is prefered?
You should write
This is recommended by the documentation (and the same for 2.x).
The reason to use
superis as always to cope with inheritance tree linearisation; you don’t know for certain that the appropriate superclass isobject, so you should always usesuper.