Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Chris Angelico Newsgroups: comp.lang.python Subject: Re: fnmatch() vs. glob.glob() Date: Tue, 8 Mar 2016 12:56:32 +1100 Lines: 24 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 Content-Transfer-Encoding: quoted-printable X-Trace: news.uni-berlin.de XqWvM8cLfPD+tFqafT8DgAez1tIgQl6UOAru6NNf1Ucg== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.002 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'received:209.85.223': 0.03; 'e.g.,': 0.07; 'verbatim': 0.07; 'cc:addr:python-list': 0.09; 'excluding': 0.09; 'second.': 0.09; 'subject:()': 0.09; 'type;': 0.09; 'whatever.': 0.09; 'files.': 0.13; 'appropriate': 0.14; 'things.': 0.15; '2016': 0.16; 'at.': 0.16; 'fnmatch': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'regex,': 0.16; 'smart,': 0.16; 'wrote:': 0.16; 'switched': 0.18; 'typing': 0.18; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'do.': 0.22; 'trying': 0.22; 'fit': 0.23; 'header:In-Reply-To:1': 0.24; 'feature': 0.24; 'updating': 0.27; 'wonder': 0.27; 'message- id:@mail.gmail.com': 0.27; 'module.': 0.27; 'specify': 0.27; 'regular': 0.29; 'mention': 0.30; 'certain': 0.31; 'real-time': 0.33; 'tue,': 0.34; 'file': 0.34; 'received:google.com': 0.35; 'could': 0.35; 'according': 0.36; 'but': 0.36; 'serve': 0.36; 'received:209.85': 0.36; 'depends': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'two': 0.37; 'itself': 0.38; 'received:209': 0.38; 'files': 0.38; 'different': 0.63; 'here:': 0.63; 'within': 0.64; 'mar': 0.65; "they're": 0.66; 'subject:. ': 0.67; 'feeling': 0.72; 'search,': 0.72; 'sounds': 0.76; '12:37': 0.84; 'chrisa': 0.84; 'gut': 0.84; 'to:none': 0.91 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-transfer-encoding; bh=yGK/X24UQQZUus3Gb2h6zMhkvOm8mUHTTefevx4FoDw=; b=JpBh+wMJQvMhDROj1FimmPx04VNEFbBCaszLWQCOsf82Tf7QVGu9Xq3S8Y1X5Yrn4e h13dw/HsJJax4vs+NPk5WD/UtPiByIYFJ27ooA3VM+2dnjYBf5TRq0bmzRwFbImPXGAB mwJpi8wd6sr3m1gRfUAu4y8lYPdQ+qSni4nndDy2kKSAYq5XfvgNQdL3pAYPCGrFilpg +UXA98eWSQmWdD0F7vUm7rHFA5f0xPHcFNKtavvY9eKeOWLxtx0UhmnvLmdtzwOAQx6N 9Iuw49EbY1RVIoX5KwuwlNfshMhmyxV3X5fiDlLGO9hXAn8wuLXTcheoo/XbMUOk7AmR HfKA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:cc:content-transfer-encoding; bh=yGK/X24UQQZUus3Gb2h6zMhkvOm8mUHTTefevx4FoDw=; b=mXIsn3kIkaX8gphaNh04isRZ8xFnrVACYZWY9CqA8Yh3Q2xBOkldJcOJz1EVikBQhe yAQkkFF8DBmXRWLVSHanKyBA/JKiq/NDdejgcm1kNnN+3qHFyY3KbGf2WlTsfi3CElKc LuOfg3yWq7SzgBQhjqXUc2dO34p0AnaX7SySz2n+zRDud62SSkEbcdfeSU+p/rAj48Gp hR6Sj3M0gbajr4nsQOkgtSRY8yt18PDbp/YGcRuGTLF+7qgnBcxUMRx+TuRwY3bxf/TF PIc5326YSRNnYl6O8/zhfD8rw4/4en/FWXSeMcj5af2Z3N+684ZvWwoGT98ESn87GgZT /0Jw== X-Gm-Message-State: AD7BkJJk+x4rCKcs7gfPRxF0jbT746bFFF0YUpEcxEDdMikTteLaX8ZK2BmxAlpMX/7AgdhqLjnhNcE5CBQkbw== X-Received: by 10.107.47.163 with SMTP id v35mr22299084iov.19.1457402192722; Mon, 07 Mar 2016 17:56:32 -0800 (PST) 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:104308 On Tue, Mar 8, 2016 at 12:37 PM, Jinghui Niu wrote: > 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 au= tomatically, 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 R= egex into either fnmatch() or glob() module. Sounds to me like you're looking at two different things. 1) File name matching, whether with fnmatch or glob, will tell you which files to look at. You mention excluding .pyc files; you could specify that only "*.py" be matched, or "*q*.py", or whatever. 2) Regular expression or other searching, within the files. Either fnmatch or glob will serve you well for the first; I don't think they're appropriate for the second. But it depends what you're trying to do. ChrisA