[Python-checkins] cpython (3.5): Issue #26576: Clarify that the @deco syntax is not always an equivalent of f =

berker.peksag python-checkins at python.org
Wed Aug 3 03:20:14 EDT 2016


https://hg.python.org/cpython/rev/e0f9f8be7963
changeset:   102510:e0f9f8be7963
branch:      3.5
parent:      102507:d9e25fe35f46
user:        Berker Peksag <berker.peksag at gmail.com>
date:        Wed Aug 03 10:17:21 2016 +0300
summary:
  Issue #26576: Clarify that the @deco syntax is not always an equivalent of f = deco(f)

Patch by Chris Angelico.

files:
  Doc/reference/compound_stmts.rst |  9 +++++----
  1 files changed, 5 insertions(+), 4 deletions(-)


diff --git a/Doc/reference/compound_stmts.rst b/Doc/reference/compound_stmts.rst
--- a/Doc/reference/compound_stmts.rst
+++ b/Doc/reference/compound_stmts.rst
@@ -503,11 +503,13 @@
    @f2
    def func(): pass
 
-is equivalent to ::
+is roughly equivalent to ::
 
    def func(): pass
    func = f1(arg)(f2(func))
 
+except that the original function is not temporarily bound to the name ``func``.
+
 .. index::
    triple: default; parameter; value
    single: argument; function definition
@@ -638,14 +640,13 @@
    @f2
    class Foo: pass
 
-is equivalent to ::
+is roughly equivalent to ::
 
    class Foo: pass
    Foo = f1(arg)(f2(Foo))
 
 The evaluation rules for the decorator expressions are the same as for function
-decorators.  The result must be a class object, which is then bound to the class
-name.
+decorators.  The result is then bound to the class name.
 
 **Programmer's note:** Variables defined in the class definition are class
 attributes; they are shared by instances.  Instance attributes can be set in a

-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list