This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Torxed
Recipients Torxed
Date 2020-12-27.18:54:36
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1609095276.8.0.751847777656.issue42758@roundup.psfhosted.org>
In-reply-to
Content
I would like to propose that the `pathlib.Path()` gets a `in` operator, much like that ipaddress has IP in Subnet, it would be nice if we could be able to do:

```
import pathlib
pathlib.Path('/home/Torxed/machine.qcow2')
pathlib.Path('/home/Torxed/machine.qcow2') in pathlib.Path('/home/Torxed')
```

Currently that would generate:
```
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: argument of type 'PosixPath' is not iterable
```

This would avoid "complicated" implementations such as:
 * https://stackoverflow.com/questions/21411904/python-how-to-check-if-path-is-a-subpath
 * https://stackoverflow.com/questions/3812849/how-to-check-whether-a-directory-is-a-sub-directory-of-another-directory

Which tend to be half-complete truths and would result in potential security issues. pathlib.Path() could help prevent some of those.
History
Date User Action Args
2020-12-27 18:54:36Torxedsetrecipients: + Torxed
2020-12-27 18:54:36Torxedsetmessageid: <1609095276.8.0.751847777656.issue42758@roundup.psfhosted.org>
2020-12-27 18:54:36Torxedlinkissue42758 messages
2020-12-27 18:54:36Torxedcreate