Path objects expose the following features of :mod:`pathlib.Path`
objects:
-Path objects are traversable using the ``/`` operator.
+Path objects are traversable using the ``/`` operator or ``joinpath``.
.. attribute:: Path.name
Read the current file as bytes.
+.. method:: Path.joinpath(*other)
+
+ Return a new Path object with each of the *other* arguments
+ joined. The following are equivalent::
+
+ >>> Path(...).joinpath('child').joinpath('grandchild')
+ >>> Path(...).joinpath('child', 'grandchild')
+ >>> Path(...) / 'child' / 'grandchild'
+
+ .. versionchanged:: 3.10
+ Prior to 3.10, ``joinpath`` was undocumented and accepted
+ exactly one parameter.
+
.. _pyzipfile-objects:
e = root.joinpath("b").joinpath("d").joinpath("e.txt")
assert e.read_text() == "content of e"
+ @pass_alpharep
+ def test_joinpath_multiple(self, alpharep):
+ root = zipfile.Path(alpharep)
+ e = root.joinpath("b", "d", "e.txt")
+ assert e.read_text() == "content of e"
+
@pass_alpharep
def test_traverse_truediv(self, alpharep):
root = zipfile.Path(alpharep)
def __repr__(self):
return self.__repr.format(self=self)
- def joinpath(self, add):
- next = posixpath.join(self.at, add)
+ def joinpath(self, *other):
+ next = posixpath.join(self.at, *other)
return self._next(self.root.resolve_dir(next))
__truediv__ = joinpath
--- /dev/null
+``zipfile.Path.joinpath`` now accepts arbitrary arguments, same as
+``pathlib.Path.joinpath``.