Python Notes (0.13.1)


The main goal of this documentation is to make available notes I’m taking about the Python language. It does not pretend to be a thourough tutorial on Python. Very good tutorials and books already exist indeed (see for instance the official Python website or dive into python and take a look at the bibliography section Bibliography).

These notes may be useful for beginners or more experienced Python developers, which is the main reason for making it public. Some sections are ready for reading (Essential Python syntax, Advanced topics on the Python language) and some others maybe draft or empty (Useful standard Modules, Great Libraries) but will be filled in the future.

Before starting, if you want to know why to use Python, just jump to the Why using Python.

You can also refer to this page with a tiny URL:

Before starting

Python provides a shell, however, we strongly recommend to install ipython instead, which provides nice features such as tab completion. In order to start an interactive python shell, just call the ipython executable. In interactive mode, the prompt is repesented by the >>> signs. Most of the code snippets and examples provided here appear as follows:

>>> variable = 1

where python codes are preeceded by the >>> signs and outputs are shown without. For your convenience, the button in the top right corner removes the >>> signs (and the output) so as to permit a convenient copy/paste in your shell.

Just a few comments about Python syntax before starting:

  • No ; character at the end of a line, just a return carriage
  • Indentation is important and used to separate code blocks
  • everything is an object

And now for something completely different, see the next section for more information about Python syntax.

Essential Python syntax

The following links present some basic notions about the Python language. Although Python is an Object Oriented language (everything is an object in Python), you do not need it to start programming in Python. We will have a very quick overview in this section.

Advanced topics on the Python language

Here are more advanced notions that will be needed to improve either the robustness of your code or to code performance.

Great Libraries

Lots of code are already existing in Python. Most of the great packages are available in a common site called Pypi. Here are some packages I use quite often, which are great quality.

matplotlib plotting a la Matlab
numpy manipulating arrays efficiently
scipy lots of numerical analysis tools
networkx Playing with graph
igraph Playing with graph