From lcatalin at siadv.com Mon Feb 6 13:58:40 2006 From: lcatalin at siadv.com (Catalin Lungu) Date: Mon, 6 Feb 2006 13:58:40 +0100 Subject: [Python.NET] Dictionary and PyDict Message-ID: <001801c62b1d$0ec930b0$c800a8c0@catalin> Hi all, Why can't I import in Python the CLR.System.Collections.Generic.Dictionary assembly? I can import only System.Collections.Generic. Another thing. I have the following finction in C# public PyDict myfunc(PyDict PythonDict) { return PythonDict; } and I call it from Python dct = myfunc({"aaa":"bbb"}) I receive an error: TypeError: no method matches given arguments Where can I find a manual with samples of use of PyDict, PyList, PyString, etc.? Thanks in advance, Catalin -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/pythondotnet/attachments/20060206/a029df1a/attachment.htm From Pierre.Zeeman at psitek.com Thu Feb 9 15:06:33 2006 From: Pierre.Zeeman at psitek.com (Pierre Zeeman) Date: Thu, 9 Feb 2006 16:06:33 +0200 Subject: [Python.NET] WndProc Message-ID: Hi, This is probably a rather obscure question, but I don't suppose anyone here knows how to override WndProc? I am using dotnet to provide a GUI for python code and I'd like to use the win32 api WM_COPYDATA message to send simple messages between forms. I can do this in c# using this rather simple bit of code: protected override void WndProc(ref Message m) { if (m.Msg == WM_COPYDATA) { //do something with message } base.WndProc(ref m); } But despite my best efforts, I can't seem to get this to work in pythondotnet. Any ideas? Thanks and regards Pierre Zeeman Software Developer Psitek (Pty) Ltd Tel: +27 21 912 2100 Fax: +27 21 912 2200 Web: www.psitek.com Notice This email is intended for the addressee only and may contain legally privileged and/or confidential information. If you have received this email in error and are not the intended recipient, you are hereby informed that you are not entitled to read, broadcast, distribute or in any manner whatsoever use the contents of this email or any attachments thereto. You are requested to please notify Psitek that you have received the email and then delete it. Unless clearly stated otherwise, the content and sentiments expressed in this email or any attachments thereto are those of the sender and not of Psitek (Proprietary) Limited. Psitek does not accept liability for any damages, loss or expense of any nature whatsoever arising (a) out of or in connection with the email or any attachments thereto and/or (b) from any act or omission by the recipient relying upon the content of the email or attachments. Psitek further disclaims liability for any damages caused by computer and/or software viruses. Should this email contain the terms of a contract, no binding agreement will result until such time as a written (hardcopy) document is signed on behalf of Psitek. From thomas_barket at yahoo.com Mon Feb 20 19:21:12 2006 From: thomas_barket at yahoo.com (T Barket) Date: Mon, 20 Feb 2006 13:21:12 -0500 Subject: [Python.NET] Tips for Python .Net 2.0 Message-ID: <001101c6364a$6dbe5db0$0512a8c0@enterprise> Hello, I noticed some recent posts about creating a Python for .Net 2.0. I went through this about six weeks ago and learned some lessons that i think will help. I started with Michael Eddington's visual studio project (and thanks again Michael for this). However, i ran into some trouble and found some fixes. i communicated these to Michael so he may have incorporated them into his visual studio project already. but just in case he has not, i am writing out this email in case it helps anyone else. Pls feel free to ignore them if you don't need them. Lessons from Michael Eddington's Python for .Net 2.0: 1) the PythonNet2.0-0.1.zip file didn't include a file called "clrmodule.il" but I substituted with the original one from Brian's pythonnet-1.0-rc2-py2.4-clr1.1-src.zip 2) Then everything compiled and linked just fine. TestPython.exe worked fine and the Python.exe launched and I could do "import CLR" and "import CLR.System". However, I could not "import CLR.System.Windows" or "import CLR.System.Drawing": Python 2.4.1 (#65, Mar 30 2005, 09:13:57) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import CLR >>> import CLR.System.Windows Traceback (most recent call last): File "", line 1, in ? ImportError: No module named Windows >>> import CLR.System.Drawing Traceback (most recent call last): File "", line 1, in ? ImportError: No module named Drawing >>> 3) This problem is bc in .Net 2.0, System.Reflection.Assembly.LoadWithPartialName is now supposed to be obsolete (http://msdn2.microsoft.com/en-us/library/0a7zy9z5.aspx). And I recognized the change Michael made inside assemblymanager.cs's LoadAssembly method to reflect this. However, if you undo Michael's change to assemblymanager.LoadAssembly from: assembly = Assembly.Load(name) back to the original: assembly = Assembly.LoadWithPartialName(name) it will work correctly as it used to. LoadWithPartialName is not quite obsolete, it is merely deprecated. it still works in .Net 2.0. Run this code in a simple C# app to see what i mean: ---------------------------------------------------------------------------- ---------------- using System; using System.Collections.Generic; using System.Text; using System.Reflection; namespace Test_Assembly_Load { class Program { static void Main(string[] args) { Assembly assembly = null; Console.WriteLine("Try LoadWithPartialName - System.Windows.Forms"); assembly = Assembly.LoadWithPartialName("System.Windows.Forms"); Console.WriteLine("LoadWithPartialName - System.Windows.Forms: " + assembly.ToString()); Console.WriteLine("Try Load - System.Windows.Forms"); assembly = Assembly.Load("System.Windows.Forms"); // Causes runtime crash in both .net 1.1 and 2.0. Console.WriteLine("Load - System.Windows.Forms: " + assembly.ToString()); } } } ---------------------------------------------------------------------------- ---------------- 4) With the changes so far, I was able to use the PythonNet2.0 generated Python.exe with no problems. However, i wasnt able to use clr.dll and python.runtime.dll with a standard cpython interpretter, such as c:/python24/python.exe, winpython or ipython which i was albe to do with PythonNet 1.0. 5) To fix (4), i made two changes to Michael's project (which i suspect go back to Brian's original code). I commented out the code that performs the import hook replacement in pythonengine.InitEx(): // string code = // "import traceback\n" + // "for item in traceback.extract_stack():\n" + // " line = item[3]\n" + // " if line is not None:\n" + // " if line.startswith('import CLR') or \\\n" + // " line.startswith('from CLR'):\n" + // " exec line\n" + // " break\n"; // PyObject r = PythonEngine.RunString(code); // if (r != null) { // r.Dispose(); // } and rewrote a line of code in inputhook.Initialize(): Runtime.PyObject_SetAttrString(mod, "import_clr_dll", hook.ptr); //<- new line //Runtime.PyObject_SetAttrString(mod, "__import__", hook.ptr); <- replaces this old line What I have now leaves python's original import mechanism alone and for importing python-for-.net dlls I use a separate function that works as follows: C:\Documents and Settings\tbarket>python Python 2.4.1 (#65, Mar 30 2005, 09:13:57) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import CLR >>> import_clr_dll('CLR.System.Windows.Forms') >>> CLR.System.Windows.Forms Yes, I recognize it is a bit of a kludge to use "import_clr_dll('CLR.System.Windows.Forms')" instead of "import CLR.System.Windows.Forms" but i personally find this worth doing to get it to work with a standard c python interpretter via the two dlls and it was the only way i knew how to do it. i am not a profeesional programmer and a great deal of Python for .Net code is above my head and i felt very fortunate just to be able to get it to work again with these few changes. i also dont find this to be too much worse than the confusion generated over having to do an explicit "import CLR" before importing another CLR module. 6) Brian, as a personal note, i would strongly encourage you to keep going with Python for .Net regardless of IronPython. I personally have alot of python C/C++ extensions (and use alot of python modules which rely on other C/C++ extensions) which will keep me with cpython for a long, long, long time to come. Python for .Net allows me to use python as my preferred language of choice and still make use of the C# libraries that i find useful. ie, it continues python's wonderful tradition of gluing anything together. i also use C# to write my Windows GUI objects and utilize/populate them with data from my "real work code" in cpython. Moving from Python for .Net to IronPython would be like moving everything i have in C++ to C# which i am just not willing to do yet and wont for a long, long time. Tom Barket From Pierre.Zeeman at psitek.com Tue Feb 21 09:27:18 2006 From: Pierre.Zeeman at psitek.com (Pierre Zeeman) Date: Tue, 21 Feb 2006 10:27:18 +0200 Subject: [Python.NET] Tips for Python .Net 2.0 Message-ID: 6) Brian, as a personal note, i would strongly encourage you to keep going with Python for .Net regardless of IronPython. I'd like to heartily second this. Being able to use dotnet in python is much more useful to me than the other way around... Rgds Pierre Notice This email is intended for the addressee only and may contain legally privileged and/or confidential information. If you have received this email in error and are not the intended recipient, you are hereby informed that you are not entitled to read, broadcast, distribute or in any manner whatsoever use the contents of this email or any attachments thereto. You are requested to please notify Psitek that you have received the email and then delete it. Unless clearly stated otherwise, the content and sentiments expressed in this email or any attachments thereto are those of the sender and not of Psitek (Proprietary) Limited. Psitek does not accept liability for any damages, loss or expense of any nature whatsoever arising (a) out of or in connection with the email or any attachments thereto and/or (b) from any act or omission by the recipient relying upon the content of the email or attachments. Psitek further disclaims liability for any damages caused by computer and/or software viruses. Should this email contain the terms of a contract, no binding agreement will result until such time as a written (hardcopy) document is signed on behalf of Psitek. From meddington at gmail.com Sun Feb 26 23:41:20 2006 From: meddington at gmail.com (Michael Eddington) Date: Sun, 26 Feb 2006 14:41:20 -0800 Subject: [Python.NET] Tips for Python .Net 2.0 In-Reply-To: <001101c6364a$6dbe5db0$0512a8c0@enterprise> References: <001101c6364a$6dbe5db0$0512a8c0@enterprise> Message-ID: <2db0cefa0602261441r3a7046dfh7da11a17185e84d6@mail.gmail.com> Good to see some feedback, comments inlined. Should see a new post of my 2.0 release with some fixes today including just a binary release. On 2/20/06, T Barket wrote: > Hello, > > 1) the PythonNet2.0-0.1.zip file didn't include a file called "clrmodule.il" > but I substituted with the original one from Brian's > pythonnet-1.0-rc2-py2.4-clr1.1-src.zip Woops, not sure how that got left out :) > > 2) Then everything compiled and linked just fine. TestPython.exe worked > fine and the Python.exe launched and I could do "import CLR" and "import > CLR.System". However, I could not "import CLR.System.Windows" or "import > CLR.System.Drawing": [SNIP[ > > 3) This problem is bc in .Net 2.0, > System.Reflection.Assembly.LoadWithPartialName is now supposed to be > obsolete (http://msdn2.microsoft.com/en-us/library/0a7zy9z5.aspx). And I > I've added some additional code, but I'm not happy going back to a depricated API as we need a correct solution. Thew loader code will try and locate the assembly in the installed .NET Framework directory if Load() fails. This does not solve loading assemblies in the GAC, but there is no doubt a way to toss that in. I'll investigate in the next week or so and see if I can't locate a current rev. > 4) With the changes so far, I was able to use the PythonNet2.0 generated > Python.exe with no problems. However, i wasnt able to use clr.dll and > python.runtime.dll with a standard cpython interpretter, such as > c:/python24/python.exe, winpython or ipython which i was albe to do with > PythonNet 1.0. Correct me if I'm wrong, but I don't think this was an origional intended feature. > > 5) To fix (4), i made two changes to Michael's project (which i suspect go > back to Brian's original code). I commented out the code that performs the > import hook replacement in pythonengine.InitEx(): I'm sure we can get the importing to work right, but not a project for today. I recommend just using the .NET console version. Shouldn't be any issues there. > > 6) Brian, as a personal note, i would strongly encourage you to keep going > with Python for .Net regardless of IronPython. I personally have alot of If anything else we can move the code over to source forge to continue development. mike From meddington at gmail.com Mon Feb 27 00:02:57 2006 From: meddington at gmail.com (Michael Eddington) Date: Sun, 26 Feb 2006 15:02:57 -0800 Subject: [Python.NET] Python.NET for .NET v2.0 updated Message-ID: <2db0cefa0602261502n5cbae9c8sc8d49e2a8ac5a7fa@mail.gmail.com> The unofficial version of Python.NET for .NET Framework v2.0 has been updated and available for download in both pre-compiled or source form. Please not the source form will require the installation of the Visual Studio 2005 SDK (~125MB download), and Visual IL. This release incorporates some bug fixed and work arounds that have been reported since the origional 0.1 release. http://sourceforge.net/project/showfiles.php?group_id=149840&package_id=181323 mike From ranish.pullanat at wipro.com Fri Feb 10 10:16:13 2006 From: ranish.pullanat at wipro.com (ranish.pullanat at wipro.com) Date: Fri, 10 Feb 2006 09:16:13 -0000 Subject: [Python.NET] Hi Brain Message-ID: <6AD9F6A5F6E096408F0B703773355A07A6007D@CHN-SNR-MBX01.wipro.com> Hi Brain, I am Ranish form India, doing as a programmer. Can I use a .NET generated dll (Regular dll ) directly form Python (Not python .NET) ? I am using calldll module, and getting a message as DLL loading failed (for my dll) But when I tried to load kernal32.dll, its scusses. Why ? [ I called my dll form C++ its working finely ] Do I need to register my dll in system ? Please help me in explain the reason, for this. Thanks for your time. Thanks & Regards P.Ranish The information contained in this electronic message and any attachments to this message are intended for the exclusive use of the addressee(s) and may contain proprietary, confidential or privileged information. If you are not the intended recipient, you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately and destroy all copies of this message and any attachments. WARNING: Computer viruses can be transmitted via email. The recipient should check this email and any attachments for the presence of viruses. The company accepts no liability for any damage caused by any virus transmitted by this email. www.wipro.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/pythondotnet/attachments/20060210/c39c1c06/attachment.htm