Guido> (1) Put decorators of the first category early in the def Guido> statement, for example here: Guido> def foobar [classmethod] (cls, foo, bar): Guido> ... How is this better than afterwards? Guido> (2) Invent some other notation for setting function attributes as Guido> part of the function *body*, before the doc string even. Guido> For (2) I am thinking aloud here: Guido> def foobar(self, arg): Guido> @author: "Guido van Rossum" Guido> @deprecated Guido> pass It's a shame that there's no good way to define function attributes already. Aside from the fact that this is different than the other form of "decoration", it's also different than setting attributes for classes. Rather than invent a unique syntax I'd prefer to either use a decorator function or suffer with tacking them on at the end: def foobar(self, arg): pass foobar.author = "Guido van Rossum" foobar.deprecated = True Using the proposed decorator syntax with the decorator after the arglist with a little judicious indentation I can make it look sort of like what you're after: def foobar(self, arg) [attributes( author = "Guido van Rossum" deprecated = True )]: pass Another possibility would be to overload def: def foobar(self, arg): def author = "Guido van Rossum" def deprecated = True pass I don't know if the parser can handle the lookahead necessary for that though. Skip
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