Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #17907

Re: Random string of digits?

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 <rosuav@gmail.com>
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 <roy-895E70.09213425122011@news.panix.com>
References <roy-EDF7D2.08304625122011@news.panix.com> <mailman.4068.1324821046.27778.python-list@python.org> <roy-895E70.09213425122011@news.panix.com>
Date Mon, 26 Dec 2011 01:51:30 +1100
Subject Re: Random string of digits?
From Chris Angelico <rosuav@gmail.com>
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 <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.4074.1324824692.27778.python-list@python.org> (permalink)
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

Show key headers only | View raw


On Mon, Dec 26, 2011 at 1:21 AM, Roy Smith <roy@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

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Random string of digits? Roy Smith <roy@panix.com> - 2011-12-25 08:30 -0500
  Re: Random string of digits? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-12-25 13:48 +0000
    Re: Random string of digits? Chris Angelico <rosuav@gmail.com> - 2011-12-26 00:54 +1100
      Re: Random string of digits? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-12-25 15:46 +0000
        Re: Random string of digits? Chris Angelico <rosuav@gmail.com> - 2011-12-26 03:11 +1100
          Re: Random string of digits? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-12-25 17:18 +0000
            Re: Random string of digits? Roy Smith <roy@panix.com> - 2011-12-25 12:41 -0500
              Re: Random string of digits? 88888 Dihedral <dihedral88888@googlemail.com> - 2011-12-25 11:50 -0800
              Re: Random string of digits? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-12-26 03:00 +0000
                Re: Random string of digits? Chris Angelico <rosuav@gmail.com> - 2011-12-26 14:43 +1100
                Re: Random string of digits? Roy Smith <roy@panix.com> - 2011-12-25 23:17 -0500
                Re: Random string of digits? Chris Angelico <rosuav@gmail.com> - 2011-12-26 15:26 +1100
    Re: Random string of digits? Serhiy Storchaka <storchaka@gmail.com> - 2011-12-25 19:32 +0200
  Re: Random string of digits? Chris Angelico <rosuav@gmail.com> - 2011-12-26 00:50 +1100
    Re: Random string of digits? Roy Smith <roy@panix.com> - 2011-12-25 09:21 -0500
      Re: Random string of digits? Chris Angelico <rosuav@gmail.com> - 2011-12-26 01:51 +1100
        Re: Random string of digits? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-12-25 15:27 +0000
  Re: Random string of digits? Chris Angelico <rosuav@gmail.com> - 2011-12-26 00:51 +1100
  Re: Random string of digits? Peter Otten <__peter__@web.de> - 2011-12-25 16:21 +0100

csiph-web