Passing list with flexible length to C extension

Michael Hudson mwh at python.net
Fri Nov 21 08:37:08 EST 2003


Boštjan Jerko <bostjan.jerko at mf.uni-lj.si> writes:

> Is there a way to pass list with flexible length to C extension?

Yes, although I'm not quite sure what you mean.  Do you want to be
able to type

my_ext_func([3.0, 1.0, 4.0, 1.0, 5.0])

or 

my_ext_func(3.0, 1.0, 4.0, 1.0, 5.0)

?  If the latter you can't use PyArg_ParseTuple, but the `args'
parameter is just a tuple, amenable to PyTuple_Length & so on.

Cheers,
mwh

-- 
  Our Constitution never promised us a good or efficient government,
  just a representative one. And that's what we got.
      -- http://www.advogato.org/person/mrorganic/diary.html?start=109




More information about the Python-list mailing list