Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.007 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'syntax': 0.04; 'subject:Python': 0.06; 'modify': 0.07; 'parser': 0.07; 'string': 0.09; 'correct,': 0.09; 'cc:addr:python-list': 0.11; 'jan': 0.12; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'restricting': 0.16; 'script,': 0.16; 'write,': 0.16; 'files.': 0.16; 'wrote:': 0.18; 'example': 0.22; 'cc:addr:python.org': 0.22; 'certainly': 0.24; 'cc:2**0': 0.24; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; 'thus': 0.29; 'message-id:@mail.gmail.com': 0.30; 'easier': 0.31; 'usually': 0.31; '13,': 0.31; 'indentation': 0.31; 'file': 0.32; 'maybe': 0.34; 'info': 0.35; 'agree': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'subject:?': 0.36; 'easily': 0.37; 'list,': 0.38; 'mailing': 0.39; 'even': 0.60; 'easy': 0.60; 'future': 0.60; 'cost.': 0.60; 'ian': 0.60; 'simple': 0.61; 'information': 0.63; '2015': 0.84; 'proofing': 0.84; 'to:none': 0.92 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-type; bh=pdFvWWzSnFdSdNkGoGtRKAvNWB/3Mpyity3UK1CaDwQ=; b=w4MVdyBFDafs1oI95i/zAg9vKgIK2OXh8y8/uqyxhiVPChinXu8vSefdMSSNqPuD8p pdfoQy3vcFHtZfknWaSy4qA9uXWtSQ+1h3Y+H8rlBomfovgS7jq35BuzoW7VwcY2ziQP l92ctQkyJr5bjHbQt3sjjYE7EQUtrzVzRnWv0P8FJAik5m5PpXTch6ChgyJy6JPYA2Tu Ty+c+TVkOaJB8S11fRRa6/bxcvca859ngoOrbMz6gzAbrigoD5GBZ0D/+YnYg7shlC0R od0eA0Xpx21+9TZjvj7TltS8C/onw1A6zAMee/44duKajQNjt/7WIDOT42dVEjK/uzud UedQ== MIME-Version: 1.0 X-Received: by 10.42.52.200 with SMTP id k8mr25337515icg.26.1421094726290; Mon, 12 Jan 2015 12:32:06 -0800 (PST) In-Reply-To: <54B42502.6050702@gmail.com> References: <54B40C85.5000806@emerytelcom.com> <54B42502.6050702@gmail.com> Date: Tue, 13 Jan 2015 07:32:06 +1100 Subject: Re: Python 3 regex? From: Chris Angelico Cc: "python-list@python.org" Content-Type: text/plain; charset=UTF-8 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 16 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1421094729 news.xs4all.nl 2937 [2001:888:2000:d::a6]:51351 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:83628 On Tue, Jan 13, 2015 at 6:48 AM, Ian wrote: > My recommendation would be to write a recursive decent parser for your > files. > > That way will be easier to write, much easier to modify and almost certainly > faster that a RE solution - and it can easily give you all the information > in the file thus future proofing it. Generally, even a recursive descent parser will be overkill. It's pretty easy to do simple string manipulation to get the info you want; maybe that means restricting the syntax some, but for a personal-use script, that's usually no big cost. The example I gave requires that the indentation be correct, and on this mailing list, I think people agree that that's not a deal-breaker :) ChrisA