[Tutor] Better way - fnmatch with list ? CORRECTION
Damon Timm
damontimm at gmail.com
Sun Jan 4 00:57:52 CET 2009
On Sat, Jan 3, 2009 at 4:35 PM, Mark Tolonen <metolone+gmane at gmail.com> wrote:
> fnmatch already takes into account systems with case-sensitive filenames:
>
>>>> help(fnmatch.fnmatch)
>
> Help on function fnmatch in module fnmatch:
>
> fnmatch(name, pat)
> Test whether FILENAME matches PATTERN.
>
> Patterns are Unix shell style:
>
> * matches everything
> ? matches any single character
> [seq] matches any character in seq
> [!seq] matches any char not in seq
>
> An initial period in FILENAME is not special.
> Both FILENAME and PATTERN are first case-normalized
> if the operating system requires it.
> If you don't want this, use fnmatchcase(FILENAME, PATTERN).
>
> -Mark
Hey Mark - thanks for your reply and the details ... I saw fnmatch did
*not* match case (which was great) ... but it also couldn't match any
item from another list of items ... had to do a single PATTERN at a
time ... that's why it was suggested I try to use the ext matching
from os.path.splitext() ... and why I needed to drop it to lowercase.
It seems like that is the easiest way to search for a match among a
list of file systems ...
Thanks! Damon
>
>
> _______________________________________________
> Tutor maillist - Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
>
More information about the Tutor
mailing list