Are decorators really that different from metaclasses...

Paolo Veronelli paolo.veronelli at
Thu Aug 26 10:28:14 CEST 2004

Anthony Baxter wrote:
> On Wed, 25 Aug 2004 19:47:35 -0400, Paul Morrow <pm_mon at> wrote:
>>What you're trying to illustrate (I believe) is a superclass doing
>>something based on the docstring of a subclass.  Yes this certainly does
>>happen.  But the superclass and subclass are separate objects.  I was
>>talking about the situation where a function does something based on
>>/its own/ metadata.  That is what I'm saying virtually never happens,
>>and therefore it's ok to make all assignments to __xxx__ attributes
>>inside of a function def create /function attributes/ rather than /local
> This is an extraordinarily complex idea - you're proposing that inside
> a function there is now access to a brand new namespace, that of the
> function object itself. I don't think you appreciate just _how_ much
> work this would requre, nor the complexity of trying to explain this
> to users. Remember, at the moment, you can't even get access to the
> function object itself from inside the function, without using a hack
> like sys._getframe() or raising an exception.

It's not the ideas complexity that fears,but the feeling we are trying 
to bring down to earth the supposed magic of some language solutions.
There is nothing good in magic,specially when you have to build robust 
things on it.

> Putting aside nested scopes for the moment, there are three namespaces
> that are used in Python - local, module level global, and builtins.
> You're proposing that there is a new namespace, that of the function
> object, and that it only be used by accessing any local variable that
> starts or ends with two underscores. At the moment, the scoping rules
> for Python are _extremely_ simple. Do you really want to add something
> like this, that looks like a hack, smells like a hack, and who's
> implementation would be a hack? I know I don't want to see something
> like this.

If this blows away clouds on the language future and bring back the 
useful features in a wider theory where metaclasses and decorators are 
members of,this shouldn't be considered a hack.If it becomes a hack the 
problem is to be searched and solved above generalizing the scope system.

More information about the Python-list mailing list