PYTHON PROGRAMMING

Python OPP, and Why repr() and str() Matter

The article discovers various faces behind using repr() and str() for Python classes

Marcin Kozak
Towards Data Science
14 min readNov 3, 2023

--

Python classes need string representation to provide the user and the developer with more information than just a mess of letters. Photo by Surendran MP on Unsplash

Python classes have many faces. For instance, you can create an empty class:

class MyClass:
pass

--

--

A full professor, interdisciplinary researcher, data scientist, statistician, Python, R and Go developer, open-source contributor — and a devoted writer