Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

5
  • that is what I got the idea of using a module to store globals. However when implementing it, it doesnt work as expected. Commented Sep 10, 2021 at 17:30
  • try stuff.test = "whatever"? Commented Sep 10, 2021 at 17:30
  • mypack.stuff.test = 'whatever' works but it defeats the purpose. The aim is not to modify module local variables. It is to only modify the variables in globals module and have that reflect throughout. Commented Sep 10, 2021 at 17:41
  • I guess I dont understand your question then? It looks like you are trying to modify the data of the variable in a different file. Commented Sep 10, 2021 at 17:42
  • my real use case is to pass the logger and log_count variables across modules (which would not be strings, but other objects). But I just framed a simpler question here to explain the issue. I will have likely several modules created. Each one will need to access the global and potentially modify it. Having each module access the local variable from every other module is not feasible. I want to import a set of globals, and ensure that modification to them is reflected in every other module immediately. Commented Sep 10, 2021 at 17:45