Duck-typing?
If it walks like a duck, quacks like a duck and swims like a duck: it's a duck.
That above is the simple definition of duck-typing...
For further actions, you may consider blocking this person and/or reporting abuse
Nice hack! But here is some little critique because the title implies a broader use for it.
Duct typing is awesome, but some Duck objects are dangerous, because
import this
) explicit is better than implicit. Python avoids strong typing because it is mostly practical to allow anything that walks like a Duck, but the Duck itself should be implemented at some point, so the reader knows what it is about.NamedTuple
from thecollections
module is often a good fit for such use.You points are much appreciated, Ali! Thanks!
I do understand that the title is generic while the content only covers a smaller ground. I'm sorry for that. And to be fair, readability is a first-class concern of mine (I have a much over due unpublished article on the matter), thus the context-through-variable-name.
Also, I thought about using the
NamedTuple
but wasn't sure about the.
accessor (and apparently was too lazy to search) which led me to the duck.