What?
- Decoration is a way to specify management code for functions and classes
- Decorator themselves take the form of callable objects (ie., function ) that process other callable objects
- Decorator are mainly two type
- function Decorator
- class Decorator
- function Decorator install wrapper object to intercept later function calls and process them as needed
- class Decorator install wrapper objects to intercept later instance creation calls and process them as required
- Decorators have very explicit syntax which makes them easier to spot than helper function class that may be arbitrarily far removed from the subject functions or classes.
- Decorators are applied once, when the subject function or class is defined; its not necessary to add extra code at every call to the class or function
No comments:
Post a Comment