[Python-Dev] PEP 506 secrets module

Random832 random832 at fastmail.com
Sat Oct 17 12:54:51 EDT 2015


Brian Gladman <brg at gladman.plus.com> writes:

>> On Sat, Oct 17, 2015 at 03:26:46AM +1100, Steven D'Aprano wrote:
> I hence support your conclusion that the module should offer randbelow
> alone.  I would oppose offering randomrange (or offering more than one
> of them) since this will pretty well guarantee that, sooner or later,
> someone will make a mistake in using the extra functionality and
> possibly deploy an insecure application as a result.
>
>    Brian Gladman

Plus if someone really does want randrange, they can simply do this:

def randfrom(seq):
    return seq[randbelow(len(seq))]

def randrange(start, stop, step=None):
    randfrom(range(start, stop, step))

These are simple recipes that probably don't belong in the module.



More information about the Python-Dev mailing list