@contextmanager
def ensure_clean_path(path):
 try:
  if isinstance(path, list):
   filenames = [create_tempfile(p) for p in path]
   (yield filenames)
  else:
   filenames = [create_tempfile(path)]
   (yield filenames[0])
 finally:
  for f in filenames:
   safe_remove(f)

@ contextmanager def ensure_clean_path ( path ) : try : if isinstance ( path , list ) : filenames = [ create_tempfile ( p ) for p in path ] ( yield filenames ) else : filenames = [ create_tempfile ( path ) ] ( yield filenames [ 0 ] ) finally : for f in filenames : safe_remove ( f )
return essentially a named temporary file that is not opened and deleted on existing; if path is a list .