code: def rename_file(old, new, path=None):
      
      cwd = os.getcwd()
      try:
          if path:
              os.chdir(path)
      except OSError:
          raise
      try:
          os.rename(old, new)
          os.chdir(cwd)
          return True
      except OSError:
          os.chdir(cwd)
          raise
docs: Rename a file.
  
      :param old: Old file name
      :param new: New file name
      :param path: Path to file
      :return: True if successfull
      :raises: OSError if chdir or rename fails.