fnmatch() vs. glob.glob()

Ben Finney ben+python at benfinney.id.au
Mon Mar 7 20:49:56 EST 2016


Jinghui Niu <niujinghui at gmail.com> writes:

> Let me try to describe the behaviours as much as I can here: It is a
> real-time search, updating the search result as you type; It is very
> smart, not limiting itself into the verbatim words, but extracting
> feature strings automatically, e.g., typing "fontz" will match not
> just "*fontz*", but also "font-size", "fontzipper", etc; It can be
> switched for certain type of files according specific rules, such as
> not including ".pyc" files.

None of that really depends on the difference between ‘glob’ versus
‘fnmatch’. Either of them could be at the bowels of an implementation of
the behaviour you describe.

> My gut feeling is that it is using Regex, but just wonder how I can
> fit Regex into either fnmatch() or glob() module.

You don't. Those two are *much* lower level than the behaviour you
describe, and don't have anything to say about that behaviour.

You will need all the extra framework implementing all the other stuff
you describe, before you make any decision between ‘fnmatch’ versus
‘glob’.

-- 
 \             “Skepticism is the highest duty and blind faith the one |
  `\               unpardonable sin.” —Thomas Henry Huxley, _Essays on |
_o__)                                   Controversial Questions_, 1889 |
Ben Finney




More information about the Python-list mailing list