def randomize_filename(ext=None, n_char=<NUM_LIT>):
if not isinstance(n_char, int):<EOL><INDENT>raise TypeError("<STR_LIT>".format(n_char))<EOL><DEDENT>if n_char < <NUM_LIT:0>:<EOL><INDENT>raise ValueError("<STR_LIT>".format(n_char))<EOL><DEDENT>fn = "<STR_LIT>".join(random.choice(string.ascii_letters) for _ in range(n_char))<EOL>if not ext:<EOL><INDENT>return fn<EOL><DEDENT>if not ext.startswith("<STR_LIT:.>"):<EOL><INDENT>ext = "<STR_LIT:.>" + ext<EOL><DEDENT>return fn + ext<EOL>
Randomly generate a filename

:param str ext: Extension, optional
:param n_char: Number of characters (excluding extension)
:return str: Randomized filename