Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #93776

Foo.__new__ is what species of method?

From Ben Finney <ben+python@benfinney.id.au>
Subject Foo.__new__ is what species of method?
Date 2015-07-14 14:45 +1000
Newsgroups comp.lang.python
Message-ID <mailman.478.1436849134.3674.python-list@python.org> (permalink)

Show all headers | View raw


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

Back to comp.lang.python | Previous | NextNext in thread | Find similar | Unroll thread


Thread

Foo.__new__ is what species of method? Ben Finney <ben+python@benfinney.id.au> - 2015-07-14 14:45 +1000
  Re: Foo.__new__ is what species of method? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-07-14 14:54 +1000
    Re: Foo.__new__ is what species of method? Ben Finney <ben+python@benfinney.id.au> - 2015-07-14 15:17 +1000
    Re: Foo.__new__ is what species of method? Stefan Behnel <stefan_ml@behnel.de> - 2015-07-14 08:26 +0200

csiph-web