Determining a replacement dictionary from scratch
moskow23 at yahoo.com
Sun Jan 18 20:16:31 CET 2004
I'd like to be able to take a formatted string and determine the
replacement dictionary necessary to do string interpolation with it.
>>> str = 'his name was %(name)s and i saw him %(years)s ago.'
>>> createdict( str )
Notice how it would automatically fill in default values based on
type. I figure since python does this automatically maybe there is a
clever way to solve the problem. Otherwise I will just have to parse
the string myself. Any clever solutions to this?
More information about the Python-list