[Ironpython-users] DynamicObjects.TryConvert not called in IronPython?
dinov at microsoft.com
Fri Jun 24 22:17:40 CEST 2011
In IronPython an assignment to a local/global variable will never perform a conversion. In your C# code the conversion has to happen because the variable you're assigning to is typed as double.
To force the conversion you should be able to do float(obj.M1.M2.M3) or you can use the clr.Convert function.
From: ironpython-users-bounces+dinov=microsoft.com at python.org [mailto:ironpython-users-bounces+dinov=microsoft.com at python.org] On Behalf Of zxpatric
Sent: Friday, June 24, 2011 1:00 PM
To: ironpython-users at python.org
Subject: [Ironpython-users] DynamicObjects.TryConvert not called in IronPython?
I am doing the similar thing as in "http://blogs.msdn.com/b/csharpfaq/archive/2009/10/19/dynamic-in-c-4-0-creating-wrappers-with-dynamicobject.aspx" to first convert any member into an object and then expect the object.TryConvert to handle the final convert. However, what is working in C# as double a = obj.M1.M2.M3 (return instance of Type C3, which has the TryConvert to convert it to double type) doesn't work in IronPython. The last step of converting instance of C3 to double in C3.TryConvert never happens. I am currently using IronPython 18.104.22.168. Is this a known issue that has been addressed in 2.7.1 Beta?
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Ironpython-users