This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author corona10
Recipients corona10, rhettinger
Date 2021-06-12.00:33:47
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1623458028.32.0.0235692226246.issue44400@roundup.psfhosted.org>
In-reply-to
Content
I noticed that the random library does not provide `random.randbool()`.
Generating bool value is quite common in the use-case when we generated faked data
(unittest, machine learning training, etc)

Somebody can say write your own library but it's too common use-case and in physically some isolated environments is hard to use 3rd party library.

Since the bool value is the built-in type of python, I think that is very useful when we provide this function.

I would like to get opinions from Raymond and then proceed with this issue.

Here is the candidate implementation:

def randbool():
    return bool(getrandbits(1))
History
Date User Action Args
2021-06-12 00:33:48corona10setrecipients: + corona10, rhettinger
2021-06-12 00:33:48corona10setmessageid: <1623458028.32.0.0235692226246.issue44400@roundup.psfhosted.org>
2021-06-12 00:33:48corona10linkissue44400 messages
2021-06-12 00:33:47corona10create