From glenjamin at gmail.com Sat Jul 2 12:23:27 2005 From: glenjamin at gmail.com (Glen Mailer) Date: Sat, 2 Jul 2005 11:23:27 +0100 Subject: [Python.NET] Creating Menu Items Message-ID: <9fd01fde050702032334a86c33@mail.gmail.com> According to the CLR spec, MenuItem objects have constructors in the form: MenuItem(Text, Handler) MenuItem(Text, Handler, Shortcut) Yet using either of these in PythonNET i get a blank menu item, any ideas why this isnt working? sample: def InitializeComponent(self): FileOpen = WinForms.MenuItem("&Open",self.OnFileOpen,WinForms.Shortcut.CtrlO) FileSave = WinForms.MenuItem("&Save",self.OnFileSave,WinForms.Shortcut.CtrlS) FileExit = WinForms.MenuItem("E&xit",self.OnFileExit,WinForms.Shortcut.AltF4) FileMenu = WinForms.MenuItem("&File", (FileOpen,FileSave,FileExit) ) self.Menu = WinForms.MainMenu( (FileMenu,) ) This produces a menu bar with a File menu having 3 entries, but all three are blank. From glenjamin at gmail.com Sun Jul 3 00:56:59 2005 From: glenjamin at gmail.com (Glen Mailer) Date: Sat, 2 Jul 2005 23:56:59 +0100 Subject: [Python.NET] Overriding OnPaint Message-ID: <9fd01fde050702155637887f46@mail.gmail.com> Is there a way of me to override the OnPaint method of a form or control? The OnPaint Method of my Form subclass gets completely ignored. From stan at phidani.be Mon Jul 4 10:32:47 2005 From: stan at phidani.be (Stan Pinte) Date: Mon, 04 Jul 2005 08:32:47 +0000 Subject: [Python.NET] crash when no .Net 1.1 installed Message-ID: <42C8F42F.5060606@phidani.be> hello, the pythondotnet runtime plainly crashes when no .Net 1.1 framework is installed... --> could it issue a nice error message saying "please install .Net framework 1.1" ? Thanks, Stan. From mathew at yeates.tv Tue Jul 5 06:27:25 2005 From: mathew at yeates.tv (Mathew Yeates) Date: Mon, 04 Jul 2005 21:27:25 -0700 Subject: [Python.NET] catching exceptions thrown from .Net Message-ID: <42CA0C2D.7090302@yeates.tv> Is this supposed to work in RC5 on Win32 using the supplied python binary? I have a .Net dll which throws a user defined exception but its being ignored by my python code. Is this to be expected? Mathew From brian at zope.com Tue Jul 5 16:25:43 2005 From: brian at zope.com (Brian Lloyd) Date: Tue, 5 Jul 2005 10:25:43 -0400 Subject: [Python.NET] catching exceptions thrown from .Net In-Reply-To: <42CA0C2D.7090302@yeates.tv> Message-ID: > Is this supposed to work in RC5 on Win32 using the supplied python > binary? I have a .Net dll which throws a user defined exception but its > being ignored by my python code. > > Is this to be expected? > > Mathew Does the user defined exception inherit (eventually) from System.Exception? If so, it should work... Brian Lloyd brian at zope.com V.P. Engineering 540.361.1716 Zope Corporation http://www.zope.com From brian at zope.com Tue Jul 5 16:31:37 2005 From: brian at zope.com (Brian Lloyd) Date: Tue, 5 Jul 2005 10:31:37 -0400 Subject: [Python.NET] Overriding OnPaint In-Reply-To: <9fd01fde050702155637887f46@mail.gmail.com> Message-ID: > Is there a way of me to override the OnPaint method of a form or control? > > The OnPaint Method of my Form subclass gets completely ignored. Hi Glen - currently .NET code cannot see any of the members that you create in Python (meaning you can't really override methods like OnPaint and have the right thing happen). You should be able to register a Python callback for the Paint event though. Brian Lloyd brian at zope.com V.P. Engineering 540.361.1716 Zope Corporation http://www.zope.com From mathew at yeates.tv Tue Jul 5 16:41:26 2005 From: mathew at yeates.tv (Mathew Yeates) Date: Tue, 05 Jul 2005 07:41:26 -0700 Subject: [Python.NET] catching exceptions thrown from .Net In-Reply-To: References: Message-ID: <42CA9C16.9060203@yeates.tv> yes, it inherits from System.Exception. In fact, I tried throwing a NullRefernceException from my dll. Still nothing. Mathew Brian Lloyd wrote: >>Is this supposed to work in RC5 on Win32 using the supplied python >>binary? I have a .Net dll which throws a user defined exception but its >>being ignored by my python code. >> >>Is this to be expected? >> >>Mathew >> >> > >Does the user defined exception inherit (eventually) from >System.Exception? If so, it should work... > > >Brian Lloyd brian at zope.com >V.P. Engineering 540.361.1716 >Zope Corporation http://www.zope.com > > > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/pythondotnet/attachments/20050705/daade2d4/attachment.htm From brian at zope.com Tue Jul 5 16:51:01 2005 From: brian at zope.com (Brian Lloyd) Date: Tue, 5 Jul 2005 10:51:01 -0400 Subject: [Python.NET] Creating Menu Items In-Reply-To: <9fd01fde050702032334a86c33@mail.gmail.com> Message-ID: > According to the CLR spec, MenuItem objects have constructors in the form: > > MenuItem(Text, Handler) > MenuItem(Text, Handler, Shortcut) > > Yet using either of these in PythonNET i get a blank menu item, any > ideas why this isnt working? > > sample: > def InitializeComponent(self): > FileOpen = > WinForms.MenuItem("&Open",self.OnFileOpen,WinForms.Shortcut.CtrlO) > FileSave = > WinForms.MenuItem("&Save",self.OnFileSave,WinForms.Shortcut.CtrlS) > FileExit = > WinForms.MenuItem("E&xit",self.OnFileExit,WinForms.Shortcut.AltF4) > > FileMenu = WinForms.MenuItem("&File", > (FileOpen,FileSave,FileExit) ) > > self.Menu = WinForms.MainMenu( (FileMenu,) ) > > This produces a menu bar with a File menu having 3 entries, but all > three are blank. Here is what appears to be happening: the handler argument wants to be an instance SystemEventHandler. Python for .NET does not automagically create the delegate for you in this case, so it fails to match the (string, EventHander, Shortcut) overload and falls back to the no-args constructor. The fix is to pass System.EventArgs(self.OnFileOpen), wrapping the callbacks in the appropriate delegates. It probably could be argued that pythonnet should convert a callable automatically when a delegate type is required -- I'd want to think about any possible side-effects of that and work out what level of error checking (sig-checking on the callable) would be appropriate first though... HTH, Brian Lloyd brian at zope.com V.P. Engineering 540.361.1716 Zope Corporation http://www.zope.com From brian at zope.com Tue Jul 5 17:16:59 2005 From: brian at zope.com (Brian Lloyd) Date: Tue, 5 Jul 2005 11:16:59 -0400 Subject: [Python.NET] catching exceptions thrown from .Net In-Reply-To: <42CA9C16.9060203@yeates.tv> Message-ID: Hmm, you mention RC5 -- do you mean RC2? An example code snippet would help here, as the unit tests actually use NullReferenceException and they are running fine for me... Brian Lloyd brian at zope.com V.P. Engineering 540.361.1716 Zope Corporation http://www.zope.com -----Original Message----- From: Mathew Yeates [mailto:mathew at yeates.tv] Sent: Tuesday, July 05, 2005 9:41 AM To: Brian Lloyd Cc: pythondotnet at python.org Subject: Re: [Python.NET] catching exceptions thrown from .Net yes, it inherits from System.Exception. In fact, I tried throwing a NullRefernceException from my dll. Still nothing. Mathew Brian Lloyd wrote: Is this supposed to work in RC5 on Win32 using the supplied python binary? I have a .Net dll which throws a user defined exception but its being ignored by my python code. Is this to be expected? Mathew Does the user defined exception inherit (eventually) from System.Exception? If so, it should work... Brian Lloyd brian at zope.com V.P. Engineering 540.361.1716 Zope Corporation http://www.zope.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/pythondotnet/attachments/20050705/f280462a/attachment.htm From mathew at yeates.tv Tue Jul 5 17:32:31 2005 From: mathew at yeates.tv (Mathew Yeates) Date: Tue, 05 Jul 2005 08:32:31 -0700 Subject: [Python.NET] catching exceptions thrown from .Net In-Reply-To: References: Message-ID: <42CAA80F.50702@yeates.tv> yes, RC2. My bad. Are we talking about the same thing? I noticed in the docs that you have an example of throwing exceptions from within the python code. But no examples of handling exceptions thrown within the .Net code. Anyway ... theres not much to this code .Net code -------------------------------------------- public class MineralDBException:Exception { public MineralDBException(String msg):base(msg){ } } public MineralDBase(String fname) { try { fs = new FileStream(fname, FileMode.Open, FileAccess.Read); } catch(Exception e) { throw new MineralDBException(e.Message); } ---------------------------------- python code, no exception is seen when calling MineralDBase this way but an exception IS seen when calling from another .Net assembly ----------------------------------- db=MineralDBase("fooey") Mathew Brian Lloyd wrote: >Hmm, you mention RC5 -- do you mean RC2? An example code snippet would >help here, as the unit tests actually use NullReferenceException and they >are >running fine for me... > > > >Brian Lloyd brian at zope.com >V.P. Engineering 540.361.1716 >Zope Corporation http://www.zope.com > > > -----Original Message----- > From: Mathew Yeates [mailto:mathew at yeates.tv] > Sent: Tuesday, July 05, 2005 9:41 AM > To: Brian Lloyd > Cc: pythondotnet at python.org > Subject: Re: [Python.NET] catching exceptions thrown from .Net > > > yes, it inherits from System.Exception. In fact, I tried throwing a >NullRefernceException from my dll. Still nothing. > > Mathew > > Brian Lloyd wrote: >Is this supposed to work in RC5 on Win32 using the supplied python >binary? I have a .Net dll which throws a user defined exception but its >being ignored by my python code. > >Is this to be expected? > >Mathew > >Does the user defined exception inherit (eventually) from >System.Exception? If so, it should work... > > >Brian Lloyd brian at zope.com >V.P. Engineering 540.361.1716 >Zope Corporation http://www.zope.com > > > > > > > From philippe at philippecmartin.com Fri Jul 8 11:54:35 2005 From: philippe at philippecmartin.com (Philippe C. Martin) Date: Fri, 8 Jul 2005 09:54:35 +0000 Subject: [Python.NET] Newbie question Message-ID: <200507080954.35735.philippe@philippecmartin.com> Hi, I am new to this list and .NET. From the quick reading I've done, I understand pythondotnet can help me "package" my Python libraries (they use a few C extensions) so they look like .NET components to the W. world. Am I correct ? Regards, Philippe -- ************************************* Philippe C. Martin SnakeCard, LLC www.snakecard.com +1 405 694 8098 ************************************* From brian at zope.com Fri Jul 8 18:18:41 2005 From: brian at zope.com (Brian Lloyd) Date: Fri, 8 Jul 2005 12:18:41 -0400 Subject: [Python.NET] Newbie question In-Reply-To: <200507080954.35735.philippe@philippecmartin.com> Message-ID: > I am new to this list and .NET. > > >From the quick reading I've done, I understand pythondotnet can help me > "package" my Python libraries (they use a few C extensions) so they look > like .NET components to the W. world. > > Am I correct ? Hi Philippe - That is not correct - actually, pythonnet is the opposite of that ;) It makes any .NET code accessible in a natural way as if they were Python objects. It does not generate IL, so it can't be used generally to expose existing Python code to the .NET world. Brian Lloyd brian at zope.com V.P. Engineering 540.361.1716 Zope Corporation http://www.zope.com From philippe at philippecmartin.com Fri Jul 8 13:34:11 2005 From: philippe at philippecmartin.com (Philippe C. Martin) Date: Fri, 8 Jul 2005 11:34:11 +0000 Subject: [Python.NET] Newbie question In-Reply-To: References: Message-ID: <200507081134.11967.philippe@philippecmartin.com> Hi Brian, Sorry to hear that - I misunderstood the readme that spoke about "embeding python". Is there any solution out there ? Regards, Philippe On Friday 08 July 2005 04:18 pm, Brian Lloyd wrote: > > I am new to this list and .NET. > > > > >From the quick reading I've done, I understand pythondotnet can help me > > > > "package" my Python libraries (they use a few C extensions) so they look > > like .NET components to the W. world. > > > > Am I correct ? > > Hi Philippe - > > That is not correct - actually, pythonnet is the opposite of > that ;) It makes any .NET code accessible in a natural way as > if they were Python objects. It does not generate IL, so it > can't be used generally to expose existing Python code to the > .NET world. > > > Brian Lloyd brian at zope.com > V.P. Engineering 540.361.1716 > Zope Corporation http://www.zope.com -- ************************************* Philippe C. Martin SnakeCard, LLC www.snakecard.com +1 405 694 8098 ************************************* From brian at zope.com Fri Jul 8 19:39:26 2005 From: brian at zope.com (Brian Lloyd) Date: Fri, 8 Jul 2005 13:39:26 -0400 Subject: [Python.NET] Newbie question In-Reply-To: <200507081134.11967.philippe@philippecmartin.com> Message-ID: You might look at IronPython, though if you have C extensions involved, that probably won't be an option (w/o reimplementing them). If the interface that the .NET world needs to your Python code is reasonably small, you could create a .NET assembly that embeds Python and defines one or more wrapper classes that would delegate to your Python code. Brian Lloyd brian at zope.com V.P. Engineering 540.361.1716 Zope Corporation http://www.zope.com > -----Original Message----- > From: Philippe C. Martin [mailto:philippe at philippecmartin.com] > Sent: Friday, July 08, 2005 6:34 AM > To: Brian Lloyd > Cc: pythondotnet at python.org > Subject: Re: [Python.NET] Newbie question > > > Hi Brian, > > Sorry to hear that - I misunderstood the readme that spoke about > "embeding > python". > > Is there any solution out there ? > > Regards, > > Philippe > > > > On Friday 08 July 2005 04:18 pm, Brian Lloyd wrote: > > > I am new to this list and .NET. > > > > > > >From the quick reading I've done, I understand pythondotnet > can help me > > > > > > "package" my Python libraries (they use a few C extensions) > so they look > > > like .NET components to the W. world. > > > > > > Am I correct ? > > > > Hi Philippe - > > > > That is not correct - actually, pythonnet is the opposite of > > that ;) It makes any .NET code accessible in a natural way as > > if they were Python objects. It does not generate IL, so it > > can't be used generally to expose existing Python code to the > > .NET world. > > > > > > Brian Lloyd brian at zope.com > > V.P. Engineering 540.361.1716 > > Zope Corporation http://www.zope.com > > -- > ************************************* > Philippe C. Martin > SnakeCard, LLC > www.snakecard.com > +1 405 694 8098 > ************************************* > From amohr at cs.wisc.edu Sun Jul 10 07:27:42 2005 From: amohr at cs.wisc.edu (Alex Mohr) Date: Sun, 10 Jul 2005 00:27:42 -0500 Subject: [Python.NET] Windows Forms design... Message-ID: <20050710052742.GA10100@cs.wisc.edu> Hi Folks, I'm new to Python for .NET and I'm wondering what methods folks are using for creating Windows Forms apps with Python. Is there a nice way to use the forms designer in Visual Studio .NET with Python? Or are people just creating forms directly in code? I tried googling around for this but couldn't find much. Thanks, Alex From thane at magna-capital.com Sun Jul 10 08:50:27 2005 From: thane at magna-capital.com (Thane) Date: Sat, 9 Jul 2005 23:50:27 -0700 Subject: [Python.NET] Windows Forms design... In-Reply-To: <20050710052742.GA10100@cs.wisc.edu> Message-ID: <20050710065037.1B6D01E4002@bag.python.org> Use VS to create a C# Windows Form, then either hand translate to Python.NET or use something like http://www.digitalfanatics.org/e8johan/projects/cs2py/ I prefer to translate "manually", which means that a smart editor does 90% of the work and I tweak the rest. HTH > -----Original Message----- > From: pythondotnet-bounces at python.org [mailto:pythondotnet- > bounces at python.org] On Behalf Of Alex Mohr > Sent: Saturday, July 09, 2005 10:28 PM > To: pythondotnet at python.org > Subject: [Python.NET] Windows Forms design... > > Hi Folks, > > I'm new to Python for .NET and I'm wondering what methods folks are > using for creating Windows Forms apps with Python. Is there a nice way > to use the forms designer in Visual Studio .NET with Python? Or are > people just creating forms directly in code? I tried googling around > for this but couldn't find much. > > Thanks, > > Alex > _________________________________________________ > Python.NET mailing list - PythonDotNet at python.org > http://mail.python.org/mailman/listinfo/pythondotnet From guy at r-e-d.co.nz Sat Jul 16 06:56:30 2005 From: guy at r-e-d.co.nz (Guy Robinson) Date: Sat, 16 Jul 2005 16:56:30 +1200 Subject: [Python.NET] 2 ? about embedding python Message-ID: <42D8937E.1030804@r-e-d.co.nz> Hello, Both questions relate to python embedded in a C# application. 1.. If my python script returns a False/True then to pass the bool to the c# script then this: bool result = (bool)runFrm.AsManagedObject(typeof(Boolean)); should work shouldn't it? 2.. If the python script needed to return 3 values(2 strings + 1 boolean), then how do I pass these to the C# application. I can't return an array because the values aren't all the same type. And I can see no equivalent of a python tuple. TIA, Guy From thomas_barket at yahoo.com Sun Jul 17 08:07:26 2005 From: thomas_barket at yahoo.com (T Barket) Date: Sun, 17 Jul 2005 02:07:26 -0400 Subject: [Python.NET] Is it possible to access the C# keywords? Message-ID: <0IJR00003D0FIAF4@mta5.srv.hcvlny.cv.net> Hello, First off, python for .net is a great tool. Tks vm, Brian. My question is, I cant figure out how to access the C# keywords. Is that possible? For instance, on the python side, I want to do something like this C# snippet: Type type = typeof(One_Of_My_CSharp_Classes); MemberInfo[] member_info = type.GetFields(); But I cant figure out how to access the C# keyword "typeof". Neither CLR.typeof nor CLR.System.typeof works. Is there a way to do this? Tks vm, Tom From brian at zope.com Sun Jul 17 18:31:43 2005 From: brian at zope.com (Brian Lloyd) Date: Sun, 17 Jul 2005 12:31:43 -0400 Subject: [Python.NET] Is it possible to access the C# keywords? In-Reply-To: <0IJR00003D0FIAF4@mta5.srv.hcvlny.cv.net> Message-ID: <20050717163145.6C96F3B8016@smtp.zope.com> > First off, python for .net is a great tool. Tks vm, Brian. > My question is, > I cant figure out how to access the C# keywords. Is that > possible? For > instance, on the python side, I want to do something like > this C# snippet: > > Type type = typeof(One_Of_My_CSharp_Classes); > MemberInfo[] member_info = type.GetFields(); > > But I cant figure out how to access the C# keyword "typeof". Neither > CLR.typeof nor CLR.System.typeof works. Is there a way to do this? You can't use C# keywords per se (they are really just tokens with special meaning to the compiler and dont have a runtime representation), but you can do what you want with something like: import CLR from CLR.System import Type mytype = Type.GetType("MyNamespace.MyType") fields = mytype.GetFields() ... hope this helps, Brian Lloyd brian at zope.com V.P. Engineering 540.361.1716 Zope Corporation http://www.zope.com From rencelj at cad.it Wed Jul 20 12:20:43 2005 From: rencelj at cad.it (Rencelj Marco) Date: Wed, 20 Jul 2005 12:20:43 +0200 Subject: [Python.NET] Strong name in python.runtime.dll Message-ID: <621CDB480A325A49BF608434668CB57804D89878@tex.cadit.it> I'm trying to integrate pythonnet into a solution that requires strong named dll. Does anybody know how to add strong names rebuilding the python.runtime.dll? Thank's in advance ... Marco Rencelj -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/pythondotnet/attachments/20050720/42aa40c9/attachment.htm From shane.holloway at ieee.org Mon Jul 25 18:17:39 2005 From: shane.holloway at ieee.org (Shane Holloway (IEEE)) Date: Mon, 25 Jul 2005 10:17:39 -0600 Subject: [Python.NET] Subset implementation for CompactFramework Message-ID: <42E510A3.6070804@ieee.org> I was wondering if I could get some insight into how much of the Python for .NET framework could be ported to the Compact Framework? Python is still my language of choice, and it would be wonderful to use it to develop on the PocketPC. This framework seems to be the ideal interop layer to help me do this effectively. Currently we have two separable goals. First is to be able to use python libraries from VB or C# on the PocketPC. Second is to be able to use WindowsForms exclusively from python. In my investigation, I worked through compiling pythonnet for the compact framework, and found a heavy dependence on system.reflection.emit, which is not available on the Compact Framework. (Which makes me grumpy, but that's another matter ;) This brings me to the question of how much of pythonnet is dependent on system.reflection.emit? Can we achieve either of the above goals? If it is possible, I'd love to help move this forward for the crippled Compact Framework. In this case, I'd like to talk with someone to get an overview of the architecture. Thanks! -Shane Holloway From brian at zope.com Mon Jul 25 19:32:56 2005 From: brian at zope.com (Brian Lloyd) Date: Mon, 25 Jul 2005 13:32:56 -0400 Subject: [Python.NET] Subset implementation for CompactFramework In-Reply-To: <42E510A3.6070804@ieee.org> Message-ID: Hi Shane - Unfortunately I'm not really up to speed on exactly what is and isn't supported on the compact framework. Its disappointing to hear that emit isn't supported -- that's likely to be a problem for getting any dynamic language to run on CF :( PythonNet currently uses reflection.emit for two things: - generating IJW thunks to a few functions in the C Python runtime (essentially calling function pointers that are only known at runtime and can't be dealt with using p/invoke or other approaches) - creating types on the fly to implement delegates that call back into python code It would probably be possible to avoid (1) by statically generating and linking the thunk code that otherwise would be done at runtime with a bit of manual labor. (2) is more problematic -- we currently generate a delegate type for each unique actual delegate type that is used from Python code (this could be optimized in the future to only generate a distinct type per signature). So when, for example, you say from Python: def myhandler(sender, args): print 'myhandler called!' someobject.SomeEvent += myhandler what happens is: - the pythonnet runtime generates a type that acts as a dispatcher that matches the Invoke signature of SomeEvent (or re-uses a previously generated type if a dispatcher has already been created for that delegate type) - an instance of the generated type is instantiated passing the callable python object that it should dispatch to and that instance is what managed code sees Its been awhile since I looked at that part of the code, but I'm not sure if there is a way around code gen in some form in this case. I tried to do the 'simplest thing that could possibly work' there, but I'd be happy to be wrong ;) Brian Lloyd brian at zope.com V.P. Engineering 540.361.1716 Zope Corporation http://www.zope.com > -----Original Message----- > From: pythondotnet-bounces at python.org > [mailto:pythondotnet-bounces at python.org]On Behalf Of Shane Holloway > (IEEE) > Sent: Monday, July 25, 2005 11:18 AM > To: pythondotnet at python.org > Subject: [Python.NET] Subset implementation for CompactFramework > > > I was wondering if I could get some insight into how much of the > Python for .NET framework could be ported to the Compact Framework? > Python is still my language of choice, and it would be wonderful to > use it to develop on the PocketPC. This framework seems to be the > ideal interop layer to help me do this effectively. Currently we > have two separable goals. First is to be able to use python > libraries from VB or C# on the PocketPC. Second is to be able to > use WindowsForms exclusively from python. > > In my investigation, I worked through compiling pythonnet for the > compact framework, and found a heavy dependence on > system.reflection.emit, which is not available on the Compact > Framework. (Which makes me grumpy, but that's another matter ;) > This brings me to the question of how much of pythonnet is dependent > on system.reflection.emit? Can we achieve either of the above goals? > > If it is possible, I'd love to help move this forward for the > crippled Compact Framework. In this case, I'd like to talk with > someone to get an overview of the architecture. > > Thanks! > -Shane Holloway > _________________________________________________ > Python.NET mailing list - PythonDotNet at python.org > http://mail.python.org/mailman/listinfo/pythondotnet > From brian at zope.com Tue Jul 26 05:40:27 2005 From: brian at zope.com (Brian Lloyd) Date: Mon, 25 Jul 2005 23:40:27 -0400 Subject: [Python.NET] IP & Python for .NET 2.0 roadmap Message-ID: <20050726034030.584CE3B805C@smtp.zope.com> Hi all - sorry to cross-post to the IP list, but I know there are some folks who follow both projects and might want a head's up -- please post any replies to the pythondotnet list unless it really is pertinent to IP per se. I'm about to wrap up development on Python for .NET and make a 1.0 release, and wanted to post a roadmap for 2.0. The next (and hopefully last) RC release of 1.0 will include a few changes to make out/ref param behavior compatible with IronPython, followed by a final 1.0 release. The Roadmap: Python for .NET 1.x will be targeted to the .NET 1.x runtime. It will not be terribly compatible with any code developed for IronPython. Python for .NET 2.x will be targeted to the .NET 2.x runtime, and Python code for it will be as compatible as possible with the IronPython runtime. Meaning, I hope that Python code that runs on pythonnet 2.x will run without changes on IronPython. Generally, I think all of us are excited to see the sustained effort being applied to IronPython. Having a code-compatible 'CLR consumer' implementation based on CPython should be helpful not only in providing an upgrade path for the future for users of pythonnet but also provide some interesting possibilities for comparative conformance and performance testing, test sharing, etc. Proposed changes for 2.0 (mostly related to IP compatibility): - Support for 'son of sys.LoadAssemblyByName' As noted on the IP mailing list, Jim doesn't like the current sys.LoadAssemblyByName solution (http://lists.ironpython.com/pipermail/users-ironpython.com/2005-July/000805 .html) I mostly tend to agree - at any rate, I'd like for pythonnet to support whatever the successor is. (Some suggestions maybe in another thread) - API compatibility with the IP PythonEngine I'd like the pythonnet PythonEngine to support the API of the IP engine, to make it at least possible to swap back and forth with a minimum of effort. The current pythonnet PythonEngine API would be deprecated (but available) until 3.0. A probable breaking change here is that pythonnet requires managed code to be aware of the GIL -- IP seems to have gotten rid of that requirement (hooray!). The gist is that it would be nice if embedders writing in C#, VB or other less-dynamic managed code could swap back and forth with no more than some namespace futzing if possible. - Support syntax for resolution of generic types, methods and overload resolution IP has (or soon will have) introduced some spelling to support instantiation of generic types and fine resolution of overloaded methods. It should be no problem to support the spellings that have so far been proposed: # instantiate a generic type from System.Collections.Generic import List x = List[str]() # realized generic type as first class object c = List[str] # open generic types as objects -- not sure yet how this would # or wouldn't relate to IP plans o = List # pinpoint overloads -- note that we would allow the use of # python types to indicate CLR types in these limited cases # a la IP (str == System.String, int == System.Int32, etc.) Console.WriteLine[str]("Hi") Console.WriteLine[int](6) - Leverage LCG in the runtime There are a few places that could benefit from LCG -- this is a 'nice to have', since we'll already benefit from some of the CLR 2.x improvements to caching of reflected members, etc. - Import spelling This is probably the most controversial and potentially breaking change for users of Python for .NET 1.x. PythonNet currently uses a top level 'CLR' module to contain all modules (namespaces) imported from the CLR. For 2.x, I would propose killing this in favor of the the direct spelling used by IP (import System.Console vs. import CLR.System.Console). This will have some effect on performance, but I think it will be \ manageable. If at all possible, I'd like to arrange for the CLR.xxx spelling to remain supported (but deprecated) until 3.0, unless it would really kill perf. Note that all of these changes are focused on the 'CLR consumer' aspect of Python. I don't know of any public designs for IP as a CLR producer (and having CPython act as a producer introduces a whole new world of problems), so at this point I'm only looking at compatibility from a consumer perspective. generic-'ly, Brian Lloyd brian at zope.com V.P. Engineering 540.361.1716 Zope Corporation http://www.zope.com From guy at r-e-d.co.nz Thu Jul 28 10:54:40 2005 From: guy at r-e-d.co.nz (Guy Robinson) Date: Thu, 28 Jul 2005 20:54:40 +1200 Subject: [Python.NET] sys.stderr and embedded python Message-ID: <42E89D50.7050605@r-e-d.co.nz> Hi, I have python for .NET embedded in my application and I'm trying to catch any sys.stderr output. If I run the script with the sys.stderr handler from the python commandline it works. If I run the script from the parent application it doesn't run my stderr handler. It seems to bypass it. Both my sys.stdout handler and sys.exitfunc work both from the commandline and the application. It's only sys.stderr that doesn't. What am I missing? Guy From mark.mcmahon at eur.autodesk.com Fri Jul 29 18:45:30 2005 From: mark.mcmahon at eur.autodesk.com (Mark McMahon) Date: Fri, 29 Jul 2005 12:45:30 -0400 Subject: [Python.NET] Trying to constructu a System.IntPtr object Message-ID: Hi, I am stumped by this one - googled, even read the Readme!! I want to call System.Forms.Control.FromHandle() to get a control from a handle. But I am getting that handle as Python int instance but FromHandle requires a System.IntPtr. I would have guess that there would be automatic conversion from Python int to .Net IntPtr. >>> CLR.System.IntPtr(23) Traceback (most recent call last): File "", line 1, in ? TypeError: 'int' value cannot be converted to System.IntPtr So I try converting it to Int32 first... (same for Int64) >>> CLR.System.IntPtr(CLR.System.Int32(23)) Traceback (most recent call last): File "", line 1, in ? TypeError: value cannot be converted to System.IntPtr So now I am stuck - any help appreciated, Thanks Mark From brian at zope.com Fri Jul 29 21:38:05 2005 From: brian at zope.com (Brian Lloyd) Date: Fri, 29 Jul 2005 15:38:05 -0400 Subject: [Python.NET] Trying to constructu a System.IntPtr object In-Reply-To: Message-ID: > I am stumped by this one - googled, even read the Readme!! > > I want to call System.Forms.Control.FromHandle() to get a control from a > handle. But I am getting that handle as Python int instance but > FromHandle requires a System.IntPtr. > > I would have guess that there would be automatic conversion from Python > int to .Net IntPtr. > > >>> CLR.System.IntPtr(23) > Traceback (most recent call last): > File "", line 1, in ? > TypeError: 'int' value cannot be converted to System.IntPtr > > So I try converting it to Int32 first... (same for Int64) > ... ooo - you've found a hole in the type conversion logic, methinks. In the interim, you can use the following sneaky hack: from CLR.System import IntPtr, Int32 i = Int32(32) p = IntPtr.op_Explicit(i) # now p is an intptr... Brian Lloyd brian at zope.com V.P. Engineering 540.361.1716 Zope Corporation http://www.zope.com From mark.mcmahon at eur.autodesk.com Fri Jul 29 22:02:14 2005 From: mark.mcmahon at eur.autodesk.com (Mark McMahon) Date: Fri, 29 Jul 2005 16:02:14 -0400 Subject: [Python.NET] Trying to constructu a System.IntPtr object Message-ID: Hi Brian, Well it seems to work :-) (or at least doesn't give me any errors. Though it seems like Control.FromHandle needs to be in the same process as the control :-( Thanks anyway Mark -----Original Message----- From: Brian Lloyd [mailto:brian at zope.com] Sent: Friday, July 29, 2005 3:38 PM To: Mark McMahon; pythondotnet at python.org Subject: RE: [Python.NET] Trying to constructu a System.IntPtr object > I am stumped by this one - googled, even read the Readme!! > > I want to call System.Forms.Control.FromHandle() to get a control from a > handle. But I am getting that handle as Python int instance but > FromHandle requires a System.IntPtr. > > I would have guess that there would be automatic conversion from Python > int to .Net IntPtr. > > >>> CLR.System.IntPtr(23) > Traceback (most recent call last): > File "", line 1, in ? > TypeError: 'int' value cannot be converted to System.IntPtr > > So I try converting it to Int32 first... (same for Int64) > ... ooo - you've found a hole in the type conversion logic, methinks. In the interim, you can use the following sneaky hack: from CLR.System import IntPtr, Int32 i = Int32(32) p = IntPtr.op_Explicit(i) # now p is an intptr... Brian Lloyd brian at zope.com V.P. Engineering 540.361.1716 Zope Corporation http://www.zope.com