Python Quick Start
Starting the IPython shell
module load python/2.7-ve2 ipython -pylab
loads matplotlib module and enables interactive plotting
module load is a ZMAW specific environment setting! Version 2.7-ve2 is needed for the notebook version (see below).
Quit with CTRL-D
Getting help
help() help modules
list available modules
Features of IPython:
- Command history (up, down)
- Word completion by typing TAB
- System commands through magic functions cd, ls, env, pwd
Access to Unix shell by prefix !, e.g. !ls -s | sort -g
- Debugging and profiling
Program control: run
Print interactive variables who, whos
Are you a Matlab user?
The exercise is to plot a sine wave:
Matlab/Octave:
>> x=linspace(0,2*pi,100) >> y=sin(x) >> plot(x,y)
Python
In [1]: x=linspace(0,2*pi,100) In [2]: y=sin(x) In [3]: plot(x,y)
So, it works pretty much the same way!
Of course there are some differences but many similarities.