Python version: "'2.7.3 (default, Apr 10 2013, 06:20:15) \n[GCC 4.6.3]'"
I have this:
>>> 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>
Some more fun! Compare with results of testclass1 above.
>>> class testclass3(object):
... def __init__(self):
... pass
...
>>> c = object.__new__(testclass3, 56)
>>> c
<__main__.testclass3 object at 0x276a790>
>>> c1 = object.__new__(testclass3)
>>> c1
<__main__.testclass3 object at 0x276a810>
My question is how does (not why does) object__new__
behave differently in these two cases?
Also notice the error is kind of misleading in the first case because in the second case object.__new__
does end up taking an argument!.