code: def chdir(directory):
      
      cur = os.getcwd()
      try:
          yield os.chdir(directory)
      finally:
          os.chdir(cur)
docs: Change the current working directory to a different directory for a code
      block and return the previous directory after the block exits. Useful to
      run commands from a specificed directory.
  
      :param str directory: The directory path to change to for this context.