title: Python: split array into variables
body: <p>I have a function that returns a list. The length of this list is unknown to the caller.</p>
  
  <pre><code>def get_array():
      ret = [1, 2]
      return ret
  
  var1, var2 = get_array()
  </code></pre>
  
  <p>This sets <code>var1 = 1</code> and <code>var2 = 2</code>. This works fine with all lists except when the length is less than 2. For example, if the list has length of 1:</p>
  
  <pre><code> def get_array():
      ret = [1]
      return ret
  
   var1 = get_array()
  </code></pre>
  
  <p>This sets <code>var1</code> to <code>[1]</code>, but I want <code>var1</code> to be <code>1</code>. Is there a cleaner way to unpack this array without having to check its length?</p>