Syntax
__str__ vs __repr__ in Python and When to Use Them
· ☕ 3 min read
In Python, the __str__ and __repr__ methods are used to define human-readable and unambiguous string representations of objects. Both of these methods are called by the str() and repr() functions respectively, and the goal of each is to provide a string representation of the object in question.
https://d2kbulfv42d43j.cloudfront.net/2023/Q1/__str__vs__repr.png