@contextmanager
def chdir(d):
    'A context manager that temporary changes the working directory.\n    '
    olddir = os.getcwd()
    os.chdir(d)
    (yield)
    os.chdir(olddir)
A context manager that temporary changes the working directory.
@contextmanager
def chdir(d):
    '\n    '
    olddir = os.getcwd()
    os.chdir(d)
    (yield)
    os.chdir(olddir)