[Python-Dev] decorator support (original) (raw)
Michael Chermside mcherm at mcherm.com
Wed Sep 8 18:49:42 CEST 2004
- Previous message: [Python-Dev] Re: [Python-checkins] python/dist/src/Tools/msi msi.py, 1.7, 1.8
- Next message: [Python-Dev] Re: Dangerous exceptions (was Re:Another test_compilermystery)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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
- Previous message: [Python-Dev] Re: [Python-checkins] python/dist/src/Tools/msi msi.py, 1.7, 1.8
- Next message: [Python-Dev] Re: Dangerous exceptions (was Re:Another test_compilermystery)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]