Which Python object can be used to create a simple context manager without defining a class?

  • @contextmanager decorator
  • contextlib.ExitStack()
  • contextlib.AbstractContextManager()
  • contextlib.contextmanager()
The contextlib.contextmanager() decorator is used to create a simple context manager without defining a class. Other options are used for different purposes related to context management.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *