title: Does Python have an "or equals" function like ||= in Ruby?
body: <p>If not, what is the best way to do this?</p>
  
  <p>Right now I'm doing (for a django project):</p>
  
  <pre><code>if not 'thing_for_purpose' in request.session:
      request.session['thing_for_purpose'] = 5
  </code></pre>
  
  <p>but its pretty awkward. In Ruby it would be:</p>
  
  <pre><code>request.session['thing_for_purpose'] ||= 5
  </code></pre>
  
  <p>which is much nicer.</p>