PyFloat_Check - help!

David Ascher da at ski.org
Thu Oct 21 13:15:51 EDT 1999


On Thu, 21 Oct 1999 k_mcdermott at my-deja.com wrote:

> I would prefer the above code to translate Integer objects, where this
> makes sense. i.e. the rate above could be either 1 or 10 to represent 1%
> or 10%, but I have to explicitly put in a 1.0 or 10.0 to make it a
> float.
> 
> I know this is possible, but how...

Would this do?

PyObject* PyNumber_Float (PyObject *o) 
     Returns the o converted to a float object on success, or NULL on
     failure. This is the equivalent of the Python expression "float(o)". 

--david





More information about the Python-list mailing list