I am hoping to post a new draft of PEP318 soon. Unfortunately, the solution that currently looks best to me has not been mentioned before. I wanted to give a heads up, so that people will be able to read the rest of the PEP too. (And so that I can change it if everyone else hates the new syntax.) The most common use case is class Foo: def bar(): pass bar = transform(bar) Because the name bar is immediately rebound, it effectively never references the original function directly. That function is hidden from the namespace where it is defined. This is similar to nested functions. def foo(): def bar(): pass bar is never visible (at least under that name) at the global level. To indicate this, it is nested inside the foo() block. I would like to do the same with decorators. class Foo: [transform] from: def bar(): pass The bar() function is now defined exactly as it was before, except that it is an extra indent to the right. [transform] can be treated as a completely ordinary list. The "from:" indicates that each member of this (just evaluated) list should be applied to the contained block, and the final result should be bound to the name (that would otherwise be) assigned to that internal block. -jJ
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4