Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: MRAB Newsgroups: comp.lang.python Subject: Re: fnmatch() vs. glob.glob() Date: Tue, 8 Mar 2016 02:35:22 +0000 Lines: 29 Message-ID: References: <14061576-1c44-49bb-a27b-279e43258f06@googlegroups.com> <7475bb64-b2e7-45ff-a94e-dbc62f658fab@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: news.uni-berlin.de LzUEkb2PGdYb9s/JEDwDtgKBNsuSJqOy7PCoUJt4QcCg== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.014 X-Spam-Evidence: '*H*': 0.97; '*S*': 0.00; 'e.g.,': 0.07; 'verbatim': 0.07; 'bold': 0.09; 'subject:()': 0.09; 'type;': 0.09; 'files.': 0.13; '2016': 0.16; 'from:addr:mrabarnett.plus.com': 0.16; 'from:addr:python': 0.16; 'from:name:mrab': 0.16; 'fuzzy': 0.16; 'message-id:@mrabarnett.plus.com': 0.16; 'order?': 0.16; 'quoted': 0.16; 'received:192.168.1.4': 0.16; 'received:84.93': 0.16; 'received:84.93.230': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'regex,': 0.16; 'smart,': 0.16; 'wrote:': 0.16; 'beginner': 0.18; 'switched': 0.18; 'typing': 0.18; 'together.': 0.20; 'fit': 0.23; 'matching': 0.23; 'header:In- Reply-To:1': 0.24; 'feature': 0.24; 'module': 0.25; 'header:User- Agent:1': 0.26; 'updating': 0.27; 'wonder': 0.27; 'question': 0.27; 'module.': 0.27; 'behaviour': 0.29; 'closer': 0.29; 'certain': 0.31; 'received:84': 0.32; 'topic': 0.32; 'real-time': 0.33; 'file': 0.34; 'could': 0.35; 'according': 0.36; 'but': 0.36; 'monday,': 0.36; 'to:addr:python-list': 0.36; 'subject:: ': 0.37; 'two': 0.37; 'being': 0.37; 'itself': 0.38; 'thank': 0.38; 'files': 0.38; 'received:192': 0.39; 'to:addr:python.org': 0.40; 'questions': 0.40; 'your': 0.60; 'son': 0.61; "you'll": 0.61; 'here.': 0.62; 'is.': 0.63; 'more': 0.63; 'here:': 0.63; 'march': 0.64; 'matthew': 0.66; 'letters': 0.67; 'subject:. ': 0.67; 'feeling': 0.72; 'search,': 0.72; '_o__)': 0.84; 'gut': 0.84; 'sublime': 0.84; 'worthy': 0.84; 'directories,': 0.91; 'father': 0.91 X-CM-Score: 0.00 X-CNFS-Analysis: v=2.1 cv=bsGxfxui c=1 sm=1 tr=0 a=0nF1XD0wxitMEM03M9B4ZQ==:117 a=0nF1XD0wxitMEM03M9B4ZQ==:17 a=L9H7d07YOLsA:10 a=9cW_t1CCXrUA:10 a=s5jvgZ67dGcA:10 a=IkcTkHD0fZMA:10 a=pGLkceISAAAA:8 a=b2qCOqhAfObdOJxei6QA:9 a=QEXdDO2ut3YA:10 X-AUTH: mrabarnett@:2500 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0 In-Reply-To: X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Xref: csiph.com comp.lang.python:104314 On 2016-03-08 01:37, Jinghui Niu wrote: > On Monday, March 7, 2016 at 5:16:44 PM UTC-8, Ben Finney wrote: >> Jinghui Niu 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. > Could it be as simple as looking for _those_ characters in _that_ order? It might be giving a higher prominence to those whose matching letters are closer together.