On Thu, Feb 12, 2015 at 8:58 PM, Ethan Furman <et...@stoneleaf.us> wrote:

> On 02/12/2015 08:01 PM, Guido van Rossum wrote:
> > On Thu, Feb 12, 2015 at 7:41 PM, Ethan Furman wrote:
> >>
> >> 2) always use the type of self when creating new instances
> >>
> >>        cons:
> >>          - if constructor signatures change, must override all methods
> which
> >>            create new objects
> >
> > Con for #2 is a showstopper. Forget about it.
>
> Happy to, but can you explain why requiring the programmer to override the
> necessary methods, or get tracebacks, is a
> showstopper?  Is there a previous email thread I can read that discusses
> it?
>

IIUC you're proposing that the base class should *try* to construct an
instance of the subclass by calling the type with an argument, and fail if
it doesn't work. But that makes the whole thing brittle in the light of
changes to the subclass constructor. Also, what should the argument be? The
only answer I can think of is an instance of the base class. Finally, this
would require more special-casing in every built-in class (at least every
built-in class that sometimes returns instances of itself).

-- 
--Guido van Rossum (python.org/~guido)
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
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