[issue2267] datetime.datetime operator methods are not subclass-friendly

Mark Dickinson report at bugs.python.org
Thu Jun 17 22:52:19 CEST 2010


Mark Dickinson <dickinsm at gmail.com> added the comment:

I had understood that the rule was that alternate constructors should be classmethods, for consistency with __new__.  (Well, except that __new__ is actually a staticmethod, of course... )

E.g., after "class MyDecimal(Decimal): pass", MyDecimal('2.3') produces a MyDecimal instance, and by analogy MyDecimal.from_float(2.3) should also produce a MyDecimal instance.  It's exactly the same type of function as the class constructor.

I don't think it would do any harm to get clarification from python-dev on the underlying reasons.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue2267>
_______________________________________


More information about the Python-bugs-list mailing list