[issue35498] Parents objects in pathlib.Path don't support slices as __getitem__ arguments

2019-09-13 Thread Joshua Cannon
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

[issue21041] pathlib.PurePath.parents rejects negative indexes

2019-09-13 Thread Joshua Cannon
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

[issue21041] pathlib.PurePath.parents rejects negative indexes

2018-12-17 Thread Joshua Cannon
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

[issue35498] Parents objects in pathlib.Path don't support slices as __getitem__ arguments

2018-12-14 Thread Joshua Cannon
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

[issue35498] Parents objects in pathlib.Path don't support slices as __getitem__ arguments

2018-12-14 Thread Joshua Cannon
Change by Joshua Cannon : -- keywords: +patch pull_requests: +10401 stage: -> patch review ___ Python tracker <https://bugs.python.org/issue35498> ___ ___ Py

[issue35498] Parents objects in pathlib.Path don't support slices as __getitem__ arguments

2018-12-14 Thread Joshua Cannon
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