3 ms·
How do these work for very old versions of python? $ python3.5 since-3.6.py File "since-3.6.py", line 1 0_0 # Python >= 3.6 is required Thi
by seniorsassycat 4y ago
How do these work for very old versions of python?
$ python3.5 since-3.6.py
File "since-3.6.py", line 1
0_0 # Python >= 3.6 is required
This error means python 3.5 knows the syntax is valid in 3.6 which is plausible, but why would `python2.4 since-3.6.py` have a useful error message?
Edit: the comment is included in the source and python prints the whole line
0_0 # use python 3.6 or greater
- mlyle 4y agoPython 3.5 doesn't know the syntax is valid in 3.6. It knows it's invalid python 3.5 syntax, and then throws the exception. We see the comment in the process. % python2 since_3.6.py File "since_3.6.py", line 1 0_0 # Python >= 3.6 is required ^ SyntaxError: invalid syntax % python2 --version Python 2.7.18
- anonymoushn 4y agoThe error message is a comment in the code, so python2.4 just has to print the line with the syntax error
- aaronmdjones 4y ago> This error means python 3.5 knows the syntax is valid in 3.6 It doesn't. This relies on the interpreter printing the whole line that contains a syntax error, including the comment on it.
- kazinator 4y agoBut that's not an error message; it's just a copy of the offending line in the file! $ python2 Python 2.7.17 (default, Feb 27 2021, 15:10:58) [GCC 7.5.0] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> 0_0 # Python >= 3.6 is required File "<stdin>", line 1 0_0 # Python >= 3.6 is required
- kevsim 4y agoThat's the point. Since it can't actually parse the file, this is as good as it gets. It at least gets something on the screen that says "Python >= 3.6 is required" which is better than nothing.
- dotancohen 4y ago$ python2 --version Python 2.7.18 $ python2 py36.py File "py36.py", line 1 0_0 ^ SyntaxError: invalid syntax