title: Partial list unpack in Python
body: <p>In Python, the assignment operator can unpack a list or a tuple into variables, like this:</p>
  
  <pre><code>l = (1, 2)
  a, b = l # Here goes auto unpack
  </code></pre>
  
  <p>But I need to specify exactly the same amount of names to the left as an item count in the list to the right. But sometimes I don't know the size of the list to the right, for example, if I use split(). </p>
  
  <p>Example:</p>
  
  <pre><code>a, b = "length=25".split("=") # This will result in a="length" and b=25
  </code></pre>
  
  <p>But the following code will lead to an error:</p>
  
  <pre><code>a, b = "DEFAULT_LENGTH".split("=") # Error, list has only one item
  </code></pre>
  
  <p>Is it possible to somehow unpack the list in the example above so I can get a = "DEFAULT_LENGTH" and b equals to <code>None</code> or not set? A straightforward way looks kind of long:</p>
  
  <pre><code>a = b = None
  if "=" in string :
    a, b = string.split("=")
  else :
    a = string
  </code></pre>