tuple creation in C extensions

Peter Schneider-Kamp petersc at stud.ntnu.no
Sat Jun 10 17:15:26 EDT 2000


I have to create a tuple (of two integer values) in a
C extension. At the moment I use the following (rather
ugly in my eyes) construction:

t = PyTuple_New(2);
PyTuple_SET_ITEM(t,0,PyInt_FromLong(a));
PyTuple_SET_ITEM(t,1,PyInt_FromLong(b));
PyErr_SetObject(PyExc_IndexError,t);

where
PyObject* t;
long a,b;

Is there "A Better Way(TM)"?

thnx,
Peter
--
Peter Schneider-Kamp          ++47-7388-7331
Herman Krags veg 51-11        mailto:peter at schneider-kamp.de
N-7050 Trondheim              http://schneider-kamp.de




More information about the Python-list mailing list