[Python-checkins] peps: Replace subscription with slashing
antoine.pitrou
python-checkins at python.org
Wed Nov 7 20:26:06 CET 2012
http://hg.python.org/peps/rev/0879efc1ea42
changeset: 4580:0879efc1ea42
user: Antoine Pitrou <solipsis at pitrou.net>
date: Wed Nov 07 20:25:27 2012 +0100
summary:
Replace subscription with slashing
files:
pep-0428.txt | 12 +++++++-----
1 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/pep-0428.txt b/pep-0428.txt
--- a/pep-0428.txt
+++ b/pep-0428.txt
@@ -360,20 +360,22 @@
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
--
Repository URL: http://hg.python.org/peps
More information about the Python-checkins
mailing list