-26

Python 2 will be retiring soon, at the start of 2020. It has been recommended countless times to Python developers to port all of their old code to Python 3.

That being said, sometimes the site still receives new questions that include code written in Python 2. Is it acceptable to leave a comment somewhat resembling this:

Your code is written in Python 2, which will soon become obsolete. It is recommended that you upgrade your code to Python 3.

on those posts? Is this considered constructive behavior, and would leaving these comments help Stack Overflow as a whole move forward from Python 2 going into the next decade?

10
  • 21
    Will Python 2 stop working? Or will legacy applications still function as per usual?
    – fbueckert
    Sep 23, 2019 at 19:47
  • 1
    @fbueckert It will no longer be maintained (meaning if any bugs are found they won't be fixed). And Python 3 is more fully-featured and popular than Python 2.
    – miike3459
    Sep 23, 2019 at 19:47
  • 24
    That doesn't answer my question. We still have people using COBOL, and really old versions of other languages. How do we handle those?
    – fbueckert
    Sep 23, 2019 at 19:48
  • 2
    @fbueckert As far as I'm concerned the best course of action for those cases is to leave a polite comment like the one I detailed in the post, except language/version specific.
    – miike3459
    Sep 23, 2019 at 19:50
  • 15
    None of that changes that people use old languages all the time, and can't, or won't, update. It doesn't mean answers need an upgrade to continue to be useful.
    – fbueckert
    Sep 23, 2019 at 19:51
  • 7
    And how many users are supporting large python 2 code bases that don't have the resources to upgrade it to python 3? Just because it is out of support doesn't mean that people will suddenly stop using it. And that being said there are many warnings for any developer that is using python 2 that this is going to happening that would make a warning on stack overflow redundant.
    – Joe W
    Sep 23, 2019 at 19:53
  • 2
    One more way to look at it - canned comments are generally discouraged... so basically this comments will be automatically eligible for "no longer needed" or maybe even "unfriendly and unkind" (chances that someone who had to dig for ancient behavior in legacy code would feel welcome with suggested "you should have upgraded the code base" comment are … slim) Sep 23, 2019 at 19:58
  • If the question somehow indicates the asker is new to Python, I think these kind of comments are constructive. I would expand a bit more on the issue if I were to leave a comment though.
    – ayhan
    Sep 23, 2019 at 20:02
  • 1
    @ayhan that doesn't mean much, it could be a new employee who has been tasked with making a change to an existing python project who could already be pushing to migrate it to python 3 but has no ability to make it happen. Best to not use it just because they look like a new python coder
    – Joe W
    Sep 23, 2019 at 20:18
  • 1
    @JoeW I was referring to obvious cases where the asker is not stuck with legacy production code but instead playing with Python basics. It is quite common in the SO Python community to warn newcomers about Python 2 and it is mostly appreciated.
    – ayhan
    Sep 23, 2019 at 20:41

1 Answer 1

35

First of all: Python 2 questions are not going to be obsolete. Only Python 2 support from the Python core team is. You’d want to focus on informing people about that fact, instead.

You can do so, within reason; I only do so when it is clear the user is new to the language and I suspect they are learning on their own. At that point that person would actually benefit from switching to learning Python 3 instead. Try to have some resources ready, like Think Python, 2nd ed., if they need replacement materials to learn from. When answering, make this an addendum to your answer solving the Python 2 problem first. In short, follow the general advice on how to answer questions about outdated tech.

However, there is little point in telling this to anyone that is stuck with Python 2 for other reasons. Yes, support is going to end but if your boss is telling you to keep an aging production system going then it’s much more helpful to just answer their direct problem. In other words, don’t assume the question asker has a choice.

Whatever you do, do not go looking for existing posts. Someone that asked about Python 2 last month, last year, or in 2009 doesn’t necessarily use it today.

You must log in to answer this question.

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