On May 6, 1:00 am, Steven D'Aprano <[EMAIL PROTECTED]> wrote: > On Sun, 06 May 2007 00:20:04 +0000, Alan Isaac wrote: > >> Should you not expect to get the same result each time? Is that not > >> the point of setting a constant seed each time you run the script? > > > Yes. That is the problem. > > If I delete module2.pyc, > > I do not get the same result. > > I think you have missed what John Machin is pointing out. According to > your original description, you get different results even if you DON'T > delete module2.pyc. > > According to your original post, you get the _same_ behaviour the first > time you run the script, regardless of the pyc file being deleted or not. > > You wrote: > > [quote] > module1 sets a seed like this:: > > if __name__ == "__main__": > random.seed(314) > main() > > I execute module1.py from the (Windows) shell. > I get a result, let's call it result1. > I execute it again. I get another result, say result2. > Running it again and again, I get result2. > [end quote] > > So, with module2.pyc file existing, you get result1 the first time you > execute module1.py, and then you get result2 every time from then onwards.
Umm... no. module2.pyc is created by the first run. > How is that different from what you wrote next? > > [quote] > Now I delete module2.pyc. > I execute module1.py from the shell. > I get result1. > I execute it again; I get result2. > From then on I get result2, > unless I delete module.pyc again, > in which case I once again get result1. > [end quote] > > You get the same behaviour with or without module2.pyc: the first run of > the script gives different results from subsequent runs. You can reset > that first run by deleting module2.pyc. > > I'm still perplexed how this is possible, but now I'm more perplexed. > > If you want to send me the modules, I will have a look at them as well. > Many eyes make for shallow bugs... > > -- > Steven. -- http://mail.python.org/mailman/listinfo/python-list