[issue33102] get the nth folder of a given path

Eric V. Smith report at bugs.python.org
Mon Mar 19 09:57:14 EDT 2018


Eric V. Smith <eric at trueblade.com> added the comment:

Path.parents will do what you want. I don't have a Windows box handy, but this is on MacOS:

>>> from pathlib import Path
>>> p = Path("/Users/User/AppData/Local/Programs/Python/Python36/Lib/asyncio/__init__.py")
>>> p.parents[1]
PosixPath('/Users/User/AppData/Local/Programs/Python/Python36/Lib')
>>>

----------
nosy: +eric.smith

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue33102>
_______________________________________


More information about the Python-bugs-list mailing list