[Jewett, Jim J] > class Foo: > def bar(): > pass > bar = transform(bar) ... > 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. -1 This gains nothing over what we have now but does incur costs on readability, yet another syntax, and limiting the ability to apply a decoration outside the class definition. In its favor, this syntax does suggest something new which is the possibility of having all similar decorations grouped under one banner: class Foo: [transform] from" def bar(): pass def bat(): pass def baf(): pass That being said, grouping doesn't go much for me. I think the key to the previous proposals was putting wrappers on the same line as the function definition. Raymond Hettinger ################################################################# ################################################################# ################################################################# ##### ##### ##### ################################################################# ################################################################# #################################################################
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