From b6e66ebdf76c56b4a893c0687f91d1e6dd9cac2d Mon Sep 17 00:00:00 2001 From: Eli Bendersky Date: Thu, 28 Nov 2013 06:53:05 -0800 Subject: [PATCH] Some minor clarifications in the documentation of pathlib + inheritance diagram --- Doc/library/pathlib-inheritance.png | Bin 0 -> 11280 bytes Doc/library/pathlib.rst | 148 +++++++++++++++------------- 2 files changed, 80 insertions(+), 68 deletions(-) create mode 100644 Doc/library/pathlib-inheritance.png diff --git a/Doc/library/pathlib-inheritance.png b/Doc/library/pathlib-inheritance.png new file mode 100644 index 0000000000000000000000000000000000000000..b81c3deb6049d83051337776fe5c4f3de751e1cb GIT binary patch literal 11280 zc-pOc2|SeB|NqdwC`&4X?5Tug$*#npXp-z}QMQnM9kff9sJK~g21Ayy4cSI2TNq7- zVFpvS$ueU%F^2y$sPFCG?(hHlExaD*jPqIEpU-p7=e*DJ%;U?Kbl7%-cY{D6Ha%Uf zDgP{f?Y`S{=pb_pf6nZi46gK60s7}+{01G{_259rqJCjJ2d%r>g=<* zEx6-rfKpoU$lzHFHx*5XEp!h|)di(F!bqrYDMU8t|L7+i z|B&~+AGGu6pA7S=EpIQ5QYuKHilC$62FVI)aWkN^a-a+rkk%GKAPX5R>}(*QgWc=` zorvuqcD8V*%`VW<+5&U{rH$@iv^Tnc(cb9(MVpP2nmSDRjsMg@&WLM9u^{mgW$qgNvN=n*$I`8y?L&U9GM{C3Wq8gE zHqSAM7~<5iYvwWo?SIp)h(2t*cKcB=|&MILAF*0P#qI~jwv2TKDRJ*j`(>-rIhjL17CH*FQu)#K+ot^hO5m0I8bb*lR zdOI4mzgD9}RQX`^($O#rKc)?_Z?$tI%Ouqb<+G;rJWrN;iY+Xj7y${;y6dtHP{L z-CkbUWg9ZnV0ZK8O$^#A|Iz+BM%M^xuHihUGPovc6xV?-usoCGWj?VNsgyB83Z`Ng zimmjeulwAVL?Ilun5|r`#}6UJYpo|DAiK#;@BQG%rH+@|MyHQwA2pVvlIk>is(dG$ zu8Q#cDb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Z1(NXWZL+6q>V^tNqCWOzS8uK7= zt}>xr1>mpE@;K!pE7O*96bTe6`{l$l5hZt;k$6AYHXWA>emU_(Yb1#fWcmD5mVlG1 zOZUs+zKH-HJq&CTI8q+fm0MnofsjZ~BV_QT*qj8xTV&DdbYo<~uoGGIqTsSc0nG_v z>ylI4Z!#D!^qHz&bsm0vYrlPWja#ZM?RcijeKUNLQmJ(T}o zm~!tzv=q*#Aw&|scPx|W7WieSm?XtV=l-jH8&np$5XC(A*n9S>bztGjZLgW{t=EdbcK<&$_jjhz7ly|Lcxe1&$BFz2P zT>3)NDKUBoE`v`FSze@5RuC0ov8BK?zWC{WhL~qnQ@%+y5uM#u<6%j%t(~B^`C-(^ z@!pa1!;FPQR(hex<5cWpD_72}hsvet2ktK-_bmc*RS=w~!)O@tb2E!BDqj!^958)E zP<6L8S~yN`r?t=*pWV#$<%oGL>joQ_s>;V_byDbM7BR#a)nT(ZxO;88uXb7q64y@+ zdV>aQ*haT0nfAN8I*`ECxAMR*U2|aSc@VTznB?={l8du{XCl7}{jXUQ^Y3qj&uysu zjtKo1+~zkt>;Fr}PO)ToYKZ^o{Or@inb7mJ$iW>N-|NFZ?s3y3)O`&2?|lz8z`, which provide purely computational operations without I/O, and :ref:`concrete paths `, which inherit from pure paths but also provide I/O operations. -The main point of entry is the :class:`Path` class, which will instantiate -a :ref:`concrete path ` for the current platform. +.. image:: pathlib-inheritance.png + :align: center + +If you've never used this module before or just aren't sure which class is +right for your task, :class:`Path` is most likely what you need. It instantiates +a :ref:`concrete path ` for the platform the code is running on. + +Pure paths are useful in some special cases; for example: + +#. If you want to manipulate Windows paths on a Unix machine (or vice versa). + You cannot instantiate a :class:`WindowsPath` when running on Unix, but you + can instantiate :class:`PureWindowsPath`. +#. You want to make sure that your code only manipulates paths without actually + accessing the OS. In this case, instantiating one of the pure classes may be + useful since those simply don't have any OS-accessing operations. .. note:: This module has been included in the standard library on a @@ -86,82 +98,78 @@ Pure path objects provide path-handling operations which don't actually access a filesystem. There are three ways to access these classes, which we also call *flavours*: +.. class:: PurePath(*pathsegments) -.. class:: PurePosixPath - - A subclass of :class:`PurePath`, this path flavour represents non-Windows - filesystem paths:: - - >>> PurePosixPath('/etc') - PurePosixPath('/etc') + A generic class that represents the system's path flavour (instantiating + it creates either a :class:`PurePosixPath` or a :class:`PureWindowsPath`):: -.. class:: PureWindowsPath + >>> PurePath('setup.py') # Running on a Unix machine + PurePosixPath('setup.py') - A subclass of :class:`PurePath`, this path flavour represents Windows - filesystem paths:: + Each element of *pathsegments* can be either a string or bytes object + representing a path segment; it can also be another path object:: - >>> PureWindowsPath('c:/Program Files/') - PureWindowsPath('c:/Program Files') + >>> PurePath('foo', 'some/path', 'bar') + PurePosixPath('foo/some/path/bar') + >>> PurePath(Path('foo'), Path('bar')) + PurePosixPath('foo/bar') -.. class:: PurePath + When *pathsegments* is empty, the current directory is assumed:: - A generic class that represents the system's path flavour (instantiating - it creates either a :class:`PurePosixPath` or a :class:`PureWindowsPath`):: + >>> PurePath() + PurePosixPath('.') - >>> PurePath('setup.py') - PurePosixPath('setup.py') + When several absolute paths are given, the last is taken as an anchor + (mimicking :func:`os.path.join`'s behaviour):: + >>> PurePath('/etc', '/usr', 'lib64') + PurePosixPath('/usr/lib64') + >>> PureWindowsPath('c:/Windows', 'd:bar') + PureWindowsPath('d:bar') -Regardless of the system you're running on, you can instantiate all of -these classes, since they don't provide any operation that does system calls. + However, in a Windows path, changing the local root doesn't discard the + previous drive setting:: + >>> PureWindowsPath('c:/Windows', '/Program Files') + PureWindowsPath('c:/Program Files') -Constructing paths -^^^^^^^^^^^^^^^^^^ + Spurious slashes and single dots are collapsed, but double dots (``'..'``) + are not, since this would change the meaning of a path in the face of + symbolic links:: -Path constructors accept an arbitrary number of positional arguments. -When called without any argument, a path object points to the current -directory:: + >>> PurePath('foo//bar') + PurePosixPath('foo/bar') + >>> PurePath('foo/./bar') + PurePosixPath('foo/bar') + >>> PurePath('foo/../bar') + PurePosixPath('foo/../bar') - >>> PurePath() - PurePosixPath('.') + (a naïve approach would make ``PurePosixPath('foo/../bar')`` equivalent + to ``PurePosixPath('bar')``, which is wrong if ``foo`` is a symbolic link + to another directory) -Any argument can be a string or bytes object representing an arbitrary number -of path segments, but it can also be another path object:: +.. class:: PurePosixPath(*pathsegments) - >>> PurePath('foo', 'some/path', 'bar') - PurePosixPath('foo/some/path/bar') - >>> PurePath(Path('foo'), Path('bar')) - PurePosixPath('foo/bar') + A subclass of :class:`PurePath`, this path flavour represents non-Windows + filesystem paths:: -When several absolute paths are given, the last is taken as an anchor -(mimicking :func:`os.path.join`'s behaviour):: + >>> PurePosixPath('/etc') + PurePosixPath('/etc') - >>> PurePath('/etc', '/usr', 'lib64') - PurePosixPath('/usr/lib64') - >>> PureWindowsPath('c:/Windows', 'd:bar') - PureWindowsPath('d:bar') + *pathsegments* is specified similarly to :class:`PurePath`. -However, in a Windows path, changing the local root doesn't discard the -previous drive setting:: +.. class:: PureWindowsPath(*pathsegments) - >>> PureWindowsPath('c:/Windows', '/Program Files') - PureWindowsPath('c:/Program Files') + A subclass of :class:`PurePath`, this path flavour represents Windows + filesystem paths:: -Spurious slashes and single dots are collapsed, but double dots (``'..'``) -are not, since this would change the meaning of a path in the face of -symbolic links:: + >>> PureWindowsPath('c:/Program Files/') + PureWindowsPath('c:/Program Files') - >>> PurePath('foo//bar') - PurePosixPath('foo/bar') - >>> PurePath('foo/./bar') - PurePosixPath('foo/bar') - >>> PurePath('foo/../bar') - PurePosixPath('foo/../bar') + *pathsegments* is specified similarly to :class:`PurePath`. -(a naïve approach would make ``PurePosixPath('foo/../bar')`` equivalent -to ``PurePosixPath('bar')``, which is wrong if ``foo`` is a symbolic link -to another directory) +Regardless of the system you're running on, you can instantiate all of +these classes, since they don't provide any operation that does system calls. General properties @@ -524,8 +532,18 @@ Concrete paths are subclasses of the pure path classes. In addition to operations provided by the latter, they also provide methods to do system calls on path objects. There are three ways to instantiate concrete paths: +.. class:: Path(*pathsegments) + + A subclass of :class:`PurePath`, this class represents concrete paths of + the system's path flavour (instantiating it creates either a + :class:`PosixPath` or a :class:`WindowsPath`):: + + >>> Path('setup.py') + PosixPath('setup.py') + + *pathsegments* is specified similarly to :class:`PurePath`. -.. class:: PosixPath +.. class:: PosixPath(*pathsegments) A subclass of :class:`Path` and :class:`PurePosixPath`, this class represents concrete non-Windows filesystem paths:: @@ -533,7 +551,9 @@ calls on path objects. There are three ways to instantiate concrete paths: >>> PosixPath('/etc') PosixPath('/etc') -.. class:: WindowsPath + *pathsegments* is specified similarly to :class:`PurePath`. + +.. class:: WindowsPath(*pathsegments) A subclass of :class:`Path` and :class:`PureWindowsPath`, this class represents concrete Windows filesystem paths:: @@ -541,15 +561,7 @@ calls on path objects. There are three ways to instantiate concrete paths: >>> WindowsPath('c:/Program Files/') WindowsPath('c:/Program Files') -.. class:: Path - - A subclass of :class:`PurePath`, this class represents concrete paths of - the system's path flavour (instantiating it creates either a - :class:`PosixPath` or a :class:`WindowsPath`):: - - >>> Path('setup.py') - PosixPath('setup.py') - + *pathsegments* is specified similarly to :class:`PurePath`. You can only instantiate the class flavour that corresponds to your system (allowing system calls on non-compatible path flavours could lead to -- 2.47.3