@contextmanager
def cd(new_dir):

    # Store current directory
    cwd = os.path.abspath(os.getcwd())

    # Move into directory and yield control
    os.chdir(new_dir)

    try:
        yield

    finally:
        # Return to current directory
        os.chdir(cwd)
Changes directories, always return, example:
dataset/ETHPy150Open jlisee/xpkg/python/xpkg/util.py/cd