Constructor Overloading in Python: Python 3.8 and Afterwards

adil
Dec 4, 2021

Did you know that since 3.8 you can overload the constructor method in Python?

Thanks to @functools.singledispatchmethod you can overload the constructor method

When I run the code in Python 3.8 I get this output:

BIOS *** Power supply
dict_items([('CPU', '3.0GHz'), ('RAM', '32GB')])
CPU - RAM - SSD
Motherboard
99999

An alternative approach:

Another alternative approach:

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

Responses (1)

Write a response

thanks! Didn‘t know this is possible.

--