search speed

rdmurray at bitdance.com rdmurray at bitdance.com
Fri Jan 30 23:37:50 EST 2009


Quoth Tim Chase <tim at 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

fnmatch is its own module, it just happens to be in the (non __all__)
namespace of the glob module because glob uses it.

--RDM




More information about the Python-list mailing list