Are decorators really that different from metaclasses...

Anthony Baxter anthonybaxter at
Thu Aug 26 13:05:46 CEST 2004

On Thu, 26 Aug 2004 10:28:14 +0200, Paolo Veronelli
<paolo.veronelli at> wrote:
> 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.

I have no idea what you're trying to say here. Are you saying that the
approach of double-under variables inside a function having some new
meaning, getting put into a new scope that did not previously exist,
is somehow _less_ magical that the syntactic sugar of decorators? If
so, how do you intend to handle the backwards compatibility issue,
where code that works on Python2.4 will do something entirely
different on Python2.3 (the double-under variables will be silently
ignored). Do you intend that the double-under names would also be
looked for in the same scopes? That is, what will this code do?

def foo():
    __name__ = '%s_banana'%(__name__) 

> 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.

Hand waving is all well and good, but this isn't a matter of
"generalizing the scope system". This is a _radical_ change to the
scoping rules of Python, and I think it's safe to say that there's
*absolutely* *no* *way* something like this would be considered,
without an excellent reason - and bolting some sort of strange
decorator semantics doesn't cut it.


More information about the Python-list mailing list