Foo.__new__ is what species of method?

Ben Finney ben+python at benfinney.id.au
Tue Jul 14 00:45:25 EDT 2015


Howdy all,

The Python reference says of a class ‘__new__’ method::

    object.__new__(cls[, ...])

    Called to create a new instance of class cls. __new__() is a static
    method (special-cased so you need not declare it as such) that takes
    the class of which an instance was requested as its first argument.

    <URL:https://docs.python.org/3/reference/datamodel.html#object.__new__>

But a “static method” is described, elsewhere in the documentation
<URL:https://docs.python.org/3/library/functions.html#staticmethod>, as
“A static method does not receive an implicit first argument”.

What the ‘__new__’ documentation describes would match a “class method”
<URL:https://docs.python.org/3/library/functions.html#classmethod>
“A class method receives the class as implicit first argument”.

I suspect this a bug in the reference documentation for ‘__new__’, and
it should instead say “__new__ is a class method …”. Am I wrong?

-- 
 \        “Cooles & Heates: If you want just condition of warm in your |
  `\    room, please control yourself.” —air conditioner instructions, |
_o__)                                                            Japan |
Ben Finney




More information about the Python-list mailing list