Another C API Question
zyzhu2000 at gmail.com
Fri Jul 27 16:11:28 CEST 2007
On Jul 26, 8:18 pm, Farshid Lashkari <n... at spam.com> wrote:
> beginner wrote:
> > I know obj is a number, but I do not know the exact type. How can I
> > convert it to double without writing a giant switch() that exhausts
> > every single type of number?
> Try using the PyFloat_AsDouble(...) function, it should be able to
> convert an object to a double, as long as the object implements the
> __float__ method.
This works with PyFloat only. It does not work with integers.
More information about the Python-list