Tag

Dunder

0 views collected around this technical thread.

Python Programming Learning Circle
Python Programming Learning Circle
Mar 19, 2025 · Fundamentals

Understanding Python Magic Methods: A Comprehensive Guide

This article explains Python's magic (dunder) methods, detailing their purpose, common special methods for initialization, comparison, arithmetic, container protocols, and other operations, and provides a practical code example to illustrate how they enable custom class behavior.

Code ExampleDunderMagic Methods
0 likes · 6 min read
Understanding Python Magic Methods: A Comprehensive Guide
Test Development Learning Exchange
Test Development Learning Exchange
Jul 18, 2024 · Fundamentals

10 Most Common Python Magic Methods with Practical Examples

This article introduces ten of the most frequently used Python magic (dunder) methods, explains their purpose, and provides clear code examples for __init__, __str__, __repr__, __add__, __len__, __getitem__, __setitem__, __iter__, __next__, __call__, __enter__, __exit__, __getattr__, __setattr__, and __new__, helping readers master Python’s special syntax.

DunderMagic MethodsOOP
0 likes · 7 min read
10 Most Common Python Magic Methods with Practical Examples
Python Programming Learning Circle
Python Programming Learning Circle
Apr 19, 2021 · Fundamentals

Understanding Python Magic (Dunder) Methods

This article explains Python's built‑in magic (dunder) methods—functions that start and end with double underscores—showing how they enable custom class behavior such as indexing, iteration, string representation, callable objects, context management, object creation, and attribute handling with clear code examples.

Callable ObjectsContext ManagersDunder
0 likes · 14 min read
Understanding Python Magic (Dunder) Methods
Test Development Learning Exchange
Test Development Learning Exchange
Dec 27, 2019 · Fundamentals

Understanding Python's Special Methods __len__ and __getitem__ with Example Code

This article explains Python’s double‑underscore special methods such as __len__ and __getitem__, demonstrates their implementation in a FrenchDeck class with example code, shows how they enable built‑in functions like len() and indexing, and further illustrates additional dunder methods using a Vector class.

DunderExample CodePython
0 likes · 4 min read
Understanding Python's Special Methods __len__ and __getitem__ with Example Code