经常在python的书中会提到 一个叫duck typing 的词,但它究竟是什么意思呢?
as an interpreted and dynamically typed language, there is no ‘compile time’ checking of data types in Python, and no formal requirement for declarations of abstract base classes. instead programmers assume interpreter will understand what their intention is and can determine the type of variable based on the context, if failed a run-time error will be raised.
the name ‘duck typing’ comes from a poet James Whitcomb Riley.
‘when i see a bird walks like a duck and swims like a duck and quacks like a duck, i call that a duck’