[issue27742] Random.randint generates different values in Python2 and Python3

Antti Haapala report at bugs.python.org
Fri Aug 12 06:47:22 EDT 2016


Antti Haapala added the comment:

Anyhow, in this case it is easy to simulate the Python 2 randint behaviour (add checks for hi >= lo if needed):

    >>> random.seed(5, version=1)
    >>> randint_compat = lambda lo, hi: lo + int(random.random() * (hi + 1 - lo))
    >>> randint_compat(0, 9999999)
    6229016

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue27742>
_______________________________________


More information about the Python-bugs-list mailing list