diff options
author | Anthony Baxter <anthonybaxter@gmail.com> | 2004-08-02 06:10:11 (GMT) |
---|---|---|
committer | Anthony Baxter <anthonybaxter@gmail.com> | 2004-08-02 06:10:11 (GMT) |
commit | c2a5a636545a88f349dbe3e452ffb4494b68e534 (patch) | |
tree | aaa24074dcdcce5afa51523969971bdd05381b01 /Doc/lib | |
parent | fd7dc5169c3ca7d64109512f38762c4ce9e96c5f (diff) | |
download | cpython-c2a5a636545a88f349dbe3e452ffb4494b68e534.zip cpython-c2a5a636545a88f349dbe3e452ffb4494b68e534.tar.gz cpython-c2a5a636545a88f349dbe3e452ffb4494b68e534.tar.bz2 |
PEP-0318, @decorator-style. In Guido's words:
"@ seems the syntax that everybody can hate equally"
Implementation by Mark Russell, from SF #979728.
Diffstat (limited to 'Doc/lib')
-rw-r--r-- | Doc/lib/asttable.tex | 6 | ||||
-rw-r--r-- | Doc/lib/libfuncs.tex | 13 |
2 files changed, 16 insertions, 3 deletions
diff --git a/Doc/lib/asttable.tex b/Doc/lib/asttable.tex index 7f6ba9f..8a93abf 100644 --- a/Doc/lib/asttable.tex +++ b/Doc/lib/asttable.tex @@ -73,6 +73,9 @@ \lineiii{Continue}{}{} \hline +\lineiii{Decorators}{\member{nodes}}{List of function decorator expressions} +\hline + \lineiii{Dict}{\member{items}}{} \hline @@ -101,7 +104,8 @@ \lineiii{}{\member{names}}{} \hline -\lineiii{Function}{\member{name}}{name used in def, a string} +\lineiii{Function}{\member{decorators}}{\class{Decorators} or \code{None}} +\lineiii{}{\member{name}}{name used in def, a string} \lineiii{}{\member{argnames}}{list of argument names, as strings} \lineiii{}{\member{defaults}}{list of default values} \lineiii{}{\member{flags}}{xxx} 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. |