While creating a context manager using a generator, the code before the yield statement is equivalent to the _______ method of a class-based context manager.

  • __enter__
  • __initialize__
  • __prepare__
  • __setup__
When creating a context manager using a generator, the code before the yield statement is equivalent to the __enter__ method of a class-based context manager. It sets up the context before it's entered.
Add your answer
Loading...

Leave a comment

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