diff options
Diffstat (limited to 'Doc/lib/libfuncs.tex')
-rw-r--r-- | Doc/lib/libfuncs.tex | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/Doc/lib/libfuncs.tex b/Doc/lib/libfuncs.tex index ff922d4..b3d3d30 100644 --- a/Doc/lib/libfuncs.tex +++ b/Doc/lib/libfuncs.tex @@ -109,10 +109,14 @@ def my_import(name): \begin{verbatim} class C: + @classmethod def f(cls, arg1, arg2, ...): ... - f = classmethod(f) \end{verbatim} + The \code{@classmethod} form is a function decorator -- see the description + of function definitions in chapter 7 of the + \citetitle[../ref/ref.html]{Python Reference Manual} for details. + It can be called either on the class (such as \code{C.f()}) or on an instance (such as \code{C().f()}). The instance is ignored except for its class. @@ -122,6 +126,7 @@ class C: Class methods are different than \Cpp{} or Java static methods. If you want those, see \function{staticmethod()} in this section. \versionadded{2.2} + Function decorator syntax added in version 2.4. \end{funcdesc} \begin{funcdesc}{cmp}{x, y} @@ -936,10 +941,14 @@ except NameError: \begin{verbatim} class C: + @staticmethod def f(arg1, arg2, ...): ... - f = staticmethod(f) \end{verbatim} + The \code{@staticmethod} form is a function decorator -- see the description + of function definitions in chapter 7 of the + \citetitle[../ref/ref.html]{Python Reference Manual} for details. + It can be called either on the class (such as \code{C.f()}) or on an instance (such as \code{C().f()}). The instance is ignored except for its class. |