Is there a good way to share the seed of random between modules (in python)?
<p>I have a project with different main files (for different simulations).
When I run one of the mainfiles, it should set a seed to random (and numpy.random), and all the modules in the project should use that seed.</p>

<p>I don't find a good way to do this. I have a file globals.py with this:</p>

<pre><code>import random

myRandom=None


def initSeed(seed):
    global myRandom
    myRandom =random.Random(seed)
</code></pre>

<p>then from a main I do:</p>

<pre><code>if __name__ == "__main__":

    seed=10
    globals.initSeed(seed)
...
</code></pre>

<p>Then in the modules that main calls, I do:</p>

<pre><code>from globals import myRandom
</code></pre>

<p>But myRandom has the value None in the module (even though I modified it in main!). Why, and how to fix it? Is there a nicer way?</p>