Another C API Question

Farshid Lashkari no at
Fri Jul 27 23:50:38 CEST 2007

beginner wrote:
> I did and it did not seem to work. I ended up doing the following.
> Verbose, isn't it?
> If I do d=PyFloat_AsDouble(oDiscount); in the third "if", I get an
> error. Maybe I missed something obvious.

That's strange. I just tried the following code:

fprintf(stdout,"True = %lf\n",PyFloat_AsDouble(Py_True));
fprintf(stdout,"False = %lf\n",PyFloat_AsDouble(Py_False));
fprintf(stdout,"5 = %lf\n",PyFloat_AsDouble(PyInt_FromLong(5)));

And it printed the following:

True = 1.000000
False = 0.000000
5 = 5.000000

What version of Python are you using?

More information about the Python-list mailing list