Image for post
Image for post

Most of the times when we create python classes, we provide it with an __init__ function, or for folks who are proficient in other programming languages, constructors.

For the sake of visuality, here is a simple python class that defines a Student object:

As you can see, it is as simple as it gets… To create a Student object, all you need to do is to type in the 4 parameters: “first_name”, “last_name”, “birth_year”, “emergency_contact”.

Let’s see it in action:

It’s intuitive and good all in all, but what if we want to support different ways to create a Student object? For example, what if we want to be able to create a Student object by just passing in one string that includes all our 4 parameters? …


Mert Öztürk

Software Developer and Data Enthusiast 🐍