rdmur...@bitdance.com wrote:
Quoth Tim Chase <t...@thechases.com>:
PS: as an aside, how do I import just the fnmatch function? I tried both of the following and neither worked:

   from glob.fnmatch import fnmatch
   from glob import fnmatch.fnmatch

I finally resorted to the contortion coded below in favor of
   import glob
   fnmatch = glob.fnmatch.fnmatch

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>

-tkc



--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to