mutapath.Path.copying

Path.copying(lock=True, timeout=1, method: Callable[[Path, Path], Path] = <function copy>)[source]

Create a copying context for this immutable path. The external value is only changed if the copying succeeds.

Parameters
  • timeout – the timeout in seconds how long the lock file should be acquired

  • lock – if the source file should be locked as long as this context is open

  • method – an alternative method that copies the path and returns the new path (e.g., shutil.copy2)

Example

>>> with Path('/home/doe/folder/a.txt').copying() as mut:
...     mut.stem = "b"
Path('/home/doe/folder/b.txt')