I am doing some analysis of the source code and should know if the source code was written for only one version (python 2 or python 3). Ideally, without running a script with both time modes and checking if this throws an exception. I do not want to check which of them are installed as here .
Maybe I'm looking for some kind of linter that validates typical python 2 code, like
type hello
instead
print (hello)
It is my problem. I read a file like this:
for i in range(10):
print(True) if (i % 2 == 1) else print(False)
which works fine under python 3 and causes an error for python2
print(True) if (i % 2 == 1) else print(False)
^
SyntaxError: invalid syntax
Maybe with compiler , but it is marked as deprecated
linter, , python 2 3? ?