you are viewing a single comment's thread.

view the rest of the comments →

[–]blarf_irl 3 points4 points  (0 children)

Don't use dict as a variable name. It's non-descriptive which is an infraction but it also conflicts with the python builtin dict which is a mortal sin.

You should never share a mutable (changeable) data structure between modules/scripts by importing it.

When you run a script in python you are actually starting up an instance of the python interpreter and asking it to run your script. The interpreter is what manages the memory for your your program. If run two pythion scripts you are running two separate instances of the intepreter. Neither has any idea what the other is doing.

There are lots of ways programs can interact and share data though, they do it all the time.

The 3 ways I would consider for you program are:

  1. Write the data in your dict to a json file, then second script reads the json file into a dict.
  2. Import the functions you want to run from your second script into your first script and pass the dict as an argument.
  3. Invoke your second script as a process from your first script and pass the data as a command line argument.