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: http://tinyurl.com/d2k7bqe
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 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.
Useful standard Modules¶
There are more than 300 modules available in the Python reference guite covering many different aspects of computer science. Some of them are covered here below.
- 1. DATABASES in Python with dbm module
- 2. copy module
- 3. CGI module
- 4. getopt module
- 5. glob module
- 6. itertools
- 7. The os module (and sys, and path)
- 8. The pickle module
- 9. The regular expression module
- 10. The shelve module
- 11. shutil module
- 12. smtplib module
- 13. The md5 and sha modules
- 14. The temporary file module
- 15. Threading
- 16. Types module
- 17. Working with XML
- 18. Web Services
- 19. Bridging other language
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|