title: Format a string with all combinations of multiple dictionary key / values
body: <p>I'm trying to figure out how, given multiple values, I can generate all combinations of the values when applies to a template / pattern. So if I have the following variables:</p>
  
  <pre><code>pattern = '{name} likes {animal}s'
  options = {'name': ['Alex', 'Sarah', 'Bob'], 'animal': ['cat', 'dog']}
  </code></pre>
  
  <p>I'd like to have the code print out all the possible combinations based on the string pattern and the values in the dictionary (or any other structure, it doesn't matter)</p>
  
  <pre><code>'Alex likes cats'
  'Alex likes dogs'
  'Sarah likes cats'
  'Sarah likes dogs'
  'Bob likes cats'
  'Bob likes dogs'
  </code></pre>
  
  <p>I can think of some ways do it, but it's messy, and I'm trying to find a way to do this without hardcoding, so in the future I could introduce a new key, like 'color' without having to change anything but <code>pattern</code> and <code>options</code></p>
  
  <p>I'm assuming I can use something similar to <a href="https://stackoverflow.com/a/33065106/380451">this code I found</a>:</p>
  
  <pre><code>def combine(template, options):
      for opts in itertools.product(*options):
          yield template.format(*opts)
  </code></pre>
  
  <p>But I can't figure out how to get all the combinations and keep them in a format that <code>string.format()</code> will accept. I'm sure there's some simple solution I'm overlooking. </p>