code: def chdir(directory):
      
      try:
          olddir = os.getcwd()
      except OSError:
          olddir = None
      os.chdir(directory)
      return olddir
docs: Remember and return current directory before calling os.chdir().
      If the current directory could not be determined, return None.