a = 0 if random.random() < 0.5 else 1
in love with python’s take on the ternary operator…
The first time I tried to use a ternary in Python, I typed the traditional cond ? if : else and the compiler yelled at me. I actually had to go lookup how to do a ternary on Wikipedia. I must say though, the syntax is pretty nice. It certainly makes you think about what the default should be and consider the ‘else’ part as the exception.