@contextlib.contextmanager
def chdir(new_dir):
    cur_dir = os.getcwd()
    os.chdir(new_dir)
    try:
        yield
    finally:
        os.chdir(cur_dir)
Context manager to temporarily change to a new directory.
dataset/ETHPy150Open chapmanb/cloudbiolinux/cloudbio/biodata/ggd.py/chdir