Passing Dictionary from python to C#
Hi,
i am trying to pass a dictinoary from python to C#. i am using python25
with python.NET 2.0 alpha 2 files(python.Runtime.dll, clr.pyd). When i
try to initiate function , i get an error saying
"TypeError: No method matches given arguments". Could someone confirm
me, if this is supported?
Pythonfile:
main.py:
params = {"one": "1","two":"2"}
ret = Hello_Dict(params)
C# file:
int Hello_Dict(Dictionary
This is not supported. However, you can easily put the values of the Python dictionary into a .NET dictionary object. Unfortunately I'm not at a computer that has Python.NET installed, but I believe the following would work:
--------------------------------------------
from System.Collections.Generic import Dictionary
from System import String
params = {"one": "1","two":"2"}
dict1 = Dictionary[String, String]()
for k, v in param.iterkeys():
dict1[k] = v
ret = Hello_Dict(dict1)
--------------------------------------------
Cheers,
Feihong
--- On Wed, 6/11/08, Kaveripakam, Sathish
From: Kaveripakam, Sathish
Subject: [Python.NET] Passing Dictionary from python to C# To: pythondotnet@python.org Date: Wednesday, June 11, 2008, 7:26 AM Hi, i am trying to pass a dictinoary from python to C#. i am using python25 with python.NET 2.0 alpha 2 files(python.Runtime.dll, clr.pyd). When i try to initiate function , i get an error saying
"TypeError: No method matches given arguments". Could someone confirm me, if this is supported?
Pythonfile:
main.py:
params = {"one": "1","two":"2"}
ret = Hello_Dict(params)
C# file:
int Hello_Dict(Dictionary
params_= { --; --; return 1; }
******************** Legal Notice: The information in this electronic transmission may contain confidential or legally privileged information and is intended solely for the individual(s) named above. If you are not an intended recipient or an authorized agent, you are hereby notified that reading, distributing, or otherwise disseminating, copying or taking any action based on the contents of this transmission is strictly prohibited. Any unauthorized interception of this transmission is illegal under law. If you have received this transmission in error, please notify the sender by telephone [at the number indicated above/ on +41 58 928 0101] as soon as possible and then destroy all copies of this transmission. ********************_________________________________________________ Python.NET mailing list - PythonDotNet@python.org http://mail.python.org/mailman/listinfo/pythondotnet
participants (2)
-
Feihong Hsu
-
Kaveripakam, Sathish