duck-type-checking?

greg greg at cosc.canterbury.ac.nz
Sat Nov 15 08:08:01 CET 2008


Joe Strout wrote:

> So, the level of assertion that I want to make in a method that  expects 
> a Duck is just that its parameter is either a Duck, or  something that 
> the caller is claiming is just as good as a Duck.

I'm not sure, but I think the new ABC stuff in Py3 is
going to provide something like this, in that there will
be a way to declare that a class conforms to the Duck
interface even if it doesn't inherit from it. Then
you can just test isinstance(x, Duck).

-- 
Greg



More information about the Python-list mailing list