Skip to main content

Command Palette

Search for a command to run...

Python Dunder Magic 🐍

Updated
•1 min read•View as Markdown
Python Dunder Magic 🐍
S

Senior Software Engineer. Fullstack Developer.

Dunder methods in Python not only helps in operator overloading, but it gives the power to instantiate a class however we want (talking about __new__ method).

In my opinion, most important “Dunder” or “Magic” methods that everyone should consider while building a class are:

✔ __new__
✔ __repr__
✔ __getattr__ and __setattr__
✔ __iter__ and __next__
✔ __enter__ and __exit__

What are some of your most commonly used dunder methods that you consider while designing a class ?


Just starting you Open Source Journey ? Don't forget to check out Hello Open Source

Want to ++ your GitHub Profile README ? Check out Quote - README

Want to make a simple and awesome game from scratch ? Check out PongPong

Till next time !

Namaste 🙏