[New-bugs-announce] [issue45889] pathlib: Path.match does not work on paths

Nick Papior report at bugs.python.org
Wed Nov 24 02:54:31 EST 2021


New submission from Nick Papior <nickpapior at gmail.com>:

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, the last one fails and one has to resort to 

print(path.match(str(pl.Path("bar"))))

which in my opinion is a little misleading.

I couldn't find any other bug/enhancement report of this. Also, this probably also targets later versions.

----------
components: Library (Lib)
messages: 406910
nosy: nickpapior
priority: normal
severity: normal
status: open
title: pathlib: Path.match does not work on paths
type: enhancement
versions: Python 3.6, Python 3.7, Python 3.8, Python 3.9

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue45889>
_______________________________________


More information about the New-bugs-announce mailing list