code: def from_dir(cwd):
      "Context manager to ensure in the cwd directory."
      import os
      curdir = os.getcwd()
      try:
          os.chdir(cwd)
          yield
      finally:
          os.chdir(curdirf from_dir(cwd):
      "Context manager to ensure in the cwd directory."
      import os
      curdir = os.getcwd()
      try:
          os.chdir(cwd)
          yield
      finally:
          os.chdir(curdir)
docs: Context manager to ensure in the cwd directory.