osdir.com


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Spread a statement over various lines


Am 18.09.2019 um 22:24 schrieb Alexandre Brault:
> 
> On 2019-09-18 4:01 p.m., Ralf M. wrote:
>>
>> I don't know the exact rules of Windows wildcards, so there may be
>> even more cases of unexpected behavior.
>> If anyone knows where to find the complete rules (or a python module
>> that implements them), I would be interested.
>>
> 
> fnmatch in the standard library has a translate function that transforms
> a glob pattern to a regex
> 
> https://docs.python.org/3.7/library/fnmatch.html#fnmatch.translate
> 
> Alex
> 
Thank you for the pointer.
However, from the documentation of module fnmatch:
"This module provides support for Unix shell-style wildcards"

And Unix shell-style wildcards differ from Windows cmd wildcards.
For one, [ ] are special in Unix shells, but not in Windows cmd.
For another, cmd wildcards have several quirks, e.g. *.* matching 
filenames that don't contain a dot, or "a???" matching "ab".

Several years ago, when I needed DOS-style globbing, I copied fnmatch.py 
and glob.py from the standard library and modified them to treat [ ] as 
not special. However, that didn't help with the cmd quirks, and I don't 
even know all the rules about cmd wildcards.

Ralf