[Python-ideas] check interfaces, isducktype(X, A)
Gregory Salvan
apieum at gmail.com
Mon Dec 2 16:55:22 CET 2013
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 ?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20131202/405b9a83/attachment.html>
More information about the Python-ideas
mailing list