There is actually a bug in IronPython. In the case of overloaded properties IronPython doesn’t handle the overloads and exposes only the property which was retrieved last via the reflection. In some cases it may be the parameter-less property, in some cases it may be the indexer, depending on the compiler/metadata etc.

 

In your case, the property returning an array of Costume is not accessible via IronPython at all and the only workaround is to rename the property in VB and avoid the conflict.

 

Martin

 

From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Rob Ashton
Sent: Tuesday, September 26, 2006 8:02 AM
To: users@lists.ironpython.com
Subject: [IronPython] Overloaded Properties

 

Apologies if this one seems obvious, I’m not a python programmer J

 

I’ve embedded the PythonEngine into a Visual Basic application that I’ve been writing on and off for the past few months, and one of the nice things that Visual Basic has over C# is of course multiple indexed properties and all the gubbins that come with it.

 

So, I’ve got these two properties:

 

    ''' <summary>

    ''' Costumes that the Engine has access to

    ''' </summary>

    Public ReadOnly Property Costumes() As Costume()

 

 

And

 

 

    ''' <summary>

    ''' Gets a Costume By Resource Name

    ''' </summary>

    Public ReadOnly Property Costumes(ByVal name As String) As Costume

 

 

When writing Python in my Scripting window, I can access the indexed property easily enough with the following Python. ( Engine is the global variable which exposes the entire object model within this application )

 

Engine.Resources.Costumes["f_stunt_burn"]

 

Now. How do I access the plain good ol’ Array of costumes so I can run some batch testing scripts which was the whole purpose of throwing IronPython into this application?

 

I want to do something like:

 

for costume in Engine.Resources.Costumes:

 print costume.GameName

 

for example, but of course it think’s I’m trying to access the indexed property and gets very confused!

 

I looked at some earlier list postings which talked about using [type] as a way of specifying when calling methods, but other than that I’ve been Googling for over an hour and have found nothing.

 

Am I going to have to move that property into a function called GetCostumes() to make this work? J

 

- Rob

_______________________________________________
users mailing list
users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com

Reply via email to