AIMS resources / python tutorial (including visual python) /

Python notes

Lots of simple python programs

Python notes en francais (copied from www.ulg.ac.be)

My python examples (2006)

Python examples (2005)

Python GUI programming assignment - Tuesday Dec 6 2005

An introduction to the tkinter package, which provides buttons, scales, and other things | More information about the tkinter package. Look at the 'patterns' to find examples.

Questions and Answers

Here are the answers to 24 hours' worth of beginner's questions.

Documentation

Simple tutorials
Python documentation online
Python Library Reference by the author of Python
Beginners' guide
Beginners' examples
Python standard library examples
Sample Python Code from 'useless python'
Sample Python Code
More Sample Python Code
Python cookbook
Python Bibliotheca
The python book - `how to think like a computer scientist' (2nd edition, html) | Appendix containing the book's example programs
Python challenges
NumPy NumPy example list
SciPy
Python quick reference sheet
An introduction to the tkinter package, which provides buttons, scales, and other things
More information about the tkinter package. Look at the 'patterns' to find examples.
Python pitfalls
AIMS python wiki Help on python gnuplot | installing py-gnuplot

How I use python at AIMS

I am trying writing my python code using idle - for example:

idle-python2.4 convolve1.py
idle can provide a python shell to test code.

Problems?

  • Start-up problems: If idle won't start properly, try killing the old processes. For example
    killall idle-python2.4
    killall python2.4
    

Recommended way to get Numeric, arrays, etc
Numpy is a rewrite of Numeric and Numarray, which reached release 1.0
only a month or so ago. We are still using Numeric, and the differences
should not be noticable. If you import scipy you get the
supporting numeric/numpy as a dependency on your platform, so they won't
even notice that it changes in future if they use

>>> import scipy as S
>>> S.array([1,2,3])

(encourage this use of "as S" or "Numeric as N" to avoid
namespace issues)
Local documentation
pydoc

pydoc <name> ...
    Show text documentation on something.  <name> may be the name of a
    Python keyword, topic, function, module, or package, or a dotted
    reference to a class or function within a module or module in a
    package.  If <name> contains a '/', it is used as the path to a
    Python source file to document. If name is 'keywords', 'topics',
    or 'modules', a listing of these things is displayed.

pydoc -k <keyword>
    Search for a keyword in the synopsis lines of all available modules.

pydoc -p <port>
    Start an HTTP server on the given port on the local machine.

pydoc -g
    Pop up a graphical interface for finding and serving documentation.

pydoc -w <name> ...
    Write out the HTML documentation for a module to a file in the current
    directory.  If <name> contains a '/', it is treated as a filename; if
    it names a directory, documentation is written for all the contents.

Examples

python -> gnuplot examples

$ ~mackay/python/gp.py

official gnuplot examples

$ ls  /usr/share/doc/python-gnuplot/examples/
datafile.py  demo.py      Gnuplot      test.py      
$ /usr/share/doc/python-gnuplot/examples/demo.py
$ /usr/share/doc/python-gnuplot/examples/test.py
gnuplot-py home page

Monte Carlo Example (using gnuplot)

This runs a simulation of a dense gas of rods.
 ~mackay/python/runme.py
(It calls the function simulate in simulate.py

Vpython examples

Just run
$ vpython
and select File->Open to get loads of demos; they are located in
 /usr/local/lib/python2.3/site-packages/visual/demos
I copied one of them to
 ~mackay/python/doublependulum.py
but it doesn't seem to be working.