Random string of digits?

Chris Angelico rosuav at gmail.com
Sun Dec 25 09:51:30 EST 2011


On Mon, Dec 26, 2011 at 1:21 AM, Roy Smith <roy at panix.com> wrote:
> It turns out, I don't really need 20 digits.  If I can count on
>
>>>> "%020d" % random.randint(0,999999999999999)
>
> to give me 15-ish digits, that's good enough for my needs and I'll
> probably go with that.  Thanks.

I'd say you can. The information about the Mersenne Twister underlying
the module's functions isn't marked as "CPython Implementation Note",
so I would expect that every Python implementation will provide a
minimum of 53-bit precision. (It does have the feeling of an
implementation detail though; is there a guarantee that two Pythons
will generate the same sequence of numbers from the same seed?)

ChrisA



More information about the Python-list mailing list