instancemethod

Michele Simionato michele.simionato at gmail.com
Sat Jan 27 07:09:50 CET 2007


On Jan 27, 6:39 am, Steven D'Aprano
<s... at REMOVE.THIS.cybersource.com.au> wrote:
>
> It seems that the description of __new__ is wrong. Since __new__ takes an
> implicit first argument, the class, it is a class method, not a static
> method.

No:

>>> class C(object):
...    def __new__(cls): pass

>>> C.__dict__['__new__']
<staticmethod object at 0xb7ad42cc>

Moreover, citing from
http://www.python.org/download/releases/2.2.3/descrintro/#staticmethods

"""
    * Factoid: __new__ is a static method, not a class method. I
initially thought it would have to be a class method, and that's why I
added the classmethod primitive. Unfortunately, with class methods,
upcalls don't work right in this case, so I had to make it a static
method with an explicit class as its first argument. Ironically, there
are now no known uses for class methods in the Python distribution
(other than in the test suite). However, class methods are still useful
in other places, for example, to program inheritable alternate
constructors. 
"""

So, I stand my point.

          Michele Simionato




More information about the Python-list mailing list