glob.fnmatch (was "search speed")
rdmurray at bitdance.com
rdmurray at bitdance.com
Sat Jan 31 11:07:08 EST 2009
Quoth Tim Chase <python.list at tim.thechases.com>:
> rdmurray at bitdance.com wrote:
> > What you want is:
> >
> > from fnmatch import fnmatch
>
> Oh, that's head-smackingly obvious now...thanks!
>
> My thought process usually goes something like
>
> """
> I want to do some file-name globbing
>
> there's a glob module that looks like a good place to start
>
> hmm, dir(glob) tells me there's a fnmatch thing that looks like
> what I want according to help(glob.fnmatch)
>
> oh, the fnmatch() function is inside this glob.fnmatch thing
>
> so, I want glob.fnmatch.fnmatch()
> """
>
> It never occurred to me that fnmatch was its own importable
> module. <sheepish grin>
I did a help(glob), saw that fnmatch wasn't in there, did a dir(glob),
saw fnmatch and was puzzled, so I looked up the glob doc page on
docs.python.org for glob. There was a cross reference at the bottom
of the page to fnmatch, and it was only at that point that I went:
"oh, duh" :)
--RDM
More information about the Python-list
mailing list