Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #17925
| From | Roy Smith <roy@panix.com> |
|---|---|
| Newsgroups | comp.lang.python |
| Subject | Re: Random string of digits? |
| Date | 2011-12-25 12:41 -0500 |
| Organization | PANIX Public Access Internet and UNIX, NYC |
| Message-ID | <roy-800FCE.12412925122011@news.panix.com> (permalink) |
| References | (1 earlier) <4ef7299f$0$29973$c3e8da3$5496439d@news.astraweb.com> <mailman.4070.1324821283.27778.python-list@python.org> <4ef74572$0$29973$c3e8da3$5496439d@news.astraweb.com> <mailman.4077.1324829519.27778.python-list@python.org> <4ef75afc$0$29973$c3e8da3$5496439d@news.astraweb.com> |
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. Steven D'Aprano <steve+comp.lang.python@pearwood.info> wrote: > In this case, the source explicitly tells you that the API includes > support for arbitrary large ranges if you include a getrandbits() method: > > Optionally, implement a getrandbits() method so that randrange() > can cover arbitrarily large ranges. > > I call that a pretty strong guarantee. I think you mis-understood Chris's point. The documentation is the specification of how something behaves. If the documentation doesn't say it, you can't rely on it. The user should never have to read the source to know how to use a function, or what they can depend on. Now, I'm not saying that reading the source isn't useful for a deeper understanding, but it should be understood that any insights you glean from doing that are strictly implementation details. If you're saying that there are guarantees made by the implementation of getrandbits() which are not documented, then one of two things are true: 1) It is intended that users can depend on that behavior, in which case it's a bug in the docs, and the docs should be updated. or 2) It is not intended that users can depend on that behavior, in which case they would be foolish to do so.
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll 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