module name errors (trying to import curses functions from modules as needed)

brrrent bfarwick at juno.com
Sun Sep 22 06:42:06 EDT 2002


I use some very simple curses functions with Python 1.5.2.  I don't
have a problem with curses per se.

I use the old top level setup code shown in Andrew Kuchling's early
curses HOWTO.  It works well.

But ...
I want to keep all my various curses input and output functions in
separate modules, calling them when needed, instead of defining them
all at the top of my main program.

If I include top level curses setup code in each module, they import
with no problem.  I call them with the desired parameters and they do
their job.

The real problem is that when a function imported with one module
finishes, so does curses (albeit briefly).

Then of course the screen flashes annoyingly (very briefly) before the
next module once again reactivates curses.

If I try to omit the curses top level setup in the modules and put it
in my main program, of course Python complains about things such as
"stdscr" name errors.  This makes sense, but I don't know how to work
around it.

I can of course finish my program, putting up with the brief screen
flashes, and when finished, pull all my function definitions into my
main program.

If there's a better way, I would be grateful for advice on same.

Sincerely,

b



More information about the Python-list mailing list