Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.chainon-marquant.org!nntpfeed.proxad.net!proxad.net!feeder2-2.proxad.net!nx02.iad01.newshosting.com!newshosting.com!news-out.readnews.com!transit3.readnews.com!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail From: 88888 Dihedral Newsgroups: comp.lang.python Subject: Re: Random string of digits? Date: Sun, 25 Dec 2011 11:50:03 -0800 (PST) Organization: http://groups.google.com Lines: 42 Message-ID: <20158346.705.1324842603361.JavaMail.geo-discussion-forums@prfi34> References: <4ef7299f$0$29973$c3e8da3$5496439d@news.astraweb.com> <4ef74572$0$29973$c3e8da3$5496439d@news.astraweb.com> <4ef75afc$0$29973$c3e8da3$5496439d@news.astraweb.com> Reply-To: comp.lang.python@googlegroups.com NNTP-Posting-Host: 1.168.128.111 Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1324842698 9418 127.0.0.1 (25 Dec 2011 19:51:38 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Sun, 25 Dec 2011 19:51:38 +0000 (UTC) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=1.168.128.111; posting-account=5JdMBQoAAABHnS4mjpqEzxnmWtgiiVNw User-Agent: G2/1.0 X-Google-Web-Client: true Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:17928 Roy Smith=E6=96=BC 2011=E5=B9=B412=E6=9C=8826=E6=97=A5=E6=98=9F=E6=9C=9F=E4= =B8=80UTC+8=E4=B8=8A=E5=8D=881=E6=99=8241=E5=88=8629=E7=A7=92=E5=AF=AB=E9= =81=93=EF=BC=9A > On Mon, 26 Dec 2011 03:11:56 +1100, Chris Angelico wrote: > > > I prefer not to rely on the source. That tells me what happens, not > > > what's guaranteed to happen.=20 >=20 > Steven D'Aprano wrote: > > In this case, the source explicitly tells you that the API includes=20 > > support for arbitrary large ranges if you include a getrandbits() metho= d: > >=20 > > Optionally, implement a getrandbits() method so that randrange() > > can cover arbitrarily large ranges. > >=20 > > I call that a pretty strong guarantee. >=20 > I think you mis-understood Chris's point. The documentation is the=20 > specification of how something behaves. If the documentation doesn't=20 > say it, you can't rely on it. The user should never have to read the=20 > source to know how to use a function, or what they can depend on. Now,= =20 > I'm not saying that reading the source isn't useful for a deeper=20 > understanding, but it should be understood that any insights you glean=20 > from doing that are strictly implementation details. >=20 > If you're saying that there are guarantees made by the implementation of= =20 > getrandbits() which are not documented, then one of two things are true: >=20 > 1) It is intended that users can depend on that behavior, in which case= =20 > it's a bug in the docs, and the docs should be updated. >=20 > or >=20 > 2) It is not intended that users can depend on that behavior, in which=20 > case they would be foolish to do so. Random bit generations for RSA2048 encoding and cryptography applications= =20 in python is simple and elegant.