Python Programming - Decorators - Discussion

Discussion Forum : Decorators - General Questions (Q.No. 26)
26.
What is the primary purpose of the @contextlib.contextmanager decorator?
Converts a method to a class method
Enables the use of the 'with' statement for resource management
Marks a method as a static method
Decorates a method with dynamic behavior
Answer: Option
Explanation:
The @contextlib.contextmanager decorator is used to define a generator-based context manager, enabling the use of the 'with' statement for resource management.
Discussion:
Be the first person to comment on this question !

Post your comments here:

Your comments will be displayed after verification.