template strings for matching?
skip at pobox.com
skip at pobox.com
Thu Oct 9 10:40:11 EDT 2008
Tino> ??? can you elaborate? I don't see the problem.
Tino> "%(foo)s" % mapping
Joe wants to go in the other direction. Using your example, he wants a
function which takes a string and a template string and returns a dict.
Here's a concrete example:
s = "My dog has fleas"
fmt = "My $pet has $parasites"
d = fmt_extract(fmt, s)
assert d['pet'] == 'dog'
assert d['parasites'] == 'fleas'
Skip
More information about the Python-list
mailing list