mutapath.Path.with_base

Path.with_base(base, strip_length: int = 0)[source]

Clone this path with a new base.

The given path is used in its full length as base of this path, if strip_length is not specified.

Example

>>> Path('/home/doe/folder/sub').with_base("/home/joe")
Path('/home/joe/folder/sub')

If strip_length is specified, the given number of path elements are stripped from the left side, and the given base is prepended.

Example

>>> Path('/home/doe/folder/sub').with_base("/home/joe", strip_length=1)
Path('/home/joe/doe/folder/sub')