-
Notifications
You must be signed in to change notification settings - Fork 12.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Decorator support in instance functions #10644
Comments
This is a major pain point. The latter is seen by the compiler as a property, hence property decorator rules apply - the decorator function doesn't receive a From docs:
I think there should be an easy way to receive the value inside the decorator, so it can be manipulated - otherwise decorators are unusable in above context (bound methods). |
@rbuckton is this a duplicate of something? |
The semantics of these two declarations is significantly different. Methods (e.g. Decorators do not run for every object, they only run on the declaration of the class. since the initialization expression can have side effects, it can not be evaluated at the declaration time, but rather has to be initialized in every invocation of the constructor. This change will need some concept of "initializer" function that is part of the PropertyDiscriptor that would be passed in the decorator, but for that we need to wait for both decorators and public fields |
It would be useful if decorator would work in second case
The text was updated successfully, but these errors were encountered: