@contextlib.contextmanager<EOL>def tempfile_context(*args, **kwargs):
fd, filename = tempfile.mkstemp(*args, **kwargs)<EOL>os.close(fd)<EOL>try:<EOL><INDENT>yield filename<EOL><DEDENT>finally:<EOL><INDENT>os.remove(filename)<EOL><DEDENT>
A wrapper around tempfile.mkstemp to create the file in a context and
delete it after.