Closed mentalisttraceur closed 2 years ago
Users can similarly define subclasses which add the above functions as @classmethod
-decorated methods, or do the isinstance
check before calling super().__init__(...)
- whether subclassing like that is better or worse than external helper functions is a separate matter, but it's also possible.
Verdict:
no, unless someone brings a particularly compelling reasonprobably, if people start asking for it.Rationale: users can easily compose type-constraining functions on top of a type-flexible constructor, like this:
However, Python is a batteries-included language, and I could imagine wanting these batteries in this library. So if someone finds themselves wanting it, I might be pretty easily swayed, especially by seeing an example use-case where this is nicer to have out-of-the-box.