title: How does a random seed work in a function factory in Python?
body: <p>Suppose I want to generate a bunch of binary number generators given the success probabilities. One concern I have is about the random seed. The random seeds for f1, f2, f3 are their creation time, right? And the seeds are fixed for each function regardless of the random seed in the global namespace, right?</p>
  
  <pre><code>def f(p):
      import random, time
      random.seed(time.time())
      def g():
          return 1 if random.random() &lt; p else 0
      return g
  
  f1 = f(0.05)
  f2 = f(0.65)
  f3 = f(0.25)
  </code></pre>