Steven D'Aprano <steve+pyt...@pearwood.info> added the comment:

Not every one line expression needs to be a function in a library. 
`bool(getrandbits(1))` is self-explanatory enough, and it is doubtful that any 
implementation would be faster.

Using getrandbits(1) to return 0 or 1 is fine; if you need a bool, call bool on 
the result.

Aside: the name getrandbits is a bit sad, there's no setrandbits and we don't 
name the other random functions with a leading "get" prefix:

    getrandint(1, 6)


Raymond, would you consider providing an alias randbits and depreciating the 
getrandbits name? We don't have to remove it, just document it as depreciated 
to be removed in Python 5000 :-)

----------
nosy: +steven.daprano

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue44400>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to