You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
assignee=Noneclosed_at=<Date2020-11-20.15:46:16.796>created_at=<Date2018-12-14.16:55:17.375>labels= ['type-feature', 'library', '3.10']
title="Parents objects in pathlib.Path don't support slices as __getitem__ arguments"updated_at=<Date2020-11-23.20:06:38.266>user='https://github.com/thejcannon'
>>> import pathlib
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "...\Python36\lib\pathlib.py", line 593, in __getitem__
if idx < 0 or idx >= len(self):
TypeError: '<' not supported between instances of 'slice' and 'int'
Since pathlib documents parents as a sequence-type, and slicing a sequence is pretty standard behavior.
One question I would have about this is that .parents is a lazily-calculated sequence, not a list or a tuple, so it's not immediately obvious what the return type of a slice would be. I don't think it makes sense to return, e.g. a _PathParents object with fewer parts, but I don't know if there's any traditional choice here, other than that the result of slicing Sequence is another Sequence.
The PR returns a list, but I'm inclined to say we should return a tuple.