[Python-ideas] pathlib.Path.parts - tuple of path objects rather than strings?
Tal Einat
taleinat at gmail.com
Tue Mar 24 14:44:39 CET 2015
On Tue, Mar 24, 2015 at 2:39 PM, Markus Unterwaditzer
<markus at unterwaditzer.net> wrote:
>
> I'd suggest that an additional property is added where:
>
> Path("/usr/bin/true").newproperty == (Path("/"),
> Path("/usr"),
> Path("/usr/bin"),
> Path("/usr/bin/true"))
>
> I.e. each part is a prefix of the next one.
Path.parents already exists:
Python 3.4.2 (default, Feb 23 2015, 21:16:28)
[GCC 4.2.1 Compatible Apple LLVM 5.1 (clang-503.0.40)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import pathlib
>>> list(pathlib.Path("/usr/bin/true").parents)
[PosixPath('/usr/bin'), PosixPath('/usr'), PosixPath('/')]
- Tal Einat
More information about the Python-ideas
mailing list