Home Reinforcement Learning and Artificial Intelligence (RLAI)
Python for CMPUT 499/510
--Steph Schaeffer, Rich Sutton, Brian Tanner, Sept 2004

The ambition of this web page is to provide all information about using python that needs to be known by students in the Reinforcement Learning for Artificial Intelligence course at the University of Alberta.  In particular, we describe how to get Python to print "hello" in various ways on various machines.



To use python:

1) interactive use
   In your shell window type:
     python                   (it will respond with the >>> prompt)
     >>> print "hello"
     hello
     >>> (use cntl-D to exit)
2) from a file
   edit h.py, put print "hello" as first line
   In your shell window type:
     python h.py      or python < h.py
     hello                    (output)
3) interactive loading a file
   edit h.py, put print "hello" as first line
   In your shell window type:
     python
     >>> import h            (note that the .py is not needed here)
     hello
     >>>

There are other options: see the man pages for details.

Python is available on:
1) the Grad linux boxes
  (use python2.3 and idle2.3 to get version 2.3. The regular python and idle
commands will start up version 2.2)
2) the Solaris boxes Update: Quick fix here
3) the OS X Macintosh computers in SUB (the student union building).  These are located in the basement, more or less across the hall from the University Microstore/Bookstore.  Follow the instructions for logging on with your CNS id and password, then select the terminal application from the dock (it looks like this:).  Then you can say "python" to the unix prompt, etc.  Currently we are double-checking that this works...
4) your home machine if you want to use it. Go to www.python.org.
Python is free and available for many platforms at:
  http://www.python.org/download/
rpms for Linux redhat9 are at
  http://www.python.org/ftp/python/2.3/rpms/redhat-9/
 

Here are some links to documentation for Python:
There are also Python books available. "Learning Python" by Lutz and Ascher is quite good, and is available from Chapters.

Extend this Page   How to edit   Style   Subscribe   Notify   Suggest   Help   This open web page hosted at the University of Alberta.   Terms of use  2616/1