[Python-3000] PEP 3100 Comments

Fredrik Lundh fredrik at pythonware.com
Mon May 8 15:40:21 CEST 2006


Thomas Wouters wrote:

> Duck typing isn't "ask the object whether it can do this". Duck typing is
> "do this".

that's your own definition, by the way.  the usual definition is the one in the Python
tutorial:

    Duck Typing

    Pythonic programming style that determines an object's type by inspection
    of its method or attribute signature rather than by explicit relationship to
    some type object ("If it looks like a duck and quacks like a duck, it must
    be a duck.") By emphasizing interfaces rather than specific types, well-
    designed code improves its flexibility by allowing polymorphic substitution.
    Duck-typing avoids tests using type() or isinstance(). Instead, it
    typically employs hasattr() tests or EAFP [Easier to Ask Forgiveness
    than Permission] programming.

looks like you're confusing duck typing with EAFP.  don't do that; they may be
related, by they are two different things.

</F> 





More information about the Python-3000 mailing list