Scott Eilerman <scott.j.eiler...@gmail.com> added the comment:

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.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue33114>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to