[issue21041] pathlib.PurePath.parents rejects negative indexes
Yaroslav Pankovych
report at bugs.python.org
Mon Aug 10 03:25:09 EDT 2020
Yaroslav Pankovych <flower.moor at gmail.com> added the comment:
That's kinda weird for python. I mean, in regular list/etc if I need the last element, I'd normally do list[-1], but here to get the last parent, I need to actually know how many parents do I have.
So now, I can do something like this:
>>> parents_count = len(path.parents) - 1
>>> path.parents[parents_count]
PosixPath('.')
----------
message_count: 16.0 -> 17.0
nosy: +ypank
nosy_count: 10.0 -> 11.0
pull_requests: +20938
stage: -> patch review
versions: +Python 3.10, Python 3.5, Python 3.6, Python 3.7, Python 3.9
pull_request: https://github.com/python/cpython/pull/21799
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue21041>
_______________________________________
More information about the Python-bugs-list
mailing list