Raymond Hettinger writes: > In my experiments with decorators, it is common to wrap the original > function with a new function. > > After creating the new function, there are efforts to make it > look like > the old: [...] > All is well and good except the argspec. Running help() on the new > function gives: [...] > So, it would be nice if there were some support for carrying > forward the > argspec to inform help(), calltips(), and inspect(). I created something to help address this... the "obvious" solution of a decorator used for making decorators. It's example #6 in: http://www.python.org/cgi-bin/moinmoin/PythonDecoratorLibrary Currently it doesn't handle argspec, but I propose adding argspec (it'll be slightly tricky, but shouldn't be impossible), then including it in a "decorators" package. Until we have a decorators package, I think it can live in the wiki and/or the cookbook. If asked to do so, I'll see about updating this to fix the argspec. If not asked to, I'll probably leave it alone, because as-is it is simple enough to serve as a decent example as well as being useful but with argspec handling it would be complex enough to be useful but too complex to be a good example to learn from. -- Michael Chermside
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