Sections
Personal tools
You are here: Home » Faculty and Staff » Hale, Walker » November 15 » A Warning to PythonWin users
 

A Warning to PythonWin users

If you are using PythonWin to do this homework, you will get stuck on your first error. This page explains what to do about it.

There is a serious limitation of PythonWin. PythonWin runs your code inside its own memory space. That means that the module you are writing is loaded the first time you execute "assigment_due_2006_11_29.py". After that any changes you make to your file have no effect since the module is already loaded into memory. As a result, you will get "stuck" on your first error, even after you have corrected the code. You can fix this three ways:

(1) Quit and relaunch PythonWin whenever your edit your module. This is probably not what you want to do.

(2) Execute the file "assigment_due_2006_11_29.py" from the command line. This isn't too painful, since you can use the up arrow to recall the previous command:

python assigment_due_2006_11_29.py

(3) Add the statement "reload(solution)" to "assigment_due_2006_11_29.py" immediately after the two import statements:

# Change this...
import unittest
import hw_solution_2006_11_29 as solution
# Into this...
import unittest
import hw_solution_2006_11_29 as solution
reload(solution)

This will force PythonWin to read your file every time you run the file "assigment_due_2006_11_29.py". Since you will probably be temporarily commenting out blocks of this file anyway, this is probably your best option.

Added by walker.hale
Last modified 2006-11-24 06:01 PM