Another C API Question

beginner zyzhu2000 at
Fri Jul 27 23:18:56 CEST 2007

On Jul 27, 11:37 am, Farshid Lashkari <n... at> wrote:
> beginner wrote:
> > This works with PyFloat only. It does not work with integers.
> Did you try it out? I have used it on ints, bools, and objects that
> implement the __float__ method. It does not work on strings though.

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.

		else if(PyFloat_Check(oDiscount))
		else if(PyNumber_Check(oDiscount))
			PyObject *pf=PyNumber_Float(oDiscount);
		else ...

More information about the Python-list mailing list