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

Joshua Cannon report at bugs.python.org
Fri Dec 14 11:55:17 EST 2018


New submission from Joshua Cannon <joshdcannon at gmail.com>:

I would expect the following to work:
```
>>> import pathlib
>>> pathlib.Path.cwd().parents[0:1]
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.

----------
components: Library (Lib)
messages: 331841
nosy: thejcannon
priority: normal
severity: normal
status: open
title: Parents objects in pathlib.Path don't support slices as __getitem__ arguments
type: enhancement
versions: Python 3.6

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue35498>
_______________________________________


More information about the New-bugs-announce mailing list