<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=us-ascii"><meta name=Generator content="Microsoft Word 14 (filtered medium)"><style><!--
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
p.MsoPlainText, li.MsoPlainText, div.MsoPlainText
        {mso-style-priority:99;
        mso-style-link:"Plain Text Char";
        margin:0in;
        margin-bottom:.0001pt;
        font-size:10.0pt;
        font-family:"Arial","sans-serif";}
span.PlainTextChar
        {mso-style-name:"Plain Text Char";
        mso-style-priority:99;
        mso-style-link:"Plain Text";
        font-family:"Arial","sans-serif";}
.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri","sans-serif";}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=EN-US link=blue vlink=purple><div class=WordSection1><p class=MsoPlainText>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Thanks for the reply, Jeff. <o:p></o:p></p><p class=MsoPlainText><o:p>&nbsp;</o:p></p><p class=MsoPlainText style='text-indent:.5in'>ILSpy reports for &quot;Type&quot; (the &#8220;IL&#8221; version):<o:p></o:p></p><p class=MsoPlainText><o:p>&nbsp;</o:p></p><p class=MsoPlainText>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style='font-family:"Courier New"'>.class interface public auto ansi abstract import [relevant dll name]<o:p></o:p></span></p><p class=MsoPlainText><span style='font-family:"Courier New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<o:p></o:p></span></p><p class=MsoPlainText><span style='font-family:"Courier New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; .custom instance void [mscorlib]System.Runtime.InteropServices.TypeLibTypeAttribute::.ctor(int16) = (<o:p></o:p></span></p><p class=MsoPlainText><span style='font-family:"Courier New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 01 00 50 10 00 00<o:p></o:p></span></p><p class=MsoPlainText><span style='font-family:"Courier New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; )<o:p></o:p></span></p><p class=MsoPlainText><span style='font-family:"Courier New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; .custom instance void [mscorlib]System.Runtime.InteropServices.GuidAttribute::.ctor(string) = (<o:p></o:p></span></p><p class=MsoPlainText><span style='font-family:"Courier New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 01 00 </span>... (lots of numbers)<span style='font-family:"Courier New"'><o:p></o:p></span></p><p class=MsoPlainText><o:p>&nbsp;</o:p></p><p class=MsoPlainText>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; And for &quot;function&quot;:<o:p></o:p></p><p class=MsoPlainText><o:p>&nbsp;</o:p></p><p class=MsoPlainText>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style='font-family:"Courier New"'>.method public hidebysig newslot abstract virtual <o:p></o:p></span></p><p class=MsoPlainText><span style='font-family:"Courier New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; instance object marshal(idispatch) function (<o:p></o:p></span></p><p class=MsoPlainText><span style='font-family:"Courier New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; [in] string marshal(bstr) Name,<o:p></o:p></span></p><p class=MsoPlainText><span style='font-family:"Courier New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; [in] bool Option,<o:p></o:p></span></p><p class=MsoPlainText><span style='font-family:"Courier New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; [in] [out] int32&amp; Errors<o:p></o:p></span></p><p class=MsoPlainText><span style='font-family:"Courier New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ) runtime managed internalcall <o:p></o:p></span></p><p class=MsoPlainText><span style='font-family:"Courier New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<o:p></o:p></span></p><p class=MsoPlainText><span style='font-family:"Courier New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; .custom instance void [mscorlib]System.Runtime.InteropServices.DispIdAttribute::.ctor(int32) = (<o:p></o:p></span></p><p class=MsoPlainText><span style='font-family:"Courier New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 01 00 5b 00 00 00 00 00<o:p></o:p></span></p><p class=MsoPlainText><span style='font-family:"Courier New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; )<o:p></o:p></span></p><p class=MsoPlainText><o:p>&nbsp;</o:p></p><p class=MsoPlainText>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; I confess this does not mean a whole lot to me, though both Type and function are declared as abstract. Hopefully this sheds light on the behavior in IronPython. <o:p></o:p></p><p class=MsoPlainText><o:p>&nbsp;</o:p></p><p class=MsoPlainText>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Thanks,<o:p></o:p></p><p class=MsoPlainText>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ~Mike C. <o:p></o:p></p><p class=MsoPlainText><o:p>&nbsp;</o:p></p><p class=MsoPlainText>-----Original Message-----<br>From: Jeff Hardy [mailto:jdhardy@gmail.com] <br>Sent: Thursday, December 01, 2011 10:36 AM<br>To: Michael Colonno<br>Cc: ironpython-users@python.org<br>Subject: Re: [Ironpython-users] abstract class conversion?</p><p class=MsoPlainText><o:p>&nbsp;</o:p></p><p class=MsoPlainText>On Thu, Dec 1, 2011 at 10:14 AM, Michael Colonno &lt;<a href="mailto:mcolonno@stanford.edu"><span style='color:windowtext;text-decoration:none'>mcolonno@stanford.edu</span></a>&gt; wrote:<o:p></o:p></p><p class=MsoPlainText>&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; In VB.NET, this works just fine:<o:p></o:p></p><p class=MsoPlainText>&gt;<o:p>&nbsp;</o:p></p><p class=MsoPlainText>&gt;<o:p>&nbsp;</o:p></p><p class=MsoPlainText>&gt;<o:p>&nbsp;</o:p></p><p class=MsoPlainText>&gt; Dim A As Type<o:p></o:p></p><p class=MsoPlainText>&gt; Dim Name As String<o:p></o:p></p><p class=MsoPlainText>&gt; Dim Option As Boolean<o:p></o:p></p><p class=MsoPlainText>&gt; Dim Err As Integer<o:p></o:p></p><p class=MsoPlainText>&gt; Dim value As Object<o:p></o:p></p><p class=MsoPlainText>&gt;<o:p>&nbsp;</o:p></p><p class=MsoPlainText>&gt; value = A.function(Name, Option, Err)<o:p></o:p></p><p class=MsoPlainText>&gt;<o:p>&nbsp;</o:p></p><p class=MsoPlainText>&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; In IronPython I am trying (pseudo-code):<o:p></o:p></p><p class=MsoPlainText>&gt;<o:p>&nbsp;</o:p></p><p class=MsoPlainText>&gt; import clr<o:p></o:p></p><p class=MsoPlainText>&gt; clr.AddReferenceToFileAndPath(&quot;relevant dll&quot;) from <o:p></o:p></p><p class=MsoPlainText>&gt; API.Interop.whatever import Type<o:p></o:p></p><p class=MsoPlainText>&gt;<o:p>&nbsp;</o:p></p><p class=MsoPlainText>&gt; A = Type()<o:p></o:p></p><p class=MsoPlainText>&gt; value = A.function(&quot;Name&quot;, True, err)<o:p></o:p></p><p class=MsoPlainText>&gt;<o:p>&nbsp;</o:p></p><p class=MsoPlainText>&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Two issues / questions:<o:p></o:p></p><p class=MsoPlainText>&gt;<o:p>&nbsp;</o:p></p><p class=MsoPlainText>&gt; 1.&nbsp;&nbsp;&nbsp;&nbsp; The IronPython code above produces: TypeError: Cannot create <o:p></o:p></p><p class=MsoPlainText>&gt; instances of Type because it is abstract. Why is an abstract Python <o:p></o:p></p><p class=MsoPlainText>&gt; class being created and do I have any control over this?<o:p></o:p></p><p class=MsoPlainText><o:p>&nbsp;</o:p></p><p class=MsoPlainText>Calling `A = Type()` tries to create an instance of Type, which your VB code doesn't do. Is `Type.function` a static method?<o:p></o:p></p><p class=MsoPlainText><o:p>&nbsp;</o:p></p><p class=MsoPlainText>&gt;<o:p>&nbsp;</o:p></p><p class=MsoPlainText>&gt; 2.&nbsp;&nbsp;&nbsp;&nbsp; Changing the code to access the functions of Type directly (e.g.<o:p></o:p></p><p class=MsoPlainText>&gt; Type.function()) results in a &#8220;self&#8221; argument being expressed as the <o:p></o:p></p><p class=MsoPlainText>&gt; first argument in the function. i.e. the syntax expected is now <o:p></o:p></p><p class=MsoPlainText>&gt; Type.function(self, string, boolean, int). I&#8217;m familiar with &#8220;self&#8221; <o:p></o:p></p><p class=MsoPlainText>&gt; only in the context of defining class functions and not outside of a <o:p></o:p></p><p class=MsoPlainText>&gt; class definition.<o:p></o:p></p><p class=MsoPlainText><o:p>&nbsp;</o:p></p><p class=MsoPlainText>It really depends on how what the signature of the function is. If it's static, calling `Type.function` from Python shouldn't need a self argument. Can you find the signature of `Type.function` (ILSpy is your friend here). Feel free to elide the names; they're not really important.<o:p></o:p></p><p class=MsoPlainText><o:p>&nbsp;</o:p></p><p class=MsoPlainText>- Jeff<o:p></o:p></p></div></body></html>