MCPcopy Index your code
hub / github.com/RustPython/RustPython / with_name

Method with_name

Lib/pathlib/__init__.py:406–415  ·  view source on GitHub ↗

Return a new path with the file name changed.

(self, name)

Source from the content-addressed store, hash-verified

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

Callers 7

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

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