Commit bd96393c authored by Miss Islington (bot)'s avatar Miss Islington (bot) Committed by GitHub

bpo-34085: Improve wording on classmethod/staticmethod (GH-8228)


* bpo-34085: Improve wording on classmethod/staticmethod

* Address comments from Éric

* Address comments from Éric
(cherry picked from commit 548cb606)
Co-authored-by: default avatarAndre Delfino <adelfino@gmail.com>
parent 0516f818
...@@ -175,19 +175,18 @@ section. ...@@ -175,19 +175,18 @@ section.
def f(cls, arg1, arg2, ...): def f(cls, arg1, arg2, ...):
... ...
The ``@classmethod`` form is a function :term:`decorator` -- see the description The ``@classmethod`` form is a function :term:`decorator` -- see
of function definitions in :ref:`function` for details. :ref:`function` for details.
It can be called either on the class (such as ``C.f()``) or on an instance (such A class method can be called either on the class (such as ``C.f()``) or on an instance (such
as ``C().f()``). The instance is ignored except for its class. If a class as ``C().f()``). The instance is ignored except for its class. If a class
method is called for a derived class, the derived class object is passed as the method is called for a derived class, the derived class object is passed as the
implied first argument. implied first argument.
Class methods are different than C++ or Java static methods. If you want those, Class methods are different than C++ or Java static methods. If you want those,
see :func:`staticmethod` in this section. see :func:`staticmethod`.
For more information on class methods, consult the documentation on the standard For more information on class methods, see :ref:`types`.
type hierarchy in :ref:`types`.
.. versionadded:: 2.2 .. versionadded:: 2.2
...@@ -1346,18 +1345,17 @@ section. ...@@ -1346,18 +1345,17 @@ section.
def f(arg1, arg2, ...): def f(arg1, arg2, ...):
... ...
The ``@staticmethod`` form is a function :term:`decorator` -- see the The ``@staticmethod`` form is a function :term:`decorator` -- see
description of function definitions in :ref:`function` for details. :ref:`function` for details.
It can be called either on the class (such as ``C.f()``) or on an instance (such A static method can be called either on the class (such as ``C.f()``) or on an instance (such
as ``C().f()``). The instance is ignored except for its class. as ``C().f()``).
Static methods in Python are similar to those found in Java or C++. Also see Static methods in Python are similar to those found in Java or C++. Also see
:func:`classmethod` for a variant that is useful for creating alternate :func:`classmethod` for a variant that is useful for creating alternate
class constructors. class constructors.
For more information on static methods, consult the documentation on the For more information on static methods, see :ref:`types`.
standard type hierarchy in :ref:`types`.
.. versionadded:: 2.2 .. versionadded:: 2.2
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment