Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #8031

Re: Parsing a dictionary from a format string

Date 2011-06-20 12:49 -0800
From Tim Johnson <tim@johnsons-web.com>
Subject Re: Parsing a dictionary from a format string
References <mailman.187.1308593682.1164.python-list@python.org> <4dffa8b9$0$49179$e4fe514c@news.xs4all.nl>
Organization AkWebsoft
Newsgroups comp.lang.python
Message-ID <mailman.198.1308602942.1164.python-list@python.org> (permalink)

Show all headers | View raw


* Hans Mulder <hansmu@xs4all.nl> [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

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Parsing a dictionary from a format string Tim Johnson <tim@johnsons-web.com> - 2011-06-20 10:14 -0800
  Re: Parsing a dictionary from a format string Hans Mulder <hansmu@xs4all.nl> - 2011-06-20 22:08 +0200
    Re: Parsing a dictionary from a format string Tim Johnson <tim@johnsons-web.com> - 2011-06-20 12:49 -0800
    Re: Parsing a dictionary from a format string Tim Johnson <tim@johnsons-web.com> - 2011-06-20 14:39 -0800

csiph-web