[issue45889] pathlib: Path.match does not work on paths

2021-12-01 Thread Nick Papior
Nick Papior added the comment: Ok, I can accept a no-fix ;) I'll close this. -- resolution: -> wont fix stage: -> resolved status: open -> closed ___ Python tracker ___

[issue45889] pathlib: Path.match does not work on paths

2021-12-01 Thread Eric V. Smith
Eric V. Smith added the comment: I agree with Éric and Ronald. -- nosy: +eric.smith ___ Python tracker ___ ___ Python-bugs-list

[issue45889] pathlib: Path.match does not work on paths

2021-11-26 Thread Éric Araujo
Éric Araujo added the comment: FWIW I think in the same way as Ronald. A pattern is not a path, it’s a string expressing rules. If it matches, the results are paths, but that does not make the pattern a path. -- nosy: +eric.araujo ___ Python

[issue45889] pathlib: Path.match does not work on paths

2021-11-24 Thread Nick Papior
Nick Papior added the comment: Thanks for the discussion. -- ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue45889] pathlib: Path.match does not work on paths

2021-11-24 Thread Ronald Oussoren
Ronald Oussoren added the comment: I don't think our opinions about this will converge, I'm therefore leaving this discussion. >> would ``Path("dir/some.py").match(Path("*.py"))`` return? > > str(Path("*.py")) == "*.py" > > So no problems here. I do think this is a problem, treating a Path

[issue45889] pathlib: Path.match does not work on paths

2021-11-24 Thread Nick Papior
Nick Papior added the comment: It basically checks that some part of the path is the same as some part of a reference path, they need not have the same complete parent which is why the resolve command would negate this comparison always. -- As for your last example, that will be quite

[issue45889] pathlib: Path.match does not work on paths

2021-11-24 Thread Ronald Oussoren
Ronald Oussoren added the comment: I'm not sure what your code tries to accomplish, does it check that ``f.parent`` refers to the same location as ``ref_file``? A clearer solution for that would be ``f.parent.resolve() == ref_file.resolve()``. The argument to match, glob and rglob

[issue45889] pathlib: Path.match does not work on paths

2021-11-24 Thread Nick Papior
Nick Papior 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,

[issue45889] pathlib: Path.match does not work on paths

2021-11-24 Thread Ronald Oussoren
Ronald Oussoren added the comment: Match doesn't match paths, but basically does a regular expression match on the textual representation (using glob syntax instead of normal regular expression syntax). Because of this I don't agree with your idea that anything that can match a path is a

[issue45889] pathlib: Path.match does not work on paths

2021-11-24 Thread Nick Papior
Nick Papior added the comment: Ok, I see this a feature. :) As for why it is desirable. A part of a path is still a path, and matching for something must mean that you are matching a partial path. Even if you use '*.py' as the pattern this would still make sense as a path: path =

[issue45889] pathlib: Path.match does not work on paths

2021-11-24 Thread Ronald Oussoren
Ronald Oussoren added the comment: This would definitely be a new feature and not something that can be back ported. That said, I don't understand why it is desirable to use a Path as the match argument. That argument is a glob pattern (such as "*.py") and not a file name . --

[issue45889] pathlib: Path.match does not work on paths

2021-11-23 Thread Nick Papior
New submission from Nick Papior : The documentation of Path.match only says it will match a pattern. But quite often this pattern may be desirable to have as a Path as well. import pathlib as pl path = pl.Path("foo/bar") print(path.match("bar")) print(path.match(pl.Path("bar"))) However,