0

I got the following piece of code:

def DisplayListCurveKeys(pCurve, pProperty):
    lKeyCount = pCurve.KeyGetCount()

    for lCount in range(lKeyCount):
        lKeyValue = static_cast<int>(pCurve.KeyGetValue(lCount))
        lKeyTime  = pCurve.KeyGetTime(lCount)

        lOutputString = "            Key Time: "
        lOutputString += lKeyTime.GetTimeString(lTimeString)
        lOutputString += ".... Key Value: "
        lOutputString += lKeyValue
        lOutputString += " ("
        lOutputString += pProperty.GetEnumValue(lKeyValue)
        lOutputString += ")"

        print(lOutputString)

it uses static_cast<int> expression, which looks like from C++. Is it valid in Python?

Dims
  • 47,675
  • 117
  • 331
  • 600

1 Answers1

3

No, there is no static_cast in Python.

In the example you show, pCurve.KeyGetValue(lCount) (whose type is not apparent in the code) is being cast to an int. You could try replacing the static_cast<int> with just int. This will work if the original value is some kind of scalar number, or a string representing an integer.

For example int('23') == 23 would evaluate to True in Python.

If you can provide some more information about the type of the expression pCurve.KeyGetValue(lCount) it might be possible to come up with a solution, if the int(...) approach does not work.

jacg
  • 2,040
  • 1
  • 14
  • 27
  • I think somebody was porting from C++ and forgot this part. Since I am new to Python, I was not sure Python disallows such construct. – Dims Oct 06 '17 at 14:51