[Python.NET] IronPython Embeddied .NET 4.0, how to transfer object from C# into Ironpython and back again
riscy00
riscy00 at gmail.com
Thu May 17 20:33:25 CEST 2012
In addition, as an example for LIST<T> basis (rather than Dictionary for
which I primary interested once I get hang of the below....
In Python
=======================================================
class Pointer(object): #class definition
def __init__(self, alist, index):
self.alist = alist
self.index = index
def get(self): # get
return self.alist[self.index]
def set(self, value): # set
self.alist[self.index] = value
def find(q):
return Pointer(q, 0)
def Process():
list1 = [1, 2, 3] #list object
p = find(list1) #this create instance of the
Pointer object with p as reference and then implement list value
p.set(0) #Modify the list value on index
0
return list1
=====================================================================
I also have C# .NET4 with embedded python
In C#
=====================================================================
private void btnRun2_Click(object sender, EventArgs e)
{
// C# Side
var runtime = Python.CreateRuntime();
dynamic test = runtime.UseFile(m_sFilename); // filename point
to test.py (above code)
var result = test.Process();
rtbConsole.Text += result.ToString();
}
=======================================================================
Under debug, I can see result containing the list element 1,2,3 (with
data)...which is great.
(a) How to pass the LIST<T> in C# to python
(b) How to pass the LIST<T> back to C# after python calculation routine.
(c) How to make return result into LIST<T> from the above....
Your input would be appreciated.
--
View this message in context: http://python.6.n6.nabble.com/IronPython-Embeddied-NET-4-0-how-to-transfer-object-from-C-into-Ironpython-and-back-again-tp4974924p4974958.html
Sent from the Python - pythondotnet mailing list archive at Nabble.com.
More information about the PythonDotNet
mailing list