On 15-02-13, Neil Girdhar wrote: > Interesting: > http://stackoverflow.com/questions/5490824/should-constructors-comply-with-the-liskov-substitution-principle
You'd better believe I read that thread not 20 minutes ago. :) > On Fri, Feb 13, 2015 at 3:37 PM, Isaac Schwabacher > <alexander.belopol...@gmail.com <ischwabac...@wisc.edu')" > target="1">ischwabac...@wisc.edu> wrote: > > > On 15-02-13, Guido van Rossum wrote: > > > Are you willing to wait 10 days for an answer? I'm out of round tuits > > > for a while. > > > > IIUC, the argument is that the Liskov Substitution Principle is a statement > > about how objects of a subtype behave relative to objects of a supertype, > > and it doesn't apply to constructors because they aren't behaviors > > of existing objects. So other overriding methods *should* be able to handle > > the same inputs that the respective overridden methods do, but constructors > > don't need to. Even though __init__ is written as an instance method, > > it seems like it's "morally" a part of the class method __new__ > > that's only split off for convenience. > > > > If this message is unclear, it's because I don't really understand > > this myself and I'm trying to articulate my best understanding of > > what's been said on this thread and those it links to. > > > > ijs > > > > > On Fri, Feb 13, 2015 at 10:22 AM, Alexander Belopolsky > > > <http://bugs.python.org/issue2267#msg125979(javascript:main.compose('new', > > > 't=alexander.belopol...@gmail.com>(java_script:main.compose()> wrote: > > > > > > > > > > > On Fri, Feb 13, 2015 at 1:19 PM, Alexander Belopolsky > > > > <alexander.belopol...@gmail.com > > > > <alexander.belopol...@gmail.com>(java_script:main.compose()> wrote: > > > > >> > > > > >> FWIW you're wrong when you claim that "a constructor is no > > > > >> different from any other method". Someone else should probably > > > > >> explain this (it's an old argument that's been thoroughly > > > > >> settled). > > > > > > > > > > > > > > > Well, the best answer I've got in the past [1] was "ask on > > > > > python-dev since Guido called the operator overriding expectation." > > > > > :-) > > > > > > > > > > > > And let me repost this bit of history [1]: > > > > > > > > Here is the annotated pre-r82065 code: > > > > > > > > 39876 gvanrossum def __add__(self, other): > > > > 39876 gvanrossum if isinstance(other, timedelta): > > > > 39928 gvanrossum return self.__class__(self.__days + other.__days, > > > > 39876 gvanrossum self.__seconds + other.__seconds, > > > > 39876 gvanrossum self.__microseconds + other.__microseconds) > > > > 40207 tim_one return NotImplemented > > > > 39876 gvanrossum > > > > > > > > > > > > > > > > [1] > --Guido van Rossum > > > > (python.org/~guido(http://python.org/~guido)(http://python.org/~guido(http://python.org/~guido))) > > _______________________________________________ > > Python-Dev mailing list > > Python-Dev@python.org <Python-Dev@python.org> > > https://mail.python.org/mailman/listinfo/python-dev > > Unsubscribe: > > https://mail.python.org/mailman/options/python-dev/mistersheik%40gmail.com > > _______________________________________________ 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