J
J
Jekson2018-08-27 11:27:09
Python
Jekson, 2018-08-27 11:27:09

Difference between __repr__ and __str__ in Python3?

Can anyone explain on the "fingers" the difference between these methods, in what cases should one or the other be used?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ivan Sharapenkov, 2018-08-27
@Lepilov

https://ru.stackoverflow.com/questions/534440/%D0%...
__repr__ is the representation of an object if you just type its name into the console. It's closer to the car. Useful for debugging to find out information about an object.
__str__ - Printed when using the print method on an object. A human-friendly string representation of an object.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question