title: Passing key-value pairs as function parameters in Python
body: <p>I am working with the Python Flickr API and have a problem defining a function (I am kind of new to Python).</p>
  
  <p>I need to wrap the following api functionality into a function:</p>
  
  <pre><code>photos = flickr.photos_search(
      tags="foo",
      is_commons="True")
  </code></pre>
  
  <p>This returns a photo search for the tag "foo" from Flickr's Commons collection.</p>
  
  <p>Now I want to replace the tag each time I search, so I wrap it in a function:</p>
  
  <pre><code>def search_photos(fl_tags):
      photos = flickr.photos_search(
          tags=fl_tags,
          is_commons="True")
  
  search_photos("foo")
  </code></pre>
  
  <p>This works, the is_commons flag however, I need to occasionally replace altogether (not only the value, but also the key, since there seems to be a bug in Flickr's API that it always searches in the Commons collection no matter to which value you set the flag).</p>
  
  <p>In this case I would like to replace it with a key-value combination <code>license="9"</code>.</p>
  
  <p>I don't know how to put that into the function parameters. If I provide a <code>fl_license</code> parameter and simply set that to <code>license="9"</code> when I call the function then this does not work (as I kind of expected).</p>
  
  <pre><code>def search_photos(fl_tags, fl_license):
      photos = flickr.photos_search(
          tags=fl_tags,
          fl_license)
  
  search_photos("foo", license="9")    # --&gt; SyntaxError: non-keyword arg after keyword arg
  </code></pre>
  
  <p>Is there any way to get this to work. How could I get the key-value pair through a function parameter?</p>
  
  <p>Thanks!</p>