New submission from Yuval S <sadan.yu...@gmail.com>:
The following code gives different results on each run, even though "``random.seed()``" is used: >>> import random >>> random.seed(6) >>> x = set(str(i) for i in range(500)) >>> print(random.sample(x, 1)) presumably because of string hash randomization (see also #27706), unless "``PYTHONHASHSEED``" is set. However, this is non-intuitive, especially as this random aspect of Python is not mentioned in `Notes on Reproducability <https://docs.python.org/3/library/random.html#notes-on-reproducibility>`_. I would suggest this is either fixed (using the provided seed for string hash randomization as well) or documented. ---------- assignee: docs@python components: Documentation, Library (Lib) files: test.py messages: 366741 nosy: Yuval S, docs@python priority: normal severity: normal status: open title: Random.seed does not affect string hash randomization leading to non-intuitive results versions: Python 3.7, Python 3.8 Added file: https://bugs.python.org/file49075/test.py _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue40325> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com