@@ -315,8 +315,12 @@ \section{Function definitions\label{function}}
315315
316316\begin {productionlist }
317317 \production {funcdef}
318- {"def" \token {funcname} "(" [\token {parameter_list}] ")"
318+ {[ \token {decorators}] "def" \token {funcname} "(" [\token {parameter_list}] ")"
319319 ":" \token {suite}}
320+ \production {decorators}
321+ {\token {decorator} ([NEWLINE] \token {decorator})* NEWLINE}
322+ \production {decorator}
323+ {"@" \token {dotted_name} ["(" [\token {argument_list} [","]] ")" ]}
320324 \production {parameter_list}
321325 {(\token {defparameter} "," )*}
322326 \productioncont {("*" \token {identifier} [, "**" \token {identifier}]}
@@ -343,6 +347,27 @@ \section{Function definitions\label{function}}
343347The function definition does not execute the function body; this gets
344348executed only when the function is called.
345349
350+ A function definition may be wrapped by one or more decorator expressions.
351+ Decorator expressions are evaluated when the function is defined, in the scope
352+ that contains the function definition. The result must be a callable,
353+ which is invoked with the function object as the only argument.
354+ The returned value is bound to the function name instead of the function
355+ object. If there are multiple decorators, they are applied in reverse
356+ order. For example, the following code:
357+
358+ \begin {verbatim }
359+ @f1
360+ @f2
361+ def func(): pass
362+ \end {verbatim }
363+
364+ is equivalent to:
365+
366+ \begin {verbatim }
367+ def func(): pass
368+ func = f2(f1(func))
369+ \end {verbatim }
370+
346371When one or more top-level parameters have the form \var {parameter}
347372\code {=} \var {expression}, the function is said to have `` default
348373parameter values.'' For a parameter with a
0 commit comments