Commit 6cafecec authored by Berker Peksag's avatar Berker Peksag

Issue #26576: Clarify that the @deco syntax is not always an equivalent of f = deco(f)

Patch by Chris Angelico.
parent e12a68be
...@@ -503,11 +503,13 @@ are applied in nested fashion. For example, the following code :: ...@@ -503,11 +503,13 @@ are applied in nested fashion. For example, the following code ::
@f2 @f2
def func(): pass def func(): pass
is equivalent to :: is roughly equivalent to ::
def func(): pass def func(): pass
func = f1(arg)(f2(func)) func = f1(arg)(f2(func))
except that the original function is not temporarily bound to the name ``func``.
.. index:: .. index::
triple: default; parameter; value triple: default; parameter; value
single: argument; function definition single: argument; function definition
...@@ -638,14 +640,13 @@ Classes can also be decorated: just like when decorating functions, :: ...@@ -638,14 +640,13 @@ Classes can also be decorated: just like when decorating functions, ::
@f2 @f2
class Foo: pass class Foo: pass
is equivalent to :: is roughly equivalent to ::
class Foo: pass class Foo: pass
Foo = f1(arg)(f2(Foo)) Foo = f1(arg)(f2(Foo))
The evaluation rules for the decorator expressions are the same as for function 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 decorators. The result is then bound to the class name.
name.
**Programmer's note:** Variables defined in the class definition are class **Programmer's note:** Variables defined in the class definition are class
attributes; they are shared by instances. Instance attributes can be set in a attributes; they are shared by instances. Instance attributes can be set in a
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment