I am formatting strings using named arguments with .format(). How can I obtain a list of arguments?
For example:
>>> my_string = 'I live in {city}, {state}, {country}.'
>>> get_format_args(my_string)
# ['city', 'state', 'country']
Note that order does not matter. I have dug a fair amount into the string.Formatter documentation to no avail. I am sure you could write regex to do this, but there must bet a more elegant way.