Alex Rivera | Logout

What is the difference between __str__ and __repr__?

Asked 2009-09-17T04:27:45.907
3836

What is the difference between __str__ and __repr__ in Python?

Edit
Report

1 Answer

16

From an (An Unofficial) Python Reference Wiki (archive copy) by effbot:

__str__ "computes the "informal" string representation of an object. This differs from __repr__ in that it does not have to be a valid Python expression: a more convenient or concise representation may be used instead."

answered 2009-09-17T04:28:52.177

Your Answer