decorators - would be nice if...
Diez B. Roggisch
deets at nospam.web.de
Wed Jul 15 00:03:03 CEST 2009
Ken Seehart schrieb:
> 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.
You can access the instance.
def _d(self, *args, **kwargs):
return method(self, *args, **kwargs)
def bar(self, a, b):
f = Foo()
So what exactly it is you are missing? The method's locals()?
And could you explain *why* you are missing this?
More information about the Python-list