Need help with "global" variables

Roman Suzi rnd at onego.ru
Sun Jul 15 07:46:34 CEST 2001


On Sun, 15 Jul 2001, Nick Perkins wrote:

>Your modules are going to have to import the globals.  You could put them
>all in a separate file, call it "my_globals.py", and then in each file
>(including the 'main' file), you would have:
>from my_globals import *

This assumes globals are constants. If you want them to change,
you can put them to class/object:

class Dummy:
  pass

globs = Dummy()
globs.var1 = 1.23
globs.var2 = 2.34
...

BTW, globals and object attributes take more time to get than
locals.


Sincerely yours, Roman Suzi
-- 
_/ Russia _/ Karelia _/ Petrozavodsk _/ rnd at onego.ru _/
_/ Sunday, July 15, 2001 _/ Powered by Linux RedHat 6.2 _/
_/ "This is Borg. <ESC> is futile <CTRL> is inevitable" _/





More information about the Python-list mailing list