312
A Installation and Use of Python
• Matplotlib 4 [7, 8] for plotting
• IPython 5 [21, 22] for interactive computing
• SymPy 6 [2] for symbolic mathematics
• Spyder 7 if you want to write and run your programs as we (primarily) do in this
book.
In addition, allthough not used herein, the following packages might be of interest
to you (probably at some later stage, if you are a newbie):
• SciTools 8 [13] for add-ons to NumPy
• ScientificPython 9 [26] for add-ons to NumPy
• pytest 10 or nose 11 for testing programs
• pip 12 for installing Python packages
• Cython 13 for compiling Python to C
• SciPy 14 [9] for advanced scientific computing
Converting a Python 2 Program to Python 3
Python comes in two versions, version 2 and 3, and these are not fully
compatible. However, for the programs in this book, the differences are very
small, the major one being print, which in Python 2 is a statement like
print ’a:’, a, ’b:’, b
while in Python 3 it is a function call
print( ’a:’, a, ’b:’, b)
The code in this book is written in Python 3.6. However, you may come
across code elsewhere that is written in Python 2, and you might prefer to
have that code in Python 3. The good news, is that porting code from Python
2 to Python 3 is usually quite straight forward. One alternative, is to use the
program 2to3. Running 2to3 prog.py will transform a Python 2 program
prog.py to its Python 3 counterpart. One can also use tools like future or
six to easily write programs that run under both Python 2 and 3. Also, the
futurize program can automatically do this for you based on v2.7 code.
4 http://matplotlib.org.
5 http://ipython.org.
6 http://sympy.org.
7 https://github.com/spyder-ide/spyder.
8 https://github.com/hplgit/scitools.
9 http://starship.python.net/crew/hinsen.
10 http://pytest.org/latest/.
11 https://nose.readthedocs.org.
12 http://www.pip-installer.org.
13 http://cython.org.
14 http://scipy.org.
A Installation and Use of Python
• Matplotlib 4 [7, 8] for plotting
• IPython 5 [21, 22] for interactive computing
• SymPy 6 [2] for symbolic mathematics
• Spyder 7 if you want to write and run your programs as we (primarily) do in this
book.
In addition, allthough not used herein, the following packages might be of interest
to you (probably at some later stage, if you are a newbie):
• SciTools 8 [13] for add-ons to NumPy
• ScientificPython 9 [26] for add-ons to NumPy
• pytest 10 or nose 11 for testing programs
• pip 12 for installing Python packages
• Cython 13 for compiling Python to C
• SciPy 14 [9] for advanced scientific computing
Converting a Python 2 Program to Python 3
Python comes in two versions, version 2 and 3, and these are not fully
compatible. However, for the programs in this book, the differences are very
small, the major one being print, which in Python 2 is a statement like
print ’a:’, a, ’b:’, b
while in Python 3 it is a function call
print( ’a:’, a, ’b:’, b)
The code in this book is written in Python 3.6. However, you may come
across code elsewhere that is written in Python 2, and you might prefer to
have that code in Python 3. The good news, is that porting code from Python
2 to Python 3 is usually quite straight forward. One alternative, is to use the
program 2to3. Running 2to3 prog.py will transform a Python 2 program
prog.py to its Python 3 counterpart. One can also use tools like future or
six to easily write programs that run under both Python 2 and 3. Also, the
futurize program can automatically do this for you based on v2.7 code.
4 http://matplotlib.org.
5 http://ipython.org.
6 http://sympy.org.
7 https://github.com/spyder-ide/spyder.
8 https://github.com/hplgit/scitools.
9 http://starship.python.net/crew/hinsen.
10 http://pytest.org/latest/.
11 https://nose.readthedocs.org.
12 http://www.pip-installer.org.
13 http://cython.org.
14 http://scipy.org.
