Re: Random and fork

2013-02-07 Thread Stephane Wirtel
* Julien Le Goff [2013-02-06 08:28:24 -0800]: > Hi everyone, > > Today I came accross a behaviour I did not expect in python (I am using 2.7). > In my program, random.random() always seemed to return the same number; it > turned out to be related to the fact that I was using os.fork. > > See

Re: Random and fork

2013-02-07 Thread Julien Le Goff
Thank you for the answers! It was much simpler than I thought. On Wednesday, 6 February 2013 17:49:06 UTC+1, Alain Ketterlin wrote: > Julien Le Goff writes: > > > > > Today I came accross a behaviour I did not expect in python (I am > > > using 2.7). In my program, random.random() always see

Re: Random and fork

2013-02-06 Thread Alain Ketterlin
Julien Le Goff writes: > Today I came accross a behaviour I did not expect in python (I am > using 2.7). In my program, random.random() always seemed to return the > same number; it turned out to be related to the fact that I was using > os.fork. The random number generator is initialized once,

Re: Random and fork

2013-02-06 Thread Peter Otten
Julien Le Goff wrote: > Hi everyone, > > Today I came accross a behaviour I did not expect in python (I am using > 2.7). In my program, random.random() always seemed to return the same > number; it turned out to be related to the fact that I was using os.fork. > > See below a small program that

Random and fork

2013-02-06 Thread Julien Le Goff
Hi everyone, Today I came accross a behaviour I did not expect in python (I am using 2.7). In my program, random.random() always seemed to return the same number; it turned out to be related to the fact that I was using os.fork. See below a small program that illustrates this. It is easily fixe