Guido van Rossum wrote: >>This looks ugly to me. I do have top level functions that would use >>decorators because those functions will be put into a class as >>classmethods and this class will be put into sys.modules instead of >>the original module. Replacing >> >>def foo(cls): >> ... >>foo = classmethod(foo) >> >>with >> >>if True: >> [classmethod] >> def foo(cls): >> ... >> >>doesn't look that attractive to me. > > > You won't have to do that except in interactive mode. How often do > you type functions that need decorators interactively? > Wouldn't a small addition to your syntax make all these (special case) problems disappear and, perhaps, go some way to making the syntax more readable (particularly for beginners):: as: [classmethod] def func(args) I'm a relative newbie to Python (12 months but many, many years elsewhere) which means I'm only qualified to comment on what a newbie would find confusing and I can assure you an isolated list on a line by itself or having to read about "if True:" work-arounds, would be remarkably confusing in a language where so much else happens just the way you would expect. If the decorator list is to go first and on the line above, then the 'as:' syntax just looks so right to my newbie eyes and sensibilities. It even read fairly well for the oft given 'classmethod' and 'staticmethod' use cases. -- Mike
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