The Python Oracle

How to print instances of a class using print()?

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: Darkness Approaches Looping

--

Chapters
00:00 Question
00:37 Accepted answer (Score 867)
01:26 Answer 2 (Score 177)
02:59 Answer 3 (Score 83)
03:19 Answer 4 (Score 81)
03:51 Thank you

--

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

Accepted answer links:
[__str__]: https://docs.python.org/reference/datamo...
[__repr__]: https://docs.python.org/reference/datamo...
[repr()]: https://docs.python.org/library/function...

Answer 2 links:
[As Chris Lutz explains]: https://stackoverflow.com/a/1535336/3357...
[repr()]: http://docs.python.org/library/functions...
[is roughly equivalent]: https://stackoverflow.com/questions/4877...

Answer 3 links:
[@Keith]: https://stackoverflow.com/a/50917475/105...

--

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

--

Tags
#python #class #printing #object

#avk47