Python Professional — Hard
Key points
- __enter__ returning self binds the resource to r
- Enables method calls on r within the with block
- r refers to the original resource, not a copy
- __exit__ method is used to clean up resources
Ready to go further?
Related questions
