Parsing a dictionary from a format string

Tim Johnson tim at johnsons-web.com
Mon Jun 20 15:41:50 EDT 2011


* Tim Johnson <tim at 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



More information about the Python-list mailing list