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

Andrew Barnert abarnert at yahoo.com
Mon Dec 2 19:42:22 CET 2013


Shouldn't this be tied to ABCs rather than redesigning and reimplementing most of ABC to add a little bit on top?

Sent from a random iPhone

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

> Hi,
> I've made a try of a function that check object/class members for duck typing.
> 
> For now I've basically called it isducktype(X, A)
> it returns true if:
> - X has all attributes of A
> - X methods have same number of arguments than corresponding A methods
> 
> or if A.__ducktypecheck__(X) returns True
> 
> Behaviour looks like isinstance and issubclass (support tuples...).
> 
> To test it:
> The patch with example is here:
> https://gist.github.com/apieum/7751279
> 
> Or you can use my branch here:
> https://bitbucket.org/gsalvan/cpython/commits/branch/default
> 
> 
> Any opinion about a feature like this ?
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> https://mail.python.org/mailman/listinfo/python-ideas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20131202/7989bb57/attachment.html>


More information about the Python-ideas mailing list