Python on itlabs.cs.umn.edu or cs.umn.edu machines
To use phyton from your itlabs.umn.edu or cs.umn.edu account you
need first to type:
module load soft/python
This works on all the Solaris and Linux machines. You can avoid
typing the module load command by adding it to youe .cshrc file.
You can start python in three ways:
- You type:
python
This starts Python in the interactive mode.
In interactive mode you type to the Python interpreter, which
will read and execute your commands.
-
If you want to execute the commands in a file, let's say
in the file
file.py
, type
python file.py
.
Python will read the file, execute it, and exit.
-
If instead you want to
load a file, execute it, and then start the interactive mode, type
python -i file.py
.
Getting started with Python
- Python runs under many operating systems. For information on python
go to python.org
- Make sure you use Python 2.1 or later, otherwise the scoping rules
are different. Versions before 2.1 have dynamic scoping instead of
lexical scoping.
- You might find it useful to
set up emacs (Xemacs) for python
Information about the Python language
-
Python for Lisp Programmers by Peter Norvig provides a brief high-level
introduction to Python by comparing it with Lisp. It includes also
data on comparing the speed of Lisp, Python, and other programming
languages. Short but with most of the essential material.
- python.org has numerous
tutorials on Python covering everything from basic to advanced material.
Look at the Python
Intros page.
- For a full tutorial look at
Python Tutorial by Guido van Rossum. This is the tutorial
I recommend most highly. It includes many examples.
- A tutorial for advanced programmers with material on
scripting applications, writing unit tests, etc is
Dive Into Python
by Mark Pilgrim.
-
Python 2.2 Quick Reference includes all the data types,
functions, etc available in the language. It is very useful as a
reference, but not as a way of learning the language.
- A full textbook
How to Think Like a Computer Scientist. Learning with Python,
by Allen B. Downey, Jeffrey Elkner and Chris Meyers on using Python to
learn computer science concepts.
Basic concepts in Python
Things we will learn:
- basic syntax: rules of indentation, single and double quote, comments
- how to import from files: import modulename, from modulename import *
- data structures: python lists, tuples, dictionaries.
- control structures: if, for, while
- scoping rules: closures over read-only variables
- functions: definitions, function calls, optional arguments, keywords
- higher-order functions: map, filter
- classes
Copyright: © 2000-2007 by the Regents of the University
of Minnesota
Department of Computer Science and
Engineering. All rights reserved.
Comments to: Maria Gini
Changes and corrections are in red.