Why doesn't this work--Extending Python--?

Todd goldfita at signalsguru.net
Wed Jan 4 20:58:58 CET 2006


jeremito wrote:
> I have written a simple C++ program in my efforts to learn how to
> extend Python.  It is shown below.  Everything compiles and installs
> correctly, but I get strange answers.  I know the function "Pi" is
> correct because when I call it from a C++ code it gives the correct
> answers.  This is what I get when I run it in Python:

>      27     int Particles;
>      28     int Pie;
>      29     if (!PyArg_ParseTuple(args, "i", &Particles))
>
>      30         return NULL;
>
>      31     Pie = Pi(Particles);
>
>      32     return Py_BuildValue("d", Pie);

Just scanning over this, looks like what you want is double Pie.  You
have int.  The compiler probably gave a warning.

http://www.signalsguru.net/




More information about the Python-list mailing list