def dir_path ( dir ) : old_dir = os . getcwd ( ) os . chdir ( dir ) yield os . chdir ( old_dir )
python change to a dir
with dir_path ( path ) to change into a directory .
def dir_path(dir):
    """with dir_path(path) to change into a directory."""
    old_dir = os.getcwd()
    os.chdir(dir)
    yield
    os.chdir(old_dir)