python calculator using python variable

Hello everyone

I just spent more than one hour trying to figure out something that seemed so simple to me:

I’m using the python calculator in a python script to multiply multiple PointData. This looks something like this:
pCalcQ = PythonCalculator(Input=[calcU, readerRho, pCalcH])
pCalcQ.ArrayName = “Qflux”
pCalcQ.Expression = ‘inputs[0].PointData[“U_Normal”]*inputs[1].PointData[“density”]*inputs[2].PointData[“H”]’

However, now I want to subtract a scalar value from each data point. The scalar value is stored in a variable called hRef.
Subtraction of a scalar value works fine like this:
pCalcQ.Expression = ‘inputs[0].PointData[“U_Normal”]*inputs[1].PointData[“density”]*inputs[2].PointData[“H”]-2’
but it does not withe the variable:
pCalcQ.Expression = ‘inputs[0].PointData[“U_Normal”]*inputs[1].PointData[“density”]*inputs[2].PointData[“H”]-hRef’

How to do that? I’ve tried to define the variable as input of the python calculator but that is also not working.

Thank you, regards

Oke, nevermind. The solution came to my mind as soon as I posted this:

Of course if the expression is a string, the float value of my variable has to be converted to a string.
pCalcQ.Expression = ‘inputs[0].PointData[“U_Normal”]*inputs[1].PointData[“density”]*inputs[2].PointData[“H”]-’ + str(hRef)

Works fine.

Cheers, nopech