+ 1
deference between inheritance. 1-using decorator 2-class child(parent)
tow type of inheritance. what's deferent?
2 Antworten
+ 1
decorators are NOT used for inheritance, only for adding functionalities to functions
0
The decorated function is not related to the decorator function, while the inherited function is related to the function it inherits from.
Think of it from this point of view: if you delete the parent class, all the child classes will suffer, because the parent class methods and properties are essential to the child classes existence. In some way, decorator is more like clothes. If you delete the decorator function, all the decorated functions will just become 'naked'. It won't go unnoticed, however, the functions themselves will continue to function.
Here is an explanation of the decorator usage:
https://code.sololearn.com/cD09ijlIS6Ev/?ref=app