You could use Ops.TryGetAttr which doesn't take a context (and flows the 
default context in for you).

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Paul Turbett
Sent: Tuesday, February 12, 2008 5:30 AM
To: [email protected]
Subject: [IronPython] Help with Ops.GetAttr

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
_______________________________________________
Users mailing list
[email protected]
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
_______________________________________________
Users mailing list
[email protected]
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com

Reply via email to