title: Python: can I change function behaviour whether output is assigned or not?
body: <p>In Matlab, nargout is a variable that tells you if the output is assigned, so</p>
  
  <pre><code>x = f(2);
  </code></pre>
  
  <p>and </p>
  
  <pre><code>f(2);
  </code></pre>
  
  <p>can behave differently.</p>
  
  <p>Is it possible to do similar in Python?</p>
  
  <p>I have a function that plots to screen and returns a matplotlib figure object. I want that if output is assigned to a variable then do not plot to screen.</p>