title: How to check if string has format arguments in Python?
body: <p>I am formatting strings using named arguments with <code>.format()</code>. How can I obtain a list of arguments?</p>
  
  <p>For example: </p>
  
  <pre><code>&gt;&gt;&gt; my_string = 'I live in {city}, {state}, {country}.'
  &gt;&gt;&gt; get_format_args(my_string)
  # ['city', 'state', 'country']
  </code></pre>
  
  <p>Note that order does not matter. I have dug a fair amount into the <a href="https://docs.python.org/2/library/string.html#string.Formatter" rel="noreferrer">string.Formatter</a> documentation to no avail. I am sure you could write regex to do this, but there <em>must</em> bet a more elegant way.</p>