Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!news2.euro.net!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.015 X-Spam-Evidence: '*H*': 0.97; '*S*': 0.00; 'python': 0.08; 'received:64.4': 0.09; 'subject:string': 0.09; 'def': 0.12; 'wrote:': 0.14; '2.6,': 0.16; 'btw:': 0.16; 'hans': 0.16; 'res': 0.16; 'str.format()': 0.16; 'sections': 0.16; 'compiled': 0.17; 'header:In-Reply-To:1': 0.21; "haven't": 0.22; 'versions': 0.23; 'function': 0.25; 'tests': 0.26; 'later': 0.26; 'thanks': 0.28; 'checking': 0.29; 'version': 0.29; 'module': 0.30; 'subject:format': 0.30; 'this.': 0.31; 'to:addr:python-list': 0.33; 'familiar': 0.33; 'list': 0.33; 'there': 0.35; 'header:User- Agent:1': 0.35; 'using': 0.35; 'charset:us-ascii': 0.36; 'depend': 0.37; 'think': 0.38; 'subject:from': 0.38; 'run': 0.38; 'but': 0.38; 'earlier': 0.38; 'subject:: ': 0.38; 'some': 0.38; 'johnson': 0.39; 'to:addr:python.org': 0.39; 'more': 0.60; 'your': 0.60; 'matter': 0.63; 'serving': 0.66; 'today,': 0.71 Date: Mon, 20 Jun 2011 12:49:16 -0800 From: Tim Johnson To: python-list@python.org Subject: Re: Parsing a dictionary from a format string References: <4dffa8b9$0$49179$e4fe514c@news.xs4all.nl> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4dffa8b9$0$49179$e4fe514c@news.xs4all.nl> Organization: AkWebsoft User-Agent: Mutt/1.5.20 (2009-06-14) X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 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: 33 NNTP-Posting-Host: 82.94.164.166 X-Trace: 1308602943 news.xs4all.nl 49175 [::ffff:82.94.164.166]:33538 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:8031 * Hans Mulder [110620 12:15]: > On 20/06/11 20:14:46, Tim Johnson wrote: > >Currently using python 2.6, but am serving some systems that have > >older versions of python (no earlier than. > >Question 1: > > With what version of python was str.format() first implemented? Duh! > It might be a matter of taste; it might depend on how familiar > you are with 're'; it might depend on what you mean by 'optimal'. As in speed. ## and then there is this - which I haven't tested a lot: def grabBetween(src,begin,end): """Grabs sections of text between `begin' and `end' and returns a list of 0 or more sections of text.""" parts = src.split(begin) res = [] for part in parts: L = part.split(end) if len(L) > 1: res.append(L[0]) return res I think later today, I will run some time tests using the `re' module as well as your function and the one above. BTW: To be more clear (hopefully) I was checking to see if there was a compiled method/function to do this. thanks -- Tim tim at johnsons-web dot com or akwebsoft dot com http://www.akwebsoft.com