Barry A. Warsaw <ba...@python.org> added the comment:

On Dec 25, 2017, at 18:51, Nick Coghlan <rep...@bugs.python.org> wrote:
> 
> 3. A for-subclasses-only "self._clone()" API could work as follows:
> 
>    def _clone(self, new_instance=None):
>        if new_instance is None:
>            new_instance = type(self)()
>        # Clone state here
>        return new_instance
> 
> Then subclasses could override *just* the instance creation part by doing:
> 
>    def _clone(self):
>        return super()._clone(self._make_instance())
> 
> While also being free to add their own additional state copying code if 
> needed.

So _make_instance() wouldn’t be part of ExitStack’s API, but subclasses could 
implement it (and name it whatever they want of course)?

I’m not sure _clone() is the right name here since that implies to me state 
copy as well, and I totally agree with your other points.  That’s why I 
originally suggested _make_instance() would be the name and API in the base 
class.

----------

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

Reply via email to