• programming in python • a course for the curious •

About this introduction

This introduction was written using Sphinx. A very nice tool for writing documentation which was designed for Python documentation (and is coded in Python). The standard documentation has been maintained using Sphinx. This allows us to bind many objects to the standard documentation and also to use the same syntax highlighting for the code snippets and scripts published. For example you can use >>> on the right side to hide the Python prompt leaders >>> and .... This is a nice trick to copy paste code into a Python shell.

Tips on usage

Whenever you want to execute a script and see both the lines that are executed and the output that is produced by the script there is a simple way of getting this. This is quite useful when you want to learn how a script works, since you can read both the script and its output at the same time. Let say that the script name is script.py. Open your terminal application, change the directory where the script.py is located and run:

python -m trace --trace script.py

You should see lines that starts with script.py(3): – these are the lines of the script. If a line produces an output (for example using the print statement) then below you will see the output. For example if the script.py file is as simple as this:


Running it as python -m trace --trace script.py will print:

  --- modulename: script, funcname: <module>
script.py(1): a=1
script.py(2): a+=1
script.py(3): print(a)
 --- modulename: trace, funcname: _unsettrace
trace.py(80):         sys.settrace(None)

You can ignore all the lines which starts with --- modulename and trace.py. The number in brackets after the script name is the line number.

Html pages of this course have folding: you can hide a section (subsection ...) by clicking on its title. Note that when a section is hidden your web-browser will not be able to find anything under the folded sections. You have to unfold the document if you want to search for something and get all results. From the other hand if you want to limit the search to a given section unit you can fold all the other ones. Folding is remembered when you close a web page. If you click on a section, which is folded, in a side bar or in the table of contents the browser will jump to that section and unfold it. On the left side you have three buttons: the up arrow will unfold all sections and the down arrow folds them all. The third button which shows a right or left arrow toggles fullscreen mode (hides the left sidebar and shrinks the margin).

Last update: 2013-11-06 11:02 (CET)
Contact us.
Created using , and
we are not associated with Python Software Foundation
© Copyright 2012, 2013 Accorda Institute.