Common variables in modules
<p>I have three python files, let's call them <code>master.py</code>, <code>slave1.py</code> and <code>slave2.py</code>. Now <code>slave1.py</code> and <code>slave2.py</code> do not have any functions, but are required to do two different things using the same input (say the variable <code>inp</code>). </p>

<p>What I'd like to do is to call both the slave programs from master, and specify the one input variable <code>inp</code> in master, so I don't have to do it twice. Also so I can change the outputs of both slaves in one master program etc. </p>

<p>I'd like to keep the code of both <code>slave1.py</code> and <code>slave2.py</code> separate, so I can debug them individually if required, but when I try to do </p>

<pre><code>#! /usr/bin/python
# This is master.py
import slave1
import slave2

inp = #some input
</code></pre>

<p>both <code>slave1</code> and <code>slave2</code> run <em>before</em> I can change the input. As I understand it, the way python imports modules is to execute them first. But is there some way to delay executing them so I can specify the common input? Or any other way to specify the input for both files from one place?</p>

<p><strong>EDIT:</strong> <code>slave1</code> and <code>slave2</code> perform two different simulations being given a particular initial condition. Since the output of the two are the same, I'd like to display them in a similar manner, as well as have control over which files to write the simulated data to. So I figured importing both of them into a master file was the easiest way to do that. </p>
