Python 2 and Python 3 are mostly the same during our discussions. However there are some differences if you explore further. During this semester, we base our discussions and exercises on Python 3. We highlight some main differences here for your reference. To read further, you can click here
If you want to install modules for Python3, please use pip3
. To install in user mode, you can use
pip3 install --user {name-of-the-module}
Python 2’s print statement has been replaced by theprint()
function, meaning that we have to wrap the object that we want to print in parantheses.
Python 2 doesn’t have a problem with additional parantheses, but in contrast, Python 3 would raise aSyntaxError
if we called the print function the Python 2-way without the parentheses.
However, if we have multiple objects inside the parantheses, we will create a tuple, sinceprint
is a “statement” in Python 2, not a function call.
Python 2 has ASCIIstr()
types, separateunicode()
, but nobyte
type.
Now, in Python 3, we finally have Unicode (utf-8)str
ings, and 2 byte classes:byte
andbytearray
s.
You can follow the steps in this Link to set up both of them.