import random
import string


def randomize_filename(ext=None, n_char=25):
    """
    Randomly generate a filename

    :param str ext: Extension, optional
    :param n_char: Number of characters (excluding extension)
    :return str: Randomized filename
    """
    if not isinstance(n_char, int):
        raise TypeError("Character count is not an integer: {}".format(n_char))
    if n_char < 0:
        raise ValueError("Negative char count: {}".format(n_char))
    fn = "".join(random.choice(string.ascii_letters) for _ in range(n_char))
    if not ext:
        return fn
    if not ext.startswith("."):
        ext = "." + ext
    return fn + ext