Table of Contents
Python Tutorial
Table of Contents
Python Tutorial
Dunder Methods in Hindi
What is Dunder Methods
Python में कुछ ऐसे pre-defined methods होते है जो specific situations में automatically call हो जाते है, इन methods को Dunder Method कहा जाता है। dunder methods के आगे और पीछे double underscore “__” लगा होता है। इन methods को “Magic Method” के नाम से भी जाना जाता है।
Dunder methods का use हम classes and Objects मे करते है और कहीं इसका use आपको जल्दी नहीं मिलेगा।
Commonly Used Dunder Methods
Dunder Function | Purpose | Small Example |
__init__(self, …) | Constructor – object banate समय call होता है | obj = MyClass() |
__del__(self) | Destructor – object delete होते समय call | del obj |
__str__(self) | Human readable string (print) | print(obj) |
__repr__(self) | Official string (debugging/logging) | repr(obj) |
__len__(self) | Object की length बताता है | len(obj) |
__getitem__(self, key) | Indexing support देता है | obj[0] |
__setitem__(self, key, value) | Index पर value assign करता है | obj[1] = 10 |
__delitem__(self, key) | Index वाली value delete करता है | del obj[2] |
__iter__(self) | Iterable बनाता है | for x in obj: |
__next__(self) | Next value return करता है | next(obj) |
__call__(self, …) | Object को function की तरह call कर सकते हैं | obj() |
__contains__(self, item) | Membership test | if 5 in obj: |
__eq__(self, other) | Equal (==) operator | obj1 == obj2 |
__lt__(self, other) | Less than (<) operator | obj1 < obj2 |
__gt__(self, other) | Greater than (>) operator | obj1 > obj2 |
__add__(self, other) | Addition (+) operator | obj1 + obj2 |
__sub__(self, other) | Subtraction (-) operator | obj1 – obj2 |
__mul__(self, other) | Multiplication (*) | obj1 * obj2 |
__truediv__(self, other) | Division (/) | obj1 / obj2 |
__floordiv__(self, other) | Floor Division (//) | obj1 // obj2 |
__mod__(self, other) | Modulo (%) | obj1 % obj2 |
__pow__(self, other) | Power (**) | obj1 ** obj2 |
__enter__(self) | Context manager start | with obj: |
__exit__(self, exc_type, exc_val, exc_tb) | Context manager end | with obj: |
उम्मीद करते है कि आपको Dunder Methods अच्छे समझ मे आ गया होगा। अपने learning को continue रखने के लिए next button पर click करे,
- All Posts
- Artificial Intelligence
- Computer Fundamentals
- Computer Networks
- Data Analytics
- Data Science
- DBMS
- Deep Learning
- Digital Electronics
- DSA with Python
- Excel
- Exercise
- Git & Github
- Machine Learning
- Matplotlib
- Natural Language Processing
- NumPy
- Operating System
- Pandas-s
- Power BI
- Python Tutorial
- Scikit-learn
- Seaborn
- SQL & MySQL

Table of Contents All Chapters 1. Personal Area Network 2. Local Area Network 3. Campus Area Network 4. Metropolitan Area...

Table of Contents All Chapters 1. Data Communication 2. Types of Data Communication 2.1. Simplex 2.2....

Table of Contents All Chapters 1. Special Logic Gate 2. XOR Gate 2.1. XOR Gate Truth Table 3....

Table of Contents All Chapters 1. Universal Logic Gates 2. NOR Gate 2.1. NOR Gate Truth Table 3....

Table of Contents All Chapters 1. Logic Gate 2. AND Gate 2.1. AND Gate Truth Table 3. OR...

Table of Contents All Chapters 1. Simplification 2. Simplification using Boolean Algebra Theorems 3. Simplification using K-map Digital Electronics...

Table of Contents All Chapters 1. Identity Laws 2. Null Laws 3. Domination Laws 4. Idempotent Laws 5. Complement Laws...