[Python-checkins]
python/dist/src/Doc/whatsnew whatsnew24.tex, 1.124, 1.125
montanaro at users.sourceforge.net
montanaro at users.sourceforge.net
Sun Dec 26 16:29:30 CET 2004
Update of /cvsroot/python/python/dist/src/Doc/whatsnew
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17042
Modified Files:
whatsnew24.tex
Log Message:
correct decorator example, tweak description slightly
Index: whatsnew24.tex
===================================================================
RCS file: /cvsroot/python/python/dist/src/Doc/whatsnew/whatsnew24.tex,v
retrieving revision 1.124
retrieving revision 1.125
diff -u -d -r1.124 -r1.125
--- whatsnew24.tex 13 Dec 2004 11:39:33 -0000 1.124
+++ whatsnew24.tex 26 Dec 2004 15:29:28 -0000 1.125
@@ -289,7 +289,9 @@
the following:
\begin{verbatim}
- at A @B @C
+ at A
+ at B
+ at C
def f ():
...
\end{verbatim}
@@ -301,16 +303,18 @@
f = A(B(C(f)))
\end{verbatim}
-Decorators must come on the line before a function definition, and
-can't be on the same line, meaning that \code{@A def f(): ...} is
-illegal. You can only decorate function definitions, either at the
-module level or inside a class; you can't decorate class definitions.
+Decorators must come on the line before a function definition, one decorator
+per line, and can't be on the same line as the def statement, meaning that
+\code{@A def f(): ...} is illegal. You can only decorate function
+definitions, either at the module level or inside a class; you can't
+decorate class definitions.
-A decorator is just a function that takes the function to be decorated
-as an argument and returns either the same function or some new
-callable thing. It's easy to write your own decorators. The
-following simple example just sets an attribute on the function
-object:
+A decorator is just a function that takes the function to be decorated as an
+argument and returns either the same function or some new object. The
+return value of the decorator need not be callable (though it typically is),
+unless further decorators will be applied to the result. It's easy to write
+your own decorators. The following simple example just sets an attribute on
+the function object:
\begin{verbatim}
>>> def deco(func):
More information about the Python-checkins
mailing list