[Python-Dev] Let's get rid of unbound methods

Phillip J. Eby pje at telecommunity.com
Tue Jan 4 19:51:42 CET 2005


At 01:36 PM 1/4/05 -0500, Jim Fulton wrote:
>duck typing?

AKA latent typing or, "if it walks like a duck and quacks like a duck, it 
must be a duck."  Or, more pythonically:

    if hasattr(ob,"quack") and hasattr(ob,"duckwalk"):
         # it's a duck

This is as distinct from both 'if isinstance(ob,Duck)' and 'if 
implements(ob,IDuck)'.  That is, "duck typing" is determining an object's 
type by inspection of its method/attribute signature rather than by 
explicit relationship to some type object.




More information about the Python-Dev mailing list