I would like to get a list of all possible keyword arguments a string template might use in a substitution.
Is there a way to do this other than re?
>>> import string >>> get_keys = lambda s:[el.strip(string.punctuation) for el in s.split()if el.startswith('$')] >>> get_keys("$one is a $lonely $number.") ['one', 'lonely', 'number']