Skip to content

Managing global variables #11

Description

@CarlinLiao

https://github.com/spartalab/aimsim/blob/56e9beaeb158b0c045f117e3b44f2c7421879659/aimsim/shared.py#L182-L183

From #2 (comment)

@ribsthakkar

should this be global? maybe you can pass an instance of the simulator around?

@CarlinLiao

From what I read, the way to share a single instance variable among multiple Python files is for them all to absolute import one module as an instance. Any updates to that instance is reflected across all modules.

@pyrito

I'd be careful with global variables in python, might be better off created a container for this kind of information potentially. Something like "GlobalState" and store a bunch of variables in this. It is more modular and makes life easier in the long run.

@CarlinLiao

I'd be careful with global variables in python, might be better off created a container for this kind of information potentially. Something like "GlobalState" and store a bunch of variables in this. It is more modular and makes life easier in the long run.

I think I kind of implemented this with the new Settings class in SHARED. Most but not all global settings are now contained in there... take a look and let me know if this is what you meant.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions