title: Only add to a dict if a condition is met
body: <p>I am using <code>urllib.urlencode</code> to build web POST parameters, however there are a few values I only want to be added if a value other than <code>None</code> exists for them.</p>
  
  <pre><code>apple = 'green'
  orange = 'orange'
  params = urllib.urlencode({
      'apple': apple,
      'orange': orange
  })
  </code></pre>
  
  <p>That works fine, however if I make the <code>orange</code> variable optional, how can I prevent it from being added to the parameters? Something like this (pseudocode):</p>
  
  <pre><code>apple = 'green'
  orange = None
  params = urllib.urlencode({
      'apple': apple,
      if orange: 'orange': orange
  })
  </code></pre>
  
  <p>I hope this was clear enough, does anyone know how to solve this?</p>