From dinov at exchange.microsoft.com Tue Aug 1 18:51:02 2006 From: dinov at exchange.microsoft.com (Dino Viehland) Date: Tue, 1 Aug 2006 09:51:02 -0700 Subject: [IronPython] [Simpy-users] RE: SimPy on IronPython timing test In-Reply-To: <200607281113.k6SBDf8U046294@smtp-vbr10.xs4all.nl> References: <200607281113.k6SBDf8U046294@smtp-vbr10.xs4all.nl> Message-ID: <7AD436E4270DD54A94238001769C22272F9B5B69E4@DF-GRTDANE-MSG.exchange.corp.microsoft.com> Klaus, You're correct in that we didn't do a whole lot of performance tuning from the betas to RC. Jim did a little bit of work based upon some small repros that were easy to pick apart. For the most part though everyone else was focused on fixing various incompatabilities. Now that we're at 1.0 RC we'll only be fixing major bugs that are blocking issues. Hopefully in the future we'll have an opportunity to drill into this. Also if you see any hot spots that can be isolated into simple repros then it'd be much easier for us to look at those issues rather than all of SimPy. Thanks for see keeping the numbers coming - it's good to see we've improved a small amount, hopefully we can improve a lot more in the future. -----Original Message----- From: Klaus Muller [mailto:kgmuller at xs4all.nl] Sent: Friday, July 28, 2006 4:14 AM To: Dino Viehland; 'Discussion of IronPython'; simpy-users at lists.sourceforge.net; 'Simpy-Developer List' Subject: FW: [Simpy-users] RE: [IronPython] SimPy on IronPython timing test Dino, I was happy to see the announcement of the IronPython 1.0 Release Candidate. I downloaded and ran the same test as indicated in my message of February 14, i.e. from SimPy.Simulation import * import time class Dum(Process): def run(self): yield hold,self,3 initialize() nrProcs=int(raw_input("Nr of processes?")) processes=[Dum("Dum%s"%x) for x in range(1,nrProcs)] for i in range(nrProcs): p=Dum("%s"%i) activate(p,p.run(),at=i) tStart=(time.clock(),time.time()) simulate(until=2*nrProcs) print "Ran in %s seconds for %s processes"%((time.clock()-tStart[0],time.time()-tStart[1]),nrProcs) raw_input("Hit any key . . .") Here are the results: Nr processes=10000 ------------------ IronPython RC: 1.82 seconds (Beta 2: 2.06 seconds) Cpython 2.3: 0.47 seconds Nr processes=50000 ------------------ IronPython rc: 14.19 seconds (Beta 2: 15.53 seconds) Cpython 2.3: 3.67 seconds So, the RC's runtime performance is slightly better than that of Beta 2, but there is still a significant speed advantage for CPython. I have the impression that not much has been done on IronPython performance tuning. Best regards, Klaus M?ller -----Original Message----- From: simpy-users-admin at lists.sourceforge.net [mailto:simpy-users-admin at lists.sourceforge.net] On Behalf Of Klaus Muller Sent: Wednesday, February 15, 2006 3:30 PM To: 'Dino Viehland'; 'Discussion of IronPython'; simpy-users at lists.sourceforge.net; 'Simpy-Developer List' Subject: RE: [Simpy-users] RE: [IronPython] SimPy on IronPython timing test Dino, Fully understood! IronPython looks good for such an early version! I am looking forward to future releases of IronPython for performance, but continue trying the beta out with SimPy in the meantime. Klaus M?ller > -----Original Message----- > From: simpy-users-admin at lists.sourceforge.net > [mailto:simpy-users-admin at lists.sourceforge.net] On Behalf Of Dino > Viehland > Sent: Tuesday, February 14, 2006 6:01 PM > To: Discussion of IronPython; > simpy-users at lists.sourceforge.net; 'Simpy-Developer List' > Subject: [Simpy-users] RE: [IronPython] SimPy on IronPython timing > test > > Thanks for the report Klaus. Currently we're mostly focused on > correctness but later in the beta cycle we're going to come back and > target perf pretty heavily. I've gone ahead and filed this in our bug > database so we won't miss it when we get to that point. > > > Do you want to help develop Dynamic languages on CLR? > (http://members.microsoft.com/careers/search/details.aspx?JobI > D=6D4754DE-11F0-45DF-8B78-DC1B43134038) > -----Original Message----- > From: users-bounces at lists.ironpython.com > [mailto:users-bounces at lists.ironpython.com] On Behalf Of Klaus Muller > Sent: Wednesday, February 01, 2006 10:57 PM > To: simpy-users at lists.sourceforge.net; 'Simpy-Developer List' > Cc: users at lists.ironpython.com > Subject: [IronPython] SimPy on IronPython timing test > > All: > I have run a first simple benchmark to compare SimPy under > IronPython with SimPy under CPython. I ran the following program: > > from SimPy.Simulation import * > import time > > class Dum(Process): > def run(self): > yield hold,self,3 > initialize() > nrProcs=int(raw_input("Nr of processes?")) > processes=[Dum("Dum%s"%x) for x in range(1,nrProcs)] > > for i in range(nrProcs): > p=Dum("%s"%i) > activate(p,p.run(),at=i) > > tStart=(time.clock(),time.time()) > simulate(until=2*nrProcs) > print "Ran in %s seconds for %s > processes"%((time.clock()-tStart[0],time.time()-tStart[1]),nrProcs) > raw_input("Hit any key . . .") > > Here are the results: > > Nr processes=10000 > ------------------ > IronPython: 2.06 seconds > CPython: 0.5 seconds > > Nr processes=50000 > ------------------ > IronPython: 15.53 seconds > CPython: 3.67 seconds > > At this moment, IronPython is clearly way slower than CPython > on this benchmark. > > Clearly, it is early days for IronPython (this was run under > beta release 2) and its developers will surely still optimize > its performance a lot. > > If Microsoft actually support IronPython, this will be an > important SimPy platform in the future and we will have to > watch its further development. > > Klaus M?ller > > > ------------------------------------------------------- > This SF.net email is sponsored by: Splunk Inc. Do you grep > through log files for problems? Stop! Download the new AJAX > search engine that makes searching your log files as easy as > surfing the web. DOWNLOAD SPLUNK! > http://sel.as-us.falkag.net/sel?cmd___________________________ > ____________________ > Simpy-users mailing list > Simpy-users at lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/simpy-users > > From Martin.Maly at microsoft.com Tue Aug 1 21:28:51 2006 From: Martin.Maly at microsoft.com (Martin Maly) Date: Tue, 1 Aug 2006 12:28:51 -0700 Subject: [IronPython] delete key on MAC OS X In-Reply-To: Message-ID: If you are not using the -X:TabCompletion, then IronPython console relies simply on the underlying console implementation in the CLR/System. My first guess is therefore that there may be something different about the console implementation on MAC in mono, but not being a mac user, I cannot confirm this for sure, unfortunately. Martin -----Original Message----- From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of HEMMI, Shigeru Sent: Sunday, July 30, 2006 6:59 PM To: Discussion of IronPython Subject: Re: [IronPython] delete key on MAC OS X Thanks for the answer > Are you using the -X:TabCompletion command line switch? If so, then only some > of the control keys are handled and the MAC OS X delete is probably not one of > them. No, I'm not using the -X:TabCompletion command line switch. > If you are not using the -X:TabCompletion command line switch, the problem > may lie in the System.Console implementation. Does it mean that the System.Console implementation by mono on OS X may have some problem? If this is the case, this mailing list is not the right place to ask this question; then I will switch the place to ask. _______________________________________________ users mailing list users at lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com From textdirected at gmail.com Wed Aug 2 11:01:59 2006 From: textdirected at gmail.com (HEMMI, Shigeru) Date: Wed, 2 Aug 2006 18:01:59 +0900 Subject: [IronPython] delete key on MAC OS X In-Reply-To: References: Message-ID: Thanks for the respnse. For the time being, I will use IP together with the ^Z+fg trick. It doesn't matter for me if there is something incomplete on MAC OS X. 2006/8/2, Martin Maly : > If you are not using the -X:TabCompletion, then IronPython console relies simply on the underlying console implementation in the CLR/System. My first guess is therefore that there may be something different about the console implementation on MAC in mono, but not being a mac user, I cannot confirm this for sure, unfortunately. > > Martin > > -----Original Message----- > From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of HEMMI, Shigeru > Sent: Sunday, July 30, 2006 6:59 PM > To: Discussion of IronPython > Subject: Re: [IronPython] delete key on MAC OS X > > Thanks for the answer > > > Are you using the -X:TabCompletion command line switch? If so, then only some > > of the control keys are handled and the MAC OS X delete is probably not one of > > them. > No, I'm not using the -X:TabCompletion command line switch. > > > > If you are not using the -X:TabCompletion command line switch, the problem > > may lie in the System.Console implementation. > Does it mean that the System.Console implementation by mono on OS X may have > some problem? If this is the case, this mailing list is not the right > place to ask this > question; then I will switch the place to ask. > _______________________________________________ > users mailing list > users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > _______________________________________________ > users mailing list > users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > From dinov at exchange.microsoft.com Wed Aug 2 17:47:39 2006 From: dinov at exchange.microsoft.com (Dino Viehland) Date: Wed, 2 Aug 2006 08:47:39 -0700 Subject: [IronPython] profiling ipy apps In-Reply-To: <44C6B12D.5050007@twinsun.com> References: <44C6B12D.5050007@twinsun.com> Message-ID: <7AD436E4270DD54A94238001769C22272F9B5B6CE0@DF-GRTDANE-MSG.exchange.corp.microsoft.com> One of the CLR developers pointed out to me that there is a free 180 day trial version of VSTS available here: https://www.tryvs2005.com/profile.aspx Obviously not a long term solution, but it does give you an opportunity to try it out and use VS's profiler (which is what we use internally when profiling). The way we go about this is to launch ipy.exe w/ the script as the parameter under the profiler (Tools->Performance Tools->New Performance Session). I suggest using the sampling profiler rather than instrumentation, although only instrumentation is available if you're running a 64-bit version of Windows. Finally it'll give you a nice breakdown w/ the top most functions consuming memory. If you want to find the issues in your code you might want to run w/ -D, although I suspect it'll work fine w/o it (usually we're looking for issues in IronPython.dll). -----Original Message----- From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Arman Bostani Sent: Tuesday, July 25, 2006 5:03 PM To: Discussion of IronPython Subject: [IronPython] profiling ipy apps Hello all, Is there a recommended process for profiling ipy applications? Understandably, the cpython profile module doesn't work (no sys.setprofile). Also, CLR Profiler isn't geared towards performance analysis. So, do I need to somehow run my ipy applications under VS 2005 Team Suite? Thanks, -arman _______________________________________________ users mailing list users at lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com From Shri.Borde at microsoft.com Wed Aug 2 21:18:09 2006 From: Shri.Borde at microsoft.com (Shri Borde) Date: Wed, 2 Aug 2006 12:18:09 -0700 Subject: [IronPython] PythonEngine.Import() In-Reply-To: <000001c6b2f9$47a16c40$0f01a8c0@notebook> Message-ID: <50B69702CA6E6D4E849D30CD4989AB8E2A45D923DE@DF-GRTDANE-MSG.exchange.corp.microsoft.com> These are good suggstions. I have opened this bug (http://www.codeplex.com/WorkItem/View.aspx?ProjectName=IronPython&WorkItemId=1547) for it. Since we locking down for V1, we are unlikely to fix this for V1. Please let us know if it is a critical issue for you. ________ Do you want to help develop Dynamic languages on CLR? (http://members.microsoft.com/careers/search/details.aspx?JobID=6D4754DE-11F0-45DF-8B78-DC1B43134038) ________________________________ From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Kristof Wagemans Sent: Saturday, July 29, 2006 3:25 AM To: 'Discussion of IronPython' Subject: [IronPython] PythonEngine.Import() Is PythonEngine.Import() a hosting version of the python import statement? It behaves differently and not all features of import are (yet?) exposed. PythonEngine pe = new PythonEngine(); pe.LoadAssembly(Assembly.GetAssembly(typeof(System.Data.DataSet))); pe.Execute("import System.Data"); // Adds System to pe.Globals. This is what I would expect. pe.Import("System.Data"); // Adds Data to pe.Globals. Is PythonEngine.LoadAssembly() a good name for the method? It seems to behave more like clr.AddReferenceXYZ then clr.LoadAssemblyXYZ. Also, clr.LoadAssembly loads and returns an assembly while PythonEngine.LoadAssembly() takes an assembly as parameter and returns nothing. The following code fails silently. Wouldn't it be better to throw an ImportError exception? PythonEngine pe = new PythonEngine(); pe.Import("DoesntExist"); -------------- next part -------------- An HTML attachment was scrubbed... URL: From jsacksteder at gmail.com Thu Aug 3 05:16:03 2006 From: jsacksteder at gmail.com (jeff sacksteder) Date: Wed, 2 Aug 2006 23:16:03 -0400 Subject: [IronPython] weirdness with DataGridViewButtonColumn Message-ID: <51c8a7be0608022016j3d19cb8ch56ab6d2ba86c91cd@mail.gmail.com> Could someone please try the following code? By every piece of documentation I can find, this SHOULD create two button columns with the text provided displayed on them. All I am getting is blank buttons and I'm beginning to suspect that there is something wrong with my workstation. import clr clr.AddReference('System.Windows.Forms') import System.Windows.Forms as SWF f = SWF.Form() dgv = SWF.DataGridView() f.Controls.Add(dgv) myCol = SWF.DataGridViewButtonColumn(Text="Spaminate",UseColumnTextForButtonValue = True) dgv.Columns.Add(myCol) myCol = SWF.DataGridViewButtonColumn(Text="Spaminate2",UseColumnTextForButtonValue = True) dgv.Columns.Add(myCol) SWF.Application.Run(f) -------------- next part -------------- An HTML attachment was scrubbed... URL: From mark.john.rees at gmail.com Thu Aug 3 07:02:52 2006 From: mark.john.rees at gmail.com (Mark Rees) Date: Thu, 3 Aug 2006 15:02:52 +1000 Subject: [IronPython] weirdness with DataGridViewButtonColumn In-Reply-To: <51c8a7be0608022016j3d19cb8ch56ab6d2ba86c91cd@mail.gmail.com> References: <51c8a7be0608022016j3d19cb8ch56ab6d2ba86c91cd@mail.gmail.com> Message-ID: It's not a problem with your workstation. I get exactly the same as you. On 8/3/06, jeff sacksteder wrote: > Could someone please try the following code? By every piece of documentation > I can find, this SHOULD create two button columns with the text provided > displayed on them. All I am getting is blank buttons and I'm beginning to > suspect that there is something wrong with my workstation. > > > import clr > clr.AddReference('System.Windows.Forms') > import System.Windows.Forms as SWF > > f = SWF.Form() > dgv = SWF.DataGridView() > > f.Controls.Add(dgv) > myCol = SWF.DataGridViewButtonColumn > (Text="Spaminate",UseColumnTextForButtonValue = True) > dgv.Columns.Add(myCol) > myCol = > SWF.DataGridViewButtonColumn(Text="Spaminate2",UseColumnTextForButtonValue > = True) > dgv.Columns.Add(myCol) > > SWF.Application.Run(f) > > _______________________________________________ > users mailing list > users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > > > From jsacksteder at gmail.com Thu Aug 3 21:58:04 2006 From: jsacksteder at gmail.com (jeff sacksteder) Date: Thu, 3 Aug 2006 15:58:04 -0400 Subject: [IronPython] How to conditionally alter DataGridViewButtonColumn? Message-ID: <51c8a7be0608031258q6e78f1avebafe69b6f9d7feb@mail.gmail.com> I'd like to change the text of my button column based on some criteria. If I handle the CellFormatting event, I can get a reference to the Cell, but how do I then get to the Button Control within? -------------- next part -------------- An HTML attachment was scrubbed... URL: From lcm at spiralcomms.com Fri Aug 4 04:12:55 2006 From: lcm at spiralcomms.com (Cheemeng) Date: Fri, 04 Aug 2006 10:12:55 +0800 Subject: [IronPython] How to conditionally alter DataGridViewButtonColumn? In-Reply-To: References: Message-ID: <44D2AD27.9080600@spiralcomms.com> can change the button text thru' the cell value like dgc = SWF.DataGridViewButtonColumn() dgc.HeaderText = dgc.Name = "Test" dgc.Text = "Test" #dgc.UseColumnTextForButtonValue = True dgv.Columns.Add(dgc) drow = dgv.Rows[0] #drow.Cells["Test"].UseColumnTextForButtonValue = True drow.Cells["Test"].Value = "Test 1" > > Subject: [IronPython] How to conditionally alter > DataGridViewButtonColumn? > To: users at lists.ironpython.com > Message-ID: > <51c8a7be0608031258q6e78f1avebafe69b6f9d7feb at mail.gmail.com> > Content-Type: text/plain; charset="iso-8859-1" > > I'd like to change the text of my button column based on some criteria. If I > handle the CellFormatting event, I can get a reference to the Cell, but how > do I then get to the Button Control within? > -------------- next part -------------- From plogi at gmx.net Fri Aug 4 12:07:03 2006 From: plogi at gmx.net (Christoph) Date: Fri, 04 Aug 2006 12:07:03 +0200 Subject: [IronPython] cast to different interface Message-ID: Hello, i'm trying to use serveral interfaces of one object. The solution mentioned here earlier don't work for porperties: Problem: dgv = System.Windows.Forms.DataGridView() dgv.BeginInit() Solution: System.ComponentModel.ISupportInitialize.BeginInit(dgv) How can i use this solution for properties? Greetings Christoph From t-bruch at microsoft.com Fri Aug 4 15:57:55 2006 From: t-bruch at microsoft.com (Bruce Christensen) Date: Fri, 4 Aug 2006 06:57:55 -0700 Subject: [IronPython] Help with bitmap & text In-Reply-To: <1153858791.1605102882.13881.sendItem@bloglines.com> References: <1153858791.1605102882.13881.sendItem@bloglines.com> Message-ID: <3581AA168D87A2479D88EA319BDF7D32010FF110@RED-MSG-80.redmond.corp.microsoft.com> You can use the types in the System.Drawing namespace to accomplish what you want. I found a pretty good example of how to overlay text on images at http://www.codeproject.com/dotnet/vbtextoverlay.asp. A search for ".NET image overlay text" should turn up some other good resources. --Bruce -----Original Message----- From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Dog.23443238 at bloglines.com Sent: Tuesday, July 25, 2006 1:20 PM To: users at lists.ironpython.com Subject: [IronPython] Help with bitmap & text I need to open a small bitmap file, either BMP or JPG, add up to 4 lines of text, then save the file. Can anyone suggest a solution or point me in the right direction? The image files contain data for viewing on my portable MP3 player, things like my address book, Google calendar info, weather forecasts, shopping lists, etc. Anything in a short text file (4 lines max). My original app is in CPython, made very simple to use due to the use of both PIL and PythonCard. It looks like PIL was going to be ported, but never completed. That's a shame, because PIL is so simple and powerful. _______________________________________________ users mailing list users at lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com From dinov at exchange.microsoft.com Fri Aug 4 17:12:45 2006 From: dinov at exchange.microsoft.com (Dino Viehland) Date: Fri, 4 Aug 2006 08:12:45 -0700 Subject: [IronPython] cast to different interface In-Reply-To: References: Message-ID: <7AD436E4270DD54A94238001769C22272FA04AF38C@DF-GRTDANE-MSG.exchange.corp.microsoft.com> You can do: System.ComponentModel.ISupportInitialize.SomeProperty.GetValue(self) Or System.ComponentModel.ISupportInitialize.SomeProperty.SetValue(self, value) We've exposed these 2 helper methods off of the reflected property for this purpose. Even if we hadn't done that you'd still be able to do: System.ComponentModel.ISupportInitialize.SomeProperty.__get__(self,type(self)) Or System.ComponentModel.ISupportInitialize.SomeProperty.__set__(self,value) But we thought GetValue & SetValue were friendlier. -----Original Message----- From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Christoph Sent: Friday, August 04, 2006 3:07 AM To: users at lists.ironpython.com Subject: [IronPython] cast to different interface Hello, i'm trying to use serveral interfaces of one object. The solution mentioned here earlier don't work for porperties: Problem: dgv = System.Windows.Forms.DataGridView() dgv.BeginInit() Solution: System.ComponentModel.ISupportInitialize.BeginInit(dgv) How can i use this solution for properties? Greetings Christoph _______________________________________________ users mailing list users at lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com From slide.o.mix at gmail.com Fri Aug 4 17:32:26 2006 From: slide.o.mix at gmail.com (Slide) Date: Fri, 4 Aug 2006 08:32:26 -0700 Subject: [IronPython] importing C# functions Message-ID: I am currently adding a scripting console to one of the applications I develop. I would like to, at runtime, add functions that can be called by the python code in the console. Something like // c# public int AddIt(int a, int b) { return a + b; } then, I would like to add that function (and possibly functions from plugins) so they can be called from python. Do I need to create a module and add the functions to the module? Is there a better way? Thanks, slide From srideviaishwariya at gmail.com Thu Aug 3 12:30:02 2006 From: srideviaishwariya at gmail.com (Sridevi) Date: Thu, 3 Aug 2006 10:30:02 +0000 (UTC) Subject: [IronPython] ElementTree in IronPython References: <295e750a0601311237y6292e8e3sfaf05a75aaebc744@mail.gmail.com> Message-ID: I need to import ElementTree into IronPython >>> from elementtree import ElementTree >>> tree = ElementTree.parse('sample.xml') Traceback (most recent call last): File , line 0, in ##16 AttributeError: 'module' object has no attribute 'parse' The parse() is a funtion in element and it has to be called. 1 . >>> import sys >>> sys.path.append("c:\python24\Lib") Here the elementtree folder is in the python library 2. I copied the elementtree folder into the pyIron library. Both the methods give the same error. :) ... can u help me solve the problem Thanking you, Sridevi From srideviaishwariya at gmail.com Thu Aug 3 14:40:43 2006 From: srideviaishwariya at gmail.com (Sridevi) Date: Thu, 3 Aug 2006 12:40:43 +0000 (UTC) Subject: [IronPython] pyexpat and IronPython References: <295e750a0601311237y6292e8e3sfaf05a75aaebc744@mail.gmail.com> Message-ID: Iam unable to run pyexpat from IronPython Is there any files i got to add for it From jdehooge at fugro-jason.com Thu Aug 3 18:04:45 2006 From: jdehooge at fugro-jason.com (Jacques de Hooge) Date: Thu, 3 Aug 2006 18:04:45 +0200 Subject: [IronPython] No automatic conversion anymore from list to array Message-ID: Hi, I've been moving my apps from IP 1 Beta 7 to IP 1 RC1. I have not tested them completely, but I ran into the fact that automatic conversion from list to array was removed. If I remember right, the reason is that a C# function receiving an array param may alter it. If a tuple is passed rather than an array, the user would not expect the tuple to be altered. - Is there a fundamental reason why the function could not update the contents of the list offered to it? - If not, couldn't some kind of optional ('strict' option) warning be generated rather than prohibiting automatic conversion? - Are you sure most Python programmers know enough about Python "passing references by value" to be aware that the function could not replace the tuple by a new instance (I tought some Python courses and my students, originally coming from C++, are always baffled by that, even after multiple years of Python experience)? One of the places where I use automatic conversion is: listViewItemsBuffer = [] for ... : listViewItemsBuffer.append (listViewItem) listViewItems.AddRange (listViewItemsBuffer) The alternatives are: 1. listViewItems.AddRange (tuple (listViewItemsBuffer)) Will probably create a third, redundant, copy of the long list of pointers involved each time its called 2. listViewItems.AddRange (System.Array [Forms.ListViewItem] (listViewItemsBuffer)) Verbose (One of the things about Python programs is that they are much shorter than their C# equivalents) Well I guess you guys will have discussed this extensively. Still I'd like to share the above thoughts with you. Kind regards J. de Hooge info at geatec.com From jdehooge at fugro-jason.com Thu Aug 3 18:10:52 2006 From: jdehooge at fugro-jason.com (Jacques de Hooge) Date: Thu, 3 Aug 2006 18:10:52 +0200 Subject: [IronPython] Auto conversion from list to array removed (sorry, formatting of previous message was faulty) Message-ID: Hi, I've been moving my apps from IP 1 Beta 7 to IP 1 RC1. I have not tested them completely, but I ran into the fact that automatic conversion from list to array was removed. If I remember right, the reason is that a C# function receiving an array param may alter it. If a tuple is passed rather than an array, the user would not expect the tuple to be altered. - Is there a fundamental reason why the function could not update the contents of the list offered to it? - If not, couldn't some kind of optional ('strict' option) warning be generated rather than prohibiting automatic conversion? - Are you sure most Python programmers know enough about Python "passing references by value" to be aware that the function could not replace the tuple by a new instance (I tought some Python courses and my students, originally coming from C++, are always baffled by that, even after multiple years of Python experience)? One of the places where I use automatic conversion is: listViewItemsBuffer = [] for ... : listViewItemsBuffer.append (listViewItem) listViewItems.AddRange (listViewItemsBuffer) The alternatives are: 1. listViewItems.AddRange (tuple (listViewItemsBuffer)) Will probably create a third, redundant, copy of the long list of pointers involved each time its called 2. listViewItems.AddRange (System.Array [Forms.ListViewItem] (listViewItemsBuffer)) Verbose (One of the things about Python programs is that they are much shorter than their C# equivalents) Well I guess you guys will have discussed this extensively. Still I'd like to share the above thoughts with you. Kind regards J. de Hooge info at geatec.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From t-bruch at microsoft.com Fri Aug 4 20:58:51 2006 From: t-bruch at microsoft.com (Bruce Christensen) Date: Fri, 4 Aug 2006 11:58:51 -0700 Subject: [IronPython] pyexpat and IronPython In-Reply-To: References: <295e750a0601311237y6292e8e3sfaf05a75aaebc744@mail.gmail.com> Message-ID: <3581AA168D87A2479D88EA319BDF7D32010FF377@RED-MSG-80.redmond.corp.microsoft.com> Nope. :) pyexpat relies on Python extension modules written in C, which don't work with IronPython. However, you can use the classes in the .NET System.Xml namespace for parsing XML documents if you're writing new code. --Bruce -----Original Message----- From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Sridevi Sent: Thursday, August 03, 2006 5:41 AM To: users-ironpython.com at lists.ironpython.com Subject: [IronPython] pyexpat and IronPython Iam unable to run pyexpat from IronPython Is there any files i got to add for it _______________________________________________ users mailing list users at lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com From t-bruch at microsoft.com Fri Aug 4 20:58:51 2006 From: t-bruch at microsoft.com (Bruce Christensen) Date: Fri, 4 Aug 2006 11:58:51 -0700 Subject: [IronPython] pyexpat and IronPython In-Reply-To: References: <295e750a0601311237y6292e8e3sfaf05a75aaebc744@mail.gmail.com> Message-ID: <3581AA168D87A2479D88EA319BDF7D32010FF377@RED-MSG-80.redmond.corp.microsoft.com> Nope. :) pyexpat relies on Python extension modules written in C, which don't work with IronPython. However, you can use the classes in the .NET System.Xml namespace for parsing XML documents if you're writing new code. --Bruce -----Original Message----- From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Sridevi Sent: Thursday, August 03, 2006 5:41 AM To: users-ironpython.com at lists.ironpython.com Subject: [IronPython] pyexpat and IronPython Iam unable to run pyexpat from IronPython Is there any files i got to add for it _______________________________________________ users mailing list users at lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com From monty at inaugust.com Fri Aug 4 21:34:54 2006 From: monty at inaugust.com (Monty Taylor) Date: Fri, 4 Aug 2006 12:34:54 -0700 Subject: [IronPython] pyexpat and IronPython In-Reply-To: <3581AA168D87A2479D88EA319BDF7D32010FF377@RED-MSG-80.redmond.corp.microsoft.com> References: <295e750a0601311237y6292e8e3sfaf05a75aaebc744@mail.gmail.com> <3581AA168D87A2479D88EA319BDF7D32010FF377@RED-MSG-80.redmond.corp.microsoft.com> Message-ID: You could write a Python or C# wrapper around System.XML that behaves like pyexpat and contribute it. :) Monty On 8/4/06, Bruce Christensen wrote: > Nope. :) pyexpat relies on Python extension modules written in C, which > don't work with IronPython. However, you can use the classes in the .NET > System.Xml namespace for parsing XML documents if you're writing new > code. > > --Bruce > > -----Original Message----- > From: users-bounces at lists.ironpython.com > [mailto:users-bounces at lists.ironpython.com] On Behalf Of Sridevi > Sent: Thursday, August 03, 2006 5:41 AM > To: users-ironpython.com at lists.ironpython.com > Subject: [IronPython] pyexpat and IronPython > > Iam unable to run pyexpat from IronPython > Is there any files i got to add for it > > _______________________________________________ > users mailing list > users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > _______________________________________________ > users mailing list > users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > From monty at inaugust.com Fri Aug 4 21:43:42 2006 From: monty at inaugust.com (Monty Taylor) Date: Fri, 4 Aug 2006 12:43:42 -0700 Subject: [IronPython] ElementTree in IronPython In-Reply-To: References: <295e750a0601311237y6292e8e3sfaf05a75aaebc744@mail.gmail.com> Message-ID: ElementTree is the module containing ElementTree the class. I think what you mean is from elementtree.ElementTree import ElementTree x=ElementTree() x.parse('sample.xml') Good luck, Monty On 8/3/06, Sridevi wrote: > I need to import ElementTree into IronPython > > >>> from elementtree import ElementTree > >>> tree = ElementTree.parse('sample.xml') > Traceback (most recent call last): > File , line 0, in ##16 > AttributeError: 'module' object has no attribute 'parse' > > The parse() is a funtion in element and it has to be called. > > 1 . > >>> import sys > >>> sys.path.append("c:\python24\Lib") > > Here the elementtree folder is in the python library > > 2. > I copied the elementtree folder into the pyIron library. > > Both the methods give the same error. > > :) ... can u help me solve the problem > > Thanking you, > Sridevi > > _______________________________________________ > users mailing list > users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > From mark.john.rees at gmail.com Fri Aug 4 22:40:02 2006 From: mark.john.rees at gmail.com (Mark Rees) Date: Sat, 05 Aug 2006 06:40:02 +1000 Subject: [IronPython] pyexpat and IronPython In-Reply-To: References: <295e750a0601311237y6292e8e3sfaf05a75aaebc744@mail.gmail.com> <3581AA168D87A2479D88EA319BDF7D32010FF377@RED-MSG-80.redmond.corp.microsoft.com> Message-ID: <44D3B0A2.9040101@gmail.com> Hi, Seo has already done a basic pyexpat wrapper. He posted about it in: http://lists.ironpython.com/pipermail/users-ironpython.com/2005-November/001227.html And it can be found at: http://sparcs.kaist.ac.kr/~tinuviel/fepy/old/pyexpat.py I have used this with ElementTree. There are limitations like iterparse doesn't work and if the XML you are parsing contains an empty element i.e it fails. I have modified Seo's pyexpat.py to handle the second limitation and have included the source in this email. I have used this for my elementtree requirements but the XML I parse is simple so there may be other as yet undiscovered issues. Regards Mark Modified version of pyexpat from http://sparcs.kaist.ac.kr/~tinuviel/fepy/old/pyexpat.py import clr clr.AddReference("System.Xml") from System.IO import MemoryStream, SeekOrigin, StreamWriter from System.Xml import NameTable, XmlNamespaceManager, XmlParserContext, XmlSpace from System.Xml import XmlTextReader, XmlNodeType def ErrorString(errno): if errno > 0: return "unknown error" else: return None def ParserCreate(*args): return xmlparser() class xmlparser: __slots__ = [ "StartElementHandler", "EndElementHandler", "CharacterDataHandler", ] returns_unicode = False def __init__(self): self._stream = MemoryStream() self._parser = self._make_parser() def Parse(self, data, isfinal=False): self._append_stream(data) self._parse() if isfinal: self._stream.Close() def _make_parser(self): table = NameTable() manager = XmlNamespaceManager(table) parser = XmlParserContext(table, manager, None, XmlSpace.None) return parser def _append_stream(self, data): stream = self._stream position = stream.Position stream.Seek(0, SeekOrigin.End) writer = StreamWriter(stream) writer.Write(data) writer.Flush() stream.Position = position def _parse(self): reader = XmlTextReader(self._stream, XmlNodeType.Element, self._parser) while reader.Read(): nodetype = reader.NodeType if nodetype == XmlNodeType.Element: name = reader.Name attributes = {} while reader.MoveToNextAttribute(): attributes[reader.Name] = reader.Value if hasattr(self, "StartElementHandler"): self.StartElementHandler(name, attributes) # Create EndElement event as XmlTextReader doesn't # do this for empty elements if reader.IsEmptyElement: nodetype = XmlNodeType.EndElement if nodetype == XmlNodeType.EndElement: name = reader.Name if hasattr(self, "EndElementHandler"): self.EndElementHandler(name) elif nodetype == XmlNodeType.Text: data = reader.Value if hasattr(self, "CharacterDataHandler"): self.CharacterDataHandler(data) Monty Taylor wrote: > You could write a Python or C# wrapper around System.XML that behaves > like pyexpat and contribute it. :) > > Monty > > On 8/4/06, Bruce Christensen wrote: > >> Nope. :) pyexpat relies on Python extension modules written in C, which >> don't work with IronPython. However, you can use the classes in the .NET >> System.Xml namespace for parsing XML documents if you're writing new >> code. >> >> --Bruce >> >> -----Original Message----- >> From: users-bounces at lists.ironpython.com >> [mailto:users-bounces at lists.ironpython.com] On Behalf Of Sridevi >> Sent: Thursday, August 03, 2006 5:41 AM >> To: users-ironpython.com at lists.ironpython.com >> Subject: [IronPython] pyexpat and IronPython >> >> Iam unable to run pyexpat from IronPython >> Is there any files i got to add for it >> >> _______________________________________________ >> users mailing list >> users at lists.ironpython.com >> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com >> _______________________________________________ >> users mailing list >> users at lists.ironpython.com >> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com >> >> > _______________________________________________ > users mailing list > users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > > From textdirected at gmail.com Sat Aug 5 03:17:09 2006 From: textdirected at gmail.com (HEMMI, Shigeru) Date: Sat, 5 Aug 2006 10:17:09 +0900 Subject: [IronPython] Latest IronPython on Mono In-Reply-To: <5b0248170607190018t7c5f5c27jcef6a4580757ad20@mail.gmail.com> References: <5b0248170607190018t7c5f5c27jcef6a4580757ad20@mail.gmail.com> Message-ID: Dear IPy Team, Change Set: 2330 is not free from bugs those reported by Sanghyeon Seo. Please apply the patch provided by himself (Thanks Sanghyeon Seo !!). After applying the patch, it still has many compilation warnings. See the attachment. Regards, 2006/7/19, Sanghyeon Seo wrote: > The latest source from CodePlex fails to compile on Mono with: > > IronPython/Runtime/Operations/Ops.cs(1336,13): error CS0411: The type > arguments for method `AddRange' cannot be infered from the usage. Try > specifying the type arguments explicitly. > IronPython/Runtime/Operations/Ops.cs(1413,13): error CS0411: The type > arguments for method `AddRange' cannot be infered from the usage. Try > specifying the type arguments explicitly. > > A simple workaround is attached. > > > _______________________________________________ > users mailing list > users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > > > > -------------- next part -------------- $ gmcs --version Mono C# compiler version 1.1.16.1 $ make gmcs -t:library -out:../IronMath.dll -recurse:IronMath/*.cs IronMath/BigInteger.cs(230,13): warning CS0642: Possible mistaken empty statement Compilation succeeded - 1 warning(s) gmcs -t:library -r:../IronMath.dll -r:System.Drawing.dll -r:System.Design.dll -out:../IronPython.dll -recurse:IronPython/*.cs IronPython/Compiler/MethodBinder.cs(963,22): warning CS0219: The variable `returnType' is assigned but its value is never used IronPython/Compiler/AST/Statements.cs(529,19): warning CS0219: The variable `beforeFinally' is assigned but its value is never used IronPython/Modules/Builtin.cs(529,33): warning CS0219: The variable `modType' is assigned but its value is never used IronPython/Modules/cPickle.cs(510,29): warning CS0219: The variable `intCode' is assigned but its value is never used IronPython/Modules/nt.cs(744,20): warning CS0219: The variable `message' is assigned but its value is never used IronPython/Modules/socket.cs(1509,22): warning CS0219: The variable `flowInfo' is assigned but its value is never used IronPython/Runtime/Types/Mro.cs(101,21): warning CS0219: The variable `lastRemove' is assigned but its value is never used IronPython/Compiler/Generation/Slot.cs(330,34): warning CS0414: The private field `IronPython.Compiler.Generation.LocalSlot.codeGen' is assigned but its value is never used IronPython/Hosting/PythonEngine.cs(367,22): warning CS0169: The private method `IronPython.Hosting.PythonEngine.ExecuteSnippet(IronPython.Compiler.Parser, IronPython.Runtime.ModuleScope)' is never used IronPython/Modules/cPickle.cs(1367,28): warning CS0169: The private method `IronPython.Modules.PythonPickle.Unpickler.ReadLine()' is never used IronPython/Runtime/Converter.cs(475,38): warning CS0414: The private field `IronPython.Runtime.Converter.ArrayListType' is assigned but its value is never used IronPython/Runtime/Converter.cs(478,38): warning CS0414: The private field `IronPython.Runtime.Converter.ListOfTType' is assigned but its value is never used IronPython/Runtime/Converter.cs(480,38): warning CS0414: The private field `IronPython.Runtime.Converter.HashtableType' is assigned but its value is never used IronPython/Runtime/Converter.cs(481,38): warning CS0414: The private field `IronPython.Runtime.Converter.ListWrapperForIListType' is assigned but its value is never used IronPython/Runtime/Converter.cs(484,38): warning CS0414: The private field `IronPython.Runtime.Converter.DictWrapperForIDictType' is assigned but its value is never used IronPython/Runtime/ModuleScope.cs(44,31): warning CS0414: The private field `IronPython.Runtime.ModuleScope.__builtin__' is assigned but its value is never used IronPython/Runtime/calls/kwargbinder.cs(46,32): warning CS0414: The private field `IronPython.Runtime.Calls.KwArgBinder.ctx' is assigned but its value is never used Compilation succeeded - 17 warning(s) gmcs -t:exe -r:../IronPython.dll -out:../ipy.exe -recurse:IronPythonConsole/*.cs gmcs -t:winexe -r:../IronPython.dll -define:IRONPYTHON_WINDOW -out:../ipyw.exe -recurse:IronPythonConsole/*.cs IronPythonConsole/PythonCommandLine.cs(417,29): warning CS0169: The private method `IronPythonConsole.PythonCommandLine.RunStartup(IronPython.Hosting.PythonEngine)' is never used IronPythonConsole/PythonCommandLine.cs(701,28): warning CS0169: The private method `IronPythonConsole.PythonCommandLine.RunInteractive()' is never used IronPythonConsole/PythonCommandLine.cs(735,29): warning CS0169: The private method `IronPythonConsole.PythonCommandLine.DefaultExceptionHandler(object, System.UnhandledExceptionEventArgs)' is never used Compilation succeeded - 3 warning(s) mkdir IronPythonTest/bin/Debug gmcs -t:library -r:../IronMath.dll -r:../IronPython.dll -out:IronPythonTest/bin/Debug/IronPythonTest.dll -recurse:IronPythonTest/*.cs IronPythonTest/DeTest.cs(151,26): warning CS0219: The variable `dts2' is assigned but its value is never used IronPythonTest/InheritTest.cs(792,49): warning CS0183: The given expression is always of the provided (`IronPythonTest.StrangeOverrides') type IronPythonTest/InheritTest.cs(797,49): warning CS0183: The given expression is always of the provided (`IronPythonTest.StrangeOverrides') type IronPythonTest/InheritTest.cs(802,49): warning CS0183: The given expression is always of the provided (`IronPythonTest.StrangeOverrides') type IronPythonTest/BinderTest.cs(210,14): warning CS0169: The private method `IronPythonTest.BinderTest.COtherOverloadConcern.M100(int)' is never used IronPythonTest/DeTest.cs(41,14): warning CS0169: The private method `IronPythonTest.DeTestStruct.Init()' is never used IronPythonTest/EngineTest.cs(63,21): warning CS0169: The private property `IronPythonTest.ClsPart.privateProperty' is never used IronPythonTest/EngineTest.cs(65,21): warning CS0169: The private method `IronPythonTest.ClsPart.privateMethod(int)' is never used IronPythonTest/EngineTest.cs(71,21): warning CS0169: The private method `IronPythonTest.ClsPart.privateStaticMethod()' is never used IronPythonTest/EngineTest.cs(593,21): warning CS0169: The private method `IronPythonTest.EngineTest.ThrowException()' is never used IronPythonTest/InheritTest.cs(337,24): warning CS0414: The private field `IronPythonTest.Inherited.str' is assigned but its value is never used Compilation succeeded - 11 warning(s) From dinov at exchange.microsoft.com Sat Aug 5 03:23:51 2006 From: dinov at exchange.microsoft.com (Dino Viehland) Date: Fri, 4 Aug 2006 18:23:51 -0700 Subject: [IronPython] Latest IronPython on Mono In-Reply-To: References: <5b0248170607190018t7c5f5c27jcef6a4580757ad20@mail.gmail.com> Message-ID: <7AD436E4270DD54A94238001769C22272FA04AF6D1@DF-GRTDANE-MSG.exchange.corp.microsoft.com> Thanks for the reports on the warnings. I'll open a bug to get those fixed. The compiler errors are presumably actual bugs on Mono so they'll need to fix those. -----Original Message----- From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of HEMMI, Shigeru Sent: Friday, August 04, 2006 6:17 PM To: Discussion of IronPython Subject: Re: [IronPython] Latest IronPython on Mono Dear IPy Team, Change Set: 2330 is not free from bugs those reported by Sanghyeon Seo. Please apply the patch provided by himself (Thanks Sanghyeon Seo !!). After applying the patch, it still has many compilation warnings. See the attachment. Regards, 2006/7/19, Sanghyeon Seo wrote: > The latest source from CodePlex fails to compile on Mono with: > > IronPython/Runtime/Operations/Ops.cs(1336,13): error CS0411: The type > arguments for method `AddRange' cannot be infered from the usage. Try > specifying the type arguments explicitly. > IronPython/Runtime/Operations/Ops.cs(1413,13): error CS0411: The type > arguments for method `AddRange' cannot be infered from the usage. Try > specifying the type arguments explicitly. > > A simple workaround is attached. > > > _______________________________________________ > users mailing list > users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > > > > From textdirected at gmail.com Sat Aug 5 04:26:56 2006 From: textdirected at gmail.com (HEMMI, Shigeru) Date: Sat, 5 Aug 2006 11:26:56 +0900 Subject: [IronPython] Latest IronPython on Mono In-Reply-To: <7AD436E4270DD54A94238001769C22272FA04AF6D1@DF-GRTDANE-MSG.exchange.corp.microsoft.com> References: <5b0248170607190018t7c5f5c27jcef6a4580757ad20@mail.gmail.com> <7AD436E4270DD54A94238001769C22272FA04AF6D1@DF-GRTDANE-MSG.exchange.corp.microsoft.com> Message-ID: Thanks for the answer. I have asked a question to Mono team: http://lists.ximian.com/pipermail/mono-devel-list/2006-August/019626.html Regards, 2006/8/5, Dino Viehland: > Thanks for the reports on the warnings. I'll open a bug to get those fixed. The compiler errors are presumably actual bugs on Mono so they'll need to fix those. > > -----Original Message----- > From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of HEMMI, Shigeru > Sent: Friday, August 04, 2006 6:17 PM > To: Discussion of IronPython > Subject: Re: [IronPython] Latest IronPython on Mono > > Dear IPy Team, > > Change Set: 2330 is not free from bugs those reported by Sanghyeon Seo. > Please apply the patch provided by himself (Thanks Sanghyeon Seo !!). > > After applying the patch, it still has many compilation warnings. > See the attachment. > > Regards, > > 2006/7/19, Sanghyeon Seo wrote: > > The latest source from CodePlex fails to compile on Mono with: > > > > IronPython/Runtime/Operations/Ops.cs(1336,13): error CS0411: The type > > arguments for method `AddRange' cannot be infered from the usage. Try > > specifying the type arguments explicitly. > > IronPython/Runtime/Operations/Ops.cs(1413,13): error CS0411: The type > > arguments for method `AddRange' cannot be infered from the usage. Try > > specifying the type arguments explicitly. > > > > A simple workaround is attached. > > > > > > _______________________________________________ > > users mailing list > > users at lists.ironpython.com > > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > > > > > > > > > _______________________________________________ > users mailing list > users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > From fuzzyman at gmail.com Sat Aug 5 13:36:49 2006 From: fuzzyman at gmail.com (Michael Foord) Date: Sat, 05 Aug 2006 11:36:49 -0000 Subject: [IronPython] importing C# functions In-Reply-To: References: Message-ID: <1154777809.185342.241920@h48g2000cwc.googlegroups.com> Slide wrote: > I am currently adding a scripting console to one of the applications I > develop. I would like to, at runtime, add functions that can be called > by the python code in the console. Something like > > // c# > public int AddIt(int a, int b) > { > return a + b; > } > Does C# allow you to define functions outside of objects ? I didn't think so... You can create static methods on objects though. > then, I would like to add that function (and possibly functions from > plugins) so they can be called from python. Do I need to create a > module and add the functions to the module? Is there a better way? > For an example of creating a dll from C#, and then accessing from IronPython, see : http://www.voidspace.org.uk/python/weblog/arch_d7_2006_07_29.shtml#e406 All the best, Fuzzyman http://www.voidspace.org.uk/python/index.shtml > Thanks, > > slide > _______________________________________________ > users mailing list > users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com From s at rusek.org Sat Aug 5 15:01:27 2006 From: s at rusek.org (Stefan Rusek) Date: Sat, 5 Aug 2006 09:01:27 -0400 Subject: [IronPython] importing C# functions In-Reply-To: <1154777809.185342.241920@h48g2000cwc.googlegroups.com> Message-ID: <20060805130157.861771BB57@che.dreamhost.com> Tell him to look into using IronPython instead of normal python. IP is written completely in C# and has really good .net support, and he should be able to declare a static method and use it like normal function in python. --Stefan -----Original Message----- From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Michael Foord Sent: Saturday, August 05, 2006 7:37 AM To: users at lists.ironpython.com Subject: Re: [IronPython] importing C# functions Slide wrote: > I am currently adding a scripting console to one of the applications I > develop. I would like to, at runtime, add functions that can be called > by the python code in the console. Something like > > // c# > public int AddIt(int a, int b) > { > return a + b; > } > Does C# allow you to define functions outside of objects ? I didn't think so... You can create static methods on objects though. > then, I would like to add that function (and possibly functions from > plugins) so they can be called from python. Do I need to create a > module and add the functions to the module? Is there a better way? > For an example of creating a dll from C#, and then accessing from IronPython, see : http://www.voidspace.org.uk/python/weblog/arch_d7_2006_07_29.shtml#e406 All the best, Fuzzyman http://www.voidspace.org.uk/python/index.shtml > Thanks, > > slide > _______________________________________________ > users mailing list > users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com _______________________________________________ users mailing list users at lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com From s at rusek.org Sat Aug 5 15:02:32 2006 From: s at rusek.org (Stefan Rusek) Date: Sat, 5 Aug 2006 09:02:32 -0400 Subject: [IronPython] Recall: importing C# functions Message-ID: Stefan Rusek would like to recall the message, "[IronPython] importing C# functions". -------------- next part -------------- A non-text attachment was scrubbed... Name: winmail.dat Type: application/ms-tnef Size: 1081 bytes Desc: not available URL: From slide.o.mix at gmail.com Sat Aug 5 20:49:52 2006 From: slide.o.mix at gmail.com (Slide) Date: Sat, 5 Aug 2006 11:49:52 -0700 Subject: [IronPython] importing C# functions In-Reply-To: <20060805130157.861771BB57@che.dreamhost.com> References: <1154777809.185342.241920@h48g2000cwc.googlegroups.com> <20060805130157.861771BB57@che.dreamhost.com> Message-ID: So I just need to make sure my functions are static? The main goal of this was to allow runtime addition of functions for a module. I was hoping to do something like EngineModule mod = _engine.CreateModule("mymodule", true); mod.AddMethod(someObject, "mymethod", someDelegate); Then I would be able to call mymodule.mymethod inside of python scripts, but I guess that might be a pipe dream. thanks slide On 8/5/06, Stefan Rusek wrote: > Tell him to look into using IronPython instead of normal python. IP is > written completely in C# and has really good .net support, and he should be > able to declare a static method and use it like normal function in python. > > --Stefan > > -----Original Message----- > From: users-bounces at lists.ironpython.com > [mailto:users-bounces at lists.ironpython.com] On Behalf Of Michael Foord > Sent: Saturday, August 05, 2006 7:37 AM > To: users at lists.ironpython.com > Subject: Re: [IronPython] importing C# functions > > > Slide wrote: > > I am currently adding a scripting console to one of the applications I > > develop. I would like to, at runtime, add functions that can be called > > by the python code in the console. Something like > > > > // c# > > public int AddIt(int a, int b) > > { > > return a + b; > > } > > > > Does C# allow you to define functions outside of objects ? I didn't > think so... > > You can create static methods on objects though. > > > then, I would like to add that function (and possibly functions from > > plugins) so they can be called from python. Do I need to create a > > module and add the functions to the module? Is there a better way? > > > > For an example of creating a dll from C#, and then accessing from > IronPython, see : > > http://www.voidspace.org.uk/python/weblog/arch_d7_2006_07_29.shtml#e406 > > All the best, > > Fuzzyman > http://www.voidspace.org.uk/python/index.shtml > > > Thanks, > > > > slide > > _______________________________________________ > > users mailing list > > users at lists.ironpython.com > > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > > _______________________________________________ > users mailing list > users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > > _______________________________________________ > users mailing list > users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > From jan.szumiec at resolversystems.com Mon Aug 7 12:21:36 2006 From: jan.szumiec at resolversystems.com (Jan Szumiec) Date: Mon, 07 Aug 2006 11:21:36 +0100 Subject: [IronPython] AttributeError problem Message-ID: <44D71430.4070609@resolversystems.com> Hi, We've discovered a bug in 1.0RC1. The behavior between CPython and IP differs. Code: class AttributeTest(object): def __getattr__(self, name): print 'hello' raise AttributeError('wibble') AttributeTest().fish IronPython trace: hello Traceback (most recent call last): File c:\development\Resolver\CSharp\RSIronPython\Engine.cs, line 52, in RunPythonFile File , line 0, in C:\development\att Test.py##1 AttributeError: fish CPython trace: C:\development>"att Test.py" hello Traceback (most recent call last): File "C:\development\att Test.py", line 7, in ? AttributeTest().fish File "C:\development\att Test.py", line 4, in __getattr__ raise AttributeError('wibble') AttributeError: wibble From michael.foord at resolversystems.com Mon Aug 7 12:23:53 2006 From: michael.foord at resolversystems.com (Michael Foord) Date: Mon, 07 Aug 2006 11:23:53 +0100 Subject: [IronPython] Updated md5.py Message-ID: <44D714B9.3000303@resolversystems.com> Hello all, At Resolver we having been using the md5.py module created by Seo. We have just updated to IronPython 1.0 RC1 and fixed it to work with that. The fix was simple (although the error message is weird and I don't understand how it ever worked anyway !). Updated copy attached. If anyone needs me to put this online I can. All the best, Michael Foord http://www.resolversystems.com http://www.voidspace.org.uk/python/index.shtml -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: md5.py URL: From dinov at exchange.microsoft.com Mon Aug 7 17:28:12 2006 From: dinov at exchange.microsoft.com (Dino Viehland) Date: Mon, 7 Aug 2006 08:28:12 -0700 Subject: [IronPython] AttributeError problem In-Reply-To: <44D71430.4070609@resolversystems.com> References: <44D71430.4070609@resolversystems.com> Message-ID: <7AD436E4270DD54A94238001769C22272FA04AF76A@DF-GRTDANE-MSG.exchange.corp.microsoft.com> Thanks for the bug report. I've opened CodePlex bug #1689 to track this (http://www.codeplex.com/WorkItem/View.aspx?ProjectName=IronPython&WorkItemId=1689) . Just to make sure we get the correct priority - is this blocking you? My only concern is that the fix here could be a little destabilizing. The point when we're catching the wibble exception and the point where we re-throw the fish exception are rather disconnected. We'd like to minimize the churn now that we're at the end game so if it's not a blocker it might be better to wait for this one until 1.01. If it is a blocker let us know and we'll take a closer look at it. Thanks! -----Original Message----- From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Jan Szumiec Sent: Monday, August 07, 2006 3:22 AM To: users at lists.ironpython.com Subject: [IronPython] AttributeError problem Hi, We've discovered a bug in 1.0RC1. The behavior between CPython and IP differs. Code: class AttributeTest(object): def __getattr__(self, name): print 'hello' raise AttributeError('wibble') AttributeTest().fish IronPython trace: hello Traceback (most recent call last): File c:\development\Resolver\CSharp\RSIronPython\Engine.cs, line 52, in RunPythonFile File , line 0, in C:\development\att Test.py##1 AttributeError: fish CPython trace: C:\development>"att Test.py" hello Traceback (most recent call last): File "C:\development\att Test.py", line 7, in ? AttributeTest().fish File "C:\development\att Test.py", line 4, in __getattr__ raise AttributeError('wibble') AttributeError: wibble _______________________________________________ users mailing list users at lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com From jan.szumiec at resolversystems.com Mon Aug 7 17:29:56 2006 From: jan.szumiec at resolversystems.com (Jan Szumiec) Date: Mon, 07 Aug 2006 16:29:56 +0100 Subject: [IronPython] AttributeError problem In-Reply-To: <7AD436E4270DD54A94238001769C22272FA04AF76A@DF-GRTDANE-MSG.exchange.corp.microsoft.com> References: <44D71430.4070609@resolversystems.com> <7AD436E4270DD54A94238001769C22272FA04AF76A@DF-GRTDANE-MSG.exchange.corp.microsoft.com> Message-ID: <44D75C74.7030202@resolversystems.com> Dino Viehland wrote: > Thanks for the bug report. I've opened CodePlex bug #1689 to track this (http://www.codeplex.com/WorkItem/View.aspx?ProjectName=IronPython&WorkItemId=1689) . > > Just to make sure we get the correct priority - is this blocking you? My only concern is that the fix here could be a little destabilizing. The point when we're catching the wibble exception and the point where we re-throw the fish exception are rather disconnected. We'd like to minimize the churn now that we're at the end game so if it's not a blocker it might be better to wait for this one until 1.01. If it is a blocker let us know and we'll take a closer look at it. Thanks! > It is preventing us from returning meaningful error messages to our users. It's not critical at the moment. Thanks, Jan From dinov at exchange.microsoft.com Mon Aug 7 17:44:22 2006 From: dinov at exchange.microsoft.com (Dino Viehland) Date: Mon, 7 Aug 2006 08:44:22 -0700 Subject: [IronPython] AttributeError problem In-Reply-To: <44D75C74.7030202@resolversystems.com> References: <44D71430.4070609@resolversystems.com> <7AD436E4270DD54A94238001769C22272FA04AF76A@DF-GRTDANE-MSG.exchange.corp.microsoft.com> <44D75C74.7030202@resolversystems.com> Message-ID: <7AD436E4270DD54A94238001769C22272FA04AF771@DF-GRTDANE-MSG.exchange.corp.microsoft.com> Ok, I'll keep it as a 1.01 bug for now and set the priority as high so make sure we get to it before it becomes critical :). -----Original Message----- From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Jan Szumiec Sent: Monday, August 07, 2006 8:30 AM To: Discussion of IronPython Subject: Re: [IronPython] AttributeError problem Dino Viehland wrote: > Thanks for the bug report. I've opened CodePlex bug #1689 to track this (http://www.codeplex.com/WorkItem/View.aspx?ProjectName=IronPython&WorkItemId=1689) . > > Just to make sure we get the correct priority - is this blocking you? My only concern is that the fix here could be a little destabilizing. The point when we're catching the wibble exception and the point where we re-throw the fish exception are rather disconnected. We'd like to minimize the churn now that we're at the end game so if it's not a blocker it might be better to wait for this one until 1.01. If it is a blocker let us know and we'll take a closer look at it. Thanks! > It is preventing us from returning meaningful error messages to our users. It's not critical at the moment. Thanks, Jan _______________________________________________ users mailing list users at lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com From jsacksteder at gmail.com Mon Aug 7 20:10:38 2006 From: jsacksteder at gmail.com (jeff sacksteder) Date: Mon, 7 Aug 2006 14:10:38 -0400 Subject: [IronPython] producing exe's Message-ID: <51c8a7be0608071110w7fe94dd3xb2d248a09772d55e@mail.gmail.com> If I make exe's like this- ipyw.exe -X:SaveAssemblies myscript.py I still get the console window. Is this correct? -------------- next part -------------- An HTML attachment was scrubbed... URL: From srideviaishwariya at gmail.com Tue Aug 8 06:47:02 2006 From: srideviaishwariya at gmail.com (Sridevi Aishwariya) Date: Tue, 8 Aug 2006 10:17:02 +0530 Subject: [IronPython] pyexpat and IronPython In-Reply-To: <44D3B0A2.9040101@gmail.com> References: <295e750a0601311237y6292e8e3sfaf05a75aaebc744@mail.gmail.com> <3581AA168D87A2479D88EA319BDF7D32010FF377@RED-MSG-80.redmond.corp.microsoft.com> <44D3B0A2.9040101@gmail.com> Message-ID: __slots__ = [ "StartElementHandler", "EndElementHandler", "CharacterDataHandler", ] gives an error On 8/5/06, Mark Rees wrote: > > Hi, > > Seo has already done a basic pyexpat wrapper. He posted about it in: > > > http://lists.ironpython.com/pipermail/users-ironpython.com/2005-November/001227.html > > And it can be found at: > > http://sparcs.kaist.ac.kr/~tinuviel/fepy/old/pyexpat.py > > I have used this with ElementTree. There are limitations like iterparse > doesn't work and if the XML you are parsing contains an empty element > i.e it fails. I have modified Seo's pyexpat.py to handle the > second limitation and have included the source in this email. I have > used this for my elementtree requirements but the XML I parse is simple > so there may be other as yet undiscovered issues. > > Regards > > Mark > > Modified version of pyexpat from > http://sparcs.kaist.ac.kr/~tinuviel/fepy/old/pyexpat.py > > > import clr > clr.AddReference("System.Xml") > > from System.IO import MemoryStream, SeekOrigin, StreamWriter > from System.Xml import NameTable, XmlNamespaceManager, XmlParserContext, > XmlSpace > from System.Xml import XmlTextReader, XmlNodeType > > def ErrorString(errno): > if errno > 0: > return "unknown error" > else: > return None > > def ParserCreate(*args): > return xmlparser() > > class xmlparser: > > __slots__ = [ > "StartElementHandler", > "EndElementHandler", > "CharacterDataHandler", > ] > > returns_unicode = False > > def __init__(self): > self._stream = MemoryStream() > self._parser = self._make_parser() > > def Parse(self, data, isfinal=False): > self._append_stream(data) > self._parse() > if isfinal: > self._stream.Close() > > def _make_parser(self): > table = NameTable() > manager = XmlNamespaceManager(table) > parser = XmlParserContext(table, manager, None, XmlSpace.None) > return parser > > def _append_stream(self, data): > stream = self._stream > position = stream.Position > stream.Seek(0, SeekOrigin.End) > writer = StreamWriter(stream) > writer.Write(data) > writer.Flush() > stream.Position = position > > def _parse(self): > reader = XmlTextReader(self._stream, XmlNodeType.Element, > self._parser) > while reader.Read(): > nodetype = reader.NodeType > if nodetype == XmlNodeType.Element: > name = reader.Name > attributes = {} > while reader.MoveToNextAttribute(): > attributes[reader.Name] = reader.Value > if hasattr(self, "StartElementHandler"): > self.StartElementHandler(name, attributes) > # Create EndElement event as XmlTextReader doesn't > # do this for empty elements > if reader.IsEmptyElement: > nodetype = XmlNodeType.EndElement > if nodetype == XmlNodeType.EndElement: > name = reader.Name > if hasattr(self, "EndElementHandler"): > self.EndElementHandler(name) > elif nodetype == XmlNodeType.Text: > data = reader.Value > if hasattr(self, "CharacterDataHandler"): > self.CharacterDataHandler(data) > > > > > > > Monty Taylor wrote: > > You could write a Python or C# wrapper around System.XML that behaves > > like pyexpat and contribute it. :) > > > > Monty > > > > On 8/4/06, Bruce Christensen wrote: > > > >> Nope. :) pyexpat relies on Python extension modules written in C, which > >> don't work with IronPython. However, you can use the classes in the > .NET > >> System.Xml namespace for parsing XML documents if you're writing new > >> code. > >> > >> --Bruce > >> > >> -----Original Message----- > >> From: users-bounces at lists.ironpython.com > >> [mailto:users-bounces at lists.ironpython.com] On Behalf Of Sridevi > >> Sent: Thursday, August 03, 2006 5:41 AM > >> To: users-ironpython.com at lists.ironpython.com > >> Subject: [IronPython] pyexpat and IronPython > >> > >> Iam unable to run pyexpat from IronPython > >> Is there any files i got to add for it > >> > >> _______________________________________________ > >> users mailing list > >> users at lists.ironpython.com > >> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > >> _______________________________________________ > >> users mailing list > >> users at lists.ironpython.com > >> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > >> > >> > > _______________________________________________ > > users mailing list > > users at lists.ironpython.com > > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > > > > > > _______________________________________________ > users mailing list > users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > -------------- next part -------------- An HTML attachment was scrubbed... URL: From dinov at exchange.microsoft.com Tue Aug 8 17:11:32 2006 From: dinov at exchange.microsoft.com (Dino Viehland) Date: Tue, 8 Aug 2006 08:11:32 -0700 Subject: [IronPython] pyexpat and IronPython In-Reply-To: References: <295e750a0601311237y6292e8e3sfaf05a75aaebc744@mail.gmail.com> <3581AA168D87A2479D88EA319BDF7D32010FF377@RED-MSG-80.redmond.corp.microsoft.com> <44D3B0A2.9040101@gmail.com> Message-ID: <7AD436E4270DD54A94238001769C22272FA04AFBAC@DF-GRTDANE-MSG.exchange.corp.microsoft.com> Do you mean copying & pasting this to the console? Or is this some issue you run into when actually using pyexpat? From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Sridevi Aishwariya Sent: Monday, August 07, 2006 9:47 PM To: Discussion of IronPython Subject: Re: [IronPython] pyexpat and IronPython __slots__ = [ "StartElementHandler", "EndElementHandler", "CharacterDataHandler", ] gives an error On 8/5/06, Mark Rees > wrote: Hi, Seo has already done a basic pyexpat wrapper. He posted about it in: http://lists.ironpython.com/pipermail/users-ironpython.com/2005-November/001227.html And it can be found at: http://sparcs.kaist.ac.kr/~tinuviel/fepy/old/pyexpat.py I have used this with ElementTree. There are limitations like iterparse doesn't work and if the XML you are parsing contains an empty element i.e it fails. I have modified Seo's pyexpat.py to handle the second limitation and have included the source in this email. I have used this for my elementtree requirements but the XML I parse is simple so there may be other as yet undiscovered issues. Regards Mark Modified version of pyexpat from http://sparcs.kaist.ac.kr/~tinuviel/fepy/old/pyexpat.py import clr clr.AddReference(" System.Xml") from System.IO import MemoryStream, SeekOrigin, StreamWriter from System.Xml import NameTable, XmlNamespaceManager, XmlParserContext, XmlSpace from System.Xml import XmlTextReader, XmlNodeType def ErrorString(errno): if errno > 0: return "unknown error" else: return None def ParserCreate(*args): return xmlparser() class xmlparser: __slots__ = [ "StartElementHandler", "EndElementHandler", "CharacterDataHandler", ] returns_unicode = False def __init__(self): self._stream = MemoryStream() self._parser = self._make_parser() def Parse(self, data, isfinal=False): self._append_stream(data) self._parse() if isfinal: self._stream.Close() def _make_parser(self): table = NameTable() manager = XmlNamespaceManager(table) parser = XmlParserContext(table, manager, None, XmlSpace.None) return parser def _append_stream(self, data): stream = self._stream position = stream.Position stream.Seek(0, SeekOrigin.End) writer = StreamWriter(stream) writer.Write(data) writer.Flush() stream.Position = position def _parse(self): reader = XmlTextReader(self._stream, XmlNodeType.Element, self._parser) while reader.Read(): nodetype = reader.NodeType if nodetype == XmlNodeType.Element: name = reader.Name attributes = {} while reader.MoveToNextAttribute(): attributes[reader.Name] = reader.Value if hasattr(self, "StartElementHandler"): self.StartElementHandler(name, attributes) # Create EndElement event as XmlTextReader doesn't # do this for empty elements if reader.IsEmptyElement : nodetype = XmlNodeType.EndElement if nodetype == XmlNodeType.EndElement: name = reader.Name if hasattr(self, "EndElementHandler"): self.EndElementHandler(name) elif nodetype == XmlNodeType.Text: data = reader.Value if hasattr(self, "CharacterDataHandler"): self.CharacterDataHandler (data) Monty Taylor wrote: > You could write a Python or C# wrapper around System.XML that behaves > like pyexpat and contribute it. :) > > Monty > > On 8/4/06, Bruce Christensen < t-bruch at microsoft.com> wrote: > >> Nope. :) pyexpat relies on Python extension modules written in C, which >> don't work with IronPython. However, you can use the classes in the .NET >> System.Xml namespace for parsing XML documents if you're writing new >> code. >> >> --Bruce >> >> -----Original Message----- >> From: users-bounces at lists.ironpython.com >> [mailto:users-bounces at lists.ironpython.com] On Behalf Of Sridevi >> Sent: Thursday, August 03, 2006 5:41 AM >> To: users-ironpython.com at lists.ironpython.com >> Subject: [IronPython] pyexpat and IronPython >> >> Iam unable to run pyexpat from IronPython >> Is there any files i got to add for it >> >> _______________________________________________ >> users mailing list >> users at lists.ironpython.com >> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com >> _______________________________________________ >> users mailing list >> users at lists.ironpython.com >> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com >> >> > _______________________________________________ > users mailing list > users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > > _______________________________________________ users mailing list users at lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From Martin.Maly at microsoft.com Tue Aug 8 19:05:37 2006 From: Martin.Maly at microsoft.com (Martin Maly) Date: Tue, 8 Aug 2006 10:05:37 -0700 Subject: [IronPython] producing exe's In-Reply-To: <51c8a7be0608071110w7fe94dd3xb2d248a09772d55e@mail.gmail.com> References: <51c8a7be0608071110w7fe94dd3xb2d248a09772d55e@mail.gmail.com> Message-ID: Yes, that's correct. The -X:SaveAssemblies flag is mainly for debugging purposes. If you need to produce an exe, the recommended way is to use the IronPython.Hosting.PythonCompiler class which allows you to set the type of assembly among other things. Martin ________________________________ From: users-bounces at lists.ironpython.com On Behalf Of jeff sacksteder Sent: Monday, August 07, 2006 11:10 AM To: users at lists.ironpython.com Subject: [IronPython] producing exe's If I make exe's like this- ipyw.exe -X:SaveAssemblies myscript.py I still get the console window. Is this correct? -------------- next part -------------- An HTML attachment was scrubbed... URL: From rodolfoconde at saitosoft.com Tue Aug 8 22:14:00 2006 From: rodolfoconde at saitosoft.com (Rodolfo Conde) Date: Tue, 8 Aug 2006 14:14:00 -0600 Subject: [IronPython] producing exe's References: <51c8a7be0608071110w7fe94dd3xb2d248a09772d55e@mail.gmail.com> Message-ID: <004c01c6bb27$31290b90$1216a8c0@RCONDE> Hi all, first mail on the list :)... Do you mean you have do make a little program with IronPython.Hosting.PythonCompiler class to make your assembly ?? Doest have the ipy.exe console an option for this purpose ?? Greetings... ----- Original Message ----- From: Martin Maly To: Discussion of IronPython Sent: Tuesday, August 08, 2006 11:05 AM Subject: Re: [IronPython] producing exe's Yes, that's correct. The -X:SaveAssemblies flag is mainly for debugging purposes. If you need to produce an exe, the recommended way is to use the IronPython.Hosting.PythonCompiler class which allows you to set the type of assembly among other things. Martin ------------------------------------------------------------------------------ From: users-bounces at lists.ironpython.com On Behalf Of jeff sacksteder Sent: Monday, August 07, 2006 11:10 AM To: users at lists.ironpython.com Subject: [IronPython] producing exe's If I make exe's like this- ipyw.exe -X:SaveAssemblies myscript.py I still get the console window. Is this correct? __________ Informaci?n de NOD32, revisi?n 1.1696 (20060807) __________ Este mensaje ha sido analizado con NOD32 antivirus system http://www.nod32.com ------------------------------------------------------------------------------ _______________________________________________ users mailing list users at lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com __________ Informaci?n de NOD32, revisi?n 1.1696 (20060807) __________ Este mensaje ha sido analizado con NOD32 antivirus system http://www.nod32.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From rdawson at exchange.microsoft.com Tue Aug 8 20:37:07 2006 From: rdawson at exchange.microsoft.com (Ryan Dawson) Date: Tue, 8 Aug 2006 11:37:07 -0700 Subject: [IronPython] importing C# functions In-Reply-To: References: <1154777809.185342.241920@h48g2000cwc.googlegroups.com> <20060805130157.861771BB57@che.dreamhost.com> Message-ID: <50B69702CA6E6D4E849D30CD4989AB8E2A4A6A5BFB@DF-GRTDANE-MSG.exchange.corp.microsoft.com> It may be I'm misunderstanding the question, but I believe you're asking for something like this: using System; using IronPython.Hosting; class Test{ public static void Main(){ Test t = new Test(); PythonEngine pe = new PythonEngine(); Del d = new Del(t.AddIt); pe.Globals["AddIt"] = d; int result = pe.EvaluateAs("AddIt(3,2)"); Console.WriteLine("Result = {0}",result); } delegate int Del(int a, int b); public int AddIt(int a, int b){ return a+b; } } This is, at runtime, adding the method AddIt into the default module for the hosted engine and making it callable via IronPython code. This is essentially the same as your suggested "AddMethod" API. The method added certainly does not have to be static. Further, I added it to the default module, but you have similar access to the globals of any module. Hope that helps, -Ryan -----Original Message----- From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Slide Sent: Saturday, August 05, 2006 11:50 AM To: Discussion of IronPython Subject: Re: [IronPython] importing C# functions So I just need to make sure my functions are static? The main goal of this was to allow runtime addition of functions for a module. I was hoping to do something like EngineModule mod = _engine.CreateModule("mymodule", true); mod.AddMethod(someObject, "mymethod", someDelegate); Then I would be able to call mymodule.mymethod inside of python scripts, but I guess that might be a pipe dream. thanks slide On 8/5/06, Stefan Rusek wrote: > Tell him to look into using IronPython instead of normal python. IP is > written completely in C# and has really good .net support, and he > should be able to declare a static method and use it like normal function in python. > > --Stefan > > -----Original Message----- > From: users-bounces at lists.ironpython.com > [mailto:users-bounces at lists.ironpython.com] On Behalf Of Michael Foord > Sent: Saturday, August 05, 2006 7:37 AM > To: users at lists.ironpython.com > Subject: Re: [IronPython] importing C# functions > > > Slide wrote: > > I am currently adding a scripting console to one of the applications > > I develop. I would like to, at runtime, add functions that can be > > called by the python code in the console. Something like > > > > // c# > > public int AddIt(int a, int b) > > { > > return a + b; > > } > > > > Does C# allow you to define functions outside of objects ? I didn't > think so... > > You can create static methods on objects though. > > > then, I would like to add that function (and possibly functions from > > plugins) so they can be called from python. Do I need to create a > > module and add the functions to the module? Is there a better way? > > > > For an example of creating a dll from C#, and then accessing from > IronPython, see : > > http://www.voidspace.org.uk/python/weblog/arch_d7_2006_07_29.shtml#e40 > 6 > > All the best, > > Fuzzyman > http://www.voidspace.org.uk/python/index.shtml > > > Thanks, > > > > slide > > _______________________________________________ > > users mailing list > > users at lists.ironpython.com > > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > > _______________________________________________ > users mailing list > users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > > _______________________________________________ > users mailing list > users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > _______________________________________________ users mailing list users at lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com From Martin.Maly at microsoft.com Tue Aug 8 22:39:48 2006 From: Martin.Maly at microsoft.com (Martin Maly) Date: Tue, 8 Aug 2006 13:39:48 -0700 Subject: [IronPython] producing exe's In-Reply-To: <004c01c6bb27$31290b90$1216a8c0@RCONDE> Message-ID: Nope, ipy.exe does not have the option to do that. Since its main purpose is to be the command line console to a large degree compatible with CPython, we didn't expose the functionality through ipy.exe. Martin ________________________________ From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Rodolfo Conde Sent: Tuesday, August 08, 2006 1:14 PM To: Discussion of IronPython Subject: Re: [IronPython] producing exe's Hi all, first mail on the list :)... Do you mean you have do make a little program with IronPython.Hosting.PythonCompiler class to make your assembly ?? Doest have the ipy.exe console an option for this purpose ?? Greetings... ----- Original Message ----- From: Martin Maly To: Discussion of IronPython Sent: Tuesday, August 08, 2006 11:05 AM Subject: Re: [IronPython] producing exe's Yes, that's correct. The -X:SaveAssemblies flag is mainly for debugging purposes. If you need to produce an exe, the recommended way is to use the IronPython.Hosting.PythonCompiler class which allows you to set the type of assembly among other things. Martin ________________________________ From: users-bounces at lists.ironpython.com On Behalf Of jeff sacksteder Sent: Monday, August 07, 2006 11:10 AM To: users at lists.ironpython.com Subject: [IronPython] producing exe's If I make exe's like this- ipyw.exe -X:SaveAssemblies myscript.py I still get the console window. Is this correct? __________ Informaci?n de NOD32, revisi?n 1.1696 (20060807) __________ Este mensaje ha sido analizado con NOD32 antivirus system http://www.nod32.com ________________________________ _______________________________________________ users mailing list users at lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com __________ Informaci?n de NOD32, revisi?n 1.1696 (20060807) __________ Este mensaje ha sido analizado con NOD32 antivirus system http://www.nod32.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From textdirected at gmail.com Wed Aug 9 01:30:51 2006 From: textdirected at gmail.com (HEMMI, Shigeru) Date: Wed, 9 Aug 2006 08:30:51 +0900 Subject: [IronPython] Bug of big integer manipulation Message-ID: Hello, NZMATH is a Python based number theory oriented calculation system developed by Tokyo Metropolitan University. The URL is http://tnt.math.metro-u.ac.jp/nzmath/. Using NZMATH, I encounterd a bug of big integer manipulation. IronPython ============================ C:\IronPython-2604>ipy IronPython 1.0.2411 on .NET 2.0.50727.42 Copyright (c) Microsoft Corporation. All rights reserved. >>> import sys >>> sys.path.append(r'C:\Python24\Lib') >>> sys.path.append(r'C:\Python24\Lib\site-packages') >>> from nzmath import prime >>> prime.nextPrime(256) 257 >>> nx = sys.maxint >>> prime.nextPrime(nx*nx) Traceback (most recent call last): File , line 0, in ##115 File C:\Python24\Lib\site-packages\nzmath\prime.py, line 158, in nextPrime File C:\Python24\Lib\site-packages\nzmath\prime.py, line 206, in primeq File C:\Python24\Lib\site-packages\nzmath\prime.py, line 188, in smallSpsp File C:\Python24\Lib\site-packages\nzmath\prime.py, line 41, in spsp ValueError: value too big >>> prime.nextPrime(nx) ## Seems going into infinite loop. CPython ============================ C:\IronPython-2604>python Python 2.4.3 (#69, Mar 29 2006, 17:35:34) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import sys >>> from nzmath import prime >>> nx = sys.maxint >>> prime.nextPrime(nx*nx) 4611686014132420667L >>> prime.nextPrime(nx) 2147483659L >>> Regards, From slide.o.mix at gmail.com Wed Aug 9 02:56:56 2006 From: slide.o.mix at gmail.com (Slide) Date: Tue, 8 Aug 2006 17:56:56 -0700 Subject: [IronPython] importing C# functions In-Reply-To: <50B69702CA6E6D4E849D30CD4989AB8E2A4A6A5BFB@DF-GRTDANE-MSG.exchange.corp.microsoft.com> References: <1154777809.185342.241920@h48g2000cwc.googlegroups.com> <20060805130157.861771BB57@che.dreamhost.com> <50B69702CA6E6D4E849D30CD4989AB8E2A4A6A5BFB@DF-GRTDANE-MSG.exchange.corp.microsoft.com> Message-ID: Ah, so the IP runtime will automatically invoke delegates. That is exactly what I am looking for. Thanks! On 8/8/06, Ryan Dawson wrote: > It may be I'm misunderstanding the question, but I believe you're asking for something like this: > > using System; > using IronPython.Hosting; > > class Test{ > public static void Main(){ > Test t = new Test(); > PythonEngine pe = new PythonEngine(); > > Del d = new Del(t.AddIt); > pe.Globals["AddIt"] = d; > > int result = pe.EvaluateAs("AddIt(3,2)"); > Console.WriteLine("Result = {0}",result); > } > > delegate int Del(int a, int b); > public int AddIt(int a, int b){ > return a+b; > } > } > > This is, at runtime, adding the method AddIt into the default module for the hosted engine and making it callable via IronPython code. This is essentially the same as your suggested "AddMethod" API. > > The method added certainly does not have to be static. Further, I added it to the default module, but you have similar access to the globals of any module. > > Hope that helps, > -Ryan > > > > -----Original Message----- > From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Slide > Sent: Saturday, August 05, 2006 11:50 AM > To: Discussion of IronPython > Subject: Re: [IronPython] importing C# functions > > So I just need to make sure my functions are static? The main goal of this was to allow runtime addition of functions for a module. I was hoping to do something like > > EngineModule mod = _engine.CreateModule("mymodule", true); > > mod.AddMethod(someObject, "mymethod", someDelegate); > > Then I would be able to call mymodule.mymethod inside of python scripts, but I guess that might be a pipe dream. > > thanks > > slide > > > On 8/5/06, Stefan Rusek wrote: > > Tell him to look into using IronPython instead of normal python. IP is > > written completely in C# and has really good .net support, and he > > should be able to declare a static method and use it like normal function in python. > > > > --Stefan > > > > -----Original Message----- > > From: users-bounces at lists.ironpython.com > > [mailto:users-bounces at lists.ironpython.com] On Behalf Of Michael Foord > > Sent: Saturday, August 05, 2006 7:37 AM > > To: users at lists.ironpython.com > > Subject: Re: [IronPython] importing C# functions > > > > > > Slide wrote: > > > I am currently adding a scripting console to one of the applications > > > I develop. I would like to, at runtime, add functions that can be > > > called by the python code in the console. Something like > > > > > > // c# > > > public int AddIt(int a, int b) > > > { > > > return a + b; > > > } > > > > > > > Does C# allow you to define functions outside of objects ? I didn't > > think so... > > > > You can create static methods on objects though. > > > > > then, I would like to add that function (and possibly functions from > > > plugins) so they can be called from python. Do I need to create a > > > module and add the functions to the module? Is there a better way? > > > > > > > For an example of creating a dll from C#, and then accessing from > > IronPython, see : > > > > http://www.voidspace.org.uk/python/weblog/arch_d7_2006_07_29.shtml#e40 > > 6 > > > > All the best, > > > > Fuzzyman > > http://www.voidspace.org.uk/python/index.shtml > > > > > Thanks, > > > > > > slide > > > _______________________________________________ > > > users mailing list > > > users at lists.ironpython.com > > > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > > > > _______________________________________________ > > users mailing list > > users at lists.ironpython.com > > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > > > > _______________________________________________ > > users mailing list > > users at lists.ironpython.com > > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > > > _______________________________________________ > users mailing list > users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > _______________________________________________ > users mailing list > users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > From brian at sweetapp.com Thu Aug 10 06:31:42 2006 From: brian at sweetapp.com (Brian Quinlan) Date: Wed, 09 Aug 2006 21:31:42 -0700 Subject: [IronPython] Pong! In-Reply-To: References: Message-ID: <44DAB6AE.1080401@sweetapp.com> I wrote a simple pong implementation using IronPython and Avalon/XAML. See: http://www.sweetapp.com/avalon/ipong.html Cheers, Brian From Martin.Maly at microsoft.com Thu Aug 10 06:53:14 2006 From: Martin.Maly at microsoft.com (Martin Maly) Date: Wed, 9 Aug 2006 21:53:14 -0700 Subject: [IronPython] Bug of big integer manipulation In-Reply-To: References: Message-ID: By any chance, were you able to determine which operation caused the exception and which numbers were involved? What would help me find out what the problem is faster would be get a call stack (for that, could you please run your repro with -X:ExceptionDetail switch? Then ideally if you could find out what the big integer numbers were with which the operation failed, that would be ideal. Thanks! Martin -----Original Message----- From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of HEMMI, Shigeru Sent: Tuesday, August 08, 2006 4:31 PM To: Discussion of IronPython Subject: [IronPython] Bug of big integer manipulation Hello, NZMATH is a Python based number theory oriented calculation system developed by Tokyo Metropolitan University. The URL is http://tnt.math.metro-u.ac.jp/nzmath/. Using NZMATH, I encounterd a bug of big integer manipulation. IronPython ============================ C:\IronPython-2604>ipy IronPython 1.0.2411 on .NET 2.0.50727.42 Copyright (c) Microsoft Corporation. All rights reserved. >>> import sys >>> sys.path.append(r'C:\Python24\Lib') >>> sys.path.append(r'C:\Python24\Lib\site-packages') >>> from nzmath import prime >>> prime.nextPrime(256) 257 >>> nx = sys.maxint >>> prime.nextPrime(nx*nx) Traceback (most recent call last): File , line 0, in ##115 File C:\Python24\Lib\site-packages\nzmath\prime.py, line 158, in nextPrime File C:\Python24\Lib\site-packages\nzmath\prime.py, line 206, in primeq File C:\Python24\Lib\site-packages\nzmath\prime.py, line 188, in smallSpsp File C:\Python24\Lib\site-packages\nzmath\prime.py, line 41, in spsp ValueError: value too big >>> prime.nextPrime(nx) ## Seems going into infinite loop. CPython ============================ C:\IronPython-2604>python Python 2.4.3 (#69, Mar 29 2006, 17:35:34) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import sys >>> from nzmath import prime >>> nx = sys.maxint >>> prime.nextPrime(nx*nx) 4611686014132420667L >>> prime.nextPrime(nx) 2147483659L >>> Regards, _______________________________________________ users mailing list users at lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com From textdirected at gmail.com Thu Aug 10 10:37:48 2006 From: textdirected at gmail.com (HEMMI, Shigeru) Date: Thu, 10 Aug 2006 17:37:48 +0900 Subject: [IronPython] Bug of big integer manipulation In-Reply-To: References: Message-ID: Thanks for the answer. I was able to take a log with -X:ExceptionDetail, but since Japanese, log file includes Japanse characters; I removed them by hand. I was not able to which numbers were involved. The log file is attached. Please note that there are two problems; one is "ValueError: value too big" problem which we do not encounter with CPython. The other is an infinite loop bug. Please also note that NZMATH is pure python, having simple module structure and we will be able to duplicate the problem if you download it. Best regards, 2006/8/10, Martin Maly : > By any chance, were you able to determine which operation caused the exception and which numbers were involved? What would help me find out what the problem is faster would be get a call stack (for that, could you please run your repro with -X:ExceptionDetail switch? Then ideally if you could find out what the big integer numbers were with which the operation failed, that would be ideal. > > Thanks! > Martin > > -----Original Message----- > From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of HEMMI, Shigeru > Sent: Tuesday, August 08, 2006 4:31 PM > To: Discussion of IronPython > Subject: [IronPython] Bug of big integer manipulation > > Hello, > > NZMATH is a Python based number theory oriented calculation system developed by Tokyo Metropolitan University. The URL is http://tnt.math.metro-u.ac.jp/nzmath/. > > Using NZMATH, I encounterd a bug of big integer manipulation. > > IronPython > ============================ > C:\IronPython-2604>ipy > IronPython 1.0.2411 on .NET 2.0.50727.42 Copyright (c) Microsoft Corporation. All rights reserved. > >>> import sys > >>> sys.path.append(r'C:\Python24\Lib') > >>> sys.path.append(r'C:\Python24\Lib\site-packages') > >>> from nzmath import prime > >>> prime.nextPrime(256) > 257 > >>> nx = sys.maxint > >>> prime.nextPrime(nx*nx) > Traceback (most recent call last): > File , line 0, in ##115 > File C:\Python24\Lib\site-packages\nzmath\prime.py, line 158, in nextPrime > File C:\Python24\Lib\site-packages\nzmath\prime.py, line 206, in primeq > File C:\Python24\Lib\site-packages\nzmath\prime.py, line 188, in smallSpsp > File C:\Python24\Lib\site-packages\nzmath\prime.py, line 41, in spsp > ValueError: value too big > >>> prime.nextPrime(nx) ## Seems going into infinite loop. > > CPython > ============================ > C:\IronPython-2604>python > Python 2.4.3 (#69, Mar 29 2006, 17:35:34) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. > >>> import sys > >>> from nzmath import prime > >>> nx = sys.maxint > >>> prime.nextPrime(nx*nx) > 4611686014132420667L > >>> prime.nextPrime(nx) > 2147483659L > >>> > > Regards, > _______________________________________________ > users mailing list > users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > _______________________________________________ > users mailing list > users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > -------------- next part -------------- A non-text attachment was scrubbed... Name: IpyBugOfBigIntegerManipulation.log Type: application/octet-stream Size: 6417 bytes Desc: not available URL: From textdirected at gmail.com Thu Aug 10 10:46:18 2006 From: textdirected at gmail.com (HEMMI, Shigeru) Date: Thu, 10 Aug 2006 17:46:18 +0900 Subject: [IronPython] Bug of big integer manipulation In-Reply-To: References: Message-ID: I wrote: > The log file is attached. Sorry, "A non-text attachment was scrubbed..." occured. I resend the attachment file again with .txt extension. -------------- next part -------------- C:\NZMATH-0.5.1>dir 2006/08/10 17:28 . 2006/08/10 17:28 .. 2006/08/08 20:42 4,214 CHANGES.txt 2006/08/08 20:42 835 HISTORY.txt 2006/08/10 17:16 61,440 ipy.exe 2006/08/10 17:16 45,056 IronMath.dll 2006/08/10 17:16 1,527,808 IronPython.dll 2006/08/08 20:42 1,563 LICENSE.txt 2006/08/08 20:42 manual 2006/08/08 20:42 nzmath 2006/08/08 20:42 288 PKG-INFO 2006/08/08 20:42 1,916 README.txt 2006/08/08 20:42 5,466 setup.py 2006/08/08 20:42 5,428 tutorial.txt C:\NZMATH-0.5.1>ipy -X:ExceptionDetail IronPython 1.0.2413 on .NET 2.0.50727.42 Copyright (c) Microsoft Corporation. All rights reserved. >>> import sys >>> sys.path.append(r'C:\Python24\Lib') >>> from nzmath import prime >>> nx = sys.maxint >>> mx = nx*nx >>> mx 4611686014132420609L >>> prime.nextPrime(mx) value too big IronPython.Runtime.Operations.LongOps.PowerMod(BigInteger x, Object y, Object z) IronPython.Runtime.Operations.IntOps.PowerMod(Int32 x, Object y, Objectz) IronPython.Runtime.Operations.Ops.PowerMod(Object x, Object y, Object z) IronPython.Modules.Builtin.Pow(Object x, Object y, Object z) IronPython.Runtime.Calls.FastCallableAny.Call(ICallerContext context, Object arg0, Object arg1, Object arg2) IronPython.Runtime.Calls.BuiltinFunction.Call(ICallerContext context, Object arg0, Object arg1, Object arg2) IronPython.Runtime.Operations.Ops.CallWithContext(ICallerContext context, Object func, Object arg0, Object arg1, Object arg2) nzmath.prime.spsp$f1(Object n, Object base, Object s, Object t) C:\NZMATH-0.5.1\nzmath\prime.py:line 43 IronPython.Runtime.Calls.Function4.Call(ICallerContext context, Object arg0, Object arg1) IronPython.Runtime.Operations.Ops.CallWithContext(ICallerContext context, Object func, Object arg0, Object arg1) nzmath.prime.smallSpsp$f17(Object n) C:\NZMATH-0.5.1\nzmath\prime.py:line 278 IronPython.Runtime.Calls.Function1.Call(ICallerContext context, Object arg0) IronPython.Runtime.Operations.Ops.CallWithContext(ICallerContext context, Object func, Object arg0) nzmath.prime.primeq$f18(Object n) C:\NZMATH-0.5.1\nzmath\prime.py:line 297 IronPython.Runtime.Calls.Function1.Call(ICallerContext context, Object arg0) IronPython.Runtime.Operations.Ops.CallWithContext(ICallerContext context, Object func, Object arg0) nzmath.prime.nextPrime$f15(Object n) C:\NZMATH-0.5.1\nzmath\prime.py:line 246 IronPython.Runtime.Calls.Function1.Call(ICallerContext context, Object arg0) IronPython.Runtime.Operations.Ops.CallWithContext(ICallerContext context, Object func, Object arg0) ##114(ModuleScope ) IronPython.Hosting.CompiledCodeDelegate.Invoke(ModuleScope moduleScope) IronPython.Hosting.CompiledCode.Run(ModuleScope moduleScope) IronPython.Hosting.PythonEngine.ExecuteToConsole(String text, EngineModule engineModule, IDictionary`2 locals) IronPython.Hosting.PythonEngine.ExecuteToConsole(String text) IronPythonConsole.PythonCommandLine.DoOneInteractive() IronPythonConsole.PythonCommandLine.b__6(Boolean& continueInteractionArgument) IronPythonConsole.PythonCommandLine.TryInteractiveAction(InteractiveAction interactiveAction, Boolean& continueInteraction) ValueError: value too big >>> prime.nextPrime(nx) ********** Going into an infinite loop; Interrupt with Ctrl+C *********** IronMath.BigInteger.op_Multiply(BigInteger x, BigInteger y) IronMath.BigInteger.Square() IronMath.BigInteger.ModPow(Int32 power, BigInteger mod) IronPython.Runtime.Operations.LongOps.PowerMod(BigInteger x, Int32 y, BigInteger z) IronPython.Runtime.Operations.LongOps.PowerMod(BigInteger x, Int32 y, Object z) IronPython.Runtime.Operations.LongOps.PowerMod(BigInteger x, Object y, Object z) IronPython.Runtime.Operations.IntOps.PowerMod(Int32 x, Object y, Objectz) IronPython.Runtime.Operations.Ops.PowerMod(Object x, Object y, Object z) IronPython.Modules.Builtin.Pow(Object x, Object y, Object z) IronPython.Runtime.Calls.FastCallableAny.Call(ICallerContext context, Object arg0, Object arg1, Object arg2) IronPython.Runtime.Calls.BuiltinFunction.Call(ICallerContext context, Object arg0, Object arg1, Object arg2) IronPython.Runtime.Operations.Ops.CallWithContext(ICallerContext context, Object func, Object arg0, Object arg1, Object arg2) nzmath.prime.spsp$f1(Object n, Object base, Object s, Object t) C:\NZMATH-0.5.1\nzmath\prime.py:line 43 IronPython.Runtime.Calls.Function4.Call(ICallerContext context, Object arg0, Object arg1) IronPython.Runtime.Operations.Ops.CallWithContext(ICallerContext context, Object func, Object arg0, Object arg1) nzmath.prime.smallSpsp$f17(Object n) C:\NZMATH-0.5.1\nzmath\prime.py:line 278 IronPython.Runtime.Calls.Function1.Call(ICallerContext context, Object arg0) IronPython.Runtime.Operations.Ops.CallWithContext(ICallerContext context, Object func, Object arg0) nzmath.prime.primeq$f18(Object n) C:\NZMATH-0.5.1\nzmath\prime.py:line 297 IronPython.Runtime.Calls.Function1.Call(ICallerContext context, Object arg0) IronPython.Runtime.Operations.Ops.CallWithContext(ICallerContext context, Object func, Object arg0) nzmath.prime.nextPrime$f15(Object n) C:\NZMATH-0.5.1\nzmath\prime.py:line 246 IronPython.Runtime.Calls.Function1.Call(ICallerContext context, Object arg0) IronPython.Runtime.Operations.Ops.CallWithContext(ICallerContext context, Object func, Object arg0) ##118(ModuleScope ) IronPython.Hosting.CompiledCodeDelegate.Invoke(ModuleScope moduleScope) IronPython.Hosting.CompiledCode.Run(ModuleScope moduleScope) IronPython.Hosting.PythonEngine.ExecuteToConsole(String text, EngineModule engineModule, IDictionary`2 locals) IronPython.Hosting.PythonEngine.ExecuteToConsole(String text) IronPythonConsole.PythonCommandLine.DoOneInteractive() IronPythonConsole.PythonCommandLine.b__6(Boolean& continueInteractionArgument) IronPythonConsole.PythonCommandLine.TryInteractiveAction(InteractiveAction interactiveAction, Boolean& continueInteraction) KeyboardInterrupt: >>> From Martin.Maly at microsoft.com Thu Aug 10 17:25:57 2006 From: Martin.Maly at microsoft.com (Martin Maly) Date: Thu, 10 Aug 2006 08:25:57 -0700 Subject: [IronPython] Bug of big integer manipulation In-Reply-To: References: Message-ID: This is a current limitation of IronPython implementation. I am filing it as a bug for us to seriously investigate. Thanks for your help with the repro! Martin -----Original Message----- From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of HEMMI, Shigeru Sent: Thursday, August 10, 2006 1:38 AM To: Discussion of IronPython Subject: Re: [IronPython] Bug of big integer manipulation Thanks for the answer. I was able to take a log with -X:ExceptionDetail, but since Japanese, log file includes Japanse characters; I removed them by hand. I was not able to which numbers were involved. The log file is attached. Please note that there are two problems; one is "ValueError: value too big" problem which we do not encounter with CPython. The other is an infinite loop bug. Please also note that NZMATH is pure python, having simple module structure and we will be able to duplicate the problem if you download it. Best regards, 2006/8/10, Martin Maly : > By any chance, were you able to determine which operation caused the exception and which numbers were involved? What would help me find out what the problem is faster would be get a call stack (for that, could you please run your repro with -X:ExceptionDetail switch? Then ideally if you could find out what the big integer numbers were with which the operation failed, that would be ideal. > > Thanks! > Martin > > -----Original Message----- > From: users-bounces at lists.ironpython.com > [mailto:users-bounces at lists.ironpython.com] On Behalf Of HEMMI, > Shigeru > Sent: Tuesday, August 08, 2006 4:31 PM > To: Discussion of IronPython > Subject: [IronPython] Bug of big integer manipulation > > Hello, > > NZMATH is a Python based number theory oriented calculation system developed by Tokyo Metropolitan University. The URL is http://tnt.math.metro-u.ac.jp/nzmath/. > > Using NZMATH, I encounterd a bug of big integer manipulation. > > IronPython > ============================ > C:\IronPython-2604>ipy > IronPython 1.0.2411 on .NET 2.0.50727.42 Copyright (c) Microsoft Corporation. All rights reserved. > >>> import sys > >>> sys.path.append(r'C:\Python24\Lib') > >>> sys.path.append(r'C:\Python24\Lib\site-packages') > >>> from nzmath import prime > >>> prime.nextPrime(256) > 257 > >>> nx = sys.maxint > >>> prime.nextPrime(nx*nx) > Traceback (most recent call last): > File , line 0, in ##115 > File C:\Python24\Lib\site-packages\nzmath\prime.py, line 158, in nextPrime > File C:\Python24\Lib\site-packages\nzmath\prime.py, line 206, in primeq > File C:\Python24\Lib\site-packages\nzmath\prime.py, line 188, in smallSpsp > File C:\Python24\Lib\site-packages\nzmath\prime.py, line 41, in spsp > ValueError: value too big > >>> prime.nextPrime(nx) ## Seems going into infinite loop. > > CPython > ============================ > C:\IronPython-2604>python > Python 2.4.3 (#69, Mar 29 2006, 17:35:34) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. > >>> import sys > >>> from nzmath import prime > >>> nx = sys.maxint > >>> prime.nextPrime(nx*nx) > 4611686014132420667L > >>> prime.nextPrime(nx) > 2147483659L > >>> > > Regards, > _______________________________________________ > users mailing list > users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > _______________________________________________ > users mailing list > users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > From Martin.Maly at microsoft.com Thu Aug 10 17:32:47 2006 From: Martin.Maly at microsoft.com (Martin Maly) Date: Thu, 10 Aug 2006 08:32:47 -0700 Subject: [IronPython] Bug of big integer manipulation In-Reply-To: References: Message-ID: As for the infinite loop ... it is a bug in our PowMod code. It is not an actual infinite loop, but we just do the calculation very inefficiently. Filing as a bug also. Martin -----Original Message----- From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Martin Maly Sent: Thursday, August 10, 2006 8:26 AM To: Discussion of IronPython Subject: Re: [IronPython] Bug of big integer manipulation This is a current limitation of IronPython implementation. I am filing it as a bug for us to seriously investigate. Thanks for your help with the repro! Martin -----Original Message----- From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of HEMMI, Shigeru Sent: Thursday, August 10, 2006 1:38 AM To: Discussion of IronPython Subject: Re: [IronPython] Bug of big integer manipulation Thanks for the answer. I was able to take a log with -X:ExceptionDetail, but since Japanese, log file includes Japanse characters; I removed them by hand. I was not able to which numbers were involved. The log file is attached. Please note that there are two problems; one is "ValueError: value too big" problem which we do not encounter with CPython. The other is an infinite loop bug. Please also note that NZMATH is pure python, having simple module structure and we will be able to duplicate the problem if you download it. Best regards, 2006/8/10, Martin Maly : > By any chance, were you able to determine which operation caused the exception and which numbers were involved? What would help me find out what the problem is faster would be get a call stack (for that, could you please run your repro with -X:ExceptionDetail switch? Then ideally if you could find out what the big integer numbers were with which the operation failed, that would be ideal. > > Thanks! > Martin > > -----Original Message----- > From: users-bounces at lists.ironpython.com > [mailto:users-bounces at lists.ironpython.com] On Behalf Of HEMMI, > Shigeru > Sent: Tuesday, August 08, 2006 4:31 PM > To: Discussion of IronPython > Subject: [IronPython] Bug of big integer manipulation > > Hello, > > NZMATH is a Python based number theory oriented calculation system developed by Tokyo Metropolitan University. The URL is http://tnt.math.metro-u.ac.jp/nzmath/. > > Using NZMATH, I encounterd a bug of big integer manipulation. > > IronPython > ============================ > C:\IronPython-2604>ipy > IronPython 1.0.2411 on .NET 2.0.50727.42 Copyright (c) Microsoft Corporation. All rights reserved. > >>> import sys > >>> sys.path.append(r'C:\Python24\Lib') > >>> sys.path.append(r'C:\Python24\Lib\site-packages') > >>> from nzmath import prime > >>> prime.nextPrime(256) > 257 > >>> nx = sys.maxint > >>> prime.nextPrime(nx*nx) > Traceback (most recent call last): > File , line 0, in ##115 > File C:\Python24\Lib\site-packages\nzmath\prime.py, line 158, in nextPrime > File C:\Python24\Lib\site-packages\nzmath\prime.py, line 206, in primeq > File C:\Python24\Lib\site-packages\nzmath\prime.py, line 188, in smallSpsp > File C:\Python24\Lib\site-packages\nzmath\prime.py, line 41, in spsp > ValueError: value too big > >>> prime.nextPrime(nx) ## Seems going into infinite loop. > > CPython > ============================ > C:\IronPython-2604>python > Python 2.4.3 (#69, Mar 29 2006, 17:35:34) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. > >>> import sys > >>> from nzmath import prime > >>> nx = sys.maxint > >>> prime.nextPrime(nx*nx) > 4611686014132420667L > >>> prime.nextPrime(nx) > 2147483659L > >>> > > Regards, > _______________________________________________ > users mailing list > users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > _______________________________________________ > users mailing list > users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > _______________________________________________ users mailing list users at lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com From riltim at gmail.com Thu Aug 10 20:01:48 2006 From: riltim at gmail.com (Tim Riley) Date: Thu, 10 Aug 2006 14:01:48 -0400 Subject: [IronPython] Embedding Question Message-ID: If I have an embedded project can I automatically make .NET assemblies referenced in the project available to my python scripts? For example I have two assemblies(not in the GAC) that I have referenced in my project. I would like them always available to all python files run from this program without having to do the import clr, clr.AddReferenceToFileAndPath('blah') stuff in the beginning of each file. Is this possible? Regards, Tim Riley -------------- next part -------------- An HTML attachment was scrubbed... URL: From dinov at exchange.microsoft.com Thu Aug 10 20:21:12 2006 From: dinov at exchange.microsoft.com (Dino Viehland) Date: Thu, 10 Aug 2006 11:21:12 -0700 Subject: [IronPython] Embedding Question In-Reply-To: References: Message-ID: <7AD436E4270DD54A94238001769C22273160A0DDDB@DF-GRTDANE-MSG.exchange.corp.microsoft.com> Adding references updates the entire engine, it's not local to just the current module. So once you have added a reference you just need to import the namespace into any given module. Were you also trying to avoid the import statements? From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Tim Riley Sent: Thursday, August 10, 2006 11:02 AM To: Discussion of IronPython Subject: [IronPython] Embedding Question If I have an embedded project can I automatically make .NET assemblies referenced in the project available to my python scripts? For example I have two assemblies(not in the GAC) that I have referenced in my project. I would like them always available to all python files run from this program without having to do the import clr, clr.AddReferenceToFileAndPath('blah') stuff in the beginning of each file. Is this possible? Regards, Tim Riley -------------- next part -------------- An HTML attachment was scrubbed... URL: From riltim at gmail.com Thu Aug 10 20:39:38 2006 From: riltim at gmail.com (Tim Riley) Date: Thu, 10 Aug 2006 14:39:38 -0400 Subject: [IronPython] Embedding Question In-Reply-To: <7AD436E4270DD54A94238001769C22273160A0DDDB@DF-GRTDANE-MSG.exchange.corp.microsoft.com> References: <7AD436E4270DD54A94238001769C22273160A0DDDB@DF-GRTDANE-MSG.exchange.corp.microsoft.com> Message-ID: What I'm trying to do is sort of weird so let me see if I can elaborate further. I am embedding IronPython in a .NET assembly that will later be loaded into AutoCAD. AutoCAD has their own two .NET assemblies that must be referenced, "acmgd.dll" and "acdbmgd.dll". These two assemblies are always loaded while AutoCAD is running so their location isn't really a concern when creating a C# .dll. However when I want to modify AutoCAD entities from within my IP scripts I must first load the assemblies from file and path which is a problem because the file and path are different with each different version of AutoCAD. For example their path in my AutoCAD Mechanical 2005 is 'C:\Program Files\Autodesk\Acadm 2005' but with regular AutoCAD it would be 'C:\Program Files\Autodesk\Acad 2005'. There are so many different variations that this path could be that it would be a big deal to try/except load them all from some sort of init script. So basically I'm looking to pass a non-GAC assembly reference from my C# project to my IP project. Note: I'm fine with the import statements. On 8/10/06, Dino Viehland wrote: > > Adding references updates the entire engine, it's not local to just the > current module. So once you have added a reference you just need to import > the namespace into any given module. > > > > Were you also trying to avoid the import statements? > > > > *From:* users-bounces at lists.ironpython.com [mailto: > users-bounces at lists.ironpython.com] *On Behalf Of *Tim Riley > *Sent:* Thursday, August 10, 2006 11:02 AM > *To:* Discussion of IronPython > *Subject:* [IronPython] Embedding Question > > > > If I have an embedded project can I automatically make .NET assemblies > referenced in the project available to my python scripts? For example I have > two assemblies(not in the GAC) that I have referenced in my project. I would > like them always available to all python files run from this program without > having to do the import clr, clr.AddReferenceToFileAndPath('blah') stuff > in the beginning of each file. Is this possible? > > > Regards, > Tim Riley > > _______________________________________________ > users mailing list > users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From dinov at exchange.microsoft.com Thu Aug 10 21:04:59 2006 From: dinov at exchange.microsoft.com (Dino Viehland) Date: Thu, 10 Aug 2006 12:04:59 -0700 Subject: [IronPython] Embedding Question In-Reply-To: References: <7AD436E4270DD54A94238001769C22273160A0DDDB@DF-GRTDANE-MSG.exchange.corp.microsoft.com> Message-ID: <7AD436E4270DD54A94238001769C22273165C96D97@DF-GRTDANE-MSG.exchange.corp.microsoft.com> You can get the assembly object from an AutoCAD type: typeof(Foo).Assembly. From there you just need to have one helper which will register this in the engine, so you could do: delegate void AddReference(object assembly); AddReference adr = engine.CreateMethod("clr.AddReference(assembly)"); adr.AddReference(typeof(SomeAutoCadType).Assembly); and then from there you should be able to import any of the AutoCAD namespaces from any of your modules. From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Tim Riley Sent: Thursday, August 10, 2006 11:40 AM To: Discussion of IronPython Subject: Re: [IronPython] Embedding Question What I'm trying to do is sort of weird so let me see if I can elaborate further. I am embedding IronPython in a .NET assembly that will later be loaded into AutoCAD. AutoCAD has their own two .NET assemblies that must be referenced, " acmgd.dll" and "acdbmgd.dll". These two assemblies are always loaded while AutoCAD is running so their location isn't really a concern when creating a C# .dll. However when I want to modify AutoCAD entities from within my IP scripts I must first load the assemblies from file and path which is a problem because the file and path are different with each different version of AutoCAD. For example their path in my AutoCAD Mechanical 2005 is 'C:\Program Files\Autodesk\Acadm 2005' but with regular AutoCAD it would be 'C:\Program Files\Autodesk\Acad 2005'. There are so many different variations that this path could be that it would be a big deal to try/except load them all from some sort of init script. So basically I'm looking to pass a non-GAC assembly reference from my C# project to my IP project. Note: I'm fine with the import statements. On 8/10/06, Dino Viehland > wrote: Adding references updates the entire engine, it's not local to just the current module. So once you have added a reference you just need to import the namespace into any given module. Were you also trying to avoid the import statements? From: users-bounces at lists.ironpython.com [mailto: users-bounces at lists.ironpython.com] On Behalf Of Tim Riley Sent: Thursday, August 10, 2006 11:02 AM To: Discussion of IronPython Subject: [IronPython] Embedding Question If I have an embedded project can I automatically make .NET assemblies referenced in the project available to my python scripts? For example I have two assemblies(not in the GAC) that I have referenced in my project. I would like them always available to all python files run from this program without having to do the import clr, clr.AddReferenceToFileAndPath('blah') stuff in the beginning of each file. Is this possible? Regards, Tim Riley _______________________________________________ users mailing list users at lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From riltim at gmail.com Thu Aug 10 21:09:47 2006 From: riltim at gmail.com (Tim Riley) Date: Thu, 10 Aug 2006 15:09:47 -0400 Subject: [IronPython] Embedding Question In-Reply-To: <7AD436E4270DD54A94238001769C22273165C96D97@DF-GRTDANE-MSG.exchange.corp.microsoft.com> References: <7AD436E4270DD54A94238001769C22273160A0DDDB@DF-GRTDANE-MSG.exchange.corp.microsoft.com> <7AD436E4270DD54A94238001769C22273165C96D97@DF-GRTDANE-MSG.exchange.corp.microsoft.com> Message-ID: That's exactly what I needed. Thank you Dino. On 8/10/06, Dino Viehland wrote: > > You can get the assembly object from an AutoCAD type: > typeof(Foo).Assembly. From there you just need to have one helper which > will register this in the engine, so you could do: > > > > delegate void AddReference(object assembly); > > AddReference adr = engine.CreateMethod > ("clr.AddReference(assembly)"); > > adr.AddReference(typeof(SomeAutoCadType).Assembly); > > > > and then from there you should be able to import any of the AutoCAD > namespaces from any of your modules. > > > > *From:* users-bounces at lists.ironpython.com [mailto: > users-bounces at lists.ironpython.com] *On Behalf Of *Tim Riley > *Sent:* Thursday, August 10, 2006 11:40 AM > *To:* Discussion of IronPython > *Subject:* Re: [IronPython] Embedding Question > > > > What I'm trying to do is sort of weird so let me see if I can elaborate > further. I am embedding IronPython in a .NET assembly that will later be > loaded into AutoCAD. AutoCAD has their own two .NET assemblies that must be > referenced, " acmgd.dll" and "acdbmgd.dll". These two assemblies are > always loaded while AutoCAD is running so their location isn't really a > concern when creating a C# .dll. However when I want to modify AutoCAD > entities from within my IP scripts I must first load the assemblies from > file and path which is a problem because the file and path are different > with each different version of AutoCAD. > > For example their path in my AutoCAD Mechanical 2005 is 'C:\Program > Files\Autodesk\Acadm 2005' but with regular AutoCAD it would be 'C:\Program > Files\Autodesk\Acad 2005'. There are so many different variations that this > path could be that it would be a big deal to try/except load them all from > some sort of init script. > > So basically I'm looking to pass a non-GAC assembly reference from my C# > project to my IP project. > > > Note: I'm fine with the import statements. > > On 8/10/06, *Dino Viehland* wrote: > > Adding references updates the entire engine, it's not local to just the > current module. So once you have added a reference you just need to import > the namespace into any given module. > > > > Were you also trying to avoid the import statements? > > > > *From:* users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] > *On Behalf Of *Tim Riley > *Sent:* Thursday, August 10, 2006 11:02 AM > *To:* Discussion of IronPython > *Subject:* [IronPython] Embedding Question > > > > If I have an embedded project can I automatically make .NET assemblies > referenced in the project available to my python scripts? For example I have > two assemblies(not in the GAC) that I have referenced in my project. I would > like them always available to all python files run from this program without > having to do the import clr, clr.AddReferenceToFileAndPath('blah') stuff > in the beginning of each file. Is this possible? > > > Regards, > Tim Riley > > > _______________________________________________ > users mailing list > users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > > > > _______________________________________________ > users mailing list > users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From dinov at exchange.microsoft.com Thu Aug 10 21:16:44 2006 From: dinov at exchange.microsoft.com (Dino Viehland) Date: Thu, 10 Aug 2006 12:16:44 -0700 Subject: [IronPython] Embedding Question In-Reply-To: References: <7AD436E4270DD54A94238001769C22273160A0DDDB@DF-GRTDANE-MSG.exchange.corp.microsoft.com> <7AD436E4270DD54A94238001769C22273165C96D97@DF-GRTDANE-MSG.exchange.corp.microsoft.com> Message-ID: <7AD436E4270DD54A94238001769C22273165C96DB2@DF-GRTDANE-MSG.exchange.corp.microsoft.com> Cool, looks like I was only close though J You may have already imported clr into the default module, but just for the record for those who haven't you'll need an import clr there. I just realized I forgot it the 1st time, and I had a redundant "AddReference" in the delegate call. I'm assuming you just fixed all that up, but just in case anyone else needs to do something like this, here's the correct code: delegate void AddReference(object assembly); AddReference adr = engine.CreateMethod("import clr\nclr.AddReference(assembly)"); adr(typeof(SomeAutoCadType).Assembly); From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Tim Riley Sent: Thursday, August 10, 2006 12:10 PM To: Discussion of IronPython Subject: Re: [IronPython] Embedding Question That's exactly what I needed. Thank you Dino. On 8/10/06, Dino Viehland > wrote: You can get the assembly object from an AutoCAD type: typeof(Foo).Assembly. From there you just need to have one helper which will register this in the engine, so you could do: delegate void AddReference(object assembly); AddReference adr = engine.CreateMethod("clr.AddReference(assembly)"); adr.AddReference(typeof(SomeAutoCadType).Assembly); and then from there you should be able to import any of the AutoCAD namespaces from any of your modules. From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Tim Riley Sent: Thursday, August 10, 2006 11:40 AM To: Discussion of IronPython Subject: Re: [IronPython] Embedding Question What I'm trying to do is sort of weird so let me see if I can elaborate further. I am embedding IronPython in a .NET assembly that will later be loaded into AutoCAD. AutoCAD has their own two .NET assemblies that must be referenced, " acmgd.dll" and "acdbmgd.dll". These two assemblies are always loaded while AutoCAD is running so their location isn't really a concern when creating a C# .dll. However when I want to modify AutoCAD entities from within my IP scripts I must first load the assemblies from file and path which is a problem because the file and path are different with each different version of AutoCAD. For example their path in my AutoCAD Mechanical 2005 is 'C:\Program Files\Autodesk\Acadm 2005' but with regular AutoCAD it would be 'C:\Program Files\Autodesk\Acad 2005'. There are so many different variations that this path could be that it would be a big deal to try/except load them all from some sort of init script. So basically I'm looking to pass a non-GAC assembly reference from my C# project to my IP project. Note: I'm fine with the import statements. On 8/10/06, Dino Viehland > wrote: Adding references updates the entire engine, it's not local to just the current module. So once you have added a reference you just need to import the namespace into any given module. Were you also trying to avoid the import statements? From: users-bounces at lists.ironpython.com [mailto: users-bounces at lists.ironpython.com] On Behalf Of Tim Riley Sent: Thursday, August 10, 2006 11:02 AM To: Discussion of IronPython Subject: [IronPython] Embedding Question If I have an embedded project can I automatically make .NET assemblies referenced in the project available to my python scripts? For example I have two assemblies(not in the GAC) that I have referenced in my project. I would like them always available to all python files run from this program without having to do the import clr, clr.AddReferenceToFileAndPath('blah') stuff in the beginning of each file. Is this possible? Regards, Tim Riley _______________________________________________ users mailing list users at lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com _______________________________________________ users mailing list users at lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From riltim at gmail.com Thu Aug 10 22:01:12 2006 From: riltim at gmail.com (Tim Riley) Date: Thu, 10 Aug 2006 16:01:12 -0400 Subject: [IronPython] PythonEngine.RunFile Message-ID: In IP version 0.9 there was a PythonEngine.RunFile() method, this seems to be gone in 1.0.6. Is there a replacement? -------------- next part -------------- An HTML attachment was scrubbed... URL: From riltim at gmail.com Thu Aug 10 22:02:13 2006 From: riltim at gmail.com (Tim Riley) Date: Thu, 10 Aug 2006 16:02:13 -0400 Subject: [IronPython] Embedding Question In-Reply-To: <7AD436E4270DD54A94238001769C22273165C96DB2@DF-GRTDANE-MSG.exchange.corp.microsoft.com> References: <7AD436E4270DD54A94238001769C22273160A0DDDB@DF-GRTDANE-MSG.exchange.corp.microsoft.com> <7AD436E4270DD54A94238001769C22273165C96D97@DF-GRTDANE-MSG.exchange.corp.microsoft.com> <7AD436E4270DD54A94238001769C22273165C96DB2@DF-GRTDANE-MSG.exchange.corp.microsoft.com> Message-ID: Thanks Dino. I had figured that out. On 8/10/06, Dino Viehland wrote: > > Cool, looks like I was only close though J You may have already imported > clr into the default module, but just for the record for those who haven't > you'll need an import clr there. I just realized I forgot it the 1sttime, and I had a redundant "AddReference" in the delegate call. I'm > assuming you just fixed all that up, but just in case anyone else needs to > do something like this, here's the correct code: > > > > delegate void AddReference(object assembly); > > AddReference adr = engine.CreateMethod("import > clr\nclr.AddReference(assembly)"); > > adr(typeof(SomeAutoCadType).Assembly); > > > > > > *From:* users-bounces at lists.ironpython.com [mailto: > users-bounces at lists.ironpython.com] *On Behalf Of *Tim Riley > *Sent:* Thursday, August 10, 2006 12:10 PM > > *To:* Discussion of IronPython > *Subject:* Re: [IronPython] Embedding Question > > > > That's exactly what I needed. Thank you Dino. > > On 8/10/06, *Dino Viehland* wrote: > > You can get the assembly object from an AutoCAD type: > typeof(Foo).Assembly. From there you just need to have one helper which > will register this in the engine, so you could do: > > > > delegate void AddReference(object assembly); > > AddReference adr = engine.CreateMethod("clr.AddReference > (assembly)"); > > adr.AddReference(typeof(SomeAutoCadType).Assembly); > > > > and then from there you should be able to import any of the AutoCAD > namespaces from any of your modules. > > > > *From:* users-bounces at lists.ironpython.com [mailto: > users-bounces at lists.ironpython.com] *On Behalf Of *Tim Riley > *Sent:* Thursday, August 10, 2006 11:40 AM > *To:* Discussion of IronPython > *Subject:* Re: [IronPython] Embedding Question > > > > What I'm trying to do is sort of weird so let me see if I can elaborate > further. I am embedding IronPython in a .NET assembly that will later be > loaded into AutoCAD. AutoCAD has their own two .NET assemblies that must be > referenced, " acmgd.dll" and "acdbmgd.dll". These two assemblies are > always loaded while AutoCAD is running so their location isn't really a > concern when creating a C# .dll. However when I want to modify AutoCAD > entities from within my IP scripts I must first load the assemblies from > file and path which is a problem because the file and path are different > with each different version of AutoCAD. > > For example their path in my AutoCAD Mechanical 2005 is 'C:\Program > Files\Autodesk\Acadm 2005' but with regular AutoCAD it would be 'C:\Program > Files\Autodesk\Acad 2005'. There are so many different variations that this > path could be that it would be a big deal to try/except load them all from > some sort of init script. > > So basically I'm looking to pass a non-GAC assembly reference from my C# > project to my IP project. > > > Note: I'm fine with the import statements. > > On 8/10/06, *Dino Viehland* wrote: > > Adding references updates the entire engine, it's not local to just the > current module. So once you have added a reference you just need to import > the namespace into any given module. > > > > Were you also trying to avoid the import statements? > > > > *From:* users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] > *On Behalf Of *Tim Riley > *Sent:* Thursday, August 10, 2006 11:02 AM > *To:* Discussion of IronPython > *Subject:* [IronPython] Embedding Question > > > > If I have an embedded project can I automatically make .NET assemblies > referenced in the project available to my python scripts? For example I have > two assemblies(not in the GAC) that I have referenced in my project. I would > like them always available to all python files run from this program without > having to do the import clr, clr.AddReferenceToFileAndPath('blah') stuff > in the beginning of each file. Is this possible? > > > Regards, > Tim Riley > > > _______________________________________________ > users mailing list > users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > > > > > _______________________________________________ > users mailing list > users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > > > > _______________________________________________ > users mailing list > users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From Martin.Maly at microsoft.com Thu Aug 10 23:06:56 2006 From: Martin.Maly at microsoft.com (Martin Maly) Date: Thu, 10 Aug 2006 14:06:56 -0700 Subject: [IronPython] PythonEngine.RunFile In-Reply-To: References: Message-ID: Think PythonEngine.ExecuteFile may work for you. From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Tim Riley Sent: Thursday, August 10, 2006 1:01 PM To: Discussion of IronPython Subject: [IronPython] PythonEngine.RunFile In IP version 0.9 there was a PythonEngine.RunFile() method, this seems to be gone in 1.0.6. Is there a replacement? -------------- next part -------------- An HTML attachment was scrubbed... URL: From kristof.wagemans at gmail.com Thu Aug 10 23:10:25 2006 From: kristof.wagemans at gmail.com (Kristof Wagemans) Date: Thu, 10 Aug 2006 23:10:25 +0200 Subject: [IronPython] Debugging support PythonEngine Message-ID: <003001c6bcc1$67175450$0f01a8c0@notebook> I have been experimenting with the debugging support for the PythonEngine. When I use the following code I have several problems. PythonEngine _pe; EngineOptions options = new EngineOptions(); options.ClrDebuggingEnabled = true; _pe = new PythonEngine(options); _pe.ExecuteFile(@"