Parsing a dictionary from a format string
Tim Johnson
tim at johnsons-web.com
Mon Jun 20 16:49:16 EDT 2011
* Hans Mulder <hansmu at 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
More information about the Python-list
mailing list