Extending python with C

Marco Mariani m.mariani at imola.nettuno.it
Fri May 18 10:48:11 EDT 2001


On Fri, May 18, 2001 at 11:03:17AM -0400, John wrote:

>     I am trying to building an C extension module.  How would I convert an
> Integer in Python to an int * in C ?  I know there's an "s" format specifier
> for char *, but what about int *?

If you're passing it as a parameter:

if (!(PyArg_ParseTuple(args,"i",&myvariable)) {
	// no chance
	} else {
	// now myvariable has been filled
	}


If you've got a python object pointer:

myvariable = PyInt_AsLong(myobject)





More information about the Python-list mailing list