- Path.renaming(lock=True, timeout=1, method: ~typing.Callable[[str, str], None] = <built-in function rename>)
Create a renaming context for this immutable path. The external value is only changed if the renaming succeeds.
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 renames the path (e.g., os.renames)
>>> with Path('/home/doe/folder/a.txt').renaming() as mut: ... mut.stem = "b" Path('/home/doe/folder/b.txt')