[Python-ideas] Default decorator?
jimjjewett at gmail.com
Thu Jan 17 16:16:29 CET 2008
On 1/16/08, Guido van Rossum <guido at python.org> wrote:
> Peter Norvig suggested ... "default decorator". ...
> set once per module and ... invoked, before any explicit decorators.
> His use case ... uses argument annotations
I would prefer that it be easier to control module creation in general.
The decorator does meet his use case (and
logging/tracing/registration), but there are varieties that would work
better if the decorator were applied after any explicit decorators.
(OTOH, doing that all the time raises the problem about whether
decorators commute.) There are already questions about whether it
should apply to nested functions or lambdas.
You can just settle those questions by fiat and meet 90% of the need,
but letting the module control it seems cleaner (and also allows other
extensions, such as alternate module dict representations).
As to how module creation should be controlled -- that is a bit
hairier. My strawman is a __moduleclass__ analogous to __metaclass__.
would be the moral equivalent of (some other file) running
exec myfile in sys.modules["myfile"]
More information about the Python-ideas