[Edu-sig] Strange transitive import problem
john.zelle at wartburg.edu
Fri Feb 9 22:09:34 CET 2007
I should have caught this when you posted your file. There is a bizarre import
interaction that I am aware of, but can't say that I fully understand
regarding my graphics library. It seems that Python imports are in some-way,
somewhat atomic, and with the way my graphics library is set up this can
produce this deadlock. I have a workaround for you. Move the graphics setup
code in your module into a function:
root = z.GraphWin()
print "If you can't see the graphics window,"
print "it's probably at the upper left"
print "of your screen, behind this one."
Then call this function once at the start of your graphics programs. This is
what will now pop up the window. So your "junk" program becomes:
from graphics2 import *
print "imported graphics2"
If someone has a better understanding of Python module imports and why that
causes a problem with my graphics package, I'd love to know how to fix this
problem rather than working around it.
On Friday 09 February 2007 1:36 pm, Peter Drake wrote:
> The graphics2.py file I supplied earlier (http://www.lclark.edu/
> ~drake/courses/cs0/graphics2.py) is a procedural front-end for
> Zelle's graphics.py.
> If I run the graphics2.py module, everything works fine, and I can
> issue commands interactively.
> A problem happens if I write ANOTHER program, say junk.py:
> from graphics2 import *
> print "imported graphics2"
> When I run this (within IDLE), it hangs trying to import graphics2.
> There is no error message or processor load, it just hangs.
> Can anyone explain (or reproduce) this behavior?
> Peter Drake
> Assistant Professor of Computer Science
> Lewis & Clark College
> Edu-sig mailing list
> Edu-sig at python.org
John M. Zelle, Ph.D. Wartburg College
Professor of Computer Science Waverly, IA
john.zelle at wartburg.edu (319) 352-8360
More information about the Edu-sig