Author cykerway
Recipients cykerway
Date 2018-11-26.10:58:12
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1543229892.22.0.788709270274.issue35314@psf.upfronthosting.co.za>
In-reply-to
Content
In short, `fnmatch.fnmatch` doesn't match shell result. To test this, create a dir with 2 files: `a.py` and `b.py`. Then `ls [!b].py` and `ls [^b].py` will both show `a.py`. However, `fnmatch.fnmatch('a.py', '[!b].py')` returns `True` but `fnmatch.fnmatch('a.py', '[^b].py')` returns `False`.

Problem seems to come from an escaped caret: https://github.com/python/cpython/blob/master/Lib/fnmatch.py#L124

I don't see why caret and exclamation mark are different from `man bash`:

>   ...If the first character following the [ is a !  or a ^ then any character not enclosed is matched...

Could someone please confirm it's a bug or intended behavior?
History
Date User Action Args
2018-11-26 10:58:12cykerwaysetrecipients: + cykerway
2018-11-26 10:58:12cykerwaysetmessageid: <1543229892.22.0.788709270274.issue35314@psf.upfronthosting.co.za>
2018-11-26 10:58:12cykerwaylinkissue35314 messages
2018-11-26 10:58:12cykerwaycreate