Reputation: 43
I'm looking at some Python scripts on GitHub, but the developer doesn't specify what version (2.7 or 3.x) of Python is required.
Is there any way to tell? What type of execution errors should I look out for when a Python script fails due to version mismatch?
Upvotes: 4
Views: 119
Reputation: 16476
I found this article useful. It shows almost all syntax differences between python2 and python3. by looking at it you should easily figure out. click
Some other new features like walrus operator or f-string are also for python3.
Upvotes: 1
Reputation: 563
A version mismatch between Python 2 and 3 is fairly simple to find.
In python 2, print
is used without brackets, for example: print "hello"
While in python 3, print
is used with brackets, such as: print("hello")
Python also frequently has easy-to-read errors for differences in such where the error would end with did you mean X?
Also to input something in the command line, python 2 uses raw_input
while python 3 uses input
Upvotes: 1