Yesterday, someone posted a question asking how to require a specific version of Python so that his script would fail gracefully when executed using an earlier version of Python that did not support a certain syntax.

Later, the question was closed as a duplicate of "How do I check what version of Python is running my script?" -- this was an incorrect duplicate, because finding the version alone would not solve the original problem.

Consider the following Python script:

with open('./t.py', 'r') as f:
   print len(f.readlines())

The user was saying that, when someone runs this script in Python < 2.6, it will fail with an error like:

$ python w.py # using Python 2.5
w.py:5: Warning: 'with' will become a reserved keyword in Python 2.6
  File "w.py", line 5
    with open('./t.py', 'r') as f:
SyntaxError: invalid syntax

He wanted to have it fail more gracefully.

Someone suggested that all you have to do is exit if the version is wrong:

import sys
if sys.version_info < (2,6,0):
   print "this isn't going to work"

with open('./t.py', 'r') as f:
   print len(f.readlines())

This is incorrect, because it produces the same error (the error occurs when lexing/compiling, not at runtime). However, the concept of checking the version must have been what caused users to close the question.

So, the answers (1, 2, etc.) were merged to this question about detecting the version of Python, which a) doesn't address the original question and b) would not have helped the original question either. (Answer 1 was a correct answer, btw)

If anything, it should have been merged with perhaps this question -- I don't think it should have been merged at all, but that's not up to me to decide.

Then the question I have (to which I don't really expect an answer), is how did this happen? Did a moderator see the single close vote and decide to merge it, without reading (or understanding) the full question? Or was this merge decided by more than one person?

I see now that it was fully voted to close as a duplicate of the wrong question. That's the community's fault. The question certainly could have been worded a lot better, but I think this snippet makes it clear that it isn't just a question of how to check the Python version:

... the problem I have is the interpreter on a 2.4 machine reads the file and sees a "finally" at the end of my try loop and errors out before it gets far enough into execution for my if statement to handle the version mismatch.

The title ("Determing Python version at runtime") was obviously the only part that the closers read.

The question:

a. Should not have been closed (but I'd settle for having it edited and reopened)
b. Should not have been merged, much less with the wrong question.

This is the kind of thing that stops people from coming back to a website/community. It's one thing to close a question like "how do i make stack in c", but this individual asked a decent question and unfairly had his question closed, locked, and merged.

Can the answers be un-merged? If not, can the question be unlocked so that the individual can receive a proper answer to his question?

  • 1
    blog.stackoverflow.com/2010/06/improved-question-merging -- Jeff said it's theoretically reversible, but that sounds like there isn't a direct process or function for it at the moment.
    – Jon Seigel
    Commented Jun 11, 2010 at 16:41
  • Do you have a link to the original? Commented Jun 11, 2010 at 17:13
  • 2
    @Bill I think the question is this one: stackoverflow.com/questions/3016157/… It's the first one I found that was asked yesterday and was merged into the linked question.
    – Grace Note StaffMod
    Commented Jun 11, 2010 at 17:17
  • 1
    Another example of why merging and even closing as a "duplicate" are done far too heavy-handedly. Just leave the questions alone.
    – Randolpho
    Commented Jun 11, 2010 at 17:37
  • (@Bill) @ccornet: Yes, that's the original question. Thanks for finding it. Commented Jun 11, 2010 at 17:41

2 Answers 2


The answer is in the revision history:


Which says it was merged from this question:

Determing Python version at runtime

  • I should have realized in the first place that I could see where the merges came from, by checking the revisions. Thanks. Commented Jun 11, 2010 at 22:01

The question was closed by 5 people before being merged.

Both that question and the question it duplicated cover the same ground, and I wouldn't find any content on the newer question's answers out of place on the older question. The exact phrasing of the answers can be out of place, however, because they're responding to a question phrased slightly differently, but that's true for all question merges.

In this case, I'd personally have left it closed as a duplicate without merging, but couldn't say it was a big issue or even a mistake to merge. However, merging seems to have been pressed into service for something it wasn't designed to do originally: combining answers on questions that independently don't particularly add value to the site.

Some way to encourage answerers to revise and post their answers on the older question (or not, if they feel their points are sufficiently covered) and then deleting the duplicate would consolidate the information. Perhaps notifying users when their answers get merged, so they can do exactly that (i.e. edit or delete), would help, as they might have answered before the duplicate was identified. (If they answer after the duplicate is identified while agreeing it's a duplicate and not expecting their answer to be deleted, then I'm flabbergasted, but I have seen that...) But I've pretty much given up on trying to improve this part of the system.

  • 1
    The questions don't exactly cover the same ground. They have similar titles and a slight overlap. The older question was "how do I find out the version of Python", and the newer question was "how do I make a Python script fail gracefully when the syntax isn't supported in a given version" -- a significant superset of the older question. Commented Jun 11, 2010 at 22:05
  • @Mark: Dealing with X follows naturally from determining X. "I wouldn't find any content on the newer question's answers out of place on the older question."
    – Gnome
    Commented Jun 11, 2010 at 22:42

Not the answer you're looking for? Browse other questions tagged .