Is there a way to define a true global across modules?

  • Thread starter Hendrik van Rooyen
  • Start date
H

Hendrik van Rooyen

I am struggling with this - I want to define a "system-wide" flag for use as a
semaphore.

It looks to me as if the only way to do it is to import all the modules that
need to access it into the main namespace using the " from whatever import * "
form.

Is there a way to have one global object known to the main module as well as say
two imported modules by using the global statement in the three places, while
using the normal "import modname " form?

It looks as if the global statement just makes the name global to the module
where it is defined, and if I use the "import modname" form I end up with a
"local global" for each module, as well as one for the main module...

Can they be "merged' into one without sticking everything into the same
namespace?

I can think of ways to work around this, but it gets a bit obfuscatory - it
would be nicer to have one name, one thing in all three places...

- Hendrik
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,019
Latest member
RoxannaSta

Latest Threads

Top