[issue21041] pathlib.PurePath.parents rejects negative indexes

2020-08-10 Thread Yaroslav Pankovych


Yaroslav Pankovych  added the comment:

Here's possible fix: https://github.com/python/cpython/pull/21799

--

___
Python tracker 
<https://bugs.python.org/issue21041>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21041] pathlib.PurePath.parents rejects negative indexes

2020-08-10 Thread Yaroslav Pankovych


Yaroslav Pankovych  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 
<https://bugs.python.org/issue21041>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21041] pathlib.PurePath.parents rejects negative indexes

2020-08-22 Thread Yaroslav Pankovych


Yaroslav Pankovych  added the comment:

Any thoughts about that folks? It's a pretty old bug, let's decide smth for it.

--

___
Python tracker 
<https://bugs.python.org/issue21041>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21041] pathlib.PurePath.parents rejects negative indexes

2020-11-21 Thread Yaroslav Pankovych


Yaroslav Pankovych  added the comment:

That makes sense, but should we have this behaviour only for negative indices? 

We'll end up with something lie:

path.parents[len(path.parents) - 1] != path.parents[-1]

I think that is should be consistent regardless of negative/positive indices.

--

___
Python tracker 
<https://bugs.python.org/issue21041>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21041] pathlib.PurePath.parents rejects negative indexes

2020-11-23 Thread Yaroslav Pankovych


Yaroslav Pankovych  added the comment:

And it looks like a special case, so "Special cases aren't special enough to 
break the rules."

--

___
Python tracker 
<https://bugs.python.org/issue21041>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21041] pathlib.PurePath.parents rejects negative indexes

2020-11-23 Thread Yaroslav Pankovych


Yaroslav Pankovych  added the comment:

Agree with that, it currently supports this behavior.

--

___
Python tracker 
<https://bugs.python.org/issue21041>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com