来自问题为什么或者更确切地说对象.__ new__在这两种情况下的工作方式不同
作者对其原因不感兴趣,而是对其如何感兴趣.
我非常想了解原因,特别是:
为什么不object.__init__打印参数而不是object.__new__ (in testclass1)
为什么没有为testclass3引发错误?(因为除了自我之外不需要任何参数)
码
>>> class testclass1(object):
    ...     pass
    ... 
>>> class testclass2(object):
    ...     def __init__(self,param):
    ...             pass
    ... 
>>> a = object.__new__(testclass1, 56)
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    TypeError: object.__new__() takes no parameters
>>> b = object.__new__(testclass2, 56)
>>> b
    <__main__.testclass2 object at 0x276a5d0>
>>> class testclass3(object):
    ...     def __init__(self):
    ...             pass
    ... 
>>> c = object.__new__(testclass3, 56)
>>> c
    <__main__.testclass3 object at 0x276a790> …