Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #70316
| From | John Gordon <gordon@panix.com> |
|---|---|
| Newsgroups | comp.lang.python |
| Subject | Re: random.seed question (not reproducing same sequence) |
| Date | 2014-04-16 04:32 +0000 |
| Organization | PANIX Public Access Internet and UNIX, NYC |
| Message-ID | <lil15p$sa4$1@reader1.panix.com> (permalink) |
| References | <e452de11-1615-4869-8c2a-c2e78a96357c@googlegroups.com> <lijma6$17a$1@reader1.panix.com> <bc918afe-4b20-46c2-ab86-de0ea3c8d456@googlegroups.com> |
In <bc918afe-4b20-46c2-ab86-de0ea3c8d456@googlegroups.com> Nick Mellor <thebalancepro@gmail.com> 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'.
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
random.seed question (not reproducing same sequence) Nick Mellor <thebalancepro@gmail.com> - 2014-04-15 08:54 -0700
Re: random.seed question (not reproducing same sequence) John Gordon <gordon@panix.com> - 2014-04-15 16:21 +0000
Re: random.seed question (not reproducing same sequence) Nick Mellor <thebalancepro@gmail.com> - 2014-04-15 18:05 -0700
Re: random.seed question (not reproducing same sequence) John Gordon <gordon@panix.com> - 2014-04-16 04:32 +0000
Re: random.seed question (not reproducing same sequence) Ned Batchelder <ned@nedbatchelder.com> - 2014-04-15 12:36 -0400
Re: random.seed question (not reproducing same sequence) Peter Otten <__peter__@web.de> - 2014-04-15 19:34 +0200
Re: random.seed question (not reproducing same sequence) Dan Stromberg <drsalists@gmail.com> - 2014-04-15 17:07 -0700
Re: random.seed question (not reproducing same sequence) Ned Batchelder <ned@nedbatchelder.com> - 2014-04-15 20:48 -0400
csiph-web