@contextmanager<EOL>def cd(directory):
old_dir = os.getcwd()<EOL>try:<EOL><INDENT>os.chdir(directory)<EOL>yield<EOL><DEDENT>finally:<EOL><INDENT>os.chdir(old_dir)<EOL><DEDENT>
Change the current working directory, temporarily.

    Use as a context manager: with cd(d): ...