This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Scott Eilerman
Recipients Scott Eilerman, docs@python, rhettinger
Date 2018-03-21.15:26:54
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1521646014.27.0.467229070634.issue33114@psf.upfronthosting.co.za>
In-reply-to
Content
To clarify the use case where this behavior was problematic for me, I wanted to get the nth random draw from a given distribution, so I used something like:

random.seed(fixed_seed)
random.sample(choices, n)[-1]

Then, later, I want the next draw, so I did:

random.seed(fixed_seed)
random.sample(choices, n)[-1]


The workaround would be to use random.shuffle and pick the nth item, or use random.sample once with the highest k value I expect to need and then pick the nth element from that list. But I settled on the above implementation because for the first few cases I tested, it returned the results I expected, and nothing in the docs suggested I should expect otherwise.
History
Date User Action Args
2018-03-21 15:26:54Scott Eilermansetrecipients: + Scott Eilerman, rhettinger, docs@python
2018-03-21 15:26:54Scott Eilermansetmessageid: <1521646014.27.0.467229070634.issue33114@psf.upfronthosting.co.za>
2018-03-21 15:26:54Scott Eilermanlinkissue33114 messages
2018-03-21 15:26:54Scott Eilermancreate