3

It seems these question are really closely related.

  1. Purpose of __repr__ method?
  2. Understanding repr( ) function in Python
  3. What is the difference between __str__ and __repr__?
  4. __repr__ vs repr

Can they be considered as a duplicate of one of them since the topics they are about seem to be interrelated? If not, what are the exact differences between each of them that makes them non-duplicates?

4
  • 25
    It's not very useful to ask "Why haven't the volunteers volunteered their time and effort into closing these". I know you meant that as "Gotcha! It must mean there is deliberate inconsistency that people planned." whereas the actual reason usually is that there was no planning. And searching for the correct duplicate can be exhausting. Many a time I've tried to find a good duplicate for something just to quit in frustration. Does that mean there was no duplicate? Does it mean there was conspiracy to not close a question? No, just a limit of how much I'm willing to invest. Commented Aug 6 at 8:47
  • 3
    Also adding to VLAZ's point the questions you've linked aren't actually duplicates of each other. Each of them is about a different (but related thing). Yes __repr__ and repr are related (Because the implementation of repr uses the __repr__ method of the objects passed to it), that doesn't mean we can't have separate questions about them. Maybe we could discuss about that repr vs __repr__ question though, since we have two separate questions about each of those it could potentially be closed as duplicate of those. Commented Aug 6 at 8:53
  • 1
    Probably yes, but at least one Python expert would have to rise to the challenge of picking the one with the best answers. Commented Aug 6 at 11:24
  • 3
    @VLAZ Or, the question is saying something like "perhaps this wasn't considered yet, let's consider it now". And if you don't want to volunteer your time towards considering it, you don't need to respond to the invitation. Commented Aug 6 at 17:27

2 Answers 2

-2

My personal philosophy on closing duplicates boils down to:

If two pages contain a reasonably similar context/scope and seek the same resolving advise, then close the less-valuable page using the more valuable page.

Page value is a multifaceted evaluation. A question with a minimal, complete reproducible example is ideal. A page with the most comprehensive, diverse, and modern insights represents an ideal dupe target. Some pages are wildly popular in terms of their page load tally, but that can sometimes occur due to vague, clickbait titles rather than the overall quality of the page.

With this in mind, I have repeatedly promoted the idea of replacing:

"Duplicate This question has been asked before and already has an answer."

with

"Resolved Elsewhere Recommended insights can be found on another page."


By focusing on "question identicality" to justify a duplicate closure, it is too easy for audiences to quibble over question nuance rather than the crux of the sought insights. Instead, first determine if the two questions share common context (e.g. environment, language, data structure), second determine relative "resolution identicality".


A page closed as a duplicate is not necessarily the end of the curation process. After a page is closed, question identicality does matter.

  • If a closed duplicate question is not well-asked or has no redeeming uniqueness versus the dupe target, then:
    • If answers have no redeeming value or uniqueness versus the answers on the dupe target, then the page should deleted,
    • If answers contain value not found on the dupe target, then answerers should be urged to transfer their answer (manually) to the dupe target or a page merge may be called for.
  • If a closed duplicate question is significantly unique in its context/scenario and is well-asked, then it can serve as a "signpost". See also: Change the stigma regarding signposts
5

In short, no.

  • "Understanding repr( ) function in Python" is effectively asking about Python fundamentals (quoting, variables)
  • "__repr__ vs repr" is effectively asking about whether to call dunder methods (and there's a separate existing question about that)
  • "Purpose" is asking a beginner-level question
  • "Difference" is asking an intermediate-level question

Original answer and details

I haven't reviewed the questions in detail yet, but just looking at the titles, they don't look like duplicates. I'll paraphrase them to make it clear as well as sorting by score:

  1. __repr__ vs __str__ (3813)
  2. What is __repr__? (208)
  3. What is repr()? (163)
  4. __repr__ vs repr() (3)

Yes, they all cover repr() or __repr__, but in different respects.

Beyond the title, I assume they're asking something like:

  1. How does "the 'official' string representation of an object" compare to "the 'informal' or nicely printable string representation of an object"? And how do I write them? (What details should go in one and not the other?)
  2. How do I write "the 'official' string representation of an object"? (a simpler question than the previous one)
  3. What is "a printable representation of an object"? (a more basic question than the previous one)
  4. What's the difference between a magic (special) method and the function that calls it?

After review

  1. What is the difference between __str__ and __repr__? - The question body just restates the title. The top answer talks about how to implement the magic methods and their purpose. It's basically exactly what I expected. I guess there's a reason this is the top one by a long shot ;)
  2. What is the purpose of the __repr__ method? - This one's even simpler than I thought. It's not asking anything deeper than the title. The top answer basically just restates the docs.
  3. Understanding repr( ) function in Python - This one's messy. The asker doesn't understand both 1) how quoting works and 2) how variables work.
    • Renamed: Why does the repr() of a string have two sets of quotes? And why don't I get the object back when I eval() it?
  4. __repr__ vs repr - It asks about calling .__repr__() directly (which is a no-no).
3
  • 4
    ... but duplication on Stack Overflow is still based on answers, not questions. There are very rich answers under several of these questions that might cover all bases given the rather general nature of the questions. Commented Aug 7 at 11:46
  • 1
    @Gimby "duplication on Stack Overflow is still based on answers, not questions" - Sort of. Even if the answers match, the questions still need to be "closely related" in order for them to be considered duplicates. Otherwise, readers will get confused by being directed towards what seems to be a totally different question. On the other hand, I just edited to add that question 4 was appropriately closed as duplicate of one of the others. Overall, this is a grey area. Commented Aug 7 at 12:25
  • 4
    @Gimby see: Does the same answer imply that the questions should be closed as duplicate? Commented Aug 7 at 13:18

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.