tuple creation in C extensions

Phil Austin phil at geog.ubc.ca
Sat Jun 10 20:26:02 EDT 2000


Peter Schneider-Kamp <petersc at stud.ntnu.no> writes:

> 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:
> 

[snip]

> Is there "A Better Way(TM)"?
> 

If you're able to use the CXX extension, the sequence is:

Tuple t(2);
t[0]=Int(a);
t[1]=Int(b);

If the conversion fails, Int will throw an exception that
can be caught on the python side.

Regards, Phil



More information about the Python-list mailing list