What is the difference between __str__ and __repr__?
- A __str__ is for end users; __repr__ is unambiguous and aimed at developers
- B __repr__ is for users
- C They are identical
- D __str__ is required in every class
Answer
__str__ is for end users; __repr__ is unambiguous and aimed at developers
If __str__ is missing Python falls back to __repr__, but not the reverse. Always define __repr__ for classes you will debug.





