Python Programming - Decorators - Discussion

Discussion Forum : Decorators - General Questions (Q.No. 30)
30.
How does the @contextlib.asynccontextmanager decorator differ from @contextlib.contextmanager?
@contextlib.asynccontextmanager is used for asynchronous context managers.
@contextlib.asynccontextmanager is used for synchronous context managers.
There is no difference; they serve the same purpose.
@contextlib.contextmanager is used for decorators.
Answer: Option
Explanation:
@contextlib.asynccontextmanager is specifically designed for creating asynchronous context managers, allowing the use of the 'async with' statement.
Discussion:
Be the first person to comment on this question !

Post your comments here:

Your comments will be displayed after verification.