When To Use __repr__ vs __str__?
# When To Use __repr__ vs __str__
# Emulate what the std lib does:
>>> import datetime
>>> today = datetime.date.today()
# Result of __str__ should be readable:
>>> str(today)
'2022-07-11'
# Result of __repr__ should be unambiguous:
>>> repr(today)
'datetime.date(2022, 7, 11)'
# Python interpreter sessions use
# __repr__ to inspect objects:
>>> today
datetime.date(2022, 7, 11)?