Martin Panter added the comment:

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.

----------
nosy: +martin.panter

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue25609>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to