[issue35314] fnmatch failed with leading caret (^)

2018-11-26 Thread Cyker Way
Cyker Way added the comment: Thank you for confirmation. Knowing it is not fully POSIX-compliant helps with understanding. I'm asking this because I had interoperability issues writing python scripts providing shell-like utilities for filename expansion and the result may surprise users. Th

[issue35314] fnmatch failed with leading caret (^)

2018-11-26 Thread Josh Rosenberg
Josh Rosenberg added the comment: Finished typing this while Serhiy was closing, but just for further explanation: This isn't a bug. fnmatch provides "shell-style" wildcards, but that doesn't mean it supports every shell's extensions to the globbing syntax. It doesn't even claim support for

[issue35314] fnmatch failed with leading caret (^)

2018-11-26 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: '^' is not considered as a special character in shell-style wildcards. Use '!' for negating the character set: '[!b].py'. https://docs.python.org/3/library/fnmatch.html `man bash` describes the behavior of Bash, not Python. -- nosy: +serhiy.storch

[issue35314] fnmatch failed with leading caret (^)

2018-11-26 Thread Karthikeyan Singaravelan
Change by Karthikeyan Singaravelan : -- nosy: +xtreak ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https:/

[issue35314] fnmatch failed with leading caret (^)

2018-11-26 Thread Cyker Way
New submission from Cyker Way : 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