Skip to content

Instantly share code, notes, and snippets.

@ecarreras
Created August 5, 2015 06:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ecarreras/17d9ae0a331cdd7104bf to your computer and use it in GitHub Desktop.
Save ecarreras/17d9ae0a331cdd7104bf to your computer and use it in GitHub Desktop.
class TempFile(object):
def __init__(self, *args, **kwargs):
self.file = open(*args, **kwargs)
def __enter__(self):
return self.file
def __exit__(self, exc_type, exc_val, exc_tb):
self.file.close()
os.remove(self.file.name)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment