Question about scope

Pat Pat at junk.net
Thu Oct 23 11:38:35 EDT 2008


I have a Globals class.

In it, I have a variable defined something like this:

remote_device_enabled = bool

In one module, I assign True/False to Globals.remote_device_enabled. 
Once set, this value never changes.

In another module, at the top after the imports statements, I tried this:

from Globals import *

RDE = Globals.remote_device_enabled

This way, I thought that I could just use 'if RDE:'

Within the functions, however, I get a different value.  What am I 
misunderstanding?

I tried this at the top of the module (but it didn't word):

global RDE
RDE =  Globals.remote_device_enabled

Of course, within a function, the variable using the same two lines of 
code assigns the correct value to RDE.

Thank you,

Total Newbie



More information about the Python-list mailing list