Mark Dickinson added the comment: Relevant post from Tim Peters back in 2005, on the subject of subclassing datetime and timedelta:
""" Yes, and all builtin Python types work that way. For example, int.__add__ or float.__add__ applied to a subclass of int or float will return an int or float; similarly for a subclass of str. This was Guido's decision, based on that an implementation of any method in a base class has no idea what requirements may exist for invoking a subclass's constructor. For example, a subclass may restrict the values of constructor arguments, or require more arguments than a base class constructor; it may permute the order of positional arguments in the base class constructor; it may even be "a feature" that a subclass constructor gives a different meaning to an argument it shares with the base class constructor. Since there isn't a way to guess, Python does a safe thing instead. """ Source: https://mail.python.org/pipermail/python-list/2005-January/311610.html ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue25535> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com