In Python, what is the purpose of the __enter__ and __exit__ methods in a class? - Study24x7
Social learning Network
study24x7

Default error msg

Login

New to Study24x7 ? Join Now
Already have an account? Login
22 Feb 2024 01:13 PM study24x7 study24x7

In Python, what is the purpose of the __enter__ and __exit__ methods in a class?

A

 Define context managers for resource management 

B

Handle exceptions in a try-except block

C

Implement iterator protocols

D

Manage the entry and exit of threads

study24x7
Write a comment
Related Questions
500+   more Questions to answer
Most Related Articles