#1) After creating a module you should be able to publish the object directly
into the module's scope. The normal CreateModule APIs allow you to provide a
dictionary which could already contain this object. Unfortunately all the
objects members won't be magically available, you'll need to access the members
through the object. You could execute some python code such as:
import sys
mymod = sys.modules[__name__]
for x in dir(myobj):
setattr(mymod, x, getattr(myobj, x))
which will copy all the members from the object into the module (you could also
do the equivalent from C# using Ops.GetAttrNames, Ops.GetAttr, and Ops.SetAttr).
#2 - yes, to do this you just need to add a reference to the assembly and
import the type from the correct namespace. E.g.:
import clr
clr.AddReference('System.Windows.Forms')
from System.Windows.Forms import Form
class MyForm(Form): pass
a = MyForm()
#3 - There's a couple of ways to do this. You could use the CreateMethod /
CreateLambda APIs which will return a strongly typed delegate w/ some code you
can later call. You can also use the CompiledCode method and the Execute
method will re-run it. The overload that takes an EngineModule allows you to
execute the code multiple times with a different set of globals.
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Ori
Sent: Wednesday, August 01, 2007 5:08 AM
To: [email protected]
Subject: [IronPython] Some questions about Iron-Python
Hello,
I'm new to IronPython and I have a few qusetions:
1. Is there an option to add a context object to the compiled module (so all
properties and methods from the object will be accesible)
2. Can a python class inherit from a class located in some referenced .net
assembly?
3. Can I save compiled code in memory and use it to evaluate code multiple
times? I've seen there is a CompiledCode object but I saw only an Execute
method.
Thanks,
Ori
--
View this message in context:
http://www.nabble.com/Some-questions-about-Iron-Python-tf4198487.html#a11940989
Sent from the IronPython mailing list archive at Nabble.com.
_______________________________________________
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