"Jewett, Jim J" <jim.jewett at eds.com> writes: > Guido van Rossum: > >> ... for decorators spelled with a single word, like classmethod, >> ... as early as reasonable in the function definition > >> def foobar(cls, blooh, blah) [classmethod]: > >> hides a more important fact for understanding it (classmethod) behind >> some less important facts (the argument list). I would much rather >> see this: > >> def foobar [classmethod] (cls, blooh, blah): > > One alternative placed it earlier still, in a second header clause. > > using: > classmethod > def foobar(cls, blooh, blah): > pass Has somebody suggested the following yet? def [classmethod] foo(cls, blooh, bla): pass or for a longer list of decorators def [classmethod, attributes(deprecated=True) ] foo(cls, blooh, bla): pass It might be more readable if a newline were allowed between the closing ] and the function name: def [classmethod, attributes(deprecated=True)] foo(cls, blooh, bla): pass Putting the decorators between the "def" and the function name has some advantages over the proposals I've seen so far: - crucial information about the function and the meaning of the parameters is given very early (this was an argument made for putting the decorat before the argument list) - The name and the argument are together, so it still looks similar to the function invocation (an argument made for putting the decorators after the function list). If the decorators come before the function name, the decorators should perhaps be applied in reverse order so that def [classmethod, deprecated] foo(cls, bar): pass is similar to def foo(cls, bar): pass foo = classmethod(deprecated(foo)) Bernhard -- Intevation GmbH http://intevation.de/ Skencil http://sketch.sourceforge.net/ Thuban http://thuban.intevation.org/
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