Suppose I have the following IronPython script:
def Calculate(input):
return input * 1.21
When called from C # with a decimal point, this function returns double:
var python = Python.CreateRuntime();
dynamic engine = python.UseFile("mypythonscript.py")
decimal input = 100m;
decimal result = engine.Calculate(input);
I seem to have two options:
Firstly, I could dump on the C # side: it seems that no-go, as I may lose accuracy.
decimal result = (decimal)engine.Calculate(input);
The second option is to use System.Decimal in a python script: it works, but it somewhat pollutes the script ...
from System import *
def CalculateVAT(amount):
return amount * Decimal(1.21)
Is there a short-form DLR that the number 1.21 should be interpreted as decimal, just as I would use the notation “1.21m” in C #? Or is there another way to force a decimal instead of two?