I mean `''.join(chr(random.choice(char_range)) for x in range(length))` is enough.