python 2.7.12 on Linux behaving differently than on Windows

Random832 random832 at fastmail.com
Thu Dec 8 11:55:58 EST 2016


On Wed, Dec 7, 2016, at 22:41, Steven D'Aprano wrote:
> Python's fnmatch lib is a good example. It has, or at least had, no
> support for escaping metacharacters. Anyone relying on Python's fnmatch and glob
> modules alone for globbing will be unable to handle legitimate file names.

That's not true. You can "escape" metacharacters by enclosing them in
square brackets, forming a character class of a single character. I've
done the same in SQL, so it occurred to me immediately. But of course
you have to know you have to do this, and it's not immediately obvious
that it will work for the square bracket characters themselves. Other
implementations of globbing (including native windows) don't do this and
don't even *have* square brackets as metacharacters.


More information about the Python-list mailing list