aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Doc/library/functions.rst
diff options
context:
space:
mode:
Diffstat (limited to 'Doc/library/functions.rst')
-rw-r--r--Doc/library/functions.rst15
1 files changed, 10 insertions, 5 deletions
diff --git a/Doc/library/functions.rst b/Doc/library/functions.rst
index dca8b933487..30f62e69e7f 100644
--- a/Doc/library/functions.rst
+++ b/Doc/library/functions.rst
@@ -1619,8 +1619,9 @@ are always available. They are listed here in alphabetical order.
The ``@staticmethod`` form is a function :term:`decorator` -- see
:ref:`function` for details.
- A static method can be called either on the class (such as ``C.f()``) or on an instance (such
- as ``C().f()``).
+ A static method can be called either on the class (such as ``C.f()``) or on
+ an instance (such as ``C().f()``). Moreover, they can be called as regular
+ functions (such as ``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
@@ -1632,15 +1633,19 @@ are always available. They are listed here in alphabetical order.
body and you want to avoid the automatic transformation to instance
method. For these cases, use this idiom::
+ def regular_function():
+ ...
+
class C:
- builtin_open = staticmethod(open)
+ method = staticmethod(regular_function)
For more information on static methods, see :ref:`types`.
.. versionchanged:: 3.10
Static methods now inherit the method attributes (``__module__``,
- ``__name__``, ``__qualname__``, ``__doc__`` and ``__annotations__``) and
- have a new ``__wrapped__`` attribute.
+ ``__name__``, ``__qualname__``, ``__doc__`` and ``__annotations__``),
+ have a new ``__wrapped__`` attribute, and are now callable as regular
+ functions.
.. index::