List of variables within a string
3 answers
Using string.Formatter.parse
:
>>> s = "{a}|{b}.{c}.{a}"
>>> import string
>>> formatter = string.Formatter()
>>> [item[1] for item in formatter.parse(s)]
['a', 'b', 'c', 'a']
+6
source to share