Discussion:
[Python.NET] Passing Dictionary from python to C#
Kaveripakam, Sathish
2008-06-11 12:26:30 UTC
Permalink
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<String,String> 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.
********************
Feihong Hsu
2008-06-11 13:09:20 UTC
Permalink
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
Subject: [Python.NET] Passing Dictionary from python to C#
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?
"1","two":"2"}
ret = Hello_Dict(params)
int Hello_Dict(Dictionary<String,String> params_=
{
--;
--;
return 1;
}
********************
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.
********************_________________________________________________
http://mail.python.org/mailman/listinfo/pythondotnet
_________________________________________________
Python.NET mailing list - PythonDotNet-+ZN9ApsXKcEdnm+***@public.gmane.org
http://mail.python.org/mailman/listinfo/pythondotnet

Loading...