Skip to main content

2 docs tagged with "duck-typing"

View all tags

Interfaces in Python: Informal and Formal

In Object-Oriented Programming, an interface is a description of the actions an object can do. It's a contract or a blueprint that defines a set of methods that a class must implement. For example, any object that acts as a "Data Parser" should have a .parse() method, regardless of whether it's parsing a PDF, a website, or a text file.

Polymorphism: Method Overriding and Duck Typing

We've learned about inheritance and how a child class can inherit attributes and methods from a parent class. Now we're going to explore polymorphism, a powerful concept that allows us to treat objects of different classes in a similar way.