Nick Papior <[email protected]> added the comment:
> Because of this I don't agree with your idea that anything that can match a
> path is a sub-path.
Why not? If a match is True, it means that what is matched must be some kind of
valid path matching a glob specification. Whether it is a regular expression,
or anything else. If one did $(ls pattern) one would list the paths that
matches the pattern, and hence a path. Agreed that the pattern itself is not
necessarily a fixed/single path, but a shell glob path. Yet, matches will
regardless be a path.
As for the use case I want to assert a files path has a parent that matches
another directory/filename something like this:
ref_file = Path("hello")
for f in dir.iterdir():
if f.parent.match(ref_file):
<do something>
in the real application the match is a bit more complex with nested directories
as well as a recursive iterator.
Lastly, you say:
> That said, I don't understand why it is desirable to use a Path as the match
> argument.
I am on the other side:
I don't understand why it is undesirable to use a Path as the match argument.
:)
A simple
if isinstance(pattern, PurePath):
pattern = str(pattern)
would suffice. Or possibly str(pattern.expanduser()) for consistency.
----------
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue45889>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com