[Ironpython-users] Implicit conversion of objects to float

Jeff Hardy jdhardy at gmail.com
Mon Feb 27 17:20:24 CET 2012


> On Fri, Feb 24, 2012 at 7:50 PM, Cesar Mello <cmello at gmail.com> wrote:
> I agree it may be error-prone. But there are valid scenarios where it is not. Although implementing the arithmetic overloads allow me to mix DataValues and floats in the same expressions, I am not able to initialize a Python's Decimal with a DataValue, for example. In C# that could be done.

On Mon, Feb 27, 2012 at 12:05 AM, Markus Schaber
<m.schaber at 3s-software.com> wrote:
> If you want to create a Decimal out of your DataValue, you could add an implicit operator Decimal to your DataValue as a workaround instead.

You still couldn't pass a DataValue directly to a decimal.Decimal,
though. I added conversions from System.Decimal to decimal.Decimal in
2.7.2, but I didn't think about implicit conversions of other types.
I'm thinking now that anything that's either a System.Decimal or
implicitly convertible to System.Decimal should be accepted.

- Jeff


More information about the Ironpython-users mailing list