Re: [Python-Dev] Return type of alternative constructors

2016年5月08日 00:06:37 -0700

IMO bool is a special case because it's meant to be a final class, and the
implementation of int (which is in C and so can violate most rules) doesn't
respect that.
But in general I think the only reasonable approach is that a construction
class method should return an instance of the subclass; these class methods
have a signature that's constrained by their signature in the base class.
OTOH operators like __add__ cannot be expected to return an instance of the
subclass, because these typically construct an instance using
__new__/__init__, whose signatures are *not* constrained by the base class.
_______________________________________________
Python-Dev mailing list
[email protected]
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to