Message261888
The official documentation declares an unambiguous equivalence which is not true in some corner cases:
@deco
def f(x): pass
is not quite the same as
def f(x): pass
f = deco(f)
as the name is never bound to the undecorated function. This is what makes @property and @prop.setter work; otherwise, the undecorated setter function would overwrite the property, and the decoration would fail. Attached patch loosens the wording slightly to "broadly equivalent"; this permits corner cases to vary from the equivalence, while still retaining its simplicity for the 99% of cases where it's correct. (Think of explaining "yield from iter" as "for x in iter: yield x" and you have a similar near-equivalence.)
Also, class decorators aren't required to return classes. Text removed saying that they do. |
|
Date |
User |
Action |
Args |
2016-03-17 06:29:58 | Rosuav | set | recipients:
+ Rosuav, docs@python |
2016-03-17 06:29:58 | Rosuav | set | messageid: <1458196198.66.0.0478952577579.issue26576@psf.upfronthosting.co.za> |
2016-03-17 06:29:57 | Rosuav | link | issue26576 messages |
2016-03-17 06:29:57 | Rosuav | create | |
|