[Python-ideas] check interfaces, isducktype(X, A)

Andrew Barnert abarnert at yahoo.com
Tue Dec 3 08:56:37 CET 2013


On Dec 2, 2013, at 17:21, Gregory Salvan <apieum at gmail.com> wrote:

> @Andrew +1
> Maybe inspect is more appropriate as it provides ArgSpec and getmembers ?

Sure, using inspect for the implementation _also_ makes sense. But my point is more about the interface to your new thing. 

Your thing checks most of the same stuff that ABCs check, but maybe not all of it, and also adds checking for compatible argspecs. (I believe that's the only new feature it adds; am I right?)

Meanwhile, it uses a new isducktype function instead of working with normal issubclass/isinstance, and a completely different way of registering explicit compliance, and so on.

Instead, why not just extend ABCMeta with a new subclass that just adds the check for compatible argspecs (maybe using inspect, as you say) and takes advantage of all the other stuff ABC already does? Besides being less code,  which isn't that big of a deal, it's less of a radical conceptual change, which is a bigger deal, and it means that all kinds of code that relies on isinstance today can work with no changes.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20131202/b9d3446c/attachment.html>


More information about the Python-ideas mailing list