New submission from Tomas Gustavsson <tompl...@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 <rep...@bugs.python.org>
<https://bugs.python.org/issue43213>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to