fnmatch() vs. glob.glob()

Jinghui Niu niujinghui at gmail.com
Mon Mar 7 20:37:12 EST 2016


On Monday, March 7, 2016 at 5:16:44 PM UTC-8, Ben Finney wrote:
> Jinghui Niu <niujinghui at gmail.com> writes:
> 
> > May I take this opportunity to ask a bold question for a beginner
> 
> No problem, your questions are on topic here. Thank you for being civil.
> 
> > if I want to mimic Sublime Text's fuzzy search for a file search in
> > given directories, which module of these two would be more suitable?
> 
> You'll need to describe the requirements, I don't know exactly what that
> behaviour is.
> 
> -- 
>  \      "He that loveth father or mother more than me is not worthy of |
>   `\        me: and he that loveth son or daughter more than me is not |
> _o__)                worthy of me." --Jesus, as quoted in Matthew 10:37 |
> Ben Finney

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.

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



More information about the Python-list mailing list