On Jul 27, 11:37 am, Farshid Lashkari <[EMAIL PROTECTED]> 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. if(oDiscount==Py_None) { } else if(PyFloat_Check(oDiscount)) { d=PyFloat_AsDouble(oDiscount); } else if(PyNumber_Check(oDiscount)) { PyObject *pf=PyNumber_Float(oDiscount); if(pfDiscount) { d=PyFloat_AsDouble(pfDiscount); Py_DECREF(pfDiscount); } } else ... -- http://mail.python.org/mailman/listinfo/python-list