Another C API Question

Farshid Lashkari no at spam.com
Thu Jul 26 21:18:38 EDT 2007


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.



More information about the Python-list mailing list