3 Special Methods for Object String Formatting in Python

Formatting Python custom objects in a user-friendly way

Yong Cui
Better Programming
Published in
5 min readFeb 15, 2021

--

The word “cool” written in light
Photo by Collin Armstrong on Unsplash

In Python, underscores have special meanings when they’re used in attribute names. A particular form is the use of two pairs of double underscores with one before and the other after the attribute name, which are termed special methods or magic methods.

--

--

Work at the nexus of biomedicine, data science & mobile dev. Author of Python How-to by Manning (https://www.manning.com/books/python-how-to).