[IronPython] Help with Ops.GetAttr

Paul Turbett sls at iinet.net.au
Tue Feb 12 14:30:02 CET 2008


Hi,

I'm attempting to get an attribute from python object from C# using a 
method like this:

public object GetAttr(object pyObject, string name)
{
   ICallerContext context = _pythonEngine.DefaultModule as ICallerContext;
   object value = Ops.GetAttr( context, pyObject, 
SymbolTable.StringToId(name));
   return value;
}

where _pythonEngine is a PythonEngine object, pyObject is a python 
object and name is the attribute I want to get.

According to other posts I've seen, this should work, but the first line 
sets context to null. How to I get a valid context?

It seems every way I've read about to get the context 
(DefaultContext.Default, GetModuleScope) is private, and therefore 
inaccessible.

I'm using IPY 1.1.1

TIA, Paul



More information about the Ironpython-users mailing list