The Python Oracle

How to create a custom string representation for a class object?

Become part of the top 3% of the developers by applying to Toptal https://topt.al/25cXVn

--

Music by Eric Matyas
https://www.soundimage.org
Track title: Quirky Dreamscape Looping

--

Chapters
00:00 Question
00:29 Accepted answer (Score 340)
01:09 Answer 2 (Score 37)
01:20 Answer 3 (Score 27)
02:12 Answer 4 (Score 9)
03:40 Thank you

--

Full question
https://stackoverflow.com/questions/4932...

Accepted answer links:
[__str__()]: https://docs.python.org/3/reference/data...
[__repr__()]: https://docs.python.org/3/reference/data...

Answer 4 links:
[Ignacio Vazquez-Abrams' approved answer]: https://stackoverflow.com/a/4932473/2404...
[six]: https://pypi.org/project/six/

--

Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...

--

Tags
#python #class

#avk47