[issue40286] Add getrandbytes() method to random.Random

2020-04-15 Thread STINNER Victor
STINNER Victor added the comment: I like "from random import randbytes" name. I concur that "from random import bytes" overrides bytes() builtin type and so can likely cause troubles. -- ___ Python tracker

[issue40286] Add getrandbytes() method to random.Random

2020-04-15 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Maybe randbytes()? -- nosy: +serhiy.storchaka ___ Python tracker ___ ___ Python-bugs-list

[issue40286] Add getrandbytes() method to random.Random

2020-04-15 Thread Raymond Hettinger
Raymond Hettinger added the comment: I concur that bytes() isn't a good name, but am still concerned that the proposed name is a bad API decision. -- ___ Python tracker ___

[issue40286] Add getrandbytes() method to random.Random

2020-04-15 Thread Vedran Čačić
Vedran Čačić added the comment: I think that the "module owner";-P must decide whether the `random` module should follow the C-namespacing or not. Of course, I'm in the "not" camp, so I believe those two "rand..." functions (randrange is completely redundant with random.choice(range)) should

[issue40286] Add getrandbytes() method to random.Random

2020-04-15 Thread Raymond Hettinger
Raymond Hettinger added the comment: Do you have another name suggestion that doesn't have a parallelism problem with the existing name? The names getrandbytes() and getrandbits() suggest a parallelism that is incorrect. -- ___ Python tracker

[issue40286] Add getrandbytes() method to random.Random

2020-04-15 Thread Vedran Čačić
Vedran Čačić added the comment: > I suggest just random.bytes(n), the same as numpy. The problem with this is that people who `from random import *` (some schools insist on this, probably because most functions they need already start with `rand`) will shadow builtin `bytes`. Not that those

[issue40286] Add getrandbytes() method to random.Random

2020-04-15 Thread Antoine Pitrou
Change by Antoine Pitrou : -- nosy: +mark.dickinson ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue40286] Add getrandbytes() method to random.Random

2020-04-14 Thread Raymond Hettinger
Raymond Hettinger added the comment: If we have to have this, the method name should be differentiated from getrandbits() because the latter returns an integer. I suggest just random.bytes(n), the same as numpy. > Python already has three functions to generate random bytes: Now, there

[issue40286] Add getrandbytes() method to random.Random

2020-04-14 Thread STINNER Victor
Change by STINNER Victor : -- keywords: +patch pull_requests: +18877 stage: -> patch review pull_request: https://github.com/python/cpython/pull/19527 ___ Python tracker ___

[issue40286] Add getrandbytes() method to random.Random

2020-04-14 Thread STINNER Victor
New submission from STINNER Victor : The random module lacks a getrandbytes() method which leads developers to be creative how to generate bytes: https://stackoverflow.com/questions/5495492/random-byte-string-in-python It's a common use request: * bpo-13396 in 2011 * bpo-27096 in 2016 *