Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #8026
| Date | 2011-06-20 11:41 -0800 |
|---|---|
| From | Tim Johnson <tim@johnsons-web.com> |
| Subject | Re: Parsing a dictionary from a format string |
| References | <20110620181446.GI1971@johnsons-web.com> |
| Organization | AkWebsoft |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.190.1308598897.1164.python-list@python.org> (permalink) |
* Tim Johnson <tim@johnsons-web.com> [110620 10:28]:
> 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?
> Question 2:
> Given the following string:
> S = 'Coordinates: {latitude}, {longitude}'
> Is there a python library that would provide an optimal way
> to parse from S the following
> {'latitude':"",'longitude':""}
> ?
P.S. :
One solution would be
import re
re.findall(r'\{([^}]*)\}', s) ## I think, being a regex dummy..
But perhaps there is something more efficient than re?
cheers
--
Tim
tim at johnsons-web dot com or akwebsoft dot com
http://www.akwebsoft.com
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: Parsing a dictionary from a format string Tim Johnson <tim@johnsons-web.com> - 2011-06-20 11:41 -0800
csiph-web