Generates a random string of length equal to the length parameter

def random_string(length, numeric_only=False):
    """
    Generates a random string of length equal to the length parameter
    """
    choices = string.digits if numeric_only else string.ascii_uppercase + string.digits
    return ''.join(random.choice(choices) for _ in range(length))