Hello,

I would like fnmatch.fnmatch to have a mode where:
** matches any files and zero or more directories and subdirectories (i.e. the current behaviour of *)
    *       matches in one path level/only to the next path separator

This is essentially achievable in glob.glob from version 3.5 (with recursive=True), but glob is not suitable for my use case, as I need to work with strings and not files. I would like to gauge whether adding such behaviour behind an optional argument similar to glob's "recursive" (e.g. "glob_asterisks=False") is likely to be accepted into the standard library, before I start working on a patch.

I have seen people raise the question of how to achieve this in a number of places. Somebody has also forked the Python 2 standard library fnmatch module to implement this as a standalone library:
https://github.com/kianxineki/python-wildcard
(which shows that the actual changes are likely to be pretty small).

This request is also discussed in the following bug:
http://bugs.python.org/issue28718

Not directly on point, but some may find the discussion interesting:
http://stackoverflow.com/questions/18341848/fnmatch-and-recursive-path-match-with http://stackoverflow.com/questions/27726545/python-glob-but-against-a-list-of-strings-rather-than-the-filesystem

I would appreciate any thoughts.

Kind regards,

Aaron

_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to