Tagged articles
6 articles
Page 1 of 1
Code Mala Tang
Code Mala Tang
Aug 23, 2025 · Fundamentals

Decoding Python’s Underscore Conventions: From Throwaway Variables to Dunder Methods

This article explains the meaning behind Python’s various underscore patterns—single underscores for throwaway variables, leading underscores for internal use, double leading underscores for name‑mangling, dunder methods for special behavior, and trailing underscores to avoid keyword conflicts—helping developers write clearer, more idiomatic code.

Naming ConventionPythoncode style
0 likes · 6 min read
Decoding Python’s Underscore Conventions: From Throwaway Variables to Dunder Methods
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-methodsprogramming
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 ObjectsIteratorsPython
0 likes · 14 min read
Understanding Python Magic (Dunder) Methods
MaGe Linux Operations
MaGe Linux Operations
Sep 30, 2020 · Fundamentals

What Do Single and Double Underscores Really Mean in Python?

This article explains the five underscore naming patterns in Python—single leading, single trailing, double leading, double leading and trailing, and a solitary underscore—detailing their conventions, the name‑mangling mechanism, and how they affect class attributes and imports.

PEP 8Pythondunder
0 likes · 12 min read
What Do Single and Double Underscores Really Mean in Python?
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.

Object-OrientedSpecial Methodsdunder
0 likes · 4 min read
Understanding Python's Special Methods __len__ and __getitem__ with Example Code