[Python-checkins] peps: "parents" is now a sequence property providing access to the path's ancestors
antoine.pitrou
python-checkins at python.org
Tue Nov 19 21:51:23 CET 2013
http://hg.python.org/peps/rev/fc4d7db90ff2
changeset: 5293:fc4d7db90ff2
user: Antoine Pitrou <solipsis at pitrou.net>
date: Tue Nov 19 21:51:19 2013 +0100
summary:
"parents" is now a sequence property providing access to the path's ancestors
files:
pep-0428.txt | 11 +++++++----
1 files changed, 7 insertions(+), 4 deletions(-)
diff --git a/pep-0428.txt b/pep-0428.txt
--- a/pep-0428.txt
+++ b/pep-0428.txt
@@ -493,14 +493,17 @@
>>> p.parent(3)
PureWindowsPath('c:/')
-The ``parents()`` method automates repeated invocations of ``parent()``, until
-the anchor is reached::
+The ``parents`` property returns an immutable sequence of the path's
+logical ancestors::
>>> p = PureWindowsPath('c:/python33/bin/python.exe')
- >>> for parent in p.parents(): parent
- ...
+ >>> len(p.parents)
+ 3
+ >>> p.parents[0]
PureWindowsPath('c:/python33/bin')
+ >>> p.parents[1]
PureWindowsPath('c:/python33')
+ >>> p.parents[2]
PureWindowsPath('c:/')
--
Repository URL: http://hg.python.org/peps
More information about the Python-checkins
mailing list