Question about scope

Lave lave.wang.w at gmail.com
Thu Oct 23 08:35:22 EDT 2008


Newbie too. I think you shoud qualify Global with the module name.

On 10/23/08, Pat <Pat at junk.net> wrote:
> 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 *
>
from <module> import Globals ?
> RDE = Globals.remote_device_enabled
>
Here,

RDE = <module>.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
> --
> http://mail.python.org/mailman/listinfo/python-list
>


-- 
Regards,
Lave



More information about the Python-list mailing list