[issue43213] Shortcut for checking if PurePath object contains str

2021-02-13 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: I guess that you need to use the parts attribute. Note that `'share' in str(path)` and `'share' in path.parts` are two very different things, even if they can give the same result in some cases. When reply be email, please remove the quoted text. It makes

[issue43213] Shortcut for checking if PurePath object contains str

2021-02-13 Thread Tomas Gustavsson
Tomas Gustavsson added the comment: Sorry Serhiy, missed your answer there. I understand your point. I guess I'll have to look for other things to help with :) Thank you for the answer. Guess this can be closed then. Best regards Tomas On Sat, 13 Feb 2021, 12:57 Serhiy Storchaka wrote: >

[issue43213] Shortcut for checking if PurePath object contains str

2021-02-13 Thread Tomas Gustavsson
Tomas Gustavsson added the comment: Okay, maybe a bad example. But let's say I want to find all folders and files but filter out those which contains .git,.svn in the paths. Anyhow, I believe this minor feature would make such use cases (and other) more clean and intuitive. I am lazy and I like

[issue43213] Shortcut for checking if PurePath object contains str

2021-02-13 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Path is not string, and it was made not string-like intentionally. Otherwise it would be made a subclass of str. If you want to check whether a string is a substring of the string representation of the path, just do it explicitly: 'share' in str(path). But

[issue43213] Shortcut for checking if PurePath object contains str

2021-02-13 Thread Vedran Čačić
Vedran Čačić added the comment: While it might be useful, I don't think it is what you want. For example, you wouldn't say it contains 'r/sh', right? I think it should only refer to full names of path parts. -- nosy: +veky ___ Python tracker

[issue43213] Shortcut for checking if PurePath object contains str

2021-02-12 Thread Tomas Gustavsson
Change by Tomas Gustavsson : -- keywords: +patch Added file: https://bugs.python.org/file49806/pure_path_contains.patch ___ Python tracker ___ _

[issue43213] Shortcut for checking if PurePath object contains str

2021-02-12 Thread Tomas Gustavsson
New submission from Tomas Gustavsson : 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'