Interface and duck typing woes
Nobody
nobody at nowhere.com
Thu Aug 29 05:41:39 EDT 2013
On Wed, 28 Aug 2013 18:09:22 -0300, Joe Junior wrote:
> Of course I don't want to check isistance(), I like duck typing, but
> should I check if hasattr() and callable() before adding to the container?
That won't tell you if the object has a quack() method but with
incompatible semantics (e.g. wrong number or types of arguments).
> What is the pythonic way to deal with it?
Ignore it. If you want early type checking, use a statically-typed
language.
More information about the Python-list
mailing list