Shalabh Chaturvedi wrote: > ... > > sync = synchronized(lock) > def sync classmethod func(a): > > In fact sync would probably be reused throughout > the class body. In this case yes. But there are other usecases where it isn't as hot (pseudo Spark): grammar_rule = grammar("x := y z?") def grammar_rule func1(a): pass grammar_rule = grammar("y := y1 y2?") def grammar_rule func2(a): pass grammar_rule = grammar("z := z2? z1") def grammar_rule func3(a): pass But it isn't terrible. It just means you need to create meaningless temporaries. It also makes life a little harder for tools trying to read the code and figure out what is going on. This is an easy pattern to look for: def sync func(a)[synchronized(lock)]: For instance an IDE could make a tooltip wherever "func" is used to indicate that it is synchronized with a particular lock. That gets much harder if there are usually arbitrary amounts of Turing complete code between the function declaration and the decorator declaration. Another concern: It arguably HURTS readability if deciphering a function declaration requires scanning backwards looking for definitions like the one for "sync". I certainly see the strength of your proposal from a readability point of view. Paul Prescod
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