Question: Why would you use a decorator?
- A decorator is similar to a class and should be used if you are doing functional programming instead of object oriented programming.
- A decorator is a visual indicator to someone reading your code that a portion of your code is critical and should not be changed.
- You use the decorator to alter the functionality of a function without having to modify the functions code.
- An import statement is preceded by a decorator, python knows to import the most recent version of whatever package or library is being imported.
Answer: The correct answer of the above question is Option C:You use the decorator to alter the functionality of a function without having to modify the functions code.