Phillip J. Eby wrote:
> Hmm... You're right. It would be nice for the decorators to be
> invariants or as close as possible to invariants. What would be nice
> is if the decorators actually maintained the signature of the
> functions they're decorating but added additional parameters as
> needed. I wonder how easy that would be?
RuleDispatch's dispatch.on() and dispatch.generic() both have tools for
generating functions that have the same signature as the original code.
These deal correctly with both nested argument tuples and default
values, so you might look there for examples of how to do it.
Personally, for most decorators I just copy the function's __name__,
__dict__, and __doc__ to the returned function, as doing the code
generation is a bit of a pain for most decorator use cases.
This is a library that defines a decorator for writing decorators:
http://www.phyast.pitt.edu/~micheles/python/documentation.html
Last I looked it could use some packaging work (no setup.py).
--
Ian Bicking / [EMAIL PROTECTED] / http://blog.ianbicking.org