Author martin.panter
Recipients Nan Wu, brett.cannon, gvanrossum, martin.panter, ncoghlan, rhettinger
Date 2016-01-02.22:18:20
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1451773101.18.0.289920730915.issue25609@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2016-01-02 22:18:21martin.pantersetrecipients: + martin.panter, gvanrossum, brett.cannon, rhettinger, ncoghlan, Nan Wu
2016-01-02 22:18:21martin.pantersetmessageid: <1451773101.18.0.289920730915.issue25609@psf.upfronthosting.co.za>
2016-01-02 22:18:21martin.panterlinkissue25609 messages
2016-01-02 22:18:20martin.pantercreate