On Tue, Jul 14, 2009 at 5:44 PM, Ken Seehart<k...@seehart.com> wrote: > Almost every time I use decorators, I find myself wishing I had access > to the local namespace of the context from which the decorator is > executed. In practice, decorator is being applied to a method, so the > namespace in question would be the dictionary of the class being created.
As other mentioned, an example would make it clearer what you are trying to do. > Similarly, before decorators were around, I often found myself lamenting > the fact that a class is not created until after it's scope is > completed, since this makes certain kinds of metaprogramming more > difficult. But after digging deeper, I realized why it is the way it > is, so I don't complain about that. Py3k to the rescue! Because the metaclass is defined outside of the class body it is possible to pass in a metaclass that uses a custom dictionary. This was added to make some common cases easier (like knowing in which order members were defined). This is not backportable to 2.6 because the __metaclass__ is defined inside the class body and possibly anywhere in the class body. -Jack -- http://mail.python.org/mailman/listinfo/python-list