<div dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Feb 12, 2015 at 11:01 PM, Guido van Rossum <span dir="ltr"><<a href="mailto:guido@python.org" target="_blank">guido@python.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div class=""><div class=""><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><br>
2) always use the type of self when creating new instances<br>    ..<br>
   cons:<br>
     - if constructor signatures change, must override all methods which<br>
       create new objects<br></blockquote></div><br></div></div></div><div class="gmail_extra">Con for #2 is a showstopper. Forget about it.</div></blockquote></div><div class="gmail_extra"><br></div>Sorry if I am missing something obvious, but I still don't understand why the same logic does not apply to class methods that create new instances:</div><div class="gmail_extra"><br></div><div class="gmail_extra"><div class="gmail_extra">>>> from datetime import *</div><div class="gmail_extra">>>> date.today()</div><div class="gmail_extra">datetime.date(2015, 2, 13)</div><div class="gmail_extra">>>> datetime.today()</div><div class="gmail_extra">datetime.datetime(2015, 2, 13, 11, 37, 23, 678680)</div><div class="gmail_extra">>>> class Date(date):</div><div class="gmail_extra">...     pass</div><div class="gmail_extra">...</div><div class="gmail_extra">>>> Date.today()</div><div class="gmail_extra">Date(2015, 2, 13)</div><div class="gmail_extra"><br></div><div class="gmail_extra">(I actually find datetime.today() returning a datetime rather than a date a questionable design decision, but probably the datetime type should not have been a subclass of the date to begin with.)</div><div class="gmail_extra"><br></div><div class="gmail_extra">Are there any date subclasses in the wild that don't accept year, month, day in the constructor?  If you create such a class, wouldn't you want to override __add__ and friends anyways?  We already know that you will have to override today().  </div><br></div></div>