module question

Bob van der Poel bvdpoel at uniserve.com
Mon Jan 1 18:54:19 EST 2001


A dumb (probably) question about modules.... I've got a monolithic
program I'm tying to modularize. Not sure if this is a good thing or
not, but it does seem to offer some promise. However, I've run into a
snag with references...

In my main program I start off with a

	from Tkinter import *
	from edit import Edit

Now, in the main program I call 'Edit', but it fails. Seems that I have
to insert a 'from Tkinter import *' in 'Edit' as well. So, does this
mean that each and every module needs to re-import all the 'global-type'
stuff? I suppose this aids in keeping data private, etc. but must add a
lot of overhead at the same time. Maybe I should keep my monolithic
program structure?


Now, to complicate my understanding even more...if I declare a variable
in the 'main' module or program how do I access it from imported modules?
For example, I might have something like:

	versionNumber = 1.4

in the mainline. Now, a module (and I guess it might be deeply nested), wants
to find out what version is running. I just tried a few variations of 'global',
but nothing seems to work. Passing this variable around to everyone who might
need it gets real old, real fast...so I'm thinking I'm not understanding something!

Obviously I need help.


-- 
Bob van der Poel ** Wynndel, British Columbia, CANADA **
EMAIL: bvdpoel at uniserve.com
WWW:   http://users.uniserve.com/~bvdpoel





More information about the Python-list mailing list