Py4Science: a Starter Kit … Great introduction to Python for Scientific Computing by Fernando Pérez of U.C. Berkeley.
According to Dave Delene, 'breakpoints' are the best way to debug a code that was given to you. When writing your own code you can run/debug as you write them. When you are given a completed script that may or may not work for you, breakpoints are a valuable asset in breaking down the code in easy to digest sections. Just like 'Interactive mode' when running a script, breakpoints allow you to interact with the script but at any point within it. In comparison with print statements to identify error placement, breakpoints allow you to stay in the running script and print troublesome variables narrowing down the real issues.
In order to use breakpoints you first need to 'import pdb' then wherever you run into an error insert 'pdb.set_trace()'. This lets you inspect anything you would like before the error occurs and print variables that could be causing it.
Check to see if you have python (i.e. type python in shell). Should get something like.
[delene@convection ~]$ python Python 2.5.2 (r252:60911, Sep 30 2008, 15:41:38) [GCC 4.3.2 20080917 (Red Hat 4.3.2-4)] on linux2 Type “help”, “copyright”, “credits” or “license” for more information.
Need to install numpy (i.e. yum install numpy). To install Numpy into your RHEL5 (32-bit or 64-bit) machine, add this repository to your existing repository listing. Then either use the GUI interface for installing “numpy” or do a yum search numpy.
Need to install ipython (i.e. yum install ipython).
Run ipython (ie. ipython in shell) and you need to configure it the first time (just access default). Beginner users don't need to modify ~/.ipython/ipy_user_conf.py.
To get help use help().
Make sure you have matplotlib (i.e. yum install python-matplotlib).
Use ipython with matplotlib (i.e. ipython –pylab).
Numerical Computing in Python: A Guide for Matlab Users … Bryant University Faculty Development Seminar, May 2007. (by Brian Blais)
Py4Science page contains the slides, notes, and updates regarding to our weekly meetings that we have on Thursdays 1PM.