我知道当我们通过超级方法调用父方法时,我们可以忽略绑定方法中的“self”参数,如下所示:
class Foo(object):
def __init__(self):
super(Foo, self).__init__() # We needn't pass in the "self" argument
# ...
但是方法有些不同__new__
:
class Bar(object):
def __new__(cls, *args, **kwargs):
return super(Bar, cls).__new__(cls, *args, **kwargs) # Why need a "cls" argument?