[IronPython] IronPython and polymorphism? Help with interfaces

Miha Valencic miha.valencic at gmail.com
Wed Jan 23 16:18:00 CET 2008


Slide, doesn't work:
I get. Unhandled Exception:
IronPython.Runtime.Exceptions.ArgumentTypeException: NoneType object is not
callable

I passed as IPerson and I even casted to IPerson in IPY.
The script:
  print IPerson(Env).Name
produces NoneType object is not callable exception and the script
  print Env.Name
produces Unhandled Exception: System.MissingMemberException: 'Person' object
has no attribute 'Name'

Is there anything else I could try? It seems weird that explicitly defined
interfaces are not callable. There are probably some even in .NET fx.. I
even tried:
IPerson pers = new Person() as IPerson;
locals["Env"] = pers as IPerson;
still no go.

Funny thing is, that dir(IPerson) lists the "Name" attribute (property):
['Name', '__class__', '__doc__', '__init__', '__module__', '__repr__']

Miha

On Jan 23, 2008 3:55 PM, Slide <slide.o.mix at gmail.com> wrote:

> On Jan 23, 2008 6:46 AM, Miha Valencic <miha.valencic at gmail.com> wrote:
> > Slide, thanks for a quick response. My answers are inline:
>           Person p = new Person();
>           locals["Env"] = p as IPerson;
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20080123/d91db636/attachment.html>


More information about the Ironpython-users mailing list