Python do something based on probability

python - True or false output based on a probability - Stack Overflow mentions a really neat idea:

def decision(probability):
    return random.random() < probability