[Tutor] Global scope

Magnus Lycka magnus@thinkware.se
Sat Feb 1 19:51:01 2003


At 13:42 2003-02-01 -0500, Pete Versteegen wrote:
>It's not working.... Here is what I'm doing:

As Bob wrote, globals are still restricted to a module.

I would really suggest that you rewrite this properly,
passing variables, or using classes to contain data as
attributes. But if you want something like C++ global
variables, why don't you just have a module for that.
Let's call it data.py.

I guess it can be empty. I don't know, maybe it must at
least contain a 'pass' statement?

# a.py

import data

data.x = 5

# b.py

import data

print data.x

...

You get the idea?


-- 
Magnus Lycka, Thinkware AB
Alvans vag 99, SE-907 50 UMEA, SWEDEN
phone: int+46 70 582 80 65, fax: int+46 70 612 80 65
http://www.thinkware.se/  mailto:magnus@thinkware.se