MCPcopy Index your code
hub / github.com/python/cpython / with_stem

Method with_stem

Lib/pathlib/__init__.py:419–428  ·  view source on GitHub ↗

Return a new path with the stem changed.

(self, stem)

Source from the content-addressed store, hash-verified

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

Callers 5

test_with_segmentsMethod · 0.45
test_with_stemMethod · 0.45
test_with_stemMethod · 0.45
test_bytesMethod · 0.45

Calls 1

with_nameMethod · 0.95

Tested by 5

test_with_segmentsMethod · 0.36
test_with_stemMethod · 0.36
test_with_stemMethod · 0.36
test_bytesMethod · 0.36