Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder2.enfer-du-nord.net!newsfeed.eweka.nl!feeder3.eweka.nl!81.171.88.15.MISMATCH!eweka.nl!lightspeed.eweka.nl!62.179.104.142.MISMATCH!amsnews11.chello.com!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.002 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'python': 0.08; '(it': 0.09; '>>>>': 0.09; "module's": 0.09; 'subject:string': 0.09; 'underlying': 0.09; 'am,': 0.12; 'received:209.85.210.174': 0.13; 'received:mail-iy0-f174.google.com': 0.13; '53-bit': 0.16; 'digits.': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'precision.': 0.16; 'pythons': 0.16; 'roy': 0.16; 'mon,': 0.16; 'wrote:': 0.18; 'dec': 0.22; 'header:In-Reply-To:1': 0.22; '\xa0if': 0.23; 'expect': 0.26; 'message- id:@mail.gmail.com': 0.28; 'can.': 0.30; 'subject:?': 0.31; "i'll": 0.31; 'does': 0.32; "isn't": 0.33; 'there': 0.33; 'to:addr :python-list': 0.34; 'probably': 0.34; 'sequence': 0.37; 'two': 0.37; 'received:google.com': 0.37; 'minimum': 0.37; 'enough': 0.38; 'received:209.85': 0.38; "i'd": 0.39; 'received:209': 0.40; 'to:addr:python.org': 0.40; '2011': 0.61; 'marked': 0.64; 'guarantee': 0.65; '26,': 0.67 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; bh=uw+IHsB4oLmg2KKoszATN6SfAkT7zUJ/ronKKEYoXDI=; b=bpXUlKs/lssTZMhehXzVxLB+s6ScwEOlnFBgolu80RwNZTQsSyTParipc2k9dKFb2Y mjpaKDEkGqSnfReQY4YExhk90J72l/Q+w3ixZ6Cb7QOOCKC0P0VefajxTerCiDEaDn2l WdKi7goL9wR5xfJzOnT0cWypLA7z1kniakP7o= MIME-Version: 1.0 In-Reply-To: References: Date: Mon, 26 Dec 2011 01:51:30 +1100 Subject: Re: Random string of digits? From: Chris Angelico To: python-list@python.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 16 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1324824692 news.xs4all.nl 6894 [2001:888:2000:d::a6]:51220 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:17907 On Mon, Dec 26, 2011 at 1:21 AM, Roy Smith wrote: > It turns out, I don't really need 20 digits. =A0If 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. =A0Thanks. 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