[Ironpython-users] instropection in an embedded engine
Dino Viehland
dinov at microsoft.com
Fri Sep 23 21:43:48 CEST 2011
__class__ exists on object in python and is then inherited by the other types. When accessing a member from
C# you get its view of the world which doesn't include Python object members. To get the Python type I suggest calling DynamicHelpers.GetPythonType.
Sent from my Windows Phone
-----Original Message-----
From: Hernán Foffani
Sent: Friday, September 23, 2011 9:12 AM
To: ironpython-users at python.org
Subject: [Ironpython-users] instropection in an embedded engine
Having the following Python code:
class Plugin:
def method(self):
pass
plugin = Plugin()
and an embedded ScriptScope instance in my .NET application,
the following C# works fine
dynamic plugin = pythonEngine.GetVariable("plugin");
var attrs = plugin.__class__.__dict__;
if Plugin python class was defined as an old-style class, but fails if
Plugin inherits from object (__class__ non existent).
Under the VS debugger the dynamic object plugin shows as having three
attributes .class, .dict and .slots_and_weakref (with dots in their names) but
no __class__ or __dict__.
I found that I could do something like plugin.method.im_class.__dict__ but
I'd rather stick with the common idiom.
Is it a known issue? Something related to the way I'm using the engine?
Thanks in advance,
-Hernán.
_______________________________________________
Ironpython-users mailing list
Ironpython-users at python.org
http://mail.python.org/mailman/listinfo/ironpython-users
More information about the Ironpython-users
mailing list