[issue33301] Add __contains__ to pathlib

2019-01-14 Thread Serhiy Storchaka
Change by Serhiy Storchaka : -- resolution: -> rejected stage: -> resolved status: open -> closed ___ Python tracker ___ ___

[issue33301] Add __contains__ to pathlib

2018-06-19 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: There was a similar (closed) issue about making Path an iterable. The problem with both these related ideas is that they are ambiguous. Does it means that a directory contains a specified file, or that a path contains a specified path component, or that a

[issue33301] Add __contains__ to pathlib

2018-06-19 Thread Andrew Berger
Andrew Berger added the comment: I think the idea is that either a subdir or file could be valid inputs. So `Path('/usr/bar') in Path('/etc/foo')` return True if `Path('/etc/foo/usr/bar')` is either a dir or file. As for PurePath, I did overlook that accessing an inode via a call to stat

[issue33301] Add __contains__ to pathlib

2018-06-19 Thread Antoine Pitrou
Antoine Pitrou added the comment: Not a good idea IMHO. Why would containment mean the existence of a file in a directory? It could just as well mean that a certain path component is part of the path. Also I don't understand what would e.g. `Path('/usr/bar') in Path('/etc/foo')` mean.

[issue33301] Add __contains__ to pathlib

2018-06-18 Thread Andrew Berger
Andrew Berger added the comment: I can make these changes. Would probably add a .exists method to PurePath, using the _normal_accessor.stats staticmethod, then call that in __contains__ -- nosy: +aberger5b ___ Python tracker

[issue33301] Add __contains__ to pathlib

2018-04-17 Thread Barry A. Warsaw
Change by Barry A. Warsaw : -- nosy: +barry ___ Python tracker ___ ___ Python-bugs-list

[issue33301] Add __contains__ to pathlib

2018-04-17 Thread Alok Singh
New submission from Alok Singh : I was thinking today that it would be natural for paths to support __contains__ since then you could write statements like `if file in dir` or `if subdir in dir` cleanly. The library plumbum appears to already have this, but I think it