title: How to avoid writing request.GET.get() twice in order to print it?
body: <p>I come from a PHP background and would like to know if there's a way to do this in Python. </p>
  
  <p>In PHP you can kill 2 birds with one stone like this:</p>
  
  <p>Instead of:</p>
  
  <pre><code>if(getData()){
      $data = getData();
      echo $data;
  }
  </code></pre>
  
  <p>I can do this:</p>
  
  <pre><code>if($data = getData()){
      echo $data;
  }
  </code></pre>
  
  <p>You check to see if <code>getData()</code> exists AND if it does, you assign it to a variable in one statement.</p>
  
  <p>I wanted to know if there's a way to do this in Python? So instead of doing this:</p>
  
  <pre><code>if request.GET.get('q'):
      q = request.GET.get('q')
      print q
  </code></pre>
  
  <p>avoid writing <code>request.GET.get('q')</code> twice.</p>