Replace subscription with slashing
This commit is contained in:
parent
7b8178a28b
commit
ee6f30d19a
12
pep-0428.txt
12
pep-0428.txt
|
@ -360,20 +360,22 @@ Deriving new paths
|
|||
Joining
|
||||
^^^^^^^
|
||||
|
||||
A path can be joined with another using the ``__getitem__`` operator::
|
||||
A path can be joined with another using the ``/`` operator::
|
||||
|
||||
>>> p = PurePosixPath('foo')
|
||||
>>> p['bar']
|
||||
>>> p / 'bar'
|
||||
PurePosixPath('foo/bar')
|
||||
>>> p[PurePosixPath('bar')]
|
||||
>>> p / PurePosixPath('bar')
|
||||
PurePosixPath('foo/bar')
|
||||
>>> 'bar' / p
|
||||
PurePosixPath('bar/foo')
|
||||
|
||||
As with the constructor, multiple path components can be specified, either
|
||||
collapsed or separately::
|
||||
|
||||
>>> p['bar/xyzzy']
|
||||
>>> p / 'bar/xyzzy'
|
||||
PurePosixPath('foo/bar/xyzzy')
|
||||
>>> p['bar', 'xyzzy']
|
||||
>>> p / 'bar' / 'xyzzy'
|
||||
PurePosixPath('foo/bar/xyzzy')
|
||||
|
||||
A joinpath() method is also provided, with the same behaviour. It can serve
|
||||
|
|
Loading…
Reference in New Issue