<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> Thanks for the reply, Jeff. <o:p></o:p></p><p class=MsoPlainText><o:p> </o:p></p><p class=MsoPlainText style='text-indent:.5in'>ILSpy reports for "Type" (the “IL” version):<o:p></o:p></p><p class=MsoPlainText><o:p> </o:p></p><p class=MsoPlainText> <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"'> {<o:p></o:p></span></p><p class=MsoPlainText><span style='font-family:"Courier New"'> .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"'> 01 00 50 10 00 00<o:p></o:p></span></p><p class=MsoPlainText><span style='font-family:"Courier New"'> )<o:p></o:p></span></p><p class=MsoPlainText><span style='font-family:"Courier New"'> .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"'> 01 00 </span>... (lots of numbers)<span style='font-family:"Courier New"'><o:p></o:p></span></p><p class=MsoPlainText><o:p> </o:p></p><p class=MsoPlainText> And for "function":<o:p></o:p></p><p class=MsoPlainText><o:p> </o:p></p><p class=MsoPlainText> <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"'> instance object marshal(idispatch) function (<o:p></o:p></span></p><p class=MsoPlainText><span style='font-family:"Courier New"'> [in] string marshal(bstr) Name,<o:p></o:p></span></p><p class=MsoPlainText><span style='font-family:"Courier New"'> [in] bool Option,<o:p></o:p></span></p><p class=MsoPlainText><span style='font-family:"Courier New"'> [in] [out] int32& Errors<o:p></o:p></span></p><p class=MsoPlainText><span style='font-family:"Courier New"'> ) runtime managed internalcall <o:p></o:p></span></p><p class=MsoPlainText><span style='font-family:"Courier New"'> {<o:p></o:p></span></p><p class=MsoPlainText><span style='font-family:"Courier New"'> .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"'> 01 00 5b 00 00 00 00 00<o:p></o:p></span></p><p class=MsoPlainText><span style='font-family:"Courier New"'> )<o:p></o:p></span></p><p class=MsoPlainText><o:p> </o:p></p><p class=MsoPlainText> 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> </o:p></p><p class=MsoPlainText> Thanks,<o:p></o:p></p><p class=MsoPlainText> ~Mike C. <o:p></o:p></p><p class=MsoPlainText><o:p> </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> </o:p></p><p class=MsoPlainText>On Thu, Dec 1, 2011 at 10:14 AM, Michael Colonno <<a href="mailto:mcolonno@stanford.edu"><span style='color:windowtext;text-decoration:none'>mcolonno@stanford.edu</span></a>> wrote:<o:p></o:p></p><p class=MsoPlainText>> In VB.NET, this works just fine:<o:p></o:p></p><p class=MsoPlainText>><o:p> </o:p></p><p class=MsoPlainText>><o:p> </o:p></p><p class=MsoPlainText>><o:p> </o:p></p><p class=MsoPlainText>> Dim A As Type<o:p></o:p></p><p class=MsoPlainText>> Dim Name As String<o:p></o:p></p><p class=MsoPlainText>> Dim Option As Boolean<o:p></o:p></p><p class=MsoPlainText>> Dim Err As Integer<o:p></o:p></p><p class=MsoPlainText>> Dim value As Object<o:p></o:p></p><p class=MsoPlainText>><o:p> </o:p></p><p class=MsoPlainText>> value = A.function(Name, Option, Err)<o:p></o:p></p><p class=MsoPlainText>><o:p> </o:p></p><p class=MsoPlainText>> In IronPython I am trying (pseudo-code):<o:p></o:p></p><p class=MsoPlainText>><o:p> </o:p></p><p class=MsoPlainText>> import clr<o:p></o:p></p><p class=MsoPlainText>> clr.AddReferenceToFileAndPath("relevant dll") from <o:p></o:p></p><p class=MsoPlainText>> API.Interop.whatever import Type<o:p></o:p></p><p class=MsoPlainText>><o:p> </o:p></p><p class=MsoPlainText>> A = Type()<o:p></o:p></p><p class=MsoPlainText>> value = A.function("Name", True, err)<o:p></o:p></p><p class=MsoPlainText>><o:p> </o:p></p><p class=MsoPlainText>> Two issues / questions:<o:p></o:p></p><p class=MsoPlainText>><o:p> </o:p></p><p class=MsoPlainText>> 1. The IronPython code above produces: TypeError: Cannot create <o:p></o:p></p><p class=MsoPlainText>> instances of Type because it is abstract. Why is an abstract Python <o:p></o:p></p><p class=MsoPlainText>> class being created and do I have any control over this?<o:p></o:p></p><p class=MsoPlainText><o:p> </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> </o:p></p><p class=MsoPlainText>><o:p> </o:p></p><p class=MsoPlainText>> 2. Changing the code to access the functions of Type directly (e.g.<o:p></o:p></p><p class=MsoPlainText>> Type.function()) results in a “self” argument being expressed as the <o:p></o:p></p><p class=MsoPlainText>> first argument in the function. i.e. the syntax expected is now <o:p></o:p></p><p class=MsoPlainText>> Type.function(self, string, boolean, int). I’m familiar with “self” <o:p></o:p></p><p class=MsoPlainText>> only in the context of defining class functions and not outside of a <o:p></o:p></p><p class=MsoPlainText>> class definition.<o:p></o:p></p><p class=MsoPlainText><o:p> </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> </o:p></p><p class=MsoPlainText>- Jeff<o:p></o:p></p></div></body></html>