[C++-sig] make tuple of tuples in embedding python?

ZiZi Zhao zzhao at laika.com
Wed Feb 28 03:22:12 CET 2007


In Python/C API 
PyTuple can have different types of items. For example,

pTuple = PyTuple_New(3);
PyTuple_SetItem(pTuple, 0, pString1);
PyTuple_SetItem(pTuple, 1, pString2);
PyTuple_SetItem(pTuple, 2, pDict);

I would like to know if I can make tuple of tuples for embedding Python in C++. For example,

pTuple0 = PyTuple_New(3);
pTuple1 = PyTuple_New(3);
pTuple2 = PyTuple_New(3);

pTupleOfTuple = PyTuple_New(3);

PyTuple_SetItem(pTupleOfTuple, 0, pTuple0);
PyTuple_SetItem(pTupleOfTuple, 1, pTuple1);
PyTuple_SetItem(pTupleOfTuple, 2, pTuple2);

It seems the code can be compiled. But, it would crash as long as it starts running without any output info. So, I could not know what is wrong.

Thanks in Advance,

ZZ






-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20070227/23775b57/attachment.htm>


More information about the Cplusplus-sig mailing list