Created
March 19, 2012 23:10
-
-
Save glenrobertson/2128211 to your computer and use it in GitHub Desktop.
Context manager for making temporary directory
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
from contextlib import contextmanager | |
import os | |
import shutil | |
@contextmanager | |
def mktempdir(folder): | |
os.mkdir(folder) | |
yield | |
shutil.rmtree(folder) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment