Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!us.feeder.erje.net!nntp.club.cc.cmu.edu!micro-heart-of-gold.mit.edu!bloom-beacon.mit.edu!bloom-beacon.mit.edu!panix!gordon From: John Gordon Newsgroups: comp.lang.python Subject: Re: random.seed question (not reproducing same sequence) Date: Wed, 16 Apr 2014 04:32:57 +0000 (UTC) Organization: PANIX Public Access Internet and UNIX, NYC Lines: 31 Message-ID: References: NNTP-Posting-Host: panix1.panix.com X-Trace: reader1.panix.com 1397622777 28996 166.84.1.1 (16 Apr 2014 04:32:57 GMT) X-Complaints-To: abuse@panix.com NNTP-Posting-Date: Wed, 16 Apr 2014 04:32:57 +0000 (UTC) User-Agent: nn/6.7.3 Xref: csiph.com comp.lang.python:70316 In Nick Mellor writes: > In response to your question, John, all I know is that my own code doesn't > use the random module outside of this code fragment. Does addUpdate_special_to_cart() use any random methods? In any case, a further test would be to strip out all the business logic and leave only the calls to random, and see if the results still differ. Something like this: rnd = random.Random() for qty in [4, 0]: print "qty is %s" % qty rnd.seed(seed) print "seed is %s" % seed for cart in range(test_size): print "cart is %s " % cart for special in range(rnd.randrange(3)): print "special is %s " % special print "stockbin is %s" % rnd.randrange(test_size) print "special_id is %s" % rnd.randrange(test_size) print "products is %s" % [(rnd.choice(PRODUCTS), rnd.choice(range(10))) for r in range(rnd.randrange(7))]) Run that code sample and see if the results differ when qty is 4 vs 0. -- John Gordon Imagine what it must be like for a real medical doctor to gordon@panix.com watch 'House', or a real serial killer to watch 'Dexter'.