17 Oct
2015
17 Oct
'15
4:54 p.m.
Brian Gladman <brg@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.