I am looking for the best way (fast and elegant) to get a random boolean in python (flip a coin).
For the moment I am using random.randint(0, 1) or
A new take on this question would involve the use of Faker which you can install easily with pip.
from faker import Factory
#----------------------------------------------------------------------
def create_values(fake):
""""""
print fake.boolean(chance_of_getting_true=50) # True
print fake.random_int(min=0, max=1) # 1
if __name__ == "__main__":
fake = Factory.create()
create_values(fake)