[New-bugs-announce] [issue43213] Shortcut for checking if PurePath object contains str

Tomas Gustavsson report at bugs.python.org
Fri Feb 12 23:44:50 EST 2021


New submission from Tomas Gustavsson <tomplast at gmail.com>:

While using pathlib I realised there are situations where I easily want to check if part of a returned path object contains a particular given path (as a string).

Today the following will give an error:
...
path = PosixPath('/usr/share/doc/')
if 'share' in path:
....print('Do something')

The patch will make the example above work and will open up for a simple shortcut.

This is my first attempt to contribute, all opinions are very welcome.

I have also pushed the commit to my own branch https://github.com/tomplast/cpython/tree/implement-path-contains.

----------
components: Library (Lib)
messages: 386904
nosy: tomplast
priority: normal
severity: normal
status: open
title: Shortcut for checking if  PurePath object contains str
versions: Python 3.10

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


More information about the New-bugs-announce mailing list