Author nickpapior
Recipients nickpapior, ronaldoussoren
Date 2021-11-24.11:48:28
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
> 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.
Date User Action Args
2021-11-24 11:48:28nickpapiorsetrecipients: + nickpapior, ronaldoussoren
2021-11-24 11:48:28nickpapiorsetmessageid: <>
2021-11-24 11:48:28nickpapiorlinkissue45889 messages
2021-11-24 11:48:28nickpapiorcreate