How about the following, which I am almost positive has not been suggested: ----- class Klass: def __init__(self, name): self.name = name deco meth0: staticmethod def meth0(x): return x deco meth1: classmethod def meth1(cls): return cls deco sayhello: funcattrs(name='GvR', language='python') log(file='func.log') def sayhello(self): print 'hello python world' ----- 1) The decorators clearly apply to a specific method/function, therefore there is no need to do any stack pushing in memory until the method/function definition is done. 2) The decorators are "outside" of the method/function they decorate: a) which will please those who want the outside location b) will not be folded within the function c) folding on the decorators can be done so that the def is not obfuscated d) can be located anywhere in the code--but most likely before the "def ...()" 3) The sequence in which the decorators are applied is just like code would be--this is certainly intuitive given that we are writing code. This approach could also be applied to classes in case decorators should ever be extended to them: ----- deco Klass: doc("This is a class to ...") class Klass: : : ----- Any comments? John
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