STINNER Victor <vstin...@python.org> added the comment:
In Python 3.8, random.Random docstring starts with "Random number generator base class". I do understand that the random module design predates the abc module (added to Python 2.7). I'm now proposing to add a real base class to move it towards modern Python stdlib coding style. That's the behavior that I would expect from a "base class": >>> class MySequence(collections.abc.Sequence): pass ... >>> seq=MySequence() Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: Can't instantiate abstract class MySequence with abstract methods __getitem__, __len__ Some examples of stdlib modules which implement base classes like this: * collections.abc.Sequence * numbers.Complex * selectors.BaseSelector * typing.SupportsInt asyncio.AbstractEventLoop doesn't fail when an instance is created, but when an abstract method is created. Users can choose to inherit from asyncio.BaseEventLoop or asyncio.AbstractEventLoop depending if they wany to inherit partially of BaseEventLoop features, or really create an event loop from scratch (AbstractEventLoop). Other classes which are designed like that: * email._policybase.Policy * http.cookiejar.CookiePolicy * importlib.abc.Loader * wsgiref.handlers.BaseHandler I don't think that it's worth it to bother with abc.ABC abstraction here, and so I only propose to provide methods which are implemented as "raise NotImplementedError". ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue40346> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com