__repr__ should return a printable representation of the object, most likely one of the ways possible to create this object. See also documentation for repr() (which calls __repr__). __repr__ is more for developers, while __str__ is for end users.

A simple example (interactive):

class Point:
    def __init__(self, x, y):
        self.x = x
        self.y = y
    def __repr__(self):
        cls = self.__class__.__name__
        return f'{cls}(x={self.x!r}, y={self.y!r})'
p = Point(1, 2)
p

Output:

Point(x=1, y=2)
Answer from Miki Tebeka on Stack Overflow
🌐
W3Schools
w3schools.com › python › python_magic_repr.asp
Python __repr__() Method
Python Examples Python Compiler ... user-facing text shown when you print an object, __repr__() controls a more technical representation, meant for developers....
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-repr-function
Python repr() Function - GeeksforGeeks
July 23, 2025 - The repr() function in Python is used to return a string representation of an object that can be used to recreate the object when passed to eval().
🌐
Codecademy
codecademy.com › docs › python › built-in functions › repr()
Python | Built-in Functions | repr() | Codecademy
June 2, 2023 - The repr() function returns a printable string describing the object that is passed in. In other words, it returns the string representation passed implicitly to the eval() function.
🌐
Programiz
programiz.com › python-programming › methods › built-in › repr
Python repr()
Online Python Online JavaScript Online SQL Online Java Online HTML Online C Online C++ Online C# Online PHP Online Swift Online Kotlin Online TypeScript Online Go Online Rust Online Scala Online Dart Online R Online Ruby ... The repr() function returns a printable representation of the given object.
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-__repr__-magic-method
Python __repr__() magic method - GeeksforGeeks
July 23, 2025 - The __str__() method is defined to return a human-readable string representation of the instance, while the __repr__() method is defined to return a string representation of the instance that can be used to recreate the object.
Find elsewhere
🌐
DataFlair
data-flair.training › blogs › python-repr-function
Python repr Function With Example | repr vs str in Python - DataFlair
April 14, 2026 - To Python, this is a class that controls what it returns for its instances via the __repr__() magic method.
🌐
w3resource
w3resource.com › python › built-in-function › repr.php
Python repr() function - w3resource
August 19, 2022 - A printable representational string of the given object.
🌐
Quora
quora.com › What-is-repr-in-Python
What is ''__ repr __'' in Python? - Quora
Answer (1 of 7): __repr__ is a ‘magic’ method that can be implemented on a class in Python. The __repr__ method (normally called dunder_repr - double underscore repr) is used to return a string which should ideally be a representation of the relevant instance - i.e something that in theory ...
🌐
Scaler
scaler.com › home › topics › what is python __repr__?
What is Python __repr__? | Scaler Topics
May 4, 2023 - If one prints an instance or passes it to format as in str.format, if an \_\_str__ method has been defined, it will be called, otherwise, it will be \_\_repr__ that gets used. The \_\_repr__ function is called by the built-in repr function and is what is “echoed” onto one’s Python shell screen when evaluating an expression that returns an object.
🌐
Codecademy
codecademy.com › docs › python › dunder methods › __repr__()
Python | Dunder Methods | __repr__() | Codecademy
May 20, 2025 - In this example, the __repr__() method returns a string that represents the Person object in a way that could be used to recreate the object. When the object is printed or included in a collection, Python calls this method to obtain a string representation.
🌐
TutorialsPoint
tutorialspoint.com › What-does-the-repr-function-do-in-Python-Object-Oriented-Programming
Python repr() Function
June 15, 2020 - While str() is mainly used to create human-readable strings, repr() provides a string that, when passed to the eval() function, can recreate the original object. Following is the syntax of Python repr() function −
🌐
BelieveMy
believemy.com › python glossary › __repr__
What is __repr__ in Python? | Python glossary
February 9, 2026 - The main goal of __repr__ is to provide an unambiguous representation of the object, ideally precise enough for a developer to recreate the object from that string. If you want to deepen your knowledge of Python and master special methods, we recommend following our comprehensive Python course which covers object-oriented programming in detail.
🌐
Codecademy
codecademy.com › forum_questions › 551c137f51b887bbc4001b73
Can someone explain what __repr__() does a little more thoroughly please? | Codecademy
When an expression is enclosed in backquotes, __repr__ is called for the appropriate type to represent the resulting object, when you print it. If you print the value of an expression without backquotes, then __str__ will take precedence over __repr__ to represent the object as a str.
🌐
Python Geeks
pythongeeks.org › python geeks › learn python › python repr() with examples
Python Repr() with Examples - Python Geeks
June 11, 2021 - When a class is passed to the repr() function, it returns a string containing the name of the passed class and the id of the passed class’s instance. ... We can use this to our advantage and override the __repr__() method to make it return a string of our choice and create custom objects. Since Python is an object-oriented programming language, it gives us the ability to override methods.
🌐
Initial Commit
initialcommit.com › blog › repr-in-python
__repr__ in Python - Initial Commit
The difference is that string will ... On the other hand, the repr() function prints out the "string representation" of an object, which usually includes quotes surrounding it....
🌐
DigitalOcean
digitalocean.com › community › tutorials › python-str-repr-functions
How To Use the __str__() and __repr__() Methods in Python | DigitalOcean
Learn Python’s str() and repr() methods in depth. Explore examples, best practices, and real-world tips for clarity and debugging.
🌐
Python Pool
pythonpool.com › home › tutorials › python repr(): __repr__, debugging, and string representations
Repr(): Discovering a Special Method in Python
July 13, 2026 - Lists, tuples, sets, and dictionaries generally use repr() for their members. This is why a good __repr__ improves an entire debugging output rather than only a direct print or repr call. Some built-in repr strings resemble valid Python expressions, but the protocol does not require that every representation be reconstructable.