| YUP Tutorial Module 0: Preparations | |
2. PythonPython is the programming and scripting language for YUP. Therefore, you have to be able to comprehend Python programs in order to use YUP. |
|
| (3 hours) In this session we will
work through the tutorial devised by
Guido van Rossum, the inventor of the Python language, and Fred L.
Drake, Jr. It is assumed that you have some programming experience. If you are working in MacOS X: switch to the Finder (clicking on the desktop is one way to do that) and select “Mac Help” or press -?. From the “Library” menu, select “Python Documentation”, and then click on the “Tutorial” link. The tutorial is also available as a PDF file. You may have to prompt the Help system to find the documentations: from the Applications folder, look for the MacPython folder and start the PythonIDE application. From the Help menu, select "Python Documentation". You only have to do this once if you have to do it at all. The contents of the PDF file and the online tutorial are slightly different. You can skip Chapters 7 and 8 if you do not plan to go beyond Module 2. The Python tutorial is also available from the Python.org web site (the link is on the bottom right corner of this page). If you are working on the Mac, use the command line version of Python: first start a terminal (X11 can be found in the Utilities folder) and then type Yup.python
to start the interpreter. You
also need a text editor. Size
the terminal and the text editor window to about 150
columns. The following UNIX commands create the working directory and
start TextWrangler and the Python interpreter in that directory:
In the following sections, you will notice that more than one use of a particular function or method are presented. Yammp 2 takes advantage of keyword arguments and preset argument values. Arguments that do not have preset values must always be specified, while other arguments are optional. Preset values are listed on the rightmost column of the summary table for each method and function in the web documentation. You need only supply values to those arguments that do not have preset or desired values. And, keyword arguments can be supplied in any order. Thus, functions and methods can be used in many ways. All are valid uses but check the documentation for the proper value ranges and exceptions. Note that a machine may have multiple installations or versions of the Python interpreter. MacOS X machines in the Harvey Lab. can have as many as three versions and each has a different mix of features. When you type python, you will execute one
copy of the interpreter and which copy runs depends on your command
path. On the SGI machines python
refers to
version 1 of the interpreter (not installed) and the correct command
for version 2 is python2.
To cut through the confusion, a command Yup.python is defined on every
machine on which YUP is also installed. This is simply a symbolic link
to the version of the Python interpreter that has all the features that
YUP needs.
|
|
|
Modules
|
|
When you have completed the tutorial you should understand: function calls, argument order, default argument values, keyword arguments, classes, the dot notation, data attributes, class methods and how they differ from functions. The Python tutorial that you have just completed is sufficient for you to read and understand YUP scripts. |
Resources Yammp Under Python The Harvey Laboratory Python Home Python Tutorial (new browsers) |
| Prev | Top | Next | |