[Tutor] help with global variables?

Alan Gauld alan.gauld at blueyonder.co.uk
Fri Jul 9 01:44:39 CEST 2004


> the "global is not defined", it is defined, which makes me think
> I defined it in the wrong place. where do you put globals?

If I'm forced to use globals - which is rare - I put them in a separae
module which I import into every other module that needs to see them.

But this of course renders those modules unreusable - one good reason
for avoiding globals.

> you say the "file level," could you be more specific?

global scope in Python means global to the file. They won't be seen
outside the file(module) unless you import the module.

HTH,

Alan G.



More information about the Tutor mailing list