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

Method with_name

Lib/pathlib/__init__.py:408–417  ·  view source on GitHub ↗

Return a new path with the file name changed.

(self, name)

Source from the content-addressed store, hash-verified

406 return tail[-1]
407
408 def with_name(self, name):
409 """Return a new path with the file name changed."""
410 p = self.parser
411 if not name or p.sep in name or (p.altsep and p.altsep in name) or name == '.':
412 raise ValueError(f"Invalid name {name!r}")
413 tail = self._tail.copy()
414 if not tail:
415 raise ValueError(f"{self!r} has an empty name")
416 tail[-1] = name
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."""

Callers 8

with_stemMethod · 0.95
with_suffixMethod · 0.95
test_with_segmentsMethod · 0.45
test_with_nameMethod · 0.45
test_with_nameMethod · 0.45
test_bytesMethod · 0.45
mainFunction · 0.45

Calls 2

_from_parsed_partsMethod · 0.95
copyMethod · 0.45

Tested by 5

test_with_segmentsMethod · 0.36
test_with_nameMethod · 0.36
test_with_nameMethod · 0.36
test_bytesMethod · 0.36