Message257371
What would your context manager base class do? I presume you supply a default __enter__() that does nothing, or perhaps just returns self.
You mentioned having a default __exit__() but I am having trouble seeing how it would be useful. A context manager is only really useful if it does something interesting in __exit__(), and for that, the programmer has to write their own version and remember its signature.
One option to simplify __exit__() that I used to use is a base class that defers to an abstract close() method with no parameters. But since ExitStack is now available, I am finding that is good enough instead. |
|
Date |
User |
Action |
Args |
2016-01-02 22:18:21 | martin.panter | set | recipients:
+ martin.panter, gvanrossum, brett.cannon, rhettinger, ncoghlan, Nan Wu |
2016-01-02 22:18:21 | martin.panter | set | messageid: <1451773101.18.0.289920730915.issue25609@psf.upfronthosting.co.za> |
2016-01-02 22:18:21 | martin.panter | link | issue25609 messages |
2016-01-02 22:18:20 | martin.panter | create | |
|