title: Pass a list or tuple of arbitrary length to Python extension written in C
body: <p>If I am extending Python in C, I can parse arguments provided on the Python side using functions like <code>PyArg_ParseTuple()</code>. However, this only allows me to specify scalar arguments, or tuple arguments of known length. How do I deal with the case where the user calls my function from Python with a tuple of arbitrary length? For example:</p>
  
  <pre><code>import foo
  foo.bar([1, 2, 3]) 
  foo.bar([4, 5])
  </code></pre>
  
  <p>Here, <code>bar()</code> is defined in C, and its arguments are parsed using <code>PyArg_ParseTuple()</code>, which copies the argument values to a local variable. I have to specify the argument format and an address into which to copy the parsed value. For instance:</p>
  
  <pre><code>int i,j;
  PyArg_ParseTuple(args, "i", &amp;i)
  /* or */
  PyArg_ParseTuple(args, "(ii)", &amp;i, &amp;j);
  </code></pre>
  
  <p>But what I want is something like this:</p>
  
  <pre><code>int *i;
  int ni;
  PyArg_ParseTuple(args, "(i...)", &amp;ni, i);
  </code></pre>
  
  <p>where i is an array, and ni is the number of elements in the array. Is this possible?</p>