Hi Farshid,
On Jul 26, 8:18 pm, Farshid Lashkari [EMAIL PROTECTED] 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
Hi Robert,
On Jul 26, 8:16 pm, Robert Kern [EMAIL PROTECTED] wrote:
beginner wrote:
Hi,
I run into another C API question. What is the simplest way to convert
an PyObject into a double?
For example, I have
PyObject *obj;
I know obj is a number, but I do not know the exact type
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.
--
http://mail.python.org/mailman/listinfo/python-list
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
On Jul 27, 4:50 pm, Farshid Lashkari [EMAIL PROTECTED] wrote:
beginner wrote:
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.
That's strange. I
On Jul 27, 4:50 pm, Farshid Lashkari [EMAIL PROTECTED] wrote:
beginner wrote:
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.
That's strange. I
beginner wrote:
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.
That's strange. I just tried the following code:
fprintf(stdout,True =
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
beginner wrote:
Hi,
I run into another C API question. What is the simplest way to convert
an PyObject into a double?
For example, I have
PyObject *obj;
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
Hi,
I run into another C API question. What is the simplest way to convert
an PyObject into a double?
For example, I have
PyObject *obj;
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
10 matches
Mail list logo