Return a new path with the stem changed.
(self, stem)
| 415 | return self._from_parsed_parts(self.drive, self.root, tail) |
| 416 | |
| 417 | def with_stem(self, stem): |
| 418 | """Return a new path with the stem changed.""" |
| 419 | suffix = self.suffix |
| 420 | if not suffix: |
| 421 | return self.with_name(stem) |
| 422 | elif not stem: |
| 423 | # If the suffix is non-empty, we can't make the stem empty. |
| 424 | raise ValueError(f"{self!r} has a non-empty suffix") |
| 425 | else: |
| 426 | return self.with_name(stem + suffix) |
| 427 | |
| 428 | def with_suffix(self, suffix): |
| 429 | """Return a new path with the file suffix changed. If the path |