From craig_farrow at sil.org Fri Jun 6 10:45:53 2008 From: craig_farrow at sil.org (Craig Farrow) Date: Fri, 06 Jun 2008 16:45:53 +0800 Subject: [Python.NET] Accessing custom module Message-ID: <4848F941.6050707@sil.org> Hi, I'm trying to access a custom .NET Assembly with Python .NET, but can't get it to recognise the Assembly name space. IronPython works fine in the code below. Any clues? I'm using the Python .NET build from here: http://sourceforge.net/project/showfiles.php?group_id=162464 ------------------------- import sys GLOBAL_IRONPython = "Iron" in sys.version # Need full path (or could add the path to sys.path) FDO_DLL_PATH = "c:\\program files\\sil\\fieldworks\\FDO.dll" import clr if GLOBAL_IRONPython: print "IRON Python Startup" clr.AddReferenceToFileAndPath(FDO_DLL_PATH) else: # Python .NET print "Python .NET Startup" from System.Reflection import Assembly fdo = Assembly.LoadFile(FDO_DLL_PATH) # This is failing in Python .NET -- "No module named SIL.FieldWorks.FDO"! from SIL.FieldWorks.FDO import FdoCache db = FdoCache.Create("DB-name") print db.ServerName, db.DatabaseName ------------------------- I've also tried clr.AddReference("SIL.FieldWorks.FDO"), but that reports "Unable to find assembly 'SIL.Fieldworks.FDO'." Thanks, Craig. -------------- next part -------------- An HTML attachment was scrubbed... URL: From Sathish.Kaveripakam at phonak.com Wed Jun 11 14:26:30 2008 From: Sathish.Kaveripakam at phonak.com (Kaveripakam, Sathish) Date: Wed, 11 Jun 2008 14:26:30 +0200 Subject: [Python.NET] Passing Dictionary from python to C# Message-ID: 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. ******************** -------------- next part -------------- An HTML attachment was scrubbed... URL: From hsu.feihong at yahoo.com Wed Jun 11 15:09:20 2008 From: hsu.feihong at yahoo.com (Feihong Hsu) Date: Wed, 11 Jun 2008 06:09:20 -0700 (PDT) Subject: [Python.NET] Passing Dictionary from python to C# In-Reply-To: Message-ID: <378863.59357.qm@web34806.mail.mud.yahoo.com> 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 wrote: > From: Kaveripakam, Sathish > Subject: [Python.NET] Passing Dictionary from python to C# > To: pythondotnet at 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 at python.org > http://mail.python.org/mailman/listinfo/pythondotnet From Sathish.Kaveripakam at phonak.com Thu Jun 12 21:28:28 2008 From: Sathish.Kaveripakam at phonak.com (Kaveripakam, Sathish) Date: Thu, 12 Jun 2008 21:28:28 +0200 Subject: [Python.NET] Calling a python script from managed C++ Message-ID: An HTML attachment was scrubbed... URL: From Sathish.Kaveripakam at phonak.com Tue Jun 17 23:21:31 2008 From: Sathish.Kaveripakam at phonak.com (Kaveripakam, Sathish) Date: Tue, 17 Jun 2008 23:21:31 +0200 Subject: [Python.NET] Reflection handling in python.net Message-ID: An HTML attachment was scrubbed... URL: From johanbeke at hotmail.com Fri Jun 13 17:47:45 2008 From: johanbeke at hotmail.com (Johan Beke) Date: Fri, 13 Jun 2008 15:47:45 +0000 Subject: [Python.NET] embedding python in vb .NET Message-ID: Hello all, I have two questions: 1) are there examples of embedding python in vb .NET 2) I'm trying to figure out how I can use the Python.Runtime.dll form VB.NET. I added it as a reference and imported using: Imports Python.Runtime Module Module1 Sub Main() PythonEngine.Initialize() Dim a As String PythonEngine.RunString("5+7" & vbCrLf) ' how can I get the result of that easy string? End Sub End Module Many Thx, Johan _________________________________________________________________ Nieuwe lente...Een nieuw online leven...Gratis dankzij Windows Live http://get.live.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From Sathish.Kaveripakam at phonak.com Thu Jun 19 15:24:46 2008 From: Sathish.Kaveripakam at phonak.com (Kaveripakam, Sathish) Date: Thu, 19 Jun 2008 15:24:46 +0200 Subject: [Python.NET] Custom arguments from python to C# Message-ID: Hi All, I am trying to interface with C# dlls from python. I am using Python.net 2.0 version. Please find the problem description: python: clr.AddReference("X.dll") import Master.Child as ChildClass ChildClass.Currclass(structVal, enumval) ---Step 1 ChildClass.Currclass(2,3) ---Step 2 C# code (which gives X.dll) namespace Master.Child { enum enumval { -, --, --, } class Currclass{ Currclass(Stream X, enumval enum) .-.-Constructor 1 { Console.WriteLine("Step1"); } Currclass(int x, int y) .-.-Constructor 2 { Console.WriteLine("Step2");} }} When i try to create an instance using the custom types (ie Setp1), the C# constructor : Constructor2 is executed and while executing the Step2 also the Constructor 2 is called. I am not sure, why Constructor 1 is not called. Is it because it uses the custom arguments types ? Any inputs to call Constructor1 is welcome. ******************** 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. ******************** -------------- next part -------------- An HTML attachment was scrubbed... URL: