PyFloat_Check - help!

k_mcdermott at my-deja.com k_mcdermott at my-deja.com
Thu Oct 21 11:46:27 EDT 1999


Hi,

I have a piece of code like this:

if (!PyFloat_Check(poRate)) {
		PyErr_SetString(DataError, "Rate must be a float");
		return NULL;
	}
else
    	Rate = PyFloat_AsDouble(poRate);

Where poRate is a PyArg_ParseTuple extracted PyObject.

The question I have is:

The type checking is too strict (who says Python isn't type checked?)

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...

Kevin


Sent via Deja.com http://www.deja.com/
Before you buy.




More information about the Python-list mailing list