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

spir denis.spir at gmail.com
Mon Dec 2 19:51:13 CET 2013


On 12/02/2013 04:55 PM, Gregory Salvan wrote:
> 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

Just a question:
I wonder about actual usefulness. For a strict safe check you'd also want to 
control method param types and names, not only number. Indeed, param types are 
out of question here, but what about param names? Since you implement that in C, 
is it at all possible to get method param names? (Well, in fact, maybe even 
Python's self-examination power allows that, does it?)

Denis


More information about the Python-ideas mailing list