Photonics Research Group Home
Ghent University
 IMEC
intern

 

Contents: Table of Contents   Back: Tutorial Up: Tutorial Forward: Example 1   Index: Index

1.1 Python

Once Python installed, you can invoke the python interpreter by typing 'python'. The python prompt '>>>' will appear.

 
C:\>python
>>>
Now you can make variables and manipulate them, e.g:

 
>>> a = 3
>>> b = 4
>>> a + b
7
>>>
That's one way to calculate 3 + 4, but not so handy to process lots of data. To avoid the re-typing work, everything can be written in a file: the python script, and will look like this:

 
a = 3
b = 4
print a +b
save this as sumthreefour.py and invoke the script at the command prompt with python sumthreefour.py.

 
C:\>python sumthreefour.py

 7

C:\>
or choose an interactive mode with

 
C:\>python -i sumthreefour.py

 7

>>>
giving the possebility to work along with the variables

 
>>> a
7
>>>
That's it. Now use python to build and calculate gratings.



This document was generated by Lieven Vanholme on June, 10 2003 using texi2html.