0

My code has the following structure:

main.py
utilities.py
generator.py
motor.py

The main module calls the other modules as per logic and all this works properly. I'm at a point where I need to keep a running track of data being generated by the called modules. One option would be to initialize an object (could be as simple as a basic dictionary) within main and pass it as an argument to each call to the called modules who update the object as necessary and then return the object back.

I'm wondering if there's a better way to accomplish this. Based on some preliminary code investigation, there are hundreds of calls being done all over the place and it would be very tedious/manual/error-prone to edit all these calls.

Ideally I'd be looking at a way to update the tracker object globally without having to explicitly pass it in as an argument to the method calls.

Is this possible, or is there a better way?

Craig
  • 1,929
  • 5
  • 30
  • 51
  • Does this answer your question? [Using global variables between files?](https://stackoverflow.com/questions/13034496/using-global-variables-between-files) – Tomerikoo Nov 18 '20 at 16:59

1 Answers1

0

Honestly you could output the tracker to an out file and use that file as a median. Not much of a better way though.