title: nargout in Python
body: <p>Does Python have any equivalent of nargout in MATLAB? I find nargout a very neat approach if we want to keep the number of return parameters flexible. Is there a way I can find out how many output parameters have been requested? Something like the following pseudo-python-code:</p>
  
  <pre><code>def var_returns_func(a):
    """
    a is a 1D numpy array
    """
    if nargout==1: return a.sum()
    elif nargout==2: return a.sum(),a.std()
  </code></pre>
  
  <p>So if I call this function as <code>mean = var_returns_func(someNumPyarray)</code>, it should return a single value. But if I call it as <code>mean,std = var_returns_func(someNumPyarray)</code>, it should return 2 values.</p>
  
  <p>Is there a Pythonic way of doing this? Or a hacky way?</p>