code: def replaceext(filepath, new_ext):
      
      if new_ext and new_ext[0] != '.':
          new_ext = '.' + new_ext
  
      root, ext = os.path.splitext(safepath(filepath))
      return root + new_ext
docs: Replace any existing file extension with a new one
  
      Example::
  
          >>> replaceext('/foo/bar.txt', 'py')
          '/foo/bar.py'
          >>> replaceext('/foo/bar.txt', '.doc')
          '/foo/bar.doc'
  
      Args:
          filepath (str, path): file path
          new_ext (str): new file extension; if a leading dot is not included,
              it will be added.
  
      Returns:
          Tuple[str]