tip # 1, no magic numbers.
unreadable:
random_bits = [random.randint(0,2) for _ in range(256)]
how can u even read that monstrosity? allow me to elucidate with a clear readable example:
NUMBER_OF_DIGITS_IN_BINARY = 2
NUMBER_OF_BITS_TO_GENERATE = 256
random_bits = [random.randint(0,NUMBER_OF_DIGITS_IN_BINARY) for _ in range(NUMBER_OF_BITS_TO_GENERATE)]
musou wrote
this is a good tip, one codebase i worked on actually had a whole module just dedicated to constants with beautiful names such as
@largest_integer_that_can_be_represented_in_ten_digits_of_base36