diff options
author | Andre Delfino <adelfino@gmail.com> | 2019-03-25 22:53:43 (GMT) |
---|---|---|
committer | Cheryl Sabella <cheryl.sabella@gmail.com> | 2019-03-25 22:53:43 (GMT) |
commit | 548cb6060ab9d5a66931ea2be4da08c2c72c9176 (patch) | |
tree | 616322f80c105a142ae841f18486a0872b07e8bd /Doc | |
parent | 360e1e4c519cfc139de707bcdd1e6c871eec79ee (diff) | |
download | cpython-548cb6060ab9d5a66931ea2be4da08c2c72c9176.zip cpython-548cb6060ab9d5a66931ea2be4da08c2c72c9176.tar.gz cpython-548cb6060ab9d5a66931ea2be4da08c2c72c9176.tar.bz2 |
bpo-34085: Improve wording on classmethod/staticmethod (#8228)
* bpo-34085: Improve wording on classmethod/staticmethod
* Address comments from Éric
* Address comments from Éric
Diffstat (limited to 'Doc')
-rw-r--r-- | Doc/library/functions.rst | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/Doc/library/functions.rst b/Doc/library/functions.rst index ae0c9fb..6342ee3 100644 --- a/Doc/library/functions.rst +++ b/Doc/library/functions.rst @@ -211,19 +211,18 @@ are always available. They are listed here in alphabetical order. @classmethod def f(cls, arg1, arg2, ...): ... - The ``@classmethod`` form is a function :term:`decorator` -- see the description - of function definitions in :ref:`function` for details. + The ``@classmethod`` form is a function :term:`decorator` -- see + :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 method is called for a derived class, the derived class object is passed as the implied first argument. 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 - type hierarchy in :ref:`types`. + For more information on class methods, see :ref:`types`. .. function:: compile(source, filename, mode, flags=0, dont_inherit=False, optimize=-1) @@ -1452,11 +1451,11 @@ are always available. They are listed here in alphabetical order. @staticmethod def f(arg1, arg2, ...): ... - The ``@staticmethod`` form is a function :term:`decorator` -- see the - description of function definitions in :ref:`function` for details. + The ``@staticmethod`` form is a function :term:`decorator` -- see + :ref:`function` for details. - It 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. + A static method can be called either on the class (such as ``C.f()``) or on an instance (such + as ``C().f()``). 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 class @@ -1471,8 +1470,7 @@ are always available. They are listed here in alphabetical order. class C: builtin_open = staticmethod(open) - For more information on static methods, consult the documentation on the - standard type hierarchy in :ref:`types`. + For more information on static methods, see :ref:`types`. .. index:: |