Posted on

Duck typing in python

When I see a bird that walks like a duck and swims like a duck and quacks like a duck I called that bird a duck

J. W. Riley

The Python code language is dynamically typed. In many languages (C++, Java) you do need to explicitly declare the types of variables. Python uses duck typing for all operations (function calls, method calls, and operators). You can treat an object as a duck. It raises a TypeError at runtime if an operation cannot be applied to an object because it is of an inappropriate type.