Created
September 3, 2013 22:44
-
-
Save meejah/6430613 to your computer and use it in GitHub Desktop.
a temporary directory like tempfile.NamedTemporaryFile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class TempDir(object): | |
def __enter__(self, *args): | |
self.dir_name = tempfile.mkdtemp() | |
return self | |
def __exit__(self, *args): | |
shutil.rmtree(self.dir_name) | |
def __str__(self): | |
return self.dir_name |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment