Ervin Hegedüs wrote: > Python has a good string formatter, eg. I can do this: > > s = "{who} likes {what}" > d = {'who': "Adam", 'what': "ants"} > s.format(**d) > > result: > 'Adam likes ants' > > Is it possible, and if yes, how to resolve the placeholders names > in string?
>>> import string >>> for item in string.Formatter().parse("{who} likes {what}"): ... print(item) ... ('', 'who', '', None) (' likes ', 'what', '', None) -- https://mail.python.org/mailman/listinfo/python-list