From m.hohner at uwinnipeg.ca Wed Mar 8 12:48:24 2006 From: m.hohner at uwinnipeg.ca (Michael Hohner) Date: Wed, 08 Mar 2006 11:48:24 -0600 Subject: [Python Wpg] python web site redone Message-ID: A new look - see http://www.python.org/ It's getting dug on digg.com Cheers, M. From syd at plug.ca Tue Mar 21 01:01:30 2006 From: syd at plug.ca (Sydney Weidman) Date: Tue, 21 Mar 2006 00:01:30 -0600 Subject: [Python Wpg] Python-db talk Wednesday 7:30 Message-ID: <1142920890.10215.9.camel@localhost.localdomain> Here is a link to a work *still* in progress, and a reminder that we will be meeting on Wednesday at the University of Winnipeg Library at 7:30 PM. http://wiki.uwinnipeg.ca/index.php/Python_Database_Access Corrections and comments are welcome, but please use the discussion tab, as I will be using these as my cheat notes for the presentation. Regards, Syd -- Sydney Weidman Prairie Linux User Group -- Sydney Weidman Prairie Linux User Group From m.hohner at uwinnipeg.ca Tue Mar 21 10:40:39 2006 From: m.hohner at uwinnipeg.ca (Michael Hohner) Date: Tue, 21 Mar 2006 09:40:39 -0600 Subject: [Python Wpg] Python DB talk Wed. Mar. 22nd at 7:30 p.m. - Room Change to 4CM04 Message-ID: Greetings All; The room has been changed for tomorrow night's meeting. It's now in 4CM04. That's located half-way up the large spiral staircase in the Library above the Reference Desk. The area is restricted after-hours but I'll be there to let people in at 7:30 and you can ring the doorbell if you're running a bit late. Cheers, Michael From mpfaiffer at callapple.org Thu Mar 23 18:01:09 2006 From: mpfaiffer at callapple.org (Mike Pfaiffer) Date: Thu, 23 Mar 2006 17:01:09 -0600 Subject: [Python Wpg] Last nights meeting Message-ID: <200603231701.09894.mpfaiffer@callapple.org> We discussed a couple of topics in the pre-presentation period I thought were worth mentioning here. The first was publicity in the Newsgroups. I was thinking it might be a good idea to have an auto-post of upcoming meetings roughly a week or so before the meeting. I suggest wpg.general, man.general, winnipeg.general, and the various local help groups. I don't have enough knowlege to create an autoposter myself. Perhaps it might be an interesting presentation if someone could write one in Python. Stuart also showed off a Python T-shirt. This got me thinking we could do something similar over the summer for additional publicity for the club. I did the rounds of T-shirt places 10 years ago. They weren't cheap. If we can get something in the $10.00 range I'd say we'd be doing well. Later Mike -- +----------------------------------------------------------------------+ |Call-A.P.P.L.E. and the Digital Civilization http://www.callapple.org | | http://members.shaw.ca/pfaiffer = Mike Pfaiffer (B.A., B.Sc.) | +----------------------------------------------------------------------+ ----- BEGIN GEEK CODE BLOCK ----- Version: 3.12 GCS/G/IT/PA/SS d s+:- a? C++ UL L++ W++ N++ o+ K- w(---) O+@ M++@ V PS+ PE !PGP t+ 5+ X R tv b+ DI+++ D++ G e++* h! r-- !y-- UF++ ------ END GEEK CODE BLOCK ------ From jason at peaceworks.ca Thu Mar 23 19:03:27 2006 From: jason at peaceworks.ca (Jason Hildebrand) Date: Thu, 23 Mar 2006 18:03:27 -0600 Subject: [Python Wpg] Last nights meeting In-Reply-To: <200603231701.09894.mpfaiffer@callapple.org> References: <200603231701.09894.mpfaiffer@callapple.org> Message-ID: <1143158607.21504.58.camel@trotzdem.wpg.peaceworks.ca> On Thu, 2006-03-23 at 17:01 -0600, Mike Pfaiffer wrote: > The first was publicity in the Newsgroups. I was thinking it might be a good > idea to have an auto-post of upcoming meetings roughly a week or so before > the meeting. I suggest wpg.general, man.general, winnipeg.general, and the > various local help groups. I don't have enough knowlege to create an > autoposter myself. Perhaps it might be an interesting presentation if someone > could write one in Python. FWIW, it doesn't look too difficult to post news from python; there's an example at: http://www.python.org/doc/lib/module-nntplib.html Though this would be cool, I actually wonder whether having it "auto" posted saves much effort as compared to someone manually cross-posting a message to all those groups, including the topic to be discussed/presented and the meeting location. peace, Jason -- Jason D. Hildebrand T: 204 775 1212 E: jason at peaceworks.ca From mpfaiffer at callapple.org Thu Mar 23 20:03:18 2006 From: mpfaiffer at callapple.org (Mike Pfaiffer) Date: Thu, 23 Mar 2006 19:03:18 -0600 Subject: [Python Wpg] Last nights meeting In-Reply-To: <1143158607.21504.58.camel@trotzdem.wpg.peaceworks.ca> References: <200603231701.09894.mpfaiffer@callapple.org> <1143158607.21504.58.camel@trotzdem.wpg.peaceworks.ca> Message-ID: <200603231903.18217.mpfaiffer@callapple.org> On March 23, 2006 06:03 pm, Jason Hildebrand wrote this amazing epistle: > On Thu, 2006-03-23 at 17:01 -0600, Mike Pfaiffer wrote: > > The first was publicity in the Newsgroups. I was thinking it might be a > > good idea to have an auto-post of upcoming meetings roughly a week or so > > before the meeting. I suggest wpg.general, man.general, winnipeg.general, > > and the various local help groups. I don't have enough knowlege to create > > an autoposter myself. Perhaps it might be an interesting presentation if > > someone could write one in Python. > > FWIW, it doesn't look too difficult to post news from python; there's an > example at: http://www.python.org/doc/lib/module-nntplib.html Cool. This opens up some possibilities for other programs I was thinking of. > Though this would be cool, I actually wonder whether having it "auto" > posted saves much effort as compared to someone manually cross-posting a > message to all those groups, including the topic to be > discussed/presented and the meeting location. It would certainly simplify things. All the maintainer would have to worry about would be setting up a cron job (again this is something I haven't done in years). The maintainer would just keep up a text file with relevant info. This way the maintainer wouldn't forget and could repost the message if they forgot to update the text file. It further occurs to me there is another UG in town (MWCS) which could benefit from this. > peace, > Jason Later Mike -- +----------------------------------------------------------------------+ |Call-A.P.P.L.E. and the Digital Civilization http://www.callapple.org | | http://members.shaw.ca/pfaiffer = Mike Pfaiffer (B.A., B.Sc.) | +----------------------------------------------------------------------+ ----- BEGIN GEEK CODE BLOCK ----- Version: 3.12 GCS/G/IT/PA/SS d s+:- a? C++ UL L++ W++ N++ o+ K- w(---) O+@ M++@ V PS+ PE !PGP t+ 5+ X R tv b+ DI+++ D++ G e++* h! r-- !y-- UF++ ------ END GEEK CODE BLOCK ------ From mpfaiffer at callapple.org Tue Mar 28 17:50:59 2006 From: mpfaiffer at callapple.org (Mike Pfaiffer) Date: Tue, 28 Mar 2006 16:50:59 -0600 Subject: [Python Wpg] String to integer conversion Message-ID: <200603281650.59342.mpfaiffer@callapple.org> I have one last thing to do before I can clean up the program I was talking about at the last meeting. Fifteen minutes of work plus testing actually. This is a tough one. As the title suggests I want to convert a string to an integer. I can use the atoi or int functions. These work well if the contents of the string is an actual integer. If someone decides to say... put their name in the string (through a raw_input function) then the function crashes. Is there a simple way to check if the value of the string is numeric first or better yet return zero if the value of the string contains alphabetic characters? The routine isn't complete yet. I'm taking a break at the moment. When I get back I'll implement it as if the user always types in an integer. This way I can do some testing and clean up. After everything is up and running properly I'll make it available on the web. Later Mike -- +----------------------------------------------------------------------+ |Call-A.P.P.L.E. and the Digital Civilization http://www.callapple.org | | http://members.shaw.ca/pfaiffer = Mike Pfaiffer (B.A., B.Sc.) | +----------------------------------------------------------------------+ ----- BEGIN GEEK CODE BLOCK ----- Version: 3.12 GCS/G/IT/PA/SS d s+:- a? C++ UL L++ W++ N++ o+ K- w(---) O+@ M++@ V PS+ PE !PGP t+ 5+ X R tv b+ DI+++ D++ G e++* h! r-- !y-- UF++ ------ END GEEK CODE BLOCK ------ From jason at peaceworks.ca Tue Mar 28 17:59:28 2006 From: jason at peaceworks.ca (Jason Hildebrand) Date: Tue, 28 Mar 2006 16:59:28 -0600 Subject: [Python Wpg] String to integer conversion In-Reply-To: <200603281650.59342.mpfaiffer@callapple.org> References: <200603281650.59342.mpfaiffer@callapple.org> Message-ID: <1143586768.6125.69.camel@trotzdem.wpg.peaceworks.ca> On Tue, 2006-03-28 at 16:50 -0600, Mike Pfaiffer wrote: > As the title suggests I want to convert a string to an > integer. I can use the atoi or int functions. These work well if the contents > of the string is an actual integer. If someone decides to say... put their > name in the string (through a raw_input function) then the function crashes. > Is there a simple way to check if the value of the string is numeric first or > better yet return zero if the value of the string contains alphabetic > characters? Hi Mike, Just try to convert the input, and catch the exception if necessary, defaulting to 0: s = raw_input() try: i = int(s) except ValueError: i = 0 -- Jason D. Hildebrand T: 204 775 1212 E: jason at peaceworks.ca From billreid at shaw.ca Tue Mar 28 18:00:53 2006 From: billreid at shaw.ca (Bill Reid) Date: Tue, 28 Mar 2006 17:00:53 -0600 Subject: [Python Wpg] String to integer conversion In-Reply-To: <200603281650.59342.mpfaiffer@callapple.org> References: <200603281650.59342.mpfaiffer@callapple.org> Message-ID: <4429C025.8020204@shaw.ca> Mike Pfaiffer wrote: > Is there a simple way to check if the value of the string is numeric first or > better yet return zero if the value of the string contains alphabetic > characters? > I did not look up a reference so there might be a better "python" way of doing it but you could using a reg expression match ^[0-9]*$ -- Bill From mpfaiffer at callapple.org Tue Mar 28 18:08:47 2006 From: mpfaiffer at callapple.org (Mike Pfaiffer) Date: Tue, 28 Mar 2006 17:08:47 -0600 Subject: [Python Wpg] Thanks guys Message-ID: <200603281708.47237.mpfaiffer@callapple.org> I'll try both methods. I'll try them out and pick one. For version 1.0 of the program I didn't expect to ask so many questions or put in so much work. ;-) A quick look at the nice sunny day outside then back to work. Later Mike -- +----------------------------------------------------------------------+ |Call-A.P.P.L.E. and the Digital Civilization http://www.callapple.org | | http://members.shaw.ca/pfaiffer = Mike Pfaiffer (B.A., B.Sc.) | +----------------------------------------------------------------------+ ----- BEGIN GEEK CODE BLOCK ----- Version: 3.12 GCS/G/IT/PA/SS d s+:- a? C++ UL L++ W++ N++ o+ K- w(---) O+@ M++@ V PS+ PE !PGP t+ 5+ X R tv b+ DI+++ D++ G e++* h! r-- !y-- UF++ ------ END GEEK CODE BLOCK ------ From stuartw at mts.net Tue Mar 28 21:38:52 2006 From: stuartw at mts.net (Stuart Williams) Date: Tue, 28 Mar 2006 20:38:52 -0600 Subject: [Python Wpg] String to integer conversion In-Reply-To: <200603281650.59342.mpfaiffer@callapple.org> References: <200603281650.59342.mpfaiffer@callapple.org> Message-ID: <17449.62268.324406.657844@gargle.gargle.HOWL> >>>>> Mike Pfaiffer writes: > Subject: [Python Wpg] String to integer conversion > Is there a simple way to check if the value of the string is numeric > first... The try/except is better, but there is an isdigit method on strings that's simpler than the regular expression, e.g.: '123'.isdigit() -> True 'abc'.isdigit() -> False '12a'.isdigit() -> False ' 3'.isdigit() -> False (try/except on int() handles white space) Stuart. From mpfaiffer at callapple.org Tue Mar 28 23:13:47 2006 From: mpfaiffer at callapple.org (Mike Pfaiffer) Date: Tue, 28 Mar 2006 22:13:47 -0600 Subject: [Python Wpg] String to integer conversion In-Reply-To: <17449.62268.324406.657844@gargle.gargle.HOWL> References: <200603281650.59342.mpfaiffer@callapple.org> <17449.62268.324406.657844@gargle.gargle.HOWL> Message-ID: <200603282213.47095.mpfaiffer@callapple.org> On March 28, 2006 08:38 pm, Stuart Williams wrote this amazing epistle: > >>>>> Mike Pfaiffer writes: > > > > Subject: [Python Wpg] String to integer conversion > > > > Is there a simple way to check if the value of the string is numeric > > first... > > The try/except is better, but there is an isdigit method on strings > that's simpler than the regular expression, e.g.: > > '123'.isdigit() -> True > 'abc'.isdigit() -> False > '12a'.isdigit() -> False > ' 3'.isdigit() -> False (try/except on int() handles white space) > > Stuart. Thanks. Syd sent me something similar. Considering this is going to be used as a very rudimentary example for instruction (and it's the first full Python program I've written) I want to keep it simple. The try/exception is familiar to the Apple// folks although the syntax is different. This example could be useful for another article when I'm feeling more adventurous. ;-) Later Mike -- +----------------------------------------------------------------------+ |Call-A.P.P.L.E. and the Digital Civilization http://www.callapple.org | | http://members.shaw.ca/pfaiffer = Mike Pfaiffer (B.A., B.Sc.) | +----------------------------------------------------------------------+ ----- BEGIN GEEK CODE BLOCK ----- Version: 3.12 GCS/G/IT/PA/SS d s+:- a? C++ UL L++ W++ N++ o+ K- w(---) O+@ M++@ V PS+ PE !PGP t+ 5+ X R tv b+ DI+++ D++ G e++* h! r-- !y-- UF++ ------ END GEEK CODE BLOCK ------ From durango at mail2world.com Fri Mar 31 23:42:28 2006 From: durango at mail2world.com (Mr X) Date: Fri, 31 Mar 2006 20:42:28 -0800 Subject: [Python Wpg] Python, VB math simple problem Message-ID: <2218501c65546$ae1ac720$0a10010a@mail2world.com> Hi looking for help with what should be a fairly simple Python problem, relating to VB inter-operability. Got a great response from a fellow named Matt at help at python.org, pointed me in some good directions - some areas, concerns still foggy on, the below thread is included.... any feedback on this simple dilemma would be very appreciated. Thanks, D thread follows below; ------------------------------------ To: help at python.org Subject: Problem with Python math functions and VB Date: 3/30/2006 9:39:28 PM Download Message Display Headers Printer Friendly Previous | Next Wondering if you might either know how to solve the following. I've a background in Visual Basic, and am using an old version, 4.0, it compiles to a smaller executable which I prefer. I find myself in an odd situation, needing a very simple yet powerful capability of Python for a VB app Im working on. Simply, a large 300 digit number is divided by a smaller number ranging from 1 to 3 digits. I.e; This large 300 digit number is generated as a string from the VB app, and I want to input this somehow from the VB app directly to Python for simple math operations. Where; x = 300 digit number, y = divisor ( say '37') x / 37 I want to divide x by y but I want the remainder of this division to at least 3 or 4 decimal places, so my Python script at the command line; x %y /y. = z So now I want to take the resultant, the full number plus its remainder, and I want to round this number up to the next highest number and divide it by the same constant; z rounded up to next highest number (never the lowest) so z /y = z Long Remove the 'L' at the end, round up the last digit of z = Z Then; Z %y /y. = a Then I want the last five digits of z (not Z) and a truncated at the end, so the last digit before the decimal point and the four digits past the decimal point printed to a text file. I want to be able to open the text file with the VB app and use this data as inputs. ========== Ok, so here is my dilemma, I know VERY litle about Python and a fair bit about VB. Ideally, I'd love to be able to simply have some extremely small executable that just accepts inputs does the calculations above and then spits out the outputs. If it were possible to write some simple lines of math code in Python and then compile these scripts in Python to a Windows compatible executable,that would be fantastic. If I could simply have my VB app, 'call' the name of the tiny Python executable, and then the Python executable just automatically looked for a named text file (created by the VB app) and extracted the 300 digit number from this, then performed the calcs, then spit this data out as a new text file name it created, which I could then use the VB app to open and read from, THAT would be ideal. However, I don't know if Python can compile scripts to an exe? If it can how could I find out how to do this? If it doesn't, how could I get VB to directly pass commands to the Python command line and then automatically extract the outputs? Shelling out from VB to Python would be tough to the command line I think, since the Python command line uses the 'Edit / Mark, Paste' approach to inserting, copy inputs, outputs and this would be virtually untenable, as far as I can tell to automate in a VB shell out routine. So basically, how the heck can I access Pythons ability to perform simple calculations on very large numbers, easily, from within VB 4.0 ? There must be a way, it seems like such a simple think to do, especially since the actual math operations are so simple, straight forward, and would never change..... Any ideas? ------ Matthew, thanks for your response. <-----Original Message-----> >From: Matthew Dixon Cowles >Sent: 3/31/2006 9:41:18 AM >To: durango at mail2world.com >Cc: help at python.org >Subject: Re: [Python-Help] Problem with Python math functions and VB >I'm sure that there's a way to do that, but I'm not familiar with >Visual Basic and I don't know what inter-process communication >facilities it offers. Is there a person or group you might direct me to that has worked with this inter-process communication between VB and Python? >I don't think that Python is going to be able to do that for you out >of the box. Hundreds of digits of floating-point precision is a lot. Could you explain that a bit more, sorry Im not sure what you mean by 'out of the box' ? If I run the Python command line screen in windows and manually type out a very large number, say 180 digits; where 'X' = very large number; X %37 /37. returns what Im after, value wise..... but of course I don't want to do this manually each time for every dividend. >You might find that one of the Python modules that let you use an >extended-precision library would do what you want. GMPY is one: >http://gmpy.sourceforge.net/ Hey, thats interesting, wonder if these modules can be operated on with VB..... >> So now I want to take the resultant, the full number plus its >> remainder, and I want to round this number up >> to the next highest number and divide it by the same constant; > >That's easy enough. > >> I want to be able to open the text file with the VB app and use this >> data as inputs. > >Python can write to a file without any trouble, so it that form of >inter-process communication suits you, you shouldn't have much >trouble. I assume that Visual Basic has an easy way to start a >program and supply it with arguments, so you could have your Python >program get its inputs from sys.argv. What is sys.argv ? Thats really good news. In fact, all I really need for the moment is a python executable that; ================ PYTHON ALGORITHM ABSTRACT a) opens a text file b) reads a string from the file, which is a very large number c) performs simple arithmetic operations; X %37 /37. = y (four digit remainder after decimal point) X /37 = w (quotient as long, the resulting output is stored as a variable, the 'L' suffix tagged on the end of this resultant then gets removed. then the last digit in the quotient resultant string is increased in value by one, rounded upwards = 'Z' then Z %37 /37. = a then, y and a are printed to a text file with hard returns between them. Thats it, thats all I need to do. =================== >Alas, it's not going to be extremely small. There isn't a compiler >from Python to machine code. Py2exe will bundle a Python program, >with everything that it needs to run, into a single executable >archive. But the archive isn't small. Py2exe is at: > >http://www.py2exe.org/ the most important thing is the functionality, I'll sacrifice size if I have to. My guess is this should work based on your comments, because perhaps all I really have to do is have VB dump out the value of the Very large number, `180 to 300 digits or so', to a text file, which then becomes the input data for the Python executable, and then if I simply call the name of the Python executable from VB as an instance, then the Python App runs, spits out the data as a new text file, then the VB app goes and opens the new text file and reads in the values, and voila! There it is. I'm pretty sure I can call the Python app from VB....... the alternative to all this would be to try and feed Python scripts directly to Python from VB, which I have NO idea how to do or where to begin.... and am guessing would be much more messy... I haven't programmed in Python, how would the "PYTHON ALGORITHM ABSTRACT" I describe above look like, code wise? Is this fairly easy for you to describe? >It may be that Python isn't the best solution for you here. Are there >extended-precision libraries for Visual Basic? Alas, none that I know of that are reliable and not incredibly expensive, been looking for years, plus Im hooped because I have to work with VB 4.0 instead of 6 +, guh.... >Regards, >Matt Matt..... good name, why do I always seem to get along with Matts, you people keep popping up in my life and its always a blast! Best regards, D

_______________________________________________________________
Get the FREE email that has everyone talking at http://www.mail2world.com
Unlimited Email Storage – POP3 – Calendar – SMS – Translator – Much More!
-------------- next part -------------- An HTML attachment was scrubbed... URL: