[Tutor] quick query relating to globals (I think)

Glen Edward Wheeler gew75@uow.edu.au
Mon, 24 Jun 2002 12:44:36 +1000


  Howdy all,

  I'm making a program with a whole bunch of modules in different files (as
you do) and I'm wondering if it's possible to make an instance of a class in
one of those modules accessible by all the other modules...how 'bout an
example to illustrate :-

main.py
one.py
two.py
thing.py -> has class thing in it

main calls one and two, main also initialises an instance of the class
thing.  Without passing the object thing to all the function calls in one
and two (which would turn out really really messy) how can they access it?

  Hmm...just a sec, if thing.py initialised it's own instance of thing, at
the global level, then could one.py and two.py do an 'import thing' and
access it with thing.thing?

  Thanks,
  Glen