I have two almost identical implementations of the __new__
method for a class.
However, in one case, there is an error message.
In the other case, it works fine.
class Klass1():
# causes RuntimeError: super(): no arguments
def __new__(*args):
obj = super().__new__(args[0])
return obj
class Klass2():
# This code here works just fine
def __new__(cls, *args):
obj = super().__new__(cls)
return obj
instance1 = Klass1()
instance2 = Klass2()
Why would it matter whether we write cls
or args[0]
?
What is causing the RuntimeError
exception to be raised?