Skip to main content

Timeline for answer to What is the difference between __str__ and __repr__? by wescpy

Current License: CC BY-SA 4.0

Post Revisions

17 events
when toggle format what by license comment
May 9, 2024 at 3:27 comment added wescpy Yep, I didn't know table-formatting was available... will convert that soon. As far as unrepresentable objects, yeah, repr() shows the default "object string" and its id(). I probably should've mentioned it and specify it's the default if you don't implement __str__() or __repr()__. I'll see if I can weave it into the response when I fix the table. Thx for the useful comments!
Oct 15, 2023 at 6:06 comment added wjandrea "repr() & __repr__() return a string representation of an object that is a valid Python expression" — Not always. Yes it's a goal, but some objects can't be meaningfully represented, like object for example: object()<object object at 0x7f4aa8b38f50>. I know other answers cover this and you're probably aware of it, but I found it strange you didn't mention it anywhere in this long explanation.
Oct 15, 2023 at 5:56 history edited wjandrea CC BY-SA 4.0
No need to repeat the question. Remove noise (refs: meta.stackoverflow.com/a/260778, meta.stackexchange.com/q/131009). No need to explain `print`. Typo.
Oct 15, 2023 at 5:45 comment added wjandrea Don't post pictures of text. Stack Exchange supports table formatting now if you want to use that.
Mar 8, 2023 at 21:48 history edited wescpy CC BY-SA 4.0
update link(s)
Feb 3, 2022 at 6:36 history edited wescpy CC BY-SA 4.0
clarity
Jan 26, 2022 at 23:08 history edited wescpy CC BY-SA 4.0
clarity
Nov 27, 2021 at 5:15 history edited wescpy CC BY-SA 4.0
fix typo
Nov 27, 2021 at 5:10 history edited wescpy CC BY-SA 4.0
clarity
Nov 16, 2021 at 20:31 history edited wescpy CC BY-SA 4.0
clarity
Jul 15, 2021 at 3:06 history edited wescpy CC BY-SA 4.0
clarity
Mar 22, 2021 at 19:33 history edited wescpy CC BY-SA 4.0
clarity
Dec 7, 2020 at 19:01 history edited wescpy CC BY-SA 4.0
clarity
Dec 7, 2020 at 18:55 history edited wescpy CC BY-SA 4.0
clarity
Aug 18, 2020 at 8:06 history edited wescpy CC BY-SA 4.0
clarity
Aug 18, 2020 at 8:01 history edited wescpy CC BY-SA 4.0
clarity
Aug 18, 2020 at 7:55 history answered wescpy CC BY-SA 4.0