News for hackers. Stuff that matters.
Re:The PEPs of Python 3.9 by pdonis on Thursday May 28, 2020 @03:57PM (#23341829)
> The same .py file runs under python2 and python3?

Sure, as long as it doesn't contain any syntax or spellings which are incompatible between the two. That's a fairly large subset of the language.

> if you bring a Python2 script and feed it to a Python3 interpreter, no, in general that will not work. They simply aren't the same language. Even a simple "print x" will do you in.

But this will work:

    from __future__ import print_function
    print(x)
This is valid under both Python 2 and Python 3.

Also, as I said above, there is a pretty large subset of the Python language that has the same syntax and spellings in both Python 2 and Python 3, and any script or module or package that only uses that subset will run just fine under both interpreters. You are drastically underestimating both the size and the usage of this subset of the language.

There are no comments on this comment yet.