R. David Murray added the comment:
Decorators are called with the decorated *function* objection when the class is
compiled. There can be no instance involved by their very nature, since the
instance doesn't exist yet. So no, you can't have a decorator that affects
instance attributes at the
Decorater added the comment:
hmm, I see. Well I was looking for an way to actually be able to use decorators
made in the same class to be able to somehow pass in the same instance as well.
Currently the only way to use class decorators is for them to be static (which
would not allow using or c
Steven D'Aprano added the comment:
Its not clear what you are asking for here. Do you think the current behaviour
is a bug? Are you asking for a new feature? What do you want?
When the decorator is called, "self" doesn't exist, so of course
@self.decorator *must* fail. What else could it do? W
New submission from Decorater:
So, many people rely on Decorators in class that accepts an instance of itself
like so:
class ExampleClass:
"""Example class with an example decorator that cannot be used."""
def __init__(self):
self.list_of_items = []
def add_item(self, item