> One thing I added awhile back to PEP 318 as an open issue is that for ease > of writing wrappers the func_name attribute of a function object should be > writable. For example, in situations where the decorator returns a new > function object (often, I would think) it would really be nice if that new > function object had the same name as the undecorated function. Consider: > > def a(func): > def _inner(*args, **kwds): > return func(*args, **kwds) > return _inner > > @a > def func(*args, **kwds): > print args > print kwds > > print "func's name:", func.func_name > > I realize you can use new.function() to create a new function object, but > that seems like a fair amount of extra complexity just to change the > function's name. I'd prefer it if the decorator could be written as: > > def a(func): > def _inner(*args, **kwds): > return func(*args, **kwds) > _inner.func_name = func.func_name > return _inner > > That fails because func_name is readonly. Any chance this restriction can > be loosened up? Good idea, independent from decorators; please add it to the PEP! --Guido van Rossum (home page: http://www.python.org/~guido/)
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