Advance Python - Dander methods

avatar

NaN years ago

A class in python has many inbuilt methods that are used to perform fixed actions. These actions are not quite popular but these methods can be used to create custom classes.


In Python, Dunder methods are inbuilt methods of the class that can be used to create custom classes and their names start and end with double underscores. These methods are also called magic methods.


Examples:

def __init__(self, parameters):
def __str__(self):
def __delitem__(self, name):


Dunder methods provide a simple way to make objects behave like built-in types. That means you can avoid ugly, counter-intuitive, and nonstandard ways of performing basic operators. To implement dunder in python and learn in detail about dunder methods, please use resources.

approvedApproved by experts
Advance Topics

Neuton's Mission

We are a team of young and enthusiastic people who are passionate about education and want to help students to learn the skills they need to succeed in life. If you want to support us, please join our community.

phonephonephonephonemail