[Ironpython-users] abstract class conversion?

Michael Colonno mcolonno at stanford.edu
Thu Dec 1 19:14:02 CET 2011


            Hi ~

 

            I'm trying to port some VB.NET code to IronPython; the goal is
to access third-party .NET functionality through Python. I've managed to
connect to the relevant Interop .dll files and expose the API but I'm having
trouble reproducing the VB.NET functionality from Python (most likely due to
my lack of familiarity with .NET itself).

 

            In VB.NET, this works just fine: 

 

Dim A As Type 

Dim Name As String 

Dim Option As Boolean 

Dim Err As Integer 

Dim value As Object 

 

value = A.function(Name, Option, Err)

            In IronPython I am trying (pseudo-code):

 

import clr

clr.AddReferenceToFileAndPath("relevant dll")

from API.Interop.whatever import Type

 

A = Type()

value = A.function("Name", True, err)

 

            Two issues / questions: 

 

1.     The IronPython code above produces: TypeError: Cannot create
instances of Type because it is abstract. Why is an abstract Python class
being created and do I have any control over this?

2.     Changing the code to access the functions of Type directly (e.g.
Type.function()) results in a "self" argument being expressed as the first
argument in the function. i.e. the syntax expected is now
Type.function(self, string, boolean, int). I'm familiar with "self" only in
the context of defining class functions and not outside of a class
definition.  

 

My guess is that I'm not understanding / using the .NET <---> Python
conversion correctly. Any advice or guidance would be greatly appreciated.

 

Thanks,

~Mike C.  

 

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20111201/dbf0d9ee/attachment.html>


More information about the Ironpython-users mailing list