Which method is responsible for cleaning up resources in a context manager?

  • __cleanup__()
  • __close__()
  • __deallocate__()
  • __exit__()
The __exit__() method is responsible for cleaning up resources in a context manager. It's called automatically when exiting the 'with' block, allowing you to release resources or handle exceptions.
Add your answer
Loading...

Leave a comment

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