Joshua Cannon added the comment:
Pretty much the same reason you would want to slice any other sequence. You
want some range of values.
top_most_3_dirs = myPath.parents[-3:]
grandparents_and_beyond = myPath.parents[1:]
The same goes for negative indexes
Joshua Cannon added the comment:
> it may explain why negative indices or slices were initially not implemented:
> It already looks like the result of a slice.
Sure the values of the sequence could be thought of as being increasingly
smaller slices of some other sequence, however I
Joshua Cannon added the comment:
I created issue35498 about .parents rejecting slices as well. (It was pointed
out this discussion would probably decide that issue's fate)
I think that .parents looking like a duck, but not quacking like one isn't very
pythonic.
Besides, the
Joshua Cannon added the comment:
If it is deemed a bug which needs to be fixed, I've gone ahead and attached the
PR to fix it.
CLA signage is pending approval at the company I work for, with most people out
for the holidays (so it might be a day or two turna
Change by Joshua Cannon :
--
keywords: +patch
pull_requests: +10401
stage: -> patch review
___
Python tracker
<https://bugs.python.org/issue35498>
___
___
Py
New submission from Joshua Cannon :
I would expect the following to work:
```
>>> import pathlib
>>> pathlib.Path.cwd().parents[0:1]
Traceback (most recent call last):
File "", line 1, in
File "...\Python36\lib\pathlib.py", line 593, in __getit