Duck Typing

Duck typing is a concept in dynamic programming languages like Python, where the type of an object is determined not by its class name, but by its behavior or the methods and attributes it defines. The term “duck typing” comes from the phrase “if it looks like a duck, swims like a duck, and quacks like a duck, then it probably is a duck.” In Python, duck typing means that an object’s suitability for a given task is determined by the presence of specific methods or attributes, rather than its type....

April 6, 2023 · aaron