1

So I'm writing a set of C++ classes that run Python scripts. I've gotten code working to run any script I want from a specified directory, and I can pass and return values just fine.

But the one issue I have is I can't seem to find out how to set Python doubles up. For example, when I was using long values, I could use "PyLong_AsLong([whatever value I'm trying to convert to a long from a PyObject])" -- but is there a PyDouble_Something in the Python/C API I can use for that? My google searching has so far turned up nothing.

Amro
  • 123,847
  • 25
  • 243
  • 454
Mister R2
  • 861
  • 5
  • 12
  • 22

2 Answers2

1

You want PyFloat_AsDouble, no?

Ned Batchelder
  • 364,293
  • 75
  • 561
  • 662
0

I found out the answer. I was mistaken, and I thought there were doubles in Python, but there aren't. I got it to work using a "PyFloat" object, and just converted the double like this:

"PyFloat_FromDouble([the double I wanted as a PyObject])"

Mister R2
  • 861
  • 5
  • 12
  • 22