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.


_______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to