[Python-ideas] Default decorator?
Brett Cannon
brett at python.org
Thu Jan 17 01:58:40 CET 2008
On Jan 16, 2008 4:31 PM, Guido van Rossum <guido at python.org> wrote:
> Peter Norvig suggested an idea to me over lunch: a "default
> decorator". This would be something you could set once per module and
> it would be invoked for each function definition in the same way as a
> decorator is invoked, before any explicit decorators. His use case was
> something that wraps every function that uses argument annotations
> with something that interprets those annotations in a certain way and
> enforces that interpretation. It would save having to explicitly
> annotate every function or method that way.
>
> Thoughts? I suggested that a metaclass could do this for methods, but
> that of course leaves plain functions in the lurch.
Do we want something like a global decorator, or more something like
__build_class__ for the 'def' statement (although a quick attempt at
replacing __build_class__ didn't work for me)? I personally prefer the
latter as that is the more powerful solution between the two. Plus I
don't see the need for a global decorator coming up often enough to
warrant making it simpler.
-Brett
More information about the Python-ideas
mailing list