From devplayer at gmail.com Sat Jan 1 01:43:46 2011 From: devplayer at gmail.com (DevPlayer) Date: Fri, 31 Dec 2010 22:43:46 -0800 (PST) Subject: default argument in method References: <4d0955ae$0$29997$c3e8da3$5496439d@news.astraweb.com> <9f77af4a-83b0-47b6-9e38-5ac5d2214c66@29g2000yqq.googlegroups.com> <4d1ce5ab$0$29968$c3e8da3$5496439d@news.astraweb.com> Message-ID: I agree with you Steven that the OP should avoid __getattribute__ and the like for many a thing. I also agree with your last statement. I try to answer the OP's question without much "You shouldn't do this's and don't do that's". I trust them to make thier own decisions. I'd say "A much better solution..." is the way I like to say it. The last solution you offered I find I use more often now as I like to set my function with default values for which I call set-and-forget function parms/args where using None is what allows my functions to know what is changing (or not). # for example def logger(parm1, parm2=None): if not hasattr(myfunc.parm2_default): if parm2: myfunc.parm2_default = parm2 else: myfunc.parm2_default = CONSOLE if not parm2: parmTwo = myfunc.parm2_default else: parmTwo = parm2 # do something print(parmTwo) log = logger(gui_frame, GUI) # an inaccurate example From michele.simionato at gmail.com Sat Jan 1 03:30:27 2011 From: michele.simionato at gmail.com (Michele Simionato) Date: Sat, 1 Jan 2011 00:30:27 -0800 (PST) Subject: decorator 3.3 is out Message-ID: <30cca189-8d5f-438f-ac7e-a2424196ec61@g26g2000vbi.googlegroups.com> Thanks to the holiday period I found the time to add to the decorator module a long-awaited feature, the ability to understand and to preserve Python 3 function annotations. I have just released version 3.3 which implements such feature. It should be considered at an experimental stage. If you use Python 3 and function annotations you may want to try out the new decorator module (easy_install decorator) and give me feedback. See http://pypi.python.org/pypi/decorator for more. Thanks for your time and Happy New Year to all fellows Pythonistas! Michele Simionato P.S. today I have also released a new bug-fixed version of plac (see http://pypi.python.org/pypi/plac) From baptiste.lepilleur at gmail.com Sat Jan 1 04:01:20 2011 From: baptiste.lepilleur at gmail.com (Baptiste Lepilleur) Date: Sat, 1 Jan 2011 10:01:20 +0100 Subject: How to port bytes formatting to Python 3.x ? Message-ID: Hi, I'm trying to port a small library to Python 3.x, and I'm wondering what is the best way to port statements such as the one belows that are frequently found in network protocol implementation: headerparts = ("%s:%s\n" % (key, value) for key, value in headers.iteritems()) framebytes = "%s\n%s\n%s\x00" % (command, "".join(headerparts), body) Where all manipulated string are actually bytes, though value in headers dict may be any objects. Baptiste. -------------- next part -------------- An HTML attachment was scrubbed... URL: From baptiste.lepilleur at gmail.com Sat Jan 1 04:08:50 2011 From: baptiste.lepilleur at gmail.com (Baptiste Lepilleur) Date: Sat, 1 Jan 2011 10:08:50 +0100 Subject: How to define a bytes literal in Python 2.x for porting to Python 3.x using 2to3? Message-ID: Hi, I'm trying to port some network protocol library to Python 3.x, and it defines many bytes literals as plain string. How do you define bytes literals so that the library can be ported to Python 3.x using only 2to3? For example: In python 2.x, I need: self.buffer = '\n' In python 3.x, I need: self.buffer = b'\n' Is there a way to mark string literals so that 2to3 automatically prefixes them with 'b'? Is there a simpler trick? Baptiste. -------------- next part -------------- An HTML attachment was scrubbed... URL: From flebber.crue at gmail.com Sat Jan 1 04:21:20 2011 From: flebber.crue at gmail.com (flebber) Date: Sat, 1 Jan 2011 01:21:20 -0800 (PST) Subject: User input masks - Access Style References: <385bcaf1-81a5-405a-b7f0-28d7994a2e95@a28g2000prb.googlegroups.com> <7a7e3beb-380a-4d09-8bf6-71a3ecac17e8@p7g2000prb.googlegroups.com> Message-ID: On Jan 1, 11:13?am, Tim Harig wrote: > On 2010-12-31, flebber wrote: > > > On Dec 28 2010, 12:21 am, Adam Tauno Williams > > wrote: > >> On Sun, 2010-12-26 at 20:37 -0800, flebber wrote: > >> > Is there anyay to use input masks in python? Similar to the function > >> > found in access where a users input is limited to a type, length and > >> > format. > > >> > > >> Typically this is handled by a callback on a keypress event. > > > Regarding 137 of the re module, relating to the code above. > > 137? I am not sure what you are referencing? > > > EDIT: I just needed to use raw_input rather than input to stop this > > input error. > > Sorry, I used input() because that is what you had used in your example > and it worked for my system. ?Normally, I would have used window.getstr() > from the curses module, or whatever the platform equivilant is, for > getting line buffered input. 137 is the line number in the re module which refernces the match string. In this example the timeinput. From tjreedy at udel.edu Sat Jan 1 05:08:56 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Sat, 01 Jan 2011 05:08:56 -0500 Subject: How to define a bytes literal in Python 2.x for porting to Python 3.x using 2to3? In-Reply-To: References: Message-ID: On 1/1/2011 4:08 AM, Baptiste Lepilleur wrote: > Is there a way to mark string literals so that 2to3 automatically > prefixes them with 'b'? Is there a simpler trick? Python 2.7.1 (r271:86832, Nov 27 2010, 18:30:46) [MSC v.1500 32 bit (Intel)] on win32 Type "copyright", "credits" or "license()" for more information. >>> b=b'abc' >>> b 'abc' The b prefix does nothing in 2.7. It was specifically added for this type of porting problem. -- Terry Jan Reedy From stefan_ml at behnel.de Sat Jan 1 05:57:08 2011 From: stefan_ml at behnel.de (Stefan Behnel) Date: Sat, 01 Jan 2011 11:57:08 +0100 Subject: How to define a bytes literal in Python 2.x for porting to Python 3.x using 2to3? In-Reply-To: References: Message-ID: Terry Reedy, 01.01.2011 11:08: > On 1/1/2011 4:08 AM, Baptiste Lepilleur wrote: > >> Is there a way to mark string literals so that 2to3 automatically >> prefixes them with 'b'? Is there a simpler trick? > > Python 2.7.1 (r271:86832, Nov 27 2010, 18:30:46) [MSC v.1500 32 bit > (Intel)] on win32 > Type "copyright", "credits" or "license()" for more information. > >>> b=b'abc' > >>> b > 'abc' > > The b prefix does nothing in 2.7. It was specifically added for this type > of porting problem. More precisely, it was added in Python 2.6, so older Python versions will consider it a syntax error. To support older Python versions, you need to write your own wrapper functions for bytes literals that do nothing in Python 2 and convert the literal back to a bytes literal in Python 3. That's ugly, but there's no other way to do it. Stefan From stefan_ml at behnel.de Sat Jan 1 05:58:48 2011 From: stefan_ml at behnel.de (Stefan Behnel) Date: Sat, 01 Jan 2011 11:58:48 +0100 Subject: How to port bytes formatting to Python 3.x ? In-Reply-To: References: Message-ID: Baptiste Lepilleur, 01.01.2011 10:01: > Hi, > I'm trying to port a small library to Python 3.x, and I'm wondering what is > the best way to port statements such as the one belows that are frequently > found in network protocol implementation: > > headerparts = ("%s:%s\n" % (key, value) for key, value in > headers.iteritems()) > framebytes = "%s\n%s\n%s\x00" % (command, "".join(headerparts), > body) > > Where all manipulated string are actually bytes, though value in headers > dict may be any objects. See my answer in the other thread you started on this topic. You need to wrap the literal in a function call that converts it to a bytes literal when running in Python 3. Stefan From baptiste.lepilleur at gmail.com Sat Jan 1 06:34:37 2011 From: baptiste.lepilleur at gmail.com (Baptiste Lepilleur) Date: Sat, 1 Jan 2011 12:34:37 +0100 Subject: How to define a bytes literal in Python 2.x for porting to Python 3.x using 2to3? In-Reply-To: References: Message-ID: 2011/1/1 Stefan Behnel > Terry Reedy, 01.01.2011 11:08: > > On 1/1/2011 4:08 AM, Baptiste Lepilleur wrote: >> >> Is there a way to mark string literals so that 2to3 automatically >>> prefixes them with 'b'? Is there a simpler trick? >>> >> >> Python 2.7.1 (r271:86832, Nov 27 2010, 18:30:46) [MSC v.1500 32 bit >> (Intel)] on win32 >> Type "copyright", "credits" or "license()" for more information. >> >>> b=b'abc' >> >>> b >> 'abc' >> >> The b prefix does nothing in 2.7. It was specifically added for this type >> of porting problem. >> > > More precisely, it was added in Python 2.6, so older Python versions will > consider it a syntax error. > > To support older Python versions, you need to write your own wrapper > functions for bytes literals that do nothing in Python 2 and convert the > literal back to a bytes literal in Python 3. That's ugly, but there's no > other way to do it. > Thanks, I'll go that way. I guess it is an area where 3to2 would be better... -------------- next part -------------- An HTML attachment was scrubbed... URL: From subhakolkata1234 at gmail.com Sat Jan 1 06:52:55 2011 From: subhakolkata1234 at gmail.com (joy99) Date: Sat, 1 Jan 2011 03:52:55 -0800 (PST) Subject: Interesting bug Message-ID: <45562e32-6fd2-4d40-be64-bb88335ad274@z17g2000prz.googlegroups.com> Dear Group, Hope all of you are fine and spending nice new year evenings. I get a bug in Python over the last 4 years or so, since I am using it. The language is superb, no doubt about it. It helped me finish many a projects, with extraordinary accuracy. But long since, I was getting an interesting bug. In the initial days, I thought it may be my learning error or usability error. It comes every now and then. The bug is suppose I am calling a library or using some logical operator, it works fine initially but if I want to copy the code to some other modules, same line of codes do not run at all. The remedy I do is, (a) I take the code from file and test it in GUI, more astonishingly in 99% of the cases I found the code llines, are correct. Then I apply a brute force technique I rewrite the whole code again. For small codes this technique is okay, but if I write mammoth code, and all on a sudden some interesting behavior came out, well it really feels bad. I keep now a days some time out that I have to do this, but is there any definite solution? I believe there is some, as I do not know them, as it happens, unnecessarily get upset. I use Python on WinXP service pack2, I started to use Python2.5.1, and now I am using Python2.6.5, IDLE as GUI. Best Regards, Subhabrata From baptiste.lepilleur at gmail.com Sat Jan 1 06:53:52 2011 From: baptiste.lepilleur at gmail.com (Baptiste Lepilleur) Date: Sat, 1 Jan 2011 12:53:52 +0100 Subject: How to port bytes formatting to Python 3.x ? In-Reply-To: References: Message-ID: 2011/1/1 Stefan Behnel > Baptiste Lepilleur, 01.01.2011 10:01: > > Hi, >> I'm trying to port a small library to Python 3.x, and I'm wondering what >> is >> the best way to port statements such as the one belows that are >> frequently >> found in network protocol implementation: >> ... >> > See my answer in the other thread you started on this topic. You need to > wrap the literal in a function call that converts it to a bytes literal when > running in Python 3. > Is there a robust implementation of the format operator % for bytes that can substitute %s? I've stumbled on a bug on Mysql python 3 connector due to a "buggy" attempt to replace it (see https://bugs.launchpad.net/myconnpy/+bug/691836). Baptiste. -------------- next part -------------- An HTML attachment was scrubbed... URL: From stefan_ml at behnel.de Sat Jan 1 07:08:48 2011 From: stefan_ml at behnel.de (Stefan Behnel) Date: Sat, 01 Jan 2011 13:08:48 +0100 Subject: How to port bytes formatting to Python 3.x ? In-Reply-To: References: Message-ID: Baptiste Lepilleur, 01.01.2011 12:53: > 2011/1/1 Stefan Behnel >> Baptiste Lepilleur, 01.01.2011 10:01: >>> I'm trying to port a small library to Python 3.x, and I'm wondering what >>> is the best way to port statements such as the one belows that are >>> frequently found in network protocol implementation: >>> ... >>> >> See my answer in the other thread you started on this topic. You need to >> wrap the literal in a function call that converts it to a bytes literal when >> running in Python 3. > > Is there a robust implementation of the format operator % for bytes that can > substitute %s? Concatenation is portable and seems to suite your examples (which you stripped above). For more involved cases (as are also likely to occur in network protocol code), have a look at the struct module. http://docs.python.org/py3k/library/struct.html Stefan From fetchinson at googlemail.com Sat Jan 1 08:22:48 2011 From: fetchinson at googlemail.com (Daniel Fetchinson) Date: Sat, 1 Jan 2011 14:22:48 +0100 Subject: Interesting bug In-Reply-To: <45562e32-6fd2-4d40-be64-bb88335ad274@z17g2000prz.googlegroups.com> References: <45562e32-6fd2-4d40-be64-bb88335ad274@z17g2000prz.googlegroups.com> Message-ID: > Dear Group, > > Hope all of you are fine and spending nice new year evenings. > > I get a bug in Python over the last 4 years or so, since I am using > it. The language is superb, no doubt about it. It helped me finish > many a projects, with extraordinary accuracy. But long since, I was > getting an interesting bug. In the initial days, I thought it may be > my learning error or usability error. It comes every now and then. The > bug is suppose I am calling a library or using some logical operator, > it works fine initially but if I want to copy the code to some other > modules, same line of codes do not run at all. > > The remedy I do is, > (a) I take the code from file and test it in GUI, more astonishingly > in 99% of the cases I found the code llines, are correct. > Then I apply a brute force technique I rewrite the whole code again. > For small codes this technique is okay, but if I write mammoth code, > and all on a sudden some interesting behavior came out, well it really > feels bad. I keep now a days some time out that I have to do this, but > is there any definite solution? I believe there is some, as I do not > know them, as it happens, unnecessarily get upset. > > I use Python on WinXP service pack2, I started to use Python2.5.1, and > now I am using Python2.6.5, IDLE as GUI. > > Best Regards, > Subhabrata An AI bot is playing a trick on us. Focus and don't let your guards down! Cheers, Daniel -- Psss, psss, put it down! - http://www.cafepress.com/putitdown From ugnews at onlinehome.de Sat Jan 1 08:34:42 2011 From: ugnews at onlinehome.de (Uwe Grauer) Date: Sat, 01 Jan 2011 14:34:42 +0100 Subject: kinterbasdb error connection In-Reply-To: References: Message-ID: On 12/31/2010 04:41 PM, Ale Ghelfi wrote: > On 09/12/2010 15:17, Uwe Grauer wrote: >> On 12/07/2010 04:35 PM, Ale Ghelfi wrote: >>> (i'm under Ubuntu 10.10 amd64 and python 2.6 and kinterbasdb 3.2 ) >>> I try to connect my database of firebird 2.5 by kinterbasdb. >>> But python return this error : >> >> >> You are not using the current kinterbasdb version. >> See: >> http://firebirdsql.org/index.php?op=devel&sub=python >> >> Uwe >> > kinterbasdb 3.2.3 is the Really current version for Ubuntu 10.10 AMD64. > Kinterbasdb 3.3.0 exists only for ubuntu 10.10 i386 > I've check in the repository. > > AFAIK 3.2.3 doesn't work for FB 2.5. If you don't get 3.3.0 from the ubuntu repositories you could do a manual install for 3.3.0 Uwe From gurudatta97 at gmail.com Sat Jan 1 08:35:50 2011 From: gurudatta97 at gmail.com (guru datta) Date: Sat, 1 Jan 2011 05:35:50 -0800 (PST) Subject: HOT FOR TENAGE GUYS Message-ID: BOLLYWOOD HOT PHOTOS&VIDEOS http://www.photoscup.com/2010/12/keerthi-chawla.html SOUTH ACTRESS HOT PHOTOS http://www.photoscup.com/2010/12/madhu-shalini.html HOT ACTRESS NAVNEET KAUR http://www.photoscup.com/2010/12/navneet-kaur.html HOT SEXY POONAM KAUR PICS http://www.photoscup.com/2010/12/poonam-kaur.html HOLLYWOOD HOT PHOTOS http://www.photoscup.com/2010/12/christina-aguilera.html CHRISTINA HENDRICKS HOT PHOTOS http://www.photoscup.com/2010/12/christina-hendricks.html UDITI GOSWAMI HOT BOOBS SHOW http://www.photoscup.com/2010/12/uditi-goswami.html NEHA DHUPIA HOT ROMANTIC STILLS http://www.photoscup.com/2010/12/neha-dhupia.html SHRADDA DAS SEXY WALLPAPERS http://www.photoscup.com/2010/12/shraddha-das.html FREIDA PINTO HOLLYWOOD HOT http://www.photoscup.com/2010/12/freida-pinto.html From subhakolkata1234 at gmail.com Sat Jan 1 08:58:04 2011 From: subhakolkata1234 at gmail.com (joy99) Date: Sat, 1 Jan 2011 05:58:04 -0800 (PST) Subject: Interesting bug References: <45562e32-6fd2-4d40-be64-bb88335ad274@z17g2000prz.googlegroups.com> Message-ID: On Jan 1, 6:22?pm, Daniel Fetchinson wrote: > > Dear Group, > > > Hope all of you are fine and spending nice new year evenings. > > > I get a bug in Python over the last 4 years or so, since I am using > > it. The language is superb, no doubt about it. It helped me finish > > many a projects, with extraordinary accuracy. But long since, I was > > getting an interesting bug. In the initial days, I thought it may be > > my learning error or usability error. It comes every now and then. The > > bug is suppose I am calling a library or using some logical operator, > > it works fine initially but if I want to copy the code to some other > > modules, same line of codes do not run at all. > > > The remedy I do is, > > (a) I take the code from file and test it in GUI, more astonishingly > > in 99% of the cases I found the code llines, are correct. > > Then I apply a brute force technique I rewrite the whole code again. > > For small codes this technique is okay, but if I write mammoth code, > > and all on a sudden some interesting behavior came out, well it really > > feels bad. I keep now a days some time out that I have to do this, but > > is there any definite solution? I believe there is some, as I do not > > know them, as it happens, unnecessarily get upset. > > > I use Python on WinXP service pack2, I started to use Python2.5.1, and > > now I am using Python2.6.5, IDLE as GUI. > > > Best Regards, > > Subhabrata > > An AI bot is playing a trick on us. > Focus and don't let your guards down! > > Cheers, > Daniel > > -- > Psss, psss, put it down! -http://www.cafepress.com/putitdown Thanks for the suggestion. I'll keep it checked. Some useless fellows forget their own business and poke nose into others business. Best Regards, Subhabrata. From sigzero at gmail.com Sat Jan 1 10:00:06 2011 From: sigzero at gmail.com (Robert) Date: Sat, 1 Jan 2011 10:00:06 -0500 Subject: Nagios References: <3f7e76bf-3d62-4314-987f-62b9fda71f91@glegroupsg2000goo.googlegroups.com> Message-ID: On 2010-12-31 23:57:24 -0500, Adam Skutt said: > On Friday, December 31, 2010 9:56:02 PM UTC-5, Robert H wrote: >> It was forked to be written in Python, yes. The whole point (and it >> wasn't a Nagios port to Tcl) was that the Tcl community (and I like the >> Tcl community a lot) has a strange fixation with not reinventing the >> wheel, even when the wheel would be in Tcl and it might give Tcl more >> exposure. It is what it is though. >> >> -- > > Perhaps because they'd rather do something useful with the tool they've > created instead of trying to win some sort of nonexistent popularity > contest? What value would there be in that? > > Not trying to reinvent the wheel whenever feasible is both good > programming and good engineering most of the time. Unfortunately, the > fact you see this as irksome only paints you in a negative light. > > Adam Right, just because you say it paints me in a negative light. Look at every language out there and look within the groups. Everyone is trying to revinvent the wheel to (in their view) make it better. Your argument is sad to me. -- Robert From perica.zivkovic at gmail.com Sat Jan 1 10:14:02 2011 From: perica.zivkovic at gmail.com (Perica Zivkovic) Date: Sat, 1 Jan 2011 07:14:02 -0800 (PST) Subject: Portable Python challenge - round 1 Message-ID: All, Portable Python challenge - round 1 has started ! Answer one simple question and you can win 4GB USB fingerprint drive. http://www.egistec.com/en/sensors/fingerprintUSB.aspx This round of Portable Python challenge is sponsored by EgisTec Inc. In the future challenges we will test your knowledge of Python programming, Python language concepts and history of the language itself. Follow us and discover more: http://www.PortablePython.com Winner will be announced on the Portable Python project portal by the end of this month. Keep pythoning ! Perica Zivkovic http://www.PortablePython.com From askutt at gmail.com Sat Jan 1 10:34:46 2011 From: askutt at gmail.com (Adam Skutt) Date: Sat, 1 Jan 2011 07:34:46 -0800 (PST) Subject: Nagios In-Reply-To: Message-ID: On Saturday, January 1, 2011 10:00:06 AM UTC-5, Robert H wrote: > > Right, just because you say it paints me in a negative light. Look at > every language out there and look within the groups. Everyone is trying > to revinvent the wheel to (in their view) make it better. "Everyone" is doing nothing of the sort, hence why Tcl "irks" you. Or are you so forgetful that you can't even remember what you said a few days ago? > Your argument is sad to me. At least I've made an argument, whereas you've done nothing of the sort. Just because you take wheel reinvention == good as a tautology doesn't mean everyone else does. Again, what point is there in attempting to win a non-existent popularity contest? Adam From askutt at gmail.com Sat Jan 1 10:34:46 2011 From: askutt at gmail.com (Adam Skutt) Date: Sat, 1 Jan 2011 07:34:46 -0800 (PST) Subject: Nagios In-Reply-To: Message-ID: On Saturday, January 1, 2011 10:00:06 AM UTC-5, Robert H wrote: > > Right, just because you say it paints me in a negative light. Look at > every language out there and look within the groups. Everyone is trying > to revinvent the wheel to (in their view) make it better. "Everyone" is doing nothing of the sort, hence why Tcl "irks" you. Or are you so forgetful that you can't even remember what you said a few days ago? > Your argument is sad to me. At least I've made an argument, whereas you've done nothing of the sort. Just because you take wheel reinvention == good as a tautology doesn't mean everyone else does. Again, what point is there in attempting to win a non-existent popularity contest? Adam From krishna1344 at gmail.com Sat Jan 1 13:33:13 2011 From: krishna1344 at gmail.com (krishna kumar) Date: Sat, 1 Jan 2011 13:33:13 -0500 Subject: python etl tool Message-ID: can u please list out the etl tool which has been devloped in python and it is being used in market now? or just list me the etl tools developed in python? Thanks.... Krishnakumar.A -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjreedy at udel.edu Sat Jan 1 15:10:44 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Sat, 01 Jan 2011 15:10:44 -0500 Subject: How to define a bytes literal in Python 2.x for porting to Python 3.x using 2to3? In-Reply-To: References: Message-ID: On 1/1/2011 5:57 AM, Stefan Behnel wrote: > Terry Reedy, 01.01.2011 11:08: >> On 1/1/2011 4:08 AM, Baptiste Lepilleur wrote: >> >>> Is there a way to mark string literals so that 2to3 automatically >>> prefixes them with 'b'? Is there a simpler trick? >> >> Python 2.7.1 (r271:86832, Nov 27 2010, 18:30:46) [MSC v.1500 32 bit >> (Intel)] on win32 >> Type "copyright", "credits" or "license()" for more information. >> >>> b=b'abc' >> >>> b >> 'abc' >> >> The b prefix does nothing in 2.7. It was specifically added for this type >> of porting problem. > > More precisely, it was added in Python 2.6, so older Python versions > will consider it a syntax error. 'so' here means 'as a consequence' rather than 'with the intention' ;-). > To support older Python versions, you need to write your own wrapper > functions for bytes literals that do nothing in Python 2 and convert the > literal back to a bytes literal in Python 3. That's ugly, but there's no > other way to do it. I think the developers expected that most maintained and updated 2.x code, especially code targeted at 3.x also, would be migrated to 2.6+. -- Terry Jan Reedy From tjreedy at udel.edu Sat Jan 1 15:22:44 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Sat, 01 Jan 2011 15:22:44 -0500 Subject: Portable Python challenge - round 1 In-Reply-To: References: Message-ID: On 1/1/2011 10:14 AM, Perica Zivkovic wrote: > All, > > Portable Python challenge - round 1 has started ! > > Answer one simple question and you can win 4GB USB fingerprint > drive. In exchange for name and email... The question: "What is the exact date (day month and year) of the first Portable Python release ?" > Winner will be announced on the Portable Python project portal by the > end of this month. The idea of Python on a thumbstick is good. However, Distributing quickly superseded Python 3.0, with its known problems, instead of much improved 3.1 is, in my opinion, a disservice to the community. And why 2.6.1 instead of 2.6.6 with perhaps a couple of hundred bugfixes? -- Terry Jan Reedy From perica.zivkovic at gmail.com Sat Jan 1 15:59:49 2011 From: perica.zivkovic at gmail.com (Perica Zivkovic) Date: Sat, 1 Jan 2011 12:59:49 -0800 (PST) Subject: Portable Python challenge - round 1 In-Reply-To: Message-ID: <00dfff75-7469-40fb-a4dc-054cb07548dd@glegroupsg2000goo.googlegroups.com> Hi Terry, when those versions of Portable Python were published, they were the latest available versions of Python. Unfortunately I did not had time to update them since the last release. regards, Perica From perica.zivkovic at gmail.com Sat Jan 1 15:59:49 2011 From: perica.zivkovic at gmail.com (Perica Zivkovic) Date: Sat, 1 Jan 2011 12:59:49 -0800 (PST) Subject: Portable Python challenge - round 1 In-Reply-To: Message-ID: <00dfff75-7469-40fb-a4dc-054cb07548dd@glegroupsg2000goo.googlegroups.com> Hi Terry, when those versions of Portable Python were published, they were the latest available versions of Python. Unfortunately I did not had time to update them since the last release. regards, Perica From rantingrick at gmail.com Sat Jan 1 17:03:11 2011 From: rantingrick at gmail.com (rantingrick) Date: Sat, 1 Jan 2011 14:03:11 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <56d4ecc8-03fb-432a-b728-bebc53f11dec@e16g2000pri.googlegroups.com> <4d1ce2d4$0$29968$c3e8da3$5496439d@news.astraweb.com> <4c682692-dc0f-4055-9587-eb7cce169ef6@g26g2000vbz.googlegroups.com> <661858a7-2eaa-4ba5-a014-0805707f0a3f@p8g2000vbs.googlegroups.com> <6895332e-26dd-4306-ada9-d44533a3c7ab@l8g2000yqh.googlegroups.com> <7de8ad23-5613-46e4-8330-0eaa3d428935@j29g2000yqm.googlegroups.com> <23b1017b-2b14-457d-b4df-0219989940db@f30g2000yqa.googlegroups.com> Message-ID: On Dec 31 2010, 8:47?am, Adam Skutt wrote: Ok, at this point i am not going to respond to the last few posts that where directed at me. What i am going to do is to restate my intentions at the time i started this thread. First and foremost i want everyone to know that i have tons of GUI code that utilizes the Tkinter module and feel very confident crating GUI's with Tkinter. I am not some novice who tried to write up a hello world GUI, got aggravated, and then decided to vent about it. Quite to the contrary... I actually like Tkinter's simplistic API. I especially love Tkinter geometry management! However i realize that TclTk is lacking and because of that fact we will always be at the mercy of another community. This bothers me, and it should also bother you. Tk has a glass ceiling that cannot be broken by you, or me, or anyone in the Python community. If we are to have a GUI library it should be one that is up to date and feature rich. In the latter case there may still be a glass ceiling but it is so high they we will never notice anyway! However be aware that GUI's libraries are large beasts. You cannot cram everything into the stdlib. So what should go into the stdlib then? Well only a very limited subset of widgets. Some might say that you will be limited with a limited subset, well i must agree with argument :). Some might also say that a glass half full is also half empty, duh! Everyone needs to realize that the only reason for having ANY GUI in the Python stdlib is for ease of learning and also for "batteries included". We just want the basics of a GUI with an extension library available for download. There are two major advantages to this setup... 1. The basics never change. So the Python "stdlib GUI module" becomes a "set it and forget it" module. The Python "GUI extension library" can change all it wants and Python remain backwards compatible. 2. By relegating the bloat to an external download the stdlib is kept as small as possible. ... These two talking points are the main idea behind this whole damn discussion i initiated. We need to look beyond our own selfish needs and think about the community first. Anyone who truly cares about Python's stability and future will agree with these two points. I'll repeat... TclTk has had a whole decade to become a 21st century GUI library. I really don't think the motivation is there. Some will argue that ttk brings in the new widgets necessary to compete with a full featured GUI like wxPython -- and they could not be more wrong! There is no real Tk::Grid. Sure as someone suggested you can mimic a grid with another widget, it's just lipstick on a pig really. Go and check out the wx::Grid with all its wonderful capabilities and then you shall be enlightened! This is also no real support for a true Listview widget. Again go check out wx::ListView with all it's capabilities and ye shall be further enlightened. Wx is by far the best choice for Python. A small subset of wx widgets in the stdlib and ONE (and only one!) downloadable extension library. Yes the stdlib widgets are only going to cover the most minimal of GUIs -- for learning purposes, utilities, or just simply toys) If you plan to do professional GUI work than package the extension library. It's very simple really. Geesh! Now i know how the early scientist felt when trying to convince the lemmings that the earth is not flat! Flatearther said: """You heritic!. If the earth were round we would fall off the bottom!""" From martin at v.loewis.de Sat Jan 1 17:07:15 2011 From: martin at v.loewis.de (Martin v. Loewis) Date: Sat, 01 Jan 2011 23:07:15 +0100 Subject: How to define a bytes literal in Python 2.x for porting to Python 3.x using 2to3? In-Reply-To: References: Message-ID: <4D1FA593.7080503@v.loewis.de> >> To support older Python versions, you need to write your own wrapper >> functions for bytes literals that do nothing in Python 2 and convert the >> literal back to a bytes literal in Python 3. That's ugly, but there's no >> other way to do it. > > I think the developers expected that most maintained and updated 2.x > code, especially code targeted at 3.x also, would be migrated to 2.6+. Unfortunately, that assumption has hurt Python 3 migration significantly. It gave the impression that, as long as you need to support Python 2.5 and earlier, there is no way you could possibly support Python 3 as well, and that, therefore, starting to support Python 3 is pointless for many years to come. I personally never shared that assumption, and encourage people to ignore these gimmicks that had been added to 2.6 to ease porting. Instead, people should first determine what Python versions their users want to see supported, and then look for solutions that cover all these versions. In the case of byte literals, the solution is fairly straight-forward, and only moderately ugly. Regards, Martin From tjreedy at udel.edu Sat Jan 1 17:07:42 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Sat, 01 Jan 2011 17:07:42 -0500 Subject: Portable Python challenge - round 1 In-Reply-To: <00dfff75-7469-40fb-a4dc-054cb07548dd@glegroupsg2000goo.googlegroups.com> References: <00dfff75-7469-40fb-a4dc-054cb07548dd@glegroupsg2000goo.googlegroups.com> Message-ID: On 1/1/2011 3:59 PM, Perica Zivkovic wrote: > when those versions of Portable Python were published, they were the > latest available versions of Python. 2.6.1: December 2008; 3.0.1: February 2009 > Unfortunately I did not had time > to update them since the last release. If you have not done any updates in about 20 months, why are you paying people (with a sweepstakes ticket) for name and email? And why put your effort into this instead of producing a much better Python3 release? In spite of efforts otherwise, 3.0 (December 2008) had some typical .0 problems. It was quickly (in 2 months) patched a bit and them abandoned, with 3.1 release soon after (June 2009, without a 3.1.2, as would have been usual) with the recommendation that everyone replace 3.0 with 3.1. Hence my opinion that promoting 3.0(.1) 18 months later is a disservice. Anyone who tries it might get an incorrect bad impression and will certainly not get the benefit of subsequent improvements. -- Terry Jan Reedy From perica.zivkovic at gmail.com Sat Jan 1 17:32:33 2011 From: perica.zivkovic at gmail.com (Perica Zivkovic) Date: Sat, 1 Jan 2011 14:32:33 -0800 (PST) Subject: Portable Python challenge - round 1 In-Reply-To: Message-ID: <7c10baab-1f93-4f0c-b6d9-e07b9d09722f@glegroupsg2000goo.googlegroups.com> Well I'm not paying anybody anything. I'm giving USB sticks for free because I got them for free from our sponsor :) Name and email I need to be able to know where to send them, or you know some easier ways for that ? And thanks for your suggestion but I'm putting my free time where I want while I work on a new release of Portable Python in parallel :) regards, Perica From perica.zivkovic at gmail.com Sat Jan 1 17:32:33 2011 From: perica.zivkovic at gmail.com (Perica Zivkovic) Date: Sat, 1 Jan 2011 14:32:33 -0800 (PST) Subject: Portable Python challenge - round 1 In-Reply-To: Message-ID: <7c10baab-1f93-4f0c-b6d9-e07b9d09722f@glegroupsg2000goo.googlegroups.com> Well I'm not paying anybody anything. I'm giving USB sticks for free because I got them for free from our sponsor :) Name and email I need to be able to know where to send them, or you know some easier ways for that ? And thanks for your suggestion but I'm putting my free time where I want while I work on a new release of Portable Python in parallel :) regards, Perica From tjreedy at udel.edu Sat Jan 1 17:47:58 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Sat, 01 Jan 2011 17:47:58 -0500 Subject: How to define a bytes literal in Python 2.x for porting to Python 3.x using 2to3? In-Reply-To: <4D1FA593.7080503@v.loewis.de> References: <4D1FA593.7080503@v.loewis.de> Message-ID: On 1/1/2011 5:07 PM, Martin v. Loewis wrote: >> I think the developers expected that most maintained and updated 2.x >> code, especially code targeted at 3.x also, would be migrated to 2.6+. > > Unfortunately, that assumption has hurt Python 3 migration > significantly. It gave the impression that, as long as you need to > support Python 2.5 and earlier, there is no way you could possibly > support Python 3 as well, and that, therefore, starting to support > Python 3 is pointless for many years to come. > > I personally never shared that assumption, and encourage people to > ignore these gimmicks that had been added to 2.6 to ease porting. > Instead, people should first determine what Python versions their > users want to see supported, and then look for solutions that cover > all these versions. You have shown that it is easier than some people thought. I think two key ideas are these. 1. Code running in multiple versions has to be syntactically correct in every detail all versions in order to be compiled without error. However, version specific syntax *can* be used in modules that are conditionally imported and therefore conditionally compiled and executed. 2. The syntax of function calls has hardly changed and using the common subset is no limitation for the overwhelming majority of uses. Moreover, function names can be conditionally bound to version-specific function objects, whether builtin or imported. -- Terry Jan Reedy From martin at v.loewis.de Sat Jan 1 17:57:10 2011 From: martin at v.loewis.de (Martin v. Loewis) Date: Sat, 01 Jan 2011 23:57:10 +0100 Subject: How to define a bytes literal in Python 2.x for porting to Python 3.x using 2to3? In-Reply-To: References: <4D1FA593.7080503@v.loewis.de> Message-ID: > 1. Code running in multiple versions has to be syntactically correct in > every detail all versions in order to be compiled without error. > However, version specific syntax *can* be used in modules that are > conditionally imported and therefore conditionally compiled and executed. I also encourage people to use 2to3. Then this requirement (must be syntactically correct in all Python versions) goes away: it is ok to write source that doesn't compile on Python 3, and still *run* it on Python 3. OTOH, writing code that only supports newer 2.x versions isn't helped by 2to3, so compatibility within 2.x is more important to consider than compatibility between 2.x and 3.x. Regards, Martin From askutt at gmail.com Sat Jan 1 18:20:03 2011 From: askutt at gmail.com (Adam Skutt) Date: Sat, 1 Jan 2011 15:20:03 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <56d4ecc8-03fb-432a-b728-bebc53f11dec@e16g2000pri.googlegroups.com> <4d1ce2d4$0$29968$c3e8da3$5496439d@news.astraweb.com> <4c682692-dc0f-4055-9587-eb7cce169ef6@g26g2000vbz.googlegroups.com> <661858a7-2eaa-4ba5-a014-0805707f0a3f@p8g2000vbs.googlegroups.com> <6895332e-26dd-4306-ada9-d44533a3c7ab@l8g2000yqh.googlegroups.com> <7de8ad23-5613-46e4-8330-0eaa3d428935@j29g2000yqm.googlegroups.com> <23b1017b-2b14-457d-b4df-0219989940db@f30g2000yqa.googlegroups.com> Message-ID: On Jan 1, 5:03?pm, rantingrick wrote: > I actually like Tkinter's simplistic API. I especially love Tkinter > geometry management! However i realize that TclTk is lacking and > because of that fact we will always be at the mercy of another > community. This bothers me, and it should also bother you. It's true of any widget library out there. It's inescapable. Python bindings to the native widgets are still at the mercy of MS and Apple (and GTK+ or Qt, whomever you pick for UNIX ). We've seen how much Apple cares about 3rd-party developers, and while MS at least cares, you never know when or how they'll implement something. Look at the mess with the ribbon, for example. There's the Office version, an MFC/ Win32/COM version, and a WPF version. Not only do all three have slightly different APIs, they all behave slightly differently too w.r.t the end-user. Even a "pure python" GUI library cannot get rid of this problem entirely. Witness that Xlib is (slowly) being deprecated for XCB[1]. It's possible, though unlikely, that MS will eventually stop providing new functionality through Win32 and/or make radical changes. It's also possible, though unlikely, that Apple will eventually pull another stunt on the level of deprecating Carbon and rip apart Quartz. Any of those changes would require drastic implementation changes on the part of the python GUI library. It's inescapable, so it's generally best not to worry about it. > However be aware that GUI's libraries are large beasts. You cannot > cram everything into the stdlib. Who says? Java does. Android does. Microsoft does. Apple does. > So what should go into the stdlib then? > Well only a very limited subset of widgets. Some might say that > you will be limited with a limited subset, well i must agree with > argument :). Some might also say that a glass half full is also half > empty, duh! No, not 'duh'. You have to explain what the utility of doing such a thing is, as the utility is not apparent in the least. You also need to explain how this is actually accomplished. I don't see it as a trivial task, especially if the implementation path is to wrap something else. What we have now is about as minimal as things are going to get. > > Everyone needs to realize that the only reason for having ANY GUI in > the Python stdlib is for ease of learning and also for "batteries > included". We just want the basics of a GUI with an extension library > available for download. There are two major advantages to this > setup... > > 1. The basics never change. So the Python "stdlib GUI module" becomes > a "set it and forget it" module. The Python "GUI extension library" > can change all it wants and Python remain backwards compatible. > No, I don't see how this follows in the least, especially if the implementation path is, "wrap something else". But even in the pure Python case, most (nearly all) GUI applications will rely on the extension library, so it will not be able to change all it wants. > 2. By relegating the bloat to an external download the stdlib is kept > as small as possible. > It's not apparent why this is desirable to me. Even if we take it as a tautology, you need to show the value and means for splitting up a GUI library. Your cutting may result in their being more value by not including a GUI at all. Trivial proof: if everyone ends up needing to download the extension library anyway, you incur no cost for anyone and make the standard library smaller by not including any GUI functionality. So go on, show us a minimized, functional widget set and what we can do with it. We're all pretty eagerly awaiting such a thing. > There is no real Tk::Grid. Sure as someone suggested you can mimic a > grid with another widget, it's just lipstick on a pig really. Go and > check out the wx::Grid with all its wonderful capabilities and then > you shall be enlightened! > TkTable seems to do everything wx::Grid[sic] can do. I didn't check fully, as it's your claim, so your responsibility to show the inadequacies, especially since you don't even seem to be aware of TkTable's existence. The biggest missing feature seems to be DnD support, AFAICT. BFD to me, since I've never actually encounterd DnD support worth a damn ever and have always ended up doing it manually. > Wx is by far the best choice for Python. A small subset of wx widgets > in the stdlib and ONE (and only one!) downloadable extension library. > Yes the stdlib widgets are only going to cover the most minimal of > GUIs -- for learning purposes, utilities, or just simply toys) If you > plan to do professional GUI work than package the extension library. > It's very simple really. > Why split it, if you use wx[sic]? All that saves you is a few .py/.c files in the stdlib. You still need the full wxWidgets install to build even the "minimal set", which is pointless and stupid. The costly part with wxWidgets is depending on the native library, not the amount of code in the stdlib. Again, do you think the various Tk bindings fall along library lines just for fun, or that there just possibly might be a method to the madness? > Geesh! Now i know how the early scientist felt when trying to convince > the lemmings that the earth is not flat! > > Flatearther said: """You heritic!. If the earth were round we would > fall off the bottom!""" You can pretend you're being persecuted all you want, but it really only furthers the opinion that you're completely and fully disconnected from reality. The torches you see are entirely of your own imagination. Adam [1] In the case of X, you could write your own protocol library, but then when the protocol changes... From sigzero at gmail.com Sat Jan 1 18:21:59 2011 From: sigzero at gmail.com (Robert) Date: Sat, 1 Jan 2011 18:21:59 -0500 Subject: Nagios References: Message-ID: On 2011-01-01 10:34:46 -0500, Adam Skutt said: > On Saturday, January 1, 2011 10:00:06 AM UTC-5, Robert H wrote: >> >> Right, just because you say it paints me in a negative light. Look at >> every language out there and look within the groups. Everyone is trying >> to revinvent the wheel to (in their view) make it better. > > "Everyone" is doing nothing of the sort, hence why Tcl "irks" you. Or > are you so forgetful that you can't even remember what you said a few > days ago? Really? How many templating systems does Python have? More than one? Why is that? How many web frameworks does Perl have? More than one? Why is that? Why *was* Nagios forked and re-written in Python? There are too many examples to count. > >> Your argument is sad to me. > > At least I've made an argument, whereas you've done nothing of the > sort. Just because you take wheel reinvention == good as a tautology > doesn't mean everyone else does. Again, what point is there in > attempting to win a non-existent popularity contest? > > Adam Just gave you a bunch. You have totally missed the whole point of the original argument. Nice job. Done with you now. -- Robert From sigzero at gmail.com Sat Jan 1 18:26:31 2011 From: sigzero at gmail.com (Robert) Date: Sat, 1 Jan 2011 18:26:31 -0500 Subject: Nagios References: Message-ID: On 2011-01-01 10:34:46 -0500, Adam Skutt said: > On Saturday, January 1, 2011 10:00:06 AM UTC-5, Robert H wrote: >> >> Right, just because you say it paints me in a negative light. Look at >> every language out there and look within the groups. Everyone is trying >> to revinvent the wheel to (in their view) make it better. > > "Everyone" is doing nothing of the sort, hence why Tcl "irks" you. Or > are you so forgetful that you can't even remember what you said a few > days ago? > >> Your argument is sad to me. > > At least I've made an argument, whereas you've done nothing of the > sort. Just because you take wheel reinvention == good as a tautology > doesn't mean everyone else does. Again, what point is there in > attempting to win a non-existent popularity contest? > > Adam I want to apologize for my part. We just aren't going to see the same side of this. -- Robert From cmpython at gmail.com Sat Jan 1 18:39:41 2011 From: cmpython at gmail.com (CM) Date: Sat, 1 Jan 2011 15:39:41 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <56d4ecc8-03fb-432a-b728-bebc53f11dec@e16g2000pri.googlegroups.com> <4d1ce2d4$0$29968$c3e8da3$5496439d@news.astraweb.com> <4c682692-dc0f-4055-9587-eb7cce169ef6@g26g2000vbz.googlegroups.com> <661858a7-2eaa-4ba5-a014-0805707f0a3f@p8g2000vbs.googlegroups.com> <6895332e-26dd-4306-ada9-d44533a3c7ab@l8g2000yqh.googlegroups.com> <7de8ad23-5613-46e4-8330-0eaa3d428935@j29g2000yqm.googlegroups.com> <23b1017b-2b14-457d-b4df-0219989940db@f30g2000yqa.googlegroups.com> Message-ID: Rantingrick, Find a closet in your home, go inside, turn off the lights, and shout into a thermos; that will likely have a similar result as these posts on the state of GUI libraries in Python. There is something admirable about the FOSS philosophy of "You want it? You make it". And I don't see this as a problem anyway. I wanted to do GUI programming in Python, so I read a bit, chose wxPython, downloaded it, and started learning it. Done. From askutt at gmail.com Sat Jan 1 18:55:42 2011 From: askutt at gmail.com (Adam Skutt) Date: Sat, 1 Jan 2011 15:55:42 -0800 (PST) Subject: Nagios References: Message-ID: <22c9af69-a6aa-4a7c-b82c-43d677433949@30g2000yql.googlegroups.com> On Jan 1, 6:21?pm, Robert wrote: > > Really? How many templating systems does Python have? More than one? > Why is that? How many web frameworks does Perl have? More than one? Why > is that? > > Why *was* Nagios forked and re-written in Python? > > There are too many examples to count. > You're missing the point: you've yet to provide any sort of argument whatsoever. It's not automatically true that rewriting Nagios in Tcl would gain the Tcl community more exposure, nor is it automatically true that more exposure is a good or desirable thing. You first have to show how rewriting Nagios in Tcl would gain them more exposure. Then you have to show that the exposure would be a good thing. Until you've done both, you're arguing with very fundamental and conventional engineering wisdom; and you have not actually presented an argument just tautologies. Neither will be easy to prove, by and by large, most people don't give a shit what language their applications are written in and rightly so. > Just gave you a bunch. No, you've given me examples of wheel reinvention. Just because the people reinventing the wheel thought it was a good thing doesn't actually make it so. You personally have to present the case as to why it is a good thing. > I want to apologize for my part. We just aren't going to see the same > side of this. You can apologize, but I don't accept it. You want to actually apologize? Admit you were wrong and retract, or act like an adult and present an actual argument instead of wasting time. Adam From gert.cuykens at gmail.com Sat Jan 1 19:26:09 2011 From: gert.cuykens at gmail.com (gert) Date: Sat, 1 Jan 2011 16:26:09 -0800 (PST) Subject: wiki language Message-ID: I can't get the space betweeen \ " to work, what am I doing wrong? http://pypi.python.org/pypi/appwsgi | Install python3_ and launch the server_ | | All the examples are sending ajax packages, no html is being generated by the server. Pleas take a look at the source code and consider this technique in your future projects. | | client request | | \{"cmd":"order", | \ "sid":"bac0c1f9a9362f9e", | \ "input":"..."} | | server response | | \{"cmd":"order", | \ "sid":"bac0c1f9a9362f9e", | \ "uid":"gert", | \ "gid":"admin", | \ "output":"..."} .. _python3: http://python.org/download/ .. _server: http://appwsgi.googlecode.com/files/server.py From rantingrick at gmail.com Sat Jan 1 19:39:24 2011 From: rantingrick at gmail.com (rantingrick) Date: Sat, 1 Jan 2011 16:39:24 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <4d1ce2d4$0$29968$c3e8da3$5496439d@news.astraweb.com> <4c682692-dc0f-4055-9587-eb7cce169ef6@g26g2000vbz.googlegroups.com> <661858a7-2eaa-4ba5-a014-0805707f0a3f@p8g2000vbs.googlegroups.com> <6895332e-26dd-4306-ada9-d44533a3c7ab@l8g2000yqh.googlegroups.com> <7de8ad23-5613-46e4-8330-0eaa3d428935@j29g2000yqm.googlegroups.com> <23b1017b-2b14-457d-b4df-0219989940db@f30g2000yqa.googlegroups.com> Message-ID: On Jan 1, 5:39?pm, CM wrote: > And I don't see this as a problem anyway. ?I wanted to do GUI > programming in Python, so I read a bit, chose wxPython, downloaded it, > and started learning it. ?Done. I, I, I...Me,Me,Me. Seems you are only concerned about yourself CM. However this a community discussion. You must put your wants and needs in the backseat before you can see what is best for the Python community as a whole. From tyler at tysdomain.com Sat Jan 1 19:54:38 2011 From: tyler at tysdomain.com (Littlefield, Tyler) Date: Sat, 01 Jan 2011 17:54:38 -0700 Subject: nagios Message-ID: <4D1FCCCE.1030403@tysdomain.com> Adam, Frankly, I am getting really tired of listening to you. I've seen numerous good posts on this list, some post more good quality information and arguments than others, and so far I have yet to see any post of yours where you do not resort to insults and totally avoid the argument. I understand people have different views, but all you are doing is insulting anyone who dares not to agree with you, while making yourself look childish and pathetic in the attempt. So: Eeither 1) Shut up and quit wasting bandwidth, or 2) Grow up and recognize that your being rude is not going to get you anywhere. If you have different views, that's great, but your resorting to insults for lack of anything better is getting really old. While I do recognize that this isn't much better than what you are posting, I hope that you will read it or that something will be done about your responses, as they are contributing nothing at all useful to any discussions. On 1/1/2011 4:55 PM, Adam Skutt wrote: > On Jan 1, 6:21 pm, Robert wrote: >> Really? How many templating systems does Python have? More than one? >> Why is that? How many web frameworks does Perl have? More than one? Why >> is that? >> >> Why *was* Nagios forked and re-written in Python? >> >> There are too many examples to count. >> > You're missing the point: you've yet to provide any sort of argument > whatsoever. It's not automatically true that rewriting Nagios in Tcl > would gain the Tcl community more exposure, nor is it automatically > true that more exposure is a good or desirable thing. > > You first have to show how rewriting Nagios in Tcl would gain them > more exposure. Then you have to show that the exposure would be a > good thing. Until you've done both, you're arguing with very > fundamental and conventional engineering wisdom; and you have not > actually presented an argument just tautologies. > > Neither will be easy to prove, by and by large, most people don't give > a shit what language their applications are written in and rightly so. > >> Just gave you a bunch. > No, you've given me examples of wheel reinvention. Just because the > people reinventing the wheel thought it was a good thing doesn't > actually make it so. You personally have to present the case as to > why it is a good thing. > >> I want to apologize for my part. We just aren't going to see the same >> side of this. > You can apologize, but I don't accept it. You want to actually > apologize? Admit you were wrong and retract, or act like an adult and > present an actual argument instead of wasting time. > > Adam -- Thanks, Ty From fabiofz at gmail.com Sat Jan 1 20:37:06 2011 From: fabiofz at gmail.com (Fabio Zadrozny) Date: Sat, 1 Jan 2011 23:37:06 -0200 Subject: Pydev 1.6.4 Released Message-ID: Hi All, Pydev 1.6.4 has been released Details on Pydev: http://pydev.org Details on its development: http://pydev.blogspot.com Release Highlights: ------------------------------- * Improved Unittest integration: o Created a PyUnit view (with a red/green bar) which can be used to see the results of tests and relaunching them o The default test runner now allows parallel execution (distributing tests by module or individually) o The nose and py.test test runners are also supported now * Major Bug Fixed: existing interpreters could be corrupted when adding a new one * Fixed AttributeError on console startup in Python 3.0 * Added theming and automatic sash orientation to the pydev code coverage view * Patch by frigo7: When creating a new remote debugger target, the terminated ones are removed * Patch by frigo7: compare editor properly showing the revision information and fixed broken shortcuts (e.g.: ctrl+z) * Read-only files no longer editable in pydev actions * Fixed issue of remaining \r on python 3.0 on input() * The pydev parser is now properly dealing with bom (utf-8) * Assign to local: if method starts with '_', the leading '_' is not added to the local What is PyDev? --------------------------- PyDev is a plugin that enables users to use Eclipse for Python, Jython and IronPython development -- making Eclipse a first class Python IDE -- It comes with many goodies such as code completion, syntax highlighting, syntax analysis, refactor, debug and many others. Cheers, -- Fabio Zadrozny ------------------------------------------------------ Software Developer Aptana http://aptana.com/ Pydev - Python Development Environment for Eclipse http://pydev.org http://pydev.blogspot.com From rich at noir.com Sat Jan 1 20:55:10 2011 From: rich at noir.com (K. Richard Pixley) Date: Sat, 01 Jan 2011 17:55:10 -0800 Subject: @property; @classmethod; def f() Message-ID: <2WQTo.29689$Qi5.28495@newsfe01.iad> Can anyone explain to me why this doesn't work? class Foo(object): @property @classmethod def f(cls): return 4 I mean, I think it seems to be syntactically clear what I'm trying to accomplish. What am I missing? --rich From Joshua.R.English at gmail.com Sat Jan 1 20:59:33 2011 From: Joshua.R.English at gmail.com (Josh English) Date: Sat, 1 Jan 2011 17:59:33 -0800 (PST) Subject: Multiple instances and wrong parental links Message-ID: <1137ce0f-cc28-4aae-a3d1-2cda66ac389a@glegroupsg2000goo.googlegroups.com> I have hit yet another wall. I am dynamically creating a class and then creating instances of that class. The class relies on a second class to store a list of objects. (This is simplified from the the original by a factor of about 20. The real program is trying to create a Python object around an XML definition object.) Here's the code: ## OPTION ONE for class: ElementList ### Not really a list, but a wrapper that behaves like a list class ElementList(object): def __init__(self, parent, name): self._parent = parent self._name = name def MakeWrapper(checker, _addNameAsAttribute = False ): ## OPTION TWO for class: ElementList class Wrap(object): ## OPTION THREE for class: Elementlist def __init__(self, name): self._name = name setattr(Wrap, 'stuff', ElementList(self, 'test')) Wrap.__name__= checker.title() return Wrap if __name__ == '__main__': Dude = MakeWrapper('Dude') print Dude d1 = Dude('Josh') print d1, d1.stuff # creating the second instance changes the behavior of the subclass d2 = Dude('Ben') print d2, d2.stuff print d1.stuff._parent print d2.stuff._parent #creating a third instance changes the behavior of all the subclasses d3 = Dude('David') print d3, d3.stuff print d1.stuff._parent, d2.stuff._parent, d3.stuff._parent ## END CODE And here is the output: >>> <__main__.Dude object at 0x00DFB930> <__main__.ElementList object at 0x00DFB950> <__main__.Dude object at 0x00DFB730> <__main__.ElementList object at 0x00DFB770> <__main__.Dude object at 0x00DFB730> <__main__.Dude object at 0x00DFB730> <__main__.Dude object at 0x00DFB870> <__main__.ElementList object at 0x00DFB9B0> <__main__.Dude object at 0x00DFB870> <__main__.Dude object at 0x00DFB870> <__main__.Dude object at 0x00DFB870> The 'stuff' attribute is an ElementList object linked back to the parent instance, but every time I create an instance, every instance's 'stuff' links back to the last instance created. I'm not sure why this is happening, or how to prevent it. Any suggestions? From ian.g.kelly at gmail.com Sat Jan 1 21:42:09 2011 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Sat, 01 Jan 2011 19:42:09 -0700 Subject: @property; @classmethod; def f() In-Reply-To: <2WQTo.29689$Qi5.28495@newsfe01.iad> References: <2WQTo.29689$Qi5.28495@newsfe01.iad> Message-ID: On 1/1/2011 6:55 PM, K. Richard Pixley wrote: > Can anyone explain to me why this doesn't work? > > class Foo(object): > @property > @classmethod > def f(cls): > return 4 > > I mean, I think it seems to be syntactically clear what I'm trying to > accomplish. What am I missing? First, because classmethod returns a classmethod instance, not a function, so what gets passed to property is the classmethod descriptor, not an actual callable. Second, because a property descriptor just returns itself when accessed on the class. It only works on instances. To do what you want, I think you would need to write your own descriptor class. Something like this: class classproperty(object): def __init__(self, getter): self._getter = getter def __get__(self, instance, owner): return self._getter(owner) class Foo(object): @classproperty def f(cls): return 4 Modify as needed if you want to accomodate setters and deleters as well. Cheers, Ian From marc at marchankin.com Sat Jan 1 23:53:47 2011 From: marc at marchankin.com (marceepoo) Date: Sat, 1 Jan 2011 20:53:47 -0800 (PST) Subject: pyWin32 attempted installation; Error message: Skipping exchdapi: No library 'Ex2KSdk' Message-ID: <5b0d857d-3e1b-4426-9b86-7c558b774872@glegroupsg2000goo.googlegroups.com> I just downloaded pyWin32 (https://sourceforge.net/projects/pywin32/) and started to install it. I get these error msgs: Skipping exchange: No library 'Ex2KSdk' Skipping exchdapi: No library 'Ex2KSdk' Skipping directsound: The header 'dsound.h' can not be located Does anyone have any suggestions about how to address this? Thanks, Marceepoo From cbrown at cbrownsystems.com Sun Jan 2 00:57:15 2011 From: cbrown at cbrownsystems.com (ChasBrown) Date: Sat, 1 Jan 2011 21:57:15 -0800 (PST) Subject: Multiple instances and wrong parental links References: <1137ce0f-cc28-4aae-a3d1-2cda66ac389a@glegroupsg2000goo.googlegroups.com> Message-ID: On Jan 1, 5:59 pm, Josh English wrote: > I have hit yet another wall. I am dynamically creating a class and then creating instances of that class. The class relies on a second class to store a list of objects. (This is simplified from the the original by a factor of about 20. The real program is trying to create a Python object around an XML definition object.) > > Here's the code: > > ## OPTION ONE for class: ElementList > ### Not really a list, but a wrapper that behaves like a list > class ElementList(object): > def __init__(self, parent, name): > self._parent = parent > self._name = name > > def MakeWrapper(checker, _addNameAsAttribute = False ): > > ## OPTION TWO for class: ElementList > class Wrap(object): > > ## OPTION THREE for class: Elementlist > > def __init__(self, name): > self._name = name > setattr(Wrap, 'stuff', ElementList(self, 'test')) > > Wrap.__name__= checker.title() > > return Wrap > > if __name__ == '__main__': > > Dude = MakeWrapper('Dude') > print Dude > d1 = Dude('Josh') > print d1, d1.stuff > > # creating the second instance changes the behavior of the subclass > d2 = Dude('Ben') > print d2, d2.stuff > print d1.stuff._parent > print d2.stuff._parent > > #creating a third instance changes the behavior of all the subclasses > d3 = Dude('David') > print d3, d3.stuff > print d1.stuff._parent, d2.stuff._parent, d3.stuff._parent > > ## END CODE > > And here is the output: > > > > > <__main__.Dude object at 0x00DFB930> <__main__.ElementList object at 0x00DFB950> > <__main__.Dude object at 0x00DFB730> <__main__.ElementList object at 0x00DFB770> > <__main__.Dude object at 0x00DFB730> > <__main__.Dude object at 0x00DFB730> > <__main__.Dude object at 0x00DFB870> <__main__.ElementList object at 0x00DFB9B0> > <__main__.Dude object at 0x00DFB870> <__main__.Dude object at 0x00DFB870> <__main__.Dude object at 0x00DFB870> > > The 'stuff' attribute is an ElementList object linked back to the parent instance, but every time I create an instance, every instance's 'stuff' links back to the last instance created. > If every instance's is the same, one guesses that the has a class scope, rather than an instance scope. > I'm not sure why this is happening, or how to prevent it. > It's perfectly predictable; to understand what is happening, compare: >>> def foo(): class Bar(object): def __init__(self): setattr(Bar, 'stuff', {}) return Bar >>> Dude = foo() >>> a = Dude() >>> b = Dude() >>> a.stuff['foo'] = 2 >>> b.stuff {'foo': 2} >>> c = Dude() >>> a.stuff {} with the behavior (which I think you expected) of: >>> def foo(): class Bar(object): def __init__(self): setattr(self, 'stuff', {}) return Bar >>> Dude = foo() >>> a = Dude() >>> b = Dude() >>> a.stuff['foo'] = 2 >>> b.stuff {} >>> c = Dude() >>> a.stuff {'foo': 2} Cheers - Chas From steve+comp.lang.python at pearwood.info Sun Jan 2 02:18:48 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 02 Jan 2011 07:18:48 GMT Subject: @property; @classmethod; def f() References: <2WQTo.29689$Qi5.28495@newsfe01.iad> Message-ID: <4d2026d8$0$29968$c3e8da3$5496439d@news.astraweb.com> On Sat, 01 Jan 2011 17:55:10 -0800, K. Richard Pixley wrote: > Can anyone explain to me why this doesn't work? > > class Foo(object): > @property > @classmethod > def f(cls): > return 4 What does "doesn't work" mean? It works for me: >>> class Foo(object): ... @property ... @classmethod ... def f(cls): ... return 4 ... >>> There is no syntax error, the class is created, it works fine. What were you expecting to happen? If you instantiate the class and try accessing the property, you get the expected runtime error: >>> x = Foo() >>> x.f Traceback (most recent call last): File "", line 1, in TypeError: 'classmethod' object is not callable (Admittedly, *you* might not have expected it, but nevertheless...) property() expects a callable object, not a classmethod object, so naturally it fails. Admittedly, it's a little unexpected that classmethods aren't callable, but they're not: >>> classmethod(lambda x: 42)() Traceback (most recent call last): File "", line 1, in TypeError: 'classmethod' object is not callable Don't confuse the classmethod object with a class method (note the space!). Class methods are what you get once the descriptor mechanism kicks into action behind the scenes. classmethod objects are the descriptors that create class methods (note space) when required: >>> cm = classmethod(lambda x: 42).__get__(Spam) # descriptor protocol >>> cm of > >>> cm() 42 > I mean, I think it seems to be syntactically clear what I'm trying to > accomplish. What am I missing? An understanding of the dark and murky waters of descriptor black magic :) http://docs.python.org/howto/descriptor.html (It's not really that dark and murky. It's actually amazingly simple.) My recommendation is, forget the classmethod. A combination of property with class attributes and self.__class__ will get you what you want. Otherwise, just create your own descriptor object. The How To above shows pure-python versions of classmethod and staticmethod. -- Steven From nagle at animats.com Sun Jan 2 02:21:53 2011 From: nagle at animats.com (John Nagle) Date: Sat, 01 Jan 2011 23:21:53 -0800 Subject: Multiple instances and wrong parental links In-Reply-To: References: <1137ce0f-cc28-4aae-a3d1-2cda66ac389a@glegroupsg2000goo.googlegroups.com> Message-ID: <4d20278b$0$44015$742ec2ed@news.sonic.net> On 1/1/2011 9:57 PM, ChasBrown wrote: > setattr(Wrap, 'stuff', ElementList(self, 'test')) Right. As the previous poster wrote, that line is the basic problem. It's not entirely clear what you're trying to do, but it seems to be overly complex. You could have Wrap inherit from ElementList, if you want each Wrap class to be a subclsss of ElementList. Or simply have a line in the __init__ of Wrap like self.something = ElementList(self, whatever) John Nagle From alonmozilla at gmail.com Sun Jan 2 02:26:50 2011 From: alonmozilla at gmail.com (azakai) Date: Sat, 1 Jan 2011 23:26:50 -0800 (PST) Subject: CPython on the Web Message-ID: <19141efb-a288-43bc-be0d-44769bf5974b@j32g2000prh.googlegroups.com> Hello, I hope this will be interesting to people here: CPython running on the web, http://syntensity.com/static/python.html That isn't a new implementation of Python, but rather CPython 2.7.1, compiled from C to JavaScript using Emscripten and LLVM. For more details on the conversion process, see http://emscripten.org This is a work in progress, main issues right now are that the code isn't optimized (so don't expect good performance), and importing non- static modules doesn't work. Otherwise, though, it seems to run properly, in particular it runs all the examples in http://wiki.python.org/moin/SimplePrograms that don't rely on importing modules or receiving input from the user (with perhaps some minor formatting errors). The demo runs fine on recent versions of Firefox, Chrome and Safari, but has problems on IE9 and Opera (hopefully those will be resolved soon). The idea is that by compiling CPython itself, all the features of the language are immediately present, and at the latest version, unlike writing a new implementation which takes time and tends to lag behind. As to why run it on the web, there could be various uses, for example it could allow a simple learning environment for Python, which since it's on the web can be entered immediately without any download (and would run even in places where Python normally can't, like say an iPad). Feedback would be very welcome! - azakai From steve+comp.lang.python at pearwood.info Sun Jan 2 02:29:53 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 02 Jan 2011 07:29:53 GMT Subject: Multiple instances and wrong parental links References: <1137ce0f-cc28-4aae-a3d1-2cda66ac389a@glegroupsg2000goo.googlegroups.com> Message-ID: <4d202971$0$29968$c3e8da3$5496439d@news.astraweb.com> On Sat, 01 Jan 2011 17:59:33 -0800, Josh English wrote: > I have hit yet another wall. I am dynamically creating a class and then > creating instances of that class. The class relies on a second class to > store a list of objects. (This is simplified from the the original by a > factor of about 20. Sounds like it's about 40 times too complex then: aim for something about half the complexity of this "simplified" version. > The real program is trying to create a Python object > around an XML definition object.) > > Here's the code: > > ## OPTION ONE for class: ElementList > ### Not really a list, but a wrapper that behaves like a list class > ElementList(object): > def __init__(self, parent, name): > self._parent = parent > self._name = name Doesn't behave much like a list for me :) > def MakeWrapper(checker, _addNameAsAttribute = False ): > ## OPTION TWO for class: ElementList > class Wrap(object): > ## OPTION THREE for class: Elementlist > def __init__(self, name): > self._name = name > setattr(Wrap, 'stuff', ElementList(self, 'test')) > Wrap.__name__= checker.title() > return Wrap Your problem is that all the instances from a MakeWrapper class share the same "stuff" attribute, which is attached to the class Wrap. What you probably want is: setattr(self, 'stuff', ElementList(self, 'test')) instead. What you *need* is to rethink this complicated strategy for a simpler one. -- Steven From kevin.p.dwyer at gmail.com Sun Jan 2 05:27:36 2011 From: kevin.p.dwyer at gmail.com (Kev Dwyer) Date: Sun, 2 Jan 2011 10:27:36 +0000 (UTC) Subject: pyWin32 attempted installation; Error message: Skipping exchdapi: No library 'Ex2KSdk' References: <5b0d857d-3e1b-4426-9b86-7c558b774872@glegroupsg2000goo.googlegroups.com> Message-ID: On Sat, 01 Jan 2011 20:53:47 -0800, marceepoo wrote: > I just downloaded pyWin32 (https://sourceforge.net/projects/pywin32/) > and started to install it. > > I get these error msgs: > > Skipping exchange: No library 'Ex2KSdk' Skipping exchdapi: No library > 'Ex2KSdk' Skipping directsound: The header 'dsound.h' can not be located > > Does anyone have any suggestions about how to address this? > > Thanks, Marceepoo Are you using the binary installer or building from source? Cf http://stackoverflow.com/questions/4476764/pywin32-support-trouble-while-building-syntax-error Cheers, Kev From stefan_ml at behnel.de Sun Jan 2 07:11:56 2011 From: stefan_ml at behnel.de (Stefan Behnel) Date: Sun, 02 Jan 2011 13:11:56 +0100 Subject: How to define a bytes literal in Python 2.x for porting to Python 3.x using 2to3? In-Reply-To: References: <4D1FA593.7080503@v.loewis.de> Message-ID: Terry Reedy, 01.01.2011 23:47: > 1. Code running in multiple versions has to be syntactically correct in > every detail all versions in order to be compiled without error. However, > version specific syntax *can* be used in modules that are conditionally > imported and therefore conditionally compiled and executed. This is something that might also be a suitable solution for the OP's problem. The format strings can be by externalised into an importable module, which can then be duplicated to use the 'b' bytes prefix for Python 3. The obvious drawback is that this moves the strings out of the immediate sight of someone reading the sources, and that it requires the two string modules to be kept in sync. But at least for the synchronisation, a simplistic conversion tool run during installation could do the trick. Stefan From orasnita at gmail.com Sun Jan 2 08:18:02 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Sun, 2 Jan 2011 15:18:02 +0200 Subject: list 2 dict? Message-ID: <0DB6C288B2274DBBA5463E7771349EFB@teddy> Hi, If I want to create a dictionary from a list, is there a better way than the long line below? l = [1, 2, 3, 4, 5, 6, 7, 'a', 8, 'b'] d = dict(zip([l[x] for x in range(len(l)) if x %2 == 0], [l[x] for x in range(len(l)) if x %2 == 1])) print(d) {8: 'b', 1: 2, 3: 4, 5: 6, 7: 'a'} Thanks. Octavian From katie at coderstack.co.uk Sun Jan 2 08:29:03 2011 From: katie at coderstack.co.uk (Katie T) Date: Sun, 2 Jan 2011 13:29:03 +0000 Subject: CPython on the Web In-Reply-To: <19141efb-a288-43bc-be0d-44769bf5974b@j32g2000prh.googlegroups.com> References: <19141efb-a288-43bc-be0d-44769bf5974b@j32g2000prh.googlegroups.com> Message-ID: On Sun, Jan 2, 2011 at 7:26 AM, azakai wrote: > The idea is that by compiling CPython itself, all the features of the > language are immediately present, and at the latest version, unlike > writing a new implementation which takes time and tends to lag behind. > As to why run it on the web, there could be various uses, for example > it could allow a simple learning environment for Python, which since > it's on the web can be entered immediately without any download (and > would run even in places where Python normally can't, like say an > iPad). It looks pretty neat ! - most solutions I've seen involve running Python in a sandbox environment on the server as opposed to on the client desktop. Katie -- CoderStack http://www.coderstack.co.uk/perl-jobs The Software Developer Job Board From ian.g.kelly at gmail.com Sun Jan 2 08:37:59 2011 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Sun, 02 Jan 2011 06:37:59 -0700 Subject: list 2 dict? In-Reply-To: <0DB6C288B2274DBBA5463E7771349EFB@teddy> References: <0DB6C288B2274DBBA5463E7771349EFB@teddy> Message-ID: On 1/2/2011 6:18 AM, Octavian Rasnita wrote: > Hi, > > If I want to create a dictionary from a list, is there a better way than the long line below? > > l = [1, 2, 3, 4, 5, 6, 7, 'a', 8, 'b'] > > d = dict(zip([l[x] for x in range(len(l)) if x %2 == 0], [l[x] for x in range(len(l)) if x %2 == 1])) d = dict(zip(l[0::2], l[1::2])) Or, using the "grouper" function recipe from the itertools documentation: d = dict(grouper(2, l)) Cheers, Ian From stefan.sonnenberg at pythonmeister.com Sun Jan 2 08:40:53 2011 From: stefan.sonnenberg at pythonmeister.com (Stefan Sonnenberg-Carstens) Date: Sun, 02 Jan 2011 14:40:53 +0100 Subject: list 2 dict? In-Reply-To: <0DB6C288B2274DBBA5463E7771349EFB@teddy> References: <0DB6C288B2274DBBA5463E7771349EFB@teddy> Message-ID: <4D208065.1020106@pythonmeister.com> Am 02.01.2011 14:18, schrieb Octavian Rasnita: > l = [1, 2, 3, 4, 5, 6, 7, 'a', 8, 'b'] l = [1, 2, 3, 4, 5, 6, 7, 'a', 8, 'b'] dict(zip(l[0::2],l[1::2])) {8: 'b', 1: 2, 3: 4, 5: 6, 7: 'a'} From python at bdurham.com Sun Jan 2 08:42:08 2011 From: python at bdurham.com (python at bdurham.com) Date: Sun, 02 Jan 2011 08:42:08 -0500 Subject: CPython on the Web In-Reply-To: <19141efb-a288-43bc-be0d-44769bf5974b@j32g2000prh.googlegroups.com> References: <19141efb-a288-43bc-be0d-44769bf5974b@j32g2000prh.googlegroups.com> Message-ID: <1293975728.14009.1413126095@webmail.messagingengine.com> Azakai, WOW! That's incredible!! Thank you for sharing your work with the community. 1. Are there plans to support IE 7 or 8? 2. I'm not sure what you mean by non-static modules? Can we use modules such as json, pickle/cPickle, StringIO/cStringIO? 3. Is there a virtual file system we can take advantage of so calls to open() would work? Malcolm From orasnita at gmail.com Sun Jan 2 08:52:45 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Sun, 2 Jan 2011 15:52:45 +0200 Subject: CPython on the Web References: <19141efb-a288-43bc-be0d-44769bf5974b@j32g2000prh.googlegroups.com> Message-ID: From: "Katie T" Subject: Re: CPython on the Web > On Sun, Jan 2, 2011 at 7:26 AM, azakai wrote: >> The idea is that by compiling CPython itself, all the features of the >> language are immediately present, and at the latest version, unlike >> writing a new implementation which takes time and tends to lag behind. >> As to why run it on the web, there could be various uses, for example >> it could allow a simple learning environment for Python, which since >> it's on the web can be entered immediately without any download (and >> would run even in places where Python normally can't, like say an >> iPad). > > It looks pretty neat ! - most solutions I've seen involve running > Python in a sandbox environment on the server as opposed to on the > client desktop. > > Katie > -- I don't understand what can be this program used for. Can anyone explain please? Ok, I understand that it can be used for learning, which is pretty useless because I doubt that a Python newbie will start using Python and learning Python that way. Then, how can the Python programs run on the "desktop"? I suspect that the Python code is somehow translated to Javascript in order to run on the browser. Am I right? If yes, then how can run a Python code that access a database or one that create a web server, or a WxPython GUI run? If it can run just simple things that prints things in the browser, then why not writing that code directly in JS? As you can see, there are many things I don't understand. :-) Thank you. BTW. I have tried that page, and it appeared a JS error window telling that the JS scripts run too slow and it asked me if I want to continue. I have executed the default Python script, but nothing happend. Nothing was printed. I use Internet Explorer. Octavian From rtw at rtw.me.uk Sun Jan 2 08:56:06 2011 From: rtw at rtw.me.uk (Rob Williscroft) Date: Sun, 2 Jan 2011 13:56:06 +0000 (UTC) Subject: list 2 dict? References: <0DB6C288B2274DBBA5463E7771349EFB@teddy> Message-ID: Octavian Rasnita wrote in news:0DB6C288B2274DBBA5463E7771349EFB at teddy in gmane.comp.python.general: > Hi, > > If I want to create a dictionary from a list, is there a better way > than the long line below? > > l = [1, 2, 3, 4, 5, 6, 7, 'a', 8, 'b'] > > d = dict(zip([l[x] for x in range(len(l)) if x %2 == 0], [l[x] for x > in range(len(l)) if x %2 == 1])) > > print(d) > > {8: 'b', 1: 2, 3: 4, 5: 6, 7: 'a'} >>> dict( zip( l[ :: 2 ], l[ 1 :: 2 ] ) ) {8: 'b', 1: 2, 3: 4, 5: 6, 7: 'a'} If you don't know about slice notation, the synatax I'm using above is: list[ start : stop : step ] where I have ommited the "stop" item, which defaults to the length of the list. That will make 3 lists before it makes the dict thought, so if the list is large: >>> dict( ( l[ i ], l[ i + 1 ] ) for i in xrange( 0, len( l ), 2 ) ) may be better. Rob. From hniksic at xemacs.org Sun Jan 2 09:38:10 2011 From: hniksic at xemacs.org (Hrvoje Niksic) Date: Sun, 02 Jan 2011 15:38:10 +0100 Subject: list 2 dict? References: Message-ID: <87zkrjl6b1.fsf@xemacs.org> "Octavian Rasnita" writes: > If I want to create a dictionary from a list, is there a better way than the long line below? > > l = [1, 2, 3, 4, 5, 6, 7, 'a', 8, 'b'] > > d = dict(zip([l[x] for x in range(len(l)) if x %2 == 0], [l[x] for x in range(len(l)) if x %2 == 1])) > > print(d) > > {8: 'b', 1: 2, 3: 4, 5: 6, 7: 'a'} it = iter(l) d = dict(izip(it, it)) izip is the iterator equivalent of zip, import it from itertools. (Or, if your list is short, just use zip instead.) It can be written in a single short line, at the cost of additional obfuscation: d = dict(izip(*[iter(l)]*2)) From orasnita at gmail.com Sun Jan 2 10:09:38 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Sun, 2 Jan 2011 17:09:38 +0200 Subject: list 2 dict? References: <0DB6C288B2274DBBA5463E7771349EFB@teddy> Message-ID: From: "Rob Williscroft" > Octavian Rasnita wrote in news:0DB6C288B2274DBBA5463E7771349EFB at teddy in > gmane.comp.python.general: > >> Hi, >> >> If I want to create a dictionary from a list, is there a better way >> than the long line below? >> >> l = [1, 2, 3, 4, 5, 6, 7, 'a', 8, 'b'] >> >> d = dict(zip([l[x] for x in range(len(l)) if x %2 == 0], [l[x] for x >> in range(len(l)) if x %2 == 1])) >> >> print(d) >> >> {8: 'b', 1: 2, 3: 4, 5: 6, 7: 'a'} > >>>> dict( zip( l[ :: 2 ], l[ 1 :: 2 ] ) ) > {8: 'b', 1: 2, 3: 4, 5: 6, 7: 'a'} > > If you don't know about slice notation, the synatax I'm using above is: > > list[ start : stop : step ] > > where I have ommited the "stop" item, which defaults to the length of the > list. > > > list-tuple-bytearray-buffer-xrange> > > That will make 3 lists before it makes the dict thought, so if the > list is large: > > >>> dict( ( l[ i ], l[ i + 1 ] ) for i in xrange( 0, len( l ), 2 ) ) > > may be better. Thank you all. I have also discovered that I can zip 2 lists made with range(0, len(l), 2) and range(1, len(l), 2) but I remembered about that the slice notation accepts that third argument and as Stefan suggested, looks to be a shorter way. I have first thought to the solution you suggested, but I have forgotten to create a tuple from the pair of elements so it didn't work. I wasn't thinking to performance, but yes, it may be important for large lists. It seems that in some cases there are more ways to do it in Python than in Perl. :-) Octavian From stefan.sonnenberg at pythonmeister.com Sun Jan 2 10:15:41 2011 From: stefan.sonnenberg at pythonmeister.com (Stefan Sonnenberg-Carstens) Date: Sun, 02 Jan 2011 16:15:41 +0100 Subject: list 2 dict? In-Reply-To: <0DB6C288B2274DBBA5463E7771349EFB@teddy> References: <0DB6C288B2274DBBA5463E7771349EFB@teddy> Message-ID: <4D20969D.6040901@pythonmeister.com> Am 02.01.2011 14:18, schrieb Octavian Rasnita: > Hi, > > If I want to create a dictionary from a list, is there a better way than the long line below? > > l = [1, 2, 3, 4, 5, 6, 7, 'a', 8, 'b'] > > d = dict(zip([l[x] for x in range(len(l)) if x %2 == 0], [l[x] for x in range(len(l)) if x %2 == 1])) > > print(d) > > {8: 'b', 1: 2, 3: 4, 5: 6, 7: 'a'} > > Thanks. > > Octavian > Or so: dict(zip((y for x,y in enumerate(l) if x%2==0),(y for x,y in enumerate(l) if not x%2==0))) From orasnita at gmail.com Sun Jan 2 10:36:35 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Sun, 2 Jan 2011 17:36:35 +0200 Subject: list 2 dict? References: <0DB6C288B2274DBBA5463E7771349EFB@teddy> Message-ID: <3C5DC041709F47AA8F2D738D5AF93574@teddy> From: "Ian Kelly" > On 1/2/2011 6:18 AM, Octavian Rasnita wrote: >> Hi, >> >> If I want to create a dictionary from a list, is there a better way than the long line below? >> >> l = [1, 2, 3, 4, 5, 6, 7, 'a', 8, 'b'] >> >> d = dict(zip([l[x] for x in range(len(l)) if x %2 == 0], [l[x] for x in range(len(l)) if x %2 == 1])) > > d = dict(zip(l[0::2], l[1::2])) > > Or, using the "grouper" function recipe from the itertools documentation: > > d = dict(grouper(2, l)) > > Cheers, > Ian The grouper-way looks nice, but I tried it and it didn't work: from itertools import * ... d = dict(grouper(2, l)) NameError: name 'grouper' is not defined I use Python 2.7. Should it work with this version? Octavian From stefan.sonnenberg at pythonmeister.com Sun Jan 2 11:31:22 2011 From: stefan.sonnenberg at pythonmeister.com (Stefan Sonnenberg-Carstens) Date: Sun, 02 Jan 2011 17:31:22 +0100 Subject: list 2 dict? In-Reply-To: <3C5DC041709F47AA8F2D738D5AF93574@teddy> References: <0DB6C288B2274DBBA5463E7771349EFB@teddy> <3C5DC041709F47AA8F2D738D5AF93574@teddy> Message-ID: <4D20A85A.6080607@pythonmeister.com> Am 02.01.2011 16:36, schrieb Octavian Rasnita: > From: "Ian Kelly" > > >> On 1/2/2011 6:18 AM, Octavian Rasnita wrote: >>> Hi, >>> >>> If I want to create a dictionary from a list, is there a better way than the long line below? >>> >>> l = [1, 2, 3, 4, 5, 6, 7, 'a', 8, 'b'] >>> >>> d = dict(zip([l[x] for x in range(len(l)) if x %2 == 0], [l[x] for x in range(len(l)) if x %2 == 1])) >> d = dict(zip(l[0::2], l[1::2])) >> >> Or, using the "grouper" function recipe from the itertools documentation: >> >> d = dict(grouper(2, l)) >> >> Cheers, >> Ian > > The grouper-way looks nice, but I tried it and it didn't work: > > from itertools import * > ... > d = dict(grouper(2, l)) > > NameError: name 'grouper' is not defined > > I use Python 2.7. Should it work with this version? > Octavian > A last one: l = [1, 2, 3, 4, 5, 6, 7, 'a', 8, 'b'] dict((x[1],x[0]) for x in ((l.pop(),l.pop()) for x in xrange(len(l)/2))) From rockitout117 at yahoo.com Sun Jan 2 12:26:35 2011 From: rockitout117 at yahoo.com (Maurice Shih) Date: Sun, 2 Jan 2011 09:26:35 -0800 (PST) Subject: Python programming Message-ID: <854042.15917.qm@web59802.mail.ac4.yahoo.com> Dear python-list at python.org, I am making a program of the quadratic sieve on python 2.5.2. I am also using sympy to find linear dependencies in mod 2. For example matrix A is : 10110 01101 00011 10000 And using sympy I can type in a command to solve ax=0, which is: 10000=0 01002=0 0010-1=0 00011=0 To find the values of vector x is easy by hand if you assign one value as 1, but I was wondering if I could turn the numbers into letters ( variables) so I could run the solve command in sympy. Thank you for listening to by question and I hope that you can help me. Thank you again. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gervaz at gmail.com Sun Jan 2 12:43:38 2011 From: gervaz at gmail.com (gervaz) Date: Sun, 2 Jan 2011 09:43:38 -0800 (PST) Subject: String building using join References: Message-ID: On 31 Dic 2010, 16:43, Emile van Sebille wrote: > On 12/31/2010 7:22 AM gervaz said... > > > > > > > Hi all, I would like to ask you how I can use the more efficient join > > operation in a code like this: > > >>>> class Test: > > ... ? ? def __init__(self, v1, v2): > > ... ? ? ? ? self.v1 = v1 > > ... ? ? ? ? self.v2 = v2 > > ... > >>>> def prg(l): > > ... ? ? txt = "" > > ... ? ? for x in l: > > ... ? ? ? ? if x.v1 is not None: > > ... ? ? ? ? ? ? txt += x.v1 + "\n" > > ... ? ? ? ? if x.v2 is not None: > > ... ? ? ? ? ? ? txt += x.v2 + "\n" > > ... ? ? return txt > > ... > >>>> t1 = Test("hello", None) > >>>> t2 = Test(None, "ciao") > >>>> t3 = Test("salut", "hallo") > >>>> t = [t1, t2, t3] > > >>>> prg(t) > > 'hello\nciao\nsalut\nhallo\n' > > > The idea would be create a new list with the values not None and then > > use the join function... but I don't know if it is really worth it. > > Any hint? > > >>>> def prg2(l): > > ? ? ? ? ? ? ?return "\n".join([x for x in l if x]) > > Emile > > > > > ... ? ? e = [] > > ... ? ? for x in l: > > ... ? ? ? ? if x.v1 is not None: > > ... ? ? ? ? ? ? e.append(x.v1) > > ... ? ? ? ? if x.v2 is not None: > > ... ? ? ? ? ? ? e.append(x.v2) > > ... ? ? return "\n".join(e) > > ... > >>>> prg2(t) > > 'hello\nciao\nsalut\nhallo' > > > Thanks, Mattia- Nascondi testo citato > > - Mostra testo citato -- Nascondi testo citato > > - Mostra testo citato - Sorry, but it does not work >>> def prg3(l): ... return "\n".join([x for x in l if x]) ... >>> prg3(t) Traceback (most recent call last): File "", line 1, in File "", line 2, in prg3 TypeError: sequence item 0: expected str instance, Test found From gervaz at gmail.com Sun Jan 2 12:56:28 2011 From: gervaz at gmail.com (gervaz) Date: Sun, 2 Jan 2011 09:56:28 -0800 (PST) Subject: Interrput a thread References: <81c24eb1-41b6-442a-a971-8a44d2cd6c1b@p8g2000vbs.googlegroups.com> <4d1e20c5$0$43986$742ec2ed@news.sonic.net> Message-ID: On 31 Dic 2010, 23:25, Alice Bevan?McGregor wrote: > On 2010-12-31 10:28:26 -0800, John Nagle said: > > > Even worse, sending control-C to a multi-thread program > > is unreliable in CPython. ?See "http://blip.tv/file/2232410" > > for why. ?It's painful. > > AFIK, that has been resolved in Python 3.2 with the introduction of an > intelligent thread scheduler as part of the GIL release/acquire process. > > ? ? ? ? - Alice. Ok, but then suppose I have multiple long running threads that I want to delete/suspend because they are tooking too much time, which solution do you propose? Thanks, Mattia From alex at moreati.org.uk Sun Jan 2 13:07:44 2011 From: alex at moreati.org.uk (Alex Willmer) Date: Sun, 2 Jan 2011 10:07:44 -0800 (PST) Subject: list 2 dict? In-Reply-To: Message-ID: <69d86a8a-fef5-4da1-99d0-b6c73a73e748@glegroupsg2000goo.googlegroups.com> On Sunday, January 2, 2011 3:36:35 PM UTC, T wrote: > The grouper-way looks nice, but I tried it and it didn't work: > > from itertools import * > ... > d = dict(grouper(2, l)) > > NameError: name 'grouper' is not defined > > I use Python 2.7. Should it work with this version? No. As Ian said grouper() is a receipe in the itertools documentation. http://docs.python.org/library/itertools.html#recipes The module doesn't provide it directly From alex at moreati.org.uk Sun Jan 2 13:07:44 2011 From: alex at moreati.org.uk (Alex Willmer) Date: Sun, 2 Jan 2011 10:07:44 -0800 (PST) Subject: list 2 dict? In-Reply-To: Message-ID: <69d86a8a-fef5-4da1-99d0-b6c73a73e748@glegroupsg2000goo.googlegroups.com> On Sunday, January 2, 2011 3:36:35 PM UTC, T wrote: > The grouper-way looks nice, but I tried it and it didn't work: > > from itertools import * > ... > d = dict(grouper(2, l)) > > NameError: name 'grouper' is not defined > > I use Python 2.7. Should it work with this version? No. As Ian said grouper() is a receipe in the itertools documentation. http://docs.python.org/library/itertools.html#recipes The module doesn't provide it directly From alex at moreati.org.uk Sun Jan 2 13:11:50 2011 From: alex at moreati.org.uk (Alex Willmer) Date: Sun, 2 Jan 2011 10:11:50 -0800 (PST) Subject: String building using join In-Reply-To: Message-ID: On Sunday, January 2, 2011 5:43:38 PM UTC, gervaz wrote: > Sorry, but it does not work > > >>> def prg3(l): > ... return "\n".join([x for x in l if x]) > ... > >>> prg3(t) > Traceback (most recent call last): > File "", line 1, in > File "", line 2, in prg3 > TypeError: sequence item 0: expected str instance, Test found def prg3(l): return '\n'.join([str(x) for x in l if x]) That should do it From emile at fenx.com Sun Jan 2 13:14:12 2011 From: emile at fenx.com (Emile van Sebille) Date: Sun, 02 Jan 2011 10:14:12 -0800 Subject: String building using join In-Reply-To: References: Message-ID: On 1/2/2011 9:43 AM gervaz said... > On 31 Dic 2010, 16:43, Emile van Sebille wrote: >> On 12/31/2010 7:22 AM gervaz said... >> >> >> >> >> >>> Hi all, I would like to ask you how I can use the more efficient join >>> operation in a code like this: >> >>>>>> class Test: >>> ... def __init__(self, v1, v2): >>> ... self.v1 = v1 >>> ... self.v2 = v2 >>> ... >>>>>> def prg(l): >>> ... txt = "" >>> ... for x in l: >>> ... if x.v1 is not None: >>> ... txt += x.v1 + "\n" >>> ... if x.v2 is not None: >>> ... txt += x.v2 + "\n" >>> ... return txt >>> ... >>>>>> t1 = Test("hello", None) >>>>>> t2 = Test(None, "ciao") >>>>>> t3 = Test("salut", "hallo") >>>>>> t = [t1, t2, t3] >> >>>>>> prg(t) >>> 'hello\nciao\nsalut\nhallo\n' >> >>> The idea would be create a new list with the values not None and then >>> use the join function... but I don't know if it is really worth it. >>> Any hint? >> >>>>>> def prg2(l): >> >> return "\n".join([x for x in l if x]) >> >> Emile >> >> >> >>> ... e = [] >>> ... for x in l: >>> ... if x.v1 is not None: >>> ... e.append(x.v1) >>> ... if x.v2 is not None: >>> ... e.append(x.v2) >>> ... return "\n".join(e) >>> ... >>>>>> prg2(t) >>> 'hello\nciao\nsalut\nhallo' >> >>> Thanks, Mattia- Nascondi testo citato >> >> - Mostra testo citato -- Nascondi testo citato >> >> - Mostra testo citato - > > Sorry, but it does not work Oh -- you want a working solution, not a hint? OK. class Test: def __init__(self, v1, v2): self.v1 = v1 self.v2 = v2 t1 = Test("hello", None) t2 = Test(None, "ciao") t3 = Test("salut", "hallo") t = [t1, t2, t3] "\n".join([y for x in t for y in [x.v1,x.v2] if y]) Emile > >>>> def prg3(l): > ... return "\n".join([x for x in l if x]) > ... >>>> prg3(t) > Traceback (most recent call last): > File "", line 1, in > File "", line 2, in prg3 > TypeError: sequence item 0: expected str instance, Test found From emile at fenx.com Sun Jan 2 13:19:27 2011 From: emile at fenx.com (Emile van Sebille) Date: Sun, 02 Jan 2011 10:19:27 -0800 Subject: list 2 dict? In-Reply-To: <4D20A85A.6080607@pythonmeister.com> References: <0DB6C288B2274DBBA5463E7771349EFB@teddy> <3C5DC041709F47AA8F2D738D5AF93574@teddy> <4D20A85A.6080607@pythonmeister.com> Message-ID: On 1/2/2011 8:31 AM Stefan Sonnenberg-Carstens said... > A last one: > > l = [1, 2, 3, 4, 5, 6, 7, 'a', 8, 'b'] > dict((x[1],x[0]) for x in ((l.pop(),l.pop()) for x in xrange(len(l)/2))) This also works: l = [1, 2, 3, 4, 5, 6, 7, 'a', 8, 'b'] pop=l.pop dict([(pop(),pop()) for i in l]) From emile at fenx.com Sun Jan 2 13:22:02 2011 From: emile at fenx.com (Emile van Sebille) Date: Sun, 02 Jan 2011 10:22:02 -0800 Subject: list 2 dict? In-Reply-To: <4D20A85A.6080607@pythonmeister.com> References: <0DB6C288B2274DBBA5463E7771349EFB@teddy> <3C5DC041709F47AA8F2D738D5AF93574@teddy> <4D20A85A.6080607@pythonmeister.com> Message-ID: On 1/2/2011 8:31 AM Stefan Sonnenberg-Carstens said... Nevermind -- my bad. Emile From catalinfest at gmail.com Sun Jan 2 13:40:45 2011 From: catalinfest at gmail.com (catalinfest at gmail.com) Date: Sun, 2 Jan 2011 10:40:45 -0800 (PST) Subject: Where is win32service Message-ID: <3651f11b-f4cc-4c03-b51f-513a0a85b977@p38g2000vbn.googlegroups.com> I install Python 2.7 on Windows XP. I try use : import win32service import win32serviceutil But I got that error : ImportError: No module named win32service Where is this module ? From stefan.sonnenberg at pythonmeister.com Sun Jan 2 13:42:35 2011 From: stefan.sonnenberg at pythonmeister.com (Stefan Sonnenberg-Carstens) Date: Sun, 02 Jan 2011 19:42:35 +0100 Subject: list 2 dict? In-Reply-To: References: <0DB6C288B2274DBBA5463E7771349EFB@teddy> <3C5DC041709F47AA8F2D738D5AF93574@teddy> <4D20A85A.6080607@pythonmeister.com> Message-ID: <4D20C71B.5000302@pythonmeister.com> Am 02.01.2011 19:19, schrieb Emile van Sebille: > On 1/2/2011 8:31 AM Stefan Sonnenberg-Carstens said... > >> A last one: >> >> l = [1, 2, 3, 4, 5, 6, 7, 'a', 8, 'b'] >> dict((x[1],x[0]) for x in ((l.pop(),l.pop()) for x in xrange(len(l)/2))) > > This also works: > > > l = [1, 2, 3, 4, 5, 6, 7, 'a', 8, 'b'] > > pop=l.pop > > dict([(pop(),pop()) for i in l]) > No, it does not: >>> l = [1, 2, 3, 4, 5, 6, 7, 'a', 8, 'b'] >>> >>> pop=l.pop >>> >>> dict([(pop(),pop()) for i in l]) {'a': 7, 'b': 8, 4: 3, 6: 5} >>> From alex at moreati.org.uk Sun Jan 2 13:58:53 2011 From: alex at moreati.org.uk (Alex Willmer) Date: Sun, 2 Jan 2011 10:58:53 -0800 (PST) Subject: Where is win32service In-Reply-To: <3651f11b-f4cc-4c03-b51f-513a0a85b977@p38g2000vbn.googlegroups.com> Message-ID: <5106f086-85d2-40b3-bc11-ea8e25467947@glegroupsg2000goo.googlegroups.com> On Sunday, January 2, 2011 6:40:45 PM UTC, catalinfest at gmail.com wrote: > I install Python 2.7 on Windows XP. > I try use : > > import win32service > import win32serviceutil > > But I got that error : > > ImportError: No module named win32service > Where is this module ? It's part of the pywin32 (aka win32all) package http://sourceforge.net/projects/pywin32/ The latest download for your Python version is http://sourceforge.net/projects/pywin32/files/pywin32/Build%20214/pywin32-214.win32-py2.7.exe/download Regards, Alex From alonmozilla at gmail.com Sun Jan 2 14:19:56 2011 From: alonmozilla at gmail.com (azakai) Date: Sun, 2 Jan 2011 11:19:56 -0800 (PST) Subject: CPython on the Web References: <19141efb-a288-43bc-be0d-44769bf5974b@j32g2000prh.googlegroups.com> Message-ID: <2d76370f-4866-4428-8a3a-91b29197dc01@c17g2000prm.googlegroups.com> On Jan 2, 5:42?am, pyt... at bdurham.com wrote: > > 1. Are there plans to support IE 7 or 8? I think it might run slowly there, but otherwise sure, it should run - the code is intended to be valid JavaScript (if it isn't, that's a bug). Currently though a minor issue prevents it from running on IE, I have been told (I don't have a Windows machine to test on myself), http://code.google.com/p/emscripten/issues/detail?id=22 > > 2. I'm not sure what you mean by non-static modules? Can we use modules > such as json, pickle/cPickle, StringIO/cStringIO? > Sorry, I should have been more clear. There isn't support for dlopen(), which opens dynamically linked libraries. That means that you can import libraries like sys, which are already linked into python. But loading a module that exists as a separate file won't work yet (but hopefully soon). > 3. Is there a virtual file system we can take advantage of so calls to > open() would work? > No, not yet, the libc implementation used just has stubs for input/ output stuff so far. Work in progress ;) - azakai From alonmozilla at gmail.com Sun Jan 2 14:29:09 2011 From: alonmozilla at gmail.com (azakai) Date: Sun, 2 Jan 2011 11:29:09 -0800 (PST) Subject: CPython on the Web References: <19141efb-a288-43bc-be0d-44769bf5974b@j32g2000prh.googlegroups.com> Message-ID: On Jan 2, 5:52?am, "Octavian Rasnita" wrote: > > Then, how can the Python programs run on the "desktop"? > I suspect that the Python code is somehow translated to Javascript in order to run on the browser. Am I right? To clarify, in this demo, CPython itself - the C implementation of Python - was translated from C to JavaScript (or more specifically, C to LLVM, and LLVM to JavaScript). So your web browser is running the same CPython that you would run on your computer normally. That CPython executes Python by compiling it into bytecode, etc., and that is exactly the same with CPython normally and CPython on the web in this demo. So actual Python code is not translated into JavaScript (which is the approach pyjamas takes), instead the entire interpreter is. > > If yes, then how can run a Python code that access a database or one that create a web server, or a WxPython GUI run? By implementing whatever library functions and system calls CPython needs, in the browser. For example, if the CPython code calls printf() to print stuff, then we need to implement printf() in JavaScript, and so forth. Obviously there are limitations of the JS environment, so not everything can be done. > > BTW. I have tried that page, and it appeared a JS error window telling that the JS scripts run too slow and it asked me if I want to continue. > I have executed the default Python script, but nothing happend. Nothing was printed. I use Internet Explorer. > I've been told it doesn't run properly on IE, we have a bug open on that, sorry. It will work on Firefox, Chrome and Safari right now. - azakai From python.list at tim.thechases.com Sun Jan 2 14:49:36 2011 From: python.list at tim.thechases.com (Tim Chase) Date: Sun, 02 Jan 2011 13:49:36 -0600 Subject: Tkinter: The good, the bad, and the ugly! In-Reply-To: References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <4d1ce2d4$0$29968$c3e8da3$5496439d@news.astraweb.com> <4c682692-dc0f-4055-9587-eb7cce169ef6@g26g2000vbz.googlegroups.com> <661858a7-2eaa-4ba5-a014-0805707f0a3f@p8g2000vbs.googlegroups.com> <6895332e-26dd-4306-ada9-d44533a3c7ab@l8g2000yqh.googlegroups.com> <7de8ad23-5613-46e4-8330-0eaa3d428935@j29g2000yqm.googlegroups.com> <23b1017b-2b14-457d-b4df-0219989940db@f30g2000yqa.googlegroups.com> Message-ID: <4D20D6D0.7000603@tim.thechases.com> On 01/01/2011 06:39 PM, rantingrick wrote: > On Jan 1, 5:39 pm, CM wrote: > >> And I don't see this as a problem anyway. I wanted to do GUI >> programming in Python, so I read a bit, chose wxPython, downloaded it, >> and started learning it. Done. > > I, I, I...Me,Me,Me. > > Seems you are only concerned about yourself CM. However this a > community discussion. You must put your wants and needs in the > backseat before you can see what is best for the Python community as a > whole. Pot? Meet Kettle... Given that the community response has largely been an overwhelming "meh, show me some code" rather than an "I whole-heartedly agree with rantingrick", your use of "we" in your emails sounds more like a "royal we"[1] than a community-based concern. "best for the Python community" seems to be something that doesn't break backwards compat. with existing code-bases, works across a multitude of platforms, has a minimal install footprint, and a proven track-record of meeting those needs. Tkinter and wx both seem to satisfy most of those requirements, except that wx seems to have a larger footprint and not have been production-ready at the time a decision needed to be made for inclusion of a gui-library in Python. (I also don't know if there are licensing concerns with wx vs. tk and their interplay with the Python license). -tkc [1] http://en.wikipedia.org/wiki/Royal_we From cmpython at gmail.com Sun Jan 2 15:52:20 2011 From: cmpython at gmail.com (CM) Date: Sun, 2 Jan 2011 12:52:20 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <4c682692-dc0f-4055-9587-eb7cce169ef6@g26g2000vbz.googlegroups.com> <661858a7-2eaa-4ba5-a014-0805707f0a3f@p8g2000vbs.googlegroups.com> <6895332e-26dd-4306-ada9-d44533a3c7ab@l8g2000yqh.googlegroups.com> <7de8ad23-5613-46e4-8330-0eaa3d428935@j29g2000yqm.googlegroups.com> <23b1017b-2b14-457d-b4df-0219989940db@f30g2000yqa.googlegroups.com> Message-ID: <301e3cfd-68ed-4eac-a7a4-c6b8f9f20c56@g26g2000vbz.googlegroups.com> On Jan 1, 7:39?pm, rantingrick wrote: > On Jan 1, 5:39?pm, CM wrote: > > > And I don't see this as a problem anyway. ?I wanted to do GUI > > programming in Python, so I read a bit, chose wxPython, downloaded it, > > and started learning it. ?Done. > > I, I, I...Me,Me,Me. > > Seems you are only concerned about yourself CM. However this a > community discussion. You must put your wants and needs in the > backseat before you can see what is best for the Python community as a > whole. Must have been too many holiday baked goods that made me even try... From greno at verizon.net Sun Jan 2 16:01:53 2011 From: greno at verizon.net (Gerry Reno) Date: Sun, 02 Jan 2011 16:01:53 -0500 Subject: CPython on the Web In-Reply-To: <19141efb-a288-43bc-be0d-44769bf5974b@j32g2000prh.googlegroups.com> References: <19141efb-a288-43bc-be0d-44769bf5974b@j32g2000prh.googlegroups.com> Message-ID: <4D20E7C1.5070207@verizon.net> On 01/02/2011 02:26 AM, azakai wrote: > Hello, I hope this will be interesting to people here: CPython running > on the web, > > http://syntensity.com/static/python.html > > That isn't a new implementation of Python, but rather CPython 2.7.1, > compiled from C to JavaScript using Emscripten and LLVM. For more > details on the conversion process, see http://emscripten.org > > This is a work in progress, main issues right now are that the code > isn't optimized (so don't expect good performance), and importing non- > static modules doesn't work. Otherwise, though, it seems to run > properly, in particular it runs all the examples in > http://wiki.python.org/moin/SimplePrograms that don't rely on > importing modules or receiving input from the user (with perhaps some > minor formatting errors). The demo runs fine on recent versions of > Firefox, Chrome and Safari, but has problems on IE9 and Opera > (hopefully those will be resolved soon). > > The idea is that by compiling CPython itself, all the features of the > language are immediately present, and at the latest version, unlike > writing a new implementation which takes time and tends to lag behind. > As to why run it on the web, there could be various uses, for example > it could allow a simple learning environment for Python, which since > it's on the web can be entered immediately without any download (and > would run even in places where Python normally can't, like say an > iPad). > > Feedback would be very welcome! > > - azakai > Ok, visiting this page: http://syntensity.com/static/python.html I do not see anything happen when I click 'execute' button. I'm running Firefox 3.6.3. Here is what I see both before and after clicking 'execute': ===================================== This is CPython, the standard Python implementation, compiled from C to JavaScript using Emscripten , running in your browser (without any plugins). * Most core language stuff should work, except for importing non-static modules (in other words, |import sys| will work, but other modules won't). * Please report bugs if you find them! * Tested on Firefox 4 and Chrome 10. * The editor is Skywriter . ------------------------------------------------------------------------ *Enter some Python*: import sys print 'Hello world! This is Python {} on {}'.format(sys.version, sys.platform) print 'Here are some numbers:', [2*x for x in range(5)][:4] ===================================== So what is happening is that the whole Python interpreter has been converted to Javascript and is running the browser, is that correct? Ok, but the usual browser 'sandbox' constraints would still apply would they not? And what is the build toolchain that you need if you want to convert your modules to be importable with this "CPython on the Web"? Regards, Gerry From orasnita at gmail.com Sun Jan 2 16:04:10 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Sun, 2 Jan 2011 23:04:10 +0200 Subject: list 2 dict? References: <69d86a8a-fef5-4da1-99d0-b6c73a73e748@glegroupsg2000goo.googlegroups.com> Message-ID: <29BD0F6C46F249F7A82064C7BB7E2E45@teddy> Octavian ----- Original Message ----- From: "Alex Willmer" Newsgroups: comp.lang.python To: Cc: Sent: Sunday, January 02, 2011 8:07 PM Subject: Re: list 2 dict? > On Sunday, January 2, 2011 3:36:35 PM UTC, T wrote: >> The grouper-way looks nice, but I tried it and it didn't work: >> >> from itertools import * >> ... >> d = dict(grouper(2, l)) >> >> NameError: name 'grouper' is not defined >> >> I use Python 2.7. Should it work with this version? > > No. As Ian said grouper() is a receipe in the itertools documentation. > > http://docs.python.org/library/itertools.html#recipes I know that, that is why I used: from itertools import * Isn't enough? Octavian From simon at brunningonline.net Sun Jan 2 16:22:37 2011 From: simon at brunningonline.net (Simon Brunning) Date: Sun, 2 Jan 2011 21:22:37 +0000 Subject: list 2 dict? In-Reply-To: <29BD0F6C46F249F7A82064C7BB7E2E45@teddy> References: <69d86a8a-fef5-4da1-99d0-b6c73a73e748@glegroupsg2000goo.googlegroups.com> <29BD0F6C46F249F7A82064C7BB7E2E45@teddy> Message-ID: On 2 January 2011 21:04, Octavian Rasnita wrote: >> No. As Ian said grouper() is a receipe in the itertools documentation. >> >> http://docs.python.org/library/itertools.html#recipes > > I know that, that is why I used: > > from itertools import * > > Isn't enough? Did you follow the link? grouper() is a recipe, not part of the itertools module. -- Cheers, Simon B. From gervaz at gmail.com Sun Jan 2 16:37:50 2011 From: gervaz at gmail.com (gervaz) Date: Sun, 2 Jan 2011 13:37:50 -0800 (PST) Subject: String building using join References: Message-ID: <6ca085f6-7c03-44b2-a9f2-8d77db046c7e@s9g2000vby.googlegroups.com> On 2 Gen, 19:14, Emile van Sebille wrote: > On 1/2/2011 9:43 AM gervaz said... > > > > > > > On 31 Dic 2010, 16:43, Emile van Sebille ?wrote: > >> On 12/31/2010 7:22 AM gervaz said... > > >>> Hi all, I would like to ask you how I can use the more efficient join > >>> operation in a code like this: > > >>>>>> class Test: > >>> ... ? ? def __init__(self, v1, v2): > >>> ... ? ? ? ? self.v1 = v1 > >>> ... ? ? ? ? self.v2 = v2 > >>> ... > >>>>>> def prg(l): > >>> ... ? ? txt = "" > >>> ... ? ? for x in l: > >>> ... ? ? ? ? if x.v1 is not None: > >>> ... ? ? ? ? ? ? txt += x.v1 + "\n" > >>> ... ? ? ? ? if x.v2 is not None: > >>> ... ? ? ? ? ? ? txt += x.v2 + "\n" > >>> ... ? ? return txt > >>> ... > >>>>>> t1 = Test("hello", None) > >>>>>> t2 = Test(None, "ciao") > >>>>>> t3 = Test("salut", "hallo") > >>>>>> t = [t1, t2, t3] > > >>>>>> prg(t) > >>> 'hello\nciao\nsalut\nhallo\n' > > >>> The idea would be create a new list with the values not None and then > >>> use the join function... but I don't know if it is really worth it. > >>> Any hint? > > >>>>>> def prg2(l): > > >> ? ? ? ? ? ? ? return "\n".join([x for x in l if x]) > > >> Emile > > >>> ... ? ? e = [] > >>> ... ? ? for x in l: > >>> ... ? ? ? ? if x.v1 is not None: > >>> ... ? ? ? ? ? ? e.append(x.v1) > >>> ... ? ? ? ? if x.v2 is not None: > >>> ... ? ? ? ? ? ? e.append(x.v2) > >>> ... ? ? return "\n".join(e) > >>> ... > >>>>>> prg2(t) > >>> 'hello\nciao\nsalut\nhallo' > > >>> Thanks, Mattia- Nascondi testo citato > > >> - Mostra testo citato -- Nascondi testo citato > > >> - Mostra testo citato - > > > Sorry, but it does not work > > Oh -- you want a working solution, not a hint? ?OK. > > class Test: > ? ? ? def __init__(self, v1, v2): > ? ? ? ? ? self.v1 = v1 > ? ? ? ? ? self.v2 = v2 > > t1 = Test("hello", None) > t2 = Test(None, "ciao") > t3 = Test("salut", "hallo") > t = [t1, t2, t3] > > "\n".join([y for x in t for y in [x.v1,x.v2] if y]) > > Emile > > > > > > >>>> def prg3(l): > > ... ? ? return "\n".join([x for x in l if x]) > > ... > >>>> prg3(t) > > Traceback (most recent call last): > > ? ?File "", line 1, in > > ? ?File "", line 2, in prg3 > > TypeError: sequence item 0: expected str instance, Test found- Nascondi testo citato > > - Mostra testo citato -- Nascondi testo citato > > - Mostra testo citato - Thanks Emile, despite that now the solution runs in quadratic time I guess. I could also provide a __str__(self) representation, but in my real code I don't have access to the class. Also using str() on an empty object (i.e. None), the representation is 'None'. Ciao, Mattia From Joshua.R.English at gmail.com Sun Jan 2 16:42:02 2011 From: Joshua.R.English at gmail.com (Josh English) Date: Sun, 2 Jan 2011 13:42:02 -0800 (PST) Subject: Multiple instances and wrong parental links In-Reply-To: Message-ID: <16944036-3260-4e4a-9d94-7eebd247833c@glegroupsg2000goo.googlegroups.com> Chas, Thanks. The "self" in the setattr statement works sometimes, but what I'm adding most of the time is a property, and if I don't use the class when setting a property, nothing works. The property is returned instead of the value of the function the property returns. (yeah, it's complicated). This is the same project I asked about at https://groups.google.com/d/topic/comp.lang.python/K9PinAbuCJk/discussion. That's why this simple sample looks so incredibly complicated. I'm coding on the far edge of my learning curve. Josh From Joshua.R.English at gmail.com Sun Jan 2 16:51:29 2011 From: Joshua.R.English at gmail.com (Josh English) Date: Sun, 2 Jan 2011 13:51:29 -0800 (PST) Subject: Multiple instances and wrong parental links In-Reply-To: <4d202971$0$29968$c3e8da3$5496439d@news.astraweb.com> Message-ID: Steven, This was simplified. The complete story is, well, tedious: I have created a set of XML Validation and Normalization classes. With them I can define my data structures and make sure my data is good. These complications have come in wanting to take this tool and create a GUI (in wxPython) around these objects. Okay, really these complication come from me generalizing the problem, probably one step too far. I want a tool to take my structural definition and create the GUI. To use some of the "easy" tools like Validators that transfer data to the GUI and back, I need an interface. I tried creating validators that went straight to the element, but that got complicated. Then I created a map from a dictionary to an element (as defined by the XML validation tool) and back again. This also bogged down and fixing one problem undid all the other progress I had made. So this is my third attempt: create a Python object around the XML definition. I've looked at pyxb. It doesn't make any sense to me. I looked at pysxer, that made even less sense. Hence, I try it on my own. The Element List isn't a list, it has the same interface as a list, but always goes back to the original XML element (an elementree.Element object in this case.) Insanely complicated and just beyond my comprehension, I fear. I haven't found an easier way to wrap an object around these XML validators of mine. Josh From benjamin.kaplan at case.edu Sun Jan 2 16:56:15 2011 From: benjamin.kaplan at case.edu (Benjamin Kaplan) Date: Sun, 2 Jan 2011 16:56:15 -0500 Subject: list 2 dict? Message-ID: On Jan 2, 2011 4:15 PM, "Octavian Rasnita" wrote: > > > Octavian > > ----- Original Message ----- > From: "Alex Willmer" > Newsgroups: comp.lang.python > To: > Cc: > Sent: Sunday, January 02, 2011 8:07 PM > Subject: Re: list 2 dict? > > > > On Sunday, January 2, 2011 3:36:35 PM UTC, T wrote: > >> The grouper-way looks nice, but I tried it and it didn't work: > >> > >> from itertools import * > >> ... > >> d = dict(grouper(2, l)) > >> > >> NameError: name 'grouper' is not defined > >> > >> I use Python 2.7. Should it work with this version? > > > > No. As Ian said grouper() is a receipe in the itertools documentation. > > > > http://docs.python.org/library/itertools.html#recipes > > I know that, that is why I used: > > from itertools import * > > > Isn't enough? > > Octavian > It would be, if, the function was actually a part of the itertools module. It isn't. It's just a code example used in the documentation. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gervaz at gmail.com Sun Jan 2 17:00:49 2011 From: gervaz at gmail.com (gervaz) Date: Sun, 2 Jan 2011 14:00:49 -0800 (PST) Subject: String building using join References: <6ca085f6-7c03-44b2-a9f2-8d77db046c7e@s9g2000vby.googlegroups.com> Message-ID: <1d33bd0b-37c9-45db-8c35-c530f5ed15cf@l7g2000vbv.googlegroups.com> On 2 Gen, 22:37, gervaz wrote: > On 2 Gen, 19:14, Emile van Sebille wrote: > > > > > > > On 1/2/2011 9:43 AM gervaz said... > > > > On 31 Dic 2010, 16:43, Emile van Sebille ?wrote: > > >> On 12/31/2010 7:22 AM gervaz said... > > > >>> Hi all, I would like to ask you how I can use the more efficient join > > >>> operation in a code like this: > > > >>>>>> class Test: > > >>> ... ? ? def __init__(self, v1, v2): > > >>> ... ? ? ? ? self.v1 = v1 > > >>> ... ? ? ? ? self.v2 = v2 > > >>> ... > > >>>>>> def prg(l): > > >>> ... ? ? txt = "" > > >>> ... ? ? for x in l: > > >>> ... ? ? ? ? if x.v1 is not None: > > >>> ... ? ? ? ? ? ? txt += x.v1 + "\n" > > >>> ... ? ? ? ? if x.v2 is not None: > > >>> ... ? ? ? ? ? ? txt += x.v2 + "\n" > > >>> ... ? ? return txt > > >>> ... > > >>>>>> t1 = Test("hello", None) > > >>>>>> t2 = Test(None, "ciao") > > >>>>>> t3 = Test("salut", "hallo") > > >>>>>> t = [t1, t2, t3] > > > >>>>>> prg(t) > > >>> 'hello\nciao\nsalut\nhallo\n' > > > >>> The idea would be create a new list with the values not None and then > > >>> use the join function... but I don't know if it is really worth it. > > >>> Any hint? > > > >>>>>> def prg2(l): > > > >> ? ? ? ? ? ? ? return "\n".join([x for x in l if x]) > > > >> Emile > > > >>> ... ? ? e = [] > > >>> ... ? ? for x in l: > > >>> ... ? ? ? ? if x.v1 is not None: > > >>> ... ? ? ? ? ? ? e.append(x.v1) > > >>> ... ? ? ? ? if x.v2 is not None: > > >>> ... ? ? ? ? ? ? e.append(x.v2) > > >>> ... ? ? return "\n".join(e) > > >>> ... > > >>>>>> prg2(t) > > >>> 'hello\nciao\nsalut\nhallo' > > > >>> Thanks, Mattia- Nascondi testo citato > > > >> - Mostra testo citato -- Nascondi testo citato > > > >> - Mostra testo citato - > > > > Sorry, but it does not work > > > Oh -- you want a working solution, not a hint? ?OK. > > > class Test: > > ? ? ? def __init__(self, v1, v2): > > ? ? ? ? ? self.v1 = v1 > > ? ? ? ? ? self.v2 = v2 > > > t1 = Test("hello", None) > > t2 = Test(None, "ciao") > > t3 = Test("salut", "hallo") > > t = [t1, t2, t3] > > > "\n".join([y for x in t for y in [x.v1,x.v2] if y]) > > > Emile > > > >>>> def prg3(l): > > > ... ? ? return "\n".join([x for x in l if x]) > > > ... > > >>>> prg3(t) > > > Traceback (most recent call last): > > > ? ?File "", line 1, in > > > ? ?File "", line 2, in prg3 > > > TypeError: sequence item 0: expected str instance, Test found- Nascondi testo citato > > > - Mostra testo citato -- Nascondi testo citato > > > - Mostra testo citato - > > Thanks Emile, despite that now the solution runs in quadratic time I > guess. I could also provide a __str__(self) representation, but in my > real code I don't have access to the class. Also using str() on an > empty object (i.e. None), the representation is 'None'. > > Ciao, > > Mattia- Nascondi testo citato > > - Mostra testo citato - And this one is another working solution... >>> def prg4(l): ... s = [] ... for x in l: ... s.extend(set([x.v1, x.v2]) - set([None])) ... return "\n".join(s) ... >>> prg4(t) 'hello\nciao\nhallo\nsalut' My original question was just related to the fact that I read that the string concatenation in expensive and it sould be used the join() function but now probably it is better to stick with the first implementation, the simplest one. Ciao, Mattia From alonmozilla at gmail.com Sun Jan 2 17:53:47 2011 From: alonmozilla at gmail.com (azakai) Date: Sun, 2 Jan 2011 14:53:47 -0800 (PST) Subject: CPython on the Web References: <19141efb-a288-43bc-be0d-44769bf5974b@j32g2000prh.googlegroups.com> Message-ID: <5942c6f9-7af5-4cff-84d4-f23a8b3bbfa1@k14g2000pre.googlegroups.com> On Jan 2, 1:01?pm, Gerry Reno wrote: > > Ok, visiting this page: > > http://syntensity.com/static/python.html > > I do not see anything happen when I click 'execute' button. ?I'm running > Firefox 3.6.3. > I've only tested with Firefox 4. I'm surprised though that it wouldn't work on 3.6.3. Can you see what errors appear in the error console (control-shift-J)? If no errors appear, it might be a failure due to limited script stack space (which is fixed in FF4, and I guess is a problem in earlier versions). > > So what is happening is that the whole Python interpreter has been > converted to Javascript and is running the browser, is that correct? Yes. > > Ok, but the usual browser 'sandbox' constraints would still apply would > they not? Yes, the JavaScript is limited in the usual ways. So Python is running in a sandboxed manner. > > And what is the build toolchain that you need if you want to convert > your modules to be importable with this "CPython on the Web"? > Note that loading modules isn't implemented yet, but I'll work on it soon. The toolchain will be to use your normal makefiles and such, but replacing gcc with llvm-gcc or clang, so it generates LLVM bytecode instead of a normal binary. Then one would run the generated LLVM bytecode through Emscripten, which compiles it to JavaScript. So, the process should be fairly simple. - azakai From greno at verizon.net Sun Jan 2 18:14:39 2011 From: greno at verizon.net (Gerry Reno) Date: Sun, 02 Jan 2011 18:14:39 -0500 Subject: CPython on the Web In-Reply-To: <5942c6f9-7af5-4cff-84d4-f23a8b3bbfa1@k14g2000pre.googlegroups.com> References: <19141efb-a288-43bc-be0d-44769bf5974b@j32g2000prh.googlegroups.com> <5942c6f9-7af5-4cff-84d4-f23a8b3bbfa1@k14g2000pre.googlegroups.com> Message-ID: <4D2106DF.6080609@verizon.net> On 01/02/2011 05:53 PM, azakai wrote: > On Jan 2, 1:01 pm, Gerry Reno wrote: > >> Ok, visiting this page: >> >> http://syntensity.com/static/python.html >> >> I do not see anything happen when I click 'execute' button. I'm running >> Firefox 3.6.3. >> >> > I've only tested with Firefox 4. I'm surprised though that it wouldn't > work on 3.6.3. Can you see what errors appear in the error console > (control-shift-J)? > > Errors when using Firefox 3.6.3: script stack space quota is exhausted Module is not defined ... line 56 Regards, Gerry From stagi.andrea at gmail.com Sun Jan 2 19:09:06 2011 From: stagi.andrea at gmail.com (Andrea Stagi) Date: Sun, 2 Jan 2011 16:09:06 -0800 (PST) Subject: Tiny4py [important update] a little python wrapper to make shorten urls and QRCodes Message-ID: Hi, I would announce you my new version of this python wrapper to make shorten urls and QRCodes, using main used services: goo.gl, bit.ly and tinyurl. Please, visit http://code.google.com/p/tiny4py/ Bests From timr at probo.com Sun Jan 2 19:50:56 2011 From: timr at probo.com (Tim Roberts) Date: Sun, 02 Jan 2011 16:50:56 -0800 Subject: Interrput a thread References: <81c24eb1-41b6-442a-a971-8a44d2cd6c1b@p8g2000vbs.googlegroups.com> <4d1e20c5$0$43986$742ec2ed@news.sonic.net> Message-ID: <5972i6hdaru9g15hs14je5imggabq4l3b8@4ax.com> gervaz wrote: > >Ok, but then suppose I have multiple long running threads that I want >to delete/suspend because they are tooking too much time, which >solution do you propose? The right solution is to write your threads so they have an escape hatch -- to periodically check a "should I die?" flag, and then commit suicide. That is the ONLY clean way to handle this problem. There is simply no clean way to force another thread to die without its permission. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From python at bdurham.com Sun Jan 2 19:58:42 2011 From: python at bdurham.com (python at bdurham.com) Date: Sun, 02 Jan 2011 19:58:42 -0500 Subject: CPython on the Web In-Reply-To: <4D2106DF.6080609@verizon.net> References: <19141efb-a288-43bc-be0d-44769bf5974b@j32g2000prh.googlegroups.com><5942c6f9-7af5-4cff-84d4-f23a8b3bbfa1@k14g2000pre.googlegroups.com> <4D2106DF.6080609@verizon.net> Message-ID: <1294016322.6824.1413185103@webmail.messagingengine.com> Azakai/Gerry, > Errors when using Firefox 3.6.3: I'm running Firefox 3.6.1.3 and the interpreter is running fine. I'm on Windows 7 Pro 64-bit. Malcolm From alonmozilla at gmail.com Sun Jan 2 20:00:52 2011 From: alonmozilla at gmail.com (azakai) Date: Sun, 2 Jan 2011 17:00:52 -0800 (PST) Subject: CPython on the Web References: <19141efb-a288-43bc-be0d-44769bf5974b@j32g2000prh.googlegroups.com> <5942c6f9-7af5-4cff-84d4-f23a8b3bbfa1@k14g2000pre.googlegroups.com> Message-ID: <3e973cb5-4208-4f73-8bbf-15e1bc2f7595@35g2000prt.googlegroups.com> On Jan 2, 3:14?pm, Gerry Reno wrote: > On 01/02/2011 05:53 PM, azakai wrote: > > > On Jan 2, 1:01 pm, Gerry Reno wrote: > > >> Ok, visiting this page: > > >>http://syntensity.com/static/python.html > > >> I do not see anything happen when I click 'execute' button. ?I'm running > >> Firefox 3.6.3. > > > I've only tested with Firefox 4. I'm surprised though that it wouldn't > > work on 3.6.3. Can you see what errors appear in the error console > > (control-shift-J)? > > Errors when using Firefox 3.6.3: > > script stack space quota is exhausted Ah, then yeah, it's the script stack issue I was afraid of. Then there's not really a way to run the demo on Firefox 3.6.x. It will work on Firefox 4 though, or other recent browsers. - azakai From greno at verizon.net Sun Jan 2 20:55:48 2011 From: greno at verizon.net (Gerry Reno) Date: Sun, 02 Jan 2011 20:55:48 -0500 Subject: CPython on the Web In-Reply-To: <3e973cb5-4208-4f73-8bbf-15e1bc2f7595@35g2000prt.googlegroups.com> References: <19141efb-a288-43bc-be0d-44769bf5974b@j32g2000prh.googlegroups.com> <5942c6f9-7af5-4cff-84d4-f23a8b3bbfa1@k14g2000pre.googlegroups.com> <3e973cb5-4208-4f73-8bbf-15e1bc2f7595@35g2000prt.googlegroups.com> Message-ID: <4D212CA4.6010807@verizon.net> I tried printing sys.path and here is the output: ['', '/usr/local/lib/python27.zip', '/usr/local/lib/python2.7/', '/usr/local/lib/python2.7/plat-linux2', '/usr/local/lib/python2.7/lib-tk', '/usr/local/lib/python2.7/lib-old', '/usr/local/lib/lib-dynload'] Now, those paths must be on your machine because they are not on my client machine. But the interpreter is now running on MY machine. Well in a sandbox really. So how is that going to work? Regards, Gerry From alonmozilla at gmail.com Sun Jan 2 21:06:09 2011 From: alonmozilla at gmail.com (azakai) Date: Sun, 2 Jan 2011 18:06:09 -0800 (PST) Subject: CPython on the Web References: <19141efb-a288-43bc-be0d-44769bf5974b@j32g2000prh.googlegroups.com><5942c6f9-7af5-4cff-84d4-f23a8b3bbfa1@k14g2000pre.googlegroups.com> <4D2106DF.6080609@verizon.net> Message-ID: <5a62ec44-7dd0-456c-b14c-92f3b97b7f2a@c13g2000prc.googlegroups.com> On Jan 2, 4:58?pm, pyt... at bdurham.com wrote: > Azakai/Gerry, > > > Errors when using Firefox 3.6.3: > > I'm running Firefox 3.6.1.3 and the interpreter is running fine. > > I'm on Windows 7 Pro 64-bit. > > Malcolm Thanks for the info. To be honest I'm surprised it works there. I guess the error Gerry ran into depends on additional factors. - azakai From news3 at mystrobl.de Mon Jan 3 02:26:20 2011 From: news3 at mystrobl.de (Wolfgang Strobl) Date: Mon, 03 Jan 2011 08:26:20 +0100 Subject: CPython on the Web References: <19141efb-a288-43bc-be0d-44769bf5974b@j32g2000prh.googlegroups.com><5942c6f9-7af5-4cff-84d4-f23a8b3bbfa1@k14g2000pre.googlegroups.com> <4D2106DF.6080609@verizon.net> <5a62ec44-7dd0-456c-b14c-92f3b97b7f2a@c13g2000prc.googlegroups.com> Message-ID: azakai : >On Jan 2, 4:58?pm, pyt... at bdurham.com wrote: >> Azakai/Gerry, >> >> > Errors when using Firefox 3.6.3: >> >> I'm running Firefox 3.6.1.3 and the interpreter is running fine. I guess that meant FIrefox 3.6.13 (without the last dot), the current stable version. I'm using Firefox 3.6.13 (german) on Windowx XP (32bit, german) here, and the interpreter is running fine, too. Same for Chrome 8.0.552.224. -- Wir danken f?r die Beachtung aller Sicherheitsbestimmungen From yoavglazner at gmail.com Mon Jan 3 05:41:23 2011 From: yoavglazner at gmail.com (Glazner) Date: Mon, 3 Jan 2011 02:41:23 -0800 (PST) Subject: list 2 dict? References: Message-ID: <8e41b3be-9279-44f3-a9ab-a8d55fa7e72a@d8g2000yqf.googlegroups.com> On Jan 2, 3:18?pm, "Octavian Rasnita" wrote: > Hi, > > If I want to create a dictionary from a list, is there a better way than the long line below? > > l = [1, 2, 3, 4, 5, 6, 7, 'a', 8, 'b'] > > d = dict(zip([l[x] for x in range(len(l)) if x %2 == 0], [l[x] for x in range(len(l)) if x %2 == 1])) > > print(d) > > {8: 'b', 1: 2, 3: 4, 5: 6, 7: 'a'} > > Thanks. > > Octavian this is efficient l = [1,2,3,4,5,6] >>> dict(izip(islice(l,0,len(l),2),islice(l,1,len(l),2))) {1: 2, 3: 4, 5: 6} From maniearthg3 at gmail.com Mon Jan 3 06:10:34 2011 From: maniearthg3 at gmail.com (mani ma) Date: Mon, 3 Jan 2011 03:10:34 -0800 (PST) Subject: Arisingsoft provides the Norton antivirus all in one security suite. Message-ID: <68d35288-9ebe-425b-9639-f08d80fe1d94@22g2000prx.googlegroups.com> hai, Uses : The package includes a personal firewall, phishing protection and the ability to detect and remove malware. Norton 360 is compatible with 32-bit editions of Windows XP and 32-bit or 64-bit editions of Windows Vista.Windows 7 support has been added. Reviews cited Norton 360's low resource usage, relative to Norton Internet Security 2007, and phishing protection. http://www.arisingsoft.com/2010_11_14_archive.html http://www.arisingsoft.com/ From xrgtn at yandex.ru Mon Jan 3 06:56:12 2011 From: xrgtn at yandex.ru (Alexander Gattin) Date: Mon, 3 Jan 2011 13:56:12 +0200 Subject: String building using join In-Reply-To: References: Message-ID: <20110103115612.GA16693@xrgtn-q40> Hello, On Sun, Jan 02, 2011 at 10:11:50AM -0800, Alex Willmer wrote: > def prg3(l): > return '\n'.join([str(x) for x in l if x]) just one fix (one fix one fix one fix): return '\n'.join([str(x) for x in l if x is not None]) -- With best regards, xrgtn From deets at web.de Mon Jan 3 11:46:31 2011 From: deets at web.de (Diez B. Roggisch) Date: Mon, 03 Jan 2011 17:46:31 +0100 Subject: Is there anyway to run JavaScript in python? References: Message-ID: <878vz27x5k.fsf@web.de> crow writes: > Hi, I'm writing a test tool to simulate Web browser. Is there anyway > to run JavaScript in python? Thanks in advance. Not really. Yes, you can invoke spidermonkey. But the crucial point about running JS is not executing JS, it's about having the *DOM* of the browser available. Which spidermonkey obviously hasn't. So, I recommend using Selenium. Diez From deets at web.de Mon Jan 3 11:47:41 2011 From: deets at web.de (Diez B. Roggisch) Date: Mon, 03 Jan 2011 17:47:41 +0100 Subject: Interrput a thread References: <81c24eb1-41b6-442a-a971-8a44d2cd6c1b@p8g2000vbs.googlegroups.com> <4d1e20c5$0$43986$742ec2ed@news.sonic.net> Message-ID: <874o9q7x3m.fsf@web.de> gervaz writes: > On 31 Dic 2010, 23:25, Alice Bevan?McGregor > wrote: >> On 2010-12-31 10:28:26 -0800, John Nagle said: >> >> > Even worse, sending control-C to a multi-thread program >> > is unreliable in CPython. ?See "http://blip.tv/file/2232410" >> > for why. ?It's painful. >> >> AFIK, that has been resolved in Python 3.2 with the introduction of an >> intelligent thread scheduler as part of the GIL release/acquire process. >> >> ? ? ? ? - Alice. > > Ok, but then suppose I have multiple long running threads that I want > to delete/suspend because they are tooking too much time, which > solution do you propose? If possible, use multiple processes instead. Diez From cfp.vinorg at gmail.com Mon Jan 3 13:31:31 2011 From: cfp.vinorg at gmail.com (CFP - 1st International Conference on Virtual and Networked Organizations Emergent Technologies and Tools) Date: Mon, 3 Jan 2011 18:31:31 +0000 Subject: CFP - ViNOrg 11 - 1st International Conference on Virtual and Networked Organizations: Emergent Technologies and Tools Message-ID: <20110103185815.0FE70EE99F@mail.python.org> ViNOrg 11 1st International Conference on Virtual and Networked Organizations Emergent Technologies and Tools ---------- Paper submission deadline: April 17, 2011 ---------- http://www.2100projects.org/vinorg11 vinorg at 2100projects.org ---------- Dear Professor, It is our great pleasure to invite you to participate in the 1st International Conference on Virtual and Networked Organizations Emergent Technologies and Tools, ViNOrg ?11, to be held in Ofir, Portugal, from July 6-8, 2011. ViNOrg ?11 is promoted by the 2100 Projects Association ? Scientific Association for Promotion of Technology and Management for Organizational and Social Transformative Change. The overall objectives of the conference are to contribute to the development, implementation and promotion of advanced emergent IC technologies to be used in future Virtual and Networked Organizations, through the discussion and sharing of knowledge, as well as experiences and scientific and technical results. A shortlist of intended topics include: metaverse, virtual and augmented reality, ubiquitous computing and organizations, grid computing, cloud computing and architectures, human-computer interfaces, serious games, intelligence and soft computing, data mining, web services, cognitive systems, social networks and other emergent IT/IS approaches in various function domains, such as decision support systems, planning, design, control, negotiation, marketing, management and many other, in the context of virtual and networked enterprises and organizations. All accepted full papers will be published in the Conference Proceedings to be published by Springer-Verlag in a book of the CCIS series (Communications in Computer and Information Science), which is listed in the ISI proceedings index. Authors of selected papers will be invited to extend their papers for publication in some international scientific journals. For more information please consult the conference webpage at http://www.2100projects.org/vinorg11 Looking forward to meeting you in Ofir (Portugal) next July 2011, accept our best regards. The conference co-chairs, * Goran D. Putnik (putnikgd at dps.uminho.pt), University of Minho, Portugal * Maria Manuela Cruz-Cunha (mcunha at ipca.pt), Polytechnic Institute of Cavado and Ave, Portugal ---------- http://www.2100projects.org/vinorg11 vinorg at 2100projects.org ---------- You are receiving this email because of your research activities on the conference related topics. To unsubscribe please send an email to vinorg at 2100projects.org with the subject "Unsubscribe". (please excuse us if you received this call more than once). ---------- From alonmozilla at gmail.com Mon Jan 3 15:10:44 2011 From: alonmozilla at gmail.com (azakai) Date: Mon, 3 Jan 2011 12:10:44 -0800 (PST) Subject: CPython on the Web References: <19141efb-a288-43bc-be0d-44769bf5974b@j32g2000prh.googlegroups.com> <5942c6f9-7af5-4cff-84d4-f23a8b3bbfa1@k14g2000pre.googlegroups.com> <3e973cb5-4208-4f73-8bbf-15e1bc2f7595@35g2000prt.googlegroups.com> Message-ID: <11daa83d-d065-4816-b63b-a0144cc49943@n32g2000pre.googlegroups.com> On Jan 2, 5:55?pm, Gerry Reno wrote: > I tried printing sys.path and here is the output: > > ['', '/usr/local/lib/python27.zip', '/usr/local/lib/python2.7/', > '/usr/local/lib/python2.7/plat-linux2', > '/usr/local/lib/python2.7/lib-tk', '/usr/local/lib/python2.7/lib-old', > '/usr/local/lib/lib-dynload'] > > Now, those paths must be on your machine because they are not on my > client machine. ?But the interpreter is now running on MY machine. ?Well > in a sandbox really. ?So how is that going to work? > Yeah, those are the paths on the machine where the binary was compiled (so, they are the standard paths on ubuntu). Anyhow the filesystem can't (and shouldn't) be accessed from inside a browser page. I think we will implement a minimal virtual filesystem here, just enough for stuff to work. The actual implementation would use HTML5 features like local storage etc. - azakai From deets at web.de Mon Jan 3 15:13:29 2011 From: deets at web.de (Diez B. Roggisch) Date: Mon, 03 Jan 2011 21:13:29 +0100 Subject: CPython on the Web References: <19141efb-a288-43bc-be0d-44769bf5974b@j32g2000prh.googlegroups.com> Message-ID: azakai writes: > Hello, I hope this will be interesting to people here: CPython running > on the web, > > http://syntensity.com/static/python.html > > That isn't a new implementation of Python, but rather CPython 2.7.1, > compiled from C to JavaScript using Emscripten and LLVM. For more > details on the conversion process, see http://emscripten.org A fun hack. Have you bothered to compare it to the PyPy javascript backend - perfomance-wise, that is? Diez From gervaz at gmail.com Mon Jan 3 15:22:59 2011 From: gervaz at gmail.com (gervaz) Date: Mon, 3 Jan 2011 12:22:59 -0800 (PST) Subject: Interrput a thread References: <81c24eb1-41b6-442a-a971-8a44d2cd6c1b@p8g2000vbs.googlegroups.com> <4d1e20c5$0$43986$742ec2ed@news.sonic.net> <874o9q7x3m.fsf@web.de> Message-ID: <71631a5e-d3af-4c5d-9f1d-07eb8044d792@39g2000yqa.googlegroups.com> On 3 Gen, 17:47, de... at web.de (Diez B. Roggisch) wrote: > gervaz writes: > > On 31 Dic 2010, 23:25, Alice Bevan?McGregor > > wrote: > >> On 2010-12-31 10:28:26 -0800, John Nagle said: > > >> > Even worse, sending control-C to a multi-thread program > >> > is unreliable in CPython. ?See "http://blip.tv/file/2232410" > >> > for why. ?It's painful. > > >> AFIK, that has been resolved in Python 3.2 with the introduction of an > >> intelligent thread scheduler as part of the GIL release/acquire process. > > >> ? ? ? ? - Alice. > > > Ok, but then suppose I have multiple long running threads that I want > > to delete/suspend because they are tooking too much time, which > > solution do you propose? > > If possible, use multiple processes instead. > > Diez- Nascondi testo citato > > - Mostra testo citato - Multiple processes, ok, but then regarding processes' interruption there will be the same problems pointed out by using threads? Mattia From greno at verizon.net Mon Jan 3 15:23:51 2011 From: greno at verizon.net (Gerry Reno) Date: Mon, 03 Jan 2011 15:23:51 -0500 Subject: CPython on the Web In-Reply-To: <11daa83d-d065-4816-b63b-a0144cc49943@n32g2000pre.googlegroups.com> References: <19141efb-a288-43bc-be0d-44769bf5974b@j32g2000prh.googlegroups.com> <5942c6f9-7af5-4cff-84d4-f23a8b3bbfa1@k14g2000pre.googlegroups.com> <3e973cb5-4208-4f73-8bbf-15e1bc2f7595@35g2000prt.googlegroups.com> <11daa83d-d065-4816-b63b-a0144cc49943@n32g2000pre.googlegroups.com> Message-ID: <4D223057.1010301@verizon.net> On 01/03/2011 03:10 PM, azakai wrote: > On Jan 2, 5:55 pm, Gerry Reno wrote: > >> I tried printing sys.path and here is the output: >> >> ['', '/usr/local/lib/python27.zip', '/usr/local/lib/python2.7/', >> '/usr/local/lib/python2.7/plat-linux2', >> '/usr/local/lib/python2.7/lib-tk', '/usr/local/lib/python2.7/lib-old', >> '/usr/local/lib/lib-dynload'] >> >> Now, those paths must be on your machine because they are not on my >> client machine. But the interpreter is now running on MY machine. Well >> in a sandbox really. So how is that going to work? >> >> > Yeah, those are the paths on the machine where the binary was compiled > (so, they are the standard paths on ubuntu). > > Anyhow the filesystem can't (and shouldn't) be accessed from inside a > browser page. Well, the local filesystem could be accessible with the user's permission and this should be an option. Regards, Gerry From greno at verizon.net Mon Jan 3 15:35:01 2011 From: greno at verizon.net (Gerry Reno) Date: Mon, 03 Jan 2011 15:35:01 -0500 Subject: CPython on the Web In-Reply-To: References: <19141efb-a288-43bc-be0d-44769bf5974b@j32g2000prh.googlegroups.com> Message-ID: <4D2232F5.2010400@verizon.net> On 01/03/2011 03:13 PM, Diez B. Roggisch wrote: > > A fun hack. Have you bothered to compare it to the PyPy javascript > backend - perfomance-wise, that is? > > Diez > I don't think that exists anymore. Didn't that get removed from PyPy about 2 years ago? Regards, Gerry From calderone.jeanpaul at gmail.com Mon Jan 3 16:06:25 2011 From: calderone.jeanpaul at gmail.com (Jean-Paul Calderone) Date: Mon, 3 Jan 2011 13:06:25 -0800 (PST) Subject: Interrput a thread References: <81c24eb1-41b6-442a-a971-8a44d2cd6c1b@p8g2000vbs.googlegroups.com> <4d1e20c5$0$43986$742ec2ed@news.sonic.net> <874o9q7x3m.fsf@web.de> <71631a5e-d3af-4c5d-9f1d-07eb8044d792@39g2000yqa.googlegroups.com> Message-ID: On Jan 3, 3:22?pm, gervaz wrote: > On 3 Gen, 17:47, de... at web.de (Diez B. Roggisch) wrote: > > > > > gervaz writes: > > > On 31 Dic 2010, 23:25, Alice Bevan?McGregor > > > wrote: > > >> On 2010-12-31 10:28:26 -0800, John Nagle said: > > > >> > Even worse, sending control-C to a multi-thread program > > >> > is unreliable in CPython. ?See "http://blip.tv/file/2232410" > > >> > for why. ?It's painful. > > > >> AFIK, that has been resolved in Python 3.2 with the introduction of an > > >> intelligent thread scheduler as part of the GIL release/acquire process. > > > >> ? ? ? ? - Alice. > > > > Ok, but then suppose I have multiple long running threads that I want > > > to delete/suspend because they are tooking too much time, which > > > solution do you propose? > > > If possible, use multiple processes instead. > > > Diez- Nascondi testo citato > > > - Mostra testo citato - > > Multiple processes, ok, but then regarding processes' interruption > there will be the same problems pointed out by using threads? > No. Processes can be terminated easily on all major platforms. See `os.kill`. Jean-Paul From askutt at gmail.com Mon Jan 3 16:17:13 2011 From: askutt at gmail.com (Adam Skutt) Date: Mon, 3 Jan 2011 13:17:13 -0800 (PST) Subject: Interrput a thread References: <81c24eb1-41b6-442a-a971-8a44d2cd6c1b@p8g2000vbs.googlegroups.com> <4d1e20c5$0$43986$742ec2ed@news.sonic.net> <874o9q7x3m.fsf@web.de> <71631a5e-d3af-4c5d-9f1d-07eb8044d792@39g2000yqa.googlegroups.com> Message-ID: <4855b05f-1ea4-4287-9066-5aeb1b7cb720@k11g2000vbf.googlegroups.com> On Jan 3, 4:06?pm, Jean-Paul Calderone wrote: > > > Multiple processes, ok, but then regarding processes' interruption > > there will be the same problems pointed out by using threads? > > No. ?Processes can be terminated easily on all major platforms. ?See > `os.kill`. > Yes, but that's not the whole story, now is it? It's certainly much more reliable and easier to kill a process. It's not any easier to do it and retain defined behavior, depending on exactly what you're doing. For example, if you kill it while it's in the middle of updating shared memory, you can potentially incur undefined behavior on the part of any process that can also access shared memory. In short, taking a program that uses threads and shared state and simply replacing the threads with processes will likely not gain you a thing. It entirely depends on what those threads are doing and how they do it. Adam From sjmachin at lexicon.net Mon Jan 3 16:28:01 2011 From: sjmachin at lexicon.net (John Machin) Date: Mon, 3 Jan 2011 13:28:01 -0800 (PST) Subject: Interesting bug References: <45562e32-6fd2-4d40-be64-bb88335ad274@z17g2000prz.googlegroups.com> Message-ID: <8ff97e7b-9eab-4c48-9fe9-a3aec425af50@22g2000prx.googlegroups.com> On Jan 2, 12:22?am, Daniel Fetchinson wrote: > An AI bot is playing a trick on us. Yes, it appears that the mystery is solved: Mark V. Shaney is alive and well and living in Bangalore :-) From gervaz at gmail.com Mon Jan 3 17:05:46 2011 From: gervaz at gmail.com (gervaz) Date: Mon, 3 Jan 2011 14:05:46 -0800 (PST) Subject: Interrput a thread References: <81c24eb1-41b6-442a-a971-8a44d2cd6c1b@p8g2000vbs.googlegroups.com> <4d1e20c5$0$43986$742ec2ed@news.sonic.net> <874o9q7x3m.fsf@web.de> <71631a5e-d3af-4c5d-9f1d-07eb8044d792@39g2000yqa.googlegroups.com> <4855b05f-1ea4-4287-9066-5aeb1b7cb720@k11g2000vbf.googlegroups.com> Message-ID: On 3 Gen, 22:17, Adam Skutt wrote: > On Jan 3, 4:06?pm, Jean-Paul Calderone > wrote: > > > > > > Multiple processes, ok, but then regarding processes' interruption > > > there will be the same problems pointed out by using threads? > > > No. ?Processes can be terminated easily on all major platforms. ?See > > `os.kill`. > > Yes, but that's not the whole story, now is it? ?It's certainly much > more reliable and easier to kill a process. ?It's not any easier to do > it and retain defined behavior, depending on exactly what you're > doing. ?For example, if you kill it while it's in the middle of > updating shared memory, you can potentially incur undefined behavior > on the part of any process that can also access shared memory. > > In short, taking a program that uses threads and shared state and > simply replacing the threads with processes will likely not gain you a > thing. ?It entirely depends on what those threads are doing and how > they do it. > > Adam As per the py3.1 documentation, os.kill is only available in the Unix os. Regarding the case pointed out by Adam I think the best way to deal with it is to create a critical section so that the shared memory will be updated in an atomic fashion. Btw it would be useful to take a look at some actual code/documentation in order to understand how others dealt with the problem... Ciao, Mattia From calderone.jeanpaul at gmail.com Mon Jan 3 17:24:55 2011 From: calderone.jeanpaul at gmail.com (Jean-Paul Calderone) Date: Mon, 3 Jan 2011 14:24:55 -0800 (PST) Subject: Interrput a thread References: <81c24eb1-41b6-442a-a971-8a44d2cd6c1b@p8g2000vbs.googlegroups.com> <4d1e20c5$0$43986$742ec2ed@news.sonic.net> <874o9q7x3m.fsf@web.de> <71631a5e-d3af-4c5d-9f1d-07eb8044d792@39g2000yqa.googlegroups.com> <4855b05f-1ea4-4287-9066-5aeb1b7cb720@k11g2000vbf.googlegroups.com> Message-ID: <3856d645-86a5-449f-adca-fcbbc6371ba4@l17g2000yqe.googlegroups.com> On Jan 3, 4:17?pm, Adam Skutt wrote: > On Jan 3, 4:06?pm, Jean-Paul Calderone > wrote: > > > > > > Multiple processes, ok, but then regarding processes' interruption > > > there will be the same problems pointed out by using threads? > > > No. ?Processes can be terminated easily on all major platforms. ?See > > `os.kill`. > > Yes, but that's not the whole story, now is it? ?It's certainly much > more reliable and easier to kill a process. ?It's not any easier to do > it and retain defined behavior, depending on exactly what you're > doing. ?For example, if you kill it while it's in the middle of > updating shared memory, you can potentially incur undefined behavior > on the part of any process that can also access shared memory. Then don't use shared memory. > > In short, taking a program that uses threads and shared state and > simply replacing the threads with processes will likely not gain you a > thing. ?It entirely depends on what those threads are doing and how > they do it. > Of course. The whole point here is not about threads vs processes. It's about shared memory concurrency vs non-shared memory concurrency. You can implement both with threads and both with processes, but threads are geared towards shared memory and processes are geared towards non-shared memory. So what most people mean by "use processes" is "don't use shared memory". Jean-Paul From kentilton at gmail.com Mon Jan 3 17:37:12 2011 From: kentilton at gmail.com (kenny) Date: Mon, 3 Jan 2011 14:37:12 -0800 (PST) Subject: SUNLisp 2: Josh vs. Kenny Flamewars Galore!! Message-ID: All they agree on is Common Lisp! Come join the Yobbos of MCNA at the Frog & Toad for booze, vino, and great food and knock down drag out debates galore on everything from Cells to Lisp IDEs: When: Tomorrow Tuesday, at 7pm Where: http://www.thefrogandtoadpub.com/ HK From deets at web.de Mon Jan 3 17:55:41 2011 From: deets at web.de (Diez B. Roggisch) Date: Mon, 03 Jan 2011 23:55:41 +0100 Subject: CPython on the Web References: <19141efb-a288-43bc-be0d-44769bf5974b@j32g2000prh.googlegroups.com> Message-ID: Gerry Reno writes: > On 01/03/2011 03:13 PM, Diez B. Roggisch wrote: >> >> A fun hack. Have you bothered to compare it to the PyPy javascript >> backend - perfomance-wise, that is? >> >> Diez >> > > I don't think that exists anymore. Didn't that get removed from PyPy > about 2 years ago? Ah, didn't know that. I was under the impression pyjamas was done with it. Apparently, that's wrong: http://pyjs.org/ But then I re-phrase my question: how does this relate to pyjamas/pyjs? Diez From deets at web.de Mon Jan 3 17:57:17 2011 From: deets at web.de (Diez B. Roggisch) Date: Mon, 03 Jan 2011 23:57:17 +0100 Subject: Interrput a thread References: <81c24eb1-41b6-442a-a971-8a44d2cd6c1b@p8g2000vbs.googlegroups.com> <4d1e20c5$0$43986$742ec2ed@news.sonic.net> <874o9q7x3m.fsf@web.de> <71631a5e-d3af-4c5d-9f1d-07eb8044d792@39g2000yqa.googlegroups.com> <4855b05f-1ea4-4287-9066-5aeb1b7cb720@k11g2000vbf.googlegroups.com> Message-ID: gervaz writes: > On 3 Gen, 22:17, Adam Skutt wrote: >> On Jan 3, 4:06?pm, Jean-Paul Calderone >> wrote: >> >> >> >> > > Multiple processes, ok, but then regarding processes' interruption >> > > there will be the same problems pointed out by using threads? >> >> > No. ?Processes can be terminated easily on all major platforms. ?See >> > `os.kill`. >> >> Yes, but that's not the whole story, now is it? ?It's certainly much >> more reliable and easier to kill a process. ?It's not any easier to do >> it and retain defined behavior, depending on exactly what you're >> doing. ?For example, if you kill it while it's in the middle of >> updating shared memory, you can potentially incur undefined behavior >> on the part of any process that can also access shared memory. >> >> In short, taking a program that uses threads and shared state and >> simply replacing the threads with processes will likely not gain you a >> thing. ?It entirely depends on what those threads are doing and how >> they do it. >> >> Adam > > As per the py3.1 documentation, os.kill is only available in the Unix > os. Regarding the case pointed out by Adam I think the best way to > deal with it is to create a critical section so that the shared memory > will be updated in an atomic fashion. Btw it would be useful to take a > look at some actual code/documentation in order to understand how > others dealt with the problem... There is the multiprocessing module. It's a good start, and works cross-platform. Diez From askutt at gmail.com Mon Jan 3 18:10:10 2011 From: askutt at gmail.com (Adam Skutt) Date: Mon, 3 Jan 2011 15:10:10 -0800 (PST) Subject: Interrput a thread References: <81c24eb1-41b6-442a-a971-8a44d2cd6c1b@p8g2000vbs.googlegroups.com> <4d1e20c5$0$43986$742ec2ed@news.sonic.net> <874o9q7x3m.fsf@web.de> <71631a5e-d3af-4c5d-9f1d-07eb8044d792@39g2000yqa.googlegroups.com> <4855b05f-1ea4-4287-9066-5aeb1b7cb720@k11g2000vbf.googlegroups.com> Message-ID: <4d1da89f-7c74-47c7-a3c9-7f3a574308c0@s4g2000yql.googlegroups.com> On Jan 3, 5:05?pm, gervaz wrote: > Regarding the case pointed out by Adam I think the best way to > deal with it is to create a critical section so that the shared memory > will be updated in an atomic fashion. Ok, so if the OS kills the process between taking the lock and releasing it, what are you going to do? Handled naively, you can end up in a deadlock situation[1]. If a process has locked a semaphore and then terminates, the semaphore retains its current value: all other processes waiting on the semaphore will still be waiting, and any new processes that access the semaphore will wait as well. In short, if a process holding a semaphore dies, you have to manually unlock it. For signals that the process intends to handle, you can always disable them before taking the lock and reenable them after releasing it. Or, you can install signal handlers in each process that ensure everything is properly cleaned up when the signal is delivered. Which solution is right depends on what you're doing. For signals you don't intend to handle (SIGSEGV) or cannot handle (SIGKILL) there's not much you can do. It's potentially dangerous to continue on after a child has received such a signal, so the right solution may be to literally do nothing and let the deadlock occur. If you must do cleanup, it must be done carefully. The key thing to understand is that the problems with killing threads haven't gone away: delivering the "please die" message isn't the hard part; it's safely cleaning up the thread in such a way it doesn't break the rest of the application! This problem still exists if you replace threads with processes (assuming you're using shared memory). As such, the better thing to do, if possible, is to avoid shared memory and use constructs like pipes and sockets for I/O. They have much better defined failure semantics, and do allow you a modicum of fault isolation. At the very least, graceful shutdown is much easier. HTH, Adam [1] For SIGINT from the terminal, the "right thing" /might/ happen. Strong emphasis on the might. From askutt at gmail.com Mon Jan 3 18:17:13 2011 From: askutt at gmail.com (Adam Skutt) Date: Mon, 3 Jan 2011 15:17:13 -0800 (PST) Subject: Interrput a thread References: <81c24eb1-41b6-442a-a971-8a44d2cd6c1b@p8g2000vbs.googlegroups.com> <4d1e20c5$0$43986$742ec2ed@news.sonic.net> <874o9q7x3m.fsf@web.de> <71631a5e-d3af-4c5d-9f1d-07eb8044d792@39g2000yqa.googlegroups.com> <4855b05f-1ea4-4287-9066-5aeb1b7cb720@k11g2000vbf.googlegroups.com> <3856d645-86a5-449f-adca-fcbbc6371ba4@l17g2000yqe.googlegroups.com> Message-ID: <561e8842-bcca-45c4-baee-e5431e778f6a@n10g2000yqd.googlegroups.com> On Jan 3, 5:24?pm, Jean-Paul Calderone wrote: > Of course. ?The whole point here is not about threads vs processes. > It's about shared memory concurrency vs non-shared memory > concurrency. ?You can implement both with threads and both with > processes, but threads are geared towards shared memory and processes > are geared towards non-shared memory. ?So what most people mean by > "use processes" is "don't use shared memory". > This is entirely my presumption, but I think if the OP were keenly aware of the differences between thread and processes, it's pretty likely he wouldn't have asked his question in the first place. Also, I've written lots and lots of "use processes" code on multiple platforms, and much of it has used some sort of shared memory construct. It's actually pretty common, especially in code bases with a lot of history. Not all the world is Apache. Adam From greno at verizon.net Mon Jan 3 18:19:20 2011 From: greno at verizon.net (Gerry Reno) Date: Mon, 03 Jan 2011 18:19:20 -0500 Subject: CPython on the Web In-Reply-To: References: <19141efb-a288-43bc-be0d-44769bf5974b@j32g2000prh.googlegroups.com> Message-ID: <4D225978.6010202@verizon.net> On 01/03/2011 05:55 PM, Diez B. Roggisch wrote: > Gerry Reno writes: > > >> On 01/03/2011 03:13 PM, Diez B. Roggisch wrote: >> >>> A fun hack. Have you bothered to compare it to the PyPy javascript >>> backend - perfomance-wise, that is? >>> >>> Diez >>> >>> >> I don't think that exists anymore. Didn't that get removed from PyPy >> about 2 years ago? >> > Ah, didn't know that. I was under the impression pyjamas was done with > it. Apparently, that's wrong: > > http://pyjs.org/ > > But then I re-phrase my question: how does this relate to pyjamas/pyjs? > > Diez > >From what I've seen so far: Pyjamas is taking your python code and converting it into javascript so that your python code (converted to javascript) can run in a browser. CPotW is taking the whole python interpreter and converting the interpreter into javascript so that the python interpreter runs in the browser. Your python code remains as python code. Regards, Gerry From PointedEars at web.de Mon Jan 3 18:21:30 2011 From: PointedEars at web.de (Thomas 'PointedEars' Lahn) Date: Tue, 04 Jan 2011 00:21:30 +0100 Subject: SUNLisp 2: Josh vs. Kenny Flamewars Galore!! References: Message-ID: <1436090.LH7GnMWURc@PointedEars.de> kenny crossposted bullshit over 5 newsgroups again: > [?] JFTR: *PLONK* From astar at spamcop.net Mon Jan 3 19:00:59 2011 From: astar at spamcop.net (astar) Date: Mon, 3 Jan 2011 16:00:59 -0800 (PST) Subject: CPython on the Web References: <19141efb-a288-43bc-be0d-44769bf5974b@j32g2000prh.googlegroups.com><5942c6f9-7af5-4cff-84d4-f23a8b3bbfa1@k14g2000pre.googlegroups.com> <4D2106DF.6080609@verizon.net> Message-ID: On Jan 2, 4:58?pm, pyt... at bdurham.com wrote: > Azakai/Gerry, > > > Errors when using Firefox 3.6.3: > firefox 3.6.13 openbsd i386 4.8 -current error console has some errors: editor not defined module not define too much recursion nothing interested happened on the web page, but wonderful project anyway From alex at moreati.org.uk Mon Jan 3 19:17:00 2011 From: alex at moreati.org.uk (Alex Willmer) Date: Mon, 3 Jan 2011 16:17:00 -0800 (PST) Subject: Python comparison matrix Message-ID: <58cb13ff-2581-463b-9d0a-3c07ab39d3f7@glegroupsg2000goo.googlegroups.com> I've created a spreadsheet that compares the built ins, features and modules of the CPython releases so far. For instance it shows: - basestring was first introduced at version 2.3 then removed in version 3.0 - List comprehensions (PEP 202) were introduced at version 2.0. - apply() was a built in throughout the 1.x and 2.x series, but was deprecated in from 2.3 and removed in 3.0 - Generator functions were first introduced in 2.2 with __future__ import, from 2.3 they were fully supported https://spreadsheets.google.com/pub?key=0At5kubLl6ri7dHU2OEJFWkJ1SE16NUNvaGg2UFBxMUE The current version covers CPython 1.5 - 3.2 on these aspects: - Built in types and functions - Keywords - Modules - Interpreter switches and environment variables - Platforms, including shipped Python version(s) for major Linux distributions - Features/PEPs (incomplete) I gathered the data from the documentation at python.org. It's work in progress so there are plenty of rough edges and holes, but I'd like to get your opinions, feedback and suggestions. - Would you find such a document useful? - What format(s) would be most useful to you (e.g. spreadsheet, pdf, web page(s), database, wall chart, desktop background)? - Are there other aspects/pages that you'd like to see included? - Do you know of source(s) for which versions of CPython supported which operating systems (e.g. the first and last Python release that works on Windows 98 or Mac OS 9)? The best I've found so far is PEP 11 Regards and thanks, Alex From solipsis at pitrou.net Mon Jan 3 19:52:03 2011 From: solipsis at pitrou.net (Antoine Pitrou) Date: Tue, 4 Jan 2011 01:52:03 +0100 Subject: Python comparison matrix References: <58cb13ff-2581-463b-9d0a-3c07ab39d3f7@glegroupsg2000goo.googlegroups.com> Message-ID: <20110104015203.6be4477b@pitrou.net> On Mon, 3 Jan 2011 16:17:00 -0800 (PST) Alex Willmer wrote: > I've created a spreadsheet that compares the built ins, features and modules of the CPython releases so far. For instance it shows: A couple of errors: - BufferError is also in 3.x - IndentationError is also in 3.x - object is also in 3.x - NotImplemented is not an exception type, it's a built-in singleton like None - you forgot VMSError (only on VMS) :-) Regards Antoine. From python at bdurham.com Mon Jan 3 19:54:24 2011 From: python at bdurham.com (python at bdurham.com) Date: Mon, 03 Jan 2011 19:54:24 -0500 Subject: Python comparison matrix In-Reply-To: <58cb13ff-2581-463b-9d0a-3c07ab39d3f7@glegroupsg2000goo.googlegroups.com> References: <58cb13ff-2581-463b-9d0a-3c07ab39d3f7@glegroupsg2000goo.googlegroups.com> Message-ID: <1294102464.18692.1413347931@webmail.messagingengine.com> Alex, I think this type of documentation is incredibly useful! Is there some type of key which explains symbols like !, *, f, etc? Thanks for sharing this work with the community. Malcolm From alonmozilla at gmail.com Mon Jan 3 19:55:19 2011 From: alonmozilla at gmail.com (azakai) Date: Mon, 3 Jan 2011 16:55:19 -0800 (PST) Subject: CPython on the Web References: <19141efb-a288-43bc-be0d-44769bf5974b@j32g2000prh.googlegroups.com> Message-ID: On Jan 3, 12:13?pm, de... at web.de (Diez B. Roggisch) wrote: > A fun hack. Have you bothered to compare it to the PyPy javascript > backend - perfomance-wise, that is? > Gerry already gave a complete and accurate answer to the status of this project in comparison to PyPy and pyjamas. Regarding performance, this hack is not currently fast, primarily because the code is not optimized yet. But through a combination of optimizations on the side of Emscripten (getting all LLVM optimizations to work when compiling to JS) and on the side of the browsers (optimizing accesses on typed arrays in JS, etc.), then I hope the code will eventually run quite fast, even comparably to C. - azakai From alex at moreati.org.uk Mon Jan 3 20:01:17 2011 From: alex at moreati.org.uk (Alex Willmer) Date: Mon, 3 Jan 2011 17:01:17 -0800 (PST) Subject: Python comparison matrix In-Reply-To: Message-ID: <801098db-eaaf-4f06-927e-916c69ebdc82@glegroupsg2000goo.googlegroups.com> On Tuesday, January 4, 2011 12:54:24 AM UTC, Malcolm wrote: > Alex, > > I think this type of documentation is incredibly useful! Thank you. > Is there some type of key which explains symbols like !, *, f, etc? There is a key, it's the second tab from the end, '!' wasn't documented and I forgot why I marked bytes() thusly, so I've removed it. From alex at moreati.org.uk Mon Jan 3 20:01:17 2011 From: alex at moreati.org.uk (Alex Willmer) Date: Mon, 3 Jan 2011 17:01:17 -0800 (PST) Subject: Python comparison matrix In-Reply-To: Message-ID: <801098db-eaaf-4f06-927e-916c69ebdc82@glegroupsg2000goo.googlegroups.com> On Tuesday, January 4, 2011 12:54:24 AM UTC, Malcolm wrote: > Alex, > > I think this type of documentation is incredibly useful! Thank you. > Is there some type of key which explains symbols like !, *, f, etc? There is a key, it's the second tab from the end, '!' wasn't documented and I forgot why I marked bytes() thusly, so I've removed it. From alex at moreati.org.uk Mon Jan 3 20:10:52 2011 From: alex at moreati.org.uk (Alex Willmer) Date: Mon, 3 Jan 2011 17:10:52 -0800 (PST) Subject: Python comparison matrix In-Reply-To: Message-ID: <886aac2d-1db6-4c9f-98b9-e25ea7ff46c1@glegroupsg2000goo.googlegroups.com> Thank you Antoine, I've fixed those errors. Going by the docs, I have VMSError down as first introduced in Python 2.5. From alex at moreati.org.uk Mon Jan 3 20:10:52 2011 From: alex at moreati.org.uk (Alex Willmer) Date: Mon, 3 Jan 2011 17:10:52 -0800 (PST) Subject: Python comparison matrix In-Reply-To: Message-ID: <886aac2d-1db6-4c9f-98b9-e25ea7ff46c1@glegroupsg2000goo.googlegroups.com> Thank you Antoine, I've fixed those errors. Going by the docs, I have VMSError down as first introduced in Python 2.5. From alonmozilla at gmail.com Mon Jan 3 20:59:10 2011 From: alonmozilla at gmail.com (azakai) Date: Mon, 3 Jan 2011 17:59:10 -0800 (PST) Subject: CPython on the Web References: <19141efb-a288-43bc-be0d-44769bf5974b@j32g2000prh.googlegroups.com> <5942c6f9-7af5-4cff-84d4-f23a8b3bbfa1@k14g2000pre.googlegroups.com> <3e973cb5-4208-4f73-8bbf-15e1bc2f7595@35g2000prt.googlegroups.com> <11daa83d-d065-4816-b63b-a0144cc49943@n32g2000pre.googlegroups.com> Message-ID: On Jan 3, 12:23?pm, Gerry Reno wrote: > On 01/03/2011 03:10 PM, azakai wrote: > > > > > > > > > > > On Jan 2, 5:55 pm, Gerry Reno wrote: > > >> I tried printing sys.path and here is the output: > > >> ['', '/usr/local/lib/python27.zip', '/usr/local/lib/python2.7/', > >> '/usr/local/lib/python2.7/plat-linux2', > >> '/usr/local/lib/python2.7/lib-tk', '/usr/local/lib/python2.7/lib-old', > >> '/usr/local/lib/lib-dynload'] > > >> Now, those paths must be on your machine because they are not on my > >> client machine. ?But the interpreter is now running on MY machine. ?Well > >> in a sandbox really. ?So how is that going to work? > > > Yeah, those are the paths on the machine where the binary was compiled > > (so, they are the standard paths on ubuntu). > > > Anyhow the filesystem can't (and shouldn't) be accessed from inside a > > browser page. > > Well, the local filesystem could be accessible with the user's > permission and this should be an option. > Hmm, I think this might be possible with the HTML5 File API. Would definitely be useful here. - azakai From devplayer at gmail.com Mon Jan 3 22:28:08 2011 From: devplayer at gmail.com (DevPlayer) Date: Mon, 3 Jan 2011 19:28:08 -0800 (PST) Subject: Multiple instances and wrong parental links References: Message-ID: Mere are my ramblings of a novice (bad) Hobbyst programmer. You mentioned that your having a hard time coming up with a solution to your complex problem. Complex means you are doing lots of different things to different things all over the place where timing is an issue. First it seems you are trying to simplify your problem by creating a generic class you might call Element which is held in an ElementList class. Right? Or is it you would like you to create a new class for each unique element? If this is the case it would be because each unique element - behaves- differently. Is this the case? Or do all XML elements basically behave the same? If they behave the same you're confusing your design. A class represents a unique behavior. Remember instances can have unique attributes like "code" or "title". But I'm digressing. For example in your other discussion you posted at: https://groups.google.com/forum/#!topic/comp.lang.python/K9PinAbuCJk/discussion you say: So, an element like: Writers of the Future Or is the element structure?: "some value" Or is it like this? value Or like this? value value ... Or this, typical XML? value value ... value value ... And is nested or only one "sub" deep? Ask yourself why do you need to have a different class for each unique element type? Or in other words, why do you need a new class for each XML tag pair? If your elements are nested to some unknown depth, perhaps broaden your idea of your ElementList into an ElementTree. Take a look at the section "Basic Usage" midway down at url: http://effbot.org/zone/element-index.htm Or change you Market Class stucture(in your other discussion) to make it more dimensional by adding a tag attribute which would mark it as if it were a certain "class". class ElementNode(objec): def__init__(self, parent, elem) self.parent = parent # another elementNode object or None self.elem = elem # entire text block or just do offsets (i.e. file line numbers) self.tag = self.get_tag(elem) # market tag==class self.token = self.get_token(self) # "code" or whatever if variable self.sub_elems= self.get_subs(elem) # recursive ElementNodes; return a list or dict self.root = self.get_root(parent) # optional but handy # I like to use the root as the XML source; sometimes an XML file self.next = None # because I love double link lists # probably useful for that ObjectListView wxPython widget If in your case each Element does behave differently (ie has unique methods) then perhaps you should be looking at some other solution. Perhaps class factories or meta classes. I can't help you there. From rtomek at ceti.com.pl Mon Jan 3 22:48:21 2011 From: rtomek at ceti.com.pl (Tomasz Rola) Date: Tue, 4 Jan 2011 04:48:21 +0100 Subject: Python comparison matrix In-Reply-To: <58cb13ff-2581-463b-9d0a-3c07ab39d3f7@glegroupsg2000goo.googlegroups.com> References: <58cb13ff-2581-463b-9d0a-3c07ab39d3f7@glegroupsg2000goo.googlegroups.com> Message-ID: On Mon, 3 Jan 2011, Alex Willmer wrote: > I've created a spreadsheet that compares the built ins, features and > modules of the CPython releases so far. For instance it shows: [...] > I gathered the data from the documentation at python.org. It's work in > progress so there are plenty of rough edges and holes, but I'd like to > get your opinions, feedback and suggestions. > - Would you find such a document useful? Yes, definitely. Great idea, thanks for doing this. > - What format(s) would be most useful to you (e.g. spreadsheet, pdf, web > page(s), database, wall chart, desktop background)? I would vote for html/web pages with pdf as an option (i.e. a link), if you find it easy enough to make. This probably means you would like to have the source in a form that allows generation of both pages and pdf without much trouble. In this case, it seems there are more than few options to choose from. Perhaps in a form of Python code doing the job, with data in hashtables? That would be so Pythonish :-). > - Are there other aspects/pages that you'd like to see included? > - Do you know of source(s) for which versions of CPython supported which operating systems (e.g. the first and last Python release that works on Windows 98 or Mac OS 9)? The best I've found so far is PEP 11 Nothing comes to my head ATM. Regards, Tomasz Rola -- ** A C programmer asked whether computer had Buddha's nature. ** ** As the answer, master did "rm -rif" on the programmer's home ** ** directory. And then the C programmer became enlightened... ** ** ** ** Tomasz Rola mailto:tomasz_rola at bigfoot.com ** From kushal.kumaran+python at gmail.com Mon Jan 3 22:52:53 2011 From: kushal.kumaran+python at gmail.com (Kushal Kumaran) Date: Tue, 4 Jan 2011 09:22:53 +0530 Subject: String building using join In-Reply-To: <6ca085f6-7c03-44b2-a9f2-8d77db046c7e@s9g2000vby.googlegroups.com> References: <6ca085f6-7c03-44b2-a9f2-8d77db046c7e@s9g2000vby.googlegroups.com> Message-ID: On Mon, Jan 3, 2011 at 3:07 AM, gervaz wrote: > On 2 Gen, 19:14, Emile van Sebille wrote: >> >> >> class Test: >> ? ? ? def __init__(self, v1, v2): >> ? ? ? ? ? self.v1 = v1 >> ? ? ? ? ? self.v2 = v2 >> >> t1 = Test("hello", None) >> t2 = Test(None, "ciao") >> t3 = Test("salut", "hallo") >> t = [t1, t2, t3] >> >> "\n".join([y for x in t for y in [x.v1,x.v2] if y]) >> >> >> > > > Thanks Emile, despite that now the solution runs in quadratic time I > guess. I could also provide a __str__(self) representation, but in my > real code I don't have access to the class. Also using str() on an > empty object (i.e. None), the representation is 'None'. > Since no one else has mentioned it, I'll just point out that Emile's solution does not run in quadratic time. It has the same number of operations as the originally posted code. That str(None) results in "None" is not a problem because of the "if y" test in the list comprehension. -- regards, kushal From mrjean1 at gmail.com Mon Jan 3 23:28:30 2011 From: mrjean1 at gmail.com (MrJean1) Date: Mon, 3 Jan 2011 20:28:30 -0800 (PST) Subject: CPython on the Web References: <19141efb-a288-43bc-be0d-44769bf5974b@j32g2000prh.googlegroups.com><5942c6f9-7af5-4cff-84d4-f23a8b3bbfa1@k14g2000pre.googlegroups.com> <4D2106DF.6080609@verizon.net> <5a62ec44-7dd0-456c-b14c-92f3b97b7f2a@c13g2000prc.googlegroups.com> Message-ID: FireFox 3.6.13 on MacOS X Tiger (10.4.11) fails: Error: too much recursion Error: Modules is not defined Source File: http://synthensity.com/static/python.html /Jean On Jan 2, 11:26?pm, Wolfgang Strobl wrote: > azakai : > > >On Jan 2, 4:58 pm, pyt... at bdurham.com wrote: > >> Azakai/Gerry, > > >> > Errors when using Firefox 3.6.3: > > >> I'm running Firefox 3.6.1.3 and the interpreter is running fine. > > I guess that meant FIrefox 3.6.13 (without the last dot), the current > stable version. > > I'm using Firefox 3.6.13 (german) on Windowx XP (32bit, german) here, > and the interpreter is running fine, too. ?Same for Chrome 8.0.552.224. > > -- > Wir danken f r die Beachtung aller Sicherheitsbestimmungen From devplayer at gmail.com Mon Jan 3 23:34:18 2011 From: devplayer at gmail.com (DevPlayer) Date: Mon, 3 Jan 2011 20:34:18 -0800 (PST) Subject: list 2 dict? References: Message-ID: <69d248d7-cf62-49bf-9824-d8aec7de0a87@j25g2000yqa.googlegroups.com> An adaptation to Hrvoje Niksic's recipe Use a dictionary comprehention instead of a list comprehension or function call: lyst = [1, 2, 3, 4, 5, 6, 7, 'a', 8, 'b'] it = iter( lyst ) dyct = {i:it.next() for i in it} # I'm using {} and not [] for those with tiny fonts. #print dyct {8: 'b', 1: 2, 3: 4, 5: 6, 7: 'a'} Of course check for an "even" number of elements to the original list to avoid exceptions or dropping the last element on traps. From mrjean1 at gmail.com Mon Jan 3 23:34:33 2011 From: mrjean1 at gmail.com (MrJean1) Date: Mon, 3 Jan 2011 20:34:33 -0800 (PST) Subject: CPython on the Web References: <19141efb-a288-43bc-be0d-44769bf5974b@j32g2000prh.googlegroups.com> <5942c6f9-7af5-4cff-84d4-f23a8b3bbfa1@k14g2000pre.googlegroups.com> <3e973cb5-4208-4f73-8bbf-15e1bc2f7595@35g2000prt.googlegroups.com> <11daa83d-d065-4816-b63b-a0144cc49943@n32g2000pre.googlegroups.com> Message-ID: <96a8df4d-5cc2-4753-878b-68b1e044586b@z9g2000yqz.googlegroups.com> FYI, The example http://syntensity.com/static/python.html works fine in Safari 4.1.3 on MacOS X Tiger (10.4.11). /Jean On Jan 3, 5:59?pm, azakai wrote: > On Jan 3, 12:23?pm, Gerry Reno wrote: > > > > > > > On 01/03/2011 03:10 PM, azakai wrote: > > > > On Jan 2, 5:55 pm, Gerry Reno wrote: > > > >> I tried printing sys.path and here is the output: > > > >> ['', '/usr/local/lib/python27.zip', '/usr/local/lib/python2.7/', > > >> '/usr/local/lib/python2.7/plat-linux2', > > >> '/usr/local/lib/python2.7/lib-tk', '/usr/local/lib/python2.7/lib-old', > > >> '/usr/local/lib/lib-dynload'] > > > >> Now, those paths must be on your machine because they are not on my > > >> client machine. ?But the interpreter is now running on MY machine. ?Well > > >> in a sandbox really. ?So how is that going to work? > > > > Yeah, those are the paths on the machine where the binary was compiled > > > (so, they are the standard paths on ubuntu). > > > > Anyhow the filesystem can't (and shouldn't) be accessed from inside a > > > browser page. > > > Well, the local filesystem could be accessible with the user's > > permission and this should be an option. > > Hmm, I think this might be possible with the HTML5 File API. Would > definitely be useful here. > > - azakai From no.email at nospam.invalid Tue Jan 4 00:33:46 2011 From: no.email at nospam.invalid (Paul Rubin) Date: Mon, 03 Jan 2011 21:33:46 -0800 Subject: list 2 dict? References: Message-ID: <7xipy5b5c5.fsf@ruckus.brouhaha.com> "Octavian Rasnita" writes: > If I want to create a dictionary from a list... > l = [1, 2, 3, 4, 5, 6, 7, 'a', 8, 'b'] dict(l[i:i+2] for i in xrange(0,len(l),2)) seems simplest to me. From nagle at animats.com Tue Jan 4 01:11:20 2011 From: nagle at animats.com (John Nagle) Date: Mon, 03 Jan 2011 22:11:20 -0800 Subject: CPython on the Web In-Reply-To: <19141efb-a288-43bc-be0d-44769bf5974b@j32g2000prh.googlegroups.com> References: <19141efb-a288-43bc-be0d-44769bf5974b@j32g2000prh.googlegroups.com> Message-ID: <4d22ba06$0$44020$742ec2ed@news.sonic.net> On 1/1/2011 11:26 PM, azakai wrote: > Hello, I hope this will be interesting to people here: CPython running > on the web, > > http://syntensity.com/static/python.html > > That isn't a new implementation of Python, but rather CPython 2.7.1, > compiled from C to JavaScript using Emscripten and LLVM. For more > details on the conversion process, see http://emscripten.org It's a cute hack, but it's about 1000 times slower than CPython. Try def cnt(n) : j = 0 for i in xrange(n) : j = j + 1 return(j) print(cnt(1000000)) with this. It will take 30 seconds or so to count to a million. John Nagle From calderone.jeanpaul at gmail.com Tue Jan 4 01:13:54 2011 From: calderone.jeanpaul at gmail.com (Jean-Paul Calderone) Date: Mon, 3 Jan 2011 22:13:54 -0800 (PST) Subject: Interrput a thread References: <81c24eb1-41b6-442a-a971-8a44d2cd6c1b@p8g2000vbs.googlegroups.com> <4d1e20c5$0$43986$742ec2ed@news.sonic.net> <874o9q7x3m.fsf@web.de> <71631a5e-d3af-4c5d-9f1d-07eb8044d792@39g2000yqa.googlegroups.com> <4855b05f-1ea4-4287-9066-5aeb1b7cb720@k11g2000vbf.googlegroups.com> <3856d645-86a5-449f-adca-fcbbc6371ba4@l17g2000yqe.googlegroups.com> <561e8842-bcca-45c4-baee-e5431e778f6a@n10g2000yqd.googlegroups.com> Message-ID: <0e9cafd1-17ab-4a0f-b93f-a18929188b06@o4g2000yqd.googlegroups.com> On Jan 3, 6:17?pm, Adam Skutt wrote: > On Jan 3, 5:24?pm, Jean-Paul Calderone > wrote: > > > Of course. ?The whole point here is not about threads vs processes. > > It's about shared memory concurrency vs non-shared memory > > concurrency. ?You can implement both with threads and both with > > processes, but threads are geared towards shared memory and processes > > are geared towards non-shared memory. ?So what most people mean by > > "use processes" is "don't use shared memory". > > This is entirely my presumption, but I think if the OP were keenly > aware of the differences between thread and processes, it's pretty > likely he wouldn't have asked his question in the first place. > Fair enough. :) > Also, I've written lots and lots of "use processes" code on multiple > platforms, and much of it has used some sort of shared memory > construct. ?It's actually pretty common, especially in code bases with > a lot of history. ?Not all the world is Apache. > Hee hee, Apache. :) > Adam From alonmozilla at gmail.com Tue Jan 4 02:13:43 2011 From: alonmozilla at gmail.com (azakai) Date: Mon, 3 Jan 2011 23:13:43 -0800 (PST) Subject: CPython on the Web References: <19141efb-a288-43bc-be0d-44769bf5974b@j32g2000prh.googlegroups.com> <4d22ba06$0$44020$742ec2ed@news.sonic.net> Message-ID: On Jan 3, 10:11?pm, John Nagle wrote: > On 1/1/2011 11:26 PM, azakai wrote: > > > Hello, I hope this will be interesting to people here: CPython running > > on the web, > > >http://syntensity.com/static/python.html > > > That isn't a new implementation of Python, but rather CPython 2.7.1, > > compiled from C to JavaScript using Emscripten and LLVM. For more > > details on the conversion process, seehttp://emscripten.org > > ? ? It's a cute hack, but it's about 1000 times slower than CPython. > > Try > > def cnt(n) : > ? ? ?j = 0 > ? ? ?for i in xrange(n) : > ? ? ? ? ?j = j + 1 > ? ? ?return(j) > > print(cnt(1000000)) > > with this. ?It will take 30 seconds or so to count to a million. > > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? John Nagle Yes, as I said, "the code isn't optimized (so don't expect good performance)" :) It can get much faster with more work. - azakai From passionate_programmer at hotmail.com Tue Jan 4 03:00:49 2011 From: passionate_programmer at hotmail.com (RP Khare) Date: Tue, 4 Jan 2011 13:30:49 +0530 Subject: Qt with PyDev Message-ID: I installed Aptana PyDev plugin to Aptana Studio 3 Beta. I want to write my first GUI application using Python and I want to use Qt for it. How to integrate Qt into PyDev, or is there any other alternative IDE to work with Qt?elementFontfont-familyfont-sizefont-stylefont-variantfont-weightletter-spacingline-heighttext-decorationtext-aligntext-indenttext-transformwhite-spaceword-spacingcolorBackgroundbg-attachmentbg-colorbg-imagebg-positionbg-repeatBoxwidthheightborder-topborder-rightborder-bottomborder-leftmarginpaddingmax-heightmin-heightmax-widthmin-widthoutline-coloroutline-styleoutline-widthPositioningpositiontopbottomrightleftfloatdisplayclearz-indexListlist-style-imagelist-style-typelist-style-positionTablevertical-alignborder-collapseborder-spacingcaption-sideempty-cellstable-layoutEffectstext-shadow-webkit-box-shadowborder-radiusOtheroverflowcursorvisibility ...........Rohit -------------- next part -------------- An HTML attachment was scrubbed... URL: From nagle at animats.com Tue Jan 4 03:02:47 2011 From: nagle at animats.com (John Nagle) Date: Tue, 04 Jan 2011 00:02:47 -0800 Subject: CPython on the Web In-Reply-To: References: <19141efb-a288-43bc-be0d-44769bf5974b@j32g2000prh.googlegroups.com> <4d22ba06$0$44020$742ec2ed@news.sonic.net> Message-ID: <4d22d425$0$44041$742ec2ed@news.sonic.net> On 1/3/2011 11:13 PM, azakai wrote: > On Jan 3, 10:11 pm, John Nagle wrote: >> On 1/1/2011 11:26 PM, azakai wrote: >> >>> Hello, I hope this will be interesting to people here: CPython running >>> on the web, >> >>> http://syntensity.com/static/python.html >> >>> That isn't a new implementation of Python, but rather CPython 2.7.1, >>> compiled from C to JavaScript using Emscripten and LLVM. For more >>> details on the conversion process, seehttp://emscripten.org >> >> It's a cute hack, but it's about 1000 times slower than CPython. > > Yes, as I said, "the code isn't optimized (so > don't expect good performance)" :) > > It can get much faster with more work. Yea, right. You're three deep in interpreters. Performance is going to suck. John Nagle From devplayer at gmail.com Tue Jan 4 04:12:32 2011 From: devplayer at gmail.com (DevPlayer) Date: Tue, 4 Jan 2011 01:12:32 -0800 (PST) Subject: list 2 dict? References: <69d248d7-cf62-49bf-9824-d8aec7de0a87@j25g2000yqa.googlegroups.com> Message-ID: <11865218-b187-479e-8ef9-9a66d8b3b443@j25g2000yqa.googlegroups.com> or only convert the item when you need it leaving the lists as the source lyst = [1, 2, 3, 4, 5, 6, 7, 'a', 8, 'b'] func = lambda alist, index: dict([(lyst[index*2], lyst[(index*2)+1]),]) func(lyst, 0) {1: 2} func(lyst, 2) {5: 6} ##########------------ or as a function def func(lyst, index): return dict(((lyst[index], lyst[index+1]),)) From oknedz at gmail.com Tue Jan 4 04:40:02 2011 From: oknedz at gmail.com (Zdenko) Date: Tue, 04 Jan 2011 10:40:02 +0100 Subject: Matrix multiplication Message-ID: Please, can anybody write me a simple recursive matrix multiplication using multiple threads in Python, or at least show me some guidelines how to write it myself Thank You From wander.lairson at gmail.com Tue Jan 4 05:06:05 2011 From: wander.lairson at gmail.com (wander.lairson) Date: Tue, 4 Jan 2011 08:06:05 -0200 Subject: PyPi question Message-ID: Dear all, I am the PyUSB author and recently I was asked to update pyusb package in the PyPi. The point is that I am not the maintainer and don't know who is. Now I need to contact the current package maintainer but I could not find how to do so through PyPi (as maintainer's email does not show). Does anyone know how am I supposed to proceed (open a support request, maybe) ? Thanks in advance. -- Best Regards, Wander Lairson Costa LCoN - Laborat?rio de Computa??o Natural - Natural Computing Laboratory (http://www.mackenzie.com.br/lcon.html) Programa de P?s-Gradua??o em Engenharia El?trica (PPGEE) Faculdade de Computa??o e Inform?tica (FCI) Universidade Presbiteriana Mackenzie - SP - Brazil From ulrich.eckhardt at dominolaser.com Tue Jan 4 05:15:15 2011 From: ulrich.eckhardt at dominolaser.com (Ulrich Eckhardt) Date: Tue, 04 Jan 2011 11:15:15 +0100 Subject: Matrix multiplication References: Message-ID: <4h8bv7-p09.ln1@satorlaser.homedns.org> Zdenko wrote: > Please, can anybody write me a simple recursive matrix multiplication > using multiple threads in Python, or at least show me some guidelines > how to write it myself No problem, I just need your bank account data to withdraw the payment and the address of your teacher whom to send the results. ;^) Seriously, things don't work like this. If you show effort, you will get help, but you don't get working solutions without even a bit of effort on your own. Start with a recursive algorithm, then make it multithreaded. Be prepared to make some experiments on how to distribute tasks to threads and collect them again. Uli From spy974 at gmail.com Tue Jan 4 06:05:23 2011 From: spy974 at gmail.com (=?ISO-8859-1?Q?Gr=E9gory_Leocadie?=) Date: Tue, 4 Jan 2011 03:05:23 -0800 (PST) Subject: Matrix multiplication References: <4h8bv7-p09.ln1@satorlaser.homedns.org> Message-ID: On 4 jan, 11:15, Ulrich Eckhardt wrote: > Zdenko wrote: > > Please, can anybody write me a simple recursive matrix multiplication > > using multiple threads in Python, or at least show me some guidelines > > how to write it myself > > No problem, I just need your bank account data to withdraw the payment and > the address of your teacher whom to send the results. ;^) > > Seriously, things don't work like this. If you show effort, you will get > help, but you don't get working solutions without even a bit of effort on > your own. > > Start with a recursive algorithm, then make it multithreaded. Be prepared to > make some experiments on how to distribute tasks to threads and collect > them again. > > Uli Hi, just have a look here http://en.wikipedia.org/wiki/Matrix_multiplication and find out what parts can be parallelized ;) Gregory LEOCADIE From pavlovevidence at gmail.com Tue Jan 4 06:17:34 2011 From: pavlovevidence at gmail.com (Carl Banks) Date: Tue, 4 Jan 2011 03:17:34 -0800 (PST) Subject: CPython on the Web References: <19141efb-a288-43bc-be0d-44769bf5974b@j32g2000prh.googlegroups.com> Message-ID: <98f1b5df-c1af-450e-876b-365e00f33695@v17g2000prc.googlegroups.com> On Jan 3, 4:55?pm, azakai wrote: > But through a combination of optimizations on the side of Emscripten > (getting all LLVM optimizations to work when compiling to JS) and on > the side of the browsers (optimizing accesses on typed arrays in JS, > etc.), then I hope the code will eventually run quite fast, even > comparably to C. This is a very cool idea. It's quite fascinating to view the Javascript "machine code" for a complete CPython interpreter. I'm sure with a little work you'll be able to improve its performance, but I think "comparably to C" is going to be a tall order. If you can get this to work reasonably well, and manage to get it successfully deployed it somewhere, I'd recommend petitioning to have this be considered an official platform. Carl Banks From oknedz at gmail.com Tue Jan 4 07:22:33 2011 From: oknedz at gmail.com (Zdenko) Date: Tue, 04 Jan 2011 13:22:33 +0100 Subject: Matrix multiplication In-Reply-To: <4h8bv7-p09.ln1@satorlaser.homedns.org> References: <4h8bv7-p09.ln1@satorlaser.homedns.org> Message-ID: On 4.1.2011 11:15, Ulrich Eckhardt wrote: > Zdenko wrote: >> Please, can anybody write me a simple recursive matrix multiplication >> using multiple threads in Python, or at least show me some guidelines >> how to write it myself > > No problem, I just need your bank account data to withdraw the payment and > the address of your teacher whom to send the results. ;^) > > Seriously, things don't work like this. If you show effort, you will get > help, but you don't get working solutions without even a bit of effort on > your own. > > Start with a recursive algorithm, then make it multithreaded. Be prepared to > make some experiments on how to distribute tasks to threads and collect > them again. > > Uli > Ok, I expected something like this :) Lets try this way: I wrote these two codes for example: this one is naive way of matrix multiplication using one thread from random import * from time import clock import threading t0 = clock() A=[] B=[] C=[] m=300 #size of matrix m x m for i in range(m): A.append([]) B.append([]) C.append([]) for j in range(m): A[i].append(randint(1,9)) B[i].append(randint(1,9)) C[i].append(0) class MyThread ( threading.Thread ): def run ( self ): for i in range(m): for j in range(m): for k in range(m): C[i][j]+=A[i][k]*B[k][j] t=MyThread() t.start() t.join() print clock() - t0, "seconds" this one is using two threads, each one is multiplying half of matrix import time from threading import Thread from random import randint t0 = time.clock() class MyThread(Thread): def __init__(self, poc, kr): Thread.__init__(self) self.poc=poc self.kr=kr def run(self): for i in range(self.poc,self.kr): for j in range(m): for k in range(m): C[i][j]+=A[i][k]*B[k][j] A=[] B=[] C=[] m=300 #size of matrix m x m for i in range(m): A.append([]) B.append([]) C.append([]) for j in range(m): A[i].append(randint(1,9)) B[i].append(randint(1,9)) C[i].append(0) thr1=MyThread(0,m/2) thr2=MyThread(m/2,m) thr1.start() thr2.start() thr1.join() thr2.join() print time.clock() - t0, "seconds" why is second one more than twice slower than first when it should be faster. I suspect that problem is in simultaneous access to matrix C but i don't know how to solve this. I used this just for example to see how the threading works so i can work on recursive and Strassen algorithm. From devplayer at gmail.com Tue Jan 4 09:27:07 2011 From: devplayer at gmail.com (DevPlayer) Date: Tue, 4 Jan 2011 06:27:07 -0800 (PST) Subject: Python comparison matrix References: <58cb13ff-2581-463b-9d0a-3c07ab39d3f7@glegroupsg2000goo.googlegroups.com> Message-ID: <40120908-0951-46bb-91c6-2efdcb5be4cc@l7g2000vbv.googlegroups.com> Awesome, thanks so much for you efforts and sharing. Idea: It would be great if we put this table into a python program where I can run a script against this table and a Python source code module (file) so that it would spit out a list of strings showing what python versions work with said source code file. python.exe get_versions.py myPythonSourceFile.py -insertMetaInfo Would prepend a text line to myPythonSourceFile.py in some format like: # __requires_python__ = ["Python 2.5-2.7"] or # __requires_python__ = ["Python", "2.5.x", "2.6.x", "2.7.x"] or # __requires_python__ = {"1.0.x":False, ..., "2.5.x":True, "2.6.x":True, "2.7.x":True] where key format is comparable agains on of the following: sys.version, sys.version_info, sys.winver, sys.api_version, sys.subversion Idea: Perhaps add the table you made a list of which libraries/packages are included in the distro to the different releases. Comparable against sys.builtin_module_names Anyone ambisous enough to play with those idea, be my guest. From gervaz at gmail.com Tue Jan 4 10:05:41 2011 From: gervaz at gmail.com (gervaz) Date: Tue, 4 Jan 2011 07:05:41 -0800 (PST) Subject: Interrput a thread References: <81c24eb1-41b6-442a-a971-8a44d2cd6c1b@p8g2000vbs.googlegroups.com> <4d1e20c5$0$43986$742ec2ed@news.sonic.net> <874o9q7x3m.fsf@web.de> <71631a5e-d3af-4c5d-9f1d-07eb8044d792@39g2000yqa.googlegroups.com> <4855b05f-1ea4-4287-9066-5aeb1b7cb720@k11g2000vbf.googlegroups.com> <3856d645-86a5-449f-adca-fcbbc6371ba4@l17g2000yqe.googlegroups.com> <561e8842-bcca-45c4-baee-e5431e778f6a@n10g2000yqd.googlegroups.com> <0e9cafd1-17ab-4a0f-b93f-a18929188b06@o4g2000yqd.googlegroups.com> Message-ID: <0e803f65-3941-4c94-84b5-8a1100942742@j29g2000yqm.googlegroups.com> On 4 Gen, 07:13, Jean-Paul Calderone wrote: > On Jan 3, 6:17?pm, Adam Skutt wrote: > > > On Jan 3, 5:24?pm, Jean-Paul Calderone > > wrote: > > > > Of course. ?The whole point here is not about threads vs processes. > > > It's about shared memory concurrency vs non-shared memory > > > concurrency. ?You can implement both with threads and both with > > > processes, but threads are geared towards shared memory and processes > > > are geared towards non-shared memory. ?So what most people mean by > > > "use processes" is "don't use shared memory". > > > This is entirely my presumption, but I think if the OP were keenly > > aware of the differences between thread and processes, it's pretty > > likely he wouldn't have asked his question in the first place. > > Fair enough. :) > > > Also, I've written lots and lots of "use processes" code on multiple > > platforms, and much of it has used some sort of shared memory > > construct. ?It's actually pretty common, especially in code bases with > > a lot of history. ?Not all the world is Apache. > > Hee hee, Apache. :) > > > > > Adam- Nascondi testo citato > > - Mostra testo citato - BTW thanks for the suggestions. As in my original code snippet, the shared object that the threads are using is the Queue, that itself implement locking mechanism so I don't have to worry about concurrent access. Regarding my question, it was just to have a hint on how a thread termination can be handled as, per example, you have the consumer-producer pattern. Mattia From gherron at islandtraining.com Tue Jan 4 10:09:53 2011 From: gherron at islandtraining.com (Gary Herron) Date: Tue, 04 Jan 2011 07:09:53 -0800 Subject: Qt with PyDev In-Reply-To: References: Message-ID: <4D233841.9080909@islandtraining.com> On 01/04/2011 12:00 AM, RP Khare wrote: > I installed Aptana PyDev plugin to Aptana Studio 3 Beta. I want to > write my first GUI application using Python and I want to use Qt for > it. How to integrate Qt into PyDev, or is there any other alternative > IDE to work with Qt? > > > element > > Font > font-family > font-size > font-style > font-variant > font-weight > letter-spacing > line-height > text-decoration > text-align > text-indent > text-transform > white-space > word-spacing > color > Background > bg-attachment > bg-color > bg-image > bg-position > bg-repeat > Box > width > height > border-top > border-right > border-bottom > border-left > margin > padding > max-height > min-height > max-width > min-width > outline-color > outline-style > outline-width > Positioning > position > top > bottom > right > left > float > display > clear > z-index > List > list-style-image > list-style-type > list-style-position > Table > vertical-align > border-collapse > border-spacing > caption-side > empty-cells > table-layout > Effects > text-shadow > -webkit-box-shadow > border-radius > Other > overflow > cursor > visibility > > > ........... > Rohit See either of these packages: PyQt: http://qt.nokia.com/products/ PySide: http://www.pyside.org/ Either one should work with PyDev. Gary Herron -------------- next part -------------- An HTML attachment was scrubbed... URL: From fuzzyman at gmail.com Tue Jan 4 10:12:48 2011 From: fuzzyman at gmail.com (Fuzzyman) Date: Tue, 4 Jan 2011 07:12:48 -0800 (PST) Subject: Interrput a thread References: <81c24eb1-41b6-442a-a971-8a44d2cd6c1b@p8g2000vbs.googlegroups.com> Message-ID: <2ebc11a5-1b45-4faa-97b9-c84f0db015a4@k22g2000yqh.googlegroups.com> On Dec 29 2010, 11:31?pm, gervaz wrote: > Hi all, I need to stop a threaded (using CTR+C or kill) application if > it runs too much or if I decide to resume the work later. > I come up with the following test implementation but I wanted some > suggestion from you on how I can implement what I need in a better or > more pythonic way. Here the code: This is a case that .NET (C#) handles better than Python or Java. It is unsafe to terminate an os level thread at an arbitrary point because it may be executing code in a critical section. Both Java and .NET used to provide ways to terminate threads "safely" by raising an asynchronous exception in the thread. Releasing locks (etc) that the thread holds could then be done in a finally section protecting the code. Python doesn't allow you to abort threads. Unfortunately the thread abort exception could also be raised in the finally section - prematurely aborting the lock / resource cleanup. Java handled this by deprecating thread aborting. (Python has never had it I believe.) .NET handled it by changing the semantics of thread aborting - the thread abort exception will never be raised in a finally block. This makes thread aborting safe, although technically you can subvert it by putting all your code in a finally block (you can also catch and cancel the thread abort exception). The standard advice is to use a flag and do manual checking to abort threads. This only works for fine grained operations and *doesn't* work for very coarse grained operations or where there aren't convenient places to check the flag. It's another place where people sometimes have a genuine need/use case yet people will insist on telling them they don't *really* want it... Anyway, although there are ways based on ctypes to abort Python threads it's not really safe. If you google you should find them, hopefully with intelligible caveat emptor warnings... All the best, Michael Foord > > import os > import signal > import time > from threading import Thread, current_thread > from queue import LifoQueue, Empty > > COMMAND = {"STOP": 0, "NORMAL": 1} > THREAD_NUM = 5 > > lq = LifoQueue() > > print("{0}\n".format(os.getpid())) > > class InterceptInterrupt(Exception): > ? ? pass > > class Handler: > ? ? def __init__(self, queue): > ? ? ? ? self._queue = queue > ? ? def __del__(self): > ? ? ? ? print("Bye bye!") > ? ? def getHandler(self, signum, frame): > ? ? ? ? print("Interrupt raised!") > ? ? ? ? for _ in range(THREAD_NUM): > ? ? ? ? ? ? self._queue.put((COMMAND["STOP"], None)) > ? ? ? ? raise InterceptInterrupt > > h = Handler(lq) > > signal.signal(signal.SIGINT, h.getHandler) > > for i in range(25): > ? ? lq.put((COMMAND["NORMAL"], i)) > > def do_work(queue): > ? ? while True: > ? ? ? ? time.sleep(5) > ? ? ? ? try: > ? ? ? ? ? ? cmd, value = queue.get(block=False) > ? ? ? ? ? ? if cmd == COMMAND["STOP"]: > ? ? ? ? ? ? ? ? print("{0}: STOP command > received!".format(current_thread().name)) > ? ? ? ? ? ? ? ? break > ? ? ? ? ? ? elif cmd == COMMAND["NORMAL"]: > ? ? ? ? ? ? ? ? print(value) > ? ? ? ? except Empty: > ? ? ? ? ? ? break > > threads = [Thread(target=do_work, args=(lq,)) for _ in > range(THREAD_NUM)] > > for t in threads: > ? ? t.start() > > while not lq.empty(): > ? ? try: > ? ? ? ? time.sleep(1) > ? ? except (IOError, InterceptInterrupt): > ? ? ? ? break > > for t in threads: > ? ? t.join() > > if lq.empty(): > ? ? print("The queue is empty.") > else: > ? ? print("The queue is NOT empty. Some additional work has to be > done.") > > Thank you, > Mattia From fuzzyman at gmail.com Tue Jan 4 10:13:49 2011 From: fuzzyman at gmail.com (Fuzzyman) Date: Tue, 4 Jan 2011 07:13:49 -0800 (PST) Subject: Interrput a thread References: <81c24eb1-41b6-442a-a971-8a44d2cd6c1b@p8g2000vbs.googlegroups.com> <2ebc11a5-1b45-4faa-97b9-c84f0db015a4@k22g2000yqh.googlegroups.com> Message-ID: <8b7bcabb-a7f8-4967-8ddb-3fc8ae40559a@w17g2000yqh.googlegroups.com> On Jan 4, 3:12?pm, Fuzzyman wrote: > On Dec 29 2010, 11:31?pm, gervaz wrote: > > > Hi all, I need to stop a threaded (using CTR+C or kill) application if > > it runs too much or if I decide to resume the work later. > > I come up with the following test implementation but I wanted some > > suggestion from you on how I can implement what I need in a better or > > more pythonic way. Here the code: > > This is a case that .NET (C#) handles better than Python or Java. > Heh, so one possible option is to use IronPython.... :-) Michael Foord > It is unsafe to terminate an os level thread at an arbitrary point > because it may be executing code in a critical section. Both Java > and .NET used to provide ways to terminate threads "safely" by raising > an asynchronous exception in the thread. Releasing locks (etc) that > the thread holds could then be done in a finally section protecting > the code. Python doesn't allow you to abort threads. > > Unfortunately the thread abort exception could also be raised in the > finally section - prematurely aborting the lock / resource cleanup. > > Java handled this by deprecating thread aborting. (Python has never > had it I believe.) > > .NET handled it by changing the semantics of thread aborting - the > thread abort exception will never be raised in a finally block. This > makes thread aborting safe, although technically you can subvert it by > putting all your code in a finally block (you can also catch and > cancel the thread abort exception). > > The standard advice is to use a flag and do manual checking to abort > threads. This only works for fine grained operations and *doesn't* > work for very coarse grained operations or where there aren't > convenient places to check the flag. It's another place where people > sometimes have a genuine need/use case yet people will insist on > telling them they don't *really* want it... > > Anyway, although there are ways based on ctypes to abort Python > threads it's not really safe. If you google you should find them, > hopefully with intelligible caveat emptor warnings... > > All the best, > > Michael Foord > > > > > import os > > import signal > > import time > > from threading import Thread, current_thread > > from queue import LifoQueue, Empty > > > COMMAND = {"STOP": 0, "NORMAL": 1} > > THREAD_NUM = 5 > > > lq = LifoQueue() > > > print("{0}\n".format(os.getpid())) > > > class InterceptInterrupt(Exception): > > ? ? pass > > > class Handler: > > ? ? def __init__(self, queue): > > ? ? ? ? self._queue = queue > > ? ? def __del__(self): > > ? ? ? ? print("Bye bye!") > > ? ? def getHandler(self, signum, frame): > > ? ? ? ? print("Interrupt raised!") > > ? ? ? ? for _ in range(THREAD_NUM): > > ? ? ? ? ? ? self._queue.put((COMMAND["STOP"], None)) > > ? ? ? ? raise InterceptInterrupt > > > h = Handler(lq) > > > signal.signal(signal.SIGINT, h.getHandler) > > > for i in range(25): > > ? ? lq.put((COMMAND["NORMAL"], i)) > > > def do_work(queue): > > ? ? while True: > > ? ? ? ? time.sleep(5) > > ? ? ? ? try: > > ? ? ? ? ? ? cmd, value = queue.get(block=False) > > ? ? ? ? ? ? if cmd == COMMAND["STOP"]: > > ? ? ? ? ? ? ? ? print("{0}: STOP command > > received!".format(current_thread().name)) > > ? ? ? ? ? ? ? ? break > > ? ? ? ? ? ? elif cmd == COMMAND["NORMAL"]: > > ? ? ? ? ? ? ? ? print(value) > > ? ? ? ? except Empty: > > ? ? ? ? ? ? break > > > threads = [Thread(target=do_work, args=(lq,)) for _ in > > range(THREAD_NUM)] > > > for t in threads: > > ? ? t.start() > > > while not lq.empty(): > > ? ? try: > > ? ? ? ? time.sleep(1) > > ? ? except (IOError, InterceptInterrupt): > > ? ? ? ? break > > > for t in threads: > > ? ? t.join() > > > if lq.empty(): > > ? ? print("The queue is empty.") > > else: > > ? ? print("The queue is NOT empty. Some additional work has to be > > done.") > > > Thank you, > > Mattia From roy at panix.com Tue Jan 4 10:31:15 2011 From: roy at panix.com (Roy Smith) Date: Tue, 04 Jan 2011 10:31:15 -0500 Subject: Interrput a thread References: <81c24eb1-41b6-442a-a971-8a44d2cd6c1b@p8g2000vbs.googlegroups.com> <2ebc11a5-1b45-4faa-97b9-c84f0db015a4@k22g2000yqh.googlegroups.com> Message-ID: In article <2ebc11a5-1b45-4faa-97b9-c84f0db015a4 at k22g2000yqh.googlegroups.com>, Fuzzyman wrote: > It is unsafe to terminate an os level thread at an arbitrary point > because it may be executing code in a critical section. > [...] > The standard advice is to use a flag and do manual checking to abort > threads. This only works for fine grained operations and *doesn't* > work for very coarse grained operations or where there aren't > convenient places to check the flag. Another possibility is to not use threads! If you 1) Need asynchronous operation 2) Need iterruptability 3) Can't poll for an "please stop" signal You should look at running your "thread" as a separate process, which you can send a kill signal to when you want it to go away. You can then communicate with it via pipes, sockets, shared memory segments, whatever. Threads are a wonderful invention, but they are not a panacea for all possible parallelism tasks. Sometimes they're just the wrong tool. From devplayer at gmail.com Tue Jan 4 10:42:25 2011 From: devplayer at gmail.com (DevPlayer) Date: Tue, 4 Jan 2011 07:42:25 -0800 (PST) Subject: Matrix multiplication References: <4h8bv7-p09.ln1@satorlaser.homedns.org> Message-ID: <5909a2c0-b1ed-4dbd-852f-bb67c5dd5aa0@f9g2000vbq.googlegroups.com> I would be very suprised if you achieve faster results threading this problem. There's been much discussed on benefits or lack thereof to threading in Python (or in general). Threading is best used in situations where you are doing different kinds of tasks. For example if you want to do your matrix multiplication WHILE you were doing other things on your computer where matrix multiplication was a background process chugging away when you are not taxing the computer doing other stuff. Threading adds efficiency when you would have lots of "blocking" operations like reading in lots of big files from a comparable slow hard drive (compared to how fast a CPU processes data) or waiting on netword data (super slow compared to CPU processing). When you are doing mass numeric processing, you want to minimize the jumping from one function to another which uses overhead, recursion adds a small amount of uneccessary overhead, you want to minimize the need for the cpu to switch between threads or processes. If you still feel the need to use threads for some reason, for numeric processing I'd recommend using a "lighter" thread object, like a tiny thread or green thread or a threadlet or whatever they are calling them now. Another thing to note is it seems you might be expecting threads to run on different CPU cores expecting improvment. Be careful with this assumption. This is not always true. It is up to the CPU and OS to determine how threads are handled and perhaps the GIL to some extent. Beaware that Python has a GIL (some distributions). Google it if you don't know of it. To encourage better use of multi-core cpus you might consider the multiprocessing library included in Python 2.7 (I think) and above. I'm assuming that speed is an issue because you where timing your code. If you are doing actual serious number crunching there's lots of advice on this. The python Numpy package as well as Stackless Python (for microthreads or whatever thier called) comes to mind. Another thought. Ask yourself if you need a large in-memory or live set of processed numbers, in your case a fully and processed multiplied matrix. Usually a large set of in-memory numbers is something your going to use to simulate a model or to process and crunch further. Or is your actual usage going to be picking out a processed number here or there from the matrix. If this is true look at iterators or generators. Which would be a snapshot in time of your matrix multiplication. I like to think of Python generators like integral calculus (definition at: http://en.wikipedia.org/wiki/Integral_calculus) where the specific integral of a generator is often just 1. I'm loving generators a lot. For example there are generator accelorators which if you think it through means you can make generator deccelorators, useful for doing interpolation between elements of your matrix elements for example. I always forget if generators are thread safe though. Some indicators that generators could help: You're doing lots of for loops with range(). Also it's been measured that list comprehensions are slightly faster then while loops are a slightly faster then for loops. You can Google to confirm, enter something like "python fast iteration". Also if your numbers in your matix are actually not really numbers but objects with numbers, __slots__ is used to for large sets of objects (10s of millions at the very least) to minimize memory usage and perhaps with speed, if used properly. Just mentioning. I'd stay away from this though. Some of my informatation may be inaccurate (and even completely wrong; like I always get when a thread is best switched during a blocking verse a non-blocking operation) but there are some things to consider. From devplayer at gmail.com Tue Jan 4 10:49:29 2011 From: devplayer at gmail.com (DevPlayer) Date: Tue, 4 Jan 2011 07:49:29 -0800 (PST) Subject: Matrix multiplication References: <4h8bv7-p09.ln1@satorlaser.homedns.org> <5909a2c0-b1ed-4dbd-852f-bb67c5dd5aa0@f9g2000vbq.googlegroups.com> Message-ID: <961f9f53-5f51-4667-bac4-020dffeca3be@m7g2000vbn.googlegroups.com> BTW http://www.python.org/dev/peps/pep-0211/ From devplayer at gmail.com Tue Jan 4 11:10:02 2011 From: devplayer at gmail.com (DevPlayer) Date: Tue, 4 Jan 2011 08:10:02 -0800 (PST) Subject: Matrix multiplication References: <4h8bv7-p09.ln1@satorlaser.homedns.org> <5909a2c0-b1ed-4dbd-852f-bb67c5dd5aa0@f9g2000vbq.googlegroups.com> Message-ID: See section titled: "'array' or 'matrix'? Which should I use?" at http://www.scipy.org/NumPy_for_Matlab_Users BTW http://www.python.org/dev/peps/pep-0211/ From drsalists at gmail.com Tue Jan 4 12:08:32 2011 From: drsalists at gmail.com (Dan Stromberg) Date: Tue, 4 Jan 2011 09:08:32 -0800 Subject: Matrix multiplication In-Reply-To: References: <4h8bv7-p09.ln1@satorlaser.homedns.org> Message-ID: On Tue, Jan 4, 2011 at 4:22 AM, Zdenko wrote: > On 4.1.2011 11:15, Ulrich Eckhardt wrote: >> >> Zdenko wrote: >>> >>> Please, can anybody write me a simple recursive matrix multiplication >>> using multiple threads in Python, or at least show me some guidelines >>> how to write it myself >> >> No problem, I just need your bank account data to withdraw the payment and >> the address of your teacher whom to send the results. ;^) >> >> Seriously, things don't work like this. If you show effort, you will get >> help, but you don't get working solutions without even a bit of effort on >> your own. >> >> Start with a recursive algorithm, then make it multithreaded. Be prepared >> to >> make some experiments on how to distribute tasks to threads and collect >> them again. >> >> Uli >> > > Ok, I expected something like this :) > Lets try this way: > > I wrote these two codes for example: > > this one is naive way of matrix multiplication using one thread > > from random import * > from time import clock > import threading > > t0 = clock() > A=[] > B=[] > C=[] > m=300 ?#size of matrix m x m > > for i in range(m): > ? ?A.append([]) > ? ?B.append([]) > ? ?C.append([]) > ? ?for j in range(m): > ? ? ? ?A[i].append(randint(1,9)) > ? ? ? ?B[i].append(randint(1,9)) > ? ? ? ?C[i].append(0) > > class MyThread ( threading.Thread ): > > ? def run ( self ): > ? ? ? ? ? for i in range(m): > ? ? ? ? ? ? ? ?for j in range(m): > ? ? ? ? ? ? ? ? ? ?for k in range(m): > ? ? ? ? ? ? ? ? ? ? ? ?C[i][j]+=A[i][k]*B[k][j] > > t=MyThread() > t.start() > t.join() > print clock() - t0, "seconds" > > > > this one is using two threads, each one is multiplying half of matrix > > import time > from threading import Thread > from random import randint > > t0 = time.clock() > class MyThread(Thread): > ? ?def __init__(self, poc, kr): > ? ? ? ?Thread.__init__(self) > ? ? ? ?self.poc=poc > ? ? ? ?self.kr=kr > ? ?def run(self): > ? ? ? ? ? for i in range(self.poc,self.kr): > ? ? ? ? ? ? ? ?for j in range(m): > ? ? ? ? ? ? ? ? ? ?for k in range(m): > ? ? ? ? ? ? ? ? ? ? ? ?C[i][j]+=A[i][k]*B[k][j] > > A=[] > B=[] > C=[] > m=300 #size of matrix m x m > > for i in range(m): > ? ?A.append([]) > ? ?B.append([]) > ? ?C.append([]) > ? ?for j in range(m): > ? ? ? ?A[i].append(randint(1,9)) > ? ? ? ?B[i].append(randint(1,9)) > ? ? ? ?C[i].append(0) > thr1=MyThread(0,m/2) > thr2=MyThread(m/2,m) > thr1.start() > thr2.start() > thr1.join() > thr2.join() > print time.clock() - t0, "seconds" > > why is second one more than twice slower than first when it should be > faster. I suspect that problem is in simultaneous access to matrix C but i > don't know how to solve this. > > I used this just for example to see how the threading works so i can work on > recursive and Strassen algorithm. > -- > http://mail.python.org/mailman/listinfo/python-list > Threads in CPython are decent when you're doing I/O, not so good when you're doing CPU-bound tasks. When you're doing CPU-bound tasks, you may actually find that your application runs about 1/n times as fast, where n is the number of CPU's - that is, much slower. I don't mean that it just doesn't scale well, I mean that each additional CPU makes things slower for CPU-bound jobs. If you require java-like threading, you might be better off with Jython or Iron Python for now. pypy's likely to have good threading eventually, but last I heard it wasn't quite there yet. If you do require CPython, you might check out the greenlets module and/or PyCSP. Oh, and there's "stackless python", which amounts to a branch of CPython that's unlikely to be merged. It's supposed to be able to thread really well, and ISTR hearing that it's pretty similar to greenlets. The main force behind stackless is working on pypy now, I believe. Finally, with CPython, you can use the multiprocessing module to get pretty good parallelism via distinct processes. This way you tend to end up using queues for interprocess communication; these queues use shared memory. However, you might actually be able to put your matrix in shared memory - if it's large enough to justify that. I know you could put a linear array of homogeneous, scalar type in shared memory; I've not heard of a way of putting an aggregate type in shared memory. Naturally, you can fake an n dimensional array using a 1 dimensional array with a little multiplication and addition. As an example of using CPython with multiprocessing without having your matrix in shared memory, you could probably have one worker subprocess for each core on a system, divide up the cells of your result matrix by their coordinates (perhaps using an iterator and izip across the queues) and send a message (via a shared memory queue) with those coordinates to the appropriate subprocess. Then those subprocess send back the coordinates and the result at said coordinate via a different result queue. I suspect you'd want one queue for all the results, and one queue for each subprocess for initiating computation. Each subprocess would have its own COW copy of the input matrix. From jlconlin at gmail.com Tue Jan 4 12:11:26 2011 From: jlconlin at gmail.com (Jeremy) Date: Tue, 4 Jan 2011 09:11:26 -0800 (PST) Subject: Regular Expression for Finding and Deleting comments Message-ID: I am trying to write a regular expression that finds and deletes (replaces with nothing) comments in a string/file. Comments are defined by the first non-whitespace character is a 'c' or a dollar sign somewhere in the line. I want to replace these comments with nothing which isn't too hard. The trouble is, the comments are replaced with a new-line; or the new-line isn't captured in the regular expression. Below, I have copied a minimal example. Can someone help? Thanks, Jeremy import re text = """ c C - Second full line comment (first comment had no text) c Third full line comment F44:N 2 $ Inline comments start with dollar sign and go to end of line""" commentPattern = re.compile(""" (^\s*?c\s*?.*?| # Comment start with c or C \$.*?)$\n # Comment starting with $ """, re.VERBOSE|re.MULTILINE|re.IGNORECASE) found = commentPattern.finditer(text) print("\n\nCard:\n--------------\n%s\n------------------" %text) if found: print("\nI found the following:") for f in found: print(f.groups()) else: print("\nNot Found") print("\n\nComments replaced with ''") replaced = commentPattern.sub('', text) print("--------------\n%s\n------------------" %replaced) From fuzzyman at gmail.com Tue Jan 4 12:31:37 2011 From: fuzzyman at gmail.com (Fuzzyman) Date: Tue, 4 Jan 2011 09:31:37 -0800 (PST) Subject: Interrput a thread References: <81c24eb1-41b6-442a-a971-8a44d2cd6c1b@p8g2000vbs.googlegroups.com> <2ebc11a5-1b45-4faa-97b9-c84f0db015a4@k22g2000yqh.googlegroups.com> Message-ID: On Jan 4, 3:31?pm, Roy Smith wrote: > In article > <2ebc11a5-1b45-4faa-97b9-c84f0db01... at k22g2000yqh.googlegroups.com>, > > ?Fuzzyman wrote: > > It is unsafe to terminate an os level thread at an arbitrary point > > because it may be executing code in a critical section. > > [...] > > The standard advice is to use a flag and do manual checking to abort > > threads. This only works for fine grained operations and *doesn't* > > work for very coarse grained operations or where there aren't > > convenient places to check the flag. > > Another possibility is to not use threads! ?If you > > 1) Need asynchronous operation > > 2) Need iterruptability > > 3) Can't poll for an "please stop" signal > > You should look at running your "thread" as a separate process, which > you can send a kill signal to when you want it to go away. ?You can then > communicate with it via pipes, sockets, shared memory segments, whatever. > > Threads are a wonderful invention, but they are not a panacea for all > possible parallelism tasks. ?Sometimes they're just the wrong tool. However some tasks / algorithms are done much better with threads than processes. Asynchronous operations are good for IO bound concurrency but not for CPU bound concurrency. Michael Foord -- http://www.voidspace.org.uk/ From georgeryoung at gmail.com Tue Jan 4 12:38:58 2011 From: georgeryoung at gmail.com (gry) Date: Tue, 4 Jan 2011 09:38:58 -0800 (PST) Subject: CPython on the Web References: <19141efb-a288-43bc-be0d-44769bf5974b@j32g2000prh.googlegroups.com> <4d22ba06$0$44020$742ec2ed@news.sonic.net> Message-ID: On Jan 4, 1:11?am, John Nagle wrote: > On 1/1/2011 11:26 PM, azakai wrote: > > > Hello, I hope this will be interesting to people here: CPython running > > on the web, > > >http://syntensity.com/static/python.html > > > That isn't a new implementation of Python, but rather CPython 2.7.1, > > compiled from C to JavaScript using Emscripten and LLVM. For more > > details on the conversion process, seehttp://emscripten.org On loading, I "get script stack space quota is exhausted" under firefox 3.5.12, under linux. Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.12) Gecko/20100907 Fedora/3.5.12-1.fc12 Firefox/3.5.12 From greno at verizon.net Tue Jan 4 12:48:43 2011 From: greno at verizon.net (Gerry Reno) Date: Tue, 04 Jan 2011 12:48:43 -0500 Subject: CPython on the Web In-Reply-To: References: <19141efb-a288-43bc-be0d-44769bf5974b@j32g2000prh.googlegroups.com> <4d22ba06$0$44020$742ec2ed@news.sonic.net> Message-ID: <4D235D7B.30703@verizon.net> On 01/04/2011 12:38 PM, gry wrote: > On Jan 4, 1:11 am, John Nagle wrote: > >> On 1/1/2011 11:26 PM, azakai wrote: >> >> >>> Hello, I hope this will be interesting to people here: CPython running >>> on the web, >>> >> >>> http://syntensity.com/static/python.html >>> >> >>> That isn't a new implementation of Python, but rather CPython 2.7.1, >>> compiled from C to JavaScript using Emscripten and LLVM. For more >>> details on the conversion process, seehttp://emscripten.org >>> > On loading, I "get script stack space quota is exhausted" under > firefox 3.5.12, under linux. > Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.12) Gecko/20100907 > Fedora/3.5.12-1.fc12 Firefox/3.5.12 > It's a Firefox bug apparently fixed in Firefox 4.x. Some versions of Firefox 3.6.x do work but most do not. Regards, Gerry From nyc61 at fibertel.com.ar Tue Jan 4 12:56:18 2011 From: nyc61 at fibertel.com.ar (apustilnik) Date: Tue, 4 Jan 2011 09:56:18 -0800 (PST) Subject: Need your website? Message-ID: <17b28295-7048-48b1-a9a1-790dd12d48aa@c17g2000prm.googlegroups.com> Need a website for your enterprise or personal profile? Contact us now d212designs at hotmail.com http://www.d212.com.ar Yours sincerely. From nyc61 at fibertel.com.ar Tue Jan 4 12:56:20 2011 From: nyc61 at fibertel.com.ar (apustilnik) Date: Tue, 4 Jan 2011 09:56:20 -0800 (PST) Subject: Need your website? Message-ID: <69ed7a47-9bb0-4716-92f8-df16cce821b5@y19g2000prb.googlegroups.com> Need a website for your enterprise or personal profile? Contact us now d212designs at hotmail.com http://www.d212.com.ar Yours sincerely. From devplayer at gmail.com Tue Jan 4 13:07:48 2011 From: devplayer at gmail.com (DevPlayer) Date: Tue, 4 Jan 2011 10:07:48 -0800 (PST) Subject: list 2 dict? References: <69d248d7-cf62-49bf-9824-d8aec7de0a87@j25g2000yqa.googlegroups.com> <11865218-b187-479e-8ef9-9a66d8b3b443@j25g2000yqa.googlegroups.com> Message-ID: <40db65ac-aa85-44a5-aae4-021a1271da76@z19g2000yqb.googlegroups.com> Here is something totally the opposite of a nice one liner: A hackish module with a bloated generator. Feel free to comment, so I can learn the errors of my ways. Try not to be too mean though. Try to think of the attached file as a demonstration of ideas instead of good coding practices. Don't be afraid to mention the good points too. I tried to send an email with an attachment (to hide my shame) but I kept getting email rejections. # ======================================================= # list2dict.py # list item to dict item generator # I forget if generators are thread safe # DevPlayer at gmail.com # 2011-01 Jan-03 # def check_slice_bounds(list_len, start, stop, step): """Incomplete slice checker.""" # ----------------------------- # force step to be non-None if step is None: step = 1 # ----------------------------- # force step to be non-zero if step == 0: step = 1 # ----------------------------- # in iterating over list to be converted to dict # where list == [key, value, key, value] or in case swap==True # list = [value, key, value, key] # actual stepping is one for key, and plus one more for value step = step * 2 # ----------------------------- # force step to be smaller then size of list or -size of list if step > 0: if step > list_len: step = list_len else: if step < -list_len: step = -list_len # ----------------------------- # force step to be even for key, value iteration if step % 2 == 1: if step > 0: step = step - 1 else: step = step + 1 # ----------------------------- # set start to default; depending on step direction (+x vs -x) if start is None: if step > 0: start = 0 elif step == 0: start = 0 stop = start else: start = -1 # ----------------------------- # set stop to default; depending on step direction (+x vs -x) if stop is None: if step > 0: stop = list_len-1 elif step == 0: stop = start else: stop = -list_len # ----------------------------- # convert "start" to equivelent positive index if start < 0: if start < -list_len: raise IndexError("IndexError: list index out of range:", start) else: start = list_len + 1 + start # ----------------------------- # convert "stop" to equivelent positive index if stop < 0: if stop < -list_len: raise IndexError("IndexError: list index out of range:", stop) else: stop = list_len + 1 + stop return (start, stop, step) def gen(lyst, dyct=None, start=None, stop=None, step=None, swap=False): """ lyst == list to convert to dict dyct == external dict to be updated start == starting index stop step == amount to move index by; usually +1 or -1 (times 2) could be a float if clever enough. if step equals zero it is converted to 1 to prevent an infinite loop. step will be reset to be an index inbounds of a list len() swap 2nd item with the first item in the yield """ # ----------------------------- # Force into bool True or False from equivelent values if swap == True: swap = True else: swap = False # ----------------------------- # check and set lyst slice/index bounds of start, stop, step start, stop, step = check_slice_bounds(len(lyst), start, stop, step) # ----------------------------- index = start # ----------------------------- while 0 <= index < len(lyst): next = index + 1 if next == len(lyst): value = None else: value = lyst[next] key = lyst[index] # ----------------------------- # update external dict if given if dyct is not None: dyct[key] = value # ----------------------------- # effectively sway key with value == index, index+1 to index +1, index if swap: newindex = yield (value,key) else: newindex = yield (key,value) # ----------------------------- # process "newindex" variable if caller does a # gen.send(some_list_index) externally if newindex is None: index = index + (step) elif 0 <= newindex < len(lyst): # fix this to allow for negative index for negative stepping # but don't forget to convert it to its corrosponding # positive index index = newindex else: # fix this so it doesn't error on index 0 #raise IndexError("Index is out of range:", index) pass # ----------------------------- # Ungracefully coerce end of iteration if step > 0: if index > stop: # fix to raise StopIteration break else: if index < stop: # fix to raise StopIteration break # Example usage testlist = [1, 2, 3, 4, 5, 6, 7, 'a', 8, 'b'] # -------------------- d = {} e = {y[0]:y[1] for y in gen(testlist,d)} print d print d print 'next demo1' # -------------------- d = {} e = {y[1]:y[0] for y in gen(testlist,d)} f = {y[0]:y[1] for y in gen(testlist,d, swap=True)} print d print e print f print 'next demo2' # -------------------- d = {} for x in gen(testlist,d): print x print d print 'next demo3' # -------------------- d = {} e = [y for y in gen(testlist,d,swap=True)] print d print e print 'next demo4' # -------------------- d = {} e = gen(testlist,d) try: while e.next(): pass except: pass print d #print 'next demo' From devplayer at gmail.com Tue Jan 4 13:18:22 2011 From: devplayer at gmail.com (DevPlayer) Date: Tue, 4 Jan 2011 10:18:22 -0800 (PST) Subject: list 2 dict? References: <69d248d7-cf62-49bf-9824-d8aec7de0a87@j25g2000yqa.googlegroups.com> <11865218-b187-479e-8ef9-9a66d8b3b443@j25g2000yqa.googlegroups.com> <40db65ac-aa85-44a5-aae4-021a1271da76@z19g2000yqb.googlegroups.com> Message-ID: <0315b5bd-30e3-4508-b4af-9ebe16cdb5bd@15g2000vbz.googlegroups.com> The shorter version: This doesn't need any x = iter(list) line. perhaps more useful if you have a bunch of lists to be converted through out your code. def dictit(lyst): i = 0 while i < len(lyst): yield lyst[i], lyst[i+1] i = i + 2 l = [1, 2, 3, 4, 5, 6, 7, 'a', 8, 'b'] {d[0]:d[1] for d in dictit(l)} 3 again a dict comprehension func = lambda l: {k[0]:k[1] for k in dictit(l)} d = func(l) From xahlee at gmail.com Tue Jan 4 13:24:24 2011 From: xahlee at gmail.com (Xah Lee) Date: Tue, 4 Jan 2011 10:24:24 -0800 (PST) Subject: opinion: comp lang docs style Message-ID: <98e82f1b-cf59-4e64-8fd4-63671f96b04f@r19g2000prm.googlegroups.com> a opinion piece. ?The Idiocy of Computer Language Docs? http://xahlee.org/comp/idiocy_of_comp_lang.html -------------------------------------------------- The Idiocy of Computer Language Docs Xah Lee, 2011-01-03 Worked with Mathematica for a whole day yesterday, after about 10 years hiatus. Very nice. Mathematica lang and doc, is quite unique. Most other langs drivel with jargons, pettiness, comp-sci pretentiousness, while their content is mathematically garbage. (unixism mumble jumple (perl, unix), or ?proper?-engineering OOP fantasy (java), or impractical and ivory-tower adacemician idiocy as in Scheme & Haskell ( currying, tail recursion, closure, call-cc, lisp1 lisp2, and monad monad monad!)) (See: What are OOP's Jargons and Complexities ? Language, Purity, Cult, and Deception.) Mathematica, in its doc, is plain and simple. None of the jargon and pretention shit. Very easy to understand. Yet, some of its function's technical aspects are far more scholarly abstruse than any other lang (dealing with advanced math special functions that typically only a few thousand people in the world understand.). ------------------------------ A Gander into the Idiocies Here's a gander into the doc drivel in common langs. ------------------------------ unix In unix man pages, it starts with this type of garbage: SYNOPSIS gzip [ -acdfhlLnNrtvV19 ] [-S suffix] [ name ... ] gunzip [ -acfhlLnNrtvV ] [-S suffix] [ name ... ] zcat [ -fhLV ] [ name ... ] SYNOPSIS zip [-aABcdDeEfFghjklLmoqrRSTuvVwXyz!@$] [-- longoption ...] [-b path] [-n suf fixes] [-t date] [-tt date] [zipfile [file ...]] [-xi list] Here, the mindset of unix idiots, is that somehow this ?synopsis? form is technically precise and superior. They are thinking that it captures the full range of syntax in the most concise way. In practice, it's seldomly read. It's actually not accurate as one'd thought; no program can parse it and agree with the actual behavior. It's filled with errors, incomprehensible to human. Worse of all, the semantic of unix software's options are the worst rape to any possible science in computer science. See: The Nature of the Unix Philosophy ? Unix Pipe As Functional Language ? Unix zip Utility Path Problem. ------------------------------ Python In Python, you see this kinda garbage: 7.1. The if statement The if statement is used for conditional execution: if_stmt ::= "if" expression ":" suite ( "elif" expression ":" suite )* ["else" ":" suite] (Source docs.python.org) Here, the mindset of the python idiots is similar to the unix tech geekers. They think that using the BNF notation makes their doc more clear and precise. The fact is, there are so many variations of BNF each trying to fix other's problem. BNF is actually not used as a computer language for syntax description. It's mostly used to communicate syntax to humans. Like regex, there are so many variations. But worse than regex in the sense that there are actually not many actual implementations of BNF. Real word syntax description language are usually nothing close to BNF. See: Pattern Matching vs Lexical Grammar Specification. This incomprehensible BNF notation is the only thing you get if you want to know the basic syntax of ?if?, ?for?, ?while?, ?lambda?, or other basic constructs of python. ------------------------------ Perl In perl, you see this type of drivel: A Perl program consists of a sequence of declarations and statements which run from the top to the bottom. Loops, subroutines and other control structures allow you to jump around within the code. Perl is a free-form language, you can format and indent it however you like. Whitespace mostly serves to separate tokens, unlike languages like Python where it is an important part of the syntax. Many of Perl's syntactic elements are optional. Rather than requiring you to put parentheses around every function call and declare every variable, you can often leave such explicit elements off and Perl will figure out what you meant. This is known as Do What I Mean, abbreviated DWIM. It allows programmers to be lazy and to code in a style with which they are comfortable. Perl borrows syntax and concepts from many languages: awk, sed, C, Bourne Shell, Smalltalk, Lisp and even English. Other languages have borrowed syntax from Perl, particularly its regular expression extensions. So if you have programmed in another language you will see familiar pieces in Perl. They often work the same, but see perltrap for information about how they differ. (Source perldoc.perl.org) Notice they introduced you to their lingo ?DWIM?. Juvenile humor is a characteristics of perl's docs. It's a whole cult. They have ?perl republic?, ?state of the onion?, ?apocalypse?, ?perl monger?, ?perl golf?, etc.(See: Larry Wall and Cults.) Another trait is irrelevant rambling. For example, in the above you see: ?Perl borrows syntax and concepts from many languages: awk, sed, C, Bourne Shell, Smalltalk, Lisp and even English.?. However, perl doc overall is more practically usable than Python's. ------------------------------ Haskell Here's a example of ivory-tower idiocy, from Haskellers: Haskell uses a traditional Hindley-Milner polymorphic type system to provide a static type semantics [4, 6], but the type system has been extended with type classes (or just classes) that provide a structured way to introduce overloaded functions. A class declaration (Section 4.3.1) introduces a new type class and the overloaded operations that must be supported by any type that is an instance of that class. An instance declaration (Section 4.3.2) declares that a type is an instance of a class and includes the definitions of the overloaded operations?called class methods? instantiated on the named type. For example, suppose we wish to overload the operations (+) and negate on types Int and Float. We introduce a new type class called Num: class Num a where -- simplified class declaration for Num (+) :: a -> a -> a -- (Num is defined in the Prelude) negate :: a -> a This declaration may be read ?a type a is an instance of the class Num if there are class methods (+) and negate, of the given types, defined on it.? (Source www.haskell.org) Note the words ?Hindley-Milner?, ?polymorphic?, ?static type semantics?, ?overloaded operations?. The reason they wrote their doc like that is because they are academicians. You might think that their writing is really scholarly, mathematically meaningful, almost provably correct, full of dense mathematical rigor, and necessarily hard to understand because of the advanced math ideas. By the look of it it is really daunting. The irony is that the writing is often imprecise, most use of tech jargons and terms are absolutely uncessarily to the point of being irrelevant. And, the writing quality is pretty bad, far below the quality of standard math journal's articles. -------------------------------------------------- uhmm, happy 2011. Xah ? http://xahlee.org/ ? From python at mrabarnett.plus.com Tue Jan 4 13:26:48 2011 From: python at mrabarnett.plus.com (MRAB) Date: Tue, 04 Jan 2011 18:26:48 +0000 Subject: Regular Expression for Finding and Deleting comments In-Reply-To: References: Message-ID: <4D236668.6070200@mrabarnett.plus.com> On 04/01/2011 17:11, Jeremy wrote: > I am trying to write a regular expression that finds and deletes (replaces with nothing) comments in a string/file. Comments are defined by the first non-whitespace character is a 'c' or a dollar sign somewhere in the line. I want to replace these comments with nothing which isn't too hard. The trouble is, the comments are replaced with a new-line; or the new-line isn't captured in the regular expression. > > Below, I have copied a minimal example. Can someone help? > > Thanks, > Jeremy > > > import re > > text = """ c > C - Second full line comment (first comment had no text) > c Third full line comment > F44:N 2 $ Inline comments start with dollar sign and go to end of line""" > > commentPattern = re.compile(""" > (^\s*?c\s*?.*?| # Comment start with c or C > \$.*?)$\n # Comment starting with $ > """, re.VERBOSE|re.MULTILINE|re.IGNORECASE) > Part of the problem is that you're not using raw string literals or doubling the backslashes. Try soemthing like this: commentPattern = re.compile(r""" (^[ \t]*c.*\n| # Comment start with c or C [ \t]*\$.*) # Comment starting with $ """, re.VERBOSE|re.MULTILINE|re.IGNORECASE) > found = commentPattern.finditer(text) > > print("\n\nCard:\n--------------\n%s\n------------------" %text) > > if found: > print("\nI found the following:") > for f in found: print(f.groups()) > > else: > print("\nNot Found") > > print("\n\nComments replaced with ''") > replaced = commentPattern.sub('', text) > print("--------------\n%s\n------------------" %replaced) > From python at mrabarnett.plus.com Tue Jan 4 13:29:53 2011 From: python at mrabarnett.plus.com (MRAB) Date: Tue, 04 Jan 2011 18:29:53 +0000 Subject: list 2 dict? In-Reply-To: <7xipy5b5c5.fsf@ruckus.brouhaha.com> References: <7xipy5b5c5.fsf@ruckus.brouhaha.com> Message-ID: <4D236721.5010500@mrabarnett.plus.com> On 04/01/2011 05:33, Paul Rubin wrote: > "Octavian Rasnita" writes: >> If I want to create a dictionary from a list... >> l = [1, 2, 3, 4, 5, 6, 7, 'a', 8, 'b'] > > dict(l[i:i+2] for i in xrange(0,len(l),2)) > > seems simplest to me. Or: dict(zip(l[0 : : 2], l[1 : : 2])) From jlconlin at gmail.com Tue Jan 4 14:37:02 2011 From: jlconlin at gmail.com (Jeremy) Date: Tue, 4 Jan 2011 11:37:02 -0800 (PST) Subject: Regular Expression for Finding and Deleting comments In-Reply-To: Message-ID: On Tuesday, January 4, 2011 11:26:48 AM UTC-7, MRAB wrote: > On 04/01/2011 17:11, Jeremy wrote: > > I am trying to write a regular expression that finds and deletes (replaces with nothing) comments in a string/file. Comments are defined by the first non-whitespace character is a 'c' or a dollar sign somewhere in the line. I want to replace these comments with nothing which isn't too hard. The trouble is, the comments are replaced with a new-line; or the new-line isn't captured in the regular expression. > > > > Below, I have copied a minimal example. Can someone help? > > > > Thanks, > > Jeremy > > > > > > import re > > > > text = """ c > > C - Second full line comment (first comment had no text) > > c Third full line comment > > F44:N 2 $ Inline comments start with dollar sign and go to end of line""" > > > > commentPattern = re.compile(""" > > (^\s*?c\s*?.*?| # Comment start with c or C > > \$.*?)$\n # Comment starting with $ > > """, re.VERBOSE|re.MULTILINE|re.IGNORECASE) > > > Part of the problem is that you're not using raw string literals or > doubling the backslashes. > > Try soemthing like this: > > commentPattern = re.compile(r""" > (^[ \t]*c.*\n| # Comment start with c or C > [ \t]*\$.*) # Comment starting with $ > """, re.VERBOSE|re.MULTILINE|re.IGNORECASE) Using a raw string literal fixed the problem for me. Thanks for the suggestion. Why is that so important? Jeremy From jlconlin at gmail.com Tue Jan 4 14:37:02 2011 From: jlconlin at gmail.com (Jeremy) Date: Tue, 4 Jan 2011 11:37:02 -0800 (PST) Subject: Regular Expression for Finding and Deleting comments In-Reply-To: Message-ID: On Tuesday, January 4, 2011 11:26:48 AM UTC-7, MRAB wrote: > On 04/01/2011 17:11, Jeremy wrote: > > I am trying to write a regular expression that finds and deletes (replaces with nothing) comments in a string/file. Comments are defined by the first non-whitespace character is a 'c' or a dollar sign somewhere in the line. I want to replace these comments with nothing which isn't too hard. The trouble is, the comments are replaced with a new-line; or the new-line isn't captured in the regular expression. > > > > Below, I have copied a minimal example. Can someone help? > > > > Thanks, > > Jeremy > > > > > > import re > > > > text = """ c > > C - Second full line comment (first comment had no text) > > c Third full line comment > > F44:N 2 $ Inline comments start with dollar sign and go to end of line""" > > > > commentPattern = re.compile(""" > > (^\s*?c\s*?.*?| # Comment start with c or C > > \$.*?)$\n # Comment starting with $ > > """, re.VERBOSE|re.MULTILINE|re.IGNORECASE) > > > Part of the problem is that you're not using raw string literals or > doubling the backslashes. > > Try soemthing like this: > > commentPattern = re.compile(r""" > (^[ \t]*c.*\n| # Comment start with c or C > [ \t]*\$.*) # Comment starting with $ > """, re.VERBOSE|re.MULTILINE|re.IGNORECASE) Using a raw string literal fixed the problem for me. Thanks for the suggestion. Why is that so important? Jeremy From python at mrabarnett.plus.com Tue Jan 4 14:54:34 2011 From: python at mrabarnett.plus.com (MRAB) Date: Tue, 04 Jan 2011 19:54:34 +0000 Subject: Regular Expression for Finding and Deleting comments In-Reply-To: References: Message-ID: <4D237AFA.2030008@mrabarnett.plus.com> On 04/01/2011 19:37, Jeremy wrote: > On Tuesday, January 4, 2011 11:26:48 AM UTC-7, MRAB wrote: >> On 04/01/2011 17:11, Jeremy wrote: >>> I am trying to write a regular expression that finds and deletes (replaces with nothing) comments in a string/file. Comments are defined by the first non-whitespace character is a 'c' or a dollar sign somewhere in the line. I want to replace these comments with nothing which isn't too hard. The trouble is, the comments are replaced with a new-line; or the new-line isn't captured in the regular expression. >>> >>> Below, I have copied a minimal example. Can someone help? >>> >>> Thanks, >>> Jeremy >>> >>> >>> import re >>> >>> text = """ c >>> C - Second full line comment (first comment had no text) >>> c Third full line comment >>> F44:N 2 $ Inline comments start with dollar sign and go to end of line""" >>> >>> commentPattern = re.compile(""" >>> (^\s*?c\s*?.*?| # Comment start with c or C >>> \$.*?)$\n # Comment starting with $ >>> """, re.VERBOSE|re.MULTILINE|re.IGNORECASE) >>> >> Part of the problem is that you're not using raw string literals or >> doubling the backslashes. >> >> Try soemthing like this: >> >> commentPattern = re.compile(r""" >> (^[ \t]*c.*\n| # Comment start with c or C >> [ \t]*\$.*) # Comment starting with $ >> """, re.VERBOSE|re.MULTILINE|re.IGNORECASE) > > Using a raw string literal fixed the problem for me. Thanks for the suggestion. Why is that so important? > Regexes often use escape sequences, but so do string literals, and a sequence which is intended for the regex engine might not get passed along correctly. For example, in a normal string literal \b means 'backspace' and will be passed to the regex engine as that; in a regex it usually means 'word boundary': A regex for "the" as a word: \bthe\b As a raw string literal: r"\bthe\b" As a normal string literal: "\\bthe\\b" "\bthe\b" means: backspace + "the" + backspace From morfeokmg at gmail.com Tue Jan 4 14:57:59 2011 From: morfeokmg at gmail.com (Mauricio Martinez Garcia) Date: Tue, 04 Jan 2011 13:57:59 -0600 Subject: Error python + cx_Oracle :Oracle-Error-Message: ORA-01036: illegal variable name/number Message-ID: <4D237BC7.9010101@gmail.com> Hi, i need help with the next error: "ERR_PYTHON:Oracle-Error-Message: ORA-01036: illegal variable name/number", i used the cx_Oracle module, and the error not is only Oracle Error. The error its for that python don't translate the query, with the variables ":VARIABLE" when the VARIABLE is a number, this is th ecause of Oracle error. The template is: updateQUERYBSCS var. The code : ============================================================================================== class HilosPrepago(object): def __init__(self,numhilos,listadoSegmentos,archivoLOG,arregloSalida): global NHilos global LSegmnts global ALog global listadoSalida global path_sal global queue global loggingRegister global updateQUERYBSCS queue = Queue() listadoSalida = arregloSalida ALog = archivoLOG LSegmnts = listadoSegmentos NHilos = numhilos loggingRegister = log_register(ALog) updateQUERYBSCS = """UPDATE CONCIL_ICC SET CONTRATO_ICC = :CONTRATO_ICC, CONTRATO_ATS = :CONTRATO_BSCS, PLAN_ICC = :PLAN_ICC, PLAN_ATS = :PLAN_BSCS, IVA_ICC = :IVA_ICC, IVA_ATS = :IVA_BSCS, IVA_MAPEO = :IVA_MAPEO, PROFILE_ICC = :PROFILE_ICC, PROFILE_ATS = :PROFILE_BSCS, LEG_SOG_ICC = :LEG_SOG_ICC, LEG_SOG_ATS = :LEG_SOG_BSCS, LIC_SOG_ICC = :LIC_SOG_ICC, LIC_SOG_ATS = :LIC_SOG_BSCS, LEGLIG_SOG_ICC = :LEGLIC_SOG_ICC, LEGLIG_SOG_ATS = :LEGLIC_SOG_BSCS, LICN_SOG_ICC = :LICN_SOG_ICC, LICN_SOG_ATS = :LICN_SOG_BSCS, LDN_SOG_ICC = :LDN_SOG_ICC, LDN_SOG_ATS = :LDN_SOG_BSCS, REFILL_SOG_ICC = :REFILL_SOG_ICC, REFILL_SOG_ATS = :REFILL_SOG_BSCS, REFILL_PROM_ICC = :REFILL_PROM_ICC, REFILL_PROM_ATS = :REFILL_PROM_BSCS, DIA_RECARGA_ICC = :DIA_RECARGA_ICC, DIA_RECARGA_PROM_ICC = :DIA_RECARGA_PROM_ICC, DIA_RECARGA_ATS = :DIA_RECARGA_BSCS, CEL_IMSI_ICC = :CEL_IMSI_ICC, CEL_IMSI_ATS = :CEL_IMSI_BSCS, STATUS_ICC = :STATUS_ICC, STATUS_ATS = :STATUS_BSCS, ERROR_CONTRATO = to_number(:ERROR_CONTRATO), ERROR_PLAN = to_number(:ERROR_PLAN), ERROR_IVA_BSCS = to_number(:ERROR_IVA_BSCS), ERROR_IVA_ICC = to_number(:ERROR_IVA_ICC), ERROR_PROFILE = to_number(:ERROR_PROFILE), ERROR_LEGSOG = to_number(:ERROR_LEGSOG), ERROR_LICSOG = to_number(:ERROR_LICSOG), ERROR_LEGLICSOG = to_number(:ERROR_LEGLICSOG), ERROR_LICNSOG = to_number(:ERROR_LICNSOG), ERROR_LDNSOG = to_number(:ERROR_LDNSOG), ERROR_REFILLSOG = to_number(:ERROR_REFILLSOG), ERROR_REFILLPROMOCION = to_number(:ERROR_REFILLPROMOCION), ERROR_DIA_RECARGA = to_number(:ERROR_DIA_RECARGA), ERROR_DIA_RECARGAPROM = to_number(:ERROR_DIA_RECARGAPROM), ERROR_IMSI = to_number(:ERROR_IMSI), ERROR_STATUS = to_number(:ERROR_STATUS), ERROR_ENALTA = to_number(:ERROR_ENALTA), ERROR_ENELIMINACION = to_number(:ERROR_ENELIMINACION), PLANACTUALPROMO = :PLANACTUALPROMO, LLEVAPROMOCION = :LLEVAPROMOCION, DUPLICIDAD_DN = to_number(:DUPLICIDAD_DN), VALIDADO_PRODUCCION = :VALIDADO_PRODUCCION, CORREGIDO_EN_ALU = :CORREGIDO_EN_ALU, MENSAJE_CORRECCION = :MENSAJE_CORRECCION WHERE TELEFONO_ATS = :TELEFONO_BSCS """ #threading.Thread.__init__(self) def ejecutaHilo(self,lista,listaRegistrosOUT,archLog,hilo): from OracleConnections import OracleConnections print "Iniciando la ejecucion para el hilo... %s" % hilo listaUnica = lista.get() loggingRegister.registrarLog('Lista de datos...'+str(listaUnica)) FullNameLOG = str(archLog)+'_'+str(hilo)+'_' validador = conciliador(FullNameLOG) i = 1 j = 1 k = 1 ListadoDeregistros=[] conexiondeUpdateenReportes = OracleConnections(FullNameLOG) abreUpdateReportesIX = conexiondeUpdateenReportes.creaConexion('usuario','password','basededatos') try: for registro in listaUnica: pdb.set_trace() #registrosDelCampo = {} #registrosDelCampo = {'TELEFONO_ICC':'','TELEFONO_BSCS':'','CONTRATO_ICC':'','CONTRATO_BSCS':'','PLAN_ICC':'','PLAN_BSCS':'','IVA_ICC':'','IVA_BSCS':'','IVA_MAPEO':'','PROFILE_ICC':'','PROFILE_BSCS':'','LEG_SOG_ICC':'','LEG_SOG_BSCS':'','LIC_SOG_ICC':'','LIC_SOG_BSCS':'','LEGLIC_SOG_ICC':'','LEGLIC_SOG_BSCS':'','LICN_SOG_ICC':'','LICN_SOG_BSCS':'','LDN_SOG_ICC':'','LDN_SOG_BSCS':'','REFILL_SOG_ICC':'','REFILL_SOG_BSCS':'','REFILL_PROM_ICC':'','REFILL_PROM_BSCS':'','DIA_RECARGA_ICC':'','DIA_RECARGA_PROM_ICC':'','DIA_RECARGA_BSCS':'','CEL_IMSI_ICC':'','CEL_IMSI_BSCS':'','STATUS_ICC':'','STATUS_BSCS':'','ERROR_CONTRATO':0,'ERROR_PLAN':0,'ERROR_IVA_BSCS':0,'ERROR_IVA_ICC':0,'ERROR_PROFILE':0,'ERROR_LEGSOG':0,'ERROR_LICSOG':0,'ERROR_LEGLICSOG':0,'ERROR_LICNSOG':0,'ERROR_LDNSOG':0,'ERROR_REFILLSOG':0,'ERROR_REFILLPROMOCION':0,'ERROR_DIA_RECARGA':0,'ERROR_DIA_RECARGAPROM':0,'ERROR_IMSI':0,'ERROR_STATUS':0,'ERROR_ENALTA':0,'ERROR_ENELIMINACION':0,'PLANACTUALPROMO':0,'LLEVAPROMOCION':0,'DUPLICIDAD_DN':0,'VALIDADO_PRODUCCION':0,'CORREGIDO_EN_ALU':0,'MENSAJE_CORRECCION':0} ejecutor = validador.conciliacionGlobal(registro.telefono) registrosDelCampo = { 'TELEFONO_ICC':str(ejecutor.ALU_DN), 'TELEFONO_BSCS':str(ejecutor.BSCS_DN), 'CONTRATO_ICC':str(ejecutor.ALU_CO_ID), 'CONTRATO_BSCS':str(ejecutor.BSCS_CO_ID), 'PLAN_ICC':str(ejecutor.ALU_ICCCODE), 'PLAN_BSCS':str(ejecutor.BSCS_ICCCODE), 'IVA_ICC':str(ejecutor.ALU_IVA), #Para cambiar por solo el IVA 'IVA_BSCS':str(ejecutor.BSCS_IVA), 'IVA_MAPEO':str(ejecutor.BSCS_IVA_MAPEO), #Para cambiar solo por el IVA 'PROFILE_ICC':str(ejecutor.ALU_PROFILE), 'PROFILE_BSCS':str(ejecutor.BSCS_PROFILE), 'LEG_SOG_ICC':str(ejecutor.ALU_LEGSOG), 'LEG_SOG_BSCS':str(ejecutor.BSCS_LEGSOG), 'LIC_SOG_ICC':str(ejecutor.ALU_LICSOG), 'LIC_SOG_BSCS':str(ejecutor.BSCS_LICSOG), 'LEGLIC_SOG_ICC':str(ejecutor.ALU_LEGLICSOG), 'LEGLIC_SOG_BSCS':str(ejecutor.BSCS_LEGLICSOG), 'LICN_SOG_ICC':str(ejecutor.ALU_LICNSOG), 'LICN_SOG_BSCS':str(ejecutor.BSCS_LICNSOG), 'LDN_SOG_ICC':str(ejecutor.ALU_LDNSOG), 'LDN_SOG_BSCS':str(ejecutor.BSCS_LDNSOG), 'REFILL_SOG_ICC':str(ejecutor.ALU_REFILLSOG), 'REFILL_SOG_BSCS':str(ejecutor.BSCS_REFILLSOG), 'REFILL_PROM_ICC':str(ejecutor.ALU_REFILLPROMOCION), 'REFILL_PROM_BSCS':str(ejecutor.BSCS_REFILLPROMOCION), 'DIA_RECARGA_ICC':str(ejecutor.ALU_DIA_RECARGA), 'DIA_RECARGA_PROM_ICC':str(ejecutor.ALU_DIA_RECARGAPROM), 'DIA_RECARGA_BSCS':str(ejecutor.BSCS_DIA_RECARGA), 'CEL_IMSI_ICC':str(ejecutor.ALU_IMSI), 'CEL_IMSI_BSCS':str(ejecutor.BSCS_IMSI), 'STATUS_ICC':str(ejecutor.ALU_CH_STATUS), 'STATUS_BSCS':str(ejecutor.BSCS_CH_STATUS), 'ERROR_CONTRATO':str(ejecutor.error_coid), 'ERROR_PLAN':str(ejecutor.error_plan), 'ERROR_IVA_BSCS':str(ejecutor.error_iva_bscs), 'ERROR_IVA_ICC':str(ejecutor.error_iva_icc), 'ERROR_PROFILE':str(ejecutor.error_profile), 'ERROR_LEGSOG':str(ejecutor.error_legsog), 'ERROR_LICSOG':str(ejecutor.error_licsog), 'ERROR_LEGLICSOG':str(ejecutor.error_leglicsog), 'ERROR_LICNSOG':str(ejecutor.error_licnsog), 'ERROR_LDNSOG':str(ejecutor.error_ldnsog), 'ERROR_REFILLSOG':str(ejecutor.error_refillsog), 'ERROR_REFILLPROMOCION':str(ejecutor.error_refillpromocion), 'ERROR_DIA_RECARGA':str(ejecutor.error_diarecarga), 'ERROR_DIA_RECARGAPROM':str(ejecutor.error_diarecargaprom), 'ERROR_IMSI':str(ejecutor.error_imsi), 'ERROR_STATUS':str(ejecutor.error_status), 'ERROR_ENALTA':str(ejecutor.error_enAlta), 'ERROR_ENELIMINACION':str(ejecutor.error_enEliminacion), 'PLANACTUALPROMO':ejecutor.PLANACTUALPROMO, 'LLEVAPROMOCION':ejecutor.LLEVAPROMOCION, 'DUPLICIDAD_DN':'1', 'VALIDADO_PRODUCCION':'Si', 'CORREGIDO_EN_ALU':'No', 'MENSAJE_CORRECCION':'' } ListadoDeregistros.append(registrosDelCampo) #print registrosDelCampo #========================================================================================================= #Aqui se realizara una prevalidacion antes de mandar las correcciones #========================================================================================================= #========================================================================================================= #Terminan las correcciones #========================================================================================================= #pdb.set_trace() registroxLinea =str(ejecutor.BSCS_TMCODE)+','+str(ejecutor.BSCS_DN)+','+str(ejecutor.ALU_DN)+','+str(ejecutor.BSCS_CO_ID)+','+str(ejecutor.ALU_CO_ID)+','+str(ejecutor.BSCS_DIA_RECARGA)+','+str(ejecutor.ALU_DIA_RECARGA)+','+str(ejecutor.BSCS_CH_STATUS)+','+str(ejecutor.ALU_CH_STATUS)+','+str(ejecutor.BSCS_IMSI)+','+str(ejecutor.ALU_IMSI)+','+str(ejecutor.BSCS_DESCPLAN)+','+str(ejecutor.BSCS_SNCODELEG)+','+str(ejecutor.BSCS_SNCODELIC)+','+str(ejecutor.BSCS_SNCODELEGLIC)+','+str(ejecutor.BSCS_SNCODELICN)+','+str(ejecutor.BSCS_SNCODELDN)+','+str(ejecutor.BSCS_SNCODEREFILL)+','+str(ejecutor.BSCS_ICCCODE)+','+str(ejecutor.ALU_ICCCODE)+','+str(ejecutor.BSCS_PROFILE)+','+str(ejecutor.ALU_PROFILE)+','+str(ejecutor.BSCS_LEGSOG)+','+str(ejecutor.ALU_LEGSOG)+','+str(ejecutor.BSCS_LICSOG)+','+str(ejecutor.ALU_LICSOG)+','+str(ejecutor.BSCS_LEGLICSOG)+','+str(ejecutor.ALU_LEGLICSOG)+','+str(ejecutor.BSCS_LICNSOG)+','+str(ejecutor.ALU_LICNSOG)+','+str(ejecutor.BSCS_LDNSOG)+','+str(ejecutor.ALU_LDNSOG)+','+str(ejecutor.BSCS_REFILLSOG)+','+str(ejecutor.ALU_REFILLSOG)+','+str(ejecutor.error_coid)+','+str(ejecutor.error_diarecarga)+','+str(ejecutor.error_status)+','+str(ejecutor.error_imsi)+','+str(ejecutor.error_plan)+','+str(ejecutor.error_profile)+','+str(ejecutor.error_legsog)+','+str(ejecutor.error_licsog)+','+str(ejecutor.error_leglicsog)+','+str(ejecutor.error_licnsog)+','+str(ejecutor.error_ldnsog)+','+str(ejecutor.error_refillsog)+','+str(ejecutor.error_sncodesBSCS)+','+str(ejecutor.escenarioCorreccion)+'\n' loggingRegister.registrarLog('Linea de conciliacion...'+str(registroxLinea)+str(hilo)) #listaRegistrosOUT.append(ejecutor) print 'Registro %s, Telefono: %s, el registro validado corresponde al Hilo: %s ' %(str(k),registro.telefono,str(hilo)) k = k+1 i = i+1 if (i == 1000): loggingRegister.registrarLog('Abrimos conexion para ejecutar actualizacion en ReportesIX...'+str(hilo)) RS_UPDATE = conexiondeUpdateenReportes.ejecutaUpdate(updateQUERYBSCS, ListadoDeregistros, abreUpdateReportesIX) listadoSalida['Hilo_'+str(hilo)]=int(listadoSalida['Hilo_'+str(hilo)])+int(RS_UPDATE) ListadoDeregistros=[] i = 1 loggingRegister.registrarLog('Abrimos conexion para ejecutar actualizacion en ReportesIX final...'+str(hilo)) RS_UPDATE = conexiondeUpdateenReportes.ejecutaUpdate(updateQUERYBSCS, ListadoDeregistros, abreUpdateReportesIX) listadoSalida['Hilo_'+str(hilo)]=int(listadoSalida['Hilo_'+str(hilo)])+int(RS_UPDATE) conexiondeUpdateenReportes.cierraConexion(abreUpdateReportesIX) lista.task_done() except Exception, err: print "Error en la ejecucion: %s " % err lista.task_done() ============================================================================================== This is my debug output: ============================================================================================== ============================================================================================== -bash-3.2$ ./conciliaAltas_Cambios.py sliceDNUnique(telefono='522281926890') sliceDNUnique(telefono='523141209462') 2 Se genero tupla con los registros del 0 al 0. -- Se genero tupla con los registros del 0 al 0. -- Se genero tupla con los registros del 0 al 0. -- Se genero tupla con los registros del 0 al 0. -- Se genero tupla con los registros del 0 al 0. -- Se genero tupla con los registros del 0 al 0. -- Total de hilos a ejecutar: 1 Datos por hilo: ----- 2 ---- ================================================ Iniciando el proceso de ejecucion por hilos ================================================ Iniciando la ejecucion por hilos... Iniciando la ejecucion para el hilo... 0 > /data/NEW_ALUCLIENT_PRUEBAS/bin/prepagoThreads.py(116)ejecutaHilo() -> ejecutor = validador.conciliacionGlobal(registro.telefono) (Pdb) c ==================================================================================== Registro 1, Telefono: 522281926890, el registro validado corresponde al Hilo: 0 > /data/NEW_ALUCLIENT_PRUEBAS/bin/prepagoThreads.py(116)ejecutaHilo() -> ejecutor = validador.conciliacionGlobal(registro.telefono) (Pdb) c ==================================================================================== Registro 2, Telefono: 523141209462, el registro validado corresponde al Hilo: 0 > /data/NEW_ALUCLIENT_PRUEBAS/bin/OracleConnections.py(350)ejecutaUpdate() -> cursor = conn.cursor() (Pdb) n > /data/NEW_ALUCLIENT_PRUEBAS/bin/OracleConnections.py(353)ejecutaUpdate() -> cursor.arraysize = 100000 (Pdb) > /data/NEW_ALUCLIENT_PRUEBAS/bin/OracleConnections.py(356)ejecutaUpdate() -> try: (Pdb) > /data/NEW_ALUCLIENT_PRUEBAS/bin/OracleConnections.py(357)ejecutaUpdate() -> cursor.executemany(query,registros) (Pdb) DatabaseError: > /data/NEW_ALUCLIENT_PRUEBAS/bin/OracleConnections.py(357)ejecutaUpdate() -> cursor.executemany(query,registros) (Pdb) n > /data/NEW_ALUCLIENT_PRUEBAS/bin/OracleConnections.py(361)ejecutaUpdate() -> except cx_Oracle.DatabaseError, exc: (Pdb) > /data/NEW_ALUCLIENT_PRUEBAS/bin/OracleConnections.py(362)ejecutaUpdate() -> error, = exc.args (Pdb) > /data/NEW_ALUCLIENT_PRUEBAS/bin/OracleConnections.py(363)ejecutaUpdate() -> print >> sys.stderr, XP_ERROR+"Oracle-Error-Code:", error.code (Pdb) ERR_PYTHON:Oracle-Error-Code: 1036 > /data/NEW_ALUCLIENT_PRUEBAS/bin/OracleConnections.py(364)ejecutaUpdate() -> print >> sys.stderr, XP_ERROR+"Oracle-Error-Message:", error.message (Pdb) ERR_PYTHON:Oracle-Error-Message: ORA-01036: illegal variable name/number > /data/NEW_ALUCLIENT_PRUEBAS/bin/OracleConnections.py(365)ejecutaUpdate() -> print query (Pdb) n UPDATE CONCIL_ICC SET CONTRATO_ICC = :CONTRATO_ICC, CONTRATO_ATS = :CONTRATO_BSCS, PLAN_ICC = :PLAN_ICC, PLAN_ATS = :PLAN_BSCS, IVA_ICC = :IVA_ICC, IVA_ATS = :IVA_BSCS, IVA_MAPEO = :IVA_MAPEO, PROFILE_ICC = :PROFILE_ICC, PROFILE_ATS = :PROFILE_BSCS, LEG_SOG_ICC = :LEG_SOG_ICC, LEG_SOG_ATS = :LEG_SOG_BSCS, LIC_SOG_ICC = :LIC_SOG_ICC, LIC_SOG_ATS = :LIC_SOG_BSCS, LEGLIG_SOG_ICC = :LEGLIC_SOG_ICC, LEGLIG_SOG_ATS = :LEGLIC_SOG_BSCS, LICN_SOG_ICC = :LICN_SOG_ICC, LICN_SOG_ATS = :LICN_SOG_BSCS, LDN_SOG_ICC = :LDN_SOG_ICC, LDN_SOG_ATS = :LDN_SOG_BSCS, REFILL_SOG_ICC = :REFILL_SOG_ICC, REFILL_SOG_ATS = :REFILL_SOG_BSCS, REFILL_PROM_ICC = :REFILL_PROM_ICC, REFILL_PROM_ATS = :REFILL_PROM_BSCS, DIA_RECARGA_ICC = :DIA_RECARGA_ICC, DIA_RECARGA_PROM_ICC = :DIA_RECARGA_PROM_ICC, DIA_RECARGA_ATS = :DIA_RECARGA_BSCS, CEL_IMSI_ICC = :CEL_IMSI_ICC, CEL_IMSI_ATS = :CEL_IMSI_BSCS, STATUS_ICC = :STATUS_ICC, STATUS_ATS = :STATUS_BSCS, ERROR_CONTRATO = to_number(:ERROR_CONTRATO), ERROR_PLAN = to_number(:ERROR_PLAN), ERROR_IVA_BSCS = to_number(:ERROR_IVA_BSCS), ERROR_IVA_ICC = to_number(:ERROR_IVA_ICC), ERROR_PROFILE = to_number(:ERROR_PROFILE), ERROR_LEGSOG = to_number(:ERROR_LEGSOG), ERROR_LICSOG = to_number(:ERROR_LICSOG), ERROR_LEGLICSOG = to_number(:ERROR_LEGLICSOG), ERROR_LICNSOG = to_number(:ERROR_LICNSOG), ERROR_LDNSOG = to_number(:ERROR_LDNSOG), ERROR_REFILLSOG = to_number(:ERROR_REFILLSOG), ERROR_REFILLPROMOCION = to_number(:ERROR_REFILLPROMOCION), ERROR_DIA_RECARGA = to_number(:ERROR_DIA_RECARGA), ERROR_DIA_RECARGAPROM = to_number(:ERROR_DIA_RECARGAPROM), ERROR_IMSI = to_number(:ERROR_IMSI), ERROR_STATUS = to_number(:ERROR_STATUS), ERROR_ENALTA = to_number(:ERROR_ENALTA), ERROR_ENELIMINACION = to_number(:ERROR_ENELIMINACION), PLANACTUALPROMO = :PLANACTUALPROMO, LLEVAPROMOCION = :LLEVAPROMOCION, DUPLICIDAD_DN = to_number(:DUPLICIDAD_DN), VALIDADO_PRODUCCION = :VALIDADO_PRODUCCION, CORREGIDO_EN_ALU = :CORREGIDO_EN_ALU, MENSAJE_CORRECCION = :MENSAJE_CORRECCION WHERE TELEFONO_ATS = :TELEFONO_BSCS > /data/NEW_ALUCLIENT_PRUEBAS/bin/OracleConnections.py(366)ejecutaUpdate() -> sys.exit(1) (Pdb) q Error en la ejecucion: Finalizando el proceso .... ============================================================================================== ============================================================================================== From calderone.jeanpaul at gmail.com Tue Jan 4 15:01:52 2011 From: calderone.jeanpaul at gmail.com (Jean-Paul Calderone) Date: Tue, 4 Jan 2011 12:01:52 -0800 (PST) Subject: Interrput a thread References: <81c24eb1-41b6-442a-a971-8a44d2cd6c1b@p8g2000vbs.googlegroups.com> <2ebc11a5-1b45-4faa-97b9-c84f0db015a4@k22g2000yqh.googlegroups.com> Message-ID: <846091cf-db63-422d-adda-2b8a46a4f270@t35g2000yqj.googlegroups.com> On Jan 4, 12:31?pm, Fuzzyman wrote: > On Jan 4, 3:31?pm, Roy Smith wrote: > > > > > In article > > <2ebc11a5-1b45-4faa-97b9-c84f0db01... at k22g2000yqh.googlegroups.com>, > > > ?Fuzzyman wrote: > > > It is unsafe to terminate an os level thread at an arbitrary point > > > because it may be executing code in a critical section. > > > [...] > > > The standard advice is to use a flag and do manual checking to abort > > > threads. This only works for fine grained operations and *doesn't* > > > work for very coarse grained operations or where there aren't > > > convenient places to check the flag. > > > Another possibility is to not use threads! ?If you > > > 1) Need asynchronous operation > > > 2) Need iterruptability > > > 3) Can't poll for an "please stop" signal > > > You should look at running your "thread" as a separate process, which > > you can send a kill signal to when you want it to go away. ?You can then > > communicate with it via pipes, sockets, shared memory segments, whatever. > > > Threads are a wonderful invention, but they are not a panacea for all > > possible parallelism tasks. ?Sometimes they're just the wrong tool. > > However some tasks / algorithms are done much better with threads than > processes. > > Asynchronous operations are good for IO bound concurrency but not for > CPU bound concurrency. > > Asynchronous and threads aren't mutually exclusive. An asynchronous multithreading or multiprocessing library is perfectly well suited for CPU bound concurrency. > > Michael Foord > --http://www.voidspace.org.uk/ From goposter at jonjay.com Tue Jan 4 15:20:42 2011 From: goposter at jonjay.com (Google Poster) Date: Tue, 4 Jan 2011 12:20:42 -0800 (PST) Subject: Trying to decide between PHP and Python Message-ID: About once a year, I have to learn yet another programming language. Given all the recommendations (an outstanding accolade from Bruce Eckel, author of "Thinking in Java") I have set my aim to Python. Sounds kinda cool. The indentation-as-block is unique, but that is how I always indent, anyway. Can any of you nice folks post a snippet of how to perform a listing of the current directory and save it in a string? Something like this: $ setenv FILES = `ls` Bonus: Let's say that I want to convert the names of the files to lowercase? As 'tolower()' TIA, -Ramon From jearl at notengoamigos.org Tue Jan 4 15:24:35 2011 From: jearl at notengoamigos.org (Jason Earl) Date: Tue, 04 Jan 2011 13:24:35 -0700 Subject: opinion: comp lang docs style References: <98e82f1b-cf59-4e64-8fd4-63671f96b04f@r19g2000prm.googlegroups.com> Message-ID: <87vd24benw.fsf@notengoamigos.org> On Tue, Jan 04 2011, Xah Lee wrote: > a opinion piece. > > ?The Idiocy of Computer Language Docs? > http://xahlee.org/comp/idiocy_of_comp_lang.html > > -------------------------------------------------- > The Idiocy of Computer Language Docs > > Xah Lee, 2011-01-03 > > Worked with Mathematica for a whole day yesterday, after about 10 > years hiatus. Very nice. Mathematica lang and doc, is quite unique. > Most other langs drivel with jargons, pettiness, comp-sci > pretentiousness, while their content is mathematically garbage. > (unixism mumble jumple (perl, unix), or ?proper?-engineering OOP > fantasy (java), or impractical and ivory-tower adacemician idiocy as > in Scheme & Haskell ( currying, tail recursion, closure, call-cc, > lisp1 lisp2, and monad monad monad!)) (See: What are OOP's Jargons and > Complexities ? Language, Purity, Cult, and Deception.) > > Mathematica, in its doc, is plain and simple. None of the jargon and > pretention shit. Very easy to understand. Yet, some of its function's > technical aspects are far more scholarly abstruse than any other lang > (dealing with advanced math special functions that typically only a > few thousand people in the world understand.). > > ------------------------------ > A Gander into the Idiocies > > Here's a gander into the doc drivel in common langs. > > ------------------------------ > unix > > In unix man pages, it starts with this type of garbage: > > SYNOPSIS > gzip [ -acdfhlLnNrtvV19 ] [-S suffix] [ name ... ] > gunzip [ -acfhlLnNrtvV ] [-S suffix] [ name ... ] > zcat [ -fhLV ] [ name ... ] > > SYNOPSIS > zip [-aABcdDeEfFghjklLmoqrRSTuvVwXyz!@$] [-- > longoption ...] [-b path] [-n suf > fixes] [-t date] [-tt date] [zipfile [file ...]] [-xi > list] > > Here, the mindset of unix idiots, is that somehow this ?synopsis? form > is technically precise and superior. They are thinking that it > captures the full range of syntax in the most concise way. Actually, it *does* capture the full range of syntax in a concise way. If you know of man pages where the Synopsis does not match the syntax then you have found a documentation bug, which should be reported so that it can be fixed. In fact, if anything the real problem with the Synopsis is that it is too concise. Fortunately gzip is a bit of an extreme example. Most man pages look more like this: --8<---------------cut here---------------start------------->8--- NAME tar ? The GNU version of the tar archiving utility SYNOPSIS tar [-] A --catenate --concatenate | c --create | d --diff --compare | --delete | r --append | t --list | --test-label | u --update | x --extract --get [options] [pathname ...] --8<---------------cut here---------------end--------------->8--- That synopsis is pretty useful. If you have used tar before and just need a refresher chances are very good that the synopsis will do the trick. If you look at the man pages from the Linux Programmer's Manual the Synopsis makes even more sense. --8<---------------cut here---------------start------------->8--- NAME open, creat - open and possibly create a file or device SYNOPSIS #include #include #include int open(const char *pathname, int flags); int open(const char *pathname, int flags, mode_t mode); int creat(const char *pathname, mode_t mode); --8<---------------cut here---------------end--------------->8--- Heck, that's basically precisely what I want to know. > In practice, it's seldomly read. It's actually not accurate as one'd > thought; no program can parse it and agree with the actual behavior. > It's filled with errors, incomprehensible to human. I've been using UNIX man pages for quite some time, and I don't think that I have ever come across an error. I am sure that there are errors, but I am also sure that Mathematica's documentation has its share of errors as well. > Worse of all, the semantic of unix software's options are the worst > rape to any possible science in computer science. See: The Nature of > the Unix Philosophy ? Unix Pipe As Functional Language ? Unix zip > Utility Path Problem. It seems to me that the problem is not UNIX software in general, but rather that the zip function does not have an analogue of tar's -C option (which sets the current directory for the command). > ------------------------------ > Python > > In Python, you see this kinda garbage: > > 7.1. The if statement > > The if statement is used for conditional execution: > if_stmt ::= "if" expression ":" suite > ( "elif" expression ":" suite )* > ["else" ":" suite] > > (Source docs.python.org) > > Here, the mindset of the python idiots is similar to the unix tech > geekers. They think that using the BNF notation makes their doc more > clear and precise. The fact is, there are so many variations of BNF > each trying to fix other's problem. BNF is actually not used as a > computer language for syntax description. It's mostly used to > communicate syntax to humans. Like regex, there are so many > variations. But worse than regex in the sense that there are actually > not many actual implementations of BNF. Real word syntax description > language are usually nothing close to BNF. See: Pattern Matching vs > Lexical Grammar Specification. This example is taken from the Python Language Reference, which is really only useful if you are looking to re-implement Python (or create something that parses Python, I suppose). The particular flavor of BNF is explained in the Introduction. I am not sure what you expect from a Language Reference, but in the case of Python the Language Reference seems to have worked quite well. Very few languages have as many successful implementations as Python. The Language Reference is clearly a large part of that. > This incomprehensible BNF notation is the only thing you get if you > want to know the basic syntax of ?if?, ?for?, ?while?, ?lambda?, or > other basic constructs of python. If you want to *use* the language the Tutorial is probably what you want. Perhaps the most well-known statement type is the if statement. Here's what the Tutorial has to say about the if statement. --8<---------------cut here---------------start------------->8--- Perhaps the most well-known statement type is the if statement. For example: >>> x = int(raw_input("Please enter an integer: ")) Please enter an integer: 42 >>> if x < 0: ... x = 0 ... print 'Negative changed to zero' ... elif x == 0: ... print 'Zero' ... elif x == 1: ... print 'Single' ... else: ... print 'More' ... More There can be zero or more elif parts, and the else part is optional. The keyword ?elif? is short for ?else if?, and is useful to avoid excessive indentation. An if ... elif ... elif ... sequence is a substitute for the switch or case statements found in other languages. --8<---------------cut here---------------end--------------->8--- Once again, that looks pretty good to me. > ------------------------------ > Perl > > In perl, you see this type of drivel: > > A Perl program consists of a sequence of declarations and > statements which run from the top to the bottom. Loops, subroutines > and other control structures allow you to jump around within the code. > > Perl is a free-form language, you can format and indent it however > you like. Whitespace mostly serves to separate tokens, unlike > languages like Python where it is an important part of the syntax. > > Many of Perl's syntactic elements are optional. Rather than > requiring you to put parentheses around every function call and > declare every variable, you can often leave such explicit elements off > and Perl will figure out what you meant. This is known as Do What I > Mean, abbreviated DWIM. It allows programmers to be lazy and to code > in a style with which they are comfortable. > > Perl borrows syntax and concepts from many languages: awk, sed, C, > Bourne Shell, Smalltalk, Lisp and even English. Other languages have > borrowed syntax from Perl, particularly its regular expression > extensions. So if you have programmed in another language you will see > familiar pieces in Perl. They often work the same, but see perltrap > for information about how they differ. > > (Source perldoc.perl.org) > > Notice they introduced you to their lingo ?DWIM?. Juvenile humor is a > characteristics of perl's docs. It's a whole cult. They have ?perl > republic?, ?state of the onion?, ?apocalypse?, ?perl monger?, ?perl > golf?, etc.(See: Larry Wall and Cults.) Another trait is irrelevant > rambling. For example, in the above you see: ?Perl borrows syntax and > concepts from many languages: awk, sed, C, Bourne Shell, Smalltalk, > Lisp and even English.?. > > However, perl doc overall is more practically usable than Python's. You might not like Larry Wall's documentation style, but if that is the case then you are in the minority. IMHO Perl is an example of a language that prospered almost entirely on the strength of its documentation. The Camel book is one of the best selling computer language books of all time. Much of Perl's "culture" is just plain old marketing, but it is hard to argue that it has not been successful. > ------------------------------ > Haskell > > Here's a example of ivory-tower idiocy, from Haskellers: > > Haskell uses a traditional Hindley-Milner polymorphic type system > to provide a static type semantics [4, 6], but the type system has > been extended with type classes (or just classes) that provide a > structured way to introduce overloaded functions. > > A class declaration (Section 4.3.1) introduces a new type class > and the overloaded operations that must be supported by any type that > is an instance of that class. An instance declaration (Section 4.3.2) > declares that a type is an instance of a class and includes the > definitions of the overloaded operations?called class methods? > instantiated on the named type. > > For example, suppose we wish to overload the operations (+) and > negate on types Int and Float. We introduce a new type class called > Num: > > class Num a where -- simplified class declaration for > Num > (+) :: a -> a -> a -- (Num is defined in the Prelude) > negate :: a -> a > > This declaration may be read ?a type a is an instance of the class > Num if there are class methods (+) and negate, of the given types, > defined on it.? > > (Source www.haskell.org) > > Note the words ?Hindley-Milner?, ?polymorphic?, ?static type > semantics?, ?overloaded operations?. > > The reason they wrote their doc like that is because they are > academicians. You might think that their writing is really scholarly, > mathematically meaningful, almost provably correct, full of dense > mathematical rigor, and necessarily hard to understand because of the > advanced math ideas. By the look of it it is really daunting. The > irony is that the writing is often imprecise, most use of tech jargons > and terms are absolutely uncessarily to the point of being irrelevant. > And, the writing quality is pretty bad, far below the quality of > standard math journal's articles. I actually agree with you on this example. > uhmm, happy 2011. You too. Jason From goposter at jonjay.com Tue Jan 4 15:29:20 2011 From: goposter at jonjay.com (Google Poster) Date: Tue, 4 Jan 2011 12:29:20 -0800 (PST) Subject: opinion: comp lang docs style References: <98e82f1b-cf59-4e64-8fd4-63671f96b04f@r19g2000prm.googlegroups.com> Message-ID: <0edd77ae-2b3b-494b-8651-94b3f56a59e4@j32g2000prh.googlegroups.com> On Jan 4, 12:24?pm, Xah Lee wrote: > a opinion piece. > > ?The Idiocy of Computer Language Docs?http://xahlee.org/comp/idiocy_of_comp_lang.html > > -------------------------------------------------- > The Idiocy of Computer Language Docs > > Xah Lee, 2011-01-03 > > Worked with Mathematica for a whole day yesterday, after about 10 > years hiatus. Very nice. Mathematica lang and doc, is quite unique. > Most other langs drivel with jargons, pettiness, comp-sci > pretentiousness, while their content is mathematically garbage. > (unixism mumble jumple (perl, unix), or ?proper?-engineering OOP > fantasy (java), or impractical and ivory-tower adacemician idiocy as > in Scheme & Haskell ( currying, tail recursion, closure, call-cc, > lisp1 lisp2, and monad monad monad!)) (See: What are OOP's Jargons and > Complexities ? Language, Purity, Cult, and Deception.) > > Mathematica, in its doc, is plain and simple. None of the jargon and > pretention shit. Very easy to understand. Yet, some of its function's > technical aspects are far more scholarly abstruse than any other lang > (dealing with advanced math special functions that typically only a > few thousand people in the world understand.). > > ------------------------------ > A Gander into the Idiocies > > Here's a gander into the doc drivel in common langs. > > ------------------------------ > unix > > In unix man pages, it starts with this type of garbage: > > ? ? SYNOPSIS > ? ? ? ? ? ?gzip [ -acdfhlLnNrtvV19 ] [-S suffix] [ name ... ?] > ? ? ? ? ? ?gunzip [ -acfhlLnNrtvV ] [-S suffix] [ name ... ?] > ? ? ? ? ? ?zcat [ -fhLV ] [ name ... ?] > > ? ? SYNOPSIS > ? ? ? ? ? ?zip ?[-aABcdDeEfFghjklLmoqrRSTuvVwXyz!@$] ?[-- > longoption ?...] ? [-b path] [-n suf > ? ? ? ? ? ?fixes] [-t date] [-tt date] [zipfile [file ...]] ?[-xi > list] > > Here, the mindset of unix idiots, is that somehow this ?synopsis? form > is technically precise and superior. They are thinking that it > captures the full range of syntax in the most concise way. In > practice, it's seldomly read. It's actually not accurate as one'd > thought; no program can parse it and agree with the actual behavior. > It's filled with errors, incomprehensible to human. Worse of all, the > semantic of unix software's options are the worst rape to any possible > science in computer science. See: The Nature of the Unix Philosophy ? > Unix Pipe As Functional Language ? Unix zip Utility Path Problem. > > ------------------------------ > Python > > In Python, you see this kinda garbage: > > ? ? 7.1. The if statement > > ? ? The if statement is used for conditional execution: > ? ? if_stmt ::= ?"if" expression ":" suite > ? ? ? ? ? ? ? ? ?( "elif" expression ":" suite )* > ? ? ? ? ? ? ? ? ?["else" ":" suite] > > (Source docs.python.org) > > Here, the mindset of the python idiots is similar to the unix tech > geekers. They think that using the BNF notation makes their doc more > clear and precise. The fact is, there are so many variations of BNF > each trying to fix other's problem. BNF is actually not used as a > computer language for syntax description. It's mostly used to > communicate syntax to humans. Like regex, there are so many > variations. But worse than regex in the sense that there are actually > not many actual implementations of BNF. Real word syntax description > language are usually nothing close to BNF. See: Pattern Matching vs > Lexical Grammar Specification. > > This incomprehensible BNF notation is the only thing you get if you > want to know the basic syntax of ?if?, ?for?, ?while?, ?lambda?, or > other basic constructs of python. > > ------------------------------ > Perl > > In perl, you see this type of drivel: > > ? ? A Perl program consists of a sequence of declarations and > statements which run from the top to the bottom. Loops, subroutines > and other control structures allow you to jump around within the code. > > ? ? Perl is a free-form language, you can format and indent it however > you like. Whitespace mostly serves to separate tokens, unlike > languages like Python where it is an important part of the syntax. > > ? ? Many of Perl's syntactic elements are optional. Rather than > requiring you to put parentheses around every function call and > declare every variable, you can often leave such explicit elements off > and Perl will figure out what you meant. This is known as Do What I > Mean, abbreviated DWIM. It allows programmers to be lazy and to code > in a style with which they are comfortable. > > ? ? Perl borrows syntax and concepts from many languages: awk, sed, C, > Bourne Shell, Smalltalk, Lisp and even English. Other languages have > borrowed syntax from Perl, particularly its regular expression > extensions. So if you have programmed in another language you will see > familiar pieces in Perl. They often work the same, but see perltrap > for information about how they differ. > > (Source perldoc.perl.org) > > Notice they introduced you to their lingo ?DWIM?. Juvenile humor is a > characteristics of perl's docs. It's a whole cult. They have ?perl > republic?, ?state of the onion?, ?apocalypse?, ?perl monger?, ?perl > golf?, etc.(See: Larry Wall and Cults.) Another trait is irrelevant > rambling. For example, in the above you see: ?Perl borrows syntax and > concepts from many languages: awk, sed, C, Bourne Shell, Smalltalk, > Lisp and even English.?. > > However, perl doc overall is more practically usable than Python's. > > ------------------------------ > Haskell > > Here's a example of ivory-tower idiocy, from Haskellers: > > ? ? Haskell uses a traditional Hindley-Milner polymorphic type system > to provide a static type semantics [4, 6], but the type system has > been extended with type classes (or just classes) that provide a > structured way to introduce overloaded functions. > > ? ? A class declaration (Section 4.3.1) introduces a new type class > and the overloaded operations that must be supported by any type that > is an instance of that class. An instance declaration (Section 4.3.2) > declares that a type is an instance of a class and includes the > definitions of the overloaded operations?called class methods? > instantiated on the named type. > > ? ? For example, suppose we wish to overload the operations (+) and > negate on types Int and Float. We introduce a new type class called > Num: > > ? ? ? class Num a ?where ? ? ? ? ?-- simplified class declaration for > Num > ? ? ? ? (+) ? ?:: a -> a -> a ? ? -- (Num is defined in the Prelude) > ? ? ? ? negate :: a -> a > > ? ? This declaration may be read ?a type a is an instance of the class > Num if there are class methods (+) and negate, of the given types, > defined on it.? > > (Sourcewww.haskell.org) > > Note the words ?Hindley-Milner?, ?polymorphic?, ?static type > semantics?, ?overloaded operations?. > > The reason they wrote their doc like that is because they are > academicians. You might think that their writing is really scholarly, > mathematically meaningful, almost provably correct, full of dense > mathematical rigor, and necessarily hard to understand because of the > advanced math ideas. By the look of it it is really daunting. The > irony is that the writing is often imprecise, most use of tech jargons > and terms are absolutely uncessarily to the point of being irrelevant. > And, the writing quality is pretty bad, far below the quality of > standard math journal's articles. > > -------------------------------------------------- > > uhmm, happy 2011. > > ?Xah ?http://xahlee.org/? Fell free to rewrite the docs of those programming languages in iambic pentameter, adding harp octaves in the background. -Ramon From catdude at gmail.com Tue Jan 4 15:29:44 2011 From: catdude at gmail.com (Dan M) Date: Tue, 04 Jan 2011 14:29:44 -0600 Subject: Trying to decide between PHP and Python References: Message-ID: <_MmdnZ36uOSlHr7QnZ2dnUVZ5uGdnZ2d@giganews.com> On Tue, 04 Jan 2011 12:20:42 -0800, Google Poster wrote: > About once a year, I have to learn yet another programming language. > Given all the recommendations (an outstanding accolade from Bruce Eckel, > author of "Thinking in Java") I have set my aim to Python. Sounds kinda > cool. > > The indentation-as-block is unique, but that is how I always indent, > anyway. > > Can any of you nice folks post a snippet of how to perform a listing of > the current directory and save it in a string? > > Something like this: > > $ setenv FILES = `ls` > > Bonus: Let's say that I want to convert the names of the files to > lowercase? As 'tolower()' > > TIA, > > -Ramon 1) import os files = ' '.join(os.listdir('/home/dan')) 2) import os import string files = string.lower(' '.join(os.listdir('/home/dan'))) As to choice between Python and PHP, I would say learn anything but PHP. Even Perl has fewer tentacles than PHP. From goposter at jonjay.com Tue Jan 4 15:30:21 2011 From: goposter at jonjay.com (Google Poster) Date: Tue, 4 Jan 2011 12:30:21 -0800 (PST) Subject: Troll Alert (do not click) References: <1f0063d2-53fc-4167-921e-aab49ce9e09b@o11g2000prf.googlegroups.com> Message-ID: <21da0736-800c-4cfc-9106-ed9edab6059f@j32g2000prh.googlegroups.com> On Jan 4, 8:19?am, SHILPA wrote: > ? ? ? ? ? ?UNSEEN HOT SEXY PHOTOS > ?http://karomasti9.blogspot.com/2011/01/never.html > ? ? ? ? ? ? ? ? ? ? ? ? SEXY DIYA MIRZA > ? ?http://karomasti9.blogspot.com/2010/12/diya-mirza.html > ? ? ? ? ? ? ? ? ? ? ? ? HOT AISHWARIYA RAIhttp://karomasti9.blogspot.com/2010/12/aish.html > ? ? ? ? ? ? ? ? ? ? ?priyamani hot&sexy photoshttp://karomasti9.blogspot.com/2010/12/priyamani.html > ? ? ? ? ? ? ? ? ? ? ? KATRINA SEXY PHOTOShttp://karomasti9.blogspot.com/2010/12/katrina.html > ? ? ? ? ? ? ? ? ?ANUSHKA HOT PHOTOShttp://karomasti9.blogspot.com/2010/12/anuska.html > ? ? ? ? ? ? ? ? ? ? BEAUTIFUL AISHWARIYA RAIhttp://karomasti9.blogspot.com/2010/12/aiesh.html > ? ? ? ? ? ? ? ? ? ? TRISHA HOT PHOTOShttp://karomasti9.blogspot.com/2010/11/trisha-hot.html > ? ? ? ? ? ? ? AMISHAPATEL HOT VIDEOShttp://karomasti9.blogspot.com/search/label/amisha > ? ? ? ? ? ? ?HANSIKHA HOT SEXY PHOTOShttp://karomasti9.blogspot.com/search/label/HANSIKA > ? ? ? ? ? ? ?HOT SEXY COLLEGE GIRLShttp://karomasti9.blogspot.com/search/label/hot > ? ? ? ? ? ? ? BEAUTIFUL LARADATTAhttp://karomasti9.blogspot.com/search/label/laradatta > ? ? ? ? ? ? ? NIKISHA HOT BOOBShttp://karomasti9.blogspot.com/search/label/nikisha > ? ? ? ? ? ?PRIYANKA SPICY LATEST PICShttp://karomasti9.blogspot.com/search/label/priyanka > ? ? ? ? ? ? ? ONLY FOR YOUTHhttp://karomasti9.blogspot.com/search/label/spicy > ? ? ? ? ? ?SRILEKHA UNSEENED PHOTOShttp://karomasti9.blogspot.com/search/label/Srilekha > ? ? ? ? ? ? ?CHOPRA UNBELIVABLE PHOTOShttp://karomasti9.blogspot.com/search/label/chopra > ? ? ? ? ? ? ? HOT BIPASA BASU PHOTOShttp://karomasti9.blogspot.com/search/label/bipasa > ? ? ? ? ? ? ? TRISHA IN A SEXY FEELhttp://karomasti9.blogspot.com/search/label/thrisha > ? ? ? ? ? ?SRISHA HOT BOOBS SHOWhttp://karomasti9.blogspot.com/search/label/srisha > ? ? ? ? ? ?BEAUTIFUL POONAM PHOTOShttp://karomasti9.blogspot.com/search/label/poonam From goposter at jonjay.com Tue Jan 4 15:32:28 2011 From: goposter at jonjay.com (Google Poster) Date: Tue, 4 Jan 2011 12:32:28 -0800 (PST) Subject: Trying to decide between PHP and Python References: <_MmdnZ36uOSlHr7QnZ2dnUVZ5uGdnZ2d@giganews.com> Message-ID: On Jan 4, 2:29?pm, Dan M wrote: > On Tue, 04 Jan 2011 12:20:42 -0800, Google Poster wrote: > > About once a year, I have to learn yet another programming language. > > Given all the recommendations (an outstanding accolade from Bruce Eckel, > > author of "Thinking in Java") I have set my aim to Python. Sounds kinda > > cool. > > > The indentation-as-block is unique, but that is how I always indent, > > anyway. > > > Can any of you nice folks post a snippet of how to perform a listing of > > the current directory and save it in a string? > > > Something like this: > > > $ setenv FILES = `ls` > > > Bonus: Let's say that I want to convert the names of the files to > > lowercase? As 'tolower()' > > > TIA, > > > -Ramon > > 1) > import os > files = ' '.join(os.listdir('/home/dan')) > > 2) > import os > import string > files = string.lower(' '.join(os.listdir('/home/dan'))) > > As to choice between Python and PHP, I would say learn anything but PHP. > Even Perl has fewer tentacles than PHP. Not to mention that it took me 9 minutes to get a reply from you... Quite speedy community support. That is a very important parameter in my technology decisions these days. Thanks! -Ramon From catdude at gmail.com Tue Jan 4 15:34:17 2011 From: catdude at gmail.com (Dan M) Date: Tue, 04 Jan 2011 14:34:17 -0600 Subject: Trying to decide between PHP and Python References: <_MmdnZ36uOSlHr7QnZ2dnUVZ5uGdnZ2d@giganews.com> Message-ID: <_MmdnZz6uOTUGb7QnZ2dnUVZ5uGdnZ2d@giganews.com> On Tue, 04 Jan 2011 12:32:28 -0800, Google Poster wrote: > Not to mention that it took me 9 minutes to get a reply from you... > Quite speedy community support. > > That is a very important parameter in my technology decisions these > days. > > Thanks! > > -Ramon This Usenet group is a truly awesome resource. I'm a Python newbie myself, and the times I've posted here looking for direction I have been very pleased with the results. Dan From tjreedy at udel.edu Tue Jan 4 15:34:40 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Tue, 04 Jan 2011 15:34:40 -0500 Subject: opinion: comp lang docs style In-Reply-To: <98e82f1b-cf59-4e64-8fd4-63671f96b04f@r19g2000prm.googlegroups.com> References: <98e82f1b-cf59-4e64-8fd4-63671f96b04f@r19g2000prm.googlegroups.com> Message-ID: On 1/4/2011 1:24 PM, an Arrogant Ignoramus wrote: what he called > a opinion piece. I normally do not respond to trolls, but while expressing his opinions, AI made statements that are factually wrong at least as regards Python and its practitioners. 1. He correctly notes that the Python Language Reference includes snippets of BNF grammar with the intention of making the doc clear and precise. > The if statement is used for conditional execution: > if_stmt ::= "if" expression ":" suite > ( "elif" expression ":" suite )* > ["else" ":" suite] He incorrectly claims that the inclusion fails in its purpose. This is based on the irrelevant fact that 'BNF' has many versions (Python only uses one, explained in 1.2. Notation) and the false claim that "BNF is actually not used as a computer language for syntax description.". Actually, the above snippet is a quotation (with initial ':' expanded to '::=' and newlines added) from the file Grammar/Grammar: "if_stmt: 'if' test ':' suite ('elif' test ':' suite)* ['else' ':' suite]" The CPython program Parser/pgen takes Grammar/Grammar as input and produces the parser tables that CPython uses to parse Python code. In other words, CPython uses its well-defined version of extended BNF as a 'computer language for syntax description', contrary to AI's claim. I presume other implementations make either human or machine use of the same file. 2. AI also claims that this notation is 'incomprehensible'. Perhaps to him, but not to me or most the the subset of users who care about it. One way to expand the BNF into English is as follows: An if-statement starts with an if-clause consisting of the word 'if', an expression, a colon, and a suite. 'expression' and a 'suite' have already been defined elsewhere. The if clause can optionally be followed any count (including 0) of elif-clauses which are the same as if-clauses but with 'elif' substituted for 'if'. An if-statement can optionally be terminated with an else-clause consisting of 'else' and a suite. Even if such long-winded paraphrases were added to the doc (and I do not think they should be), in addition to the explanations currently given, the grammar snippet would still be needed to show the exact technical definition that CPython actually uses, for those who wan precisely that. (The people who care include those who want to change the grammar or those who think the behavior might might match the grammar.) 3. AI's complaint is deceptive and deficient in omitting any mention the part of the docs *intended* to teach beginners: the Tutorial. The main doc pages list the Tutorial first, as what one should start with. That is where I started and I cannot remember if I have ever read the formal if-statement grammar before, as I knew how to write such before I ever looked at the Language Reference. Guido and other developers do not and never have expected people to learn about if-statements from the grammar. The tutorial says: " 4.1. if Statements Perhaps the most well-known statement type is the if statement. For example: >>> x = int(input("Please enter an integer: ")) Please enter an integer: 42 >>> if x < 0: ... x = 0 ... print('Negative changed to zero') ... elif x == 0: ... print('Zero') ... elif x == 1: ... print('Single') ... else: ... print('More') There can be zero or more elif parts, and the else part is optional. The keyword ?elif? is short for ?else if?, and is useful to avoid excessive indentation. An if ... elif ... elif ... sequence is a substitute for the switch or case statements found in other languages. " I think this says by example and plain English just what a Python programmer needs to know. It is, of course, followed by many other examples in the remainder of the tutorial. If one wants to critique the 'Python Docs', especially as regards to usefulness to beginners, one must start with the Tutorial; and if one wants to use if statements as an example, one must start with the above. -- Terry Jan Reedy From arnodel at gmail.com Tue Jan 4 15:36:56 2011 From: arnodel at gmail.com (Arnaud Delobelle) Date: Tue, 04 Jan 2011 20:36:56 +0000 Subject: String building using join References: Message-ID: <87bp3wv21j.fsf@gmail.com> gervaz writes: > Hi all, I would like to ask you how I can use the more efficient join > operation in a code like this: > >>>> class Test: > ... def __init__(self, v1, v2): > ... self.v1 = v1 > ... self.v2 = v2 > ... >>>> def prg(l): > ... txt = "" > ... for x in l: > ... if x.v1 is not None: > ... txt += x.v1 + "\n" > ... if x.v2 is not None: > ... txt += x.v2 + "\n" > ... return txt > ... You can change the prg() function above slightly to make it a generator function: def genprg(l): for x in l: if x.v1 is not None: yield x.v1 if x.v2 is not None: yield x.v2 Then you can rewrite prg using join: def prg(l): return '\n'.join(genprg(l)) This way you save yourself from creating a list. I know this is not the one liner that others have suggested but it shows a general way of transforming a piece of code in order to make use of generator functions. -- Arnaud From goposter at jonjay.com Tue Jan 4 15:37:07 2011 From: goposter at jonjay.com (Google Poster) Date: Tue, 4 Jan 2011 12:37:07 -0800 (PST) Subject: Trying to decide between PHP and Python References: <_MmdnZ36uOSlHr7QnZ2dnUVZ5uGdnZ2d@giganews.com> <_MmdnZz6uOTUGb7QnZ2dnUVZ5uGdnZ2d@giganews.com> Message-ID: <2fdba007-53e0-470b-9663-1eb30183e76a@o11g2000prf.googlegroups.com> On Jan 4, 2:34?pm, Dan M wrote: > On Tue, 04 Jan 2011 12:32:28 -0800, Google Poster wrote: > > Not to mention that it took me 9 minutes to get a reply from you... > > Quite speedy community support. > > > That is a very important parameter in my technology decisions these > > days. > > > Thanks! > > > -Ramon > > This Usenet group is a truly awesome resource. My kinda place. :-) Now, I will embark on my learning journey the proper way: reading some Internet tutorials, instead of cheating like I just did. -Ramon From benjamin.kaplan at case.edu Tue Jan 4 15:45:12 2011 From: benjamin.kaplan at case.edu (Benjamin Kaplan) Date: Tue, 4 Jan 2011 15:45:12 -0500 Subject: Trying to decide between PHP and Python In-Reply-To: References: Message-ID: On Tue, Jan 4, 2011 at 3:20 PM, Google Poster wrote: > > About once a year, I have to learn yet another programming language. > Given all the recommendations (an outstanding accolade from Bruce > Eckel, author of "Thinking in Java") I have set my aim to Python. > Sounds kinda cool. > > The indentation-as-block is unique, but that is how I always indent, > anyway. > > Can any of you nice folks post a snippet of how to perform a listing > of the current directory and save it in a string? > > Something like this: > > $ setenv FILES = `ls` > import os FILES = os.listdir('.') will give you a list of all the files in the current directory. If you wanted that as a single string, just join all of the file names with whatever you want as a separator. files_str = '\n'.join(FILES) It's a bit different than what your original command does- it doesn't use the external "ls" command, it just gives you the list of files already parsed. > Bonus: Let's say that I want to convert the names of the files to > lowercase? As 'tolower()' > Strings in Python have a lower() method. files_str = files_str.lower() > TIA, > > -Ramon > -- > http://mail.python.org/mailman/listinfo/python-list > From bthate at gmail.com Tue Jan 4 15:46:39 2011 From: bthate at gmail.com (Bart Thate) Date: Tue, 4 Jan 2011 12:46:39 -0800 (PST) Subject: JSONBOT 0.6 RELEASED Message-ID: Hello world and the best wishes for 2011 for all of you ! i'm pleased to announce version 0.6 of JSONBOT, a release that saw it's complete codebase refactored. Things have moved into their own package, making it easier to distribute JSONBOT to the various OS around. I even renamed the name of the distribution to "jsb", so use the jsb-0.6.tar.gz or "easy_install jsb" to get this version of JSONBOT. So once again i need to ask existing users to upgrade their JSONBOT install, see http://jsonbot.appspot.com/docs/html/handbook/UPGRADE.html for instructions on how to do that. Functionality of the bot is the same as 0.5. For more information on JSONBOT, see http://jsonbot.googlecode.com or join us on #dunkbots Freenode. Bot documentation and demo is on http://jsonbot.appspot.com I hope you enjoy this release of JSONBOT, i'm glad i can start working on 0.7 ;] About JSONBOT: JSONBOT is a remote event-driven framework for building bots that talk JSON to each other over XMPP. This distribution provides bots built on this framework for console, IRC, XMPP for the shell and WWW and XMPP for the Google Application engine. JSONBOT is all of the following: * a shell console bot * a shell IRC bot * a shell XMPP bot * a Web bot running on Google Application Engine * a XMPP bot running on Google Application Engine * a Google Wave bot running op Google Application Engine * the XMPP bots are used to communicate between bots * plugin infrastructure to write your own functionality * event driven framework by the use of callbacks Bart From ameyer2 at yahoo.com Tue Jan 4 15:53:02 2011 From: ameyer2 at yahoo.com (Alan Meyer) Date: Tue, 04 Jan 2011 15:53:02 -0500 Subject: Trying to decide between PHP and Python In-Reply-To: References: Message-ID: <4D2388AE.6090103@yahoo.com> I confess that I haven't used php so someone correct me if I'm wrong. Looking at the history of the two languages, it is my impression that php originated as a language for web/CGI development which eventually added features enabling it to be used (sparingly) as a general purpose language. Python on the other hand is a general purpose language that has added features, in the form of library modules, that enable it to be used as a web/CGI development. Given these histories, one might ask, do you want to learn a new language for general purposes including web development, or do you want to learn a new language that is specifically focused on web/CGI? If the later, php will be an excellent choice, if the former, Python. If you only want to learn one language, or at least only want to learn one at this time, Python seems like a more useful choice - but only if you work (or also work) on some applications other than web/CGI. Alan From clp2 at rebertia.com Tue Jan 4 15:53:15 2011 From: clp2 at rebertia.com (Chris Rebert) Date: Tue, 4 Jan 2011 12:53:15 -0800 Subject: Trying to decide between PHP and Python In-Reply-To: <_MmdnZ36uOSlHr7QnZ2dnUVZ5uGdnZ2d@giganews.com> References: <_MmdnZ36uOSlHr7QnZ2dnUVZ5uGdnZ2d@giganews.com> Message-ID: On Tue, Jan 4, 2011 at 12:29 PM, Dan M wrote: > On Tue, 04 Jan 2011 12:20:42 -0800, Google Poster wrote: > >> About once a year, I have to learn yet another programming language. >> Given all the recommendations (an outstanding accolade from Bruce Eckel, >> author of "Thinking in Java") I have set my aim to Python. Sounds kinda >> cool. >> >> The indentation-as-block is unique, but that is how I always indent, >> anyway. >> >> Can any of you nice folks post a snippet of how to perform a listing of >> the current directory and save it in a string? >> >> Something like this: >> >> $ setenv FILES = `ls` >> >> Bonus: Let's say that I want to convert the names of the files to >> lowercase? As 'tolower()' > import os > import string > files = string.lower(' '.join(os.listdir('/home/dan'))) Most of the string module has been deprecated for quite a while now; use string methods instead: files = ' '.join(os.listdir('/home/dan')).lower() Cheers, Chris From alex at moreati.org.uk Tue Jan 4 16:09:13 2011 From: alex at moreati.org.uk (Alex Willmer) Date: Tue, 4 Jan 2011 13:09:13 -0800 (PST) Subject: Trying to decide between PHP and Python References: Message-ID: On Jan 4, 8:20?pm, Google Poster wrote: > Can any of you nice folks post a snippet of how to perform a listing > of the current directory and save it in a string? > > Something like this: > > $ setenv FILES = `ls` > > Bonus: Let's say that I want to convert the names of the files to > lowercase? As 'tolower()' I'd just like to mention one more python nicety: list comprehension. If you wanted the filenames as a list of strings, with each made lowercase then the following would serve well: import os filenames = os.listdir('.') filenames_lower = [fn.lower() for fn in filenames] You could also combine this into one line: import os filenames_lower = [fn.lower() for fn in os.listdir('.')] Regards, Alex From rtomek at ceti.com.pl Tue Jan 4 16:12:14 2011 From: rtomek at ceti.com.pl (Tomasz Rola) Date: Tue, 4 Jan 2011 22:12:14 +0100 Subject: Trying to decide between PHP and Python In-Reply-To: <_MmdnZ36uOSlHr7QnZ2dnUVZ5uGdnZ2d@giganews.com> References: <_MmdnZ36uOSlHr7QnZ2dnUVZ5uGdnZ2d@giganews.com> Message-ID: On Tue, 4 Jan 2011, Dan M wrote: > As to choice between Python and PHP, I would say learn anything but PHP. > Even Perl has fewer tentacles than PHP. However, the quality of code depends heavily on who writes it. My impression is that more folks of "I did it and it works so it is good, right?" attitude can be found among Perl/PHP crowd (compared to Python or Ruby or...). The reason is probably the "easyness" of those languages (mostly because of tons of readymade code on the net) which - wrongly - suggests they are already "there", no need to learn anymore. But I find, from time to time, nice code written in, say, PHP and from this I know it is possible to use it without screwing up. I guess it requires just some learning, some books (leaning towards theory rather than teaching dummies whatever in 2 and 1/10 days) and about five years (or maybe ten, or maybe only two) - after that, you can learn PHP and Perl if you really want to :-). I guess stackoverflow can give some pointers about it. Myself, I see neither of the two as promising for me, so I deflect them. Regards, Tomasz Rola -- ** A C programmer asked whether computer had Buddha's nature. ** ** As the answer, master did "rm -rif" on the programmer's home ** ** directory. And then the C programmer became enlightened... ** ** ** ** Tomasz Rola mailto:tomasz_rola at bigfoot.com ** From ian.g.kelly at gmail.com Tue Jan 4 16:14:17 2011 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Tue, 4 Jan 2011 14:14:17 -0700 Subject: Error python + cx_Oracle :Oracle-Error-Message: ORA-01036: illegal variable name/number In-Reply-To: <4D237BC7.9010101@gmail.com> References: <4D237BC7.9010101@gmail.com> Message-ID: On Tue, Jan 4, 2011 at 12:57 PM, Mauricio Martinez Garcia wrote: > > Hi, i need help with the next error: > > "ERR_PYTHON:Oracle-Error-Message: ORA-01036: illegal variable name/number", > i used the cx_Oracle module, and the error not is only Oracle Error. > > The error its for that python don't translate the query, with the variables > ":VARIABLE" when the VARIABLE is a number, this is th ecause of Oracle > error. You can only specify bind parameters that are used in the query. The dict you are passing in has 56 key/value pairs, but your query has only 55 variables. "TELEFONO_ICC" does not appear to be used anywhere in the query. Cheers, Ian From stef.mientki at gmail.com Tue Jan 4 16:15:33 2011 From: stef.mientki at gmail.com (Stef Mientki) Date: Tue, 04 Jan 2011 22:15:33 +0100 Subject: Trying to decide between PHP and Python In-Reply-To: <_MmdnZ36uOSlHr7QnZ2dnUVZ5uGdnZ2d@giganews.com> References: <_MmdnZ36uOSlHr7QnZ2dnUVZ5uGdnZ2d@giganews.com> Message-ID: <4D238DF5.4010305@gmail.com> > As to choice between Python and PHP, I would say learn anything but PHP. > Even Perl has fewer tentacles than PHP. type this in a form field 2.2250738585072011e-308 http://www.exploringbinary.com/php-hangs-on-numeric-value-2-2250738585072011e-308/ cheers, Stef From ben+python at benfinney.id.au Tue Jan 4 16:15:59 2011 From: ben+python at benfinney.id.au (Ben Finney) Date: Wed, 05 Jan 2011 08:15:59 +1100 Subject: Trying to decide between PHP and Python References: <_MmdnZ36uOSlHr7QnZ2dnUVZ5uGdnZ2d@giganews.com> <_MmdnZz6uOTUGb7QnZ2dnUVZ5uGdnZ2d@giganews.com> <2fdba007-53e0-470b-9663-1eb30183e76a@o11g2000prf.googlegroups.com> Message-ID: <87tyhofjzk.fsf@benfinney.id.au> Google Poster writes: > On Jan 4, 2:34?pm, Dan M wrote: > > This Usenet group is a truly awesome resource. > > My kinda place. :-) Can I ask, since you'll be joining us here, that you use your name (?Ramon? according to your signature, but preferably a full name) in your ?From? field to identify your messages better? -- \ ?I am too firm in my consciousness of the marvelous to be ever | `\ fascinated by the mere supernatural ?? ?Joseph Conrad, _The | _o__) Shadow-Line_ | Ben Finney From goposter at jonjay.com Tue Jan 4 16:22:41 2011 From: goposter at jonjay.com (Google Poster) Date: Tue, 4 Jan 2011 13:22:41 -0800 (PST) Subject: Trying to decide between PHP and Python References: Message-ID: On Jan 4, 3:09?pm, Alex Willmer wrote: > On Jan 4, 8:20?pm, Google Poster wrote: > > > Can any of you nice folks post a snippet of how to perform a listing > > of the current directory and save it in a string? > > > Something like this: > > > $ setenv FILES = `ls` > > > Bonus: Let's say that I want to convert the names of the files to > > lowercase? As 'tolower()' > > I'd just like to mention one more python nicety: list comprehension. > If you wanted the filenames as a list of strings, with each made > lowercase then the following would serve well: > > import os > filenames = os.listdir('.') > filenames_lower = [fn.lower() for fn in filenames] > > You could also combine this into one line: > > import os > filenames_lower = [fn.lower() for fn in os.listdir('.')] > > Regards, Alex The syntax reminds me of Lots of Interspersed Silly Parentheses (L.I.S.P.), but without the parentheses. :-) -Ramon From steve+comp.lang.python at pearwood.info Tue Jan 4 16:23:46 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 04 Jan 2011 21:23:46 GMT Subject: Troll Alert (do not click) References: <1f0063d2-53fc-4167-921e-aab49ce9e09b@o11g2000prf.googlegroups.com> <21da0736-800c-4cfc-9106-ed9edab6059f@j32g2000prh.googlegroups.com> Message-ID: <4d238fe1$0$29968$c3e8da3$5496439d@news.astraweb.com> On Tue, 04 Jan 2011 12:30:21 -0800, Google Poster wrote: [snip spam] Good lord, why the hell are you RE-POSTING spam??? Did you actually think it was HELPFUL to defeat everyone's anti-spam filters? Most people won't see the original spam, and then you "helpfully" resend it. Thanks a lot, if not for you we might not have seen it at all -- and if we did, we almost certainly wouldn't have clicked on it without the misleading subject line. I thought you were complaining about Xah Lee, which is always fun to read, not re-posting Indian porno spam. If I didn't know better, I'd seriously wonder whether you are, in fact, the spammer, just pretending to be replying to some other spammer. A false name (do your friends call you "Google Poster"?), a misleading subject line (it's not a troll post, it's spam), a trick to defeat filters and win the off-topic URLs many more links. Hmmm. Please don't try to "help" in this way again. -- Steven From steve+comp.lang.python at pearwood.info Tue Jan 4 16:31:56 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 04 Jan 2011 21:31:56 GMT Subject: Trying to decide between PHP and Python References: Message-ID: <4d2391cc$0$29968$c3e8da3$5496439d@news.astraweb.com> On Tue, 04 Jan 2011 13:09:13 -0800, Alex Willmer wrote: > You could also combine this into one line: > > import os > filenames_lower = [fn.lower() for fn in os.listdir('.')] That's two lines :) Here are a couple of nicely obfuscated one-liners: [name.lower() for name in __import__('os').listdir('.')] map(str.lower, __import__('os').listdir('.')) -- Steven From ameyer2 at yahoo.com Tue Jan 4 17:43:41 2011 From: ameyer2 at yahoo.com (Alan Meyer) Date: Tue, 04 Jan 2011 17:43:41 -0500 Subject: Trying to decide between PHP and Python In-Reply-To: References: Message-ID: <4D23A29D.7030104@yahoo.com> On 1/4/2011 4:22 PM, Google Poster wrote: > The syntax reminds me of Lots of Interspersed Silly Parentheses > (L.I.S.P.), but without the parentheses. I haven't heard that version before. The one I heard was: "Lots of Irritating Single Parentheses". Alan From steve+comp.lang.python at pearwood.info Tue Jan 4 17:48:24 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 04 Jan 2011 22:48:24 GMT Subject: Matrix multiplication References: <4h8bv7-p09.ln1@satorlaser.homedns.org> Message-ID: <4d23a3b8$0$29968$c3e8da3$5496439d@news.astraweb.com> On Tue, 04 Jan 2011 13:22:33 +0100, Zdenko wrote: > I wrote these two codes for example: > > this one is naive way of matrix multiplication using one thread [...] > this one is using two threads, each one is multiplying half of matrix [...] > why is second one more than twice slower than first when it should be > faster. I suspect that problem is in simultaneous access to matrix C but > i don't know how to solve this. Can I suggest that your timing code leaves something to be desired? * You time too much. You're interested in how long it takes to multiply two matrices, but you time how long it takes to do much more than just the multiplication: your timing code covers the time it takes to create the class object (which will be trivial), and build the matrix (non- trivial), as well as perform the multiplication. * Your perform the timing test once, which makes it subject to sampling errors. (Although if the process takes a long time, say, multiple seconds, the sampling error will *probably* be small relative to the measured time. But not always.) * You use time.clock, but without knowing which operating system you are running, it's impossible to tell whether you should be using time.time instead. Whether these issues will actually make a practical difference in this *specific* case, I don't know, but as a general rule, the most accurate way to perform these sorts of timing tests is with the timeit module. Something like this: A = ... # initialise matrix A B = ... # and B C = ... # and the result def mult1(A, B, C): # Multiply matrices A and B using 1 thread. t = MyThread() t.start() t.join() def mult2(A, B, C): # Multiply matrices A and B using 2 threads. t1 = MyThread() t2 = MyThread() t1.start() t2.start() t1.join() # Block until thread 1 is done. t2.join() # Now block until thread 2 is done. setup1 = "from __main__ import A, B, C, mult1" setup2 = "from __main__ import A, B, C, mult2" from timeit import Timer t1 = Timer("mult1(A, B, C)", setup1) t2 = Timer("mult2(A, B, C)", setup2) # Now perform the timing tests. best1 = min(t1.repeat()) best2 = min(t2.repeat()) By default, Timer.repeat will measure the time taken by one million iterations of the code snippet, and take three measurements. You almost always only care about the smallest measurement -- any larger times will represent sampling error. If it takes too long to time one million iterations, either make the matrices smaller, or pass keyword arguments number and/or repeat to the repeat method: # best of five measurements of one hundred iterations best1 = min(t1.repeat(number=100, repeat=5)) -- Steven From rurpy at yahoo.com Tue Jan 4 18:17:37 2011 From: rurpy at yahoo.com (rurpy at yahoo.com) Date: Tue, 4 Jan 2011 15:17:37 -0800 (PST) Subject: opinion: comp lang docs style References: <98e82f1b-cf59-4e64-8fd4-63671f96b04f@r19g2000prm.googlegroups.com> Message-ID: <4745479a-10c5-4281-9dcd-c9d7b013a1ec@k13g2000vbq.googlegroups.com> On 01/04/2011 01:34 PM, Terry Reedy wrote: > On 1/4/2011 1:24 PM, an Arrogant Ignoramus wrote: > > what he called >> a opinion piece. > > I normally do not respond to trolls, but while expressing his opinions, > AI made statements that are factually wrong at least as regards Python > and its practitioners. Given that most trolls include factually false statements, the above is inconsistent. And speaking of arrogant, it is just that to go around screaming "troll" about a posting relevant to the newsgroup it was posted in because you don't happen to agree with its content. In doing so you lower your own credibility. (Which is also not helped by your "Arrogant Ignoramus" name-calling.) > [...] > 2. AI also claims that this notation is 'incomprehensible'. Since incomprehensibility is clearly subjective your claim that it is a factual error is every bit as hyperbolic as his. > [...] > 3. AI's complaint is deceptive and deficient in omitting any mention the > part of the docs *intended* to teach beginners: the Tutorial. The main > doc pages list the Tutorial first, as what one should start with. That > [...] > If one wants to critique the 'Python Docs', especially as regards to > usefulness to beginners, one must start with the Tutorial; and if one > wants to use if statements as an example, one must start with the above. No. The language reference (LR) and standard library reference (SLR) must stand on their own merits. It is nice to have a good tutorial for those who like that style of learning. But it should be possible for a programmer with a basic understanding of computers and some other programming languages to understand how to program in python without referring to tutorials, explanatory websites, commercially published books, the source code, etc. The difficulty of doing that is a measure of the failure of the python docs to achive a level quality commensurate with the language itself. FWIW, I think the BNF in the LR is perfectly reasonable given the target audience I gave above. The failure of the LR has more to do with missing or excessively terse material -- it concentrates too exclusively on syntax and insufficiently on semantics. Much of the relevant semantics information is currently mislocated in the SLR. From roy at panix.com Tue Jan 4 19:31:01 2011 From: roy at panix.com (Roy Smith) Date: Tue, 04 Jan 2011 19:31:01 -0500 Subject: Trying to decide between PHP and Python References: <4D23A29D.7030104@yahoo.com> Message-ID: In article <4D23A29D.7030104 at yahoo.com>, Alan Meyer wrote: > On 1/4/2011 4:22 PM, Google Poster wrote: > > > The syntax reminds me of Lots of Interspersed Silly Parentheses > > (L.I.S.P.), but without the parentheses. > > I haven't heard that version before. The one I heard was: > > "Lots of Irritating Single Parentheses". > > Alan Long Involved Stupid Parentheses. From rtomek at ceti.com.pl Tue Jan 4 20:51:29 2011 From: rtomek at ceti.com.pl (Tomasz Rola) Date: Wed, 5 Jan 2011 02:51:29 +0100 Subject: Trying to decide between PHP and Python In-Reply-To: References: <4D23A29D.7030104@yahoo.com> Message-ID: On Tue, 4 Jan 2011, Roy Smith wrote: > In article <4D23A29D.7030104 at yahoo.com>, Alan Meyer > wrote: > > > On 1/4/2011 4:22 PM, Google Poster wrote: > > > > > The syntax reminds me of Lots of Interspersed Silly Parentheses > > > (L.I.S.P.), but without the parentheses. > > > > I haven't heard that version before. The one I heard was: > > > > "Lots of Irritating Single Parentheses". > > > > Alan > > Long Involved Stupid Parentheses. Heh. One day, guys, when you have nothing better to do, try writing a parser for Lisp-like language (Common Lisp, Scheme, whatever). After that, do the same with some other language of your preference (Python, Java, whatever). Compare time and code spent... Regards :-) Tomasz Rola -- ** A C programmer asked whether computer had Buddha's nature. ** ** As the answer, master did "rm -rif" on the programmer's home ** ** directory. And then the C programmer became enlightened... ** ** ** ** Tomasz Rola mailto:tomasz_rola at bigfoot.com ** From askutt at gmail.com Tue Jan 4 21:11:55 2011 From: askutt at gmail.com (Adam Skutt) Date: Tue, 4 Jan 2011 18:11:55 -0800 (PST) Subject: Interrput a thread References: <81c24eb1-41b6-442a-a971-8a44d2cd6c1b@p8g2000vbs.googlegroups.com> <2ebc11a5-1b45-4faa-97b9-c84f0db015a4@k22g2000yqh.googlegroups.com> Message-ID: <68004bac-5d4d-40fa-afb7-6de45f3ea87a@v17g2000yqv.googlegroups.com> On Jan 4, 10:12?am, Fuzzyman wrote: > > This is a case that .NET (C#) handles better than Python or Java. > Nope, read the documentation for Thread.Abort() carefully. Thread.Abort() can cause termination inside a static constructor, which is very bad. You sure your application can cope with that? Mine can't. Thread.Abort() is only safe for self-abortion, app domain termination and a few other very narrow and obscure scenarios. It is not a safe way to end arbitrary threads doing arbitrary processing. > It's another place where people > sometimes have a genuine need/use case yet people will insist on > telling them they don't *really* want it... > Because there's no safe way to do it. It's fundamentally a racy operation, with the typical horrible consequences when you lose. Removing the race requires support from the application, i.e., you have to write the code yourself. Frequently, it's simply not possible to remove the race. Adam From roy at panix.com Tue Jan 4 21:32:17 2011 From: roy at panix.com (Roy Smith) Date: Tue, 04 Jan 2011 21:32:17 -0500 Subject: Trying to decide between PHP and Python References: <4D23A29D.7030104@yahoo.com> Message-ID: In article , Tomasz Rola wrote: > Heh. One day, guys, when you have nothing better to do, try writing a > parser for Lisp-like language (Common Lisp, Scheme, whatever). After that, > do the same with some other language of your preference (Python, Java, > whatever). Compare time and code spent... There is no doubt that lisp is easy to parse. Even I can increment a counter every time I see '(' and decrement it every time I see ')'. But, computers are there to make life easy on people, not the other way around. There. Now that I've tossed some gasoline on the language wars fire, I'll duck and run in the other direction :-) From ben+python at benfinney.id.au Tue Jan 4 22:01:23 2011 From: ben+python at benfinney.id.au (Ben Finney) Date: Wed, 05 Jan 2011 14:01:23 +1100 Subject: Trying to decide between PHP and Python References: <4D23A29D.7030104@yahoo.com> Message-ID: <87bp3wf3zw.fsf@benfinney.id.au> Tomasz Rola writes: > Heh. One day, guys, when you have nothing better to do, try writing a > parser for Lisp-like language (Common Lisp, Scheme, whatever). After > that, do the same with some other language of your preference (Python, > Java, whatever). Compare time and code spent... Perhaps Lisp is a simpler language to parse than Python. Perhaps a machine with only one instruction is simpler to implement than one with a broader instruction set. So what? -- \ ?Shepherds ? look after their sheep so they can, first, fleece | `\ them and second, turn them into meat. That's much more like the | _o__) priesthood as I know it.? ?Christopher Hitchens, 2008-10-29 | Ben Finney From rtomek at ceti.com.pl Tue Jan 4 22:18:40 2011 From: rtomek at ceti.com.pl (Tomasz Rola) Date: Wed, 5 Jan 2011 04:18:40 +0100 Subject: Trying to decide between PHP and Python In-Reply-To: <87bp3wf3zw.fsf@benfinney.id.au> References: <4D23A29D.7030104@yahoo.com> <87bp3wf3zw.fsf@benfinney.id.au> Message-ID: On Wed, 5 Jan 2011, Ben Finney wrote: > > Tomasz Rola writes: > > Heh. One day, guys, when you have nothing better to do, try writing a > > parser for Lisp-like language (Common Lisp, Scheme, whatever). After > > that, do the same with some other language of your preference (Python, > > Java, whatever). Compare time and code spent... > Perhaps Lisp is a simpler language to parse than Python. > Perhaps a machine with only one instruction > is > simpler to implement than one with a broader instruction set. > So what? So... nothing at all. My intention was to point out that parentheses (or rather, simple syntax that is enabled when using them) can give a boost in some situations. BTW, my own experience tells me, they are not really as bad as some folk tales imply. Of course, there is also esthetic reason - some people don't like parentheses, period. I am ok with this. Me, OTOH, I have esthetic incompatibility with Perl and to some extent with PHP. No problem for me :-). Regards, Tomasz Rola -- ** A C programmer asked whether computer had Buddha's nature. ** ** As the answer, master did "rm -rif" on the programmer's home ** ** directory. And then the C programmer became enlightened... ** ** ** ** Tomasz Rola mailto:tomasz_rola at bigfoot.com ** From nagle at animats.com Tue Jan 4 22:46:10 2011 From: nagle at animats.com (John Nagle) Date: Tue, 04 Jan 2011 19:46:10 -0800 Subject: Matrix multiplication In-Reply-To: <4h8bv7-p09.ln1@satorlaser.homedns.org> References: <4h8bv7-p09.ln1@satorlaser.homedns.org> Message-ID: <4d23e980$0$44012$742ec2ed@news.sonic.net> On 1/4/2011 2:15 AM, Ulrich Eckhardt wrote: > Zdenko wrote: >> Please, can anybody write me a simple recursive matrix multiplication >> using multiple threads in Python, or at least show me some guidelines >> how to write it myself > > No problem, I just need your bank account data to withdraw the payment and > the address of your teacher whom to send the results. ;^) > > Seriously, things don't work like this. If you show effort, you will get > help, but you don't get working solutions without even a bit of effort on > your own. > > Start with a recursive algorithm, then make it multithreaded. Be prepared to > make some experiments on how to distribute tasks to threads and collect > them again. If you want to do matrix multiplication from Python, use NumPy. Anything you write in Python itself and run in CPython will be far, far slower. CPython without NumPy is about 60x slower than C on basic array math. Writing high-speed parallel number-crunching code that outperforms off the shelf libraries is typically non-trivial. If there's some easy way to make a simple operation like matrix multiply go faster, it's probably been done already. If you're really into this, look into the Unified Parallel C effort and its libraries. The supercomputer types spend their lives doing this sort of thing. John Nagle From nagle at animats.com Tue Jan 4 22:53:14 2011 From: nagle at animats.com (John Nagle) Date: Tue, 04 Jan 2011 19:53:14 -0800 Subject: Interrput a thread In-Reply-To: <68004bac-5d4d-40fa-afb7-6de45f3ea87a@v17g2000yqv.googlegroups.com> References: <81c24eb1-41b6-442a-a971-8a44d2cd6c1b@p8g2000vbs.googlegroups.com> <2ebc11a5-1b45-4faa-97b9-c84f0db015a4@k22g2000yqh.googlegroups.com> <68004bac-5d4d-40fa-afb7-6de45f3ea87a@v17g2000yqv.googlegroups.com> Message-ID: <4d23eb28$0$44049$742ec2ed@news.sonic.net> On 1/4/2011 6:11 PM, Adam Skutt wrote: > On Jan 4, 10:12 am, Fuzzyman wrote: >> >> This is a case that .NET (C#) handles better than Python or Java. >> > > Nope, read the documentation for Thread.Abort() carefully. > Thread.Abort() can cause termination inside a static constructor, > which is very bad. You sure your application can cope with that? > Mine can't. Thread.Abort() is only safe for self-abortion, app domain > termination and a few other very narrow and obscure scenarios. It is > not a safe way to end arbitrary threads doing arbitrary processing. > >> It's another place where people >> sometimes have a genuine need/use case yet people will insist on >> telling them they don't *really* want it... >> > > Because there's no safe way to do it. It's fundamentally a racy > operation, with the typical horrible consequences when you lose. > Removing the race requires support from the application, i.e., you > have to write the code yourself. Frequently, it's simply not possible > to remove the race. There are systems where there's support designed in for thread abort. LISP/Scheme systems tend to support it. QNX, the real-time OS, has well worked out thread-abort semantics at the C level. (QNX has really good features for "not getting stuck", like the ability to put a time limit on any system call.) But Python doesn't support things like that. What you'd really like in Python is the ability for one thread to be able to force an exception in another thread, plus a mechanism for locking out such exceptions for critical sections. It's not worth having, though, in a system where you can really only run one thread at a time. John Nagle From aahz at pythoncraft.com Tue Jan 4 23:40:15 2011 From: aahz at pythoncraft.com (Aahz) Date: 4 Jan 2011 20:40:15 -0800 Subject: Trying to decide between PHP and Python References: Message-ID: In article , Google Poster wrote: > >The syntax reminds me of Lots of Interspersed Silly Parentheses >(L.I.S.P.), but without the parentheses. You're not the first person to make that observation: http://norvig.com/python-lisp.html See also: http://norvig.com/python-iaq.html -- Aahz (aahz at pythoncraft.com) <*> http://www.pythoncraft.com/ "Think of it as evolution in action." --Tony Rand From aahz at pythoncraft.com Tue Jan 4 23:41:27 2011 From: aahz at pythoncraft.com (Aahz) Date: 4 Jan 2011 20:41:27 -0800 Subject: Trying to decide between PHP and Python References: <4D23A29D.7030104@yahoo.com> Message-ID: In article , Roy Smith wrote: >In article <4D23A29D.7030104 at yahoo.com>, Alan Meyer >wrote: >> On 1/4/2011 4:22 PM, Google Poster wrote: >>> >>> The syntax reminds me of Lots of Interspersed Silly Parentheses >>> (L.I.S.P.), but without the parentheses. >> >> I haven't heard that version before. The one I heard was: >> "Lots of Irritating Single Parentheses". > >Long Involved Stupid Parentheses. http://www.netfunny.com/rhf/jokes/90q2/lispcode.html -- Aahz (aahz at pythoncraft.com) <*> http://www.pythoncraft.com/ "Think of it as evolution in action." --Tony Rand From inyeol.lee at gmail.com Tue Jan 4 23:46:34 2011 From: inyeol.lee at gmail.com (Inyeol) Date: Tue, 4 Jan 2011 20:46:34 -0800 (PST) Subject: Which coding style is better? public API or private method inside class definition Message-ID: <0470dc9d-2a5f-40d4-afd4-97796059ba0a@q8g2000prm.googlegroups.com> For example: I'm writing simple class: class Numbers: def __init__(self, numbers): self._numbers = numbers def get_all(self): for number in self._numbers: yield number If I want to add another method for yielding even numbers only, I may use: def get_even(self): for numbers in self._numbers: if numbers % 2 == 0: yield number or, I can use public method 'get_all' instead of using private attribute '_numbers', like: def get_even(self): for numbers in self.get_all(): if numbers % 2 == 0: yield number Which coding style do you prefer? I'm more toward public API way, since it requires less code change if I refactor private data structure later. Plz give pros and cons of these. From inyeol.lee at gmail.com Tue Jan 4 23:52:00 2011 From: inyeol.lee at gmail.com (Inyeol) Date: Tue, 4 Jan 2011 20:52:00 -0800 (PST) Subject: Which coding style is better? public API or private method inside class definition References: <0470dc9d-2a5f-40d4-afd4-97796059ba0a@q8g2000prm.googlegroups.com> Message-ID: I found typo after posting: local name 'numbers' and 'number' are mixed. Plz don't report bug but focus on coding style only :-) From thaicares at gmail.com Wed Jan 5 00:22:58 2011 From: thaicares at gmail.com (Thai) Date: Tue, 4 Jan 2011 21:22:58 -0800 (PST) Subject: Just Starting in on programming Message-ID: <2c19b70f-917f-449c-9c6d-51f07cd769c5@glegroupsg2000goo.googlegroups.com> I was told this was good and some of the easier way to start programming. I'm just wondering if this statement is true and if so what is it I should do to really start getting in there and go ahead and start using some other languages. Thank you those who reply and help in advance Tyler Ryan Carroll From Joshua.R.English at gmail.com Wed Jan 5 00:31:52 2011 From: Joshua.R.English at gmail.com (Josh English) Date: Tue, 4 Jan 2011 21:31:52 -0800 (PST) Subject: Which coding style is better? public API or private method inside class definition In-Reply-To: <0470dc9d-2a5f-40d4-afd4-97796059ba0a@q8g2000prm.googlegroups.com> Message-ID: <801598ad-6bf9-4f62-a518-d5a469c0917d@glegroupsg2000goo.googlegroups.com> I think it depends on where you're willing to deal with changes. As it stands, if you make changes to get_all that will effect the way get_even works. If there's a logical chain that your code needs to follow and such changes would be acceptable, use them, because it's easier to change one thing once instead of one thing twice. In general, I try to code in a way that will reduce the number of places I'll have to change or refactor. Josh From ameyer2 at yahoo.com Wed Jan 5 00:57:37 2011 From: ameyer2 at yahoo.com (Alan Meyer) Date: Wed, 05 Jan 2011 00:57:37 -0500 Subject: Problem inserting an element where I want it using lxml Message-ID: <4D240851.4060802@yahoo.com> I'm having some trouble inserting elements where I want them using the lxml ElementTree (Python 2.6). I presume I'm making some wrong assumptions about how lxml works and I'm hoping someone can clue me in. I want to process an xml document as follows: For every occurrence of a particular element, no matter where it appears in the tree, I want to add a sibling to that element with the same name and a different value. Here's the smallest artificial example I've found so far demonstrates the problem: Add another bingo after this What I'd like to produce is this: Add another bingo after this Here's my program: -------- cut here ----- from lxml import etree as etree xml = """ Add another bingo after this """ tree = etree.fromstring(xml) # A list of all "bingo" element objects in the unmodified original xml # There's only one in this example elems = tree.xpath("//bingo") # For each one, insert a sibling after it bingoCounter = 0 for elem in elems: parent = elem.getparent() subIter = parent.iter() pos = 0 for subElem in subIter: # Is it one we want to create a sibling for? if subElem == elem: newElem = etree.Element("bingo") bingoCounter += 1 newElem.text = "New bingo %d" % bingoCounter newElem.tail = "\n" parent.insert(pos, newElem) break pos += 1 newXml = etree.tostring(tree) print("") print(newXml) -------- cut here ----- The output follows: -------- output ----- Add another bingo after this New bingo 1 -------- output ----- Setting aside the whitespace issues, the bug in the program shows up in the positioning of the insertion. I wanted and expected it to appear immediately after the original "bingo" element, and before the "bar" element, but it appeared after the "bar" instead of before it. Everything works if I take the "something" element out of the original input document. The new "bingo" appears before the "bar". But when I put it back in, the inserted bingo is out of order. Why should that be? What am I misunderstanding? Is there a more intelligent way to do what I'm trying to do? Thanks. Alan From kb1pkl at aim.com Wed Jan 5 01:07:01 2011 From: kb1pkl at aim.com (Corey Richardson) Date: Wed, 05 Jan 2011 01:07:01 -0500 Subject: Just Starting in on programming In-Reply-To: <2c19b70f-917f-449c-9c6d-51f07cd769c5@glegroupsg2000goo.googlegroups.com> References: <2c19b70f-917f-449c-9c6d-51f07cd769c5@glegroupsg2000goo.googlegroups.com> Message-ID: <4D240A85.5080702@aim.com> On 01/05/2011 12:22 AM, Thai wrote: > I was told this was good and some of the easier way to start >programming. I'm just wondering if this statement is true and if >so what is it I should do to really start getting in there and go >ahead and start using some other languages. > > Thank you those who reply and help in advance > Tyler Ryan Carrollhttp://docs.python.org/tutorial/ You were told what was good? Get started in where? If you're just learning to program, I found http://www.alan-g.me.uk/ was a very good resource, and I learned a lot. #python recommends http://www.greenteapress.com/thinkpython/html/index.html in the topic, and the Python tutorial at http://docs.python.org/tutorial/ is quality, you may learn quite a bit from it. If you have questions, I suggest you look into the tutor mailing list, tutor at python.org ~Corey Richardson From Joshua.R.English at gmail.com Wed Jan 5 01:16:14 2011 From: Joshua.R.English at gmail.com (Josh English) Date: Tue, 4 Jan 2011 22:16:14 -0800 (PST) Subject: Problem inserting an element where I want it using lxml In-Reply-To: <4D240851.4060802@yahoo.com> Message-ID: <106ef57e-6d86-4eef-959e-529453b8b026@glegroupsg2000goo.googlegroups.com> Here's a trimmed down version of how I did this (using ElementTree standalone, but the API should be the same) This is from a class definition and the _elem attribute is a link to an ElementTree.Element object. ... def _add_elem(self, tagName, text, attrib ={}): """_add_elem(tagName, text, attrib={}) Adds a child element in the appropriate place in the tree. Raises an IndexError if the checker does not allow an addition child of tagName. """ last_child = None for child in self._elem.findall('.//%s' % tagName): last_child = child if last_child is None: new_child = ET.SubElement(self._elem, tagName, attrib) else: new_child = ET.Element(tagName, attrib) self._elem.insert(self._elem._children.index(last_child)+1, new_child) new_child.text=str(text) return new_child I don't think you need to count the instances of the bingo node (unless you want to prevent too many from being added in). Josh From Joshua.R.English at gmail.com Wed Jan 5 01:17:42 2011 From: Joshua.R.English at gmail.com (Josh English) Date: Tue, 4 Jan 2011 22:17:42 -0800 (PST) Subject: Problem inserting an element where I want it using lxml In-Reply-To: <106ef57e-6d86-4eef-959e-529453b8b026@glegroupsg2000goo.googlegroups.com> Message-ID: <39b53121-1e38-4652-86ba-b53a631e3bc1@glegroupsg2000goo.googlegroups.com> Oh, and I usually use a separate function to indent my xml for readability when I need to actually look at the xml. It's easier than trying to change the element in situ and make it look nice. Josh From steve+comp.lang.python at pearwood.info Wed Jan 5 01:29:31 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 05 Jan 2011 06:29:31 GMT Subject: opinion: comp lang docs style References: <98e82f1b-cf59-4e64-8fd4-63671f96b04f@r19g2000prm.googlegroups.com> <4745479a-10c5-4281-9dcd-c9d7b013a1ec@k13g2000vbq.googlegroups.com> Message-ID: <4d240fca$0$29969$c3e8da3$5496439d@news.astraweb.com> On Tue, 04 Jan 2011 15:17:37 -0800, rurpy at yahoo.com wrote: >> If one wants to critique the 'Python Docs', especially as regards to >> usefulness to beginners, one must start with the Tutorial; and if one >> wants to use if statements as an example, one must start with the >> above. > > No. The language reference (LR) and standard library reference (SLR) > must stand on their own merits. It is nice to have a good tutorial for > those who like that style of learning. But it should be possible for a > programmer with a basic understanding of computers and some other > programming languages to understand how to program in python without > referring to tutorials, explanatory websites, commercially published > books, the source code, etc. No it shouldn't. That's what the tutorial is for. The language reference and standard library reference are there to be reference manuals, not to teach beginners Python. In any case, your assumption that any one documentation work should stand on its own merits is nonsense -- *nothing* stands alone. Everything builds on something else. Technical documentation is no different: it *must* assume some level of knowledge of its readers -- should it be aimed at Python experts, or average Python coders, or beginners, or beginners to programming, or at the very least is it allowed to assume that the reader already knows how to read? You can't satisfy all of these groups with one document, because their needs are different and in conflict. This is why you have different documentation -- tutorials and reference manuals and literate source code and help text are all aimed at different audiences. Expecting one document to be useful for all readers' needs is like expecting one data type to be useful for all programming tasks. Reasonable people might disagree on what a particular documentation work should target, and the best way to target it, but not on the need for different documentation for different targets. -- Steven From alice at gothcandy.com Wed Jan 5 02:23:31 2011 From: alice at gothcandy.com (=?utf-8?Q?Alice_Bevan=E2=80=93McGregor?=) Date: Tue, 4 Jan 2011 23:23:31 -0800 Subject: opinion: comp lang docs style References: <98e82f1b-cf59-4e64-8fd4-63671f96b04f@r19g2000prm.googlegroups.com> <4745479a-10c5-4281-9dcd-c9d7b013a1ec@k13g2000vbq.googlegroups.com> <4d240fca$0$29969$c3e8da3$5496439d@news.astraweb.com> Message-ID: On 2011-01-04 22:29:31 -0800, Steven D'Aprano said: > In any case, your assumption that any one documentation work should stand > on its own merits is nonsense -- *nothing* stands alone. +1 How many RFCs still in use today don't start with: > The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", > "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this > document are to be interpreted as described in RFC 2119 I posted a response on the article itself, rather than pollute a mailing list with replies to a troll. The name calling was a rather large hint as to the intention of the "opinion", either that or whoever translated the article (man or machine) was really angry at the time. ;) - Alice. From timr at probo.com Wed Jan 5 02:31:37 2011 From: timr at probo.com (Tim Roberts) Date: Tue, 04 Jan 2011 23:31:37 -0800 Subject: Matrix multiplication References: Message-ID: Zdenko wrote: > >Please, can anybody write me a simple recursive matrix multiplication >using multiple threads in Python, or at least show me some guidelines >how to write it myself Matrix multiplication is not generally done recursively. There's no conceptual gain. It makes more sense iteratively. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From stefan_ml at behnel.de Wed Jan 5 02:47:04 2011 From: stefan_ml at behnel.de (Stefan Behnel) Date: Wed, 05 Jan 2011 08:47:04 +0100 Subject: Problem inserting an element where I want it using lxml In-Reply-To: <4D240851.4060802@yahoo.com> References: <4D240851.4060802@yahoo.com> Message-ID: Alan Meyer, 05.01.2011 06:57: > I'm having some trouble inserting elements where I want them > using the lxml ElementTree (Python 2.6). I presume I'm making > some wrong assumptions about how lxml works and I'm hoping > someone can clue me in. > > I want to process an xml document as follows: > > For every occurrence of a particular element, no matter where it > appears in the tree, I want to add a sibling to that element with > the same name and a different value. > > Here's the smallest artificial example I've found so far > demonstrates the problem: > > > > > > Add another bingo after this > > > > What I'd like to produce is this: > > > > > > Add another bingo after this > > Looks trivial to me. ;) > Here's my program: > > -------- cut here ----- > from lxml import etree as etree > > xml = """ > > > > > Add another bingo after this > > > """ > > tree = etree.fromstring(xml) > > # A list of all "bingo" element objects in the unmodified original xml > # There's only one in this example > elems = tree.xpath("//bingo") > > # For each one, insert a sibling after it > bingoCounter = 0 > for elem in elems: > parent = elem.getparent() > subIter = parent.iter() ".iter()" gives you a recursive iterator that will also yield the "something" Element in your case, thus the incorrect counting. You only want the children, so you should iterate over the Element itself. > pos = 0 > for subElem in subIter: > # Is it one we want to create a sibling for? > if subElem == elem: There is an .index() method on Elements that does what you want to achieve here. However, the right way to do it is to use ".addnext()". http://codespeak.net/lxml/api/lxml.etree._Element-class.html Stefan From orasnita at gmail.com Wed Jan 5 02:48:40 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Wed, 5 Jan 2011 09:48:40 +0200 Subject: Trying to decide between PHP and Python References: <_MmdnZ36uOSlHr7QnZ2dnUVZ5uGdnZ2d@giganews.com> Message-ID: <00DCA6C991454D1A879B9F7BADDCEFCA@octavian> From: "Tomasz Rola" > On Tue, 4 Jan 2011, Dan M wrote: > >> As to choice between Python and PHP, I would say learn anything but PHP. >> Even Perl has fewer tentacles than PHP. > > However, the quality of code depends heavily on who writes it. My > impression is that more folks of "I did it and it works so it is good, > right?" attitude can be found among Perl/PHP crowd (compared to Python or > Ruby or...). The reason is probably the "easyness" of those languages > (mostly because of tons of readymade code on the net) which - wrongly - > suggests they are already "there", no need to learn anymore. Yes you are right. Perl is much flexible than all other languages and there was written a lot of bad code in the past that can now be found on the net, beeing very hard for a newbie to find only the good examples and tutorials. But Perl offers many helpful modules for testing the apps so for good programmers there is not true the idea of "it works so it's ok". Usually we compare the languages although we always think to all aditional modules and libraries we can use with them for creating apps. Thinking this way, Perl is better than Python for creating web apps, because Catalyst framework is more advanced than the frameworks for Python and it is more flexible even than Ruby on Rails, DBIx::Class ORM is a very advanced ORM and a very clean one and Perl web apps can use strong templating systems and form processors, unicode is a native code for Perl for a long time and so on. So how good is the language depends on what you need to use it for. (But I hope that this won't start a language war, because I have just done the same on a Perl mailing list telling about some Perl disadvantages towards Python :) Octavian From s.selvamsiva at gmail.com Wed Jan 5 04:28:31 2011 From: s.selvamsiva at gmail.com (Selvam) Date: Wed, 5 Jan 2011 14:58:31 +0530 Subject: Beautifulsoup html parsing - nested tags Message-ID: Hi all, I am trying to parse some html string with BeatifulSoup. The string is,

Tax

Base

Amount

rtables=soup.findAll(re.compile('table$')) The rtables is, [

Tax

Base

Amount

, ] The tr inside the blocktable are appearing inside the table, while blocktable contains nothing. Is there any way, I can get the tr in the right place (inside blocktable) ? -- Regards, S.Selvam SG E-ndicus Infotech Pvt Ltd. http://e-ndicus.com/ " I am because we are " -------------- next part -------------- An HTML attachment was scrubbed... URL: From s.selvamsiva at gmail.com Wed Jan 5 05:15:12 2011 From: s.selvamsiva at gmail.com (Selvam) Date: Wed, 5 Jan 2011 15:45:12 +0530 Subject: Beautifulsoup html parsing - nested tags In-Reply-To: References: Message-ID: On Wed, Jan 5, 2011 at 2:58 PM, Selvam wrote: > Hi all, > > I am trying to parse some html string with BeatifulSoup. > > The string is, > > > > > > > > > > > >
> >
>

Tax

>

Base

>

Amount

> > > rtables=soup.findAll(re.compile('table$')) > > The rtables is, > > [ > > > > > > >
> >
>

Tax

>

Base

>

Amount

, > ] > > > > The tr inside the blocktable are appearing inside the table, while > blocktable contains nothing. > > Is there any way, I can get the tr in the right place (inside blocktable) ? > > -- > Regards, > S.Selvam > SG E-ndicus Infotech Pvt Ltd. > http://e-ndicus.com/ > > " I am because we are " > Replying to myself, BeautifulSoup.BeautifulSoup.NESTABLE_TABLE_TAGS['tr'].append('blocktable') adding this, solved the issue. -- Regards, S.Selvam SG E-ndicus Infotech Pvt Ltd. http://e-ndicus.com/ " I am because we are " -------------- next part -------------- An HTML attachment was scrubbed... URL: From stackslip at gmail.com Wed Jan 5 05:19:59 2011 From: stackslip at gmail.com (Slie) Date: Wed, 5 Jan 2011 01:19:59 -0900 Subject: Graphing API, Message-ID: Is there a graphing API, someone suggests? From nitinpawar432 at gmail.com Wed Jan 5 05:22:31 2011 From: nitinpawar432 at gmail.com (Nitin Pawar) Date: Wed, 5 Jan 2011 15:52:31 +0530 Subject: Graphing API, In-Reply-To: References: Message-ID: you can check pywebgraph On Wed, Jan 5, 2011 at 3:49 PM, Slie wrote: > Is there a graphing API, someone suggests? > -- > http://mail.python.org/mailman/listinfo/python-list > -- Nitin Pawar -------------- next part -------------- An HTML attachment was scrubbed... URL: From flebber.crue at gmail.com Wed Jan 5 05:29:25 2011 From: flebber.crue at gmail.com (flebber) Date: Wed, 5 Jan 2011 02:29:25 -0800 (PST) Subject: Trying to decide between PHP and Python References: <_MmdnZ36uOSlHr7QnZ2dnUVZ5uGdnZ2d@giganews.com> Message-ID: On Jan 5, 6:48?pm, "Octavian Rasnita" wrote: > From: "Tomasz Rola" > > > On Tue, 4 Jan 2011, Dan M wrote: > > >> As to choice between Python and PHP, I would say learn anything but PHP. > >> Even Perl has fewer tentacles than PHP. > > > However, the quality of code depends heavily on who writes it. My > > impression is that more folks of "I did it and it works so it is good, > > right?" attitude can be found among Perl/PHP crowd (compared to Python or > > Ruby or...). The reason is probably the "easyness" of those languages > > (mostly because of tons of readymade code on the net) which - wrongly - > > suggests they are already "there", no need to learn anymore. > > Yes you are right. Perl is much flexible than all other languages and there > was written a lot of bad code in the past that can now be found on the net, > beeing very hard for a newbie to find only the good examples and tutorials. > > But Perl offers many helpful modules for testing the apps so for good > programmers there is not true the idea of "it works so it's ok". > > Usually we compare the languages although we always think to all aditional > modules and libraries we can use with them for creating apps. > Thinking this way, Perl is better than Python for creating web apps, because > Catalyst framework is more advanced than the frameworks for Python and it is > more flexible even than Ruby on Rails, DBIx::Class ORM is a very advanced > ORM and a very clean one and Perl web apps can use strong templating systems > and form processors, unicode is a native code for Perl for a long time and > so on. > > So how good is the language depends on what you need to use it for. > > (But I hope that this won't start a language war, because I have just done > the same on a Perl mailing list telling about some Perl disadvantages > towards Python :) > > Octavian My two cents, I am understanding python far better by learning scheme. Didn't intentionally set out to achieve that as a goal just a by product. An excelent resource http://htdp.org and using the racket scheme ide(as much of an ide as idle), simple thorough well explained concepts via worked examples and a very encouraging and enthusiastic mail group, much like this list. I would so love a book like that for python but after i complete htdp I may not need it. Regards Sayth From nobody at nowhere.com Wed Jan 5 05:44:19 2011 From: nobody at nowhere.com (Nobody) Date: Wed, 05 Jan 2011 10:44:19 +0000 Subject: Trying to decide between PHP and Python References: Message-ID: On Tue, 04 Jan 2011 12:20:42 -0800, Google Poster wrote: > The indentation-as-block is unique, Not at all. It's also used in occam, Miranda, Haskell and F#. From clp2 at rebertia.com Wed Jan 5 05:45:31 2011 From: clp2 at rebertia.com (Chris Rebert) Date: Wed, 5 Jan 2011 02:45:31 -0800 Subject: Graphing API, In-Reply-To: References: Message-ID: On Wed, Jan 5, 2011 at 2:19 AM, Slie wrote: > Is there a graphing API, someone suggests? matplotlib: http://matplotlib.sourceforge.net/ Cheers, Chris From ameyer2 at yahoo.com Wed Jan 5 06:20:22 2011 From: ameyer2 at yahoo.com (Alan Meyer) Date: Wed, 05 Jan 2011 06:20:22 -0500 Subject: Problem inserting an element where I want it using lxml In-Reply-To: References: <4D240851.4060802@yahoo.com> Message-ID: On 01/05/2011 02:47 AM, Stefan Behnel wrote: > ... > Looks trivial to me. ;) > ... > ".iter()" gives you a recursive iterator that will also yield the > "something" Element in your case, thus the incorrect counting. You only > want the children, so you should iterate over the Element itself. Thanks Stephan. I went home and went to sleep and woke up in the middle of the night and thought, wait a minute, iter() is giving me a depth first list of elements but insert() is indexing children of the parent. I think I must have been up too late. > There is an .index() method on Elements that does what you want to > achieve here. However, the right way to do it is to use ".addnext()". > > http://codespeak.net/lxml/api/lxml.etree._Element-class.html > > Stefan > Those are exactly the functions I wanted. I didn't see them (and still don't) in the Python ElementTree documentation and thought I had to use parent.insert(). Thanks again. From ameyer2 at yahoo.com Wed Jan 5 06:25:11 2011 From: ameyer2 at yahoo.com (Alan Meyer) Date: Wed, 05 Jan 2011 06:25:11 -0500 Subject: Problem inserting an element where I want it using lxml In-Reply-To: <106ef57e-6d86-4eef-959e-529453b8b026@glegroupsg2000goo.googlegroups.com> References: <106ef57e-6d86-4eef-959e-529453b8b026@glegroupsg2000goo.googlegroups.com> Message-ID: On 01/05/2011 01:16 AM, Josh English wrote: > Here's a trimmed down version of how I did this (using ElementTree standalone, but the API should be the same) > This is from a class definition and the _elem attribute is a link to an ElementTree.Element object. > > ... > def _add_elem(self, tagName, text, attrib ={}): > """_add_elem(tagName, text, attrib={}) > Adds a child element in the appropriate place in the tree. > Raises an IndexError if the checker does not allow an addition child of tagName. > """ > last_child = None > for child in self._elem.findall('.//%s' % tagName): > last_child = child > > if last_child is None: > new_child = ET.SubElement(self._elem, tagName, attrib) > else: > new_child = ET.Element(tagName, attrib) > self._elem.insert(self._elem._children.index(last_child)+1, new_child) > new_child.text=str(text) > > return new_child > > I don't think you need to count the instances of the bingo node (unless you want to prevent too many from being added in). > > Josh Thanks Josh. It looks like lxml adds some incredibly useful extensions to ElementTree that I will use. See Stephan's reply. Alan From alice at gothcandy.com Wed Jan 5 06:31:03 2011 From: alice at gothcandy.com (=?utf-8?Q?Alice_Bevan=E2=80=93McGregor?=) Date: Wed, 5 Jan 2011 03:31:03 -0800 Subject: Trying to decide between PHP and Python References: <4D2388AE.6090103@yahoo.com> Message-ID: On 2011-01-04 12:53:02 -0800, Alan Meyer said: > I confess that I haven't used PHP so someone correct me if I'm wrong. > [snip] +1 You're pretty much on the ball with your description. I might summarize it as: PHP (PHP: Hypertext Processor) is a templating language with a significant enough standard library for aspirations of general-purpose scripting. Python is a general-purpose scripting language with numerous templating languages, let alone the terrifyingly large standard library. ;) Yes, PHP has templating language syntaxes like Smarty, but you're running a template parser within another template parser... A fairly common sarcastic quote is: "You aren't a real Python programmer until you write your own [coroutine framework | web framework | templating language | ...]!" I've done all three, and this probably does not make me a good person. ;) The coroutine framework was a hack to see how they work through experimentation, but I'm quite proud of the web framework and templating system! :D - Alice. From pavlovevidence at gmail.com Wed Jan 5 06:37:46 2011 From: pavlovevidence at gmail.com (Carl Banks) Date: Wed, 5 Jan 2011 03:37:46 -0800 (PST) Subject: Which coding style is better? public API or private method inside class definition References: <0470dc9d-2a5f-40d4-afd4-97796059ba0a@q8g2000prm.googlegroups.com> Message-ID: On Jan 4, 8:46?pm, Inyeol wrote: > For example: I'm writing simple class: > > ? ? class Numbers: > ? ? ? ? def __init__(self, numbers): > ? ? ? ? ? ? self._numbers = numbers > ? ? ? ? def get_all(self): > ? ? ? ? ? ? for number in self._numbers: > ? ? ? ? ? ? ? ? yield number > > If I want to add another method for yielding even numbers only, I may > use: > > ? ? ? ? def get_even(self): > ? ? ? ? ? ? for numbers in self._numbers: > ? ? ? ? ? ? ? ? if numbers % 2 == 0: > ? ? ? ? ? ? ? ? ? ? yield number > > or, I can use public method 'get_all' instead of using private > attribute '_numbers', like: > > ? ? ? ? def get_even(self): > ? ? ? ? ? ? for numbers in self.get_all(): > ? ? ? ? ? ? ? ? if numbers % 2 == 0: > ? ? ? ? ? ? ? ? ? ? yield number > > Which coding style do you prefer? I'm more toward public API way, > since it requires less code change if I refactor private data > structure later. > Plz give pros and cons of these. Using Public API makes it easier to subclass, if you want to redefine the meaning of "all" somehow. The main reason to avoid Public API is to get performance benefits (most Python built-in classes access the internal structure directly for this reason). There are occasions where a function really needs to access the internals and not the "visible" value. Also, in Python it's reasonable to consider an instance variable to be part of the public interface of a class, because backwards- incompatible changes can be avoided using properties. Carl Banks From duncan.booth at invalid.invalid Wed Jan 5 07:43:09 2011 From: duncan.booth at invalid.invalid (Duncan Booth) Date: 5 Jan 2011 12:43:09 GMT Subject: Trying to decide between PHP and Python References: Message-ID: Nobody wrote: > On Tue, 04 Jan 2011 12:20:42 -0800, Google Poster wrote: > >> The indentation-as-block is unique, > > Not at all. It's also used in occam, Miranda, Haskell and F#. > Also Yaml. -- Duncan Booth http://kupuguy.blogspot.com From usernet at ilthio.net Wed Jan 5 08:32:45 2011 From: usernet at ilthio.net (Tim Harig) Date: Wed, 5 Jan 2011 13:32:45 +0000 (UTC) Subject: Graphing API, References: Message-ID: On 2011-01-05, Slie wrote: > Is there a graphing API, someone suggests? You should check the archives, variations of this question get asked a lot. I use GNUplot to do my graphing. I simply pipe it commands and data through the subprocess module; but, there are libraries available for interacting with it. Posts here also indicate that Google offers a web service based API for generating graphs. I have never actually used it; but, the documentation seems to be clear enough to get it working without too much trouble. From private at private.com Wed Jan 5 08:51:35 2011 From: private at private.com (ana sanchez) Date: Wed, 5 Jan 2011 13:51:35 +0000 (UTC) Subject: why generator assigned to slice? Message-ID: hi!!! i found this when i read the source of a program in python: self.__chunks[start:end] = (chunk for i in xrange(start, end)) and also this: self.__lines[line:line] = (None for i in xrange(count)) what utility has to assign a generator to a slice??? ?the *final result* isn't the same as this?: self.__chunks[start:end] = [chunk for i in xrange(start, end)] self.__chunks[line:line] = [None for i in xrange(count)] thanks!!! ana p.d. excuse my english From __peter__ at web.de Wed Jan 5 09:12:07 2011 From: __peter__ at web.de (Peter Otten) Date: Wed, 05 Jan 2011 15:12:07 +0100 Subject: why generator assigned to slice? References: Message-ID: ana sanchez wrote: > i found this when i read the source of a program in python: > > self.__chunks[start:end] = (chunk for i in xrange(start, end)) > what utility has to assign a generator to a slice??? ?the *final > result* isn't the same as this?: > > self.__chunks[start:end] = [chunk for i in xrange(start, end)] Whoever used the first variant probably was hoping that it was either faster or used less peak memory. I think the latter is wrong, and the former can easily be checked: $ python -m timeit -s'chunk = "yadda"; chunks = range(100); start = 20; end = 50' 'chunks[start:end] = (chunk for i in xrange(start, end))' 100000 loops, best of 3: 9.02 usec per loop $ python -m timeit -s'chunk = "yadda"; chunks = range(100); start = 20; end = 50' 'chunks[start:end] = [chunk for i in xrange(start, end)]' 100000 loops, best of 3: 4.16 usec per loop $ python -m timeit -s'chunk = "yadda"; chunks = range(100); start = 20; end = 50' 'chunks[start:end] = [chunk]*(end-start)' 1000000 loops, best of 3: 1.02 usec per loop From tinauser at libero.it Wed Jan 5 10:07:58 2011 From: tinauser at libero.it (tinauser) Date: Wed, 5 Jan 2011 07:07:58 -0800 (PST) Subject: dictionary as attribute of a class... Message-ID: Hallo list, here again I have a problem whose solution might be very obvious, but I really cannot see it: I have a class having as attribute a dictionary whose keys are names and values are instance of another class. This second class has in turn as an attribute a dictionary. I want a function of the first class that can change value of one of the second class instance's dictionary. however I cannot do it without modifying this attribute for ALL the instance of the second class contained in the first class' dictionary. What I'm doing wrong? the code: ############### ###can i change a dictionary attribute of an instantated object without affectin all the instances of that object? class mistClass(): def __init__(self,name,cDict={}): print 'mistClass ',name,' Init' self._name=name self._cDict=cDict def setName(self,n): self._name=n def getName(self): return self._name ## def setDict(self,one,two): ## self._cDict['one']=one ## self._cDict['two']=two def setDict(self,listK,listV): assert len(listK)==len(listV) for k,v in zip(listK,listV): self._cDict[k]=v def getDict(self): return self._cDict class mistClassContainer(): def __init__(self,name,dict_of_mistclass={}): print 'init mistClassContainer ',name self._name=name self._DOM=dict_of_mistclass def add_mistclass(self,mc): for el in mc: self._DOM[el]=mistClass(el) ## def mod_mistclasscDict(self,mc,one,two): ## self._DOM[mc].setDict(one,two) def mod_mistclasscDict(self,mc,lK,lV): self._DOM[mc].setDict(lK,lV) a=mistClassContainer('firsmistclasscontainer') a.add_mistclass(['mc1','mc2','mc3','mc4','mc5','mc6']) print 'before modification' for el in a._DOM.iterkeys(): print a._DOM[el].getDict() print a._DOM[el].getName() a.mod_mistclasscDict('mc1',['one','two'],['modone','modtwo']) print 'after modification' for el in a._DOM.iterkeys(): print a._DOM[el].getDict() print a._DOM[el].getName() b=mistClass('mc7') print b.getDict() print b.getName() b.setName('modified name') b.getName() for el in a._DOM.iterkeys(): print a._DOM[el].getName() From jeanmichel at sequans.com Wed Jan 5 10:18:22 2011 From: jeanmichel at sequans.com (Jean-Michel Pichavant) Date: Wed, 05 Jan 2011 16:18:22 +0100 Subject: Which coding style is better? public API or private method inside class definition In-Reply-To: <0470dc9d-2a5f-40d4-afd4-97796059ba0a@q8g2000prm.googlegroups.com> References: <0470dc9d-2a5f-40d4-afd4-97796059ba0a@q8g2000prm.googlegroups.com> Message-ID: <4D248BBE.6030102@sequans.com> Inyeol wrote: > For example: I'm writing simple class: > > class Numbers: > def __init__(self, numbers): > self._numbers = numbers > def get_all(self): > for number in self._numbers: > yield number > > If I want to add another method for yielding even numbers only, I may > use: > > def get_even(self): > for numbers in self._numbers: > if numbers % 2 == 0: > yield number > > or, I can use public method 'get_all' instead of using private > attribute '_numbers', like: > > def get_even(self): > for numbers in self.get_all(): > if numbers % 2 == 0: > yield number > > Which coding style do you prefer? I'm more toward public API way, > since it requires less code change if I refactor private data > structure later. > Plz give pros and cons of these. > - Unless you already know that you'll need to refactor the structure later, there's no need to anticipate => unnecessary optimization - Using public API deos not necessarily make refactoring easier. Let me explain, public APIs are meant to be called by external objects. These APIs may need to do some things that internal computing doesn't. For instance, let's say you add a logging statement in the get_all() method. Every call triggers a log entry. Does the get_even method want to log this call ? Maybe not. In that particular case, using the internal strucutre is preferable. - If you agree to the statement that readability > edition, then you should care more about writing clean and concise code, than refactorable ( :D ) code. Using self._numbers raises less questions to the reader. Though I admit that question raised by get_all are answered in 5 seconds (the question being 'If he used an method instead of _numbers, this method must do something special') - In fine, it doesn't really matter in the example you gave above. JM From rtomek at ceti.com.pl Wed Jan 5 10:21:05 2011 From: rtomek at ceti.com.pl (Tomasz Rola) Date: Wed, 5 Jan 2011 16:21:05 +0100 Subject: Trying to decide between PHP and Python In-Reply-To: References: <_MmdnZ36uOSlHr7QnZ2dnUVZ5uGdnZ2d@giganews.com> Message-ID: On Wed, 5 Jan 2011, flebber wrote: > My two cents, I am understanding python far better by learning scheme. > Didn't intentionally set out to achieve that as a goal just a by > product. An excelent resource http://htdp.org and using the racket > scheme ide(as much of an ide as idle), simple thorough well explained > concepts via worked examples and a very encouraging and enthusiastic > mail group, much like this list. > > I would so love a book like that for python but after i complete htdp > I may not need it. Agreed. I freezed my Racket usage while it was called DrScheme but I keep my eye on it ever since. It is really nice and well designed environment. It took me by a storm, which I cannot say about Idle ;-) . I also agree that every Python programmer could gain something valuable by at least trying it, as well as reading their docs and mailing list for a while. Or every programmer regardless of his/her current language. HTDP is interesting book, pity I couldn't read it when it might have made a bigger difference to my development. Regards, Tomasz Rola -- ** A C programmer asked whether computer had Buddha's nature. ** ** As the answer, master did "rm -rif" on the programmer's home ** ** directory. And then the C programmer became enlightened... ** ** ** ** Tomasz Rola mailto:tomasz_rola at bigfoot.com ** From invalid at invalid.invalid Wed Jan 5 10:30:23 2011 From: invalid at invalid.invalid (Grant Edwards) Date: Wed, 5 Jan 2011 15:30:23 +0000 (UTC) Subject: Trying to decide between PHP and Python References: <4D23A29D.7030104@yahoo.com> Message-ID: On 2011-01-05, Tomasz Rola wrote: > On Tue, 4 Jan 2011, Roy Smith wrote: >> Alan Meyer wrote: >>> On 1/4/2011 4:22 PM, Google Poster wrote: >>> >>>> The syntax reminds me of Lots of Interspersed Silly Parentheses >>>> (L.I.S.P.), but without the parentheses. >>> >>> I haven't heard that version before. The one I heard was: >>> >>> "Lots of Irritating Single Parentheses". >> >> Long Involved Stupid Parentheses. > > Heh. One day, guys, when you have nothing better to do, try writing a > parser for Lisp-like language (Common Lisp, Scheme, whatever). After that, > do the same with some other language of your preference (Python, Java, > whatever). Compare time and code spent... I've heard that justification many times, but I think it's 200% specious. 1) How often is a compiler for language X written? 2) How often is source code written in language X? 3) How often is that source code in language X read/modified? If you compare those numbers you'll realize that optimizing for case 1 at the expense of cases 2 & 3 is just plain stupid. Perhaps there is somebody on the planet who finds Lisp as easy to read/modify as Python, but I've never met him/her and never have you... Optimizing a language for the ease of the compiler writer is like saying, sure, that car is expensive to buy, expensive to run, doesn't work well, and tends to kill a lot of people, but it took less time to design! -- Grant Edwards grant.b.edwards Yow! I know things about at TROY DONAHUE that can't gmail.com even be PRINTED!! From benjamin.kaplan at case.edu Wed Jan 5 10:31:25 2011 From: benjamin.kaplan at case.edu (Benjamin Kaplan) Date: Wed, 5 Jan 2011 10:31:25 -0500 Subject: dictionary as attribute of a class... In-Reply-To: References: Message-ID: On Wed, Jan 5, 2011 at 10:07 AM, tinauser wrote: > Hallo list, > here again I have a problem whose solution might be very obvious, but > I really cannot see it: > I have a class having as attribute a dictionary whose keys are names > and values are instance of another class. > This second class has in turn as an attribute a dictionary. > I want a function of the first class that can change value of one of > the second class instance's dictionary. > however I cannot do it without modifying this attribute for ALL the > instance of the second class contained in the first class' dictionary. > What I'm doing wrong? > This is one of the biggest gotchas in Python. Default arguments are only evaluated *once*, when the function/method is declared. Not every time the function is called. Every instance of mistClass that didn't specify a separate cDict gets the same object as its cDict. The solution is to use a sentinel value (either None or a single object and use an "is" comparison) and create a new dict in the constructor if the default argument is still the sentinel. > class mistClass(): > ? ?def __init__(self,name,cDict={}): > ? ? ? ?print 'mistClass ',name,' Init' > ? ? ? ?self._name=name > ? ? ? ?self._cDict=cDict > should be changed to sentinel = object() class mistClass : def __init__(self, name, cDict=sentinel) : print 'mistClass ',name,' Init' self._name=name if cDict is not sentinel : self._cDict=cDict else : self._cDict = {} > class mistClassContainer(): > ? ?def __init__(self,name,dict_of_mistclass={}): > ? ? ? ?print 'init mistClassContainer ',name > ? ? ? ?self._name=name > ? ? ? ?self._DOM=dict_of_mistclass > and do the same thing with this one. From __peter__ at web.de Wed Jan 5 10:34:34 2011 From: __peter__ at web.de (Peter Otten) Date: Wed, 05 Jan 2011 16:34:34 +0100 Subject: dictionary as attribute of a class... References: Message-ID: tinauser wrote: > Hallo list, > here again I have a problem whose solution might be very obvious, but > I really cannot see it: > I have a class having as attribute a dictionary whose keys are names > and values are instance of another class. > This second class has in turn as an attribute a dictionary. > I want a function of the first class that can change value of one of > the second class instance's dictionary. > however I cannot do it without modifying this attribute for ALL the > instance of the second class contained in the first class' dictionary. > What I'm doing wrong? > > the code: > > ############### > ###can i change a dictionary attribute of an instantated object > without affectin all the instances of that object? > > class mistClass(): > def __init__(self,name,cDict={}): When you don't provide a cDict argument the default is used which is the same for every instance. Change the above to def __init__(self, name, cDict=None): if cDict is None: cDict = {} > class mistClassContainer(): > def __init__(self,name,dict_of_mistclass={}): Same here. > def setName(self,n): > self._name=n > > def getName(self): > return self._name Python has properties, so you don't need this just-in-case getter/setter nonsense. > for k,v in zip(listK,listV): > self._cDict[k]=v Make that self._cDict.update(zip(listK, listV)) By the way, not everyone loves Hungarian notation... From tinauser at libero.it Wed Jan 5 10:44:16 2011 From: tinauser at libero.it (tinauser) Date: Wed, 5 Jan 2011 07:44:16 -0800 (PST) Subject: dictionary as attribute of a class... References: Message-ID: On Jan 5, 4:34?pm, Peter Otten <__pete... at web.de> wrote: > tinauser wrote: > > Hallo list, > > here again I have a problem whose solution might be very obvious, but > > I really cannot see it: > > I have a class having as attribute a dictionary whose keys are names > > and values are instance of another class. > > This second class has in turn as an attribute a dictionary. > > I want a function of the first class that can change value of one of > > the second class instance's dictionary. > > however I cannot do it without modifying this attribute for ALL the > > instance of the second class contained in the first class' dictionary. > > What I'm doing wrong? > > > the code: > > > ############### > > ###can i change a dictionary attribute of an instantated object > > without affectin all the instances of that object? > > > class mistClass(): > > ? ? def __init__(self,name,cDict={}): > > When you don't provide a cDict argument the default is used which is the > same for every instance. Change the above to > > def __init__(self, name, cDict=None): > ? ? if cDict is None: > ? ? ? ? cDict = {} > > > class mistClassContainer(): > > ? ? def __init__(self,name,dict_of_mistclass={}): > > Same here. > > > ? ? def setName(self,n): > > ? ? ? ? self._name=n > > > ? ? def getName(self): > > ? ? ? ? return self._name > > Python has properties, so you don't need this just-in-case getter/setter > nonsense. > > > ? ? ? ? for k,v in zip(listK,listV): > > ? ? ? ? ? ? self._cDict[k]=v > > Make that > > self._cDict.update(zip(listK, listV)) > > By the way, not everyone loves Hungarian notation... Thanks both for the reply, I'll take some time to digest so to avoid further error in the future.Thanks again. From neilc at norwich.edu Wed Jan 5 11:15:15 2011 From: neilc at norwich.edu (Neil Cerutti) Date: 5 Jan 2011 16:15:15 GMT Subject: Trying to decide between PHP and Python References: <4D23A29D.7030104@yahoo.com> Message-ID: <8ojjojFdloU1@mid.individual.net> On 2011-01-05, Grant Edwards wrote: > Optimizing a language for the ease of the compiler writer is > like saying, sure, that car is expensive to buy, expensive to > run, doesn't work well, and tends to kill a lot of people, but > it took less time to design! A simple to parse syntax has non-trivial benefits. It makes a macro system feasible. -- Neil Cerutti From neilc at norwich.edu Wed Jan 5 11:26:14 2011 From: neilc at norwich.edu (Neil Cerutti) Date: 5 Jan 2011 16:26:14 GMT Subject: Which coding style is better? public API or private method inside class definition References: <0470dc9d-2a5f-40d4-afd4-97796059ba0a@q8g2000prm.googlegroups.com> Message-ID: <8ojkd6FdloU2@mid.individual.net> On 2011-01-05, Inyeol wrote: > For example: I'm writing simple class: > > class Numbers: > def __init__(self, numbers): > self._numbers = numbers > def get_all(self): > for number in self._numbers: > yield number > > If I want to add another method for yielding even numbers only, > I may use: > > def get_even(self): > for numbers in self._numbers: > if numbers % 2 == 0: > yield number > > or, I can use public method 'get_all' instead of using private > attribute '_numbers', like: > > def get_even(self): > for numbers in self.get_all(): > if numbers % 2 == 0: > yield number > > Which coding style do you prefer? I'm more toward public API > way, since it requires less code change if I refactor private > data structure later. Plz give pros and cons of these. Decoupling a member function from its own internal state would be of little benefit. However, decoupling an interface from its implementation can be a good idea. Python provides inheritance and the NotImplmented exception to help with that. Duck-typing is another popular approach. -- Neil Cerutti From eric.frederich at gmail.com Wed Jan 5 11:27:02 2011 From: eric.frederich at gmail.com (Eric Frederich) Date: Wed, 5 Jan 2011 11:27:02 -0500 Subject: Creating custom Python objects from C code Message-ID: I have read through all the documentation here: http://docs.python.org/extending/newtypes.html I have not seen any documentation anywhere else explaining how to create custom defined objects from C. I have this need to create custom objects from C and pass them as arguments to a function call. Question 1: how am I to create those objects from C code? The other thing I would like to know is how I can create helper functions in my extension so they can be created and manipulated easily. I am thinking along the lines of the built-in helper functions PyList_New and PyList_Append. Once I have an answer to question 1, the problem won't be creating the helper functions, but making them available from something built with distutils. To use the builtin python functions from C I need to link against python27.lib but when I create my own package using distutils it creates dll or pyd files. Question 2: How do I make C helper functions that are part of my extension available to other C projects in the same way that PyList_*, PyString_*, PyInt_* functions are available? Is it possible to have distutils make a .lib file for me? Thanks, ~Eric From rtomek at ceti.com.pl Wed Jan 5 11:36:29 2011 From: rtomek at ceti.com.pl (Tomasz Rola) Date: Wed, 5 Jan 2011 17:36:29 +0100 Subject: Trying to decide between PHP and Python In-Reply-To: References: <4D23A29D.7030104@yahoo.com> Message-ID: On Wed, 5 Jan 2011, Grant Edwards wrote: > On 2011-01-05, Tomasz Rola wrote: > > On Tue, 4 Jan 2011, Roy Smith wrote: > >> Alan Meyer wrote: > >>> On 1/4/2011 4:22 PM, Google Poster wrote: > >>> > >>>> The syntax reminds me of Lots of Interspersed Silly Parentheses > >>>> (L.I.S.P.), but without the parentheses. > >>> > >>> I haven't heard that version before. The one I heard was: > >>> > >>> "Lots of Irritating Single Parentheses". > >> > >> Long Involved Stupid Parentheses. > > > > Heh. One day, guys, when you have nothing better to do, try writing a > > parser for Lisp-like language (Common Lisp, Scheme, whatever). After that, > > do the same with some other language of your preference (Python, Java, > > whatever). Compare time and code spent... > > I've heard that justification many times, but I think it's 200% > specious. > > 1) How often is a compiler for language X written? > > 2) How often is source code written in language X? > > 3) How often is that source code in language X read/modified? > > If you compare those numbers you'll realize that optimizing for case 1 > at the expense of cases 2 & 3 is just plain stupid. You are right here. OTOH, a parser or even a compiler are just nice examples of non-trivial code. IMHO, the more non-trivial task one is trying to perform with a language, the more one appreciates language features that seem nonsense for less trivial programs. While in theory one can do the same job with a shovel and an excavator, in practice one should use the right tool depending on the job. Trying to get a car from a snowdrift with excavator requires a lot of attention and caution. It is easy (even if tiring) task for a man with a shovel. So one could extrapolate from this, that using excavator is ridiculous compared to using shovel. However, building dams or digging mile-long trenches with a shovel is not only ridicule but a sign of bad planning or desperation. And maybe even an incompetence. Now, how often they are building dams, trenches and other nontrivial constructions? I would hypothesise that in a society well developed, this happens quite often. Maybe even once every two days. The truth is, once you have an excavator, you don't shy away from using it and you more often than not are open for doing non-trivial assignments. > Perhaps there is > somebody on the planet who finds Lisp as easy to read/modify as > Python, but I've never met him/her and never have you... Here you are wrong. I meet the guy every day in a mirror. Now you have met him, too. I doubt, however, that I am so extraordinary as to be just one on the whole planet. > Optimizing a language for the ease of the compiler writer is like > saying, sure, that car is expensive to buy, expensive to run, doesn't > work well, and tends to kill a lot of people, but it took less time to > design! I guess every compiled language designed so far has been somewhat optimised for compilation by it's designers. If you say that some language, like Common Lisp, had been optimised for compiler at the expense of human programmer, I disagree. I find programing in CL to be nice experience, maybe even a refreshing one. From what I have read about Lisp history so far, your claims don't match the facts (at least facts as I know them). True, it requires some learning. AFAIK, nobody has to learn, so it is purely voluntary effort. Regards, Tomasz Rola -- ** A C programmer asked whether computer had Buddha's nature. ** ** As the answer, master did "rm -rif" on the programmer's home ** ** directory. And then the C programmer became enlightened... ** ** ** ** Tomasz Rola mailto:tomasz_rola at bigfoot.com ** From solipsis at pitrou.net Wed Jan 5 11:39:00 2011 From: solipsis at pitrou.net (Antoine Pitrou) Date: Wed, 5 Jan 2011 17:39:00 +0100 Subject: Creating custom Python objects from C code References: Message-ID: <20110105173900.4bad877b@pitrou.net> On Wed, 5 Jan 2011 11:27:02 -0500 Eric Frederich wrote: > I have read through all the documentation here: > > http://docs.python.org/extending/newtypes.html > > I have not seen any documentation anywhere else explaining how to > create custom defined objects from C. > I have this need to create custom objects from C and pass them as > arguments to a function call. What do you mean? Create instances of a type defined in Python code? The C API is not very different from Python-land. When you want to instantiate a type, just call that type (as a PyObject pointer) with the right arguments (using PyObject_Call() and friends). Whether that type has been defined in C or in Python does not make a difference. > Question 2: How do I make C helper functions that are part of my > extension available to other C projects in the same way that PyList_*, > PyString_*, PyInt_* functions are available? > Is it possible to have distutils make a .lib file for me? I don't know. I'd say "probably" :S Otherwise you can use the PyCapsule system, but that seems quite a bit more involved: http://docs.python.org/c-api/capsule.html Regards Antoine. From rtomek at ceti.com.pl Wed Jan 5 11:40:23 2011 From: rtomek at ceti.com.pl (Tomasz Rola) Date: Wed, 5 Jan 2011 17:40:23 +0100 Subject: Trying to decide between PHP and Python In-Reply-To: References: <4D23A29D.7030104@yahoo.com> Message-ID: On Tue, 4 Jan 2011, Roy Smith wrote: > There. Now that I've tossed some gasoline on the language wars fire, > I'll duck and run in the other direction :-) May I suggest a better strategy? Run first, duck next :-). Regards, Tomasz Rola -- ** A C programmer asked whether computer had Buddha's nature. ** ** As the answer, master did "rm -rif" on the programmer's home ** ** directory. And then the C programmer became enlightened... ** ** ** ** Tomasz Rola mailto:tomasz_rola at bigfoot.com ** From default at tlen.pl Wed Jan 5 11:59:06 2011 From: default at tlen.pl (Jacek Krysztofik) Date: Wed, 05 Jan 2011 17:59:06 +0100 Subject: Which coding style is better? public API or private method inside class definition In-Reply-To: <0470dc9d-2a5f-40d4-afd4-97796059ba0a@q8g2000prm.googlegroups.com> References: <0470dc9d-2a5f-40d4-afd4-97796059ba0a@q8g2000prm.googlegroups.com> Message-ID: -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 Sorry for OT, but this is actually a question of mine > if numbers % 2 == 0: wouldn't the following be faster? > if numbers & 1 == 0: JK -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iF4EAREIAAYFAk0ko1oACgkQfD3PECtxdkWzPAD+LD32NzjjDm8gb8qVFydIT693 ORuhRaYZOriaf+36/yMBAIREiarQAJ2ZYX8NPyHS2ns22PkEEEAkC98OYf1CkhwK =tg7G -----END PGP SIGNATURE----- From passionate_programmer at hotmail.com Wed Jan 5 12:11:17 2011 From: passionate_programmer at hotmail.com (Rohit Coder) Date: Wed, 5 Jan 2011 22:41:17 +0530 Subject: Qt with PyDev In-Reply-To: <4D233841.9080909@islandtraining.com> References: , <4D233841.9080909@islandtraining.com> Message-ID: Seen both, but do I need to install the binaries or add a link in Pydev to PySide source-code? Date: Tue, 4 Jan 2011 07:09:53 -0800 From: gherron at islandtraining.com To: python-list at python.org Subject: Re: Qt with PyDev On 01/04/2011 12:00 AM, RP Khare wrote: I installed Aptana PyDev plugin to Aptana Studio 3 Beta. I want to write my first GUI application using Python and I want to use Qt for it. How to integrate Qt into PyDev, or is there any other alternative IDE to work with Qt? element Font font-family font-size font-style font-variant font-weight letter-spacing line-height text-decoration text-align text-indent text-transform white-space word-spacing color Background bg-attachment bg-color bg-image bg-position bg-repeat Box width height border-top border-right border-bottom border-left margin padding max-height min-height max-width min-width outline-color outline-style outline-width Positioning position top bottom right left float display clear z-index List list-style-image list-style-type list-style-position Table vertical-align border-collapse border-spacing caption-side empty-cells table-layout Effects text-shadow -webkit-box-shadow border-radius Other overflow cursor visibility ........... Rohit See either of these packages: PyQt: http://qt.nokia.com/products/ PySide: http://www.pyside.org/ Either one should work with PyDev. Gary Herron -- http://mail.python.org/mailman/listinfo/python-list -------------- next part -------------- An HTML attachment was scrubbed... URL: From __peter__ at web.de Wed Jan 5 12:15:31 2011 From: __peter__ at web.de (Peter Otten) Date: Wed, 05 Jan 2011 18:15:31 +0100 Subject: Which coding style is better? public API or private method inside class definition References: <0470dc9d-2a5f-40d4-afd4-97796059ba0a@q8g2000prm.googlegroups.com> Message-ID: Jacek Krysztofik wrote: > Sorry for OT, but this is actually a question of mine >> if numbers % 2 == 0: > wouldn't the following be faster? >> if numbers & 1 == 0: You can answer that and similar questions yourself with the timeit module: $ python -m timeit -s'm, n = 1234, 1235' 'm % 2 == 0; n % 2 == 0' 1000000 loops, best of 3: 0.377 usec per loop $ python -m timeit -s'm, n = 1234, 1235' 'm & 1 == 0; n & 1 == 0' 1000000 loops, best of 3: 0.298 usec per loop So yes, a binary and seems to be faster. From python at mrabarnett.plus.com Wed Jan 5 12:26:05 2011 From: python at mrabarnett.plus.com (MRAB) Date: Wed, 05 Jan 2011 17:26:05 +0000 Subject: Trying to decide between PHP and Python In-Reply-To: References: Message-ID: <4D24A9AD.5030003@mrabarnett.plus.com> On 05/01/2011 10:44, Nobody wrote: > On Tue, 04 Jan 2011 12:20:42 -0800, Google Poster wrote: > >> The indentation-as-block is unique, > > Not at all. It's also used in occam, Miranda, Haskell and F#. > Don't forget about ABC. From benjamin.kaplan at case.edu Wed Jan 5 12:27:05 2011 From: benjamin.kaplan at case.edu (Benjamin Kaplan) Date: Wed, 5 Jan 2011 12:27:05 -0500 Subject: Qt with PyDev In-Reply-To: References: <4D233841.9080909@islandtraining.com> Message-ID: On Jan 5, 2011 12:15 PM, "Rohit Coder" wrote: > > Seen both, but do I need to install the binaries or add a link in Pydev to PySide source-code? > You need to install the binaries. Doing that will put the pyside libraries in a location where Python and Pydev can find them automatically. > ________________________________ > Date: Tue, 4 Jan 2011 07:09:53 -0800 > From: gherron at islandtraining.com > To: python-list at python.org > Subject: Re: Qt with PyDev > > > On 01/04/2011 12:00 AM, RP Khare wrote: >> >> I installed Aptana PyDev plugin to Aptana Studio 3 Beta. I want to write my first GUI application using Python and I want to use Qt for it. How to integrate Qt into PyDev, or is there any other alternative IDE to work with Qt? >> element >> Font >> font-family >> font-size >> font-style >> font-variant >> font-weight >> letter-spacing >> line-height >> text-decoration >> text-align >> text-indent >> text-transform >> white-space >> word-spacing >> color >> Background >> bg-attachment >> bg-color >> bg-image >> bg-position >> bg-repeat >> Box >> width >> height >> border-top >> border-right >> border-bottom >> border-left >> margin >> padding >> max-height >> min-height >> max-width >> min-width >> outline-color >> outline-style >> outline-width >> Positioning >> position >> top >> bottom >> right >> left >> float >> display >> clear >> z-index >> List >> list-style-image >> list-style-type >> list-style-position >> Table >> vertical-align >> border-collapse >> border-spacing >> caption-side >> empty-cells >> table-layout >> Effects >> text-shadow >> -webkit-box-shadow >> border-radius >> Other >> overflow >> cursor >> visibility >> >> ........... >> Rohit > > > See either of these packages: > PyQt: http://qt.nokia.com/products/ > PySide: http://www.pyside.org/ > > Either one should work with PyDev. > > Gary Herron > > > > -- http://mail.python.org/mailman/listinfo/python-list > > -- > http://mail.python.org/mailman/listinfo/python-list > -------------- next part -------------- An HTML attachment was scrubbed... URL: From no.email at nospam.invalid Wed Jan 5 12:44:40 2011 From: no.email at nospam.invalid (Paul Rubin) Date: Wed, 05 Jan 2011 09:44:40 -0800 Subject: Which coding style is better? public API or private method inside class definition References: <0470dc9d-2a5f-40d4-afd4-97796059ba0a@q8g2000prm.googlegroups.com> Message-ID: <7xy66zz1mf.fsf@ruckus.brouhaha.com> Inyeol writes: > def get_all(self): > for number in self._numbers: > yield number I think def get_all(self): return iter(self._numbers) is more direct. From nambo4jb at gmail.com Wed Jan 5 12:57:15 2011 From: nambo4jb at gmail.com (Cathy James) Date: Wed, 5 Jan 2011 11:57:15 -0600 Subject: Help with code-lists and strings Message-ID: Dear all, You folks will probably hear from me more often in the next few months. I hope some of you have time help me on occassion. Actually, a volunteer mentor would be greatly appreciated:) I am learning python and came across an excercise where i need to use lists to strip words from a sentence; starting with those containing one or more uppercase letters, followed by words with lower case letters. When I try, i get words in the order they were written:(* *I tried if statements, but unsuccessful. This has to be very easy to you experts, but I am clueless ( still rocket science to me) :( #Below is my shot at it: s=input("Write a sentence: ") list=s.strip().split() for word in list: list2 = (word.isupper() or word.istitle()) print (word) else print (word) -------------- next part -------------- An HTML attachment was scrubbed... URL: From miki.tebeka at gmail.com Wed Jan 5 13:15:05 2011 From: miki.tebeka at gmail.com (Miki) Date: Wed, 5 Jan 2011 10:15:05 -0800 (PST) Subject: Just Starting in on programming In-Reply-To: <2c19b70f-917f-449c-9c6d-51f07cd769c5@glegroupsg2000goo.googlegroups.com> Message-ID: <5bb4e2a8-2294-42bc-87ef-b2eb31908dc1@glegroupsg2000goo.googlegroups.com> http://www.openbookproject.net/thinkCSpy/ ? From Rob.Richardson at rad-con.com Wed Jan 5 13:20:39 2011 From: Rob.Richardson at rad-con.com (Rob Richardson) Date: Wed, 5 Jan 2011 13:20:39 -0500 Subject: Help with code-lists and strings In-Reply-To: Message-ID: <04A6DB42D2BA534FAC77B90562A6A03D01689A2B@server.rad-con.local> You take a sentence and break it up into words, storing it in a list named "list". Then, for each word in the list, you set list2 to a boolean value of true or false, depending on the result of isupper() and istitle(). Note that the variable "list2" does not refer to a list. It refers to whatever the result of the "or" operation is. Finally, you print out the word from the original, unordered list. You never do anything at all with list2. At least, that what I think is happening, but I am by no means a Python expert. Here's a suggestion: Try writing out what you want to do in plain English, but formatted sort of like a Python script would be. (This is generally called "pseudocode". It looks like a computer language, but it isn't.) Once you've got that, use it as a framework to write your Python code. Good luck! RobR ________________________________ From: python-list-bounces+rob.richardson=rad-con.com at python.org [mailto:python-list-bounces+rob.richardson=rad-con.com at python.org] On Behalf Of Cathy James Sent: Wednesday, January 05, 2011 12:57 PM To: python-list at python.org Subject: Help with code-lists and strings Dear all, You folks will probably hear from me more often in the next few months. I hope some of you have time help me on occassion. Actually, a volunteer mentor would be greatly appreciated:) I am learning python and came across an excercise where i need to use lists to strip words from a sentence; starting with those containing one or more uppercase letters, followed by words with lower case letters. When I try, i get words in the order they were written:( I tried if statements, but unsuccessful. This has to be very easy to you experts, but I am clueless ( still rocket science to me) :( #Below is my shot at it: s=input("Write a sentence: ") list=s.strip().split() for word in list: list2 = (word.isupper() or word.istitle()) print (word) else print (word) -------------- next part -------------- An HTML attachment was scrubbed... URL: From stefan_ml at behnel.de Wed Jan 5 13:42:06 2011 From: stefan_ml at behnel.de (Stefan Behnel) Date: Wed, 05 Jan 2011 19:42:06 +0100 Subject: Creating custom Python objects from C code In-Reply-To: References: Message-ID: Eric Frederich, 05.01.2011 17:27: > I have read through all the documentation here: > > http://docs.python.org/extending/newtypes.html > > I have not seen any documentation anywhere else explaining how to > create custom defined objects from C. At this point, it is best to take a look at Cython *before* continuing your struggle to solve problems that you wouldn't even have become aware of if you had used it right away. > I have this need to create custom objects from C and pass them as > arguments to a function call. > > Question 1: how am I to create those objects from C code? In Cython: obj = SomeType() or (in some truly performance critical cases): obj = SomeType.__new__(SomeType) > The other thing I would like to know is how I can create helper > functions in my extension so they can be created and manipulated > easily. Either functions or static methods would work here. It's up to you to make a suitable design choice. > I am thinking along the lines of the built-in helper functions > PyList_New and PyList_Append. > Once I have an answer to question 1, the problem won't be creating the > helper functions, but making them available from something built with > distutils. > To use the builtin python functions from C I need to link against > python27.lib but when I create my own package using distutils it > creates dll or pyd files. Cython has an embedding mode ("--embed" option) that generates a suitable main() function to embed the Python interpreter in your module. That might work for you as is, or it will at least show you the required C code that you can adapt as you see fit. > Question 2: How do I make C helper functions that are part of my > extension available to other C projects in the same way that PyList_*, > PyString_*, PyInt_* functions are available? Cython allows you to mark C functions and Python extension types with the "api" keyword and generates suitable header files and import/export code for them that you can use both from C and from other Cython generated modules. It automatically uses PyCObject in older Python versions and PyCapsule in Py2.7 and Py3.1+. Stefan From tjreedy at udel.edu Wed Jan 5 14:58:05 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Wed, 05 Jan 2011 14:58:05 -0500 Subject: Help with code-lists and strings In-Reply-To: References: Message-ID: On 1/5/2011 12:57 PM, Cathy James wrote: > I am learning python and came across an excercise where i need to use > lists to strip words from a sentence; starting with those containing one > or more uppercase letters, followed by words with lower case letters. When writing code, it is good to start with one or more input-output pairs that constitute a test. For example, what, exactly, do you want to result from "Some special words are ALLCAPS, TitleCase, and MIXed." It is also good to think about all relevant cases. Note the following: >>> 'MIXed'.isupper() or 'MIXed'.istitle() False Do you want punctuation stripped off words? You might skip that at first. -- Terry Jan Reedy From drsalists at gmail.com Wed Jan 5 15:02:13 2011 From: drsalists at gmail.com (Dan Stromberg) Date: Wed, 5 Jan 2011 12:02:13 -0800 Subject: Matrix multiplication In-Reply-To: References: Message-ID: On Tue, Jan 4, 2011 at 11:31 PM, Tim Roberts wrote: > Zdenko wrote: >> >>Please, can anybody write me a simple recursive matrix multiplication >>using multiple threads in Python, or at least show me some guidelines >>how to write it myself > > Matrix multiplication is not generally done recursively. ?There's no > conceptual gain. ?It makes more sense iteratively. It may not be that common, but there is at least one significant advantage: Cache obliviousness. http://www.catonmat.net/blog/mit-introduction-to-algorithms-part-fourteen From rurpy at yahoo.com Wed Jan 5 15:10:02 2011 From: rurpy at yahoo.com (rurpy at yahoo.com) Date: Wed, 5 Jan 2011 12:10:02 -0800 (PST) Subject: opinion: comp lang docs style References: <98e82f1b-cf59-4e64-8fd4-63671f96b04f@r19g2000prm.googlegroups.com> <4745479a-10c5-4281-9dcd-c9d7b013a1ec@k13g2000vbq.googlegroups.com> <4d240fca$0$29969$c3e8da3$5496439d@news.astraweb.com> Message-ID: <541fb01b-7c88-4bd9-814c-f921c591c2af@o14g2000yqe.googlegroups.com> On 01/04/2011 11:29 PM, Steven D'Aprano wrote: > On Tue, 04 Jan 2011 15:17:37 -0800, rurpy at yahoo.com wrote: > >>> If one wants to critique the 'Python Docs', especially as regards to >>> usefulness to beginners, one must start with the Tutorial; and if one >>> wants to use if statements as an example, one must start with the >>> above. >> >> No. The language reference (LR) and standard library reference (SLR) >> must stand on their own merits. It is nice to have a good tutorial for >> those who like that style of learning. But it should be possible for a >> programmer with a basic understanding of computers and some other >> programming languages to understand how to program in python without >> referring to tutorials, explanatory websites, commercially published >> books, the source code, etc. > > No it shouldn't. That's what the tutorial is for. The language reference > and standard library reference are there to be reference manuals, not to > teach beginners Python. Yes it should. That's not what the tutorial is for. The (any) tutorial is for people new to python, often new to programming, who have the time and a learning style suitable for sitting down and going through a slow step-by-step exposition, much as one would get in a classroom. That is a perfectly valid way for someone in that target audience to learn python. Your (and Terry's) mistake is to presume that it is appropriate for everyone, perhaps because it worked for you personally. There is a large class of potential python users for whom a tutorial is highly suboptimal -- people who have some significant programming experience, who don't have the time or patience required to go through it getting information serially bit by bit, or whos learning style is, "don't spoon feed me, just tell me concisely what python does", who fill in gaps on a need-to-know basis rather than linearly. I (and many others) don't need or want an explanation of how to use lists as a stack! A language reference manual should completely and accurately describe the language it documents. (That seems fairly obvious to me although there will be differing opinions of how precise one needs to be, etc.) Once it meets that minimum standard, it's quality is defined by how effectively it transfers that information to its target audience. A good reference manual meets the learning needs of the target audience above admirably. I learned Perl (reputedly more difficult to learn than Python) from the Perl manpages and used it for many many years before I ever bought a Perl book. I learned C mostly from Harbison and Steele's "C: A Reference". Despite several attempts at python using its reference docs, I never got a handle on it until I forked out money for Beazley's book. There is obviously nothing inherently "difficult" about python -- it's just that python's reference docs are written for people who already know python. Since limiting their scope that narrowly is not necessary, as other languages show, it is fair to say that python's reference docs are poorer. > In any case, your assumption that any one documentation work should stand > on its own merits is nonsense -- *nothing* stands alone. Everything > builds on something else. Technical documentation is no different: it > *must* assume some level of knowledge of its readers -- should it be > aimed at Python experts, or average Python coders, or beginners, or > beginners to programming, or at the very least is it allowed to assume > that the reader already knows how to read? > > You can't satisfy all of these groups with one document, because their > needs are different and in conflict. This is why you have different > documentation -- tutorials and reference manuals and literate source code > and help text are all aimed at different audiences. Expecting one > document to be useful for all readers' needs is like expecting one data > type to be useful for all programming tasks. I defined (roughly) the target audience I was talking about when I wrote "for a programmer with a basic understanding of computers and some other programming languages". Let's dispense with the 6th-grade arguments about people who don't know how to read, etc. > Reasonable people might disagree on what a particular documentation work > should target, and the best way to target it, but not on the need for > different documentation for different targets. As I hope I clarified above, that was exactly my point too. There is a significant, unsatisfied gap between the audience that a tutorial aims at, and the audience that the reference docs as currently written seem to be aimed at. Since other language manuals incorporate this gap audience more or less sucessfully in their reference manuals, python's failure to do so is justification for calling them poor. (Of course they are poor in lots of other ways too but my original response was prompted by the erroneous claim that good (in my sense above) reference manuals were unnecessary because a tutorial exists.) From rurpy at yahoo.com Wed Jan 5 15:15:28 2011 From: rurpy at yahoo.com (rurpy at yahoo.com) Date: Wed, 5 Jan 2011 12:15:28 -0800 (PST) Subject: opinion: comp lang docs style References: <98e82f1b-cf59-4e64-8fd4-63671f96b04f@r19g2000prm.googlegroups.com> <4745479a-10c5-4281-9dcd-c9d7b013a1ec@k13g2000vbq.googlegroups.com> <4d240fca$0$29969$c3e8da3$5496439d@news.astraweb.com> Message-ID: On 01/05/2011 12:23 AM, Alice Bevan?McGregor wrote: > > On 2011-01-04 22:29:31 -0800, Steven D'Aprano said: > > >> >> In any case, your assumption that any one documentation work should stand >> >> on its own merits is nonsense -- *nothing* stands alone. > > > > +1 I responded more fully in my response to Steven but you like he is taking "stand on it's own merits" out of context. The context I gave was someone who wants a complete and accurate description of python and who understands programming with other languages but not python. > > How many RFCs still in use today don't start with: > > >> >> The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", >> >> "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this >> >> document are to be interpreted as described in RFC 2119 RFC 2119 is incorporated in the others by reference. It is purely a matter of technical convenience that those definitions, which are common to hundreds of RFCs, are factored out to a single common location. RFC 2119 is not a tutorial. > > I posted a response on the article itself, rather than pollute a > > mailing list with replies to a troll. The name calling was a rather > > large hint as to the intention of the "opinion", either that or whoever > > translated the article (man or machine) was really angry at the time. > > ;) I can hint to my neighbor that his stereo is too loud by throwing a brick through his window. Neither that nor calling people arrogant ignoramus is acceptable in polite society. I am not naive, nor not shocked that c.l.p is not always polite, and normally would not have even commented on it except that 1) Terry Reedy is usually more polite and thoughtful, and 2) Xah Lee's post was not a troll -- it was a legitimate comment on free software documentation (including specifically python's) and while I don't agree with some of his particulars, the Python docs would be improved if some of his comments were considered rather than dismissed with mindless epithets like troll and arrogant ignoramus. From eric.frederich at gmail.com Wed Jan 5 15:46:44 2011 From: eric.frederich at gmail.com (Eric Frederich) Date: Wed, 5 Jan 2011 15:46:44 -0500 Subject: Creating custom Python objects from C code In-Reply-To: <20110105173900.4bad877b@pitrou.net> References: <20110105173900.4bad877b@pitrou.net> Message-ID: On Wed, Jan 5, 2011 at 11:39 AM, Antoine Pitrou wrote: > On Wed, 5 Jan 2011 11:27:02 -0500 > Eric Frederich wrote: >> I have read through all the documentation here: >> >> ? ? http://docs.python.org/extending/newtypes.html >> >> I have not seen any documentation anywhere else explaining how to >> create custom defined objects from C. >> I have this need to create custom objects from C and pass them as >> arguments to a function call. > > What do you mean? Create instances of a type defined in Python code? > > The C API is not very different from Python-land. When you want to > instantiate a type, just call that type (as a PyObject pointer) with the > right arguments (using PyObject_Call() and friends). Whether that type > has been defined in C or in Python does not make a difference. No, the custom types are defined in C. I need to create the objects in C. I need to pass those custom C objects created in C to a python function via PyObject_CallObject(pFunc, pArgs). From passionate_programmer at hotmail.com Wed Jan 5 16:21:18 2011 From: passionate_programmer at hotmail.com (Rohit Coder) Date: Thu, 6 Jan 2011 02:51:18 +0530 Subject: Attaching C++ libraries to Python app. Message-ID: Is it possible to use C++ libraries within a Python application? I am planning to write an encryption program and want to use GnuPG C++ libraries.elementFontfont-familyfont-sizefont-stylefont-variantfont-weightletter-spacingline-heighttext-decorationtext-aligntext-indenttext-transformwhite-spaceword-spacingcolorBackgroundbg-attachmentbg-colorbg-imagebg-positionbg-repeatBoxwidthheightborder-topborder-rightborder-bottomborder-leftmarginpaddingmax-heightmin-heightmax-widthmin-widthoutline-coloroutline-styleoutline-widthPositioningpositiontopbottomrightleftfloatdisplayclearz-indexListlist-style-imagelist-style-typelist-style-positionTablevertical-alignborder-collapseborder-spacingcaption-sideempty-cellstable-layoutEffectstext-shadow-webkit-box-shadowborder-radiusOtheroverflowcursorvisibility ...................................................Rohit. -------------- next part -------------- An HTML attachment was scrubbed... URL: From stackslip at gmail.com Wed Jan 5 16:30:51 2011 From: stackslip at gmail.com (Slie) Date: Wed, 5 Jan 2011 12:30:51 -0900 Subject: Graphing API, In-Reply-To: References: Message-ID: <184DF132-C405-4276-ABED-E518DE21AD88@gmail.com> Thank you, I will defiantly look into that. On Jan 5, 2011, at 4:32 AM, Tim Harig wrote: > On 2011-01-05, Slie wrote: >> Is there a graphing API, someone suggests? > > You should check the archives, variations of this question get asked > a lot. > > I use GNUplot to do my graphing. I simply pipe it commands and data > through the subprocess module; but, there are libraries available for > interacting with it. > > Posts here also indicate that Google offers a web service based API for > generating graphs. I have never actually used it; but, the documentation > seems to be clear enough to get it working without too much trouble. > -- > http://mail.python.org/mailman/listinfo/python-list From clp2 at rebertia.com Wed Jan 5 16:42:48 2011 From: clp2 at rebertia.com (Chris Rebert) Date: Wed, 5 Jan 2011 13:42:48 -0800 Subject: Trying to decide between PHP and Python In-Reply-To: <4D24A9AD.5030003@mrabarnett.plus.com> References: <4D24A9AD.5030003@mrabarnett.plus.com> Message-ID: On Wed, Jan 5, 2011 at 9:26 AM, MRAB wrote: > On 05/01/2011 10:44, Nobody wrote: >> >> On Tue, 04 Jan 2011 12:20:42 -0800, Google Poster wrote: >> >>> The indentation-as-block is unique, >> >> Not at all. It's also used in occam, Miranda, Haskell and F#. >> > Don't forget about ABC. Just to round out the list: ISWIM ("invented" the concept) Boo (via Python heritage) Cobra (via Python heritage) BuddyScript Curry Genie Nemerle (not by default) Pliant PROMAL Spin XL Source: http://en.wikipedia.org/wiki/Off-side_rule Cheers, Chris From stefan.sonnenberg at pythonmeister.com Wed Jan 5 16:44:15 2011 From: stefan.sonnenberg at pythonmeister.com (Stefan Sonnenberg-Carstens) Date: Wed, 5 Jan 2011 22:44:15 +0100 Subject: Attaching C++ libraries to Python app. In-Reply-To: References: Message-ID: You don't need to reinvent the wheel: http://www.dlitz.net/software/pycrypto/ Am Mi, 5.01.2011, 22:21 schrieb Rohit Coder: > > Is it possible to use C++ libraries within a Python application? I am > planning to write an encryption program and want to use GnuPG C++ > libraries.elementFontfont-familyfont-sizefont-stylefont-variantfont-weightletter-spacingline-heighttext-decorationtext-aligntext-indenttext-transformwhite-spaceword-spacingcolorBackgroundbg-attachmentbg-colorbg-imagebg-positionbg-repeatBoxwidthheightborder-topborder-rightborder-bottomborder-leftmarginpaddingmax-heightmin-heightmax-widthmin-widthoutline-coloroutline-styleoutline-widthPositioningpositiontopbottomrightleftfloatdisplayclearz-indexListlist-style-imagelist-style-typelist-style-positionTablevertical-alignborder-collapseborder-spacingcaption-sideempty-cellstable-layoutEffectstext-shadow-webkit-box-shadowborder-radiusOtheroverflowcursorvisibility > ...................................................Rohit. -- > http://mail.python.org/mailman/listinfo/python-list > -- MfG, Stefan Sonnenberg-Carstens IT Architect From emile at fenx.com Wed Jan 5 17:16:55 2011 From: emile at fenx.com (Emile van Sebille) Date: Wed, 05 Jan 2011 14:16:55 -0800 Subject: opinion: comp lang docs style In-Reply-To: <541fb01b-7c88-4bd9-814c-f921c591c2af@o14g2000yqe.googlegroups.com> References: <98e82f1b-cf59-4e64-8fd4-63671f96b04f@r19g2000prm.googlegroups.com> <4745479a-10c5-4281-9dcd-c9d7b013a1ec@k13g2000vbq.googlegroups.com> <4d240fca$0$29969$c3e8da3$5496439d@news.astraweb.com> <541fb01b-7c88-4bd9-814c-f921c591c2af@o14g2000yqe.googlegroups.com> Message-ID: On 1/5/2011 12:10 PM rurpy at yahoo.com said... > A language reference manual should completely and accurately > describe the language it documents. (That seems fairly obvious > to me although there will be differing opinions of how precise > one needs to be, etc.) Once it meets that minimum standard, > it's quality is defined by how effectively it transfers that > information to its target audience. A good reference manual > meets the learning needs of the target audience above admirably. > > I learned Perl (reputedly more difficult to learn than Python) > from the Perl manpages and used it for many many years before > I ever bought a Perl book. I learned C mostly from Harbison > and Steele's "C: A Reference". Despite several attempts at > python using its reference docs, I never got a handle on > it until I forked out money for Beazley's book. Hmm... I suspect most of us with prior programming experience simply worked the tutorial and immediately put python into play, digging deeper as necessary. Further, absolute beginners at programming are not likely to learn programming from a man page, nor should anyone expect the tutorial to be sufficient for their needs. I agree that as far as the specific details around the edges and corner cases go, it would be nice to have a single reference that provides those answers at the level you need (ala postscript's redbook imo), but I find this group serves well to fill the gaps when I can't easily find what I need. Emile From robert.kern at gmail.com Wed Jan 5 17:17:01 2011 From: robert.kern at gmail.com (Robert Kern) Date: Wed, 05 Jan 2011 16:17:01 -0600 Subject: Attaching C++ libraries to Python app. In-Reply-To: References: Message-ID: On 1/5/11 3:44 PM, Stefan Sonnenberg-Carstens wrote: > Am Mi, 5.01.2011, 22:21 schrieb Rohit Coder: >> >> Is it possible to use C++ libraries within a Python application? I am >> planning to write an encryption program and want to use GnuPG C++ > > You don't need to reinvent the wheel: > > http://www.dlitz.net/software/pycrypto/ Wrong wheel. http://pyme.sourceforge.net/ -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco From passionate_programmer at hotmail.com Wed Jan 5 17:44:44 2011 From: passionate_programmer at hotmail.com (Rohit Coder) Date: Thu, 6 Jan 2011 04:14:44 +0530 Subject: Attaching C++ libraries to Python app. In-Reply-To: References: , Message-ID: I am just asking. In future I may need to import any C++ library, not a Crypto, but some other. Is it possible? > Date: Wed, 5 Jan 2011 22:44:15 +0100 > Subject: Re: Attaching C++ libraries to Python app. > From: stefan.sonnenberg at pythonmeister.com > To: passionate_programmer at hotmail.com > CC: python-list at python.org > > You don't need to reinvent the wheel: > > http://www.dlitz.net/software/pycrypto/ > > Am Mi, 5.01.2011, 22:21 schrieb Rohit Coder: > > > > Is it possible to use C++ libraries within a Python application? I am > > planning to write an encryption program and want to use GnuPG C++ > > libraries.elementFontfont-familyfont-sizefont-stylefont-variantfont-weightletter-spacingline-heighttext-decorationtext-aligntext-indenttext-transformwhite-spaceword-spacingcolorBackgroundbg-attachmentbg-colorbg-imagebg-positionbg-repeatBoxwidthheightborder-topborder-rightborder-bottomborder-leftmarginpaddingmax-heightmin-heightmax-widthmin-widthoutline-coloroutline-styleoutline-widthPositioningpositiontopbottomrightleftfloatdisplayclearz-indexListlist-style-imagelist-style-typelist-style-positionTablevertical-alignborder-collapseborder-spacingcaption-sideempty-cellstable-layoutEffectstext-shadow-webkit-box-shadowborder-radiusOtheroverflowcursorvisibility > > ...................................................Rohit. -- > > http://mail.python.org/mailman/listinfo/python-list > > > > > -- > MfG, > > Stefan Sonnenberg-Carstens > > IT Architect elementFontfont-familyfont-sizefont-stylefont-variantfont-weightletter-spacingline-heighttext-decorationtext-aligntext-indenttext-transformwhite-spaceword-spacingcolorBackgroundbg-attachmentbg-colorbg-imagebg-positionbg-repeatBoxwidthheightborder-topborder-rightborder-bottomborder-leftmarginpaddingmax-heightmin-heightmax-widthmin-widthoutline-coloroutline-styleoutline-widthPositioningpositiontopbottomrightleftfloatdisplayclearz-indexListlist-style-imagelist-style-typelist-style-positionTablevertical-alignborder-collapseborder-spacingcaption-sideempty-cellstable-layoutEffectstext-shadow-webkit-box-shadowborder-radiusOtheroverflowcursorvisibility -------------- next part -------------- An HTML attachment was scrubbed... URL: From alice at gothcandy.com Wed Jan 5 17:56:15 2011 From: alice at gothcandy.com (=?utf-8?Q?Alice_Bevan=E2=80=93McGregor?=) Date: Wed, 5 Jan 2011 14:56:15 -0800 Subject: Streaming templating languages for use as WSGI body. Message-ID: Howdy! I'm trying to find a templating engine whose templates can be consumed directly as a WSGI response body iterable. So far I haven't been very successful with Google; the engines I've found universally generate a monolithic rendered string. Bonus points for templating engines that support flush() mechanics internally to allow developer-chosen 'break points' in the iterable. Bonus points++ if it can somehow calculate the response body length without generating the whole thing monolithically. ;) - Alice. From howe.steven at gmail.com Wed Jan 5 17:56:40 2011 From: howe.steven at gmail.com (GrayShark) Date: Wed, 05 Jan 2011 16:56:40 -0600 Subject: Help with code-lists and strings References: Message-ID: On Wed, 05 Jan 2011 14:58:05 -0500, Terry Reedy wrote: > On 1/5/2011 12:57 PM, Cathy James wrote: > >> I am learning python and came across an excercise where i need to use >> lists to strip words from a sentence; starting with those containing >> one or more uppercase letters, followed by words with lower case >> letters. > > When writing code, it is good to start with one or more input-output > pairs that constitute a test. For example, what, exactly, do you want to > result from > "Some special words are ALLCAPS, TitleCase, and MIXed." > > It is also good to think about all relevant cases. Note the following: > >>> 'MIXed'.isupper() or 'MIXed'.istitle() > False > > Do you want punctuation stripped off words? You might skip that at > first. In python it's best to build up you functional needs. So two steps. First a nand (negative 'and' operation). Then wrap that with a function to create two strings of your list element, you''re calling 'word'. By the way, list is reserved word, like string. Don't get in the bad habit of using it. def nand( a, b ): """nand has to vars. Both must be strings """ return( ( not eval( a ) ) and ( not eval( b ) ) ) Eval of 'Abcd'.isupper() returns False. Ditto 'Abcd'.islower(); negate both results, 'and' values, return. Now wrap 'nand' in packaging an you're cooking with grease. def mixed_case( str ): return nand( "'%s'.islower()" % str , "'%s'.isupper()" % str ) or if that's too advanced/compact, try ... def mixed_case( str ): # nand() needs strings a = "'%s'.isupper()" % str b = "'%s'.islower()" % str res = nand( a, b ) return res >>> mixed_case('Abcd' ) True >>> mixed_case('ABCD' ) False >>> mixed_case('abcd' ) False Good luck Steven Howe From kanthony at woh.rr.com Wed Jan 5 18:12:13 2011 From: kanthony at woh.rr.com (kanthony at woh.rr.com) Date: Wed, 05 Jan 2011 17:12:13 -0600 Subject: Help with a Python coding question Message-ID: <44CdnVDzP-NQZ7nQnZ2dnUVZ_h-dnZ2d@giganews.com> I want to use Python to find all "\n" terminated strings in a PDF file, ideally returning string starting addresses. Anyone willing to help? -- --------------------------------- --- -- - Posted with NewsLeecher v4.0 Final Web @ http://www.newsleecher.com/?usenet ------------------- ----- ---- -- - From emile at fenx.com Wed Jan 5 18:45:36 2011 From: emile at fenx.com (Emile van Sebille) Date: Wed, 05 Jan 2011 15:45:36 -0800 Subject: Help with a Python coding question In-Reply-To: <44CdnVDzP-NQZ7nQnZ2dnUVZ_h-dnZ2d@giganews.com> References: <44CdnVDzP-NQZ7nQnZ2dnUVZ_h-dnZ2d@giganews.com> Message-ID: On 1/5/2011 3:12 PM kanthony at woh.rr.com said... > I want to use Python to find all "\n" terminated > strings in a PDF file, ideally returning string > starting addresses. Anyone willing to help? pdflines = open(r'c:\shared\python_book_01.pdf').readlines() sps = [0] for ii in pdflines: sps.append(sps[-1]+len(ii)) Emile From jshgwave at yahoo.com Wed Jan 5 20:08:14 2011 From: jshgwave at yahoo.com (Jshgwave) Date: Wed, 5 Jan 2011 17:08:14 -0800 (PST) Subject: Importing modules from miscellaneous folders Message-ID: <614812.98013.qm@web84415.mail.ac2.yahoo.com> On a Windows PC, I would like to be able to store modules in topic-specific foldersinstead of in Python26/Lib/site-packages, and then import into an IPython session those modules and the functions in them. To test this, I have made a toy module: --- """ ?toy_module.py ? ?This is for testing the importing of modules from folders ?other than "Lib". ?The first statement below is from Langtangen, Primer, p.143. ?At allows running the module as a program, as well as ?importing it as a module. """ if __name__ == '__main__' : ? def double_it (a) : ??? b = 2.*a ??? print 'double_it in toy_module: a = ', a, ', b = ', b ??? return b ? def triple_it (a) : ??? b = 3.*a ??? print 'triple_it in toy_module: a = ', a, ', b = ', b ??? return b --- I have tried many ways of importing this module and its functions, but all of them have failed.? In the IPython session below, the failures have been flagged for easy identification by "<<<". --- Python 2.6.6 (r266:84297, Aug 24 2010, 18:46:32) [MSC v.1500 32 bit (Intel)] Type "copyright", "credits" or "license" for more information. IPython 0.10.1 -- An enhanced Interactive Python. ????????? -> Introduction and overview of IPython's features. %quickref -> Quick reference. help????? -> Python's own help system. object??? -> Details about 'object'. ?object also works, ?? prints more. In [1]: # Test importing from other than Lib. In [2]: # 2011-01-05 In [3]: function_dir = 'G:\\Python_2010-12\\JH_Python_Functions' In [4]: # That is for the PC at work. In [5]: import os In [6]: os.getcwd() Out[6]: 'C:\\Documents and Settings\\Hornstein' In [7]: os.chdir(function_dir) In [8]: os.getcwd() Out[8]: 'G:\\Python_2010-12\\JH_Python_Functions' In [9]: import toy_module In [10]: result1 = toy_module.double_it(3.) --------------------------------------------------------------------------- AttributeError??????????????????????????? Traceback (most recent call last) G:\Python_2010-12\JH_Python_Functions\ in () AttributeError: 'module' object has no attribute 'double_it'? <<< 1 In [11]: from toy_module import double_it as twox --------------------------------------------------------------------------- ImportError?????????????????????????????? Traceback (most recent call last) G:\Python_2010-12\JH_Python_Functions\ in () ImportError: cannot import name double_it???????????????????? <<< 2 In [12]: IsFileThere = os.isfile('toy_module.py') --------------------------------------------------------------------------- AttributeError??????????????????????????? Traceback (most recent call last) G:\Python_2010-12\JH_Python_Functions\ in () AttributeError: 'module' object has no attribute 'isfile' In [13]: IsFileThere = os.path.isfile('toy_module.py') In [14]: IsFileThere Out[14]: True In [15]: filelist = os.listdir(function_dir) In [16]: filelist Out[16]: ['arc_to_-pitopi.py', ?'arc_to_0to2pi.py', ?'ClustersOfGalaxiesUtils.py', ?'ClustersOfGalaxiesUtils.py.txt', ?'ClustersOfGalaxiesUtils.Test.2010-08-04.1.txt', ?'CosmolFns.py.txt', ?'CosmolGeom_SmoothedMatter_CL.py.txt', ?'Distances_z.py.txt', ?'extract_text_line.py', ?'JH.PythonExperimentsOnWindows.2011-01-03.txt', ?'LAMBDA_calc.py', ?'loop_to_sum.example.py', ?'number_theory.py', ?'omega_plasma_radHz.py', ?'README.txt', ?'Sampletxt.IPython.txt', ?'Sampletxt.txt', ?'script2_1.py', ?'synchRadn.py.txt', ?'toy_module.py', ?'toy_module.pyc', ?'uv2D.Feb14-06.py', ?'VariablesInFile.py', ?'VariablesInFile.pyc', ?'VLA_beamwidths.py', ?'z_cosmol.py'] In [17]: import glob In [18]: pyfilelist = glob.glob('*.py') In [19]: pyfilelist Out[19]: ['arc_to_-pitopi.py', ?'arc_to_0to2pi.py', ?'ClustersOfGalaxiesUtils.py', ?'extract_text_line.py', ?'LAMBDA_calc.py', ?'loop_to_sum.example.py', ?'number_theory.py', ?'omega_plasma_radHz.py', ?'script2_1.py', ?'toy_module.py', ?'uv2D.Feb14-06.py', ?'VariablesInFile.py', ?'VLA_beamwidths.py', ?'z_cosmol.py'] In [20]: # Try changing the Python search path. In [21]: import sys In [22]: sys.path Out[22]: ['', ?'C:\\Python26\\scripts', ?'C:\\WINDOWS\\system32\\python26.zip', ?'C:\\Python26\\DLLs', ?'C:\\Python26\\lib', ?'C:\\Python26\\lib\\plat-win', ?'C:\\Python26\\lib\\lib-tk', ?'C:\\Python26', ?'C:\\Python26\\lib\\site-packages', ?'C:\\Python26\\lib\\site-packages\\IPython/Extensions', ?u'C:\\Documents and Settings\\Hornstein\\_ipython'] In [23]: sys.path.append(function_dir) In [24]: sys.path Out[24]: ['', ?'C:\\Python26\\scripts', ?'C:\\WINDOWS\\system32\\python26.zip', ?'C:\\Python26\\DLLs', ?'C:\\Python26\\lib', ?'C:\\Python26\\lib\\plat-win', ?'C:\\Python26\\lib\\lib-tk', ?'C:\\Python26', ?'C:\\Python26\\lib\\site-packages', ?'C:\\Python26\\lib\\site-packages\\IPython/Extensions', ?u'C:\\Documents and Settings\\Hornstein\\_ipython', ?'G:\\Python_2010-12\\JH_Python_Functions'] In [25]: import toy_module In [26]: result1 = toy_module.double_it(3.) --------------------------------------------------------------------------- AttributeError??????????????????????????? Traceback (most recent call last) G:\Python_2010-12\JH_Python_Functions\ in () AttributeError: 'module' object has no attribute 'double_it'?? <<< 3 In [27]: exit() Do you really want to exit ([y]/n)? Any insight would be appreciated. Also, it is unfortunate that no warning is issued when an attempt at importing fails. John Hornstein (By the way, I am stuck with Python2.6 because the binary installer for NumPy on Windows still refuses to accept any later version of Python.) -------------- next part -------------- An HTML attachment was scrubbed... URL: From peelpy at gmail.com Wed Jan 5 20:14:28 2011 From: peelpy at gmail.com (Justin Peel) Date: Wed, 5 Jan 2011 18:14:28 -0700 Subject: Help with a Python coding question In-Reply-To: References: <44CdnVDzP-NQZ7nQnZ2dnUVZ_h-dnZ2d@giganews.com> Message-ID: On Wed, Jan 5, 2011 at 4:45 PM, Emile van Sebille wrote: > On 1/5/2011 3:12 PM kanthony at woh.rr.com said... > > I want to use Python to find all "\n" terminated >> strings in a PDF file, ideally returning string >> starting addresses. Anyone willing to help? >> > > pdflines = open(r'c:\shared\python_book_01.pdf').readlines() > sps = [0] > for ii in pdflines: sps.append(sps[-1]+len(ii)) > > Emile > > > -- > http://mail.python.org/mailman/listinfo/python-list > Bear in mind that pdf files often have compressed objects in them. If that is the case, then I would recommend opening the pdf in binary mode and figuring out how to deflate the correct objects before doing any searching. PyPDF is a package that might help with this though it could use some updating. -------------- next part -------------- An HTML attachment was scrubbed... URL: From askutt at gmail.com Wed Jan 5 20:25:49 2011 From: askutt at gmail.com (Adam Skutt) Date: Wed, 5 Jan 2011 17:25:49 -0800 (PST) Subject: Interrput a thread References: <81c24eb1-41b6-442a-a971-8a44d2cd6c1b@p8g2000vbs.googlegroups.com> <2ebc11a5-1b45-4faa-97b9-c84f0db015a4@k22g2000yqh.googlegroups.com> <68004bac-5d4d-40fa-afb7-6de45f3ea87a@v17g2000yqv.googlegroups.com> <4d23eb28$0$44049$742ec2ed@news.sonic.net> Message-ID: On Jan 4, 10:53?pm, John Nagle wrote: > ? ? ?There are systems where there's support designed in for thread > abort. ?LISP/Scheme systems tend to support it. ?QNX, the real-time > OS, has well worked out thread-abort semantics at the C level. > (QNX has really good features for "not getting stuck", like the > ability to put a time limit on any system call.) Yes, but "not getting stuck" and ending the thread execution is only one small part of the problem (and arguably the least significant). What we really want is a way to abort without harming other threads of execution, which is the hard part. QNX doesn't ipso facto make that easier. Functionality like time limits on system calls is more about latency guarantees and priority than "getting stuck" in a deadlock sense. > ? ? ?What you'd really like in Python is the ability for one thread > to be able to force an exception in another thread, plus a > mechanism for locking out such exceptions for critical sections. > It's not worth having, though, in a system where you can really only > run one thread at a time. Exceptions and critical sections are rather fundamentally incompatible, hence the absurd amount of gymnastics .NET goes through to attempt to make ThreadAbortException functional (and still fails rather miserably). If you had STM or 'antitry' blocks, then exceptions might be a semi-saneish way to abort a thread. Without either, I'm not entirely convinced of the utility. Only allowing the exception to be thrown from defined cancellation points is much better (ala POSIX threads), but diminishes the utility for things that are mostly grinding away in userspace. Adam From stackslip at gmail.com Wed Jan 5 20:31:13 2011 From: stackslip at gmail.com (Slie) Date: Wed, 5 Jan 2011 16:31:13 -0900 Subject: Searching Python-list Message-ID: <6113BAE4-29BB-416A-820F-CFCB0688DD37@gmail.com> I was wondering if anyone could tell me how to search through the Archives otter then manually looking through each month. From alice at gothcandy.com Wed Jan 5 20:36:31 2011 From: alice at gothcandy.com (=?utf-8?Q?Alice_Bevan=E2=80=93McGregor?=) Date: Wed, 5 Jan 2011 17:36:31 -0800 Subject: Streaming templating languages for use as WSGI body. References: Message-ID: Not sure if it's bad form to respond to your own posts, but here goes. ;) Coding up a quick hack of a templating engine, I've produced this: > http://pastie.textmate.org/private/ws5jbeh1xyeaqtrhahevqw (The implementation of the engine itself is a base class that overrides __call__ and __getitem__, with __unicode__ serializing in one block, the norm for templating engines, and .render(encoding='ascii') returning a generator using cStringIO for internal buffering.) I even have a light-weight widget system based on it, now. E.g. > class Input(Widget): > type_ = None > > @property > def template(self): > return tag.input ( > type_ = self.type_, > name = self.name, > id = self.name + '-field', > value = self.value, > **self.args > ) I'll polish it and package it up. :) - Alice. From nad at acm.org Wed Jan 5 20:39:42 2011 From: nad at acm.org (Ned Deily) Date: Wed, 05 Jan 2011 17:39:42 -0800 Subject: Searching Python-list References: <6113BAE4-29BB-416A-820F-CFCB0688DD37@gmail.com> Message-ID: In article <6113BAE4-29BB-416A-820F-CFCB0688DD37 at gmail.com>, Slie wrote: > I was wondering if anyone could tell me how to search through the Archives > otter then manually looking through each month. One way is to use the mirror of the mailing list at gmane.org: http://dir.gmane.org/gmane.comp.python.general -- Ned Deily, nad at acm.org From alice at gothcandy.com Wed Jan 5 20:39:49 2011 From: alice at gothcandy.com (=?utf-8?Q?Alice_Bevan=E2=80=93McGregor?=) Date: Wed, 5 Jan 2011 17:39:49 -0800 Subject: Searching Python-list References: <6113BAE4-29BB-416A-820F-CFCB0688DD37@gmail.com> Message-ID: On 2011-01-05 17:31:13 -0800, Slie said: > I was wondering if anyone could tell me how to search through the > Archives otter then manually looking through each month. Grab a Usenet news reader (such as Thunderbird or Unison), point it at: nntps://news.gmane.org/gmane.comp.python.general I can rather quickly search through articles using this interface (let alone keep my e-mail clear of mailing lists) and even post. :) - Alice. From BubbaCoder at gmail.com Wed Jan 5 20:55:45 2011 From: BubbaCoder at gmail.com (Bubba) Date: Wed, 05 Jan 2011 19:55:45 -0600 Subject: Help with a Python coding question References: Message-ID: <092dnYjfL7i8vLjQnZ2dnUVZ_u-dnZ2d@giganews.com> Does this work for binary files? (Like PDFs) -- --------------------------------- --- -- - Posted with NewsLeecher v4.0 Final Web @ http://www.newsleecher.com/?usenet ------------------- ----- ---- -- - From BubbaCoder at gmail.com Wed Jan 5 21:24:44 2011 From: BubbaCoder at gmail.com (Bubba) Date: Wed, 05 Jan 2011 20:24:44 -0600 Subject: Help with a Python coding question References: Message-ID: <58OdncbWoqVxurjQnZ2dnUVZ_hWdnZ2d@giganews.com> Your code only shows the first 488 bytes of the file? -- --------------------------------- --- -- - Posted with NewsLeecher v4.0 Final Web @ http://www.newsleecher.com/?usenet ------------------- ----- ---- -- - From stackslip at gmail.com Wed Jan 5 21:35:04 2011 From: stackslip at gmail.com (Garland) Date: Thu, 06 Jan 2011 02:35:04 +0000 Subject: Searching Python-list Message-ID: <90e6ba6e83d66145bd0499245919@google.com> Amazing you are a genius, I use google chrome and I chose Google Reader as my solution for the e-mail clutter and response. RSS from here. http://permalink.gmane.org/gmane.comp.python.general/681862 All i have to do is click on a response and i'm brought the the search thank you. Sent to you by Garland via Google Reader: Re: Searching Python-list via gmane.comp.python.general by Alice Bevan?McGregor on 1/6/11 On 2011-01-05 17:31:13 -0800, Slie said: Grab a Usenet news reader (such as Thunderbird or Unison), point it at: nntps://news.gmane.org/gmane.comp.python.general I can rather quickly search through articles using this interface (let alone keep my e-mail clear of mailing lists) and even post. :) - Alice. Things you can do from here: - Subscribe to gmane.comp.python.general using Google Reader - Get started using Google Reader to easily keep up with all your favorite sites -------------- next part -------------- An HTML attachment was scrubbed... URL: From nambo4jb at gmail.com Wed Jan 5 21:39:56 2011 From: nambo4jb at gmail.com (Cathy James) Date: Wed, 5 Jan 2011 20:39:56 -0600 Subject: Help with code-lists and strings Message-ID: Thank you all for your help. 1) I need to list words with uppercase first, then those with lower case; I used istitle() and isupper (don't know the method for mixed case yet) 2) Steve, it's a compliment that you though I'd undersand your code, but I only know conditional statements, started on lists, not functions yet. nand is still Greek to me right now. 3) If someone input "Thank you my FOLKS, i want the output to print words with upper case first: Thank FOLKS you my 3) Can someone help me make my code work in a very simple way. I am still learning, but watch this space colleagues; I may be helping you guys in a few months ;) Thanks to all who took their time to help. Future Python Expert, Cathy. My initial code: s=input("Write a sentence: ") list=s.strip().split() for word in list: list2 = (word.isupper() or word.istitle()) print (word) else print (word) On Wed, Jan 5, 2011 at 7:35 PM, wrote: > Send Python-list mailing list submissions to > python-list at python.org > > To subscribe or unsubscribe via the World Wide Web, visit > http://mail.python.org/mailman/listinfo/python-list > or, via email, send a message with subject or body 'help' to > python-list-request at python.org > > You can reach the person managing the list at > python-list-owner at python.org > > When replying, please edit your Subject line so it is more specific > than "Re: Contents of Python-list digest..." > > Today's Topics: > > 1. Re: Help with code-lists and strings (GrayShark) > 2. Help with a Python coding question (kanthony at woh.rr.com) > 3. Re: Help with a Python coding question (Emile van Sebille) > 4. Re: Help with a Python coding question (Justin Peel) > 5. Importing modules from miscellaneous folders (Jshgwave) > 6. Searching Python-list (Slie) > 7. Re: Interrput a thread (Adam Skutt) > > > ---------- Forwarded message ---------- > From: GrayShark > To: python-list at python.org > Date: Wed, 05 Jan 2011 16:56:40 -0600 > Subject: Re: Help with code-lists and strings > On Wed, 05 Jan 2011 14:58:05 -0500, Terry Reedy wrote: > > > On 1/5/2011 12:57 PM, Cathy James wrote: > > > >> I am learning python and came across an excercise where i need to use > >> lists to strip words from a sentence; starting with those containing > >> one or more uppercase letters, followed by words with lower case > >> letters. > > > > When writing code, it is good to start with one or more input-output > > pairs that constitute a test. For example, what, exactly, do you want to > > result from > > "Some special words are ALLCAPS, TitleCase, and MIXed." > > > > It is also good to think about all relevant cases. Note the following: > > >>> 'MIXed'.isupper() or 'MIXed'.istitle() > > False > > > > Do you want punctuation stripped off words? You might skip that at > > first. > > In python it's best to build up you functional needs. So two steps. First > a nand (negative 'and' operation). Then wrap that with a function to create > two strings of your list element, you''re calling 'word'. By the way, > list is reserved word, like string. Don't get in the bad habit of using it. > > def nand( a, b ): > """nand has to vars. Both must be strings """ > return( ( not eval( a ) ) and ( not eval( b ) ) ) > > Eval of 'Abcd'.isupper() returns False. Ditto 'Abcd'.islower(); negate both > results, 'and' values, return. > > Now wrap 'nand' in packaging an you're cooking with grease. > def mixed_case( str ): > return nand( "'%s'.islower()" % str , "'%s'.isupper()" % str ) > > or if that's too advanced/compact, try ... > def mixed_case( str ): > # nand() needs strings > a = "'%s'.isupper()" % str > b = "'%s'.islower()" % str > res = nand( a, b ) > return res > > >>> mixed_case('Abcd' ) > True > >>> mixed_case('ABCD' ) > False > >>> mixed_case('abcd' ) > False > > Good luck > Steven Howe > > > > ---------- Forwarded message ---------- > From: kanthony at woh.rr.com > To: python-list at python.org > Date: Wed, 05 Jan 2011 17:12:13 -0600 > Subject: Help with a Python coding question > I want to use Python to find all "\n" terminated > strings in a PDF file, ideally returning string > starting addresses. Anyone willing to help? > > > -- > --------------------------------- --- -- - > Posted with NewsLeecher v4.0 Final > Web @ http://www.newsleecher.com/?usenet > ------------------- ----- ---- -- - > > > > > ---------- Forwarded message ---------- > From: Emile van Sebille > To: python-list at python.org > Date: Wed, 05 Jan 2011 15:45:36 -0800 > Subject: Re: Help with a Python coding question > On 1/5/2011 3:12 PM kanthony at woh.rr.com said... > >> I want to use Python to find all "\n" terminated >> strings in a PDF file, ideally returning string >> starting addresses. Anyone willing to help? >> > > pdflines = open(r'c:\shared\python_book_01.pdf').readlines() > sps = [0] > for ii in pdflines: sps.append(sps[-1]+len(ii)) > > Emile > > > > > ---------- Forwarded message ---------- > From: Justin Peel > To: python-list at python.org > Date: Wed, 5 Jan 2011 18:14:28 -0700 > Subject: Re: Help with a Python coding question > > > On Wed, Jan 5, 2011 at 4:45 PM, Emile van Sebille wrote: > >> On 1/5/2011 3:12 PM kanthony at woh.rr.com said... >> >> I want to use Python to find all "\n" terminated >>> strings in a PDF file, ideally returning string >>> starting addresses. Anyone willing to help? >>> >> >> pdflines = open(r'c:\shared\python_book_01.pdf').readlines() >> sps = [0] >> for ii in pdflines: sps.append(sps[-1]+len(ii)) >> >> Emile >> >> >> -- >> http://mail.python.org/mailman/listinfo/python-list >> > Bear in mind that pdf files often have compressed objects in them. If that > is the case, then I would recommend opening the pdf in binary mode and > figuring out how to deflate the correct objects before doing any searching. > PyPDF is a package that might help with this though it could use some > updating. > > ---------- Forwarded message ---------- > From: Jshgwave > To: python-list at python.org > Date: Wed, 5 Jan 2011 17:08:14 -0800 (PST) > Subject: Importing modules from miscellaneous folders > On a Windows PC, I would like to be able to store modules in > topic-specific foldersinstead of in Python26/Lib/site-packages, > and then import into an IPython session those modules and the > functions in them. > > To test this, I have made a toy module: > > --- > > """ > toy_module.py > > This is for testing the importing of modules from folders > other than "Lib". > > The first statement below is from Langtangen, Primer, p.143. > At allows running the module as a program, as well as > importing it as a module. > """ > > > if __name__ == '__main__' : > > def double_it (a) : > b = 2.*a > print 'double_it in toy_module: a = ', a, ', b = ', b > return b > > > def triple_it (a) : > b = 3.*a > print 'triple_it in toy_module: a = ', a, ', b = ', b > return b > --- > > I have tried many ways of importing this module and its functions, but > all of them have failed. In the IPython session below, the failures > have been flagged for easy identification by "<<<". > > --- > > Python 2.6.6 (r266:84297, Aug 24 2010, 18:46:32) [MSC v.1500 32 bit > (Intel)] > Type "copyright", "credits" or "license" for more information. > > IPython 0.10.1 -- An enhanced Interactive Python. > ? -> Introduction and overview of IPython's features. > %quickref -> Quick reference. > help -> Python's own help system. > object? -> Details about 'object'. ?object also works, ?? prints more. > > In [1]: # Test importing from other than Lib. > > In [2]: # 2011-01-05 > > In [3]: function_dir = 'G:\\Python_2010-12\\JH_Python_Functions' > > In [4]: # That is for the PC at work. > > In [5]: import os > > In [6]: os.getcwd() > Out[6]: 'C:\\Documents and Settings\\Hornstein' > > In [7]: os.chdir(function_dir) > > In [8]: os.getcwd() > Out[8]: 'G:\\Python_2010-12\\JH_Python_Functions' > > In [9]: import toy_module > > In [10]: result1 = toy_module.double_it(3.) > --------------------------------------------------------------------------- > AttributeError Traceback (most recent call last) > > G:\Python_2010-12\JH_Python_Functions\ in () > > AttributeError: 'module' object has no attribute 'double_it' <<< 1 > > In [11]: from toy_module import double_it as twox > --------------------------------------------------------------------------- > ImportError Traceback (most recent call last) > > G:\Python_2010-12\JH_Python_Functions\ in () > > ImportError: cannot import name double_it <<< 2 > > In [12]: IsFileThere = os.isfile('toy_module.py') > --------------------------------------------------------------------------- > AttributeError Traceback (most recent call last) > > G:\Python_2010-12\JH_Python_Functions\ in () > > AttributeError: 'module' object has no attribute 'isfile' > > In [13]: IsFileThere = os.path.isfile('toy_module.py') > > In [14]: IsFileThere > Out[14]: True > > In [15]: filelist = os.listdir(function_dir) > > In [16]: filelist > Out[16]: > ['arc_to_-pitopi.py', > 'arc_to_0to2pi.py', > 'ClustersOfGalaxiesUtils.py', > 'ClustersOfGalaxiesUtils.py.txt', > 'ClustersOfGalaxiesUtils.Test.2010-08-04.1.txt', > 'CosmolFns.py.txt', > 'CosmolGeom_SmoothedMatter_CL.py.txt', > 'Distances_z.py.txt', > 'extract_text_line.py', > 'JH.PythonExperimentsOnWindows.2011-01-03.txt', > 'LAMBDA_calc.py', > 'loop_to_sum.example.py', > 'number_theory.py', > 'omega_plasma_radHz.py', > 'README.txt', > 'Sampletxt.IPython.txt', > 'Sampletxt.txt', > 'script2_1.py', > 'synchRadn.py.txt', > 'toy_module.py', > 'toy_module.pyc', > 'uv2D.Feb14-06.py ', > 'VariablesInFile.py', > 'VariablesInFile.pyc', > 'VLA_beamwidths.py', > 'z_cosmol.py'] > > In [17]: import glob > > In [18]: pyfilelist = glob.glob('*.py') > > In [19]: pyfilelist > Out[19]: > ['arc_to_-pitopi.py', > 'arc_to_0to2pi.py', > 'ClustersOfGalaxiesUtils.py', > 'extract_text_line.py', > 'LAMBDA_calc.py', > 'loop_to_sum.example.py', > 'number_theory.py', > 'omega_plasma_radHz.py', > 'script2_1.py', > 'toy_module.py', > 'uv2D.Feb14-06.py ', > 'VariablesInFile.py', > 'VLA_beamwidths.py', > 'z_cosmol.py'] > > In [20]: # Try changing the Python search path. > > In [21]: import sys > > In [22]: sys.path > Out[22]: > ['', > 'C:\\Python26\\scripts', > 'C:\\WINDOWS\\system32\\python26.zip', > 'C:\\Python26\\DLLs', > 'C:\\Python26\\lib', > 'C:\\Python26\\lib\\plat-win', > 'C:\\Python26\\lib\\lib-tk', > 'C:\\Python26', > 'C:\\Python26\\lib\\site-packages', > 'C:\\Python26\\lib\\site-packages\\IPython/Extensions', > u'C:\\Documents and Settings\\Hornstein\\_ipython'] > > In [23]: sys.path.append(function_dir) > > In [24]: sys.path > Out[24]: > ['', > 'C:\\Python26\\scripts', > 'C:\\WINDOWS\\system32\\python26.zip', > 'C:\\Python26\\DLLs', > 'C:\\Python26\\lib', > 'C:\\Python26\\lib\\plat-win', > 'C:\\Python26\\lib\\lib-tk', > 'C:\\Python26', > 'C:\\Python26\\lib\\site-packages', > 'C:\\Python26\\lib\\site-packages\\IPython/Extensions', > u'C:\\Documents and Settings\\Hornstein\\_ipython', > 'G:\\Python_2010-12\\JH_Python_Functions'] > > In [25]: import toy_module > > In [26]: result1 = toy_module.double_it(3.) > --------------------------------------------------------------------------- > AttributeError Traceback (most recent call last) > > G:\Python_2010-12\JH_Python_Functions\ in () > > AttributeError: 'module' object has no attribute 'double_it' <<< 3 > > In [27]: exit() > Do you really want to exit ([y]/n)? > > > Any insight would be appreciated. > > Also, it is unfortunate that no warning is issued when an attempt at > importing fails. > > John Hornstein > > > (By the way, I am stuck with Python2.6 because the binary installer for > NumPy on Windows still refuses to accept any later version of Python.) > > > > ---------- Forwarded message ---------- > From: Slie > To: python-list at python.org > Date: Wed, 5 Jan 2011 16:31:13 -0900 > Subject: Searching Python-list > I was wondering if anyone could tell me how to search through the Archives > otter then manually looking through each month. > > > > > ---------- Forwarded message ---------- > From: Adam Skutt > To: python-list at python.org > Date: Wed, 5 Jan 2011 17:25:49 -0800 (PST) > Subject: Re: Interrput a thread > On Jan 4, 10:53 pm, John Nagle wrote: > > There are systems where there's support designed in for thread > > abort. LISP/Scheme systems tend to support it. QNX, the real-time > > OS, has well worked out thread-abort semantics at the C level. > > (QNX has really good features for "not getting stuck", like the > > ability to put a time limit on any system call.) > > Yes, but "not getting stuck" and ending the thread execution is only > one small part of the problem (and arguably the least significant). > What we really want is a way to abort without harming other threads of > execution, which is the hard part. QNX doesn't ipso facto make that > easier. Functionality like time limits on system calls is more about > latency guarantees and priority than "getting stuck" in a deadlock > sense. > > > What you'd really like in Python is the ability for one thread > > to be able to force an exception in another thread, plus a > > mechanism for locking out such exceptions for critical sections. > > It's not worth having, though, in a system where you can really only > > run one thread at a time. > > Exceptions and critical sections are rather fundamentally > incompatible, hence the absurd amount of gymnastics .NET goes through > to attempt to make ThreadAbortException functional (and still fails > rather miserably). If you had STM or 'antitry' blocks, then > exceptions might be a semi-saneish way to abort a thread. Without > either, I'm not entirely convinced of the utility. > > Only allowing the exception to be thrown from defined cancellation > points is much better (ala POSIX threads), but diminishes the utility > for things that are mostly grinding away in userspace. > > Adam > > > -- > http://mail.python.org/mailman/listinfo/python-list > -------------- next part -------------- An HTML attachment was scrubbed... URL: From davea at ieee.org Wed Jan 5 22:17:29 2011 From: davea at ieee.org (Dave Angel) Date: Wed, 05 Jan 2011 22:17:29 -0500 Subject: Help with code-lists and strings In-Reply-To: References: Message-ID: <4D253449.90507@ieee.org> On 01/-10/-28163 02:59 PM, GrayShark wrote: > < > In python it's best to build up you functional needs. So two steps. First > a nand (negative 'and' operation). Then wrap that with a function to create > two strings of your list element, you''re calling 'word'. By the way, > list is reserved word, like string. Don't get in the bad habit of using it. > > def nand( a, b ): > """nand has to vars. Both must be strings """ > return( ( not eval( a ) ) and ( not eval( b ) ) ) > Two problems with that. One is that you've defined a NOR function, but called it nand(). The other is using eval. There's no need for it, and it's both slow and risky. DaveA From stackslip at gmail.com Wed Jan 5 22:36:55 2011 From: stackslip at gmail.com (Slie) Date: Wed, 5 Jan 2011 18:36:55 -0900 Subject: Google Chart API, HTTP POST request format. Message-ID: http://code.google.com/apis/chart/docs/post_requests.html Google will return a chart in your browser from a URL that you have built. If your URL is bigger then 2K characters it will allow you to submit POST requests. They gives examples of HTML, JavaScript, and PHP POST requests. Is there a way I can submit a request with Python? Or possibly submit the HTML, JavaScript or PHP using python?(That was a long shot thought). If I do that I would need to find out what to do with the .PNG it gives me. Am I headed in the right direction, is the above paragraph about submitting an HTML form from my program even logical? I have read several examples on python post requests but I'm not sure mine needs to be that complicated. Thank You, From benjamin.kaplan at case.edu Wed Jan 5 22:48:08 2011 From: benjamin.kaplan at case.edu (Benjamin Kaplan) Date: Wed, 5 Jan 2011 22:48:08 -0500 Subject: Importing modules from miscellaneous folders In-Reply-To: <614812.98013.qm@web84415.mail.ac2.yahoo.com> References: <614812.98013.qm@web84415.mail.ac2.yahoo.com> Message-ID: On Wed, Jan 5, 2011 at 8:08 PM, Jshgwave wrote: > > On a Windows PC, I would like to be able to store modules in > topic-specific foldersinstead of in Python26/Lib/site-packages, > and then import into an IPython session those modules and the > functions in them. > > To test this, I have made a toy module: > > --- > > """ > ?toy_module.py > > ?This is for testing the importing of modules from folders > ?other than "Lib". > > ?The first statement below is from Langtangen, Primer, p.143. > ?At allows running the module as a program, as well as > ?importing it as a module. > """ > > > if __name__ == '__main__' : > You've misunderstood what this statement does. Any python script can be executed as a program. In fact, all Python modules are scripts. Upon running or importing them, they are executed. Anything at the top level is run. If a module is imported, it's __name__ attribute will be the name of the script. If the module is run as a script, it's __name__ will be "__main__". By checking to see if the __name__ == "__main__", you can have certain code only run if the script is run as a program, as opposed to being imported as a module. The def statement in python is an executable statement, not a declaration. The function does not exist until after the def statement is executed. Because your functions are only created if __name__ == "__main__", they don't exist when __name__ == "toy_module", which is the case when you import it in the ipython shell. That's what's causing your error. From emile at fenx.com Wed Jan 5 22:54:25 2011 From: emile at fenx.com (Emile van Sebille) Date: Wed, 05 Jan 2011 19:54:25 -0800 Subject: Searching Python-list In-Reply-To: <6113BAE4-29BB-416A-820F-CFCB0688DD37@gmail.com> References: <6113BAE4-29BB-416A-820F-CFCB0688DD37@gmail.com> Message-ID: On 1/5/2011 5:31 PM Slie said... > I was wondering if anyone could tell me how to search through the Archives otter then manually looking through each month. > http://groups.google.com To limit the results to this group, prepend group:comp.lang.python to your search terms. Emile From emile at fenx.com Wed Jan 5 23:01:38 2011 From: emile at fenx.com (Emile van Sebille) Date: Wed, 05 Jan 2011 20:01:38 -0800 Subject: Help with a Python coding question In-Reply-To: <092dnYjfL7i8vLjQnZ2dnUVZ_u-dnZ2d@giganews.com> References: <092dnYjfL7i8vLjQnZ2dnUVZ_u-dnZ2d@giganews.com> Message-ID: On 1/5/2011 5:55 PM Bubba said... > Does this work for binary files? (Like PDFs) I don't know what you want -- pdf's are not line oriented so searching for \n's is sketchy from the get go. I figured this was homework to test something.... Emile From emile at fenx.com Wed Jan 5 23:02:28 2011 From: emile at fenx.com (Emile van Sebille) Date: Wed, 05 Jan 2011 20:02:28 -0800 Subject: Help with a Python coding question In-Reply-To: <58OdncbWoqVxurjQnZ2dnUVZ_hWdnZ2d@giganews.com> References: <58OdncbWoqVxurjQnZ2dnUVZ_hWdnZ2d@giganews.com> Message-ID: On 1/5/2011 6:24 PM Bubba said... > Your code only shows the first 488 bytes of the file? > > add 'rb' to the open statement... >>> pdflines = open(r'c:\shared\python_book_01.pdf','rb').readlines() >>> sps = [0] >>> for ii in pdflines: sps.append(sps[-1]+len(ii)) Emile From philip at semanchuk.com Wed Jan 5 23:11:44 2011 From: philip at semanchuk.com (Philip Semanchuk) Date: Wed, 5 Jan 2011 23:11:44 -0500 Subject: Searching Python-list In-Reply-To: <6113BAE4-29BB-416A-820F-CFCB0688DD37@gmail.com> References: <6113BAE4-29BB-416A-820F-CFCB0688DD37@gmail.com> Message-ID: <90E84BA3-297D-4DE0-866A-C99FD08FB420@semanchuk.com> On Jan 5, 2011, at 8:31 PM, Slie wrote: > I was wondering if anyone could tell me how to search through the Archives otter then manually looking through each month. Do a Google search and include this term: site:mail.python.org/pipermail/python-list/ e.g. to search for banana: http://www.google.com/search?q=site:mail.python.org%2Fpipermail%2Fpython-list%2F+banana HTH Philip From steve+comp.lang.python at pearwood.info Wed Jan 5 23:19:04 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 06 Jan 2011 04:19:04 GMT Subject: Help with code-lists and strings References: Message-ID: <4d2542b7$0$29996$c3e8da3$5496439d@news.astraweb.com> Apologies if this comes through twice, I'm having problems with my news client and/or provider. On Wed, 05 Jan 2011 16:56:40 -0600, GrayShark wrote: > In python it's best to build up you functional needs. So two steps. > First a nand (negative 'and' operation). Then wrap that with a function > to create two strings of your list element, you''re calling 'word'. By > the way, list is reserved word, like string. Don't get in the bad habit > of using it. Speaking of bad habits: > def nand( a, b ): > """nand has to vars. Both must be strings """ > return( ( not eval( a ) ) and ( not eval( b ) ) ) What is the purpose of the two calls to eval, other than potentially introducing serious security bugs, being slow, and raising exceptions? def nand(a, b): return not (a and b) is faster and safer, and less likely to cause annoyance if somebody manages to fool you into executing something similar to: nand("0", "__import__('os').system('# r m -rf /')") More safely, and works on both Linux and Windows: nand("0", "__import__('os').system('dir .')") > Eval of 'Abcd'.isupper() returns False. Ditto 'Abcd'.islower(); negate > both results, 'and' values, return. > > Now wrap 'nand' in packaging an you're cooking with grease. Eww. Greasy food. I think the idiom you are thinking of is "now you're cooking with gas", gas cooking being cleaner, faster and easier than cooking with wood. > def mixed_case( str ): > return nand( "'%s'.islower()" % str , "'%s'.isupper()" % str ) I'm afraid that's incorrect, because it returns True for strings that aren't mixed case: >>> mixed_case("123") True as well as strings that can't be mixed anything on account of being a single character: >>> mixed_case("!") True A better solution would be: def ismixed(s): seen_upper = seen_lower = False for c in s: if c.isupper(): seen_upper = True if c.islower(): seen_lower = True if seen_upper and seen_lower: return True return False which should return True if and only if the string contains both lowercase and uppercase characters. -- Steven From usernet at ilthio.net Wed Jan 5 23:26:42 2011 From: usernet at ilthio.net (Tim Harig) Date: Thu, 6 Jan 2011 04:26:42 +0000 (UTC) Subject: Google Chart API, HTTP POST request format. References: Message-ID: On 2011-01-06, Slie wrote: [reformated to <80 columns per RFC 1855 guidelines] > I have read several examples on python post requests but I'm not sure > mine needs to be that complicated. >From the HTML example on the page you posted:
you can retreive the same chart from Python: Python 3.1.2 (r312:79147, Oct 9 2010, 00:16:06) [GCC 4.4.4] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import urllib.request, urllib.parse >>> params = urllib.parse.urlencode({'cht':'lc', 'chtt':'This is | my >>> chart', ... 'chs':'600x200', 'chxt':'x,y', 'chd':'t:40,20,50,20,100'}) >>> chart = urllib.request.urlopen('https://chart.googleapis.com/chart', ... data = params).read() >>> chartFile = open("chart.png", 'wb') >>> chartFile.write(chart) 10782 >>> chartFile.close() From clp2 at rebertia.com Wed Jan 5 23:52:12 2011 From: clp2 at rebertia.com (Chris Rebert) Date: Wed, 5 Jan 2011 20:52:12 -0800 Subject: Google Chart API, HTTP POST request format. In-Reply-To: References: Message-ID: On Wed, Jan 5, 2011 at 7:36 PM, Slie wrote: > > http://code.google.com/apis/chart/docs/post_requests.html > > Google will return a chart in your browser from a URL that you have built. If your URL is bigger then 2K characters it will allow you to submit POST requests. > > They gives examples of HTML, JavaScript, and PHP POST requests. Is there a way I can submit a request with Python? Or possibly submit the HTML, JavaScript or PHP using python?(That was a long shot thought). If I do that I would need to find out what to do with the .PNG it gives me. > > Am I headed in the right direction, is the above paragraph about submitting an HTML form from my program even logical? You should probably first try one of the existing Python wrappers for Google's chart API and see if that meets your needs: http://code.google.com/p/google-chartwrapper/ http://pygooglechart.slowchop.com/ Cheers, Chris -- http://blog.rebertia.com From clp2 at rebertia.com Wed Jan 5 23:59:59 2011 From: clp2 at rebertia.com (Chris Rebert) Date: Wed, 5 Jan 2011 20:59:59 -0800 Subject: Help with code-lists and strings In-Reply-To: References: Message-ID: On Wed, Jan 5, 2011 at 6:39 PM, Cathy James wrote: > > Thank you all for your help. > 1) I need to list words with uppercase first, then those with lower case; I used istitle() and isupper (don't know the method for mixed case yet) > 2) Steve,?it's a compliment that you though I'd undersand your code, but I only know?conditional statements, started on lists, not functions yet. nand is still Greek to me right now. > 3) If someone input "Thank you my FOLKS, i want the output to print words with upper case first: > > Thank > FOLKS > you > my > > 3) Can someone help me make my code work in a very simple way. I am still learning, but watch this space colleagues;?I may be helping you guys in a few months ;) > > Thanks to all who took their time to help. > Future Python Expert, > Cathy. > > My initial code: > > s=input("Write a sentence: ") > list=s.strip().split() > for word in list: > ??? list2 = (word.isupper() or word.istitle()) > ??? print (word) > else print (word) > > On Wed, Jan 5, 2011 at 7:35 PM, wrote: >> >> Send Python-list mailing list submissions to >> ? ? ? ?python-list at python.org >> >> To subscribe or unsubscribe via the World Wide Web, visit >> ? ? ? ?http://mail.python.org/mailman/listinfo/python-list >> or, via email, send a message with subject or body 'help' to >> ? ? ? ?python-list-request at python.org >> >> You can reach the person managing the list at >> ? ? ? ?python-list-owner at python.org >> >> When replying, please edit your Subject line so it is more specific >> than "Re: Contents of Python-list digest..." >> >> Today's Topics: Note: Avoid replying to digests in the future, or at least trim off the irrelevant posts when doing so. You may want to switch to a non-digest subscription; this can be done at http://mail.python.org/mailman/listinfo/python-list (login and edit your subscription options). Cheers, Chris From stackslip at gmail.com Thu Jan 6 00:16:30 2011 From: stackslip at gmail.com (Garland Fulton) Date: Wed, 5 Jan 2011 20:16:30 -0900 Subject: Google Chart API, HTTP POST request format. In-Reply-To: References: Message-ID: I tried to use "pygooglechart.py" and I have been trying to get it set up all day actually along with several other graphing API's. I just found out that there is a problem with numpy and python 3.1 that is why I moved from the API's. Should I change version just for these library's? Should I be learning Python on 3.1? Awesome! On Wed, Jan 5, 2011 at 7:52 PM, Chris Rebert wrote: > On Wed, Jan 5, 2011 at 7:36 PM, Slie wrote: > > > > http://code.google.com/apis/chart/docs/post_requests.html > > > > Google will return a chart in your browser from a URL that you have > built. If your URL is bigger then 2K characters it will allow you to submit > POST requests. > > > > They gives examples of HTML, JavaScript, and PHP POST requests. Is there > a way I can submit a request with Python? Or possibly submit the HTML, > JavaScript or PHP using python?(That was a long shot thought). If I do that > I would need to find out what to do with the .PNG it gives me. > > > > Am I headed in the right direction, is the above paragraph about > submitting an HTML form from my program even logical? > > You should probably first try one of the existing Python wrappers for > Google's chart API and see if that meets your needs: > http://code.google.com/p/google-chartwrapper/ > http://pygooglechart.slowchop.com/ > > Cheers, > Chris > -- > http://blog.rebertia.com > -------------- next part -------------- An HTML attachment was scrubbed... URL: From stackslip at gmail.com Thu Jan 6 00:17:23 2011 From: stackslip at gmail.com (Garland Fulton) Date: Wed, 5 Jan 2011 20:17:23 -0900 Subject: Google Chart API, HTTP POST request format. In-Reply-To: References: Message-ID: Thank you for showing me the POST request, I will defiantly learn a lot from that. On Wed, Jan 5, 2011 at 7:26 PM, Tim Harig wrote: > On 2011-01-06, Slie wrote: > [reformated to <80 columns per RFC 1855 guidelines] > > I have read several examples on python post requests but I'm not sure > > mine needs to be that complicated. > > >From the HTML example on the page you posted: > >
> > > > > > >
> > you can retreive the same chart from Python: > > Python 3.1.2 (r312:79147, Oct 9 2010, 00:16:06) > [GCC 4.4.4] on linux2 > Type "help", "copyright", "credits" or "license" for more information. > >>> import urllib.request, urllib.parse > >>> params = urllib.parse.urlencode({'cht':'lc', 'chtt':'This is | my > >>> chart', > ... 'chs':'600x200', 'chxt':'x,y', 'chd':'t:40,20,50,20,100'}) > >>> chart = urllib.request.urlopen('https://chart.googleapis.com/chart > ', > ... data = params).read() > >>> chartFile = open("chart.png", 'wb') > >>> chartFile.write(chart) > 10782 > >>> chartFile.close() > -- > http://mail.python.org/mailman/listinfo/python-list > -------------- next part -------------- An HTML attachment was scrubbed... URL: From kb1pkl at aim.com Thu Jan 6 00:21:54 2011 From: kb1pkl at aim.com (Corey Richardson) Date: Thu, 06 Jan 2011 00:21:54 -0500 Subject: Google Chart API, HTTP POST request format. In-Reply-To: References: Message-ID: <4D255172.8020607@aim.com> On 01/06/2011 12:16 AM, Garland Fulton wrote: > I tried to use "pygooglechart.py" and I have been trying to get it set > up all day actually along with several other graphing API's. > > I just found out that there is a problem with numpy and python 3.1 that > is why I moved from the API's. Should I change version just for > these library's? > > Should I be learning Python on 3.1? > > Awesome! > > [snip] I swapped from 3 to 2.6 a while back, better support for modules, and not really losing much in the way of features. ~Corey Richardson From clp2 at rebertia.com Thu Jan 6 00:30:41 2011 From: clp2 at rebertia.com (Chris Rebert) Date: Wed, 5 Jan 2011 21:30:41 -0800 Subject: Google Chart API, HTTP POST request format. In-Reply-To: References: Message-ID: > On Wed, Jan 5, 2011 at 7:52 PM, Chris Rebert wrote: >> On Wed, Jan 5, 2011 at 7:36 PM, Slie wrote: >> > >> > http://code.google.com/apis/chart/docs/post_requests.html >> > >> > Google will return a chart in your browser from a URL that you have >> > built. If your URL is bigger then 2K characters it will allow you to submit >> > POST requests. >> > >> > They gives examples of HTML, JavaScript, and PHP POST requests. Is there >> > a way I can submit a request with Python? Or possibly submit the HTML, >> > JavaScript or PHP using python?(That was a long shot thought). If I do that >> > I would need to find out what to do with the .PNG it gives me. >> > >> > Am I headed in the right direction, is the above paragraph about >> > submitting an HTML form from my program even logical? >> >> You should probably first try one of the existing Python wrappers for >> Google's chart API and see if that meets your needs: >> http://code.google.com/p/google-chartwrapper/ >> http://pygooglechart.slowchop.com/ On Wed, Jan 5, 2011 at 9:16 PM, Garland Fulton wrote: > I tried to use "pygooglechart.py" and I have been trying to get it set up > all day actually along with several other graphing API's. > I just found out that there is a problem with numpy and python 3.1 that is > why I moved from the API's. Should I change version just for > these?library's? > Should I be learning Python on 3.1? Most third-party libraries have yet to be ported to Python 3.1 (with a few notable exceptions). If you actually want to write non-(toy/demo/trivial) programs, you should probably use Python 2.x. Python 3.1 is fine for learning the basics of the language; once you've done that, learning the Python 2.x differences and wart workarounds is not hard. (Also, in the future, please don't top-post.) Cheers, Chris -- http://blog.rebertia.com From stackslip at gmail.com Thu Jan 6 00:52:01 2011 From: stackslip at gmail.com (Garland Fulton) Date: Wed, 5 Jan 2011 20:52:01 -0900 Subject: Google Chart API, HTTP POST request format. In-Reply-To: References: Message-ID: On Wed, Jan 5, 2011 at 7:52 PM, Chris Rebert wrote: > On Wed, Jan 5, 2011 at 7:36 PM, Slie wrote: > > > > http://code.google.com/apis/chart/docs/post_requests.html > > > > Google will return a chart in your browser from a URL that you have > built. If your URL is bigger then 2K characters it will allow you to submit > POST requests. > > > > They gives examples of HTML, JavaScript, and PHP POST requests. Is there > a way I can submit a request with Python? Or possibly submit the HTML, > JavaScript or PHP using python?(That was a long shot thought). If I do that > I would need to find out what to do with the .PNG it gives me. > > > > Am I headed in the right direction, is the above paragraph about > submitting an HTML form from my program even logical? > > You should probably first try one of the existing Python wrappers for > Google's chart API and see if that meets your needs: > http://code.google.com/p/google-chartwrapper/ > http://pygooglechart.slowchop.com/ > > Cheers, > Chris > -- > http://blog.rebertia.com > Google Chart Wrapper is compatible with 3.1 and i have been looking all day for something like this. Thank you. -------------- next part -------------- An HTML attachment was scrubbed... URL: From stefan.sonnenberg at pythonmeister.com Thu Jan 6 01:08:14 2011 From: stefan.sonnenberg at pythonmeister.com (Stefan Sonnenberg-Carstens) Date: Thu, 06 Jan 2011 07:08:14 +0100 Subject: Attaching C++ libraries to Python app. In-Reply-To: References: , Message-ID: <4D255C4E.4060500@pythonmeister.com> Am 05.01.2011 23:44, schrieb Rohit Coder: > I am just asking. In future I may need to import any C++ library, not > a Crypto, but some other. Is it possible? Yes. There are at least five possible ways: - Handcode the interface and glue code (http://docs.python.org/extending) - use SWIG to autogenerate (mostly) the interface (http://www.swig.org) - using BOOST's python interface (http://www.boost.org/doc/libs/1_45_0/libs/python/doc/index.html) - using ctypes module for runtime interaction (like and use it a _lot_, very cool for rapid prototyping :-) http://docs.python.org/library/ctypes.html) - cython (different approach, implements a python subset, http://cython.org) I used SWIG and ctypes in the past, as it seems (for me) the easiest way. > > > Date: Wed, 5 Jan 2011 22:44:15 +0100 > > Subject: Re: Attaching C++ libraries to Python app. > > From: stefan.sonnenberg at pythonmeister.com > > To: passionate_programmer at hotmail.com > > CC: python-list at python.org > > > > You don't need to reinvent the wheel: > > > > http://www.dlitz.net/software/pycrypto/ > > > > Am Mi, 5.01.2011, 22:21 schrieb Rohit Coder: > > > > > > Is it possible to use C++ libraries within a Python application? I am > > > planning to write an encryption program and want to use GnuPG C++ > > > > libraries.elementFontfont-familyfont-sizefont-stylefont-variantfont-weightletter-spacingline-heighttext-decorationtext-aligntext-indenttext-transformwhite-spaceword-spacingcolorBackgroundbg-attachmentbg-colorbg-imagebg-positionbg-repeatBoxwidthheightborder-topborder-rightborder-bottomborder-leftmarginpaddingmax-heightmin-heightmax-widthmin-widthoutline-coloroutline-styleoutline-widthPositioningpositiontopbottomrightleftfloatdisplayclearz-indexListlist-style-imagelist-style-typelist-style-positionTablevertical-alignborder-collapseborder-spacingcaption-sideempty-cellstable-layoutEffectstext-shadow-webkit-box-shadowborder-radiusOtheroverflowcursorvisibility > > > ...................................................Rohit. -- > > > http://mail.python.org/mailman/listinfo/python-list > > > > > > > > > -- > > MfG, > > > > Stefan Sonnenberg-Carstens > > > > IT Architect > > > element > > Font > font-family > font-size > font-style > font-variant > font-weight > letter-spacing > line-height > text-decoration > text-align > text-indent > text-transform > white-space > word-spacing > color > Background > bg-attachment > bg-color > bg-image > bg-position > bg-repeat > Box > width > height > border-top > border-right > border-bottom > border-left > margin > padding > max-height > min-height > max-width > min-width > outline-color > outline-style > outline-width > Positioning > position > top > bottom > right > left > float > display > clear > z-index > List > list-style-image > list-style-type > list-style-position > Table > vertical-align > border-collapse > border-spacing > caption-side > empty-cells > table-layout > Effects > text-shadow > -webkit-box-shadow > border-radius > Other > overflow > cursor > visibility > -------------- next part -------------- An HTML attachment was scrubbed... URL: From stackslip at gmail.com Thu Jan 6 02:21:53 2011 From: stackslip at gmail.com (Garland Fulton) Date: Wed, 5 Jan 2011 22:21:53 -0900 Subject: Google Chart API, HTTP POST request format. In-Reply-To: References: Message-ID: On Wed, Jan 5, 2011 at 7:26 PM, Tim Harig wrote: > On 2011-01-06, Slie wrote: > [reformated to <80 columns per RFC 1855 guidelines] > > I have read several examples on python post requests but I'm not sure > > mine needs to be that complicated. > > >From the HTML example on the page you posted: > >
> > > > > > >
> > you can retreive the same chart from Python: > > Python 3.1.2 (r312:79147, Oct 9 2010, 00:16:06) > [GCC 4.4.4] on linux2 > Type "help", "copyright", "credits" or "license" for more information. > >>> import urllib.request, urllib.parse > >>> params = urllib.parse.urlencode({'cht':'lc', 'chtt':'This is | my > >>> chart', > ... 'chs':'600x200', 'chxt':'x,y', 'chd':'t:40,20,50,20,100'}) > >>> chart = urllib.request.urlopen('https://chart.googleapis.com/chart > ', > ... data = params).read() > >>> chartFile = open("chart.png", 'wb') > >>> chartFile.write(chart) > 10782 > >>> chartFile.close() > -- > http://mail.python.org/mailman/listinfo/python-list > Hope this isn't to stupid, For the chart = urllib.request.urlopen('https://chart.googleapis.com/chart', data = params).read() Where would I find information on why and what the ).read() part does. Thank you, -------------- next part -------------- An HTML attachment was scrubbed... URL: From passionate_programmer at hotmail.com Thu Jan 6 04:05:58 2011 From: passionate_programmer at hotmail.com (Rohit Coder) Date: Thu, 6 Jan 2011 14:35:58 +0530 Subject: How suitable is Python to write system utilities? Message-ID: Is Python suitable to write low-level system utilities like Defrag, Malware Removal Tools and Drivers? -------------- next part -------------- An HTML attachment was scrubbed... URL: From stefan_ml at behnel.de Thu Jan 6 04:57:08 2011 From: stefan_ml at behnel.de (Stefan Behnel) Date: Thu, 06 Jan 2011 10:57:08 +0100 Subject: Attaching C++ libraries to Python app. In-Reply-To: <4D255C4E.4060500@pythonmeister.com> References: , <4D255C4E.4060500@pythonmeister.com> Message-ID: Stefan Sonnenberg-Carstens, 06.01.2011 07:08: > Am 05.01.2011 23:44, schrieb Rohit Coder: >> I am just asking. In future I may need to import any C++ library, not a >> Crypto, but some other. Is it possible? > Yes. > There are at least five possible ways: > > - Handcode the interface and glue code (http://docs.python.org/extending) > - use SWIG to autogenerate (mostly) the interface (http://www.swig.org) > - using BOOST's python interface > (http://www.boost.org/doc/libs/1_45_0/libs/python/doc/index.html) None of these is worth recommending. Too much work, too hard to build a good interface with them and simply too slow for the invested effort. Their main drawback is that they distract you from designing wrappers and require you to think about lots of C/C++ problems. > - using ctypes module for runtime interaction (like and use it a _lot_, > very cool for rapid prototyping :-) > http://docs.python.org/library/ctypes.html) > - cython (different approach, implements a python subset, http://cython.org) IMHO, these are the two ways to do it nowadays. Cython wrappers are obviously much faster than anything you could ever write in ctypes, but both are similarly easy to use and allow users to focus on good wrapper design. Stefan From clp2 at rebertia.com Thu Jan 6 05:57:24 2011 From: clp2 at rebertia.com (Chris Rebert) Date: Thu, 6 Jan 2011 02:57:24 -0800 Subject: Google Chart API, HTTP POST request format. In-Reply-To: References: Message-ID: On Wed, Jan 5, 2011 at 11:21 PM, Garland Fulton wrote: > On Wed, Jan 5, 2011 at 7:26 PM, Tim Harig wrote: >> >> On 2011-01-06, Slie wrote: >> [reformated to <80 columns per RFC 1855 guidelines] >> > I have read several examples on python post requests but I'm not sure >> > mine needs to be that complicated. >> >> >From the HTML example on the page you posted: >> >> ? ?
>> ? ? ? ? >> ? ? ? ? >> ? ? ? ? >> ? ? ? ? >> ? ? ? ? >> ? ? ? ? >> ? ?
>> >> you can retreive the same chart from Python: >> >> ? ?Python 3.1.2 (r312:79147, Oct ?9 2010, 00:16:06) >> ? ?[GCC 4.4.4] on linux2 >> ? ?Type "help", "copyright", "credits" or "license" for more information. >> ? ?>>> import urllib.request, urllib.parse >> ? ?>>> params = urllib.parse.urlencode({'cht':'lc', 'chtt':'This is | my >> ? ?>>> chart', >> ? ?... ? ? ? ? 'chs':'600x200', 'chxt':'x,y', 'chd':'t:40,20,50,20,100'}) >> ? ?>>> chart = >> urllib.request.urlopen('https://chart.googleapis.com/chart', >> ? ?... ? ? ? ? data = params).read() >> ? ?>>> chartFile = open("chart.png", 'wb') >> ? ?>>> chartFile.write(chart) >> ? ?10782 >> ? ?>>> chartFile.close() >> -- >> http://mail.python.org/mailman/listinfo/python-list > > Hope this isn't to stupid, > For the > chart = urllib.request.urlopen('https://chart.googleapis.com/chart', data = > params).read() > Where would I find information on why and what the ).read() part does. http://docs.python.org/py3k/library/urllib.request.html#urllib.request.urlopen Specifically: "This function returns a file-like object" (representing the stream of data received). Thus, .read() on the file-like object returns the actual bytes obtained from the given URL. Cheers, Chris -- http://blog.rebertia.com From clp2 at rebertia.com Thu Jan 6 06:01:28 2011 From: clp2 at rebertia.com (Chris Rebert) Date: Thu, 6 Jan 2011 03:01:28 -0800 Subject: How suitable is Python to write system utilities? In-Reply-To: References: Message-ID: On Thu, Jan 6, 2011 at 1:05 AM, Rohit Coder wrote: > Is Python suitable to write low-level system utilities like Defrag, Malware > Removal Tools and Drivers? No; but I wouldn't classify a malware remover as a "low-level system utility". Writing such a tool in Python seems pretty feasible. Cheers, Chris -- http://blog.rebertia.com From alice at gothcandy.com Thu Jan 6 06:08:28 2011 From: alice at gothcandy.com (=?utf-8?Q?Alice_Bevan=E2=80=93McGregor?=) Date: Thu, 6 Jan 2011 03:08:28 -0800 Subject: How suitable is Python to write system utilities? References: Message-ID: On 2011-01-06 01:35:58 -0800, Rohit Coder said: > Is Python suitable to write low-level system utilities like Defrag, > Malware Removal Tools and Drivers? Yes and no. Python does include libraries (and has available third-party libraries) to interface with external low-level libraries of every kind, has Python-native third-party libraries to do things like examine ELF object files / executables, manipulate raw IP datagrams, etc, and it is possible to access glib (and other C libraries or even Windows DLLs) directly from within Python without creating wrapper interfaces. While you -can- do all of these things, the question becomes do you really -want to-? I've implemented server monitoring suites, FUSE filesystem drivers, and other strange low-level things in Python. This doesn't mean I'm getting the best "bang for the buck" when it comes to performance or overhead; I'm trading these things for the ease of prototyping, debugging, and the ability to utilize other high-level interfaces. My FUSE driver won't be as performant as it would have been had I written it in C. My server monitoring suite consumes more RAM than an equivalent solution in C. When it comes down to it, if you want it done efficiently, use C. ;) (As an aside, you -can- create hideous frankenstein monsters by using compiled CPython modules with glue code between the driver API, e.g. FUSE, and your CPython driver implementation; but in that case you're adding the overhead of Python for no gain whatsoever.) For anything system critical, Python might not be the best choice. Malware removal tools are themselves the target of malware (e.g. virii attempting to disable scanners and removal tools), and utilizing Python adds (IMHO) too many points of failure. Also, file fragmentation is a non-issue on all modern filesystems (ext3/4, reiser, ntfs, hfs+, etc.) as they perform live-system defragmentation to varying degrees. I have never seen a production server of mine (utilizing reiserfs) go above 11% fragmentation (non-contiguous extant allocations), and even that resolved itself within a few hours of active use. Note that non-contiguous extants are a distinct problem, reducing file read performance substantially, thus why filesystem drivers generally handle solving this problem by themselves. The other forms of fragmentation (free space fragmentation and file scattering / related-file fragmentation) substantially less so. Certain filesystems have features designed to avoid the latter (e.g. squashfs for ordering files on bootable CDs) and the former becomes more of an issue as you attempt to allocate extremely large contiguous files. (Becoming worse as free space is exhausted as more and more files of greater size need to be shuffled around the disk platter in order to free up a contiguous run of extants.) Hope this helps, - Alice. From passionate_programmer at hotmail.com Thu Jan 6 06:32:55 2011 From: passionate_programmer at hotmail.com (Rohit Coder) Date: Thu, 6 Jan 2011 17:02:55 +0530 Subject: Working with PyQt and Pydev Message-ID: I installed the PyDev plugin into Aptana Stdui 3 Beta. Someone suggested me to use PyQt for Python GUI app, and so I downloaded and installed PyQt. But when I open Aptana Studio, I could see a new menu added with the name "PyDev", but there is nothing for PyQt. In the Windows Start Meny item list, I could see a folder named PyQt and when I open it, there are few tools like Designer. When Designer is run, it opens Qt IDE for designing Forms like Visual Studio and the files have the extension .ui.I want to know how to integrate PyQt and PyDev. Do I need to use them separately by adding the .ui files to PyDev and then adding Python core code for functionality? ...............Rohit.elementFontfont-familyfont-sizefont-stylefont-variantfont-weightletter-spacingline-heighttext-decorationtext-aligntext-indenttext-transformwhite-spaceword-spacingcolorBackgroundbg-attachmentbg-colorbg-imagebg-positionbg-repeatBoxwidthheightborder-topborder-rightborder-bottomborder-leftmarginpaddingmax-heightmin-heightmax-widthmin-widthoutline-coloroutline-styleoutline-widthPositioningpositiontopbottomrightleftfloatdisplayclearz-indexListlist-style-imagelist-style-typelist-style-positionTablevertical-alignborder-collapseborder-spacingcaption-sideempty-cellstable-layoutEffectstext-shadow-webkit-box-shadowborder-radiusOtheroverflowcursorvisibility -------------- next part -------------- An HTML attachment was scrubbed... URL: From davea at ieee.org Thu Jan 6 06:38:01 2011 From: davea at ieee.org (Dave Angel) Date: Thu, 06 Jan 2011 06:38:01 -0500 Subject: Help with code-lists and strings In-Reply-To: <4D255309.5070109@gmail.com> References: <4D253449.90507@ieee.org> <4D255309.5070109@gmail.com> Message-ID: <4D25A999.6090508@ieee.org> On 01/06/2011 12:28 AM, Steven Howe wrote: > On 01/05/2011 07:17 PM, Dave Angel wrote: >> On 01/-10/-28163 02:59 PM, GrayShark wrote: >>> >> < >>> In python it's best to build up you functional needs. So two steps. >>> First >>> a nand (negative 'and' operation). Then wrap that with a function to >>> create >>> two strings of your list element, you''re calling 'word'. By the way, >>> list is reserved word, like string. Don't get in the bad habit of >>> using it. >>> >>> def nand( a, b ): >>> """nand has to vars. Both must be strings """ >>> return( ( not eval( a ) ) and ( not eval( b ) ) ) >>> >> >> Two problems with that. One is that you've defined a NOR function, but >> called it nand(). The other is using eval. There's no need for it, and >> it's both slow and risky. >> >> DaveA >> > Stupid. > All code is risky. > As to a nand operation, it not the same as a nor operation. > Stupid Well, if you're going to attack me, you could try to get your facts straight. Of course namd is different than nor. If it were not, I wouldn't have responded. NAND is defined as NOT (A and B) while NOR is defined as NOT (A or B) What you defined was the contrapositive of NOR, but you called it nand() If you need a refresher, check out http://en.wikipedia.org/wiki/Negated_AND_gate In particular, see the truth table, using ones and zeroes. DaveA From user at example.net Thu Jan 6 06:52:38 2011 From: user at example.net (J.O. Aho) Date: Thu, 06 Jan 2011 12:52:38 +0100 Subject: How suitable is Python to write system utilities? In-Reply-To: References: Message-ID: <8oloo6F566U1@mid.individual.net> Alice Bevan?McGregor wrote: > On 2011-01-06 01:35:58 -0800, Rohit Coder said: > >> Is Python suitable to write low-level system utilities like Defrag, >> Malware Removal Tools and Drivers? > > Yes and no. > > Also, file fragmentation is a non-issue on all modern filesystems > (ext3/4, reiser, ntfs, hfs+, etc.) as they perform live-system > defragmentation to varying degrees. According to microsoft documentation, the recommendation is to run defragmentation on ntfs on a regular bases. There seems to come some improvement on the mft fragmentation, but still it feels long behind the linux/unix file systems. Do you have any recent documentation on ntfs that shows it has the capability to defragmentate itself other than mft? -- //Aho From usernet at ilthio.net Thu Jan 6 08:19:17 2011 From: usernet at ilthio.net (Tim Harig) Date: Thu, 6 Jan 2011 13:19:17 +0000 (UTC) Subject: Google Chart API, HTTP POST request format. References: Message-ID: On 2011-01-06, Chris Rebert wrote: > On Wed, Jan 5, 2011 at 11:21 PM, Garland Fulton wrote: >> On Wed, Jan 5, 2011 at 7:26 PM, Tim Harig wrote: >>> ? ?Python 3.1.2 (r312:79147, Oct ?9 2010, 00:16:06) >>> ? ?[GCC 4.4.4] on linux2 >>> ? ?Type "help", "copyright", "credits" or "license" for more information. >>> ? ?>>> import urllib.request, urllib.parse >>> ? ?>>> params = urllib.parse.urlencode({'cht':'lc', 'chtt':'This is | my >>> ? ?>>> chart', Sorry I didn't notice this got accidently wrapped when I pasted it. >>> params = urllib.parse.urlencode({'cht':'lc', 'chtt':'This is | my chart', >>> ? ?... ? ? ? ? 'chs':'600x200', 'chxt':'x,y', 'chd':'t:40,20,50,20,100'}) >>> ? ?>>> chart = >>> urllib.request.urlopen('https://chart.googleapis.com/chart', >>> ? ?... ? ? ? ? data = params).read() >>> ? ?>>> chartFile = open("chart.png", 'wb') >>> ? ?>>> chartFile.write(chart) >>> ? ?10782 >>> ? ?>>> chartFile.close() >> >> Hope this isn't to stupid, >> For the >> chart = urllib.request.urlopen('https://chart.googleapis.com/chart', data = >> params).read() >> Where would I find information on why and what the ).read() part does. For some reason, posts from from this account don't seem to be making it through the gateway to usenet so I am only seeing what Mr. Rebert has replied to. If you have asked anything else, I very well may have missed it. > http://docs.python.org/py3k/library/urllib.request.html#urllib.request.urlopen > Specifically: "This function returns a file-like object" (representing > the stream of data received). Thus, .read() on the file-like object > returns the actual bytes obtained from the given URL. Mr. Rebert already answed your question; but, I will expand on that a little bit. One of the great things about the Python language is that it uses what is commonly known as "duck typing." That is anything object which provides the same attributes as another object can be used as though it is actually the second object. It is kind of like an implicit form of generics that doesn't require a template or an interface. The Python standard library makes extensive use of duck typing for file like objects. Any object that provides the proper method attributes can be given to functions that expect files even though the object is given might not be the traditional concept of a file on the filesystem. It might be a stringIO object, a socket file object, or something new that you have created that supports the required method attributes. The semantics and documentation for file like objects have changed a little for python2 vs. python3: python2: http://docs.python.org/library/stdtypes.html#file-objects python3: http://docs.python.org/py3k/library/io.html#io.IOBase but they still basically work the same way. Much of the Python 3 documentation still refers file objects. From roy at panix.com Thu Jan 6 08:21:38 2011 From: roy at panix.com (Roy Smith) Date: Thu, 06 Jan 2011 08:21:38 -0500 Subject: How suitable is Python to write system utilities? References: <8oloo6F566U1@mid.individual.net> Message-ID: In article <8oloo6F566U1 at mid.individual.net>, "J.O. Aho" wrote: > According to microsoft documentation, the recommendation is to run > defragmentation on ntfs on a regular bases. There seems to come some > improvement on the mft fragmentation, but still it feels long behind the > linux/unix file systems. > > Do you have any recent documentation on ntfs that shows it has the capability > to defragmentate itself other than mft? This is the best defragmenter for a windows file system is this: http://www.ubuntu.com/desktop/get-ubuntu/download From user at example.net Thu Jan 6 08:42:44 2011 From: user at example.net (J.O. Aho) Date: Thu, 06 Jan 2011 14:42:44 +0100 Subject: How suitable is Python to write system utilities? In-Reply-To: References: <8oloo6F566U1@mid.individual.net> Message-ID: <8olv6kFb8hU1@mid.individual.net> Roy Smith wrote: > In article <8oloo6F566U1 at mid.individual.net>, > "J.O. Aho" wrote: > >> According to microsoft documentation, the recommendation is to run >> defragmentation on ntfs on a regular bases. There seems to come some >> improvement on the mft fragmentation, but still it feels long behind the >> linux/unix file systems. >> >> Do you have any recent documentation on ntfs that shows it has the capability >> to defragmentate itself other than mft? > > This is the best defragmenter for a windows file system is this: > > http://www.ubuntu,com/desktop/get-ubuntu/download It depends on your taste, I favour to be able to customize quite a lot of my installation and those rather use a meta-distribution. As SourceMage ( www.sourcemage.org ) or Gentoo ( www.gentoo.org ). But your reply don't point at a ms-documentation about auto defragmentation of a file system. -- //Aho From private at private.com Thu Jan 6 08:44:08 2011 From: private at private.com (ana sanchez) Date: Thu, 6 Jan 2011 13:44:08 +0000 (UTC) Subject: why generator assigned to slice? References: Message-ID: In Peter Otten <__peter__ at web.de> writes: >ana sanchez wrote: >> i found this when i read the source of a program in python: >> >> self.__chunks[start:end] = (chunk for i in xrange(start, end)) >> what utility has to assign a generator to a slice??? ?the *final >> result* isn't the same as this?: >> >> self.__chunks[start:end] = [chunk for i in xrange(start, end)] >Whoever used the first variant probably was hoping that it was either faster >or used less peak memory. I think the latter is wrong, and the former can >easily be checked: >$ python -m timeit -s'chunk = "yadda"; chunks = range(100); start = 20; end >= 50' 'chunks[start:end] = (chunk for i in xrange(start, end))' >100000 loops, best of 3: 9.02 usec per loop >$ python -m timeit -s'chunk = "yadda"; chunks = range(100); start = 20; end >= 50' 'chunks[start:end] = [chunk for i in xrange(start, end)]' >100000 loops, best of 3: 4.16 usec per loop >$ python -m timeit -s'chunk = "yadda"; chunks = range(100); start = 20; end >= 50' 'chunks[start:end] = [chunk]*(end-start)' >1000000 loops, best of 3: 1.02 usec per loop peter thank you very much!!! (i like very much the timing "miniscripts") ana From Rob.Richardson at rad-con.com Thu Jan 6 08:50:51 2011 From: Rob.Richardson at rad-con.com (Rob Richardson) Date: Thu, 6 Jan 2011 08:50:51 -0500 Subject: Help with code-lists and strings In-Reply-To: Message-ID: <04A6DB42D2BA534FAC77B90562A6A03D01689A94@server.rad-con.local> Cathy, Please take another try at writing your program, using what advice you have received so far that you understand. I think this discussion is going rather far away from what you need, and seeing another step in the evolution of your program should help bring it back on track. I like your optimism! RobR From roy at panix.com Thu Jan 6 08:55:08 2011 From: roy at panix.com (Roy Smith) Date: Thu, 06 Jan 2011 08:55:08 -0500 Subject: How suitable is Python to write system utilities? References: <8oloo6F566U1@mid.individual.net> <8olv6kFb8hU1@mid.individual.net> Message-ID: In article <8olv6kFb8hU1 at mid.individual.net>, "J.O. Aho" wrote: > Roy Smith wrote: > > In article <8oloo6F566U1 at mid.individual.net>, > > "J.O. Aho" wrote: > > > >> According to microsoft documentation, the recommendation is to run > >> defragmentation on ntfs on a regular bases. There seems to come some > >> improvement on the mft fragmentation, but still it feels long behind the > >> linux/unix file systems. > >> > >> Do you have any recent documentation on ntfs that shows it has the > >> capability > >> to defragmentate itself other than mft? > > > > This is the best defragmenter for a windows file system is this: > > > > http://www.ubuntu,com/desktop/get-ubuntu/download > > It depends on your taste, I favour to be able to customize quite a lot of my > installation and those rather use a meta-distribution. > > As SourceMage ( www.sourcemage.org ) or Gentoo ( www.gentoo.org ). > > But your reply don't point at a ms-documentation about auto defragmentation > of > a file system. I think you missed the point :-) From david at boddie.org.uk Thu Jan 6 09:38:24 2011 From: david at boddie.org.uk (David Boddie) Date: Thu, 06 Jan 2011 15:38:24 +0100 Subject: How suitable is Python to write system utilities? References: Message-ID: On Thursday 06 January 2011 12:08, Alice Bevan?McGregor wrote: > Python does include libraries (and has available third-party libraries) > to interface with external low-level libraries of every kind, has > Python-native third-party libraries to do things like examine ELF > object files / executables, manipulate raw IP datagrams, etc, and it is > possible to access glib (and other C libraries or even Windows DLLs) > directly from within Python without creating wrapper interfaces. Just out of interest, which module/package are you using to examine ELF files? David From alice at gothcandy.com Thu Jan 6 10:06:17 2011 From: alice at gothcandy.com (=?utf-8?Q?Alice_Bevan=E2=80=93McGregor?=) Date: Thu, 6 Jan 2011 07:06:17 -0800 Subject: How suitable is Python to write system utilities? References: Message-ID: On 2011-01-06 06:38:24 -0800, David Boddie said: > Just out of interest, which module/package are you using to examine ELF files? http://pypi.python.org/pypi/elffile - Alice. From dmitrey.kroshko at scipy.org Thu Jan 6 10:28:49 2011 From: dmitrey.kroshko at scipy.org (dmitrey) Date: Thu, 6 Jan 2011 07:28:49 -0800 (PST) Subject: PEP: possibility of inline using of a symbol instead of "import" Message-ID: <0952cc24-097d-4685-a92d-75054406ddf3@f20g2000vbc.googlegroups.com> hi all, I have th PEP (I'm not sure something like that hadn't been proposed although): very often in a Python file header the following lines are present, like: from MyModule1 import myFunc1 import MyModule2 as mm2 from MyModule3 import myFunc3 as mf3 etc and after several pages of code they are using somewhere, maybe only one time, e.g. r1 = myFunc1(...) r2 = mm2.myFunc2(...) r3 = mf3(...) It makes programs less clear, you have to scroll several pages of code in IDE to understand what it refers to. I propose to add possibility of using a symbol instead (for simplicity I use @ here, that is already reserved for decorators, thus it should be other symbol, maybe from Unicode although for simplicity to type it I would prefer something ordinary like $ or ` or !). e.g. instead of import MyModule (...lots of code...) r = MyModule.myFunc(...) someone could just type in the single place r = @MyModule.myFunc(...) Also, "import MyModule2 as mm2" could be replaced to mere mm2 = @MyModule2 and "from MyModule3 import myFunc3 as mf3" could be replaced to mere "mf3 = @MyModule3.myFunc3". As for __import__(ModuleTextName), it could be replaced to something like @(ModuleTextName) or @{ModuleTextName} or @[ModuleTextName]. Regards, D. From shahmed at sfwmd.gov Thu Jan 6 10:51:42 2011 From: shahmed at sfwmd.gov (Ahmed, Shakir) Date: Thu, 6 Jan 2011 10:51:42 -0500 Subject: list from FTP server to a text file In-Reply-To: References: Message-ID: <77F33A87D54B2F47AB06A81DA7B5252736DBED@EXCHVS02.ad.sfwmd.gov> Hi, I am trying to create a list in a txt file from an ftp server. The following code is retrieving the list of the files but could not able to write in a text file. Any help is highly appreciated. Thanks **************************** import os import time from ftplib import FTP ftp = FTP("*.org","","") # connect to host, default port ftp.login() ftp.cwd("/pub/remotefolder/") ftp.retrlines('NLST') ****************************** From usernet at ilthio.net Thu Jan 6 10:57:46 2011 From: usernet at ilthio.net (Tim Harig) Date: Thu, 6 Jan 2011 15:57:46 +0000 (UTC) Subject: PEP: possibility of inline using of a symbol instead of "import" References: <0952cc24-097d-4685-a92d-75054406ddf3@f20g2000vbc.googlegroups.com> Message-ID: On 2011-01-06, dmitrey wrote: > and after several pages of code they are using somewhere, maybe only > one time, e.g. [SNIP] > It makes programs less clear, you have to scroll several pages of code > in IDE to understand what it refers to. Python doesn't require imports to be at the top of a file. They can be imported at any time. > import MyModule > (...lots of code...) > r = MyModule.myFunc(...) (...lots of code...) import MyModule r = MyModule.myFunc(...) From duncan.booth at invalid.invalid Thu Jan 6 11:02:40 2011 From: duncan.booth at invalid.invalid (Duncan Booth) Date: 6 Jan 2011 16:02:40 GMT Subject: PEP: possibility of inline using of a symbol instead of "import" References: <0952cc24-097d-4685-a92d-75054406ddf3@f20g2000vbc.googlegroups.com> Message-ID: dmitrey wrote: > e.g. instead of > > import MyModule > (...lots of code...) > r = MyModule.myFunc(...) > > someone could just type in the single place > > r = @MyModule.myFunc(...) > > Also, "import MyModule2 as mm2" could be replaced to mere > mm2 = @MyModule2 > and "from MyModule3 import myFunc3 as mf3" could be replaced to mere > "mf3 = @MyModule3.myFunc3". If you just import the modules at the top of the file then there's nothing to prevent you writing: mm2 = MyModule2 mf3 = MyModule3.myFunc3 without any punctuation to obscure the meaning. Your complaint seems to be that: r1 = myFunc1(...) is unclear when you don't know where myfunc1 originates, so why don't you write: r1 = MyModule1.myFunc1(...) -- Duncan Booth http://kupuguy.blogspot.com From dmitrey.kroshko at scipy.org Thu Jan 6 11:03:35 2011 From: dmitrey.kroshko at scipy.org (dmitrey) Date: Thu, 6 Jan 2011 08:03:35 -0800 (PST) Subject: PEP: possibility of inline using of a symbol instead of "import" References: <0952cc24-097d-4685-a92d-75054406ddf3@f20g2000vbc.googlegroups.com> Message-ID: <1201388b-16b8-4452-9a1f-c9aa00b126e7@p38g2000vbn.googlegroups.com> Yes, I know, still usually it is placed in file header On Jan 6, 5:57?pm, Tim Harig wrote: > Python doesn't require imports to be at the top of a file. ?They can be > imported at any time. > > > import MyModule > > (...lots of code...) > > r = MyModule.myFunc(...) > > (...lots of code...) > import MyModule > r = MyModule.myFunc(...) From catdude at gmail.com Thu Jan 6 11:06:12 2011 From: catdude at gmail.com (Dan M) Date: Thu, 06 Jan 2011 10:06:12 -0600 Subject: list from FTP server to a text file References: Message-ID: <4-ednbGsULvpdbjQnZ2dnUVZ5rudnZ2d@giganews.com> On Thu, 06 Jan 2011 10:51:42 -0500, Ahmed, Shakir wrote: > Hi, > > I am trying to create a list in a txt file from an ftp server. The > following code is retrieving the list of the files but could not able to > write in a text file. Any help is highly appreciated. > > Thanks > > > > **************************** > import os > import time > from ftplib import FTP > ftp = FTP("*.org","","") # connect to host, default port ftp.login() > ftp.cwd("/pub/remotefolder/") > ftp.retrlines('NLST') > ****************************** WARNING: I am a newbie! Expect more pythonic ways to do this in other replies from ftplib import FTP ftp = FTP("host", "user", "pass") ftp.cwd("/pub/myfolder") files = ftp.nlst(".") f = open('files.txt', 'w') for file in files: f.write('%s\n' % (file,)) f.close() From wanderer at dialup4less.com Thu Jan 6 11:11:34 2011 From: wanderer at dialup4less.com (Wanderer) Date: Thu, 6 Jan 2011 08:11:34 -0800 (PST) Subject: find in smartpdf files Message-ID: <4f69bdf1-2e68-4a6b-8110-09f0f5517387@k9g2000pre.googlegroups.com> We generate PCB assembly files in pdf format using SmartPDF. This allows us to search for a component in the assembly using the find feature. We would like to be able to generate a list of components sorted by part type and then use that list to cycle through a search by ref designator in the pdf file. Is there a way to use Python scripts to interface PDF files? Thanks From catdude at gmail.com Thu Jan 6 11:20:00 2011 From: catdude at gmail.com (Dan M) Date: Thu, 06 Jan 2011 10:20:00 -0600 Subject: find in smartpdf files References: <4f69bdf1-2e68-4a6b-8110-09f0f5517387@k9g2000pre.googlegroups.com> Message-ID: <4-ednbOsULstdrjQnZ2dnUVZ5rudnZ2d@giganews.com> On Thu, 06 Jan 2011 08:11:34 -0800, Wanderer wrote: > We generate PCB assembly files in pdf format using SmartPDF. This allows > us to search for a component in the assembly using the find feature. We > would like to be able to generate a list of components sorted by part > type and then use that list to cycle through a search by ref designator > in the pdf file. Is there a way to use Python scripts to interface PDF > files? > > Thanks Would PDFMiner help with your task? http://www.unixuser.org/~euske/python/pdfminer/index.html From dwdreisigmeyer at gmail.com Thu Jan 6 11:23:49 2011 From: dwdreisigmeyer at gmail.com (David) Date: Thu, 6 Jan 2011 08:23:49 -0800 (PST) Subject: Convert arbitrary function inputs to string Message-ID: Hi, I'd like to have a function that takes arbitrary inputs and returns them as a single string, with proper escapes for special characters I can define. For example: fun( ( + 1 2 ) ) => "( + 1 2)" or fun( (define (myhello str) (begin (print (string-append "Hello " str)) (newline) )) ) => "(define (myhello str) (begin (print (string-append \"Hello \" str)) (newline) ))" Thanks, -Dave From usernet at ilthio.net Thu Jan 6 11:32:31 2011 From: usernet at ilthio.net (Tim Harig) Date: Thu, 6 Jan 2011 16:32:31 +0000 (UTC) Subject: PEP: possibility of inline using of a symbol instead of "import" References: <0952cc24-097d-4685-a92d-75054406ddf3@f20g2000vbc.googlegroups.com> <1201388b-16b8-4452-9a1f-c9aa00b126e7@p38g2000vbn.googlegroups.com> Message-ID: On 2011-01-06, dmitrey wrote: [re-ordered] > On Jan 6, 5:57?pm, Tim Harig wrote: >> Python doesn't require imports to be at the top of a file. ?They can be >> imported at any time. >> >> > import MyModule >> > (...lots of code...) >> > r = MyModule.myFunc(...) >> >> (...lots of code...) >> import MyModule >> r = MyModule.myFunc(...) > > Yes, I know, still usually it is placed in file header 1. Don't top post. 2. Your so-called PEP probably clashes with Python's use of @ for decorators. 3. Do you really expect a language holding the mantra that there should be a single way of doing things to embrace a language bloating feature for what is effectively already possible with the language as it exists? From wanderer at dialup4less.com Thu Jan 6 11:33:14 2011 From: wanderer at dialup4less.com (Wanderer) Date: Thu, 6 Jan 2011 08:33:14 -0800 (PST) Subject: find in smartpdf files References: <4f69bdf1-2e68-4a6b-8110-09f0f5517387@k9g2000pre.googlegroups.com> <4-ednbOsULstdrjQnZ2dnUVZ5rudnZ2d@giganews.com> Message-ID: <4d74bf8f-38c0-4972-b1bc-06307c9a0668@k9g2000pre.googlegroups.com> On Jan 6, 11:20?am, Dan M wrote: > On Thu, 06 Jan 2011 08:11:34 -0800, Wanderer wrote: > > We generate PCB assembly files in pdf format using SmartPDF. This allows > > us to search for a component in the assembly using the find feature. We > > would like to be able to generate a list of components sorted by part > > type and then use that list to cycle through a search by ref designator > > in the pdf file. Is there a way to use Python scripts to interface PDF > > files? > > > Thanks > > Would PDFMiner help with your task?http://www.unixuser.org/~euske/python/pdfminer/index.html I'm not sure. I'll check it out. From jeanmichel at sequans.com Thu Jan 6 11:34:57 2011 From: jeanmichel at sequans.com (Jean-Michel Pichavant) Date: Thu, 06 Jan 2011 17:34:57 +0100 Subject: Convert arbitrary function inputs to string In-Reply-To: References: Message-ID: <4D25EF31.1050608@sequans.com> David wrote: > Hi, > > I'd like to have a function that takes arbitrary inputs and returns > them as a single string, with proper escapes for special characters I > can define. For example: > > fun( ( + 1 2 ) ) > => "( + 1 2)" > > or > > fun( (define (myhello str) (begin (print (string-append "Hello " > str)) (newline) )) ) > => "(define (myhello str) (begin (print (string-append \"Hello \" > str)) (newline) ))" > > Thanks, > > -Dave > Are you talking about python ?? fun( ( + 1 2 ) ) File "", line 1 fun( ( + 1 2 ) ) ^ SyntaxError: invalid syntax From mrmakent at cox.net Thu Jan 6 11:40:16 2011 From: mrmakent at cox.net (Mike Kent) Date: Thu, 6 Jan 2011 08:40:16 -0800 (PST) Subject: PEP: possibility of inline using of a symbol instead of "import" References: <0952cc24-097d-4685-a92d-75054406ddf3@f20g2000vbc.googlegroups.com> Message-ID: <6f5c2fd1-6e72-4b55-88a2-efcce0e9724b@z17g2000prz.googlegroups.com> On Jan 6, 11:02?am, Duncan Booth wrote: > Your complaint seems to be that: > > ? ?r1 = myFunc1(...) > > is unclear when you don't know where myfunc1 originates, so why don't > you write: > > ? ?r1 = MyModule1.myFunc1(...) > > -- > Duncan Boothhttp://kupuguy.blogspot.com My interpretation of his proposal is a bit different. I thought he meant that '@MyModule.myFunc' (yes, using '@' here is bad, but for conversation sake...) would cause MyModule to be imported if this was the first time '@MyModule' was encountered in the current module. Sort of an implied 'import MyModule', which would eliminate the need to actually use the explicit import. My reaction to his proposal is 'Meh.' Explicit is better than implicit. Python is not Perl. From eva_maia at sapo.pt Thu Jan 6 11:41:21 2011 From: eva_maia at sapo.pt (Eva Maia) Date: Thu, 06 Jan 2011 16:41:21 +0000 Subject: type of methods of builtin exceptions Message-ID: <4D25F0B1.5030905@sapo.pt> Hi, anyone has a list of the types of methods of builtin exceptions. For example, for the exception BaseException i need to know the type of arguments method __reduce__ and type of your return. Thanks, Eva Maia From ian.g.kelly at gmail.com Thu Jan 6 11:41:36 2011 From: ian.g.kelly at gmail.com (Ian) Date: Thu, 6 Jan 2011 08:41:36 -0800 (PST) Subject: Convert arbitrary function inputs to string References: Message-ID: <0f1768db-1636-4afd-8cec-f1724b55529a@c39g2000yqi.googlegroups.com> On Jan 6, 9:23?am, David wrote: > Hi, > > I'd like to have a function that takes arbitrary inputs and returns > them as a single string, with proper escapes for special characters I > can define. ?For example: What sorts of arbitrary inputs? Strings? Sequences of strings? Something else? It's not clear from your examples, which use invalid syntax. If you're looking for something like the "quote" form from Lisp, you can't really do that in Python. Just use a string. Cheers, Ian From dwdreisigmeyer at gmail.com Thu Jan 6 11:42:23 2011 From: dwdreisigmeyer at gmail.com (David Dreisigmeyer) Date: Thu, 6 Jan 2011 11:42:23 -0500 Subject: Convert arbitrary function inputs to string In-Reply-To: <4D25EF31.1050608@sequans.com> References: <4D25EF31.1050608@sequans.com> Message-ID: Yes, I'm calling Gambit-C from Python and would like to make this cleaner. Instead of having to do something like: gambit.eval ("(print \"Hello\n\")") I want to do this: gambit.eval (print "Hello\n") so that the expression following gambit.eval is a standard scheme expression. On Thu, Jan 6, 2011 at 11:34 AM, Jean-Michel Pichavant wrote: > David wrote: >> >> Hi, >> >> I'd like to have a function that takes arbitrary inputs and returns >> them as a single string, with proper escapes for special characters I >> can define. ?For example: >> >> fun( ( + 1 2 ) ) >> => "( + 1 2)" >> >> or >> >> fun( ?(define (myhello str) (begin (print (string-append "Hello " >> str)) (newline) )) ) >> => ?"(define (myhello str) (begin (print (string-append \"Hello \" >> str)) (newline) ))" >> >> Thanks, >> >> -Dave >> > > Are you talking about python ?? > > fun( ( + 1 2 ) ) > ?File "", line 1 > ? fun( ( + 1 2 ) ) > ? ? ? ? ? ? ?^ > SyntaxError: invalid syntax > > From shahmed at sfwmd.gov Thu Jan 6 11:48:16 2011 From: shahmed at sfwmd.gov (Ahmed, Shakir) Date: Thu, 6 Jan 2011 11:48:16 -0500 Subject: list from FTP server to a text file In-Reply-To: <4-ednbGsULvpdbjQnZ2dnUVZ5rudnZ2d@giganews.com> References: <4-ednbGsULvpdbjQnZ2dnUVZ5rudnZ2d@giganews.com> Message-ID: <77F33A87D54B2F47AB06A81DA7B5252736DBEE@EXCHVS02.ad.sfwmd.gov> -----Original Message----- From: python-list-bounces+shahmed=sfwmd.gov at python.org [mailto:python-list-bounces+shahmed=sfwmd.gov at python.org] On Behalf Of Dan M Sent: Thursday, January 06, 2011 11:06 AM To: python-list at python.org Subject: Re: list from FTP server to a text file On Thu, 06 Jan 2011 10:51:42 -0500, Ahmed, Shakir wrote: > Hi, > > I am trying to create a list in a txt file from an ftp server. The > following code is retrieving the list of the files but could not able to > write in a text file. Any help is highly appreciated. > > Thanks > > > > **************************** > import os > import time > from ftplib import FTP > ftp = FTP("*.org","","") # connect to host, default port ftp.login() > ftp.cwd("/pub/remotefolder/") > ftp.retrlines('NLST') > ****************************** WARNING: I am a newbie! Expect more pythonic ways to do this in other replies from ftplib import FTP ftp = FTP("host", "user", "pass") ftp.cwd("/pub/myfolder") files = ftp.nlst(".") f = open('files.txt', 'w') for file in files: f.write('%s\n' % (file,)) f.close() -- It worked Thanks, shk From ian.g.kelly at gmail.com Thu Jan 6 11:53:54 2011 From: ian.g.kelly at gmail.com (Ian) Date: Thu, 6 Jan 2011 08:53:54 -0800 (PST) Subject: Convert arbitrary function inputs to string References: <4D25EF31.1050608@sequans.com> Message-ID: On Jan 6, 9:42?am, David Dreisigmeyer wrote: > Yes, ?I'm calling Gambit-C from Python and would like to make this > cleaner. ?Instead of having to do something like: > > gambit.eval ("(print \"Hello\n\")") > > I want to do this: > > gambit.eval (print "Hello\n") > > so that the expression following gambit.eval is a standard scheme expression. That's much clearer. As I indicated in my previous email, there is no way to do this in Python. You might try using a raw multi-line string literal to reduce the amount of escaping you need to do. So this: "(print \"Hello\\n\")" becomes this: r"""(print "Hello\n")""" Cheers, Ian From ian.g.kelly at gmail.com Thu Jan 6 12:03:02 2011 From: ian.g.kelly at gmail.com (Ian) Date: Thu, 6 Jan 2011 09:03:02 -0800 (PST) Subject: PEP: possibility of inline using of a symbol instead of "import" References: <0952cc24-097d-4685-a92d-75054406ddf3@f20g2000vbc.googlegroups.com> <1201388b-16b8-4452-9a1f-c9aa00b126e7@p38g2000vbn.googlegroups.com> Message-ID: <7f726500-a9d1-45e2-8a7d-2236a9ef7845@p1g2000yqm.googlegroups.com> On Jan 6, 9:32?am, Tim Harig wrote: > 2. Your so-called PEP probably clashes with Python's use of @ for > ? ? ? ? decorators. > > 3. Do you really expect a language holding the mantra that there should be > ? ? ? ? a single way of doing things to embrace a language bloating feature > ? ? ? ? for what is effectively already possible with the language as it > ? ? ? ? exists? Isn't "Python's use of @ for decorators" a "language bloating feature for what [was] effectively already possible with the language as it [existed]?" ;-) Cheers, Ian From ian.g.kelly at gmail.com Thu Jan 6 12:09:34 2011 From: ian.g.kelly at gmail.com (Ian) Date: Thu, 6 Jan 2011 09:09:34 -0800 (PST) Subject: type of methods of builtin exceptions References: Message-ID: <7e4ef23e-8e31-4bce-8b8c-231cfdc6b92d@s5g2000yqm.googlegroups.com> On Jan 6, 9:41?am, Eva Maia wrote: > Hi, > > anyone has a list of the types of methods of builtin exceptions. For > example, for the exception BaseException i need to know the type of ? > arguments method __reduce__ and type of your return. http://docs.python.org/library/pickle.html?highlight=__reduce__#object.__reduce__ Another good place to start would be: http://docs.python.org/reference/datamodel.html#special-method-names Cheers, Ian From robert.kern at gmail.com Thu Jan 6 12:14:52 2011 From: robert.kern at gmail.com (Robert Kern) Date: Thu, 06 Jan 2011 11:14:52 -0600 Subject: Convert arbitrary function inputs to string In-Reply-To: References: <4D25EF31.1050608@sequans.com> Message-ID: On 1/6/11 10:42 AM, David Dreisigmeyer wrote: > Yes, I'm calling Gambit-C from Python and would like to make this > cleaner. Instead of having to do something like: > > gambit.eval ("(print \"Hello\n\")") > > I want to do this: > > gambit.eval (print "Hello\n") > > so that the expression following gambit.eval is a standard scheme expression. Sorry, Python's syntax is not extensible like this. -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco From robert.kern at gmail.com Thu Jan 6 12:17:04 2011 From: robert.kern at gmail.com (Robert Kern) Date: Thu, 06 Jan 2011 11:17:04 -0600 Subject: type of methods of builtin exceptions In-Reply-To: <4D25F0B1.5030905@sapo.pt> References: <4D25F0B1.5030905@sapo.pt> Message-ID: On 1/6/11 10:41 AM, Eva Maia wrote: > Hi, > > anyone has a list of the types of methods of builtin exceptions. For example, > for the exception BaseException i need to know the type of arguments method > __reduce__ and type of your return. http://docs.python.org/search.html?q=__reduce__&check_keywords=yes&area=default -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco From isaacrc82 at gmail.com Thu Jan 6 12:26:40 2011 From: isaacrc82 at gmail.com (Ariel) Date: Thu, 6 Jan 2011 12:26:40 -0500 Subject: I get an error when I used urllib2.urlopen() to open a remote file in a ftp server Message-ID: Hi everybody: I get an error when I used urllib2.urlopen() to open a remote file in a ftp server, My code is the following: >>> file = 'ftp:/192.168.250.14:2180/RTVE/VIDEOS/Thisisit.wmv' >>> mydata = urllib2.urlopen(file) Traceback (most recent call last): File "", line 1, in File "/usr/lib/python2.6/urllib2.py", line 126, in urlopen return _opener.open(url, data, timeout) File "/usr/lib/python2.6/urllib2.py", line 391, in open response = self._open(req, data) File "/usr/lib/python2.6/urllib2.py", line 409, in _open '_open', req) File "/usr/lib/python2.6/urllib2.py", line 369, in _call_chain result = func(*args) File "/usr/lib/python2.6/urllib2.py", line 1316, in ftp_open raise URLError('ftp error: no host given') URLError: But how you can see I get an error 'no host given'. Any idea how to solve this ? Could you help me please ? Regards Ariel -------------- next part -------------- An HTML attachment was scrubbed... URL: From python.list at tim.thechases.com Thu Jan 6 12:32:12 2011 From: python.list at tim.thechases.com (Tim Chase) Date: Thu, 06 Jan 2011 11:32:12 -0600 Subject: PEP: possibility of inline using of a symbol instead of "import" In-Reply-To: References: <0952cc24-097d-4685-a92d-75054406ddf3@f20g2000vbc.googlegroups.com> <1201388b-16b8-4452-9a1f-c9aa00b126e7@p38g2000vbn.googlegroups.com> Message-ID: <4D25FC9C.1010704@tim.thechases.com> On 01/06/2011 10:32 AM, Tim Harig wrote: > 2. Your so-called PEP probably clashes with Python's use of @ for > decorators. > > 3. Do you really expect a language holding the mantra that there should be > a single way of doing things to embrace a language bloating feature > for what is effectively already possible with the language as it > exists? Just as a side note, decorators (your #2, and an approved PEP) do exactly what you mention in #3, as @my_decorator def my_func(...): pass could just as well be written as def my_func(...): pass my_func = my_decorator(my_func) so you #3 point is counterargued by your #2 point :-/ So the powers-that-be have certainly deemed *some* level of syntactic sugar worthwhile. That said, I'm -1 (okay, -0.5) on the OP's suggestion, both in terms of the syntax clashing with decorators, and the need for syntactic sugar in this case. -tkc From ian.g.kelly at gmail.com Thu Jan 6 12:55:22 2011 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Thu, 6 Jan 2011 10:55:22 -0700 Subject: I get an error when I used urllib2.urlopen() to open a remote file in a ftp server In-Reply-To: References: Message-ID: On Thu, Jan 6, 2011 at 10:26 AM, Ariel wrote: > Hi everybody: > > I get an error when I used urllib2.urlopen() to open a remote file in a ftp > server, My code is the following: > >>>> file = 'ftp:/192.168.250.14:2180/RTVE/VIDEOS/Thisisit.wmv' Looks to me like you're missing a slash separating the protocol from the hostname. Try 'ftp://' instead of 'ftp:/'. From xahlee at gmail.com Thu Jan 6 12:55:49 2011 From: xahlee at gmail.com (Xah Lee) Date: Thu, 6 Jan 2011 09:55:49 -0800 (PST) Subject: opinion: comp lang docs style References: <98e82f1b-cf59-4e64-8fd4-63671f96b04f@r19g2000prm.googlegroups.com> <4745479a-10c5-4281-9dcd-c9d7b013a1ec@k13g2000vbq.googlegroups.com> Message-ID: <02827749-bed2-47d8-81cf-a2c3231b2940@u25g2000pra.googlegroups.com> On Jan 4, 3:17?pm, "ru... at yahoo.com" wrote: > On 01/04/2011 01:34 PM, Terry Reedy wrote: > > > On 1/4/2011 1:24 PM, an Arrogant Ignoramus wrote: > > > what he called > >> a opinion piece. > > > I normally do not respond to trolls, but while expressing his opinions, > > AI made statements that are factually wrong at least as regards Python > > and its practitioners. > > Given that most trolls include factually false statements, > the above is inconsistent. ?And speaking of arrogant, it > is just that to go around screaming "troll" about a posting > relevant to the newsgroup it was posted in because you don't > happen to agree with its content. ?In doing so you lower > your own credibility. ?(Which is also not helped by your > "Arrogant Ignoramus" name-calling.) yeah. i called them idiots, he calls me Artificial Intelligence ?. fair game. > No. ?The language reference (LR) and standard library reference > (SLR) must stand on their own merits. ?It is nice to have a good > tutorial for those who like that style of learning. ?But it should > be possible for a programmer with a basic understanding of computers > and some other programming languages to understand how to program > in python without referring to tutorials, explanatory websites, > commercially published books, the source code, etc. yes exactly. the best python reference to me is Richard Gruet's quick ref: http://rgruet.free.fr/PQR26/PQR2.6.html on the python doc, afaik people complains all the time, and i know at least 3 times in different years people have tried to bring up projects to fix it, all shot down with spit badly by python priests, of course. just 2 days ago, i was pissed due to python doc url disappearance too http://xahlee.org/perl-python/python_doc_url_disappearance.html Xah From awilliam at whitemice.org Thu Jan 6 13:00:39 2011 From: awilliam at whitemice.org (Adam Tauno Williams) Date: Thu, 06 Jan 2011 13:00:39 -0500 Subject: Streaming templating languages for use as WSGI body. In-Reply-To: References: Message-ID: <1294336839.10436.2.camel@linux-yu4c.site> On Wed, 2011-01-05 at 14:56 -0800, Alice Bevan?McGregor wrote: > Howdy! > I'm trying to find a templating engine whose templates can be consumed > directly as a WSGI response body iterable. So far I haven't been very > successful with Google; the engines I've found universally generate a > monolithic rendered string. With HTTP/1.0 [and WSGI is HTTP/1.0 only] you have to provide a Content-Length header - so you have to generate the entire response at once [however you want to muddy "at once"]. Streaming responses to the client requires Chunked-Encoding [HTTP/1.1] which is not possible via WSGI. It took me quite awhile to believe that, but there it is. I ditched WSGI; handling HTTP isn't that hard. From devent at deventm.org Thu Jan 6 13:43:29 2011 From: devent at deventm.org (Erwin Mueller) Date: Thu, 6 Jan 2011 19:43:29 +0100 Subject: PEP: possibility of inline using of a symbol instead of "import" In-Reply-To: <0952cc24-097d-4685-a92d-75054406ddf3@f20g2000vbc.googlegroups.com> References: <0952cc24-097d-4685-a92d-75054406ddf3@f20g2000vbc.googlegroups.com> Message-ID: <201101061943.30101.devent@deventm.org> On Thursday 06 January 2011 16:28:49 dmitrey wrote: > hi all, > I have th PEP (I'm not sure something like that hadn't been proposed > although): > very often in a Python file header the following lines are present, > like: > from MyModule1 import myFunc1 > import MyModule2 as mm2 > from MyModule3 import myFunc3 as mf3 > etc > > and after several pages of code they are using somewhere, maybe only > one time, e.g. > r1 = myFunc1(...) > r2 = mm2.myFunc2(...) > r3 = mf3(...) > It makes programs less clear, you have to scroll several pages of code > in IDE to understand what it refers to. > > Regards, D. Why you have several pages of code in the first place? Don't you know that you can split your code in files? Just a suggestion. -- Erwin Mueller, devent at deventm.org http://www.global-scaling-institute.de/ From isaacrc82 at gmail.com Thu Jan 6 13:59:24 2011 From: isaacrc82 at gmail.com (Ariel) Date: Thu, 6 Jan 2011 13:59:24 -0500 Subject: I get an error when I used urllib2.urlopen() to open a remote file in a ftp server In-Reply-To: References: Message-ID: You are right, Thanks. On Thu, Jan 6, 2011 at 12:55 PM, Ian Kelly wrote: > On Thu, Jan 6, 2011 at 10:26 AM, Ariel wrote: > > Hi everybody: > > > > I get an error when I used urllib2.urlopen() to open a remote file in a > ftp > > server, My code is the following: > > > >>>> file = 'ftp:/192.168.250.14:2180/RTVE/VIDEOS/Thisisit.wmv' > > Looks to me like you're missing a slash separating the protocol from > the hostname. Try 'ftp://' instead of 'ftp:/'. > -------------- next part -------------- An HTML attachment was scrubbed... URL: From alice at gothcandy.com Thu Jan 6 14:07:22 2011 From: alice at gothcandy.com (=?utf-8?Q?Alice_Bevan=E2=80=93McGregor?=) Date: Thu, 6 Jan 2011 11:07:22 -0800 Subject: Streaming templating languages for use as WSGI body. References: <1294336839.10436.2.camel@linux-yu4c.site> Message-ID: On 2011-01-06 10:00:39 -0800, Adam Tauno Williams said: > With HTTP/1.0 [and WSGI is HTTP/1.0 only] you have to provide a > Content-Length header - so you have to generate the entire response at > once [however you want to muddy "at once"]. Both of these statements are false. > Streaming responses to the client requires Chunked-Encoding [HTTP/1.1] > which is not possible via WSGI. This is also false. Oh for three, please try again. :) - Alice. From awilliam at whitemice.org Thu Jan 6 14:11:27 2011 From: awilliam at whitemice.org (Adam Tauno Williams) Date: Thu, 06 Jan 2011 14:11:27 -0500 Subject: Streaming templating languages for use as WSGI body. In-Reply-To: References: <1294336839.10436.2.camel@linux-yu4c.site> Message-ID: <1294341087.14042.3.camel@linux-yu4c.site> On Thu, 2011-01-06 at 11:07 -0800, Alice Bevan?McGregor wrote: > On 2011-01-06 10:00:39 -0800, Adam Tauno Williams said: > > > With HTTP/1.0 [and WSGI is HTTP/1.0 only] you have to provide a > > Content-Length header - so you have to generate the entire response at > > once [however you want to muddy "at once"]. > Both of these statements are false. Both these statements are true! I suggest you consult the HTTP spec. A valid Content-Length field value is required on all HTTP/1.0 request messages containing an entity body. > > Streaming responses to the client requires Chunked-Encoding [HTTP/1.1] > > which is not possible via WSGI. > This is also false. You claim of falsehood is false. > Oh for three, please try again. :) OK. From nagle at animats.com Thu Jan 6 14:11:47 2011 From: nagle at animats.com (John Nagle) Date: Thu, 06 Jan 2011 11:11:47 -0800 Subject: Trying to decide between PHP and Python In-Reply-To: References: Message-ID: <4d2613ef$0$44009$742ec2ed@news.sonic.net> On 1/4/2011 12:20 PM, Google Poster wrote: > > About once a year, I have to learn yet another programming language. > Given all the recommendations (an outstanding accolade from Bruce > Eckel, author of "Thinking in Java") I have set my aim to Python. > Sounds kinda cool. If you're just doing simple web-based services, PHP is the way of least resistance. It's supported by almost all hosting services. Trying to run Python on shared hosting is generally painful. Either you're stuck running in CGI, which means you take the cost of a Python load on every transaction, or you have to find someone who will let you run long-running processes so you can run FCGI/WSGI or some Python framework. Efforts to compile PHP to hard code have been more successful than the corresponding efforts for Python. Facebook developed and uses their HipHop compiler for their huge internal PHP code base. John Nagle From dmitrey.kroshko at scipy.org Thu Jan 6 14:42:16 2011 From: dmitrey.kroshko at scipy.org (dmitrey) Date: Thu, 6 Jan 2011 11:42:16 -0800 (PST) Subject: PEP: possibility of inline using of a symbol instead of "import" References: <0952cc24-097d-4685-a92d-75054406ddf3@f20g2000vbc.googlegroups.com> Message-ID: <5b21224a-edb7-49dd-8a41-2b16dbd4afcd@q18g2000vbk.googlegroups.com> On Jan 6, 8:43?pm, Erwin Mueller wrote: > > Why you have several pages of code in the first place? Don't you know that you > can split your code in files? Just a suggestion. > > -- > Erwin Mueller, dev... at deventm.orghttp://www.global-scaling-institute.de/ Erwin, take a look at Python language developers source code and see how many files have *tens* of pages. Or any other mature soft, e.g. numpy or scipy. Also, possibility of splitting *my* files doesn't matter I can split other files I deal with, e.g. written by other programmers. D. From subscriptions at cagttraining.com Thu Jan 6 14:44:13 2011 From: subscriptions at cagttraining.com (Bill Felton) Date: Thu, 6 Jan 2011 14:44:13 -0500 Subject: Can I have both Python 2.7 and Python 3.1 at the same time on the Mac? Message-ID: <775A9D45-25B5-4A16-9FE5-6217FD67F3AF@cagttraining.com> Hi All, I'm new to python, trying to learn it from a variety of resources, including references posted recently to this list. I'm going through /www.openbookproject.net/thinkCSpy/ and find it makes use of gasp, which apparently is not compatible with 3.1. I've also seen various resources indicate that one can install both Python 2.7 and Python 3.1 -- but when I did this, I get no end of problems in the 2.7 install. IDLE, in particular, fails rather spectacularly, even if I launch it directly from the Python 2.7 directory in which it resides. So, either I've been misled and should only try to have one or the other. OR I'm missing some (probably simple) step that's mucking me up. Help? Thanks, Bill From greno at verizon.net Thu Jan 6 14:51:10 2011 From: greno at verizon.net (Gerry Reno) Date: Thu, 06 Jan 2011 14:51:10 -0500 Subject: Can I have both Python 2.7 and Python 3.1 at the same time on the Mac? In-Reply-To: <775A9D45-25B5-4A16-9FE5-6217FD67F3AF@cagttraining.com> References: <775A9D45-25B5-4A16-9FE5-6217FD67F3AF@cagttraining.com> Message-ID: <4D261D2E.5070701@verizon.net> On 01/06/2011 02:44 PM, Bill Felton wrote: > Hi All, > I'm new to python, trying to learn it from a variety of resources, including references posted recently to this list. > I'm going through /www.openbookproject.net/thinkCSpy/ and find it makes use of gasp, which apparently is not compatible with 3.1. > I've also seen various resources indicate that one can install both Python 2.7 and Python 3.1 -- but when I did this, I get no end of problems in the 2.7 install. IDLE, in particular, fails rather spectacularly, even if I launch it directly from the Python 2.7 directory in which it resides. > So, either I've been misled and should only try to have one or the other. OR I'm missing some (probably simple) step that's mucking me up. > Help? > > Thanks, > Bill > > > You probably want to use 'virtualenv' for keeping things separated. From robert.kern at gmail.com Thu Jan 6 15:23:57 2011 From: robert.kern at gmail.com (Robert Kern) Date: Thu, 06 Jan 2011 14:23:57 -0600 Subject: PEP: possibility of inline using of a symbol instead of "import" In-Reply-To: <201101061943.30101.devent@deventm.org> References: <0952cc24-097d-4685-a92d-75054406ddf3@f20g2000vbc.googlegroups.com> <201101061943.30101.devent@deventm.org> Message-ID: On 1/6/11 12:43 PM, Erwin Mueller wrote: > On Thursday 06 January 2011 16:28:49 dmitrey wrote: >> hi all, >> I have th PEP (I'm not sure something like that hadn't been proposed >> although): >> very often in a Python file header the following lines are present, >> like: >> from MyModule1 import myFunc1 >> import MyModule2 as mm2 >> from MyModule3 import myFunc3 as mf3 >> etc >> >> and after several pages of code they are using somewhere, maybe only >> one time, e.g. >> r1 = myFunc1(...) >> r2 = mm2.myFunc2(...) >> r3 = mf3(...) >> It makes programs less clear, you have to scroll several pages of code >> in IDE to understand what it refers to. >> >> Regards, D. > > Why you have several pages of code in the first place? Don't you know that you > can split your code in files? Just a suggestion. Modules *should* have several pages of code. *Functions* should be limited to about a page of code at maximum. -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco From clp2 at rebertia.com Thu Jan 6 15:41:38 2011 From: clp2 at rebertia.com (Chris Rebert) Date: Thu, 6 Jan 2011 12:41:38 -0800 Subject: Trying to decide between PHP and Python In-Reply-To: <4d2613ef$0$44009$742ec2ed@news.sonic.net> References: <4d2613ef$0$44009$742ec2ed@news.sonic.net> Message-ID: On Thu, Jan 6, 2011 at 11:11 AM, John Nagle wrote: > On 1/4/2011 12:20 PM, Google Poster wrote: >> >> About once a year, I have to learn yet another programming language. >> Given all the recommendations (an outstanding accolade from Bruce >> Eckel, author of "Thinking in Java") I have set my aim to Python. >> Sounds kinda cool. > > ? ?If you're just doing simple web-based services, PHP is the > way of least resistance. ?It's supported by almost all hosting > services. ?Trying to run Python on shared hosting is generally > painful. ?Either you're stuck running in CGI, which means you > take the cost of a Python load on every transaction, or you > have to find someone who will let you run long-running > processes so you can run FCGI/WSGI or some Python framework. VPS hosting can be surprisingly cheap these days though (e.g. prgmr's super-cheapo plan is $4-5/month); you get root access, so setting up a Python web application is much easier. Cheers, Chris From nad at acm.org Thu Jan 6 15:46:12 2011 From: nad at acm.org (Ned Deily) Date: Thu, 06 Jan 2011 12:46:12 -0800 Subject: Can I have both Python 2.7 and Python 3.1 at the same time on the Mac? References: <775A9D45-25B5-4A16-9FE5-6217FD67F3AF@cagttraining.com> Message-ID: In article <775A9D45-25B5-4A16-9FE5-6217FD67F3AF at cagttraining.com>, Bill Felton wrote: > I'm new to python, trying to learn it from a variety of resources, including > references posted recently to this list. > I'm going through /www.openbookproject.net/thinkCSpy/ and find it makes use > of gasp, which apparently is not compatible with 3.1. > I've also seen various resources indicate that one can install both Python > 2.7 and Python 3.1 -- but when I did this, I get no end of problems in the > 2.7 install. IDLE, in particular, fails rather spectacularly, even if I > launch it directly from the Python 2.7 directory in which it resides. > So, either I've been misled and should only try to have one or the other. OR > I'm missing some (probably simple) step that's mucking me up. > Help? Yes, you can have multiple versions of Python installed on Mac OS X. In fact, Apple ships multiple versions of Python with OS X (2.6 and 2.6 with OS X 10.6, for example). Starting with Python 2.7, python.org offers two variants of OS X installers, one is 32-bit-only and works on all versions of OS X 10.3.9 through OS X 10.6, the other supports 64-bit execution and only works on 10.6 (as of 2.7.1). Unfortunately, there are some major interaction problems between Tkinter, Python's GUI toolkit which is used by IDLE, and the Tcl/Tk 8.5 supplied by Apple in OS X 10.6. I'm assuming you installed the 64-bit version. If so, until the problem is resolved in the next maintenance release of Python 2.7, I suggest you download and install the 32-bit-only version of Python 2.7.1 which does not have those problems. -- Ned Deily, nad at acm.org From nagle at animats.com Thu Jan 6 15:54:20 2011 From: nagle at animats.com (John Nagle) Date: Thu, 06 Jan 2011 12:54:20 -0800 Subject: Trying to decide between PHP and Python In-Reply-To: References: <4d2613ef$0$44009$742ec2ed@news.sonic.net> Message-ID: <4d262bf8$0$44066$742ec2ed@news.sonic.net> On 1/6/2011 12:41 PM, Chris Rebert wrote: > On Thu, Jan 6, 2011 at 11:11 AM, John Nagle wrote: >> On 1/4/2011 12:20 PM, Google Poster wrote: >>> >>> About once a year, I have to learn yet another programming language. >>> Given all the recommendations (an outstanding accolade from Bruce >>> Eckel, author of "Thinking in Java") I have set my aim to Python. >>> Sounds kinda cool. >> >> If you're just doing simple web-based services, PHP is the >> way of least resistance. It's supported by almost all hosting >> services. Trying to run Python on shared hosting is generally >> painful. Either you're stuck running in CGI, which means you >> take the cost of a Python load on every transaction, or you >> have to find someone who will let you run long-running >> processes so you can run FCGI/WSGI or some Python framework. > > VPS hosting can be surprisingly cheap these days though (e.g. prgmr's > super-cheapo plan is $4-5/month); you get root access, so setting up a > Python web application is much easier. That makes it possible, but not easier. If you're just running a typical web site with some "web 2.0" pages, forms, and a database, it's probably easier to use PHP. Administering a virtual machine instance puts you in the system administration business. With PHP, the hosting service will routinely handle that for you. You just create PHP pages, upload them, and the behind the scenes machinery is someone else's problem. If PHP breaks on shared hosting, enough users will be screaming that it gets fixed. John Nagle From ameyer2 at yahoo.com Thu Jan 6 15:57:25 2011 From: ameyer2 at yahoo.com (Alan Meyer) Date: Thu, 06 Jan 2011 15:57:25 -0500 Subject: PEP: possibility of inline using of a symbol instead of "import" In-Reply-To: <0952cc24-097d-4685-a92d-75054406ddf3@f20g2000vbc.googlegroups.com> References: <0952cc24-097d-4685-a92d-75054406ddf3@f20g2000vbc.googlegroups.com> Message-ID: <4D262CB5.90905@yahoo.com> On 1/6/2011 10:28 AM, dmitrey wrote: > hi all, > I have th PEP (I'm not sure something like that hadn't been proposed > although): > very often in a Python file header the following lines are present, > like: > from MyModule1 import myFunc1 > import MyModule2 as mm2 > from MyModule3 import myFunc3 as mf3 > etc ... Personally, I always do all of my imports at the top of every program I write and like it when others do the same. The reason is that, in a single glance, I can see all of the dependencies of the program. For similar reasons of explicit clarity I prefer this construct: import re pat = re.compile(...) To something like this one: from re import compile as cp pat = cp(...) The only benefit I can see from your proposal is that it cuts down slightly on the number of characters in a program, but I think it does so at the cost of reducing explicit clarity and increasing the learning burden for a programmer who will have to learn two techniques (if only so she can read other people's code) instead of one. Also, there are only 95 printable ASCII characters most of which are already dedicated to other uses (e.g., for use in variable names.) I would hate to reserve one to do something that can be done equally well without reserving a character. I applaud your interest in improving the language but I don't think the benefit justifies the cost in this case. Alan From nad at acm.org Thu Jan 6 16:15:25 2011 From: nad at acm.org (Ned Deily) Date: Thu, 06 Jan 2011 13:15:25 -0800 Subject: Can I have both Python 2.7 and Python 3.1 at the same time on the Mac? References: <775A9D45-25B5-4A16-9FE5-6217FD67F3AF@cagttraining.com> <4D261D2E.5070701@verizon.net> Message-ID: In article <4D261D2E.5070701 at verizon.net>, Gerry Reno wrote: > On 01/06/2011 02:44 PM, Bill Felton wrote: [...] > > I've also seen various resources indicate that one can install both Python > > 2.7 and Python 3.1 -- but when I did this, I get no end of problems in the > > 2.7 install. IDLE, in particular, fails rather spectacularly, even if I > > launch it directly from the Python 2.7 directory in which it resides. > > So, either I've been misled and should only try to have one or the other. > > OR I'm missing some (probably simple) step that's mucking me up. > > Help? > You probably want to use 'virtualenv' for keeping things separated. There are certainly good reasons to use virtualenv but simply to distinguish between Py2 and Py3 is not one of them. There is no ambiguity, using a "standard" distribution on OS X or any other platform that I'm aware of, between Python 2 and Python 3 installations. (Or, at least, any ambiguity that virtualenv would help resolve.) While you could get into an ambiguous situation if you install things yourself and are not careful about which targets are installed (and some additional versioning endcases are being addressed in the upcoming Python 3.2 release), all python3-related scripts and libraries are generally installed with different names (i.e. by adding a "3" somewhere) than their Python 2 counterparts. -- Ned Deily, nad at acm.org From carey.tilden at gmail.com Thu Jan 6 16:19:47 2011 From: carey.tilden at gmail.com (Carey Tilden) Date: Thu, 6 Jan 2011 13:19:47 -0800 Subject: Which coding style is better? public API or private method inside class definition In-Reply-To: References: <0470dc9d-2a5f-40d4-afd4-97796059ba0a@q8g2000prm.googlegroups.com> Message-ID: On Wed, Jan 5, 2011 at 9:15 AM, Peter Otten <__peter__ at web.de> wrote: > Jacek Krysztofik wrote: > > > Sorry for OT, but this is actually a question of mine > >> if numbers % 2 == 0: > > wouldn't the following be faster? > >> if numbers & 1 == 0: > > You can answer that and similar questions yourself with the timeit module: > > $ python -m timeit -s'm, n = 1234, 1235' 'm % 2 == 0; n % 2 == 0' > 1000000 loops, best of 3: 0.377 usec per loop > > $ python -m timeit -s'm, n = 1234, 1235' 'm & 1 == 0; n & 1 == 0' > 1000000 loops, best of 3: 0.298 usec per loop > > So yes, a binary and seems to be faster. > I would be curious to hear of a Python application where such a small speed difference mattered even a little bit. Looks to me like a pretty meaningless difference. Carey -------------- next part -------------- An HTML attachment was scrubbed... URL: From ameyer2 at yahoo.com Thu Jan 6 16:32:05 2011 From: ameyer2 at yahoo.com (Alan Meyer) Date: Thu, 06 Jan 2011 16:32:05 -0500 Subject: Trying to decide between PHP and Python In-Reply-To: References: <4D23A29D.7030104@yahoo.com> Message-ID: <4D2634D5.7040402@yahoo.com> On 1/5/2011 11:40 AM, Tomasz Rola wrote: > On Tue, 4 Jan 2011, Roy Smith wrote: > >> There. Now that I've tossed some gasoline on the language wars fire, >> I'll duck and run in the other direction :-) > > May I suggest a better strategy? Run first, duck next :-). Or more precisely: ((run) duck) Alan From ameyer2 at yahoo.com Thu Jan 6 16:42:19 2011 From: ameyer2 at yahoo.com (Alan Meyer) Date: Thu, 06 Jan 2011 16:42:19 -0500 Subject: Trying to decide between PHP and Python In-Reply-To: References: <4D23A29D.7030104@yahoo.com> Message-ID: <4D26373B.8070700@yahoo.com> On 1/5/2011 10:30 AM, Grant Edwards wrote: > 1) How often is a compiler for language X written? > > 2) How often is source code written in language X? > > 3) How often is that source code in language X read/modified? > > If you compare those numbers you'll realize that optimizing for case 1 > at the expense of cases 2& 3 is just plain stupid. Today? Sure. But let's remember the context. LISP was created in 1958 at a time when the only other high level language (if the Wikipedia is right) was Fortran. Writing a practical interpreter or compiler to run on a 16 or 32 K word memory machine, using punched cards and maybe mag tape, and probably starting in assembly language, was a pretty daunting task. It required gobs of intelligence and not a little fortitude. So instead of calling it "plain stupid" I'd be more comfortable saying that it is "no longer the best design choice for modern computers." Alan From kwmsmith at gmail.com Thu Jan 6 16:54:05 2011 From: kwmsmith at gmail.com (Kurt Smith) Date: Thu, 6 Jan 2011 15:54:05 -0600 Subject: Trying to decide between PHP and Python In-Reply-To: <4D2634D5.7040402@yahoo.com> References: <4D23A29D.7030104@yahoo.com> <4D2634D5.7040402@yahoo.com> Message-ID: On Thu, Jan 6, 2011 at 3:32 PM, Alan Meyer wrote: > On 1/5/2011 11:40 AM, Tomasz Rola wrote: >> >> On Tue, 4 Jan 2011, Roy Smith wrote: >> >>> There. ?Now that I've tossed some gasoline on the language wars fire, >>> I'll duck and run in the other direction :-) >> >> May I suggest a better strategy? Run first, duck next :-). > > Or more precisely: > > ? ((run) duck) If you're going to mock another language, you might as well get it right :-) If that's Lisp code, it should be: (funcall (run) duck) see: http://hornbeck.wordpress.com/2009/07/05/lisp-1-vs-lisp-2/ It'll work unchanged for Scheme, though. From kost-bebix at yandex.ua Thu Jan 6 17:07:09 2011 From: kost-bebix at yandex.ua (kost BebiX) Date: Fri, 07 Jan 2011 00:07:09 +0200 Subject: Rewriting __getattr__ Message-ID: <730351294351630@web139.yandex.ru> Hi everyone! I just saw a bug (?) in bson.dbref:DBRef.__getattr__ Here's they're code: ??? def __getattr__(self, key): ??????? return self.__kwargs[key] And when you do copy.deepcopy on that object it will raise you KeyError. So here's a small piece of code that reproduces the problem: >>> class A(object): .. def __init__(self): .. self.d = {} .. def __getattr__(self, key): .. self.d[key] .. a = A() .. copy.deepcopy(a) Traceback (most recent call last): File "", line 7, in copy.deepcopy(a) File "/usr/lib/python2.6/copy.py", line 171, in deepcopy copier = getattr(x, "__deepcopy__", None) File "", line 5, in __getattr__ self.d[key] KeyError: '__deepcopy__' So I thought the right thing right now will be to do just: class A(object): def __init__(self): self.d = {} def __getattr__(self, key): if key.startswith('__'): raise AttributeError self.d[key] and it works, but... isn't that wrong? I mean, shouldn't deepcopy somehow work in this situation, or, maybe, something else should differ? And why this code: class A(object): def __init__(self): self.d = {} def __getattr__(self, key): if key in dir(self.d): return self.d[key] raise AttributeError a = A() deepcopy(a) gets "maximum recursion depth exceeded"? Thank you. -- jabber: kost-bebix at ya.ru From alice at gothcandy.com Thu Jan 6 17:19:25 2011 From: alice at gothcandy.com (=?utf-8?Q?Alice_Bevan=E2=80=93McGregor?=) Date: Thu, 6 Jan 2011 14:19:25 -0800 Subject: Can I have both Python 2.7 and Python 3.1 at the same time on the Mac? References: <775A9D45-25B5-4A16-9FE5-6217FD67F3AF@cagttraining.com> Message-ID: On 2011-01-06 11:44:13 -0800, Bill Felton said: > I've also seen various resources indicate that one can install both > Python 2.7 and Python 3.1 -- but when I did this, I get no end of > problems in the 2.7 install. I have Apple's native Python installations (2.5 and 2.6, I believe), plus Python 2.7 and 3.1 from the Python.org site (.pkg installers) installed simultaneously without a problem, but I don't use Python GUI toolkits on my Mac. Still waiting on a .pkg installer for 3.2b2, though. :( - Alice. From subscriptions at cagttraining.com Thu Jan 6 17:25:51 2011 From: subscriptions at cagttraining.com (Bill Felton) Date: Thu, 6 Jan 2011 17:25:51 -0500 Subject: Can I have both Python 2.7 and Python 3.1 at the same time on the Mac? In-Reply-To: References: <775A9D45-25B5-4A16-9FE5-6217FD67F3AF@cagttraining.com> Message-ID: <51F66C79-5607-4943-B56C-2EF22F3AD407@cagttraining.com> On Jan 6, 2011, at 3:46 PM, Ned Deily wrote: > In article <775A9D45-25B5-4A16-9FE5-6217FD67F3AF at cagttraining.com>, > Bill Felton wrote: >> I'm new to python, trying to learn it from a variety of resources, including >> references posted recently to this list. >> I'm going through /www.openbookproject.net/thinkCSpy/ and find it makes use >> of gasp, which apparently is not compatible with 3.1. >> I've also seen various resources indicate that one can install both Python >> 2.7 and Python 3.1 -- but when I did this, I get no end of problems in the >> 2.7 install. IDLE, in particular, fails rather spectacularly, even if I >> launch it directly from the Python 2.7 directory in which it resides. >> So, either I've been misled and should only try to have one or the other. OR >> I'm missing some (probably simple) step that's mucking me up. >> Help? > > Yes, you can have multiple versions of Python installed on Mac OS X. In > fact, Apple ships multiple versions of Python with OS X (2.6 and 2.6 > with OS X 10.6, for example). Starting with Python 2.7, python.org > offers two variants of OS X installers, one is 32-bit-only and works on > all versions of OS X 10.3.9 through OS X 10.6, the other supports 64-bit > execution and only works on 10.6 (as of 2.7.1). Unfortunately, there > are some major interaction problems between Tkinter, Python's GUI > toolkit which is used by IDLE, and the Tcl/Tk 8.5 supplied by Apple in > OS X 10.6. I'm assuming you installed the 64-bit version. If so, until > the problem is resolved in the next maintenance release of Python 2.7, I > suggest you download and install the 32-bit-only version of Python 2.7.1 > which does not have those problems. > Thank you, Ned! Installing what appeared to be the 'old OS' version seems to fix my difficulty. IDLE now works fine without hanging, I can enter code, save, check syntax, and run from the 'new window'. And 3.1 still works as before. regards, Bill -------------- next part -------------- An HTML attachment was scrubbed... URL: From alice at gothcandy.com Thu Jan 6 17:33:29 2011 From: alice at gothcandy.com (=?utf-8?Q?Alice_Bevan=E2=80=93McGregor?=) Date: Thu, 6 Jan 2011 14:33:29 -0800 Subject: Streaming templating languages for use as WSGI body. References: <1294336839.10436.2.camel@linux-yu4c.site> <1294341087.14042.3.camel@linux-yu4c.site> Message-ID: On 2011-01-06 11:11:27 -0800, Adam Tauno Williams said: > On Thu, 2011-01-06 at 11:07 -0800, Alice Bevan?McGregor wrote: >> On 2011-01-06 10:00:39 -0800, Adam Tauno Williams said: >>> With HTTP/1.0 [and WSGI is HTTP/1.0 only] you have to provide a >>> Content-Length header - so you have to generate the entire response at >>> once [however you want to muddy "at once"]. >> >> Both of these statements are false. > > Both these statements are true! I suggest you consult the HTTP spec. It's generally polite to provide direct references, either sections or actual links when asking someone to RTFM. No matter, examining the HTTP/1.0 RFC (conveniently chopped up and HTML-ified by the w3) I find evidence to support your argument: http://www.w3.org/Protocols/HTTP/1.0/draft-ietf-http-spec.html#Entity-Body However, HTTP clients are smarter than the raw spec. ;) Run the code found at the following link and poke the wsgiref server that is run in a web browser, with curl, or any other HTTP tool, even telnet: http://pastie.textmate.org/1435415 You'll notice no content-length header (wsgiref adds one automatically for single-element iterables) and no difficulty in receiving the entire response body, even without a content-length. The de-facto standard behaviour combined with the following text from WSGI makes streaming content with non-deterministic lengths completely reasonable: > WSGI servers, gateways, and middleware must not delay the transmission > of any block; they must either fully transmit the block to the client, > or guarantee that they will continue transmission even while the > application is producing its next block. Point me to a HTTP client from the last 10 years that doesn't handle this particular condition and I'll believe your original statements. :) - Alice. From cerutti.francesco.to at gmail.com Thu Jan 6 17:49:22 2011 From: cerutti.francesco.to at gmail.com (francesco) Date: Thu, 6 Jan 2011 14:49:22 -0800 (PST) Subject: python only prints integers Message-ID: <5e52fbfb-c02e-4855-920e-8918cb12c90f@k11g2000vbf.googlegroups.com> I'm pretty new in Python language. I have a problem with numbers: it seems python doesn't know any more how to count! I get only the down rounded integer 20/8 = 2 8/3=2 I probably changed some option to round the numbers, but I don't remember how. Is there a way to reset the number of digits to default? Thanks in advance From debatem1 at gmail.com Thu Jan 6 17:58:28 2011 From: debatem1 at gmail.com (geremy condra) Date: Thu, 6 Jan 2011 14:58:28 -0800 Subject: python only prints integers In-Reply-To: <5e52fbfb-c02e-4855-920e-8918cb12c90f@k11g2000vbf.googlegroups.com> References: <5e52fbfb-c02e-4855-920e-8918cb12c90f@k11g2000vbf.googlegroups.com> Message-ID: On Thu, Jan 6, 2011 at 2:49 PM, francesco wrote: > I'm pretty new in Python language. I have a problem with numbers: it > seems python doesn't know any more how to count! > I get only the down rounded integer > 20/8 = 2 > 8/3=2 > I probably changed some option to round the numbers, but I don't > remember how. > Is there a way to reset the number of digits to default? > Thanks in advance Use floats instead of integers: Python 2.6.5 (r265:79063, Apr 16 2010, 13:57:41) [GCC 4.4.3] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> 20/8 2 >>> 20.0/8 2.5 or use Python3: Python 3.2a1 (r32a1:83318, Aug 13 2010, 22:32:03) [GCC 4.4.3] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> 20/8 2.5 >>> 20.0/8 2.5 From ian.g.kelly at gmail.com Thu Jan 6 17:59:00 2011 From: ian.g.kelly at gmail.com (Ian) Date: Thu, 6 Jan 2011 14:59:00 -0800 (PST) Subject: python only prints integers References: <5e52fbfb-c02e-4855-920e-8918cb12c90f@k11g2000vbf.googlegroups.com> Message-ID: On Jan 6, 3:49?pm, francesco wrote: > I'm pretty new in Python language. I have a problem with numbers: it > seems python doesn't know any more how to count! > I get only the down rounded integer > 20/8 = 2 > 8/3=2 > I probably changed some option to round the numbers, but I don't > remember how. > Is there a way to reset the number of digits to default? In Python 2, the '/' operator performs integer division by default when both its operands are integers. To change this, either place this at the top of the file: from __future__ import division or convert your numbers to floats: >>> 20.0 / 8.0 2.5 >>> float(20) / float(8) 2.5 In Python 3, the '/' operator always performs true division. From enalicho at gmail.com Thu Jan 6 18:02:59 2011 From: enalicho at gmail.com (Noah Hall) Date: Thu, 6 Jan 2011 23:02:59 +0000 Subject: python only prints integers In-Reply-To: <5e52fbfb-c02e-4855-920e-8918cb12c90f@k11g2000vbf.googlegroups.com> References: <5e52fbfb-c02e-4855-920e-8918cb12c90f@k11g2000vbf.googlegroups.com> Message-ID: On Thu, Jan 6, 2011 at 10:49 PM, francesco wrote: > I'm pretty new in Python language. I have a problem with numbers: it > seems python doesn't know any more how to count! > I get only the down rounded integer > 20/8 = 2 > 8/3=2 > I probably changed some option to round the numbers, but I don't > remember how. > Is there a way to reset the number of digits to default? > Thanks in advance > -- > http://mail.python.org/mailman/listinfo/python-list > Hi, the problem is that you've used two integers, which in turn return an integer. In order to get around your problem, try 20.0/8 - the 20.0 is a float, which will return a float. Have a read here - http://docs.python.org/library/stdtypes.html#numeric-types-int-float-long-complex Might I also suggest that you use the tutor at python.org mailing list for beginner questions - you'll get more help there. :) -------------- next part -------------- An HTML attachment was scrubbed... URL: From kost-bebix at yandex.ua Thu Jan 6 18:09:22 2011 From: kost-bebix at yandex.ua (kost BebiX) Date: Fri, 07 Jan 2011 01:09:22 +0200 Subject: python only prints integers In-Reply-To: <5e52fbfb-c02e-4855-920e-8918cb12c90f@k11g2000vbf.googlegroups.com> References: <5e52fbfb-c02e-4855-920e-8918cb12c90f@k11g2000vbf.googlegroups.com> Message-ID: <191741294355362@web95.yandex.ru> Well, that's because 20 is integer. To get float you can write 20.0 (or 20.). 20.0/8.0 = 2.5 8.0/3.0 = 2.6666666666666665 07.01.2011, 00:49, "francesco" : > I'm pretty new in Python language. I have a problem with numbers: it > seems python doesn't know any more how to count! > I get only the down rounded integer > 20/8 = 2 > 8/3=2 > I probably changed some option to round the numbers, but I don't > remember how. > Is there a way to reset the number of digits to default? > Thanks in advance > > -- > http://mail.python.org/mailman/listinfo/python-list -- jabber: kost-bebix at ya.ru From cerutti.francesco.to at gmail.com Thu Jan 6 18:12:19 2011 From: cerutti.francesco.to at gmail.com (francesco) Date: Thu, 6 Jan 2011 15:12:19 -0800 (PST) Subject: python only prints integers References: <5e52fbfb-c02e-4855-920e-8918cb12c90f@k11g2000vbf.googlegroups.com> Message-ID: <02f94678-853d-457e-a048-4711d7e9edc0@v17g2000vbo.googlegroups.com> On 6 Gen, 23:59, Ian wrote: > On Jan 6, 3:49?pm, francesco wrote: > > > I'm pretty new in Python language. I have a problem with numbers: it > > seems python doesn't know any more how to count! > > I get only the down rounded integer > > 20/8 = 2 > > 8/3=2 > > I probably changed some option to round the numbers, but I don't > > remember how. > > Is there a way to reset the number of digits to default? > > In Python 2, the '/' operator performs integer division by default > when both its operands are integers. ?To change this, either place > this at the top of the file: > > from __future__ import division > > or convert your numbers to floats: > > >>> 20.0 / 8.0 > 2.5 > >>> float(20) / float(8) > > 2.5 > > In Python 3, the '/' operator always performs true division. Thanks to all! Very quick answer! I fixed the problem by using floats. Thanks again From sol2ray at gmail.com Thu Jan 6 18:30:36 2011 From: sol2ray at gmail.com (Sol Toure) Date: Thu, 6 Jan 2011 18:30:36 -0500 Subject: Trying to decide between PHP and Python In-Reply-To: References: <4D23A29D.7030104@yahoo.com> <4D2634D5.7040402@yahoo.com> Message-ID: > > >> > >>> There. Now that I've tossed some gasoline on the language wars fire, > >>> I'll duck and run in the other direction :-) > >> > >> May I suggest a better strategy? Run first, duck next :-). > > > > Or more precisely: > > > > ((run) duck) > > If you're going to mock another language, you might as well get it right > :-) > > If that's Lisp code, it should be: > > (funcall (run) duck) > > Did you mean (progn #'run #'duck) -------------- next part -------------- An HTML attachment was scrubbed... URL: From steve+comp.lang.python at pearwood.info Thu Jan 6 18:37:29 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 06 Jan 2011 23:37:29 GMT Subject: PEP: possibility of inline using of a symbol instead of "import" References: <0952cc24-097d-4685-a92d-75054406ddf3@f20g2000vbc.googlegroups.com> <1201388b-16b8-4452-9a1f-c9aa00b126e7@p38g2000vbn.googlegroups.com> <7f726500-a9d1-45e2-8a7d-2236a9ef7845@p1g2000yqm.googlegroups.com> Message-ID: <4d265239$0$29968$c3e8da3$5496439d@news.astraweb.com> On Thu, 06 Jan 2011 09:03:02 -0800, Ian wrote: > On Jan 6, 9:32?am, Tim Harig wrote: >> 2. Your so-called PEP probably clashes with Python's use of @ for >> ? ? ? ? decorators. >> >> 3. Do you really expect a language holding the mantra that there should >> be >> ? ? ? ? a single way of doing things to embrace a language bloating >> ? ? ? ? feature for what is effectively already possible with the >> ? ? ? ? language as it exists? > > Isn't "Python's use of @ for decorators" a "language bloating feature > for what [was] effectively already possible with the language as it > [existed]?" ;-) Yes. The difference is that the invention of decorator syntax was a huge success, encouraging people to write code in a new way that added great power and expressiveness to their code. Guido's intuition as a language designer got decorator syntax right. Although function decorators of a sort have been possible since Python 1.5 or older (functions have always been first class objects), it needed good syntax that puts the wrapper function up near the function def to get people to see their potential. Decorator syntax isn't merely a time- saver, or to reduce the number of keystrokes needed from this: def spam(): pass spam = wrapper(spam) to this: @wrapper def spam(): pass While the two are functionally equivalent, the two are not mentally equivalent to the reader and writer. Decorators are significantly enhanced by the new syntax: it means you no longer have to use the function name three times, which is a code smell. More importantly, it puts the wrapper up with the function signature, where it belongs, instead of obscurely down the bottom past the definition. The end result has been to take a powerful design pattern that was always possible but hardly ever used, and make it friendly and far more common. This has been a huge win. So @ loses two points for being obscure and bringing nothing new to the language, while gaining ten thousand points for being one of the most successful examples of syntactic sugars since people realised they could use assembly language op codes instead of writing in hex. The use of syntax to turn: import module module.function() into something like: @module.function() is unlikely to give any such win. Its utility is fairly narrow: it doesn't encourage any new design patterns. It does save a few characters of typing, which may be a small win, but the use of this will be a code smell. Python doesn't require all imports to be at the beginning of your module, but it is recommended, and this inlining of imports encourages the anti-pattern of scattering imports all throughout your code base. Let me put it this way. The suggested syntactic sugar will encourage code that is functionally the equivalent of this: import math math.sin(1.2) # ... # much later import math math.cos(2.5) # ... # much later import math math.sqrt(24) Yes, the subsequent imports are relatively fast, but even so, we shouldn't *encourage* that sort of thing with special syntax for it. If you don't like this code pattern: import function from module # ... # much code goes here # ... function(x) then instead of creating new syntax, the conventional solution is the best: import module # ... # much code goes here # ... module.function(x) -- Steven From debatem1 at gmail.com Thu Jan 6 19:23:34 2011 From: debatem1 at gmail.com (geremy condra) Date: Thu, 6 Jan 2011 16:23:34 -0800 Subject: Trying to decide between PHP and Python In-Reply-To: <4d262bf8$0$44066$742ec2ed@news.sonic.net> References: <4d2613ef$0$44009$742ec2ed@news.sonic.net> <4d262bf8$0$44066$742ec2ed@news.sonic.net> Message-ID: On Thu, Jan 6, 2011 at 12:54 PM, John Nagle wrote: > On 1/6/2011 12:41 PM, Chris Rebert wrote: >> >> On Thu, Jan 6, 2011 at 11:11 AM, John Nagle ?wrote: >>> >>> On 1/4/2011 12:20 PM, Google Poster wrote: >>>> >>>> About once a year, I have to learn yet another programming language. >>>> Given all the recommendations (an outstanding accolade from Bruce >>>> Eckel, author of "Thinking in Java") I have set my aim to Python. >>>> Sounds kinda cool. >>> >>> ? ?If you're just doing simple web-based services, PHP is the >>> way of least resistance. ?It's supported by almost all hosting >>> services. ?Trying to run Python on shared hosting is generally >>> painful. ?Either you're stuck running in CGI, which means you >>> take the cost of a Python load on every transaction, or you >>> have to find someone who will let you run long-running >>> processes so you can run FCGI/WSGI or some Python framework. >> >> VPS hosting can be surprisingly cheap these days though (e.g. prgmr's >> super-cheapo plan is $4-5/month); you get root access, so setting up a >> Python web application is much easier. > > ? ?That makes it possible, but not easier. ?If you're just running a > typical web site with some "web 2.0" pages, forms, and a database, > it's probably easier to use PHP. ?Administering a virtual machine > instance puts you in the system administration business. ?With > PHP, the hosting service will routinely handle that for you. > You just create PHP pages, upload them, and the behind the scenes > machinery is someone else's problem. ?If PHP breaks on shared hosting, > enough users will be screaming that it gets fixed. > > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?John Nagle I'm not exactly a god unto sysadmins and I've had no problems with either bargain-basement Python managed hosting or VPS's. I'd encourage anybody looking at the differences between PHP and Python to try both and get some hosting that lets you use either. I'm pretty confident that in the long run Python will win out. Geremy Condra From bc at freeuk.com Thu Jan 6 19:31:52 2011 From: bc at freeuk.com (BartC) Date: Fri, 7 Jan 2011 00:31:52 -0000 Subject: Trying to decide between PHP and Python In-Reply-To: <87bp3wf3zw.fsf@benfinney.id.au> References: <4D23A29D.7030104@yahoo.com> <87bp3wf3zw.fsf@benfinney.id.au> Message-ID: "Ben Finney" wrote in message news:87bp3wf3zw.fsf at benfinney.id.au... > Tomasz Rola writes: > >> Heh. One day, guys, when you have nothing better to do, try writing a >> parser for Lisp-like language (Common Lisp, Scheme, whatever). After >> that, do the same with some other language of your preference (Python, >> Java, whatever). Compare time and code spent... > > Perhaps Lisp is a simpler language to parse than Python. > > Perhaps a machine with only one instruction > is > simpler to implement than one with a broader instruction set. One with zero instructions might be even simpler than that: http://en.wikipedia.org/wiki/Zero_instruction_set_computer -- Bartc From googler.1.webmaster at spamgourmet.com Thu Jan 6 21:24:13 2011 From: googler.1.webmaster at spamgourmet.com (moerchendiser2k3) Date: Thu, 6 Jan 2011 18:24:13 -0800 (PST) Subject: Resolve circular reference Message-ID: <1718ea91-fc4e-49f3-a15a-bdc683789126@k22g2000yqh.googlegroups.com> Hi, I have a small problem with circular references. I embedded Python into my app and I have two types which are flagged with Py_TPFLAGS_BASETYPE so I can inherit Python types from these types. Lets call my C types A and B. Here is the dependency: class Foo(A): e=Bar() class Bar(B): def __init__(self, p): self.p=p i=Foo() j=Bar(i) Everything works fine, the problem starts when I start to make a circular reference in Python. In my embedded app I have a reference to instance A. When I decref this reference its still alive because the instance j(Bar) makes this object still alive. Is there any chance to force this? Because without A the instance A shouldnt be alive anymore. Thanks for any hint!! Bye From python at mrabarnett.plus.com Thu Jan 6 21:59:26 2011 From: python at mrabarnett.plus.com (MRAB) Date: Fri, 07 Jan 2011 02:59:26 +0000 Subject: Resolve circular reference In-Reply-To: <1718ea91-fc4e-49f3-a15a-bdc683789126@k22g2000yqh.googlegroups.com> References: <1718ea91-fc4e-49f3-a15a-bdc683789126@k22g2000yqh.googlegroups.com> Message-ID: <4D26818E.5060604@mrabarnett.plus.com> On 07/01/2011 02:24, moerchendiser2k3 wrote: > Hi, > > I have a small problem with circular references. I embedded Python > into my app and I have two types which are flagged with > Py_TPFLAGS_BASETYPE so I can inherit Python types from these types. > Lets call my C types A and B. > > > Here is the dependency: > > class Foo(A): > e=Bar() > > class Bar(B): > def __init__(self, p): > self.p=p > i=Foo() > j=Bar(i) > > Everything works fine, the problem starts when I start to make a > circular reference in Python. In my embedded app I have a reference to > instance A. When I decref this reference its still alive because the > instance j(Bar) makes this object still alive. Is there any chance to > force this? Because without A the instance A shouldnt be alive > anymore. Thanks for any hint!! > Force what? j refers to i, i refers to Foo, Foo refers to A. Therefore A should be alive. From falk at rahul.net Thu Jan 6 22:32:54 2011 From: falk at rahul.net (Edward A. Falk) Date: Fri, 7 Jan 2011 03:32:54 +0000 (UTC) Subject: python only prints integers References: <5e52fbfb-c02e-4855-920e-8918cb12c90f@k11g2000vbf.googlegroups.com> Message-ID: In article , Ian wrote: > >In Python 3, the '/' operator always performs true division. How can I get integer division? -- -Ed Falk, falk at despams.r.us.com http://thespamdiaries.blogspot.com/ From enalicho at gmail.com Thu Jan 6 22:42:46 2011 From: enalicho at gmail.com (Noah Hall) Date: Fri, 7 Jan 2011 03:42:46 +0000 Subject: python only prints integers In-Reply-To: References: <5e52fbfb-c02e-4855-920e-8918cb12c90f@k11g2000vbf.googlegroups.com> Message-ID: On Fri, Jan 7, 2011 at 3:32 AM, Edward A. Falk wrote: > In article < > cd9d1c80-b1d2-4d20-9896-a6fd77bd7db2 at j25g2000yqa.googlegroups.com>, > Ian wrote: > > > >In Python 3, the '/' operator always performs true division. > > How can I get integer division? > > -- > -Ed Falk, falk at despams.r.us.com > http://thespamdiaries.blogspot.com/ > -- > http://mail.python.org/mailman/listinfo/python-list > Use // where you would / in order to preform integer division in Python 3. -------------- next part -------------- An HTML attachment was scrubbed... URL: From erwin.mueller at deventm.org Thu Jan 6 23:00:52 2011 From: erwin.mueller at deventm.org (Erwin Mueller) Date: Fri, 7 Jan 2011 05:00:52 +0100 Subject: PEP: possibility of inline using of a symbol instead of "import" In-Reply-To: References: <0952cc24-097d-4685-a92d-75054406ddf3@f20g2000vbc.googlegroups.com> <201101061943.30101.devent@deventm.org> Message-ID: <201101070500.52368.erwin.mueller@deventm.org> On Thursday 06 January 2011 21:23:57 Robert Kern wrote: > On 1/6/11 12:43 PM, Erwin Mueller wrote: > > On Thursday 06 January 2011 16:28:49 dmitrey wrote: > >> hi all, > >> I have th PEP (I'm not sure something like that hadn't been proposed > >> although): > >> very often in a Python file header the following lines are present, > >> like: > >> from MyModule1 import myFunc1 > >> import MyModule2 as mm2 > >> from MyModule3 import myFunc3 as mf3 > >> etc > >> > >> and after several pages of code they are using somewhere, maybe only > >> one time, e.g. > >> r1 = myFunc1(...) > >> r2 = mm2.myFunc2(...) > >> r3 = mf3(...) > >> It makes programs less clear, you have to scroll several pages of code > >> in IDE to understand what it refers to. > >> > >> Regards, D. > > > > Why you have several pages of code in the first place? Don't you know > > that you can split your code in files? Just a suggestion. > > Modules *should* have several pages of code. *Functions* should be limited > to about a page of code at maximum. I'm not quite familar with Python development, but why should modules be so big that the user is lost in the code? What is preventing you from splittin a module in several files, each file with a single responsibility? -- Erwin Mueller, erwin.mueller at deventm.org http://www.global-scaling-institute.de/ From devent at deventm.org Thu Jan 6 23:01:38 2011 From: devent at deventm.org (Erwin Mueller) Date: Fri, 7 Jan 2011 05:01:38 +0100 Subject: PEP: possibility of inline using of a symbol instead of "import" In-Reply-To: References: <0952cc24-097d-4685-a92d-75054406ddf3@f20g2000vbc.googlegroups.com> <201101061943.30101.devent@deventm.org> Message-ID: <201101070501.38410.devent@deventm.org> On Thursday 06 January 2011 21:23:57 Robert Kern wrote: > On 1/6/11 12:43 PM, Erwin Mueller wrote: > > On Thursday 06 January 2011 16:28:49 dmitrey wrote: > >> hi all, > >> I have th PEP (I'm not sure something like that hadn't been proposed > >> although): > >> very often in a Python file header the following lines are present, > >> like: > >> from MyModule1 import myFunc1 > >> import MyModule2 as mm2 > >> from MyModule3 import myFunc3 as mf3 > >> etc > >> > >> and after several pages of code they are using somewhere, maybe only > >> one time, e.g. > >> r1 = myFunc1(...) > >> r2 = mm2.myFunc2(...) > >> r3 = mf3(...) > >> It makes programs less clear, you have to scroll several pages of code > >> in IDE to understand what it refers to. > >> > >> Regards, D. > > > > Why you have several pages of code in the first place? Don't you know > > that you can split your code in files? Just a suggestion. > > Modules *should* have several pages of code. *Functions* should be limited > to about a page of code at maximum. I'm not quite familar with Python development, but why should modules be so big that the user is lost in the code? What is preventing you from splittin a module in several files, each file with a single responsibility? -- Erwin Mueller, devent at deventm.org http://www.global-scaling-institute.de/ From clp2 at rebertia.com Fri Jan 7 00:05:10 2011 From: clp2 at rebertia.com (Chris Rebert) Date: Thu, 6 Jan 2011 21:05:10 -0800 Subject: PEP: possibility of inline using of a symbol instead of "import" In-Reply-To: <201101070500.52368.erwin.mueller@deventm.org> References: <0952cc24-097d-4685-a92d-75054406ddf3@f20g2000vbc.googlegroups.com> <201101061943.30101.devent@deventm.org> <201101070500.52368.erwin.mueller@deventm.org> Message-ID: On Thu, Jan 6, 2011 at 8:00 PM, Erwin Mueller wrote: > On Thursday 06 January 2011 21:23:57 Robert Kern wrote: > > On 1/6/11 12:43 PM, Erwin Mueller wrote: > > > On Thursday 06 January 2011 16:28:49 dmitrey wrote: > > >> hi all, > > >> I have th PEP (I'm not sure something like that hadn't been proposed > > >> although): > > >> very often in a Python file header the following lines are present, > > >> like: > > >> from MyModule1 import myFunc1 > > >> import MyModule2 as mm2 > > >> from MyModule3 import myFunc3 as mf3 > > >> etc > > >> > > >> and after several pages of code they are using somewhere, maybe only > > >> one time, e.g. > > >> r1 = myFunc1(...) > > >> r2 = mm2.myFunc2(...) > > >> r3 = mf3(...) > > >> It makes programs less clear, you have to scroll several pages of code > > >> in IDE to understand what it refers to. > > >> > > >> Regards, D. > > > > > > Why you have several pages of code in the first place? Don't you know > > > that you can split your code in files? Just a suggestion. > > > > Modules *should* have several pages of code. *Functions* should be limited > > to about a page of code at maximum. > > ? ? ? ?I'm not quite familar with Python development, but why should modules > be so big that the user is lost in the code? They shouldn't, but due to Python's conciseness, the amount of code a module can hold before it becomes unwieldy is a good bit greater than some more verbose languages. Unlike say, Java, it is quite normal to have several classes, functions, and constants in a single Python module. "Several pages" is not an unreasonable upper bound for a Python module. > What is preventing you from > splittin a module in several files, each file with a single responsibility? Circular dependencies perhaps. Also, how a responsibility is defined and what level of module granularity is most useful is a design decision requiring skilled judgment; it's possible that just-one-module is appropriate for Dmitrey's situation. Cheers, Chris -- http://blog.rebertia.com From steve+comp.lang.python at pearwood.info Fri Jan 7 02:09:03 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 07 Jan 2011 07:09:03 GMT Subject: python only prints integers References: <5e52fbfb-c02e-4855-920e-8918cb12c90f@k11g2000vbf.googlegroups.com> Message-ID: <4d26bc0f$0$29976$c3e8da3$5496439d@news.astraweb.com> On Fri, 07 Jan 2011 03:32:54 +0000, Edward A. Falk wrote: > In article > , Ian > wrote: >> >>In Python 3, the '/' operator always performs true division. > > How can I get integer division? >>> 25//4 6 -- Steven From steve+comp.lang.python at pearwood.info Fri Jan 7 02:27:28 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 07 Jan 2011 07:27:28 GMT Subject: PEP: possibility of inline using of a symbol instead of "import" References: <0952cc24-097d-4685-a92d-75054406ddf3@f20g2000vbc.googlegroups.com> <201101061943.30101.devent@deventm.org> <201101070500.52368.erwin.mueller@deventm.org> Message-ID: <4d26c060$0$29976$c3e8da3$5496439d@news.astraweb.com> On Thu, 06 Jan 2011 21:05:10 -0800, Chris Rebert wrote: > On Thu, Jan 6, 2011 at 8:00 PM, Erwin Mueller > wrote: >> On Thursday 06 January 2011 21:23:57 Robert Kern wrote: >> > On 1/6/11 12:43 PM, Erwin Mueller wrote: >> > > On Thursday 06 January 2011 16:28:49 dmitrey wrote: >> > >> hi all, >> > >> I have th PEP (I'm not sure something like that hadn't been >> > >> proposed although): >> > >> very often in a Python file header the following lines are >> > >> present, like: >> > >> from MyModule1 import myFunc1 >> > >> import MyModule2 as mm2 >> > >> from MyModule3 import myFunc3 as mf3 >> > >> etc >> > >> >> > >> and after several pages of code they are using somewhere, maybe >> > >> only one time, e.g. >> > >> r1 = myFunc1(...) >> > >> r2 = mm2.myFunc2(...) >> > >> r3 = mf3(...) >> > >> It makes programs less clear, you have to scroll several pages of >> > >> code in IDE to understand what it refers to. >> > >> >> > >> Regards, D. >> > > >> > > Why you have several pages of code in the first place? Don't you >> > > know that you can split your code in files? Just a suggestion. >> > >> > Modules *should* have several pages of code. *Functions* should be >> > limited to about a page of code at maximum. >> >> ? ? ? ?I'm not quite familar with Python development, but why >> ? ? ? ?should modules >> be so big that the user is lost in the code? > > They shouldn't, but due to Python's conciseness, the amount of code a > module can hold before it becomes unwieldy is a good bit greater than > some more verbose languages. Unlike say, Java, it is quite normal to > have several classes, functions, and constants in a single Python > module. "Several pages" is not an unreasonable upper bound for a Python > module. Have a look at the decimal.py module in the standard library. That's nearly 5800 lines, including blanks, comments and docstrings, for 18 classes and 19 top-level functions, over 88 pages. I'd call that the maximum size I'm comfortable with a single module. "Several pages" is nothing to fear. I recently split a module I'm working on into a package of seven modules (plus about the same again for tests). My module was about 2500 lines, for about 50 classes and functions, and I expect it to grow by another dozen or so functions over the coming months. Splitting a single module into multiples doesn't happen for free. You have to worry about imports and dependencies that simply aren't an issue in a single module. But on the plus side, I was able to rename a bunch of similar-but-different functions from: module.function module.function1 to a much more sensible: module.function module.submodule.function -- Steven From googler.1.webmaster at spamgourmet.com Fri Jan 7 06:20:36 2011 From: googler.1.webmaster at spamgourmet.com (moerchendiser2k3) Date: Fri, 7 Jan 2011 03:20:36 -0800 (PST) Subject: Resolve circular reference References: <1718ea91-fc4e-49f3-a15a-bdc683789126@k22g2000yqh.googlegroups.com> Message-ID: > Force what? > > j refers to i, i refers to Foo, Foo refers to A. Therefore A should be > alive. Oh, sorry. Force the deletion of A. From googler.1.webmaster at spamgourmet.com Fri Jan 7 06:58:24 2011 From: googler.1.webmaster at spamgourmet.com (moerchendiser2k3) Date: Fri, 7 Jan 2011 03:58:24 -0800 (PST) Subject: Resolve circular reference References: <1718ea91-fc4e-49f3-a15a-bdc683789126@k22g2000yqh.googlegroups.com> Message-ID: <353ecd61-22f8-4770-be30-29cb76b0f6b0@t35g2000yqj.googlegroups.com> > Force what? > j refers to i, i refers to Foo, Foo refers to A. Therefore A should be > alive. Oh, sorry. Force the deletion of instance Foo(A) and Bar(B). From fabiofz at gmail.com Fri Jan 7 07:09:48 2011 From: fabiofz at gmail.com (Fabio Zadrozny) Date: Fri, 7 Jan 2011 10:09:48 -0200 Subject: [PyQt] Working with PyQt and Pydev In-Reply-To: References: Message-ID: On Thu, Jan 6, 2011 at 9:32 AM, Rohit Coder < passionate_programmer at hotmail.com> wrote: > I installed the PyDev plugin into Aptana Stdui 3 Beta. Someone suggested > me to use PyQt for Python GUI app, and so I downloaded and installed PyQt. > But when I open Aptana Studio, I could see a new menu added with the name > "PyDev", but there is nothing for PyQt. > > > In the Windows Start Meny item list, I could see a folder named PyQt and > when I open it, there are few tools like Designer. > > > When Designer is run, it opens Qt IDE for designing Forms like Visual > Studio and the files have the extension .ui. > > I want to know how to integrate PyQt and PyDev. Do I need to use them > separately by adding the .ui files to PyDev and then adding Python core code > for functionality? > > After you design your class in the Qt Designer, you need to run pyuic to convert the .ui file to a python file (which you'd probably subclass in another module to add your own code, as you don't want to mess the automatically generated file). If you want, you can add a builder (project > properties > builders) to run pyuic when a .ui file is changed, so you don't have to go to the console to ask pyuic to be rerun every time you change the file. Cheers, Fabio -------------- next part -------------- An HTML attachment was scrubbed... URL: From jeanmichel at sequans.com Fri Jan 7 08:45:56 2011 From: jeanmichel at sequans.com (Jean-Michel Pichavant) Date: Fri, 07 Jan 2011 14:45:56 +0100 Subject: Rewriting __getattr__ In-Reply-To: <730351294351630@web139.yandex.ru> References: <730351294351630@web139.yandex.ru> Message-ID: <4D271914.6090308@sequans.com> kost BebiX wrote: > Hi everyone! > I just saw a bug (?) in bson.dbref:DBRef.__getattr__ > > Here's they're code: > def __getattr__(self, key): > return self.__kwargs[key] > > And when you do copy.deepcopy on that object it will raise you KeyError. So here's a small piece of code that reproduces the problem: > > from http://docs.python.org/reference/datamodel.html About __getattr__ "This method should return the (computed) attribute value or raise an AttributeError exception." The code you provided raises a KeyError thus methods such as 'getattr' will fail as they expect an AttributeError exception. JM From kost-bebix at yandex.ua Fri Jan 7 08:54:37 2011 From: kost-bebix at yandex.ua (kost BebiX) Date: Fri, 07 Jan 2011 15:54:37 +0200 Subject: Rewriting __getattr__ In-Reply-To: <4D271914.6090308@sequans.com> References: <730351294351630@web139.yandex.ru> <4D271914.6090308@sequans.com> Message-ID: <191511294408478@web10.yandex.ru> You're absolutely right! Now try to do except Keyerror: raise AttributeError and it will also fail. But why? 07.01.2011, 15:45, "Jean-Michel Pichavant" : > kost BebiX wrote: > >> ?Hi everyone! >> ?I just saw a bug (?) in bson.dbref:DBRef.__getattr__ >> >> ?Here's they're code: >> ?????def __getattr__(self, key): >> ?????????return self.__kwargs[key] >> >> ?And when you do copy.deepcopy on that object it will raise you KeyError. So here's a small piece of code that reproduces the problem: > > from http://docs.python.org/reference/datamodel.html > > About __getattr__ > "This method should return the (computed) attribute value or raise an > AttributeError > > exception." > > The code you provided raises a KeyError thus methods such as 'getattr' > will fail as they expect an AttributeError exception. > > JM > > -- > http://mail.python.org/mailman/listinfo/python-list -- jabber: kost-bebix at ya.ru From tavares at fe.up.pt Fri Jan 7 09:16:04 2011 From: tavares at fe.up.pt (tavares at fe.up.pt) Date: Fri, 7 Jan 2011 06:16:04 -0800 (PST) Subject: =?windows-1252?Q?VipIMAGE_2011_=96_ECCOMAS_Thematic_Conference_=96_2n?= =?windows-1252?Q?d_ANNOUNCE_and_CALL?= Message-ID: <89e4a378-df07-49d9-87de-6a57b8bc8918@i41g2000vbn.googlegroups.com> ------------------------------------------------------------------------------------------------------------------------------------------ International ECCOMAS Thematic Conference VipIMAGE 2011 - III ECCOMAS THEMATIC CONFERENCE ON COMPUTATIONAL VISION AND MEDICAL IMAGE PROCESSING 12-14th October 2011, Olh?o, Algarve, Portugal www.fe.up.pt/~vipimage 2nd ANNOUNCE and CALL for PAPERS AND THEMATIC SESSIONS We would appreciate if you could distribute this information by your colleagues and co-workers. ------------------------------------------------------------------------------------------------------------------------------------------ Dear Colleague, We would like to call your attention to the International Conference VipIMAGE 2011 - III ECCOMAS THEMATIC CONFERENCE ON COMPUTATIONAL VISION AND MEDICAL IMAGE PROCESSING that will be held in Real Marina Hotel & Spa, Olh?o, Algarve, Portugal, on October 12-14, 2011. Possible Topics (not limited to) - Signal and Image Processing - Computational Vision - Medical Imaging - Physics of Medical Imaging - Tracking and Analysis of Movement - Simulation and Modeling - Image Acquisition - Shape Reconstruction - Objects Segmentation, Matching, Simulation - Data Interpolation, Registration, Acquisition and Compression - 3D Vision - Virtual Reality - Software Development for Image Processing and Analysis - Computer Aided Diagnosis, Surgery, Therapy, and Treatment - Computational Bioimaging and Visualization - Telemedicine Systems and their Applications Invited Lecturers - Armando J. Pinho - University of Aveiro, Portugal - Irene M. Gamba - The University of Texas at Austin, USA - Marc Pollefeys - ETH Zurich, Switzerland - Marc Thiriet - Universite Pierre et Marie Curie (Paris VI), France - Xavier Roca Marv? - Autonomous University of Barcelona, Spain - Stan Sclaroff - Boston University, USA Thematic Sessions Proposals to organize Thematic Session within VipIMAGE 2011 are mostly welcome. Proposals for Thematic Sessions should be submitted by email to the conference co-chairs (tavares at fe.up.pt, rnatal at fe.up.pt) Thematic Sessions Confirmed - Simultaneous MR-PET imaging - Satellite image analysis for environmental risk assessment Publications The proceedings book will be published by the Taylor & Francis Group and indexed by Thomson Reuters Conference Proceedings Citation Index, IET Inspect and Elsevier Scopus. A book with 20 invited works from the best ones presented in VipIMAGE2011 (extended versions) will be published by Springer. The organizers will encourage the submission of extended versions of the accepted papers to related International Journals; in particular, for special issues dedicated to the conference. Important dates - Deadline for Thematic Sessions proposals: 15th January 2011 - Deadline for Extended Abstracts: 15th March 2011 - Authors Notification: 15th April 2011 - Deadline for Full Papers: 15th June 2011 Awards "best paper award" and "best student paper award" are going to be given to the author(s) of two papers presented at the conference, selected by the Organizing Committee based on the best combined marks from the Scientific Committee and Session Chairs. We are looking forward to see you in Algarve next October. Kind regards, Jo?o Manuel R. S. Tavares Renato Natal Jorge (conference co-chairs) PS. For further details please see the conference website at: www.fe.up.pt/~vipimage From jeanmichel at sequans.com Fri Jan 7 09:22:40 2011 From: jeanmichel at sequans.com (Jean-Michel Pichavant) Date: Fri, 07 Jan 2011 15:22:40 +0100 Subject: Rewriting __getattr__ In-Reply-To: <191511294408478@web10.yandex.ru> References: <730351294351630@web139.yandex.ru> <4D271914.6090308@sequans.com> <191511294408478@web10.yandex.ru> Message-ID: <4D2721B0.7060601@sequans.com> kost BebiX wrote: > You're absolutely right! Now try to do except Keyerror: raise AttributeError and it will also fail. But why? > > 07.01.2011, 15:45, "Jean-Michel Pichavant" : > >> kost BebiX wrote: >> >> >>> Hi everyone! >>> I just saw a bug (?) in bson.dbref:DBRef.__getattr__ >>> >>> Here's they're code: >>> def __getattr__(self, key): >>> return self.__kwargs[key] >>> >>> And when you do copy.deepcopy on that object it will raise you KeyError. So here's a small piece of code that reproduces the problem: >>> >> from http://docs.python.org/reference/datamodel.html >> >> About __getattr__ >> "This method should return the (computed) attribute value or raise an >> AttributeError >> >> exception." >> >> The code you provided raises a KeyError thus methods such as 'getattr' >> will fail as they expect an AttributeError exception. >> >> JM >> >> -- >> http://mail.python.org/mailman/listinfo/python-list >> > > please don't top post :) It fails because you simply did not returned any value (with your class A example). class A(object): def __init__(self): self.d = {} def __getattr__(self, key): try: *return* self.d[key] except KeyError: raise AttributeError works fine with deepcopy JM From pavlovevidence at gmail.com Fri Jan 7 09:31:29 2011 From: pavlovevidence at gmail.com (Carl Banks) Date: Fri, 7 Jan 2011 06:31:29 -0800 (PST) Subject: PEP: possibility of inline using of a symbol instead of "import" References: <0952cc24-097d-4685-a92d-75054406ddf3@f20g2000vbc.googlegroups.com> Message-ID: <8fe5b19f-084a-4897-8d12-605344c6fa4d@y19g2000prb.googlegroups.com> On Jan 6, 7:28?am, dmitrey wrote: > hi all, > I have th PEP (I'm not sure something like that hadn't been proposed > although): > very often in a Python file header the following lines are present, > like: > from MyModule1 import myFunc1 > import MyModule2 as mm2 > from MyModule3 import myFunc3 as mf3 > etc > > and after several pages of code they are using somewhere, maybe only > one time, e.g. > r1 = myFunc1(...) > r2 = mm2.myFunc2(...) > r3 = mf3(...) > It makes programs less clear, you have to scroll several pages of code > in IDE to understand what it refers to. > > I propose to add possibility of using a symbol instead (for simplicity > I use @ here, that is already reserved for decorators, thus it should > be other symbol, maybe from Unicode although for simplicity to type it > I would prefer something ordinary like $ or ` or !). > > e.g. instead of > > import MyModule > (...lots of code...) > r = MyModule.myFunc(...) > > someone could just type in the single place > > r = @MyModule.myFunc(...) > > Also, "import MyModule2 as mm2" could be replaced to mere > mm2 = @MyModule2 > and "from MyModule3 import myFunc3 as mf3" could be replaced to mere > "mf3 = @MyModule3.myFunc3". > > As for __import__(ModuleTextName), it could be replaced to something > like @(ModuleTextName) or @{ModuleTextName} or @[ModuleTextName]. I actually wouldn't mind this; in fact Python's importing mechanism is bad enough that a complete overhaul might not be a bad thing. But, first of all, one can already do in-line imports in Python with the __import__ built-in function (and I used to do this frequently in throwaway scripts before list comprehensions were added). For instance, a one-liner to generate a password would be this: python -c 'for i in xrange(8): __import__("sys").stdout.write(__import__("random").choice(__import__("string").letters))' Today a better way to do it would be like this: python -c 'import random,string; print "".join(random.choice(string.letters) for i in xrange(8))' But that's a digression. The problem with in-line imports is that it can lead to deadlock in multithreaded programs, so for the most part it's a good idea to avoid importing within functions. Therefore, a syntax for it would really be needed to gain full benefit. This would allow the compiler to scan the file to collect a list of prerequisite modules. In my mind, the module itself wouldn't import the dependencies itself, it simply lists prerequisites and leaves it to the runtime to ensure that they've been imported. A side benefit to this is to keep module namespaces clean. Main drawback is that it makes accessing symbols in deepely nested packages unwieldy (since presumably you'd have to write out the fully- qualified name). Meh, I pretty much avoid deeply nested packages, and typically spell out the fully-qualified module names anyway. So not my problem. As for listing imports at the top of the program--I can't say I have much use for it. Sometimes it helps to see a list of prerqequisites in one place, but I can't say it's the most useful thing ever, and anyway it's misleading since the imports can become stale. I'd rather not have to stop and scroll up ten pages to add an import to the top of the module when I suddenly need to access time.sleep or itertools.count. So, pending a better syntax, I'll give it a +0; and the only reason I don't give it a +1 is it's such a drastic change. The syntax probably would deserve a lot of thought (being such a drastic change) but drawing from C++ a postfix operator would seem to fit. sys:: -> evaulates to the sys module sys::version -> evaluates to sys.version xml::etree::ElementTree:: -> as expected That has the unfortunate effect of making Python look like C++ though. Won't ever happen though. Carl Banks From pavlovevidence at gmail.com Fri Jan 7 09:34:38 2011 From: pavlovevidence at gmail.com (Carl Banks) Date: Fri, 7 Jan 2011 06:34:38 -0800 (PST) Subject: PEP: possibility of inline using of a symbol instead of "import" References: <0952cc24-097d-4685-a92d-75054406ddf3@f20g2000vbc.googlegroups.com> <1201388b-16b8-4452-9a1f-c9aa00b126e7@p38g2000vbn.googlegroups.com> Message-ID: <71bc0300-7bb1-4bc3-a72a-ef4dd3a413f6@21g2000prv.googlegroups.com> On Jan 6, 8:32?am, Tim Harig wrote: > 2. Your so-called PEP probably clashes with Python's use of @ for > ? ? ? ? decorators. He said it was just for simplicity's sake. Carl Banks From thibaud.roussillat at gmail.com Fri Jan 7 09:38:26 2011 From: thibaud.roussillat at gmail.com (Thibaud Roussillat) Date: Fri, 7 Jan 2011 15:38:26 +0100 Subject: Close stdout socket on CGI after fork with subprocess In-Reply-To: References: Message-ID: Hi, I work with Python 2.4 and CGI. I have a CGI which call a Python script in background process and return result before background task is finished. Actually, the browser displays response but it is waiting for end of background task because the socket is not closed. Internet told me that I must close the stdout file descriptor (sys.stdout.close()) to close the socket but it doesn't work. The background task is launched via subprocess.Popen and is attached to the root process on ps command. Any idea ? Thanks Thibaud -------------- next part -------------- An HTML attachment was scrubbed... URL: From kost-bebix at yandex.ua Fri Jan 7 09:47:55 2011 From: kost-bebix at yandex.ua (kost BebiX) Date: Fri, 07 Jan 2011 16:47:55 +0200 Subject: Rewriting __getattr__ In-Reply-To: <4D2721B0.7060601@sequans.com> References: <730351294351630@web139.yandex.ru> <4D271914.6090308@sequans.com> <191511294408478@web10.yandex.ru> <4D2721B0.7060601@sequans.com> Message-ID: <118251294411675@web154.yandex.ru> 07.01.2011, 16:22, "Jean-Michel Pichavant" : > kost BebiX wrote: > >> ?You're absolutely right! Now try to do except Keyerror: raise AttributeError and it will also fail. But why? >> >> ?07.01.2011, 15:45, "Jean-Michel Pichavant" ;: >>> ?kost BebiX wrote: >>>> ??Hi everyone! >>>> ??I just saw a bug (?) in bson.dbref:DBRef.__getattr__ >>>> >>>> ??Here's they're code: >>>> ??????def __getattr__(self, key): >>>> ??????????return self.__kwargs[key] >>>> >>>> ??And when you do copy.deepcopy on that object it will raise you KeyError. So here's a small piece of code that reproduces the problem: >>> ?from http://docs.python.org/reference/datamodel.html >>> >>> ?About __getattr__ >>> ?"This method should return the (computed) attribute value or raise an >>> ?AttributeError >>> ? >>> ?exception." >>> >>> ?The code you provided raises a KeyError thus methods such as 'getattr' >>> ?will fail as they expect an AttributeError exception. >>> >>> ?JM >>> >>> ?-- >>> ?http://mail.python.org/mailman/listinfo/python-list > > please don't top post :) > > It fails because you simply did not returned any value (with your class > A example). > > class A(object): > ????def __init__(self): > ????????self.d = {} > ????def __getattr__(self, key): > ????????try: > ????????????*return* self.d[key] > ????????except KeyError: > ????????????raise AttributeError > > works fine with deepcopy > > JM > > -- > http://mail.python.org/mailman/listinfo/python-list Sorry for top posting, didn't know about that) I'm quote new to posting to mailing lists. Well, actually the code you showed doesn't work) >>> class A(object): .. def __init__(self): .. self.d = {} .. def __getattr__(self, key): .. try: .. return self.d[key] .. except KeyError: .. raise AttributeError >>> from copy import deepcopy >>> a = A() >>> deepcopy(a) Exception RuntimeError: 'maximum recursion depth exceeded while calling a Python object' in ignored Exception RuntimeError: 'maximum recursion depth exceeded while calling a Python object' in ignored 0: <__main__.A object at 0xda0250> -- jabber: k.bx at ya.ru From jeanmichel at sequans.com Fri Jan 7 10:14:45 2011 From: jeanmichel at sequans.com (Jean-Michel Pichavant) Date: Fri, 07 Jan 2011 16:14:45 +0100 Subject: Rewriting __getattr__ In-Reply-To: <118251294411675@web154.yandex.ru> References: <730351294351630@web139.yandex.ru> <4D271914.6090308@sequans.com> <191511294408478@web10.yandex.ru> <4D2721B0.7060601@sequans.com> <118251294411675@web154.yandex.ru> Message-ID: <4D272DE5.9040604@sequans.com> kost BebiX wrote: > Sorry for top posting, didn't know about that) I'm quote new to posting to mailing lists. > > Well, actually the code you showed doesn't work) > > >>>> class A(object): >>>> > .. def __init__(self): > .. self.d = {} > .. def __getattr__(self, key): > .. try: > .. return self.d[key] > .. except KeyError: > .. raise AttributeError > >>>> from copy import deepcopy >>>> a = A() >>>> deepcopy(a) >>>> > Exception RuntimeError: 'maximum recursion depth exceeded while calling a Python object' in ignored > Exception RuntimeError: 'maximum recursion depth exceeded while calling a Python object' in ignored > 0: <__main__.A object at 0xda0250> > > > It does work as I pasted it with python2.5. recursion problems often occur when overriding __getattr__ or __getattribute__ *AND* accessing self attributes using self.attr form inside the method. try to change return self.d[key] into return object.__getattribute__(self, 'd')[key] Just speculating though, I cannot test since I don't reproduce the problem. JM From michael at stroeder.com Fri Jan 7 10:17:33 2011 From: michael at stroeder.com (=?UTF-8?B?TWljaGFlbCBTdHLDtmRlcg==?=) Date: Fri, 07 Jan 2011 16:17:33 +0100 Subject: Streaming templating languages for use as WSGI body. In-Reply-To: References: <1294336839.10436.2.camel@linux-yu4c.site> <1294341087.14042.3.camel@linux-yu4c.site> Message-ID: Alice Bevan?McGregor wrote: > On 2011-01-06 11:11:27 -0800, Adam Tauno Williams said: >> On Thu, 2011-01-06 at 11:07 -0800, Alice Bevan?McGregor wrote: >>> On 2011-01-06 10:00:39 -0800, Adam Tauno Williams said: >>>> With HTTP/1.0 [and WSGI is HTTP/1.0 only] you have to provide a >>>> Content-Length header - so you have to generate the entire response >>>> at once [however you want to muddy "at once"]. >>> >>> Both of these statements are false. >> >> Both these statements are true! I suggest you consult the HTTP spec. > > It's generally polite to provide direct references, either sections or > actual links when asking someone to RTFM. No matter, examining the > HTTP/1.0 RFC (conveniently chopped up and HTML-ified by the w3) I find > evidence to support your argument: > > http://www.w3.org/Protocols/HTTP/1.0/draft-ietf-http-spec.html#Entity-Body As I read section 7.2.2 (Length) the Content-length header is only required in HTTP *requests* if the body contains data. According to the text it's not required in HTTP *responses*. Ciao, Michael. From k.bx at ya.ru Fri Jan 7 10:18:43 2011 From: k.bx at ya.ru (kost BebiX) Date: Fri, 07 Jan 2011 17:18:43 +0200 Subject: Rewriting __getattr__ In-Reply-To: <4D272DE5.9040604@sequans.com> References: <730351294351630@web139.yandex.ru> <4D271914.6090308@sequans.com> <191511294408478@web10.yandex.ru> <4D2721B0.7060601@sequans.com> <118251294411675@web154.yandex.ru> <4D272DE5.9040604@sequans.com> Message-ID: <224691294413523@web18.yandex.ru> 07.01.2011, 17:14, "Jean-Michel Pichavant" : > kost BebiX wrote: > >> ?Sorry for top posting, didn't know about that) I'm quote new to posting to mailing lists. >> >> ?Well, actually the code you showed doesn't work) >>>>> ?class A(object): >> ?.. ????def __init__(self): >> ?.. ????????self.d = {} >> ?.. ????def __getattr__(self, key): >> ?.. ????????try: >> ?.. ????????????return self.d[key] >> ?.. ????????except KeyError: >> ?.. ????????????raise AttributeError >>>>> ?from copy import deepcopy >>>>> ?a = A() >>>>> ?deepcopy(a) >> ?Exception RuntimeError: 'maximum recursion depth exceeded while calling a Python object' in ignored >> ?Exception RuntimeError: 'maximum recursion depth exceeded while calling a Python object' in ignored >> ?0: <__main__.A object at 0xda0250> > > It does work as I pasted it with python2.5. > recursion problems often occur when overriding __getattr__ or > __getattribute__ *AND* accessing self attributes using self.attr form > inside the method. > > try to change > > ????return self.d[key] > > into > > ????return object.__getattribute__(self, 'd')[key] > > Just speculating though, I cannot test since I don't reproduce the problem. > > JM Yeap, that works. So, is it a python 2.6 bug? Because documentation says that __getattr__ is called only after property was not found (and __getattr__ was actually invented in a way that you can use self inside it). -- jabber: k.bx at ya.ru From steve+comp.lang.python at pearwood.info Fri Jan 7 10:41:59 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 07 Jan 2011 15:41:59 GMT Subject: Rewriting __getattr__ References: <730351294351630@web139.yandex.ru> <4D271914.6090308@sequans.com> <191511294408478@web10.yandex.ru> <4D2721B0.7060601@sequans.com> Message-ID: <4d273447$0$29976$c3e8da3$5496439d@news.astraweb.com> On Fri, 07 Jan 2011 16:47:55 +0200, kost BebiX wrote: > Well, actually the code you showed doesn't work) Actually, it does. It just prints a warning message as well. Look carefully: >>>> class A(object): > .. def __init__(self): > .. self.d = {} > .. def __getattr__(self, key): > .. try: > .. return self.d[key] > .. except KeyError: > .. raise AttributeError >>>> from copy import deepcopy >>>> a = A() >>>> deepcopy(a) > Exception RuntimeError: 'maximum recursion depth exceeded while calling > a Python object' in ignored > Exception RuntimeError: 'maximum recursion depth exceeded while calling > a Python object' in ignored > 0: <__main__.A object at 0xda0250> The last thing printed is the deepcopied object. I've tested the above code in Python versions 2.4 through 3.2 and the only one that prints that message is 2.6. -- Steven From pavlovevidence at gmail.com Fri Jan 7 10:56:26 2011 From: pavlovevidence at gmail.com (Carl Banks) Date: Fri, 7 Jan 2011 07:56:26 -0800 (PST) Subject: Resolve circular reference References: <1718ea91-fc4e-49f3-a15a-bdc683789126@k22g2000yqh.googlegroups.com> <353ecd61-22f8-4770-be30-29cb76b0f6b0@t35g2000yqj.googlegroups.com> Message-ID: <2349f7d4-2b85-456f-96b5-140f15548859@v17g2000prc.googlegroups.com> On Jan 7, 3:58?am, moerchendiser2k3 wrote: > > Force what? > > j refers to i, i refers to Foo, Foo refers to A. Therefore A should be > > alive. > > Oh, sorry. Force the deletion of instance Foo(A) and Bar(B). If you don't want j to keep i alive, you should look at weak referencing. (Look at the documentation for the weakref module. Also, this has nothing to do with A and B being C-defined types; this exact same behavior would happen even with Python types.) Carl Banks From jtim.arnold at gmail.com Fri Jan 7 11:24:01 2011 From: jtim.arnold at gmail.com (Tim) Date: Fri, 7 Jan 2011 08:24:01 -0800 (PST) Subject: os.system and loggers Message-ID: <70ac3463-cf3c-4435-909b-ac044bef7e41@z9g2000yqz.googlegroups.com> hi, I'm using a 3rd-party python program that uses the python logging facility and also makes calls to os.system. I'm trying to capture its output to a file. In my own code, I've taken control of the loggers that are setup in the other program by removing its StreamHandler and replacing with FileHander. But when it comes to the call to os.system I'm at a loss. I want to capture the stdout from that os.system call in my FileHandler. I thought this might work, before I call the other program's class/method: sys.stdout = getLogger('status').handlers[0].stream but no dice. Is there any clean way to get what I want? If not, I guess I'll override the other method with my own, but it will basically be a bunch of code copied with os.sytem replaced with subprocess, using getLogger('status').handlers[0].stream for stdout/ stderr. thanks, --Tim Arnold From alice at gothcandy.com Fri Jan 7 16:25:10 2011 From: alice at gothcandy.com (=?utf-8?Q?Alice_Bevan=E2=80=93McGregor?=) Date: Fri, 7 Jan 2011 13:25:10 -0800 Subject: Streaming templating languages for use as WSGI body. References: <1294336839.10436.2.camel@linux-yu4c.site> <1294341087.14042.3.camel@linux-yu4c.site> Message-ID: On 2011-01-07 07:17:33 -0800, Michael Str?der said: > As I read section 7.2.2 (Length) the Content-length header is only > required in HTTP *requests* if the body contains data. According to the > text it's not required in HTTP *responses*. You are correct; I mis-read that section in my haste. - Alice. From k.bx at ya.ru Fri Jan 7 16:51:53 2011 From: k.bx at ya.ru (kost BebiX) Date: Fri, 07 Jan 2011 23:51:53 +0200 Subject: Rewriting __getattr__ In-Reply-To: <2c5dfddb-abab-40ac-9936-ac4ee3778002@fm22g2000vbb.googlegroups.com> References: <730351294351630@web139.yandex.ru> <4D271914.6090308@sequans.com> <191511294408478@web10.yandex.ru> <4D2721B0.7060601@sequans.com> <118251294411675@web154.yandex.ru> <4D272DE5.9040604@sequans.com> <2c5dfddb-abab-40ac-9936-ac4ee3778002@fm22g2000vbb.googlegroups.com> Message-ID: <93751294437113@web122.yandex.ru> 07.01.2011, 23:48, "Fuzzyman" : > On Jan 7, 3:18?pm, kost BebiX ; wrote: > >> ?07.01.2011, 17:14, "Jean-Michel Pichavant" ;: >>> ?kost BebiX wrote: >>>> ??Sorry for top posting, didn't know about that) I'm quote new to posting to mailing lists. >>>> ??Well, actually the code you showed doesn't work) >>>>>>> ??class A(object): >>>> ??.. ????def __init__(self): >>>> ??.. ????????self.d = {} >>>> ??.. ????def __getattr__(self, key): >>>> ??.. ????????try: >>>> ??.. ????????????return self.d[key] >>>> ??.. ????????except KeyError: >>>> ??.. ????????????raise AttributeError >>>>>>> ??from copy import deepcopy >>>>>>> ??a = A() >>>>>>> ??deepcopy(a) >>>> ??Exception RuntimeError: 'maximum recursion depth exceeded while calling a Python object' in ignored >>>> ??Exception RuntimeError: 'maximum recursion depth exceeded while calling a Python object' in ignored >>>> ??0: <__main__.A object at 0xda0250> >>> ?It does work as I pasted it with python2.5. >>> ?recursion problems often occur when overriding __getattr__ or >>> ?__getattribute__ *AND* accessing self attributes using self.attr form >>> ?inside the method. >>> ?try to change >>> ?????return self.d[key] >>> ?into >>> ?????return object.__getattribute__(self, 'd')[key] >>> ?Just speculating though, I cannot test since I don't reproduce the problem. >>> ?JM >> ?Yeap, that works. So, is it a python 2.6 bug? Because documentation says that __getattr__ is called only after property was not found (and __getattr__ was actually invented in a way that you can use self inside it). > > That is true (that __getattr__ is called only if the attribute doesn't > exist), however deepcopy works by creating a new instance *without* > calling __init__. When it is copying the attributes self.d *doesn't* > exist initially. You should work around this case in your __getattr__ > if you want your object to be deep-copyable. > > Michael Foord > -- > http://www.voidspace.org.uk/ Yeah, but, I mean, shouldn't deepcopy copy the attributes before it gets to calling __getattr__? From k.bx at ya.ru Fri Jan 7 16:54:24 2011 From: k.bx at ya.ru (kost BebiX) Date: Fri, 07 Jan 2011 23:54:24 +0200 Subject: Rewriting __getattr__ In-Reply-To: <4d273447$0$29976$c3e8da3$5496439d@news.astraweb.com> References: <730351294351630@web139.yandex.ru> <4D271914.6090308@sequans.com> <191511294408478@web10.yandex.ru> <4D2721B0.7060601@sequans.com> <4d273447$0$29976$c3e8da3$5496439d@news.astraweb.com> Message-ID: <546511294437264@web13.yandex.ru> 07.01.2011, 17:47, "Steven D'Aprano" : > On Fri, 07 Jan 2011 16:47:55 +0200, kost BebiX wrote: > >> ?Well, actually the code you showed doesn't work) > > Actually, it does. It just prints a warning message as well. Look > carefully: > >>>>> ?class A(object): >> ?.. ????def __init__(self): >> ?.. ????????self.d = {} >> ?.. ????def __getattr__(self, key): >> ?.. ????????try: >> ?.. ????????????return self.d[key] >> ?.. ????????except KeyError: >> ?.. ????????????raise AttributeError >>>>> ?from copy import deepcopy >>>>> ?a = A() >>>>> ?deepcopy(a) >> ?Exception RuntimeError: 'maximum recursion depth exceeded while calling >> ?a Python object' in ignored >> ?Exception RuntimeError: 'maximum recursion depth exceeded while calling >> ?a Python object' in ignored >> ?0: <__main__.A object at 0xda0250> > > The last thing printed is the deepcopied object. > > I've tested the above code in Python versions 2.4 through 3.2 and the > only one that prints that message is 2.6. > > -- > Steven > -- > http://mail.python.org/mailman/listinfo/python-list So maybe it should be fixed in 2.6? When I'll have time I'll look at copy.py in different python's. Maybe there's the answer) Thanks anyway. From steve+comp.lang.python at pearwood.info Fri Jan 7 19:20:19 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 08 Jan 2011 00:20:19 GMT Subject: Rewriting __getattr__ References: <730351294351630@web139.yandex.ru> <4D271914.6090308@sequans.com> <191511294408478@web10.yandex.ru> <4D2721B0.7060601@sequans.com> <4d273447$0$29976$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4d27adc3$0$29976$c3e8da3$5496439d@news.astraweb.com> On Fri, 07 Jan 2011 23:54:24 +0200, kost BebiX wrote: > 07.01.2011, 17:47, "Steven D'Aprano" > : >> On Fri, 07 Jan 2011 16:47:55 +0200, kost BebiX wrote: >> >>> ?Well, actually the code you showed doesn't work) >> >> Actually, it does. It just prints a warning message as well. Look >> carefully: [...] >> I've tested the above code in Python versions 2.4 through 3.2 and the >> only one that prints that message is 2.6. > So maybe it should be fixed in 2.6? When I'll have time I'll look at > copy.py in different python's. Maybe there's the answer) Thanks anyway. Before you spend too much (i.e. any) time trying to fix this, I think that Python 2.6 is now only accepting security fixes. http://www.python.org/download/releases/2.6.6/ -- Steven From jason.swails at gmail.com Fri Jan 7 20:05:40 2011 From: jason.swails at gmail.com (Jason Swails) Date: Fri, 7 Jan 2011 20:05:40 -0500 Subject: Can I have both Python 2.7 and Python 3.1 at the same time on the Mac? In-Reply-To: <51F66C79-5607-4943-B56C-2EF22F3AD407@cagttraining.com> References: <775A9D45-25B5-4A16-9FE5-6217FD67F3AF@cagttraining.com> <51F66C79-5607-4943-B56C-2EF22F3AD407@cagttraining.com> Message-ID: MacPorts! They include a nifty little package called python_select that lets you switch default python versions on-the-fly and organizes everything for you perfectly. I have python 2.4, 2.5, 2.6, 2.7, 3.2, and the system default 2.6.1 all installed, and python_select python27 python_select python32 python_select python26-apple switches seamlessly between them. (I have so many versions to test script compatibility, not because I'm an avid collector). In any case, this seems to be an ideal solution. All the best, Jason On Thu, Jan 6, 2011 at 5:25 PM, Bill Felton wrote: > On Jan 6, 2011, at 3:46 PM, Ned Deily wrote: > > In article <775A9D45-25B5-4A16-9FE5-6217FD67F3AF at cagttraining.com>, > > Bill Felton wrote: > > I'm new to python, trying to learn it from a variety of resources, > including > > references posted recently to this list. > > I'm going through /www.openbookproject.net/thinkCSpy/ and find it makes > use > > of gasp, which apparently is not compatible with 3.1. > > I've also seen various resources indicate that one can install both Python > > 2.7 and Python 3.1 -- but when I did this, I get no end of problems in the > > 2.7 install. IDLE, in particular, fails rather spectacularly, even if I > > launch it directly from the Python 2.7 directory in which it resides. > > So, either I've been misled and should only try to have one or the other. > OR > > I'm missing some (probably simple) step that's mucking me up. > > Help? > > > Yes, you can have multiple versions of Python installed on Mac OS X. In > > fact, Apple ships multiple versions of Python with OS X (2.6 and 2.6 > > with OS X 10.6, for example). Starting with Python 2.7, python.org > > offers two variants of OS X installers, one is 32-bit-only and works on > > all versions of OS X 10.3.9 through OS X 10.6, the other supports 64-bit > > execution and only works on 10.6 (as of 2.7.1). Unfortunately, there > > are some major interaction problems between Tkinter, Python's GUI > > toolkit which is used by IDLE, and the Tcl/Tk 8.5 supplied by Apple in > > OS X 10.6. I'm assuming you installed the 64-bit version. If so, until > > the problem is resolved in the next maintenance release of Python 2.7, I > > suggest you download and install the 32-bit-only version of Python 2.7.1 > > which does not have those problems. > > > > Thank you, Ned! Installing what appeared to be the 'old OS' version seems > to fix my difficulty. > IDLE now works fine without hanging, I can enter code, save, check syntax, > and run from the 'new window'. > And 3.1 still works as before. > > regards, > Bill > > -- > http://mail.python.org/mailman/listinfo/python-list > > -- Jason M. Swails Quantum Theory Project, University of Florida Ph.D. Graduate Student 352-392-4032 -------------- next part -------------- An HTML attachment was scrubbed... URL: From linnaweb at gmail.com Fri Jan 7 20:08:28 2011 From: linnaweb at gmail.com (linna li) Date: Fri, 7 Jan 2011 17:08:28 -0800 (PST) Subject: apscheduler error Message-ID: <9699865b-a8be-4284-a347-58d875b491f6@n2g2000pre.googlegroups.com> I tried to use the apscheduler and used the sample code below from the tutorial, but got the error message: Exception in thread APScheduler (most likely raised during interpreter shutdown). What's going on here? I really appreciate any help! from apscheduler.scheduler import Scheduler sched = Scheduler() sched.start() def some_job(): print "Decorated job" sched.add_interval_job(some_job,minutes=1) From nad at acm.org Fri Jan 7 20:46:37 2011 From: nad at acm.org (Ned Deily) Date: Fri, 07 Jan 2011 17:46:37 -0800 Subject: Can I have both Python 2.7 and Python 3.1 at the same time on the Mac? References: <775A9D45-25B5-4A16-9FE5-6217FD67F3AF@cagttraining.com> <51F66C79-5607-4943-B56C-2EF22F3AD407@cagttraining.com> Message-ID: In article , Jason Swails wrote: > MacPorts! They include a nifty little package called python_select that > lets you switch default python versions on-the-fly and organizes everything > for you perfectly. I have python 2.4, 2.5, 2.6, 2.7, 3.2, and the system > default 2.6.1 all installed, and > > python_select python27 > python_select python32 > python_select python26-apple > > switches seamlessly between them. (I have so many versions to test script > compatibility, not because I'm an avid collector). In any case, this seems > to be an ideal solution. Unfortunately, that's not a complete solution. The biggest hole is that it does not automatically solve the problem of scripts installed into the particular version's framework bin directory, neither all of the current scripts included in the standard python distribution nor 3rd party version-dependent scripts, things like easy_install, pip, etc. The former is easily fixed, the latter is harder to automate. The python.org installers take the route of providing a shell script app for each version to modify your shell login profile to insert that version's bin directory at the head of the $PATH env variable. Modifying a shell profile is clearly not a particularly clean solution but it does actually work whereas python_select, in general, does not. -- Ned Deily, nad at acm.org From steve+comp.lang.python at pearwood.info Fri Jan 7 21:09:49 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 08 Jan 2011 02:09:49 GMT Subject: apscheduler error References: <9699865b-a8be-4284-a347-58d875b491f6@n2g2000pre.googlegroups.com> Message-ID: <4d27c76d$0$29976$c3e8da3$5496439d@news.astraweb.com> On Fri, 07 Jan 2011 17:08:28 -0800, linna li wrote: > I tried to use the apscheduler and used the sample code below from the > tutorial, but got the error message: Exception in thread APScheduler > (most likely raised during interpreter shutdown). What's going on here? > I really appreciate any help! I've tried your code in every version of Python from 2.4 through 3.2, and get an exception on the very first line every time: ImportError: No module named apscheduler.scheduler I think you will need to give some more detail... what version of Python are you running, and what is apschedular? Also, please copy and paste the exact error message, in full, including the traceback. Don't summarise it, retype it, or paraphrase it. -- Steven From clp2 at rebertia.com Fri Jan 7 21:13:26 2011 From: clp2 at rebertia.com (Chris Rebert) Date: Fri, 7 Jan 2011 18:13:26 -0800 Subject: apscheduler error In-Reply-To: <4d27c76d$0$29976$c3e8da3$5496439d@news.astraweb.com> References: <9699865b-a8be-4284-a347-58d875b491f6@n2g2000pre.googlegroups.com> <4d27c76d$0$29976$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Fri, Jan 7, 2011 at 6:09 PM, Steven D'Aprano wrote: > On Fri, 07 Jan 2011 17:08:28 -0800, linna li wrote: >> I tried to use the apscheduler and used the sample code below from the >> tutorial, but got the error message: Exception in thread APScheduler >> (most likely raised during interpreter shutdown). What's going on here? >> I really appreciate any help! > > > I've tried your code in every version of Python from 2.4 through 3.2, and > get an exception on the very first line every time: > > ImportError: No module named apscheduler.scheduler > > > I think you will need to give some more detail... what version of Python > are you running, and what is apschedular? A quick Google search suggests it's http://packages.python.org/APScheduler/ Cheers, Chris From k.bx at ya.ru Fri Jan 7 21:13:42 2011 From: k.bx at ya.ru (kost BebiX) Date: Sat, 08 Jan 2011 04:13:42 +0200 Subject: Rewriting __getattr__ In-Reply-To: <4d27adc3$0$29976$c3e8da3$5496439d@news.astraweb.com> References: <730351294351630@web139.yandex.ru> <4D271914.6090308@sequans.com> <191511294408478@web10.yandex.ru> <4D2721B0.7060601@sequans.com> <4d273447$0$29976$c3e8da3$5496439d@news.astraweb.com> <4d27adc3$0$29976$c3e8da3$5496439d@news.astraweb.com> Message-ID: <771791294452822@web75.yandex.ru> 08.01.2011, 02:20, "Steven D'Aprano" : > On Fri, 07 Jan 2011 23:54:24 +0200, kost BebiX wrote: > >> ?07.01.2011, 17:47, "Steven D'Aprano" >> ?;: >>> ?On Fri, 07 Jan 2011 16:47:55 +0200, kost BebiX wrote: >>>> ??Well, actually the code you showed doesn't work) >>> ?Actually, it does. It just prints a warning message as well. Look >>> ?carefully: > > [...] > >>> ?I've tested the above code in Python versions 2.4 through 3.2 and the >>> ?only one that prints that message is 2.6. >> ?So maybe it should be fixed in 2.6? When I'll have time I'll look at >> ?copy.py in different python's. Maybe there's the answer) Thanks anyway. > > Before you spend too much (i.e. any) time trying to fix this, I think > that Python 2.6 is now only accepting security fixes. > > http://www.python.org/download/releases/2.6.6/ > > -- > Steven Too bad (I mean, it's not too bad, because this thing can break other's 2.6 code that somehow depends on that). Now when I'll install 2.7 I'll have to remember about this bug when coding) From kushal.kumaran+python at gmail.com Fri Jan 7 21:19:18 2011 From: kushal.kumaran+python at gmail.com (Kushal Kumaran) Date: Sat, 8 Jan 2011 07:49:18 +0530 Subject: Close stdout socket on CGI after fork with subprocess In-Reply-To: References: Message-ID: On Fri, Jan 7, 2011 at 8:08 PM, Thibaud Roussillat wrote: > Hi, > > I work with Python 2.4 and CGI. > > I have a CGI which call a Python script in background process and return > result before background task is finished. > > Actually, the browser displays response but it is waiting for end of > background task because the socket is not closed. > > Internet told me that I must close the stdout file descriptor > (sys.stdout.close()) to close the socket but it doesn't work. > > The background task is launched via subprocess.Popen and is attached to the > root process on ps command. > This means that the parent process finished before the child. Call wait() on the Popen object to wait for the child to terminate. Depending on how you create the Popen object, the child process may inherit your own stdout. In that case, the child process may be keeping the socket open after the parent dies. -- regards, kushal From jlsphar at gmail.com Fri Jan 7 21:42:45 2011 From: jlsphar at gmail.com (John) Date: Fri, 7 Jan 2011 18:42:45 -0800 (PST) Subject: student question Message-ID: >>> q_file = open(questions_location) #opens the document successfully >>> for line in q_file: print line # prints document successfully >>> line # prints last line of document >>> for line in q_file: print line # prints nothing ...why does it print nothing? From kb1pkl at aim.com Fri Jan 7 21:47:05 2011 From: kb1pkl at aim.com (Corey Richardson) Date: Fri, 07 Jan 2011 21:47:05 -0500 Subject: student question In-Reply-To: References: Message-ID: <4D27D029.7050708@aim.com> On 01/07/2011 09:42 PM, John wrote: >>>> q_file = open(questions_location) #opens the document successfully >>>> for line in q_file: > print line > > # prints document successfully >>>> line > # prints last line of document >>>> for line in q_file: > print line # prints nothing > > ...why does it print nothing? IIRC, iterating through the lines in a file moves the cursor (is that the correct term?) to the end of the file. After the first one, use q_file.seek(0) to go back to the start. I think. ~Corey Richardson From jlsphar at gmail.com Fri Jan 7 21:54:29 2011 From: jlsphar at gmail.com (John) Date: Fri, 7 Jan 2011 18:54:29 -0800 (PST) Subject: student question References: Message-ID: On Jan 7, 6:47?pm, Corey Richardson wrote: > On 01/07/2011 09:42 PM, John wrote: > > >>>> q_file = open(questions_location) #opens the document successfully > >>>> for line in q_file: > > ? ? ? ? ? ?print line > > > # prints document successfully > >>>> line > > # prints last line of document > >>>> for line in q_file: > > ? ? ? ? ? ?print line # prints nothing > > > ...why does it print nothing? > > IIRC, iterating through the lines in a file moves the cursor (is that > the correct term?) to the end of the file. After the first one, use > q_file.seek(0) to go back to the start. I think. > > ~Corey Richardson fantastic. thanks, corey! From zuying at gmail.com Fri Jan 7 22:06:46 2011 From: zuying at gmail.com (Ying Zu) Date: 8 Jan 2011 03:06:46 GMT Subject: How to read ansic file into a pre-defined class? Message-ID: How to read ansic file into a pre-defined class? I have a series of files written in the following format, 2 # number of classes 100 # number of items for the first class object 0 foo 1 foo ... 99 foo 150 # number of items for the second class object 0 bar 1 bar ... 149 bar ultimately I want to read the file to two *structs* (sorry for my C jargon, just started playing with Python), with attributes number_of_items and data_array. I wrote a simply code to read and split each line into a list, then try to tell the meaning of each line by the number of elements of each line list and the its position in the file. But it is definitely not the way Python should be used. Any ideas on how to implement a more elegant yet efficient python version? Thanks. meaning of each line by counting the number of elements From zuying at gmail.com Fri Jan 7 22:24:01 2011 From: zuying at gmail.com (Ying Zu) Date: 8 Jan 2011 03:24:01 GMT Subject: How to read ansic file into a pre-defined class? Message-ID: How to read ansic file into a pre-defined class? I have a series of files written in the following format, 2 # number of classes 100 # number of items for the first class object 0 foo 1 foo ... 99 foo 150 # number of items for the second class object 0 bar 1 bar ... 149 bar ultimately I want to read the file to two *structs* (sorry for my C jargon, just started playing with Python), with attributes number_of_items and data_array. I wrote a simply code to read and split each line into a list, then try to tell the meaning of each line by the number of elements of each line list and the its position in the file. But it is definitely not the way Python should be used. Any ideas on how to implement a more elegant yet efficient python version? Thanks. -- ~ying From awilliam at whitemice.org Fri Jan 7 22:49:54 2011 From: awilliam at whitemice.org (Adam Tauno Williams) Date: Fri, 07 Jan 2011 22:49:54 -0500 Subject: apscheduler error In-Reply-To: <9699865b-a8be-4284-a347-58d875b491f6@n2g2000pre.googlegroups.com> References: <9699865b-a8be-4284-a347-58d875b491f6@n2g2000pre.googlegroups.com> Message-ID: <1294458594.11145.21.camel@linux-yu4c.site> On Fri, 2011-01-07 at 17:08 -0800, linna li wrote: > I tried to use the apscheduler and used the sample code below from the > tutorial, but got the error message: Exception in thread APScheduler > (most likely raised during interpreter shutdown). What's going on > here? I really appreciate any help! > > from apscheduler.scheduler import Scheduler > > sched = Scheduler() > sched.start() > > def some_job(): > print "Decorated job" > > sched.add_interval_job(some_job,minutes=1) I see this same error when I run this code (python-2.6.5-3.3.1.x86_64) I develop an application that uses APScheduler , the scheduler works very well. But I haven't used it in exactly this manner. If I add - import time time.sleep(300) - to the end of your script I don't get the error; and the job actually gets run [the scheduler thread won't stop the main thread, and thus the script, from exiting]. The author of APScheduler has an eponymously named channel on FreeNode, he can probably answer your question exactly. From kanthony at woh.rr.com Fri Jan 7 23:43:54 2011 From: kanthony at woh.rr.com (Keith Anthony) Date: Fri, 07 Jan 2011 22:43:54 -0600 Subject: More Help with python .find fucntion Message-ID: My previous question asked how to read a file into a strcuture a line at a time. Figured it out. Now I'm trying to use .find to separate out the PDF objects. (See code) PROBLEM/QUESTION: My call to lines[i].find does NOT find all instances of endobj. Any help available? Any insights? #!/usr/bin/python inputfile = file('sample.pdf','rb') # This is PDF with which we will work lines = inputfile.readlines() # read file one line at a time linestart = [] # Starting address for each line lineend = [] # Ending address for each line linetype = [] print len(lines) # print number of lines i = 0 # define an iterator, i addr = 0 # and address pointer while i < len(lines): # Go through each line linestart = linestart + [addr] length = len(lines[i]) lineend = lineend + [addr + (length-1)] addr = addr + length i = i + 1 i = 0 while i < len(lines): # Initialize line types as normal linetype = linetype + ['normal'] i = i + 1 i = 0 while i < len(lines): # if lines[i].find(' obj') > 0: linetype[i] = 'object' print "At address ",linestart[i],"object found at line ",i,": ", lines[i] if lines[i].find('endobj') > 0: linetype[i] = 'endobj' print "At address ",linestart[i],"endobj found at line ",i,": ", lines[i] i = i + 1 -- --------------------------------- --- -- - Posted with NewsLeecher v4.0 Final Web @ http://www.newsleecher.com/?usenet ------------------- ----- ---- -- - From clp2 at rebertia.com Sat Jan 8 00:06:55 2011 From: clp2 at rebertia.com (Chris Rebert) Date: Fri, 7 Jan 2011 21:06:55 -0800 Subject: More Help with python .find fucntion In-Reply-To: References: Message-ID: On Fri, Jan 7, 2011 at 8:43 PM, Keith Anthony wrote: > My previous question asked how to read a file into a strcuture > a line at a time. ?Figured it out. ?Now I'm trying to use .find > to separate out the PDF objects. ?(See code) ?PROBLEM/QUESTION: > My call to lines[i].find does NOT find all instances of endobj. > Any help available? ?Any insights? > > #!/usr/bin/python > > inputfile = ?file('sample.pdf','rb') ? ? ? ? ? ?# This is PDF with which we will work > lines = inputfile.readlines() ? ? ? ? ? ? ? ? ? # read file one line at a time > > linestart = [] ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?# Starting address for each line > lineend = [] ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?# Ending address for each line > linetype = [] > > print len(lines) ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?# print number of lines > > i = 0 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? # define an iterator, i > addr = 0 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?# and address pointer > > while i < len(lines): ? ? ? ? ? ? ? ? ? ? ? ? ? # Go through each line > ? ?linestart = linestart + [addr] > ? ?length = len(lines[i]) > ? ?lineend = lineend + [addr + (length-1)] > ? ?addr = addr + length > ? ?i = i + 1 > > i = 0 > while i < len(lines): ? ? ? ? ? ? ? ? ? ? ? ? ? # Initialize line types as normal > ? ?linetype = linetype + ['normal'] > ? ?i = i + 1 > > i = 0 > while i < len(lines): ? ? ? ? ? ? ? ? ? ? ? ? ? # > ? ?if lines[i].find(' obj') > 0: > ? ? ? ?linetype[i] = 'object' > ? ? ? ?print "At address ",linestart[i],"object found at line ",i,": ", lines[i] > ? ?if lines[i].find('endobj') > 0: > ? ? ? ?linetype[i] = 'endobj' > ? ? ? ?print "At address ",linestart[i],"endobj found at line ",i,": ", lines[i] > ? ?i = i + 1 Your code can be simplified significantly. In particular: - Don't add single-element lists. Use the list.append() method instead. - One seldom manually tracks counters like `i` in Python; use range() or enumerate() instead. - Lists have a multiply method which gives the concatenation of n copies of the list. Revised version (untested obviously): inputfile = file('sample.pdf','rb') # This is PDF with which we will work lines = inputfile.readlines() # read file one line at a time linestart = [] # Starting address for each line lineend = [] # Ending address for each line linetype = ['normal']*len(lines) print len(lines) # print number of lines addr = 0 # and address pointer for line in lines: # Go through each line linestart.append(addr) length = len(line) lineend.append(addr + (length-1)) addr += length for i, line in enumerate(lines): if line.find(' obj') > 0: linetype[i] = 'object' print "At address ",linestart[i],"object found at line ",i,": ", line if line.find('endobj') > 0: linetype[i] = 'endobj' print "At address ",linestart[i],"endobj found at line ",i,": ", line As to the bug: I think you want "!= -1" rather than "> 0" for your conditionals; remember that Python list/string indices are 0-based. Cheers, Chris -- http://blog.rebertia.com From stackslip at gmail.com Sat Jan 8 00:18:42 2011 From: stackslip at gmail.com (Garland Fulton) Date: Fri, 7 Jan 2011 20:18:42 -0900 Subject: Error invalid syntax while statement Message-ID: I don't understand what I'm doing wrong i've tried several different cases for what i am doing here. Will someone please point my error out. Thank you. 1 #!/bin/bash/python 2 import math 3 try: 4 x = int(input("Enter your number: ")) 5 if( 0 > x | x > 2147483647): 6 raise Exception() 7 else: 8 end = 0 9 count = 0 10 count1 = x 11 counter = 0 12 print("end: ", end) 13 print("count: ", count) 14 print("count1: ", count1) 15 print("counter: ", counter 16 17 while (end == 0): # <-------------------returns syntax error on this while statement 18 if(count < x): 19 20 sol = math.pow(count, 2) + math.pow(count1, 2) 21 count += 1 22 count1 -= 1 23 print("end: ", end) 24 print("count: ", count) 25 print("count1: ", count1) 26 print("counter: ", counter 27 if( sol == x): 28 counter += x 29 else: 30 end = 1 31 except Exception as ran: 32 print("Value not within range", ran) -------------- next part -------------- An HTML attachment was scrubbed... URL: From clp2 at rebertia.com Sat Jan 8 00:28:19 2011 From: clp2 at rebertia.com (Chris Rebert) Date: Fri, 7 Jan 2011 21:28:19 -0800 Subject: Error invalid syntax while statement In-Reply-To: References: Message-ID: On Fri, Jan 7, 2011 at 9:18 PM, Garland Fulton wrote: > I don't understand what I'm doing wrong i've tried several different cases > for what i am doing here. Will someone please point my error out. > Thank you. > > ??1 #!/bin/bash/python This shebang undoubtedly erroneous. > ??5 ? ? if( 0 > x | x > 2147483647): One normally writes that using boolean "or" rather than the bitwise operator. Also, the parentheses are completely unnecessary visual clutter. > ?15 ? ? ? ? print("counter: ", counter Where's the closing parenthesis? > ?17 ? ? ? ? ? ? ? while (end == 0): ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?# > <-------------------returns syntax error on this while statement Always include the exact error message + traceback in the future. Cheers, Chris -- http://blog.rebertia.com From nad at acm.org Sat Jan 8 00:28:40 2011 From: nad at acm.org (Ned Deily) Date: Fri, 07 Jan 2011 21:28:40 -0800 Subject: Error invalid syntax while statement References: Message-ID: In article , Garland Fulton wrote: > I don't understand what I'm doing wrong i've tried several different cases > for what i am doing here. Will someone please point my error out. > 15 print("counter: ", counter Missing ")" on line 15. -- Ned Deily, nad at acm.org From steve+comp.lang.python at pearwood.info Sat Jan 8 00:35:45 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 08 Jan 2011 05:35:45 GMT Subject: More Help with python .find fucntion References: Message-ID: <4d27f7b1$0$29976$c3e8da3$5496439d@news.astraweb.com> On Fri, 07 Jan 2011 22:43:54 -0600, Keith Anthony wrote: > My previous question asked how to read a file into a strcuture a line at > a time. Figured it out. Now I'm trying to use .find to separate out > the PDF objects. (See code) PROBLEM/QUESTION: My call to lines[i].find > does NOT find all instances of endobj. Any help available? Any > insights? > > #!/usr/bin/python > > inputfile = file('sample.pdf','rb') # This is PDF with which > we will work > lines = inputfile.readlines() # read file > one line at a time That's incorrect. readlines() reads the entire file in one go, and splits it into individual lines. > linestart = [] # Starting address for > each line > lineend = [] # Ending > address for each line > linetype = [] *raises eyebrow* How is an empty list a starting or ending address? The only thing worse than no comments where you need them is misleading comments. A variable called "linestart" implies that it should be a position, e.g. linestart = 0. Or possibly a flag. > print len(lines) # print number of lines > > i = 0 # define an iterator, i Again, 0 is not an iterator. 0 is a number. > addr = 0 # and address pointer > > while i < len(lines): # Go through each line > linestart = linestart + [addr] > length = len(lines[i]) > lineend = lineend + [addr + (length-1)] addr = addr + length > i = i + 1 Complicated and confusing and not the way to do it in Python. Something like this is much simpler: linetypes = [] # note plural inputfile = open('sample.pdf','rb') # Don't use file, use open. for line_number, line in enumerate(inputfile): # Process one line at a time. No need for that nonsense with manually # tracked line numbers, enumerate() does that for us. # No need to initialise linetypes. status = 'normal' i = line.find(' obj') if i >= 0: print "Object found at offset %d in line %d" % (i, line_number) status = 'object' i = line.find('endobj') if i >= 0: print "endobj found at offset %d in line %d" % (i, line_number) if status == 'normal': status = 'endobj' else: status = 'object & endobj' # both found on the one line linetypes.append(status) # What if obj or endobj exist more than once in a line? One last thing... if PDF files are a binary format, what makes you think that they can be processed line-by-line? They may not have lines, except by accident. -- Steven From stackslip at gmail.com Sat Jan 8 00:46:51 2011 From: stackslip at gmail.com (Garland Fulton) Date: Fri, 7 Jan 2011 20:46:51 -0900 Subject: Error invalid syntax while statement In-Reply-To: References: Message-ID: On Fri, Jan 7, 2011 at 8:28 PM, Ned Deily wrote: > In article > , > Garland Fulton wrote: > > I don't understand what I'm doing wrong i've tried several different > cases > > for what i am doing here. Will someone please point my error out. > > > 15 print("counter: ", counter > > Missing ")" on line 15. > > -- > Ned Deily, > nad at acm.org > > -- > http://mail.python.org/mailman/listinfo/python-list > 1 #!/bin/bash/python 2 import math 3 try: 4 x = int(input("Enter your number: ")) 5 if 0 > x > 2147483647: 6 raise Exception() 7 else: 8 end = 0 9 count = 0 10 count1 = x 11 counter = 0 12 print("end: ", end) 13 print("count: ", count) 14 print("count1: ", count1) 15 print("counter: ", counter) 16 17 while end == 0: # <-------------------returns syntax error on this while statement 18 if(count < x): 19 20 sol = math.pow(count, 2) + math.pow(count1, 2) 21 count += 1 22 count1 -= 1 23 print("end: ", end) 24 print("count: ", count) 25 print("count1: ", count1) 26 print("counter: ", counter) 27 if sol == x: 28 counter += x 29 else: 30 end = 1 31 except Exception as ran: 32 print("Value not within range", ran) File "blah.py", line 17 while (end == 0): # <-------------------returns syntax error on this while statement ^ IndentationError: unexpected indent Thank you and I'm sorry for the very blind question, it was because of the missing par-ends I have spent a while on this won't happen again. What is wrong with my shebang line? Thank you for the syntax tips! -------------- next part -------------- An HTML attachment was scrubbed... URL: From clp2 at rebertia.com Sat Jan 8 00:55:05 2011 From: clp2 at rebertia.com (Chris Rebert) Date: Fri, 7 Jan 2011 21:55:05 -0800 Subject: Error invalid syntax while statement In-Reply-To: References: Message-ID: On Fri, Jan 7, 2011 at 9:46 PM, Garland Fulton wrote: > ??1 #!/bin/bash/python > What is > wrong with my shebang line? Its path is invalid (unless you're using a *very* weird system). /bin/bash is the bash shell executable; bash is completely unrelated to Python. Further, /bin/bash is a file, not a directory. The shebang for Python is normally one of the following: #!/usr/bin/env python #!/usr/bin/python Cheers, Chris -- http://blog.rebertia.com From stackslip at gmail.com Sat Jan 8 00:57:25 2011 From: stackslip at gmail.com (Garland Fulton) Date: Fri, 7 Jan 2011 20:57:25 -0900 Subject: Error invalid syntax while statement In-Reply-To: References: Message-ID: On Fri, Jan 7, 2011 at 8:55 PM, Chris Rebert wrote: > On Fri, Jan 7, 2011 at 9:46 PM, Garland Fulton > wrote: > > > 1 #!/bin/bash/python > > > What is > > wrong with my shebang line? > > Its path is invalid (unless you're using a *very* weird system). > /bin/bash is the bash shell executable; bash is completely unrelated > to Python. Further, /bin/bash is a file, not a directory. > > The shebang for Python is normally one of the following: > #!/usr/bin/env python > #!/usr/bin/python > > Cheers, > Chris > -- > http://blog.rebertia.com > Great I have learned a ton and these questions will not arise again. -------------- next part -------------- An HTML attachment was scrubbed... URL: From alice at gothcandy.com Sat Jan 8 02:03:58 2011 From: alice at gothcandy.com (=?utf-8?Q?Alice_Bevan=E2=80=93McGregor?=) Date: Fri, 7 Jan 2011 23:03:58 -0800 Subject: apscheduler error References: <9699865b-a8be-4284-a347-58d875b491f6@n2g2000pre.googlegroups.com> Message-ID: Howdy! On 2011-01-07 17:08:28 -0800, linna li said: > I tried to use the apscheduler and used the sample code below from the > tutorial, but got the error message: Exception in thread APScheduler > (most likely raised during interpreter shutdown). What's going on here? > I really appreciate any help! After talking a bit with Alex Gr?nholm it seems this is an issue raised fairly often (not always in the context of this package) and is not really a problem with APScheduler. It has far more to do with attempting to start a thread, then immediately exiting the main thread. That's not how threading is supposed to be used, so don't do it. ;) APScheduler 2.0 adds some improved examples, according to Alex, that don't suffer the "problem" demonstrated by the short code snippit you provided. A package of mine, TurboMail, suffers from the same threading issue if used improperly; you enqueue e-mail, it starts a thread, then you immediately exit. TM tries to work around the issue, but in most cases that workaround does not work properly. (You get strange uncatchable exceptions printed on stderr though AFIK the e-mail does get sent correctly, your application may hang waiting for the thread pool to drain if you have a "minimum thread count" option set.) I hope this clears things up a bit, - Alice. From tjreedy at udel.edu Sat Jan 8 06:04:08 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Sat, 08 Jan 2011 06:04:08 -0500 Subject: Error invalid syntax while statement In-Reply-To: References: Message-ID: > 15 print("counter: ", counter > 16 > 17 while (end == 0): # > <-------------------returns syntax error on this while statement Among other responses, there is no indent after print. should be print() while x: #now indent -- Terry Jan Reedy From kanthony at woh.rr.com Sat Jan 8 08:44:19 2011 From: kanthony at woh.rr.com (Keith Anthony) Date: Sat, 08 Jan 2011 07:44:19 -0600 Subject: More Help with python .find fucntion References: <4d27f7b1$0$29976$c3e8da3$5496439d@news.astraweb.com> Message-ID: THanks ... I am new to Python ... Comparing the result of find with -1 fixes the bug ... some of the endobj start in the firt position ... You're right about the lines ending in \n by accident, EXCEPT in PDF files items are separated by obj <<\n and endobj\n -- --------------------------------- --- -- - Posted with NewsLeecher v4.0 Final Web @ http://www.newsleecher.com/?usenet ------------------- ----- ---- -- - From dmw at coder.cl Sat Jan 8 09:38:10 2011 From: dmw at coder.cl (Daniel Molina Wegener) Date: Sat, 08 Jan 2011 11:38:10 -0300 Subject: [ANN] pyxser-1.5.2r --- Python Object to XML serializer/deserializer Message-ID: Hello Python Community. I'm pleased to announce pyxser-1.5.2r, a python extension which contains functions to serialize and deserialize Python Objects into XML. This is a model based serializer. This release is supports Python 2.4 to Python 2.5. What can do this serializer? * Serialization of cross references. * Serialization of circular references. * Preserves object references on deserialization. * Custom serializations. * Custom deserializations. * Object attribute selection call-back. * Serialization depth limit. * Standards based serialization. * Standards based XML validation using pyxser XML Schema. * C14N based serialization, as optional kind of output. * Model based XML serialization, represented on XML Schema and XML DTD. The ChangeLog for this release is as follows: -----8<----------8<----------8<----------8<----- 1.5.2r (2011.01.08): Daniel Molina Wegener * Added support for Python 2.4 * Replaced the use of the commands package by the subprocess package on the setup script. * On the next release will be added support for Python 3.X ;) Thanks to pyxser users for their feedback. -----8<----------8<----------8<----------8<----- The project is hosted at: http://sourceforge.net/projects/pyxser/ Where you can report bugs and have other options, like forums mailing lists and access to the repository if you want to contribute. The web page for the project is located at: http://coder.cl/products/pyxser/ PyPi entry is: http://pypi.python.org/pypi/pyxser/1.5.2r Best regards, -- Daniel Molina Wegener System Programmer & Web Developer Phone: +56 (2) 979-0277 | Blog: http://coder.cl/ From wayne.dads.bell at gmail.com Sat Jan 8 09:44:05 2011 From: wayne.dads.bell at gmail.com (dads) Date: Sat, 8 Jan 2011 06:44:05 -0800 (PST) Subject: filecmp.dircmp performance Message-ID: I'm creating a one way sync program, it's to automate backing up data over the wan from our shops to a server at head office. It uses filecmp.dircmp() but the performance seems poor to me. for x in dc.diff_files: srcfp = os.path.join(src, x) self.fn777(srcfp) if os.path.isfile(srcfp): try: shutil.copy2(srcfp, dst) self.lg.add_diffiles(src, x) except Exception, e: self.lg.add_errors(e) I tested it at a store which is only around 50 miles away on a 10Mbps line, the directory has 59 files that are under 100KB. When it gets to dc.diff_files it takes 15mins to complete. Looking at the filecmp.py it's only using os.stat, it seems excessively long. code: http://pastebin.com/QskXGDQT From no.email at please.post Sat Jan 8 11:07:23 2011 From: no.email at please.post (kj) Date: Sat, 8 Jan 2011 16:07:23 +0000 (UTC) Subject: Python app dev tools for Gnome? Message-ID: There's a zillion utility apps that I've had kicking around in my head for years, but I've never implemented because I absolutely hate GUI programming. But I'm increasingly impressed by the quality, stability, and sheer number, of Gnome apps that I keep coming across that use Python under the hood. This gives me hope that maybe programming GUI Python apps for Gnome these days is no longer the traumatizing experience it used to be when I last tried it. Can someone recommend some good tools to speed up the development of Python apps[1] for Gnome? E.g. is there anything like Xcode for Gnome+Python? TIA! ~kj [1] Needless to say, when I write "apps" I mean full-blown GUI apps: windows, menus, events, threads, clickable icon, the whole ball of wax. As opposed to cli apps, panel widgets, etc. From __peter__ at web.de Sat Jan 8 11:28:56 2011 From: __peter__ at web.de (Peter Otten) Date: Sat, 08 Jan 2011 17:28:56 +0100 Subject: filecmp.dircmp performance References: Message-ID: dads wrote: > I'm creating a one way sync program, it's to automate backing up data > over the wan from our shops to a server at head office. It uses > filecmp.dircmp() but the performance seems poor to me. > > for x in dc.diff_files: > srcfp = os.path.join(src, x) > self.fn777(srcfp) > if os.path.isfile(srcfp): > try: > shutil.copy2(srcfp, dst) > self.lg.add_diffiles(src, x) > except Exception, e: > self.lg.add_errors(e) > > I tested it at a store which is only around 50 miles away on a 10Mbps > line, the directory has 59 files that are under 100KB. When it gets to > dc.diff_files it takes 15mins to complete. Looking at the filecmp.py > it's only using os.stat, it seems excessively long. As a baseline it would be interesting to see how long it takes to copy those 59 files using system tools. However, there are efficient tools out there that work hard to reduce the traffic over the net which is likely to be the bottleneck. I suggest that you have have a look at http://en.wikipedia.org/wiki/Rsync From awilliam at whitemice.org Sat Jan 8 11:35:17 2011 From: awilliam at whitemice.org (Adam Tauno Williams) Date: Sat, 08 Jan 2011 11:35:17 -0500 Subject: Python app dev tools for Gnome? In-Reply-To: References: Message-ID: <1294504517.17190.7.camel@linux-yu4c.site> On Sat, 2011-01-08 at 16:07 +0000, kj wrote: > There's a zillion utility apps that I've had kicking around in my > head for years, but I've never implemented because I absolutely > hate GUI programming. > But I'm increasingly impressed by the quality, stability, and sheer > number, of Gnome apps that I keep coming across that use Python > under the hood. > This gives me hope that maybe programming GUI Python apps for Gnome > these days is no longer the traumatizing experience it used to be > when I last tried it. > Can someone recommend some good tools to speed up the development > of Python apps[1] for Gnome? E.g. is there anything like Xcode > for Gnome+Python? I use Monodevelop for coding in Python, but I'm only writing server-side Python. While Monodevelop provides an excellent [possibly the best] Gtk UI designer I believe that component only works for C#. There are a variety of articles on the PyGTK site; Glade is the UI designer you probably want. I've also found which covers TreeViews which are the most tedious part of Gtk application development. Note that, technically, Glade is deprecated and replaced with GtkBuilder. But I believe the application is still called Glade. > [1] Needless to say, when I write "apps" I mean full-blown GUI > apps: windows, menus, events, threads, clickable icon, the whole > ball of wax. As opposed to cli apps, panel widgets, etc. Awesome; although I've avoided [to do Python's myriad deployment issues] Python for fat-client apps I'm becoming more and more tempted. From drsalists at gmail.com Sat Jan 8 13:25:47 2011 From: drsalists at gmail.com (Dan Stromberg) Date: Sat, 8 Jan 2011 10:25:47 -0800 Subject: Python app dev tools for Gnome? In-Reply-To: References: Message-ID: On Sat, Jan 8, 2011 at 8:07 AM, kj wrote: > There's a zillion utility apps that I've had kicking around in my > head for years, but I've never implemented because I absolutely > hate GUI programming. > > But I'm increasingly impressed by the quality, stability, and sheer > number, of Gnome apps that I keep coming across that use Python > under the hood. > > This gives me hope that maybe programming GUI Python apps for Gnome > these days is no longer the traumatizing experience it used to be > when I last tried it. > > Can someone recommend some good tools to speed up the development > of Python apps[1] for Gnome? ?E.g. is there anything like Xcode > for Gnome+Python? > > TIA! > > ~kj > > [1] Needless to say, when I write "apps" I mean full-blown GUI > apps: windows, menus, events, threads, clickable icon, the whole > ball of wax. ?As opposed to cli apps, panel widgets, etc. > -- > http://mail.python.org/mailman/listinfo/python-list > Check out Glade (the standard answer), Illumination (a new tool that has a very interesting design and goals), wxWindows (can run overtop of GTK+, but is pretty different from PyGTK to program, and like PyGTK, enables running on multiple desktop platforms), and pyjamas (produces GTK GUI's using its own widget set overtop of GTK, and web 2.0 apps, from the same code). Personally, I prefer to just code PyGTK GUI's manually, but I can't help but be curious about Ilumination and pyjamas. Illumination is at: http://radicalbreeze.com/ ...and it purportedly allows you to graphically build apps that run on PyGTK, Android, iPhone (not mature last I heard), Windows, Haiku - all automatically generated _from_a_single_description_, and I wouldn't be surprised if it does more platforms than that by now. It's been getting a lot of buzz in the Android community, but if it lives up to its design goals, it probably deserves buzz all over the place. From ppearson at nowhere.invalid Sat Jan 8 13:33:28 2011 From: ppearson at nowhere.invalid (Peter Pearson) Date: 8 Jan 2011 18:33:28 GMT Subject: student question References: Message-ID: <8orovoFe38U1@mid.individual.net> On Fri, 7 Jan 2011 18:42:45 -0800 (PST), John wrote: >>>> q_file = open(questions_location) #opens the document successfully >>>> for line in q_file: > print line > > # prints document successfully >>>> line > # prints last line of document >>>> for line in q_file: > print line # prints nothing > > ...why does it print nothing? open(filename) returns an iterator, not a list. Once you have exhausted the iterator, it stays exhausted. -- To email me, substitute nowhere->spamcop, invalid->net. From roy at panix.com Sat Jan 8 15:03:01 2011 From: roy at panix.com (Roy Smith) Date: Sat, 08 Jan 2011 15:03:01 -0500 Subject: Absolute imports? Message-ID: If I have an absolute path to a file (i.e. '/home/roy/foo.py'), is there a way to import that as a module WITHOUT modifying sys.path? I'm using Python 2.6. I've read PEP 328, and don't really understand how the absolute imports it's talking about are supposed to work. Should I be using imp.load_source()? From tjreedy at udel.edu Sat Jan 8 16:33:50 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Sat, 08 Jan 2011 16:33:50 -0500 Subject: Absolute imports? In-Reply-To: References: Message-ID: On 1/8/2011 3:03 PM, Roy Smith wrote: > If I have an absolute path to a file (i.e. '/home/roy/foo.py'), is there > a way to import that as a module WITHOUT modifying sys.path? I'm using > Python 2.6. Import from another file in /home/roy. (since '.' is part of sys.path). Or put module or package of modules in Lib/site-packages. But why the horror of modifying sys.path? It is normal proceedure. > I've read PEP 328, and don't really understand how the absolute imports > it's talking about are supposed to work. Those are the normal imports that start from a directory in sys.path. Relative imports (now) are ones that use '.'s to locate relative to the importing module. I have never done that. Purpose is to make a subpackage relocatable to another package without modification. > Should I be using imp.load_source()? No idea, never done that. Try it if you want. -- Terry Jan Reedy From ben+python at benfinney.id.au Sat Jan 8 16:53:18 2011 From: ben+python at benfinney.id.au (Ben Finney) Date: Sun, 09 Jan 2011 08:53:18 +1100 Subject: Absolute imports? References: Message-ID: <877heff4fl.fsf@benfinney.id.au> Roy Smith writes: > If I have an absolute path to a file (i.e. '/home/roy/foo.py'), is > there a way to import that as a module WITHOUT modifying sys.path? I'm > using Python 2.6. Importing a module with ?import? is done by using the module's name, which is only *incidentally* related to its filesystem path. What is the problem you're trying to solve? It is likely we can suggest a better solution. > I've read PEP 328, and don't really understand how the absolute > imports it's talking about are supposed to work. Should I be using > imp.load_source()? PEP 328 introduces a distinction between absolute imports and relative imports. Before the implementation of PEP 328, it was impossible to distinguish in the ?import? statement whether the import would be absolute (i.e., from the directories listed in ?sys.path?) or relative (i.e., from the directory housing the current module). I hope that clarifies. If you describe what you're trying to do and why you want a different import behaviour, the answers might be more directed to your actual situation. -- \ ?Spam will be a thing of the past in two years' time.? ?Bill | `\ Gates, 2004-01-24 | _o__) | Ben Finney From not0read0765 at yopmail.com Sat Jan 8 16:57:45 2011 From: not0read0765 at yopmail.com (Olive) Date: Sat, 8 Jan 2011 22:57:45 +0100 Subject: list displays Message-ID: <20110108225745.06b4f843@yopmail.com> I am a newbie to python. Python supports what I thinks it is called list display, for example: [i for i in range(10)] [i for i in range(10) if i<6] Does anyone know a good documentation for this. I have read the language reference but it is confusing. Olive From ddasilva at umd.edu Sat Jan 8 17:11:00 2011 From: ddasilva at umd.edu (Daniel da Silva) Date: Sat, 8 Jan 2011 17:11:00 -0500 Subject: list displays In-Reply-To: <20110108225745.06b4f843@yopmail.com> References: <20110108225745.06b4f843@yopmail.com> Message-ID: They're called "List Comprehensions" http://docs.python.org/tutorial/datastructures.html#list-comprehensions On Sat, Jan 8, 2011 at 4:57 PM, Olive wrote: > I am a newbie to python. Python supports what I thinks it is called > list display, for example: > > [i for i in range(10)] > [i for i in range(10) if i<6] > > Does anyone know a good documentation for this. I have read the > language reference but it is confusing. > > Olive > > -- > http://mail.python.org/mailman/listinfo/python-list > -------------- next part -------------- An HTML attachment was scrubbed... URL: From clp2 at rebertia.com Sat Jan 8 17:26:03 2011 From: clp2 at rebertia.com (Chris Rebert) Date: Sat, 8 Jan 2011 14:26:03 -0800 Subject: list displays In-Reply-To: <20110108225745.06b4f843@yopmail.com> References: <20110108225745.06b4f843@yopmail.com> Message-ID: On Sat, Jan 8, 2011 at 1:57 PM, Olive wrote: > I am a newbie to python. Python supports what I thinks it is called > list display, for example: > > [i for i in range(10)] > [i for i in range(10) if i<6] > > Does anyone know a good documentation for this. I have read the > language reference but it is confusing. You may find the translation to equivalent list-comprehension-free code in http://docs.python.org/howto/functional.html#generator-expressions-and-list-comprehensions helpful. Cheers, Chris From steve+comp.lang.python at pearwood.info Sat Jan 8 17:41:41 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 08 Jan 2011 22:41:41 GMT Subject: list displays References: <20110108225745.06b4f843@yopmail.com> Message-ID: <4d28e824$0$29976$c3e8da3$5496439d@news.astraweb.com> On Sat, 08 Jan 2011 22:57:45 +0100, Olive wrote: > I am a newbie to python. Python supports what I thinks it is called list > display, for example: > > [i for i in range(10)] > [i for i in range(10) if i<6] This is called a list comprehension, not list display. > Does anyone know a good documentation for this. I have read the language > reference but it is confusing. A list comprehension is syntactic sugar for a for loop. If you start with code looking like this: storage = [] for i in range(10): if i < 6: storage.append(i) you can re-write this as a list comprehension: storage = [i for i in range(10) if i < 6] The source doesn't have to be range, it can be any sequence or iterator: lengths = [len(obj) for obj in my_list_of_objects] # like map(len, my_list_of_objects) If you are mathematically inclined, you might also like this analogy: the syntax for a list comprehension is similar to that of sets in mathematics. [f(x) for x in D] is similar to: { f(x) ? x ? D } ("the set of f(x) for all x element of D") Don't waste your time with list comprehensions that just walk over the source, doing nothing. For example: [i for i in range(10)] Just use list(range(10)) instead. Where list comps get complicated is when you combine them. Nested list comps are not too bad, although they can get messy: [len(s) for s in [str(x) for x in [2**n for n in range(10)]]] That's the same as: powers_of_two = [2**n for n in range(10)] strings = [str(x) for x in powers_of_two] lengths = [len(s) for s in strings] But what do you make of this? [a*b for a in range(3) for b in range(4)] This is like a nested for-loop: results = [] for a in range(3): for b in range(4): results.append(a*b) Hope this helps. -- Steven From roy at panix.com Sat Jan 8 17:45:23 2011 From: roy at panix.com (Roy Smith) Date: Sat, 08 Jan 2011 17:45:23 -0500 Subject: Absolute imports? References: <877heff4fl.fsf@benfinney.id.au> Message-ID: In article <877heff4fl.fsf at benfinney.id.au>, Ben Finney wrote: > Roy Smith writes: > > > If I have an absolute path to a file (i.e. '/home/roy/foo.py'), is > > there a way to import that as a module WITHOUT modifying sys.path? I'm > > using Python 2.6. > > Importing a module with ???import??? is done by using the module's name, > which is only *incidentally* related to its filesystem path. > > What is the problem you're trying to solve? It is likely we can suggest > a better solution. Well, the problem I'm trying to solve is that I have an absolute pathname to a python source file that I want to import as a module :-) I'm working on a project where developers will typically have several sandboxes, with different versions of the code. There's a config file (which I have no control over) which defines a big multi-level dict containing configuration options: config = { 'memcache_servers' : ['localhost'], 'build_type' : 'development', 'thrift_configs' : { 'SearchService' : {'hosts' : ['localhost'], 'sendTimeout' : 300, 'port' : 9192, 'recvTimeout' : 3000 }, } } and so on. The file is auto-generated by some huge pile of perl scripts which also generates the same information in a forms ingestible by perl, PHP, Java, shell scripts, etc. Not how I would have designed it, but it is what it is. The best I can describe how to find the location of the config file is, "Work your way up the directory tree from where you are now, (i.e. following '..' links) until you get to the top level of the project, then from there, it's ./code/configs/autogen/config.py." It's reasonably straight-forward to figure out that absolute path, starting from sys.argv[0] and using the tools in os.path. Now I need to import the file, given that I know its absolute pathname. It looks like imp.load_source() does what I want, I'm just wondering if there's a cleaner way. From roy at panix.com Sat Jan 8 17:48:25 2011 From: roy at panix.com (Roy Smith) Date: Sat, 08 Jan 2011 17:48:25 -0500 Subject: Absolute imports? References: Message-ID: In article , Terry Reedy wrote: > > Import from another file in /home/roy. (since '.' is part of sys.path). > Or put module or package of modules in Lib/site-packages. > But why the horror of modifying sys.path? It is normal proceedure. Not quite horror, but since I already know the absolute path to the file, it seems silly to change the search path just so import can use it to search. Also, if I change the search path, I risk other things finding my module by mistake (if there's a module name collision). From jnoller at gmail.com Sat Jan 8 17:59:14 2011 From: jnoller at gmail.com (Jesse Noller) Date: Sat, 8 Jan 2011 17:59:14 -0500 Subject: PyCon 2011 - Full talk and tutorial list now available, registration open! Message-ID: I'm very pleased to announce, on behalf of the PyCon 2011 Program committee, and entire PyCon 2011 volunteer staff, that the full list of PyCon 2011 talks is now public, and available! This was an especially hard year for the PyCon program committee: we had over 200 proposals for only 95 total slots, so we ended up having to reject a lot of excellent proposals. We've spent the better part of the last few months in reviews, meetings and debates selecting which talks would be in the final PyCon program. It was not and easy task - all of the proposal authors really came through in their proposals - the number of high quality proposals we had to chose from was simply staggering. That said - the program committee completed it's work yesterday morning. Acceptance and rejection letters have been sent, and you can now view the full program on the site: http://us.pycon.org/2011/schedule/lists/talks/ This obviously complements the list of tutorials also available: http://us.pycon.org/2011/schedule/lists/tutorials/ Personally, this is my second year acting as the Program Committee chair (and hence, my last) - and between the talk list, and the list of tutorials, our current keynote speaker (http://us.pycon.org/2011/home/keynotes/) and the emerging line of up poster sessions - I'm extremely proud to have been part of the process, and extremely excited about the upcoming conference. It is going to be amazing One behalf of the entire PyCon 2011 staff, I want to again thank every single talk author for their submission(s), and I look forward to seeing all of you, and them at the conference. PyCon is an amazing conference only because of the quality talks, tutorials and community we have. I'm confident this one will knock it out of the park. As a reminder: Early Bird registration (http://us.pycon.org/2011/tickets/) closes January 17th - and we have an attendance cap of 1500 total attendees (speakers are counted against this number, and guaranteed a slot) so be sure to register today! Jesse Noller PyCon 2011 From tjreedy at udel.edu Sat Jan 8 19:32:12 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Sat, 08 Jan 2011 19:32:12 -0500 Subject: Absolute imports? In-Reply-To: References: Message-ID: On 1/8/2011 5:48 PM, Roy Smith wrote: > In article, > Terry Reedy wrote: > >> >> Import from another file in /home/roy. (since '.' is part of sys.path). >> Or put module or package of modules in Lib/site-packages. >> But why the horror of modifying sys.path? It is normal proceedure. > > Not quite horror, but since I already know the absolute path to the > file, it seems silly to change the search path just so import can use it > to search. Also, if I change the search path, I risk other things > finding my module by mistake (if there's a module name collision). Ben Finney asked you the right question. If config.py is the only .py file in .../autogen/, which I infer from your responses, you could .pop() .../autogen after the append and import. Or open config.py and use imp.load_module, being careful to get all the args correct. In either case, if I had a startup module or utility module that is imported right away, I would do the import with extra code there, just once. Then, either refer to util.config after importing util in other modules, or just do 'import config'. The latter should work because import first looks for already imported modules (in sys.modules). When the module is already there, 'import x' reduces to "x = sys.modules['x']". -- Terry Jan Reedy From passionate_programmer at hotmail.com Sat Jan 8 21:23:01 2011 From: passionate_programmer at hotmail.com (Rohit Coder) Date: Sun, 9 Jan 2011 07:53:01 +0530 Subject: Create a class to position a window on the screen. Message-ID: Hi,elementFontfont-familyfont-sizefont-stylefont-variantfont-weightletter-spacingline-heighttext-decorationtext-aligntext-indenttext-transformwhite-spaceword-spacingcolorBackgroundbg-attachmentbg-colorbg-imagebg-positionbg-repeatBoxwidthheightborder-topborder-rightborder-bottomborder-leftmarginpaddingmax-heightmin-heightmax-widthmin-widthoutline-coloroutline-styleoutline-widthPositioningpositiontopbottomrightleftfloatdisplayclearz-indexListlist-style-imagelist-style-typelist-style-positionTablevertical-alignborder-collapseborder-spacingcaption-sideempty-cellstable-layoutEffectstext-shadow-webkit-box-shadowborder-radiusOtheroverflowcursorvisibility I am new to Python and this is my fist Python class. I am using PyQt4 framework on Windows 7. I don't know whether the code below is correctly written or not. I want to modify it further as: 1. In the arguments, I want to pass the name of another opened Window (.py) on the screen. 2. I want to pass the x-coord., y-coord. and the name of the window to position on the screen. How to modify the code to fulfill these requirements? **Attempted Code** class PositionWindow: def __init__(self, xCoord, yCoord, windowName, parent = None): self.x = xCoord self.y = yCoord self.wName = windowName; def center(self): screen = QtGui.QDesktopWidget().screenGeometry() size = self.geometry() self.move((screen.width()-size.width())/2, (screen.height()-size.height())/2) ...................Rohit. -------------- next part -------------- An HTML attachment was scrubbed... URL: From aahz at pythoncraft.com Sat Jan 8 21:39:43 2011 From: aahz at pythoncraft.com (Aahz) Date: 8 Jan 2011 18:39:43 -0800 Subject: surprised by import in python 2.6 References: Message-ID: In article , Stefaan Himpe wrote: > >Recently someone asked me this question, to which I could not give an >answer. I'm hoping for some insight, or a manual page. What follows is >python 2.6. > >The problem is with the difference between > >from test import * > >and > >import test Just adding to this thread for Gooja: Don't use "import *" -- it makes debugging difficult because you can't tell where a name comes from. -- Aahz (aahz at pythoncraft.com) <*> http://www.pythoncraft.com/ "Think of it as evolution in action." --Tony Rand From timr at probo.com Sat Jan 8 21:51:38 2011 From: timr at probo.com (Tim Roberts) Date: Sat, 08 Jan 2011 18:51:38 -0800 Subject: How to read ansic file into a pre-defined class? References: Message-ID: Ying Zu wrote: > >How to read ansic file into a pre-defined class? This is not an "ansic" file. It's just a plain old data file. >I have a series of files written in the following format, > >2 # number of classes >100 # number of items for the first class object >0 foo >1 foo >... >99 foo >150 # number of items for the second class object >0 bar >1 bar >... >149 bar > >ultimately I want to read the file to two *structs* (sorry for my C >jargon, just started playing with Python), with attributes >number_of_items and data_array. > >I wrote a simply code to read and split each line into a list, then >try to tell the meaning of each line by the number of elements of >each line list and the its position in the file. But it is >definitely not the way Python should be used. You don't really need to count the number of elements. The file tells you how many of each to expect. This works: numclasses = int(f.next().strip()) classlist = [] for i in range(numclasses): numitems = int(f.next().strip()) classlist.append( [f.next().strip().split() for j in range(numitems)] ) Then len(classlist) tells you how many classes. len(classlist[0]) tells you how many items in the first class. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From rahul.nbg at gmail.com Sun Jan 9 01:10:38 2011 From: rahul.nbg at gmail.com (aregee) Date: Sat, 8 Jan 2011 22:10:38 -0800 (PST) Subject: compute the double square...... :( Message-ID: <654f1a64-b4c2-4a02-b4f8-86ee7e34d3cd@y19g2000prb.googlegroups.com> Double Squares A double-square number is an integer X which can be expressed as the sum of two perfect squares. For example, 10 is a double-square because 10 = 32 + 12. Your task in this problem is, given X, determine the number of ways in which it can be written as the sum of two squares. For example, 10 can only be written as 32 + 12 (we don't count 12 + 32 as being different). On the other hand, 25 can be written as 52 + 02 or as 42 + 32. Input You should first read an integer N, the number of test cases. The next N lines will contain N values of X. Constraints 0 ? X ? 2147483647 1 ? N ? 100 Output For each value of X, you should output the number of ways to write X as the sum of two square Is the code mention below solution to this question ???? what is the fault... Error : aregee at aregee-laptop:~/Desktop$ python pie.py enter a number::10 pie.py:3: Deprecation Warning: integer argument expected, got float for b in range(0,(x**0.5)/2): #Double square.... x = input("enter a number::") for b in range(0,(x**0.5)/2): a = (x-(b**2))**0.5 try: a = int(a) except: print("not an integer") exit(1) count = 0; count = count + 1; if (x == a**2 + b**2): print "double square" From kb1pkl at aim.com Sun Jan 9 01:23:27 2011 From: kb1pkl at aim.com (Corey Richardson) Date: Sun, 09 Jan 2011 01:23:27 -0500 Subject: compute the double square...... :( In-Reply-To: <654f1a64-b4c2-4a02-b4f8-86ee7e34d3cd@y19g2000prb.googlegroups.com> References: <654f1a64-b4c2-4a02-b4f8-86ee7e34d3cd@y19g2000prb.googlegroups.com> Message-ID: <4D29545F.3030601@aim.com> On 01/09/2011 01:10 AM, aregee wrote: > > Double Squares > A double-square number is an integer X which can be expressed as the > sum of two perfect squares. For example, 10 is a double-square because > 10 = 32 + 12. Your task in this problem is, given X, determine the > number of ways in which it can be written as the sum of two squares. > For example, 10 can only be written as 32 + 12 (we don't count 12 + 32 > as being different). On the other hand, 25 can be written as 52 + 02 > or as 42 + 32. > > Input > You should first read an integer N, the number of test cases. The next > N lines will contain N values of X. > Constraints > 0 ? X ? 2147483647 > 1 ? N ? 100 > Output > For each value of X, you should output the number of ways to write X > as the sum of two square > > Is the code mention below solution to this question ???? what is the > fault... > Error : > aregee at aregee-laptop:~/Desktop$ python pie.py > enter a number::10 > pie.py:3: Deprecation Warning: integer argument expected, got float > for b in range(0,(x**0.5)/2): That says it all. You can't use a float in range(), use int(x ** 0.5) if that's what you need, but the behavior won't be the same. My suggestion would be to try to find a different way to do it. > > #Double square.... > > x = input("enter a number::") > for b in range(0,(x**0.5)/2): > a = (x-(b**2))**0.5 > try: > a = int(a) > except: > print("not an integer") > exit(1) > Here it would be better to use: if type(a) != int print("Not an integer") exit(1) > count = 0; > count = count + 1; > if (x == a**2 + b**2): > > print "double square" ~Corey Richardson From gherron at islandtraining.com Sun Jan 9 02:14:28 2011 From: gherron at islandtraining.com (Gary Herron) Date: Sat, 08 Jan 2011 23:14:28 -0800 Subject: compute the double square...... :( In-Reply-To: <654f1a64-b4c2-4a02-b4f8-86ee7e34d3cd@y19g2000prb.googlegroups.com> References: <654f1a64-b4c2-4a02-b4f8-86ee7e34d3cd@y19g2000prb.googlegroups.com> Message-ID: <4D296054.9030208@islandtraining.com> On 01/08/2011 10:10 PM, aregee wrote: > Double Squares > A double-square number is an integer X which can be expressed as the > sum of two perfect squares. For example, 10 is a double-square because > 10 = 32 + 12. Your task in this problem is, given X, determine the > number of ways in which it can be written as the sum of two squares. > For example, 10 can only be written as 32 + 12 (we don't count 12 + 32 > as being different). On the other hand, 25 can be written as 52 + 02 > or as 42 + 32. Huh? In what number system does 10 = 32 + 12? And how do either 32 or 12 qualify as perfect squares? Gary Herron > Input > You should first read an integer N, the number of test cases. The next > N lines will contain N values of X. > Constraints > 0 ? X ? 2147483647 > 1 ? N ? 100 > Output > For each value of X, you should output the number of ways to write X > as the sum of two square > > Is the code mention below solution to this question ???? what is the > fault... > Error : > aregee at aregee-laptop:~/Desktop$ python pie.py > enter a number::10 > pie.py:3: Deprecation Warning: integer argument expected, got float > for b in range(0,(x**0.5)/2): > > #Double square.... > > x = input("enter a number::") > for b in range(0,(x**0.5)/2): > a = (x-(b**2))**0.5 > try: > a = int(a) > except: > print("not an integer") > exit(1) > > count = 0; > count = count + 1; > if (x == a**2 + b**2): > > print "double square" From xemoth at gmail.com Sun Jan 9 03:10:08 2011 From: xemoth at gmail.com (Owen) Date: Sun, 9 Jan 2011 00:10:08 -0800 (PST) Subject: compute the double square...... :( References: <654f1a64-b4c2-4a02-b4f8-86ee7e34d3cd@y19g2000prb.googlegroups.com> Message-ID: <0cc271af-35e9-47b9-8c31-324e484cd9a8@f21g2000prn.googlegroups.com> On Jan 9, 6:14?pm, Gary Herron wrote: > On 01/08/2011 10:10 PM, aregee wrote: > > > Double Squares > > A double-square number is an integer X which can be expressed as the > > sum of two perfect squares. For example, 10 is a double-square because > > 10 = 32 + 12. Your task in this problem is, given X, determine the > > number of ways in which it can be written as the sum of two squares. > > For example, 10 can only be written as 32 + 12 (we don't count 12 + 32 > > as being different). On the other hand, 25 can be written as 52 + 02 > > or as 42 + 32. > > Huh? ?In what number system does ?10 = 32 + 12? > And how do either 32 or 12 qualify as perfect squares? > > Gary Herron > > > > > > > > > Input > > You should first read an integer N, the number of test cases. The next > > N lines will contain N values of X. > > Constraints > > 0 ? X ? 2147483647 > > 1 ? N ? 100 > > Output > > For each value of X, you should output the number of ways to write X > > as the sum of two square > > > Is the code mention below solution to this question ???? what is the > > fault... > > Error : > > aregee at aregee-laptop:~/Desktop$ python pie.py > > enter a number::10 > > pie.py:3: Deprecation Warning: integer argument expected, got float > > ? ?for b in range(0,(x**0.5)/2): > > > #Double square.... > > > x = input("enter a number::") > > for b in range(0,(x**0.5)/2): > > ? ? ? ?a = (x-(b**2))**0.5 > > try: > > ? ? ? ?a = int(a) > > except: > > ? ? ? ?print("not an integer") > > ? ? ? ?exit(1) > > > ? ? ? ?count = 0; > > ? ? ? ?count = count + 1; > > if (x == a**2 + b**2): > > > ? ? ? ?print "double square" Well that he means 3(squared)+1(squared) [3 superscript 2 etc] Owen From ian.g.kelly at gmail.com Sun Jan 9 05:59:27 2011 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Sun, 09 Jan 2011 03:59:27 -0700 Subject: compute the double square...... :( In-Reply-To: <654f1a64-b4c2-4a02-b4f8-86ee7e34d3cd@y19g2000prb.googlegroups.com> References: <654f1a64-b4c2-4a02-b4f8-86ee7e34d3cd@y19g2000prb.googlegroups.com> Message-ID: On 1/8/2011 11:10 PM, aregee wrote: > pie.py:3: Deprecation Warning: integer argument expected, got float > for b in range(0,(x**0.5)/2): I expect you want range(0, int((x / 2) ** 0.5) + 1), no? > for b in range(0,(x**0.5)/2): > a = (x-(b**2))**0.5 > try: > a = int(a) > except: > print("not an integer") > exit(1) Your indentation is confusing. Is the try-except contained inside the for loop or not? And what are you actually trying to test for here? The assignment here of "a = int(a)" will never throw an exception as long as the loop runs. > > count = 0; > count = count + 1; Again, confusing indentation. Is this supposed to be part of the except block? And what is the purpose of incrementing count if you're going to set it to 0 immediately before? You might as well just write "count = 1" > if (x == a**2 + b**2): > > print "double square" This also appears to be outside of the loop. From cedric at schmeits.net Sun Jan 9 06:05:55 2011 From: cedric at schmeits.net (Cedric Schmeits) Date: Sun, 9 Jan 2011 03:05:55 -0800 (PST) Subject: compute the double square...... :( References: <654f1a64-b4c2-4a02-b4f8-86ee7e34d3cd@y19g2000prb.googlegroups.com> Message-ID: <5ba53a5b-c545-42e2-afab-5b21c832a2cc@32g2000yqz.googlegroups.com> On Jan 9, 7:10?am, aregee wrote: > Double Squares > A double-square number is an integer X which can be expressed as the > sum of two perfect squares. For example, 10 is a double-square because > 10 = 32 + 12. Your task in this problem is, given X, determine the > number of ways in which it can be written as the sum of two squares. > For example, 10 can only be written as 32 + 12 (we don't count 12 + 32 > as being different). On the other hand, 25 can be written as 52 + 02 > or as 42 + 32. > > Input > You should first read an integer N, the number of test cases. The next > N lines will contain N values of X. > Constraints > 0 ? X ? 2147483647 > 1 ? N ? 100 > Output > For each value of X, you should output the number of ways to write X > as the sum of two square > > Is the code mention below solution to this question ???? what is the > fault... > Error : > aregee at aregee-laptop:~/Desktop$ python pie.py > enter a number::10 > pie.py:3: Deprecation Warning: integer argument expected, got float > ? for b in range(0,(x**0.5)/2): > > #Double square.... > > x = input("enter a number::") > for b in range(0,(x**0.5)/2): > ? ? ? a = (x-(b**2))**0.5 > try: > ? ? ? a = int(a) > except: > ? ? ? print("not an integer") > ? ? ? exit(1) > > ? ? ? count = 0; > ? ? ? count = count + 1; > if (x == a**2 + b**2): > > ? ? ? print "double square" aregee, The problem you had was that you put a division by 2 in the range, if x would be 25 than x**0.5 = 5.0 than you would feed range with 2.5 and than you get the warning. Also I don't understand why you use de division by 2, because if for instance you would take 25 you get 5 and 0 but you mis 3 and 4 as match. I've put in a tried list to I would try the following: #Double square.... x = input("enter a number::") for b in range(0,int((x**0.5))): a = (x-(b**2))**0.5 try: a = int(a) except: print("not an integer") exit(1) if a < b: # when a is smaller than b we already have this match # and all the following matches we also have break if (x == a**2 + b**2): print "double square %s = %s**2 + %s**2" % (x, a, b) From rahul.nbg at gmail.com Sun Jan 9 06:26:22 2011 From: rahul.nbg at gmail.com (aregee) Date: Sun, 9 Jan 2011 03:26:22 -0800 (PST) Subject: compute the double square...... :( References: <654f1a64-b4c2-4a02-b4f8-86ee7e34d3cd@y19g2000prb.googlegroups.com> Message-ID: <1b8905da-0a84-424d-9ccf-9c4e7cba0e48@21g2000prv.googlegroups.com> hey all thanks for yr help,i got it right .....n sorry for confussions...i m very new to python...just started learning it couple of days ago... Ian Kelly wrote: > On 1/8/2011 11:10 PM, aregee wrote: > > pie.py:3: Deprecation Warning: integer argument expected, got float > > for b in range(0,(x**0.5)/2): > > I expect you want range(0, int((x / 2) ** 0.5) + 1), no? > > > for b in range(0,(x**0.5)/2): > > a = (x-(b**2))**0.5 > > try: > > a = int(a) > > except: > > print("not an integer") > > exit(1) > > Your indentation is confusing. Is the try-except contained inside the > for loop or not? > > And what are you actually trying to test for here? The assignment here > of "a = int(a)" will never throw an exception as long as the loop runs. > > > > > count = 0; > > count = count + 1; > > Again, confusing indentation. Is this supposed to be part of the except > block? And what is the purpose of incrementing count if you're going to > set it to 0 immediately before? You might as well just write "count = 1" > > > if (x == a**2 + b**2): > > > > print "double square" > > This also appears to be outside of the loop. From develsoftware at gmail.com Sun Jan 9 09:03:25 2011 From: develsoftware at gmail.com (=?UTF-8?B?0JXQstCz0LXQvdC40Lkg0J/QvtGH0LjRgtCw0LXQsg==?=) Date: Sun, 9 Jan 2011 06:03:25 -0800 (PST) Subject: Embedded Python static modules Message-ID: I build python from sources(static version): ./configure --disable-shared Next I build program with this static library. Program work fine on my linux, but when I tried run my program on another linux, I got next message: Could not find platform independent libraries Could not find platform dependent libraries Consider setting $PYTHONHOME to [:] ImportError: No module named site This message I receive when call Py_Initialize(). How I can build python static library with all required Python modules? Thanks. From acm at muc.de Sun Jan 9 09:54:53 2011 From: acm at muc.de (Alan Mackenzie) Date: Sun, 9 Jan 2011 14:54:53 +0000 (UTC) Subject: compute the double square...... :( References: <654f1a64-b4c2-4a02-b4f8-86ee7e34d3cd@y19g2000prb.googlegroups.com> Message-ID: aregee wrote: > Double Squares > A double-square number is an integer X which can be expressed as the > sum of two perfect squares. For example, 10 is a double-square because > 10 = 32 + 12. Your task in this problem is, given X, determine the > number of ways in which it can be written as the sum of two squares. > For example, 10 can only be written as 32 + 12 (we don't count 12 + 32 > as being different). On the other hand, 25 can be written as 52 + 02 > or as 42 + 32. There is interesting mathematics involved in "double squares". Such properties are intimately bound up with the factorisation of the number. It can be shown that: (i) a prime number of the form 4n + 1 is a double square in exactly one way. So is 2. E.g. 73 = 64 + 9, 2 = 1 + 1. (ii) a prime number of the form 4n + 3 is not a double square. (iii) The product of m distinct primes, each of the form 4n + 1, is a double square in 2^(m-1) ways. E.g. 5*13 = 65 = 64 + 1 = 49 + 16 (iv) If k = a^2 + b^2, l = c^2 + d^2, then: kl = (ac + bd)^2 + (ad - bc)^2 = (ac - bd)^2 + (ad + bc)^2. (v) if k is a prime of the form 4n + 1, then k^m is a double square in (m + 2) / 2 ways. E.g. 5^4 = 625 = 625 + 0 = 576 + 49 = 400 + 225. (vi) .... and so on. It's all in the factorisation! -- Alan Mackenzie (Nuremberg, Germany). From rohan.pai at live.com Sun Jan 9 10:41:41 2011 From: rohan.pai at live.com (Rohan Pai) Date: Sun, 9 Jan 2011 10:41:41 -0500 Subject: How can I find the remainder when dividing 2 integers Message-ID: Try using dividend % divisor, this will return the remainder Rohan Pai -------------- next part -------------- An HTML attachment was scrubbed... URL: From ian at ianhobson.co.uk Sun Jan 9 11:14:45 2011 From: ian at ianhobson.co.uk (Ian Hobson) Date: Sun, 09 Jan 2011 16:14:45 +0000 Subject: Help needed with unittest and global Message-ID: <4D29DEF5.2030702@ianhobson.co.uk> Hi all, I am trying to develop a PyQt application, and I want to unittest it. After three false starts, I am plainly unaware of something rather basic - can some kind person please help me out? This is a log to show what I have so far D:\work\ian>type testAll.py # coding=utf8 # testAll.py - run all tests. import unittest import sys from PyQt4.QtGui import * from testCubic import testCubic global app def main(): suite = unittest.TestLoader() suite.loadTestsFromTestCase(testCubic) unittest.TextTestRunner().run(suite) if __name__=="__main__": global app app = QApplication(sys.argv) # set gloabl app unittest.main() D:\work\ian>type testCubic.py # coding=utf8 # testCubic.py - tests the top level module import unittest global app class testCubic(unittest.TestCase): def test001_walkingSkeleton(self): global app # use global version app.processEvents() # fails D:\work\ian>python testAll.py E ====================================================================== ERROR: test001_walkingSkeleton (testCubic.testCubic) ---------------------------------------------------------------------- Traceback (most recent call last): File "D:\work\ian\testCubic.py", line 8, in test001_walkingSkeleton app.processEvents() # fails NameError: global name 'app' is not defined ---------------------------------------------------------------------- Ran 1 test in 0.001s FAILED (errors=1) D:\work\ian> Thanks Ian From twic at urchin.earth.li Sun Jan 9 11:49:35 2011 From: twic at urchin.earth.li (Tom Anderson) Date: Sun, 9 Jan 2011 16:49:35 +0000 Subject: Nothing to repeat Message-ID: Hello everyone, long time no see, This is probably not a Python problem, but rather a regular expressions problem. I want, for the sake of arguments, to match strings comprising any number of occurrences of 'spa', each interspersed by any number of occurrences of the 'm'. 'any number' includes zero, so the whole pattern should match the empty string. Here's the conversation Python and i had about it: Python 2.6.4 (r264:75706, Jun 4 2010, 18:20:16) [GCC 4.4.4 20100503 (Red Hat 4.4.4-2)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import re >>> re.compile("(spa|m*)*") Traceback (most recent call last): File "", line 1, in File "/usr/lib/python2.6/re.py", line 190, in compile return _compile(pattern, flags) File "/usr/lib/python2.6/re.py", line 245, in _compile raise error, v # invalid expression sre_constants.error: nothing to repeat What's going on here? Why is there nothing to repeat? Is the problem having one *'d term inside another? Now, i could actually rewrite this particular pattern as '(spa|m)*'. But what i neglected to mention above is that i'm actually generating patterns from structures of objects (representations of XML DTDs, as it happens), and as it stands, patterns like this are a possibility. Any thoughts on what i should do? Do i have to bite the bullet and apply some cleverness in my pattern generation to avoid situations like this? Thanks, tom -- If it ain't broke, open it up and see what makes it so bloody special. From aahz at pythoncraft.com Sun Jan 9 11:56:52 2011 From: aahz at pythoncraft.com (Aahz) Date: 9 Jan 2011 08:56:52 -0800 Subject: Integrating doctest with unittest References: <4d038b63$0$30000$c3e8da3$5496439d@news.astraweb.com> Message-ID: In article <4d038b63$0$30000$c3e8da3$5496439d at news.astraweb.com>, Steven D'Aprano wrote: > >Is there a way to have unittest.main() find and run doc_test_suite >together with the other test suites? You probably need to use nose or something. (That's what we're doing.) -- Aahz (aahz at pythoncraft.com) <*> http://www.pythoncraft.com/ "Think of it as evolution in action." --Tony Rand From hobson42 at gmail.com Sun Jan 9 12:49:10 2011 From: hobson42 at gmail.com (Ian) Date: Sun, 09 Jan 2011 17:49:10 +0000 Subject: Nothing to repeat In-Reply-To: References: Message-ID: <4D29F516.3030700@gmail.com> On 09/01/2011 16:49, Tom Anderson wrote: > Hello everyone, long time no see, > > This is probably not a Python problem, but rather a regular > expressions problem. > > I want, for the sake of arguments, to match strings comprising any > number of occurrences of 'spa', each interspersed by any number of > occurrences of the 'm'. 'any number' includes zero, so the whole > pattern should match the empty string. > > Here's the conversation Python and i had about it: > > Python 2.6.4 (r264:75706, Jun 4 2010, 18:20:16) > [GCC 4.4.4 20100503 (Red Hat 4.4.4-2)] on linux2 > Type "help", "copyright", "credits" or "license" for more information. >>>> import re >>>> re.compile("(spa|m*)*") > Traceback (most recent call last): > File "", line 1, in > File "/usr/lib/python2.6/re.py", line 190, in compile > return _compile(pattern, flags) > File "/usr/lib/python2.6/re.py", line 245, in _compile > raise error, v # invalid expression > sre_constants.error: nothing to repeat > > What's going on here? Why is there nothing to repeat? Is the problem > having one *'d term inside another? > > Now, i could actually rewrite this particular pattern as '(spa|m)*'. > But what i neglected to mention above is that i'm actually generating > patterns from structures of objects (representations of XML DTDs, as > it happens), and as it stands, patterns like this are a possibility. > > Any thoughts on what i should do? Do i have to bite the bullet and > apply some cleverness in my pattern generation to avoid situations > like this? > > Thanks, > tom > I think you want to anchor your list, or anything will match. Perhaps re.compile('/^(spa(m)+)*$/') is what you need. Regards Ian From martin at address-in-sig.invalid Sun Jan 9 13:05:46 2011 From: martin at address-in-sig.invalid (Martin Gregorie) Date: Sun, 9 Jan 2011 18:05:46 +0000 (UTC) Subject: Nothing to repeat References: Message-ID: On Sun, 09 Jan 2011 16:49:35 +0000, Tom Anderson wrote: > > Any thoughts on what i should do? Do i have to bite the bullet and apply > some cleverness in my pattern generation to avoid situations like this? > This sort of works: import re f = open("test.txt") p = re.compile("(spam*)*") for line in f: print "input line: %s" % (line.strip()) for m in p.findall(line): if m != "": print "==> %s" % (m) when I feed it =======================test.txt=========================== a line with no match spa should match spam should match so should all of spaspamspammspammm and so should all of spa spam spamm spammm no match again. =======================test.txt=========================== it produces: input line: a line with no match input line: spa should match ==> spa input line: spam should match ==> spam input line: so should all of spaspamspammspammm ==> spammm input line: and so should all of spa spam spamm spammm ==> spa ==> spam ==> spamm ==> spammm input line: no match again. so obviously there's a problem with greedy matching where there are no separators between adjacent matching strings. I tried non-greedy matching, e.g. r'(spam*?)*', but this was worse, so I'll be interested to see how the real regex mavens do it. -- martin@ | Martin Gregorie gregorie. | Essex, UK org | From hobson42 at gmail.com Sun Jan 9 13:09:44 2011 From: hobson42 at gmail.com (Ian) Date: Sun, 09 Jan 2011 18:09:44 +0000 Subject: Nothing to repeat In-Reply-To: <4D29F516.3030700@gmail.com> References: <4D29F516.3030700@gmail.com> Message-ID: <4D29F9E8.90902@gmail.com> On 09/01/2011 17:49, Ian wrote: > I think you want to anchor your list, or anything will match. Perhaps My bad - this is better re.compile('^((spa)*(m)*)+$') search finds match in 'spa', 'spaspaspa', 'spammmspa', '' and 'mmm' search fails on 'spats', 'mats' and others. From tjreedy at udel.edu Sun Jan 9 13:58:09 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Sun, 09 Jan 2011 13:58:09 -0500 Subject: Nothing to repeat In-Reply-To: References: Message-ID: On 1/9/2011 11:49 AM, Tom Anderson wrote: > Hello everyone, long time no see, > > This is probably not a Python problem, but rather a regular expressions > problem. > > I want, for the sake of arguments, to match strings comprising any > number of occurrences of 'spa', each interspersed by any number of > occurrences of the 'm'. 'any number' includes zero, so the whole pattern > should match the empty string. All you sure? A pattern that matches the empty string matches every string. > Here's the conversation Python and i had about it: > > Python 2.6.4 (r264:75706, Jun 4 2010, 18:20:16) > [GCC 4.4.4 20100503 (Red Hat 4.4.4-2)] on linux2 > Type "help", "copyright", "credits" or "license" for more information. >>>> import re >>>> re.compile("(spa|m*)*") I believe precedence rule of * tighter than | (not in the doc) makes this re is the same as "(spa|(m)*)*", which gives same error traceback. I believe that for this, re compiles first (spa)* and then ((m)*)* and the latter gives the same traceback. Either would seem to match strings of 'm's without and 'spa', which is not your spec. "((spa|m)*)*" does compile, so it is not the nesting itself. The doc does not give the formal grammar for Python re's, so it is hard to pinpoint which informal rule is violated, or if indeed the error is a bug. Someone else may do better. > Now, i could actually rewrite this particular pattern as '(spa|m)*'. That also does not match your spec. > Any thoughts on what i should do? Do i have to bite the bullet and apply > some cleverness in my pattern generation to avoid situations like this? Well, it has to generate legal re's according to the engine you are using (with whatever bugs and limitations it has). -- Terry Jan Reedy From davea at ieee.org Sun Jan 9 14:53:46 2011 From: davea at ieee.org (Dave Angel) Date: Sun, 09 Jan 2011 14:53:46 -0500 Subject: Help needed with unittest and global In-Reply-To: <4D29DEF5.2030702@ianhobson.co.uk> References: <4D29DEF5.2030702@ianhobson.co.uk> Message-ID: <4D2A124A.9000508@ieee.org> On 01/-10/-28163 02:59 PM, Ian Hobson wrote: > Hi all, > > I am trying to develop a PyQt application, and I want to unittest it. > > After three false starts, I am plainly unaware of something rather basic > - can some kind person please help me out? > > This is a log to show what I have so far > D:\work\ian>type testAll.py > # coding=utf8 > # testAll.py - run all tests. > import unittest > import sys > from PyQt4.QtGui import * > from testCubic import testCubic > global app > def main(): > suite = unittest.TestLoader() > suite.loadTestsFromTestCase(testCubic) > unittest.TextTestRunner().run(suite) > if __name__=="__main__": > global app > app = QApplication(sys.argv) # set gloabl app > unittest.main() > > D:\work\ian>type testCubic.py > # coding=utf8 > # testCubic.py - tests the top level module > import unittest > global app > class testCubic(unittest.TestCase): > def test001_walkingSkeleton(self): > global app # use global version > app.processEvents() # fails > D:\work\ian>python testAll.py > E > ====================================================================== > ERROR: test001_walkingSkeleton (testCubic.testCubic) > ---------------------------------------------------------------------- > Traceback (most recent call last): > File "D:\work\ian\testCubic.py", line 8, in test001_walkingSkeleton > app.processEvents() # fails > NameError: global name 'app' is not defined > You have two global variables called app, one is in the testCubic module and the other is in the testAll.py script. They do not automatically refer to the same thing. To use a global from another module, you can either do an import, or you can pass it as an argument. But beware of mutual imports. DaveA From hobson42 at gmail.com Sun Jan 9 15:13:07 2011 From: hobson42 at gmail.com (Ian) Date: Sun, 09 Jan 2011 20:13:07 +0000 Subject: Help needed with unittest and global In-Reply-To: <4D2A124A.9000508@ieee.org> References: <4D29DEF5.2030702@ianhobson.co.uk> <4D2A124A.9000508@ieee.org> Message-ID: <4D2A16D3.4070405@gmail.com> On 09/01/2011 19:53, Dave Angel wrote: > On 01/-10/-28163 02:59 PM, Ian Hobson wrote: >> Hi all, >> >> I am trying to develop a PyQt application, and I want to unittest it. >> snip >> D:\work\ian>python testAll.py >> E >> ====================================================================== >> ERROR: test001_walkingSkeleton (testCubic.testCubic) >> ---------------------------------------------------------------------- >> Traceback (most recent call last): >> File "D:\work\ian\testCubic.py", line 8, in test001_walkingSkeleton >> app.processEvents() # fails >> NameError: global name 'app' is not defined >> > > You have two global variables called app, one is in the testCubic > module and the other is in the testAll.py script. They do not > automatically refer to the same thing. > > To use a global from another module, you can either do an import, or > you can pass it as an argument. But beware of mutual imports. > > DaveA > Thanks David, I found http://mail.python.org/pipermail/tutor/2002-November/018353.html and created a shared module that both modules can import. Then I refer to shared.app, no use of global and it works as desired. I am on to the next step - actually running my code. Regards Ian From tshinnic at io.com Sun Jan 9 15:43:30 2011 From: tshinnic at io.com (Thomas L. Shinnick) Date: Sun, 09 Jan 2011 14:43:30 -0600 Subject: What INI config file module allows lists of duplicate same-named options? In-Reply-To: <4D2A16D3.4070405@gmail.com> References: <4D29DEF5.2030702@ianhobson.co.uk> <4D2A124A.9000508@ieee.org> <4D2A16D3.4070405@gmail.com> Message-ID: Having (possibly) surveyed all the available pypi config file modules, I still haven't seen one that allows an obvious and familiar extension of the strict Windows INI format. Each INI-style config module seems to enforce the strict rule: each option in a section must have a different name - no duplicates. Thus it is impossible to have a simple list, e.g. [pathset uk] pathpair: /bath/* to /london/* pathpair: /bath/upload/** to /london/* pathpair: /firth/* to /forth/* pathpair: /firth/upload/** to /forth/* Rather you must give each line a separate name, e.g. [pathset uk] pathpair001: /bath/* to /london/* pathpair002: /bath/upload/** to /london/* pathpair003: /firth/* to /forth/* pathpair004: /firth/upload/** to /forth/* | | | | | | pathpair068: /glasgow/* to /edinburgh/* pathpair069: /glasgow/upload/** to /edinburgh/* | | | | | | This is not ideal for a number of reasons. Do you know of a library module that has the (optional?) ability to handle duplicate-named options, returning them as a list? If instead someone can point me to a reasonable Apache-style config module, that might also serve. I've looked for such and the few found seemed to be either bare bones or clumsily stripped out of something much larger. -- I'm a pessimist about probabilities; I'm an optimist about possibilities. Lewis Mumford (1895-1990) -------------- next part -------------- An HTML attachment was scrubbed... URL: From kb1pkl at aim.com Sun Jan 9 15:47:06 2011 From: kb1pkl at aim.com (Corey Richardson) Date: Sun, 09 Jan 2011 15:47:06 -0500 Subject: What INI config file module allows lists of duplicate same-named options? In-Reply-To: References: <4D29DEF5.2030702@ianhobson.co.uk> <4D2A124A.9000508@ieee.org> <4D2A16D3.4070405@gmail.com> Message-ID: <4D2A1ECA.2090901@aim.com> On 01/09/2011 03:43 PM, Thomas L. Shinnick wrote: > Having (possibly) surveyed all the available pypi config file modules, I > still haven't seen one that allows an obvious and familiar extension of > the strict Windows INI format. > > Each INI-style config module seems to enforce the strict rule: each > option in a section must have a different name - no duplicates. Thus it > is impossible to have a simple list, e.g. > > [pathset uk] > pathpair: /bath/* to /london/* > pathpair: /bath/upload/** to /london/* > pathpair: /firth/* to /forth/* > pathpair: /firth/upload/** to /forth/* > > Rather you must give each line a separate name, e.g. > > [pathset uk] > pathpair001: /bath/* to /london/* > pathpair002: /bath/upload/** to /london/* > pathpair003: /firth/* to /forth/* > pathpair004: /firth/upload/** to /forth/* > | | | | | | > pathpair068: /glasgow/* to /edinburgh/* > pathpair069: /glasgow/upload/** to /edinburgh/* > | | | | | | > > This is not ideal for a number of reasons. Do you know of a library > module that has the (optional?) ability to handle duplicate-named > options, returning them as a list? > > If instead someone can point me to a reasonable Apache-style config > module, that might also serve. I've looked for such and the few found > seemed to be either bare bones or clumsily stripped out of something > much larger. > > > -- > I'm a pessimist about probabilities; I'm an optimist about possibilities. > Lewis Mumford (1895-1990) > Seems to me to be a standard enforced by Windows itself, not any an issue with the modules. What exactly are you doing? ~Corey Richardson From stefan.sonnenberg at pythonmeister.com Sun Jan 9 15:52:42 2011 From: stefan.sonnenberg at pythonmeister.com (Stefan Sonnenberg-Carstens) Date: Sun, 09 Jan 2011 21:52:42 +0100 Subject: What INI config file module allows lists of duplicate same-named options? In-Reply-To: References: <4D29DEF5.2030702@ianhobson.co.uk> <4D2A124A.9000508@ieee.org> <4D2A16D3.4070405@gmail.com> Message-ID: <4D2A201A.9040604@pythonmeister.com> Am 09.01.2011 21:43, schrieb Thomas L. Shinnick: > Having (possibly) surveyed all the available pypi config file modules, > I still haven't seen one that allows an obvious and familiar extension > of the strict Windows INI format. > > Each INI-style config module seems to enforce the strict rule: each > option in a section must have a different name - no duplicates. Thus > it is impossible to have a simple list, e.g. > > [pathset uk] > pathpair: /bath/* to /london/* > pathpair: /bath/upload/** to /london/* > pathpair: /firth/* to /forth/* > pathpair: /firth/upload/** to /forth/* > > Rather you must give each line a separate name, e.g. > > [pathset uk] > pathpair001: /bath/* to /london/* > pathpair002: /bath/upload/** to /london/* > pathpair003: /firth/* to /forth/* > pathpair004: /firth/upload/** to /forth/* > | | | | | | > pathpair068: /glasgow/* to /edinburgh/* > pathpair069: /glasgow/upload/** to /edinburgh/* > | | | | | | > > This is not ideal for a number of reasons. Do you know of a library > module that has the (optional?) ability to handle duplicate-named > options, returning them as a list? > > If instead someone can point me to a reasonable Apache-style config > module, that might also serve. I've looked for such and the few found > seemed to be either bare bones or clumsily stripped out of something > much larger. > > > -- > I'm a pessimist about probabilities; I'm an optimist about possibilities. > Lewis Mumford (1895-1990) > I've let ini style files alone some time ago. Whenever possible I use JSON based files. Your example could then look like this: { "pathpairs":{ "uk":[ ["/bath/*","/london/*"], ["/bath/upload/**","/london/*"], ["/firth/*,"/forth/*"], ["/firth/upload/**","/forth/*"] ] } } Since Python 2.7, json is in the standard library. -------------- next part -------------- An HTML attachment was scrubbed... URL: From tshinnic at io.com Sun Jan 9 16:04:07 2011 From: tshinnic at io.com (Thomas L. Shinnick) Date: Sun, 09 Jan 2011 15:04:07 -0600 Subject: What INI config file module allows lists of duplicate same-named options? In-Reply-To: <4D2A1ECA.2090901@aim.com> References: <4D29DEF5.2030702@ianhobson.co.uk> <4D2A124A.9000508@ieee.org> <4D2A16D3.4070405@gmail.com> <4D2A1ECA.2090901@aim.com> Message-ID: <6B.79.24070.8C22A2D4@hrndva-omtalb.mail.rr.com> At 02:47 PM 1/9/2011, Corey Richardson wrote: >On 01/09/2011 03:43 PM, Thomas L. Shinnick wrote: > > Having (possibly) surveyed all the available pypi config file modules, I > > still haven't seen one that allows an obvious and familiar extension of > > the strict Windows INI format. > > > > Each INI-style config module seems to enforce the strict rule: each > > option in a section must have a different name - no duplicates. Thus it > > is impossible to have a simple list, e.g. > > > > [pathset uk] > > pathpair: /bath/* to /london/* > > pathpair: /bath/upload/** to /london/* > > pathpair: /firth/* to /forth/* > > pathpair: /firth/upload/** to /forth/* > > > > Rather you must give each line a separate name, e.g. > > > > [pathset uk] > > pathpair001: /bath/* to /london/* > > pathpair002: /bath/upload/** to /london/* > > pathpair003: /firth/* to /forth/* > > pathpair004: /firth/upload/** to /forth/* > > | | | | | | > > pathpair068: /glasgow/* to /edinburgh/* > > pathpair069: /glasgow/upload/** to /edinburgh/* > > | | | | | | > > > > This is not ideal for a number of reasons. Do you know of a library > > module that has the (optional?) ability to handle duplicate-named > > options, returning them as a list? > > > > If instead someone can point me to a reasonable Apache-style config > > module, that might also serve. I've looked for such and the few found > > seemed to be either bare bones or clumsily stripped out of something > > much larger. > > > > > > -- > > I'm a pessimist about probabilities; I'm an optimist about possibilities. > > Lewis Mumford (1895-1990) > > > >Seems to me to be a standard enforced by Windows itself, not any an >issue with the modules. What exactly are you doing? Windows established the format, established the 'rules', then people adopted the format and rules, but often with 'adaptions' and extensions. I see many variations in the various modules found in pypi, such as variable interpolation, but none that violate the 'rule' "no duplicates". Here, I need to list multiple file/dir path pairs. A list of multiple items to be acted upon in a common way. It is a list. Simple. Except I can't find a library/pypi module with the obvious extension. Full disclosure: I'm familiar with $lang which has many such possible modules, which has me rather puzzled here. >~Corey Richardson From tshinnic at io.com Sun Jan 9 16:11:15 2011 From: tshinnic at io.com (Thomas L. Shinnick) Date: Sun, 09 Jan 2011 15:11:15 -0600 Subject: What INI config file module allows lists of duplicate same-named options? In-Reply-To: <4D2A201A.9040604@pythonmeister.com> References: <4D29DEF5.2030702@ianhobson.co.uk> <4D2A124A.9000508@ieee.org> <4D2A16D3.4070405@gmail.com> <4D2A201A.9040604@pythonmeister.com> Message-ID: <35.8D.14011.5742A2D4@hrndva-omtalb.mail.rr.com> At 02:52 PM 1/9/2011, Stefan Sonnenberg-Carstens wrote: >Am 09.01.2011 21:43, schrieb Thomas L. Shinnick: >>Having (possibly) surveyed all the available pypi config file >>modules, I still haven't seen one that allows an obvious and >>familiar extension of the strict Windows INI format. >> >>Each INI-style config module seems to enforce the strict rule: each >>option in a section must have a different name - no >>duplicates. Thus it is impossible to have a simple list, e.g. >> >> [pathset uk] >> pathpair: /bath/* to /london/* >> pathpair: /bath/upload/** to /london/* >> pathpair: /firth/* to /forth/* >> pathpair: /firth/upload/** to /forth/* >> >>Rather you must give each line a separate name, e.g. >> >> [pathset uk] >> pathpair001: /bath/* to /london/* >> pathpair002: /bath/upload/** to /london/* >> pathpair003: /firth/* to /forth/* >> pathpair004: /firth/upload/** to /forth/* >> | | | | | | >> pathpair068: /glasgow/* to /edinburgh/* >> pathpair069: /glasgow/upload/** to /edinburgh/* >> | | | | | | >> >>This is not ideal for a number of reasons. Do you know of a >>library module that has the (optional?) ability to handle >>duplicate-named options, returning them as a list? >> >>If instead someone can point me to a reasonable Apache-style config >>module, that might also serve. I've looked for such and the few >>found seemed to be either bare bones or clumsily stripped out of >>something much larger. >> >> >>-- >>I'm a pessimist about probabilities; I'm an optimist about possibilities. >> Lewis Mumford (1895-1990) >I've let ini style files alone some time ago. >Whenever possible I use JSON based files. > >Your example could then look like this: > >{ >"pathpairs":{ > "uk":[ > ["/bath/*","/london/*"], > ["/bath/upload/**","/london/*"], > ["/firth/*,"/forth/*"], > ["/firth/upload/**","/forth/*"] > ] >} >} > >Since Python 2.7, json is in the standard library. A reasonable response, if your only audience is computer folk. And used internally already. But in trying to be simple as can be for those installing and maintaining a package, INI-style configurations are a familiar format. As Apache-style configs would be. So, JSON is concise and flexible and easily handled by programs. But I was hoping for something easier for the poor soul coming back to a config after 2 months and wondering how to add something ... -------------- next part -------------- An HTML attachment was scrubbed... URL: From develsoftware at gmail.com Sun Jan 9 16:58:33 2011 From: develsoftware at gmail.com (=?UTF-8?B?0JXQstCz0LXQvdC40Lkg0J/QvtGH0LjRgtCw0LXQsg==?=) Date: Sun, 9 Jan 2011 13:58:33 -0800 (PST) Subject: Embedded Python static modules References: Message-ID: I made frozen modules and link this modules with my program. PyImport_FrozenModules = frozen_modules; Py_Initialize(); I got next message: Could not find platform independent libraries Could not find platform dependent libraries Consider setting $PYTHONHOME to [:] Traceback (most recent call last): File "site.py", line 553, in File "site.py", line 535, in main File "site.py", line 268, in addusersitepackages File "site.py", line 243, in getusersitepackages File "site.py", line 233, in getuserbase File "sysconfig.py", line 535, in get_config_var File "sysconfig.py", line 434, in get_config_vars File "sysconfig.py", line 287, in _init_posix IOError: invalid Python installation: unable to open /usr/local/lib/ python2.7/config/Makefile (No such file or directory) How I can fix this problem? From develsoftware at gmail.com Sun Jan 9 17:18:05 2011 From: develsoftware at gmail.com (=?UTF-8?B?0JXQstCz0LXQvdC40Lkg0J/QvtGH0LjRgtCw0LXQsg==?=) Date: Sun, 9 Jan 2011 14:18:05 -0800 (PST) Subject: Embedded Python static modules References: Message-ID: <6452fac5-88b4-4d71-81ec-26e6e6bb96cb@m11g2000vbs.googlegroups.com> I found solution: Py_NoSiteFlag = 1; Py_FrozenFlag = 1; Py_IgnoreEnvironmentFlag = 1; Py_SetPythonHome(""); Py_SetProgramName(""); From steve+comp.lang.python at pearwood.info Sun Jan 9 21:14:24 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 10 Jan 2011 02:14:24 GMT Subject: Integrating doctest with unittest References: <4d038b63$0$30000$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4d2a6b80$0$30004$c3e8da3$5496439d@news.astraweb.com> On Sun, 09 Jan 2011 08:56:52 -0800, Aahz wrote: > In article <4d038b63$0$30000$c3e8da3$5496439d at news.astraweb.com>, Steven > D'Aprano wrote: >> >>Is there a way to have unittest.main() find and run doc_test_suite >>together with the other test suites? > > You probably need to use nose or something. (That's what we're doing.) Thanks for the reply Aahz, even though it wasn't what I wanted to hear :( -- Steven From googler.1.webmaster at spamgourmet.com Mon Jan 10 03:21:31 2011 From: googler.1.webmaster at spamgourmet.com (moerchendiser2k3) Date: Mon, 10 Jan 2011 00:21:31 -0800 (PST) Subject: Resolve circular reference References: <1718ea91-fc4e-49f3-a15a-bdc683789126@k22g2000yqh.googlegroups.com> <353ecd61-22f8-4770-be30-29cb76b0f6b0@t35g2000yqj.googlegroups.com> <2349f7d4-2b85-456f-96b5-140f15548859@v17g2000prc.googlegroups.com> Message-ID: <1e7f6338-33ff-488e-9182-b31498babe0b@c39g2000yqi.googlegroups.com> so there is no chance without using weakrefs? any ideas, tips, workarounds how I might handle this? bye, moerchendiser2k3 From kushal.kumaran+python at gmail.com Mon Jan 10 03:26:51 2011 From: kushal.kumaran+python at gmail.com (Kushal Kumaran) Date: Mon, 10 Jan 2011 13:56:51 +0530 Subject: Close stdout socket on CGI after fork with subprocess In-Reply-To: References: Message-ID: On Mon, Jan 10, 2011 at 1:15 PM, Thibaud Roussillat wrote: > On Sat, Jan 8, 2011 at 3:19 AM, Kushal Kumaran > wrote: >> >> On Fri, Jan 7, 2011 at 8:08 PM, Thibaud Roussillat >> wrote: >> > Hi, >> > >> > I work with Python 2.4 and CGI. >> > >> > I have a CGI which call a Python script in background process and return >> > result before background task is finished. >> > >> > Actually, the browser displays response but it is waiting for end of >> > background task because the socket is not closed. >> > >> > Internet told me that I must close the stdout file descriptor >> > (sys.stdout.close()) to close the socket but it doesn't work. >> > >> > The background task is launched via subprocess.Popen and is attached to >> > the >> > root process on ps command. >> > >> >> This means that the parent process finished before the child. ?Call >> wait() on the Popen object to wait for the child to terminate. >> Depending on how you create the Popen object, the child process may >> inherit your own stdout. ?In that case, the child process may be >> keeping the socket open after the parent dies. >> > > > > In fact, the parent process finished before the child, it's why I want to > run the child in a forked process, and close the socket of the parent task. > > The goal is not to wait for the child process but to leave it lead one's own > life as a background task. The client don't have to wait for the end of the > child process. > > Is there a way to not inherit from the parent stdout on the child process ? > open os.devnull and pass that file object as stdin, stdout and stderr for the child process. Hopefully the program you are running has been designed not to expect to be able to use stdin/stdout/stderr. Please keep the discussion on the mailing list. Other people on the list are smarter than me. Also, the convention on this mailing list is to keep replies below the quoted content. -- regards, kushal From jeanmichel at sequans.com Mon Jan 10 05:13:38 2011 From: jeanmichel at sequans.com (Jean-Michel Pichavant) Date: Mon, 10 Jan 2011 11:13:38 +0100 Subject: Absolute imports? In-Reply-To: References: <877heff4fl.fsf@benfinney.id.au> Message-ID: <4D2ADBD2.3070604@sequans.com> Roy Smith wrote: > [snip] > It's reasonably straight-forward to figure out that absolute path, > starting from sys.argv[0] and using the tools in os.path. Now I need to > import the file, given that I know its absolute pathname. It looks like > imp.load_source() does what I want, I'm just wondering if there's a > cleaner way. > What about config = __import__(configPath.replace('.py', '')) JM From jldunn2000 at gmail.com Mon Jan 10 09:12:29 2011 From: jldunn2000 at gmail.com (loial) Date: Mon, 10 Jan 2011 06:12:29 -0800 (PST) Subject: PJL Message-ID: <19d28e76-6085-42b5-a98f-7bf40591910f@f35g2000vbl.googlegroups.com> Anyone got any experience of send PJL commands to a printer using Python on Unix? From thibaud.roussillat at gmail.com Mon Jan 10 09:53:18 2011 From: thibaud.roussillat at gmail.com (Thibaud Roussillat) Date: Mon, 10 Jan 2011 15:53:18 +0100 Subject: Close stdout socket on CGI after fork with subprocess In-Reply-To: References: Message-ID: On Mon, Jan 10, 2011 at 9:26 AM, Kushal Kumaran < kushal.kumaran+python at gmail.com > wrote: > On Mon, Jan 10, 2011 at 1:15 PM, Thibaud Roussillat > wrote: > > On Sat, Jan 8, 2011 at 3:19 AM, Kushal Kumaran > > > > wrote: > >> > >> On Fri, Jan 7, 2011 at 8:08 PM, Thibaud Roussillat > >> wrote: > >> > Hi, > >> > > >> > I work with Python 2.4 and CGI. > >> > > >> > I have a CGI which call a Python script in background process and > return > >> > result before background task is finished. > >> > > >> > Actually, the browser displays response but it is waiting for end of > >> > background task because the socket is not closed. > >> > > >> > Internet told me that I must close the stdout file descriptor > >> > (sys.stdout.close()) to close the socket but it doesn't work. > >> > > >> > The background task is launched via subprocess.Popen and is attached > to > >> > the > >> > root process on ps command. > >> > > >> > >> This means that the parent process finished before the child. Call > >> wait() on the Popen object to wait for the child to terminate. > >> Depending on how you create the Popen object, the child process may > >> inherit your own stdout. In that case, the child process may be > >> keeping the socket open after the parent dies. > >> > > > > > > > > In fact, the parent process finished before the child, it's why I want to > > run the child in a forked process, and close the socket of the parent > task. > > > > The goal is not to wait for the child process but to leave it lead one's > own > > life as a background task. The client don't have to wait for the end of > the > > child process. > > > > Is there a way to not inherit from the parent stdout on the child process > ? > > > > open os.devnull and pass that file object as stdin, stdout and stderr > for the child process. Hopefully the program you are running has been > designed not to expect to be able to use stdin/stdout/stderr. > > Please keep the discussion on the mailing list. Other people on the > list are smarter than me. Also, the convention on this mailing list > is to keep replies below the quoted content. > > -- > regards, > kushal > Thanks a lot, this works well with a file object opened on /dev/null (or os.devnull) and passed as stdin, stdout and stderr. Sorry for the reply, I just do "reply" on my webmail ;) Regards, Thib -------------- next part -------------- An HTML attachment was scrubbed... URL: From emile at fenx.com Mon Jan 10 10:00:23 2011 From: emile at fenx.com (Emile van Sebille) Date: Mon, 10 Jan 2011 07:00:23 -0800 Subject: PJL In-Reply-To: <19d28e76-6085-42b5-a98f-7bf40591910f@f35g2000vbl.googlegroups.com> References: <19d28e76-6085-42b5-a98f-7bf40591910f@f35g2000vbl.googlegroups.com> Message-ID: On 1/10/2011 6:12 AM loial said... > Anyone got any experience of send PJL commands to a printer using > Python on Unix? > Are you having trouble? PJL is sent like any other text... Emile From zac256 at gmail.com Mon Jan 10 10:00:47 2011 From: zac256 at gmail.com (Zac Burns) Date: Mon, 10 Jan 2011 23:00:47 +0800 Subject: Create a class to position a window on the screen. In-Reply-To: References: Message-ID: I'm not exactly sure what you are asking here, but one problem that is notable in your example is that the center function is indented inside the __init__ function. This would create a closure instead of a method on PositionWindow, which is probably not what you want. -Zac On Sun, Jan 9, 2011 at 10:23 AM, Rohit Coder < passionate_programmer at hotmail.com> wrote: > Hi, > elementFontfont-familyfont-sizefont-stylefont-variantfont-weight > letter-spacingline-heighttext-decorationtext-aligntext-indent > text-transformwhite-spaceword-spacingcolorBackgroundbg-attachmentbg-color > bg-imagebg-positionbg-repeatBoxwidthheightborder-topborder-right > border-bottomborder-leftmarginpaddingmax-heightmin-heightmax-width > min-widthoutline-coloroutline-styleoutline-widthPositioningpositiontop > bottomrightleftfloatdisplayclearz-indexListlist-style-imagelist-style-type > list-style-positionTablevertical-alignborder-collapseborder-spacing > caption-sideempty-cellstable-layoutEffectstext-shadow-webkit-box-shadow > border-radiusOtheroverflowcursorvisibility > > I am new to Python and this is my fist Python class. I am using PyQt4 > framework on Windows 7. > > I don't know whether the code below is correctly written or not. I want to > modify it further as: > > 1. In the arguments, I want to pass the name of another opened Window > (.py) on the screen. > 2. I want to pass the x-coord., y-coord. and the name of the window to > position on the screen. > > How to modify the code to fulfill these requirements? > > ***Attempted Code*** > > class PositionWindow: > def __init__(self, xCoord, yCoord, windowName, parent = None): > self.x = xCoord > self.y = yCoord > self.wName = windowName; > > def center(self): > screen = QtGui.QDesktopWidget().screenGeometry() > size = self.geometry() > self.move((screen.width()-size.width())/2, > (screen.height()-size.height())/2) > > ................... > Rohit. > > > -- > http://mail.python.org/mailman/listinfo/python-list > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From jldunn2000 at gmail.com Mon Jan 10 10:06:16 2011 From: jldunn2000 at gmail.com (loial) Date: Mon, 10 Jan 2011 07:06:16 -0800 (PST) Subject: PJL References: <19d28e76-6085-42b5-a98f-7bf40591910f@f35g2000vbl.googlegroups.com> Message-ID: <44a7123a-52e7-4c34-adba-d9cf19985899@u9g2000pra.googlegroups.com> Thanks for responding.. First question...how do I send it to the printer? Printer would be on the network. From pavlovevidence at gmail.com Mon Jan 10 10:20:06 2011 From: pavlovevidence at gmail.com (Carl Banks) Date: Mon, 10 Jan 2011 07:20:06 -0800 (PST) Subject: Resolve circular reference References: <1718ea91-fc4e-49f3-a15a-bdc683789126@k22g2000yqh.googlegroups.com> <353ecd61-22f8-4770-be30-29cb76b0f6b0@t35g2000yqj.googlegroups.com> <2349f7d4-2b85-456f-96b5-140f15548859@v17g2000prc.googlegroups.com> <1e7f6338-33ff-488e-9182-b31498babe0b@c39g2000yqi.googlegroups.com> Message-ID: <429e3e67-9732-4f82-9f97-99ed5aeb1f74@r8g2000prm.googlegroups.com> On Jan 10, 12:21?am, moerchendiser2k3 wrote: > so there is no chance without using weakrefs? > any ideas, tips, workarounds how I might handle this? No, sorry: as long as a reference to an object exists, the object is never deleted. There is no way to get around this. Python in general isn't designed to allow for exact control over the destruction of objects. Even in CPython, which uses reference counting, there are a bunch of situations where a reference might be stored to an object that keeps it alive. (Unexpected locations where a stray reference might exist: an unpickler object, the _ symbol in the interactive shell.) Other implementations, like Jython and IronPython, don't use reference counting and don't provide for any particular time at all for an object to be destroyed. The recommended way to ensure timely release of resources in Python is to provide a method (such as close or finalize) to explicity release the resource--the object then lives on in a zombie state. The with statement can be used in many cases to avoid the need to call this method explicitly. For example, if you were to run this code in Python: with open(filename) as f: g = f print g It would print . The object still exists because there is a reference to it, but the file has been closed. If you can tell us why it's so important that the object be destroyed at that given time, even while a reference to it exists, maybe we can give you better suggestions. Carl Banks From wolfgang at rohdewald.de Mon Jan 10 10:49:03 2011 From: wolfgang at rohdewald.de (Wolfgang Rohdewald) Date: Mon, 10 Jan 2011 16:49:03 +0100 Subject: PJL In-Reply-To: <44a7123a-52e7-4c34-adba-d9cf19985899@u9g2000pra.googlegroups.com> References: <19d28e76-6085-42b5-a98f-7bf40591910f@f35g2000vbl.googlegroups.com> <44a7123a-52e7-4c34-adba-d9cf19985899@u9g2000pra.googlegroups.com> Message-ID: <201101101649.03489.wolfgang@rohdewald.de> On Montag 10 Januar 2011, loial wrote: > First question...how do I send it to the printer? Printer > would be on the network. echo PJL | lp -oraw -dnetworkprinter if it works, translate it to python -- Wolfgang -------------- next part -------------- An HTML attachment was scrubbed... URL: From jtim.arnold at gmail.com Mon Jan 10 11:29:07 2011 From: jtim.arnold at gmail.com (Tim) Date: Mon, 10 Jan 2011 08:29:07 -0800 (PST) Subject: os.system and loggers References: <70ac3463-cf3c-4435-909b-ac044bef7e41@z9g2000yqz.googlegroups.com> Message-ID: <285801ef-7e26-4c40-a307-3c6eb5314b82@z17g2000prz.googlegroups.com> On Jan 7, 11:24?am, Tim wrote: > hi, I'm using a 3rd-party python program that uses the python logging > facility and also makes calls to os.system. I'm trying to capture its > output to a file. > > In my own code, I've taken control of the loggers that are setup in > the other program by removing its StreamHandler and replacing with > FileHander. But when it comes to the call to os.system I'm at a loss. > > I want to capture the stdout from that os.system call in my > FileHandler. I thought this might work, before I call the other > program's class/method: > sys.stdout = getLogger('status').handlers[0].stream > > but no dice. Is there any clean way to get what I want? If not, I > guess I'll override the other method with my own, but it will > basically be a bunch of code copied with os.sytem replaced with > subprocess, using getLogger('status').handlers[0].stream for stdout/ > stderr. > > thanks, > --Tim Arnold Replying to my own post.... I think I may have included too much fluff in my original question. The main thing I wonder is whether I can attach a log handler to stdout in such a way that os.system calls will write to that handler instead of the console. thanks, --Tim From emile at fenx.com Mon Jan 10 12:08:36 2011 From: emile at fenx.com (Emile van Sebille) Date: Mon, 10 Jan 2011 09:08:36 -0800 Subject: PJL In-Reply-To: <44a7123a-52e7-4c34-adba-d9cf19985899@u9g2000pra.googlegroups.com> References: <19d28e76-6085-42b5-a98f-7bf40591910f@f35g2000vbl.googlegroups.com> <44a7123a-52e7-4c34-adba-d9cf19985899@u9g2000pra.googlegroups.com> Message-ID: On 1/10/2011 7:06 AM loial said... > Thanks for responding.. > > First question...how do I send it to the printer? Printer would be > on the network. Start here: http://mail.python.org/pipermail/python-announce-list/2000-November/000567.html The middle article covers accessing the printer. Emile From torriem at gmail.com Mon Jan 10 12:37:33 2011 From: torriem at gmail.com (Michael Torrie) Date: Mon, 10 Jan 2011 10:37:33 -0700 Subject: Print to an IPP printer (pkipplib?) In-Reply-To: <1287247744.11414.0.camel@linux-yu4c.site> References: <1287247744.11414.0.camel@linux-yu4c.site> Message-ID: <4D2B43DD.4040101@gmail.com> On 10/16/2010 10:49 AM, Adam Tauno Williams wrote: > I've found the module pkipplib which seems to work well for things like > interrogating an IPP (CUPS) server. But is there a way to send a print > job to an IPP print queue? [and no, the local system knows nothing about > the print architecture so popen....lp is not an option]. I just want to > send the data from a file handle to a remote IPP queue as a print job. I wonder if you could post the print job directly to the IPP url. It's really just HTTP under the hood. From googler.1.webmaster at spamgourmet.com Mon Jan 10 12:55:54 2011 From: googler.1.webmaster at spamgourmet.com (moerchendiser2k3) Date: Mon, 10 Jan 2011 09:55:54 -0800 (PST) Subject: Resolve circular reference References: <1718ea91-fc4e-49f3-a15a-bdc683789126@k22g2000yqh.googlegroups.com> <353ecd61-22f8-4770-be30-29cb76b0f6b0@t35g2000yqj.googlegroups.com> <2349f7d4-2b85-456f-96b5-140f15548859@v17g2000prc.googlegroups.com> <1e7f6338-33ff-488e-9182-b31498babe0b@c39g2000yqi.googlegroups.com> <429e3e67-9732-4f82-9f97-99ed5aeb1f74@r8g2000prm.googlegroups.com> Message-ID: <451b9057-609a-4b1d-a064-62e738267084@e4g2000vbg.googlegroups.com> > If you can tell us why it's so important that the object be destroyed > at that given time, even while a reference to it exists, maybe we can > give you better suggestions. Thanks for your answer! In my case the types A and B (in my example above) are a dialog and a dialog widget. At a special time I have to close and destroy all dialogs but this does not happen because the widget keeps the dialog alive. I have the reference to the dialog but after I closed the dialogs I also would like to destroy them because they have to free some special ressources. Thanks a lot!! Bye, moerchendiser2k3 From pavlovevidence at gmail.com Mon Jan 10 13:01:06 2011 From: pavlovevidence at gmail.com (Carl Banks) Date: Mon, 10 Jan 2011 10:01:06 -0800 (PST) Subject: os.system and loggers References: <70ac3463-cf3c-4435-909b-ac044bef7e41@z9g2000yqz.googlegroups.com> <285801ef-7e26-4c40-a307-3c6eb5314b82@z17g2000prz.googlegroups.com> Message-ID: On Jan 10, 8:29?am, Tim wrote: > On Jan 7, 11:24?am, Tim wrote: > > > > > > > hi, I'm using a 3rd-party python program that uses the python logging > > facility and also makes calls to os.system. I'm trying to capture its > > output to a file. > > > In my own code, I've taken control of the loggers that are setup in > > the other program by removing its StreamHandler and replacing with > > FileHander. But when it comes to the call to os.system I'm at a loss. > > > I want to capture the stdout from that os.system call in my > > FileHandler. I thought this might work, before I call the other > > program's class/method: > > sys.stdout = getLogger('status').handlers[0].stream > > > but no dice. Is there any clean way to get what I want? If not, I > > guess I'll override the other method with my own, but it will > > basically be a bunch of code copied with os.sytem replaced with > > subprocess, using getLogger('status').handlers[0].stream for stdout/ > > stderr. > > > thanks, > > --Tim Arnold > > Replying to my own post.... > > I think I may have included too much fluff in my original question. > The main thing I wonder is whether I can attach a log handler to > stdout in such a way that os.system calls will write to that handler > instead of the console. No, but you could replace os.system with something that does work. (It would replace it globally for all uses, so you may need some logic to decide whether to leave the call alone, or to modify it, perhaps by inspecting the call stack.) The simplest thing to do is to append a shell redirection to the command (>/your/log/file), so something like this: _real_os_system = os.system def my_os_system(cmd): if test_log_condition: return _real_os_system(cmd + "2> /my/log/file") return _real_os_system(cmd) os.system = my_os_system That could backfire for any number of reasons so you probably should only do this if you know that it works with all the commands it issues. The better way might be to call the subprocess module instead, where you can dispatch the command with redirection to any stream. I doubt there's a foolproof way to do that given an arbitrary os.system command, but the subprocess way is probably safer. Carl Banks From pavlovevidence at gmail.com Mon Jan 10 13:03:57 2011 From: pavlovevidence at gmail.com (Carl Banks) Date: Mon, 10 Jan 2011 10:03:57 -0800 (PST) Subject: os.system and loggers References: <70ac3463-cf3c-4435-909b-ac044bef7e41@z9g2000yqz.googlegroups.com> <285801ef-7e26-4c40-a307-3c6eb5314b82@z17g2000prz.googlegroups.com> Message-ID: On Jan 10, 8:29?am, Tim wrote: > I think I may have included too much fluff in my original question. > The main thing I wonder is whether I can attach a log handler to > stdout in such a way that os.system calls will write to that handler > instead of the console. From stefan_ml at behnel.de Mon Jan 10 13:18:02 2011 From: stefan_ml at behnel.de (Stefan Behnel) Date: Mon, 10 Jan 2011 19:18:02 +0100 Subject: Resolve circular reference In-Reply-To: <451b9057-609a-4b1d-a064-62e738267084@e4g2000vbg.googlegroups.com> References: <1718ea91-fc4e-49f3-a15a-bdc683789126@k22g2000yqh.googlegroups.com> <353ecd61-22f8-4770-be30-29cb76b0f6b0@t35g2000yqj.googlegroups.com> <2349f7d4-2b85-456f-96b5-140f15548859@v17g2000prc.googlegroups.com> <1e7f6338-33ff-488e-9182-b31498babe0b@c39g2000yqi.googlegroups.com> <429e3e67-9732-4f82-9f97-99ed5aeb1f74@r8g2000prm.googlegroups.com> <451b9057-609a-4b1d-a064-62e738267084@e4g2000vbg.googlegroups.com> Message-ID: moerchendiser2k3, 10.01.2011 18:55: >> If you can tell us why it's so important that the object be destroyed >> at that given time, even while a reference to it exists, maybe we can >> give you better suggestions. > > Thanks for your answer! In my case the types A and B (in my example > above) > are a dialog and a dialog widget. At a special time I have to close > and > destroy all dialogs but this does not happen because the widget keeps > the dialog alive. I have the reference to the dialog > but after I closed the dialogs I also would like to destroy them > because they have to free some special ressources. Objects within a reference cycle will eventually get cleaned up, just not right away and not in a predictable order. If you need immediate cleanup, you should destroy the reference cycle yourself, e.g. by removing the widgets from the dialog when closing it. Stefan From awilliam at whitemice.org Mon Jan 10 13:40:54 2011 From: awilliam at whitemice.org (Adam Tauno Williams) Date: Mon, 10 Jan 2011 13:40:54 -0500 Subject: Print to an IPP printer (pkipplib?) In-Reply-To: <4D2B43DD.4040101@gmail.com> References: <1287247744.11414.0.camel@linux-yu4c.site> <4D2B43DD.4040101@gmail.com> Message-ID: <1294684854.16499.3.camel@linux-yu4c.site> On Mon, 2011-01-10 at 10:37 -0700, Michael Torrie wrote: > On 10/16/2010 10:49 AM, Adam Tauno Williams wrote: > > I've found the module pkipplib which seems to work well for things like > > interrogating an IPP (CUPS) server. But is there a way to send a print > > job to an IPP print queue? [and no, the local system knows nothing about > > the print architecture so popen....lp is not an option]. I just want to > > send the data from a file handle to a remote IPP queue as a print job. > I wonder if you could post the print job directly to the IPP url. It's > really just HTTP under the hood. Correct; I've been meaning to try that but haven't gotten back to it on my to-do list. First I have to make a text stream into a PDF, so I have something to send. Surprisingly I've been able to find no code to steal which does that; which means it will take longer. :( [clumsily thunking out to commands like "a2ps", etc... is strictly forbidden in this code-base; and that seems how a lot of people seem to hand it]. From emile at fenx.com Mon Jan 10 13:49:10 2011 From: emile at fenx.com (Emile van Sebille) Date: Mon, 10 Jan 2011 10:49:10 -0800 Subject: Print to an IPP printer (pkipplib?) In-Reply-To: <1294684854.16499.3.camel@linux-yu4c.site> References: <1287247744.11414.0.camel@linux-yu4c.site> <4D2B43DD.4040101@gmail.com> <1294684854.16499.3.camel@linux-yu4c.site> Message-ID: On 1/10/2011 10:40 AM Adam Tauno Williams said... > First I have to make a text stream into a PDF, so I have something to > send. Surprisingly I've been able to find no code to steal which does > that; which means it will take longer. :( reportlab? [clumsily thunking out to > commands like "a2ps", etc... is strictly forbidden in this code-base; > and that seems how a lot of people seem to hand it]. > From awilliam at whitemice.org Mon Jan 10 13:58:42 2011 From: awilliam at whitemice.org (Adam Tauno Williams) Date: Mon, 10 Jan 2011 13:58:42 -0500 Subject: Print to an IPP printer (pkipplib?) In-Reply-To: References: <1287247744.11414.0.camel@linux-yu4c.site> <4D2B43DD.4040101@gmail.com> <1294684854.16499.3.camel@linux-yu4c.site> Message-ID: <1294685922.16499.6.camel@linux-yu4c.site> On Mon, 2011-01-10 at 10:49 -0800, Emile van Sebille wrote: > On 1/10/2011 10:40 AM Adam Tauno Williams said... > > First I have to make a text stream into a PDF, so I have something to > > send. Surprisingly I've been able to find no code to steal which does > > that; which means it will take longer. :( > reportlab? Possibly, there is that an pyPdf. I've found recently, but haven't had time to take it apart yet [and the license looks OK, other code snippets I've found were explicitly GPL so I couldn't look at those]. > [clumsily thunking out to > > commands like "a2ps", etc... is strictly forbidden in this code-base; > > and that seems how a lot of people seem to hand it]. From stefan at bytereef.org Mon Jan 10 14:01:55 2011 From: stefan at bytereef.org (Stefan Krah) Date: Mon, 10 Jan 2011 20:01:55 +0100 Subject: [ANN] cdecimal-2.2 released Message-ID: <20110110190155.GA17474@yoda.bytereef.org> Hi, I'm pleased to announce the release of cdecimal-2.2. cdecimal is a fast drop-in replacement for the decimal module in Python's standard library. Blurb ===== cdecimal is a complete implementation of IBM's General Decimal Arithmetic Specification. With the appropriate context parameters, cdecimal will also conform to the IEEE 754-2008 Standard for Floating-Point Arithmetic. Typical performance gains over decimal.py are between 30x for I/O heavy benchmarks and 80x for numerical programs. In a PostgreSQL database benchmark, the speedup is 12x. +---------+-------------+--------------+-------------+ | | decimal | cdecimal | speedup | +=========+=============+==============+=============+ | pi | 42.75s | 0.58s | 74x | +---------+-------------+--------------+-------------+ | telco | 172.19s | 5.68s | 30x | +---------+-------------+--------------+-------------+ | psycopg | 3.57s | 0.29s | 12x | +---------+-------------+--------------+-------------+ In the pi benchmark, cdecimal often performs better than Java's BigDecimal running on Java HotSpot(TM) 64-Bit Server VM. Both cdecimal and the underlying library - libmpdec - have very large test suites. libmpdec has 100% code coverage, cdecimal 85%. The test suites have been running continuously for over a year without any major issues. Install ======= Since cdecimal is now listed on PyPI, it can be installed using pip: pip install cdecimal Windows installers are available at: http://www.bytereef.org/mpdecimal/download.html Links ===== http://www.bytereef.org/mpdecimal/index.html http://www.bytereef.org/mpdecimal/changelog.html http://www.bytereef.org/mpdecimal/download.html Checksums of the released packages ================================== sha256sum --------- 3d92429fab74ddb17d12feec9cd949cd8a0be4bc0ba9afc5ed9b3af884e5d406 mpdecimal-2.2.tar.gz e8f02731d4089d7c2b79513d01493c36ef41574423ea3e49b245b86640212bdc mpdecimal-2.2.zip 515625c5c5830b109c57af93d49ae2c57ec3f230d46a3e0583840ff73d7963be cdecimal-2.2.tar.gz sha1sum ------- 24695b2c9254e1b870eb663e3d966eb4f0abd5ab cdecimal-2.2.win32-py2.6.msi e74cb7e722f30265b408b322d2c50d9a18f78587 cdecimal-2.2.win32-py2.7.msi 7c39243b2fc8b1923ad6a6066536982844a7617f cdecimal-2.2.win32-py3.1.msi 5711fd69a8e1e2e7be0ad0e6b93ecc10aa584c68 cdecimal-2.2.win-amd64-py2.6.msi b1cd7b6a373c212bf2f6aa288cd767171bfefd41 cdecimal-2.2.win-amd64-py2.7.msi f08a803a1a42a2d8507da1dc49f3bf7eed37c332 cdecimal-2.2.win-amd64-py3.1.msi cb29fa8f67befaf2d1a05f4675f840d7cd35cf6c cdecimal-2.2-no-thread.win32-py2.6.msi 012a44488f2ce2912f903ae9faf995efc7c9324b cdecimal-2.2-no-thread.win32-py2.7.msi 1c08c73643fc45d7b0feb62c33bebd76537f9d02 cdecimal-2.2-no-thread.win32-py3.1.msi b6dbd92e86ced38506ea1a6ab46f2e41f1444eae cdecimal-2.2-no-thread.win-amd64-py2.6.msi b239b41e6958d9e71e91b122183dc0eaefa00fef cdecimal-2.2-no-thread.win-amd64-py2.7.msi 413724ff20ede7b648f57dd9a78a12e72e064583 cdecimal-2.2-no-thread.win-amd64-py3.1.msi Stefan Krah From opentracker124 at googlemail.com Mon Jan 10 15:25:35 2011 From: opentracker124 at googlemail.com (http://groups.google.com/group/de.comp.os.os2.apps/post) Date: Mon, 10 Jan 2011 12:25:35 -0800 (PST) Subject: arbeitsamt jobs ausland , stellenangebot in ausland , Berufskraftfahrer Berufskraftfahrerin , Maler Malerin , stellenanzeigen jobboerse , arbeitsvermittlung , Meteorologe Meteorologin , jobs und praktika im ausland 2007 , Innenarchitekt Innenarchi Message-ID: <9bc81066-8f36-4caf-ac88-df3eab511ad8@d7g2000vbv.googlegroups.com> arbeitsamt jobs ausland , stellenangebot in ausland , Berufskraftfahrer Berufskraftfahrerin , Maler Malerin , stellenanzeigen jobboerse , arbeitsvermittlung , Meteorologe Meteorologin , jobs und praktika im ausland 2007 , Innenarchitekt Innenarchitektin , + + + +++ TOPJOB AUSLAND +++ IM AUSLAND ARBEITEN +++ + + http://WWW.AUSLANDS-JOB.ORG http://WWW.AUSLANDS-JOB.ORG http://WWW.AUSLANDS-JOB.ORG http://WWW.AUSLANDS-JOB.ORG http://WWW.AUSLANDS-JOB.ORG http://WWW.AUSLANDS-JOB.ORG + + + + + + + + ehrenamtlich arbeiten im ausland Polizeivollzugsbeamte Polizeivollzugsbeamter Mediengestalter Bild und Ton www ausland jobs stellenangebote fuers ausland ausland jobs de jobboerse angebote stellenanzeigen ausland au?endienstmitarbeiter jobs im ausland australien jobboersen ausland berufe ausland Maurer Maurerin arbeiten im ausland steuern Tieraerztin Tierarzt auswandern jobs im ausland praktikum im ausland Event-Manager Event-Managerin Industriemechaniker Industriemechanikerin jobsuche jobboerse Restaurantfachfrau Restaurantfachmann Journalist Journalistin will im ausland arbeiten jobangebote ausland jobboerse arbeitgeber Personalreferent Personalreferentin jobboerse bayern Kauffrau audiovisuelle Medien www arbeiten im ausland Hebamme From drsalists at gmail.com Mon Jan 10 15:29:09 2011 From: drsalists at gmail.com (Dan Stromberg) Date: Mon, 10 Jan 2011 12:29:09 -0800 Subject: Python use growing fast Message-ID: I invite folks to check out Tiobe's Language Popularity Rankings: http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html The gist is: Python grew faster than any other programming language over the last year, according to this (slightly arbitrary, but better than no indicator) ranking. ...despite our wikipedia page whose first paragraph almost seems like it was written with the intention of scaring off new converts, with its "unusual" comment: http://en.wikipedia.org/wiki/Python_%28programming_language%29 (Like it or not, people do frequently confuse the descriptive for the normative) From python at mrabarnett.plus.com Mon Jan 10 16:02:09 2011 From: python at mrabarnett.plus.com (MRAB) Date: Mon, 10 Jan 2011 21:02:09 +0000 Subject: Python use growing fast In-Reply-To: References: Message-ID: <4D2B73D1.6060303@mrabarnett.plus.com> On 10/01/2011 20:29, Dan Stromberg wrote: > I invite folks to check out Tiobe's Language Popularity Rankings: > > http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html > > The gist is: Python grew faster than any other programming language > over the last year, according to this (slightly arbitrary, but better > than no indicator) ranking. > > ...despite our wikipedia page whose first paragraph almost seems like > it was written with the intention of scaring off new converts, with > its "unusual" comment: > > http://en.wikipedia.org/wiki/Python_%28programming_language%29 > > (Like it or not, people do frequently confuse the descriptive for the normative) It shows an example of Python code, which happens to have 2 syntax errors! From googler.1.webmaster at spamgourmet.com Mon Jan 10 16:19:25 2011 From: googler.1.webmaster at spamgourmet.com (moerchendiser2k3) Date: Mon, 10 Jan 2011 13:19:25 -0800 (PST) Subject: Resolve circular reference References: <1718ea91-fc4e-49f3-a15a-bdc683789126@k22g2000yqh.googlegroups.com> <353ecd61-22f8-4770-be30-29cb76b0f6b0@t35g2000yqj.googlegroups.com> <2349f7d4-2b85-456f-96b5-140f15548859@v17g2000prc.googlegroups.com> <1e7f6338-33ff-488e-9182-b31498babe0b@c39g2000yqi.googlegroups.com> <429e3e67-9732-4f82-9f97-99ed5aeb1f74@r8g2000prm.googlegroups.com> <451b9057-609a-4b1d-a064-62e738267084@e4g2000vbg.googlegroups.com> Message-ID: <55db55e9-539a-4f36-a84f-5199500cd909@k30g2000vbn.googlegroups.com> On Jan 10, 7:18?pm, Stefan Behnel wrote: > moerchendiser2k3, 10.01.2011 18:55: > > >> If you can tell us why it's so important that the object be destroyed > >> at that given time, even while a reference to it exists, maybe we can > >> give you better suggestions. > > > Thanks for your answer! In my case the types A and B (in my example > > above) > > are a dialog and a dialog widget. At a special time I have to close > > and > > destroy all dialogs but this does not happen because the widget keeps > > the dialog alive. I have the reference to the dialog > > but after I closed the dialogs I also would like to destroy them > > because they have to free some special ressources. > > Objects within a reference cycle will eventually get cleaned up, just not > right away and not in a predictable order. > > If you need immediate cleanup, you should destroy the reference cycle > yourself, e.g. by removing the widgets from the dialog when closing it. > > Stefan The PyWidget type does not own the widget, it just points to it. I have an idea, would this fix the problem? I destroy the internal dictionary of the dialog which points to other PyObjects? Then I would cut the dependency. From alice at gothcandy.com Mon Jan 10 16:43:23 2011 From: alice at gothcandy.com (=?utf-8?Q?Alice_Bevan=E2=80=93McGregor?=) Date: Mon, 10 Jan 2011 13:43:23 -0800 Subject: Python use growing fast References: <4D2B73D1.6060303@mrabarnett.plus.com> Message-ID: On 2011-01-10 13:02:09 -0800, MRAB said: > On 10/01/2011 20:29, Dan Stromberg wrote: >> ...despite our wikipedia page whose first paragraph almost seems like >> it was written with the intention of scaring off new converts, with its >> "unusual" comment... Indentation as a syntatitical structure is not actually unusual in any way as was recently discussed in another thread (having difficulty finding it). > It shows an example of Python code, which happens to have 2 syntax errors! Wikipedia is a Wiki; everyone is free to contribute and correct mistakes. - Alice. From krzysztof.t.bieniasz at gmail.com Mon Jan 10 16:56:13 2011 From: krzysztof.t.bieniasz at gmail.com (Krzysztof Bieniasz) Date: Mon, 10 Jan 2011 21:56:13 +0000 (UTC) Subject: Python use growing fast References: Message-ID: > I invite folks to check out Tiobe's Language Popularity Rankings: > > http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html > > The gist is: Python grew faster than any other programming language over > the last year, according to this (slightly arbitrary, but better than no > indicator) ranking. And look at the Hall of Fame. Python is the first language to win the popularity award twice. Although the statistical population isn't really extensive... From nagle at animats.com Mon Jan 10 17:29:32 2011 From: nagle at animats.com (John Nagle) Date: Mon, 10 Jan 2011 14:29:32 -0800 Subject: Python use growing fast In-Reply-To: References: Message-ID: <4d2b8844$0$43996$742ec2ed@news.sonic.net> On 1/10/2011 1:02 PM, MRAB wrote: > On 10/01/2011 20:29, Dan Stromberg wrote: >> I invite folks to check out Tiobe's Language Popularity Rankings: >> >> http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html That's somehow derived from web searches, not from any real data source. Look how far down JavaScript is. John Nagle From Philippe.vouters at laposte.net Mon Jan 10 17:33:01 2011 From: Philippe.vouters at laposte.net (A famous IT technical writer) Date: Mon, 10 Jan 2011 14:33:01 -0800 (PST) Subject: Compiling and Executing a Python byte coded program Message-ID: <446c01a1-b2c2-467a-a54b-853db80443b5@f2g2000vby.googlegroups.com> If interested with, have a look to http://vouters.dyndns.org/tima/All-OS-Python-Compiling_a_Python_Program_and_Executing_the_compiled_version.html Note you may boost your Python's startup time but not the execution speed of your program which depends on the generated byte code. From passionate_programmer at hotmail.com Mon Jan 10 17:37:35 2011 From: passionate_programmer at hotmail.com (Rohit Coder) Date: Tue, 11 Jan 2011 04:07:35 +0530 Subject: Centering a window Message-ID: I am using PyQt4 for GUI apps. I created a class that contains a function to center any window (Form) whose name is passed to this class. I have two questions: How to modify the below given code to center the window whose name we passed as an argument.How to pass window name to this class from another file that imports this class? ============= CODE BLOCK STARTS HERE ===========from PyQt4 import QtGui class PositionWindow: def __init__(self, xCoord, yCoord, windowName, parent = None): self.x = xCoord self.y = yCoord self.wName = windowName; def center(self): screen = QtGui.QDesktopWidget().screenGeometry() size = self.geometry() self.move((screen.width()-size.width())/2, (screen.height()-size.height())/2)============= CODE BLOCK ENDS HERE =========== ................Rohit K.elementFontfont-familyfont-sizefont-stylefont-variantfont-weightletter-spacingline-heighttext-decorationtext-aligntext-indenttext-transformwhite-spaceword-spacingcolorBackgroundbg-attachmentbg-colorbg-imagebg-positionbg-repeatBoxwidthheightborder-topborder-rightborder-bottomborder-leftmarginpaddingmax-heightmin-heightmax-widthmin-widthoutline-coloroutline-styleoutline-widthPositioningpositiontopbottomrightleftfloatdisplayclearz-indexListlist-style-imagelist-style-typelist-style-positionTablevertical-alignborder-collapseborder-spacingcaption-sideempty-cellstable-layoutEffectstext-shadow-webkit-box-shadowborder-radiusOtheroverflowcursorvisibility -------------- next part -------------- An HTML attachment was scrubbed... URL: From shankarphy at gmail.com Mon Jan 10 17:44:35 2011 From: shankarphy at gmail.com (SANKAR .) Date: Tue, 11 Jan 2011 09:44:35 +1100 Subject: String to char and decimal number conversion Message-ID: Hello There, I am from non IT field also new to python programming.Could you please help me to solve the following problem? I have a list T1 with following format: T1 = [ *' "*Field*" **' , ' "*12.5*" **', ' "*2.5*" ']* * * How do get the list elements without double quote in my output (T2). T2 =[ *' *Field* **' , ' *12.5 *', ' *2.5* ']* Thanks Sankar -------------- next part -------------- An HTML attachment was scrubbed... URL: From ben+python at benfinney.id.au Mon Jan 10 18:00:28 2011 From: ben+python at benfinney.id.au (Ben Finney) Date: Tue, 11 Jan 2011 10:00:28 +1100 Subject: Absolute imports? References: <877heff4fl.fsf@benfinney.id.au> Message-ID: <87y66se54j.fsf@benfinney.id.au> Roy Smith writes: > Ben Finney wrote: > > What is the problem you're trying to solve? It is likely we can > > suggest a better solution. > > Well, the problem I'm trying to solve is that I have an absolute > pathname to a python source file that I want to import as a module :-) And then have it available in the code under what name? It is important to realise that ?import? does many things. Among the many things it does (see the Python documentation for more) it executes the code within a namespace, and then binds that namespace to a name that is specified in the ?import? statement. The filesystem path (if any!) is derived from the name that the module will be bound to within the code. That'w why the indirection of ?sys.path? is necessary: it keeps the mapping between module names and filesystem paths. > The best I can describe how to find the location of the config file is, > "Work your way up the directory tree from where you are now, (i.e. > following '..' links) until you get to the top level of the project, > then from there, it's ./code/configs/autogen/config.py." One way to keep the import mechanism working with that situation would be to: * compute the path: ?config_dir_path = your_algorithm_above()? * add the path to the search list: ?sys.path.append(config_dir_path)? * import the config module: ?import config? The module is then available under the name ?config?. > It's reasonably straight-forward to figure out that absolute path, > starting from sys.argv[0] and using the tools in os.path. Now I need > to import the file, given that I know its absolute pathname. It looks > like imp.load_source() does what I want, I'm just wondering if there's > a cleaner way. I think ?imp.load_source? is not as clean as the steps I describe above, given the rest of the ?import? job that needs to be done. Given that modules in Python form a namespace hierarchy, it's unusual and discouraged to import files from arbitrary parts of the filesystem. -- \ ?I must say that I find television very educational. The minute | `\ somebody turns it on, I go to the library and read a book.? | _o__) ?Groucho Marx | Ben Finney From clp2 at rebertia.com Mon Jan 10 18:02:15 2011 From: clp2 at rebertia.com (Chris Rebert) Date: Mon, 10 Jan 2011 15:02:15 -0800 Subject: String to char and decimal number conversion In-Reply-To: References: Message-ID: On Mon, Jan 10, 2011 at 2:44 PM, SANKAR . wrote: > Hello There, > > ?????? I am from non IT field also new to python programming.Could you > please help me to solve the following problem? > > I have a list T1 with following format: > > T1 = [ ' "Field" ' , ' "12.5" ', ' "2.5" '] > > How do get the list elements without double quote in my output (T2). > > T2 =[ ' Field ' , ' 12.5 ', ' 2.5 '] How are you obtaining T1 in the first place? Cheers, Chris -- http://blog.rebertia.com From clp2 at rebertia.com Mon Jan 10 18:04:01 2011 From: clp2 at rebertia.com (Chris Rebert) Date: Mon, 10 Jan 2011 15:04:01 -0800 Subject: Python use growing fast In-Reply-To: <4d2b8844$0$43996$742ec2ed@news.sonic.net> References: <4d2b8844$0$43996$742ec2ed@news.sonic.net> Message-ID: On Mon, Jan 10, 2011 at 2:29 PM, John Nagle wrote: > On 1/10/2011 1:02 PM, MRAB wrote: >> >> On 10/01/2011 20:29, Dan Stromberg wrote: >>> >>> I invite folks to check out Tiobe's Language Popularity Rankings: >>> >>> http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html > > ? That's somehow derived from web searches, not from any real data > source. ?Look how far down JavaScript is. Also depends on how one defines "popularity" in the context of programming languages. Cheers, Chris From ben+python at benfinney.id.au Mon Jan 10 18:05:16 2011 From: ben+python at benfinney.id.au (Ben Finney) Date: Tue, 11 Jan 2011 10:05:16 +1100 Subject: What INI config file module allows lists of duplicate same-named options? References: <4D29DEF5.2030702@ianhobson.co.uk> <4D2A124A.9000508@ieee.org> <4D2A16D3.4070405@gmail.com> <4D2A1ECA.2090901@aim.com> Message-ID: <87tyhge4wj.fsf@benfinney.id.au> "Thomas L. Shinnick" writes: > Here, I need to list multiple file/dir path pairs. A list of multiple > items to be acted upon in a common way. It is a list. Simple. > Except I can't find a library/pypi module with the obvious extension. What you want is incompatible with calling the result ?an INI file?, because that entails the restrictions you described. You would be better advised to use a configuration format that can do what you want, such as YAML or JSON. Both of those have good Python support; JSON in particular has support in the standard library. -- \ ?Saying that Java is nice because it works on all OSes is like | `\ saying that anal sex is nice because it works on all genders? | _o__) ?http://bash.org/ | Ben Finney From philip at semanchuk.com Mon Jan 10 18:28:29 2011 From: philip at semanchuk.com (Philip Semanchuk) Date: Mon, 10 Jan 2011 18:28:29 -0500 Subject: What INI config file module allows lists of duplicate same-named options? In-Reply-To: <87tyhge4wj.fsf@benfinney.id.au> References: <4D29DEF5.2030702@ianhobson.co.uk> <4D2A124A.9000508@ieee.org> <4D2A16D3.4070405@gmail.com> <4D2A1ECA.2090901@aim.com> <87tyhge4wj.fsf@benfinney.id.au> Message-ID: On Jan 10, 2011, at 6:05 PM, Ben Finney wrote: > "Thomas L. Shinnick" writes: > >> Here, I need to list multiple file/dir path pairs. A list of multiple >> items to be acted upon in a common way. It is a list. Simple. >> Except I can't find a library/pypi module with the obvious extension. > > What you want is incompatible with calling the result ?an INI file?, > because that entails the restrictions you described. I dunno about that. The INI file format isn't standardized so there aren't restrictions on what one can expect to find in an INI file other than people's expectations. I'll grant you that most INI files don't have (or expect) duplicate keys in a section, but I've seen some that do. > You would be better advised to use a configuration format that can do > what you want, such as YAML or JSON. Both of those have good Python > support; JSON in particular has support in the standard library. I second that, and the point above (about there being no standard that governs INI files) is another reason to avoid them. Some INI file libraries expect a hash mark as a comment, some expect semicolon, some make no allowances for non-ASCII encodings, some expect UTF-8 or ISO-8859-1 or Win-1252, some only allow '=' as the key/value separator, some allow other characters. INI files are nice and simple but there's devils in those details. Cheers Philip From ben+python at benfinney.id.au Mon Jan 10 18:40:27 2011 From: ben+python at benfinney.id.au (Ben Finney) Date: Tue, 11 Jan 2011 10:40:27 +1100 Subject: Absolute imports? References: <877heff4fl.fsf@benfinney.id.au> <87y66se54j.fsf@benfinney.id.au> Message-ID: <87pqs4e39w.fsf@benfinney.id.au> Ben Finney writes: > The filesystem path (if any!) is derived from the name that the module > will be bound to within the code. That'w why the indirection of > ?sys.path? is necessary: it keeps the mapping between module names and > filesystem paths. That phrasing gives the wrong impression; ?sys.path? doesn't store that mapping. I meant only that the indirection of ?sys.path? is necessary to allow Python to maintain that mapping at import time. -- \ ?This world in arms is not spending money alone. It is spending | `\ the sweat of its laborers, the genius of its scientists, the | _o__) hopes of its children.? ?Dwight Eisenhower, 1953-04-16 | Ben Finney From shankarphy at gmail.com Mon Jan 10 19:00:10 2011 From: shankarphy at gmail.com (SANKAR .) Date: Tue, 11 Jan 2011 11:00:10 +1100 Subject: String to char and decimal number conversion In-Reply-To: References: Message-ID: Hi Chris , Thanks for your response. I am reading a Test.txt (see atatchment) file using following code to get the T2: F =open('C:\Test.txt','r') T1 = F.readlines() for i in range(len(T1)): T2 = T1[i].split(',') print(T2) Regards Sankar On Tue, Jan 11, 2011 at 10:02 AM, Chris Rebert wrote: > On Mon, Jan 10, 2011 at 2:44 PM, SANKAR . wrote: > > Hello There, > > > > I am from non IT field also new to python programming.Could you > > please help me to solve the following problem? > > > > I have a list T1 with following format: > > > > T1 = [ ' "Field" ' , ' "12.5" ', ' "2.5" '] > > > > How do get the list elements without double quote in my output (T2). > > > > T2 =[ ' Field ' , ' 12.5 ', ' 2.5 '] > > How are you obtaining T1 in the first place? > > Cheers, > Chris > -- > http://blog.rebertia.com > -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: Test.txt URL: From drsalists at gmail.com Mon Jan 10 19:51:17 2011 From: drsalists at gmail.com (Dan Stromberg) Date: Mon, 10 Jan 2011 16:51:17 -0800 Subject: Python use growing fast In-Reply-To: <4d2b8844$0$43996$742ec2ed@news.sonic.net> References: <4d2b8844$0$43996$742ec2ed@news.sonic.net> Message-ID: On Mon, Jan 10, 2011 at 2:29 PM, John Nagle wrote: > On 1/10/2011 1:02 PM, MRAB wrote: >> >> On 10/01/2011 20:29, Dan Stromberg wrote: >>> >>> I invite folks to check out Tiobe's Language Popularity Rankings: >>> >>> http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html > > ? That's somehow derived from web searches, not from any real data > source. ?Look how far down JavaScript is. Please define "real data source", and give examples... ^_^ From tjreedy at udel.edu Mon Jan 10 19:52:01 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Mon, 10 Jan 2011 19:52:01 -0500 Subject: Python use growing fast In-Reply-To: References: <4D2B73D1.6060303@mrabarnett.plus.com> Message-ID: On 1/10/2011 4:43 PM, Alice Bevan?McGregor wrote: > >> It shows an example of Python code, which happens to have 2 syntax >> errors! > > Wikipedia is a Wiki; everyone is free to contribute and correct mistakes. The errors, if there, are in .png and .svg images of a random, unrunnable snippet that will disappear in a week (at least the .png) due to lack of copyright release. A complete example that runs, pulled from the tutorial, would be good. I have no idea how to produce those types of images from code. -- Terry Jan Reedy From linnaweb at gmail.com Mon Jan 10 20:19:10 2011 From: linnaweb at gmail.com (linna li) Date: Mon, 10 Jan 2011 17:19:10 -0800 (PST) Subject: apscheduler error References: <9699865b-a8be-4284-a347-58d875b491f6@n2g2000pre.googlegroups.com> Message-ID: Thank you for all the replies here! I will try your suggestions. On Jan 7, 11:03?pm, Alice Bevan?McGregor wrote: > Howdy! > > On 2011-01-07 17:08:28 -0800, linna li said: > > > I tried to use the apscheduler and used the sample code below from the > > tutorial, but got the error message: Exception in thread APScheduler > > (most likely raised during interpreter shutdown). What's going on here? > > I really appreciate any help! > > After talking a bit with Alex Gr?nholm it seems this is an issue raised > fairly often (not always in the context of this package) and is not > really a problem with APScheduler. ?It has far more to do with > attempting to start a thread, then immediately exiting the main thread. > ?That's not how threading is supposed to be used, so don't do it. ?;) > > APScheduler 2.0 adds some improved examples, according to Alex, that > don't suffer the "problem" demonstrated by the short code snippit you > provided. > > A package of mine, TurboMail, suffers from the same threading issue if > used improperly; you enqueue e-mail, it starts a thread, then you > immediately exit. ?TM tries to work around the issue, but in most cases > that workaround does not work properly. ?(You get strange uncatchable > exceptions printed on stderr though AFIK the e-mail does get sent > correctly, your application may hang waiting for the thread pool to > drain if you have a "minimum thread count" option set.) > > I hope this clears things up a bit, > > ? ? ? ? - Alice. From krzysztof.t.bieniasz at gmail.com Mon Jan 10 20:22:54 2011 From: krzysztof.t.bieniasz at gmail.com (Krzysztof Bieniasz) Date: Tue, 11 Jan 2011 01:22:54 +0000 (UTC) Subject: Python use growing fast References: <4d2b8844$0$43996$742ec2ed@news.sonic.net> Message-ID: > Also depends on how one defines "popularity" in the context of > programming languages. Tiobe quite clearly states what they mean by the name "popularity". Namely the number of Google search results of expressions like "programming X" for X in languages. If no one in the Web writes about programming JavaScript then obviously it's not popular... sort of. From linnaweb at gmail.com Mon Jan 10 20:23:34 2011 From: linnaweb at gmail.com (linna li) Date: Mon, 10 Jan 2011 17:23:34 -0800 (PST) Subject: apscheduler error References: <9699865b-a8be-4284-a347-58d875b491f6@n2g2000pre.googlegroups.com> Message-ID: <8d45d736-8b89-41f0-96d7-66c3c077b670@22g2000prx.googlegroups.com> On Jan 7, 11:03?pm, Alice Bevan?McGregor wrote: > Howdy! > > On 2011-01-07 17:08:28 -0800, linna li said: > > > I tried to use the apscheduler and used the sample code below from the > > tutorial, but got the error message: Exception in thread APScheduler > > (most likely raised during interpreter shutdown). What's going on here? > > I really appreciate any help! > > After talking a bit with Alex Gr?nholm it seems this is an issue raised > fairly often (not always in the context of this package) and is not > really a problem with APScheduler. ?It has far more to do with > attempting to start a thread, then immediately exiting the main thread. > ?That's not how threading is supposed to be used, so don't do it. ?;) > > APScheduler 2.0 adds some improved examples, according to Alex, that > don't suffer the "problem" demonstrated by the short code snippit you > provided. > > A package of mine, TurboMail, suffers from the same threading issue if > used improperly; you enqueue e-mail, it starts a thread, then you > immediately exit. ?TM tries to work around the issue, but in most cases > that workaround does not work properly. ?(You get strange uncatchable > exceptions printed on stderr though AFIK the e-mail does get sent > correctly, your application may hang waiting for the thread pool to > drain if you have a "minimum thread count" option set.) > > I hope this clears things up a bit, > > ? ? ? ? - Alice. I see the latest version is APScheduler 1.3.1. Where can I get APScheduler 2.0? From katie at coderstack.co.uk Mon Jan 10 20:31:15 2011 From: katie at coderstack.co.uk (Katie T) Date: Tue, 11 Jan 2011 01:31:15 +0000 Subject: Python use growing fast In-Reply-To: <4d2b8844$0$43996$742ec2ed@news.sonic.net> References: <4d2b8844$0$43996$742ec2ed@news.sonic.net> Message-ID: On Mon, Jan 10, 2011 at 10:29 PM, John Nagle wrote: > On 1/10/2011 1:02 PM, MRAB wrote: >> >> On 10/01/2011 20:29, Dan Stromberg wrote: >>> >>> I invite folks to check out Tiobe's Language Popularity Rankings: >>> >>> http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html > > ? That's somehow derived from web searches, not from any real data > source. ?Look how far down JavaScript is. Any measure is arbitrary and subject to biases, what methodology would you prefer ? Katie -- CoderStack http://www.coderstack.co.uk/python-jobs The Software Developer Job Board From greno at verizon.net Mon Jan 10 20:37:23 2011 From: greno at verizon.net (Gerry Reno) Date: Mon, 10 Jan 2011 20:37:23 -0500 Subject: Python use growing fast In-Reply-To: References: <4d2b8844$0$43996$742ec2ed@news.sonic.net> Message-ID: <4D2BB453.8030304@verizon.net> On 01/10/2011 08:31 PM, Katie T wrote: > On Mon, Jan 10, 2011 at 10:29 PM, John Nagle wrote: > >> On 1/10/2011 1:02 PM, MRAB wrote: >> >>> On 10/01/2011 20:29, Dan Stromberg wrote: >>> >>>> I invite folks to check out Tiobe's Language Popularity Rankings: >>>> >>>> http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html >>>> >> That's somehow derived from web searches, not from any real data >> source. Look how far down JavaScript is. >> > Any measure is arbitrary and subject to biases, what methodology would > you prefer ? > > > Katie > Measuring the "Buzz" about a language is actually a pretty good way to gauge its popularity. . From drsalists at gmail.com Mon Jan 10 22:24:44 2011 From: drsalists at gmail.com (Dan Stromberg) Date: Mon, 10 Jan 2011 19:24:44 -0800 Subject: Python use growing fast In-Reply-To: References: <4d2b8844$0$43996$742ec2ed@news.sonic.net> Message-ID: On Mon, Jan 10, 2011 at 5:22 PM, Krzysztof Bieniasz wrote: >> Also depends on how one defines "popularity" in the context of >> programming languages. > > Tiobe quite clearly states what they mean by the name "popularity". > Namely the number of Google search results of expressions like > "programming X" for X in languages. If no one in the Web writes about > programming JavaScript then obviously it's not popular... sort of. > -- > http://mail.python.org/mailman/listinfo/python-list > About JavaScript's popularity: 1) I've been getting the impression that JavaScript is popular in a manner similar to how x86 machine language is popular: That is, it's used all over, but few people hand code it (though admittedly, there are probably more people hand coding JavaScript than people hand coding x86 assembler today) 2) JavaScript seems widely considered a bit of a mess, and yet, many tools make use of it because it's in almost all web browsers 3) It seems that when JavaScript does get used directly, it tends to be done in small snippets, like inline assembler in C or C++ 4) It appears that there is quite a few different tools (one of them, our own Pyjamas, and to a lesser extent, Django - and of course GWT though that's only tenuously related to Python through Pyjamas) that attempt to take the pain out of writing JavaScript IOW, I'm not convinced that Tiobe's ranking of JavaScript is inaccurate, or even weakly correlated with reality. From kb1pkl at aim.com Mon Jan 10 22:28:25 2011 From: kb1pkl at aim.com (Corey Richardson) Date: Mon, 10 Jan 2011 22:28:25 -0500 Subject: Python use growing fast In-Reply-To: References: <4d2b8844$0$43996$742ec2ed@news.sonic.net> Message-ID: <4D2BCE59.2040204@aim.com> On 01/10/2011 10:24 PM, Dan Stromberg wrote: > On Mon, Jan 10, 2011 at 5:22 PM, Krzysztof Bieniasz > wrote: >>> Also depends on how one defines "popularity" in the context of >>> programming languages. >> >> Tiobe quite clearly states what they mean by the name "popularity". >> Namely the number of Google search results of expressions like >> "programming X" for X in languages. If no one in the Web writes about >> programming JavaScript then obviously it's not popular... sort of. >> -- >> http://mail.python.org/mailman/listinfo/python-list >> > > About JavaScript's popularity: > 1) I've been getting the impression that JavaScript is popular in a > manner similar to how x86 machine language is popular: That is, it's > used all over, but few people hand code it (though admittedly, there > are probably more people hand coding JavaScript than people hand > coding x86 assembler today) > 2) JavaScript seems widely considered a bit of a mess, and yet, many > tools make use of it because it's in almost all web browsers > 3) It seems that when JavaScript does get used directly, it tends to > be done in small snippets, like inline assembler in C or C++ > 4) It appears that there is quite a few different tools (one of them, > our own Pyjamas, and to a lesser extent, Django - and of course GWT > though that's only tenuously related to Python through Pyjamas) that > attempt to take the pain out of writing JavaScript > > IOW, I'm not convinced that Tiobe's ranking of JavaScript is > inaccurate, or even weakly correlated with reality. The biggest use of JavaScript I've seen is browser-based games using them for some display magic, windows popping up etc. Their back-end is still VB.NET (or x framework), and none of the lifting is done by JavaScript. From alice at gothcandy.com Mon Jan 10 22:46:33 2011 From: alice at gothcandy.com (=?utf-8?Q?Alice_Bevan=E2=80=93McGregor?=) Date: Mon, 10 Jan 2011 19:46:33 -0800 Subject: apscheduler error References: <9699865b-a8be-4284-a347-58d875b491f6@n2g2000pre.googlegroups.com> <8d45d736-8b89-41f0-96d7-66c3c077b670@22g2000prx.googlegroups.com> Message-ID: On 2011-01-10 17:23:34 -0800, linna li said: > I see the latest version is APScheduler 1.3.1. Where can I get APScheduler 2.0? https://bitbucket.org/agronholm/apscheduler/ I don't think 2.0 has been released yet, but that is the version number in apscheduler/__init__.py on HG tip. The examples, BTW, just add time.sleep() calls. ;) - Alice. From roy at panix.com Mon Jan 10 22:49:47 2011 From: roy at panix.com (Roy Smith) Date: Mon, 10 Jan 2011 22:49:47 -0500 Subject: Python use growing fast References: <4d2b8844$0$43996$742ec2ed@news.sonic.net> Message-ID: In article , Dan Stromberg wrote: > About JavaScript's popularity: > 1) I've been getting the impression that JavaScript is popular in a > manner similar to how x86 machine language is popular: That is, it's > used all over, but few people hand code it (though admittedly, there > are probably more people hand coding JavaScript than people hand > coding x86 assembler today) One of the surprising (to me, anyway) uses of JavaScript is as the scripting language for MongoDB (http://www.mongodb.org/). From ameyer2 at yahoo.com Mon Jan 10 22:50:55 2011 From: ameyer2 at yahoo.com (Alan Meyer) Date: Mon, 10 Jan 2011 22:50:55 -0500 Subject: String to char and decimal number conversion In-Reply-To: References: Message-ID: <4D2BD39F.9080802@yahoo.com> On 1/10/2011 6:02 PM, Chris Rebert wrote: > On Mon, Jan 10, 2011 at 2:44 PM, SANKAR . wrote: >> Hello There, >> >> I am from non IT field also new to python programming.Could you >> please help me to solve the following problem? >> >> I have a list T1 with following format: >> >> T1 = [ ' "Field" ' , ' "12.5" ', ' "2.5" '] >> >> How do get the list elements without double quote in my output (T2). >> >> T2 =[ ' Field ' , ' 12.5 ', ' 2.5 '] This will do it: ------------------------------------------------ T1 = [ ' "Field" ' , ' "12.5" ', ' "2.5" '] T2 = [] for t in T1: T2.append(t.replace('"', '')) ------------------------------------------------ The "replace" function acts on each element in T1, replacing every double quote with nothing. We then append that to the new list T2. Alan From wx1234 at gmail.com Mon Jan 10 23:42:17 2011 From: wx1234 at gmail.com (dubux) Date: Mon, 10 Jan 2011 20:42:17 -0800 (PST) Subject: importing modules dynamicly Message-ID: <3c6f5e1e-2f0a-46a3-a99e-8b3eb4fcb063@30g2000yql.googlegroups.com> I am trying to import modules dynamicly from a directory (modules/) in which i have __init__.py with the __all__ variable set. Everything imports correctly and I have verified this however I am stuck on actually using my classes in the dynamicly imported modules. this bit is in my main.py (or base script) to import the modules in the modules/ directory: loaded_modules = [] for item in modules: if item == '__init__.py': pass else: if item.endswith('.py'): __import__('modules.' + item[0:len(item) - 3]) loaded_modules.append(item[0:len(item) - 3]) else: pass After loading all the modules, i try to do something like: instance = modules.modulename.class() And I get an AttributeError. What am I doing wrong here? Help please!! From data.2 at rediff.com Tue Jan 11 00:07:10 2011 From: data.2 at rediff.com (gaurav) Date: Mon, 10 Jan 2011 21:07:10 -0800 (PST) Subject: You can get careers in Management work. Message-ID: <9a905ba5-12cc-4847-847f-5a64851f927a@e20g2000vbn.googlegroups.com> Great careers in Management work. Management careers bases. http://topcareer.webs.com/executivemanager.htm http://rojgars1.webs.com/gov.htm From sohail at stupidcomputing.com Tue Jan 11 00:18:41 2011 From: sohail at stupidcomputing.com (Sohail) Date: Mon, 10 Jan 2011 21:18:41 -0800 (PST) Subject: Ideas for a module to process command line arguments Message-ID: Hey, every body has their own favorite method/ways to process command line arguments. I've worked on a little CPython extension to handle command line arguments may be you'll find it interesting and useful.... To download the source code.... http://www.stupidcomputing.com/page.php?id=argsv Thank you. From shankarphy at gmail.com Tue Jan 11 00:50:22 2011 From: shankarphy at gmail.com (SANKAR .) Date: Tue, 11 Jan 2011 16:50:22 +1100 Subject: String to char and decimal number conversion In-Reply-To: <4D2BD39F.9080802@yahoo.com> References: <4D2BD39F.9080802@yahoo.com> Message-ID: Thanks Alan! -Sankar On Tue, Jan 11, 2011 at 2:50 PM, Alan Meyer wrote: > On 1/10/2011 6:02 PM, Chris Rebert wrote: > >> On Mon, Jan 10, 2011 at 2:44 PM, SANKAR . wrote: >> >>> Hello There, >>> >>> >>> I am from non IT field also new to python programming.Could you >>> please help me to solve the following problem? >>> >>> I have a list T1 with following format: >>> >>> T1 = [ ' "Field" ' , ' "12.5" ', ' "2.5" '] >>> >>> How do get the list elements without double quote in my output (T2). >>> >>> T2 =[ ' Field ' , ' 12.5 ', ' 2.5 '] >>> >> > This will do it: > ------------------------------------------------ > > T1 = [ ' "Field" ' , ' "12.5" ', ' "2.5" '] > T2 = [] > for t in T1: > T2.append(t.replace('"', '')) > ------------------------------------------------ > > The "replace" function acts on each element in T1, replacing every double > quote with nothing. We then append that to the new list T2. > > Alan > -- > http://mail.python.org/mailman/listinfo/python-list > -------------- next part -------------- An HTML attachment was scrubbed... URL: From steve+comp.lang.python at pearwood.info Tue Jan 11 01:11:00 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 11 Jan 2011 06:11:00 GMT Subject: importing modules dynamicly References: <3c6f5e1e-2f0a-46a3-a99e-8b3eb4fcb063@30g2000yql.googlegroups.com> Message-ID: <4d2bf473$0$30004$c3e8da3$5496439d@news.astraweb.com> On Mon, 10 Jan 2011 20:42:17 -0800, dubux wrote: > After loading all the modules, i try to do something like: > > instance = modules.modulename.class() No you don't. class is a reserved word in Python, you would get a SyntaxError if you did that. Please post the error you get, including the complete traceback, showing the line of code that fails. Copy and paste the *actual* message in full, don't retype it from memory, paraphrase it, simplify it, translate it into Swahili, or otherwise change it in anyway. -- Steven From alice at gothcandy.com Tue Jan 11 02:25:55 2011 From: alice at gothcandy.com (=?utf-8?Q?Alice_Bevan=E2=80=93McGregor?=) Date: Mon, 10 Jan 2011 23:25:55 -0800 Subject: Ideas for a module to process command line arguments References: Message-ID: On 2011-01-10 21:18:41 -0800, Sohail said: > Hey, every body has their own favorite method/ways to process command > line arguments. I've worked on a little CPython extension to handle > command line arguments may be you'll find it interesting and useful.... Even I've implemented my own way to handle command-line scripts, marrow.script: https://github.com/pulp/marrow.script The idea with mine that you write a Python function... and that's it. The latest version has experimental support for class-based "subcommand" dispatch, but it needs work, needs to be updated to support sub-sub commands, and the help text generator needs to be overhauled to support classes properly. The argument list, typecasting, etc. is built from the argspec. Help text is pulled from the docstring. Decorators are provided to override short names, define explicit callbacks or typecasting functions, etc. I got tired of using PasteScript and OptParse. Mostly OptParse, actually. :/ - Alice. From orasnita at gmail.com Tue Jan 11 02:37:49 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Tue, 11 Jan 2011 09:37:49 +0200 Subject: Python use growing fast References: <4d2b8844$0$43996$742ec2ed@news.sonic.net> <4D2BB453.8030304@verizon.net> Message-ID: <08AA70425ADB4D99A8054A7F33141B76@octavian> From: "Gerry Reno" > On 01/10/2011 08:31 PM, Katie T wrote: >> On Mon, Jan 10, 2011 at 10:29 PM, John Nagle wrote: >> >>> On 1/10/2011 1:02 PM, MRAB wrote: >>> >>>> On 10/01/2011 20:29, Dan Stromberg wrote: >>>> >>>>> I invite folks to check out Tiobe's Language Popularity Rankings: >>>>> >>>>> http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html >>>>> >>> That's somehow derived from web searches, not from any real data >>> source. Look how far down JavaScript is. >>> >> Any measure is arbitrary and subject to biases, what methodology would >> you prefer ? >> >> >> Katie >> > > Measuring the "Buzz" about a language is actually a pretty good way to > gauge its popularity. Well, not exactly. C and C++ are older than many other languages and probably many of the web pages that contain "programming C" are very old and don't reflect their current popularity. On the other hand, newer languages are more attractive for book publishers because they can sell more books about Ruby than about C, because for C there are already very many books written so there is a bigger intrest to promote the newer languages, not just because they are better, but because there are interests involved. Talking about interests, Java and DotNet are more popular than many other languages, but we all know why, and we also know why PHP has such a big success although it is a bad language, as we all know why Window has a bigger success than other operating systems... so the popularity contest is good, but for something else than we want to prove. A programming language popularity contest is like a beauty contest for finding the most intelligent girl. Octavian From stefan_ml at behnel.de Tue Jan 11 02:47:26 2011 From: stefan_ml at behnel.de (Stefan Behnel) Date: Tue, 11 Jan 2011 08:47:26 +0100 Subject: Resolve circular reference In-Reply-To: <55db55e9-539a-4f36-a84f-5199500cd909@k30g2000vbn.googlegroups.com> References: <1718ea91-fc4e-49f3-a15a-bdc683789126@k22g2000yqh.googlegroups.com> <353ecd61-22f8-4770-be30-29cb76b0f6b0@t35g2000yqj.googlegroups.com> <2349f7d4-2b85-456f-96b5-140f15548859@v17g2000prc.googlegroups.com> <1e7f6338-33ff-488e-9182-b31498babe0b@c39g2000yqi.googlegroups.com> <429e3e67-9732-4f82-9f97-99ed5aeb1f74@r8g2000prm.googlegroups.com> <451b9057-609a-4b1d-a064-62e738267084@e4g2000vbg.googlegroups.com> <55db55e9-539a-4f36-a84f-5199500cd909@k30g2000vbn.googlegroups.com> Message-ID: moerchendiser2k3, 10.01.2011 22:19: > On Jan 10, 7:18 pm, Stefan Behnel wrote: >> moerchendiser2k3, 10.01.2011 18:55: >> >>>> If you can tell us why it's so important that the object be destroyed >>>> at that given time, even while a reference to it exists, maybe we can >>>> give you better suggestions. >> >>> Thanks for your answer! In my case the types A and B (in my example >>> above) >>> are a dialog and a dialog widget. At a special time I have to close >>> and >>> destroy all dialogs but this does not happen because the widget keeps >>> the dialog alive. I have the reference to the dialog >>> but after I closed the dialogs I also would like to destroy them >>> because they have to free some special ressources. >> >> Objects within a reference cycle will eventually get cleaned up, just not >> right away and not in a predictable order. >> >> If you need immediate cleanup, you should destroy the reference cycle >> yourself, e.g. by removing the widgets from the dialog when closing it. >> >> Stefan > > The PyWidget type does not own the widget, it just points to it. I > have an idea, would this fix the problem? > > I destroy the internal dictionary of the dialog which points to other > PyObjects? Then I would cut the dependency. Sure, that should work. Stefan From michele.simionato at gmail.com Tue Jan 11 03:32:32 2011 From: michele.simionato at gmail.com (Michele Simionato) Date: Tue, 11 Jan 2011 00:32:32 -0800 (PST) Subject: Ideas for a module to process command line arguments References: Message-ID: On Jan 11, 8:25?am, Alice Bevan?McGregor wrote: explicit callbacks or typecasting functions, etc. > > I got tired of using PasteScript and OptParse. ?Mostly OptParse, actually. ?:/ It's a pity that the argument parsing modules in the standard library are so verbose that everybody is reinventing the same thing :-( It looks like you have reinvented plac: http://pypi.python.org/pypi/plac From wander.lairson at gmail.com Tue Jan 11 04:42:28 2011 From: wander.lairson at gmail.com (wander.lairson) Date: Tue, 11 Jan 2011 07:42:28 -0200 Subject: ctypes and cygwin Message-ID: Hello, I was trying to use the libusb 1.0 with cygwin environments and noticed that this library uses stdcall calling convention, but ctypes does not have WinDLL object for cygwin. As far as I know, libusb builds with stdcall calling convention on cygwin by default. My question is if ctypes should have WinDLL in cygwin or cygwin, as a kind of emulation of Unix, considers everything to be cdecl and libusb guys should change their default build behavior in cygwin. Not sure if this is the right place to ask this question, but if ctypes guy(s) took out WinDLL from cygwin, I believe he (they) had a good reason to do so... -- Best Regards, Wander Lairson Costa LCoN - Laborat?rio de Computa??o Natural - Natural Computing Laboratory (http://www.mackenzie.com.br/lcon.html) Programa de P?s-Gradua??o em Engenharia El?trica (PPGEE) Faculdade de Computa??o e Inform?tica (FCI) Universidade Presbiteriana Mackenzie - SP - Brazil From ddasilva at umd.edu Tue Jan 11 04:43:52 2011 From: ddasilva at umd.edu (Daniel da Silva) Date: Tue, 11 Jan 2011 04:43:52 -0500 Subject: Parsing string for " " Message-ID: Hi, I have come across a task where I would like to scan a short 20-80 character line of text for instances of " ". Ideally could be of any tense. I know quite a bit of programming and computer science, but computational linguistics is relatively new to me. If anyone can point me in the right direction, I would be very thankful! Cheers, Daniel -------------- next part -------------- An HTML attachment was scrubbed... URL: From davishbhardwaj1986 at gmail.com Tue Jan 11 05:41:50 2011 From: davishbhardwaj1986 at gmail.com (Davish Bhardwaj) Date: Tue, 11 Jan 2011 02:41:50 -0800 (PST) Subject: String to char and decimal number conversion References: Message-ID: <5a568ba8-fca5-4d3e-bd05-ca3c865cfa31@fo10g2000vbb.googlegroups.com> On Jan 11, 4:02?am, Chris Rebert wrote: > On Mon, Jan 10, 2011 at 2:44 PM, SANKAR . wrote: > > Hello There, > > > ?????? I am from non IT field also new to python programming.Could you > > please help me to solve the following problem? > > > I have a list T1 with following format: > > > T1 = [ ' "Field" ' , ' "12.5" ', ' "2.5" '] > > > How do get the list elements without double quote in my output (T2). > > > T2 =[ ' Field ' , ' 12.5 ', ' 2.5 '] > > How are you obtaining T1 in the first place? > > Cheers, > Chris > --http://blog.rebertia.com You can also do it like : T1 = [ ' "Field" ' , ' "12.5" ', ' "2.5" '] T2 = [t.replace('"', '') for t in T1] This seems to me a more better and fast code ;) Davish From jeanmichel at sequans.com Tue Jan 11 06:14:18 2011 From: jeanmichel at sequans.com (Jean-Michel Pichavant) Date: Tue, 11 Jan 2011 12:14:18 +0100 Subject: importing modules dynamicly In-Reply-To: <3c6f5e1e-2f0a-46a3-a99e-8b3eb4fcb063@30g2000yql.googlegroups.com> References: <3c6f5e1e-2f0a-46a3-a99e-8b3eb4fcb063@30g2000yql.googlegroups.com> Message-ID: <4D2C3B8A.408@sequans.com> dubux wrote: > I am trying to import modules dynamicly from a directory (modules/) in > which i have __init__.py with the __all__ variable set. Everything > imports correctly and I have verified this however I am stuck on > actually using my classes in the dynamicly imported modules. > > this bit is in my main.py (or base script) to import the modules in > the modules/ directory: > > loaded_modules = [] > for item in modules: > if item == '__init__.py': pass > else: > if item.endswith('.py'): > __import__('modules.' + item[0:len(item) - 3]) > loaded_modules.append(item[0:len(item) - 3]) > else: pass > > After loading all the modules, i try to do something like: > > instance = modules.modulename.class() > > And I get an AttributeError. What am I doing wrong here? Help please!! > > Your code is rather strange, 'modules' looks to be a list or some iterable, and then you expect to have a 'modulename' attribute or something... My guess is that you pasted an approximative translation of your code which makes it impossible de debug. Here is a possible way of importing a bunch of python files: loaded_modules = {} fileNames = os.listdir('./modules') pyFiles = [os.path.basename(name).replace('.py', '') for name in fileNames if name.endswith('.py')] for pyFile in pyFiles: loaded_modules[pyFile] = __import__('modules.%s' % pyFile) # how to get a class named 'AClassName' defined in then modules for module in loaded_modules: myClass = getattr(loaded_modules[module], 'AClassName', None) print myClass if myClass: myInstance = myClass() JM From wiz1024 at gmail.com Tue Jan 11 06:18:27 2011 From: wiz1024 at gmail.com (wiz1024 wiz1024) Date: Tue, 11 Jan 2011 12:18:27 +0100 Subject: "socket operation on non socket" on Windows Message-ID: Hi I have a problem on Windows with the module urllib2 with python 2.5 when i use the "urlopen" function, i have some time the following error : error I don't understand why suddenly this error arrives The urlopen function is called from a thread Thanks in advance. -------------- next part -------------- An HTML attachment was scrubbed... URL: From jurko.gospodnetic at pke.hr Tue Jan 11 06:35:50 2011 From: jurko.gospodnetic at pke.hr (=?windows-1250?Q?Jurko_Gospodneti=E6?=) Date: Tue, 11 Jan 2011 12:35:50 +0100 Subject: os.path.realpath() and os.path.abspath() Message-ID: Hi all. os.path.realpath() documentation states that it returns a 'canonical' path. Does that infer that it returns an absolute path? I have not found seen any implementation that does not return an absolute path, but can this be counted on? Or should we use os.path.abspath(os.path.realpath(x)) when we want to convert x to its full/canonical name? Best regards, Jurko Gospodneti? From jldunn2000 at gmail.com Tue Jan 11 06:42:28 2011 From: jldunn2000 at gmail.com (loial) Date: Tue, 11 Jan 2011 03:42:28 -0800 (PST) Subject: PJL References: <19d28e76-6085-42b5-a98f-7bf40591910f@f35g2000vbl.googlegroups.com> <44a7123a-52e7-4c34-adba-d9cf19985899@u9g2000pra.googlegroups.com> Message-ID: Thank you. I was able to send the following PJL to the printer and it worked. @PJL STMSG DISPLAY = "Hello from John" Do you have any experience handling PJL responses from the printer?...What I really want to do is get PJL information back from the printer and read it in python(or some other Unix scripting tool) From ben+python at benfinney.id.au Tue Jan 11 07:21:20 2011 From: ben+python at benfinney.id.au (Ben Finney) Date: Tue, 11 Jan 2011 23:21:20 +1100 Subject: Asking for help with code? Post a minimal working example. (was: importing modules dynamicly) References: <3c6f5e1e-2f0a-46a3-a99e-8b3eb4fcb063@30g2000yql.googlegroups.com> Message-ID: <877hebeim7.fsf_-_@benfinney.id.au> Jean-Michel Pichavant writes: > Your code is rather strange, 'modules' looks to be a list or some > iterable, and then you expect to have a 'modulename' attribute or > something... > My guess is that you pasted an approximative translation of your code > which makes it impossible de debug. To the OP: It is often a good idea to simplify one's code when asking for help. That will make it easier to understand. But don't simplify to the point where the code doesn't actually run, or doesn't demonstrate the behaviour you're reporting! Instead, post a minimal working example of the thing you want explained. To discuss the code and present advice, people will want to run your code for themselves to see what you're seeing, or as close as they can get. Make that easier for them by ensuring your example actually does what you say it does. -- \ ?I prayed for twenty years but received no answer until I | `\ prayed with my legs.? ?Frederick Douglass, escaped slave | _o__) | Ben Finney From stefan_ml at behnel.de Tue Jan 11 08:08:07 2011 From: stefan_ml at behnel.de (Stefan Behnel) Date: Tue, 11 Jan 2011 14:08:07 +0100 Subject: String to char and decimal number conversion In-Reply-To: References: Message-ID: SANKAR ., 11.01.2011 01:00: > I am reading a Test.txt (see atatchment) file using following code to get > the T2: > > F =open('C:\Test.txt','r') > T1 = F.readlines() > for i in range(len(T1)): > T2 = T1[i].split(',') > print(T2) Take a look at the "csv" module in the standard library. Stefan From alice at gothcandy.com Tue Jan 11 09:37:28 2011 From: alice at gothcandy.com (=?utf-8?Q?Alice_Bevan=E2=80=93McGregor?=) Date: Tue, 11 Jan 2011 06:37:28 -0800 Subject: Ideas for a module to process command line arguments References: Message-ID: On 2011-01-11 00:32:32 -0800, Michele Simionato said: > On Jan 11, 8:25?am, Alice Bevan?McGregor wrote: >> I got tired of using PasteScript and OptParse. ?Mostly OptParse, actually. ?:/ > > It's a pity that the argument parsing modules in the standard library > are so verbose that everybody is reinventing the same thing :-( It > looks like you have reinvented plac: http://pypi.python.org/pypi/plac And a package called `commandline`. There are many command line parsing modules, many of which are unmaintained, few have reached 1.0. My criteria for 1.0? 100% unit test coverage, complete documentation, compatibility with 2.6+ and 3.1+ within a single package. marrow.script meets that criteria, do the others? :) - Alice. From alice at gothcandy.com Tue Jan 11 10:06:20 2011 From: alice at gothcandy.com (=?utf-8?Q?Alice_Bevan=E2=80=93McGregor?=) Date: Tue, 11 Jan 2011 07:06:20 -0800 Subject: Ideas for a module to process command line arguments References: Message-ID: On 2011-01-11 00:32:32 -0800, Michele Simionato said: > It's a pity that the argument parsing modules in the standard library > are so verbose that everybody is reinventing the same thing :-( It > looks like you have reinvented plac: http://pypi.python.org/pypi/plac After looking into it, Plac's default help display isn't very helpful; you need to massage your application a fair amount before generating nice, complete-looking argument lists and such. For example: def main(verbose: ('prints more info', 'flag', 'v'), dsn: 'connection string'): @annotate(dsn="connection string", verbose="prints more info") def main(dsn, verbose=False): The latter is marrow.script, and even without the annotation a more complete help text is generated. The -v and flag nature are assumed from the first unique character and default value. (Flags, when present on the command line, invert the default value.) Py3k annotations haven't been implemented yet, though. Also included is an easy way to simulte command-line execution (i.e. by reading arguments passed by hand and by returning the exit code, vs. reading sys.argv and calling sys.exit()) for unit testing purposes. Plac appears (from the documentation) to be written on top of argparse. :( - Alice. From michele.simionato at gmail.com Tue Jan 11 10:49:36 2011 From: michele.simionato at gmail.com (Michele Simionato) Date: Tue, 11 Jan 2011 07:49:36 -0800 (PST) Subject: Ideas for a module to process command line arguments References: Message-ID: <941cfb0b-e34b-4d07-8c51-293656878f6a@z19g2000yqb.googlegroups.com> On Jan 11, 4:06?pm, Alice Bevan?McGregor wrote: > Plac appears (from the documentation) to be written on top of argparse. > ?:( And the problem with that being what? From jeanmichel at sequans.com Tue Jan 11 11:22:10 2011 From: jeanmichel at sequans.com (Jean-Michel Pichavant) Date: Tue, 11 Jan 2011 17:22:10 +0100 Subject: Ideas for a module to process command line arguments In-Reply-To: <941cfb0b-e34b-4d07-8c51-293656878f6a@z19g2000yqb.googlegroups.com> References: <941cfb0b-e34b-4d07-8c51-293656878f6a@z19g2000yqb.googlegroups.com> Message-ID: <4D2C83B2.7030808@sequans.com> Michele Simionato wrote: > On Jan 11, 4:06 pm, Alice Bevan?McGregor wrote: > >> Plac appears (from the documentation) to be written on top of argparse. >> :( >> > > And the problem with that being what? > ... not available to python 2.5 / 2.6 users :) JM From michele.simionato at gmail.com Tue Jan 11 11:26:40 2011 From: michele.simionato at gmail.com (Michele Simionato) Date: Tue, 11 Jan 2011 08:26:40 -0800 (PST) Subject: Ideas for a module to process command line arguments References: <941cfb0b-e34b-4d07-8c51-293656878f6a@z19g2000yqb.googlegroups.com> Message-ID: <8dd04926-2ad2-4c01-b9e7-5843e801852f@39g2000yqa.googlegroups.com> On Jan 11, 5:22?pm, Jean-Michel Pichavant wrote: > Michele Simionato wrote: > > On Jan 11, 4:06 pm, Alice Bevan McGregor wrote: > > >> Plac appears (from the documentation) to be written on top of argparse. > >> ?:( > > > And the problem with that being what? > > ... not available to python 2.5 / 2.6 users :) > > JM In that case easy_install/pip/whatever will install the dependency automatically (who is installing dependencies by hand nowadays?). More seriously I thought being based on a solid module which is also part of the standard library (for Python 2.7+) was an asset of plac. From jtim.arnold at gmail.com Tue Jan 11 11:55:28 2011 From: jtim.arnold at gmail.com (Tim) Date: Tue, 11 Jan 2011 08:55:28 -0800 (PST) Subject: os.system and loggers References: <70ac3463-cf3c-4435-909b-ac044bef7e41@z9g2000yqz.googlegroups.com> <285801ef-7e26-4c40-a307-3c6eb5314b82@z17g2000prz.googlegroups.com> Message-ID: On Jan 10, 1:01?pm, Carl Banks wrote: > On Jan 10, 8:29?am, Tim wrote: > > > > > > > > > > > On Jan 7, 11:24?am, Tim wrote: > > > > hi, I'm using a 3rd-party python program that uses the python logging > > > facility and also makes calls to os.system. I'm trying to capture its > > > output to a file. > > > > In my own code, I've taken control of the loggers that are setup in > > > the other program by removing its StreamHandler and replacing with > > > FileHander. But when it comes to the call to os.system I'm at a loss. > > > > I want to capture the stdout from that os.system call in my > > > FileHandler. I thought this might work, before I call the other > > > program's class/method: > > > sys.stdout = getLogger('status').handlers[0].stream > > > > but no dice. Is there any clean way to get what I want? If not, I > > > guess I'll override the other method with my own, but it will > > > basically be a bunch of code copied with os.sytem replaced with > > > subprocess, using getLogger('status').handlers[0].stream for stdout/ > > > stderr. > > > > thanks, > > > --Tim Arnold > > > Replying to my own post.... > > > I think I may have included too much fluff in my original question. > > The main thing I wonder is whether I can attach a log handler to > > stdout in such a way that os.system calls will write to that handler > > instead of the console. > > No, but you could replace os.system with something that does work. > (It would replace it globally for all uses, so you may need some logic > to decide whether to leave the call alone, or to modify it, perhaps by > inspecting the call stack.) > > The simplest thing to do is to append a shell redirection to the > command (>/your/log/file), so something like this: > > _real_os_system = os.system > > def my_os_system(cmd): > ? ? if test_log_condition: > ? ? ? ? return _real_os_system(cmd + "2> /my/log/file") > ? ? return _real_os_system(cmd) > > os.system = my_os_system > > That could backfire for any number of reasons so you probably should > only do this if you know that it works with all the commands it > issues. > > The better way might be to call the subprocess module instead, where > you can dispatch the command with redirection to any stream. ?I doubt > there's a foolproof way to do that given an arbitrary os.system > command, but the subprocess way is probably safer. > > Carl Banks Thanks Carl. I will use subprocess. I made this little toy example to prove to myself that subprocess does handle a filehandler stream, so I include it here for completeness' sake: import subprocess,logging,shlex # create the logger, filehandler and get the stream log = logging.getLogger('mytest') fh = logging.FileHandler('mytest.log') log.addHandler(fh) log.setLevel(logging.INFO) mylog = logging.getLogger('mytest').handlers[0].stream # write a test line to the log log.info('my first line') # execute the subprocess using the stream as stdout cmd = 'ls -l' p = subprocess.Popen(shlex.split(cmd),stdout=mylog) # if you don't wait(), the output won't be necessarily in chronological order. r = p.wait() # write a last test line to the log log.info('done %s'% r) and it works as expected. thanks, --Tim Arnold From tjreedy at udel.edu Tue Jan 11 12:04:20 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Tue, 11 Jan 2011 12:04:20 -0500 Subject: "socket operation on non socket" on Windows In-Reply-To: References: Message-ID: On 1/11/2011 6:18 AM, wiz1024 wiz1024 wrote: > Hi > > I have a problem on Windows with the module urllib2 with python 2.5 > > when i use the "urlopen" function, i have some time the following error : > error > > I don't understand why suddenly this error arrives > The urlopen function is called from a thread Give us both the failing call and the complete copy-and-pasted traceback. -- Terry Jan Reedy From wiz1024 at gmail.com Tue Jan 11 12:16:31 2011 From: wiz1024 at gmail.com (wiz1024 wiz1024) Date: Tue, 11 Jan 2011 18:16:31 +0100 Subject: "socket operation on non socket" on Windows In-Reply-To: References: Message-ID: 2011/1/11 Terry Reedy > On 1/11/2011 6:18 AM, wiz1024 wiz1024 wrote: > >> Hi >> >> I have a problem on Windows with the module urllib2 with python 2.5 >> >> when i use the "urlopen" function, i have some time the following error : >> error >> >> I don't understand why suddenly this error arrives >> The urlopen function is called from a thread >> > > Give us both the failing call and the complete copy-and-pasted traceback. > > the failing call is urlopen I investigate a little and it seams that the problem is cause by the function connect of httplib I have the following traceback with log level debug connect: (10.42.1.116, 1111) connect fail: ('10.42.1.116', 1111) File "W:\david\OvdServer\ovd\SMRequestManager.py", line 145, in do_open h.request(req.get_method(), req.get_selector(), req.data, headers) File "C:\Python25\lib\httplib.py", line 866, in request self._send_request(method, url, body, headers) File "C:\Python25\lib\httplib.py", line 889, in _send_request self.endheaders() File "C:\Python25\lib\httplib.py", line 860, in endheaders self._send_output() File "C:\Python25\lib\httplib.py", line 732, in _send_output self.send(msg) File "C:\Python25\lib\httplib.py", line 699, in send self.connect() File "C:\Python25\lib\httplib.py", line 683, in connect raise socket.error, msg (10038, 'Socket operation on non-socket') best regard. David. > -- > Terry Jan Reedy > > -- > http://mail.python.org/mailman/listinfo/python-list > -------------- next part -------------- An HTML attachment was scrubbed... URL: From termim at gmail.com Tue Jan 11 12:57:32 2011 From: termim at gmail.com (Mike) Date: Tue, 11 Jan 2011 09:57:32 -0800 (PST) Subject: Ideas for a module to process command line arguments References: <941cfb0b-e34b-4d07-8c51-293656878f6a@z19g2000yqb.googlegroups.com> <8dd04926-2ad2-4c01-b9e7-5843e801852f@39g2000yqa.googlegroups.com> Message-ID: On Jan 11, 11:26?am, Michele Simionato wrote: > > In that case easy_install/pip/whatever will install the dependency > automatically (who is installing > dependencies by hand nowadays?). More seriously I thought being based I do. Is this bad? :} From jlconlin at gmail.com Tue Jan 11 15:53:02 2011 From: jlconlin at gmail.com (Jeremy) Date: Tue, 11 Jan 2011 12:53:02 -0800 (PST) Subject: Convert unicode escape sequences to unicode in a file Message-ID: I have a file that has unicode escape sequences, i.e., J\u00e9r\u00f4me and I want to replace all of them in a file and write the results to a new file. The simple script I've created is copied below. However, I am getting the following error: UnicodeEncodeError: 'ascii' codec can't encode character u'\xe9' in position 947: ordinal not in range(128) It appears that the data isn't being converted when writing to the file. Can someone please help? Thanks, Jeremy if __name__ == "__main__": f = codecs.open(filename, 'r', 'unicode-escape') lines = f.readlines() line = ''.join(lines) f.close() utFound = re.sub('STRINGDECODE\((.+?)\)', r'\1', line) print(utFound[:1000]) o = open('newDice.sql', 'w') o.write(utFound.decode('utf-8')) o.close() From SegundoBob at earthlink.net Tue Jan 11 17:30:40 2011 From: SegundoBob at earthlink.net (SegundoBob) Date: Tue, 11 Jan 2011 14:30:40 -0800 (PST) Subject: Integrating doctest with unittest References: <4d038b63$0$30000$c3e8da3$5496439d@news.astraweb.com> <4d2a6b80$0$30004$c3e8da3$5496439d@news.astraweb.com> Message-ID: <82d99929-40e8-4d69-8272-f156017f5bd0@u3g2000vbj.googlegroups.com> On Jan 9, 6:14?pm, Steven D'Aprano wrote: > >>Is there a way to have unittest.main() find and run doc_test_suite > >>together with the other test suites? I only recently began using unittest, so I only know a little about it. There are almost certainly more clever ways to what you want, but what I have done may satisfy you. allTests.py: import unittest import PalmDS.test.test_tree_node as test_tree_node import PalmDS.test.test_plugin_manager as test_plugin_manager import PalmDS.test.test_ds_utils as test_ds_utils import PalmDS.test.test_main as test_main import PalmDS.test.test_root as test_root all = unittest.TestSuite() for module in [test_tree_node, test_plugin_manager, test_ds_utils, test_root, ]: all.addTest(module.suite()) if __name__ == '__main__': unittest.main() Note: This requires me to put a suite() function in every unittest module, such as this one from my test_tree_node.py module: def suite(): return unittest.TestLoader().loadTestsFromTestCase(TstTreeNode) Note: I must change TstTreeNode appropriately when I copy suite() to a new module. Terminal contents after a run: bob at BobBuilt01:~/svnMyWork/PalmDS/test$ ./all_tests.py -v all testDs2tree01 (PalmDS.test.test_tree_node.TstTreeNode) ... ok testDs2tree02 (PalmDS.test.test_tree_node.TstTreeNode) ... ok testPlug01 (PalmDS.test.test_plugin_manager.TstPluginManager) ... ok testPlug02 (PalmDS.test.test_plugin_manager.TstPluginManager) ... ok testBitstringBytes (PalmDS.test.test_ds_utils.TstDsUtils) ... ok testComputeLoadDir (PalmDS.test.test_ds_utils.TstDsUtils) ... ok testDs2fmtStr (PalmDS.test.test_ds_utils.TstDsUtils) ... ok testPalmDateDecode (PalmDS.test.test_root.TstRoot) ... ok testPalmDateEncode (PalmDS.test.test_root.TstRoot) ... ok ---------------------------------------------------------------------- Ran 9 tests in 0.016s OK bob at BobBuilt01:~/svnMyWork/PalmDS/test$ My guess at an answer to your specific question: At the end of allTests.py add all.addTest(doctest.DocTestSuite(module=module_to_test))) Then I think your DocTest suite will be run with the unittest suites when you specify "all" on the command line. From alex at moreati.org.uk Tue Jan 11 17:36:26 2011 From: alex at moreati.org.uk (Alex Willmer) Date: Tue, 11 Jan 2011 14:36:26 -0800 (PST) Subject: Convert unicode escape sequences to unicode in a file References: Message-ID: On Jan 11, 8:53?pm, Jeremy wrote: > I have a file that has unicode escape sequences, i.e., > > J\u00e9r\u00f4me > > and I want to replace all of them in a file and write the results to a new file. ?The simple script I've created is copied below. ?However, I am getting the following error: > > UnicodeEncodeError: 'ascii' codec can't encode character u'\xe9' in position 947: ordinal not in range(128) > > It appears that the data isn't being converted when writing to the file. ?Can someone please help? Are you _sure_ that your file contains the characters '\', 'u', '0', '0', 'e' and '9'? I expect that actually your file contains a byte with value 0xe9 and you have inspected the file using Python, which has printed the byte using a Unicode escape sequence. Open the file using a text editor or hex editor and look at the value at offset 947 to be sure. If so, you need to replace 'unicode-escape' with the actual encoding of the file. > if __name__ == "__main__": > ? ? f = codecs.open(filename, 'r', 'unicode-escape') > ? ? lines = f.readlines() > ? ? line = ''.join(lines) > ? ? f.close() > > ? ? utFound = re.sub('STRINGDECODE\((.+?)\)', r'\1', line) > ? ? print(utFound[:1000]) > > ? ? o = open('newDice.sql', 'w') > ? ? o.write(utFound.decode('utf-8')) > ? ? o.close() From nitin1singhal at gmail.com Tue Jan 11 17:38:44 2011 From: nitin1singhal at gmail.com (nitin) Date: Tue, 11 Jan 2011 14:38:44 -0800 (PST) Subject: Req: Python Developer : Direct CLient Message-ID: <874604c5-62dc-445d-b645-e33d1b60adae@l8g2000yqh.googlegroups.com> Hi, Please send me your resume if you are interested in it. Python Developer Location: Sebastapol, CA Duration: 3 Months Python web application development. Systems integration. RESTful architectures and Web standards. Familiar with the following: JVM and java tools. Creating documentation. Workable knowledge of relational databases and NoSQL solutions Thanks Nitin Singhal | RJT Compuquest Inc. 23440 Hawthorne Blvd., Suite 210, Torrance, CA 90505 nsinghal at rjtcompuquest.com www.rjtcompuquest.com Direct: 310 961 5807 Voice: 866-978-0384 Ext- 46 Fax: 310-378-6867 From debacle at debian.org Tue Jan 11 17:40:01 2011 From: debacle at debian.org (W. Martin Borgert) Date: Tue, 11 Jan 2011 23:40:01 +0100 Subject: How to dump a Python 2.6 dictionary with UTF-8 strings? Message-ID: <20110111224001.GA1503@beron.tangosoft.com> Hi, naively, I thought the following code: #!/usr/bin/env python2.6 # -*- coding: utf-8 -*- import codecs d = { u'key': u'?????' } if __name__ == "__main__": with codecs.open("ilike.txt", "w", "utf-8") as f: print >>f, d would produce a file ilike.txt like this: {u'key': u'?????'} But unfortunately, it results in: {u'key': u'\u6211\u7231\u4e2d\u56fd\u4eba'} What's the right way to get the strings in UTF-8? Thanks in advance! From martin at v.loewis.de Tue Jan 11 18:27:02 2011 From: martin at v.loewis.de (Martin v. Loewis) Date: Wed, 12 Jan 2011 00:27:02 +0100 Subject: How to dump a Python 2.6 dictionary with UTF-8 strings? In-Reply-To: References: Message-ID: <4D2CE746.6090607@v.loewis.de> > What's the right way to get the strings in UTF-8? This will work. I doubt you can get it much simpler in 2.x; in 3.x, your code will work out of the box (with proper syntactical adjustments). import pprint, cStringIO class UniPrinter(pprint.PrettyPrinter): def format(self, obj, context, maxlevels, level): if not isinstance(obj, unicode): return pprint.PrettyPrinter.format(self, obj, context, maxlevels, level) out = cStringIO.StringIO() out.write('u"') for c in obj: if ord(c)<32 or c in u'"\\': out.write('\\x%.2x' % ord(c)) else: out.write(c.encode("utf-8")) out.write('"') # result, readable, recursive return out.getvalue(), True, False UniPrinter().pprint({ u'k"e\\y': u'?????' }) From ben+python at benfinney.id.au Tue Jan 11 18:31:20 2011 From: ben+python at benfinney.id.au (Ben Finney) Date: Wed, 12 Jan 2011 10:31:20 +1100 Subject: Please use the Python Job Board for recruitment (was: Req: Python Developer : Direct CLient) References: <874604c5-62dc-445d-b645-e33d1b60adae@l8g2000yqh.googlegroups.com> Message-ID: <8739ozdnlj.fsf@benfinney.id.au> nitin writes: > Please send me your resume if you are interested in it. Please don't use this forum for recruitment purposes. Instead, please use the Python Job Board . -- \ ?For every complex problem, there is a solution that is simple, | `\ neat, and wrong.? ?Henry L. Mencken | _o__) | Ben Finney From alex at moreati.org.uk Tue Jan 11 18:32:31 2011 From: alex at moreati.org.uk (Alex Willmer) Date: Tue, 11 Jan 2011 15:32:31 -0800 (PST) Subject: How to dump a Python 2.6 dictionary with UTF-8 strings? References: Message-ID: <69a51798-5ebd-471c-a30a-294b2e4e7b84@v12g2000vbx.googlegroups.com> On Jan 11, 10:40?pm, "W. Martin Borgert" wrote: > Hi, > > naively, I thought the following code: > > #!/usr/bin/env python2.6 > # -*- coding: utf-8 -*- > import codecs > d = { u'key': u'?????' } > if __name__ == "__main__": > ? ? with codecs.open("ilike.txt", "w", "utf-8") as f: > ? ? ? ? print >>f, d > > would produce a file ilike.txt like this: > > {u'key': u'?????'} > > But unfortunately, it results in: > > {u'key': u'\u6211\u7231\u4e2d\u56fd\u4eba'} > > What's the right way to get the strings in UTF-8? > > Thanks in advance! It has worked, you're just seeing how python presents unicode characters in the interactive interpreter: Python 2.7.1+ (r271:86832, Dec 24 2010, 10:04:43) [GCC 4.5.2] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> x = {u'key': u'\u6211\u7231\u4e2d\u56fd\u4eba'} >>> x {u'key': u'\u6211\u7231\u4e2d\u56fd\u4eba'} >>> print x {u'key': u'\u6211\u7231\u4e2d\u56fd\u4eba'} >>> print x['key'] ????? That last line only works if your terminal uses an suitable encoding (e.g. utf-8). Regards, Alex From jlconlin at gmail.com Tue Jan 11 18:39:15 2011 From: jlconlin at gmail.com (Jeremy) Date: Tue, 11 Jan 2011 15:39:15 -0800 (PST) Subject: Convert unicode escape sequences to unicode in a file In-Reply-To: Message-ID: <3565d3e8-0a5e-414d-b130-fb0bfecd83f0@glegroupsg2000goo.googlegroups.com> On Tuesday, January 11, 2011 3:36:26 PM UTC-7, Alex wrote: > > Are you _sure_ that your file contains the characters '\', 'u', '0', > '0', 'e' and '9'? I expect that actually your file contains a byte > with value 0xe9 and you have inspected the file using Python, which > has printed the byte using a Unicode escape sequence. Open the file > using a text editor or hex editor and look at the value at offset 947 > to be sure. > > If so, you need to replace 'unicode-escape' with the actual encoding > of the file. Yeah, I'm sure that's what the file contains. In fact, I solved my own problem while waiting for an answer. When writing to the file I need to *en*code instead of *de*code; i.e., o = open('newDice.sql', 'w') o.write(utFound.encode('utf-8')) o.close() That works! From Catherine.M.Moroney at jpl.nasa.gov Tue Jan 11 19:30:22 2011 From: Catherine.M.Moroney at jpl.nasa.gov (Catherine Moroney) Date: Tue, 11 Jan 2011 16:30:22 -0800 Subject: order of importing modules Message-ID: <4D2CF61E.7010500@jpl.nasa.gov> In what order does python import modules on a Linux system? I have a package that is both installed in /usr/lib64/python2.5/site-packages, and a newer version of the same module in a working directory. I want to import the version from the working directory, but when I print module.__file__ in the interpreter after importing the module, I get the version that's in site-packages. I've played with the PYTHONPATH environmental variable by setting it to just the path of the working directory, but when I import the module I still pick up the version in site-packages. /usr/lib64 is in my PATH variable, but doesn't appear anywhere else. I don't want to remove /usr/lib64 from my PATH because that will break a lot of stuff. Can I force python to import from my PYTHONPATH first, before looking in the system directory? Catherine From debacle at debian.org Tue Jan 11 20:05:25 2011 From: debacle at debian.org (W. Martin Borgert) Date: Wed, 12 Jan 2011 02:05:25 +0100 Subject: How to dump a Python 2.6 dictionary with UTF-8 strings? In-Reply-To: <4D2CE746.6090607@v.loewis.de> References: <4D2CE746.6090607@v.loewis.de> Message-ID: <20110112010525.GA2458@beron.tangosoft.com> On 2011-01-12 00:27, Martin v. Loewis wrote: > This will work. I doubt you can get it much simpler > in 2.x; in 3.x, your code will work out of the box > (with proper syntactical adjustments). Thanks, this works like a charm. I tried pprint before for this task and failed. Now I know why :~) From drsalists at gmail.com Tue Jan 11 20:20:18 2011 From: drsalists at gmail.com (Dan Stromberg) Date: Tue, 11 Jan 2011 17:20:18 -0800 Subject: order of importing modules In-Reply-To: <4D2CF61E.7010500@jpl.nasa.gov> References: <4D2CF61E.7010500@jpl.nasa.gov> Message-ID: On Tue, Jan 11, 2011 at 4:30 PM, Catherine Moroney wrote: > In what order does python import modules on a Linux system? ?I have a > package that is both installed in /usr/lib64/python2.5/site-packages, > and a newer version of the same module in a working directory. > > I want to import the version from the working directory, but when I > print module.__file__ in the interpreter after importing the module, > I get the version that's in site-packages. > > I've played with the PYTHONPATH environmental variable by setting it > to just the path of the working directory, but when I import the module > I still pick up the version in site-packages. > > /usr/lib64 is in my PATH variable, but doesn't appear anywhere else. ?I > don't want to remove /usr/lib64 from my PATH because that will break > a lot of stuff. > > Can I force python to import from my PYTHONPATH first, before looking > in the system directory? > > Catherine > -- > http://mail.python.org/mailman/listinfo/python-list Please import sys and inspect sys.path; this defines the search path for imports. By looking at sys.path, you can see where in the search order your $PYTHONPATH is going. It might actually be better to give your script a command line option that says "Throw the following directory at the beginning of sys.path". From ben+python at benfinney.id.au Tue Jan 11 20:26:04 2011 From: ben+python at benfinney.id.au (Ben Finney) Date: Wed, 12 Jan 2011 12:26:04 +1100 Subject: order of importing modules References: <4D2CF61E.7010500@jpl.nasa.gov> Message-ID: <87tyhediab.fsf@benfinney.id.au> Catherine Moroney writes: > In what order does python import modules on a Linux system? An import caused by a statement is done when that statement is executed. So the answer to that question is: in the order the statements occur in the execution flow. > I have a package that is both installed in > /usr/lib64/python2.5/site-packages, and a newer version of the same > module in a working directory. Ah, you're asking about the search path for importing modules. You would do well to work through the entire Python tutorial to cover the basics like that. Don't merely read it; actually *do* it, exploring each example and experimenting to understand before proceeding. The module import search path is part of that coverage . > I want to import the version from the working directory, but when I > print module.__file__ in the interpreter after importing the module, > I get the version that's in site-packages. You will be interested in the features enabled by PEP 328 , specifically the feature of relative imports. -- \ ?When I turned two I was really anxious, because I'd doubled my | `\ age in a year. I thought, if this keeps up, by the time I'm six | _o__) I'll be ninety.? ?Steven Wright | Ben Finney From ddasilva at umd.edu Tue Jan 11 20:50:46 2011 From: ddasilva at umd.edu (Daniel da Silva) Date: Tue, 11 Jan 2011 17:50:46 -0800 (PST) Subject: Parsing string for " " Message-ID: <0d7143ca-45cf-44c3-9e8d-acb867c52037@f30g2000yqa.googlegroups.com> Hi, I have come across a task where I would like to scan a short 20-80 character line of text for instances of " ". Ideally could be of any tense. I know quite a bit of programming and computer science, but computational linguistics is relatively new to me. If anyone can point me in the right direction, I would be very thankful! Cheers, Daniel From blume.erich at gmail.com Tue Jan 11 21:22:33 2011 From: blume.erich at gmail.com (eblume) Date: Tue, 11 Jan 2011 18:22:33 -0800 (PST) Subject: Syntactic structure for 'until :' loop Message-ID: <198391a1-7257-4422-a076-35b815ab99c6@l22g2000vbp.googlegroups.com> I'm still quite new to Python and I'm probably going about this entirely the wrong way, but it recently struck me that there might be the need for a control flow loop based on exception handling. First let me give the proposed syntax: until : do_something() This would be exactly equivalent to (but much more compact than): while True: try: do_something() except Exception: break Now, why would anyone want this structure? In my case, I'm using it (well, the latter form of it, obviously) to loop over an iterator object that was not created via the 'for obj in collection:' syntax. Here's the actual code snippet: headers = self.reader.next() ... intermediate code .... while True: try: line = self.reader.next() except StopIteration: return data data.append(line) I'm sure I'm doing this in a very backward and wrong way, and would appreciate tips on a better way to accomplish the same task. Obviously there is an existing syntax which handles the same situations, and I don't suspect that this will be an embraced proposal, I'm more hoping to spark some conversation. Thanks! From SSharma84 at slb.com Tue Jan 11 21:38:50 2011 From: SSharma84 at slb.com (Sachin Kumar Sharma) Date: Wed, 12 Jan 2011 02:38:50 +0000 Subject: Python use growing fast In-Reply-To: <08AA70425ADB4D99A8054A7F33141B76@octavian> References: <4d2b8844$0$43996$742ec2ed@news.sonic.net> <4D2BB453.8030304@verizon.net> <08AA70425ADB4D99A8054A7F33141B76@octavian> Message-ID: <75C2FED246299A478280FA1470EDA4430C907364@NL0230MBX06N1.DIR.slb.com> Since this discussion is going on about the popularity of a programming language. I would like to know views regarding the best language for scientific programming especially in terms of user friendliness, resources available, graphics and robustness to handle large numerical and simulation problems. Thanks & regards Sachin ************************************************************************ Sachin Kumar Sharma Senior Geomodeler -----Original Message----- From: python-list-bounces+ssharma84=slb.com at python.org [mailto:python-list-bounces+ssharma84=slb.com at python.org] On Behalf Of Octavian Rasnita Sent: Tuesday, January 11, 2011 3:38 PM To: python-list at python.org Subject: Re: Python use growing fast From: "Gerry Reno" > On 01/10/2011 08:31 PM, Katie T wrote: >> On Mon, Jan 10, 2011 at 10:29 PM, John Nagle wrote: >> >>> On 1/10/2011 1:02 PM, MRAB wrote: >>> >>>> On 10/01/2011 20:29, Dan Stromberg wrote: >>>> >>>>> I invite folks to check out Tiobe's Language Popularity Rankings: >>>>> >>>>> http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html >>>>> >>> That's somehow derived from web searches, not from any real data >>> source. Look how far down JavaScript is. >>> >> Any measure is arbitrary and subject to biases, what methodology would >> you prefer ? >> >> >> Katie >> > > Measuring the "Buzz" about a language is actually a pretty good way to > gauge its popularity. Well, not exactly. C and C++ are older than many other languages and probably many of the web pages that contain "programming C" are very old and don't reflect their current popularity. On the other hand, newer languages are more attractive for book publishers because they can sell more books about Ruby than about C, because for C there are already very many books written so there is a bigger intrest to promote the newer languages, not just because they are better, but because there are interests involved. Talking about interests, Java and DotNet are more popular than many other languages, but we all know why, and we also know why PHP has such a big success although it is a bad language, as we all know why Window has a bigger success than other operating systems... so the popularity contest is good, but for something else than we want to prove. A programming language popularity contest is like a beauty contest for finding the most intelligent girl. Octavian -- http://mail.python.org/mailman/listinfo/python-list From ian.g.kelly at gmail.com Tue Jan 11 21:53:19 2011 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Tue, 11 Jan 2011 19:53:19 -0700 Subject: Syntactic structure for 'until :' loop In-Reply-To: <198391a1-7257-4422-a076-35b815ab99c6@l22g2000vbp.googlegroups.com> References: <198391a1-7257-4422-a076-35b815ab99c6@l22g2000vbp.googlegroups.com> Message-ID: On 1/11/2011 7:22 PM, eblume wrote: > This would be exactly equivalent to (but much more compact than): > > while True: > try: > do_something() > except Exception: > break Or perhaps: try: while True: do_something() except Exception: pass > Now, why would anyone want this structure? In my case, I'm using it > (well, the latter form of it, obviously) to loop over an iterator > object that was not created via the 'for obj in collection:' syntax. > Here's the actual code snippet: > > headers = self.reader.next() > ... intermediate code .... > while True: > try: > line = self.reader.next() > except StopIteration: > return data > data.append(line) > > I'm sure I'm doing this in a very backward and wrong way, and would > appreciate tips on a better way to accomplish the same task. Obviously > there is an existing syntax which handles the same situations, and I > don't suspect that this will be an embraced proposal, I'm more hoping > to spark some conversation. reader_iter = iter(self.reader) headers = reader_iter.next() # intermediate code for line in reader_iter: data.append(line) return data Also note that recommended best practice is to wrap the "headers = reader_iter.next()" line in a try-except in case it raises a StopIteration. Otherwise it could get propagated silently up to some unrelated for loop higher in the stack, resulting in unexpected behavior. Cheers, Ian From python at mrabarnett.plus.com Tue Jan 11 22:23:11 2011 From: python at mrabarnett.plus.com (MRAB) Date: Wed, 12 Jan 2011 03:23:11 +0000 Subject: Parsing string for " " In-Reply-To: <0d7143ca-45cf-44c3-9e8d-acb867c52037@f30g2000yqa.googlegroups.com> References: <0d7143ca-45cf-44c3-9e8d-acb867c52037@f30g2000yqa.googlegroups.com> Message-ID: <4D2D1E9F.2020500@mrabarnett.plus.com> On 12/01/2011 01:50, Daniel da Silva wrote: > Hi, > > I have come across a task where I would like to scan a short 20-80 > character line of text for instances of " ". Ideally > could be of any tense. > > I know quite a bit of programming and computer science, but > computational linguistics is relatively new to me. If anyone can point > me in the right direction, I would be very thankful! > Have a look at the Natural Language Toolkit: http://www.nltk.org/ From askutt at gmail.com Tue Jan 11 22:30:43 2011 From: askutt at gmail.com (Adam Skutt) Date: Tue, 11 Jan 2011 19:30:43 -0800 (PST) Subject: os.path.realpath() and os.path.abspath() References: Message-ID: On Jan 11, 6:35?am, Jurko Gospodneti? wrote: > ? ?Hi all. > > ? ?os.path.realpath() documentation states that it returns a 'canonical' > path. Does that infer that it returns an absolute path? > A canonical path is supposed to be absolute and at least Python 2.7.1 ensures that is the case. Historically, some versions of the UNIX syscall (Solaris in particular) have not always returned absolute paths, but I believe this is no longer the case and was a very long standing bug (though I may be mistaken). Adam From sjbenner at gmail.com Tue Jan 11 22:50:15 2011 From: sjbenner at gmail.com (Josh Benner) Date: Tue, 11 Jan 2011 19:50:15 -0800 Subject: Python use growing fast In-Reply-To: <75C2FED246299A478280FA1470EDA4430C907364@NL0230MBX06N1.DIR.slb.com> References: <4d2b8844$0$43996$742ec2ed@news.sonic.net> <4D2BB453.8030304@verizon.net> <08AA70425ADB4D99A8054A7F33141B76@octavian> <75C2FED246299A478280FA1470EDA4430C907364@NL0230MBX06N1.DIR.slb.com> Message-ID: On Tue, Jan 11, 2011 at 6:38 PM, Sachin Kumar Sharma wrote: > Since this discussion is going on about the popularity of a programming > language. > > I would like to know views regarding the best language for scientific > programming especially in terms of user friendliness, resources available, > graphics and robustness to handle large numerical and simulation problems. > > Thanks & regards > > Sachin > > ************************************************************************ > Sachin Kumar Sharma > Senior Geomodeler > > According to this article ... http://neopythonic.blogspot.com/2009/11/python-in-scientific-world.html ... the answer is python. Josh Benner -------------- next part -------------- An HTML attachment was scrubbed... URL: From lanyjie at yahoo.com Tue Jan 11 23:08:12 2011 From: lanyjie at yahoo.com (Yingjie Lan) Date: Tue, 11 Jan 2011 20:08:12 -0800 (PST) Subject: the C header file when extending CPython Message-ID: <31414.45942.qm@web121506.mail.ne1.yahoo.com> Hi, I am wondering when extending Python (CPython), what should be put into the C header file? Any guidelines? Thanks, Yingjie From blume.erich at gmail.com Tue Jan 11 23:29:06 2011 From: blume.erich at gmail.com (eblume) Date: Tue, 11 Jan 2011 20:29:06 -0800 (PST) Subject: Syntactic structure for 'until :' loop References: <198391a1-7257-4422-a076-35b815ab99c6@l22g2000vbp.googlegroups.com> Message-ID: On Jan 11, 6:53?pm, Ian Kelly wrote: > On 1/11/2011 7:22 PM, eblume wrote: > > > > > reader_iter = iter(self.reader) > headers = reader_iter.next() > # intermediate code > for line in reader_iter: > ? ? ?data.append(line) > return data > > Also note that recommended best practice is to wrap the "headers = > reader_iter.next()" line in a try-except in case it raises a > StopIteration. ?Otherwise it could get propagated silently up to some > unrelated for loop higher in the stack, resulting in unexpected behavior. > > Cheers, > Ian That's brilliant, exactly the code I was looking for. Thanks very much Ian! Erich From michele.simionato at gmail.com Wed Jan 12 00:41:24 2011 From: michele.simionato at gmail.com (Michele Simionato) Date: Tue, 11 Jan 2011 21:41:24 -0800 (PST) Subject: Ideas for a module to process command line arguments References: Message-ID: <2ee89e8b-f7f6-48f2-9b7e-6b8592db0c13@k30g2000vbn.googlegroups.com> On Jan 11, 4:06?pm, Alice Bevan?McGregor wrote: > After looking into it, Plac's default help display isn't very helpful; > you need to massage your application a fair amount before generating > nice, complete-looking argument lists and such. ?For example: > > ? ? ? ? def main(verbose: ('prints more info', 'flag', 'v'), dsn: 'connection > string'): > > ? ? ? ? @annotate(dsn="connection string", verbose="prints more info") > ? ? ? ? def main(dsn, verbose=False): > > The latter is marrow.script, and even without the annotation a more > complete help text is generated. ?The -v and flag nature are assumed > from the first unique character and default value. ?(Flags, when > present on the command line, invert the default value.) Honestly I do not see any significant difference both in the level of verbosity for the annotations and in the quality of the help message provided in the absence of annotations. Originally plac too was able to recognize flags automatically by looking at the default value (if the default value is a boolean then the option is a flag); however I removed that functionality because I wanted to be able to differentiate between flag and (smart) options (see http://micheles.googlecode.com/hg/plac/doc/plac.html#scripts-with-options-and-smart-options). From michele.simionato at gmail.com Wed Jan 12 00:43:41 2011 From: michele.simionato at gmail.com (Michele Simionato) Date: Tue, 11 Jan 2011 21:43:41 -0800 (PST) Subject: Ideas for a module to process command line arguments References: <941cfb0b-e34b-4d07-8c51-293656878f6a@z19g2000yqb.googlegroups.com> <8dd04926-2ad2-4c01-b9e7-5843e801852f@39g2000yqa.googlegroups.com> Message-ID: <9745a845-7d39-4e84-91c8-b656681c9a6b@j1g2000vbl.googlegroups.com> On Jan 11, 6:57?pm, Mike wrote: > On Jan 11, 11:26?am, Michele Simionato > wrote: > > In that case easy_install/pip/whatever will install the dependency > > automatically (who is installing > > dependencies by hand nowadays?). > > I do. Is this bad? :} You are simply spending more time than needed, since there are already tools available to perform the task for you. From doomster at knuut.de Wed Jan 12 01:36:21 2011 From: doomster at knuut.de (Ulrich Eckhardt) Date: Wed, 12 Jan 2011 07:36:21 +0100 Subject: the C header file when extending CPython References: Message-ID: <8p50f6F4lpU1@mid.uni-berlin.de> Yingjie Lan wrote: > I am wondering when extending Python (CPython), what should be put into > the C header file? Any guidelines? You don't even need to write a header file at all. There are no Python- specific requirements to put anything into a header file, though you might want to do so for reasons internal to your project. Uli From __peter__ at web.de Wed Jan 12 03:39:37 2011 From: __peter__ at web.de (Peter Otten) Date: Wed, 12 Jan 2011 09:39:37 +0100 Subject: Syntactic structure for 'until :' loop References: <198391a1-7257-4422-a076-35b815ab99c6@l22g2000vbp.googlegroups.com> Message-ID: Ian Kelly wrote: > reader_iter = iter(self.reader) > headers = reader_iter.next() > # intermediate code > for line in reader_iter: > data.append(line) > return data If data is a list the for loop can be replaced with data.extend(reader_iter) or, if data is an empty list created within the function data = list(reader_iter) From prakash.stack at gmail.com Wed Jan 12 05:27:12 2011 From: prakash.stack at gmail.com (prakash jp) Date: Wed, 12 Jan 2011 15:57:12 +0530 Subject: read text color from image Message-ID: Hi All, During automation of a test case the web interface throws failure and sucess text in RED and GREEN colors respectively. Is there a method to read the color of the Success(green) and Failure(red) from the screenshots of the webinterfaces collect for Failure and Success say : import Image import ImageChops im2 = Image.open("Failure.JPG") im1 = Image.open("Sucess.JPG") #print list(im1.getdata()) diff = ImageChops.difference(im2, im1) #print diff.getbbox() #diff.show() #print im1.tostring() Thanks for all in advance Prakash -------------- next part -------------- An HTML attachment was scrubbed... URL: From cjwilliams43 at gmail.com Wed Jan 12 09:51:50 2011 From: cjwilliams43 at gmail.com (Colin J. Williams) Date: Wed, 12 Jan 2011 09:51:50 -0500 Subject: Python use growing fast In-Reply-To: References: Message-ID: On 10-Jan-11 16:02 PM, MRAB wrote: > On 10/01/2011 20:29, Dan Stromberg wrote: >> I invite folks to check out Tiobe's Language Popularity Rankings: >> >> http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html >> >> The gist is: Python grew faster than any other programming language >> over the last year, according to this (slightly arbitrary, but better >> than no indicator) ranking. >> >> ...despite our wikipedia page whose first paragraph almost seems like >> it was written with the intention of scaring off new converts, with >> its "unusual" comment: >> >> http://en.wikipedia.org/wiki/Python_%28programming_language%29 >> >> (Like it or not, people do frequently confuse the descriptive for the >> normative) > > It shows an example of Python code, which happens to have 2 syntax > errors! Why not correct the Wikipedia entry? Colin W. From aharrisreid at googlemail.com Wed Jan 12 11:37:16 2011 From: aharrisreid at googlemail.com (Alan Harris-Reid) Date: Wed, 12 Jan 2011 16:37:16 +0000 Subject: Career path - where next? Message-ID: <4D2DD8BC.1020907@googlemail.com> Hi there, I wonder if any Python folk out there can help me. For many years I was a contractor developing desktop and web applications using Visual Foxpro as my main language, with Foxpro, SQL-server and Oracle as back-end databases. Unfortunately Foxpro was killed-off by Microsoft, hence my work dried-up and my last 'big' contract ended about a year ago. Since then I have taken time off programming doing house-renovation, and in the last 6 months I have been updating my programming skills by learning Python (3) with SQLite, JavaScript, HTML and CSS to a level where I can create and deploy data-based web-sites. My situation now is that I am reasonably comfortable with the above languages and am now in a position where I wish to return to employment using my new and/or existing skills (contract/permanent, full/part-time or teleworking). However, I have yet to find any UK vacancy which will accept a relative 'beginner' - they all require at least 2-3 years Python in a commercial environment. It's a catch-22 situation - it's hard to get a job without experience, but you need a job to get experience in the 1st place! I would even consider doing small projects for nothing so that I can 'get my foot in the door' (although I hope to be wise-enough to know when I am being taken advantage of!). I am also mailing CVs to agencies I think may be interested. If anyone out has ideas as to how to proceed towards achieving my goal, I would be grateful for any advice. Regards, Alan Harris-Reid From tjreedy at udel.edu Wed Jan 12 11:56:53 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Wed, 12 Jan 2011 11:56:53 -0500 Subject: Career path - where next? In-Reply-To: <4D2DD8BC.1020907@googlemail.com> References: <4D2DD8BC.1020907@googlemail.com> Message-ID: On 1/12/2011 11:37 AM, Alan Harris-Reid wrote: ... > updating my programming skills by learning Python (3) with SQLite, > JavaScript, HTML and CSS to a level where I can create and deploy > data-based web-sites. ... > I would even consider doing small projects for nothing so that I can > 'get my foot in the door' (although I hope to be wise-enough to know I believe both Roundup/Python tracker and PyPI (Python package index) are based on sqlite and have small projects available/needed. I cannot help you otherwise. Good luck. -- Terry Jan Reedy From tjreedy at udel.edu Wed Jan 12 12:01:15 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Wed, 12 Jan 2011 12:01:15 -0500 Subject: Python use growing fast In-Reply-To: References: Message-ID: On 1/12/2011 9:51 AM, Colin J. Williams wrote: >> It shows an example of Python code, which happens to have 2 syntax >> errors! > > Why not correct the Wikipedia entry? As I reported early, the errors, if any, are in .png and .svg images of text, which would have to be replaced, not corrected. Would be good since the imaged snippet is a haphazard except from a much larger file and inane out of context. -- Terry Jan Reedy From alice at gothcandy.com Wed Jan 12 12:09:56 2011 From: alice at gothcandy.com (=?utf-8?Q?Alice_Bevan=E2=80=93McGregor?=) Date: Wed, 12 Jan 2011 09:09:56 -0800 Subject: Ideas for a module to process command line arguments References: <2ee89e8b-f7f6-48f2-9b7e-6b8592db0c13@k30g2000vbn.googlegroups.com> Message-ID: On 2011-01-11 21:41:24 -0800, Michele Simionato said: > Originally plac too was able to recognize flags automatically by > looking at the default value (if the default value is a boolean then > the option is a flag); however I removed that functionality because I > wanted to be able to differentiate between flag and (smart) options > (see > http://micheles.googlecode.com/hg/plac/doc/plac.html#scripts-with-options-and-smart-options). Not > entirely sure what you mean by 'smart' options. If your'e referring to using a single hyphen and a list of characters to represent a long option (which, to the rest of the world, use two leading hyphens) then that's pretty weird. ;) Consider most of the GNU tools: ls -lvh tar -xzvf file.tgz (goes so far as to make the leading hyphen optional!) less -ceF logfile bc -qw ps -aux (same as tar) And even third-party tools: mysql -fH pg_dump -abO ... One major system in the world that doesn't really differentiate between long and short options is... DOS, and by extension, Windows. But they also use / as a switch character. Anyway; I'm happy with what I have wrought (and am continuing to update with support for class-based sub-command dispatch) and will be utilizing it for all scripts in the Marrow suite. To each their own, but reinvention itself can be for motivations other than NIH. I wanted something pure-Python, portable across the 3k barrier without code modification (no 2to3), that didn't use optparse, getopt, or argparse and basically be a translation layer. It can be simpler than that, as marrow.script demonstrates. - Alice. From philip at semanchuk.com Wed Jan 12 13:28:23 2011 From: philip at semanchuk.com (Philip Semanchuk) Date: Wed, 12 Jan 2011 13:28:23 -0500 Subject: Career path - where next? In-Reply-To: <4D2DD8BC.1020907@googlemail.com> References: <4D2DD8BC.1020907@googlemail.com> Message-ID: On Jan 12, 2011, at 11:37 AM, Alan Harris-Reid wrote: > > Hi there, I wonder if any Python folk out there can help me. > > For many years I was a contractor developing desktop and web applications using Visual Foxpro as my main language, with Foxpro, SQL-server and Oracle as back-end databases. Unfortunately Foxpro was killed-off by Microsoft, hence my work dried-up and my last 'big' contract ended about a year ago. Since then I have taken time off programming doing house-renovation, and in the last 6 months I have been updating my programming skills by learning Python (3) with SQLite, JavaScript, HTML and CSS to a level where I can create and deploy data-based web-sites. > > My situation now is that I am reasonably comfortable with the above languages and am now in a position where I wish to return to employment using my new and/or existing skills (contract/permanent, full/part-time or teleworking). However, I have yet to find any UK vacancy which will accept a relative 'beginner' - they all require at least 2-3 years Python in a commercial environment. It's a catch-22 situation - it's hard to get a job without experience, but you need a job to get experience in the 1st place! > > I would even consider doing small projects for nothing so that I can 'get my foot in the door' (although I hope to be wise-enough to know when I am being taken advantage of!). I am also mailing CVs to agencies I think may be interested. > > If anyone out has ideas as to how to proceed towards achieving my goal, I would be grateful for any advice. Contributing to open source projects (your own or someone else's) will help to convince some employers that you're worth taking a look at. If nothing else it gives you a public example of the work that you can point them to. Good luck Philip From krzysztof.t.bieniasz at gmail.com Wed Jan 12 13:44:52 2011 From: krzysztof.t.bieniasz at gmail.com (Krzysztof Bieniasz) Date: Wed, 12 Jan 2011 18:44:52 +0000 (UTC) Subject: Python use growing fast References: Message-ID: > As I reported early, the errors, if any, are in .png and .svg images of > text, which would have to be replaced, not corrected. Would be good > since the imaged snippet is a haphazard except from a much larger file > and inane out of context. I don't think it really is a big deal. I mean, this is merely an illustration for the syntax-highlighted python code. So the message isn't: "Go ahead and try it with your Python". It's rather "Look, you can have colorful highlighting of python code, isn't that cool?!" It actually presents the specific indentation of Python code and therefore it is mostly useful to someone who never used Python. And actually I wouldn't expect any Python programmer to look for feedback on Wikipedia. It's not that I have anything against Wikipedia -- on the contrary, I use it all the time. But remember that it's an encyclopedia not a Python manual. From joncle at googlemail.com Wed Jan 12 13:47:41 2011 From: joncle at googlemail.com (Jon Clements) Date: Wed, 12 Jan 2011 10:47:41 -0800 (PST) Subject: Career path - where next? References: Message-ID: On Jan 12, 4:37?pm, Alan Harris-Reid wrote: > Hi there, I wonder if any Python folk out there can help me. > > For many years I was a contractor developing desktop and web > applications using Visual Foxpro as my main language, with Foxpro, > SQL-server and Oracle as back-end databases. ?Unfortunately Foxpro was > killed-off by Microsoft, hence my work dried-up and my last 'big' > contract ended about a year ago. ?Since then I have taken time off > programming doing house-renovation, and in the last 6 months I have been > updating my programming skills by learning Python (3) with SQLite, > JavaScript, HTML and CSS to a level where I can create and deploy > data-based web-sites. > > My situation now is that I am reasonably comfortable with the above > languages and am now in a position where I wish to return to employment > using my new and/or existing skills (contract/permanent, full/part-time > or teleworking). ? However, I have yet to find any UK vacancy which will > accept a relative 'beginner' - they all require at least 2-3 years > Python in a commercial environment. ?It's a catch-22 situation - it's > hard to get a job without experience, but you need a job to get > experience in the 1st place! > > I would even consider doing small projects for nothing so that I can > 'get my foot in the door' (although I hope to be wise-enough to know > when I am being taken advantage of!). ?I am also mailing CVs to agencies > I think may be interested. > > If anyone out has ideas as to how to proceed towards achieving my goal, > I would be grateful for any advice. > > Regards, > Alan Harris-Reid Hi Alan, Just some ideas (not in any order, just as they're thought of):- - Emphasise your experience with Oracle & SQL Server, and use Python as a "I also have". It may be someone will accept that as viable (saves them a DBA or something), and maybe you'll get into an experienced group and get on the job training. (I assume you have good SQL skills). - Look at cwjobs.co.uk / monster / etc..., and search for Python. Get a list of agencies there. Phone them *first*, explain what is it you've done, and what you can do. If the person seems to know what they're talking about send your CV - but chase often. - Look at web-frameworks. Django seems to be the most listed for "required"/"nice to have". Also check out javascript-frameworks - jquery & extjs are the biggest 2, so at least you can say you've had some experience. - Perhaps phone your local job centre, and ask for a contact for their local volunteer centre. They might have something like work for a small charity that just needs a couple of pages done. The idea being: 1) If it's a cause you believe in, it makes up for not getting paid; 2) You can use it as an example and reference; 3) You might be able to use it as networking - might get a free lunch from an event and meet someone with money, that's impressed with your good will and work, and just happens to have a job going spare... - Build a copy of your CV designed for the web. Make sure it looks good, is HTML/CSS compliant, and even add some nice interactive stuff to it, and include it as a link in your CV. [The other thing you can do, is only display the CV on entry of a short PIN (different for each one you send - '2431' or something'), then you can log who's bothered looking at it, and when, enabling timing of a follow-up better)]. - Look in local papers for local companies that offer not necessarily web design, but possibly just print design. See if you can't have a chat with them and get some work your way. Other options might be new- starts up, non-chain pubs, community/sports clubs, a local church for fund-raising, your local chinese/indian takeaway - wouldn't hurt to put their menu online with an online order form would it!? [What you might find about this, is that as they're not likely to be technical, you can take your own time, charge a reasonable amount, experiment a little and learn, and not have too tight deadlines or someone looking over your shoulder]. Brain (or somewhere else) dump finished. hth Jon. From msarro at gmail.com Wed Jan 12 13:59:05 2011 From: msarro at gmail.com (Matty Sarro) Date: Wed, 12 Jan 2011 13:59:05 -0500 Subject: Best way to automatically copy out attachments from an email Message-ID: As of now here is my situation: I am working on a system to aggregate IT data and logs. A number of important data are gathered by a third party system. The only immediate way I have to access the data is to have their system automatically email me updates in CSV format every hour. If I set up a mail client on the server, this shouldn't be a huge issue. However, is there a way to automatically open the emails, and copy the attachments to a directory based on the filename? Kind of a weird project, I know. Just looking for some ideas hence posting this on two lists. Thanks all, and happy hump day! -Matty From Catherine.M.Moroney at jpl.nasa.gov Wed Jan 12 14:07:24 2011 From: Catherine.M.Moroney at jpl.nasa.gov (Catherine Moroney) Date: Wed, 12 Jan 2011 11:07:24 -0800 Subject: order of importing modules In-Reply-To: References: <4D2CF61E.7010500@jpl.nasa.gov> Message-ID: <4D2DFBEC.1070605@jpl.nasa.gov> I've looked at my sys.path variable and I see that it has a whole bunch of site-package directories, followed by the contents of my $PYTHONPATH variable, followed by a list of misc site-package variables (see below). I've verified that if I manually reverse the order of sys.path I can then import the proper version of the module that I want. But this is not a permanent solution for me as this will mess up other people are who working with the same code. But, I'm curious as to where the first bunch of 'site-package' entries come from. The /usr/lib64/python2.5/site-packages/pyhdfeos-1.0_r57_58-py2.5-linux-x86_64.egg is not present in any of my environmental variables yet it shows up as one of the first entries in sys.path. A colleague of mine is running on the same system as I am, and he does not have the problem of the /usr/lib64/python2.5/site-packages/pyhdfeos-1.0_r57_58-py2.5-linux-x86_64.egg variable showing up as one of the first entries in sys.path. Thanks for the education, Catherine Dan Stromberg wrote: > On Tue, Jan 11, 2011 at 4:30 PM, Catherine Moroney > wrote: >> In what order does python import modules on a Linux system? I have a >> package that is both installed in /usr/lib64/python2.5/site-packages, >> and a newer version of the same module in a working directory. >> >> I want to import the version from the working directory, but when I >> print module.__file__ in the interpreter after importing the module, >> I get the version that's in site-packages. >> >> I've played with the PYTHONPATH environmental variable by setting it >> to just the path of the working directory, but when I import the module >> I still pick up the version in site-packages. >> >> /usr/lib64 is in my PATH variable, but doesn't appear anywhere else. I >> don't want to remove /usr/lib64 from my PATH because that will break >> a lot of stuff. >> >> Can I force python to import from my PYTHONPATH first, before looking >> in the system directory? >> >> Catherine >> -- >> http://mail.python.org/mailman/listinfo/python-list > > Please import sys and inspect sys.path; this defines the search path > for imports. > > By looking at sys.path, you can see where in the search order your > $PYTHONPATH is going. > > It might actually be better to give your script a command line option > that says "Throw the following directory at the beginning of > sys.path". From justpark78 at gmail.com Wed Jan 12 14:09:45 2011 From: justpark78 at gmail.com (justin) Date: Wed, 12 Jan 2011 11:09:45 -0800 (PST) Subject: How to populate all possible hierarchical clusterings from a set of elements? Message-ID: <3cb5ae7e-866d-40fb-ae3f-496193db91e4@t35g2000yqj.googlegroups.com> The title sounds too complex, but my question is actually simple. Suppose I have [1,2,3,4,5], then there are many ways of making clustering. Among them, I want to pair up terminals until there is only one left at the end. For example, ((((1,2),3),4),5), (1,(2,(3,(4,5)))), or (((1,2),(3,4)), 5) would be legitimate ones. How do you think can I, using the modules of Python such as itertools as much as possible, make all possible such clusterings? Thanks in advance, Justin. From physicsandpython at gmail.com Wed Jan 12 14:22:30 2011 From: physicsandpython at gmail.com (Physics Python) Date: Wed, 12 Jan 2011 11:22:30 -0800 (PST) Subject: Nested structures question Message-ID: Hello, I am teaching myself python using the book: Python Programming for Absolute Beginners, 2nd edition by Michael Dawson. I am using python 2.7.1. In chapter 3 we are learning to use structures (while, if, elif) to write a program that has the user guess a number between 1 and 100. Here is the code for the baseline program: ------------- start -------------- # Guess My Number # # The computer picks a random number between 1 and 100 # The player tries to guess it and the computer lets # the player know if the guess is too high, too low # or right on the money import random print "\tWelcome to 'Guess My Number'!" print "\nI'm thinking of a number between 1 and 100." print "Try to guess it in as few attempts as possible.\n" # set the initial values the_number = random.randrange(100) + 1 guess = int(raw_input("Take a guess: ")) tries = 1 # guessing loop while (guess != the_number): if (guess > the_number): print "Lower..." else: print "Higher..." guess = int(raw_input("Take a guess: ")) tries += 1 print "You guessed it! The number was", the_number print "And it only took you", tries, "tries!\n" raw_input("\n\nPress the enter key to exit.") ------------------- end --------------------- The book asks to write a version of this program that limits the number of guess the user can take. I have tried to write this program, and I am getting some run time errors. Can anybody take a look at my code and give me some advice or hints? Thanks! ---- start --- # Number Guessing Game Version 2 # # The computer picks a random number between 1 and 100 # The player tries to guess and the computer tells # the player if the guess is high or low or correct # The player has to guess the number in less than 7 tries. # # 1/12/2011 import random # welcome the player to the game print "\tWelcome to 'Guess My Number'!" print "\nI am thinking of a number between 1 and 100." print "Try and guess it in as few attempts as possible.\n" # Set the initial values the_number= random.randrange(100) + 1 guess = int(raw_input("Take a guess: ")) tries = 1 # Guessing loop while guess != the_number: while tries > 7: if guess > the_number: print "Lower..." else: print "Higher..." guess = int(raw_input("Take a guess: ")) tries += 1 print "You guessed it! The number was: ", the_number print "And it only took you", tries, "tries!\n" print "Wow, you suck at this, you should be able to solve this in 7 attempts or less" raw_input("Press Enter to exit the program.") ------- end ----- From Catherine.M.Moroney at jpl.nasa.gov Wed Jan 12 14:38:39 2011 From: Catherine.M.Moroney at jpl.nasa.gov (Catherine Moroney) Date: Wed, 12 Jan 2011 11:38:39 -0800 Subject: order of importing modules In-Reply-To: References: <4D2CF61E.7010500@jpl.nasa.gov> Message-ID: <4D2E033F.6030704@jpl.nasa.gov> I've looked at my sys.path variable and I see that it has a whole bunch of site-package directories, followed by the contents of my $PYTHONPATH variable, followed by a list of misc site-package variables (see below). I've verified that if I manually reverse the order of sys.path I can then import the proper version of the module that I want. But this is not a permanent solution for me as this will mess up other people are who working with the same code. But, I'm curious as to where the first bunch of 'site-package' entries come from. The /usr/lib64/python2.5/site-packages/pyhdfeos-1.0_r57_58-py2.5-linux-x86_64.egg is not present in any of my environmental variables yet it shows up as one of the first entries in sys.path. A colleague of mine is running on the same system as I am, and he does not have the problem of the /usr/lib64/python2.5/site-packages/pyhdfeos-1.0_r57_58-py2.5-linux-x86_64.egg variable showing up as one of the first entries in sys.path. Thanks for the education, Catherine Dan Stromberg wrote: > On Tue, Jan 11, 2011 at 4:30 PM, Catherine Moroney > wrote: >> In what order does python import modules on a Linux system? I have a >> package that is both installed in /usr/lib64/python2.5/site-packages, >> and a newer version of the same module in a working directory. >> >> I want to import the version from the working directory, but when I >> print module.__file__ in the interpreter after importing the module, >> I get the version that's in site-packages. >> >> I've played with the PYTHONPATH environmental variable by setting it >> to just the path of the working directory, but when I import the module >> I still pick up the version in site-packages. >> >> /usr/lib64 is in my PATH variable, but doesn't appear anywhere else. I >> don't want to remove /usr/lib64 from my PATH because that will break >> a lot of stuff. >> >> Can I force python to import from my PYTHONPATH first, before looking >> in the system directory? >> >> Catherine >> -- >> http://mail.python.org/mailman/listinfo/python-list > > Please import sys and inspect sys.path; this defines the search path > for imports. > > By looking at sys.path, you can see where in the search order your > $PYTHONPATH is going. > > It might actually be better to give your script a command line option > that says "Throw the following directory at the beginning of > sys.path". From usernet at ilthio.net Wed Jan 12 14:41:53 2011 From: usernet at ilthio.net (Tim Harig) Date: Wed, 12 Jan 2011 19:41:53 +0000 (UTC) Subject: Nested structures question References: Message-ID: On 2011-01-12, Physics Python wrote: > while guess != the_number: ================================================= > while tries > 7: > if guess > the_number: > print "Lower..." > else: > print "Higher..." > guess = int(raw_input("Take a guess: ")) > tries += 1 ================================================= Think about what happens when this nested loop exits because tries > 7? It returns to the outer loop whether or not the actual number was guessed correctly. There is no real need for this loop. > print "You guessed it! The number was: ", the_number > print "And it only took you", tries, "tries!\n" Note that the outer loop ends here without any test to see whether or not the number was actually guested and there is *nothing* that stops this outer loop, so it will spin forever. > print "Wow, you suck at this, you should be able to solve this in 7 attempts or less" > > raw_input("Press Enter to exit the program.") This is never reached. From invalid at invalid.invalid Wed Jan 12 14:51:00 2011 From: invalid at invalid.invalid (Grant Edwards) Date: Wed, 12 Jan 2011 19:51:00 +0000 (UTC) Subject: Python use growing fast References: Message-ID: On 2011-01-12, Terry Reedy wrote: > On 1/12/2011 9:51 AM, Colin J. Williams wrote: > >>> It shows an example of Python code, which happens to have 2 syntax >>> errors! >> >> Why not correct the Wikipedia entry? > > As I reported early, the errors, if any, are in .png and .svg images of > text, which would have to be replaced, not corrected. Would be good > since the imaged snippet is a haphazard except from a much larger file > and inane out of context. OK, but that answerws the question "what's wrong with it?", not "why not fix it?" -- Grant Edwards grant.b.edwards Yow! Thousands of days of at civilians ... have produced gmail.com a ... feeling for the aesthetic modules -- From physicsandpython at gmail.com Wed Jan 12 14:52:33 2011 From: physicsandpython at gmail.com (Physics Python) Date: Wed, 12 Jan 2011 11:52:33 -0800 (PST) Subject: Nested structures question In-Reply-To: Message-ID: <89b61e2d-cb26-4a44-9c86-57e7461a9eb8@glegroupsg2000goo.googlegroups.com> Thanks, Is this an indentation problem then? How do I update the sentinel within the secondary while loop. I am trying to avoid using breaks by the way, as I can program this example using breaks: --- start--- import random print "\tWelcome to 'Guess my number'!:" print "\nI'm thinking of a number between 1 and 100." print "Try to guess it in as few attempts as possible.\n" the_number = random.randrange(1,101) tries = 0 while True: guess = int(raw_input("Take a guess: ")) tries += 1 if guess > the_number: print "Lower..." elif guess < the_number: print "Higher..." else: print "You guessed it! The number was", the_number print "And it only took you", tries, "tries!\n" break if tries == 7: print "Wow you suck! It should only take at most 7 tries!" break raw_input ("\n\nPress the enter key to exit.") --- end --- But the book states that this can be done without needing to use breaks. Thanks! From jasons at adventureaquarium.com Wed Jan 12 15:04:36 2011 From: jasons at adventureaquarium.com (Jason Staudenmayer) Date: Wed, 12 Jan 2011 15:04:36 -0500 Subject: Nested structures question In-Reply-To: <89b61e2d-cb26-4a44-9c86-57e7461a9eb8@glegroupsg2000goo.googlegroups.com> Message-ID: Return False instead of break should work else: print "You guessed it! The number was", the_number print "And it only took you", tries, "tries!\n" return False Jason ..?><((((?> > -----Original Message----- > From: > python-list-bounces+jasons=adventureaquarium.com at python.org > [mailto:python-list-bounces+jasons=adventureaquarium.com at pytho > n.org] On Behalf Of Physics Python > Sent: Wednesday, January 12, 2011 2:53 PM > To: python-list at python.org > Subject: Re: Nested structures question > > > Thanks, > > Is this an indentation problem then? > How do I update the sentinel within the secondary while loop. > I am trying to avoid using breaks by the way, as I can > program this example using breaks: > > --- start--- > import random > print "\tWelcome to 'Guess my number'!:" > print "\nI'm thinking of a number between 1 and 100." > print "Try to guess it in as few attempts as possible.\n" > > the_number = random.randrange(1,101) > > tries = 0 > > while True: > guess = int(raw_input("Take a guess: ")) > tries += 1 > if guess > the_number: > print "Lower..." > elif guess < the_number: > print "Higher..." > else: > print "You guessed it! The number was", the_number > print "And it only took you", tries, "tries!\n" > break > if tries == 7: > print "Wow you suck! It should only take at most 7 tries!" > break > > raw_input ("\n\nPress the enter key to exit.") > > --- end --- > > But the book states that this can be done without needing to > use breaks. > > Thanks! > -- > http://mail.python.org/mailman/listinfo/python-list > From usernet at ilthio.net Wed Jan 12 15:12:11 2011 From: usernet at ilthio.net (Tim Harig) Date: Wed, 12 Jan 2011 20:12:11 +0000 (UTC) Subject: Nested structures question References: <89b61e2d-cb26-4a44-9c86-57e7461a9eb8@glegroupsg2000goo.googlegroups.com> Message-ID: [wrapped lines to <80 characters per RFC 1855] On 2011-01-12, Physics Python wrote: > Is this an indentation problem then? That depends how you look at it. I was not clear from your code exactly where you wanted to handle things. > How do I update the sentinel within the secondary while loop. I am > trying to avoid using breaks by the way, as I can program this example > using breaks: You don't need breaks. > import random > print "\tWelcome to 'Guess my number'!:" > print "\nI'm thinking of a number between 1 and 100." > print "Try to guess it in as few attempts as possible.\n" > > the_number = random.randrange(1,101) > > tries = 0 > > while True: while can be used to test for more then a single condition at a time using and/or chains. > else: > print "You guessed it! The number was", the_number > print "And it only took you", tries, "tries!\n" > break > if tries == 7: > print "Wow you suck! It should only take at most 7 tries!" > break Both of these tests can be performed as part of the loop itself. The end results can therefore be tested and handled outside of the loop without using breaks. From usernet at ilthio.net Wed Jan 12 15:22:24 2011 From: usernet at ilthio.net (Tim Harig) Date: Wed, 12 Jan 2011 20:22:24 +0000 (UTC) Subject: Nested structures question References: Message-ID: On 2011-01-12, Jason Staudenmayer wrote: > Return False instead of break should work > > else: > print "You guessed it! The number was", the_number > print "And it only took you", tries, "tries!\n" > return False Since he isn't in a function, that isn't any good. He would import sys and use sys.exit() but that rather defeats the purpose of having a single entry and exit point to the loop. From __peter__ at web.de Wed Jan 12 15:43:22 2011 From: __peter__ at web.de (Peter Otten) Date: Wed, 12 Jan 2011 21:43:22 +0100 Subject: How to populate all possible hierarchical clusterings from a set of elements? References: <3cb5ae7e-866d-40fb-ae3f-496193db91e4@t35g2000yqj.googlegroups.com> Message-ID: justin wrote: > The title sounds too complex, but my question is actually simple. > > Suppose I have [1,2,3,4,5], then there are many ways of making > clustering. > Among them, I want to pair up terminals until there is only one left > at the end. > For example, ((((1,2),3),4),5), (1,(2,(3,(4,5)))), or (((1,2),(3,4)), > 5) would be legitimate ones. > > How do you think can I, using the modules of Python such as itertools > as much as possible, make all possible such clusterings? Here's my first attempt: def cluster(items): if len(items) == 2: yield items return for i in range(len(items)-1): for c in cluster(items[:i] + (items[i:i+2],) + items[i+2:]): yield c def unique(items): seen = set() for item in items: if item not in seen: seen.add(item) yield item if __name__ == "__main__": for item in unique(cluster(tuple("abcd"))): print item Unfortunately I get a lot of duplicates :( You could define a kind of operator precedence using itertools.combinations(), but I think it suffers from the same problem as a 3 b 1 c 2 d and a 2 b 1 c 3 d would both result in ((a, b), (c, d)). From scott.mccarty at gmail.com Wed Jan 12 16:05:22 2011 From: scott.mccarty at gmail.com (Scott McCarty) Date: Wed, 12 Jan 2011 16:05:22 -0500 Subject: How to Buffer Serialized Objects to Disk Message-ID: Sorry to ask this question. I have search the list archives and googled, but I don't even know what words to find what I am looking for, I am just looking for a little kick in the right direction. I have a Python based log analysis program called petit ( http://crunchtools.com/petit). I am trying to modify it to manage the main object types to and from disk. Essentially, I have one object which is a list of a bunch of "Entry" objects. The Entry objects have date, time, date, etc fields which I use for analysis techniques. At the very beginning I build up the list of objects then would like to start pickling it while building to save memory. I want to be able to process more entries than I have memory. With a strait list it looks like I could build from xreadlines(), but once you turn it into a more complex object, I don't quick know where to go. I understand how to pickle the entire data structure, but I need something that will manage the memory/disk allocation? Any thoughts? Gracias Scott M -------------- next part -------------- An HTML attachment was scrubbed... URL: From alice at gothcandy.com Wed Jan 12 16:08:47 2011 From: alice at gothcandy.com (=?utf-8?Q?Alice_Bevan=E2=80=93McGregor?=) Date: Wed, 12 Jan 2011 13:08:47 -0800 Subject: Python use growing fast References: <4d2b8844$0$43996$742ec2ed@news.sonic.net> Message-ID: On 2011-01-10 19:49:47 -0800, Roy Smith said: > One of the surprising (to me, anyway) uses of JavaScript is as the > scripting language for MongoDB (http://www.mongodb.org/). I just wish they'd drop spidermonkey and go with V8 or another, faster and more modern engine. :( - Alice. From crebert at ucsd.edu Wed Jan 12 16:31:59 2011 From: crebert at ucsd.edu (Chris Rebert) Date: Wed, 12 Jan 2011 13:31:59 -0800 Subject: order of importing modules In-Reply-To: <4D2DFBEC.1070605@jpl.nasa.gov> References: <4D2CF61E.7010500@jpl.nasa.gov> <4D2DFBEC.1070605@jpl.nasa.gov> Message-ID: > Dan Stromberg wrote: >> On Tue, Jan 11, 2011 at 4:30 PM, Catherine Moroney >> wrote: >>> >>> In what order does python import modules on a Linux system? ?I have a >>> package that is both installed in /usr/lib64/python2.5/site-packages, >>> and a newer version of the same module in a working directory. >>> >>> I want to import the version from the working directory, but when I >>> print module.__file__ in the interpreter after importing the module, >>> I get the version that's in site-packages. >>> >>> I've played with the PYTHONPATH environmental variable by setting it >>> to just the path of the working directory, but when I import the module >>> I still pick up the version in site-packages. >>> >>> /usr/lib64 is in my PATH variable, but doesn't appear anywhere else. ?I >>> don't want to remove /usr/lib64 from my PATH because that will break >>> a lot of stuff. >>> >>> Can I force python to import from my PYTHONPATH first, before looking >>> in the system directory? >>> >> Please import sys and inspect sys.path; this defines the search path >> for imports. >> >> By looking at sys.path, you can see where in the search order your >> $PYTHONPATH is going. >> On Wed, Jan 12, 2011 at 11:07 AM, Catherine Moroney wrote: > I've looked at my sys.path variable and I see that it has > a whole bunch of site-package directories, followed by the > contents of my $PYTHONPATH variable, followed by a list of > misc site-package variables (see below). > But, I'm curious as to where the first bunch of 'site-package' > entries come from. ?The > /usr/lib64/python2.5/site-packages/pyhdfeos-1.0_r57_58-py2.5-linux-x86_64.egg > is not present in any of my environmental variables yet it shows up > as one of the first entries in sys.path. You probably have a .pth file somewhere that adds it (since it's an egg, probably site-packages/easy-install.pth). See http://docs.python.org/install/index.html#modifying-python-s-search-path Cheers, Chris -- http://blog.rebertia.com From python at mrabarnett.plus.com Wed Jan 12 16:32:49 2011 From: python at mrabarnett.plus.com (MRAB) Date: Wed, 12 Jan 2011 21:32:49 +0000 Subject: How to Buffer Serialized Objects to Disk In-Reply-To: References: Message-ID: <4D2E1E01.2070907@mrabarnett.plus.com> On 12/01/2011 21:05, Scott McCarty wrote: > Sorry to ask this question. I have search the list archives and googled, > but I don't even know what words to find what I am looking for, I am > just looking for a little kick in the right direction. > > I have a Python based log analysis program called petit > (http://crunchtools.com/petit). I am trying to modify it to manage the > main object types to and from disk. > > Essentially, I have one object which is a list of a bunch of "Entry" > objects. The Entry objects have date, time, date, etc fields which I use > for analysis techniques. At the very beginning I build up the list of > objects then would like to start pickling it while building to save > memory. I want to be able to process more entries than I have memory. > With a strait list it looks like I could build from xreadlines(), but > once you turn it into a more complex object, I don't quick know where to go. > > I understand how to pickle the entire data structure, but I need > something that will manage the memory/disk allocation? Any thoughts? > To me it sounds like you need to use a database. From clp2 at rebertia.com Wed Jan 12 16:41:32 2011 From: clp2 at rebertia.com (Chris Rebert) Date: Wed, 12 Jan 2011 13:41:32 -0800 Subject: How to Buffer Serialized Objects to Disk In-Reply-To: References: Message-ID: On Wed, Jan 12, 2011 at 1:05 PM, Scott McCarty wrote: > Sorry to ask this question. I have search the list archives and googled, but > I don't even know what words to find what I am looking for, I am just > looking for a little kick in the right direction. > I have a Python based log analysis program called petit > (http://crunchtools.com/petit). I am trying to modify it to manage the main > object types to and from disk. > Essentially, I have one object which is a list of a bunch of "Entry" > objects. The Entry objects have date, time, date, etc fields which I use for > analysis techniques. At the very beginning I build up the list of objects > then would like to start pickling it while building to save memory. I want > to be able to process more entries than I have memory. With a strait list it > looks like I could build from xreadlines(), but once you turn it into a more > complex object, I don't quick know where to go. > I understand how to pickle the entire data structure, but I need something > that will manage the memory/disk allocation? ?Any thoughts? You could subclass `list` and use sys.getsizeof() [http://docs.python.org/library/sys.html#sys.getsizeof ] to keep track of the size of the elements, and then start pickling them to disk once the total size reaches some preset limit. But like MRAB said, using a proper database, e.g. SQLite (http://docs.python.org/library/sqlite3.html ), wouldn't be a bad idea either. Cheers, Chris -- http://blog.rebertia.com From __peter__ at web.de Wed Jan 12 17:04:52 2011 From: __peter__ at web.de (Peter Otten) Date: Wed, 12 Jan 2011 23:04:52 +0100 Subject: How to Buffer Serialized Objects to Disk References: Message-ID: Scott McCarty wrote: > Sorry to ask this question. I have search the list archives and googled, > but I don't even know what words to find what I am looking for, I am just > looking for a little kick in the right direction. > > I have a Python based log analysis program called petit ( > http://crunchtools.com/petit). I am trying to modify it to manage the main > object types to and from disk. > > Essentially, I have one object which is a list of a bunch of "Entry" > objects. The Entry objects have date, time, date, etc fields which I use > for analysis techniques. At the very beginning I build up the list of > objects then would like to start pickling it while building to save > memory. I want to be able to process more entries than I have memory. With > a strait list it looks like I could build from xreadlines(), but once you > turn it into a more complex object, I don't quick know where to go. > > I understand how to pickle the entire data structure, but I need something > that will manage the memory/disk allocation? Any thoughts? You can write multiple pickled objects into a single file: import cPickle as pickle def dump(filename, items): with open(filename, "wb") as out: dump = pickle.Pickler(out).dump for item in items: dump(item) def load(filename): with open(filename, "rb") as instream: load = pickle.Unpickler(instream).load while True: try: item = load() except EOFError: break yield item if __name__ == "__main__": filename = "tmp.pickle" from collections import namedtuple T = namedtuple("T", "alpha beta") dump(filename, (T(a, b) for a, b in zip("abc", [1,2,3]))) for item in load(filename): print item To get random access you'd have to maintain a list containing the offsets of the entries in the file. However, a simple database like SQLite is probably sufficient for the kind of entries you have in mind, and it allows operations like aggregation, sorting and grouping out of the box. Peter From clp2 at rebertia.com Wed Jan 12 17:06:08 2011 From: clp2 at rebertia.com (Chris Rebert) Date: Wed, 12 Jan 2011 14:06:08 -0800 Subject: Best way to automatically copy out attachments from an email In-Reply-To: References: Message-ID: On Wed, Jan 12, 2011 at 10:59 AM, Matty Sarro wrote: > As of now here is my situation: > I am working on a system to aggregate IT data and logs. A number of > important data are gathered by a third party system. The only > immediate way I have to access the data is to have their system > automatically email me updates in CSV format every hour. If I set up a > mail client on the server, this shouldn't be a huge issue. > > However, is there a way to automatically open the emails, and copy the > attachments to a directory based on the filename? Kind of a weird > project, I know. Just looking for some ideas hence posting this on two > lists. Parsing out email attachments: http://docs.python.org/library/email.parser.html http://docs.python.org/library/email.message.html#module-email.message Parsing the extension from a filename: http://docs.python.org/library/os.path.html#os.path.splitext Retrieving email from a mail server: http://docs.python.org/library/poplib.html http://docs.python.org/library/imaplib.html You could poll for new messages via a cron job or the `sched` module (http://docs.python.org/library/sched.html ). Or if the messages are being delivered locally, you could use inotify bindings or similar to watch the appropriate directory for incoming mail. Integration with a mail server itself is also a possibility, but I don't know much about that. Cheers, Chris -- http://blog.rebertia.com From aahz at pythoncraft.com Wed Jan 12 17:07:28 2011 From: aahz at pythoncraft.com (Aahz) Date: 12 Jan 2011 14:07:28 -0800 Subject: Parsing string for " " References: <0d7143ca-45cf-44c3-9e8d-acb867c52037@f30g2000yqa.googlegroups.com> Message-ID: In article <0d7143ca-45cf-44c3-9e8d-acb867c52037 at f30g2000yqa.googlegroups.com>, Daniel da Silva wrote: > >I have come across a task where I would like to scan a short 20-80 >character line of text for instances of " ". Ideally > could be of any tense. In Soviet Russia, you! -- Aahz (aahz at pythoncraft.com) <*> http://www.pythoncraft.com/ "Think of it as evolution in action." --Tony Rand From usernet at ilthio.net Wed Jan 12 17:19:25 2011 From: usernet at ilthio.net (Tim Harig) Date: Wed, 12 Jan 2011 22:19:25 +0000 (UTC) Subject: Nested structures question References: <89b61e2d-cb26-4a44-9c86-57e7461a9eb8@glegroupsg2000goo.googlegroups.com> Message-ID: In case you still need help: - # Set the initial values - the_number= random.randrange(100) + 1 - tries = 0 - guess = None - - # Guessing loop - while guess != the_number and tries < 7: - guess = int(raw_input("Take a guess: ")) - if guess > the_number: - print "Lower..." - elif guess < the_number: - print "Higher..." - tries += 1 - - # did the user guess correctly to make too many guesses? - if guess == the_number: - print "You guessed it! The number was", the_number - print "And it only took you", tries, "tries!\n" - else: - print "Wow you suck! It should only take at most 7 tries!" - - raw_input("Press Enter to exit the program.") From scott.mccarty at gmail.com Wed Jan 12 17:29:19 2011 From: scott.mccarty at gmail.com (Scott McCarty) Date: Wed, 12 Jan 2011 17:29:19 -0500 Subject: How to Buffer Serialized Objects to Disk In-Reply-To: References: Message-ID: Been digging ever since I posted this. I suspected that the response might be use a database. I am worried I am trying to reinvent the wheel. The problem is I don't want any dependencies and I also don't need persistence program runs. I kind of wanted to keep the use of petit very similar to cat, head, awk, etc. But, that said, I have realized that if I provide the analysis features as an API, you very well, might want persistence between runs. What about using an array inside a shelve? Just got done messing with this in python shell: import shelve d = shelve.open(filename="/root/test.shelf", protocol=-1) d["log"] = () d["log"].append("test1") d["log"].append("test2") d["log"].append("test3") Then, always interacting with d["log"], for example: for i in d["log"]: print i Thoughts? I know this won't manage memory, but it will keep the footprint down right? On Wed, Jan 12, 2011 at 5:04 PM, Peter Otten <__peter__ at web.de> wrote: > Scott McCarty wrote: > > > Sorry to ask this question. I have search the list archives and googled, > > but I don't even know what words to find what I am looking for, I am just > > looking for a little kick in the right direction. > > > > I have a Python based log analysis program called petit ( > > http://crunchtools.com/petit). I am trying to modify it to manage the > main > > object types to and from disk. > > > > Essentially, I have one object which is a list of a bunch of "Entry" > > objects. The Entry objects have date, time, date, etc fields which I use > > for analysis techniques. At the very beginning I build up the list of > > objects then would like to start pickling it while building to save > > memory. I want to be able to process more entries than I have memory. > With > > a strait list it looks like I could build from xreadlines(), but once you > > turn it into a more complex object, I don't quick know where to go. > > > > I understand how to pickle the entire data structure, but I need > something > > that will manage the memory/disk allocation? Any thoughts? > > You can write multiple pickled objects into a single file: > > import cPickle as pickle > > def dump(filename, items): > with open(filename, "wb") as out: > dump = pickle.Pickler(out).dump > for item in items: > dump(item) > > def load(filename): > with open(filename, "rb") as instream: > load = pickle.Unpickler(instream).load > while True: > try: > item = load() > except EOFError: > break > yield item > > if __name__ == "__main__": > filename = "tmp.pickle" > from collections import namedtuple > T = namedtuple("T", "alpha beta") > dump(filename, (T(a, b) for a, b in zip("abc", [1,2,3]))) > for item in load(filename): > print item > > To get random access you'd have to maintain a list containing the offsets > of > the entries in the file. > However, a simple database like SQLite is probably sufficient for the kind > of entries you have in mind, and it allows operations like aggregation, > sorting and grouping out of the box. > > Peter > > -- > http://mail.python.org/mailman/listinfo/python-list > -------------- next part -------------- An HTML attachment was scrubbed... URL: From __peter__ at web.de Wed Jan 12 17:49:43 2011 From: __peter__ at web.de (Peter Otten) Date: Wed, 12 Jan 2011 23:49:43 +0100 Subject: How to Buffer Serialized Objects to Disk References: Message-ID: Scott McCarty wrote: > Been digging ever since I posted this. I suspected that the response might > be use a database. I am worried I am trying to reinvent the wheel. The > problem is I don't want any dependencies and I also don't need persistence > program runs. I don't think sqlite3 counts as a dependency these days. > I kind of wanted to keep the use of petit very similar to > cat, head, awk, etc. But, that said, I have realized that if I provide the > analysis features as an API, you very well, might want persistence between > runs. > > What about using an array inside a shelve? > > Just got done messing with this in python shell: > > import shelve > > d = shelve.open(filename="/root/test.shelf", protocol=-1) > > d["log"] = () > d["log"].append("test1") > d["log"].append("test2") > d["log"].append("test3") > > Then, always interacting with d["log"], for example: > > for i in d["log"]: > print i > > Thoughts? That won't save you any memory as the whole value (the complete list) is unpickled once you say d["log"]. From awilliam at whitemice.org Wed Jan 12 18:08:20 2011 From: awilliam at whitemice.org (Adam Tauno Williams) Date: Wed, 12 Jan 2011 18:08:20 -0500 Subject: How to Buffer Serialized Objects to Disk In-Reply-To: References: Message-ID: <1294873700.7831.3.camel@linux-yu4c.site> On Wed, 2011-01-12 at 17:29 -0500, Scott McCarty wrote: > Been digging ever since I posted this. I suspected that the response > might be use a database. I use shelve extensively; there are many use-cases where it makes sense. And there are many where a database makes sense. Basically, if I just want key based lookup and the data fits in memory I use a shelve. > The problem is I don't want any dependencies and I also don't need > persistence program runs. I kind of wanted to keep the use of petit > very similar to cat, head, awk, etc. But, that said, I have realized > that if I provide the analysis features as an API, you very well, > might want persistence between runs. > What about using an array inside a shelve? > Just got done messing with this in python shell: > import shelve > d = shelve.open(filename="/root/test.shelf", protocol=-1) > d["log"] = () > d["log"].append("test1") > d["log"].append("test2") > d["log"].append("test3") > Then, always interacting with d["log"], for example: > for i in d["log"]: > print i > Thoughts? That is fine so long as all your data fits comfortable in memory. > I know this won't manage memory, but it will keep the footprint down > right? No. All of "log" will always be in memory. From roy at panix.com Wed Jan 12 18:43:00 2011 From: roy at panix.com (Roy Smith) Date: Wed, 12 Jan 2011 18:43:00 -0500 Subject: Python use growing fast References: <4d2b8844$0$43996$742ec2ed@news.sonic.net> Message-ID: In article , Alice Bevan?McGregor wrote: > On 2011-01-10 19:49:47 -0800, Roy Smith said: > > > One of the surprising (to me, anyway) uses of JavaScript is as the > > scripting language for MongoDB (http://www.mongodb.org/). > > I just wish they'd drop spidermonkey and go with V8 or another, faster > and more modern engine. :( Could be. I've opened a few bugs against Mongo which were explained away as "it's really a bug in SM". From nambo4jb at gmail.com Wed Jan 12 19:35:46 2011 From: nambo4jb at gmail.com (Cathy James) Date: Wed, 12 Jan 2011 18:35:46 -0600 Subject: cipher encoding Message-ID: Dear all, I hope someone out there can help me. The output string of my code is close to what i need, but i need it 1)printed on one line and 2) reversed #mycode: s= input("Enter message: ") key=1 for letter in s: num=(chr(ord(letter)+1)) print(num) #or is there a better way to rewrite it with elementary level Python, which happens 2b my current ranking. #Your insight is always appreciated:) -------------- next part -------------- An HTML attachment was scrubbed... URL: From kb1pkl at aim.com Wed Jan 12 19:39:14 2011 From: kb1pkl at aim.com (Corey Richardson) Date: Wed, 12 Jan 2011 19:39:14 -0500 Subject: cipher encoding In-Reply-To: References: Message-ID: <4D2E49B2.9010602@aim.com> On 01/12/2011 07:35 PM, Cathy James wrote: > Dear all, > > I hope someone out there can help me. > > The output string of my code is close to what i need, but i need it > 1)printed on one line and > 2) reversed > > #mycode: > s= input("Enter message: ") > key=1 > for letter in s: > num=(chr(ord(letter)+1)) > print(num) > #or is there a better way to rewrite it with elementary level Python, > which happens 2b my current ranking. > #Your insight is always appreciated:) > s = input("Enter message: ") key = int(input("Enter offset: ")) # I think that's what you wanted for letter in s: print(chr(ord(letter) + key), end = "") From kb1pkl at aim.com Wed Jan 12 19:49:19 2011 From: kb1pkl at aim.com (Corey Richardson) Date: Wed, 12 Jan 2011 19:49:19 -0500 Subject: cipher encoding In-Reply-To: <4D2E49B2.9010602@aim.com> References: <4D2E49B2.9010602@aim.com> Message-ID: <4D2E4C0F.6030804@aim.com> On 01/12/2011 07:39 PM, Corey Richardson wrote: > On 01/12/2011 07:35 PM, Cathy James wrote: >> Dear all, >> >> I hope someone out there can help me. >> >> The output string of my code is close to what i need, but i need it >> 1)printed on one line and >> 2) reversed >> >> #mycode: >> s= input("Enter message: ") >> key=1 >> for letter in s: >> num=(chr(ord(letter)+1)) >> print(num) >> #or is there a better way to rewrite it with elementary level Python, >> which happens 2b my current ranking. >> #Your insight is always appreciated:) >> > > s = input("Enter message: ") > key = int(input("Enter offset: ")) # I think that's what you wanted > for letter in s: > print(chr(ord(letter) + key), end = "") > Oh, and you wanted it reversed. That's not hard. message = input("Enter message: ") key = int(input("Enter offset: ")) new_message = "" for char in message: new_message += chr(ord(letter) + key) print(new_message[::-1]) From nstinemates at gmail.com Wed Jan 12 19:50:15 2011 From: nstinemates at gmail.com (Nick Stinemates) Date: Wed, 12 Jan 2011 16:50:15 -0800 Subject: cipher encoding In-Reply-To: References: Message-ID: Try print s[::-1] Nick On Wednesday, January 12, 2011, Cathy James wrote: > Dear all, > > I hope someone out there can help me. > > ?The output string of my code is close to what i need, but i need it > 1)printed on one line and > > 2) reversed > > > #mycode: > s= input("Enter message: ") > key=1 > for letter in s: > ??? num=(chr(ord(letter)+1)) > ??? print(num) > #or is there a better way to rewrite it with elementary level Python, which happens 2b my current ranking. > #Your insight is always appreciated:) > From python at mrabarnett.plus.com Wed Jan 12 20:05:30 2011 From: python at mrabarnett.plus.com (MRAB) Date: Thu, 13 Jan 2011 01:05:30 +0000 Subject: cipher encoding In-Reply-To: <4D2E4C0F.6030804@aim.com> References: <4D2E49B2.9010602@aim.com> <4D2E4C0F.6030804@aim.com> Message-ID: <4D2E4FDA.4070704@mrabarnett.plus.com> On 13/01/2011 00:49, Corey Richardson wrote: > On 01/12/2011 07:39 PM, Corey Richardson wrote: >> On 01/12/2011 07:35 PM, Cathy James wrote: >>> Dear all, >>> >>> I hope someone out there can help me. >>> >>> The output string of my code is close to what i need, but i need it >>> 1)printed on one line and >>> 2) reversed >>> >>> #mycode: >>> s= input("Enter message: ") >>> key=1 >>> for letter in s: >>> num=(chr(ord(letter)+1)) >>> print(num) >>> #or is there a better way to rewrite it with elementary level Python, >>> which happens 2b my current ranking. >>> #Your insight is always appreciated:) >>> >> >> s = input("Enter message: ") >> key = int(input("Enter offset: ")) # I think that's what you wanted >> for letter in s: >> print(chr(ord(letter) + key), end = "") >> > Oh, and you wanted it reversed. That's not hard. > > message = input("Enter message: ") > key = int(input("Enter offset: ")) > new_message = "" > for char in message: > new_message += chr(ord(letter) + key) > print(new_message[::-1]) It's neater with: for char in reversed(message): then you don't need 'new_message'. From devplayer at gmail.com Wed Jan 12 20:15:20 2011 From: devplayer at gmail.com (DevPlayer) Date: Wed, 12 Jan 2011 17:15:20 -0800 (PST) Subject: Which coding style is better? public API or private method inside class definition References: <0470dc9d-2a5f-40d4-afd4-97796059ba0a@q8g2000prm.googlegroups.com> Message-ID: <6e9f2bdb-e08d-4864-9e0c-4d39ac6d11d1@b25g2000vbz.googlegroups.com> On Jan 4, 11:46?pm, Inyeol wrote: > Which coding style do you prefer? I'm more toward public API way, > since it requires less code change if I refactor private data > structure later. > Plz give pros and cons of these. Great question. It gets at the heart of Python style. It's a tricky question and can be answered so many ways. I'm not a pro- programmer anymore so here's my hobbyst's take on it. First, API is application programming interface. Follow me for a sec. It's the interface that your programmers use to use your "package". But WHICH programmers? For large apps like game developers or large all encompassing apps for companys there are many different types of programmers. That helps determine how heavy to lean towards private verse public interfaces. Funny thing is I end up using the private interfaces as much as the public interaces for certain things. For example when coding in wxPython I rarely use any private apis (ie. __dict__ or other "special or magic named" attributes). But when coding outside of wxPython I'm all over the place defining new classes with special named attributes like __new__ or __metaclass__, and lots and lots of other magic named methods and private attributes. So one way to decide whether to be coding towards more public verse private is where in your project you are. Building infrastructure and framework verse building "application" and end-user interfaces. Or similarly the interface TO the API interface is private (as far as Python considers things private that is). The interface to all others to use your "package" is public. And if your code is not a package for other coders, then what is the sense in having private anythings? One thing that mungles one's mind into thinking it matters is your IDE tools. When you run your scripts as an end user, who cares that there's tons of objects cluttering your namespace - I'm implying that using private API in that case is somewhat a waste. When in your IDE coding like PyCrust and you type in the interface something like wx. you'll get a popup of "attributes" and you think "ah, these attributes and methods I can use". But in use of that program, there's no sense in hidding stuff with underscored names. On the otherhand. I like to think my namespaces are simple, clean, uncluttered. There's less "What the heck is that thing" while looking at dir() and debugging. Personally I do not like the underscore. My hands don't like the keystroke pattern. And the underscore is butt ugly to me. Ugly does not equal "less readable". I find underscore easier to read then camel case/Hungarian Notation (wx and .NET has a lot of that). Although name mangling and camel case usage are different things, from a visual (of source code), to me they are the same. Also when there is name mangling, there is often an unmangled version of it in some usage somewhere in your code. Another thought. Although private interfaces are not intended to be SEEN, you code your private interfaces (i.e. attributes and methods, functions, etc) to denote themselves as private when you LOOK at them by using underscores. I'd rather have my source code just color private attributes differently. However editors are not at that level yet (meaning they'd have to interpret the code to know what's private). Lastly. Shouldn't it be better to use APIs based on the docs instead of analyzing the code for intended public interfaces verse private ones? Although not explicidly listing pros and cons to public verse private APIs I hope I spark some useful insight. From drsalists at gmail.com Wed Jan 12 21:27:51 2011 From: drsalists at gmail.com (Dan Stromberg) Date: Wed, 12 Jan 2011 18:27:51 -0800 Subject: order of importing modules In-Reply-To: <4D2DFBEC.1070605@jpl.nasa.gov> References: <4D2CF61E.7010500@jpl.nasa.gov> <4D2DFBEC.1070605@jpl.nasa.gov> Message-ID: I don't know where the site-packages directories are coming from - maybe a site.py or sitecustomize.py? Sometimes you can strace with a very large -s to see where something like this is coming from. -o is your friend for saving the output to a file in, EG, /tmp. What I usually do is to put specific versions of modules I need, that are different from what the OS is providing, in the same CWD as my script during testing. Then in my experience, CPython imports them instead. When it comes time for a production run, you can drop the special modules into the OS directories somewhere. However, another option is to add a --test command line argument to your script, and make the option just do something like: if '--test' in sys.argv: sys.path.insert(0, os.path.expanduser('~/magic-modules')) ...for example (and that in sys.argv test could probably be improved to fit your program's specifics). On Wed, Jan 12, 2011 at 11:07 AM, Catherine Moroney wrote: > I've looked at my sys.path variable and I see that it has > a whole bunch of site-package directories, followed by the > contents of my $PYTHONPATH variable, followed by a list of > misc site-package variables (see below). > > I've verified that if I manually reverse the order of sys.path > I can then import the proper version of the module that I want. > But this is not a permanent solution for me as this will mess up > other people are who working with the same code. > > But, I'm curious as to where the first bunch of 'site-package' > entries come from. ?The > /usr/lib64/python2.5/site-packages/pyhdfeos-1.0_r57_58-py2.5-linux-x86_64.egg > is not present in any of my environmental variables yet it shows up > as one of the first entries in sys.path. > > A colleague of mine is running on the same system as I am, and he > does not have the problem of the > /usr/lib64/python2.5/site-packages/pyhdfeos-1.0_r57_58-py2.5-linux-x86_64.egg > variable showing up as one of the first entries in sys.path. > > Thanks for the education, > > Catherine > > Dan Stromberg wrote: >> >> On Tue, Jan 11, 2011 at 4:30 PM, Catherine Moroney >> wrote: >>> >>> In what order does python import modules on a Linux system? ?I have a >>> package that is both installed in /usr/lib64/python2.5/site-packages, >>> and a newer version of the same module in a working directory. >>> >>> I want to import the version from the working directory, but when I >>> print module.__file__ in the interpreter after importing the module, >>> I get the version that's in site-packages. >>> >>> I've played with the PYTHONPATH environmental variable by setting it >>> to just the path of the working directory, but when I import the module >>> I still pick up the version in site-packages. >>> >>> /usr/lib64 is in my PATH variable, but doesn't appear anywhere else. ?I >>> don't want to remove /usr/lib64 from my PATH because that will break >>> a lot of stuff. >>> >>> Can I force python to import from my PYTHONPATH first, before looking >>> in the system directory? >>> >>> Catherine >>> -- >>> http://mail.python.org/mailman/listinfo/python-list >> >> Please import sys and inspect sys.path; this defines the search path >> for imports. >> >> By looking at sys.path, you can see where in the search order your >> $PYTHONPATH is going. >> >> It might actually be better to give your script a command line option >> that says "Throw the following directory at the beginning of >> sys.path". > > -- > http://mail.python.org/mailman/listinfo/python-list > From ben+python at benfinney.id.au Wed Jan 12 21:47:50 2011 From: ben+python at benfinney.id.au (Ben Finney) Date: Thu, 13 Jan 2011 13:47:50 +1100 Subject: order of importing modules References: <4D2CF61E.7010500@jpl.nasa.gov> <4D2DFBEC.1070605@jpl.nasa.gov> Message-ID: <87r5chbju1.fsf@benfinney.id.au> (Please don't top-post replies. Instead, reply in-line with the quoted material, removing irrelevant material. An example is this message.) Catherine Moroney writes: > I've looked at my sys.path variable and I see that it has a whole > bunch of site-package directories, followed by the contents of my > $PYTHONPATH variable, followed by a list of misc site-package > variables (see below). Can you show the full list here? What does ?sys.path? actually contain when your Python interpreter is running? > I've verified that if I manually reverse the order of sys.path I can > then import the proper version of the module that I want. I think the PEP 328 relative import feature is likely to be what you want: you can specify that a specific import should search for the file relative to the current module's file, instead of from ?sys.path?. As described earlier, by working through the Python tutorial you will learn about the different styles of import statement, including relative versus absolute . > But, I'm curious as to where the first bunch of 'site-package' entries > come from. The > /usr/lib64/python2.5/site-packages/pyhdfeos-1.0_r57_58-py2.5-linux-x86_64.egg > is not present in any of my environmental variables yet it shows up as > one of the first entries in sys.path. That's probably there because you have used the Setuptools system (or something related) to install a third-party package. That is achieved by meddling with the start-up module search path, to make the third-party package available for import. The result is often a messy search path. Python's system for installing third-party components is far from ideal; it has seen a lot of improvement recently, but on the other hand is carrying a lot of baggage from its earlier design. This is one of the symptoms. > Thanks for the education, I hope that helps! -- \ ?To me, boxing is like a ballet, except there's no music, no | `\ choreography, and the dancers hit each other.? ?Jack Handey | _o__) | Ben Finney From zvictoryz at gmail.com Wed Jan 12 23:20:14 2011 From: zvictoryz at gmail.com (shengli zhang) Date: Thu, 13 Jan 2011 12:20:14 +0800 Subject: The problem of 324 (net::ERR_EMPTY_RESPONSE) Message-ID: This is something I've been fighting for a couple of days. Let me try to describe it as I can. I use "python2.5 + django1.0 + mod_python + apache2" to develop a website. the website has run for two years. But the problem happend these days. when I log in my system, the first browser's sessin will be a error page: 324 (net::ERR_EMPTY_RESPONSE) in Chrom, empty page in Firefox, error in IE, and "exit signal Segmentation fault (11)" in apache error_log. However, when I close this error page and open a new page to log in the system, everything is ok. I have tried many ways to test or solve this problem, but I failed. following is my tries: 1 using "python manage.py runserver" to start project, everything is ok, so django is not a factor of the problem. 2 update the OS's expat to expat-2.0.0 which is accordant with pyexpat of python, the problem remains. 3 replace mod_python to mod_wsgi, the problem remains too. 4 modify apache's httpd.conf to remove some modules of apache, including mod_expires, mod_deflate and libphp5, but I failed again. Any idea about these? Has anyone experienced something similar? Or how shall I approach this further? Thanks a lot! -------------- next part -------------- An HTML attachment was scrubbed... URL: From ddasilva at umd.edu Thu Jan 13 01:21:04 2011 From: ddasilva at umd.edu (Daniel da Silva) Date: Thu, 13 Jan 2011 01:21:04 -0500 Subject: Parsing string for " " In-Reply-To: <4D2D1E9F.2020500@mrabarnett.plus.com> References: <0d7143ca-45cf-44c3-9e8d-acb867c52037@f30g2000yqa.googlegroups.com> <4D2D1E9F.2020500@mrabarnett.plus.com> Message-ID: MRAB, I will check it out. Thanks! Daniel On Tue, Jan 11, 2011 at 10:23 PM, MRAB wrote: > On 12/01/2011 01:50, Daniel da Silva wrote: > >> Hi, >> >> I have come across a task where I would like to scan a short 20-80 >> character line of text for instances of " ". Ideally >> could be of any tense. >> >> I know quite a bit of programming and computer science, but >> computational linguistics is relatively new to me. If anyone can point >> me in the right direction, I would be very thankful! >> >> Have a look at the Natural Language Toolkit: > > http://www.nltk.org/ > -- > http://mail.python.org/mailman/listinfo/python-list > -------------- next part -------------- An HTML attachment was scrubbed... URL: From devplayer at gmail.com Thu Jan 13 01:57:33 2011 From: devplayer at gmail.com (DevPlayer) Date: Wed, 12 Jan 2011 22:57:33 -0800 (PST) Subject: Nested structures question References: Message-ID: looping = True while looping: guess = int(raw_input("Take a guess: ")) tries += 1 if guess > the_number: print "Lower..." elif guess < the_number: print "Higher..." else: print "You guessed it! The number was", the_number print "And it only took you", tries, "tries!\n" break if tries >= 7: print "Wow you suck! It should only take at most 7 tries!" looping = False # Alternatively while learing while looping use the continue statement looping = True while looping: guess = int(raw_input("Take a guess: ")) tries += 1 if guess > the_number: print "Lower..." elif guess < the_number: print "Higher..." else: print "You guessed it! The number was", the_number print "And it only took you", tries, "tries!\n" break if tries < 7: continue print "Wow you suck! It should only take at most 7 tries!" looping = False # In a while loop I recommend to NOT end loops using the # conditional test of == but instead use >, <, >= or <= or !=. # In a complex while loop the exit condition may be skipped # by mistake and you'll loop forever. # In while loops I get less bugs by putting the incrementor as # the last statement in the while block; # this helps follow precedence like range(7) is - zero to 6 # as well as index 0 in a list is the first item. However # while index: where index == 0 will exit the loop before # it even starts as 0 == False (0 is not False but equals False) # Use the while loop for looping an undetermined number of # iterations or conditional iterations. # Use for loops for an explicid number of iterations. for tries in range(7): guess = int(raw_input("Take a guess: ")) if guess > the_number: print "Lower..." elif guess < the_number: print "Higher..." else: print "You guessed it! The number was", the_number print "And it only took you", tries, "tries!\n" break if tries >= 7: print "Wow you suck! It should only take at most 7 tries!" # I'm guessing the chapter's test is to see if you remember the for loop. # start using print() to get into a good habit for Python 3.0+ # I haven't seen the book but often one part of while that is # left off in tutorials is the "else" statement. while condition: "block" else: "block" # you can use else for when the condition never happens. From michele.simionato at gmail.com Thu Jan 13 03:32:03 2011 From: michele.simionato at gmail.com (Michele Simionato) Date: Thu, 13 Jan 2011 00:32:03 -0800 (PST) Subject: Ideas for a module to process command line arguments References: <2ee89e8b-f7f6-48f2-9b7e-6b8592db0c13@k30g2000vbn.googlegroups.com> Message-ID: On Jan 12, 6:09?pm, Alice Bevan?McGregor wrote: > entirely sure what you mean by 'smart' options. ?If your'e referring to > using a single hyphen and a list of characters to represent a long > option (which, to the rest of the world, use two leading hyphens) then > that's pretty weird. ?;) > > One major system in the world that doesn't really differentiate between > long and short options is... DOS, and by extension, Windows. ?But they > also use / as a switch character. Yes, and plac (it is argparse actually) can accomodate the Windows convention by setting the prefix_chars to "/". I wanted to be able to give that freedom even if personally am more used to the GNU double-dash convention. > Anyway; I'm happy with what I have wrought (and am continuing to update > with support for class-based sub-command dispatch) and will be > utilizing it for all scripts in the Marrow suite. ?To each their own, > but reinvention itself can be for motivations other than NIH. ?I wanted > something pure-Python, portable across the 3k barrier without code > modification (no 2to3), that didn't use optparse, getopt, or argparse > and basically be a translation layer. ?It can be simpler than that, as > marrow.script demonstrates. No arguing against that. BTW, I was not criticizing marrow.script, I was simply deploring the situation in the standard library. If the same approach for parsing command-line options is being reinvented by different people multiple times there must be something wrong with the current standard. From devplayer at gmail.com Thu Jan 13 04:23:02 2011 From: devplayer at gmail.com (DevPlayer) Date: Thu, 13 Jan 2011 01:23:02 -0800 (PST) Subject: How to populate all possible hierarchical clusterings from a set of elements? References: <3cb5ae7e-866d-40fb-ae3f-496193db91e4@t35g2000yqj.googlegroups.com> Message-ID: <4e88e8bc-4704-4b07-98dc-1e79b770acae@30g2000yql.googlegroups.com> lst = [1, 2, 3, 4, 5] def maketup(lst): cur_item = lst[-1] lst = lst[:-1] if len(lst): return maketup(lst), cur_item else: return cur_item print maketup(lst) ((((1, 2), 3), 4), 5) But I'm confused as to what you mean by : > Among them, I want to pair up terminals until there is only one left > at the end. One what? one pair?, one terminal meaning one number? From devplayer at gmail.com Thu Jan 13 04:51:02 2011 From: devplayer at gmail.com (DevPlayer) Date: Thu, 13 Jan 2011 01:51:02 -0800 (PST) Subject: How to populate all possible hierarchical clusterings from a set of elements? References: <3cb5ae7e-866d-40fb-ae3f-496193db91e4@t35g2000yqj.googlegroups.com> <4e88e8bc-4704-4b07-98dc-1e79b770acae@30g2000yql.googlegroups.com> Message-ID: def maketup(lst): if len(lst) == 1: return lst[0] elif len(lst) == 2: return (lst[0],lst[1]) elif len(lst) > 2: return ( (maketup(lst[:-2]), lst[-2]), lst[-1]) maketup(lst) ((((1, 2), 3), 4), 5) From alain at dpt-info.u-strasbg.fr Thu Jan 13 05:02:46 2011 From: alain at dpt-info.u-strasbg.fr (Alain Ketterlin) Date: Thu, 13 Jan 2011 11:02:46 +0100 Subject: How to populate all possible hierarchical clusterings from a set of elements? References: <3cb5ae7e-866d-40fb-ae3f-496193db91e4@t35g2000yqj.googlegroups.com> Message-ID: <87tyhdi0jd.fsf@dpt-info.u-strasbg.fr> justin writes: > Suppose I have [1,2,3,4,5], then there are many ways of making > clustering. > Among them, I want to pair up terminals until there is only one left > at the end. Are you trying "ascending hierarchical clustering" by any chance? In that case you're supposed to use some kind of distance to select the (unique) pair of elements to merge at each step. > For example, ((((1,2),3),4),5), (1,(2,(3,(4,5)))), or (((1,2),(3,4)), > 5) would be legitimate ones. > > How do you think can I, using the modules of Python such as itertools > as much as possible, make all possible such clusterings? I don't know about itertools, but the basic idea is: def clusterings(l): if len(l) == 1: print repr(l) else: n = len(l) for i in xrange(n): for j in xrange(i+1,n): clusterings(l[:i]+l[i+1:j]+l[j+1:]+[[l[i],l[j]]]) Test this with: import sys clusterings([i for i in xrange(int(sys.argv[1]))]) Do you realize there are *many* such clusterings? (the exact number should be (n!)*((n-1)!)/2^(n-1) given the code above, if I'm not mistaken.) -- Alain. From alain at dpt-info.u-strasbg.fr Thu Jan 13 05:27:20 2011 From: alain at dpt-info.u-strasbg.fr (Alain Ketterlin) Date: Thu, 13 Jan 2011 11:27:20 +0100 Subject: How to populate all possible hierarchical clusterings from a set of elements? References: <3cb5ae7e-866d-40fb-ae3f-496193db91e4@t35g2000yqj.googlegroups.com> <4e88e8bc-4704-4b07-98dc-1e79b770acae@30g2000yql.googlegroups.com> Message-ID: <87pqs1hzef.fsf@dpt-info.u-strasbg.fr> DevPlayer writes: > def maketup(lst): > > if len(lst) == 1: > return lst[0] > > elif len(lst) == 2: > return (lst[0],lst[1]) > > elif len(lst) > 2: > return ( (maketup(lst[:-2]), lst[-2]), lst[-1]) The OP wants all binary trees over the elements, not just one. -- Alain. From dzizes451 at gmail.com Thu Jan 13 05:28:12 2011 From: dzizes451 at gmail.com (dzizes451) Date: Thu, 13 Jan 2011 02:28:12 -0800 (PST) Subject: File "/usr/lib/python2.6/atexit.py", line 24, in _run_exitfuncs Message-ID: <9c1513be-2fb1-40ae-ad04-56a9574f1313@32g2000yqz.googlegroups.com> Hello! I wrote a python (2.6) deamon running on linux. Program (deamon, manager) collects lets say work-orders from db and creates sub- processes for each one. Sub-processes do their job with out problems, errors, exceptions. However, sometimes deamon throws: Traceback (most recent call last): File "/usr/lib/python2.6/atexit.py", line 24, in _run_exitfuncs func(*targs, **kargs) File "/usr/lib/python2.6/multiprocessing/util.py", line 281, in _exit_function p.join() File "/usr/lib/python2.6/multiprocessing/process.py", line 119, in join res = self._popen.wait(timeout) File "/usr/lib/python2.6/multiprocessing/forking.py", line 117, in wait return self.poll(0) File "/usr/lib/python2.6/multiprocessing/forking.py", line 106, in poll pid, sts = os.waitpid(self.pid, flag) OSError: [Errno 4] Interrupted system call the main deamon process crushes (after some time) and the sub- processes (childs) work fine until their work is finished. below sample code that is responsible for creating sub_processes : #!/usr/bin/python2.6 import pwd import os import sys import time import multiprocessing import signal import traceback from deamon import deamon from post import post class manager(deamon): def __run_subprocess(self, typ, work_order): def runrun(t, z): self.__info('creating object post for %s' %(z)) wns = post(z) self.__info('done creating object post for %s' %(z)) #slownik z choiceem opcji choice = {'typ1': wns.typ1, 'typ2': wns.typ2, 'typ3': wns.typ3} if typ in choice: self.__info('lounching %s for %s' %(t, z)) choice[typ]() else: self.__blad('nie znam %s typu operacji post, znam tylko %s' \ %(t, str(choice))) wns.endit() del(wns) self.__blad('problem with starting proces for =%s, typ= %s' %(z, t)) try: p = multiprocessing.Process(target=runrun, args=(typ,work_order)) self.__info('done preparing proces...') p.start() self.__info('done lounching process...doing join...') p.join() return p.pid except Exception, err: ex = sys.exc_info() sys.stderr.write(str(sys.exc_info())) msg = 'manager.__run_subprocess %s error in line %s' sys.stderr.write(msg %(str(err), ex[2].tb_lineno)) #traceback.print_last() return None def __liczba_wierszy(self, active_child): return int(self._deamon__liczba_proces - active_child) def run(self): try: while True: active_child = len(multiprocessing.active_children()) #czy liczba pod-procesow <= liczba mozliwych pod- procesow if active_child <= self._deamon__liczba_proces: lista_zlecen = self._deamon__baza.get_work( self.__liczba_wierszy(active_child)) if len(lista_zlecen) > 0: for work_order in lista_zlecen: self.__info('start %s' %(work_order)) pid = self.__run_subprocess('typ1',work_order) self.__info('end %s %s' %(work_order, str(pid))) time.sleep(self._deamon__sleep) elif active_child == self.__liczba_proces: msg = 'number of processes %i is equal to maximum %i, '\ 'going sleep for %i seconds' %( active_child, self.__liczba_proces, self._deamon__sleep) self.__info(msg) time.sleep(self._deamon__sleep) else: self.__info('nothing to do... going sleep for %i seconds' %(self._deamon__liczba_proces)) #self._deamon__baza.zamknij_polacznie() time.sleep(self._deamon__sleep) except Exception, err: ei = sys.exc_info() msg = 'manager.run %s\n' %(str(err)) sys.stderr.write('error in line %s\n' % (str(ei[2].tb_lineno))) sys.stderr.write(msg) def receive_sygnal(self, signum, stack): if signum == 10: #print 'otrzymalem sygnal', signum self.__zapisz_status() elif signum == 12: self.__info('cheking if there are any active sub- processes') while len(multiprocessing.active_children()) > 0: self.__info('liczba podprocesow > 0, ide spac na 10 sekund') time.sleep(10) else: print 'got unknown signal', signum From devplayer at gmail.com Thu Jan 13 05:29:32 2011 From: devplayer at gmail.com (DevPlayer) Date: Thu, 13 Jan 2011 02:29:32 -0800 (PST) Subject: How to populate all possible hierarchical clusterings from a set of elements? References: <3cb5ae7e-866d-40fb-ae3f-496193db91e4@t35g2000yqj.googlegroups.com> <4e88e8bc-4704-4b07-98dc-1e79b770acae@30g2000yql.googlegroups.com> Message-ID: <1b177afd-8023-4755-827f-1093fddb6f55@v17g2000yqv.googlegroups.com> tuple([ (tuple(lst[x-1:x+1]) if len(tuple(lst[x-1:x+1]))==2 else lst[x-1]) for x in lst[::2]]) ((1, 2), (3, 4), 5) # or x = ((tuple(lst[x-1:x+1]) if len(tuple(lst[x-1:x+1]))==2 else lst[x-1]) for x in lst[::2]) x.next() (1, 2) x.next() (3, 4) x.next() 5 From devplayer at gmail.com Thu Jan 13 05:31:25 2011 From: devplayer at gmail.com (DevPlayer) Date: Thu, 13 Jan 2011 02:31:25 -0800 (PST) Subject: How to populate all possible hierarchical clusterings from a set of elements? References: <3cb5ae7e-866d-40fb-ae3f-496193db91e4@t35g2000yqj.googlegroups.com> <4e88e8bc-4704-4b07-98dc-1e79b770acae@30g2000yql.googlegroups.com> <87pqs1hzef.fsf@dpt-info.u-strasbg.fr> Message-ID: <4e7d3e84-b48f-4207-b012-0b8b7594bbf9@j29g2000yqm.googlegroups.com> Ah. out of my depth. From krzysztof.t.bieniasz at gmail.com Thu Jan 13 05:54:01 2011 From: krzysztof.t.bieniasz at gmail.com (Krzysztof Bieniasz) Date: Thu, 13 Jan 2011 10:54:01 +0000 (UTC) Subject: cipher encoding References: Message-ID: > Dear all, > > I hope someone out there can help me. > > The output string of my code is close to what i need, but i need it > 1)printed on one line and > 2) reversed > > #mycode: > s= input("Enter message: ") > key=1 > for letter in s: > num=(chr(ord(letter)+1)) > print(num) > #or is there a better way to rewrite it with elementary level Python, > which happens 2b my current ranking. > #Your insight is always appreciated:) If you want it on one line the simplest thing would be to have it in one string: num='' for letter in s: num+=chr(ord(letter)+1) print num[::-1] But if you don't want it that way you can simply write print num, in your original code. The comma suppresses '\n' at the end of print. Only you have to feed letters to the loop in reverse order if you want it reversed. From jeanmichel at sequans.com Thu Jan 13 06:13:02 2011 From: jeanmichel at sequans.com (Jean-Michel Pichavant) Date: Thu, 13 Jan 2011 12:13:02 +0100 Subject: Nested structures question In-Reply-To: References: Message-ID: <4D2EDE3E.7050404@sequans.com> Physics Python wrote: > Hello, > > I am teaching myself python using the book: Python Programming for Absolute Beginners, 2nd edition by Michael Dawson. I am using python 2.7.1. > > In chapter 3 we are learning to use structures (while, if, elif) to write a program that has the user guess a number between 1 and 100. > > Here is the code for the baseline program: > > [snip] here is an example of code using a for loop, which is always better than a while loop, when applicable of course. It uses the for... else... statement which is rather strange at first glance but has some uses, it's always good to know it exists. http://paste.pocoo.org/show/319931/ JM From chardster at gmail.com Thu Jan 13 09:11:32 2011 From: chardster at gmail.com (Richard Thomas) Date: Thu, 13 Jan 2011 06:11:32 -0800 (PST) Subject: How to populate all possible hierarchical clusterings from a set of elements? References: <3cb5ae7e-866d-40fb-ae3f-496193db91e4@t35g2000yqj.googlegroups.com> <87tyhdi0jd.fsf@dpt-info.u-strasbg.fr> Message-ID: <562e7da2-fa99-458f-80cf-01f21d37b1b4@s9g2000vby.googlegroups.com> On Jan 13, 10:02?am, Alain Ketterlin wrote: > justin writes: > > Suppose I have [1,2,3,4,5], then there are many ways of making > > clustering. > > Among them, I want to pair up terminals until there is only one left > > at the end. > > Are you trying "ascending hierarchical clustering" by any chance? In > that case you're supposed to use some kind of distance to select the > (unique) pair of elements to merge at each step. > > > For example, ((((1,2),3),4),5), (1,(2,(3,(4,5)))), or (((1,2),(3,4)), > > 5) would be legitimate ones. > > > How do you think can I, using the modules of Python such as itertools > > as much as possible, make all possible such clusterings? > > I don't know about itertools, but the basic idea is: > > def clusterings(l): > ? ? if len(l) == 1: > ? ? ? ? print repr(l) > ? ? else: > ? ? ? ? n = len(l) > ? ? ? ? for i in xrange(n): > ? ? ? ? ? ? for j in xrange(i+1,n): > ? ? ? ? ? ? ? ? clusterings(l[:i]+l[i+1:j]+l[j+1:]+[[l[i],l[j]]]) > > Test this with: > > import sys > clusterings([i for i in xrange(int(sys.argv[1]))]) > > Do you realize there are *many* such clusterings? (the exact number > should be (n!)*((n-1)!)/2^(n-1) given the code above, if I'm not > mistaken.) > > -- Alain. Actually the number of such "clusterings" is the (n-1)th Catalan number. http://en.wikipedia.org/wiki/Catalan_numbers Chard. From hankfay at gmail.com Thu Jan 13 10:31:34 2011 From: hankfay at gmail.com (Hank Fay) Date: Thu, 13 Jan 2011 07:31:34 -0800 (PST) Subject: Career path - where next? In-Reply-To: Message-ID: <7de3dd11-d60e-4daf-9519-e186f309cb1a@glegroupsg2000goo.googlegroups.com> I would second the recommendation for Django: on LinkedIn, the python jobs postings (there is a Python group there) most often mention Django. I also would second the recommendation to participate in open source projects. I met a couple of days ago with a college sophomore who is a core contributor to the Cappuccino project(cappuccino.org -- warning: not Python ). My employer said, on my relating the pleasant and interesting conversation we had, "he doesn't need to finish college: anyone would hire him." >From a selfish (to you and to me ) perspective, may I suggest the pyjamas (pyjs.org) project and accompanying visual designer (http://pyjsglade.sourceforge.net), which brings the GWT widgets to Python, for desktop and web apps. Selfish to me because I'm porting our VFP framework to there over the next year or so. To you because, well, you've been spoiled by having the most productive data-oriented software development framework available, past or present, for maybe as many years as have I (21 at this point, started with FoxPro 1.0), and that's the end result at which I'm aiming. Hank From hankfay at gmail.com Thu Jan 13 10:31:34 2011 From: hankfay at gmail.com (Hank Fay) Date: Thu, 13 Jan 2011 07:31:34 -0800 (PST) Subject: Career path - where next? In-Reply-To: Message-ID: <7de3dd11-d60e-4daf-9519-e186f309cb1a@glegroupsg2000goo.googlegroups.com> I would second the recommendation for Django: on LinkedIn, the python jobs postings (there is a Python group there) most often mention Django. I also would second the recommendation to participate in open source projects. I met a couple of days ago with a college sophomore who is a core contributor to the Cappuccino project(cappuccino.org -- warning: not Python ). My employer said, on my relating the pleasant and interesting conversation we had, "he doesn't need to finish college: anyone would hire him." >From a selfish (to you and to me ) perspective, may I suggest the pyjamas (pyjs.org) project and accompanying visual designer (http://pyjsglade.sourceforge.net), which brings the GWT widgets to Python, for desktop and web apps. Selfish to me because I'm porting our VFP framework to there over the next year or so. To you because, well, you've been spoiled by having the most productive data-oriented software development framework available, past or present, for maybe as many years as have I (21 at this point, started with FoxPro 1.0), and that's the end result at which I'm aiming. Hank From alain at dpt-info.u-strasbg.fr Thu Jan 13 10:59:06 2011 From: alain at dpt-info.u-strasbg.fr (Alain Ketterlin) Date: Thu, 13 Jan 2011 16:59:06 +0100 Subject: How to populate all possible hierarchical clusterings from a set of elements? References: <3cb5ae7e-866d-40fb-ae3f-496193db91e4@t35g2000yqj.googlegroups.com> <87tyhdi0jd.fsf@dpt-info.u-strasbg.fr> <562e7da2-fa99-458f-80cf-01f21d37b1b4@s9g2000vby.googlegroups.com> Message-ID: <87hbdciylx.fsf@dpt-info.u-strasbg.fr> Richard Thomas writes: > On Jan 13, 10:02?am, Alain Ketterlin >> def clusterings(l): >> ? ? if len(l) == 1: >> ? ? ? ? print repr(l) >> ? ? else: >> ? ? ? ? n = len(l) >> ? ? ? ? for i in xrange(n): >> ? ? ? ? ? ? for j in xrange(i+1,n): >> ? ? ? ? ? ? ? ? clusterings(l[:i]+l[i+1:j]+l[j+1:]+[[l[i],l[j]]]) >> [...] there are *many* such clusterings? (the exact number should be >> (n!)*((n-1)!)/2^(n-1) given the code above, if I'm not mistaken.) > Actually the number of such "clusterings" is the (n-1)th Catalan > number. > > http://en.wikipedia.org/wiki/Catalan_numbers I don't think Catalan numbers exactly captures this number. As far as I remember (and wikipedia seems to confirm this), Cn is the number of ways you can repeatedly apply a binary operator to a sequence of objects, where sequence means that the objects are ordered, which is not the case here. To use wikipedia's example, C3 is 5 because you can do: ((ab)c)d (a(bc))d (ab)(cd) a((bc)d) a(b(cd)) If we list clusterings we can also have: ((ac)b)d ((ac)d)b (ac)(bd) ... Actually, for each of the 5 "catalan expressions" above, you have 4! valid permutations of the objects (leading to a complete count of n!*C(n-1)). But this leads to many "duplicates", because (ab)(cd) and (cd)(ab) are considered the same. I just realize that the code I've given above also produces duplicates (in particular, the example I've just used). At least, my counting was correct w.r.t. the code :-) The plot thickens... -- Alain. From tjreedy at udel.edu Thu Jan 13 11:46:18 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Thu, 13 Jan 2011 11:46:18 -0500 Subject: File "/usr/lib/python2.6/atexit.py", line 24, in _run_exitfuncs In-Reply-To: <9c1513be-2fb1-40ae-ad04-56a9574f1313@32g2000yqz.googlegroups.com> References: <9c1513be-2fb1-40ae-ad04-56a9574f1313@32g2000yqz.googlegroups.com> Message-ID: On 1/13/2011 5:28 AM, dzizes451 wrote: > Hello! > > I wrote a python (2.6) deamon running on linux. Program (deamon, > manager) collects lets say work-orders from db and creates sub- > processes for each one. Sub-processes do their job with out problems, > errors, exceptions. However, sometimes deamon throws: > > Traceback (most recent call last): > File "/usr/lib/python2.6/atexit.py", line 24, in _run_exitfuncs > func(*targs, **kargs) I would either just try 2.7 or at least examine What's New or even Misc/NEWS in the repository to see if there were changes that affect this. My impression is that there were. -- Terry Jan Reedy From chardster at gmail.com Thu Jan 13 11:58:42 2011 From: chardster at gmail.com (Richard Thomas) Date: Thu, 13 Jan 2011 08:58:42 -0800 (PST) Subject: How to populate all possible hierarchical clusterings from a set of elements? References: <3cb5ae7e-866d-40fb-ae3f-496193db91e4@t35g2000yqj.googlegroups.com> <87tyhdi0jd.fsf@dpt-info.u-strasbg.fr> <562e7da2-fa99-458f-80cf-01f21d37b1b4@s9g2000vby.googlegroups.com> <87hbdciylx.fsf@dpt-info.u-strasbg.fr> Message-ID: On Jan 13, 3:59?pm, Alain Ketterlin wrote: > Richard Thomas writes: > > On Jan 13, 10:02?am, Alain Ketterlin > >> def clusterings(l): > >> ? ? if len(l) == 1: > >> ? ? ? ? print repr(l) > >> ? ? else: > >> ? ? ? ? n = len(l) > >> ? ? ? ? for i in xrange(n): > >> ? ? ? ? ? ? for j in xrange(i+1,n): > >> ? ? ? ? ? ? ? ? clusterings(l[:i]+l[i+1:j]+l[j+1:]+[[l[i],l[j]]]) > >> [...] there are *many* such clusterings? (the exact number should be > >> (n!)*((n-1)!)/2^(n-1) given the code above, if I'm not mistaken.) > > Actually the number of such "clusterings" is the (n-1)th Catalan > > number. > > >http://en.wikipedia.org/wiki/Catalan_numbers > > I don't think Catalan numbers exactly captures this number. As far as I > remember (and wikipedia seems to confirm this), Cn is the number of ways > you can repeatedly apply a binary operator to a sequence of objects, > where sequence means that the objects are ordered, which is not the case > here. To use wikipedia's example, C3 is 5 because you can do: > > ((ab)c)d (a(bc))d (ab)(cd) a((bc)d) a(b(cd)) > > If we list clusterings we can also have: > > ((ac)b)d ((ac)d)b (ac)(bd) ... > > Actually, for each of the 5 "catalan expressions" above, you have 4! > valid permutations of the objects (leading to a complete count of > n!*C(n-1)). But this leads to many "duplicates", because (ab)(cd) and > (cd)(ab) are considered the same. > > I just realize that the code I've given above also produces duplicates > (in particular, the example I've just used). At least, my counting was > correct w.r.t. the code :-) The plot thickens... > > -- Alain. Okay, I misunderstood the problem, sorry about that. This makes it rather hard to define a nice recurrence relation for the number of such clusterings: C(1) = 1 C(2n+1) = Sigma(1; n; choose(2n+1, r) * C(r) * C(2n+1-r)) C(2n) = Sigma(1; n-1; choose(2n, r) * C(r) * C(2n-r)) + choose(2n, n) * C(n) * C(n) / 2 See, very ugly. I can't reduce it to anything workable so I just computed it. Clearly its more than exponential. Some values: In [1]: [cluster(n) for n in xrange(1, 21)] Out[1]: [1, 1, 3, 15, 105, 945, 10395, 135135, 2027025, 34459425, 654729075, 13749310575L, 316234143225L, 7905853580625L, 213458046676875L, 6190283353629375L, 191898783962510625L, 6332659870762850625L, 221643095476699771875L, 8200794532637891559375L] Anyway, I'm done counting things for now. Chard. From marcohornung at googlemail.com Thu Jan 13 12:07:47 2011 From: marcohornung at googlemail.com (Marco Hornung) Date: Thu, 13 Jan 2011 12:07:47 -0500 Subject: how to use priority queue with multiprocessing Message-ID: <0191111D-0C16-4CA3-A680-FDFB98FF7C07@gmail.com> Hey, ------------------------------------------------------------------------------------------ question ------------------------------------------------------------------------------------------ How can I use a priority queue to schedule jobs within the "multiprocessing pool" module? ------------------------------------------------------------------------------------------ my scenario ------------------------------------------------------------------------------------------ I want to run several jobs on a server. The jobs are being sent by users. However, all jobs have a different priority, and high-priority jobs should be processed before any low-priority job gets touched. Currently I just append all incoming jobs to the multiprocessing worker pool as follows: ### initialize worker pool pool = PriorityPool(processes=worker_count) process_handles = [] ### distribute function execution over several processes for job_parameter in job_parameter_list: handle = pool.apply_async(process_function, [job_parameter,]) process_handles.append(handle) This will only put the jobs in some kind of a list - and execute the jobs in the order they come in. Is it possible to use a priority queue for the process-pool? Kind Regards, Marco From lycka at carmen.se Thu Jan 13 13:12:49 2011 From: lycka at carmen.se (=?ISO-8859-1?Q?Magnus_Lyck=E5?=) Date: Thu, 13 Jan 2011 19:12:49 +0100 Subject: Resolve circular reference In-Reply-To: <1718ea91-fc4e-49f3-a15a-bdc683789126@k22g2000yqh.googlegroups.com> References: <1718ea91-fc4e-49f3-a15a-bdc683789126@k22g2000yqh.googlegroups.com> Message-ID: On 2011-01-07 03:24, moerchendiser2k3 wrote: > Everything works fine, the problem starts when I start to make a > circular reference in Python. I didn't quite grok your example, but concerning CPython GC & circular references... >>> import gc >>> class X: ... def __del__(self): ... print 'Deleted', self ... >>> a = X() >>> del a Deleted <__main__.X instance at 0x00CCCF80> >>> a=X() >>> b=X() >>> a.b=b >>> b.a=a >>> del a >>> gc.collect() 0 >>> del b >>> gc.collect() 4 >>> From lycka at carmen.se Thu Jan 13 13:23:22 2011 From: lycka at carmen.se (=?UTF-8?B?TWFnbnVzIEx5Y2vDpQ==?=) Date: Thu, 13 Jan 2011 19:23:22 +0100 Subject: How to read ansic file into a pre-defined class? In-Reply-To: References: Message-ID: On 2011-01-08 04:24, Ying Zu wrote: > How to read ansic file into a pre-defined class? > > I have a series of files written in the following format, ... You might like to take a look at the json module if you aren't locked to the exact format you suggested. http://json.org/ http://docs.python.org/library/json.html#module-json From ethan at stoneleaf.us Thu Jan 13 14:33:48 2011 From: ethan at stoneleaf.us (Ethan Furman) Date: Thu, 13 Jan 2011 11:33:48 -0800 Subject: Career path - where next? In-Reply-To: <7de3dd11-d60e-4daf-9519-e186f309cb1a@glegroupsg2000goo.googlegroups.com> References: <7de3dd11-d60e-4daf-9519-e186f309cb1a@glegroupsg2000goo.googlegroups.com> Message-ID: <4D2F539C.6070803@stoneleaf.us> Hank Fay wrote: > ... > > From a selfish (to you and to me ) perspective, may I suggest > the pyjamas (pyjs.org) project and accompanying visual designer > (http://pyjsglade.sourceforge.net), which brings the GWT widgets > to Python, for desktop and web apps. Selfish to me because I'm > porting our VFP framework to there over the next year or so. > To you because, well, you've been spoiled by having the most > productive data-oriented software development framework available, > past or present, for maybe as many years as have I (21 at this point, > started with FoxPro 1.0), and that's the end result at which I'm > aiming. Hank, I have a dbf* package which supports VFP dbf files up to 6, and I would like to implement support for compound index files. So far, I have been unable to locate the algorithms necessary to do so. If you have any information that would help me, I would be very grateful! ~Ethan~ *http://pypi.python.org/pypi/dbf/0.88.16 From heshamebrahimi at gmail.com Thu Jan 13 14:47:15 2011 From: heshamebrahimi at gmail.com (Hesham) Date: Thu, 13 Jan 2011 11:47:15 -0800 (PST) Subject: apscheduler error References: <9699865b-a8be-4284-a347-58d875b491f6@n2g2000pre.googlegroups.com> <8d45d736-8b89-41f0-96d7-66c3c077b670@22g2000prx.googlegroups.com> Message-ID: In cases like that instead of sleep() can use pause(). E.g., from apscheduler.scheduler import Scheduler import signal sched = Scheduler() sched.start() def some_job(): print "Decorated job" sched.add_interval_job(some_job,minutes=1) signal.pause() Mosalam From arnodel at gmail.com Thu Jan 13 14:54:03 2011 From: arnodel at gmail.com (Arnaud Delobelle) Date: Thu, 13 Jan 2011 19:54:03 +0000 Subject: How to populate all possible hierarchical clusterings from a set of elements? References: <3cb5ae7e-866d-40fb-ae3f-496193db91e4@t35g2000yqj.googlegroups.com> Message-ID: <87d3o0r350.fsf@gmail.com> Peter Otten <__peter__ at web.de> writes: > justin wrote: > >> The title sounds too complex, but my question is actually simple. >> >> Suppose I have [1,2,3,4,5], then there are many ways of making >> clustering. >> Among them, I want to pair up terminals until there is only one left >> at the end. >> For example, ((((1,2),3),4),5), (1,(2,(3,(4,5)))), or (((1,2),(3,4)), >> 5) would be legitimate ones. >> >> How do you think can I, using the modules of Python such as itertools >> as much as possible, make all possible such clusterings? > > Here's my first attempt: > > def cluster(items): > if len(items) == 2: > yield items > return > > for i in range(len(items)-1): > for c in cluster(items[:i] + (items[i:i+2],) + items[i+2:]): > yield c > > def unique(items): > seen = set() > for item in items: > if item not in seen: > seen.add(item) > yield item > > if __name__ == "__main__": > for item in unique(cluster(tuple("abcd"))): > print item more simply: def clusters(l): if len(l) == 1: yield l[0] return for i in range(1, len(l)): for left in clusters(l[:i]): for right in clusters(l[i:]): yield (left, right) That would give all solutions without duplicates. In fact, this is simply finding all full binary trees which order l. However, somewhere else in the thread someone claims that no ordering is implied on the initial list of items (which is not at all obvious from the OP). -- Arnaud From somewhere at hotmail.com Thu Jan 13 14:57:53 2011 From: somewhere at hotmail.com (Dave) Date: Thu, 13 Jan 2011 15:57:53 -0400 Subject: troubles compiling pythonwebkit Message-ID: <4d2f5543$0$5598$9a566e8b@news.aliant.net> Hello Python enthusiasts, I'm trying to install the "Python Webkit DOM Bindings" (http://www.gnu.org/software/pythonwebkit/) but am not successful. The trouble starts when trying to 'make' pywebkitgtk. I've tried the prepatched version and downloading and patching myself. In both case the 'make' fails but with different errors. Here are the steps I performed and the error output. Thanks for any insight in resolving this problem. :-) I'm running Ubuntu 10.04 32bit sudo apt-get remove python-webkit sudo apt-get install python-dev sudo apt-get install python-ply sudo apt-get install autoconf sudo apt-get install automake sudo apt-get install autotools-dev sudo apt-get install bison sudo apt-get install flex sudo apt-get install gperf sudo apt-get install glib-networking <---E: Couldn't find package glib-networking sudo apt-get install gtk-doc-tools sudo apt-get install libenchant-dev sudo apt-get install libgail-dev sudo apt-get install libgeoclue-dev sudo apt-get install libglib2.0-dev sudo apt-get install libgstreamer-plugins-base0.10-dev sudo apt-get install libgtk2.0-dev sudo apt-get install libicu-dev sudo apt-get install libjpeg62-dev sudo apt-get install libpango1.0-dev sudo apt-get install libpng12-dev sudo apt-get install libsoup2.4-dev sudo apt-get install libsqlite3-dev sudo apt-get install libtool sudo apt-get install libxslt-dev sudo apt-get install libxt-dev sudo apt-get install git-core git clone git://git.savannah.gnu.org/pythonwebkit.git cd pythonwebkit git checkout -b python_codegen sudo mkdir build cd build sudo ../autogen.sh sudo ../configure sudo make sudo make install cd ../.. sudo apt-get install libxslt1-dev sudo apt-get install python-gtk2-dev sudo apt-get install liblogthread-dev git clone git://github.com/lkcl/pywebkitgtk.git cd pywebkitgtk git checkout -b pythonwebkitgtk_1_1_8 sudo ./autogen.sh sudo ./configure sudo make results in the following: make all-am make[1]: Entering directory `/home/david/Downloads/pywebkitgtk' /bin/bash ./libtool --tag=CC --mode=compile gcc -DHAVE_CONFIG_H -I. -I/usr/include/python2.6 -pthread -I/usr/include/libxml2 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/pygtk-2.0 -pthread -D_REENTRANT -I/usr/local/include/webkit-1.0 -I/usr/local/include/libsoup-2.4 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/gio-unix-2.0/ -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/directfb -I/usr/include/libpng12 -I/usr/include/libxml2 -g -O2 -MT webkit/webkit_la-webkitmodule.lo -MD -MP -MF webkit/.deps/webkit_la-webkitmodule.Tpo -c -o webkit/webkit_la-webkitmodule.lo `test -f 'webkit/webkitmodule.c' || echo './'`webkit/webkitmodule.c libtool: compile: gcc -DHAVE_CONFIG_H -I. -I/usr/include/python2.6 -pthread -I/usr/include/libxml2 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/pygtk-2.0 -pthread -D_REENTRANT -I/usr/local/include/webkit-1.0 -I/usr/local/include/libsoup-2.4 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/gio-unix-2.0/ -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/directfb -I/usr/include/libpng12 -I/usr/include/libxml2 -g -O2 -MT webkit/webkit_la-webkitmodule.lo -MD -MP -MF webkit/.deps/webkit_la-webkitmodule.Tpo -c webkit/webkitmodule.c -fPIC -DPIC -o webkit/.libs/webkit_la-webkitmodule.o libtool: compile: gcc -DHAVE_CONFIG_H -I. -I/usr/include/python2.6 -pthread -I/usr/include/libxml2 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/pygtk-2.0 -pthread -D_REENTRANT -I/usr/local/include/webkit-1.0 -I/usr/local/include/libsoup-2.4 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/gio-unix-2.0/ -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/directfb -I/usr/include/libpng12 -I/usr/include/libxml2 -g -O2 -MT webkit/webkit_la-webkitmodule.lo -MD -MP -MF webkit/.deps/webkit_la-webkitmodule.Tpo -c webkit/webkitmodule.c -o webkit/webkit_la-webkitmodule.o >/dev/null 2>&1 mv -f webkit/.deps/webkit_la-webkitmodule.Tpo webkit/.deps/webkit_la-webkitmodule.Plo /bin/bash ./libtool --tag=CC --mode=compile gcc -DHAVE_CONFIG_H -I. -I/usr/include/python2.6 -pthread -I/usr/include/libxml2 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/pygtk-2.0 -pthread -D_REENTRANT -I/usr/local/include/webkit-1.0 -I/usr/local/include/libsoup-2.4 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/gio-unix-2.0/ -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/directfb -I/usr/include/libpng12 -I/usr/include/libxml2 -g -O2 -MT javascriptcore/webkit_la-javascriptcore_types.lo -MD -MP -MF javascriptcore/.deps/webkit_la-javascriptcore_types.Tpo -c -o javascriptcore/webkit_la-javascriptcore_types.lo `test -f 'javascriptcore/javascriptcore_types.c' || echo './'`javascriptcore/javascriptcore_types.c libtool: compile: gcc -DHAVE_CONFIG_H -I. -I/usr/include/python2.6 -pthread -I/usr/include/libxml2 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/pygtk-2.0 -pthread -D_REENTRANT -I/usr/local/include/webkit-1.0 -I/usr/local/include/libsoup-2.4 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/gio-unix-2.0/ -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/directfb -I/usr/include/libpng12 -I/usr/include/libxml2 -g -O2 -MT javascriptcore/webkit_la-javascriptcore_types.lo -MD -MP -MF javascriptcore/.deps/webkit_la-javascriptcore_types.Tpo -c javascriptcore/javascriptcore_types.c -fPIC -DPIC -o javascriptcore/.libs/webkit_la-javascriptcore_types.o libtool: compile: gcc -DHAVE_CONFIG_H -I. -I/usr/include/python2.6 -pthread -I/usr/include/libxml2 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/pygtk-2.0 -pthread -D_REENTRANT -I/usr/local/include/webkit-1.0 -I/usr/local/include/libsoup-2.4 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/gio-unix-2.0/ -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/directfb -I/usr/include/libpng12 -I/usr/include/libxml2 -g -O2 -MT javascriptcore/webkit_la-javascriptcore_types.lo -MD -MP -MF javascriptcore/.deps/webkit_la-javascriptcore_types.Tpo -c javascriptcore/javascriptcore_types.c -o javascriptcore/webkit_la-javascriptcore_types.o >/dev/null 2>&1 mv -f javascriptcore/.deps/webkit_la-javascriptcore_types.Tpo javascriptcore/.deps/webkit_la-javascriptcore_types.Plo /usr/bin/python /usr/share/pygobject/2.0/codegen/createdefs.py webkit/webkit.defs ./webkit/webkitdom.defs ./webkit/webkit-base-types.defs ./webkit/webkit-1.1-types.defs ./webkit/webkit-1.0.2.defs ./webkit/webkit-1.1.defs (/usr/bin/pygobject-codegen-2.0 \ --register /usr/share/pygtk/2.0/defs/gdk-types.defs \ --register /usr/share/pygtk/2.0/defs/gtk-types.defs \ --override ./webkit/webkit.override \ --prefix pywebkit webkit/webkit.defs) 2>&1 > webkit/gen-webkit.c | tee webkit/webkit.errors \ && cp webkit/gen-webkit.c webkit/webkit.c \ && rm -f webkit/gen-webkit.c Warning: Constructor for WebKitWebHistoryItem needs to be updated to new API See http://live.gnome.org/PyGTK_2fWhatsNew28#update-constructors ***INFO*** The coverage of global functions is 100.00% (5/5) ***INFO*** The coverage of methods is 100.00% (1434/1434) ***INFO*** There are no declared virtual proxies. ***INFO*** There are no declared virtual accessors. ***INFO*** There are no declared interface proxies. /bin/bash ./libtool --tag=CC --mode=compile gcc -DHAVE_CONFIG_H -I. -I/usr/include/python2.6 -pthread -I/usr/include/libxml2 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/pygtk-2.0 -pthread -D_REENTRANT -I/usr/local/include/webkit-1.0 -I/usr/local/include/libsoup-2.4 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/gio-unix-2.0/ -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/directfb -I/usr/include/libpng12 -I/usr/include/libxml2 -g -O2 -MT webkit/webkit_la-webkit.lo -MD -MP -MF webkit/.deps/webkit_la-webkit.Tpo -c -o webkit/webkit_la-webkit.lo `test -f 'webkit/webkit.c' || echo './'`webkit/webkit.c libtool: compile: gcc -DHAVE_CONFIG_H -I. -I/usr/include/python2.6 -pthread -I/usr/include/libxml2 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/pygtk-2.0 -pthread -D_REENTRANT -I/usr/local/include/webkit-1.0 -I/usr/local/include/libsoup-2.4 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/gio-unix-2.0/ -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/directfb -I/usr/include/libpng12 -I/usr/include/libxml2 -g -O2 -MT webkit/webkit_la-webkit.lo -MD -MP -MF webkit/.deps/webkit_la-webkit.Tpo -c webkit/webkit.c -fPIC -DPIC -o webkit/.libs/webkit_la-webkit.o webkit/webkit.c: In function ?_wrap_webkit_dom_navigator_get_geolocation?: webkit/webkit.c:3642: error: ?WebKitDOMGeolocation? undeclared (first use in this function) webkit/webkit.c:3642: error: (Each undeclared identifier is reported only once webkit/webkit.c:3642: error: for each function it appears in.) webkit/webkit.c:3642: error: ?ret? undeclared (first use in this function) webkit/webkit.c: In function ?pywebkit_register_classes?: webkit/webkit.c:32127: error: ?WEBKIT_TYPE_DOM_GEOLOCATION? undeclared (first use in this function) make[1]: *** [webkit/webkit_la-webkit.lo] Error 1 make[1]: Leaving directory `/home/david/Downloads/pywebkitgtk' make: *** [all] Error 2 Alternatively I download pywebkitgtk-1.1.8 and extract. I download pywebkitgtk-1.1.8.patch to dir just extracted. cd pywebkitgtk-1.1.8 patch -p 1 < pywebkitgtk-1.1.8.patch ./configure sudo make Results in the following: cd . && /bin/bash /home/david/Downloads/pywebkitgtk-1.1.8/missing --run automake-1.11 --foreign aclocal.m4:16: warning: this file was generated for autoconf 2.66. You have another version of autoconf. It may work, but is not guaranteed to. If you have problems, you may need to regenerate the build system entirely. To do so, use the procedure documented by the package, typically `autoreconf'. cd . && /bin/bash ./config.status Makefile depfiles config.status: creating Makefile config.status: executing depfiles commands make all-am make[1]: Entering directory `/home/david/Downloads/pywebkitgtk-1.1.8' /bin/bash ./libtool --tag=CC --mode=compile gcc -DHAVE_CONFIG_H -I. -I/usr/include/python2.6 -pthread -I/usr/include/libxml2 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/pygtk-2.0 -pthread -D_REENTRANT -I/usr/local/include/webkit-1.0 -I/usr/local/include/libsoup-2.4 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/gio-unix-2.0/ -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/directfb -I/usr/include/libpng12 -I/usr/include/libxml2 -g -O2 -MT webkit/webkit_la-webkitmodule.lo -MD -MP -MF webkit/.deps/webkit_la-webkitmodule.Tpo -c -o webkit/webkit_la-webkitmodule.lo `test -f 'webkit/webkitmodule.c' || echo './'`webkit/webkitmodule.c libtool: compile: gcc -DHAVE_CONFIG_H -I. -I/usr/include/python2.6 -pthread -I/usr/include/libxml2 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/pygtk-2.0 -pthread -D_REENTRANT -I/usr/local/include/webkit-1.0 -I/usr/local/include/libsoup-2.4 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/gio-unix-2.0/ -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/directfb -I/usr/include/libpng12 -I/usr/include/libxml2 -g -O2 -MT webkit/webkit_la-webkitmodule.lo -MD -MP -MF webkit/.deps/webkit_la-webkitmodule.Tpo -c webkit/webkitmodule.c -fPIC -DPIC -o webkit/.libs/webkit_la-webkitmodule.o webkit/webkitmodule.c:30:22: error: pywebkit.h: No such file or directory webkit/webkitmodule.c:37: warning: 'struct pyjoinapi' declared inside parameter list webkit/webkitmodule.c:37: warning: its scope is only this definition or declaration, which is probably not what you want webkit/webkitmodule.c: In function 'initwebkit': webkit/webkitmodule.c:59: warning: passing argument 2 of 'webkit_init_pywebkit' from incompatible pointer type webkit/webkitmodule.c:37: note: expected 'struct pyjoinapi *' but argument is of type 'struct pyjoinapi *' make[1]: *** [webkit/webkit_la-webkitmodule.lo] Error 1 make[1]: Leaving directory `/home/david/Downloads/pywebkitgtk-1.1.8' make: *** [all] Error 2 From pythonmarco at gmail.com Thu Jan 13 15:03:39 2011 From: pythonmarco at gmail.com (Marco Hornung) Date: Thu, 13 Jan 2011 15:03:39 -0500 Subject: how to use priority queue with multiprocessing Message-ID: <87E38041-C753-40C1-BD37-0334717C543D@gmail.com> Hey, ------------------------------------------------------------------------------------------ question ------------------------------------------------------------------------------------------ How can I use a priority queue to schedule jobs within the "multiprocessing pool" module? ------------------------------------------------------------------------------------------ my scenario ------------------------------------------------------------------------------------------ I want to run several jobs on a server. The jobs are being sent by users. However, all jobs have a different priority, and high-priority jobs should be processed before any low-priority job gets touched. Currently I just append all incoming jobs to the multiprocessing worker pool as follows: ### initialize worker pool pool = PriorityPool(processes=worker_count) process_handles = [] ### distribute function execution over several processes for job_parameter in job_parameter_list: handle = pool.apply_async(process_function, [job_parameter,]) process_handles.append(handle) This will only put the jobs in some kind of a list - and execute the jobs in the order they come in. Is it possible to use a priority queue for the process-pool? Kind Regards, Marco From leoboiko at gmail.com Thu Jan 13 15:45:31 2011 From: leoboiko at gmail.com (leoboiko) Date: Thu, 13 Jan 2011 12:45:31 -0800 (PST) Subject: python 3 and Unicode line breaking Message-ID: <32f75200-b4d8-4ec8-b07d-4740a79c28b6@g26g2000vba.googlegroups.com> Hi, Is there an equivalent to the textwrap module that knows about the Unicode line breaking algorithm (UAX #14, http://unicode.org/reports/tr14/ )? From gnuist006 at gmail.com Thu Jan 13 16:18:31 2011 From: gnuist006 at gmail.com (bolega) Date: Thu, 13 Jan 2011 13:18:31 -0800 (PST) Subject: GURU NEEDED : break a command into several lines and comment each line Message-ID: Basically, I have spent a few hours experimenting and searching on the comp.unix.shell how to break a command with several switches into more than one line AND to be able to put some comment on each line. #!/bin/bash -xv command \ # comment1 -sw1 \ # comment2 -sw2 \ # comment3 arguments One ought to be able to comment every single switch if desired for whatever reason. Bolega From bhoel at despammed.com Thu Jan 13 16:45:20 2011 From: bhoel at despammed.com (Berthold =?utf-8?Q?H=C3=B6llmann?=) Date: Thu, 13 Jan 2011 22:45:20 +0100 Subject: GURU NEEDED : break a command into several lines and comment each line References: Message-ID: <87wrm8scjz.fsf@pchoel.xn--hllmanns-n4a.de> bolega writes: > Basically, I have spent a few hours experimenting and searching on the > comp.unix.shell > > how to break a command with several switches into more than one line > AND to be able to put some comment on each line. > > #!/bin/bash -xv > > command \ # comment1 > -sw1 \ # comment2 > -sw2 \ # comment3 > arguments How about ----------- #!/bin/bash -xv COMMAND=command # comment1 COMMAND=$COMMAND -sw1 \ # comment2 COMMAND=$COMMAND -sw2 \ # comment3 COMMAND=$COMMAND arguments $COMMAND --------- ? Regards Berthold > One ought to be able to comment every single switch if desired for > whatever reason. > > Bolega > > -- A: Weil es die Lesbarkeit des Textes verschlechtert. F: Warum ist TOFU so schlimm? A: TOFU F: Was ist das gr??te ?rgernis im Usenet? -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 197 bytes Desc: not available URL: From clp2 at rebertia.com Thu Jan 13 16:49:06 2011 From: clp2 at rebertia.com (Chris Rebert) Date: Thu, 13 Jan 2011 13:49:06 -0800 Subject: GURU NEEDED : break a command into several lines and comment each line In-Reply-To: References: Message-ID: On Thu, Jan 13, 2011 at 1:18 PM, bolega wrote: > Basically, I have spent a few hours experimenting and searching on the > comp.unix.shell > > how to break a command with several switches into more than one line > AND to be able to put some comment on each line. > > #!/bin/bash -xv > > command ? ? ? \ # comment1 > ? ? ? ? -sw1 \ # comment2 > ? ? ? ? -sw2 \ # comment3 > ? ? ? ? arguments > > One ought to be able to comment every single switch if desired for > whatever reason. This doesn't seem to have anything whatsoever to do with Python... Regards, Chris From dwhodgins at nomail.afraid.org Thu Jan 13 17:08:46 2011 From: dwhodgins at nomail.afraid.org (David W. Hodgins) Date: Thu, 13 Jan 2011 17:08:46 -0500 Subject: GURU NEEDED : break a command into several lines and comment each line References: Message-ID: On Thu, 13 Jan 2011 16:18:31 -0500, bolega wrote: > how to break a command with several switches into more than one line > AND to be able to put some comment on each line. > command \ # comment1 > -sw1 \ # comment2 Not what you want to hear, but that will not work. With the above, the backslash is being used to escape the following space, rather then a newline, as is required to continue the line. Even if it were to work that way, would the next line be considered a continuation of the command, or of the comment? Your stuck with command \ -sw1 # comment1 # comment2 Regards, Dave Hodgins -- Change nomail.afraid.org to ody.ca to reply by email. (nomail.afraid.org has been set up specifically for use in usenet. Feel free to use it yourself.) From steve+comp.lang.python at pearwood.info Thu Jan 13 19:15:23 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 14 Jan 2011 00:15:23 GMT Subject: python 3 and Unicode line breaking References: <32f75200-b4d8-4ec8-b07d-4740a79c28b6@g26g2000vba.googlegroups.com> Message-ID: <4d2f959a$0$29984$c3e8da3$5496439d@news.astraweb.com> On Thu, 13 Jan 2011 12:45:31 -0800, leoboiko wrote: > Hi, > > Is there an equivalent to the textwrap module that knows about the > Unicode line breaking algorithm (UAX #14, > http://unicode.org/reports/tr14/ )? Is access to Google blocked where you are, or would you just like us to do your searches for you? If you have tried searching, please say so, otherwise most people will conclude you haven't bothered, and most likely will not bother to reply. -- Steven From martin.hellwig at dcuktec.org Thu Jan 13 19:27:40 2011 From: martin.hellwig at dcuktec.org (Martin P. Hellwig) Date: Fri, 14 Jan 2011 00:27:40 +0000 Subject: Multiple independently started python processes and sharing of a module Message-ID: Hi all, I have the following problem (which I already have a hacked around solution that works but I'd would like some more input on it): I have a situation where multiple python processes are started independently from each other but by the same user with the same environment (as happens with mod_wsgi, when not using daemon mode). All of these processes access a single module which needs synchronization for some of the commands, for example a db (MySQLdb) module where when a select is done, the fetchall must be done of that same process before another process can do anything else. How would I go and provide synchronization? Locking does not seem to work because there is no relationship between all the python processes except that they are started by the same user. Currently my solution is to wrap the module around a module that when used creates a directory and pipes to the process (multiprocessing.Connection) thus enforcing single access and within that I have wrapped the db function around again so that select statement as mentioned above is actually an execute followed by a fetchall. I still have the nagging feeling that I have reinvented a squared wheel or am totally missing the point. Any suggestions/comments are greatly appreciated, Thanks in advanced, Martin P. Hellwig From steve+comp.lang.python at pearwood.info Thu Jan 13 19:48:53 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 14 Jan 2011 00:48:53 GMT Subject: GURU NEEDED : break a command into several lines and comment each line References: Message-ID: <4d2f9d74$0$29984$c3e8da3$5496439d@news.astraweb.com> On Thu, 13 Jan 2011 13:49:06 -0800, Chris Rebert wrote: > On Thu, Jan 13, 2011 at 1:18 PM, bolega wrote: >> Basically, I have spent a few hours experimenting and searching on the >> comp.unix.shell [...] > This doesn't seem to have anything whatsoever to do with Python... Well, I launch Python scripts from the shell, so there's your connection. *wink* -- Steven From aahz at pythoncraft.com Thu Jan 13 21:22:08 2011 From: aahz at pythoncraft.com (Aahz) Date: 13 Jan 2011 18:22:08 -0800 Subject: Trying to parse a HUGE(1gb) xml file References: <5f734c26-a804-4370-9e0d-5f1e1bb31105@glegroupsg2000goo.googlegroups.com> <1292874586.11975.8.camel@linux-yu4c.site> Message-ID: In article , Stefan Behnel wrote: > >Try > > import xml.etree.cElementTree as etree > >instead. Note the leading "c", which hints at the C implementations of >ElementTree. It's much faster and much more memory friendly than the Python >implementation. Thanks! I updated our codebase this afternoon... -- Aahz (aahz at pythoncraft.com) <*> http://www.pythoncraft.com/ "The volume of a pizza of thickness 'a' and radius 'z' is given by pi*z*z*a" From kushal.kumaran at gmail.com Thu Jan 13 22:04:05 2011 From: kushal.kumaran at gmail.com (Kushal Kumaran) Date: Fri, 14 Jan 2011 08:34:05 +0530 Subject: Multiple independently started python processes and sharing of a module In-Reply-To: References: Message-ID: <1294974245.31975.2.camel@Nokia-N900> ----- Original message ----- > Hi all, > > I have the following problem (which I already have a hacked around > solution that works but I'd would like some more input on it): > > I have a situation where multiple python processes are started > independently from each other but by the same user with the same > environment (as happens with mod_wsgi, when not using daemon mode). > > All of these processes access a single module which needs > synchronization for some of the commands, for example a db (MySQLdb) > module where when a select is done, the fetchall must be done of that > same process before another process can do anything else. > If the processes are independent, they are not sharing the database connection, unless you've taken steps to make it so. MySQLdb imported in one process should not interfere with MySQLdb importerd in another process. > -- regards, kushal From monnier at iro.umontreal.ca Thu Jan 13 22:12:30 2011 From: monnier at iro.umontreal.ca (Stefan Monnier) Date: Thu, 13 Jan 2011 22:12:30 -0500 Subject: GURU NEEDED : break a command into several lines and comment each line References: Message-ID: > #!/bin/bash -xv > command \ # comment1 > -sw1 \ # comment2 > -sw2 \ # comment3 > arguments > One ought to be able to comment every single switch if desired for > whatever reason. Thanks for the riddle. Here's a solution: command $(: # comment1 ) -sw1 $(: # comment2 ) -sw2 $(: # comment3 ) arguments -- Stefan From zuying at gmail.com Fri Jan 14 02:04:31 2011 From: zuying at gmail.com (ZuYing) Date: Thu, 13 Jan 2011 23:04:31 -0800 (PST) Subject: overplot while keeping the axes fixed Message-ID: <6289eadb-05d0-40be-8303-19b5373cb197@p38g2000vbn.googlegroups.com> Hi folks, I was trying to split the frame into 2 panels using "subplot", fig = matplotlib.pyplot.figure() plt1 = fig.add_subplot(2,1,1 ) plt2 = fig.add_subplot(2,1,2 ) plt1.plot(x1, y1, 'g-') plt2.plot(x2, y2, 'g-') then I need to overplot other curves on each subplot panel using the same axes/ticksize settings, although the new data points extend a longer x-range plt1.plot(x3, y3, 'g-') will simply overplot the new x3/y3 by extending the x-axis, is there a simply option or way to hold the axes/ ticksize setting fixed while doing overplot? I am writing a pipeline to analyze thousands of sets of data points, so a tunning on the pyplot would be a lot more preferred than finding the xrange individually for each data sets. Thanks! From __peter__ at web.de Fri Jan 14 02:05:31 2011 From: __peter__ at web.de (Peter Otten) Date: Fri, 14 Jan 2011 08:05:31 +0100 Subject: How to populate all possible hierarchical clusterings from a set of elements? References: <3cb5ae7e-866d-40fb-ae3f-496193db91e4@t35g2000yqj.googlegroups.com> <87d3o0r350.fsf@gmail.com> Message-ID: Arnaud Delobelle wrote: > more simply: > > def clusters(l): > if len(l) == 1: > yield l[0] > return > for i in range(1, len(l)): > for left in clusters(l[:i]): > for right in clusters(l[i:]): > yield (left, right) > > That would give all solutions without duplicates. In fact, this is > simply finding all full binary trees which order l. Easy, now that I see it ;) From martin.hellwig at dcuktec.org Fri Jan 14 03:21:45 2011 From: martin.hellwig at dcuktec.org (Martin P. Hellwig) Date: Fri, 14 Jan 2011 08:21:45 +0000 Subject: Multiple independently started python processes and sharing of a module In-Reply-To: References: Message-ID: On 01/14/11 03:04, Kushal Kumaran wrote: > ----- Original message ----- >> Hi all, >> >> I have the following problem (which I already have a hacked around >> solution that works but I'd would like some more input on it): >> >> I have a situation where multiple python processes are started >> independently from each other but by the same user with the same >> environment (as happens with mod_wsgi, when not using daemon mode). >> >> All of these processes access a single module which needs >> synchronization for some of the commands, for example a db (MySQLdb) >> module where when a select is done, the fetchall must be done of that >> same process before another process can do anything else. >> > > If the processes are independent, they are not sharing the database connection, unless you've taken steps to make it so. MySQLdb imported in one process should not interfere with MySQLdb importerd in another process. > >> > It might be a misconfiguration but, under mod_wsgi with apache it does. Cheers, Martin From aotto1968 at users.berlios.de Fri Jan 14 04:23:21 2011 From: aotto1968 at users.berlios.de (Andreas Otto) Date: Fri, 14 Jan 2011 10:23:21 +0100 Subject: ANNOUNCE: NHI1-0.11, PLMK-2.0 und libmsgque-5.0 Message-ID: -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Dear User, ANNOUNCE: Major Feature Release ==================================== libmsgque: Application-Server-Toolkit for C, C++, JAVA, C#, Go, TCL, PERL, PHP, PYTHON, RUBY, VB.NET PLMK: Programming-Language-Microkernel NHI1: Non-Human-Intelligence #1 SUMMARY ======= Finish release 4 of wp2 with adding Factory support. The Factory add the ability to create NEW server-types on-the-fly and introduce the self-programming capability to NHI1. The "Factory" is an important part of the object management and has the following basic features: * create a new instance identified by an "Identifier" or using an already available instance as template * cleanup and delete an instance * provide an "Identifier" for factory lookup and as an unique application name * identify the server in the network The link between the "Factory-Identifier" and the "Factory-Interface" is important for the future development of "libmsgque". Message-Routing, Service-Location and Persistent-Transactions depend on this feature. The relationship between the "MqFactoryS" and the "MqS" is the same as the relationship between a "type" and an "instance" of the "type" in a regular programming language. The "MqFactoryS" define the "type" of the server and the "MqS" define a single instance of the server. Every kind of server has !!only one!! specific "MqFactoryS" object but every instance of a server has one "MqS" object used for object management. Decreasing the size and the complexity of a "MqS" object will improve the server performance. In future more fields, defined in the "MqSetupS" attribute of the the "MqS" object, will move into "MqFactoryS" object. LINKS ===== libmsgque including PHP documentation: > http://nhi1.berlios.de/theLink/index.htm NHI1: > http://nhi1.berlios.de/ DOWNLOAD: > http://developer.berlios.de/projects/nhi1/ mfg, Andreas Otto (aotto1968) -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.15 (GNU/Linux) Comment: Using GnuPG with SUSE - http://enigmail.mozdev.org/ iQEcBAEBAgAGBQJNMBYJAAoJEGTcPijNG3/AxGkH/1Nf7GBL7DWAUktwaFs7Bs69 7voAXXWgIug+X42MqmsjFY8TrVGSHJfB8au+gecP1z6RQnPlubT2Od9T3GbXJL5h ZeyK8r2cf7reqp0W63iw0Gh+mDV/bmcjqjA8RTvw95du8l8t0W+zSjcDmeMct/a6 o8eTvQTfCyr7+LcOqjzVEA19XVVgJBF55DA24+HACVFgXfRchpylZiXegmAC0iFy gWKDAyiC95wJzZuqK+a5hPAYOZ+nhAaEMDVY0olN81qnWnb7j6uubSWAbgdXPWaP zu1gXoGo2fugqQt8XB1Ux8gHZhXOXVQGxcX2LyMUwiI1iXxnLVXXL1K3p7+Wnng= =/7W5 -----END PGP SIGNATURE----- From kushal.kumaran+python at gmail.com Fri Jan 14 05:05:25 2011 From: kushal.kumaran+python at gmail.com (Kushal Kumaran) Date: Fri, 14 Jan 2011 15:35:25 +0530 Subject: Multiple independently started python processes and sharing of a module In-Reply-To: References: Message-ID: On Fri, Jan 14, 2011 at 1:51 PM, Martin P. Hellwig wrote: > On 01/14/11 03:04, Kushal Kumaran wrote: >> >> ----- Original message ----- >>> >>> Hi all, >>> >>> I have the following problem (which I already have a hacked around >>> solution that works but I'd would like some more input on it): >>> >>> I have a situation where multiple python processes are started >>> independently from each other but by the same user with the same >>> environment (as happens with mod_wsgi, when not using daemon mode). >>> >>> All of these processes access a single module which needs >>> synchronization for some of the commands, for example a db (MySQLdb) >>> module where when a select is done, the fetchall must be done of that >>> same process before another process can do anything else. >>> >> >> If the processes are independent, they are not sharing the database >> connection, unless you've taken steps to make it so. ?MySQLdb imported in >> one process should not interfere with MySQLdb importerd in another process. >> >>> >> > It might be a misconfiguration but, under mod_wsgi with apache it does. > Ah, I didn't notice the mod_wsgi reference. I'm out of my depth here. Hopefully someone with mod_wsgi experience will chime in. This might help though: https://code.google.com/p/modwsgi/wiki/ProcessesAndThreading It seems if you're not using 'daemon' mode, global data might be shared. You could create new connections for each request (and close them when done). There won't be interference between select/fetch across multiple database connections. Additionally, the documentation of MySQLdb says it is a bad idea to share database connections between threads. -- regards, kushal From martin.hellwig at dcuktec.org Fri Jan 14 05:51:01 2011 From: martin.hellwig at dcuktec.org (Martin P. Hellwig) Date: Fri, 14 Jan 2011 10:51:01 +0000 Subject: Multiple independently started python processes and sharing of a module In-Reply-To: References: Message-ID: On 01/14/11 10:05, Kushal Kumaran wrote: > This might help though: > https://code.google.com/p/modwsgi/wiki/ProcessesAndThreading > > It seems if you're not using 'daemon' mode, global data might be shared. > Yes I read that thoroughly before I started out implementing a solution. But in my case I wanted something that worked as expected and not be depending on specific configuration of underlying technology as I can not assure that these condition will be met. > You could create new connections for each request (and close them when > done). There won't be interference between select/fetch across > multiple database connections. Additionally, the documentation of > MySQLdb says it is a bad idea to share database connections between > threads. > That is a possible solution too, however the performance impact is in the range of 40% while doing forced synchronization and overhead of the singleton wrapper is around 20%. So the latter is what I have gone with. Thanks for bouncing off ideas though, much appreciated. -- mph From hniksic at xemacs.org Fri Jan 14 06:25:11 2011 From: hniksic at xemacs.org (Hrvoje Niksic) Date: Fri, 14 Jan 2011 12:25:11 +0100 Subject: Resolve circular reference References: <1718ea91-fc4e-49f3-a15a-bdc683789126@k22g2000yqh.googlegroups.com> Message-ID: <87sjwviv6w.fsf@xemacs.org> Magnus Lyck? writes: >>>> a = X() >>>> del a > Deleted <__main__.X instance at 0x00CCCF80> >>>> a=X() >>>> b=X() >>>> a.b=b >>>> b.a=a >>>> del a >>>> gc.collect() > 0 >>>> del b >>>> gc.collect() > 4 If your method has a __del__ at all, the automatic cyclic collector is disabled. It detects the cycle, but it only stores the objects in gc.garbage, to give you a chance to do something about them, such as break the cycle(s) yourself. For example: >>> class X(object): ... def __del__(self): ... print 'deleted', self ... >>> a, b = X(), X() >>> a.cycle = b >>> b.cycle = a >>> del a, b >>> import gc >>> gc.collect() 4 >>> gc.garbage [<__main__.X object at 0xb76d84cc>, <__main__.X object at 0xb76d980c>] >>> del gc.garbage[0].cycle >>> del gc.garbage[:] deleted <__main__.X object at 0xb76d980c> deleted <__main__.X object at 0xb76d84cc> From tkpmep at gmail.com Fri Jan 14 06:55:10 2011 From: tkpmep at gmail.com (Thomas Philips) Date: Fri, 14 Jan 2011 03:55:10 -0800 (PST) Subject: FTP problem Message-ID: I'm using ftplib for the first time, and am having trouble getting it to work. I type >>> from ftplib import FTP >>> ftp = FTP('ftp.indexftp.barcap.com', 'A Valid Username', ' A Valid Password') where I have suppressed the user name and password, and I get Traceback (most recent call last): File "", line 1, in ftp = FTP('ftp.indexftp.barcap.com') File "C:\Python26\lib\ftplib.py", line 116, in __init__ self.connect(host) File "C:\Python26\lib\ftplib.py", line 131, in connect self.sock = socket.create_connection((self.host, self.port), self.timeout) File "C:\Python26\lib\socket.py", line 498, in create_connection for res in getaddrinfo(host, port, 0, SOCK_STREAM): gaierror: [Errno 11001] getaddrinfo failed I have tried this on two different computers and on two different versions of Python (2.6 and 2.7). I get the same error both times, and have no understanding of what the problem might be. Any assistance would be greatly appreciated. Sincerely Thomas Philips From python at bdurham.com Fri Jan 14 07:05:05 2011 From: python at bdurham.com (python at bdurham.com) Date: Fri, 14 Jan 2011 07:05:05 -0500 Subject: FTP problem In-Reply-To: References: Message-ID: <1295006705.28988.1415283211@webmail.messagingengine.com> Thomas, > ftp = FTP('ftp.indexftp.barcap.com', 'A Valid Username', ' A Valid Password') Your FTP URI is bad. When I try to connect to your site from the Windows FTP client, I get the following response: Unknown host ftp.indexftp.barcap.com. Malcolm From sudheer.s at sudheer.net Fri Jan 14 07:07:11 2011 From: sudheer.s at sudheer.net (Sudheer Satyanarayana) Date: Fri, 14 Jan 2011 17:37:11 +0530 Subject: FTP problem In-Reply-To: References: Message-ID: <4D303C6F.9080809@sudheer.net> > gaierror: [Errno 11001] getaddrinfo failed That part of the error indicates, your computer is unable to resolve the IP address for the hostname ftp.indexftp.barcap.com Make sure the hostname is valid. -- With warm regards, Sudheer. S Personal home page - http://sudheer.net | Tech Chorus - http://techchorus.net Web and IT services - http://binaryvibes.co.in From alex.kyrish at gmail.com Fri Jan 14 07:15:10 2011 From: alex.kyrish at gmail.com (Alex Boyko) Date: Fri, 14 Jan 2011 14:15:10 +0200 Subject: unbalanced tree iteration issue Message-ID: Dear All! I have deal with large unbalanced trees and I have to implement post-order tree traversal. My first attempt is shown below ("Node" and "Tree" classes) and based on recursive generators approach. class Node(): def __init__(self,value): self.childs = [] self.value = value class Tree(): def __init__(self, root): self.root = root self.numberCells = 1 def add(self, node, child): node.childs.append(child) self.numberCells+=1 def __iter__(self): return self.postorder(self.root) def postorder(self, node): if node: for child in node.childs: for n in self.postorder(child): yield n yield node It works fine for small test trees. But, my tree has approximately 300000 nodes, and shown post order traversal with generators takes 80 sec against 1 sec with simple recursive routine: def recursiveFromTop(node): for child in node.childs: recursiveFromTop(child) ## here I can do some computations with current node's data So, I'd like to know how should I implement (if it's possible of course) __iter__ for my tree class based on recursion without generators? Please, can You show me the ways? because I'm very passionate in idea iterate through my tree with simple: for node in tree: do something with node Thanks in Advance! Best Regards! Alex -------------- next part -------------- An HTML attachment was scrubbed... URL: From alt.mcarter at gmail.com Fri Jan 14 07:28:37 2011 From: alt.mcarter at gmail.com (Mark Carter) Date: Fri, 14 Jan 2011 04:28:37 -0800 (PST) Subject: wx Just Print! Message-ID: <00354847-5ab0-4247-802c-15cd0f7d22c7@fo10g2000vbb.googlegroups.com> I'm using Python 2.6.5. I would like to be able to print an RTF file, with no prompts for printers or anything like that. Here's the code so far: import wx.richtext rtp = wx.richtext.RichTextPrinting() rtp.PrintFile('C:\\path\\to\\file.rtf') When I run it, it says: ... assert "(wxThePrintPaperDatabase*) NULL) failed ... What is the fix? From chris at simplistix.co.uk Fri Jan 14 07:38:26 2011 From: chris at simplistix.co.uk (Chris Withers) Date: Fri, 14 Jan 2011 12:38:26 +0000 Subject: TestFixtures 1.8.0 Released! Message-ID: <4D3043C2.6020305@simplistix.co.uk> Hi All, I'm very happy to announce the first fully-documented release of TestFixtures, my collection of testing fixtures and helpers that I've been collecting for the last couple of years. Along with my own take on a lot of the common fixtures and helpers, it has some bits that I haven't seen anywhere else and so would like to point out: - Comparison objects for comparing objects that don't natively support comparison: http://packages.python.org/testfixtures/comparing.html#comparison-objects - Helpful mock objects for when you want to test code that makes use of datetime.datetime.now, datetime.date.today or time.time: http://packages.python.org/testfixtures/datetime.html - Helpers for capturing and checking messages logged from your code using the python logging framework: http://packages.python.org/testfixtures/logging.html - Helpers for working with temporary directories in tests. In particular, quickly and easily creating temporary directories and files within them and making assertions about things written to them by the code under test: http://packages.python.org/testfixtures/files.html There's plenty more in there too! Please do let me know what you find useful, if you find any bugs or if there are any features you'd like to see added. The package is on PyPI and a full list of all the links to docs, issue trackers and the like can be found here: http://www.simplistix.co.uk/software/python/testfixtures cheers, Chris -- Simplistix - Content Management, Batch Processing & Python Consulting - http://www.simplistix.co.uk From leoboiko at gmail.com Fri Jan 14 08:06:15 2011 From: leoboiko at gmail.com (leoboiko) Date: Fri, 14 Jan 2011 05:06:15 -0800 (PST) Subject: python 3 and Unicode line breaking References: <32f75200-b4d8-4ec8-b07d-4740a79c28b6@g26g2000vba.googlegroups.com> <4d2f959a$0$29984$c3e8da3$5496439d@news.astraweb.com> Message-ID: <55c2f7dc-d4d8-4939-85de-41c19c336f23@k25g2000vbl.googlegroups.com> Of course I searched for one and couldn?t find; that goes without saying. Otherwise I wouldn?t even bother writing a message, isn?t it? I disagree people should cruft their messages with details about how they failed to find information, as that is unrelated to the question at hand and has no point other than polluting people?s mailboxes. I also see no reason to reply to a simple question with such discourtesy, and cannot understand why someone would be so aggressive to a stranger. From k.bx at ya.ru Fri Jan 14 08:26:59 2011 From: k.bx at ya.ru (kost BebiX) Date: Fri, 14 Jan 2011 15:26:59 +0200 Subject: unbalanced tree iteration issue In-Reply-To: References: Message-ID: <461431295011620@web65.yandex.ru> 14.01.2011, 14:15, "Alex Boyko" : > Dear All! > > I have deal with large unbalanced trees and I have to implement post-order tree traversal. My first attempt is shown below ("Node" and "Tree" classes) and based on recursive generators approach. > > class Node(): > ?? ?def __init__(self,value): > ?? ? ? ?self.childs = [] > ?? ? ? ?self.value = value > > class Tree(): > > ?? ?def __init__(self, root): > ?? ? ? ?self.root = root > ?? ? ? ?self.numberCells = 1 > > ?? ?def add(self, node, child): > ?? ? ? ?node.childs.append(child) > ?? ? ? ?self.numberCells+=1 > > ?? ?def __iter__(self): > ?? ? ? ?return self.postorder(self.root) > > ?? ?def postorder(self, node): > ?? ? ? ?if node: > ?? ? ? ? ? ?for child in node.childs: > ?? ? ? ? ? ? ? ?for n in self.postorder(child): > ?? ? ? ? ? ? ? ? ? ?yield n > ?? ? ? ? ? ?yield node > > It works fine for small test trees. But, my tree has approximately 300000 nodes, and shown post order traversal with generators takes 80 sec against 1 sec with simple recursive routine: > > def recursiveFromTop(node): > ?? ?for child in node.childs: > ?? ? ? ?recursiveFromTop(child) > ?? ? ? ?## here I can do some computations with current node's data > > So, I'd like to know how?should?I implement (if it's possible of course) __iter__ for my tree class based on recursion without generators? Please, can You show me the ways? > because I'm very passionate in idea iterate through my tree with simple: > > for node in tree: > ?? do something with node > > Thanks in Advance! > Best Regards! > Alex > > -- > http://mail.python.org/mailman/listinfo/python-list Well, I think it's actually because the difference is that you would not do yielding, you would just put everything in memory and then return it. ret_val = [x for x in self.postorder(child)] return ret_val + [self] or something like that (but beware of memory). But that's strange. This code works fast: #!/usr/bin/env python # -*- coding: utf-8 -*- import sys def w(s): sys.stdout.write("%s" % s) sys.stdout.flush() class Node(): __slots__ = ('childs', 'value',) def __init__(self, value): self.childs = [] self.value = value def post_order(self): for child in self.childs: yield child yield self def build_tree(): def append_1000_childs(node): for i in xrange(20): node.childs.append(Node(10)) def append_n_levels(node, levels=1): if levels >= 1: append_1000_childs(node) if levels > 1: for child in node.childs: append_n_levels(child, levels - 1) root = Node(10) append_n_levels(root, 5) return root if __name__ == '__main__': from datetime import datetime w("building tree...") _t = datetime.now() root = build_tree() w("done\n") w(datetime.now() - _t) w("\n") w("doing generator post_order...") _t = datetime.now() for item in root.post_order(): fake = item.value w("done\n") w(datetime.now() - _t) w("\n") def post_order(root): for child in root.childs: post_order(child) fake = item.value w("doing non-generator post_order...") _t = datetime.now() post_order(root) w("done\n") w(datetime.now() - _t) w("\n") $ python postorder.py building tree...done 0:01:34.422288 doing generator post_order...done 0:00:00.000018 doing non-generator post_order...done 0:00:01.232272 -- jabber: k.bx at ya.ru From k.bx at ya.ru Fri Jan 14 08:29:34 2011 From: k.bx at ya.ru (kost BebiX) Date: Fri, 14 Jan 2011 15:29:34 +0200 Subject: unbalanced tree iteration issue In-Reply-To: References: Message-ID: <77391295011774@web158.yandex.ru> 14.01.2011, 14:15, "Alex Boyko" : > Dear All! > > I have deal with large unbalanced trees and I have to implement post-order tree traversal. My first attempt is shown below ("Node" and "Tree" classes) and based on recursive generators approach. > > class Node(): > ?? ?def __init__(self,value): > ?? ? ? ?self.childs = [] > ?? ? ? ?self.value = value > > class Tree(): > > ?? ?def __init__(self, root): > ?? ? ? ?self.root = root > ?? ? ? ?self.numberCells = 1 > > ?? ?def add(self, node, child): > ?? ? ? ?node.childs.append(child) > ?? ? ? ?self.numberCells+=1 > > ?? ?def __iter__(self): > ?? ? ? ?return self.postorder(self.root) > > ?? ?def postorder(self, node): > ?? ? ? ?if node: > ?? ? ? ? ? ?for child in node.childs: > ?? ? ? ? ? ? ? ?for n in self.postorder(child): > ?? ? ? ? ? ? ? ? ? ?yield n > ?? ? ? ? ? ?yield node > > It works fine for small test trees. But, my tree has approximately 300000 nodes, and shown post order traversal with generators takes 80 sec against 1 sec with simple recursive routine: > > def recursiveFromTop(node): > ?? ?for child in node.childs: > ?? ? ? ?recursiveFromTop(child) > ?? ? ? ?## here I can do some computations with current node's data > > So, I'd like to know how?should?I implement (if it's possible of course) __iter__ for my tree class based on recursion without generators? Please, can You show me the ways? > because I'm very passionate in idea iterate through my tree with simple: > > for node in tree: > ?? do something with node > > Thanks in Advance! > Best Regards! > Alex > > -- > http://mail.python.org/mailman/listinfo/python-list Forgot to make new-style object) class Node(object): The results for new-style objects are: $ python postorder.py building tree...done 0:00:26.180799 doing generator post_order...done 0:00:00.000017 doing non-generator post_order...done 0:00:01.117986 -- jabber: k.bx at ya.ru From k.bx at ya.ru Fri Jan 14 08:33:34 2011 From: k.bx at ya.ru (kost BebiX) Date: Fri, 14 Jan 2011 15:33:34 +0200 Subject: unbalanced tree iteration issue In-Reply-To: References: Message-ID: <85071295012015@web146.yandex.ru> 14.01.2011, 14:17, "Alex Boyko" : > Dear All! > > I have deal with large unbalanced trees and I have to implement post-order tree traversal. My first attempt is shown below ("Node" and "Tree" classes) and based on recursive generators approach. > > class Node(): > ?? ?def __init__(self,value): > ?? ? ? ?self.childs = [] > ?? ? ? ?self.value = value > > class Tree(): > > ?? ?def __init__(self, root): > ?? ? ? ?self.root = root > ?? ? ? ?self.numberCells = 1 > > ?? ?def add(self, node, child): > ?? ? ? ?node.childs.append(child) > ?? ? ? ?self.numberCells+=1 > > ?? ?def __iter__(self): > ?? ? ? ?return self.postorder(self.root) > > ?? ?def postorder(self, node): > ?? ? ? ?if node: > ?? ? ? ? ? ?for child in node.childs: > ?? ? ? ? ? ? ? ?for n in self.postorder(child): > ?? ? ? ? ? ? ? ? ? ?yield n > ?? ? ? ? ? ?yield node > > It works fine for small test trees. But, my tree has approximately 300000 nodes, and shown post order traversal with generators takes 80 sec against 1 sec with simple recursive routine: > > def recursiveFromTop(node): > ?? ?for child in node.childs: > ?? ? ? ?recursiveFromTop(child) > ?? ? ? ?## here I can do some computations with current node's data > > So, I'd like to know how?should?I implement (if it's possible of course) __iter__ for my tree class based on recursion without generators? Please, can You show me the ways? > because I'm very passionate in idea iterate through my tree with simple: > > for node in tree: > ?? do something with node > > Thanks in Advance! > Best Regards! > Alex > > -- > http://mail.python.org/mailman/listinfo/python-list God damn pypy is fast)) $ ~/bin/pypy-1.4.1-linux64/bin/pypy ./postorder.py building tree...done 0:00:03.000854 doing generator post_order...done 0:00:00.000069 doing non-generator post_order...done 0:00:00.240168 -- jabber: k.bx at ya.ru From stefan_ml at behnel.de Fri Jan 14 08:39:01 2011 From: stefan_ml at behnel.de (Stefan Behnel) Date: Fri, 14 Jan 2011 14:39:01 +0100 Subject: python 3 and Unicode line breaking In-Reply-To: <55c2f7dc-d4d8-4939-85de-41c19c336f23@k25g2000vbl.googlegroups.com> References: <32f75200-b4d8-4ec8-b07d-4740a79c28b6@g26g2000vba.googlegroups.com> <4d2f959a$0$29984$c3e8da3$5496439d@news.astraweb.com> <55c2f7dc-d4d8-4939-85de-41c19c336f23@k25g2000vbl.googlegroups.com> Message-ID: leoboiko, 14.01.2011 14:06: > Of course I searched for one and couldn?t find; that goes without > saying. Otherwise I wouldn?t even bother writing a message, isn?t > it? I disagree people should cruft their messages with details about > how they failed to find information, as that is unrelated to the > question at hand and has no point other than polluting people?s > mailboxes. http://www.catb.org/~esr/faqs/smart-questions.html#beprecise http://www.catb.org/~esr/faqs/smart-questions.html#volume Stefan From stefan_ml at behnel.de Fri Jan 14 08:48:29 2011 From: stefan_ml at behnel.de (Stefan Behnel) Date: Fri, 14 Jan 2011 14:48:29 +0100 Subject: python 3 and Unicode line breaking In-Reply-To: <4d2f959a$0$29984$c3e8da3$5496439d@news.astraweb.com> References: <32f75200-b4d8-4ec8-b07d-4740a79c28b6@g26g2000vba.googlegroups.com> <4d2f959a$0$29984$c3e8da3$5496439d@news.astraweb.com> Message-ID: Steven D'Aprano, 14.01.2011 01:15: > On Thu, 13 Jan 2011 12:45:31 -0800, leoboiko wrote: >> Is there an equivalent to the textwrap module that knows about the >> Unicode line breaking algorithm (UAX #14, >> http://unicode.org/reports/tr14/ )? > > Is access to Google blocked where you are, or would you just like us to > do your searches for you? > > If you have tried searching, please say so, otherwise most people will > conclude you haven't bothered, and most likely will not bother to reply. I think the OP was asking for something like the "textwrap" module (which the OP apparently knows about), but based on a special line break algorithm which, as suggested by the way the OP asks, is not supported by textwrap. Sadly, the OP did not clearly state that the required feature is really not supported by "textwrap" and in what way textwrap behaves differently. That would have helped in answering. Stefan From phlip2005 at gmail.com Fri Jan 14 09:15:35 2011 From: phlip2005 at gmail.com (Phlip) Date: Fri, 14 Jan 2011 06:15:35 -0800 Subject: [TIP] TestFixtures 1.8.0 Released! In-Reply-To: <4D3043C2.6020305@simplistix.co.uk> References: <4D3043C2.6020305@simplistix.co.uk> Message-ID: [ please set the reply-to to testing-in-python@ !] > The package is on PyPI and a full list of all the links to docs, issue > trackers and the like can be found here: > > http://www.simplistix.co.uk/software/python/testfixtures The number one problem with all the test fixture systems I ever auditioned for Django models was unbelievable slowness. Thats' a major bummer for TDD, because you should integrate after every few edits, and a slow integration derails your flow. On a project with 500 tests the complete run could be 5 minutes. Some fixture systems use JSON to represent model values, and they pump the JSON directly into SQL insert statements. I was using farmdev's fixture system, and it was incredibly slow. It also did not use raw SQL. It fully resolved all records into model objects, and called save() on them. (The extra round trip thru a model's validations would be nice - if we were testing validations. That's what explicit tests are for!) I rewrote the fixture loader, going direct to SQL, and got a major speed boost. Then I rewrote it again, going directly from XML to our (very simple & stereotypical) model objects, and called save(). The speed boost remained. I have no idea what farmdev fixture was doing to slow things down. Anyway thanks for the library, but you can see I can't use its fixture loader; I'm just putting this out here. But does it do Django models, and are they performant? -- Phlip http://c2.com/cgi/wiki?ZeekLand From leoboiko at gmail.com Fri Jan 14 09:29:27 2011 From: leoboiko at gmail.com (leoboiko) Date: Fri, 14 Jan 2011 06:29:27 -0800 (PST) Subject: python 3 and Unicode line breaking References: <32f75200-b4d8-4ec8-b07d-4740a79c28b6@g26g2000vba.googlegroups.com> <4d2f959a$0$29984$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Jan 14, 11:48 am, Stefan Behnel wrote: > Sadly, the OP did not clearly state that the required feature > is really not supported by "textwrap" and in what way textwrap > behaves differently. That would have helped in answering. Oh, textwrap doesn?t work for arbitrary Unicode text at all. For example, it separates combining sequences: >>> s = "ti?ng Vi?t" # precomposed >>> len(s) 10 >>> s = "ti?ng Vi?t" # combining >>> len(s) # number of unicode characters; ? line length 14 >>> print(textwrap.fill(s, width=4)) # breaks sequences ti? ng Vi? t It also doesn?t know about double-width characters: >>> s1 = "???????" >>> s2 = "12345678901234" # both s1 and s2 use 14 columns >>> print(textwrap.fill(s1, width=7)) ??????? >>> print(textwrap.fill(s2, width=7)) 1234567 8901234 It doesn?t know about non-ascii punctuation: >>> print(textwrap.fill("abc-def", width=5)) # ASCII minus-hyphen abc- def >>> print(textwrap.fill("abc?def", width=5)) # true hyphen U+2010 abc?d ef It doesn?t know East Asian filling rules (though this is perhaps pushing it a bit beyond textwrap?s goals): >>> print(textwrap.fill("???????", width=3)) ??? ??? # should avoid linebreak before CJK punctuation ? And it generally doesn?t try to pick good places to break lines at all, just making the assumption that 1 character = 1 column and that breaking on ASCII whitespaces/hyphens is enough. We can?t really blame textwrap for that, it is a very simple module and Unicode line breaking gets complex fast (that?s why the consortium provides a ready-made algorithm). It?s just that, with python3?s emphasis on Unicode support, I was surprised not to be able to find an UAX #14 implementation. I thought someone would surely have written one and I simply couldn?t find, so I asked precisely that. From whatsjacksemail at gmail.com Fri Jan 14 09:39:05 2011 From: whatsjacksemail at gmail.com (Jack Keegan) Date: Fri, 14 Jan 2011 14:39:05 +0000 Subject: TestFixtures 1.8.0 Released! In-Reply-To: <4D3043C2.6020305@simplistix.co.uk> References: <4D3043C2.6020305@simplistix.co.uk> Message-ID: I'm new to python and have just been looking into a solution for Mocking objects. In particular, at the moment, testing some code that needs to access hardware IOs using DLLs. I do this using Ctypes. However, on my dev machine, I don't have the same hardware so calling the DLL functions will not work as expected. Therefore I'd like to mock out the ctypes dll calls. Can you give me an indication of how you would go about doing this with Simplistix? Just so you know, I use py.test for unit testing. Thanks, Jack On Fri, Jan 14, 2011 at 12:38 PM, Chris Withers wrote: > Hi All, > > I'm very happy to announce the first fully-documented release of > TestFixtures, my collection of testing fixtures and helpers that I've been > collecting for the last couple of years. > > Along with my own take on a lot of the common fixtures and helpers, it has > some bits that I haven't seen anywhere else and so would like to point out: > > - Comparison objects for comparing objects that don't natively support > comparison: > > http://packages.python.org/testfixtures/comparing.html#comparison-objects > > - Helpful mock objects for when you want to test code that makes use of > datetime.datetime.now, datetime.date.today or time.time: > > http://packages.python.org/testfixtures/datetime.html > > - Helpers for capturing and checking messages logged from your code > using the python logging framework: > > http://packages.python.org/testfixtures/logging.html > > - Helpers for working with temporary directories in tests. In > particular, quickly and easily creating temporary directories and > files within them and making assertions about things written to them > by the code under test: > > http://packages.python.org/testfixtures/files.html > > There's plenty more in there too! > > Please do let me know what you find useful, if you find any bugs or if > there are any features you'd like to see added. > > The package is on PyPI and a full list of all the links to docs, issue > trackers and the like can be found here: > > http://www.simplistix.co.uk/software/python/testfixtures > > cheers, > > Chris > > -- > Simplistix - Content Management, Batch Processing & Python Consulting > - http://www.simplistix.co.uk > -- > http://mail.python.org/mailman/listinfo/python-list > -- The earth is a very small stage in a vast cosmic arena. Think of the rivers of blood spilled by all those generals and emperors so that in glory and in triumph they could become the momentary masters of a fraction of a dot. - Carl Sagan [Pale Blue Dot] -------------- next part -------------- An HTML attachment was scrubbed... URL: From whatsjacksemail at gmail.com Fri Jan 14 09:40:52 2011 From: whatsjacksemail at gmail.com (Jack Keegan) Date: Fri, 14 Jan 2011 14:40:52 +0000 Subject: TestFixtures 1.8.0 Released! In-Reply-To: References: <4D3043C2.6020305@simplistix.co.uk> Message-ID: Appologies, please read the 2nd last line as: Can you give me an indication of how you would go about doing this with TestFixtures? :) Thanks Jack On Fri, Jan 14, 2011 at 2:39 PM, Jack Keegan wrote: > I'm new to python and have just been looking into a solution for Mocking > objects. In particular, at the moment, testing some code that needs to > access hardware IOs using DLLs. I do this using Ctypes. > However, on my dev machine, I don't have the same hardware so calling the > DLL functions will not work as expected. Therefore I'd like to mock out the > ctypes dll calls. Can you give me an indication of how you would go about > doing this with Simplistix? Just so you know, I use py.test for unit > testing. > > Thanks, > > Jack > > On Fri, Jan 14, 2011 at 12:38 PM, Chris Withers wrote: > >> Hi All, >> >> I'm very happy to announce the first fully-documented release of >> TestFixtures, my collection of testing fixtures and helpers that I've been >> collecting for the last couple of years. >> >> Along with my own take on a lot of the common fixtures and helpers, it has >> some bits that I haven't seen anywhere else and so would like to point out: >> >> - Comparison objects for comparing objects that don't natively support >> comparison: >> >> >> http://packages.python.org/testfixtures/comparing.html#comparison-objects >> >> - Helpful mock objects for when you want to test code that makes use of >> datetime.datetime.now, datetime.date.today or time.time: >> >> http://packages.python.org/testfixtures/datetime.html >> >> - Helpers for capturing and checking messages logged from your code >> using the python logging framework: >> >> http://packages.python.org/testfixtures/logging.html >> >> - Helpers for working with temporary directories in tests. In >> particular, quickly and easily creating temporary directories and >> files within them and making assertions about things written to them >> by the code under test: >> >> http://packages.python.org/testfixtures/files.html >> >> There's plenty more in there too! >> >> Please do let me know what you find useful, if you find any bugs or if >> there are any features you'd like to see added. >> >> The package is on PyPI and a full list of all the links to docs, issue >> trackers and the like can be found here: >> >> http://www.simplistix.co.uk/software/python/testfixtures >> >> cheers, >> >> Chris >> >> -- >> Simplistix - Content Management, Batch Processing & Python Consulting >> - http://www.simplistix.co.uk >> -- >> http://mail.python.org/mailman/listinfo/python-list >> > > > > -- > The earth is a very small stage in a vast cosmic arena. Think of the rivers > of blood spilled by all those generals and emperors so that in glory and in > triumph they could become the momentary masters of a fraction of a dot. > - Carl Sagan [Pale Blue Dot] > -- The earth is a very small stage in a vast cosmic arena. Think of the rivers of blood spilled by all those generals and emperors so that in glory and in triumph they could become the momentary masters of a fraction of a dot. - Carl Sagan [Pale Blue Dot] -------------- next part -------------- An HTML attachment was scrubbed... URL: From chris at simplistix.co.uk Fri Jan 14 09:49:16 2011 From: chris at simplistix.co.uk (Chris Withers) Date: Fri, 14 Jan 2011 14:49:16 +0000 Subject: TestFixtures 1.8.0 Released! In-Reply-To: References: <4D3043C2.6020305@simplistix.co.uk> Message-ID: <4D30626C.2@simplistix.co.uk> Hi Jack, On 14/01/2011 14:39, Jack Keegan wrote: > objects. In particular, at the moment, testing some code that needs to > access hardware IOs using DLLs. I do this using Ctypes. > However, on my dev machine, I don't have the same hardware so calling > the DLL functions will not work as expected. Therefore I'd like to mock > out the ctypes dll calls. Can you give me an indication of how you would > go about doing this with TestFixtures? Just so you know, I use py.test for > unit testing. I've not used ctypes myself so let me know if things don't work ;-) I'd suggest developing mock objects to work in place of your ctypes objects. You may well find that if you're just wanting to test that the right calls are made you can use an existing mock objects such as: http://pypi.python.org/pypi/mock/ ...and then compare the method_calls attribute of the mock with what you expect it to be. TestFixtures provides some handy tools for managing the insertion and removal of mock objects, read here: http://packages.python.org/testfixtures/mocking.html cheers, Chris -- Simplistix - Content Management, Batch Processing & Python Consulting - http://www.simplistix.co.uk From whatsjacksemail at gmail.com Fri Jan 14 09:53:38 2011 From: whatsjacksemail at gmail.com (Jack Keegan) Date: Fri, 14 Jan 2011 14:53:38 +0000 Subject: TestFixtures 1.8.0 Released! In-Reply-To: <4D30626C.2@simplistix.co.uk> References: <4D3043C2.6020305@simplistix.co.uk> <4D30626C.2@simplistix.co.uk> Message-ID: Hi Chris, Thanks for that. I'll give it a go. Cheers, Jack On Fri, Jan 14, 2011 at 2:49 PM, Chris Withers wrote: > Hi Jack, > > > On 14/01/2011 14:39, Jack Keegan wrote: > >> objects. In particular, at the moment, testing some code that needs to >> access hardware IOs using DLLs. I do this using Ctypes. >> However, on my dev machine, I don't have the same hardware so calling >> the DLL functions will not work as expected. Therefore I'd like to mock >> out the ctypes dll calls. Can you give me an indication of how you would >> go about doing this with TestFixtures? Just so you know, I use py.test for >> unit testing. >> > > I've not used ctypes myself so let me know if things don't work ;-) > > I'd suggest developing mock objects to work in place of your ctypes > objects. You may well find that if you're just wanting to test that the > right calls are made you can use an existing mock objects such as: > > http://pypi.python.org/pypi/mock/ > > ...and then compare the method_calls attribute of the mock with what you > expect it to be. > > TestFixtures provides some handy tools for managing the insertion and > removal of mock objects, read here: > > http://packages.python.org/testfixtures/mocking.html > > > cheers, > > Chris > > -- > Simplistix - Content Management, Batch Processing & Python Consulting > - http://www.simplistix.co.uk > -- The earth is a very small stage in a vast cosmic arena. Think of the rivers of blood spilled by all those generals and emperors so that in glory and in triumph they could become the momentary masters of a fraction of a dot. - Carl Sagan [Pale Blue Dot] -------------- next part -------------- An HTML attachment was scrubbed... URL: From anurag.chourasia at gmail.com Fri Jan 14 10:50:56 2011 From: anurag.chourasia at gmail.com (Anurag Chourasia) Date: Fri, 14 Jan 2011 21:20:56 +0530 Subject: FTP problem In-Reply-To: References: Message-ID: Please make the below change to get past this problem Change *ftp.*indexftp.barcap.com to indexftp.barcap.com Regards, Anurag On Fri, Jan 14, 2011 at 5:25 PM, Thomas Philips wrote: > I'm using ftplib for the first time, and am having trouble getting it > to work. I type > > >>> from ftplib import FTP > >>> ftp = FTP('ftp.indexftp.barcap.com', 'A Valid Username', ' A Valid > Password') > > where I have suppressed the user name and password, and I get > > Traceback (most recent call last): > File "", line 1, in > ftp = FTP('ftp.indexftp.barcap.com') > File "C:\Python26\lib\ftplib.py", line 116, in __init__ > self.connect(host) > File "C:\Python26\lib\ftplib.py", line 131, in connect > self.sock = socket.create_connection((self.host, self.port), > self.timeout) > File "C:\Python26\lib\socket.py", line 498, in create_connection > for res in getaddrinfo(host, port, 0, SOCK_STREAM): > gaierror: [Errno 11001] getaddrinfo failed > > I have tried this on two different computers and on two different > versions of Python (2.6 and 2.7). I get the same error both times, and > have no understanding of what the problem might be. Any assistance > would be greatly appreciated. > > Sincerely > > Thomas Philips > -- > http://mail.python.org/mailman/listinfo/python-list > -------------- next part -------------- An HTML attachment was scrubbed... URL: From apzc2529 at gmail.com Fri Jan 14 10:52:41 2011 From: apzc2529 at gmail.com (Cun Zhang) Date: Fri, 14 Jan 2011 23:52:41 +0800 Subject: Is it possible to let a virtual file created by cStringIO have a filename so that functions can read it by its filename? Message-ID: Hi,all I hope use cStringIO to create virtual file, but my customed function which is from a shared library imported by ctypes just accepts a filename(string type) as parameter. So I'm wondering whether there is any method that make the virtual file created by cStringIO like a normal file which have a filename, so it can be called by my functions. Thank you! Yours, Cun Zhang -------------- next part -------------- An HTML attachment was scrubbed... URL: From steve+comp.lang.python at pearwood.info Fri Jan 14 11:07:12 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 14 Jan 2011 16:07:12 GMT Subject: python 3 and Unicode line breaking References: <32f75200-b4d8-4ec8-b07d-4740a79c28b6@g26g2000vba.googlegroups.com> <4d2f959a$0$29984$c3e8da3$5496439d@news.astraweb.com> <55c2f7dc-d4d8-4939-85de-41c19c336f23@k25g2000vbl.googlegroups.com> Message-ID: <4d3074b0$0$29984$c3e8da3$5496439d@news.astraweb.com> On Fri, 14 Jan 2011 05:06:15 -0800, leoboiko wrote: > Of course I searched for one and couldn?t find; that goes without > saying. Otherwise I wouldn?t even bother writing a message, isn?t it? You wouldn't say that if you had the slightest idea about how many people write to newsgroups and web forums asking for help without making the tiniest effort to solve the problem themselves. So, no, it *doesn't* go without saying -- unless, of course, you want the answer to also go without saying. > I disagree people should cruft their messages with details about how > they failed to find information, as that is unrelated to the question at > hand and has no point other than polluting people?s mailboxes. This is total nonsense -- how on earth can you say that it is unrelated to the question you are asking? It tells others what they should not waste their time trying, because you've already tried it. You don't need to write detailed step-by-step instructions of everything you've tried, but you can point us in the directions you've already traveled. Think of it this way... if you were paying money for professional advice, would you be happy to receive a bill for time spent doing the exact same things you have already tried? I'm sure you wouldn't be. So why do you think it is okay to waste the time of unpaid volunteers? That's just thoughtless and selfish. If you think so little of other people's time that you won't even write a few words to save them from going down the same dead-ends that you've already tried, then don't be surprised if they think so little of your time that they don't bother replying even when they know the answer. > I also see no reason to reply to a simple question with such > discourtesy, and cannot understand why someone would be so aggressive to > a stranger. If you think my reply was aggressive and discourteous, you've got a lot to learn about public forums. -- Steven From alex.kyrish at gmail.com Fri Jan 14 11:57:17 2011 From: alex.kyrish at gmail.com (Alex Boyko) Date: Fri, 14 Jan 2011 18:57:17 +0200 Subject: unbalanced tree iteration issue In-Reply-To: <461431295011620@web65.yandex.ru> References: <461431295011620@web65.yandex.ru> Message-ID: Thank you for your reply, but I have question about your code. Your defined: def post_order(self): for child in self.childs: yield child yield self just for "Node" , not for "Tree", and do w("doing generator post_order...") _t = datetime.now() for item in root.post_order(): fake = item.value w("done\n") w(datetime.now() - _t) w("\n") what give us only iterating along root's children, not iterating along tree...Or I didn't catch your though? Best Regards Alex 2011/1/14 kost BebiX > 14.01.2011, 14:15, "Alex Boyko" : > > Dear All! > > > > I have deal with large unbalanced trees and I have to implement > post-order tree traversal. My first attempt is shown below ("Node" and > "Tree" classes) and based on recursive generators approach. > > > > class Node(): > > def __init__(self,value): > > self.childs = [] > > self.value = value > > > > class Tree(): > > > > def __init__(self, root): > > self.root = root > > self.numberCells = 1 > > > > def add(self, node, child): > > node.childs.append(child) > > self.numberCells+=1 > > > > def __iter__(self): > > return self.postorder(self.root) > > > > def postorder(self, node): > > if node: > > for child in node.childs: > > for n in self.postorder(child): > > yield n > > yield node > > > > It works fine for small test trees. But, my tree has approximately 300000 > nodes, and shown post order traversal with generators takes 80 sec against 1 > sec with simple recursive routine: > > > > def recursiveFromTop(node): > > for child in node.childs: > > recursiveFromTop(child) > > ## here I can do some computations with current node's data > > > > So, I'd like to know how should I implement (if it's possible of course) > __iter__ for my tree class based on recursion without generators? Please, > can You show me the ways? > > because I'm very passionate in idea iterate through my tree with simple: > > > > for node in tree: > > do something with node > > > > Thanks in Advance! > > Best Regards! > > Alex > > > > -- > > http://mail.python.org/mailman/listinfo/python-list > > Well, I think it's actually because the difference is that you would not do > yielding, you would just put everything in memory and then return it. > > ret_val = [x for x in self.postorder(child)] > return ret_val + [self] > > or something like that (but beware of memory). But that's strange. This > code works fast: > > #!/usr/bin/env python > # -*- coding: utf-8 -*- > > import sys > > def w(s): > sys.stdout.write("%s" % s) > sys.stdout.flush() > > class Node(): > __slots__ = ('childs', 'value',) > > def __init__(self, value): > self.childs = [] > self.value = value > > def post_order(self): > for child in self.childs: > yield child > yield self > > def build_tree(): > def append_1000_childs(node): > for i in xrange(20): > node.childs.append(Node(10)) > > def append_n_levels(node, levels=1): > if levels >= 1: > append_1000_childs(node) > if levels > 1: > for child in node.childs: > append_n_levels(child, levels - 1) > > root = Node(10) > append_n_levels(root, 5) > return root > > if __name__ == '__main__': > from datetime import datetime > > w("building tree...") > _t = datetime.now() > root = build_tree() > w("done\n") > w(datetime.now() - _t) > w("\n") > > w("doing generator post_order...") > _t = datetime.now() > for item in root.post_order(): > fake = item.value > w("done\n") > w(datetime.now() - _t) > w("\n") > > def post_order(root): > for child in root.childs: > post_order(child) > fake = item.value > > w("doing non-generator post_order...") > _t = datetime.now() > post_order(root) > w("done\n") > w(datetime.now() - _t) > w("\n") > > $ python postorder.py > building tree...done > 0:01:34.422288 > doing generator post_order...done > 0:00:00.000018 > doing non-generator post_order...done > 0:00:01.232272 > > -- > jabber: k.bx at ya.ru > -------------- next part -------------- An HTML attachment was scrubbed... URL: From alex.kyrish at gmail.com Fri Jan 14 12:32:24 2011 From: alex.kyrish at gmail.com (Alex Boyko) Date: Fri, 14 Jan 2011 19:32:24 +0200 Subject: unbalanced tree iteration issue In-Reply-To: References: <461431295011620@web65.yandex.ru> Message-ID: So I mean, your approach with generators showed good results in terms of time efficiency 'cos iteration was done for root and root's children. On 14 January 2011 18:57, Alex Boyko wrote: > Thank you for your reply, but I have question about your code. Your > defined: > > def post_order(self): > for child in self.childs: > yield child > yield self > > just for "Node" , not for "Tree", and do > > w("doing generator post_order...") > _t = datetime.now() > for item in root.post_order(): > fake = item.value > w("done\n") > w(datetime.now() - _t) > w("\n") > > what give us only iterating along root's children, not iterating along > tree...Or I didn't catch your though? > > Best Regards > Alex > > 2011/1/14 kost BebiX > > 14.01.2011, 14:15, "Alex Boyko" : >> > Dear All! >> > >> > I have deal with large unbalanced trees and I have to implement >> post-order tree traversal. My first attempt is shown below ("Node" and >> "Tree" classes) and based on recursive generators approach. >> > >> > class Node(): >> > def __init__(self,value): >> > self.childs = [] >> > self.value = value >> > >> > class Tree(): >> > >> > def __init__(self, root): >> > self.root = root >> > self.numberCells = 1 >> > >> > def add(self, node, child): >> > node.childs.append(child) >> > self.numberCells+=1 >> > >> > def __iter__(self): >> > return self.postorder(self.root) >> > >> > def postorder(self, node): >> > if node: >> > for child in node.childs: >> > for n in self.postorder(child): >> > yield n >> > yield node >> > >> > It works fine for small test trees. But, my tree has approximately >> 300000 nodes, and shown post order traversal with generators takes 80 sec >> against 1 sec with simple recursive routine: >> > >> > def recursiveFromTop(node): >> > for child in node.childs: >> > recursiveFromTop(child) >> > ## here I can do some computations with current node's data >> > >> > So, I'd like to know how should I implement (if it's possible of course) >> __iter__ for my tree class based on recursion without generators? Please, >> can You show me the ways? >> > because I'm very passionate in idea iterate through my tree with simple: >> > >> > for node in tree: >> > do something with node >> > >> > Thanks in Advance! >> > Best Regards! >> > Alex >> > >> > -- >> > http://mail.python.org/mailman/listinfo/python-list >> >> Well, I think it's actually because the difference is that you would not >> do yielding, you would just put everything in memory and then return it. >> >> ret_val = [x for x in self.postorder(child)] >> return ret_val + [self] >> >> or something like that (but beware of memory). But that's strange. This >> code works fast: >> >> #!/usr/bin/env python >> # -*- coding: utf-8 -*- >> >> import sys >> >> def w(s): >> sys.stdout.write("%s" % s) >> sys.stdout.flush() >> >> class Node(): >> __slots__ = ('childs', 'value',) >> >> def __init__(self, value): >> self.childs = [] >> self.value = value >> >> def post_order(self): >> for child in self.childs: >> yield child >> yield self >> >> def build_tree(): >> def append_1000_childs(node): >> for i in xrange(20): >> node.childs.append(Node(10)) >> >> def append_n_levels(node, levels=1): >> if levels >= 1: >> append_1000_childs(node) >> if levels > 1: >> for child in node.childs: >> append_n_levels(child, levels - 1) >> >> root = Node(10) >> append_n_levels(root, 5) >> return root >> >> if __name__ == '__main__': >> from datetime import datetime >> >> w("building tree...") >> _t = datetime.now() >> root = build_tree() >> w("done\n") >> w(datetime.now() - _t) >> w("\n") >> >> w("doing generator post_order...") >> _t = datetime.now() >> for item in root.post_order(): >> fake = item.value >> w("done\n") >> w(datetime.now() - _t) >> w("\n") >> >> def post_order(root): >> for child in root.childs: >> post_order(child) >> fake = item.value >> >> w("doing non-generator post_order...") >> _t = datetime.now() >> post_order(root) >> w("done\n") >> w(datetime.now() - _t) >> w("\n") >> >> $ python postorder.py >> building tree...done >> 0:01:34.422288 >> doing generator post_order...done >> 0:00:00.000018 >> doing non-generator post_order...done >> 0:00:01.232272 >> >> -- >> jabber: k.bx at ya.ru >> > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ian.g.kelly at gmail.com Fri Jan 14 13:07:32 2011 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Fri, 14 Jan 2011 11:07:32 -0700 Subject: unbalanced tree iteration issue In-Reply-To: References: Message-ID: On Fri, Jan 14, 2011 at 5:15 AM, Alex Boyko wrote: > So, I'd like to know how?should?I implement (if it's possible of course) > __iter__ for my tree class based on recursion without generators? You could try something like this (untested): from itertools import chain, imap ... def postorder(self, node): return chain(chain.from_iterable(imap(self.postorder, node.childs)), [node]) Or you could write the iterator the old-fashioned way, as an object with state (also untested): def __iter__(self): return PostOrderIter(self.root) class PostOrderIter(object): def __iter__(self, node): self.stack = [(node, 0)] def next(self): if not self.stack: raise StopIteration node, index = self.stack.pop() if index < len(node.childs): child = node.childs[index] self.stack.append((node, index+1)) self.stack.append((child, 0)) return self.next() else: return node From ian.g.kelly at gmail.com Fri Jan 14 13:08:36 2011 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Fri, 14 Jan 2011 11:08:36 -0700 Subject: unbalanced tree iteration issue In-Reply-To: References: Message-ID: On Fri, Jan 14, 2011 at 11:07 AM, Ian Kelly wrote: > class PostOrderIter(object): > > ? ?def __iter__(self, node): > ? ? ? ?self.stack = [(node, 0)] That __iter__ should actually be __init__, of course. From k.bx at ya.ru Fri Jan 14 13:08:42 2011 From: k.bx at ya.ru (kost BebiX) Date: Fri, 14 Jan 2011 20:08:42 +0200 Subject: unbalanced tree iteration issue In-Reply-To: References: <461431295011620@web65.yandex.ru> Message-ID: <189501295028530@web144.yandex.ru> 14.01.2011, 18:57, "Alex Boyko" : > 2011/1/14 kost BebiX >> 14.01.2011, 14:15, "Alex Boyko" : >> >>> Dear All! >>> >>> I have deal with large unbalanced trees and I have to implement post-order tree traversal. My first attempt is shown below ("Node" and "Tree" classes) and based on recursive generators approach. >>> >>> class Node(): >>> ?? ?def __init__(self,value): >>> ?? ? ? ?self.childs = [] >>> ?? ? ? ?self.value = value >>> >>> class Tree(): >>> >>> ?? ?def __init__(self, root): >>> ?? ? ? ?self.root = root >>> ?? ? ? ?self.numberCells = 1 >>> >>> ?? ?def add(self, node, child): >>> ?? ? ? ?node.childs.append(child) >>> ?? ? ? ?self.numberCells+=1 >>> >>> ?? ?def __iter__(self): >>> ?? ? ? ?return self.postorder(self.root) >>> >>> ?? ?def postorder(self, node): >>> ?? ? ? ?if node: >>> ?? ? ? ? ? ?for child in node.childs: >>> ?? ? ? ? ? ? ? ?for n in self.postorder(child): >>> ?? ? ? ? ? ? ? ? ? ?yield n >>> ?? ? ? ? ? ?yield node >>> >>> It works fine for small test trees. But, my tree has approximately 300000 nodes, and shown post order traversal with generators takes 80 sec against 1 sec with simple recursive routine: >>> >>> def recursiveFromTop(node): >>> ?? ?for child in node.childs: >>> ?? ? ? ?recursiveFromTop(child) >>> ?? ? ? ?## here I can do some computations with current node's data >>> >>> So, I'd like to know how?should?I implement (if it's possible of course) __iter__ for my tree class based on recursion without generators? Please, can You show me the ways? >>> because I'm very passionate in idea iterate through my tree with simple: >>> >>> for node in tree: >>> ?? do something with node >>> >>> Thanks in Advance! >>> Best Regards! >>> Alex >>> >> >>> -- >>> http://mail.python.org/mailman/listinfo/python-list >> >> Well, I think it's actually because the difference is that you would not do yielding, you would just put everything in memory and then return it. >> >> ret_val = [x for x in self.postorder(child)] >> return ret_val + [self] >> >> or something like that (but beware of memory). But that's strange. This code works fast: >> >> #!/usr/bin/env python >> # -*- coding: utf-8 -*- >> >> import sys >> >> def w(s): >> ? ?sys.stdout.write("%s" % s) >> ? ?sys.stdout.flush() >> >> class Node(): >> ? ?__slots__ = ('childs', 'value',) >> >> ? ?def __init__(self, value): >> ? ? ? ?self.childs = [] >> ? ? ? ?self.value = value >> >> ? ?def post_order(self): >> ? ? ? ?for child in self.childs: >> ? ? ? ? ? ?yield child >> ? ? ? ?yield self >> >> def build_tree(): >> ? ?def append_1000_childs(node): >> ? ? ? ?for i in xrange(20): >> ? ? ? ? ? ?node.childs.append(Node(10)) >> >> ? ?def append_n_levels(node, levels=1): >> ? ? ? ?if levels >= 1: >> ? ? ? ? ? ?append_1000_childs(node) >> ? ? ? ? ? ?if levels > 1: >> ? ? ? ? ? ? ? ?for child in node.childs: >> >> ? ? ? ? ? ? ? ? ? ?append_n_levels(child, levels - 1) >> >> ? ?root = Node(10) >> ? ?append_n_levels(root, 5) >> ? ?return root >> >> if __name__ == '__main__': >> ? ?from datetime import datetime >> >> ? ?w("building tree...") >> ? ?_t = datetime.now() >> ? ?root = build_tree() >> ? ?w("done\n") >> ? ?w(datetime.now() - _t) >> ? ?w("\n") >> >> ? ?w("doing generator post_order...") >> ? ?_t = datetime.now() >> ? ?for item in root.post_order(): >> ? ? ? ?fake = item.value >> ? ?w("done\n") >> ? ?w(datetime.now() - _t) >> ? ?w("\n") >> >> ? ?def post_order(root): >> ? ? ? ?for child in root.childs: >> ? ? ? ? ? ?post_order(child) >> ? ? ? ? ? ?fake = item.value >> >> ? ?w("doing non-generator post_order...") >> ? ?_t = datetime.now() >> ? ?post_order(root) >> ? ?w("done\n") >> ? ?w(datetime.now() - _t) >> ? ?w("\n") >> >> $ python postorder.py >> building tree...done >> 0:01:34.422288 >> doing generator post_order...done >> 0:00:00.000018 >> doing non-generator post_order...done >> 0:00:01.232272 >> >> -- >> jabber: k.bx at ya.ru > Thank you for your reply, but I have question about your code. Your defined: > > def post_order(self): > for child in self.childs: > yield child > yield self > > just for "Node" , not for "Tree", and do > > w("doing generator post_order...") > _t = datetime.now() > for item in root.post_order(): > fake = item.value > w("done\n") > w(datetime.now() - _t) > w("\n") > > what give us only iterating along root's children, not iterating along tree...Or I didn't catch your though? > > Best Regards > Alex > Well, isn't tree is a root node and it's children? Why do you need Tree class anyway? p.s.: please, do not top-post the messages, write your reply at bottom because it will then be easier to read for those who will google this page. -- jabber: k.bx at ya.ru From ian.g.kelly at gmail.com Fri Jan 14 13:19:01 2011 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Fri, 14 Jan 2011 11:19:01 -0700 Subject: unbalanced tree iteration issue In-Reply-To: <189501295028530@web144.yandex.ru> References: <461431295011620@web65.yandex.ru> <189501295028530@web144.yandex.ru> Message-ID: 2011/1/14 kost BebiX : > Well, isn't tree is a root node and it's children? And its grandchildren, great-grandchildren, etc. What Alex is saying is that the implementation you posted traverses the root and its immediate children, but does not recur any further than that. That is why it was so fast. From k.bx at ya.ru Fri Jan 14 13:41:31 2011 From: k.bx at ya.ru (kost BebiX) Date: Fri, 14 Jan 2011 20:41:31 +0200 Subject: unbalanced tree iteration issue In-Reply-To: References: <461431295011620@web65.yandex.ru> <189501295028530@web144.yandex.ru> Message-ID: <141461295030492@web155.yandex.ru> 14.01.2011, 20:19, "Ian Kelly" : > 2011/1/14 kost BebiX ;: > >> ?Well, isn't tree is a root node and it's children? > > And its grandchildren, great-grandchildren, etc. ?What Alex is saying > is that the implementation you posted traverses the root and its > immediate children, but does not recur any further than that. ?That is > why it was so fast. Oh, yeah, sorry, forgot the recursion. It should be (if I'm not wrong again): def post_order(self): for child in self.childs: for po in child.post_order(): yield po yield self if you give it more deepness: $ python postorder.py building tree...done 0:00:25.839462 doing generator post_order...done 0:00:02.776876 doing non-generator post_order...done 0:00:01.092648 still not bad, but if you'll give it more deepness $ python postorder.py building tree...done 0:00:16.078972 doing generator post_order...done 0:00:03.119023 doing non-generator post_order...done 0:00:00.841976 it will be worse -- jabber: k.bx at ya.ru From nagle at animats.com Fri Jan 14 13:57:59 2011 From: nagle at animats.com (John Nagle) Date: Fri, 14 Jan 2011 10:57:59 -0800 Subject: how to use priority queue with multiprocessing In-Reply-To: References: Message-ID: <4d309cc3$0$43988$742ec2ed@news.sonic.net> On 1/13/2011 9:07 AM, Marco Hornung wrote: > Hey, > > ------------------------------------------------------------------------------------------ > > question > ------------------------------------------------------------------------------------------ > > How can I use a priority queue to schedule jobs within the "multiprocessing pool" module? > > ------------------------------------------------------------------------------------------ > > my scenario > ------------------------------------------------------------------------------------------ > > I want to run several jobs on a server. The jobs are being sent by users. However, all jobs have a different priority, and high-priority jobs should be processed before any low-priority job gets touched. > Currently I just append all incoming jobs to the multiprocessing > worker pool as follows: ### initialize worker pool pool = > PriorityPool(processes=worker_count) process_handles = [] > > ### distribute function execution over several processes for > job_parameter in job_parameter_list: handle = > pool.apply_async(process_function, [job_parameter,]) > process_handles.append(handle) > > This will only put the jobs in some kind of a list - and execute the > jobs in the order they come in. Is it possible to use a priority > queue for the process-pool? > You''ll probably have to track the available processes yourself, starting a new job when there's a process available. One way to do this is to have a management thread for each process. Each management thread starts a subprocess, gets a work item from the priority queue (blocking if necessary), gives it to the subprocess, waits for the subprocess to return a result, and goes back to get another work item. This is straightforward, except for working out a way to cleanly shut the thing down. One way to do that is to have a "shutdown" flag visible to all the threads. That's checked before getting a new task. If it's set, the thread terminates its subprocess and returns. Set the terminate flag in a signal handler for control-C. (I have something that manages multiple processes using a priority queue, where the queue is implemented using MySQL. This allows me to put a whole cluster to work.) John Nagle From a.j.romanista at gmail.com Fri Jan 14 14:39:40 2011 From: a.j.romanista at gmail.com (Ata Jafari) Date: Fri, 14 Jan 2011 11:39:40 -0800 (PST) Subject: Developing a program to make a family tree. Message-ID: <317f6ed0-ebd9-4a58-9ad3-da57563193ad@w29g2000vba.googlegroups.com> Hi there. I'm trying to develop a program like family tree maker. I have all information, so there is no need to search on the net. This must be something like trees. Can someone help me? I'm at the beginning. Thanks. -- Ata J. Tabrizi atae.tabrizi at metu.edu.tr From solipsis at pitrou.net Fri Jan 14 14:47:35 2011 From: solipsis at pitrou.net (Antoine Pitrou) Date: Fri, 14 Jan 2011 20:47:35 +0100 Subject: python 3 and Unicode line breaking References: <32f75200-b4d8-4ec8-b07d-4740a79c28b6@g26g2000vba.googlegroups.com> <4d2f959a$0$29984$c3e8da3$5496439d@news.astraweb.com> <55c2f7dc-d4d8-4939-85de-41c19c336f23@k25g2000vbl.googlegroups.com> <4d3074b0$0$29984$c3e8da3$5496439d@news.astraweb.com> Message-ID: <20110114204735.094d1c8a@pitrou.net> Hey, On 14 Jan 2011 16:07:12 GMT Steven D'Aprano wrote: > > > I also see no reason to reply to a simple question with such > > discourtesy, and cannot understand why someone would be so aggressive to > > a stranger. > > If you think my reply was aggressive and discourteous, you've got a lot > to learn about public forums. Perhaps you've got to learn about politeness yourself! Just because some people are jerks on internet forums (or in real life) doesn't mean everyone should; this is quite a stupid and antisocial excuse actually. You would never have reacted this way if the same question had been phrased by a regular poster here (let alone on python-dev). Taking cheap shots at newcomers is certainly not the best way to welcome them. Thank you Antoine. From mukeshtiwari.iiitm at gmail.com Fri Jan 14 14:52:21 2011 From: mukeshtiwari.iiitm at gmail.com (mukesh tiwari) Date: Fri, 14 Jan 2011 11:52:21 -0800 (PST) Subject: Elliptic Curve Prime factorisation Message-ID: <2040fe29-f11d-4e64-acac-d49ae8bb5ca9@u32g2000yqe.googlegroups.com> Hello all , I have implemented Elliptic curve prime factorisation using wikipedia [ http://en.wikipedia.org/wiki/Lenstra_elliptic_curve_factorization]. I think that this code is not optimised and posting for further improvement. Feel free to comment and if you have any link regarding Elliptic curve prime factorisation , kindly post it. Thank you import math import random #y^2=x^3+ax+b mod n def extended_gcd(a,b): # taken from wikipedia x,y,lastx,lasty=0,1,1,0 while b!=0: q=a/b a,b=b,a%b x,lastx=(lastx-q*x,x) y,lasty=(lasty-q*y,y) if a<0: return (-a,-lastx,-lasty) else: return (a,lastx,lasty) def gcd(a,b): if a < 0: a = -a if b < 0: b = -b if a == 0: return b if b == 0: return a while b != 0: (a, b) = (b, a%b) return a def randomCurve(N): A,u,v=random.randrange(N),random.randrange(N),random.randrange(N) B=(v*v-u*u*u-A*u)%N return [(A,B,N),(u,v)] def addPoint(E,p_1,p_2): if p_1=="Identity": return [p_2,1] if p_2=="Identity": return [p_1,1] a,b,n=E (x_1,y_1)=p_1 (x_2,y_2)=p_2 x_1%=n y_1%=n x_2%=n y_2%=n if x_1 != x_2 : d,u,v=extended_gcd(x_1-x_2,n) s=((y_1-y_2)*u)%n x_3=(s*s-x_1-x_2)%n y_3=(-y_1-s*(x_3-x_1))%n else: if (y_1+y_2)%n==0:return ["Identity",1] else: d,u,v=extended_gcd(2*y_1,n) s=((3*x_1*x_1+a)*u)%n x_3=(s*s-2*x_1)%n y_3=(-y_1-s*(x_3-x_1))%n return [(x_3,y_3),d] def mulPoint(E,P,m): Ret="Identity" d=1 while m!=0: if m%2!=0: Ret,d=addPoint(E,Ret,P) if d!=1 : return [Ret,d] # as soon as i got anything otherthan 1 return P,d=addPoint(E,P,P) if d!=1 : return [Ret,d] m>>=1 return [Ret,d] def ellipticFactor(N,m,times=5): for i in xrange(times): E,P=randomCurve(N); Q,d=mulPoint(E,P,m) if d!=1 : return d return N if __name__=="__main__": n=input() m=int(math.factorial(1000)) while n!=1: k=ellipticFactor(n,m) n/=k print k From joncle at googlemail.com Fri Jan 14 14:57:52 2011 From: joncle at googlemail.com (Jon Clements) Date: Fri, 14 Jan 2011 11:57:52 -0800 (PST) Subject: Developing a program to make a family tree. References: <317f6ed0-ebd9-4a58-9ad3-da57563193ad@w29g2000vba.googlegroups.com> Message-ID: On Jan 14, 7:39?pm, Ata Jafari wrote: > Hi there. > I'm trying to develop a program like family tree maker. I have all > information, so there is no need to search on the net. This must be > something like trees. Can someone help me? I'm at the beginning. > Thanks. > > -- > Ata J. Tabrizi > atae.tabr... at metu.edu.tr If you're after mature and actively developed Genealogy software developed in Python, then check out http://gramps-project.org/ The developer list is very friendly. Otherwise, you're in for a struggle, as you need to choose a storage back-end, a GUI (wxWindows/GTK/Qt4 etc...), how to handle GEDCOM format (unless it's not going to be compatible with other software), does it need to produce web pages/reports (and in what formats). I strongly suggest looking at GRAMPS and see what you're setting yourself up for :) hth Jon From k.bx at ya.ru Fri Jan 14 15:01:52 2011 From: k.bx at ya.ru (kost BebiX) Date: Fri, 14 Jan 2011 22:01:52 +0200 Subject: Elliptic Curve Prime factorisation In-Reply-To: <2040fe29-f11d-4e64-acac-d49ae8bb5ca9@u32g2000yqe.googlegroups.com> References: <2040fe29-f11d-4e64-acac-d49ae8bb5ca9@u32g2000yqe.googlegroups.com> Message-ID: <792711295035313@web108.yandex.ru> 14.01.2011, 21:52, "mukesh tiwari" : > Hello all , I have implemented Elliptic curve prime factorisation > using wikipedia [ http://en.wikipedia.org/wiki/Lenstra_elliptic_curve_factorization]. > I think that this code is not optimised and posting for further > improvement. Feel free to comment and if you have any link regarding > Elliptic curve prime factorisation , kindly post it. > Thank you > > import math > import random > > #y^2=x^3+ax+b mod n > > def extended_gcd(a,b): ??# taken from wikipedia > ????????x,y,lastx,lasty=0,1,1,0 > ????????while b!=0: > ????????????????q=a/b > ????????????????a,b=b,a%b > ????????????????x,lastx=(lastx-q*x,x) > ????????????????y,lasty=(lasty-q*y,y) > ????????if a<0: > ????????????????return (-a,-lastx,-lasty) > ????????else: > ????????????????return (a,lastx,lasty) > def gcd(a,b): > ????????if a < 0: ?a = -a > ????????if b < 0: ?b = -b > ????????if a == 0: return b > ????????if b == 0: return a > ????????while b != 0: > ????????????????(a, b) = (b, a%b) > ????????return a > > def randomCurve(N): > ????????A,u,v=random.randrange(N),random.randrange(N),random.randrange(N) > ????????B=(v*v-u*u*u-A*u)%N > ????????return [(A,B,N),(u,v)] > > def addPoint(E,p_1,p_2): > ????????if p_1=="Identity": return [p_2,1] > ????????if p_2=="Identity": return [p_1,1] > ????????a,b,n=E > ????????(x_1,y_1)=p_1 > ????????(x_2,y_2)=p_2 > ????????x_1%=n > ????????y_1%=n > ????????x_2%=n > ????????y_2%=n > ????????if x_1 != x_2 : > ????????????????d,u,v=extended_gcd(x_1-x_2,n) > ????????????????s=((y_1-y_2)*u)%n > ????????????????x_3=(s*s-x_1-x_2)%n > ????????????????y_3=(-y_1-s*(x_3-x_1))%n > ????????else: > ????????????????if (y_1+y_2)%n==0:return ["Identity",1] > ????????????????else: > ????????????????????????d,u,v=extended_gcd(2*y_1,n) > ????????????????????????s=((3*x_1*x_1+a)*u)%n > ????????????????????????x_3=(s*s-2*x_1)%n > ????????????????????????y_3=(-y_1-s*(x_3-x_1))%n > > ????????return [(x_3,y_3),d] > > def mulPoint(E,P,m): > ????????Ret="Identity" > ????????d=1 > ????????while m!=0: > ????????????????if m%2!=0: Ret,d=addPoint(E,Ret,P) > ????????????????if d!=1 : return [Ret,d] ?# as soon as i got anything otherthan 1 > return > ????????????????P,d=addPoint(E,P,P) > ????????????????if d!=1 : return [Ret,d] > ????????????????m>>=1 > ????????return [Ret,d] > > def ellipticFactor(N,m,times=5): > ????????for i in xrange(times): > ????????????????E,P=randomCurve(N); > ????????????????Q,d=mulPoint(E,P,m) > ????????????????if d!=1 : return d > ????????return N > > if __name__=="__main__": > ????????n=input() > ????????m=int(math.factorial(1000)) > ????????while n!=1: > ????????????????k=ellipticFactor(n,m) > ????????????????n/=k > ????????????????print k > > -- > http://mail.python.org/mailman/listinfo/python-list Well, first of all you should read and follow this http://www.python.org/dev/peps/pep-0008/ :-) -- jabber: k.bx at ya.ru From awilliam at whitemice.org Fri Jan 14 15:16:48 2011 From: awilliam at whitemice.org (Adam Tauno Williams) Date: Fri, 14 Jan 2011 15:16:48 -0500 Subject: how to use priority queue with multiprocessing In-Reply-To: <4d309cc3$0$43988$742ec2ed@news.sonic.net> References: <4d309cc3$0$43988$742ec2ed@news.sonic.net> Message-ID: <1295036208.8883.7.camel@linux-yu4c.site> On Fri, 2011-01-14 at 10:57 -0800, John Nagle wrote: > On 1/13/2011 9:07 AM, Marco Hornung wrote: > I want to run several jobs on a server. The jobs are being sent by > users. However, all jobs have a different priority, and high-priority > jobs should be processed before any low-priority job gets touched. > > Currently I just append all incoming jobs to the multiprocessing > > worker pool as follows: ### initialize worker pool pool = > > PriorityPool(processes=worker_count) process_handles = [] > > ### distribute function execution over several processes for > > job_parameter in job_parameter_list: handle = > > pool.apply_async(process_function, [job_parameter,]) > > process_handles.append(handle) > > This will only put the jobs in some kind of a list - and execute the > > jobs in the order they come in. Is it possible to use a priority > > queue for the process-pool? > You''ll probably have to track the available processes yourself, > starting a new job when there's a process available. Which is exactly what we do in OpenGroupwre Coils' OIE. There is a process [job] list which is sorted by priority and the next available process is started when a worker is available. We use multiprocessing to create a *process*, rather than a thread, for each job. > One way to do this is to have a management thread for each > process. Each management thread starts a subprocess, gets > a work item from the priority queue (blocking if necessary), > gives it to the subprocess, waits for the subprocess to > return a result, and goes back to get another work item. We have a manager process and an executor process. These communicate via AMQ, but you could use any mechanism. The manager process controls the process [job] list. When a process needs to be started a message is send to the executor which creates a worker process if an opening is available. Otherwise it messages the manager process to place the process in a queued state. When a worker process completes it messages the executor which in turn messages the manager that a process slot may be available; then the manager looks up the next available process and messages the executor to start it - provided a worker slot is still available the executor will start the worker.... [otherwise the process will go back into a queued state]. > This is straightforward, except for working out a way > to cleanly shut the thing down. One way to do that is > to have a "shutdown" flag visible to all the threads. Using a message bus helps a lot, and with multiprocessing you just do a join/isalive to make sure a worker is still working. From clp2 at rebertia.com Fri Jan 14 15:51:11 2011 From: clp2 at rebertia.com (Chris Rebert) Date: Fri, 14 Jan 2011 12:51:11 -0800 Subject: Is it possible to let a virtual file created by cStringIO have a filename so that functions can read it by its filename? In-Reply-To: References: Message-ID: On Fri, Jan 14, 2011 at 7:52 AM, Cun Zhang wrote: > Hi,all > I hope use cStringIO to create virtual file, but my customed function which > is from a shared library imported by ctypes > just accepts a filename(string type) as parameter. > > So I'm wondering whether there is any method that make the virtual file > created by cStringIO like a normal file which have > a filename, so it can be called by my functions. That's not possible. (c)StringIO presents a file-like interface at the Python level, but under the covers, it's not implemented using anything like a normal file; thus, it doesn't have a presence on any filesystem. I would suggest using a temporary file (http://docs.python.org/library/tempfile.html ) for communicating with the C module, writing the contents of the StringIO object to the temporary file if necessary. (It's probably also possible to hack something together with FUSE, but it'd be a slow, platform-specific kludge.) Cheers, Chris -- http://blog.rebertia.com From cjwilliams43 at gmail.com Fri Jan 14 16:11:51 2011 From: cjwilliams43 at gmail.com (Colin J. Williams) Date: Fri, 14 Jan 2011 16:11:51 -0500 Subject: python 3 and Unicode line breaking In-Reply-To: References: <32f75200-b4d8-4ec8-b07d-4740a79c28b6@g26g2000vba.googlegroups.com> <4d2f959a$0$29984$c3e8da3$5496439d@news.astraweb.com> <55c2f7dc-d4d8-4939-85de-41c19c336f23@k25g2000vbl.googlegroups.com> <4d3074b0$0$29984$c3e8da3$5496439d@news.astraweb.com> Message-ID: On 14-Jan-11 14:47 PM, Antoine Pitrou wrote: > > Hey, > > On 14 Jan 2011 16:07:12 GMT > Steven D'Aprano wrote: >> >>> I also see no reason to reply to a simple question with such >>> discourtesy, and cannot understand why someone would be so aggressive to >>> a stranger. >> >> If you think my reply was aggressive and discourteous, you've got a lot >> to learn about public forums. > > Perhaps you've got to learn about politeness yourself! Just because > some people are jerks on internet forums (or in real life) doesn't mean > everyone should; this is quite a stupid and antisocial excuse actually. > > You would never have reacted this way if the same question had been > phrased by a regular poster here (let alone on python-dev). Taking > cheap shots at newcomers is certainly not the best way to welcome > them. > > Thank you > > Antoine. > > +1 From xahlee at gmail.com Fri Jan 14 16:20:28 2011 From: xahlee at gmail.com (Xah Lee) Date: Fri, 14 Jan 2011 13:20:28 -0800 (PST) Subject: do you know what's CGI? (web history personal story) Message-ID: some extempore thought. Do you know what is CGI? Worked with Mathematica for 5 hours yesterday. Fantastic! This old hand can still do something! lol. My plane curve packages soon to be out n am gonna be rich. ...gosh what godly hours i've spend on Mathematica in 1990s. Surprised to find that i even Unproctected builtin symbols to fix things. (get rid of asymptotes in ParametricPlot) (Draft notes as i go: Mathematica Version 3 to Version 7 Conversion Notes) ... i recall, i stopped doing Mathematica in 1998 because it's a career dead-end as a programing lang, and dived into the utterly idiotic Perl & unix & mysql world. (See: The Unix Pestilence ? Xah Lee's Computing Experience (Impression Of Lisp from Mathematica).) Well, dead-end just as Emacs Lisp i'm spending my nights with in the past 4 years. LOL. And on that note, same thing can be said with haskell, OCaml. Though, fringe langs are picking up these days. Remember Python, ruby, in year 2000? Who'd imagined they'd become mainstream. But it took 10+ years. (See: Language, Purity, Cult, and Deception.) Also got reminded my age recently. Someone on stackoverflow is asking about what are those ?A:? and ?B:? drives on Windows. (anyone heard of floppy drives?) In another incident, i was chatting to a friend, and the topic went to internet tech in 1990s, and i was telling him about how PHP (aka Pretty Home Page) came about, then naturally i discussed CGI. After a while, i realized, those who are around 20 years old today were under 10 in the 1990s. They wouldn't know what was CGI, and no amount of explanation can tell them exactly it was like, because it has become HISTORY ? if you didn't live it, you can't feel it. http://xahlee.blogspot.com/2011/01/do-you-know-what-is-cgi.html Xah ? http://xahlee.org/ From debatem1 at gmail.com Fri Jan 14 16:37:24 2011 From: debatem1 at gmail.com (geremy condra) Date: Fri, 14 Jan 2011 13:37:24 -0800 Subject: Tkinter: The good, the bad, and the ugly! In-Reply-To: References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <18c2f4d8-0cce-4cdf-a386-80831dc2f114@m37g2000vbn.googlegroups.com> Message-ID: On Wed, Dec 29, 2010 at 5:03 PM, rantingrick wrote: > On Dec 29, 6:41?pm, Gerry Reno wrote: >> Also, what do you think about frameworks such as pyjamas? ?It lets you >> write in python and compiles everything down to Javascript so it can be >> used across the Web as well as on the desktop. > > Hmm, this is like two double edged swords smashing one another in > battle. Seriously, get off of WoW and go write some code. If you'd spent the last year programming instead of doing your best Xah Lee impression you might have actually made some progress on this. Geremy Condra From ladasky at my-deja.com Fri Jan 14 16:41:56 2011 From: ladasky at my-deja.com (John Ladasky) Date: Fri, 14 Jan 2011 13:41:56 -0800 (PST) Subject: Python use growing fast References: <4D2B73D1.6060303@mrabarnett.plus.com> Message-ID: <48293735-9370-4037-b130-07f6735df886@m11g2000vbs.googlegroups.com> On Jan 10, 1:43?pm, Alice Bevan?McGregor wrote: > On 2011-01-10 13:02:09 -0800, MRAB said: > > Wikipedia is a Wiki; everyone is free to contribute and correct mistakes. > > ? ? ? ? - Alice. Except for some of us. I tried to make a correction to a chemistry Wikipedia entry several months back. I received a message saying that a series of IP addresses which happen to include the one that my ISP assigned me had been blocked, due to hacking problems. Wikipedia provided a link to contact a real human being to request that an address be unblocked. I submitted a request, and -- nothing happened. From miki.tebeka at gmail.com Fri Jan 14 17:05:54 2011 From: miki.tebeka at gmail.com (Miki) Date: Fri, 14 Jan 2011 14:05:54 -0800 (PST) Subject: wx Just Print! In-Reply-To: <00354847-5ab0-4247-802c-15cd0f7d22c7@fo10g2000vbb.googlegroups.com> Message-ID: <6c709190-4294-4b17-8ca4-b3e0c6ab8f57@glegroupsg2000goo.googlegroups.com> I think you need to create a wxApp first. Try adding app = wx.PySimpleApp() at the beginning. From steve+comp.lang.python at pearwood.info Fri Jan 14 17:10:02 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 14 Jan 2011 22:10:02 GMT Subject: python 3 and Unicode line breaking References: <32f75200-b4d8-4ec8-b07d-4740a79c28b6@g26g2000vba.googlegroups.com> <4d2f959a$0$29984$c3e8da3$5496439d@news.astraweb.com> <55c2f7dc-d4d8-4939-85de-41c19c336f23@k25g2000vbl.googlegroups.com> <4d3074b0$0$29984$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4d30c9ba$0$29984$c3e8da3$5496439d@news.astraweb.com> On Fri, 14 Jan 2011 20:47:35 +0100, Antoine Pitrou wrote: > You would never have reacted this way if the same question had been > phrased by a regular poster here (let alone on python-dev). Taking cheap > shots at newcomers is certainly not the best way to welcome them. You're absolutely correct. Regular posters have demonstrated their ability to perform the basics -- if you had asked the question, I could assume that you would have done a google search, because I know you're not a lazy n00b who expects others to do their work for them. But the Original Poster has not, as far as I can see, ever posted here before. He has no prior reputation and gives no detail in his post. You have focused on my first blunt remark, and ignored the second: "If you have tried searching, please say so, otherwise most people will conclude you haven't bothered, and most likely will not bother to reply." This is good, helpful advice, and far more useful to the OP than just ignoring his post. You have jumped to his defense (or rather, you have jumped to criticise me) but I see that you haven't replied to his question or given him any advice in how to solve his problem. Instead of encouraging him to ask smarter questions, you encourage the behaviour that hinders his ability to get help from others. The only other person I can see who has attempted to actually help the OP is Stefan Behnel, who tried to get more information about the problem being solved in order to better answer the question. The OP has, so far as I can see, not responded, although he has taken the time to write to me in private to argue further. -- Steven From albert at spenarnc.xs4all.nl Fri Jan 14 17:17:01 2011 From: albert at spenarnc.xs4all.nl (Albert van der Horst) Date: 14 Jan 2011 22:17:01 GMT Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> Message-ID: In article , Adam Skutt wrote: > >Replacing TkInter with some sort of minimized wxwidgets is a dumb idea >for some very obvious reasons, reasons that are obvious if you simply >look at a widget gallery and then the applications you run on your own >computer. Quite honestly, if you're not capable of that, there's >little reason to believe you'll ever be able to bring forth a >coherent, cogent proposal. I really don't follow that. You need a tremendous set to write gimp. Obviously you won't write gimp in Python. Now you want to jot together three cooperating screens to specify some properties for say bluetooth. The proposed set is ample for that, no? Such things make up a substantial part of the applications as far as numbers is concerned. They are probably written by people who don't want to dive very deeply into GUI. (Maybe they are more bluetooth experts than GUI-experts, what would you say?) > >Adam Groetjes Albert -- -- Albert van der Horst, UTRECHT,THE NETHERLANDS Economic growth -- being exponential -- ultimately falters. albert at spe&ar&c.xs4all.nl &=n http://home.hccnet.nl/a.w.m.van.der.horst From Zeissmann at gmail.com Fri Jan 14 17:22:57 2011 From: Zeissmann at gmail.com (Zeissmann) Date: Fri, 14 Jan 2011 22:22:57 +0000 (UTC) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <18c2f4d8-0cce-4cdf-a386-80831dc2f114@m37g2000vbn.googlegroups.com> Message-ID: > Seriously, get off of WoW and go write some code. If you'd spent the > last year programming instead of doing your best Xah Lee impression you > might have actually made some progress on this. I'm curious, is Xah Lee some sort of a Usenet meme? Cause this is not the first time I see his name in the context of a lightweight invective. From leoboiko at gmail.com Fri Jan 14 17:26:09 2011 From: leoboiko at gmail.com (leoboiko) Date: Fri, 14 Jan 2011 14:26:09 -0800 (PST) Subject: python 3 and Unicode line breaking References: <32f75200-b4d8-4ec8-b07d-4740a79c28b6@g26g2000vba.googlegroups.com> <4d2f959a$0$29984$c3e8da3$5496439d@news.astraweb.com> <55c2f7dc-d4d8-4939-85de-41c19c336f23@k25g2000vbl.googlegroups.com> <4d3074b0$0$29984$c3e8da3$5496439d@news.astraweb.com> <4d30c9ba$0$29984$c3e8da3$5496439d@news.astraweb.com> Message-ID: <9b84ec07-0679-4bc6-96ea-b37231d3fd83@b25g2000vbz.googlegroups.com> On Jan 14, 8:10?pm, Steven D'Aprano wrote: > The only other person I can see who has attempted to actually help the OP > is Stefan Behnel, who tried to get more information about the problem > being solved in order to better answer the question. The OP has, so far > as I can see, not responded, although he has taken the time to write to > me in private to argue further. I have written in private because I really feel this discussion is out- of-place here. This thread is already in the first page of google results for ?python unicode line breaking?, ?python uax #14? etc. I feel it would be good to use this place to discuss Unicode line breaking, not best practices on asking questions, or in how disappointly impolite the Internet has become. (Briefly: As a tech support professional myself, I prefer direct, concise questions than crufty ones; and I try to ask questions in the most direct manner precisely _because_ I don?t want to waste the time of kind volunteers with my problems.) As for taking the time to provide information, I wonder if there was any technical problem that prevented you from seeing my reply to Stefan, sent Jan 14, 12:29PM? He asked how exacly the stdlib module ?textwrap? differs from the Unicode algorithm, so I provided some commented examples. From howe.steven at gmail.com Fri Jan 14 17:32:59 2011 From: howe.steven at gmail.com (Steven Howe) Date: Fri, 14 Jan 2011 14:32:59 -0800 Subject: Is it possible to let a virtual file created by cStringIO have a filename so that functions can read it by its filename? In-Reply-To: References: Message-ID: <4D30CF1B.9030307@gmail.com> On 01/14/2011 12:51 PM, Chris Rebert wrote: > On Fri, Jan 14, 2011 at 7:52 AM, Cun Zhang wrote: >> Hi,all >> I hope use cStringIO to create virtual file, but my customed function which >> is from a shared library imported by ctypes >> just accepts a filename(string type) as parameter. >> >> So I'm wondering whether there is any method that make the virtual file >> created by cStringIO like a normal file which have >> a filename, so it can be called by my functions. > That's not possible. (c)StringIO presents a file-like interface at the > Python level, but under the covers, it's not implemented using > anything like a normal file; thus, it doesn't have a presence on any > filesystem. I would suggest using a temporary file > (http://docs.python.org/library/tempfile.html ) for communicating with > the C module, writing the contents of the StringIO object to the > temporary file if necessary. > (It's probably also possible to hack something together with FUSE, but > it'd be a slow, platform-specific kludge.) > > Cheers, > Chris > -- > http://blog.rebertia.com However, as the only reason to have the cstringIO object have a name is for you to open or close it. The rest of the functionality is the same, reading and writing too. ------------------ in a terminal ... import cStringIO ab = cStringIO.StringIO() # an output type, as it was call with nothing. cd = cStringIO.StringIO( 'a filled buffer') # an input type. type( ab ) == cStringIO.OutputType True type( cd ) == cStringIO.InputType True Working with these properties .... we get Let's assume you have class with read and write ability, which assumes opening a file or cStringIO object (could extend to StringIO object with out much changing ). class foo: def __init__( self ): """ Define some variables. House keeping. """ self.readState = False self.writeState = False self.readObj = None self.writeObj = None def fooOpenWrite( self, fileobj ): if type( fileobj ) === StringType: self.writeObj = open( fileobj, 'wb' ) elif type( fileobj ) == cStringIO.OutputType: self.writeObj = fileobj else: self.writeState = False return self.readState = True return True def fooOpenRead( self, fileobj ): if type( fileobj ) === StringType: self.readObj = open( fileobj, 'wb' ) elif type( fileobj ) == cStringIO.OutputType: self.readObj = fileobj else: self.readState = False return self.readState = True return def fooRead( self ): for x in self.readObj: print x def fooWrite( self, str ): self.readObj.write( str ) Steven From solipsis at pitrou.net Fri Jan 14 17:54:34 2011 From: solipsis at pitrou.net (Antoine Pitrou) Date: Fri, 14 Jan 2011 23:54:34 +0100 Subject: python 3 and Unicode line breaking References: <32f75200-b4d8-4ec8-b07d-4740a79c28b6@g26g2000vba.googlegroups.com> <4d2f959a$0$29984$c3e8da3$5496439d@news.astraweb.com> <55c2f7dc-d4d8-4939-85de-41c19c336f23@k25g2000vbl.googlegroups.com> <4d3074b0$0$29984$c3e8da3$5496439d@news.astraweb.com> <4d30c9ba$0$29984$c3e8da3$5496439d@news.astraweb.com> Message-ID: <20110114235434.1040bb5a@pitrou.net> On 14 Jan 2011 22:10:02 GMT Steven D'Aprano wrote: > > This is good, helpful advice, and far more useful to the OP than just > ignoring his post. You have jumped to his defense (or rather, you have > jumped to criticise me) but I see that you haven't replied to his > question or given him any advice in how to solve his problem. Simply because I have no elaborate answer to give, even in the light of his/her recent precisions on the topic (and, actually, neither do you). Asking for precisions is certainly fine; doing it in an agressive way is not, especially when the original message doesn't look like the usual blunt, impolite and typo-ridden "can you do my homework" message. Also, I would expect someone familiar with the textwrap module's (lack of) unicode capabilities would have been able to answer the first message without even asking for precisions. Regards Antoine. From solipsis at pitrou.net Fri Jan 14 18:23:55 2011 From: solipsis at pitrou.net (Antoine Pitrou) Date: Sat, 15 Jan 2011 00:23:55 +0100 Subject: python 3 and Unicode line breaking References: <32f75200-b4d8-4ec8-b07d-4740a79c28b6@g26g2000vba.googlegroups.com> <4d2f959a$0$29984$c3e8da3$5496439d@news.astraweb.com> Message-ID: <20110115002355.3b9a7b5d@pitrou.net> On Fri, 14 Jan 2011 06:29:27 -0800 (PST) leoboiko wrote: > > And it generally doesn?t try to pick good places to break lines > at all, just making the assumption that 1 character = 1 column > and that breaking on ASCII whitespaces/hyphens is enough. We > can?t really blame textwrap for that, it is a very simple module > and Unicode line breaking gets complex fast (that?s why the > consortium provides a ready-made algorithm). It?s just that, > with python3?s emphasis on Unicode support, I was surprised not > to be able to find an UAX #14 implementation. I thought someone > would surely have written one and I simply couldn?t find, so I > asked precisely that. If you're willing to help on that matter (or some aspects of them, textwrap-specific or not), you can open an issue on http://bugs.python.org and propose a patch. See also http://docs.python.org/devguide/#contributing if you need more info on how to contribute. Regards Antoine. From billy.earney at gmail.com Fri Jan 14 19:07:19 2011 From: billy.earney at gmail.com (Billy Earney) Date: Fri, 14 Jan 2011 18:07:19 -0600 Subject: Developing a program to make a family tree. In-Reply-To: <317f6ed0-ebd9-4a58-9ad3-da57563193ad@w29g2000vba.googlegroups.com> References: <317f6ed0-ebd9-4a58-9ad3-da57563193ad@w29g2000vba.googlegroups.com> Message-ID: try http://gramps-project.org/, which is created in python.. :) On Fri, Jan 14, 2011 at 1:39 PM, Ata Jafari wrote: > Hi there. > I'm trying to develop a program like family tree maker. I have all > information, so there is no need to search on the net. This must be > something like trees. Can someone help me? I'm at the beginning. > Thanks. > > -- > Ata J. Tabrizi > atae.tabrizi at metu.edu.tr > -- > http://mail.python.org/mailman/listinfo/python-list > -------------- next part -------------- An HTML attachment was scrubbed... URL: From kushal.kumaran at gmail.com Fri Jan 14 20:26:27 2011 From: kushal.kumaran at gmail.com (Kushal Kumaran) Date: Sat, 15 Jan 2011 06:56:27 +0530 Subject: Developing a program to make a family tree. In-Reply-To: <317f6ed0-ebd9-4a58-9ad3-da57563193ad@w29g2000vba.googlegroups.com> References: <317f6ed0-ebd9-4a58-9ad3-da57563193ad@w29g2000vba.googlegroups.com> Message-ID: <1295054787.6346.2.camel@Nokia-N900> ----- Original message ----- > Hi there. > I'm trying to develop a program like family tree maker. I have all > information, so there is no need to search on the net. This must be > something like trees. Can someone help me? I'm at the beginning. > Thanks. > Family trees are nothing like trees, actually. If you start with that assumption, your software will sadly not be usable by many people. -- regards, kushal From steve+comp.lang.python at pearwood.info Fri Jan 14 20:28:10 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 15 Jan 2011 01:28:10 GMT Subject: python 3 and Unicode line breaking References: <32f75200-b4d8-4ec8-b07d-4740a79c28b6@g26g2000vba.googlegroups.com> <4d2f959a$0$29984$c3e8da3$5496439d@news.astraweb.com> <55c2f7dc-d4d8-4939-85de-41c19c336f23@k25g2000vbl.googlegroups.com> <4d3074b0$0$29984$c3e8da3$5496439d@news.astraweb.com> <4d30c9ba$0$29984$c3e8da3$5496439d@news.astraweb.com> <9b84ec07-0679-4bc6-96ea-b37231d3fd83@b25g2000vbz.googlegroups.com> Message-ID: <4d30f82a$0$29984$c3e8da3$5496439d@news.astraweb.com> On Fri, 14 Jan 2011 14:26:09 -0800, leoboiko wrote: ... > As for taking the time to provide information, I wonder if there was any > technical problem that prevented you from seeing my reply to Stefan, > sent Jan 14, 12:29PM? Presumably, since I haven't got it in my news client. This is not the first time. > He asked how exacly the stdlib module ?textwrap? > differs from the Unicode algorithm, so I provided some commented > examples. Does this help? http://packages.python.org/kitchen/api-text-display.html kitchen.text.display.wrap(text, width=70, initial_indent=u'', subsequent_indent=u'', encoding='utf-8', errors='replace') Works like we want textwrap.wrap() to work [...] textwrap.wrap() from the python standard libray has two drawbacks that this attempts to fix: 1. It does not handle textual width. It only operates on bytes or characters which are both inadequate (due to multi-byte and double width characters). 2. It malforms lists and blocks. -- Steven From steve+comp.lang.python at pearwood.info Fri Jan 14 21:02:45 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 15 Jan 2011 02:02:45 GMT Subject: Elliptic Curve Prime factorisation References: <2040fe29-f11d-4e64-acac-d49ae8bb5ca9@u32g2000yqe.googlegroups.com> Message-ID: <4d310045$0$29984$c3e8da3$5496439d@news.astraweb.com> On Fri, 14 Jan 2011 11:52:21 -0800, mukesh tiwari wrote: > Hello all , I have implemented Elliptic curve prime factorisation using > wikipedia [ > http://en.wikipedia.org/wiki/Lenstra_elliptic_curve_factorization]. I > think that this code is not optimised and posting for further > improvement. Feel free to comment and if you have any link regarding > Elliptic curve prime factorisation , kindly post it. Thank you I don't think you can optimize it further in pure Python, although it is probably a good candidate for something like Cython, Pyrex or Shedskin. I think the code can be optimized for easier reading by putting single spaces around operators, following commas, etc. I find your style difficult to read. It could do with a docstring explaining what it does and how to use it, and some doctests. But other than that, it looks good. Have you considered putting it up on the ActiveState Python cookbook? -- Steven From usernet at ilthio.net Fri Jan 14 21:09:55 2011 From: usernet at ilthio.net (Tim Harig) Date: Sat, 15 Jan 2011 02:09:55 +0000 (UTC) Subject: Developing a program to make a family tree. References: <317f6ed0-ebd9-4a58-9ad3-da57563193ad@w29g2000vba.googlegroups.com> Message-ID: On 2011-01-14, Ata Jafari wrote: > I'm trying to develop a program like family tree maker. I have all > information, so there is no need to search on the net. This must be > something like trees. Can someone help me? I'm at the beginning. I don't know anything specific about family tree software and you don't really specify what you want your software to do. I can only assume that you are interested in taking the data in some format which contains the links between family members and creating a tree representation of that data? If I was going to attempt something like this, I would probably generate the representation as a set of postscript instructions. I would start with a basic template for a union which could be essentially pasted into different places in the output page. Then generating your tree is a simple matter of laying out the templates to match your data, filling in the template fields for each persion within their union, and drawing the connecting lines of the tree. Since I was already generating postscript anyway, I would probably implement much of the actual logic in postscript (the built in stacks provide an exellent way to process tree like structures in all of their nested levels). I would Python provide any user interface for manipulating the data and to dump the data into the postscript program. From drsalists at gmail.com Fri Jan 14 22:28:28 2011 From: drsalists at gmail.com (Dan Stromberg) Date: Fri, 14 Jan 2011 19:28:28 -0800 Subject: Elliptic Curve Prime factorisation In-Reply-To: <2040fe29-f11d-4e64-acac-d49ae8bb5ca9@u32g2000yqe.googlegroups.com> References: <2040fe29-f11d-4e64-acac-d49ae8bb5ca9@u32g2000yqe.googlegroups.com> Message-ID: On Fri, Jan 14, 2011 at 11:52 AM, mukesh tiwari wrote: > Hello all , I have implemented Elliptic curve prime factorisation > using wikipedia [ http://en.wikipedia.org/wiki/Lenstra_elliptic_curve_factorization]. > I think that this code is not optimised and posting for further > improvement. Feel free to comment and if you have any link regarding > Elliptic curve prime factorisation , kindly post it. > Thank you You can get a lot of good suggestions for your code quickly and easily by going over it with pylint. For performance, you could try the gmpy module - it's good at dealing with large numbers. For an example, you might examine http://stromberg.dnsalias.org/svn/huge-prime/trunk . BTW, huge-prime dates from just shortly before I started routinely going over my code with pylint. From mukeshtiwari.iiitm at gmail.com Fri Jan 14 23:34:49 2011 From: mukeshtiwari.iiitm at gmail.com (mukesh tiwari) Date: Fri, 14 Jan 2011 20:34:49 -0800 (PST) Subject: Elliptic Curve Prime factorisation References: <2040fe29-f11d-4e64-acac-d49ae8bb5ca9@u32g2000yqe.googlegroups.com> <4d310045$0$29984$c3e8da3$5496439d@news.astraweb.com> Message-ID: <1f251f3f-4446-4c29-bc41-b1a03ae372e2@s9g2000vby.googlegroups.com> On Jan 15, 7:02 am, Steven D'Aprano wrote: > On Fri, 14 Jan 2011 11:52:21 -0800, mukesh tiwari wrote: > > Hello all , I have implemented Elliptic curve prime factorisation using > > wikipedia [ > >http://en.wikipedia.org/wiki/Lenstra_elliptic_curve_factorization]. I > > think that this code is not optimised and posting for further > > improvement. Feel free to comment and if you have any link regarding > > Elliptic curve prime factorisation , kindly post it. Thank you > > I don't think you can optimize it further in pure Python, although it is > probably a good candidate for something like Cython, Pyrex or Shedskin. > > I think the code can be optimized for easier reading by putting single > spaces around operators, following commas, etc. I find your style > difficult to read. > > It could do with a docstring explaining what it does and how to use it, > and some doctests. But other than that, it looks good. Have you > considered putting it up on the ActiveState Python cookbook? > > -- > Steven Thank you for your suggestion. I posted it ActiveState with comments. #!/usr/local/bin/python # -*- coding: utf-8 -*- import math import random #y^2=x^3+ax+b mod n # ax+by=gcd(a,b). This function returns [gcd(a,b),x,y]. Source Wikipedia def extended_gcd(a,b): x,y,lastx,lasty=0,1,1,0 while b!=0: q=a/b a,b=b,a%b x,lastx=(lastx-q*x,x) y,lasty=(lasty-q*y,y) if a<0: return (-a,-lastx,-lasty) else: return (a,lastx,lasty) def gcd(a,b): if a < 0: a = -a if b < 0: b = -b if a == 0: return b if b == 0: return a while b != 0: (a, b) = (b, a%b) return a # pick first a point P=(u,v) with random non-zero coordinates u,v (mod N), then pick a random non-zero A (mod N), # then take B = u^2 - v^3 - Ax (mod N). # http://en.wikipedia.org/wiki/Lenstra_elliptic_curve_factorization def randomCurve(N): A,u,v=random.randrange(N),random.randrange(N),random.randrange(N) B=(v*v-u*u*u-A*u)%N return [(A,B,N),(u,v)] # Given the curve y^2 = x^3 + ax + b over the field K (whose characteristic we assume to be neither 2 nor 3), and points # P = (xP, yP) and Q = (xQ, yQ) on the curve, assume first that xP != xQ. Let the slope of the line s = (yP - yQ)/(xP - xQ); since K # is a field, s is well-defined. Then we can define R = P + Q = (xR, - yR) by # s=(xP-xQ)/(yP-yQ) Mod N # xR=s^2-xP-xQ Mod N # yR=yP+s(xR-xP) Mod N # If xP = xQ, then there are two options: if yP = -yQ, including the case where yP = yQ = 0, then the sum is defined as 0[Identity]. # thus, the inverse of each point on the curve is found by reflecting it across the x-axis. If yP = yQ != 0, then R = P + P = 2P = # (xR, -yR) is given by # s=3xP^2+a/(2yP) Mod N # xR=s^2-2xP Mod N # yR=yP+s(xR-xP) Mod N # http://en.wikipedia.org/wiki/Elliptic_curve#The_group_law''') def addPoint(E,p_1,p_2): if p_1=="Identity": return [p_2,1] if p_2=="Identity": return [p_1,1] a,b,n=E (x_1,y_1)=p_1 (x_2,y_2)=p_2 x_1%=n y_1%=n x_2%=n y_2%=n if x_1 != x_2 : d,u,v=extended_gcd(x_1-x_2,n) s=((y_1-y_2)*u)%n x_3=(s*s-x_1-x_2)%n y_3=(-y_1-s*(x_3-x_1))%n else: if (y_1+y_2)%n==0:return ["Identity",1] else: d,u,v=extended_gcd(2*y_1,n) s=((3*x_1*x_1+a)*u)%n x_3=(s*s-2*x_1)%n y_3=(-y_1-s*(x_3-x_1))%n return [(x_3,y_3),d] # http://en.wikipedia.org/wiki/Elliptic_curve_point_multiplication # Q=0 [Identity element] # while m: # if (m is odd) Q+=P # P+=P # m/=2 # return Q') def mulPoint(E,P,m): Ret="Identity" d=1 while m!=0: if m%2!=0: Ret,d=addPoint(E,Ret,P) if d!=1 : return [Ret,d] # as soon as i got anything otherthan 1 return P,d=addPoint(E,P,P) if d!=1 : return [Ret,d] m>>=1 return [Ret,d] def ellipticFactor(N,m,times=5): for i in xrange(times): E,P=randomCurve(N); Q,d=mulPoint(E,P,m) if d!=1 : return d return N if __name__=="__main__": n=input() m=int(math.factorial(1000)) while n!=1: k=ellipticFactor(n,m) n/=k print k From apzc2529 at gmail.com Sat Jan 15 00:42:39 2011 From: apzc2529 at gmail.com (Cun Zhang) Date: Sat, 15 Jan 2011 13:42:39 +0800 Subject: Is it possible to let a virtual file created by cStringIO have a filename so that functions can read it by its filename? In-Reply-To: References: Message-ID: hi Chris, Thank you for your advice. I will use tmpfs as a temperory file system to detail with it. Cheers, Cun Zhang On Sat, Jan 15, 2011 at 4:51 AM, Chris Rebert wrote: > On Fri, Jan 14, 2011 at 7:52 AM, Cun Zhang wrote: > > Hi,all > > I hope use cStringIO to create virtual file, but my customed function > which > > is from a shared library imported by ctypes > > just accepts a filename(string type) as parameter. > > > > So I'm wondering whether there is any method that make the virtual file > > created by cStringIO like a normal file which have > > a filename, so it can be called by my functions. > > That's not possible. (c)StringIO presents a file-like interface at the > Python level, but under the covers, it's not implemented using > anything like a normal file; thus, it doesn't have a presence on any > filesystem. I would suggest using a temporary file > (http://docs.python.org/library/tempfile.html ) for communicating with > the C module, writing the contents of the StringIO object to the > temporary file if necessary. > (It's probably also possible to hack something together with FUSE, but > it'd be a slow, platform-specific kludge.) > > Cheers, > Chris > -- > http://blog.rebertia.com > -- ======================================== Cun Zhang Ph.D. Candidate LNM,Institute of Mechanics Chinese Academy of Sciences Beijing, 100190, China Tel:86-10-82544204 http://www.edwardpku.com/cun ======================================== -------------- next part -------------- An HTML attachment was scrubbed... URL: From rantingrick at gmail.com Sat Jan 15 00:57:51 2011 From: rantingrick at gmail.com (rantingrick) Date: Fri, 14 Jan 2011 21:57:51 -0800 (PST) Subject: Python use growing fast References: <4d2b8844$0$43996$742ec2ed@news.sonic.net> Message-ID: <66961d22-be39-4dc1-a7bf-3bf406808137@z19g2000yqb.googlegroups.com> On Jan 10, 9:24?pm, Dan Stromberg wrote: > About JavaScript's popularity: > 1) I've been getting the impression that JavaScript is popular in a > manner similar to how x86 machine language is popular: That is, it's > used all over, but few people hand code it (though admittedly, there > are probably more people hand coding JavaScript than people hand > coding x86 assembler today) Exactly, another half baked language that has been shoved down our throats like artery clogging Big Macs and French Fries! Oh how many times i have lamented for Python's eloquent syntax whilst brain farting Javascript idiosyncrasies! >:( From justin.mailinglists at gmail.com Sat Jan 15 05:27:20 2011 From: justin.mailinglists at gmail.com (Justin Ezequiel) Date: Sat, 15 Jan 2011 02:27:20 -0800 (PST) Subject: FTP problem References: Message-ID: 'indexftp.barcap.com' only (sans the 'ftp.' prefix) allows me to connect to an FTP server >ftp indexftp.barcap.com Connected to usftp.barcap.com. 220-Connected to usftp.barcap.com. 220 FTP server ready. User (usftp.barcap.com:(none)): From udodenko at users.sourceforge.net Sat Jan 15 09:45:13 2011 From: udodenko at users.sourceforge.net (Captain Obvious) Date: Sat, 15 Jan 2011 16:45:13 +0200 Subject: do you know what's CGI? (web history personal story) References: Message-ID: <4d31b300$0$23758$14726298@news.sunsite.dk> XL> ... i recall, i stopped doing Mathematica in 1998 because it's a XL> career dead-end as a programing lang, and dived into the utterly XL> idiotic Perl & unix & mysql world. (See: The Unix Pestilence ? Xah XL> Lee's Computing Experience (Impression Of Lisp from Mathematica).) I guess you're calling "idiotic" everything you're too lazy to understand. XL> today were under 10 in the 1990s. They wouldn't know what was CGI, and XL> no amount of explanation can tell them exactly it was like, because it XL> has become HISTORY ? if you didn't live it, you can't feel it. CGI is still used in some places today, hello? If spawning a process for each request is what you want to do, it is a way to go. inetd is quite similar to CGI and, guess what, it is still used. From mwilson at the-wire.com Sat Jan 15 09:55:00 2011 From: mwilson at the-wire.com (Mel) Date: Sat, 15 Jan 2011 09:55 -0500 Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <18c2f4d8-0cce-4cdf-a386-80831dc2f114@m37g2000vbn.googlegroups.com> Message-ID: Zeissmann wrote: >> Seriously, get off of WoW and go write some code. If you'd spent the >> last year programming instead of doing your best Xah Lee impression you >> might have actually made some progress on this. > > I'm curious, is Xah Lee some sort of a Usenet meme? Cause this is not the > first time I see his name in the context of a lightweight invective. AFAIK he's just a guy who thinks Usenet is his blog, and kicks off big rambling threads, cross-posted to infinity that mathematically have probability 0.0 of being on topic in any of the groups they're in. Mel. From stefan.sonnenberg at pythonmeister.com Sat Jan 15 10:06:58 2011 From: stefan.sonnenberg at pythonmeister.com (Stefan Sonnenberg-Carstens) Date: Sat, 15 Jan 2011 16:06:58 +0100 Subject: BackupRead problem Message-ID: <4D31B812.2040105@pythonmeister.com> I'm trying to create a Backup/Restore app. I'm really struggeling for a long time. I can successfully read directories, but not files. Every time, I'll try I get "Access denied", Error 5. It's running with admin privs. Any ideas ? #!python import sys import os import os.path import getopt import time DELETE=0x00010000 READ_CONTROL=0x00020000 WRITE_DAC=0x00040000 WRITE_OWNER=0x00080000 SYNCHRONIZE=0x00100000 STANDARD_RIGHTS_REQUIRED=0x000F0000L STANDARD_RIGHTS_READ=READ_CONTROL STANDARD_RIGHTS_WRITE=READ_CONTROL STANDARD_RIGHTS_EXECUTE=READ_CONTROL STANDARD_RIGHTS_ALL=0x001F0000 SPECIFIC_RIGHTS_ALL=0x0000FFFF FILE_ATTRIBUTE_REPARSE_POINT=0x400 from ctypes import * if os.name == 'nt': import win32security import win32process import win32file try: import win32api except ImportError,e: print >>sys.stderr,'Could not load win32api module. Can not continue' os._exit(1) try: import wmi except ImportError,e: print >>sys.stderr,'Could not load wmi module. Can not continue' os._exit(1) try: import ctypes except ImportError,e: print >>sys.stderr,'Could not load ctypes module. Can not continue' os._exit(1) else: print >>sys.stderr,'Sorry, your platform %s is not supported' % os.name os._exit(1) if len(sys.argv) >= 1: try: opts,args = getopt.getopt(sys.argv[1:],'h',('help',)) except getopt.GetoptError,e: print str(e) if not ctypes.windll.shell32.IsUserAnAdmin(): win32api.ShellExecute(None,'runas',sys.executable,' '.join(sys.argv),r'C:\WINDOWS',0) else: print >>sys.stderr,'Running with administrative privileges' token = win32security.OpenProcessToken(win32process.GetCurrentProcess(),win32security.TOKEN_ADJUST_PRIVILEGES|win32security.TOKEN_QUERY) if token: for priv in (win32security.SE_BACKUP_NAME,win32security.SE_RESTORE_NAME): luid = win32security.LookupPrivilegeValue(None,priv) newState = [(luid,win32security.SE_PRIVILEGE_ENABLED)] try: win32security.AdjustTokenPrivileges(token,0,newState) except: print >>sys.stderr,'Could not get (some) required priviledge(s): ',win32api.FormatMessage(win32api.GetLastError()) os._exit(1) win32api.CloseHandle(token) else: print >>sys.stderr,'Could not get token for running process' os._exit(1) print >>sys.stderr,'Acquired backup/restore context (SeRestorePrivilege and SeBackupPrivilege enabled)' inf = win32file.CreateFile(r'C:\Windows\System32\drivers\etc\hosts',READ_CONTROL,0,None,win32file.OPEN_EXISTING,win32file.FILE_FLAG_BACKUP_SEMANTICS,None) buf = win32file.AllocateReadBuffer(4096) ctx = 0 (bytes_read,buf,ctx) = win32file.BackupRead(inf,4096,buf,False,True,ctx) From invalid at invalid.invalid Sat Jan 15 10:26:54 2011 From: invalid at invalid.invalid (Grant Edwards) Date: Sat, 15 Jan 2011 15:26:54 +0000 (UTC) Subject: Developing a program to make a family tree. References: <317f6ed0-ebd9-4a58-9ad3-da57563193ad@w29g2000vba.googlegroups.com> Message-ID: On 2011-01-14, Ata Jafari wrote: > I'm trying to develop a program like family tree maker. I have all > information, so there is no need to search on the net. This must be > something like trees. Not really. It's more like a combination of a directed graph and a relational database. > Can someone help me? I'm at the beginning. You do know there is already a "family-tree-maker" program written in Python, right? http://gramps-project.org/ Your time might be better spent working on Gramps... -- Grant From sherm.pendley at gmail.com Sat Jan 15 11:15:25 2011 From: sherm.pendley at gmail.com (Sherm Pendley) Date: Sat, 15 Jan 2011 11:15:25 -0500 Subject: do you know what's CGI? (web history personal story) References: <4d31b300$0$23758$14726298@news.sunsite.dk> Message-ID: "Captain Obvious" writes: > XL> ... i recall, i stopped doing Mathematica in 1998 because it's a > XL> career dead-end as a programing lang, and dived into the utterly > XL> idiotic Perl & unix & mysql world. (See: The Unix Pestilence ? Xah > XL> Lee's Computing Experience (Impression Of Lisp from Mathematica).) > > I guess you're calling "idiotic" everything you're too lazy to understand. That's Xah for you. > XL> today were under 10 in the 1990s. They wouldn't know what was CGI, and > XL> no amount of explanation can tell them exactly it was like, because it > XL> has become HISTORY ? if you didn't live it, you can't feel it. > > CGI is still used in some places today, hello? Yeah, James Cameron made a *ton* of money using it to make Avatar. What? Why is everyone looking at me that way? ;-) sherm-- -- Sherm Pendley Cocoa Developer From invalid at invalid.invalid Sat Jan 15 11:38:49 2011 From: invalid at invalid.invalid (Grant Edwards) Date: Sat, 15 Jan 2011 16:38:49 +0000 (UTC) Subject: do you know what's CGI? (web history personal story) References: <4d31b300$0$23758$14726298@news.sunsite.dk> Message-ID: On 2011-01-15, Sherm Pendley wrote: > "Captain Obvious" writes: > >> XL> ... i recall, i stopped doing Mathematica in 1998 because it's a >> XL> career dead-end as a programing lang, and dived into the utterly >> XL> idiotic Perl & unix & mysql world. (See: The Unix Pestilence ??? Xah >> XL> Lee's Computing Experience (Impression Of Lisp from Mathematica).) >> >> I guess you're calling "idiotic" everything you're too lazy to understand. > > That's Xah for you. > >> XL> today were under 10 in the 1990s. They wouldn't know what was CGI, and >> XL> no amount of explanation can tell them exactly it was like, because it >> XL> has become HISTORY ??? if you didn't live it, you can't feel it. >> >> CGI is still used in some places today, hello? > > Yeah, James Cameron made a *ton* of money using it to make Avatar. Too bad he couldn't have used it to make a better movie. Did we really need "Furngully" avec 3D sans funny? -- Grant From martin at v.loewis.de Sat Jan 15 11:41:43 2011 From: martin at v.loewis.de (Martin v. Loewis) Date: Sat, 15 Jan 2011 17:41:43 +0100 Subject: do you know what's CGI? (web history personal story) In-Reply-To: References: <4d31b300$0$23758$14726298@news.sunsite.dk> Message-ID: <4D31CE47.4050501@v.loewis.de> >> CGI is still used in some places today, hello? > > Yeah, James Cameron made a *ton* of money using it to make Avatar. He used compacted graphite iron in Avatar? I didn't know that. Regards, Martin From invalid at invalid.invalid Sat Jan 15 11:44:43 2011 From: invalid at invalid.invalid (Grant Edwards) Date: Sat, 15 Jan 2011 16:44:43 +0000 (UTC) Subject: do you know what's CGI? (web history personal story) References: <4d31b300$0$23758$14726298@news.sunsite.dk> <4D31CE47.4050501@v.loewis.de> Message-ID: On 2011-01-15, Martin v. Loewis wrote: >>> CGI is still used in some places today, hello? >> >> Yeah, James Cameron made a *ton* of money using it to make Avatar. > > He used compacted graphite iron in Avatar? I didn't know that. Is that what "unobtanium" is? Did anybody else thing Unobtainium was a blatant ripoff of Upsidasium from Rocky and Bullwinkle? http://en.wikipedia.org/wiki/Upsidaisium -- Grant From rantingrick at gmail.com Sat Jan 15 11:55:47 2011 From: rantingrick at gmail.com (rantingrick) Date: Sat, 15 Jan 2011 08:55:47 -0800 (PST) Subject: do you know what's CGI? (web history personal story) References: <4d31b300$0$23758$14726298@news.sunsite.dk> Message-ID: <9b74ebf2-f9d4-48b1-b614-94ad4abd1f46@k3g2000yqc.googlegroups.com> On Jan 15, 10:38?am, Grant Edwards wrote: > > Yeah, James Cameron made a *ton* of money using it to make Avatar. > > Too bad he couldn't have used it to make a better movie. I don't LOL very often but i must say that i was ROTF after this comment. Avatar was very disappointing (Both in graphics and story) but maybe i expect too much...? I found the look and feel of Beowulf to be more lifelike. Actually if you appreciate great rendering then you may want to check out "Despicable Me". The story was utterly atrocious (although slightly interesting at moments) but the render quality rivaled the best Dreamworks i have ever seem! From stefan.sonnenberg at pythonmeister.com Sat Jan 15 11:58:16 2011 From: stefan.sonnenberg at pythonmeister.com (Stefan Sonnenberg-Carstens) Date: Sat, 15 Jan 2011 17:58:16 +0100 Subject: BackupRead problem In-Reply-To: <4D31B812.2040105@pythonmeister.com> References: <4D31B812.2040105@pythonmeister.com> Message-ID: <4D31D228.7020101@pythonmeister.com> Am 15.01.2011 16:06, schrieb Stefan Sonnenberg-Carstens: > I'm trying to create a Backup/Restore app. > I'm really struggeling for a long time. > > I can successfully read directories, but not files. > Every time, I'll try I get "Access denied", Error 5. > > It's running with admin privs. > > Any ideas ? > > #!python > import sys > import os > import os.path > import getopt > import time > > > DELETE=0x00010000 > READ_CONTROL=0x00020000 > WRITE_DAC=0x00040000 > WRITE_OWNER=0x00080000 > SYNCHRONIZE=0x00100000 > STANDARD_RIGHTS_REQUIRED=0x000F0000L > STANDARD_RIGHTS_READ=READ_CONTROL > STANDARD_RIGHTS_WRITE=READ_CONTROL > STANDARD_RIGHTS_EXECUTE=READ_CONTROL > STANDARD_RIGHTS_ALL=0x001F0000 > SPECIFIC_RIGHTS_ALL=0x0000FFFF > > FILE_ATTRIBUTE_REPARSE_POINT=0x400 > > from ctypes import * > > if os.name == 'nt': > > import win32security > import win32process > import win32file > > try: > import win32api > except ImportError,e: > print >>sys.stderr,'Could not load win32api module. Can not > continue' > os._exit(1) > try: > import wmi > except ImportError,e: > print >>sys.stderr,'Could not load wmi module. Can not continue' > os._exit(1) > try: > import ctypes > except ImportError,e: > print >>sys.stderr,'Could not load ctypes module. Can not > continue' > os._exit(1) > else: > print >>sys.stderr,'Sorry, your platform %s is not supported' % > os.name > os._exit(1) > > if len(sys.argv) >= 1: > try: > opts,args = getopt.getopt(sys.argv[1:],'h',('help',)) > except getopt.GetoptError,e: > print str(e) > if not ctypes.windll.shell32.IsUserAnAdmin(): > win32api.ShellExecute(None,'runas',sys.executable,' > '.join(sys.argv),r'C:\WINDOWS',0) > else: > print >>sys.stderr,'Running with administrative privileges' > token = > win32security.OpenProcessToken(win32process.GetCurrentProcess(),win32security.TOKEN_ADJUST_PRIVILEGES|win32security.TOKEN_QUERY) > if token: > for priv in > (win32security.SE_BACKUP_NAME,win32security.SE_RESTORE_NAME): > luid = win32security.LookupPrivilegeValue(None,priv) > newState = [(luid,win32security.SE_PRIVILEGE_ENABLED)] > try: > win32security.AdjustTokenPrivileges(token,0,newState) > except: > print >>sys.stderr,'Could not get (some) required > priviledge(s): ',win32api.FormatMessage(win32api.GetLastError()) > os._exit(1) > win32api.CloseHandle(token) > else: > print >>sys.stderr,'Could not get token for running process' > os._exit(1) > print >>sys.stderr,'Acquired backup/restore context > (SeRestorePrivilege and SeBackupPrivilege enabled)' > inf = > win32file.CreateFile(r'C:\Windows\System32\drivers\etc\hosts',READ_CONTROL,0,None,win32file.OPEN_EXISTING,win32file.FILE_FLAG_BACKUP_SEMANTICS,None) > buf = win32file.AllocateReadBuffer(4096) > ctx = 0 > (bytes_read,buf,ctx) = > win32file.BackupRead(inf,4096,buf,False,True,ctx) MS's documenation sucks. Just found some code on the web regarding root-kits, but after changing win32file.CreateFile(r'C:\Windows\System32\drivers\etc\hosts',READ_CONTROL,0,None,win32file.OPEN_EXISTING,win32file.FILE_FLAG_BACKUP_SEMANTICS,None) to win32file.CreateFile(r'C:\Windows\System32\drivers\etc\hosts',win32file.GENERIC_READ,0,None,win32file.OPEN_EXISTING,win32file.FILE_FLAG_BACKUP_SEMANTICS,None) it works. From antonio.cardenes at gmail.com Sat Jan 15 12:47:19 2011 From: antonio.cardenes at gmail.com (Antonio Cardenes) Date: Sat, 15 Jan 2011 17:47:19 +0000 Subject: Fitness data program Message-ID: Hello folks, I'm trying to improve my Phyton skills with a project: A fitness program that can correlate measurements (weight and size of various body parts), date taken and it has to be able to print a nice graph showing improvements (a la Wii Fit) I was wondering if you could point me in the right path (modules and such), thanks. Antonio Cardenes -------------- next part -------------- An HTML attachment was scrubbed... URL: From emile at fenx.com Sat Jan 15 13:02:46 2011 From: emile at fenx.com (Emile van Sebille) Date: Sat, 15 Jan 2011 10:02:46 -0800 Subject: do you know what's CGI? (web history personal story) In-Reply-To: References: <4d31b300$0$23758$14726298@news.sunsite.dk> <4D31CE47.4050501@v.loewis.de> Message-ID: On 1/15/2011 8:44 AM Grant Edwards said... > On 2011-01-15, Martin v. Loewis wrote: >>>> CGI is still used in some places today, hello? >>> >>> Yeah, James Cameron made a *ton* of money using it to make Avatar. >> >> He used compacted graphite iron in Avatar? I didn't know that. > > Is that what "unobtanium" is? > > Did anybody else thing Unobtainium was a blatant ripoff of Upsidasium > from Rocky and Bullwinkle? http://en.wikipedia.org/wiki/Upsidaisium > No -- I figured he took it directly form the name of the material used to make the MotoGP bikes... Emile From nagle at animats.com Sat Jan 15 13:38:16 2011 From: nagle at animats.com (John Nagle) Date: Sat, 15 Jan 2011 10:38:16 -0800 Subject: do you know what's CGI? (web history personal story) In-Reply-To: References: Message-ID: <4d31e9a9$0$44039$742ec2ed@news.sonic.net> On 1/14/2011 1:20 PM, Xah Lee wrote: > some extempore thought. Who let the dogs in? John Nagle From alan at baselinedata.co.uk Sat Jan 15 14:39:25 2011 From: alan at baselinedata.co.uk (Alan Harris-Reid) Date: Sat, 15 Jan 2011 19:39:25 +0000 Subject: Career path - where next? In-Reply-To: References: <4D2DD8BC.1020907@googlemail.com> Message-ID: <4D31F7ED.4040307@baselinedata.co.uk> To all those who answered my original post so far (Jon Clements, Terry Jan Reedy, Philip Semanchuk) - many thanks. Your suggestions have given me a number of avenues to follow. I'll let you know how I get on. Regards, Alan From katie at coderstack.co.uk Sat Jan 15 14:45:49 2011 From: katie at coderstack.co.uk (Katie T) Date: Sat, 15 Jan 2011 19:45:49 +0000 Subject: Developing a program to make a family tree. In-Reply-To: References: <317f6ed0-ebd9-4a58-9ad3-da57563193ad@w29g2000vba.googlegroups.com> Message-ID: On Fri, Jan 14, 2011 at 7:57 PM, Jon Clements wrote: > Otherwise, you're in for a struggle, as you need to choose a storage > back-end, a GUI (wxWindows/GTK/Qt4 etc...), how to handle GEDCOM > format (unless it's not going to be compatible with other software), > does it need to produce web pages/reports (and in what formats). There are a couple of Python gedcom parsers around: http://ilab.cs.byu.edu/cs460/code/gedcom/gedcom.py https://github.com/dijxtra/simplepyged Katie -- CoderStack http://www.coderstack.co.uk/python-jobs The Software Developer Job Board From katie at coderstack.co.uk Sat Jan 15 14:48:40 2011 From: katie at coderstack.co.uk (Katie T) Date: Sat, 15 Jan 2011 19:48:40 +0000 Subject: Fitness data program In-Reply-To: References: Message-ID: On Sat, Jan 15, 2011 at 5:47 PM, Antonio Cardenes wrote: > Hello folks, I'm trying to improve my Phyton skills with a project: A > fitness program that can correlate measurements (weight and size of various > body parts), date taken and it has to be able to print a nice graph showing > improvements (a la Wii Fit) Scipy + Matplotlib should give you the tools to do correlation stats and graphing. Katie -- CoderStack http://www.coderstack.co.uk/python-jobs The Software Developer Job Board From howe.steven at gmail.com Sat Jan 15 16:13:25 2011 From: howe.steven at gmail.com (GrayShark) Date: Sat, 15 Jan 2011 15:13:25 -0600 Subject: Fitness data program References: Message-ID: On Sat, 15 Jan 2011 19:48:40 +0000, Katie T wrote: > On Sat, Jan 15, 2011 at 5:47 PM, Antonio Cardenes > wrote: >> Hello folks, I'm trying to improve my Phyton skills with a project: A >> fitness program that can correlate measurements (weight and size of >> various body parts), date taken and it has to be able to print a nice >> graph showing improvements (a la Wii Fit) > > Scipy + Matplotlib should give you the tools to do correlation stats and > graphing. > > Katie Likely you'll want a database, for usernames, dates, weights. Since it's so simple, using sqlite (which doesn't have a running database engine) is a wise choice. There's a python module to help interface. Also you might visit the django website. This sort of project could use a web frontend, since your likely want users to have access to their plots, so logins are required; Remote access (via web) sounds reasonable too. During those early days of shaping up, well, no one else need see my progress. Remember the old adage KISS (Keep It Simple, Stupid) steven From tahoemph at gmail.com Sat Jan 15 16:43:18 2011 From: tahoemph at gmail.com (Michael Hunter) Date: Sat, 15 Jan 2011 13:43:18 -0800 Subject: Developing a program to make a family tree. In-Reply-To: <317f6ed0-ebd9-4a58-9ad3-da57563193ad@w29g2000vba.googlegroups.com> References: <317f6ed0-ebd9-4a58-9ad3-da57563193ad@w29g2000vba.googlegroups.com> Message-ID: On Fri, Jan 14, 2011 at 11:39 AM, Ata Jafari wrote: > Hi there. > I'm trying to develop a program like family tree maker. I have all > information, so there is no need to search on the net. This must be > something like trees. Can someone help me? I'm at the beginning. > Thanks. I think you are probably coming at this from the wrong direction. Either you want to solve your family tree problem in the easiest way possible in which case there are already packages available or you want to develop this because you want to do the project to learn (more) python, etc. Assuming the later the fact you have to ask the question in the way you did means you are short on software design experience and don't know much about the problem domain (genealogy). Additionally you probably havn't written much code although you came here so you probably have a little experience. That is triple death. You need to hold a couple of those variables stable. I'd suggest finding a existing open source genealogy program and use bug fixing as a way to learn basics about the package and then try to add a feature as a way of learning something about software design. Michael From a.j.romanista at gmail.com Sat Jan 15 17:01:30 2011 From: a.j.romanista at gmail.com (Ata Jafari) Date: Sat, 15 Jan 2011 14:01:30 -0800 (PST) Subject: Developing a program to make a family tree. References: <317f6ed0-ebd9-4a58-9ad3-da57563193ad@w29g2000vba.googlegroups.com> Message-ID: People here guided me to GRAMPS, an open-source software project. Yes, I'm new, and Python is my first programming language. My software should not be only a "tree-like" one. There are 254 people in this family tree. I'm trying to find another method. But I think it is better to start with contributing to GRAMPS first. Thanks. Ata From alice at gothcandy.com Sat Jan 15 17:19:47 2011 From: alice at gothcandy.com (=?utf-8?Q?Alice_Bevan=E2=80=93McGregor?=) Date: Sat, 15 Jan 2011 14:19:47 -0800 Subject: do you know what's CGI? (web history personal story) References: <4d31b300$0$23758$14726298@news.sunsite.dk> Message-ID: On 2011-01-15 08:15:25 -0800, Sherm Pendley said: > "Captain Obvious" writes: > >> XL> ... i recall, i stopped doing Mathematica in 1998 because it's a >> XL> career dead-end as a programing lang, and dived into the utterly >> XL> idiotic Perl & unix & mysql world. (See: The Unix Pestilence ? Xah >> XL> Lee's Computing Experience (Impression Of Lisp from Mathematica).) >> >> I guess you're calling "idiotic" everything you're too lazy to understand. > > That's Xah for you. It's a bad sign when people use your name as a running joke in multiple mailing lists (outside the ones regularly posted in, specificaly I noticed this in one of the web framework lists) to mean "silly/stupid comments with no basis in reality". ? Alice. From alice at gothcandy.com Sat Jan 15 17:22:41 2011 From: alice at gothcandy.com (=?utf-8?Q?Alice_Bevan=E2=80=93McGregor?=) Date: Sat, 15 Jan 2011 14:22:41 -0800 Subject: do you know what's CGI? (web history personal story) References: <4d31b300$0$23758$14726298@news.sunsite.dk> <9b74ebf2-f9d4-48b1-b614-94ad4abd1f46@k3g2000yqc.googlegroups.com> Message-ID: On 2011-01-15 08:55:47 -0800, rantingrick said: > On Jan 15, 10:38?am, Grant Edwards wrote: > >>> Yeah, James Cameron made a *ton* of money using it to make Avatar. >> >> Too bad he couldn't have used it to make a better movie. I found the graphics impressive; the "blue people" was merely an effort to avoid a more clear representation of the Na'vi as North American indigenous people. > Avatar was very disappointing (Both in graphics and story) but maybe i > expect too much...? The story was clearly "Pocahontas? in Space!", which was very disappointing. > I found the look and feel of Beowulf to be more lifelike. That's just the naked Angelina Jolie in your brain talking. ;) ? Alice. From rantingrick at gmail.com Sat Jan 15 19:00:37 2011 From: rantingrick at gmail.com (rantingrick) Date: Sat, 15 Jan 2011 16:00:37 -0800 (PST) Subject: do you know what's CGI? (web history personal story) References: <4d31b300$0$23758$14726298@news.sunsite.dk> <9b74ebf2-f9d4-48b1-b614-94ad4abd1f46@k3g2000yqc.googlegroups.com> Message-ID: <43af9f08-e20d-4897-b9e4-65babe8679db@u32g2000yqe.googlegroups.com> On Jan 15, 4:22?pm, Alice Bevan?McGregor wrote: > That's just the naked Angelina Jolie in your brain talking. ?;) must...keep...hands...on...keyboard :-O . . . . . . . . OPPS! ;-) From jeanfrancois.leberre at gmail.com Sat Jan 15 20:48:28 2011 From: jeanfrancois.leberre at gmail.com (Jean-Francois) Date: Sat, 15 Jan 2011 17:48:28 -0800 (PST) Subject: Regex url Message-ID: Hi, I try to match the following url with one regex /hello /hello/ /hello/world /hello/world/ world is a variable, I can put toto instead Thanks ! From python at mrabarnett.plus.com Sat Jan 15 21:26:28 2011 From: python at mrabarnett.plus.com (MRAB) Date: Sun, 16 Jan 2011 02:26:28 +0000 Subject: Regex url In-Reply-To: References: Message-ID: <4D325754.4050602@mrabarnett.plus.com> On 16/01/2011 01:48, Jean-Francois wrote: > Hi, > > I try to match the following url with one regex > > /hello > /hello/ > /hello/world > /hello/world/ > > > world is a variable, I can put toto instead > The regex is: ^/hello(?:/(?:[a-z]+/?)?)$ Its meaning is: start of string characters "/hello" optional: character "/" optional: one or more: one of: "a" .. "z" optional: character "/" end of string If it's not what you want, you need to be more specific. From kb1pkl at aim.com Sat Jan 15 21:27:17 2011 From: kb1pkl at aim.com (Corey Richardson) Date: Sat, 15 Jan 2011 21:27:17 -0500 Subject: Regex url In-Reply-To: References: Message-ID: <4D325785.1020908@aim.com> On 01/15/2011 08:48 PM, Jean-Francois wrote: > Hi, > > I try to match the following url with one regex > > /hello > /hello/ > /hello/world > /hello/world/ > > > world is a variable, I can put toto instead > > Thanks ! What was the regex you tried, and where did it fail? I'm no re guru, but here's my go at it: "(/hello/?(%s)?/?)" % var Interpreter session: Python 2.6.6 (r266:84292, Sep 15 2010, 16:22:56) [GCC 4.4.5] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import re >>> var = "toto" >>> pat = re.compile("(/hello/?(%s)?/?)" % var) >>> pat.match("/hello/toto") <_sre.SRE_Match object at 0x7f53baf25938> >>> pat.match("/hello") <_sre.SRE_Match object at 0x7f53baf25c68> >>> pat.match("/hello/") <_sre.SRE_Match object at 0x7f53baf25938> >>> pat.match("/hello/toto/") <_sre.SRE_Match object at 0x7f53baf25c68> From andrei.avk at gmail.com Sat Jan 15 21:28:35 2011 From: andrei.avk at gmail.com (Rainy) Date: Sat, 15 Jan 2011 18:28:35 -0800 (PST) Subject: do you know what's CGI? (web history personal story) References: <4d31b300$0$23758$14726298@news.sunsite.dk> <9b74ebf2-f9d4-48b1-b614-94ad4abd1f46@k3g2000yqc.googlegroups.com> Message-ID: On Jan 15, 5:22?pm, Alice Bevan?McGregor wrote: > On 2011-01-15 08:55:47 -0800, rantingrick said: > > > On Jan 15, 10:38?am, Grant Edwards wrote: > > >>> Yeah, James Cameron made a *ton* of money using it to make Avatar. > > >> Too bad he couldn't have used it to make a better movie. > > I found the graphics impressive; the "blue people" was merely an effort > to avoid a more clear representation of the Na'vi as North American > indigenous people. > > > Avatar was very disappointing (Both in graphics and story) but maybe i > > expect too much...? > > The story was clearly "Pocahontas? in Space!", which was very disappointing. > I have to disagree.. without writing a dozen pages of my thoughts on Avatar, I think this comment from Metafilter sums it up best: http://www.metafilter.com/88197/Even-better-without-special-effects#2897157 link From rantingrick at gmail.com Sat Jan 15 23:17:45 2011 From: rantingrick at gmail.com (rantingrick) Date: Sat, 15 Jan 2011 20:17:45 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <18c2f4d8-0cce-4cdf-a386-80831dc2f114@m37g2000vbn.googlegroups.com> Message-ID: <39e4dbf5-f7ca-40fe-ae54-b9a7b6b5d1eb@g26g2000vba.googlegroups.com> On Jan 14, 3:37?pm, geremy condra wrote: > If you'd spent the > last year programming instead of doing your best Xah Lee impression > you might have actually made some progress on this. Well Geremy the very first step a wise developer employs is to get an idea of what the masses want and what they don't want. Nobody wants to waste a second (much less a whole year) developing a wxPython stdlib module when the powers that be won't even *entertain* the idea of a wxPython stdlib module. Most every Python programmer (noob to pro) understands that while Tkinter is a great starter GUI module eventually you hit the glass ceiling. However for some strange and quite ridiculous reason they insist on keeping Tkinter alive forever. I am at a loss here. Interviewer: So how do you feel about Tkinter? Python Community: Well Tkinter sucks what more can i say? Interviewer: Ok so maybe we should replace Tkinter with something better then? Python Community: What? Are you stupid? No it sucks but we will keep it! And that is that! I have spoken! Interviewer: So let me get this strait fella... You hate Tkinter, and most of your constituents won't even bother to use it because they hate it also *however* you just want to let it rot in the stdlib like some aging hero of boredom and booze? Python Community: Pretty much. Yea. Interviewer: Sounds like a Masochistic psychosis to me. Python Community: ad hominem!, ad hominem! From aman.6677 at gmail.com Sun Jan 16 00:30:00 2011 From: aman.6677 at gmail.com (Aman) Date: Sat, 15 Jan 2011 21:30:00 -0800 (PST) Subject: After C++, what with Python? Message-ID: <5adf432d-2629-4717-8fe6-6d073d6de860@glegroupsg2000goo.googlegroups.com> Hey all, I am a college student, and at college, we did most of the work in C/C++. I kind of stopped using C when I learned C++ (simply because C++ seemed a natural/elegant choice to me, and had backward compatibility with C). I've had a lot of experience with C++. Recently, I was on the path to learn a new programming language, and after suggestion of some of my friends and consulting the web, I chose to proceed with Python. I've finished with core Python and now I'm going through the various inbuilt packages that Python provides. I have an inquisitive mind, and while programming, I always want/tend to make something that is out of the box. It would be great if you people could guide me as to what to proceed with and how. From xahlee at gmail.com Sun Jan 16 00:45:59 2011 From: xahlee at gmail.com (Xah Lee) Date: Sat, 15 Jan 2011 21:45:59 -0800 (PST) Subject: do you know what's CGI? (web history personal story) References: <4d31b300$0$23758$14726298@news.sunsite.dk> <9b74ebf2-f9d4-48b1-b614-94ad4abd1f46@k3g2000yqc.googlegroups.com> Message-ID: <0b19f9e6-d1e3-4481-920d-d980073884c3@e4g2000vbg.googlegroups.com> > > > Avatar was very disappointing (Both in graphics and story) but maybe i > > > expect too much...? > > > The story was clearly "Pocahontas? in Space!", which was very disappointing. > > I have to disagree.. Loly. At this point, i must voice Xah's Point Of View. ?Avatar and District 9 Movie Review? http://xahlee.org/Periodic_dosage_dir/skina/avatar.html -------------------------------------------------- Avatar and District 9 Movie Review Xah Lee, 2010-01-07 ------------------------------ Avatar Went to watch the movie Avatar (2009 film) in theater today. Boo. On a scale of 1 to 10, i'd say this is no more than 7. This movie is totally predicable, stereotypical, intellectually shallow. The 3D effect isn't impressive at all, and about the only thing that is positive about this movie is the imaginative flora and fauna. This movies garnered raving reviews, both by critics as well as being a highly successful money maker. But it's so disappointing to me that i have to think about where to begin. ------------------------------ 3D Effect Ok, lets begin at some easy criticisms, the 3D tech. I recall, back in late 1970s or early 1980s when i was about 10 or so, my mom's mom took me to see one of the first 3D film, in Taiwan, a kung fu film. I vividly recall that i physically dodged when the weapons swung towards me from the screen. Yeah, a lot people did that. That, is the effect of good 3D on you. But now, after 30 years, one'd suppose that the 3D tech has improved vastly, which it has. However, watching Avatar, i hardly get ANY 3D sense at all. In fact, i absolutely don't feel any 3D sense, perhaps a little, if i force my self to feel it, thru its 3D glasses. (I did not watch it on iMax) What's wrong? I don't know. Perhaps the 3D tech is different. I don't remember which 3D films i've watched back 30 years ago, but am guessing that some 3D tech are designed to have a exaggerated perspectivity, and am guessing the 3D tech used in this movie is designed to be more mellow or wide angle. But over all, i say bah. ------------------------------ Predicable Ok, now i might disclose some of this movie's plot, and so here's your ?spoiler? warning, but, the movie is so formula driven and stereotypical that it doesn't matter much. The movie, in one sentence, is about Western powers with high tech wanting to take over gold from some primitive, indigenous people, for their riches in their land. Yeah, that's it. And, yes, there's a hero, who gradually realized that this isn't right, and fell in love with one of the beautiful chick from the indigenous people (you guessed right, the daughter of a chieftain!), and saved the tribe, with the help of local animals and magical nature. The movies runs 2.5 hours. I didn't particular cry ?move on already? at any point, but nor did the long movie had my attention wholly seized. There are no characters. All are shallow. The bad guys, in this case, the corporation head and the head of marines, are just what they are. The corporation head has eyes on gold, and that's his only concern. The marines head has bulky muscles, and is all about toughness. The hero, is just that, with good heart, and handsome to boot, courageous, always miraculously succeeds against all odds, and gets his girl. The heroin, in this case a alien race chick, is of course beautiful as much beauty we can put on a feline humanoid. And what's she like? Well, a beautiful woman, with concerns of loyalty of her man, love of her family, her people, a caring of nature. Actually had sex with the half-human half-alien hero. (inter-species porn anyone?) ------------------------------ Where is the Science in Sci-Fi? What about the story line? Well, the human animals want this million- dollar land inhabited by primitive tribes. The human animals created what's called a ?avatar?, which is a humanoid creature grown from bio- tubes that has mixed DNA from humans and the native feline-like humanoid aliens. The avatar is connected and controlled by a sleeping human. When one is awake, the other goes to sleep. Thru the avatars, it is thought that they can persuade the feline humanoids to move out. But the diplomatic cunning didn't work out, of course, and violence is resorted to. The hero fell in love with the heroin, and grew the sense of American Justice, and defended the primitive feline-humanoids with the help of miracle nature. The Sci-Fi aspect of the avatar concept is all interesting. How does the avatar work? How's it grown? How long does it take? How's the technology to control or connect it? What's the biology of the alien? What they eat? Well, this movie isn't concerned about these things, only that these settings qualify it as Sci-Fi flick. Another interesting aspect of sci-fi is that the plants and animals on this alien place have some sort bio-wire grown from their body, that allows direct animal-to-animal communication or animal-to-plant. For example, the feline-humanoid can connect her bio-wire grown from her head, with the bio-wire on a 6-legged horse or a flying-saurus, similar to how you connect 2 electric wires. Also, the plants form some kinda neural network by some bio-chemical means. (see Biocommunication (science)) Again, all this is used as plot-devices, you don't get to whiff them. ------------------------------ The Message? You can't help but think about American Indians when watching this movie, which the US American Disney proudly showed you in Pocahontas (1995 film). A history of genocide shown as one big, happy, tale. (See: Hollywood and Disney's Rape of Culture.) What can we say about that? Is it just a coincidence that this movie made you think of American Indians? The alien race is named ?Na'vi?. The tribe is called Omaticaya. They worship their tree deity. They mumble some prayer after killing in hunt, presumably to thank mother nature and bless the deceased prey. They tame wild alien beasts the likes of 6 legged horse and flying-saurus as a warrior's rite of passage. They do their face war-paints. They use bows and arrows... I'm not sure how much of all these is connected to real American Indian, or pop beliefs in Primitive Culture. What is Primitive culture anyway? Wikipedia doesn't help much except saying it's controversial. One thing for sure, is that the movie isn't shy of perpetuating the primitive people concept. So is there a message in this movie? Maybe i think too much. Maybe it is simply a visual treat of special effects and explosions. But you can't help thinking how shallow it is, how it reinforces a simplistic picture of Colonization and backwater savages trying to defend it. It is a insult to anthropology educators. ------------------------------ Enjoyable Parts I give this movie 6 out of 10. So, it's a bit above average. What i liked is watching the weird-looking, feline-like humanoid alien race. Of course, especially the female heroin. (Yeah, i'd totally do her.) The exotic flora and fauna, based on exotic rain forest things, are enjoyable to look at. The imagined bipedal mech, the vertical take off chopper, are all well done. The final battle, i wouldn't say spectacular, but still, enjoyable. Conclusion If you love sci-fi and is a movie-goer, yeah sure by all means go watch it. If you watch movies just 4 times a year, then i'm not sure. Wikipedia says with references, that the director acknowledged and some critics thought this movie carries anti-imperialism message. But i think, if anything, it is another black vs white, good vs evil, US- American-justice driven, brainlessness, that is likely to do more harm than good, as far as human animal's moral progress is concerned. Suppose, after watching this movie, viewer came out persuaded by the film and filled with the brainless zeal of JUSTICE. That IS American, and is where the problem is. Avatar movie trailer. ------------------------------ District 9 2010-02-07 Watched movie District 9. Fantastic. Much better than Avatar. Both movies are science fiction. Both involve aliens. Both have mechs. Both involves human animals as a group needing to deal and interact with alien animal. Both are successful, either by movie critics as well by profit. However, the Avatar is the most stereotypical Hollywood brainlessness. No intelligence, no content, no creativity, but plenty of big expensive computer graphics and explosions. The District 9, is just the opposite in every way. The aliens there are quite novel, and i really loved them. They have distinct, idiosyncratic, character. The mecha is also quite interesting, far more so than the one in Avatar. The alien mecha, somehow is integrated biologically with the aliens, and would puke, and when it being shot, hurts the alien inside too. The computer graphics is so well done. The overall movie content, unlike Avatar, doesn't contain some anti-this message or pro-that message, but makes you think, about deep ugly human nature, african history, history of race treatment. The only negative part about District 9, i would say, is that the beginning 30 min is quite boring. I'd give this movie a 9. District 9 Official Trailer 2 Xah ? http://xahlee.org/ From nagle at animats.com Sun Jan 16 01:03:25 2011 From: nagle at animats.com (John Nagle) Date: Sat, 15 Jan 2011 22:03:25 -0800 Subject: After C++, what with Python? In-Reply-To: <5adf432d-2629-4717-8fe6-6d073d6de860@glegroupsg2000goo.googlegroups.com> References: <5adf432d-2629-4717-8fe6-6d073d6de860@glegroupsg2000goo.googlegroups.com> Message-ID: <4d328a3d$0$44058$742ec2ed@news.sonic.net> On 1/15/2011 9:30 PM, Aman wrote: > Hey all, I am a college student, and at college, we did most of the > work in C/C++. I kind of stopped using C when I learned C++ (simply > because C++ seemed a natural/elegant choice to me, and had backward > compatibility with C). I've had a lot of experience with C++. > Recently, I was on the path to learn a new programming language, and > after suggestion of some of my friends and consulting the web, I > chose to proceed with Python. I've finished with core Python and now > I'm going through the various inbuilt packages that Python provides. > I have an inquisitive mind, and while programming, I always want/tend > to make something that is out of the box. It would be great if you > people could guide me as to what to proceed with and how. If you know C++ well, and have a computer science background. Python is trivial. Here's what you need to know: It's a safe dynamically typed imperative object oriented language, with explicit classes. The language is declaration-free and block structure is defined by indentation. Threading is supported but thread concurrency is marginal. The most common implementation is a naive interpreter with reference counting backed up by a mark and sweep garbage collector. Performance is about 1/60 of optimized C code. That's Python. John Nagle From aman.6677 at gmail.com Sun Jan 16 01:48:12 2011 From: aman.6677 at gmail.com (Aman) Date: Sat, 15 Jan 2011 22:48:12 -0800 (PST) Subject: After C++, what with Python? In-Reply-To: <4d328a3d$0$44058$742ec2ed@news.sonic.net> Message-ID: <86a904f8-05b0-435f-81d6-7450650f1679@glegroupsg2000goo.googlegroups.com> @nagle Means you are suggesting me not to proceed with Python because I've had experience with C++? From nagle at animats.com Sun Jan 16 02:04:40 2011 From: nagle at animats.com (John Nagle) Date: Sat, 15 Jan 2011 23:04:40 -0800 Subject: After C++, what with Python? In-Reply-To: <86a904f8-05b0-435f-81d6-7450650f1679@glegroupsg2000goo.googlegroups.com> References: <86a904f8-05b0-435f-81d6-7450650f1679@glegroupsg2000goo.googlegroups.com> Message-ID: <4d329899$0$43988$742ec2ed@news.sonic.net> On 1/15/2011 10:48 PM, Aman wrote: > @nagle Means you are suggesting me not to proceed with Python because I've had experience with C++? No, Python is quite useful, but on the slow side. If you're I/O bound, not time critical, or otherwise not performance constrained, it's quite useful. The language is really quite good, but there's some excessive dynamism which has caused every attempt at an optimizing implementation to fail. John Nagle From tjreedy at udel.edu Sun Jan 16 02:20:59 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Sun, 16 Jan 2011 02:20:59 -0500 Subject: Tkinter: The good, the bad, and the ugly! In-Reply-To: <39e4dbf5-f7ca-40fe-ae54-b9a7b6b5d1eb@g26g2000vba.googlegroups.com> References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <18c2f4d8-0cce-4cdf-a386-80831dc2f114@m37g2000vbn.googlegroups.com> <39e4dbf5-f7ca-40fe-ae54-b9a7b6b5d1eb@g26g2000vba.googlegroups.com> Message-ID: On 1/15/2011 11:17 PM, rantingrick wrote: > Well Geremy the very first step a wise developer employs is to get an > idea of what the masses want and what they don't want. 'The masses' have so far been divided on what alternative they might want. In any case, open source developers are typically scratching their own itches, which may are may not be influenced by 'the masses'. > Nobody wants to waste a second (much less a whole year) > developing a wxPython stdlib > module when the powers that be won't even *entertain* the idea of a > wxPython stdlib module. As far as I know, no one has ever seriously proposed any replacement for tkinter in at least the last ten years. There has been nothing to entertain, review, or discuss, let alone approve or reject. (And if you propose to the PSF that developer X contribute his code, the answer will be to talk to developer X instead.) 'gui' does not appear in any PEP title (except as part of 'guide' or 'guideline'. -- Terry Jan Reedy From georg at python.org Sun Jan 16 02:33:41 2011 From: georg at python.org (Georg Brandl) Date: Sun, 16 Jan 2011 08:33:41 +0100 Subject: [RELEASED] Python 3.2 rc 1 Message-ID: <4D329F55.9040903@python.org> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On behalf of the Python development team, I'm very happy to announce the first release candidate of Python 3.2. Python 3.2 is a continuation of the efforts to improve and stabilize the Python 3.x line. Since the final release of Python 2.7, the 2.x line will only receive bugfixes, and new features are developed for 3.x only. Since PEP 3003, the Moratorium on Language Changes, is in effect, there are no changes in Python's syntax and built-in types in Python 3.2. Development efforts concentrated on the standard library and support for porting code to Python 3. Highlights are: * numerous improvements to the unittest module * PEP 3147, support for .pyc repository directories * PEP 3149, support for version tagged dynamic libraries * PEP 3148, a new futures library for concurrent programming * PEP 384, a stable ABI for extension modules * PEP 391, dictionary-based logging configuration * an overhauled GIL implementation that reduces contention * an extended email package that handles bytes messages * a much improved ssl module with support for SSL contexts and certificate hostname matching * a sysconfig module to access configuration information * additions to the shutil module, among them archive file support * many enhancements to configparser, among them mapping protocol support * improvements to pdb, the Python debugger * countless fixes regarding bytes/string issues; among them full support for a bytes environment (filenames, environment variables) * many consistency and behavior fixes for numeric operations For a more extensive list of changes in 3.2, see http://docs.python.org/3.2/whatsnew/3.2.html To download Python 3.2 visit: http://www.python.org/download/releases/3.2/ Please consider trying Python 3.2 with your code and reporting any bugs you may notice to: http://bugs.python.org/ Enjoy! - -- Georg Brandl, Release Manager georg at python.org (on behalf of the entire python-dev team and 3.2's contributors) -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.16 (GNU/Linux) iEYEARECAAYFAk0yn1QACgkQN9GcIYhpnLDTdACgqQYW5ZmTLlxmppBZItprSj7I TmAAn13lgnu9TdVy0Jln7VwOt5JW9CwL =VZ3p -----END PGP SIGNATURE----- From debatem1 at gmail.com Sun Jan 16 02:35:54 2011 From: debatem1 at gmail.com (geremy condra) Date: Sat, 15 Jan 2011 23:35:54 -0800 Subject: After C++, what with Python? In-Reply-To: <5adf432d-2629-4717-8fe6-6d073d6de860@glegroupsg2000goo.googlegroups.com> References: <5adf432d-2629-4717-8fe6-6d073d6de860@glegroupsg2000goo.googlegroups.com> Message-ID: On Sat, Jan 15, 2011 at 9:30 PM, Aman wrote: > Hey all, I am a college student, and at college, we did most of the work in C/C++. I kind of stopped using C when I learned C++ (simply because C++ seemed a natural/elegant choice to me, and had backward compatibility with C). I've had a lot of experience with C++. > Recently, I was on the path to learn a new programming language, and after suggestion of some of my friends and consulting the web, I chose to proceed with Python. I've finished with core Python and now I'm going through the various inbuilt packages that Python provides. I have an inquisitive mind, and while programming, I always want/tend to make something that is out of the box. It would be great if you people could guide me as to what to proceed with and how. Here's what I would do: 1. Start off slow; reimplement things you've written in other languages until you're sure that you understand how Python constructs differ from superficially similar things in C/C++. 2. Once you've done that, pick a few small tasks (things you would expect to take about one or two weeks to finish), write all the high-level architectural code, and then put together a test harness for them using either unittest[0] or doctest[1]. Pick the one you're most confident you can write the code for and keep at it until you pass all your tests. Using the lessons learned from that, refactor the code of the others and iterate until you feel comfortable thinking about Python at a high level. As a bonus, you also now have a set of medium-scale projects with good test harnesses to show off. 3. After you've convinced yourself you know how to write Python, learn to read other peoples' Python code. Look for small projects (1-5 KLOC) with 'easy' bugs, get familiar with them, and fix those bugs. It isn't a race- make sure your work is high-quality, well-tested, and well documented before you send it to the maintainers. As yet another bonus, if those patches get accepted you'll be able to tell that to potential employers. At this point you'll probably have a much better idea of what you'd like to do moving forward- you'll probably have found out what kinds of problems you find interesting, which ones you have an aptitude for, and what kinds of environments you like. In other words, you'll be much better off than the vast majority of your peers ;) Geremy Condra [0]: http://docs.python.org/library/unittest.html [1]: http://docs.python.org/library/doctest.html From usernet at ilthio.net Sun Jan 16 03:25:13 2011 From: usernet at ilthio.net (Tim Harig) Date: Sun, 16 Jan 2011 08:25:13 +0000 (UTC) Subject: After C++, what with Python? References: <86a904f8-05b0-435f-81d6-7450650f1679@glegroupsg2000goo.googlegroups.com> <4d329899$0$43988$742ec2ed@news.sonic.net> Message-ID: On 2011-01-16, John Nagle wrote: > On 1/15/2011 10:48 PM, Aman wrote: >> @nagle Means you are suggesting me not to proceed with Python because I've had experience with C++? > > No, Python is quite useful, but on the slow side. If you're I/O > bound, not time critical, or otherwise not performance constrained, > it's quite useful. The language is really quite good, but there's > some excessive dynamism which has caused every attempt at an optimizing > implementation to fail. Those who are concerned about performance should check out Go. Garbage collection, duck typing, and compiles to a native binary. It creates a great middle ground between C++ and Python. Any C and/or Python programmer will feel right at home with the language. It is still a young language; but, I have been using it for some useful things. http://golang.org From no.email at nospam.invalid Sun Jan 16 03:53:20 2011 From: no.email at nospam.invalid (Paul Rubin) Date: Sun, 16 Jan 2011 00:53:20 -0800 Subject: After C++, what with Python? References: <86a904f8-05b0-435f-81d6-7450650f1679@glegroupsg2000goo.googlegroups.com> <4d329899$0$43988$742ec2ed@news.sonic.net> Message-ID: <7x8vylfcvz.fsf@ruckus.brouhaha.com> Tim Harig writes: > Those who are concerned about performance should check out Go. > Garbage collection, duck typing, and compiles to a native binary. > It creates a great middle ground between C++ and Python. Any C and/or > Python programmer will feel right at home with the language. It is > still a young language; but, I have been using it for some useful things. Go has some nice aspects but it is much lower level than Python. If you want a statically typed, compiled language closer to Python's level, I know of some projects that have switched from Python to Ocaml. If you want dynamic types, I guess there's Dylan, Lisp, or possibly Erlang. There is also Haskell, but I think using it takes a much different mind-set than Python usually brings out. From list at qtrac.plus.com Sun Jan 16 04:10:56 2011 From: list at qtrac.plus.com (Mark Summerfield) Date: Sun, 16 Jan 2011 09:10:56 +0000 Subject: [python-committers] [RELEASED] Python 3.2 rc 1 In-Reply-To: <4D329F55.9040903@python.org> References: <4D329F55.9040903@python.org> Message-ID: <20110116091056.7d78cca8@dino> On Sun, 16 Jan 2011 08:33:41 +0100 Georg Brandl wrote: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > On behalf of the Python development team, I'm very happy to announce > the first release candidate of Python 3.2. [snip] Regarding http://docs.python.org/dev/whatsnew/3.2.html - in the first argparse example the comment says "one of four allowed values", but the choices list has only three items so I wonder if this is correct? - in the coverage of PEP 3333 code points are written as u0000 and u00FF which is non-standard; one standard way to write them is U+0000 and U+00FF I love the clickable table of built-in functions in functions.html. On debian testing 64-bit make test resulted in: ... [349/349] test_zlib 328 tests OK. 21 tests skipped: test_codecmaps_cn test_codecmaps_hk test_codecmaps_jp test_codecmaps_kr test_codecmaps_tw test_curses test_gdb test_kqueue test_ossaudiodev test_smtpnet test_socketserver test_startfile test_timeout test_tk test_ttk_guionly test_urllib2net test_urllibnet test_winreg test_winsound test_xmlrpc_net test_zipfile64 Those skips are all expected on linux2. sys:1: ResourceWarning: unclosed file <_io.TextIOWrapper name='/dev/null' mode='a' encoding='UTF-8'> which looks pretty good:-) However, I hit a problem with relative imports not working (compared with 3.1). I have to go now but will try to produce a small example if I can. -- Mark Summerfield, Qtrac Ltd, www.qtrac.eu C++, Python, Qt, PyQt - training and consultancy "Programming in Python 3" - ISBN 0321680561 http://www.qtrac.eu/py3book.html From wxjmfauth at gmail.com Sun Jan 16 04:22:00 2011 From: wxjmfauth at gmail.com (jmfauth) Date: Sun, 16 Jan 2011 01:22:00 -0800 (PST) Subject: Issue 1602, cp65001, powershell and python3 crash Message-ID: <04f85ff6-7ece-4397-b0f8-e8b4127a3641@s9g2000vby.googlegroups.com> After having read the discussion about the issue 1602, http://bugs.python.org/issue1602, I came to the idea to test Python with the PowerShell. I thought, it could help and manage "unicode" better than the std "dosbox" does My experience with PowerShell is closed to zero, so take the following as a flat raw information. 1) Setup the coding in PowerShell (font: Consolas) PS D:\jm> $OutputEncoding IsSingleByte : True BodyName : us-ascii EncodingName : US-ASCII HeaderName : us-ascii WebName : us-ascii WindowsCodePage : 1252 IsBrowserDisplay : False IsBrowserSave : False IsMailNewsDisplay : True IsMailNewsSave : True EncoderFallback : System.Text.EncoderReplacementFallback DecoderFallback : System.Text.DecoderReplacementFallback IsReadOnly : True CodePage : 20127 PS D:\jm> chcp 65001 Page de codes active?: 65001 PS D:\jm> $OutputEncoding = [Console]::OutputEncoding PS D:\jm> $OutputEncoding BodyName : utf-8 EncodingName : Unicode (UTF-8) HeaderName : utf-8 WebName : utf-8 WindowsCodePage : 1200 IsBrowserDisplay : True IsBrowserSave : True IsMailNewsDisplay : True IsMailNewsSave : True IsSingleByte : False EncoderFallback : System.Text.EncoderReplacementFallback DecoderFallback : System.Text.DecoderReplacementFallback IsReadOnly : True CodePage : 65001 So far, so good. It seems I can enter and display "unicode characters" (as opposed to cp850). PS D:\jm> echo 'abc?????' abc????? PS D:\jm> chcp Page de codes active?: 65001 PS D:\jm> 2) Python test PS D:\jm> c:\python31\python.exe Fatal Python error: Py_Initialize: can't initialize sys standard streams LookupError: unknown encoding: cp65001 This application has requested the Runtime to terminate it in an unusual way. Please contact the application's support team for more information. PS D:\jm> Obviously and expectedly Python does not recognize cp65001. That's not the problem. The main concern is, Python crashes with the usual msgbox, "python.exe has stopped working ..." . win7 pro (32 bits), Swiss French setup, cp850/cp1252, Python 3.1.2 . Take this a raw information and do not ask me what's happen behind the scene. Last minute info: Python 3.2.rc1: same behaviour. jmf From stefan_ml at behnel.de Sun Jan 16 04:31:36 2011 From: stefan_ml at behnel.de (Stefan Behnel) Date: Sun, 16 Jan 2011 10:31:36 +0100 Subject: After C++, what with Python? In-Reply-To: <4d328a3d$0$44058$742ec2ed@news.sonic.net> References: <5adf432d-2629-4717-8fe6-6d073d6de860@glegroupsg2000goo.googlegroups.com> <4d328a3d$0$44058$742ec2ed@news.sonic.net> Message-ID: John Nagle, 16.01.2011 07:03: > Threading is supported > but thread concurrency is marginal. The most common implementation is > a naive interpreter with reference counting backed up by a mark > and sweep garbage collector. Performance is about 1/60 of > optimized C code. > > That's Python. Since the OP is new to Python (and thus also to this group), it's worth noting that the above is what John Nagle commonly claims to be important about Python. It doesn't match everybody's POV. For most other people, the essence is that Python is actually fun to work with. And if you come from a C++ background, you will happily appreciate how simple programming can be. You will also appreciate learning about Cython, which is the straight forward way for you to write Python code that interfaces with C++ natively. Stefan From usernet at ilthio.net Sun Jan 16 04:47:35 2011 From: usernet at ilthio.net (Tim Harig) Date: Sun, 16 Jan 2011 09:47:35 +0000 (UTC) Subject: [OT] Python like lanugages [was Re: After C++, what with Python?] References: <86a904f8-05b0-435f-81d6-7450650f1679@glegroupsg2000goo.googlegroups.com> <4d329899$0$43988$742ec2ed@news.sonic.net> <7x8vylfcvz.fsf@ruckus.brouhaha.com> Message-ID: On 2011-01-16, Paul Rubin wrote: > Tim Harig writes: >> Those who are concerned about performance should check out Go. >> Garbage collection, duck typing, and compiles to a native binary. >> It creates a great middle ground between C++ and Python. Any C and/or >> Python programmer will feel right at home with the language. It is >> still a young language; but, I have been using it for some useful things. > > Go has some nice aspects but it is much lower level than Python. If you It is a little lower; but, I wouldn't say much lower. My Go code is much more similar in concept, feel, and size to my Python code then it is to my C code. > want a statically typed, compiled language closer to Python's level, I > know of some projects that have switched from Python to Ocaml. If you I have head good things about Ocaml; but, I have never taken the time to learn the language myself. It never reached a critical mass of interest from me to consider adopting it. One of the things that gives me hope for Go is that it is backed by Google so I expect that it may gain some rather rapid adoption. It has made enough of a wake to grab one of Eweek's 18 top languages for 2011. http://www.eweek.com/c/a/Application-Development/Java-C-C-Top-18-Programming-Languages-for-2011-480790/ > want dynamic types, I guess there's Dylan, Lisp, or possibly Erlang. I am a big fan of Erlang and it's ability to create fault tolerant systems; but, it isn't really a general purpose programming language. It also runs inside of a VM which means that it doesn't produce native binary. From steve+comp.lang.python at pearwood.info Sun Jan 16 05:26:23 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 16 Jan 2011 10:26:23 GMT Subject: [OT] Python like lanugages [was Re: After C++, what with Python?] References: <86a904f8-05b0-435f-81d6-7450650f1679@glegroupsg2000goo.googlegroups.com> <4d329899$0$43988$742ec2ed@news.sonic.net> <7x8vylfcvz.fsf@ruckus.brouhaha.com> Message-ID: <4d32c7cf$0$29983$c3e8da3$5496439d@news.astraweb.com> On Sun, 16 Jan 2011 09:47:35 +0000, Tim Harig wrote: > One of the things that gives me hope > for Go is that it is backed by Google so I expect that it may gain some > rather rapid adoption. It has made enough of a wake to grab one of > Eweek's 18 top languages for 2011. If the author thinks that Go is a "tried and true" (his words, not mine) language "where programmers can go to look for work", I think he's fooling himself. When I design my new language, I will make sure I choose a name such that any attempt to search for it on job sites will produce oodles and oodles and oodles of false positives, all the better to ensure that simple- minded "top language of ..." surveys will give a massively inflated job count. I think I'll call it "Salary". -- Steven From wxjmfauth at gmail.com Sun Jan 16 05:55:58 2011 From: wxjmfauth at gmail.com (jmfauth) Date: Sun, 16 Jan 2011 02:55:58 -0800 (PST) Subject: Does Python 3.1 accept \r\n in compile()? References: <5c7ae38a-4302-427b-98f0-2900eaf2a974@l24g2000vby.googlegroups.com> <19d5330a-1237-4e7a-b9aa-47ce312ce8f9@d7g2000vbv.googlegroups.com> Message-ID: <91286f34-037e-47b9-baf4-9427766f2d05@g26g2000vbz.googlegroups.com> Just an info, addendum. >>> sys.version '3.2rc1 (r32rc1:88035, Jan 15 2011, 21:05:51) [MSC v.1500 32 bit (Intel)]' >>> compile('if True:\r\n print(999)\r\n', '', 'exec') at 0x023CA610, file "", line 2> >>> exec(compile('if True:\r\n print(999)\r\n', '', 'exec')) 999 >>> From usernet at ilthio.net Sun Jan 16 06:03:48 2011 From: usernet at ilthio.net (Tim Harig) Date: Sun, 16 Jan 2011 11:03:48 +0000 (UTC) Subject: [OT] Python like lanugages [was Re: After C++, what with Python?] References: <86a904f8-05b0-435f-81d6-7450650f1679@glegroupsg2000goo.googlegroups.com> <4d329899$0$43988$742ec2ed@news.sonic.net> <7x8vylfcvz.fsf@ruckus.brouhaha.com> <4d32c7cf$0$29983$c3e8da3$5496439d@news.astraweb.com> Message-ID: On 2011-01-16, Steven D'Aprano wrote: > On Sun, 16 Jan 2011 09:47:35 +0000, Tim Harig wrote: > >> One of the things that gives me hope >> for Go is that it is backed by Google so I expect that it may gain some >> rather rapid adoption. It has made enough of a wake to grab one of >> Eweek's 18 top languages for 2011. > > If the author thinks that Go is a "tried and true" (his words, not mine) > language "where programmers can go to look for work", I think he's > fooling himself. No I wouldn't say that it has reached market penetration yet; but, it has more momentum then any language I am familiar with. I wouldn't be at all surprised to see it becoming quite common in the next five years. How long has it taken Python to reach its present level of market penetration? And, I still don't see a huge amount of professional Python use outside of web developement. Go has only been public for less then a year. Personally, I think the time is ripe for a language that bridges the gap between ease of use dynamic languages with the performance and distribution capabilities of a full systems level language. This is after all the promise the VM based languages made but never really fulfilled. It is also high time for a fully concurrent language fully capable of taking advantage of multicore processors without having to deal with the inherent dangers of threading. There are several good choices available for both a even a few that fit both bills; but, few of them have the support of a company like Google that is capable of the push required to move the language into the mainstream. > When I design my new language, I will make sure I choose a name such that > any attempt to search for it on job sites will produce oodles and oodles > and oodles of false positives, all the better to ensure that simple- > minded "top language of ..." surveys will give a massively inflated job > count. I would agree that Go wasn't the best idea for a language name from the search perspective. One would have though a company like Google would have been cognizant of those limitations... From nambo4jb at gmail.com Sun Jan 16 09:49:18 2011 From: nambo4jb at gmail.com (Cathy James) Date: Sun, 16 Jan 2011 08:49:18 -0600 Subject: Functions Not Fun (yet)-please help! Message-ID: Dear all, I can't thank you enough for taking time from your busy schedules to assist me (and others) in my baby steps with Python. Learning about functions now and wondering about some things commented in my code below. Maybe someone can break it down for me and show me why i cant print the function i created. I am using IDLE, saved it as .py def my_func(a, b="b is a default" ,c="c is another default"): print (a) print (b) print (c) #printing the function itself: #1. assign value to a only, b and c as default: a= "testing" print (my_func(a,b,c)) #why does program say c is not defined, tho default in function above? #2. assign a and b only, c is default print my_func(a="testing a", b="testing b") -------------- next part -------------- An HTML attachment was scrubbed... URL: From askutt at gmail.com Sun Jan 16 10:18:16 2011 From: askutt at gmail.com (Adam Skutt) Date: Sun, 16 Jan 2011 07:18:16 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> Message-ID: On Jan 14, 5:17?pm, Albert van der Horst wrote: > > I really don't follow that. You need a tremendous set to write gimp. > Obviously you won't write gimp in Python. > You need a tremendous set to write /the majority of the applications on your computer/. On my desktop right now, I have running: * Google Chrome * TweetDeck * PuTTY * Pidgin * Game for Windows Launcher * Free Download Manager * Steam Client * A Windows Control Panel Window None of those applications could be written with his proposed widget set, he's literally 0/7 on running applications. If the situation isn't the same on your computer then your application usage is highly unusual or you don't understand what widgets are used to construct your applications. You've just told me that Python would no longer be suitable for constructing the majority of GUI applications on the planet. > Now you want to jot together three cooperating screens to specify > some properties for say bluetooth. The proposed set is ample for > that, no? Yes, but why would I ever do such a thing? Such things are provided for me by the operating system already, pretty much regardless of platform. His widget set is quite truly only good for OS utilities, but I already have those. I generally don't need nor want more of them. Neither do Python users, because the majority of us aren't writing OS utilities. That leaves the logical equivalent of traditional terrible, awful Visual Basic applications left, and even Microsoft gives them a full widget set (and "real" programming language) now in VB.NET. The effort involved in segmentation doesn't make things any easier and doesn't save them, the library authors, much of anything. > Such things make up a substantial part of the applications > as far as numbers is concerned. They are probably written by > people who don't want to dive very deeply into GUI. > (Maybe they are more bluetooth experts than GUI-experts, what > would you say?) > I could list every application on the my computer and make a table of which ones would be workable given the list above, but I can already tell you that the answer is, "Not very many, and most of the ones that can were written by MS". And I'm entirely ignoring issues like theming as well. Adding a few additional layout controls would expand the list a moderate deal, but that's going to be true pretty much regardless of which 3 or 4 additional widgets you pick. And this ignores the obvious, "You'd still need a full WxWidgets install in order to build the minimized set, so all you've saved is a few .py files" part of the argument, which is just as compelling, if not more so. Really, if you believe the case to be otherwise, I truly believe you aren't paying attention to your own computer(s), or don't understand how the applications you use are constructed. What's out there isn't interesting, it's what people use that's interesting, and people tend to use GUIs that are moderately to highly complicated. Adam From emile at fenx.com Sun Jan 16 10:24:14 2011 From: emile at fenx.com (Emile van Sebille) Date: Sun, 16 Jan 2011 07:24:14 -0800 Subject: Functions Not Fun (yet)-please help! In-Reply-To: References: Message-ID: On 1/16/2011 6:49 AM Cathy James said... > Dear all, > > I can't thank you enough for taking time from your busy schedules to assist > me (and others) in my baby steps with Python. Learning about functions now > and wondering about some things commented in my code below. Maybe someone > can break it down for me and show me why i cant print the function i > created. I am using IDLE, saved it as .py > > def my_func(a, b="b is a default" ,c="c is another default"): > print (a) > print (b) > print (c) > > > #printing the function itself: > > #1. assign value to a only, b and c as default: > a= "testing" > print (my_func(a,b,c)) #why does program say c is not defined, tho default > in function above? Because c is not defined in the scope outside the function where you are passing the variables into my_func. To see the effect of the defaults, call with only 'a', as otherwise any variables you pass in must have been previously defined. >>> print (my_func(a)) testing b is a default c is another default None >>> Emile > #2. assign a and b only, c is default > print my_func(a="testing a", b="testing b") > > From david at boddie.org.uk Sun Jan 16 10:30:45 2011 From: david at boddie.org.uk (David Boddie) Date: Sun, 16 Jan 2011 16:30:45 +0100 Subject: After C++, what with Python? References: <5adf432d-2629-4717-8fe6-6d073d6de860@glegroupsg2000goo.googlegroups.com> Message-ID: On Sunday 16 January 2011 08:35, geremy condra wrote: > On Sat, Jan 15, 2011 at 9:30 PM, Aman wrote: >> It would be great if you people could guide me as to what to proceed with >> and how. > > Here's what I would do: [Snip advice] Maybe it would be good to expand the Getting Started material in the Python Wiki with your advice, Geremy. It would save you the trouble of having to type it all over again the next time a similar question is asked. David From jamuah at gmail.com Sun Jan 16 10:34:15 2011 From: jamuah at gmail.com (Moses) Date: Sun, 16 Jan 2011 17:34:15 +0200 Subject: [PYTHON] threading: Parallel processing Message-ID: Hi All, Is there is a way to print or use the value of new in the main function of the script below? from thread import start_new_thread, allocate_lock num_threads = 0 thread_started = False lock = allocate_lock() def heron(a): global num_threads, thread_started lock.acquire() num_threads += 1 thread_started = True lock.release() """Calculates the square root of a""" eps = 0.0000001 old = 1 new = 1 while True: old,new = new, (new + a/new) / 2.0 print old, new if abs(new - old) < eps: break lock.acquire() num_threads -= 1 lock.release() return new start_new_thread(heron,(81,)) start_new_thread(heron,(999,)) start_new_thread(heron,(1733,)) while not thread_started: pass while num_threads > 0: pass Thanks, Moses. -------------- next part -------------- An HTML attachment was scrubbed... URL: From rantingrick at gmail.com Sun Jan 16 11:30:06 2011 From: rantingrick at gmail.com (rantingrick) Date: Sun, 16 Jan 2011 08:30:06 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> Message-ID: On Jan 16, 9:18?am, Adam Skutt wrote: > You need a tremendous set to write /the majority of the applications > on your computer/. [...snip incessant rambling...] Adam your post is so incoherent that i cannot decide if you are FOR or AGAINST changing the current Tkinter GUI module into a wxPython GUI module. And this widget set that you keep referring to is a bit vague also. So i will quote myself because i *think* this may be what "it" referres to... ####################### # Start Quote by Rick # ####################### Exactly! All we need to do is replace the existing Tkinter with a small sub-set of wxPython widgets that mirrors exactly what we have now... Toplevel Label Entry Button Radiobutton Checkbutton Canvas Textbox Listbox Menu Scale Scrollbar ...thats all you need in the std library "widget wise". ##################### # End Quote by Rick # ##################### If you cannot relize that this is exactly what we have now in Tkinter then you need to go and read the source for Tkinter. Oh hell, i'd better do it for you. Watch this... >>> f = open('C:\\Python26\\Lib\\lib-tk\\Tkinter.py') >>> s = f.read() >>> f.close() >>> import re >>> re.findall(r'class (\w+)\(', s) ['StringVar', 'IntVar', 'DoubleVar', 'BooleanVar', 'Tk', 'BaseWidget', 'Widget', 'Toplevel', 'Button', 'Canvas', 'Checkbutton', 'Entry', 'Frame', 'Label', 'Listbox', 'Menu', 'Menubutton', 'Message', 'Radiobutton', 'Scale', 'Scrollbar', 'Text', 'OptionMenu', 'PhotoImage', 'BitmapImage', 'Spinbox', 'LabelFrame', 'PanedWindow', 'Studbutton', 'Tributton'] Now what seems to be missing from my proposed widget set that hampers you from re-creating every GUI app on your computer? And just in case you did not notice "my proposed wxPython module" includes the exact same widget set. Ok, Ok, i let out image support but in my mind PIL should handle all of that. The IntVar, StringVar, and BooleanVar classes are non-applicable in a wx GUI. So just for your sake i shall "lower the bar of comprehension"... >>> tkclasses = re.findall(r'class (\w+)\(', s) >>> omit = ['StringVar', 'IntVar', 'DoubleVar', 'BooleanVar', 'Tk', 'BaseWidget', 'Widget', 'Frame', 'Message', 'OptionMenu', 'LabelFrame', 'PanedWindow', 'Studbutton', 'Tributton'] >>> [x for x in tkclasses if x not in omit] ['Toplevel', 'Button', 'Canvas', 'Checkbutton', 'Entry', 'Label', 'Listbox', 'Menu', 'Menubutton', 'Radiobutton', 'Scale', 'Scrollbar', 'Text', 'PhotoImage', 'BitmapImage', 'Spinbox'] There you have it. The same exact widget set we have now. Sure you cannot re-create every GUI app on your stinking computer however if you download the 3rd party wxPython extension module not only will you be able to re-create every GUI app on your stinking computer it will wipe your backside too! (psst: "it" refers to wxPython) i hope you learned something from this exercise Adam. From rantingrick at gmail.com Sun Jan 16 12:08:08 2011 From: rantingrick at gmail.com (rantingrick) Date: Sun, 16 Jan 2011 09:08:08 -0800 (PST) Subject: Developing a program to make a family tree. References: <317f6ed0-ebd9-4a58-9ad3-da57563193ad@w29g2000vba.googlegroups.com> Message-ID: <8d37c88b-5695-49a5-a3d1-ce5ad60ac724@w2g2000yqb.googlegroups.com> On Jan 15, 3:43?pm, Michael Hunter wrote: > I think you are probably coming at this from the wrong direction. > Either you want to solve your family tree problem in the easiest way > possible in which case there are already packages available or you > want to develop this because you want to do the project to learn > (more) python, etc. ?Assuming the later the fact you have to ask the > question in the way you did means you are short on software design > experience and don't know much about the problem domain (genealogy). > Additionally you probably havn't written much code although you came > here so you probably have a little experience. ?That is triple death. > You need to hold a couple of those variables stable. ?I'd suggest > finding a existing open source genealogy program and use bug fixing as > a way to learn basics about the package and then try to add a feature > as a way of learning something about software design. While i mostly agree with this statement i must also whole-heart-ly disagree. I have many projects that i am currently "developing" that are far beyond my skill set at this time. However this "lack of experience" within the problem domain does not scare me away. Actually i want to learn how many things work "under the hood". So what i do is develop and design until i hit a wall. Then i move over to another project and develop and design until i hit another wall. Sometimes i have to go back and re-write the hole thing, but hey, its part of the learning curve. And in the process something interesting always happens... I find that solving one problem lends knowledge and insight into another completely different problem. This technique may not be for the weak of heart but it works well for me. I like a challenge. I also like to learn. So this drives me to keep going. I can tell you that i have written code i previously thought was impossible for me to create. Nothing is impossible if you want it bad enough or if you can manage to live long enough! :). Sadly even if your thirst for knowledge is unquenchable, your life will be quenched in due time :(. But i do not want to image a world where we all live forever, what a nightmare! From kw at codebykevin.com Sun Jan 16 12:39:41 2011 From: kw at codebykevin.com (Kevin Walzer) Date: Sun, 16 Jan 2011 12:39:41 -0500 Subject: Tkinter: The good, the bad, and the ugly! In-Reply-To: References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> Message-ID: <79a8a$4d332d1a$4275d90a$3986@FUSE.NET> On 1/16/11 11:30 AM, rantingrick wrote: > > ####################### > # Start Quote by Rick # > ####################### > Exactly! All we need to do is replace the existing Tkinter with a > small sub-set of wxPython widgets that mirrors exactly what we have > now... > Toplevel > Label > Entry > Button > Radiobutton > Checkbutton > Canvas > Textbox > Listbox > Menu > Scale > Scrollbar > ...thats all you need in the std library "widget wise". Rick, So, after all this discussion, your idea (it's not quite a proposal since you haven't initiated the PEP process for it) boils down to replacing Tkinter in the stdlib with a very stripped-down subset of wxPython? I'm not quite clear on what this accomplishes. Some of these widgets in Tkinter are ugly, but they have themed (ttk) equivalents (such as label, entry, button) that wrap native widgets in a manner similar to wxPython. So there's no real advantage to wx here. Your suggestion that developers who want a larger widget set can download the entire wxPython package is, again, answered by the observation that numerous Tk extensions, with Tkinter wrappers, exist to expand the standard Tk widget set. And there are pure-Python extension packages that are not dependent on binary Tk extensions, cf. Python Megawidgets. Again, no real advantage to wxPython. Your initial criticism that Python's standard GUI toolkit should not dependent on the priorities and development schedule of an outside project (Tcl/Tk) seems to have gone by the wayside here, because wxPython is an outside project (led by Robin Dunn) that is in turn dependent on the timeline of yet another outside project--wxWidgets, the underlying C++ library. Finally, there are licensing issues to consider. Tcl/Tk's license is very liberal, BSD-style, and it is quite similar to Python's. wxWidget's library is basically LGPL with a couple of exceptions to make it friendlier to proprietary software. Could code under such a license be gracefully included in the stlib? --Kevin -- Kevin Walzer Code by Kevin http://www.codebykevin.com From tjreedy at udel.edu Sun Jan 16 12:58:49 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Sun, 16 Jan 2011 12:58:49 -0500 Subject: [python-committers] [RELEASED] Python 3.2 rc 1 In-Reply-To: <20110116091056.7d78cca8@dino> References: <4D329F55.9040903@python.org> <20110116091056.7d78cca8@dino> Message-ID: On 1/16/2011 4:10 AM, Mark Summerfield wrote: > Regarding http://docs.python.org/dev/whatsnew/3.2.html > > - in the first argparse example the comment says "one of four allowed > values", but the choices list has only three items so I wonder if this > is correct? > > - in the coverage of PEP 3333 code points are written as u0000 and u00FF > which is non-standard; one standard way to write them is U+0000 and > U+00FF Both fixed. > I love the clickable table of built-in functions in functions.html. I do too. > On debian testing 64-bit make test resulted in: > ... > However, I hit a problem with relative imports not working (compared > with 3.1). I have to go now but will try to produce a small example if I > can. -- Terry Jan Reedy From tjreedy at udel.edu Sun Jan 16 13:17:35 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Sun, 16 Jan 2011 13:17:35 -0500 Subject: Issue 1602, cp65001, powershell and python3 crash In-Reply-To: <04f85ff6-7ece-4397-b0f8-e8b4127a3641@s9g2000vby.googlegroups.com> References: <04f85ff6-7ece-4397-b0f8-e8b4127a3641@s9g2000vby.googlegroups.com> Message-ID: On 1/16/2011 4:22 AM, jmfauth wrote: > After having read the discussion about the issue 1602, > http://bugs.python.org/issue1602, I came to the idea > to test Python with the PowerShell. I thought, it > could help and manage "unicode" better than the > std "dosbox" does > > My experience with PowerShell is closed to zero, so > take the following as a flat raw information. > > 1) Setup the coding in PowerShell (font: Consolas) > > PS D:\jm> $OutputEncoding > > > IsSingleByte : True > BodyName : us-ascii > EncodingName : US-ASCII > HeaderName : us-ascii > WebName : us-ascii > WindowsCodePage : 1252 > IsBrowserDisplay : False > IsBrowserSave : False > IsMailNewsDisplay : True > IsMailNewsSave : True > EncoderFallback : System.Text.EncoderReplacementFallback > DecoderFallback : System.Text.DecoderReplacementFallback > IsReadOnly : True > CodePage : 20127 > > PS D:\jm> chcp 65001 > Page de codes active : 65001 > > PS D:\jm> $OutputEncoding = [Console]::OutputEncoding > PS D:\jm> $OutputEncoding > > > BodyName : utf-8 > EncodingName : Unicode (UTF-8) > HeaderName : utf-8 > WebName : utf-8 > WindowsCodePage : 1200 > IsBrowserDisplay : True > IsBrowserSave : True > IsMailNewsDisplay : True > IsMailNewsSave : True > IsSingleByte : False > EncoderFallback : System.Text.EncoderReplacementFallback > DecoderFallback : System.Text.DecoderReplacementFallback > IsReadOnly : True > CodePage : 65001 > > > So far, so good. It seems I can enter and display "unicode > characters" (as opposed to cp850). > > PS D:\jm> echo 'abc?????' > abc????? > PS D:\jm> chcp > Page de codes active : 65001 > PS D:\jm> > > 2) Python test > > PS D:\jm> c:\python31\python.exe > Fatal Python error: Py_Initialize: can't initialize sys standard > streams > LookupError: unknown encoding: cp65001 > > This application has requested the Runtime to terminate it in an > unusual way. > Please contact the application's support team for more information. > PS D:\jm> > > Obviously and expectedly Python does not recognize cp65001. > That's not the problem. > > The main concern is, Python crashes with the usual msgbox, > "python.exe has stopped working ..." . > > win7 pro (32 bits), Swiss French setup, cp850/cp1252, Python 3.1.2 . > > Take this a raw information and do not ask me what's happen > behind the scene. > > Last minute info: > Python 3.2.rc1: same behaviour. Could you add this report, slightly condensed, to the issue? -- Terry Jan Reedy From rantingrick at gmail.com Sun Jan 16 13:27:01 2011 From: rantingrick at gmail.com (rantingrick) Date: Sun, 16 Jan 2011 10:27:01 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <79a8a$4d332d1a$4275d90a$3986@FUSE.NET> Message-ID: On Jan 16, 11:39?am, Kevin Walzer wrote: First of all welcome back to the discussion Kevin. You and i both appreciate and use Tkinter extensively and your input is most welcome here. You are a smart and level headed fella which makes for good discussion. Thanks for that! Ok, let the battle begin! :-) > So, after all this discussion, your idea (it's not quite a proposal > since you haven't initiated the PEP process for it) ?boils down to > replacing Tkinter in the stdlib with a very stripped-down subset of > wxPython? Exactly (almost). However I need to stress that nothing will be lost to the user when this change happens! On the contrary, much will be gained. You're going to have the same basic capabilities as you have now in the stdlib with Tkinter HOWEVER, you can download all the feature rich goodies that only wx can offer. > I'm not quite clear on what this accomplishes. Some of these widgets in > Tkinter are ugly, but they have themed (ttk) equivalents (such as label, > entry, button) that wrap native widgets in a manner similar to wxPython. > So there's no real advantage to wx here. This statement is uninformed Kevin. Wx needs no themed widgets because the default widgets where created equal from day one. TclTk has always been behind in look and feel. Yes we do now FINALLY have themed widgets however this does not make TclTk equal to wxPython in any shape or form. Kevin i ask that you and everyone else who may be interested in this community to download the wxPython demo. This demo (which is a work of art in it's own right!) will be all you need to understand the vast differences between TclTk and wxPython. You can get it here... http://www.wxpython.org/download.php#stable If for some reason you cannot download this beautiful demo, then at least look at the awesome screen shots here... http://www.wxpython.org/screenshots.php > Your suggestion that developers who want a larger widget set can > download the entire wxPython package is, again, answered by the > observation that numerous Tk extensions, with Tkinter wrappers, exist to > expand the standard Tk widget set. And there are pure-Python extension > packages that are not dependent on binary Tk extensions, cf. Python > Megawidgets. Again, no real advantage to wxPython. Wrong. Even with the hodgepodge of third party downloads and extension packages Tkinter cannot hold a candle to the professional quality of wxPython. Again i urge you to at least download the demo and see for yourself. WxPython is a massive library of almost any widget you can imagine using in the 21st century. All of the hard work has been done for you, no need to create your own custom widgets again and again. Do yourself a favor and download the demo. Here it is again... http://www.wxpython.org/download.php#stable > Your initial criticism that Python's standard GUI toolkit should not > dependent on the priorities and development schedule of an outside > project (Tcl/Tk) seems to have gone by the wayside here, because > wxPython is an outside project (led by Robin Dunn) that is in turn > dependent on the timeline of yet another outside project--wxWidgets, the > underlying C++ library. Yes, we will always be at the mercy of another development community unless we build a real Python GUI. Well newsflash, that dream is not going to happen because we would need to re-invent the wheel many times over and not to mention the long bug fix time-line. However let's get back to reality and compare wxPython to TclTk+Tkinter. First of all wxPython IS a part of the Python community. They DO care about Python and Python only. Yes WxWidgets IS NOT part of our community, however the widget set is so mature that we don't need to worry about version releases. We could live off the current widget set unchanged for many years to come!! Compare that to TclTk who only cares about TclTk and the fact that TclTk is not ANYWHERE near the maturity of wxPython. With Tkinter we WILL need to update as new widgets and functionality come into being. Oh did i forget to give you a link to the beautiful wxDemo, ok here it is... http://www.wxpython.org/download.php#stable > Finally, there are licensing issues to consider. Tcl/Tk's license is > very liberal, BSD-style, and it is quite similar to Python's. wxWidget's > library is basically LGPL with a couple of exceptions to make it > friendlier to proprietary software. Could code under such a license be > gracefully included in the stlib? Well we need the license lawyers to weigh in on that aspect. If wxPythons license is weighed and found wanting then we must consider something else. However, i will tell you that nothing else exists that can match the maturity, cross-platform, and feature rich-ness of wx. If someone knows of any such package by all means speak up! In any event, the time to start looking for something more appropriate to this community in the 21st century has long passed. We have allowed Tkinter to rot and grow pungent for the sake of people's "feelings". Yes, big changes alike this are going to piss off a few folks because it is human nature to fear change. However i must stress that as Python 3000 was a difficult --but very necessary change-- so too will the ushering of a new GUI kit be. But in the the end, we will be a better community and language for it. But we must start the transformation now, because transformations take such a looong time! We have dragged our collective feet long enough! From tjreedy at udel.edu Sun Jan 16 13:49:24 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Sun, 16 Jan 2011 13:49:24 -0500 Subject: Tkinter: The good, the bad, and the ugly! In-Reply-To: References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> Message-ID: On 1/16/2011 11:30 AM, rantingrick wrote: > Toplevel > Label > Entry > Button > Radiobutton > Checkbutton > Canvas > Textbox > Listbox > Menu > Scale > Scrollbar > ...thats all you need in the std library "widget wise". Once IDLE is revised to use some of the widgets in ttk that are not in tk (such as Notebook) the set would need expansion. But the details of any such set are irrelevant to the main problems of replacement. -- Terry Jan Reedy From kw at codebykevin.com Sun Jan 16 13:59:19 2011 From: kw at codebykevin.com (Kevin Walzer) Date: Sun, 16 Jan 2011 13:59:19 -0500 Subject: Tkinter: The good, the bad, and the ugly! In-Reply-To: References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <79a8a$4d332d1a$4275d90a$3986@FUSE.NET> Message-ID: <552a7$4d334005$4275d90a$11458@FUSE.NET> On 1/16/11 1:27 PM, rantingrick wrote: > On Jan 16, 11:39 am, Kevin Walzer wrote: > > First of all welcome back to the discussion Kevin. You and i both > appreciate and use Tkinter extensively and your input is most welcome > here. You are a smart and level headed fella which makes for good > discussion. Thanks for that! Ok, let the battle begin! :-) Glad to be back. > > Wrong. Even with the hodgepodge of third party downloads and extension > packages Tkinter cannot hold a candle to the professional quality of > wxPython. Again i urge you to at least download the demo and see for > yourself. WxPython is a massive library of almost any widget you can > imagine using in the 21st century. All of the hard work has been done > for you, no need to create your own custom widgets again and again. Do > yourself a favor and download the demo. Here it is again... I'm quite familiar with the wxPython demo. I've got the latest incarnation, from 2.9.x, installed on my machine. The latest version is quite nice, especially with the AUI widgets, and the underlying wxWidgets libraries are finally up-to-date on my Mac as they access the Cocoa frameworks, rather than the deprecated Carbon frameworks. However, wxPython does lack some things on my Mac, which I have been able to implement in Tk. Specifically: 1. My Tkinter apps can access the Mac's Services menu, which provides a form of inter-application communication that allows one application to send data to another and have the target application perform some manipulation of that data. wxPython does not support this feature of the Mac. 2. Any wxPython application that attempts to display the filesystem on the Mac looks out-of-place because wx has no support for displaying native icons on the Mac, though it can display them in Windows. Tk on the Mac has a few different ways of displaying icons natively. 3. wxPython applications do not make use of common window flags on the Mac, such as sheets and drawers. Tk provides native support for some of this, and extension packages provide further support. So: while wxPython is quite capable of creating handsome applications, even on the Mac, there are subtle things about wxPython applications that make them feel not quite native, regardless of how rich the overall widget set is. Part of my preference for Tkinter is that, under the hood, Tk is much, much easier to extend than wxWidgets. I have written several libraries in Objective-C, using Tk's C API, that hook into various aspects of native Mac functionality, such as the Services menu. Once this functionality is accessible from Tk, it's trivial to write a Python wrapper for it; it's often as easy as 'root.tk.call', 'nativetclcode here'. As I understand it, extending wxWidgets requires coding in C++, and then you'd need to run your code through SWIG in some fashion to be able to access it from wxPython. In short, there are several more steps, and it's likely more complicated at each step. For various reasons, the things I think are missing from wxWidgets (native icons, sheets/drawers, etc.) are not considered important by the core wxWidget developers, or implementing them is a low priority. > Well we need the license lawyers to weigh in on that aspect. If > wxPythons license is weighed and found wanting then we must consider > something else. However, i will tell you that nothing else exists that > can match the maturity, cross-platform, and feature rich-ness of wx. > If someone knows of any such package by all means speak up! Well, PyQt comes to mind. Qt is better at native Mac implementation than wx in many respects (window flags, accessing native Mac icons), and overall it is a richer framework (its support for WebKit is amazing), but PyQt remains licensed under the GPL, which makes it off-limits for the stdlib. Plus, there are other Python-Qt implementations out there (PySide) that may claim some of PyQt's mindshare in the future. --Kevin -- Kevin Walzer Code by Kevin http://www.codebykevin.com From tomf.sessile at gmail.com Sun Jan 16 14:05:37 2011 From: tomf.sessile at gmail.com (TomF) Date: Sun, 16 Jan 2011 11:05:37 -0800 Subject: examples of realistic multiprocessing usage? Message-ID: <2011011611053732597-tomfsessile@gmailcom> I'm trying to multiprocess my python code to take advantage of multiple cores. I've read the module docs for threading and multiprocessing, and I've done some web searches. All the examples I've found are too simple: the processes take simple inputs and compute a simple value. My problem involves lots of processes, complex data structures, and potentially lots of results. It doesn't map cleanly into a Queue, Pool, Manager or Listener/Client example from the python docs. Instead of explaining my problem and asking for design suggestions, I'll ask: is there a compendium of realistic Python multiprocessing examples somewhere? Or an open source project to look at? Thanks, -Tom From rantingrick at gmail.com Sun Jan 16 14:17:02 2011 From: rantingrick at gmail.com (rantingrick) Date: Sun, 16 Jan 2011 11:17:02 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> Message-ID: <00a62b5b-c1f8-4c54-b416-7f86c0b0ed24@m13g2000yqb.googlegroups.com> On Jan 16, 12:49?pm, Terry Reedy wrote: > Once IDLE is revised to use some of the widgets in ttk that are not in > tk (such as Notebook) the set would need expansion. The IDLE library has had a NoteBook widget for ages. They just choose to call it TabPages instead. And what is a NoteBook exactly? Well a Notebook is a compound widget consisting of a "main frame that holds two sub frames -- which are a "tab" frame and "pages" frame. When any "tab" is clicked the page it is linked to is either *raised-to-the-top- of-the-stack* OR *made-visible* depending on the design. Each "tab" within the "tab frame" is a Radiobutton. Technically you could even consider a RadioButton as a compound widget consisting of a button and a label widget. And one could even dissect further the components of any such widget however we must stop at some point. The widgets i outlined are the highest of the lowest you'd want to consider. I believe compound widgets have no business in the stdlib. When Guido included Tkinter in the stdlib it was mainly for ease of introductory GUI programming to the uninitiaed and for batteries included. However since we do have a "batteries included" mantra we will need to hash out which compound widgets should be included in the stdlib -- at a later time! At this time the discussion needs to focus on defending OR replacing Tkinter with something better. And my position is that we cannot keep lugging around this ancient TclTk library. > But the details of > any such set are irrelevant to the main problems of replacement. Not exactly. Once a library has been chosen we will need to consider a small subset for inclusion in the stdlib and ONE large extension library. So these problems are very relevant -- albeit out of chronological order. From awilliam at whitemice.org Sun Jan 16 14:25:18 2011 From: awilliam at whitemice.org (Adam Tauno Williams) Date: Sun, 16 Jan 2011 14:25:18 -0500 Subject: examples of realistic multiprocessing usage? In-Reply-To: <2011011611053732597-tomfsessile@gmailcom> References: <2011011611053732597-tomfsessile@gmailcom> Message-ID: <1295205918.10561.7.camel@linux-yu4c.site> > Instead of explaining my problem and asking for design suggestions, > I'll ask: is there a compendium of realistic Python multiprocessing > examples somewhere? Not that I've ever seen. > Or an open source project to look at? OpenGroupware Coils uses multiprocessing [in conjunction with AMQ]. From rantingrick at gmail.com Sun Jan 16 14:44:25 2011 From: rantingrick at gmail.com (rantingrick) Date: Sun, 16 Jan 2011 11:44:25 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <79a8a$4d332d1a$4275d90a$3986@FUSE.NET> <552a7$4d334005$4275d90a$11458@FUSE.NET> Message-ID: On Jan 16, 12:59?pm, Kevin Walzer wrote: > I'm quite familiar with the wxPython demo. I've got the latest > incarnation, from 2.9.x, installed on my machine. The latest version is > quite nice, especially with the AUI widgets, and the underlying > wxWidgets libraries are finally up-to-date on my Mac as they access the > Cocoa frameworks, rather than the deprecated Carbon frameworks. Glad to hear that! :) > However, wxPython does lack some things on my Mac, which I have been > able to implement in Tk. Specifically: > > 1. My Tkinter apps can access the Mac's Services menu, which provides a > form of inter-application communication that allows one application to > send data to another and have the target application perform some > manipulation of that data. wxPython does not support this feature of the > Mac. Ok so you're complaining about a "Mac specific" missing functionality? > 2. Any wxPython application that attempts to display the filesystem on > the Mac looks out-of-place because wx has no support for displaying > native icons on the Mac, though it can display them in Windows. ?Tk on > the Mac has a few different ways of displaying icons natively. Ok, even if it looks "out of place" this is another "Mac Specific" problem. > 3. wxPython applications do not make use of common window flags on the > Mac, such as sheets and drawers. Tk provides native support for some of > this, and extension packages provide further support. "Mac Specific" > So: while wxPython is quite capable of creating handsome applications, > even on the Mac, there are subtle things about wxPython applications > that make them feel not quite native, regardless of how rich the overall > widget set is. I think the moral of this story is simple. Mac decided to implement an OS that is completely different from the others. Also as you well know Macs are at the bottom of the stack in terms of popularity. Windows, Unix, Linix, Mac, in that order. Sure you "may" have the most pretentious OS on the planet. However you must accept that with a small user community also comes an equally small developer community. And even if i give these "minor complaints" 100% merit you still only have 0.25% of the market you are representing, so you lose the argument in a big way. Your complaints are but a drop in the proverbial bucket. But don't fret my friend with wxPython in the stdlib i'll bet you could persuade or even help to bring Mac support for these "small" annoyances. > As I understand it, extending wxWidgets requires coding in C++, and then > you'd need to run your code through SWIG in some fashion to be able to > access it from wxPython. In short, there are several more steps, and > it's likely more complicated at each step. ?For various reasons, the > things I think are missing from wxWidgets (native icons, sheets/drawers, > etc.) are not considered important by the core wxWidget developers, or > implementing them is a low priority. Well this is something that you need to attack at the source Kevin. Specifically i mean for you to join the WxWidgets group and start a grassroots movement for better mac support. Barking about a few small "annoyances" with an OS that has a "last ranked" standing is a bit bombastic to say the least. Yes? > Well, PyQt comes to mind. Qt is better at native Mac implementation than > wx in many respects (window flags, accessing native Mac icons), and > overall it is a richer framework (its support for WebKit is amazing), > but PyQt remains licensed under the GPL, which makes it off-limits for > the stdlib. Plus, there are other Python-Qt implementations out there > (PySide) that may claim some of PyQt's mindshare in the future. I am willing to support any GUI library that will move us forward and TclTk is dead weight. I like the feature rich nature of wx however i will consider others if a "compelling" argument is put forward. From joe at goldthwaites.com Sun Jan 16 14:51:04 2011 From: joe at goldthwaites.com (Joe Goldthwaite) Date: Sun, 16 Jan 2011 12:51:04 -0700 Subject: Functions Not Fun (yet)-please help! In-Reply-To: References: Message-ID: <67EB215872114010A58F81DEF27776EB@NewMBP> Hi Kathy, The defaults only get assigned when you leave them out of the list. This will work the way you want by setting b & c to the defaults. print my_func(a) When you try this; a = "testing" b = "defaults" print my_func(a, b, c) You get an undefined error on c. This is because at this point, c has been created but hasn't had anything assigned to it. In other words, you're actually passing the undefined c variable from here into my_func. _____ From: python-list-bounces+joe=goldthwaites.com at python.org [mailto:python-list-bounces+joe=goldthwaites.com at python.org] On Behalf Of Cathy James Sent: Sunday, January 16, 2011 7:49 AM To: python-list at python.org Subject: Functions Not Fun (yet)-please help! Dear all, I can't thank you enough for taking time from your busy schedules to assist me (and others) in my baby steps with Python. Learning about functions now and wondering about some things commented in my code below. Maybe someone can break it down for me and show me why i cant print the function i created. I am using IDLE, saved it as .py def my_func(a, b="b is a default" ,c="c is another default"): print (a) print (b) print (c) #printing the function itself: #1. assign value to a only, b and c as default: a= "testing" print (my_func(a,b,c)) #why does program say c is not defined, tho default in function above? #2. assign a and b only, c is default print my_func(a="testing a", b="testing b") -------------- next part -------------- An HTML attachment was scrubbed... URL: From azeynel1 at gmail.com Sun Jan 16 14:59:11 2011 From: azeynel1 at gmail.com (Zeynel) Date: Sun, 16 Jan 2011 11:59:11 -0800 (PST) Subject: Not clear about the dot notation Message-ID: <2d3e986b-6e6a-477f-a4ba-fe091ff72b8f@i41g2000vbn.googlegroups.com> What does vote.vote refer to in this snippet? def txn(): quote = Quote.get_by_id(quote_id) vote = Vote.get_by_key_name(key_names = user.email(), parent = quote) if vote is None: vote = Vote(key_name = user.email(), parent = quote) if vote.vote == newvote: return quote.votesum = quote.votesum - vote.vote + newvote vote.vote = newvote from here: http://code.google.com/appengine/articles/overheard.html From tomf.sessile at gmail.com Sun Jan 16 15:24:40 2011 From: tomf.sessile at gmail.com (TomF) Date: Sun, 16 Jan 2011 12:24:40 -0800 Subject: Not clear about the dot notation References: <2d3e986b-6e6a-477f-a4ba-fe091ff72b8f@i41g2000vbn.googlegroups.com> Message-ID: <2011011612244047855-tomfsessile@gmailcom> On 2011-01-16 11:59:11 -0800, Zeynel said: > What does vote.vote refer to in this snippet? > > def txn(): > quote = Quote.get_by_id(quote_id) > vote = Vote.get_by_key_name(key_names = user.email(), parent = > quote) > if vote is None: > vote = Vote(key_name = user.email(), parent = quote) > if vote.vote == newvote: > return > quote.votesum = quote.votesum - vote.vote + newvote > vote.vote = newvote > > from here: http://code.google.com/appengine/articles/overheard.html vote refers to the Vote instance. vote.vote refers to the instance variable in that instance: ? ? ? vote: The value of 1 for like, -1 for dislike. Confusing choice of names, in my opinion. -Tom From ian.g.kelly at gmail.com Sun Jan 16 15:26:02 2011 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Sun, 16 Jan 2011 13:26:02 -0700 Subject: Not clear about the dot notation In-Reply-To: <2d3e986b-6e6a-477f-a4ba-fe091ff72b8f@i41g2000vbn.googlegroups.com> References: <2d3e986b-6e6a-477f-a4ba-fe091ff72b8f@i41g2000vbn.googlegroups.com> Message-ID: On 1/16/2011 12:59 PM, Zeynel wrote: > What does vote.vote refer to in this snippet? "vote" is an instance of the Vote class, and "vote.vote" is the value of the "vote" attribute on that instance. In this case, that will be an int. More precisely, "vote.vote" is a value managed by the "vote" descriptor on the "Vote" class, a Google App Engine IntegerProperty. Cheers, Ian From azeynel1 at gmail.com Sun Jan 16 15:44:35 2011 From: azeynel1 at gmail.com (Zeynel) Date: Sun, 16 Jan 2011 12:44:35 -0800 (PST) Subject: Not clear about the dot notation References: <2d3e986b-6e6a-477f-a4ba-fe091ff72b8f@i41g2000vbn.googlegroups.com> <2011011612244047855-tomfsessile@gmailcom> Message-ID: On Jan 16, 3:24?pm, TomF wrote: > vote refers to the Vote instance. So he must have instatiated previously like vote = Vote() is this correct? So I have a model class Item(db.Model): title = db.StringProperty() url = db.StringProperty() date = db.DateTimeProperty(auto_now_add=True) author = db.UserProperty() and to write to the database I do item = Item() item.title = self.request.get("title") item.url = self.request.get("url") item.author = users.get_current_user() item.put() self.redirect("/newest") so his vote.vote is like my item.url ? From philip at semanchuk.com Sun Jan 16 16:22:12 2011 From: philip at semanchuk.com (Philip Semanchuk) Date: Sun, 16 Jan 2011 16:22:12 -0500 Subject: examples of realistic multiprocessing usage? In-Reply-To: <2011011611053732597-tomfsessile@gmailcom> References: <2011011611053732597-tomfsessile@gmailcom> Message-ID: <590FF1A8-55C7-4058-A8C9-AB9CC8B3DFAB@semanchuk.com> On Jan 16, 2011, at 2:05 PM, TomF wrote: > I'm trying to multiprocess my python code to take advantage of multiple cores. I've read the module docs for threading and multiprocessing, and I've done some web searches. All the examples I've found are too simple: the processes take simple inputs and compute a simple value. My problem involves lots of processes, complex data structures, and potentially lots of results. It doesn't map cleanly into a Queue, Pool, Manager or Listener/Client example from the python docs. > > Instead of explaining my problem and asking for design suggestions, I'll ask: is there a compendium of realistic Python multiprocessing examples somewhere? Or an open source project to look at? A colleague pointed me to this project the other day. http://gluino.com/ I grepped through the code to see that it's using multiprocessing.Listener. I didn't go any further than that because our project is BSD licensed and the license for Gluino is unclear. Until I find out whether or not its under an equally permissive license, I can't borrow ideas and/or code from it. Hope it's of some help to you, though. Cheers Philip From tomf.sessile at gmail.com Sun Jan 16 16:34:57 2011 From: tomf.sessile at gmail.com (TomF) Date: Sun, 16 Jan 2011 13:34:57 -0800 Subject: Not clear about the dot notation References: <2d3e986b-6e6a-477f-a4ba-fe091ff72b8f@i41g2000vbn.googlegroups.com> <2011011612244047855-tomfsessile@gmailcom> Message-ID: <2011011613345783108-tomfsessile@gmailcom> On 2011-01-16 12:44:35 -0800, Zeynel said: > On Jan 16, 3:24?pm, TomF wrote: > >> vote refers to the Vote instance. > > So he must have instatiated previously like > > vote = Vote() > > is this correct? Yes. > > So I have a model > > class Item(db.Model): > title = db.StringProperty() > url = db.StringProperty() > date = db.DateTimeProperty(auto_now_add=True) > author = db.UserProperty() > > and to write to the database I do > > item = Item() > item.title = self.request.get("title") > item.url = self.request.get("url") > item.author = users.get_current_user() > item.put() > self.redirect("/newest") > > so his vote.vote is like my item.url ? I believe so. Though you're now talking about an extension to db.Model which looks like it's doing a lot more behind the scenes than a simple variable access. -Tom From rantingrick at gmail.com Sun Jan 16 17:57:36 2011 From: rantingrick at gmail.com (rantingrick) Date: Sun, 16 Jan 2011 14:57:36 -0800 (PST) Subject: Python like lanugages [was Re: After C++, what with Python?] References: <86a904f8-05b0-435f-81d6-7450650f1679@glegroupsg2000goo.googlegroups.com> <4d329899$0$43988$742ec2ed@news.sonic.net> <7x8vylfcvz.fsf@ruckus.brouhaha.com> <4d32c7cf$0$29983$c3e8da3$5496439d@news.astraweb.com> Message-ID: <14ad108e-93d7-41fc-bb42-065f12a062f2@s5g2000yqm.googlegroups.com> On Jan 16, 5:03?am, Tim Harig wrote: > Personally, I think the time is ripe for a language that bridges the > gap between ease of use dynamic languages with the performance and > distribution capabilities of a full systems level language. ? Bravo! > This is after > all the promise the VM based languages made but never really fulfilled. > It is also high time for a fully concurrent language fully capable of > taking advantage of multicore processors without having to deal with the > inherent dangers of threading. Bravissimo!!!!!! > There are several good choices available > for both a even a few that fit both bills; but, few of them have the > support of a company like Google that is capable of the push required > to move the language into the mainstream. Maybe. I have skimmed over Go and while it looks "somewhat" promising i always miss the batteries included and elegant syntax of Python. Of course the language is still young so i hope they plan to invest into it. From steve+comp.lang.python at pearwood.info Sun Jan 16 18:04:35 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 16 Jan 2011 23:04:35 GMT Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> Message-ID: <4d337983$0$29983$c3e8da3$5496439d@news.astraweb.com> On Sun, 16 Jan 2011 07:18:16 -0800, Adam Skutt wrote: [...] I'm afraid I found most of your post hard to interpret, because you didn't give sufficient context for me to understand it. You refer to "his proposed widget set", but with no clue as to who he is, or what the widget set is, or what essential widgets you continue missing. I can guess "he" is rantingrick, but am not sure -- there's only so much of his time-wasting I can read before reaching for the killfile. Rantingrick believes he is doing us a service by haranguing us incessantly into scratching *his* poorly thought-out itches, regardless of practicality or actual need. But putting that aside, I'd like to comment on a few points: [...] > If the situation isn't > the same on your computer then your application usage is highly unusual > or you don't understand what widgets are used to construct your > applications. You've just told me that Python would no longer be > suitable for constructing the majority of GUI applications on the > planet. No, that does not follow. Unless "he" (I'll assume it is rantingrick) has proposed hunting down and destroying all third-party GUI tool sets, what you've been told is that *one specific* tool set is unsuitable for constructing the majority of GUI apps. [...] > Really, if you believe the case to be otherwise, I truly believe you > aren't paying attention to your own computer(s), or don't understand how > the applications you use are constructed. What's out there isn't > interesting, it's what people use that's interesting, and people tend to > use GUIs that are moderately to highly complicated. Well, true, but people tend to *use* the parts of the GUIs that are simple and basic. Not only do the big complicated apps get all the press even when they are actually a niche product (everyone knows about Photoshop, but more people use MS Paint) but it's a truism that most people use something like 20% of the functionality of big, complicated GUI apps. Most people use Microsoft Word or OpenOffice for little more than text editing with formatting. It's easy for power users to overestimate how much of their complicated GUIs are actually used by the average user. Or even the *above* average user. I suspect that a variation of Zipf's Law probably holds for GUI complexity -- if you rank the widgets in order of most to least commonly used, I expect that you'll see actual use drop away rapidly and at an accelerated rate. E.g. the widget in second place might be used roughly half as often as the widget in first place place, the widget in third place one third as often, the widget in fourth place one quarter as often, and so forth. -- Steven From tjreedy at udel.edu Sun Jan 16 18:14:44 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Sun, 16 Jan 2011 18:14:44 -0500 Subject: Tkinter: The good, the bad, and the ugly! In-Reply-To: References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <79a8a$4d332d1a$4275d90a$3986@FUSE.NET> Message-ID: On 1/16/2011 1:27 PM, rantingrick wrote: > least look at the awesome screen shots here... > > http://www.wxpython.org/screenshots.php I did. Well, they say, "Beauty is in the eye of the beholder!". To me, these are mostly awesomely ugly, ugly, ugly. Shot 1: Ugly gray field followed by shot2: ugly black on gray. These first two examples look like Windows 95/8 -- ie, 20th century look, not 21st. Based on this page, wxwidgets would be a regression from tk. Current tkinter on Windows looks like it use native Windows windows. IDLE on WinXP looks like a WinXP app; on Windows 7 it looks like a Windows 7 app. If wxwidgets/wxpython does the same, this page hides it very well. And this is apparently an update from 'the old Screen shots' page. The above is based on presented looks. I have no idea whether, to what extent, and how easily one could duplicate the layout and performance of the examples with tk. There are, however, other problems with wx that I have and will point out in other posts. -- Terry Jan Reedy From askutt at gmail.com Sun Jan 16 18:16:51 2011 From: askutt at gmail.com (Adam Skutt) Date: Sun, 16 Jan 2011 15:16:51 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> Message-ID: On Jan 16, 11:30?am, rantingrick wrote: > Adam your post is so incoherent that i cannot decide if you are FOR or > AGAINST changing the current Tkinter GUI module into a wxPython GUI > module. And this widget set that you keep referring to is a bit vague > also. If you found my post incoherent then you shouldn't be attempting to respond, you should ask me to fucking clarify! Funny how when I ask you technical questions you refuse to respond, but when you find my post incoherent you find plenty of time to attempt to twist my words to support your own mental masturbation. > If you cannot relize that this is exactly what we have now in Tkinter > then you need to go and read the source for Tkinter. Oh hell, i'd > better do it for you. Watch this... As I already told you, if you think that what's contained only in TkInter is relevant or interesting, then you're hopelessly lost. In fact, you're outright trolling. Python's standard library don't only include TkInter so only talking about TkInter is entirely disingenuous. > Now what seems to be missing from my proposed widget set that hampers > you from re-creating every GUI app on your computer? Go download the applications and run them yourself! If you can't figure it out from a visual examination, you lack the competence to bring forward your proposal. Being able to identify what widgets are used to create an application is a fundamental, rudimentary skill. If you lack that skill, you're tacitly calling all of your credibility (not that you haven't already done a fine job of demolishing any assumed credibility on your part) into question. > Ok, Ok, i let out image support but in my mind PIL > should handle all of that. It fundamentally cannot. That's not how image rendering in native widgets works. > There you have it. The same exact widget set we have now. Sure you > cannot re-create every GUI app on your stinking computer however if > you download the 3rd party wxPython extension module not only will you > be able to re-create every GUI app on your stinking computer it will > wipe your backside too! (psst: "it" refers to wxPython) > Again, I've already responded to this in detail, in other postings, posted serious and detailed technical questions, and asked for your clarifications. So instead of posting the same tired, idiotic tripe, why don't you go find those postings, read them, and respond to them? Your refusal and/or inability to do so harms your position immensely. > i hope you learned something from this exercise Adam. I'm not the one who needs to learn anything. Adam From debatem1 at gmail.com Sun Jan 16 18:38:47 2011 From: debatem1 at gmail.com (geremy condra) Date: Sun, 16 Jan 2011 15:38:47 -0800 Subject: [OT] Python like lanugages [was Re: After C++, what with Python?] In-Reply-To: References: <86a904f8-05b0-435f-81d6-7450650f1679@glegroupsg2000goo.googlegroups.com> <4d329899$0$43988$742ec2ed@news.sonic.net> <7x8vylfcvz.fsf@ruckus.brouhaha.com> <4d32c7cf$0$29983$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Sun, Jan 16, 2011 at 3:03 AM, Tim Harig wrote: > On 2011-01-16, Steven D'Aprano wrote: >> If the author thinks that Go is a "tried and true" (his words, not mine) >> language "where programmers can go to look for work", I think he's >> fooling himself. > > No I wouldn't say that it has reached market penetration yet; but, it > has more momentum then any language I am familiar with. ?I wouldn't be > at all surprised to see it becoming quite common in the next five years. I would be very surprised if this were the case. As you point out, languages typically have very long incubation times before they reach any kind of serious market penetration. This seems doubly true for a relatively narrowly targeted language that is in many ways on the wrong side of history. > How long has it taken Python to reach its present level of market > penetration? ?And, I still don't see a huge amount of professional Python > use outside of web developement. ?Go has only been public for less then > a year. Python's very widely used for scripting and related tasks, and has a pretty big user base in academia and the sciences. > Personally, I think the time is ripe for a language that bridges the > gap between ease of use dynamic languages with the performance and > distribution capabilities of a full systems level language. I agree. That does not make Go that language, and many of the choices made during Go's development indicate that they don't think it's that language either. I'm speaking specifically of its non-object model, lack of exceptions, etc. >This is after all the promise the VM based languages made but never > really fulfilled. It is also high time for a fully concurrent language fully > capable of taking advantage of multicore processors without having to > deal with the inherent dangers of threading. ?There are several good > choices available for both a even a few that fit both bills; but, few of > them have the support of a company like Google that is capable of the > push required to move the language into the mainstream. You might be right, but I doubt we'll know one way or the other in the next 5 years. Personally, I'm hoping that functional language use continues to grow. Geremy Condra From kw at codebykevin.com Sun Jan 16 18:41:17 2011 From: kw at codebykevin.com (Kevin Walzer) Date: Sun, 16 Jan 2011 18:41:17 -0500 Subject: Tkinter: The good, the bad, and the ugly! In-Reply-To: References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <79a8a$4d332d1a$4275d90a$3986@FUSE.NET> <552a7$4d334005$4275d90a$11458@FUSE.NET> Message-ID: <7b37f$4d33821c$4275d90a$11538@FUSE.NET> On 1/16/11 2:44 PM, rantingrick wrote: > > Ok so you're complaining about a "Mac specific" missing functionality? Um, yes. > > Ok, even if it looks "out of place" this is another "Mac Specific" > problem. Yes, it sure does. "Mac-specific"=="important." > >> 3. wxPython applications do not make use of common window flags on the >> Mac, such as sheets and drawers. Tk provides native support for some of >> this, and extension packages provide further support. > > "Mac Specific" Ditto. > > > I think the moral of this story is simple. Mac decided to implement an > OS that is completely different from the others. Also as you well know > Macs are at the bottom of the stack in terms of popularity. Windows, > Unix, Linix, Mac, in that order. Sure you "may" have the most > pretentious OS on the planet. However you must accept that with a > small user community also comes an equally small developer community. > And even if i give these "minor complaints" 100% merit you still only > have 0.25% of the market you are representing, so you lose the > argument in a big way. Your complaints are but a drop in the > proverbial bucket. But don't fret my friend with wxPython in the > stdlib i'll bet you could persuade or even help to bring Mac support > for these "small" annoyances. Rick, your statements here are entirely untroubled by facts.:-) First of all, Mac OS X *is* Unix, at least according to The Open Group, which controls the UNIX trademark and is actually in charge of certifying an OS as valid UNIX. Next, in terms of market share, Apple's machines exceeded 10% of the U.S. market (placing them third in shipments behind HP and Dell), and run about 4-5% of the market globally. (See http://bit.ly/cqxl6L.) In any event, it's a bit more than 0.25%. (Actually, according to http://bit.ly/c4PBlm, Linux comes in at around 0.77%, while Mac OS X comes int around 5%.) > > Well this is something that you need to attack at the source Kevin. > Specifically i mean for you to join the WxWidgets group and start a > grassroots movement for better mac support. Barking about a few small > "annoyances" with an OS that has a "last ranked" standing is a bit > bombastic to say the least. Yes? I have commit rights to the Tk core, so it's much easier for me to submit bug fixes and patches there. It's not worth my while to do the same for wxWidgets. --Kevin -- Kevin Walzer Code by Kevin http://www.codebykevin.com From askutt at gmail.com Sun Jan 16 18:41:41 2011 From: askutt at gmail.com (Adam Skutt) Date: Sun, 16 Jan 2011 15:41:41 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <4d337983$0$29983$c3e8da3$5496439d@news.astraweb.com> Message-ID: <044a5101-948d-4458-9c94-57dbb3e25f67@m35g2000vbn.googlegroups.com> On Jan 16, 6:04?pm, Steven D'Aprano wrote: > > If the situation isn't > > the same on your computer then your application usage is highly unusual > > or you don't understand what widgets are used to construct your > > applications. ?You've just told me that Python would no longer be > > suitable for constructing the majority of GUI applications on the > > planet. > > No, that does not follow. Unless "he" (I'll assume it is rantingrick) has > proposed hunting down and destroying all third-party GUI tool sets, what > you've been told is that *one specific* tool set is unsuitable for > constructing the majority of GUI apps. > If you're going to expect me to be that pedantic, then pay me the courtesy of taking the time to find the necessary context. Nevertheless, it's not the least bit unreasonable to address deficiencies in the standard library as deficiencies in the language, like it or not; and since rick's proposal involves regressing the standard library.. > > Really, if you believe the case to be otherwise, I truly believe you > > aren't paying attention to your own computer(s), or don't understand how > > the applications you use are constructed. ?What's out there isn't > > interesting, it's what people use that's interesting, and people tend to > > use GUIs that are moderately to highly complicated. > > Well, true, but people tend to *use* the parts of the GUIs that are > simple and basic. Not only do the big complicated apps get all the press > even when they are actually a niche product (everyone knows about > Photoshop, but more people use MS Paint) but it's a truism that most > people use something like 20% of the functionality of big, complicated > GUI apps. Most people use Microsoft Word or OpenOffice for little more > than text editing with formatting. First, you can't even build MS Paint from Rick's set / the TkInter set alone, so you're already way off mark (even ignoring the ribbon in the latest versions). Second, relevance? If I cannot ship the application with only 20% of the functionality, then your point is meaningless. Plus, look at my list more closely: TweetDeck is really little more than a bunch of listboxes stuck side by side, but we cannot even construct that without replicating what would be considered standard widgets (mostlu layout widgets, but still, that's the hardest stuff to get right and therefore the most important stuff to include). It is not, from a GUI L&F perspective, "complicated". Yet, I still need quite a few widgets in order to assemble it and make it work. And many of those widgets need fairly rich functionality: buttons must support text and images, listboxes must support embedding more than text, text controls must support hyperlinks, the various layout panes must support scrollbars, sizing, and dynamic updates. > I suspect that a variation of Zipf's Law probably holds for GUI > complexity -- if you rank the widgets in order of most to least commonly > used, I expect that you'll see actual use drop away rapidly and at an > accelerated rate. E.g. the widget in second place might be used roughly > half as often as the widget in first place place, the widget in third > place one third as often, the widget in fourth place one quarter as > often, and so forth. Perhaps, but the drop off isn't relevant till we approach well over 30 widgets, at least, quite arguably more (since GUI toolkits include both things that are common, and things that absolutely suck to program, even if they're not used often). Adam From askutt at gmail.com Sun Jan 16 18:54:14 2011 From: askutt at gmail.com (Adam Skutt) Date: Sun, 16 Jan 2011 15:54:14 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <00a62b5b-c1f8-4c54-b416-7f86c0b0ed24@m13g2000yqb.googlegroups.com> Message-ID: On Jan 16, 2:17?pm, rantingrick wrote: > The IDLE library has had a NoteBook widget for ages. They just choose > to call it TabPages instead. And what is a NoteBook exactly? Well a > Notebook is a compound widget consisting of a "main frame that holds > two sub frames -- which are a "tab" frame and "pages" frame. When any > "tab" is clicked the page it is linked to is either *raised-to-the-top- > of-the-stack* OR *made-visible* depending on the design. Each "tab" > within the "tab frame" is a Radiobutton. You need an eye exam if you actually believe what you just wrote. TabLayouts are not just two frames and radiobuttons inside a bigger frame. To even say that is disingenuous and insulting to every human who's ever used one. > I believe compound widgets have no business in the stdlib. All widgets are compound widgets, ergo you believe no widgets should be in the stdlib. Adam From rantingrick at gmail.com Sun Jan 16 18:58:43 2011 From: rantingrick at gmail.com (rantingrick) Date: Sun, 16 Jan 2011 15:58:43 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <79a8a$4d332d1a$4275d90a$3986@FUSE.NET> Message-ID: <64976187-88ad-47c9-9bc6-c0712a657264@j32g2000yqc.googlegroups.com> On Jan 16, 5:14?pm, Terry Reedy wrote: > On 1/16/2011 1:27 PM, rantingrick wrote: > > > least look at the awesome screen shots here... > > > ? ? ?http://www.wxpython.org/screenshots.php > > I did. Well, they say, "Beauty is in the eye of the beholder!". To me, > these are mostly awesomely ugly, ugly, ugly. Shot 1: Ugly gray field > followed by shot2: ugly black on gray. These first two examples look > like Windows 95/8 -- ie, 20th century look, not 21st. Now hold on Terry because you are overreacting just a bit here. If you remember i had requested that everyone download the beautiful demo and only look at the screen shots as a last resort. It seems you went to the screenshots page and went home in a huff. However let's investigate the screen shots with a little more clarity shall we? ######### # Shot1 # ######### This shot shows the most minimal wx GUI, that is, a simple Toplevel window and nothing more. And if you took the time to read the captions above that said... "Here is a screen shot of the "minimal" wxPython application:"... and the screenshot below that said... "Okay, so it is very minimal, but it is small enough that the source should be understandable without somebody holding your hand... Take a peek."... you probably would not have jumped to such bombastic conclusions. ########## # Shot 2 # ########## This shot merely builds on shot one. Nothing fancy. They were not trying to woo you with the most fancy GUI coding available from shot one (psst: THAT IS WHAT THE DEMO IS FOR!). You must remember that screen shots are for inquisitive and possible future users. If you continue to follow along with the shots you'll see the complexity increase with each shot. It seems to me that "easy intoduction" was the focus of the screenshots not "selfish vanity" (psst: THAT IS WHAT THE DEMO IS FOR!) > Based on this page, wxwidgets would be a regression from tk. Yes one might come to that conclusion if they are as shallow as you seem to be behaving Terry. However i urge you to download the wxPython demo and then give me an honest opinion. but only AFTER you have spent at least one hour familiarizing yourself with all the feature richness of this great GUI library. Heck each widget has an overview page, a source code page, and a demo page all wrapped up into a nice GUI. No GUI in the world is this user friendly! Geesh! > Current > tkinter on Windows looks like it use native Windows windows. IDLE on > WinXP looks like a WinXP app; on Windows 7 it looks like a Windows 7 > app. If wxwidgets/wxpython does the same, this page hides it very well. > And this is apparently an update from 'the old Screen shots' page. I'll agree this screenshots page needs an update. However (like me) the wxPython folks probably put more time into the demo and thought that most people would at least download it before jumping to conclusions about the screenshots without sufficient data. Oh, did i give you the demo link. No? Well here it is again... http://www.wxpython.org/download.php#stable > The above is based on presented looks. I have no idea whether, to what > extent, and how easily one could duplicate the layout and performance of > the examples with tk. Tkinter and all of TclTk cannot hold a matchstick to WxPython in feature richness. Anyone who says otherwise is ill-informed! > There are, however, other problems with wx that I > have and will point out in other posts. Please elaborate, these are free and open forums as far as know...? From rantingrick at gmail.com Sun Jan 16 19:12:34 2011 From: rantingrick at gmail.com (rantingrick) Date: Sun, 16 Jan 2011 16:12:34 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> Message-ID: <2778bd04-c2c0-423a-9254-64c547b02fc8@m13g2000yqb.googlegroups.com> On Jan 16, 5:16?pm, Adam Skutt wrote: [...snip: emotionally nonsensical hyperbole...] Adam. Arguing with you is like masturbating with a cheese-grater... slightly amusing, but mostly painful. I don't have the energy to chase my tail like you do. From debatem1 at gmail.com Sun Jan 16 19:59:19 2011 From: debatem1 at gmail.com (geremy condra) Date: Sun, 16 Jan 2011 16:59:19 -0800 Subject: Tkinter: The good, the bad, and the ugly! In-Reply-To: <2778bd04-c2c0-423a-9254-64c547b02fc8@m13g2000yqb.googlegroups.com> References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <2778bd04-c2c0-423a-9254-64c547b02fc8@m13g2000yqb.googlegroups.com> Message-ID: On Sun, Jan 16, 2011 at 4:12 PM, rantingrick wrote: > > I don't have the energy to chase my tail like you do. Hahahahahahahaha. Troll. Geremy Condra From rantingrick at gmail.com Sun Jan 16 20:50:39 2011 From: rantingrick at gmail.com (rantingrick) Date: Sun, 16 Jan 2011 17:50:39 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <2778bd04-c2c0-423a-9254-64c547b02fc8@m13g2000yqb.googlegroups.com> Message-ID: <17eb1e05-d8b9-423c-bcc0-49a5651c4812@f35g2000vbl.googlegroups.com> On Jan 16, 6:59?pm, geremy condra wrote: > Hahahahahahahaha. Troll. Coming from someone who actually gives advice on how to troll more efficiently... now that is ironic! ################################################### # Geremy Condra From: I strongly dislike Python 3 # ################################################### Eh, 3 troll points out of 10. Bonus awarded for the gratuitous sexual reference, but the deductions for lack of finesse more than overcame it. Some suggestions for next time: * use proper punctuation- it lends your posts an air of seriousness. * use the weakest arguments presented- it infuriates those who support the position you're trolling from as well. * overly dramatic statements are a dead giveaway. Hmm. So i take it you are some sort of *expert* on the matter of trolling then? From askutt at gmail.com Sun Jan 16 20:57:17 2011 From: askutt at gmail.com (Adam Skutt) Date: Sun, 16 Jan 2011 17:57:17 -0800 (PST) Subject: examples of realistic multiprocessing usage? References: <2011011611053732597-tomfsessile@gmailcom> Message-ID: <70bc330a-63d7-4162-b21f-4b38257d6c5b@g26g2000vbz.googlegroups.com> On Jan 16, 2:05?pm, TomF wrote: > Instead of explaining my problem and asking for design suggestions, > I'll ask: is there a compendium of realistic Python multiprocessing > examples somewhere? ?Or an open source project to look at? There are tons, but without even a knowledge domain, it's difficult to recommend much of anything. Multiprocessing for I/O (e.g., web serving) tends to look different and be structured differently from multiprocessing for CPU-intensive tasking (e.g., digital signal processing), and both look different from things with specific requirements w.r.t latency (e.g., video game server, hard-real time applications) or other requirements. Even the level at which you parallel process can change things dramatically. Consider the simple case of matrix multiplication. I can make the multiplication itself parallel; or assuming I have multiple sets of matricies I want to multiply (common), I can make execute each multiplication in parallel. Both solutions look different, and a solution that uses both levels of parallelism frequently will look different still. Adam From debatem1 at gmail.com Sun Jan 16 20:59:17 2011 From: debatem1 at gmail.com (geremy condra) Date: Sun, 16 Jan 2011 17:59:17 -0800 Subject: Tkinter: The good, the bad, and the ugly! In-Reply-To: <17eb1e05-d8b9-423c-bcc0-49a5651c4812@f35g2000vbl.googlegroups.com> References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <2778bd04-c2c0-423a-9254-64c547b02fc8@m13g2000yqb.googlegroups.com> <17eb1e05-d8b9-423c-bcc0-49a5651c4812@f35g2000vbl.googlegroups.com> Message-ID: On Sun, Jan 16, 2011 at 5:50 PM, rantingrick wrote: > On Jan 16, 6:59?pm, geremy condra wrote: >> Hahahahahahahaha. Troll. > > > Coming from someone who actually gives advice on how to troll more > efficiently... now that is ironic! > > ################################################### > # Geremy Condra From: I strongly dislike Python 3 # > ################################################### > Eh, 3 troll points out of 10. Bonus awarded for the gratuitous sexual > reference, but the deductions for lack of finesse more than overcame > it. Some suggestions for next time: > ?* use proper punctuation- it lends your posts an air of > seriousness. > ?* use the weakest arguments presented- it infuriates those who > ? ?support the position you're trolling from as well. > ?* overly dramatic statements are a dead giveaway. > > Hmm. So i take it you are some sort of *expert* on the matter of > trolling then? I've read most of your threads, yes. Geremy Condra From drsalists at gmail.com Sun Jan 16 22:16:15 2011 From: drsalists at gmail.com (Dan Stromberg) Date: Sun, 16 Jan 2011 19:16:15 -0800 Subject: examples of realistic multiprocessing usage? In-Reply-To: <2011011611053732597-tomfsessile@gmailcom> References: <2011011611053732597-tomfsessile@gmailcom> Message-ID: On Sun, Jan 16, 2011 at 11:05 AM, TomF wrote: > I'm trying to multiprocess my python code to take advantage of multiple > cores. ?I've read the module docs for threading and multiprocessing, and > I've done some web searches. ?All the examples I've found are too simple: > the processes take simple inputs and compute a simple value. ?My problem > involves lots of processes, complex data structures, and potentially lots of > results. ?It doesn't map cleanly into a Queue, Pool, Manager or > Listener/Client example from the python docs. > > Instead of explaining my problem and asking for design suggestions, I'll > ask: is there a compendium of realistic Python multiprocessing examples > somewhere? ?Or an open source project to look at? I'm unaware of a big archive of projects that use multiprocessing, but maybe one of the free code search engines could help with that. It sounds like you're planning to use mutable shared state, which is generally best avoided if at all possible, in concurrent programming - because mutable shared state tends to slow down things quite a bit. But if you must have mutable shared state that's more complex than a basic scalar or homogeneous array, I believe the multiprocessing module would have you use a "server process manager". From tjreedy at udel.edu Sun Jan 16 22:45:42 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Sun, 16 Jan 2011 22:45:42 -0500 Subject: Tkinter: The good, the bad, and the ugly! In-Reply-To: <64976187-88ad-47c9-9bc6-c0712a657264@j32g2000yqc.googlegroups.com> References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <79a8a$4d332d1a$4275d90a$3986@FUSE.NET> <64976187-88ad-47c9-9bc6-c0712a657264@j32g2000yqc.googlegroups.com> Message-ID: On 1/16/2011 6:58 PM, rantingrick wrote: > On Jan 16, 5:14 pm, Terry Reedy wrote: >> On 1/16/2011 1:27 PM, rantingrick wrote: >> >>> least look at the awesome screen shots here... >> >>> http://www.wxpython.org/screenshots.php >> >> I did. Well, they say, "Beauty is in the eye of the beholder!". To me, >> these are mostly awesomely ugly, ugly, ugly. Shot 1: Ugly gray field >> followed by shot2: ugly black on gray. These first two examples look >> like Windows 95/8 -- ie, 20th century look, not 21st. > > remember i had requested that everyone download the beautiful demo and > only look at the screen shots as a last resort. You called them 'awesome'. I did not expect 'awesomely ugly'. Screenshots are the first thing for someone to look at, to see WHAT THE APP LOOKS LIKE, and to decide whether one wants to bother to download, switch to admin, install, run, and uninstall (and hope that that really disinstalls everything). I looked and decided that what I saw (except for the Mac example), was too ugly to bother with, at least for now. One of the criticisms against tk has been that it is 'ugly' compared to other other guis. Comparing current tk against the screenshots, I saw the reverse. If the screenshots are awesomely unfair to wx, because they are actually 12 years old and RD and the wxpython community cannot be bothered to update them at least to merely 7 years old, that is their fault, not mine for taking them at their presentation. > ######### > # Shot1 # > ######### > This shot shows the most minimal wx GUI, that is, a simple Toplevel > window and nothing more. And to me it is ugly compared to a minimal tk GUI. > ########## > # Shot 2 # > ########## > This shot merely builds on shot one. Nothing fancy. And it is ugly compared to the equivalent tk example. > However i urge you to download the wxPython > demo and then give me an honest opinion. If you think the site is bad, send me a ONE better screenshot, or link thereto, of wx on WinXP/Vista/7. I promise to look at it. Then urge Robin to update the page. But until wx is either a serious contender for the stdlib, or I have personal need of a modern gui system, or I become curious enough about wx, compared to other things I have already downloaded and not looked at, I have little reason to spend more time with it. I already know that some people like wx and swear by it and have even had the vague idea that it somehow should replace tk. > I'll agree this screenshots page needs an update. However (like me) > the wxPython folks probably put more time into the demo and thought If Python developers gave that excuse to not update decade-old examples in the doc, you would probably rant about it for a week;-). Instead, we are updating text and examples as problems are discovered and we can get to them. I improved some years-old text and examples just last week. 3.2 will have hundreds of other improvements. >> There are, however, other problems with wx that I >> have and will point out in other posts. > Please elaborate, these are free and open forums as far as know...? There are two issues: some interface to wxwidgets, and wxpython as that interface or the base therefore. As to wxpython: for starters, it is written in Python2, not Python3. It is owned by Roben Dunn and he has shown no interest that I know of in having it in the stdlib. Given what that would mean in terms of loss of control of interface, code style, docs, release schedule, repository, and so on, I would not either if I had done what he has done. A wxinter written for the stdlib in Python3, possibly based on ctypes rather than swig or the equivalent, might be a stdlib candidate, somewhat independently of the fate of tkinter. But no one has volunteered and you yourself suggested that such are unlikely. -- Terry Jan Reedy From rantingrick at gmail.com Sun Jan 16 23:20:02 2011 From: rantingrick at gmail.com (rantingrick) Date: Sun, 16 Jan 2011 20:20:02 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <79a8a$4d332d1a$4275d90a$3986@FUSE.NET> <64976187-88ad-47c9-9bc6-c0712a657264@j32g2000yqc.googlegroups.com> Message-ID: <3af4fd5e-8cc9-4cec-aad2-cbf82ad3bab3@l24g2000vby.googlegroups.com> On Jan 16, 9:45?pm, Terry Reedy wrote: > You called them 'awesome'. I did not expect 'awesomely ugly'. > Screenshots are the first thing for someone to look at, to see WHAT THE > APP LOOKS LIKE, and to decide whether one wants to bother to download, > switch to admin, install, run, and uninstall (and hope that that really > disinstalls everything). I looked and decided that what I saw (except > for the Mac example), was too ugly to bother with, at least for now. Ok, Ok, i concede. The screenshots are horrendous, atrocious, and utterly reprehensible. I should never had posted a link to such a horrible example of wx. Trust me wx is much more beautiful than that! > One of the criticisms against tk has been that it is 'ugly' compared to > other other guis. Comparing current tk against the screenshots, I saw > the reverse. Ok, but read on because i may be able to convince you with some new screenshots... > If you think the site is bad, send me a ONE better screenshot, or link > thereto, of wx on WinXP/Vista/7. I promise to look at it. Then urge > Robin to update the page. Ok, try this... http://juicereceiver.sourceforge.net/screenshots/index.php and this... http://www.sensi.org/~ak/pyslsk/pyslsk6.png and this (wxWidgets)... http://www.wxwidgets.org/about/screensh.htm > If Python developers gave that excuse to not update decade-old examples > in the doc, you would probably rant about it for a week ;-). Agreed. These horrible screenshots need to be updated yesterday! Or just redirect to the wxwidgets screenshots if they are too lazy. > There are two issues: some interface to wxwidgets, and wxpython as that > interface or the base therefore. > > As to wxpython: for starters, it is written in Python2, not Python3. It > is owned by Roben Dunn and he has shown no interest that I know of in > having it in the stdlib. Given what that would mean in terms of loss of > control of interface, code style, docs, release schedule, repository, > and so on, I would not either if I had done what he has done. Agreed. However we NEED Roben Dunn to keep doing what he is doing now. And we need the people who are investing (maybe wasting) energy on Tkinter to focus on a small subset of wx for stdlib inclusion. Roben can keep his BDFL title, and Python can be updated. From tomf.sessile at gmail.com Sun Jan 16 23:39:51 2011 From: tomf.sessile at gmail.com (TomF) Date: Sun, 16 Jan 2011 20:39:51 -0800 Subject: examples of realistic multiprocessing usage? References: <2011011611053732597-tomfsessile@gmailcom> Message-ID: <2011011620395149614-tomfsessile@gmailcom> On 2011-01-16 19:16:15 -0800, Dan Stromberg said: > On Sun, Jan 16, 2011 at 11:05 AM, TomF wrote: >> I'm trying to multiprocess my python code to take advantage of multiple >> cores. ?I've read the module docs for threading and multiprocessing, and >> I've done some web searches. ?All the examples I've found are too simple: >> the processes take simple inputs and compute a simple value. ?My problem >> involves lots of processes, complex data structures, and potentially lots of >> results. ?It doesn't map cleanly into a Queue, Pool, Manager or >> Listener/Client example from the python docs. >> >> Instead of explaining my problem and asking for design suggestions, I'll >> ask: is there a compendium of realistic Python multiprocessing examples >> somewhere? ?Or an open source project to look at? > > I'm unaware of a big archive of projects that use multiprocessing, but > maybe one of the free code search engines could help with that. > > It sounds like you're planning to use mutable shared state, which is > generally best avoided if at all possible, in concurrent programming - > because mutable shared state tends to slow down things quite a bit. > I'm trying to avoid mutable shared state since I've read the cautions against it. I think it's possible for each worker to compute changes and return them back to the parent (and have the parent coordinate all changes) without too much overhead. So far It looks like multiprocessing.Pool.apply_async is the best match to what I want. One difficulty is that there is a queue of work to be done and a queue of results to be incorporated back into the parent; there is no one-to-one correspondence between the two. It's not obvious to me how to coordinate the queues in a natural way to avoid deadlock or starvation. > > But if you must have mutable shared state that's more complex than a > basic scalar or homogeneous array, I believe the multiprocessing > module would have you use a "server process manager". I've looked into Manager but I don't really understand the trade-offs. -Tom From askutt at gmail.com Sun Jan 16 23:57:41 2011 From: askutt at gmail.com (Adam Skutt) Date: Sun, 16 Jan 2011 20:57:41 -0800 (PST) Subject: examples of realistic multiprocessing usage? References: <2011011611053732597-tomfsessile@gmailcom> <2011011620395149614-tomfsessile@gmailcom> Message-ID: <0ab368a7-0cff-4de5-9527-4f14a70edb3b@v12g2000vbx.googlegroups.com> On Jan 16, 11:39?pm, TomF wrote: > One difficulty is that there is a queue of work to be done and a queue > of results to be incorporated back into the parent; there is no > one-to-one correspondence between the two. ?It's not obvious to me how > to coordinate the queues in a natural way to avoid deadlock or > starvation. > Depends on what you are doing. If you can enqueue all the jobs before waiting for your results, then two queues are adequate. The first queue is jobs to be accomplished, the second queue is the results. The items you put on the result queue have both the result and some sort of id so the results can be ordered after the fact. Your parent thread of execution (thread hereafter) then: 1. Adds jobs to the queue 2. Blocks until all the results are returned. Given that you suggested that there isn't a 1:1 correspondence between jobs and results, have the queue support a message saying, 'Job X is done'. You're finished when all jobs send such a message. 3. Sorts the results into the desired ordered. 4. Acts on them. If you cannot enqueue all the jobs before waiting for the results, I suggest turning the problem into a pipeline, such that the thread submitting the jobs and the thread acting on the results are different: submitter -> job processor -> results processor. Again though, the devil is in the details and without more details, it's hard to suggest an explicit approach. The simplest way to avoid contention between two queues is to just remove it entirely (by converting the processing to a single pipeline like I suggested). If that is not possible, then I suggest moving to pipes (or some other form of I/O based IPC) and asynchronous I/O. But I'd only do that if I really couldn't write a pipeline. Adam From timr at probo.com Mon Jan 17 00:14:59 2011 From: timr at probo.com (Tim Roberts) Date: Sun, 16 Jan 2011 21:14:59 -0800 Subject: Not clear about the dot notation References: <2d3e986b-6e6a-477f-a4ba-fe091ff72b8f@i41g2000vbn.googlegroups.com> <2011011612244047855-tomfsessile@gmailcom> Message-ID: <80k7j6t9jbqvd8t1t9hlueeo05dlfvvvqd@4ax.com> Zeynel wrote: >On Jan 16, 3:24?pm, TomF wrote: > >> vote refers to the Vote instance. > >So he must have instatiated previously like > >vote = Vote() No, it's the line immediately above the one you asked about: if vote is None: vote = Vote(key_name = user.email(), parent = quote) if vote.vote == newvote: return If "vote" is empty, it creates a Vote object and assigns it to "vote". It then checks the "vote" member of that object. >class Item(db.Model): > title = db.StringProperty() > url = db.StringProperty() > date = db.DateTimeProperty(auto_now_add=True) > author = db.UserProperty() > >and to write to the database I do > > item = Item() > item.title = self.request.get("title") > item.url = self.request.get("url") > item.author = users.get_current_user() > item.put() > self.redirect("/newest") > >so his vote.vote is like my item.url ? Exactly. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From hjtoi-better-remove-before-reply at comcast.net Mon Jan 17 00:44:02 2011 From: hjtoi-better-remove-before-reply at comcast.net (Heikki Toivonen) Date: Sun, 16 Jan 2011 21:44:02 -0800 Subject: ANN: M2Crypto 0.21.1 Message-ID: Announcing M2Crypto 0.21.1 Changes: 0.21.1 - 2011-01-15 ------------------- - Distribution fix 0.21 - 2011-01-12 ----------------- - Support OpenSSL 1.0. Thanks to Miloslav Trmac for figuring out how to fix test_smime.py - Rename m2.engine_init to engine_init_error so that ENGINE_init and ENGINE_finish can be exposed, thanks to Erlo - 0.20 started releasing Python locks even around some operations that interacted with the Python runtime, potentially causing crashes and other weirdness, fix by Miloslav Trmac - Make httpslib.ProxyHTTPSConnection work with Python 2.3 M2Crypto is the most complete Python wrapper for OpenSSL featuring RSA, DSA, DH, EC, HMACs, message digests, symmetric ciphers (including AES); SSL functionality to implement clients and servers; HTTPS extensions to Python's httplib, urllib, and xmlrpclib; unforgeable HMAC'ing AuthCookies for web session management; FTP/TLS client and server; S/MIME; ZServerSSL: A HTTPS server for Zope and ZSmime: An S/MIME messenger for Zope. M2Crypto can also be used to provide SSL for Twisted. Smartcards supported through the Engine interface. -- Heikki Toivonen - http://heikkitoivonen.net From tomf.sessile at gmail.com Mon Jan 17 00:44:22 2011 From: tomf.sessile at gmail.com (TomF) Date: Sun, 16 Jan 2011 21:44:22 -0800 Subject: examples of realistic multiprocessing usage? References: <2011011611053732597-tomfsessile@gmailcom> <2011011620395149614-tomfsessile@gmailcom> <0ab368a7-0cff-4de5-9527-4f14a70edb3b@v12g2000vbx.googlegroups.com> Message-ID: <2011011621442275350-tomfsessile@gmailcom> On 2011-01-16 20:57:41 -0800, Adam Skutt said: > On Jan 16, 11:39?pm, TomF wrote: >> One difficulty is that there is a queue of work to be done and a queue >> of results to be incorporated back into the parent; there is no >> one-to-one correspondence between the two. ?It's not obvious to me how >> to coordinate the queues in a natural way to avoid deadlock or >> starvation. >> > > Depends on what you are doing. If you can enqueue all the jobs before > waiting for your results, then two queues are adequate. The first > queue is jobs to be accomplished, the second queue is the results. > The items you put on the result queue have both the result and some > sort of id so the results can be ordered after the fact. Your parent > thread of execution (thread hereafter) then: > > 1. Adds jobs to the queue > 2. Blocks until all the results are returned. Given that you > suggested that there isn't a 1:1 correspondence between jobs and > results, have the queue support a message saying, 'Job X is done'. > You're finished when all jobs send such a message. > 3. Sorts the results into the desired ordered. > 4. Acts on them. > > If you cannot enqueue all the jobs before waiting for the results, I > suggest turning the problem into a pipeline, such that the thread > submitting the jobs and the thread acting on the results are > different: submitter -> job processor -> results processor. > Adam Thanks for your reply. I can enqueue all the jobs before waiting for the results, it's just that I want the parent to process the results as they come back. I don't want the parent to block until all results are returned. I was hoping the Pool module had a test for whether all processes were done, but I guess it isn't hard to keep track of that myself. -Tom From orasnita at gmail.com Mon Jan 17 01:46:58 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Mon, 17 Jan 2011 08:46:58 +0200 Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <4d337983$0$29983$c3e8da3$5496439d@news.astraweb.com> Message-ID: From: "Steven D'Aprano" Sent: Monday, January 17, 2011 1:04 AM Subject: Re: Tkinter: The good, the bad, and the ugly! .... > Well, true, but people tend to *use* the parts of the GUIs that are > simple and basic. Not only do the big complicated apps get all the press > even when they are actually a niche product (everyone knows about > Photoshop, but more people use MS Paint) but it's a truism that most > people use something like 20% of the functionality of big, complicated > GUI apps. Most people use Microsoft Word or OpenOffice for little more > than text editing with formatting. True, but the most important thing is that those apps need to work and these days the portability of programs is also important for making them available to as many people as possible. wxWIDGETS are portable and also pretty accessible for those who need to use screen readers which is not the case of purely native widgets as the Win32 GUI standard controls or the libraries like Tk, GTK or QT. Octavian From no.email at nospam.invalid Mon Jan 17 02:21:49 2011 From: no.email at nospam.invalid (Paul Rubin) Date: Sun, 16 Jan 2011 23:21:49 -0800 Subject: [OT] Python like lanugages References: <86a904f8-05b0-435f-81d6-7450650f1679@glegroupsg2000goo.googlegroups.com> <4d329899$0$43988$742ec2ed@news.sonic.net> <7x8vylfcvz.fsf@ruckus.brouhaha.com> <4d32c7cf$0$29983$c3e8da3$5496439d@news.astraweb.com> Message-ID: <7xipxo9er6.fsf@ruckus.brouhaha.com> geremy condra writes: > I agree. That does not make Go that language, and many of the choices > made during Go's development indicate that they don't think it's that > language either. I'm speaking specifically of its non-object model, > lack of exceptions, etc .... > You might be right, but I doubt we'll know one way or the other in the > next 5 years. Personally, I'm hoping that functional language use > continues to grow. You know, the functional programming community seems to think of OOP as a 1990's thing that didn't work out. Most things that can be done with OOP, can be done with higher-order functions and bounded polymorphism like in Haskell. I'm not sure, but I don't think Erlang has exceptions in the sense we're used to. Someone mentioned Erlang uses a VM, but I think there is a native compiler called HIPE. Of course there is still a fairly substantial runtime system, but that's true of any language with a garbage collector and so forth. Scala seems like an interesting language that is maybe a bit more "practical" than Haskell. I want to try writing something in it. Yes it's JVM-bound but maybe the Java aspects can be decoupled somehow. From howe.steven at gmail.com Mon Jan 17 03:30:28 2011 From: howe.steven at gmail.com (Steven Howe) Date: Mon, 17 Jan 2011 00:30:28 -0800 Subject: Tkinter: Joking? In-Reply-To: References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <4d337983$0$29983$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4D33FE24.3050109@gmail.com> On 01/16/2011 10:46 PM, Octavian Rasnita wrote: > From: "Steven D'Aprano" > Sent: Monday, January 17, 2011 1:04 AM > Subject: Re: Tkinter: The good, the bad, and the ugly! > .... >> Well, true, but people tend to *use* the parts of the GUIs that are >> simple and basic. Not only do the big complicated apps get all the press >> even when they are actually a niche product (everyone knows about >> Photoshop, but more people use MS Paint) but it's a truism that most >> people use something like 20% of the functionality of big, complicated >> GUI apps. Most people use Microsoft Word or OpenOffice for little more >> than text editing with formatting. > > > > True, but the most important thing is that those apps need to work and > these days the portability of programs is also important for making > them available to as many people as possible. > > wxWIDGETS are portable and also pretty accessible for those who need > to use screen readers which is not the case of purely native widgets > as the Win32 GUI standard controls or the libraries like Tk, GTK or QT. > > Octavian > If you are making a product, you want it to be unique and inaccessible to other companies/products. Hence 'propriety'. It's part of that 'capture the market' mindset that engineers and programmers have a problem with. Fight or flight, you have to deal with it. So ... Target your market. Design your software in the Model-View-Controller format. It becomes easy to configure you frontend, your GUI, your web page, if your code is written to separate the work from the glitz. Car companies know this. There is the body design crew, and the engineers that make it work. So software products too. Artists always come first; with good reason, their work catches the eye; remember what Dr. Lecter said "Don't your eyes seek out what you want Clares?". Fighting that fact, for 'efficiency' is just tilting at windmills (or Pontiac Aztec). Instead, think 'optimal' i.e. maximum usage per market. MVC makes that approach reasonable in the first market. Easy in the second (Apple), third (Linux) and fourth (BSD). In the mean time, quit bad mouthing works like Tk/Tcl that have come before the current crop. Their successors too shall pass. Oh, and if your interested, I'm in the third market, been here since 1992. Time and Tide Microsoft, Apple. Time and tide. Steven From list at qtrac.plus.com Mon Jan 17 03:33:42 2011 From: list at qtrac.plus.com (Mark Summerfield) Date: Mon, 17 Jan 2011 08:33:42 +0000 Subject: [python-committers] [RELEASED] Python 3.2 rc 1 In-Reply-To: <4D329F55.9040903@python.org> References: <4D329F55.9040903@python.org> Message-ID: <20110117083342.719d9ab5@dino> Hi Georg, I can't be sure it is a bug, but there is a definite difference of behavior between 3.0/3.1 and 3.2rc1. Given this directory layout: $ ls -R Graphics/ Graphics/: __init__.py Vector Xpm.py Graphics/Vector: __init__.py Svg.py And these files: $ cat Graphics/__init__.py __all__ = ["Xpm"] $ cat Graphics/Xpm.py #!/usr/bin/env python3 XPM = 0 $ cat Graphics/Vector/__init__.py __all__ = ["Svg"] $ cat Graphics/Vector/Svg.py #!/usr/bin/env python3 from ..Graphics import Xpm SVG = 1 I can do the relative import with Python 3.0 and 3.1 but not with 3.2rc1: $ python30 Python 3.0.1 (r301:69556, Jul 15 2010, 10:31:51) [GCC 4.4.4] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> from Graphics.Vector import * >>> Svg.SVG 1 $ python31 Python 3.1.2 (r312:79147, Jul 15 2010, 10:56:05) [GCC 4.4.4] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> from Graphics.Vector import * >>> Svg.SVG 1 $ ~/opt/python32rc1/bin/python3 Python 3.2rc1 (r32rc1:88035, Jan 16 2011, 08:32:59) [GCC 4.4.5] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> from Graphics.Vector import * Traceback (most recent call last): File "", line 1, in File "Graphics/Vector/Svg.py", line 2, in from ..Graphics import Xpm ImportError: No module named Graphics Should I report it as a bug or is this a planned change of behavior (or was the original behavior wrong?). -- Mark Summerfield, Qtrac Ltd, www.qtrac.eu C++, Python, Qt, PyQt - training and consultancy "Advanced Qt Programming" - ISBN 0321635906 http://www.qtrac.eu/aqpbook.html From usernet at ilthio.net Mon Jan 17 04:12:04 2011 From: usernet at ilthio.net (Tim Harig) Date: Mon, 17 Jan 2011 09:12:04 +0000 (UTC) Subject: [OT] Python like lanugages [was Re: After C++, what with Python?] References: <86a904f8-05b0-435f-81d6-7450650f1679@glegroupsg2000goo.googlegroups.com> <4d329899$0$43988$742ec2ed@news.sonic.net> <7x8vylfcvz.fsf@ruckus.brouhaha.com> <4d32c7cf$0$29983$c3e8da3$5496439d@news.astraweb.com> Message-ID: On 2011-01-16, geremy condra wrote: > On Sun, Jan 16, 2011 at 3:03 AM, Tim Harig wrote: >> On 2011-01-16, Steven D'Aprano wrote: >>> If the author thinks that Go is a "tried and true" (his words, not mine) >>> language "where programmers can go to look for work", I think he's >>> fooling himself. >> >> No I wouldn't say that it has reached market penetration yet; but, it >> has more momentum then any language I am familiar with. ?I wouldn't be >> at all surprised to see it becoming quite common in the next five years. > > I would be very surprised if this were the case. As you point out, > languages typically have very long incubation times before they reach > any kind of serious market penetration. This seems doubly true for a > relatively narrowly targeted language that is in many ways on the > wrong side of history. I wouldn't say Go is narrowly targeted. It's a systems language that can compete in the same domain with scripting languages. It is true that most languages have long incubation periods; but, corporate support can change that quite a bit. C#, being backed by Microsoft, managed to go mainstream pretty quickly. >> How long has it taken Python to reach its present level of market >> penetration? ?And, I still don't see a huge amount of professional Python >> use outside of web developement. ?Go has only been public for less then >> a year. > > Python's very widely used for scripting and related tasks, and has a > pretty big user base in academia and the sciences. Python has been widely used by people like us that happen to like the language and found ways to use it in our workplaces; but, most of the time it is an unofficial use that the company. You still don't see many companies doing large scale internal development using Python and you definately don't see any doing external developement using a language that gives the customers full access to the source code. >> Personally, I think the time is ripe for a language that bridges the >> gap between ease of use dynamic languages with the performance and >> distribution capabilities of a full systems level language. > > I agree. That does not make Go that language, and many of the choices > made during Go's development indicate that they don't think it's that > language either. I'm speaking specifically of its non-object model, > lack of exceptions, etc. 1. Go has an object model. What it lacks is an object hierarchy where all object are decended from a single root "object" since it does not support object inheritance as it is used in most languages. In Go we simply adapt an object to meet the needs of the newer object by adding whatever new functionality is needed. 2. Go has a similar mechanism to exceptions, defer/panic/recover. It does downplay >>This is after all the promise the VM based languages made but never >> really fulfilled. It is also high time for a fully concurrent language fully >> capable of taking advantage of multicore processors without having to >> deal with the inherent dangers of threading. ?There are several good >> choices available for both a even a few that fit both bills; but, few of >> them have the support of a company like Google that is capable of the >> push required to move the language into the mainstream. > > You might be right, but I doubt we'll know one way or the other in the > next 5 years. Personally, I'm hoping that functional language use > continues to grow. I personally doubt that purely functional languages will ever make it mainstream. Functional programming has been around for a long time and never really ever managed to break out of academic research. The current interest in functional programming stems merely because some announced that it would be *the* way to utilize multicore computers. Having looked into the space somewhat, there is more hype then substantiation for purely functional concepts. What the hype did do was return attention to SCP style concurrency using actors and MPI and I think that will be the direction taken for concurrent programming into the future. I believe functional programming will make an impact in the mainstream in the form of functionally enabled multiparadigm but not purely functional languages. I think you will see code that uses more functional concepts as guidelines to better code. From usernet at ilthio.net Mon Jan 17 04:34:58 2011 From: usernet at ilthio.net (Tim Harig) Date: Mon, 17 Jan 2011 09:34:58 +0000 (UTC) Subject: [OT] Python like lanugages References: <86a904f8-05b0-435f-81d6-7450650f1679@glegroupsg2000goo.googlegroups.com> <4d329899$0$43988$742ec2ed@news.sonic.net> <7x8vylfcvz.fsf@ruckus.brouhaha.com> <4d32c7cf$0$29983$c3e8da3$5496439d@news.astraweb.com> <7xipxo9er6.fsf@ruckus.brouhaha.com> Message-ID: On 2011-01-17, Paul Rubin wrote: > geremy condra writes: >> I agree. That does not make Go that language, and many of the choices >> made during Go's development indicate that they don't think it's that >> language either. I'm speaking specifically of its non-object model, >> lack of exceptions, etc .... >> You might be right, but I doubt we'll know one way or the other in the >> next 5 years. Personally, I'm hoping that functional language use >> continues to grow. > > You know, the functional programming community seems to think of OOP as > a 1990's thing that didn't work out. Most things that can be done with > OOP, can be done with higher-order functions and bounded polymorphism > like in Haskell. Which is rather interesting because the OOP community had traditionally though of functional programming as a 1960's thing that didn't work out. Functional programming has been around a long time; but, it only regained conciousness outside of academia because of its hyped abilities to make threading easier. Unfortunately for functional programming, much of that ability actually traces back to MPI and the actor model. Using the actor model, it is possible to reap the benefits of easier multiprocessing without using any functional programming concepts. That isn't to say that the injection of functional programming into the mainstream will not have some good affects overall. I expect to see functional programming concepts being incorporated into guidelines for imperative language use. > I'm not sure, but I don't think Erlang has exceptions in the sense we're > used to. Someone mentioned Erlang uses a VM, but I think there is a Erlang has exceptions that look very much like Python exceptions. > native compiler called HIPE. Of course there is still a fairly > substantial runtime system, but that's true of any language with a > garbage collector and so forth. Which is why I say Erlang doesn't compile to a native binary. HIPE has been available through the standard OTP for some time now. HIPE generates native machine OP codes where possible; but, the generated product must still run on the BEAM runtime system. The end result is much faster then Python and often faster then Java with a JIT; but, still doesn't rival C code. It is possible to optimize things quite a bit by integrating with C code; but, then you loose much of the safety provided by Erlang and BEAM. This isn't such a tragedy Erlang as it is for other managed VMs because Erlang/BEAM makes powerful usage of its VM for fault tolerance mechanisms. I don't know of any other VM that allows software upgrades on a running system. From frankcui24 at gmail.com Mon Jan 17 05:01:22 2011 From: frankcui24 at gmail.com (frank cui) Date: Mon, 17 Jan 2011 18:01:22 +0800 Subject: Question on the Module Import Message-ID: Hi all, I'm quite a novice in doing python,and i wish to ask you guys a question on the module import. Say we have a source file called module1.py. What's the difference between the " import module1 " and " from module1 import * " I know that conventionally by coding style, we dont use the second form,but does the first one also reach the same effect ? (importing all the classes and functions and pollute the namespace?) thanks in advance for your answer. Regards, Frank -------------- next part -------------- An HTML attachment was scrubbed... URL: From arndt.roger at addcom.de Mon Jan 17 05:03:22 2011 From: arndt.roger at addcom.de (Arndt Roger Schneider) Date: Mon, 17 Jan 2011 11:03:22 +0100 Subject: [OT] Python like lanugages References: <86a904f8-05b0-435f-81d6-7450650f1679@glegroupsg2000goo.googlegroups.com> <4d329899$0$43988$742ec2ed@news.sonic.net> <7x8vylfcvz.fsf@ruckus.brouhaha.com> <4d32c7cf$0$29983$c3e8da3$5496439d@news.astraweb.com> <7xipxo9er6.fsf@ruckus.brouhaha.com> Message-ID: Tim Harig schrieb: [snip] > > This isn't such a tragedy Erlang as it is for other managed VMs because > Erlang/BEAM makes powerful usage of its VM for fault tolerance mechanisms. I > don't know of any other VM that allows software upgrades on a running system. styx, the distributed operating system inferno, language: limbo. From clp2 at rebertia.com Mon Jan 17 05:25:43 2011 From: clp2 at rebertia.com (Chris Rebert) Date: Mon, 17 Jan 2011 02:25:43 -0800 Subject: Question on the Module Import In-Reply-To: References: Message-ID: On Mon, Jan 17, 2011 at 2:01 AM, frank cui wrote: > Hi all, > > I'm quite a novice in doing python,and i wish to ask you guys a question on > the module import. > > Say we have a source file called module1.py. > > What's the difference between the " import module1 " and " from module1 > import * " > > I know that conventionally by coding style, we dont use the second form,but > does the first one also reach the same effect ? (importing all the classes > and functions and pollute the namespace?) No, not at all. Only the second form pollutes the namespace. The first form *only* imports the name "module1" into your namespace. To access stuff in module1, you then *must* write "module1.foo" etc., explicitly going thru the "module1" name every single time.? The latter form dumps *all* the stuff in module1 into your namespace,? with the name "module1" itself left unbound. To access stuff from module1, you then merely write "foo" etc., and are unable to refer to the module namespace as a whole. By way of example: $ python Python 2.6.6 (r266:84292, Jan 12 2011, 13:35:00) >>> import pickle >>> dir(pickle) # output severely trimmed for convenience/relevance [..., 'dump', 'dumps', 'encode_long', 'format_version', 'load', 'loads', ...] >>> dump Traceback (most recent call last): File "", line 1, in NameError: name 'dump' is not defined >>> pickle.dump >>> pickle Contrast with: $ python Python 2.6.6 (r266:84292, Jan 12 2011, 13:35:00) >>> from pickle import * >>> dump >>> pickle.dump Traceback (most recent call last): File "", line 1, in NameError: name 'pickle' is not defined >>> pickle Traceback (most recent call last): File "", line 1, in NameError: name 'pickle' is not defined ?: Unless you manually alias something to a local name of course, but that's not pedagogically relevant here. ?: Excepting names starting with an underscore. Cheers, Chris -- http://blog.rebertia.com From orsenthil at gmail.com Mon Jan 17 05:31:42 2011 From: orsenthil at gmail.com (Senthil Kumaran) Date: Mon, 17 Jan 2011 16:01:42 +0530 Subject: [Python-Dev] [python-committers] [RELEASED] Python 3.2 rc 1 In-Reply-To: <20110117083342.719d9ab5@dino> References: <4D329F55.9040903@python.org> <20110117083342.719d9ab5@dino> Message-ID: On Mon, Jan 17, 2011 at 2:03 PM, Mark Summerfield wrote: > Hi Georg, > > I can't be sure it is a bug, but there is a definite difference of > behavior between 3.0/3.1 and 3.2rc1. > > I can do the relative import with Python 3.0 and 3.1 but not with > 3.2rc1: Are you sure that the package that you are trying to import is the PYTHONPATH of your system's Python 3.0 and Python 3.1 and Not in RC1? Looks to me a PYTHONPATH problem than a problem with rc1. - I tried to recreate the directory structure that you mentioned and tried from Graphics.Vector import * It failed with ImportError on python3, 3.1 and rc. - Just to test the relative imports, I created a directory structure as mentioned here: http://www.python.org/dev/peps/pep-0328/ and tried to test the relative import for usecase :- from ..moduleA import foo and works fine in rc1. - I also find that your use case (from ..Graphics import XPM in Graphics/Vector/Svg.py) is not one of the listed ones in PEP-0328. -- Senthil From steve+comp.lang.python at pearwood.info Mon Jan 17 06:20:30 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 17 Jan 2011 11:20:30 GMT Subject: [OT] Python like lanugages [was Re: After C++, what with Python?] References: <86a904f8-05b0-435f-81d6-7450650f1679@glegroupsg2000goo.googlegroups.com> <4d329899$0$43988$742ec2ed@news.sonic.net> <7x8vylfcvz.fsf@ruckus.brouhaha.com> <4d32c7cf$0$29983$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4d3425fe$0$29983$c3e8da3$5496439d@news.astraweb.com> On Mon, 17 Jan 2011 09:12:04 +0000, Tim Harig wrote: > Python has been widely used by people like us that happen to like the > language and found ways to use it in our workplaces; but, most of the > time it is an unofficial use that the company. You still don't see many > companies doing large scale internal development using Python and you > definately don't see any doing external developement using a language > that gives the customers full access to the source code. Careful with the FUD there *wink* http://www.python.org/about/quotes/ Sometimes giving access to the source code is a feature, not a bug. Just ask Red Hat. And for those who think otherwise, you can always ship the .pyc files alone. Or turn your software into a web-app. In any case, most companies, and individuals, follow the crowd. They do what everybody else does. There are good reasons for this, as well as bad reasons, but the end result is that most companies' software development is, quite frankly, crap, using the wrong language and the wrong methodology for the wrong reasons. If you doubt this, then perhaps you would like to explain why most software projects fail and those that don't rarely come in on time or on budget? It would probably be crap regardless of what language they used (Sturgeon's Law), but there are degrees of crap. Being optimized for rapid development, at least with Python the average company will develop their crap software five times as quickly and at a third the cost than if they had chosen C++ or Java. You should also consider Paul Graham's essay: http://www.paulgraham.com/avg.html He's hot for Lisp, which is fine, but the lessons hold for Python too. -- Steven From clp2 at rebertia.com Mon Jan 17 06:45:08 2011 From: clp2 at rebertia.com (Chris Rebert) Date: Mon, 17 Jan 2011 03:45:08 -0800 Subject: [OT] Python like lanugages [was Re: After C++, what with Python?] In-Reply-To: References: <86a904f8-05b0-435f-81d6-7450650f1679@glegroupsg2000goo.googlegroups.com> <4d329899$0$43988$742ec2ed@news.sonic.net> <7x8vylfcvz.fsf@ruckus.brouhaha.com> <4d32c7cf$0$29983$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Mon, Jan 17, 2011 at 1:12 AM, Tim Harig wrote: > On 2011-01-16, geremy condra wrote: >> On Sun, Jan 16, 2011 at 3:03 AM, Tim Harig wrote: >>> Personally, I think the time is ripe for a language that bridges the >>> gap between ease of use dynamic languages with the performance and >>> distribution capabilities of a full systems level language. >> >> I agree. That does not make Go that language, and many of the choices >> made during Go's development indicate that they don't think it's that >> language either. I'm speaking specifically of its non-object model, >> lack of exceptions, etc. > > 2. Go has a similar mechanism to exceptions, defer/panic/recover. ?It does > ? ? ? ?downplay > Downplay what exactly? Seems your paragraph got truncated. Cheers, Chris From askutt at gmail.com Mon Jan 17 07:05:36 2011 From: askutt at gmail.com (Adam Skutt) Date: Mon, 17 Jan 2011 04:05:36 -0800 (PST) Subject: examples of realistic multiprocessing usage? References: <2011011611053732597-tomfsessile@gmailcom> <2011011620395149614-tomfsessile@gmailcom> <0ab368a7-0cff-4de5-9527-4f14a70edb3b@v12g2000vbx.googlegroups.com> <2011011621442275350-tomfsessile@gmailcom> Message-ID: On Jan 17, 12:44?am, TomF wrote: > Thanks for your reply. ?I can enqueue all the jobs before waiting for > the results, it's just that I want the parent to process the results as > they come back. ?I don't want the parent to block until all results are > returned. ?I was hoping the Pool module had a test for whether all > processes were done, but I guess it isn't hard to keep track of that > myself. > Regardless of whether it does or doesn't, you don't really want to be blocking in two places anyway, so the "FINISHED" event in the queue is the superior solution. It's certainly possible to build a work pool w/ a queue such that you block on both for entries added to the queue and job completion, but I'm pretty sure it's something you'd have to write yourself. Adam From askutt at gmail.com Mon Jan 17 07:22:12 2011 From: askutt at gmail.com (Adam Skutt) Date: Mon, 17 Jan 2011 04:22:12 -0800 (PST) Subject: Tkinter: Joking? References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <4d337983$0$29983$c3e8da3$5496439d@news.astraweb.com> Message-ID: <8be36c74-d10a-4848-ba69-3b208bb98243@k30g2000vbn.googlegroups.com> On Jan 17, 3:30?am, Steven Howe wrote: > Target your market. Design your software in the Model-View-Controller > format. It becomes easy to configure you frontend, your GUI, your web > page, if your code is written to separate the work from the glitz. > If there were some evidence MVC actually worked, perhaps. Unfortunately, there isn't, so there's little reason to do this. Nevermind that most MVC frameworks get the definitions entirely wrong, despite the plethora of examples from the original paper (e.g., Swing does). > Car companies know this. There is the body design crew, and the > engineers that make it work. No, there really isn't anymore. Integrated teams are the mandatory order of the day, because getting the necessary fuel economy requires paying close attention to body design. Vehicles where the designer runs rampant over the look are getting rarer, and will continue to do so as long as governments continue to tighten fuel economy standards (and to a lesser degree, safety standards). Adam From usernet at ilthio.net Mon Jan 17 07:25:57 2011 From: usernet at ilthio.net (Tim Harig) Date: Mon, 17 Jan 2011 12:25:57 +0000 (UTC) Subject: [OT] Python like lanugages [was Re: After C++, what with Python?] References: <86a904f8-05b0-435f-81d6-7450650f1679@glegroupsg2000goo.googlegroups.com> <4d329899$0$43988$742ec2ed@news.sonic.net> <7x8vylfcvz.fsf@ruckus.brouhaha.com> <4d32c7cf$0$29983$c3e8da3$5496439d@news.astraweb.com> <4d3425fe$0$29983$c3e8da3$5496439d@news.astraweb.com> Message-ID: On 2011-01-17, Steven D'Aprano wrote: > On Mon, 17 Jan 2011 09:12:04 +0000, Tim Harig wrote: > >> Python has been widely used by people like us that happen to like the >> language and found ways to use it in our workplaces; but, most of the >> time it is an unofficial use that the company. You still don't see many >> companies doing large scale internal development using Python and you >> definately don't see any doing external developement using a language >> that gives the customers full access to the source code. > > Careful with the FUD there *wink* This isn't FUD, I am as enthusiastic about Python as anybody here; but, I also have to be realistic about its actual impact in the industry. > http://www.python.org/about/quotes/ There are always success stories; although, many of those are web based companies which, if you will look up the thread, I already excuded from the conversation. However from my experience, a small percentage of people make their primary income from writing non-web based Python software. It certainly hasn't displaced, or even encroached on the primary langauge leaders. > Sometimes giving access to the source code is a feature, not a bug. Just > ask Red Hat. And for those who think otherwise, you can always ship > the .pyc files alone. Or turn your software into a web-app. Red Hat is the big example; but, few other companies actually make substantial profits from FOSS. I am not interested in an idealogy debate about whether exposing your source is good or bad; the fact is that those who fund software developement have a strong preference to choosing closed source. Any software that doesn't provide good methods for closed sourced software is going to suffer. 1. Distributing .pyc files still requires the user to have a Python interpreter. 2. My understanding is that Python bytecode is not guaranteed to be compatible between releases? 3. I have already excluded web apps where Python has a large market penetration (were most of the dynamic languages have found their niche). My point pertains to those areas where Python cannot, or doesn't, compete well with systems level languages and that even for its web niche, it didn't arrive here overnight. There was a long period where it was less likely the Perl to be used for server side web scripting. You can see the recent thread about a web based IDE for what I think about many web applications. > In any case, most companies, and individuals, follow the crowd. They do > what everybody else does. There are good reasons for this, as well as bad > reasons, but the end result is that most companies' software development > is, quite frankly, crap, using the wrong language and the wrong > methodology for the wrong reasons. If you doubt this, then perhaps you People funding software developement really don't care about the quality of the software. They care how much money it will make them. If you really think quality matters, then look at Microsoft's meteoric rise to dominance. Early Microsoft was not known for its superior quality. Only in the last ten years, since they have had to contend with a really poor reputation and competition from their own products have they started to be conserned with writing better software. > methodology for the wrong reasons. If you doubt this, then perhaps you > would like to explain why most software projects fail and those that > don't rarely come in on time or on budget? Yes, lots of projects fail; but, the choice of language is seldom the primary, or even a major contributing reason, for the failure. Python holds the distinction of having had a book written about one such failed project. > It would probably be crap regardless of what language they used > (Sturgeon's Law), but there are degrees of crap. Being optimized for > rapid development, at least with Python the average company will develop > their crap software five times as quickly and at a third the cost than if > they had chosen C++ or Java. If I didn't think Python was a good language, I wouldn't be here. Nevertheless, it isn't a good fit for many pieces of software where a systems language is better suited. Reasons include ease of distribution without an interpeter, non-necessity of distributing source with the product, ability to leverage multiple CPU and multicore systems, and simple sequential performance. Given that Python does't work well in many areas, we could just give up and accept having to write C++ for our day jobs or we can look for a language which bridges the gap between those tasks that require C++'s level of control and those which work well for dynamic languages. Java attempted to do that, and has the market share to show that the concept works, but I think that it missed the mark for many needs. It is still much lower level then Python for purposes of rapid developement and too slow to be competative for non-long-lived tasks. From usernet at ilthio.net Mon Jan 17 07:28:21 2011 From: usernet at ilthio.net (Tim Harig) Date: Mon, 17 Jan 2011 12:28:21 +0000 (UTC) Subject: [OT] Python like lanugages [was Re: After C++, what with Python?] References: <86a904f8-05b0-435f-81d6-7450650f1679@glegroupsg2000goo.googlegroups.com> <4d329899$0$43988$742ec2ed@news.sonic.net> <7x8vylfcvz.fsf@ruckus.brouhaha.com> <4d32c7cf$0$29983$c3e8da3$5496439d@news.astraweb.com> Message-ID: On 2011-01-17, Chris Rebert wrote: > On Mon, Jan 17, 2011 at 1:12 AM, Tim Harig wrote: >> On 2011-01-16, geremy condra wrote: >>> On Sun, Jan 16, 2011 at 3:03 AM, Tim Harig wrote: > >>>> Personally, I think the time is ripe for a language that bridges the >>>> gap between ease of use dynamic languages with the performance and >>>> distribution capabilities of a full systems level language. >>> >>> I agree. That does not make Go that language, and many of the choices >>> made during Go's development indicate that they don't think it's that >>> language either. I'm speaking specifically of its non-object model, >>> lack of exceptions, etc. > >> >> 2. Go has a similar mechanism to exceptions, defer/panic/recover. ?It does >> ? ? ? ?downplay there use for less exceptional conditions in favor of function return values; however, there is nothing preventing you from using them as you see fit to do so. > Downplay what exactly? Seems your paragraph got truncated. Sorry. From askutt at gmail.com Mon Jan 17 08:17:39 2011 From: askutt at gmail.com (Adam Skutt) Date: Mon, 17 Jan 2011 05:17:39 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> Message-ID: <0139798e-dd80-4fc3-a820-f328124b27c1@a10g2000vby.googlegroups.com> On Jan 17, 8:30?am, Albert van der Horst wrote: > We are not talking about running applications, but about writing > applications. Someone has to write the applications I run... > I count 4000+ .py files in my /usr/share alone on Ubuntu. > Your set is totally unrepresentative for those scripts. Yeah, go back and count how many of those actually use a GUI and were not written by Canonical for the purpose of OS configuration (though it'd be especially odd to find them in /usr/_share_). Such a response is entirely and completely disingenuous and borderline insulting. You and rick both need eye exams, apparently. Adam From awilliam at whitemice.org Mon Jan 17 08:27:58 2011 From: awilliam at whitemice.org (Adam Tauno Williams) Date: Mon, 17 Jan 2011 08:27:58 -0500 Subject: examples of realistic multiprocessing usage? In-Reply-To: References: <2011011611053732597-tomfsessile@gmailcom> Message-ID: <1295270878.4082.12.camel@linux-yu4c.site> On Mon, 2011-01-17 at 13:55 +0000, Albert van der Horst wrote: > In article , > Philip Semanchuk wrote: > > >I grepped through the code to see that it's using = > >multiprocessing.Listener. I didn't go any further than that because our = > >project is BSD licensed and the license for Gluino is unclear. Until I = > >find out whether or not its under an equally permissive license, I can't = > >borrow ideas and/or code from it. > You have been brain washed by the Intellectual Properties congsy. > Of course you can read through code to borrow idea's from it. I wouldn't; and there is no brain-washing. It is very unwise to look at GPL'd code if you are working on a non-GPL project; the GPL is specifically and intentionally viral. The distinction between reading-through-code-and-borrowing-ideas and copying-code is thin and best left to lawyers. Aside: Comments to the contrary often stand-on-their-head to make such cases. For example: "You do have a choice under the GPL license: you can stop using the stolen code and write your own, or you can decide you'd rather release under the GPL. But the choice is yours. If you say, I choose neither, then the court can impose an injunction to stop you from further distribution, but it won't order your code released under the GPL. ... Of course, you could avoid all such troubles in the first place by not stealing GPL code to begin with" Seriously? What that basically means is you can't use GPL'd code in a non-GPL'd product/project. Saying if you do it is OK, but you'll be required to replace the code or change your license is standing-on-ones-head. Risking a forced reimplementation of a core component of an existing application is 'just nuts'. From albert at spenarnc.xs4all.nl Mon Jan 17 08:30:18 2011 From: albert at spenarnc.xs4all.nl (Albert van der Horst) Date: 17 Jan 2011 13:30:18 GMT Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> Message-ID: In article , Adam Skutt wrote: >On Jan 14, 5:17=A0pm, Albert van der Horst >wrote: >> >> I really don't follow that. You need a tremendous set to write gimp. >> Obviously you won't write gimp in Python. >> > >You need a tremendous set to write /the majority of the applications >on your computer/. > >On my desktop right now, I have running: >* Google Chrome >* TweetDeck >* PuTTY >* Pidgin >* Game for Windows Launcher >* Free Download Manager >* Steam Client >* A Windows Control Panel Window > >None of those applications could be written with his proposed widget >set, he's literally 0/7 on running applications. If the situation >isn't the same on your computer then your application usage is highly >unusual or you don't understand what widgets are used to construct >your applications. You've just told me that Python would no longer be >suitable for constructing the majority of GUI applications on the >planet. We are not talking about running applications, but about writing applications. I count 4000+ .py files in my /usr/share alone on Ubuntu. Your set is totally unrepresentative for those scripts. >Adam Groetjes Albert -- -- Albert van der Horst, UTRECHT,THE NETHERLANDS Economic growth -- being exponential -- ultimately falters. albert at spe&ar&c.xs4all.nl &=n http://home.hccnet.nl/a.w.m.van.der.horst From albert at spenarnc.xs4all.nl Mon Jan 17 08:37:10 2011 From: albert at spenarnc.xs4all.nl (Albert van der Horst) Date: 17 Jan 2011 13:37:10 GMT Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <4d337983$0$29983$c3e8da3$5496439d@news.astraweb.com> Message-ID: In article <4d337983$0$29983$c3e8da3$5496439d at news.astraweb.com>, Steven D'Aprano wrote: >On Sun, 16 Jan 2011 07:18:16 -0800, Adam Skutt wrote: > >[...] > >I'm afraid I found most of your post hard to interpret, because you >didn't give sufficient context for me to understand it. You refer to "his >proposed widget set", but with no clue as to who he is, or what the >widget set is, or what essential widgets you continue missing. I can >guess "he" is rantingrick, but am not sure -- there's only so much of his >time-wasting I can read before reaching for the killfile. Rantingrick >believes he is doing us a service by haranguing us incessantly into >scratching *his* poorly thought-out itches, regardless of practicality or >actual need. > >But putting that aside, I'd like to comment on a few points: > >[...] >> If the situation isn't >> the same on your computer then your application usage is highly unusual >> or you don't understand what widgets are used to construct your >> applications. You've just told me that Python would no longer be >> suitable for constructing the majority of GUI applications on the >> planet. > >No, that does not follow. Unless "he" (I'll assume it is rantingrick) has >proposed hunting down and destroying all third-party GUI tool sets, what >you've been told is that *one specific* tool set is unsuitable for >constructing the majority of GUI apps. Actually it was me. Those guys don't even know how to attribute or quote. >[...] >> Really, if you believe the case to be otherwise, I truly believe you >> aren't paying attention to your own computer(s), or don't understand how >> the applications you use are constructed. What's out there isn't >> interesting, it's what people use that's interesting, and people tend to >> use GUIs that are moderately to highly complicated. > >Well, true, but people tend to *use* the parts of the GUIs that are >simple and basic. Not only do the big complicated apps get all the press >even when they are actually a niche product (everyone knows about >Photoshop, but more people use MS Paint) but it's a truism that most >people use something like 20% of the functionality of big, complicated >GUI apps. Most people use Microsoft Word or OpenOffice for little more >than text editing with formatting. > >It's easy for power users to overestimate how much of their complicated >GUIs are actually used by the average user. Or even the *above* average >user. Or even for the support of other packages, I gave the bluetooth example. I think the use of Python for e.g. configuration of packages is quite common. > >I suspect that a variation of Zipf's Law probably holds for GUI >complexity -- if you rank the widgets in order of most to least commonly >used, I expect that you'll see actual use drop away rapidly and at an >accelerated rate. E.g. the widget in second place might be used roughly >half as often as the widget in first place place, the widget in third >place one third as often, the widget in fourth place one quarter as >often, and so forth. That is the point I wanted to make. >-- >Steven Groetjes Albert -- -- Albert van der Horst, UTRECHT,THE NETHERLANDS Economic growth -- being exponential -- ultimately falters. albert at spe&ar&c.xs4all.nl &=n http://home.hccnet.nl/a.w.m.van.der.horst From albert at spenarnc.xs4all.nl Mon Jan 17 08:55:35 2011 From: albert at spenarnc.xs4all.nl (Albert van der Horst) Date: 17 Jan 2011 13:55:35 GMT Subject: examples of realistic multiprocessing usage? References: <2011011611053732597-tomfsessile@gmailcom> Message-ID: In article , Philip Semanchuk wrote: >I grepped through the code to see that it's using = >multiprocessing.Listener. I didn't go any further than that because our = >project is BSD licensed and the license for Gluino is unclear. Until I = >find out whether or not its under an equally permissive license, I can't = >borrow ideas and/or code from it. You have been brain washed by the Intellectual Properties congsy. Of course you can read through code to borrow idea's from it. >Hope it's of some help to you, though. > >Cheers >Philip= -- -- Albert van der Horst, UTRECHT,THE NETHERLANDS Economic growth -- being exponential -- ultimately falters. albert at spe&ar&c.xs4all.nl &=n http://home.hccnet.nl/a.w.m.van.der.horst From rdmurray at bitdance.com Mon Jan 17 09:23:39 2011 From: rdmurray at bitdance.com (R. David Murray) Date: Mon, 17 Jan 2011 09:23:39 -0500 Subject: [Python-Dev] [python-committers] [RELEASED] Python 3.2 rc 1 In-Reply-To: <20110117083342.719d9ab5@dino> References: <4D329F55.9040903@python.org> <20110117083342.719d9ab5@dino> Message-ID: <20110117142339.E3D2D24108C@kimball.webabinitio.net> On Mon, 17 Jan 2011 08:33:42 +0000, Mark Summerfield wrote: > from ..Graphics import Xpm > SVG = 1 > > I can do the relative import with Python 3.0 and 3.1 but not with > 3.2rc1: What about 3.1.3? I wonder if it is related to this issue: http://bugs.python.org/issue7902 -- R. David Murray www.bitdance.com From wxjmfauth at gmail.com Mon Jan 17 09:31:00 2011 From: wxjmfauth at gmail.com (jmfauth) Date: Mon, 17 Jan 2011 06:31:00 -0800 (PST) Subject: __pycache__, one more good reason to stck with Python 2? Message-ID: <23e02e0d-b2f1-4b52-85ea-d1feba99dd37@22g2000prx.googlegroups.com> As a scientist using computer tools, and not as a computer scientist, I discovered Python long time ago (it was in its 1.5.6 version) and I remain an happy user up to now date. Yesterday, I was happy to download and test Python 3.2rc1. Python is still this powerful and pleasant language, but... I fall on this cached pyc's directory, __pycache__. Without to many explanations (I think they will be obvious for an end user), one word: a nithtmare. From list at qtrac.plus.com Mon Jan 17 09:33:21 2011 From: list at qtrac.plus.com (Mark Summerfield) Date: Mon, 17 Jan 2011 14:33:21 +0000 Subject: [Python-Dev] [python-committers] [RELEASED] Python 3.2 rc 1 In-Reply-To: <20110117142339.E3D2D24108C@kimball.webabinitio.net> References: <4D329F55.9040903@python.org> <20110117083342.719d9ab5@dino> <20110117142339.E3D2D24108C@kimball.webabinitio.net> Message-ID: <20110117143321.627793c9@dino> On Mon, 17 Jan 2011 09:23:39 -0500 "R. David Murray" wrote: > On Mon, 17 Jan 2011 08:33:42 +0000, Mark Summerfield > wrote: > > from ..Graphics import Xpm > > SVG = 1 > > > > I can do the relative import with Python 3.0 and 3.1 but not with > > 3.2rc1: > > What about 3.1.3? I wonder if it is related to this issue: > > http://bugs.python.org/issue7902 > > -- > R. David Murray www.bitdance.com I'm not sure. Anyway, I have reported it a Georg's suggestion: http://bugs.python.org/issue10926 And mentioned issue7902. -- Mark Summerfield, Qtrac Ltd, www.qtrac.eu C++, Python, Qt, PyQt - training and consultancy "Programming in Python 3" - ISBN 0321680561 http://www.qtrac.eu/py3book.html From brian.curtin at gmail.com Mon Jan 17 09:40:41 2011 From: brian.curtin at gmail.com (Brian Curtin) Date: Mon, 17 Jan 2011 08:40:41 -0600 Subject: __pycache__, one more good reason to stck with Python 2? In-Reply-To: <23e02e0d-b2f1-4b52-85ea-d1feba99dd37@22g2000prx.googlegroups.com> References: <23e02e0d-b2f1-4b52-85ea-d1feba99dd37@22g2000prx.googlegroups.com> Message-ID: On Mon, Jan 17, 2011 at 08:31, jmfauth wrote: > As a scientist using computer tools, and not as a computer > scientist, I discovered Python long time ago (it was in its > 1.5.6 version) and I remain an happy user up to now date. > Yesterday, I was happy to download and test Python 3.2rc1. > Python is still this powerful and pleasant language, but... > > I fall on this cached pyc's directory, __pycache__. Without > to many explanations (I think they will be obvious for an > end user), one word: a nithtmare. What are the specific problems you've seen with __pycache__? Have you read PEP 3147 [0], at least through the rationale section? [0] http://www.python.org/dev/peps/pep-3147/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From leoboiko at gmail.com Mon Jan 17 09:46:22 2011 From: leoboiko at gmail.com (leoboiko) Date: Mon, 17 Jan 2011 06:46:22 -0800 (PST) Subject: python 3 and Unicode line breaking References: <32f75200-b4d8-4ec8-b07d-4740a79c28b6@g26g2000vba.googlegroups.com> <4d2f959a$0$29984$c3e8da3$5496439d@news.astraweb.com> <55c2f7dc-d4d8-4939-85de-41c19c336f23@k25g2000vbl.googlegroups.com> <4d3074b0$0$29984$c3e8da3$5496439d@news.astraweb.com> <4d30c9ba$0$29984$c3e8da3$5496439d@news.astraweb.com> <9b84ec07-0679-4bc6-96ea-b37231d3fd83@b25g2000vbz.googlegroups.com> <4d30f82a$0$29984$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Jan 14, 11:28?pm, Steven D'Aprano wrote: > Does this help? > > http://packages.python.org/kitchen/api-text-display.html Ooh, it doesn?t appear to be a full line-breaking implementation but it certainly helps for what I want to do in my project! Thanks much! (There?s also the alternative of using something like PyICU to access a C library, something I had forgotten about entirely.) Antoine wrote: > If you're willing to help on that matter (or some aspects of them, > textwrap-specific or not), you can open an issue on > http://bugs.python.org and propose a patch. I?m not sure my poor coding is good enough to contribute but I?ll keep this is mind if I find myself implementing the algorithm or wanting to patch textwrap. Thanks. From sherm.pendley at gmail.com Mon Jan 17 10:47:44 2011 From: sherm.pendley at gmail.com (Sherm Pendley) Date: Mon, 17 Jan 2011 10:47:44 -0500 Subject: [OT] Python like lanugages References: <86a904f8-05b0-435f-81d6-7450650f1679@glegroupsg2000goo.googlegroups.com> <4d329899$0$43988$742ec2ed@news.sonic.net> <7x8vylfcvz.fsf@ruckus.brouhaha.com> <4d32c7cf$0$29983$c3e8da3$5496439d@news.astraweb.com> <7xipxo9er6.fsf@ruckus.brouhaha.com> Message-ID: Tim Harig writes: > Functional programming has been around a long time; but, it only regained > conciousness outside of academia because of its hyped abilities to > make threading easier. I believe the widespread use of some functional techniques in JavaScript had a lot to do with that as well. sherm-- -- Sherm Pendley Cocoa Developer From steve+comp.lang.python at pearwood.info Mon Jan 17 10:57:07 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 17 Jan 2011 15:57:07 GMT Subject: __pycache__, one more good reason to stck with Python 2? References: <23e02e0d-b2f1-4b52-85ea-d1feba99dd37@22g2000prx.googlegroups.com> Message-ID: <4d3466d3$0$29983$c3e8da3$5496439d@news.astraweb.com> On Mon, 17 Jan 2011 06:31:00 -0800, jmfauth wrote: > As a scientist using computer tools, and not as a computer scientist, I > discovered Python long time ago (it was in its 1.5.6 version) and I > remain an happy user up to now date. Yesterday, I was happy to download > and test Python 3.2rc1. Python is still this powerful and pleasant > language, but... > > I fall on this cached pyc's directory, __pycache__. Without to many > explanations (I think they will be obvious for an end user), one word: a > nithtmare. No, I'm sorry, they're not obvious at all. I too have been using Python since version 1.5 (although I don't remember the minor point release), and I've also been testing Python 3.2, but I'm afraid I have no idea why you think that __pycache__ is a nightmare. -- Steven From steve+comp.lang.python at pearwood.info Mon Jan 17 11:01:04 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 17 Jan 2011 16:01:04 GMT Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <4d337983$0$29983$c3e8da3$5496439d@news.astraweb.com> <044a5101-948d-4458-9c94-57dbb3e25f67@m35g2000vbn.googlegroups.com> Message-ID: <4d3467bf$0$29983$c3e8da3$5496439d@news.astraweb.com> On Sun, 16 Jan 2011 15:41:41 -0800, Adam Skutt wrote: > If you're going to expect me to be that pedantic, then pay me the > courtesy of taking the time to find the necessary context. Nevertheless, > it's not the least bit unreasonable to address deficiencies in the > standard library as deficiencies in the language, like it or not; I'm afraid that's precisely what I'm arguing you *can't* do -- there's nothing reasonable about equating the standard library with the language. Some languages don't even have a standard library, or for that matter a standard implementation. Would you argue that Python is unsuitable for parsing real-world (i.e. broken) HTML because Beautiful Soup is not in the standard library? That Python is unsuitable for scientific and mathematical processing because Scipy and Numpy aren't in the standard library? That you can't do natural language processing with Python because NLTK is not in the standard library? That you can't do image processing with Python because PIL is a third-party library? There's no doubt that having a good standard library with a rich toolset is a beneficial feature of Python. Python's philosophy of "batteries included" has been one of it's strengths. But it would be absurd to claim that if a tool isn't in the standard library, the language can't do it. > and since rick's proposal involves regressing the standard library.. If you think I'm supporting Rick's incoherent proposal, you've misunderstood me. In any case, I'm not disputing that if you wish to write modern looking, and feeling, GUI apps, you need a powerful widget set, or spend all your time reinventing the wheel. Nevertheless, you can do good, useful work with only a minimal widget set. Back when dinosaurs walked the earth, I wrote GUI apps using an *extremely* limited widget set, equivalent to window, button, text field, and simple bit-mapped graphics -- no menus, no scroll bars, no list boxes, no styled text, and certainly no layout widgets. By today's standards, that's even more primitive than the average web UI, and yet some of the apps written in it were useful and even elegant. (I don't claim credit for the elegant ones, but the ones I wrote were at least useful to me.) You can get surprisingly far with only simple widgets and a bit of ingenuity. Or at least by lowering your expectations. *wink* -- Steven From stefan_ml at behnel.de Mon Jan 17 11:02:00 2011 From: stefan_ml at behnel.de (Stefan Behnel) Date: Mon, 17 Jan 2011 17:02:00 +0100 Subject: [OT] Python like lanugages In-Reply-To: References: <86a904f8-05b0-435f-81d6-7450650f1679@glegroupsg2000goo.googlegroups.com> <4d329899$0$43988$742ec2ed@news.sonic.net> <7x8vylfcvz.fsf@ruckus.brouhaha.com> <4d32c7cf$0$29983$c3e8da3$5496439d@news.astraweb.com> <7xipxo9er6.fsf@ruckus.brouhaha.com> Message-ID: Sherm Pendley, 17.01.2011 16:47: > I believe the widespread use of some functional techniques in JavaScript > had a lot to do with that as well. I doubt that there's really "widespread use" of functional techniques in JavaScript. Such code may be widely deployed, but that doesn't tell anything about the skill level of 'the average' JavaScript developer wrt. functional techniques. Stefan From rantingrick at gmail.com Mon Jan 17 11:02:36 2011 From: rantingrick at gmail.com (rantingrick) Date: Mon, 17 Jan 2011 08:02:36 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <79a8a$4d332d1a$4275d90a$3986@FUSE.NET> <64976187-88ad-47c9-9bc6-c0712a657264@j32g2000yqc.googlegroups.com> <3af4fd5e-8cc9-4cec-aad2-cbf82ad3bab3@l24g2000vby.googlegroups.com> Message-ID: Everyone needs to jump off the troll wagon and come back to reality. We need to get back on topic and compare Tkinter and wxPython by nuts and bolts. We need to make a decision based on facts NOT misconceptions, based on merit NOT prejudice, and finally based on sanity NOT lunacy! ------------------- Tkinter Pros: ------------------- * Very simple to use! * Geometry managers are a delight! ------------------ Tkinter Cons: ------------------ * very limited widget set! * some of the widgets have a asinine API! * very poor packaging of widgets (extensions) * the events where given horrendous names: ButtonRelease-1 -> ButtonOneRelease B1-Motion -> ButtonOneMotion etc * slow execution speed due to calling ANOTHER interpretor! * not extensible within our community! * no real Grid Widget. * no real Listveiw Widget. * not real OpenGL Widget (togl sucks). * the Canvas is lacking manipulators, rotation, etc. ------------------- WxPython Pros: ------------------- * A truly 21st century widget set! * More feature rich than one could ever dream! * Fully instructional, professional, and exhaustive Free Demo! * Up to date OpenGL support ------------------- WxPython Cons ------------------- * Screenshots are outdated * Large library (however we can split it!) * Some people are (w)xenophobic From stefan_ml at behnel.de Mon Jan 17 11:29:10 2011 From: stefan_ml at behnel.de (Stefan Behnel) Date: Mon, 17 Jan 2011 17:29:10 +0100 Subject: [OT] Python like lanugages [was Re: After C++, what with Python?] In-Reply-To: References: <86a904f8-05b0-435f-81d6-7450650f1679@glegroupsg2000goo.googlegroups.com> <4d329899$0$43988$742ec2ed@news.sonic.net> <7x8vylfcvz.fsf@ruckus.brouhaha.com> <4d32c7cf$0$29983$c3e8da3$5496439d@news.astraweb.com> <4d3425fe$0$29983$c3e8da3$5496439d@news.astraweb.com> Message-ID: Tim Harig, 17.01.2011 13:25: > If I didn't think Python was a good language, I wouldn't be here. > Nevertheless, it isn't a good fit for many pieces of software where a > systems language is better suited. Reasons include ease of distribution > without an interpeter, non-necessity of distributing source with the > product, ability to leverage multiple CPU and multicore systems, and > simple sequential performance. > > Given that Python does't work well in many areas, we could just give up > and accept having to write C++ for our day jobs or we can look for a > language which bridges the gap between those tasks that require C++'s > level of control and those which work well for dynamic languages. > Java attempted to do that, and has the market share to show that the > concept works, but I think that it missed the mark for many needs. It is > still much lower level then Python for purposes of rapid developement > and too slow to be competative for non-long-lived tasks. So seriously need to take a look at Cython. http://cython.org Stefan From robin at reportlab.com Mon Jan 17 11:52:23 2011 From: robin at reportlab.com (Robin Becker) Date: Mon, 17 Jan 2011 16:52:23 +0000 Subject: [OT] Python like lanugages In-Reply-To: References: <86a904f8-05b0-435f-81d6-7450650f1679@glegroupsg2000goo.googlegroups.com> <4d329899$0$43988$742ec2ed@news.sonic.net> <7x8vylfcvz.fsf@ruckus.brouhaha.com> <4d32c7cf$0$29983$c3e8da3$5496439d@news.astraweb.com> <7xipxo9er6.fsf@ruckus.brouhaha.com> Message-ID: <4D3473C7.80506@chamonix.reportlab.co.uk> On 17/01/2011 16:02, Stefan Behnel wrote: > Sherm Pendley, 17.01.2011 16:47: >> I believe the widespread use of some functional techniques in JavaScript >> had a lot to do with that as well. > > I doubt that there's really "widespread use" of functional techniques in > JavaScript. Such code may be widely deployed, but that doesn't tell anything > about the skill level of 'the average' JavaScript developer wrt. functional > techniques. > > Stefan > I'm not sure whether this counts as functional, but it certainly not traditional imperative style http://www.vpri.org/pdf/tr2008003_experimenting.pdf it was mentioned in some recent clp thread. -- Robin Becker From robin at reportlab.com Mon Jan 17 11:52:23 2011 From: robin at reportlab.com (Robin Becker) Date: Mon, 17 Jan 2011 16:52:23 +0000 Subject: [OT] Python like lanugages In-Reply-To: References: <86a904f8-05b0-435f-81d6-7450650f1679@glegroupsg2000goo.googlegroups.com> <4d329899$0$43988$742ec2ed@news.sonic.net> <7x8vylfcvz.fsf@ruckus.brouhaha.com> <4d32c7cf$0$29983$c3e8da3$5496439d@news.astraweb.com> <7xipxo9er6.fsf@ruckus.brouhaha.com> Message-ID: <4D3473C7.80506@chamonix.reportlab.co.uk> On 17/01/2011 16:02, Stefan Behnel wrote: > Sherm Pendley, 17.01.2011 16:47: >> I believe the widespread use of some functional techniques in JavaScript >> had a lot to do with that as well. > > I doubt that there's really "widespread use" of functional techniques in > JavaScript. Such code may be widely deployed, but that doesn't tell anything > about the skill level of 'the average' JavaScript developer wrt. functional > techniques. > > Stefan > I'm not sure whether this counts as functional, but it certainly not traditional imperative style http://www.vpri.org/pdf/tr2008003_experimenting.pdf it was mentioned in some recent clp thread. -- Robin Becker From alan at baselinedata.co.uk Mon Jan 17 12:10:15 2011 From: alan at baselinedata.co.uk (Alan Harris-Reid) Date: Mon, 17 Jan 2011 17:10:15 +0000 Subject: Career path - where next? In-Reply-To: References: <4D2DD8BC.1020907@googlemail.com> <4D31F7ED.4040307@baselinedata.co.uk> Message-ID: <4D3477F7.6010309@baselinedata.co.uk> Hi Fred, thanks for the reply. I have already contacted old clients (those that are still in business), but unfortunately they have either gone the 'off the shelf' route (ie. don't use bespoke software any more), or moved-over to .NET, which is a route which I don't want to follow. Still, at least I've let them know what I am doing now and you never know where word-of-mouth may lead. I tried C# for a while, but after Foxpro it appeared to me to be such a horrible, clunky language. Then I discovered Python about a year ago and have loved it ever since. Regards, Alan ------------------------------------------------------------------------ On 17/01/2011 16:13, Sells, Fred wrote: > Since you were burned by Microsoft dropping foxpro, I suspect many > others were also. I would contact all my old clients and see how they > are coping and tell them you've been converting FoxPro to *xyz* and can > help them (assuming of course that you have done some of this). If they > don't have anything, ask them for leads contacts. > > Trying to get a job "cold" is much more difficult than if you have a > referral. -------------- next part -------------- An HTML attachment was scrubbed... URL: From venu.allipuram at gmail.com Mon Jan 17 12:35:30 2011 From: venu.allipuram at gmail.com (Venu) Date: Mon, 17 Jan 2011 09:35:30 -0800 (PST) Subject: Need the list of XML parsers Message-ID: <9f75fdb8-78e3-4675-a48a-64147e0a0095@w29g2000vba.googlegroups.com> Hi, I am getting into serious Python programming for Electronic CAD tools, I am trying to find the best XML parser modules available. I need good searching capability for attributes, nodes and block of XML. I am looking for either a recommendation or previous forum links. Thanks Venu From sudheer.s at sudheer.net Mon Jan 17 12:48:36 2011 From: sudheer.s at sudheer.net (Sudheer Satyanarayana) Date: Mon, 17 Jan 2011 23:18:36 +0530 Subject: Need the list of XML parsers In-Reply-To: <9f75fdb8-78e3-4675-a48a-64147e0a0095@w29g2000vba.googlegroups.com> References: <9f75fdb8-78e3-4675-a48a-64147e0a0095@w29g2000vba.googlegroups.com> Message-ID: <4D3480F4.6070606@sudheer.net> On Monday 17 January 2011 11:05 PM, Venu wrote: > Hi, > > I am getting into serious Python programming for Electronic CAD tools, > I am trying to find the best XML parser modules available. I need good > searching capability for attributes, nodes and block of XML. I am > looking for either a recommendation or previous forum links. > > Thanks > Venu lxml is a good XML parser. It supports xpath and IIRC, xquery. I wrote a blog post about it a while ago - http://techchorus.net/web-scraping-lxml -- With warm regards, Sudheer. S Personal home page - http://sudheer.net | Tech Chorus - http://techchorus.net Web and IT services - http://binaryvibes.co.in From hackingkk at gmail.com Mon Jan 17 12:49:12 2011 From: hackingkk at gmail.com (hackingKK) Date: Mon, 17 Jan 2011 23:19:12 +0530 Subject: Need the list of XML parsers In-Reply-To: <9f75fdb8-78e3-4675-a48a-64147e0a0095@w29g2000vba.googlegroups.com> References: <9f75fdb8-78e3-4675-a48a-64147e0a0095@w29g2000vba.googlegroups.com> Message-ID: <4D348118.9090801@gmail.com> Hi Venu, Use element tree module. This comes with Python itself and does all that you need with presision. I have already used it and it does a very very good job. Happy hacking. Krishnakant. On 17/01/11 23:05, Venu wrote: > Hi, > > I am getting into serious Python programming for Electronic CAD tools, > I am trying to find the best XML parser modules available. I need good > searching capability for attributes, nodes and block of XML. I am > looking for either a recommendation or previous forum links. > > Thanks > Venu > From stefan_ml at behnel.de Mon Jan 17 12:57:13 2011 From: stefan_ml at behnel.de (Stefan Behnel) Date: Mon, 17 Jan 2011 18:57:13 +0100 Subject: Need the list of XML parsers In-Reply-To: <9f75fdb8-78e3-4675-a48a-64147e0a0095@w29g2000vba.googlegroups.com> References: <9f75fdb8-78e3-4675-a48a-64147e0a0095@w29g2000vba.googlegroups.com> Message-ID: Venu, 17.01.2011 18:35: > I am getting into serious Python programming for Electronic CAD tools, > I am trying to find the best XML parser modules available. I need good > searching capability for attributes, nodes and block of XML. I am > looking for either a recommendation or previous forum links. Canonical answers: cElementTree and lxml. The first, if you want to use stdlib tools, the second, if you can afford external dependencies. Both are mostly compatible, very fast and memory friendly. lxml has lots of features in addition. Stefan From wxjmfauth at gmail.com Mon Jan 17 13:17:08 2011 From: wxjmfauth at gmail.com (jmfauth) Date: Mon, 17 Jan 2011 10:17:08 -0800 (PST) Subject: __pycache__, one more good reason to stck with Python 2? References: <23e02e0d-b2f1-4b52-85ea-d1feba99dd37@22g2000prx.googlegroups.com> <4d3466d3$0$29983$c3e8da3$5496439d@news.astraweb.com> Message-ID: <0c62aacd-e6d2-4778-81d6-e06924192add@j1g2000vbl.googlegroups.com> > No, I'm sorry, they're not obvious at all. These reasons become obious as soon as you start working. Let's take a practical point view. It did not take a long time to understand, that it is much simpler to delete the __pycache__ directory everytime I compile my scripts than to visit it just because I deleted or renamed a .py file in my working directory. How long will it take to find on the web tools to parse and delete ophan .pyc files on a hd? If I get (stupidly, I agree) a .pyc file and want to test it. Should I create manually a cache alongside my test.py script? If I wish to delete the numerous auxiliary files a TeX document produces, I just del /rm .* to keep a clean working dir. With Python now? Impossible! The files are spread in two dirs (at least). ... That's life, unfortunately. From orasnita at gmail.com Mon Jan 17 13:27:38 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Mon, 17 Jan 2011 20:27:38 +0200 Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com><4d337983$0$29983$c3e8da3$5496439d@news.astraweb.com><044a5101-948d-4458-9c94-57dbb3e25f67@m35g2000vbn.googlegroups.com> <4d3467bf$0$29983$c3e8da3$5496439d@news.astraweb.com> Message-ID: From: "Steven D'Aprano" Subject: Re: Tkinter: The good, the bad, and the ugly! > On Sun, 16 Jan 2011 15:41:41 -0800, Adam Skutt wrote: > >> If you're going to expect me to be that pedantic, then pay me the >> courtesy of taking the time to find the necessary context. Nevertheless, >> it's not the least bit unreasonable to address deficiencies in the >> standard library as deficiencies in the language, like it or not; > > I'm afraid that's precisely what I'm arguing you *can't* do -- there's > nothing reasonable about equating the standard library with the language. > Some languages don't even have a standard library, or for that matter a > standard implementation. > > Would you argue that Python is unsuitable for parsing real-world (i.e. > broken) HTML because Beautiful Soup is not in the standard library? That > Python is unsuitable for scientific and mathematical processing because > Scipy and Numpy aren't in the standard library? That you can't do natural > language processing with Python because NLTK is not in the standard > library? That you can't do image processing with Python because PIL is a > third-party library? > > There's no doubt that having a good standard library with a rich toolset > is a beneficial feature of Python. Python's philosophy of "batteries > included" has been one of it's strengths. But it would be absurd to claim > that if a tool isn't in the standard library, the language can't do it. Well, you are right, but it is not the same thing. If Tkinter is included by default in Python package, much more programmers would be tempted to use Tkinter instead of WxPython, so they will create bad programs. The best idea would be to include WxPython in Python and eliminate Tkinter. If this is not possible, because of those reasons that were discussed here, then the second-best idea would be to just eliminate Tkinter from Python, because as you said, if it is not included, it doesn't mean that a module can't be used, but in that case the programmers won't be tempted to use it. And Python should also not include any editor because for some programmers it is absolutely useless anyway. The editor can be installed separately very easy and the programmers can choose the editor they like. The problem is not that WxPython is not encouraged, but that Tkinter is encouraged because it is promoted. Octavian From jsmithfield at hotmail.co.uk Mon Jan 17 13:34:13 2011 From: jsmithfield at hotmail.co.uk (J Smithfield) Date: Mon, 17 Jan 2011 18:34:13 +0000 Subject: FW: Entry of Non-European (Unicode or UTF-8) characters In-Reply-To: References: Message-ID: From: jsmithfield at hotmail.co.uk To: wiki at python.org Subject: Entry of Non-European (Unicode or UTF-8) characters Date: Mon, 17 Jan 2011 18:26:36 +0000 Hi there. I have difficulty entering directly non-European Unicode characters into Python 3.2's interpreter. When I do enter them, I get "????"; pastinf is OK though, but who wants to paste all the time? I use Python 3 on Windows XP and Vista. The same problem was experienced on other developement systems, but most have since corrected the problem: Python should not be the last to do so! J -------------- next part -------------- An HTML attachment was scrubbed... URL: From rantingrick at gmail.com Mon Jan 17 13:53:17 2011 From: rantingrick at gmail.com (rantingrick) Date: Mon, 17 Jan 2011 10:53:17 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com><4d337983$0$29983$c3e8da3$5496439d@news.astraweb.com><044a5101-948d-4458-9c94-57dbb3e25f67@m35g2000vbn.googlegroups.com> <4d3467bf$0$29983$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Jan 17, 12:27?pm, "Octavian Rasnita" wrote: > And Python should also not include any editor because for > some programmers it is absolutely useless anyway. The > editor can be installed separately very easy and the > programmers can choose the editor they like. The problem > is not that WxPython is not encouraged, but that Tkinter > is encouraged because it is promoted. These are very true statements Octavian! I had always believed that Python should include a GUI AND and IDE even though Tkinter and IDLE are severely dated. Now i am thinking that maybe we should judt dump both and leave it that way. Why did i previously think this way? Well my concern was to keep the goals of GvR alive. That is that programming should be for everyone and having a simplistic IDE and GUI in the stdlib help foster these goals. However that was circa 1980's and we now find our selfs a decade past the 21st century. We now have a huge amount of 3rd party GUI's and IDE's. Do we even need to include them any more? Sure one could always argue batteries included however with the plethera of 3rd party downloads, the batteries may not be included, but they are located witin reach at the reqister check out Q. Do we need ANY GUI or ANY IDE in the stdlib anymore? I say probably not considering the availability of 3rd party downloads. What say you, Python community? From alexlbasso at gmail.com Mon Jan 17 14:08:52 2011 From: alexlbasso at gmail.com (AlexLBasso) Date: Mon, 17 Jan 2011 11:08:52 -0800 (PST) Subject: 9 Month Python contract in Austin, TX Message-ID: I am recruiting for a 9 month contract (with contract extension potential) for a company in North Austin. I am seeking an Applications Developer very familiar with the JavaScript toolkit. The position requires specific experience with Python, Dojo, and JQuery. In this role, you would be developing front-end applications for the management and configuration of IPS systems. If you (or someone you know) is interested in this opportunity, please contact me at 512.257.7903 or abasso at aerotek.com From rantingrick at gmail.com Mon Jan 17 14:15:12 2011 From: rantingrick at gmail.com (rantingrick) Date: Mon, 17 Jan 2011 11:15:12 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com><4d337983$0$29983$c3e8da3$5496439d@news.astraweb.com><044a5101-948d-4458-9c94-57dbb3e25f67@m35g2000vbn.googlegroups.com> <4d3467bf$0$29983$c3e8da3$5496439d@news.astraweb.com> Message-ID: More post thoughts on removing all GUI's from stdlib... This change would not only affect Python in a positive way (lighting the proverbial load) it would also serve to speed the advancement of Tkinter because now Tkinter could advance at its own pace untethered by the release cycles of Python! You guys need to start thinking about this from a purley community perspective. From askutt at gmail.com Mon Jan 17 14:26:15 2011 From: askutt at gmail.com (Adam Skutt) Date: Mon, 17 Jan 2011 11:26:15 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <4d337983$0$29983$c3e8da3$5496439d@news.astraweb.com> <044a5101-948d-4458-9c94-57dbb3e25f67@m35g2000vbn.googlegroups.com> <4d3467bf$0$29983$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Jan 17, 11:01?am, Steven D'Aprano wrote: > > I'm afraid that's precisely what I'm arguing you *can't* do -- there's > nothing reasonable about equating the standard library with the language. > Some languages don't even have a standard library, or for that matter a > standard implementation. And we're not discussing those languages, we're discussing Python, which has an explicit policy of "batteries included". As such, criticism of the standard library is perfectly acceptable under the name "Python", whether you like it or not. Besides, it's inevitable anyway. > Would you argue that Python is unsuitable for parsing real-world (i.e. > broken) HTML because Beautiful Soup is not in the standard library? That > Python is unsuitable for scientific and mathematical processing because > Scipy and Numpy aren't in the standard library? That you can't do natural > language processing with Python because NLTK is not in the standard > library? That you can't do image processing with Python because PIL is a > third-party library? > Out of the box? Absolutely. Again, expecting me to explicitly state that is worthless pedantry, especially when the discussion at hand proposes modifications to the standard library. There's no question, in context, about what my words meant. > There's no doubt that having a good standard library with a rich toolset > is a beneficial feature of Python. Python's philosophy of "batteries > included" has been one of it's strengths. But it would be absurd to claim > that if a tool isn't in the standard library, the language can't do it. > Too bad that isn't what I claimed, nor can what I said be interpreted as such in any way whatsoever, unless you're a pedantic twit. > > and since rick's proposal involves regressing the standard library.. > > If you think I'm supporting Rick's incoherent proposal, you've > misunderstood me. > If you think what I said somehow even implies you support his proposal, then you need to take a few English courses. > Nevertheless, you can do good, useful work > with only a minimal widget set. Back when dinosaurs walked the earth, I > wrote GUI apps using an *extremely* limited widget set, equivalent to > window, button, text field, and simple bit-mapped graphics -- no menus, > no scroll bars, no list boxes, no styled text, and certainly no layout > widgets. By today's standards, that's even more primitive than the > average web UI, and yet some of the apps written in it were useful and > even elegant. (I don't claim credit for the elegant ones, but the ones I > wrote were at least useful to me.) You can get surprisingly far with only > simple widgets and a bit of ingenuity. Or at least by lowering your > expectations. *wink* And when a time machine warps all back to the 1980s, that argument might have some merit. Since you're not Dr. Emmett Brown, I suggest you refrain from making arguments that predicate themselves on time travel. Adam From debatem1 at gmail.com Mon Jan 17 14:35:39 2011 From: debatem1 at gmail.com (geremy condra) Date: Mon, 17 Jan 2011 11:35:39 -0800 Subject: [OT] Python like lanugages [was Re: After C++, what with Python?] In-Reply-To: References: <86a904f8-05b0-435f-81d6-7450650f1679@glegroupsg2000goo.googlegroups.com> <4d329899$0$43988$742ec2ed@news.sonic.net> <7x8vylfcvz.fsf@ruckus.brouhaha.com> <4d32c7cf$0$29983$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Mon, Jan 17, 2011 at 1:12 AM, Tim Harig wrote: > On 2011-01-16, geremy condra wrote: >> On Sun, Jan 16, 2011 at 3:03 AM, Tim Harig wrote: >>> On 2011-01-16, Steven D'Aprano wrote: >>>> If the author thinks that Go is a "tried and true" (his words, not mine) >>>> language "where programmers can go to look for work", I think he's >>>> fooling himself. >>> >>> No I wouldn't say that it has reached market penetration yet; but, it >>> has more momentum then any language I am familiar with. ?I wouldn't be >>> at all surprised to see it becoming quite common in the next five years. >> >> I would be very surprised if this were the case. As you point out, >> languages typically have very long incubation times before they reach >> any kind of serious market penetration. This seems doubly true for a >> relatively narrowly targeted language that is in many ways on the >> wrong side of history. > > I wouldn't say Go is narrowly targeted. ?It's a systems language that can > compete in the same domain with scripting languages. ?It is true that most > languages have long incubation periods; but, corporate support can change > that quite a bit. ?C#, being backed by Microsoft, managed to go mainstream > pretty quickly. This seems... shall we say, overly optimistic. I've seen no evidence at all that Go is even trying to compete with scripting languages, and I don't know of anyone who would actually use it where a shell script might do. AFAICS, it is an unabashedly concurrency-centric systems language for people who are willing to sacrifice some speed and control for legible code. That's not an impossibly narrow niche (and it certainly has deep pockets) but it *is* narrow compared to a general purpose language like Java or Python. I'd also note that the .NET languages received much, much more in the way of support than Go seems to be. >>> How long has it taken Python to reach its present level of market >>> penetration? ?And, I still don't see a huge amount of professional Python >>> use outside of web developement. ?Go has only been public for less then >>> a year. >> >> Python's very widely used for scripting and related tasks, and has a >> pretty big user base in academia and the sciences. > > Python has been widely used by people like us that happen to like the > language and found ways to use it in our workplaces; but, most of the > time it is an unofficial use that the company. ?You still don't see many > companies doing large scale internal development using Python and you > definately don't see any doing external developement using a language > that gives the customers full access to the source code. Right, I mean, it's not like the company that wrote Go would *ever* stoop to using Python ;) Seriously, I see a lot of Python in use in the sciences, HPC, etc. It's also a major part of nearly every linux distro, is widely used by defense and intelligence contractors for what they consider to be critical infrastructure, etc etc etc. Even if none of that were true though, the fact is that you can be a successful language and only deal with the web, and even you admit that Python is widely used in that context. >>> Personally, I think the time is ripe for a language that bridges the >>> gap between ease of use dynamic languages with the performance and >>> distribution capabilities of a full systems level language. >> >> I agree. That does not make Go that language, and many of the choices >> made during Go's development indicate that they don't think it's that >> language either. I'm speaking specifically of its non-object model, >> lack of exceptions, etc. > > 1. Go has an object model. ?What it lacks is an object hierarchy where all > ? ? ? ?object are decended from a single root "object" since it does > ? ? ? ?not support object inheritance as it is used in most languages. > ? ? ? ?In Go we simply adapt an object to meet the needs of the newer > ? ? ? ?object by adding whatever new functionality is needed. Go has structs. Its structs are not objects, principally because they can't do real inheritance. You can do similar things ('structural inheritance') to C structs, and nobody argues that C is OO. > 2. Go has a similar mechanism to exceptions, defer/panic/recover. ?It does > ? ? ? ?downplay Defer, panic, and recover only allow you to build a recovery stack. That's like saying that try/except isn't needed anymore because you have the with statement. Do you think you could get through a rewrite of Django without ripping out some hair over that? >>>This is after all the promise the VM based languages made but never >>> really fulfilled. It is also high time for a fully concurrent language fully >>> capable of taking advantage of multicore processors without having to >>> deal with the inherent dangers of threading. ?There are several good >>> choices available for both a even a few that fit both bills; but, few of >>> them have the support of a company like Google that is capable of the >>> push required to move the language into the mainstream. >> >> You might be right, but I doubt we'll know one way or the other in the >> next 5 years. Personally, I'm hoping that functional language use >> continues to grow. > > I personally doubt that purely functional languages will ever make it > mainstream. ?Functional programming has been around for a long time and > never really ever managed to break out of academic research. I doubt it as well. Doesn't mean I can't hope for it- I would really like to see something a little more readable out of that community, a kind of hybrid between haskell's writability and python's readability. > The current > interest in functional programming stems merely because some announced > that it would be *the* way to utilize multicore computers. ?Having looked > into the space somewhat, there is more hype then substantiation for > purely functional concepts. ?What the hype did do was return attention > to SCP style concurrency using actors and MPI and I think that will be > the direction taken for concurrent programming into the future. I'm not an expert in concurrency and can't evaluate the claims many are making in that space. I know that I still find writing highly parallel programs easier in C and Python than I do in Haskell, but I seldom wind up thinking that concurrency was the hard part of the problem I was solving. > I believe functional programming will make an impact in the mainstream in > the form of functionally enabled multiparadigm but not purely functional > languages. ?I think you will see code that uses more functional concepts > as guidelines to better code. Ditto. Geremy Condra From rantingrick at gmail.com Mon Jan 17 14:39:11 2011 From: rantingrick at gmail.com (rantingrick) Date: Mon, 17 Jan 2011 11:39:11 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com><4d337983$0$29983$c3e8da3$5496439d@news.astraweb.com><044a5101-948d-4458-9c94-57dbb3e25f67@m35g2000vbn.googlegroups.com> <4d3467bf$0$29983$c3e8da3$5496439d@news.astraweb.com> Message-ID: <0947517d-a2c4-44af-83cb-8ed4299b143a@k25g2000vbl.googlegroups.com> Even more post thoughts on removing all GUI's from stlib... Q: If you could replace Tkinter with any module/library (THAT IS NOT A GUI OR IDE!!) what would you like to see fill its place? PS: And please make this decision from a *community* perspective and not pure selfishness. From usernet at ilthio.net Mon Jan 17 14:41:54 2011 From: usernet at ilthio.net (Tim Harig) Date: Mon, 17 Jan 2011 19:41:54 +0000 (UTC) Subject: [OT] Python like lanugages [was Re: After C++, what with Python?] References: <86a904f8-05b0-435f-81d6-7450650f1679@glegroupsg2000goo.googlegroups.com> <4d329899$0$43988$742ec2ed@news.sonic.net> <7x8vylfcvz.fsf@ruckus.brouhaha.com> <4d32c7cf$0$29983$c3e8da3$5496439d@news.astraweb.com> <4d3425fe$0$29983$c3e8da3$5496439d@news.astraweb.com> Message-ID: In comp.lang.python, you wrote: > Tim Harig, 17.01.2011 13:25: >> If I didn't think Python was a good language, I wouldn't be here. >> Nevertheless, it isn't a good fit for many pieces of software where a >> systems language is better suited. Reasons include ease of distribution >> without an interpeter, non-necessity of distributing source with the >> product, ability to leverage multiple CPU and multicore systems, and >> simple sequential performance. >> >> Given that Python does't work well in many areas, we could just give up >> and accept having to write C++ for our day jobs or we can look for a >> language which bridges the gap between those tasks that require C++'s >> level of control and those which work well for dynamic languages. >> Java attempted to do that, and has the market share to show that the >> concept works, but I think that it missed the mark for many needs. It is >> still much lower level then Python for purposes of rapid developement >> and too slow to be competative for non-long-lived tasks. > > So seriously need to take a look at Cython. > > http://cython.org One of the arguments for Python has always made is that you can optimize it by writing the most important parts in C. Perhaps that is a crutch that has held the communty back from seeking higher performance solutions in the language itself. I prefer a single language as opposed to a creolization of two. Go gives me more less complete independence from C. I can write pretty much anything I would like using almost pure Go and because it generates a native binary with similar performance to C, I don't need to resort to using another language. I certainly don't need to require anybody who wants to use a program I have compiled to install an interpreter. From vishal2295 at gmail.com Mon Jan 17 14:43:56 2011 From: vishal2295 at gmail.com (vishal kumar rai) Date: Mon, 17 Jan 2011 11:43:56 -0800 (PST) Subject: CodeFest - Online Coding Festival by Computer Engineering Society, IT-BHU Message-ID: Hello, We are delighted to inform you that CodeFest, the annual International online coding festival of Computer Engineering Society, IT-BHU, has been unveiled. CodeFest is a unique fest wherein concepts of mathematics, logic, artificial intelligence, algorithms, language syntax, etc. are required to be deployed in programming; these concepts manifest themselves in solving problems effectively and efficiently! CodeFest was started last year. CodeFest'10 was a phenomenal success with participation from all over the globe. CodeFest'11 is geared up with some new and pepped up events, while maintaining the integrity of its standards. Here is a brief description of the constituent online events: * Mathmania: A mathematical puzzle contest that puts mathematical and computational skills to test. * Manthan: An algorithm intensive programming contest that would require coders to tailor existing standard algorithms to solve real life computation problems. * Virtual Combat: An educational game wherein teams of programmed robotic tanks will fight the battles for glory. Codes Do Fight! Watch this out. * Perplexed: A programming contest, aimed to test the knowledge of C, wherein codes will be rewarded against syntactic constraints. * Ratespiel: A technical quiz covering different areas of Computer Science. This year CodeFest, in association with Technex'11, brings onsite events: * Eniac: An open software exhibition where you get an opportunity to demonstrate your software from any domain. * Code Warrior: A multiple round contest to award the title of 'ultimate computer geek'. Visit our website to get more details. Few exciting statistics about CodeFest'10: * 2354 registrations (including 128 professionals) from 680 different institutions, across 59 countries. * Some participants were among the winners of Google Code Jam, Top Coder SRMs and ACM ICPC. * Total prize money was a whopping amount of 260,000 INR! * CodeFest '10 was the largest online coding festival of the Indian subcontinent in 2010 in terms of prize money! * CodeFest'10 was the second largest online coding festival of the Indian subcontinent in 2010, next to Bitwise. * Gained recognition from several international organizations including Codechef, Adobe, British Telecom, TCS and IEEE. The CodeFest'11 team has set out to unleash a coding extravaganza. You can't afford to miss the chance to be a part of this fest! Still have any questions? Feel free to contact us at codefest at itbhu.ac.in or reach us personally at: * Mohit Bansal mohit.bansal.cse06 at itbhu.ac.in * Saket Saurabh +91-9452-825-690 saket.saurabh.cse07 at itbhu.ac.in We wish you all the best for CodeFest and for your future endeavors. Be free and Happy Coding! Team CodeFest IT-BHU From rantingrick at gmail.com Mon Jan 17 14:44:53 2011 From: rantingrick at gmail.com (rantingrick) Date: Mon, 17 Jan 2011 11:44:53 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <4d337983$0$29983$c3e8da3$5496439d@news.astraweb.com> <044a5101-948d-4458-9c94-57dbb3e25f67@m35g2000vbn.googlegroups.com> <4d3467bf$0$29983$c3e8da3$5496439d@news.astraweb.com> Message-ID: <00d83365-8bb0-435e-929f-d20f456faf2b@f20g2000vbc.googlegroups.com> On Jan 17, 1:26?pm, Adam Skutt wrote: > On Jan 17, 11:01?am, Steven D'Aprano > Nevertheless, you can do good, useful work > > with only a minimal widget set. Back when dinosaurs walked the earth, [...snip...] > And when a time machine warps all back to the 1980s, that argument > might have some merit. ?Since you're not Dr. Emmett Brown, I suggest > you refrain from making arguments that predicate themselves on time > travel. You know Adam some people could use that very same sarcastic argument against you for claiming that Tkinter is "just as good" or *giggles* "better" than wxPython. From venu.allipuram at gmail.com Mon Jan 17 15:01:03 2011 From: venu.allipuram at gmail.com (Venu Allipuram) Date: Mon, 17 Jan 2011 14:01:03 -0600 Subject: Need the list of XML parsers In-Reply-To: <4D3480F4.6070606@sudheer.net> References: <9f75fdb8-78e3-4675-a48a-64147e0a0095@w29g2000vba.googlegroups.com> <4D3480F4.6070606@sudheer.net> Message-ID: lxml is a great one, but it is not simple to install libxml and libxslt on Linux using user permissions. Also it is hard to package the scripts after the complete development for release. Did anybody try this, if so please let me know your thoughts on this. Thanks venu On Mon, Jan 17, 2011 at 11:48 AM, Sudheer Satyanarayana < sudheer.s at sudheer.net> wrote: > On Monday 17 January 2011 11:05 PM, Venu wrote: > >> Hi, >> >> I am getting into serious Python programming for Electronic CAD tools, >> I am trying to find the best XML parser modules available. I need good >> searching capability for attributes, nodes and block of XML. I am >> looking for either a recommendation or previous forum links. >> >> Thanks >> Venu >> > lxml is a good XML parser. It supports xpath and IIRC, xquery. > > I wrote a blog post about it a while ago - > http://techchorus.net/web-scraping-lxml > > > -- > With warm regards, > Sudheer. S > Personal home page - http://sudheer.net | Tech Chorus - > http://techchorus.net > Web and IT services - http://binaryvibes.co.in > -- ************************ Venu Allipuram 479-445-3502 -------------- next part -------------- An HTML attachment was scrubbed... URL: From solipsis at pitrou.net Mon Jan 17 15:02:47 2011 From: solipsis at pitrou.net (Antoine Pitrou) Date: Mon, 17 Jan 2011 21:02:47 +0100 Subject: 9 Month Python contract in Austin, TX References: Message-ID: <20110117210247.7418f6a9@pitrou.net> On Mon, 17 Jan 2011 11:08:52 -0800 (PST) AlexLBasso wrote: > I am recruiting for a 9 month contract (with contract extension > potential) for a company in North Austin. Please post on the job board instead: http://python.org/community/jobs/ Thank you Antoine. From orasnita at gmail.com Mon Jan 17 15:04:57 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Mon, 17 Jan 2011 22:04:57 +0200 Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com><4d337983$0$29983$c3e8da3$5496439d@news.astraweb.com><044a5101-948d-4458-9c94-57dbb3e25f67@m35g2000vbn.googlegroups.com><4d3467bf$0$29983$c3e8da3$5496439d@news.astraweb.com> Message-ID: From: "rantingrick" Sent: Monday, January 17, 2011 8:53 PM Subject: Re: Tkinter: The good, the bad, and the ugly! On Jan 17, 12:27 pm, "Octavian Rasnita" wrote: > And Python should also not include any editor because for > some programmers it is absolutely useless anyway. The > editor can be installed separately very easy and the > programmers can choose the editor they like. The problem > is not that WxPython is not encouraged, but that Tkinter > is encouraged because it is promoted. These are very true statements Octavian! I had always believed that Python should include a GUI AND and IDE even though Tkinter and IDLE are severely dated. Now i am thinking that maybe we should judt dump both and leave it that way. Why did i previously think this way? Well my concern was to keep the goals of GvR alive. That is that programming should be for everyone and having a simplistic IDE and GUI in the stdlib help foster these goals. However that was circa 1980's and we now find our selfs a decade past the 21st century. We now have a huge amount of 3rd party GUI's and IDE's. Do we even need to include them any more? Sure one could always argue batteries included however with the plethera of 3rd party downloads, the batteries may not be included, but they are located witin reach at the reqister check out Q. Do we need ANY GUI or ANY IDE in the stdlib anymore? I say probably not considering the availability of 3rd party downloads. What say you, Python community? And one more thing. Not all the Python programmers create desktop apps so a GUI lib is useless. Some of them use Python only for web programming or only for system administration. Octavian From orasnita at gmail.com Mon Jan 17 15:08:56 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Mon, 17 Jan 2011 22:08:56 +0200 Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com><4d337983$0$29983$c3e8da3$5496439d@news.astraweb.com><044a5101-948d-4458-9c94-57dbb3e25f67@m35g2000vbn.googlegroups.com><4d3467bf$0$29983$c3e8da3$5496439d@news.astraweb.com> Message-ID: <2BA870E82295475CA5568A2E57E1DE6E@teddy> From: "Adam Skutt" Subject: Re: Tkinter: The good, the bad, and the ugly! On Jan 17, 11:01 am, Steven D'Aprano wrote: > > I'm afraid that's precisely what I'm arguing you *can't* do -- there's > nothing reasonable about equating the standard library with the language. > Some languages don't even have a standard library, or for that matter a > standard implementation. And we're not discussing those languages, we're discussing Python, which has an explicit policy of "batteries included". As such, criticism of the standard library is perfectly acceptable under the name "Python", whether you like it or not. Besides, it's inevitable anyway. "Batteries included"? Python doesn't follow this policy at all. We can say that maybe PHP follows it, but not Python. And if this is the wanted policy, why should it be "cheap batteries included" and not "strong batteries included"? Octavian From martin.hellwig at dcuktec.org Mon Jan 17 15:09:44 2011 From: martin.hellwig at dcuktec.org (Martin P. Hellwig) Date: Mon, 17 Jan 2011 20:09:44 +0000 Subject: Should there be a 'core' python install? (was Re: Tkinter: The good, the bad, and the ugly!) In-Reply-To: <0947517d-a2c4-44af-83cb-8ed4299b143a@k25g2000vbl.googlegroups.com> References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com><4d337983$0$29983$c3e8da3$5496439d@news.astraweb.com><044a5101-948d-4458-9c94-57dbb3e25f67@m35g2000vbn.googlegroups.com> <4d3467bf$0$29983$c3e8da3$5496439d@news.astraweb.com> <0947517d-a2c4-44af-83cb-8ed4299b143a@k25g2000vbl.googlegroups.com> Message-ID: On 01/17/11 19:39, rantingrick wrote: Q: If you could replace Tkinter with any module/library (THAT IS NOT A > GUI OR IDE!!) what would you like to see fill its place? Some systems, like FreeBSD have Tkinter and IDLE as a separate package which is not installed by default. Purely because those systems don't assume that the user has X installed. Though since this is a windows world, that argument is rather mood. But then again the win32 extension modules aren't installed by default, rather inconsistent in that perspective. You could argue that there is some advantage especially for starters, having at least something to start on (IDLE), but on the other hand there are already a couple of special 'distribution packages' that aim to include anything remotely python related. I think that the ones that should make these decisions (if any) are those how spend _their_ time integrating the dependencies and making the builds for public download. Perhaps for pythons 3 lifetime there should still be a 'python' maintained tkinter integration. But I don't see any reason why this should be continued for 4, fortunately it is not my call and I actually quite like Tkinter. -- mph From venu.allipuram at gmail.com Mon Jan 17 15:34:06 2011 From: venu.allipuram at gmail.com (Venu) Date: Mon, 17 Jan 2011 12:34:06 -0800 (PST) Subject: Need the list of XML parsers In-Reply-To: Message-ID: <625910e2-22c2-4365-bc34-d0f9d5af8c65@glegroupsg2000goo.googlegroups.com> Hi Stefan Using cElementTree, would you be willing show to me how to find the nodes with certain attribute, ie search using attributes and attibute values. I did not see any example code from the cElementTree official website. Regards, Venu From venu.allipuram at gmail.com Mon Jan 17 15:34:06 2011 From: venu.allipuram at gmail.com (Venu) Date: Mon, 17 Jan 2011 12:34:06 -0800 (PST) Subject: Need the list of XML parsers In-Reply-To: Message-ID: <625910e2-22c2-4365-bc34-d0f9d5af8c65@glegroupsg2000goo.googlegroups.com> Hi Stefan Using cElementTree, would you be willing show to me how to find the nodes with certain attribute, ie search using attributes and attibute values. I did not see any example code from the cElementTree official website. Regards, Venu From nagle at animats.com Mon Jan 17 15:40:26 2011 From: nagle at animats.com (John Nagle) Date: Mon, 17 Jan 2011 12:40:26 -0800 Subject: [OT] Python like lanugages In-Reply-To: References: <86a904f8-05b0-435f-81d6-7450650f1679@glegroupsg2000goo.googlegroups.com> <4d329899$0$43988$742ec2ed@news.sonic.net> <7x8vylfcvz.fsf@ruckus.brouhaha.com> <4d32c7cf$0$29983$c3e8da3$5496439d@news.astraweb.com> <7xipxo9er6.fsf@ruckus.brouhaha.com> Message-ID: <4d34a939$0$44014$742ec2ed@news.sonic.net> On 1/17/2011 1:34 AM, Tim Harig wrote: > On 2011-01-17, Paul Rubin wrote: >> geremy condra writes: > > Which is rather interesting because the OOP community had > traditionally though of functional programming as a 1960's thing that > didn't work out. Right. The big problem with functional programming is that each function has only one output. It's interesting that this is purely a syntactical problem. Functional programs look like trees. They have "fan in", gathering many inputs into one, but no "fan out", spreading outputs out to multiple destinations. Conceptually, you could have a programming language which allows you to write programs where functions had multiple outputs which could be directed to different places, but which weren't stored as state. Such programs would be directed acyclic graphs, rather than trees. That's been done once or twice. There's what are called "single assignment languages". Each variable can only be assigned once. The result looks like an imperative language but works like a functional language. Look up "SISAL" for an example. This approach is good for concurrency and optimization, but it never caught on. Note that from a concurrency standpoint, immutability is very useful. It's a lot like single assignment. You can pass around immutable objects to concurrent threads without race conditions, provided that memory management can handle concurrency. This works in Python, although, because of the GIL problem, it doesn't help performance. A form of Python for highly concurrent work is possible. More things would have to be immutable, at least once the program went multi-thread. If modules, classes, and functions were immutable in multi-thread code, global locking wouldn't be necessary, and you could put tens or hundreds of CPUs to work on one program. But Guido would never allow that, so concurrency in Python is doomed to suck. John Nagle From askutt at gmail.com Mon Jan 17 15:54:05 2011 From: askutt at gmail.com (Adam Skutt) Date: Mon, 17 Jan 2011 12:54:05 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com><4d337983$0$29983$c3e8da3$5496439d@news.astraweb.com><044a5101-948d-4458-9c94-57dbb3e25f67@m35g2000vbn.googlegroups.com><4d3467bf$0$29983$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Jan 17, 3:08?pm, "Octavian Rasnita" wrote: >> From: "Adam Skutt" >> And we're not discussing those languages, we're discussing Python, >> which has an explicit policy of "batteries included". ?As such, >> criticism of the standard library is perfectly acceptable under the >> name "Python", whether you like it or not. ?Besides, it's inevitable >> anyway. > > "Batteries included"? > > Python doesn't follow this policy at all. We can say that maybe PHP follows it, but not Python. > http://lmgtfy.com/?q=python+%22batteries+included%22&l=1 > And if this is the wanted policy, why should it be "cheap batteries included" and not "strong batteries included"? You'd have this same argument regardless of GUI toolkit you end up picking, or even if you choose to not include one at all. This would be because none of them are universal solutions, all of them have deficiencies (actual or perceived) that make them unsuitable for certain applications. Adam From usernet at ilthio.net Mon Jan 17 16:07:42 2011 From: usernet at ilthio.net (Tim Harig) Date: Mon, 17 Jan 2011 21:07:42 +0000 (UTC) Subject: [OT] Python like lanugages [was Re: After C++, what with Python?] References: <86a904f8-05b0-435f-81d6-7450650f1679@glegroupsg2000goo.googlegroups.com> <4d329899$0$43988$742ec2ed@news.sonic.net> <7x8vylfcvz.fsf@ruckus.brouhaha.com> <4d32c7cf$0$29983$c3e8da3$5496439d@news.astraweb.com> Message-ID: On 2011-01-17, geremy condra wrote: > On Mon, Jan 17, 2011 at 1:12 AM, Tim Harig wrote: >> On 2011-01-16, geremy condra wrote: >> I wouldn't say Go is narrowly targeted. ?It's a systems language that can >> compete in the same domain with scripting languages. ?It is true that most >> languages have long incubation periods; but, corporate support can change >> that quite a bit. ?C#, being backed by Microsoft, managed to go mainstream >> pretty quickly. > > This seems... shall we say, overly optimistic. I've seen no evidence > at all that Go is even trying to compete with scripting languages, and > I don't know of anyone who would actually use it where a shell script > might do. AFAICS, it is an unabashedly concurrency-centric systems I don't write Python where shell scripts will do either. I have rewritten several simple Python scripts in Go. I will not be leaving Python completely; but, Go will likely replace Python for most of my large scale programming needs. > might do. AFAICS, it is an unabashedly concurrency-centric systems > language for people who are willing to sacrifice some speed and > control for legible code. That's not an impossibly narrow niche (and > it certainly has deep pockets) but it *is* narrow compared to a > general purpose language like Java or Python. You are writing Go into far too narrow of a niche then it actually is. In fact, whatever language you are commenting on doesn't sound like Go at all. Go is every bit of a general purpose programming language. It is useful for the same basic applications that you would otherwise write in Java. It can do pretty much anything that you can do in C, with the probable exception of writing operating systems. I have been using C/C++ for most of my programming career; but, everything that I have done can be done with Go. I am not really sure where you are seeing such narrowing limitations. Support for concurrency is really icing on the cake. I find it rather supprising that so many modern languages do not already support full concurrency constructs. >>> Python's very widely used for scripting and related tasks, and has a >>> pretty big user base in academia and the sciences. >> >> Python has been widely used by people like us that happen to like the >> language and found ways to use it in our workplaces; but, most of the >> time it is an unofficial use that the company. ?You still don't see many >> companies doing large scale internal development using Python and you >> definately don't see any doing external developement using a language >> that gives the customers full access to the source code. > > Right, I mean, it's not like the company that wrote Go would *ever* > stoop to using Python ;) I have never said that there are not companies doing developement in Python and certainly not for web programming; but, a handful of companies that have adopted Python doesn't make it mainstream. Good luck finding many Python jobs in my area. Java, C#, Visual Basic, PHP, *COBOL*, RPG-IV, and, to a lesser extent, C++ jobs are available in abundance. The few Python jobs that are available are for web based programming. >> 1. Go has an object model. ?What it lacks is an object hierarchy where all >> ? ? ? ?object are decended from a single root "object" since it does >> ? ? ? ?not support object inheritance as it is used in most languages. >> ? ? ? ?In Go we simply adapt an object to meet the needs of the newer >> ? ? ? ?object by adding whatever new functionality is needed. > > Go has structs. Its structs are not objects, principally because they > can't do real inheritance. You can do similar things ('structural > inheritance') to C structs, and nobody argues that C is OO. http://www.infoq.com/interviews/johnson-armstrong-oop Listen to the third point. Object orientation is quite possible even without inheritance. Not all programming languages support the same set of OOP features. Not all classless OOP programming languages support inheritance. The basic definition of object oriented programming is programing with self contained objects which contain their own data and the procedures necessary to manipulate that data. >> 2. Go has a similar mechanism to exceptions, defer/panic/recover. ?It does >> ? ? ? ?downplay > > Defer, panic, and recover only allow you to build a recovery stack. > That's like saying that try/except isn't needed anymore because you > have the with statement. Do you think you could get through a rewrite > of Django without ripping out some hair over that? I don't know what you are referencing about Django as I don't work on or with the project; but, if one wanted exceptions with similar sematics to Python's, it could easily be built around Go's defer/panic/recover. There are actually packages availble that recreate exceptions as they are used in Ruby and other languages. The only think defer/panic/recover lacks is an exception class containing more more detailed information about what actually went wrong. >> The current >> interest in functional programming stems merely because some announced >> that it would be *the* way to utilize multicore computers. ?Having looked >> into the space somewhat, there is more hype then substantiation for >> purely functional concepts. ?What the hype did do was return attention >> to SCP style concurrency using actors and MPI and I think that will be >> the direction taken for concurrent programming into the future. > > I'm not an expert in concurrency and can't evaluate the claims many > are making in that space. I know that I still find writing highly > parallel programs easier in C and Python than I do in Haskell, but I > seldom wind up thinking that concurrency was the hard part of the > problem I was solving. I don't know much about Haskells concurrent programming constructs. If you have found concurrent programming easy, then your problems probably don't involve many shared resources. From alex.kapps at web.de Mon Jan 17 16:10:38 2011 From: alex.kapps at web.de (Alexander Kapps) Date: Mon, 17 Jan 2011 22:10:38 +0100 Subject: Tkinter: The good, the bad, and the ugly! In-Reply-To: References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com><4d337983$0$29983$c3e8da3$5496439d@news.astraweb.com><044a5101-948d-4458-9c94-57dbb3e25f67@m35g2000vbn.googlegroups.com><4d3467bf$0$29983$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4D34B04E.8050309@web.de> On 17.01.2011 21:04, Octavian Rasnita wrote: > I say probably not considering the availability of 3rd party > downloads. What say you, Python community? Available as 3rd party downloads: XML,HTML,... HTTP,FTP,SMTP,POP,IMAP/... MD5,SHA,... zip,bzip,... and so on and so on and so on. Remove them all just because they are available as 3rd party downloads? The "Batteries included" of Python is just *great* and I vote for *more* not less batteries! > And one more thing. Not all the Python programmers create desktop apps so a GUI lib is useless. Some of them use Python only for web programming or only for system administration. Not all Python programmers do web programming, so please remove the useless HTML junk too. Almost every beginner wants to do GUIs or at least some graphic stuff. Removing the GUI module from the stdlib would be plain wrong IMHO. But I don't understand the whole issue anyway. It isn't that you need to fire up your torrent client and wait 48 hours for the Python download to complete. Why remove useful (to many, not most) stuff from the lib? From usernet at ilthio.net Mon Jan 17 16:59:56 2011 From: usernet at ilthio.net (Tim Harig) Date: Mon, 17 Jan 2011 21:59:56 +0000 (UTC) Subject: [OT] Python like lanugages References: <86a904f8-05b0-435f-81d6-7450650f1679@glegroupsg2000goo.googlegroups.com> <4d329899$0$43988$742ec2ed@news.sonic.net> <7x8vylfcvz.fsf@ruckus.brouhaha.com> <4d32c7cf$0$29983$c3e8da3$5496439d@news.astraweb.com> <7xipxo9er6.fsf@ruckus.brouhaha.com> <4d34a939$0$44014$742ec2ed@news.sonic.net> Message-ID: On 2011-01-17, John Nagle wrote: > That's been done once or twice. There's what are called "single > assignment languages". Each variable can only be assigned once. > The result looks like an imperative language but works like a functional > language. Look up "SISAL" for an example. This approach is good > for concurrency and optimization, but it never caught on. That is rather interesting; especially since most of the current hype is about immutability and the lack of side affects of functional languages rather then functional decomposition using lamda calculus constructs. > Note that from a concurrency standpoint, immutability is very > useful. It's a lot like single assignment. You can pass around > immutable objects to concurrent threads without race conditions, > provided that memory management can handle concurrency. This works I wonder if even that is fully necessary. In, Ada procedure arguments specify whether or not they can be changed within the procedure effectively creating a gateway whereby side affects can be specified. If you take that a step further and require: 1. The function of a scope is completely closed. It cannot access anything from the scope above it except what is passed to it as arguments. 2. Arguments that can be changed must be copied on write so that they don't directly affect the memory of the outer scope. Then you can be sure that the functions have no side affects outside of the values that they return. Internally, the function can use imperative semantics that require mutability such as iteration instead recursion without affecting anything above it. From rantingrick at gmail.com Mon Jan 17 17:00:47 2011 From: rantingrick at gmail.com (rantingrick) Date: Mon, 17 Jan 2011 14:00:47 -0800 (PST) Subject: Should there be a 'core' python install? (was Re: Tkinter: The good, the bad, and the ugly!) References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com><4d337983$0$29983$c3e8da3$5496439d@news.astraweb.com><044a5101-948d-4458-9c94-57dbb3e25f67@m35g2000vbn.googlegroups.com> <4d3467bf$0$29983$c3e8da3$5496439d@news.astraweb.com> <0947517d-a2c4-44af-83cb-8ed4299b143a@k25g2000vbl.googlegroups.com> Message-ID: <3ac4634f-1c6f-4552-9e7f-a2d912a77dc2@f35g2000vbl.googlegroups.com> On Jan 17, 2:09?pm, "Martin P. Hellwig" wrote: > fortunately it is not my call and I actually > quite like Tkinter. Are you sure about that Martin? :))) > From: "Martin P. Hellwig" > Newsgroups: comp.lang.python > Subject: Re: GUIs - A Modest Proposal > Date: Fri, 11 Jun 2010 07:10:35 +0100 [...snip...] > Though I don't like tkinter either, but I don't seem to hate it as > much as others do. hmm? From sysengp2p at gmail.com Mon Jan 17 17:19:13 2011 From: sysengp2p at gmail.com (carlo) Date: Mon, 17 Jan 2011 14:19:13 -0800 (PST) Subject: UTF-8 question from Dive into Python 3 Message-ID: Hi, recently I had to study *seriously* Unicode and encodings for one project in Python but I left with a couple of doubts arised after reading the unicode chapter of Dive into Python 3 book by Mark Pilgrim. 1- Mark says: "Also (and you?ll have to trust me on this, because I?m not going to show you the math), due to the exact nature of the bit twiddling, there are no byte-ordering issues. A document encoded in UTF-8 uses the exact same stream of bytes on any computer." Is it true UTF-8 does not have any "big-endian/little-endian" issue because of its encoding method? And if it is true, why Mark (and everyone does) writes about UTF-8 with and without BOM some chapters later? What would be the BOM purpose then? 2- If that were true, can you point me to some documentation about the math that, as Mark says, demonstrates this? thank you Carlo From jake.biesinger at gmail.com Mon Jan 17 17:20:59 2011 From: jake.biesinger at gmail.com (Jake Biesinger) Date: Mon, 17 Jan 2011 14:20:59 -0800 (PST) Subject: Efficient python 2-d arrays? Message-ID: Hi all, Using numpy, I can create large 2-dimensional arrays quite easily. >>> import numpy >>> mylist = numpy.zeros((100000000,2), dtype=numpy.int32) Unfortunately, my target audience may not have numpy so I'd prefer not to use it. Similarly, a list-of-tuples using standard python syntax. >>> mylist = [(0,0) for i in xrange(100000000) but this method uses way too much memory (>4GB for 100 million items, compared to 1.5GB for numpy method). Since I want to keep the two elements together during a sort, I *can't* use array.array. >>> mylist = [array.array('i',xrange(100000000)), array.array('i',xrange(100000000))] If I knew the size in advance, I could use ctypes arrays. >>> from ctypes import * >>> class myStruct(Structure): >>> _fields_ = [('x',c_int),('y',c_int)] >>> mylist_type = myStruct * 100000000 >>> mylist = mylist_type() but I don't know that size (and it can vary between 1 million-200 million), so preallocating doesn't seem to be an option. Is there a python standard library way of creating *efficient* 2-dimensional lists/arrays, still allowing me to sort and append? Thanks! From debatem1 at gmail.com Mon Jan 17 17:21:17 2011 From: debatem1 at gmail.com (geremy condra) Date: Mon, 17 Jan 2011 14:21:17 -0800 Subject: [OT] Python like lanugages [was Re: After C++, what with Python?] In-Reply-To: References: <86a904f8-05b0-435f-81d6-7450650f1679@glegroupsg2000goo.googlegroups.com> <4d329899$0$43988$742ec2ed@news.sonic.net> <7x8vylfcvz.fsf@ruckus.brouhaha.com> <4d32c7cf$0$29983$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Mon, Jan 17, 2011 at 1:07 PM, Tim Harig wrote: > On 2011-01-17, geremy condra wrote: >> On Mon, Jan 17, 2011 at 1:12 AM, Tim Harig wrote: >>> On 2011-01-16, geremy condra wrote: >>> I wouldn't say Go is narrowly targeted. ?It's a systems language that can >>> compete in the same domain with scripting languages. ?It is true that most >>> languages have long incubation periods; but, corporate support can change >>> that quite a bit. ?C#, being backed by Microsoft, managed to go mainstream >>> pretty quickly. >> >> This seems... shall we say, overly optimistic. I've seen no evidence >> at all that Go is even trying to compete with scripting languages, and >> I don't know of anyone who would actually use it where a shell script >> might do. AFAICS, it is an unabashedly concurrency-centric systems > > I don't write Python where shell scripts will do either. ?I have rewritten > several simple Python scripts in Go. ?I will not be leaving Python > completely; but, Go will likely replace Python for most of my large scale > programming needs. I'm happy that you've found a language you like. I don't happen to share your enthusiasm for it, and I think my arguments are better grounded. I suspect you feel the same about yours, and I'm happy to leave it at that. >> might do. AFAICS, it is an unabashedly concurrency-centric systems >> language for people who are willing to sacrifice some speed and >> control for legible code. That's not an impossibly narrow niche (and >> it certainly has deep pockets) but it *is* narrow compared to a >> general purpose language like Java or Python. > > You are writing Go into far too narrow of a niche then it actually is. ?In > fact, whatever language you are commenting on doesn't sound like Go at all. > > Go is every bit of a general purpose programming language. ?It is useful > for the same basic applications that you would otherwise write in Java. ?It > can do pretty much anything that you can do in C, with the probable > exception of writing operating systems. ?I have been using C/C++ for most > of my programming career; but, everything that I have done can be done with > Go. ?I am not really sure where you are seeing such narrowing limitations. I'm a C, Python, and Haskell developer. Everything I've done could be done in C. I would probably not be happy if I had to, though. Some people get very attached to one language and use it for everything. I'd rather use the right tool for the job. Go is not an ideal language for high-performance code. Despite the occasional claims of others, Go is consistently outperformed by C, C++, and Java on a wide variety of benchmarks. Some claim that Ada and Haskell do as well, and my benchmarks (CPU bound, focused on speed of cryptographic primitives) *seem* to confirm that for Haskell. I say 'seem' because I'm clearly much more familiar with Haskell than with Go, and would be inclined to question my conclusions if they weren't in line with the work of others. You can argue that it's good enough- it is, for most cases- but taking a 20% performance hit rules it out of a lot of systems work, and the C-Go gap in many cases is much larger than that. Go is also not an ideal language for enterprise development. It provides no compatibility or support guarantees; in fact, the website describes it as 'an experiment' and recommends it for 'adventurous users'. There are no independent experts in case something goes wrong, and if it goes belly up a year from now you will have a one year old piece of legacy infrastructure on your hands. Maybe you don't think that this will be the case; in any event, I would not want to try convincing a CFO of that. As you point out, Go is also not a good language for operating systems work. The lack of a widely accepted GUI toolkit weakens your argument about application development. The lack of third party tools and dependence on foreign language bindings weakens your single-language argument. Etc, etc, etc. Taking these things out you are left with very little that Go is compellingly good at. I certainly don't see it displacing Java or C, which you claim is equivalent. > Support for concurrency is really icing on the cake. ?I find it rather > supprising that so many modern languages do not already support full > concurrency constructs. Go's most-lauded feature is its goroutines. I suspect that if this isn't a big deal for you, you aren't its primary use case. >>>> Python's very widely used for scripting and related tasks, and has a >>>> pretty big user base in academia and the sciences. >>> >>> Python has been widely used by people like us that happen to like the >>> language and found ways to use it in our workplaces; but, most of the >>> time it is an unofficial use that the company. ?You still don't see many >>> companies doing large scale internal development using Python and you >>> definately don't see any doing external developement using a language >>> that gives the customers full access to the source code. >> >> Right, I mean, it's not like the company that wrote Go would *ever* >> stoop to using Python ;) > > I have never said that there are not companies doing developement in > Python and certainly not for web programming; but, a handful of companies > that have adopted Python doesn't make it mainstream. ?Good luck finding > many Python jobs in my area. ?Java, C#, Visual Basic, PHP, *COBOL*, > RPG-IV, and, to a lesser extent, C++ jobs are available in abundance. > The few Python jobs that are available are for web based programming. Let me know when you get a job writing Go. >>> 1. Go has an object model. ?What it lacks is an object hierarchy where all >>> ? ? ? ?object are decended from a single root "object" since it does >>> ? ? ? ?not support object inheritance as it is used in most languages. >>> ? ? ? ?In Go we simply adapt an object to meet the needs of the newer >>> ? ? ? ?object by adding whatever new functionality is needed. >> >> Go has structs. Its structs are not objects, principally because they >> can't do real inheritance. You can do similar things ('structural >> inheritance') to C structs, and nobody argues that C is OO. > > http://www.infoq.com/interviews/johnson-armstrong-oop > > Listen to the third point. ?Object orientation is quite possible even > without inheritance. ?Not all programming languages support the same set > of OOP features. ?Not all classless OOP programming languages support > inheritance. ?The basic definition of object oriented programming is > programing with self contained objects which contain their own data and > the procedures necessary to manipulate that data. So C is OOP. Let's agree to disagree on that. >>> 2. Go has a similar mechanism to exceptions, defer/panic/recover. ?It does >>> ? ? ? ?downplay >> >> Defer, panic, and recover only allow you to build a recovery stack. >> That's like saying that try/except isn't needed anymore because you >> have the with statement. Do you think you could get through a rewrite >> of Django without ripping out some hair over that? > > I don't know what you are referencing about Django as I don't work on or > with the project; but, if one wanted exceptions with similar sematics to > Python's, it could easily be built around Go's defer/panic/recover. ?There > are actually packages availble that recreate exceptions as they are used in > Ruby and other languages. ?The only think defer/panic/recover lacks is an > exception class containing more more detailed information about what > actually went wrong. You could also build it in C, yet C is exceptionless and is commonly faulted for that fact. >>> The current >>> interest in functional programming stems merely because some announced >>> that it would be *the* way to utilize multicore computers. ?Having looked >>> into the space somewhat, there is more hype then substantiation for >>> purely functional concepts. ?What the hype did do was return attention >>> to SCP style concurrency using actors and MPI and I think that will be >>> the direction taken for concurrent programming into the future. >> >> I'm not an expert in concurrency and can't evaluate the claims many >> are making in that space. I know that I still find writing highly >> parallel programs easier in C and Python than I do in Haskell, but I >> seldom wind up thinking that concurrency was the hard part of the >> problem I was solving. > > I don't know much about Haskells concurrent programming constructs. ?If you > have found concurrent programming easy, then your problems probably don't > involve many shared resources. Not an enormous number, no. Geremy Condra From martin.hellwig at dcuktec.org Mon Jan 17 17:23:59 2011 From: martin.hellwig at dcuktec.org (Martin P. Hellwig) Date: Mon, 17 Jan 2011 22:23:59 +0000 Subject: Should there be a 'core' python install? (was Re: Tkinter: The good, the bad, and the ugly!) In-Reply-To: <3ac4634f-1c6f-4552-9e7f-a2d912a77dc2@f35g2000vbl.googlegroups.com> References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com><4d337983$0$29983$c3e8da3$5496439d@news.astraweb.com><044a5101-948d-4458-9c94-57dbb3e25f67@m35g2000vbn.googlegroups.com> <4d3467bf$0$29983$c3e8da3$5496439d@news.astraweb.com> <0947517d-a2c4-44af-83cb-8ed4299b143a@k25g2000vbl.googlegroups.com> <3ac4634f-1c6f-4552-9e7f-a2d912a77dc2@f35g2000vbl.googlegroups.com> Message-ID: On 01/17/11 22:00, rantingrick wrote: > On Jan 17, 2:09 pm, "Martin P. Hellwig" > wrote: > >> fortunately it is not my call and I actually >> quite like Tkinter. > > > Are you sure about that Martin? :))) > >> From: "Martin P. Hellwig" >> Newsgroups: comp.lang.python >> Subject: Re: GUIs - A Modest Proposal >> Date: Fri, 11 Jun 2010 07:10:35 +0100 > [...snip...] >> Though I don't like tkinter either, but I don't seem to hate it as >> much as others do. > > hmm? Yep when I started looking much more at other toolkits, I started to like Tkinter more and more. Maybe it its simplicity, or that not every thing starts with a bloody g or that it is actually cross platform usable without jumping through hoops charted in a map where lat/long references have been omitted because in the future a map of mars will not cause confusion, even though it is totally irrelevant now. Actually my favourite GUI toolkit at the moment is pyjamas. -- mph From tr03 at jm.rinkleff.com Mon Jan 17 17:30:10 2011 From: tr03 at jm.rinkleff.com (plovet) Date: Mon, 17 Jan 2011 14:30:10 -0800 (PST) Subject: New to Jpype - TypeError .... class is not callable Message-ID: <30676235.post@talk.nabble.com> Hello, I am trying to use jpype, but after several hours/days, I still cannot get it to work. I get a TypeError --- Package is not Callable error. (See below) I already have done a good workable chunk of code I wrote in Java that implements steam table calculations. After a few weeks of playing with Python, I see that as much more promising for me, and want to switch. But rewriting all of this java code a second time is not going to happen. If I can get jpype to make this ONE link to my existing Java code for me, I can move forward. I would appreciate any help as I can not find the answer in my internet searches. -------------------------------------------------------------------------- I get the following error (IDLE): Traceback (most recent call last): File "C:\Python26\testPype.py", line 16, in myClass = steamPackage.SteamPoint() File "C:\Python26\lib\site-packages\jpype\_jpackage.py", line 53, in __call__ raise TypeError, "Package "+self.__name+" is not Callable" TypeError: Package de.engineering.steam.SteamPoint is not Callable ---------------------------------------------------------------- Here is my Python Code: import jpype jvmPath = "C:\\Program Files\\Java\\jdk1.5.0_13\\jre\\bin\\client\\jvm.dll" options = "-ea" jarPath = "-DJava.class.path=C:\\javaNetBeans\\Projects\\de.engineering.steam\\dist\\de.engineering.steam.jar" jpype.startJVM(jvmPath,options, jarPath) packageName="de.engineering.steam" steamPackage = jpype.JPackage(packageName) myClass = steamPackage.SteamPoint() FYI, I have tried various variations that I could think of, but still no luck myClass = steamPackage.SteamPoint #produces no error, but I can do nothing with this myClass = steamPacakge.NonExistentClass #also produces no error, and just as useless! myClass = steamPackage.SteamPoint(1,40,400) # TypeError as above myClass = steamPackage.SteamPoint.SteamPoint() # TypeError as above --------------------------------------------------------------------- Here is a summary of the Java code for the class. This is stored in a .jar file (see python code). As stated, this single Java class is the gateway to all of my Java code stored in that jar file ... so all I need is to access the functionality in this one class. package de.engineering.steam; import de.engineering.steam.IAPWSF97.*; public class SteamPoint { private double p, t, h, s, v, x; ///etc. etc. //blank constructor - not important public SteamPoint() {} //the *real* constructer public SteamPoint(int switchCode, double d1, double d2) {...} //the methods I need to access after a sucessful construction creation /**Returns the pressure (bara)*/ public double p() {return p;} //etc.... etc... etc.. } THANK YOU for any help! Timothy (plovet) -- View this message in context: http://old.nabble.com/New-to-Jpype---TypeError-....-class-is-not-callable-tp30676235p30676235.html Sent from the Python - python-list mailing list archive at Nabble.com. From alex.kapps at web.de Mon Jan 17 17:30:59 2011 From: alex.kapps at web.de (Alexander Kapps) Date: Mon, 17 Jan 2011 23:30:59 +0100 Subject: UTF-8 question from Dive into Python 3 In-Reply-To: References: Message-ID: <4D34C323.4030909@web.de> On 17.01.2011 23:19, carlo wrote: > Is it true UTF-8 does not have any "big-endian/little-endian" issue > because of its encoding method? And if it is true, why Mark (and > everyone does) writes about UTF-8 with and without BOM some chapters > later? What would be the BOM purpose then? Can't answer your other questions, but the UTF-8 BOM is simply a marker saying "This is a UTF-8 text file, not an ASCII text file" If I'm not wrong, this was a Microsoft invention and surely one of their brightest ideas. I really wish, that this had been done for ANSI some decades ago. Determining the encoding for text files is hard to impossible because such a mark was never introduced. From usernet at ilthio.net Mon Jan 17 17:34:32 2011 From: usernet at ilthio.net (Tim Harig) Date: Mon, 17 Jan 2011 22:34:32 +0000 (UTC) Subject: UTF-8 question from Dive into Python 3 References: Message-ID: On 2011-01-17, carlo wrote: > Is it true UTF-8 does not have any "big-endian/little-endian" issue > because of its encoding method? And if it is true, why Mark (and > everyone does) writes about UTF-8 with and without BOM some chapters > later? What would be the BOM purpose then? Yes, it is true. The BOM simply identifies that the encoding as a UTF-8.: http://unicode.org/faq/utf_bom.html#bom5 > 2- If that were true, can you point me to some documentation about the > math that, as Mark says, demonstrates this? It is true because UTF-8 is essentially an 8 bit encoding that resorts to the next bit once it exhausts the addressible space of the current byte it moves to the next one. Since the bytes are accessed and assessed sequentially, they must be in big-endian order. From solipsis at pitrou.net Mon Jan 17 17:34:57 2011 From: solipsis at pitrou.net (Antoine Pitrou) Date: Mon, 17 Jan 2011 23:34:57 +0100 Subject: UTF-8 question from Dive into Python 3 References: Message-ID: <20110117233457.17f716ea@pitrou.net> On Mon, 17 Jan 2011 14:19:13 -0800 (PST) carlo wrote: > Is it true UTF-8 does not have any "big-endian/little-endian" issue > because of its encoding method? Yes. > And if it is true, why Mark (and > everyone does) writes about UTF-8 with and without BOM some chapters > later? What would be the BOM purpose then? "BOM" in this case is a misnomer. For UTF-8, it is only used as a marker (a magic number, if you like) to signal than a given text file is UTF-8. The UTF-8 "BOM" does not say anything about byte order; and, actually, it does not change with endianness. (note that it is not required to put an UTF-8 "BOM" at the beginning of text files; it is just a hint that some tools use when generating/reading UTF-8) > 2- If that were true, can you point me to some documentation about the > math that, as Mark says, demonstrates this? Math? UTF-8 is simply a byte-oriented (rather than word-oriented) encoding. There is no math involved, it just works by construction. Regards Antoine. From tjreedy at udel.edu Mon Jan 17 17:47:28 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Mon, 17 Jan 2011 17:47:28 -0500 Subject: Tkinter: The good, the bad, and the ugly! In-Reply-To: <3af4fd5e-8cc9-4cec-aad2-cbf82ad3bab3@l24g2000vby.googlegroups.com> References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <79a8a$4d332d1a$4275d90a$3986@FUSE.NET> <64976187-88ad-47c9-9bc6-c0712a657264@j32g2000yqc.googlegroups.com> <3af4fd5e-8cc9-4cec-aad2-cbf82ad3bab3@l24g2000vby.googlegroups.com> Message-ID: On 1/16/2011 11:20 PM, rantingrick wrote: > Ok, try this... > > http://juicereceiver.sourceforge.net/screenshots/index.php > http://www.sensi.org/~ak/pyslsk/pyslsk6.png > http://www.wxwidgets.org/about/screensh.htm Ok, wxwidgets can look at least as good as tk. Agreed that wxpython might instead link to the excellent wxwidgets page. -- Terry Jan Reedy From sysengp2p at gmail.com Mon Jan 17 17:51:21 2011 From: sysengp2p at gmail.com (carlo) Date: Mon, 17 Jan 2011 14:51:21 -0800 (PST) Subject: UTF-8 question from Dive into Python 3 References: Message-ID: On 17 Gen, 23:34, Antoine Pitrou wrote: > On Mon, 17 Jan 2011 14:19:13 -0800 (PST) > > carlo wrote: > > Is it true UTF-8 does not have any "big-endian/little-endian" issue > > because of its encoding method? > > Yes. > > > And if it is true, why Mark (and > > everyone does) writes about UTF-8 with and without BOM some chapters > > later? What would be the BOM purpose then? > > "BOM" in this case is a misnomer. For UTF-8, it is only used as a > marker (a magic number, if you like) to signal than a given text file > is UTF-8. The UTF-8 "BOM" does not say anything about byte order; and, > actually, it does not change with endianness. > > (note that it is not required to put an UTF-8 "BOM" at the beginning of > text files; it is just a hint that some tools use when > generating/reading UTF-8) > > > 2- If that were true, can you point me to some documentation about the > > math that, as Mark says, demonstrates this? > > Math? UTF-8 is simply a byte-oriented (rather than word-oriented) > encoding. There is no math involved, it just works by construction. > > Regards > > Antoine. thank you all, eventually found http://www.unicode.org/versions/Unicode5.2.0/ch03.pdf#G7404 which clears up. No math in fact, as Tim and Antoine pointed out. From drsalists at gmail.com Mon Jan 17 17:54:20 2011 From: drsalists at gmail.com (Dan Stromberg) Date: Mon, 17 Jan 2011 14:54:20 -0800 Subject: Efficient python 2-d arrays? In-Reply-To: References: Message-ID: On Mon, Jan 17, 2011 at 2:20 PM, Jake Biesinger wrote: > Hi all, > > Using numpy, I can create large 2-dimensional arrays quite easily. >>>> import numpy >>>> mylist = numpy.zeros((100000000,2), dtype=numpy.int32) > > Unfortunately, my target audience may not have numpy so I'd prefer not to use it. > > Similarly, a list-of-tuples using standard python syntax. >>>> mylist = [(0,0) for i in xrange(100000000) > > but this method uses way too much memory (>4GB for 100 million items, compared to 1.5GB for numpy method). > > Since I want to keep the two elements together during a sort, I *can't* use array.array. >>>> mylist = [array.array('i',xrange(100000000)), array.array('i',xrange(100000000))] > > If I knew the size in advance, I could use ctypes arrays. >>>> from ctypes import * >>>> class myStruct(Structure): >>>> ? ? _fields_ = [('x',c_int),('y',c_int)] >>>> mylist_type = myStruct * 100000000 >>>> mylist = mylist_type() > > but I don't know that size (and it can vary between 1 million-200 million), so preallocating doesn't seem to be an option. > > Is there a python standard library way of creating *efficient* 2-dimensional lists/arrays, still allowing me to sort and append? > > Thanks! > -- > http://mail.python.org/mailman/listinfo/python-list > I recently had need of a two dimensional array also, but I only needed small ones, so I just used a dictionary indexed by tuples. If you need to sort a row as an aggregate type, it seems that you probably either want to: 1) Use a list of lists, where the outer list is the easier one to sort by - this is analogous to the array of pointers in C - sorting by the outer would want to compare "elements" by looking at the 0th inner, then 1st inner, etc. So if you can organize things this way, things might be pretty easy. 2) Use a list of instances, where the instances (rows) might just include a list 3) Use array.array with a custom sort so that you can move multiple things when a more common sort would move "one" (possibly an aggregate). If you want some sorting code to start from for #3, I have a variety of sorts written in Python (pure python or cython, your option, each automatically derived from the same m4 file for a given sort) at http://stromberg.dnsalias.org/svn/sorts/compare/trunk/ - however, even the cython timsort provided there doesn't perform quite as well as the standard library's timsort. HTH From rantingrick at gmail.com Mon Jan 17 18:13:39 2011 From: rantingrick at gmail.com (rantingrick) Date: Mon, 17 Jan 2011 15:13:39 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <79a8a$4d332d1a$4275d90a$3986@FUSE.NET> <64976187-88ad-47c9-9bc6-c0712a657264@j32g2000yqc.googlegroups.com> <3af4fd5e-8cc9-4cec-aad2-cbf82ad3bab3@l24g2000vby.googlegroups.com> Message-ID: <7c1928e5-ba2c-4034-9a5d-3f20cfe756ab@1g2000yqz.googlegroups.com> On Jan 17, 4:47?pm, Terry Reedy wrote: > On 1/16/2011 11:20 PM, rantingrick wrote: > > > Ok, try this... > > > ? ? ?http://juicereceiver.sourceforge.net/screenshots/index.php > > ? ? ?http://www.sensi.org/~ak/pyslsk/pyslsk6.png > > ? ? ?http://www.wxwidgets.org/about/screensh.htm > > Ok, wxwidgets can look at least as good as tk. Agreed that wxpython > might instead link to the excellent wxwidgets page. > > -- > Terry Jan Reedy Thanks for being honest. We need more people acting in this manner and just think of the progress we could make, it would wonderful! You know we Python programmers are professional debaters. This has been my take on the Python community. However without the virtues of compromise and community spirit all we are going to do is fight like cats and dogs forever to the very detriment of the very community we wish to muster We need to look at these problems from a community perspective and tone down the rhetoric. The layer of thick sarcasm that exists is so viscous and putrid that any semblance of civility is completely impervious to it's gelatinous all encompassing mass. We need to get more folks involved in the decision process. We need more community discussion and less community corruption. Currently we have a small subset of the community making a large proportion of the decisions. We did have a monarchy ruled by our beloved dictator however it has degenerated into a banana republic! We need democracy and we need it now! From tjreedy at udel.edu Mon Jan 17 18:18:36 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Mon, 17 Jan 2011 18:18:36 -0500 Subject: __pycache__, one more good reason to stck with Python 2? In-Reply-To: <0c62aacd-e6d2-4778-81d6-e06924192add@j1g2000vbl.googlegroups.com> References: <23e02e0d-b2f1-4b52-85ea-d1feba99dd37@22g2000prx.googlegroups.com> <4d3466d3$0$29983$c3e8da3$5496439d@news.astraweb.com> <0c62aacd-e6d2-4778-81d6-e06924192add@j1g2000vbl.googlegroups.com> Message-ID: No. The benefit of, for instance, not adding 200 .pyc files to a directory with 200 .py files is immediately obvious to most people. On 1/17/2011 1:17 PM, jmfauth wrote: >> No, I'm sorry, they're not obvious at all. > These reasons become obious as soon as you start working. > > Let's take a practical point view. It did not take a long time > to understand, that it is much simpler to delete the __pycache__ > directory everytime I compile my scripts than to visit it just > because I deleted or renamed a .py file in my working directory. Deleting the subdirectory is as least as easy as searching through the directory to find one or more files. In any case, the obsolete misnamed .pyc files hurt very little. Delete once a year or so if the space is an issue. In 13 years, I have hardly ever worried about deleting .pyc files. > How long will it take to find on the web tools to parse and > delete ophan .pyc files on a hd? > > If I get (stupidly, I agree) a .pyc file and want to test > it. Should I create manually a cache alongside my test.py > script? Since this is stupid (your word), it should be rare ;-). Since it can be dangerous, it should be more difficult. If you get a zip or tar file from a trusted source, get the .__cache__ dir with the file. > If I wish to delete the numerous auxiliary files a TeX > document produces, I just del /rm .* to keep a clean working > dir. With Python now? Impossible! The files are spread in two > dirs (at least). I do not know what TeX has to do with Python. -- Terry Jan Reedy From usernet at ilthio.net Mon Jan 17 19:02:38 2011 From: usernet at ilthio.net (Tim Harig) Date: Tue, 18 Jan 2011 00:02:38 +0000 (UTC) Subject: [OT] Python like lanugages [was Re: After C++, what with Python?] References: <86a904f8-05b0-435f-81d6-7450650f1679@glegroupsg2000goo.googlegroups.com> <4d329899$0$43988$742ec2ed@news.sonic.net> <7x8vylfcvz.fsf@ruckus.brouhaha.com> <4d32c7cf$0$29983$c3e8da3$5496439d@news.astraweb.com> Message-ID: On 2011-01-17, geremy condra wrote: > On Mon, Jan 17, 2011 at 1:07 PM, Tim Harig wrote: >> On 2011-01-17, geremy condra wrote: >>> On Mon, Jan 17, 2011 at 1:12 AM, Tim Harig wrote: >>>> On 2011-01-16, geremy condra wrote: >> Go is every bit of a general purpose programming language. ?It is useful >> for the same basic applications that you would otherwise write in Java. ?It >> can do pretty much anything that you can do in C, with the probable >> exception of writing operating systems. ?I have been using C/C++ for most >> of my programming career; but, everything that I have done can be done with >> Go. ?I am not really sure where you are seeing such narrowing limitations. > > Some people get very attached to one language and use it for > everything. I'd rather use the right tool for the job. I much agree. You don't see me dropping python, shell, awk, etc. I do expect Go will enter some of the programming that I am doing in Python and it will almost certainly replace much of the programming that I am doing in C/C++. > Go is not an ideal language for high-performance code. Despite the > occasional claims of others, Go is consistently outperformed by C, > C++, and Java on a wide variety of benchmarks. Some claim that Ada and > Haskell do as well, and my benchmarks (CPU bound, focused on speed of I much agree that Go doesn't beat C or C++. I really doubt that it could with the runtime necessary to do garbage collction. Nevertheless, I find that Go can be optimized to perform within tolerable limits of C given the boost it gives in development. I really question that you get Java anywhere even close to C performance. Google reports they get within the same order of magnitude as C for their long-lived server processes where the JIT has had time to optimize its results. For shorter term processes such as desktop applications, Java performance stinks -- even after you discount the JVM starup time. Ada is capable of C++ like performance *if* you compile it to remove *all* of runtime checking. Depending what checks you enable, it can run much slower. > cryptographic primitives) *seem* to confirm that for Haskell. I say > 'seem' because I'm clearly much more familiar with Haskell than with > Go, and would be inclined to question my conclusions if they weren't I have not worked with Haskell, so I don't really have any idea's about its performance. I understand that leveraging lazy evaluation and result caching can provide some *huge* opportunities for optimizations. > in line with the work of others. You can argue that it's good enough- > it is, for most cases- but taking a 20% performance hit rules it out > of a lot of systems work, and the C-Go gap in many cases is much > larger than that. I don't work anything that involves and absolute need for performance. I could probably accept penalty several times that of C for higher level functionality; but, sometimes the penalty for Python is just too much. Many of my programs are very quick lived such that even loading an interpeter or VM can eclipse the actual runtime. Given less developmental effort required, I also find that I have more time to look for ways to optimize Go. There are many things (such as using alternate data structures rather then the build in slices and immutable strings) that can be used to accelerate Go when time permits and I suspect many more will be found as the language matures. > Go is also not an ideal language for enterprise development. It > provides no compatibility or support guarantees; in fact, the website > describes it as 'an experiment' and recommends it for 'adventurous There is no doubt that it is a young project and there are a number of things that will need to be improved to be effective for some branches of programming; but, that isn't a language restriction. Frankly, I am rather impressed by the sheer number of third party packages that have already become available. No go isn't going to replace some of the other top mainstream langauges today; but, I can easily see it starting to see some market penetration 5 years from now. > users'. There are no independent experts in case something goes wrong, > and if it goes belly up a year from now you will have a one year old > piece of legacy infrastructure on your hands. Maybe you don't think > that this will be the case; in any event, I would not want to try > convincing a CFO of that. If I was trying to convince a CFO, I would ask if he really thought Google was likely to simply drop the time and effort that Google has already placed into the infrastructure. Furthermore, few dying languages already have not one, but two, open source compilers available for use. > As you point out, Go is also not a good language for operating systems > work. The lack of a widely accepted GUI toolkit weakens your argument > about application development. The lack of third party tools and > dependence on foreign language bindings weakens your single-language > argument. Etc, etc, etc. I don't really do GUI programming so you are probably right about the need for GUI toolkits. I do know that there is a GTK binding available as well as direct X11 support. Database bindings are another weak link outside of the more common open source databases. In both cases, Go readily capable of C library functions as a stop-gap until a native wrapper is available. Yes it will be nice once community has filled in the gaps; but, I am rather impressed at what is already available in less then a years time. There are a few libraries you may have missed here: http://go-lang.cat-v.org/pure-go-libs http://go-lang.cat-v.org/library-bindings Every language I know of has some binds that are simply wrappers to C libraries. There isn't much gain in reinventing the wheel to create a 100% non-C implementation for every library available and there are strong disadvantages such as trail time from the C release until it is reimplented natively. What are the advantages of recreating the termcap parser just to be able to position a few characters on the screen? I will point out that Go's libraries are miles ahead of the standard C library and other minimalistic standard libraries. Many things are possible with even the most basic functionalities. I don't use Python bindings when using GNUplot simply because its easier to access GNUplot directly. Finally, and most importantly, nothing about any third party tools and libraries has any bearing on the generality language itself. >> Support for concurrency is really icing on the cake. ?I find it rather >> supprising that so many modern languages do not already support full >> concurrency constructs. > > Go's most-lauded feature is its goroutines. I suspect that if this > isn't a big deal for you, you aren't its primary use case. Actually, I would consider Go's implicit interfaces to be a far more important innovation. The goroutines are nice but not ground breaking. They are quite recognizable to other SCP concurrancy derivatives. >> http://www.infoq.com/interviews/johnson-armstrong-oop >> >> Listen to the third point. ?Object orientation is quite possible even >> without inheritance. ?Not all programming languages support the same set >> of OOP features. ?Not all classless OOP programming languages support >> inheritance. ?The basic definition of object oriented programming is >> programing with self contained objects which contain their own data and ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >> the procedures necessary to manipulate that data. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ > So C is OOP. Let's agree to disagree on that. C fails to be an object oriented language because it fails to provide the syntactic sugar necessary to bind functions to the data that they manipulate and because it doesn't provide the isolation necessary for encapsilation of objects. >>>> 2. Go has a similar mechanism to exceptions, defer/panic/recover. ?It does >>>> ? ? ? ?downplay >>> >>> Defer, panic, and recover only allow you to build a recovery stack. >>> That's like saying that try/except isn't needed anymore because you >>> have the with statement. Do you think you could get through a rewrite >>> of Django without ripping out some hair over that? >> >> I don't know what you are referencing about Django as I don't work on or >> with the project; but, if one wanted exceptions with similar sematics to >> Python's, it could easily be built around Go's defer/panic/recover. ?There >> are actually packages availble that recreate exceptions as they are used in >> Ruby and other languages. ?The only think defer/panic/recover lacks is an >> exception class containing more more detailed information about what >> actually went wrong. > > You could also build it in C, yet C is exceptionless and is commonly > faulted for that fact. defer/panic/recover is conceptually a world closer to exceptions then is setjmp/longjmp. It really isn't any further different then the variantions in exceptions between different languages. From programming at toomuchcookies.net Mon Jan 17 19:12:51 2011 From: programming at toomuchcookies.net (OAN) Date: Tue, 18 Jan 2011 01:12:51 +0100 Subject: Efficient python 2-d arrays? In-Reply-To: References: Message-ID: <4D34DB03.9010009@toomuchcookies.net> Hi, what about pytables? It's built for big data collections and it doesn't clog up the memory. Am 17.01.2011 23:54, schrieb Dan Stromberg: > On Mon, Jan 17, 2011 at 2:20 PM, Jake Biesinger > wrote: >> Hi all, >> >> Using numpy, I can create large 2-dimensional arrays quite easily. >>>>> import numpy >>>>> mylist = numpy.zeros((100000000,2), dtype=numpy.int32) >> Unfortunately, my target audience may not have numpy so I'd prefer not to use it. >> >> Similarly, a list-of-tuples using standard python syntax. >>>>> mylist = [(0,0) for i in xrange(100000000) >> but this method uses way too much memory (>4GB for 100 million items, compared to 1.5GB for numpy method). >> >> Since I want to keep the two elements together during a sort, I *can't* use array.array. >>>>> mylist = [array.array('i',xrange(100000000)), array.array('i',xrange(100000000))] >> If I knew the size in advance, I could use ctypes arrays. >>>>> from ctypes import * >>>>> class myStruct(Structure): >>>>> _fields_ = [('x',c_int),('y',c_int)] >>>>> mylist_type = myStruct * 100000000 >>>>> mylist = mylist_type() >> but I don't know that size (and it can vary between 1 million-200 million), so preallocating doesn't seem to be an option. >> >> Is there a python standard library way of creating *efficient* 2-dimensional lists/arrays, still allowing me to sort and append? >> >> Thanks! >> -- >> http://mail.python.org/mailman/listinfo/python-list >> > I recently had need of a two dimensional array also, but I only needed > small ones, so I just used a dictionary indexed by tuples. > > If you need to sort a row as an aggregate type, it seems that you > probably either want to: > 1) Use a list of lists, where the outer list is the easier one to sort > by - this is analogous to the array of pointers in C - sorting by the > outer would want to compare "elements" by looking at the 0th inner, > then 1st inner, etc. So if you can organize things this way, things > might be pretty easy. > 2) Use a list of instances, where the instances (rows) might just include a list > 3) Use array.array with a custom sort so that you can move multiple > things when a more common sort would move "one" (possibly an > aggregate). > > If you want some sorting code to start from for #3, I have a variety > of sorts written in Python (pure python or cython, your option, each > automatically derived from the same m4 file for a given sort) at > http://stromberg.dnsalias.org/svn/sorts/compare/trunk/ - however, even > the cython timsort provided there doesn't perform quite as well as the > standard library's timsort. > > HTH From martin at v.loewis.de Mon Jan 17 20:11:16 2011 From: martin at v.loewis.de (Martin v. Loewis) Date: Tue, 18 Jan 2011 02:11:16 +0100 Subject: Efficient python 2-d arrays? In-Reply-To: References: Message-ID: > Using numpy, I can create large 2-dimensional arrays quite easily. IIUC (please confirm), you don't need a generic two-dimensional array, but rather an Nx2 array, where N may be large (but the other dimension will always have a magnitude of 2). > Since I want to keep the two elements together during a sort I assume (please confirm) that you want to sort by one of the numbers, and keep the other one together with the sort key. I suggest that you implement your own sorting algorithm, or reuse heapsort (actually, any of the sorting algorithms would do). You then use array.array, and take the elements at indices 2k and 2k+1 together. Sorting would then only look at even indices, but any swapping you do during the sorting would always swap two numbers with two other numbers. Regards, Martin From jake.biesinger at gmail.com Mon Jan 17 20:30:55 2011 From: jake.biesinger at gmail.com (Jake Biesinger) Date: Mon, 17 Jan 2011 17:30:55 -0800 (PST) Subject: Efficient python 2-d arrays? In-Reply-To: Message-ID: > IIUC (please confirm), you don't need a generic two-dimensional > array, but rather an Nx2 array, where N may be large (but the other > dimension will always have a magnitude of 2). Yes, that's right, Nx2 not NxM. > > Since I want to keep the two elements together during a sort > > I assume (please confirm) that you want to sort by one of the numbers, > and keep the other one together with the sort key. Again, yes. > I suggest that you implement your own sorting algorithm, or reuse > heapsort (actually, any of the sorting algorithms would do). > > You then use array.array, and take the elements at indices 2k and 2k+1 > together. Sorting would then only look at even indices, but any swapping > you do during the sorting would always swap two numbers with two other > numbers. Yes, this is an option. Writing a custom sort function just didn't sound very appealing and I was hoping for a more generic solution. Thanks! From jake.biesinger at gmail.com Mon Jan 17 20:32:34 2011 From: jake.biesinger at gmail.com (Jake Biesinger) Date: Mon, 17 Jan 2011 17:32:34 -0800 (PST) Subject: Efficient python 2-d arrays? In-Reply-To: Message-ID: <28a234f1-c4d7-41a4-a1c5-74ee48a1e9f0@glegroupsg2000goo.googlegroups.com> On Monday, January 17, 2011 4:12:51 PM UTC-8, OAN wrote: > Hi, > > what about pytables? It's built for big data collections and it doesn't > clog up the memory. I thought PyTables depends on NumPy? Otherwise I would indeed use their carray module. Thanks! From jake.biesinger at gmail.com Mon Jan 17 20:32:34 2011 From: jake.biesinger at gmail.com (Jake Biesinger) Date: Mon, 17 Jan 2011 17:32:34 -0800 (PST) Subject: Efficient python 2-d arrays? In-Reply-To: Message-ID: <28a234f1-c4d7-41a4-a1c5-74ee48a1e9f0@glegroupsg2000goo.googlegroups.com> On Monday, January 17, 2011 4:12:51 PM UTC-8, OAN wrote: > Hi, > > what about pytables? It's built for big data collections and it doesn't > clog up the memory. I thought PyTables depends on NumPy? Otherwise I would indeed use their carray module. Thanks! From flisboa.costa at gmail.com Mon Jan 17 20:59:15 2011 From: flisboa.costa at gmail.com (=?UTF-8?B?RmzDoXZpbyBMaXNiw7Rh?=) Date: Mon, 17 Jan 2011 22:59:15 -0300 Subject: __pycache__, one more good reason to stck with Python 2? In-Reply-To: <0c62aacd-e6d2-4778-81d6-e06924192add@j1g2000vbl.googlegroups.com> References: <23e02e0d-b2f1-4b52-85ea-d1feba99dd37@22g2000prx.googlegroups.com> <4d3466d3$0$29983$c3e8da3$5496439d@news.astraweb.com> <0c62aacd-e6d2-4778-81d6-e06924192add@j1g2000vbl.googlegroups.com> Message-ID: That's why i disagree (and hate) the automatic compilation of code, my project directory becomes full of object files, and then i need to either delete everything manually or create a script to do the work (not in python, because it'll dirt things even more :). Sometimes i notice python doesn't recompile the .pyc in response to changes in .py (because i share my project folders between computers using Dropbox). Unless this is just a rant, maybe you could use the PYTHONDONTWRITEBYTECODE environment flag or set the -B flag when executing the python interpreter. This flag deactivates auto-compilation, and may also deactivate __pycache__ effects, but i'm not sure, i can't test it now. See http://docs.python.org/using/cmdline.html#envvar-PYTHONDONTWRITEBYTECODE . The implications of deactivating this behaviour are somewhat obvious, and i wonder what impacts it'd cause on your system (but i hardly expect it to be anything serious). After reading some articles about it, I've come to think python depends a lot on bytecode writing on the filesystem. I wonder if it's good or bad. I find it so invasive, and that it should not be the default behaviour. But that's me, i'm sure most of python users don't mind at all. -------------- next part -------------- An HTML attachment was scrubbed... URL: From pavlovevidence at gmail.com Mon Jan 17 21:26:14 2011 From: pavlovevidence at gmail.com (Carl Banks) Date: Mon, 17 Jan 2011 18:26:14 -0800 (PST) Subject: Efficient python 2-d arrays? References: Message-ID: <3ab5326f-bf39-4dfa-9875-a1bfd5ccab68@w29g2000vba.googlegroups.com> On Jan 17, 2:20?pm, Jake Biesinger wrote: > Is there a python standard library way of creating *efficient* 2-dimensional lists/arrays, still allowing me to sort and append? Without using third party libraries, no not really. numpy has it covered so there's not really a lot of demand for it. If your users are loading 1.5 GB arrays into memory, it's probably not unreasonable to expect them to have numpy installed. Other than that you're probably stuck emulating 2D with the array module. Carl Banks From alice at gothcandy.com Mon Jan 17 21:29:50 2011 From: alice at gothcandy.com (=?utf-8?Q?Alice_Bevan=E2=80=93McGregor?=) Date: Mon, 17 Jan 2011 18:29:50 -0800 Subject: __pycache__, one more good reason to stck with Python 2? References: <23e02e0d-b2f1-4b52-85ea-d1feba99dd37@22g2000prx.googlegroups.com> <4d3466d3$0$29983$c3e8da3$5496439d@news.astraweb.com> <0c62aacd-e6d2-4778-81d6-e06924192add@j1g2000vbl.googlegroups.com> Message-ID: find . -name \*.pyc -exec rm -f {} \; vs. rm -rf __pycache__ I do not see how this is more difficult, but I may be missing something. ? Alice. From pruebauno at latinmail.com Mon Jan 17 21:51:01 2011 From: pruebauno at latinmail.com (nn) Date: Mon, 17 Jan 2011 18:51:01 -0800 (PST) Subject: move to end, in Python 3.2 Really? Message-ID: <58c17709-d68e-4448-b618-b6f594d0e8c5@t35g2000yqj.googlegroups.com> I somehow missed this before. I like most of the additions from Raymond Hettinger. But the api on this baffles me a bit: >>> d = OrderedDict.fromkeys('abcde') >>> d.move_to_end('b', last=False) >>> ''.join(d.keys) 'bacde' I understand that "end" could potentially mean either end, but would "move_to_end" and "move_to_beginning" not have been clearer? From rantingrick at gmail.com Mon Jan 17 21:58:57 2011 From: rantingrick at gmail.com (rantingrick) Date: Mon, 17 Jan 2011 18:58:57 -0800 (PST) Subject: move to end, in Python 3.2 Really? References: <58c17709-d68e-4448-b618-b6f594d0e8c5@t35g2000yqj.googlegroups.com> Message-ID: <8a0329a1-e84e-43f0-a89e-a2c66dab41e6@30g2000yql.googlegroups.com> On Jan 17, 8:51?pm, nn wrote: > I somehow missed this before. I like most of the additions from > Raymond Hettinger. But the api on this baffles me a bit: If we are not careful with all these "additions" we could end up with a language like ruby which has wasteful methods to clean your backside, and take out your trash -- clogging up your dir requests >:( Multiplicity is a slippery slope my friend! From tjreedy at udel.edu Mon Jan 17 22:39:33 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Mon, 17 Jan 2011 22:39:33 -0500 Subject: __pycache__, one more good reason to stck with Python 2? In-Reply-To: References: <23e02e0d-b2f1-4b52-85ea-d1feba99dd37@22g2000prx.googlegroups.com> <4d3466d3$0$29983$c3e8da3$5496439d@news.astraweb.com> <0c62aacd-e6d2-4778-81d6-e06924192add@j1g2000vbl.googlegroups.com> Message-ID: On 1/17/2011 8:59 PM, Fl?vio Lisb?a wrote: > That's why i disagree (and hate) the automatic compilation of code, my > project directory becomes full of object files That is one point of stashing them all in a .__pycache__ directory. > After reading some articles about it, I've come to think python depends > a lot on bytecode writing on the filesystem. A purely interpreted Python would be much slower. Saving module code to the filesystem speeds startup, which most find slow as it is. > I wonder if it's good or > bad. I find it so invasive, and that it should not be the default > behaviour. But that's me, i'm sure most of python users don't mind at all. Seems so. Complaints are rare. -- Terry Jan Reedy From ben+python at benfinney.id.au Mon Jan 17 22:57:13 2011 From: ben+python at benfinney.id.au (Ben Finney) Date: Tue, 18 Jan 2011 14:57:13 +1100 Subject: __pycache__, one more good reason to stck with Python 2? References: <23e02e0d-b2f1-4b52-85ea-d1feba99dd37@22g2000prx.googlegroups.com> <4d3466d3$0$29983$c3e8da3$5496439d@news.astraweb.com> <0c62aacd-e6d2-4778-81d6-e06924192add@j1g2000vbl.googlegroups.com> Message-ID: <87vd1m6ezq.fsf@benfinney.id.au> Terry Reedy writes: > On 1/17/2011 8:59 PM, Fl?vio Lisb?a wrote: > > But that's me, i'm sure most of python users don't mind at all. > > Seems so. Complaints are rare. That conclusion isn't valid; the behaviour is (AIUI) only in Python 3.2 and later. You can't presume that a lack of complaints means anything about ?most Python users? until those users are on a Python that shows this behaviour. -- \ ?If nature has made any one thing less susceptible than all | `\ others of exclusive property, it is the action of the thinking | _o__) power called an idea? ?Thomas Jefferson | Ben Finney From rustompmody at gmail.com Mon Jan 17 23:24:30 2011 From: rustompmody at gmail.com (rusi) Date: Mon, 17 Jan 2011 20:24:30 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <79a8a$4d332d1a$4275d90a$3986@FUSE.NET> <64976187-88ad-47c9-9bc6-c0712a657264@j32g2000yqc.googlegroups.com> <3af4fd5e-8cc9-4cec-aad2-cbf82ad3bab3@l24g2000vby.googlegroups.com> <7c1928e5-ba2c-4034-9a5d-3f20cfe756ab@1g2000yqz.googlegroups.com> Message-ID: <44dfe215-4e9d-4621-8999-1f46536df878@d1g2000pra.googlegroups.com> On Jan 18, 4:13?am, rantingrick wrote: > On Jan 17, 4:47?pm, Terry Reedy wrote: > > > On 1/16/2011 11:20 PM, rantingrick wrote: > > > > Ok, try this... > > > > ? ? ?http://juicereceiver.sourceforge.net/screenshots/index.php > > > ? ? ?http://www.sensi.org/~ak/pyslsk/pyslsk6.png > > > ? ? ?http://www.wxwidgets.org/about/screensh.htm > > > Ok, wxwidgets can look at least as good as tk. Agreed that wxpython > > might instead link to the excellent wxwidgets page. > > > -- > > Terry Jan Reedy > > Thanks for being honest. We need more people acting in this manner and > just think of the progress we could make, it would wonderful! > > You know we Python programmers are professional debaters. This has > been my take on the Python community. However without the virtues of > compromise and community spirit all we are going to do is fight like > cats and dogs forever to the very detriment of the very community we > wish to muster > > ?We need to look at these problems from a community perspective and > tone down the rhetoric. The layer of thick sarcasm that exists is so > viscous and putrid that any semblance of civility is completely > impervious to it's gelatinous all encompassing mass. We need to get > more folks involved in the decision process. We need more community > discussion and less community corruption. Currently we have a small > subset of the community making a large proportion of the decisions. We > did have a monarchy ruled by our beloved dictator however it has > degenerated into a banana republic! We need democracy and we need it > now! Lehman Beladys entropy law http://en.wikipedia.org/wiki/Lehman%27s_laws_of_software_evolution says The quality of ... systems will decline unless they are rigorously maintained and adapted to operational environment changes. Just look at emacs --once upon a time the best editor for alpha geeks, today unable to get rid of 40 years of cruft. Guido's 'benevolent dictatorship' has so far kept python the exception because - he give powerful batteries to start with - does not introduce junk - is not afraid of backward incompatibility for the sake of clarity and cleanliness (python3) Gui (and web) frameworks are two of his more visible failures From pavlovevidence at gmail.com Mon Jan 17 23:40:23 2011 From: pavlovevidence at gmail.com (Carl Banks) Date: Mon, 17 Jan 2011 20:40:23 -0800 (PST) Subject: __pycache__, one more good reason to stck with Python 2? References: <23e02e0d-b2f1-4b52-85ea-d1feba99dd37@22g2000prx.googlegroups.com> <4d3466d3$0$29983$c3e8da3$5496439d@news.astraweb.com> <0c62aacd-e6d2-4778-81d6-e06924192add@j1g2000vbl.googlegroups.com> Message-ID: <77ef8068-7f07-404f-8b0e-c039d1122659@e16g2000pri.googlegroups.com> On Jan 17, 6:29?pm, Alice Bevan?McGregor wrote: > ? ? ? ? find . -name \*.pyc -exec rm -f {} \; > > vs. > > ? ? ? ? rm -rf __pycache__ > > I do not see how this is more difficult, but I may be missing something. Well the former deletes all the pyc files in the directory tree whereas the latter only deletes the top level __pycache__, not the __pycache__ for subpackages. To delete all the __pycache__s you'd have to do something like this: file . -name __pycache__ -prune -exec rm -rf {} \; or, better, file . -name __pycache__ -prune | xargs rm -rf Still not anything really difficult. (I don't think a lot of people know about -prune; it tells find don't recursively descend.) Carl Banks From pavlovevidence at gmail.com Mon Jan 17 23:51:13 2011 From: pavlovevidence at gmail.com (Carl Banks) Date: Mon, 17 Jan 2011 20:51:13 -0800 (PST) Subject: __pycache__, one more good reason to stck with Python 2? References: <23e02e0d-b2f1-4b52-85ea-d1feba99dd37@22g2000prx.googlegroups.com> <4d3466d3$0$29983$c3e8da3$5496439d@news.astraweb.com> <0c62aacd-e6d2-4778-81d6-e06924192add@j1g2000vbl.googlegroups.com> Message-ID: <58b2111d-f0d5-499b-8339-6b27bb4743ca@z17g2000prz.googlegroups.com> On Jan 17, 10:17?am, jmfauth wrote: > > No, I'm sorry, they're not obvious at all. > > These reasons become obious as soon as you start working. > > Let's take a practical point view. It did not take a long time > to understand, that it is much simpler to delete the __pycache__ > directory everytime I compile my scripts than to visit it just > because I deleted or renamed a .py file in my working directory. According to PEP 3147, stale *.pyc files in the __pycache__ directories are ignored. So it's no longer necessary to delete the *.pyc files when renaming a *.py file. This is a big improvement, and easily justifies __pycache__ IMO, even without the distro considerations. > How long will it take to find on the web tools to parse and > delete ophan .pyc files on a hd? Probably under a month. (Updating old tools to work with new scheme will take a bit longer.) > If I get (stupidly, I agree) a .pyc file and want to test > it. Should I create manually a cache alongside my test.py > script? Nope: according to PEP 3147 a standalone *.pyc should not be put in same directory where the source file would have been, not in the __pycache__ directory (it'll be considered stale otherwise). It says this is for backwards compatibility, but I think there are valid reasons you don't want to deliver source so it's good that we can still do that. > If I wish to delete the numerous auxiliary files a TeX > document produces, I just del /rm .* to keep a clean working > dir. With Python now? Impossible! The files are spread in two > dirs (at least). > > ... > > That's life, unfortunately. Give yourself a little time. The one little non-temporary drawback I see for __pycache__ is if you have a directory with lots of stuff and one or two python files in the mix; and then you add that directory to sys.path and import the files. It creates the __pycache__ in that directory. It's a bit of a shock compared to the *.pyc files because it's at a very different place in the listings, and is a directory and not a file. But that's a minor thing. Carl Banks From tjreedy at udel.edu Tue Jan 18 00:07:05 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Tue, 18 Jan 2011 00:07:05 -0500 Subject: __pycache__, one more good reason to stck with Python 2? In-Reply-To: <87vd1m6ezq.fsf@benfinney.id.au> References: <23e02e0d-b2f1-4b52-85ea-d1feba99dd37@22g2000prx.googlegroups.com> <4d3466d3$0$29983$c3e8da3$5496439d@news.astraweb.com> <0c62aacd-e6d2-4778-81d6-e06924192add@j1g2000vbl.googlegroups.com> <87vd1m6ezq.fsf@benfinney.id.au> Message-ID: On 1/17/2011 10:57 PM, Ben Finney wrote: > Terry Reedy writes: > >> On 1/17/2011 8:59 PM, Fl?vio Lisb?a wrote: >>> But that's me, i'm sure most of python users don't mind at all. >> >> Seems so. Complaints are rare. > > That conclusion isn't valid; the behaviour is (AIUI) only in Python 3.2 > and later. You can't presume that a lack of complaints means anything > about ?most Python users? until those users are on a Python that shows > this behaviour. The person I was responding to was complaining, I believe, about .pyc files in the project directory, which I take to be the same directory as .py files. This is the 21-year-old behavior now changed. -- Terry Jan Reedy From pavlovevidence at gmail.com Tue Jan 18 00:09:42 2011 From: pavlovevidence at gmail.com (Carl Banks) Date: Mon, 17 Jan 2011 21:09:42 -0800 (PST) Subject: __pycache__, one more good reason to stck with Python 2? References: <23e02e0d-b2f1-4b52-85ea-d1feba99dd37@22g2000prx.googlegroups.com> <4d3466d3$0$29983$c3e8da3$5496439d@news.astraweb.com> <0c62aacd-e6d2-4778-81d6-e06924192add@j1g2000vbl.googlegroups.com> Message-ID: <4956ce5a-11f7-43c1-9936-fd6957af2023@u13g2000prd.googlegroups.com> On Jan 17, 10:17?am, jmfauth wrote: > That's life, unfortunately. Also, an earlier version of the proposal was to create a *.pyr directory for each *.py file. That was a real mess; be thankful they worked on it and came up with a much cleaner method. Carl Banks From rantingrick at gmail.com Tue Jan 18 00:18:16 2011 From: rantingrick at gmail.com (rantingrick) Date: Mon, 17 Jan 2011 21:18:16 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <79a8a$4d332d1a$4275d90a$3986@FUSE.NET> <64976187-88ad-47c9-9bc6-c0712a657264@j32g2000yqc.googlegroups.com> <3af4fd5e-8cc9-4cec-aad2-cbf82ad3bab3@l24g2000vby.googlegroups.com> <7c1928e5-ba2c-4034-9a5d-3f20cfe756ab@1g2000yqz.googlegroups.com> <44dfe215-4e9d-4621-8999-1f46536df878@d1g2000pra.googlegroups.com> Message-ID: <37d23248-b47a-4af5-8a98-f3002fa259d0@e20g2000vbn.googlegroups.com> On Jan 17, 10:24?pm, rusi wrote: > The quality of ... systems will ?decline unless they are rigorously > maintained and adapted to operational environment changes. This is both eloquent and frightening at the same time when applied to the current state of Python's stdlib. We have come so far and forged a path of langauge innovation. However we have now entered a state of limbo, we have solidified -- This collective static state has manifested both in the tangible (stdlib) and more frighteningly the intangible (community). Are we going to allow this slow decay to wither away all the work that has been done because we cannot come to a consensus on anything as a community? Heck i'll bet we could not even agree on what punch to serve at the next Pycon much less makes some real decisions that concern this community. When does the slightly overweight spare tire become the morbidly obese? When does losing a few hairs become que ball histeria , and when does the slow creeping of time catch up to the blissful ignorants and mortality slap you in the face *slap*. Sadly and most often-ly when the missed opportunities are now but wishful fantasies and stories of glory days unrealized! Are we in those days as a community? Maybe? > Just look at emacs --once upon a time the best editor for alpha geeks, > today unable to get rid of 40 years of cruft. Today emacs, tomorrow Python. > Guido's 'benevolent dictatorship' has so far kept python the exception > because > - he give powerful batteries to start with > - does not introduce junk > - is not afraid of backward incompatibility for the sake of clarity > and cleanliness (python3) Agreed > Gui (and web) frameworks are two of his more visible failures His initial intention were pure. However TclTk may turn out to be GvR's Achilles heel. It seems Tkinter has metamorphosis into some ill legitimate red-headed step child that the community both hates and loves at the same time. Or is something more sinister at work here? Could a high ranking TclTk "Guru" be within the "inner circle" of Python dev? Or maybe even Guido's close friend? Could emotions and back door politics be standing in the way of Tkinters graceful exit? Is hurting one or two peoples feelings really that bad in face of what is best for a community? In any event we definitely need a mid life crisis to wake ourselves from this slow decay of narcissism, sarcasm, pretentiousness, apathy, and just outright laziness that is destroying everything we hold dear. Because the bell that tolls, may just be our own (as a community). From steve+comp.lang.python at pearwood.info Tue Jan 18 00:19:01 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 18 Jan 2011 05:19:01 GMT Subject: [OT] Python like lanugages [was Re: After C++, what with Python?] References: <86a904f8-05b0-435f-81d6-7450650f1679@glegroupsg2000goo.googlegroups.com> <4d329899$0$43988$742ec2ed@news.sonic.net> <7x8vylfcvz.fsf@ruckus.brouhaha.com> <4d32c7cf$0$29983$c3e8da3$5496439d@news.astraweb.com> <4d3425fe$0$29983$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4d3522c5$0$29990$c3e8da3$5496439d@news.astraweb.com> On Mon, 17 Jan 2011 19:41:54 +0000, Tim Harig wrote: > One of the arguments for Python has always made is that you can optimize > it by writing the most important parts in C. Perhaps that is a crutch > that has held the communty back from seeking higher performance > solutions in the language itself. Are you aware of PyPy? PyPy is now about double the speed of CPython for most things, and they have set themselves the ambitious target of being faster than C. http://codespeak.net/pypy/dist/pypy/doc/faq.html -- Steven From pavlovevidence at gmail.com Tue Jan 18 00:20:19 2011 From: pavlovevidence at gmail.com (Carl Banks) Date: Mon, 17 Jan 2011 21:20:19 -0800 (PST) Subject: move to end, in Python 3.2 Really? References: <58c17709-d68e-4448-b618-b6f594d0e8c5@t35g2000yqj.googlegroups.com> Message-ID: On Jan 17, 6:51?pm, nn wrote: > I somehow missed this before. I like most of the additions from > Raymond Hettinger. But the api on this baffles me a bit: > > >>> d = OrderedDict.fromkeys('abcde') > >>> d.move_to_end('b', last=False) > >>> ''.join(d.keys) > > 'bacde' > > I understand that "end" could potentially mean either end, but would > "move_to_end" and "move_to_beginning" not have been clearer? It's a minor issue, but I'd tend to lean that way. Most other times when something can happen on one end of a sequence or another, it uses different function calls. E.g.: startswith vs endswith, lstrip vs rstrip, and even pop vs popleft. Oddly, Hettinger seems to be a big advocate of not overloading functions. Carl Banks From python at rcn.com Tue Jan 18 00:20:48 2011 From: python at rcn.com (Raymond Hettinger) Date: Mon, 17 Jan 2011 21:20:48 -0800 (PST) Subject: move to end, in Python 3.2 Really? References: <58c17709-d68e-4448-b618-b6f594d0e8c5@t35g2000yqj.googlegroups.com> Message-ID: <125db7fe-036e-47c9-be89-50f05106936f@n2g2000pre.googlegroups.com> On Jan 17, 6:51?pm, nn wrote: > ...But the api on this baffles me a bit: > > >>> d = OrderedDict.fromkeys('abcde') > >>> d.move_to_end('b', last=False) > >>> ''.join(d.keys) > > 'bacde' > > I understand that "end" could potentially mean either end, but would > "move_to_end" and "move_to_beginning" not have been clearer? The default (and normal usage) is to move an item to the last position. So, od.move_to_end(k) becomes a fast equivalent to v=d.pop(k) followed by d[k]=v. The less common usage of moving to the beginning is done with last=False. This parallels the existing API for od.popitem(): >>> od = OrderedDict.fromkeys('abcdefghi') >>> od.move_to_end('c') # default case: move to last >>> od.popitem() # default case: pop from last ('c', None) >>> od.move_to_end('d', last=False) # other case: move to first >>> od.popitem(last=False) # other case: pop from first ('d', None) The existing list.pop() API is similar (though it takes an index value instead of a boolean): >>> mylist.pop() # default case: pop from last >>> mylist.pop(0) # other case: pop from first Those were the design considerations. Sorry you didn't like the result. Raymond From rantingrick at gmail.com Tue Jan 18 00:28:43 2011 From: rantingrick at gmail.com (rantingrick) Date: Mon, 17 Jan 2011 21:28:43 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <79a8a$4d332d1a$4275d90a$3986@FUSE.NET> <64976187-88ad-47c9-9bc6-c0712a657264@j32g2000yqc.googlegroups.com> <3af4fd5e-8cc9-4cec-aad2-cbf82ad3bab3@l24g2000vby.googlegroups.com> <7c1928e5-ba2c-4034-9a5d-3f20cfe756ab@1g2000yqz.googlegroups.com> <44dfe215-4e9d-4621-8999-1f46536df878@d1g2000pra.googlegroups.com> <37d23248-b47a-4af5-8a98-f3002fa259d0@e20g2000vbn.googlegroups.com> Message-ID: I have proposed this before and i shall propose it again. Most of the naysayers parrot off about how many people use Tkinter. Maybe they are right, and maybe they are wrong. Nobody, and i repeat NOBODY even GvR himself can offer reliable evidence as to how important moduleX *is* or *is not* to this community... However i can! I propose a truly democratic method by which we can gather REAL data about what is important, and what is not important to the average Python programmer. I am not suggesting that this data be an official vote. I am only suggesting that those who walk the halls of "privilege" should listen carefully to the peasants when making decisions that affect the peasants. To make a long story short my proposal is to send out a warning in the next official release of Python. The warning will be as follows... """ ------------------------------- ModuleRemovalWarning: Tkinter ------------------------------- The GUI module "Tkinter" is being considered for removal from the Python stdlib FOREVER. If you use Tkinter and wish for it to stay in the stdlib you need to visit "www.savetkinter.com" and cast your vote now. The voting will end on dd/mm/yyyy so make sure to cast your vote or don't be complaining about it later. Note: Simon Cowell WILL NOT be making a celebrity appearance! """ If i need to create a PEP i will. From stefan_ml at behnel.de Tue Jan 18 02:06:42 2011 From: stefan_ml at behnel.de (Stefan Behnel) Date: Tue, 18 Jan 2011 08:06:42 +0100 Subject: Need the list of XML parsers In-Reply-To: <625910e2-22c2-4365-bc34-d0f9d5af8c65@glegroupsg2000goo.googlegroups.com> References: <625910e2-22c2-4365-bc34-d0f9d5af8c65@glegroupsg2000goo.googlegroups.com> Message-ID: Venu, 17.01.2011 21:34: > Using cElementTree, would you be willing show to me how to find the nodes with certain attribute, ie search using attributes and attibute values. > I did not see any example code from the cElementTree official website. Check out the documentation of ElementTree and lxml.etree. That should get you going. Stefan From stefan_ml at behnel.de Tue Jan 18 02:08:50 2011 From: stefan_ml at behnel.de (Stefan Behnel) Date: Tue, 18 Jan 2011 08:08:50 +0100 Subject: Need the list of XML parsers In-Reply-To: References: <9f75fdb8-78e3-4675-a48a-64147e0a0095@w29g2000vba.googlegroups.com> <4D3480F4.6070606@sudheer.net> Message-ID: Venu Allipuram, 17.01.2011 21:01: > lxml is a great one, but it is not simple to install libxml and libxslt on > Linux using user permissions. Well, you have to build it, obviously. Just pass "--static-deps" to the build script and it will build and link libxml2 and libxslt automatically for you. Stefan From stefan_ml at behnel.de Tue Jan 18 02:31:26 2011 From: stefan_ml at behnel.de (Stefan Behnel) Date: Tue, 18 Jan 2011 08:31:26 +0100 Subject: [OT] Python like lanugages [was Re: After C++, what with Python?] In-Reply-To: References: <86a904f8-05b0-435f-81d6-7450650f1679@glegroupsg2000goo.googlegroups.com> <4d329899$0$43988$742ec2ed@news.sonic.net> <7x8vylfcvz.fsf@ruckus.brouhaha.com> <4d32c7cf$0$29983$c3e8da3$5496439d@news.astraweb.com> <4d3425fe$0$29983$c3e8da3$5496439d@news.astraweb.com> Message-ID: Tim Harig, 17.01.2011 20:41: > In comp.lang.python, I wrote: >> Tim Harig, 17.01.2011 13:25: >>> If I didn't think Python was a good language, I wouldn't be here. >>> Nevertheless, it isn't a good fit for many pieces of software where a >>> systems language is better suited. Reasons include ease of distribution >>> without an interpeter, non-necessity of distributing source with the >>> product, ability to leverage multiple CPU and multicore systems, and >>> simple sequential performance. >>> >>> Given that Python does't work well in many areas, we could just give up >>> and accept having to write C++ for our day jobs or we can look for a >>> language which bridges the gap between those tasks that require C++'s >>> level of control and those which work well for dynamic languages. >>> Java attempted to do that, and has the market share to show that the >>> concept works, but I think that it missed the mark for many needs. It is >>> still much lower level then Python for purposes of rapid developement >>> and too slow to be competative for non-long-lived tasks. >> >> So seriously need to take a look at Cython. >> >> http://cython.org > > One of the arguments for Python has always made is that you can optimize > it by writing the most important parts in C. Perhaps that is a crutch > that has held the communty back from seeking higher performance solutions > in the language itself. The good news with Cython is that you no longer need to "write the most important parts in C". Instead, you type them statically and compile them. You don't even need to sacrifice Python source compatibility for that. So you get the best of Python at the speed of C (or 'c', as some would say ;). > I prefer a single language as opposed to a creolization of two. With the possible exception of Lisp, I find it hard to think of a language that's still alive and not the creolisation of (at least) two other languages. They all inherited from each other, sometimes right from the start ("lessons learned") and always during their subsequent life time. > I certainly don't need to require anybody who > wants to use a program I have compiled to install an interpreter. You will be happy to hear that you can link Cython programs against libpython (even statically) to build an executable that embeds the interpreter for you. Besides, on most operating systems, installing a dependency is done automatically, and Go code doesn't run natively on Windows either, without first installing and running the compiler over it. Stefan From healthyweightloss2burnfat at gmail.com Tue Jan 18 03:30:31 2011 From: healthyweightloss2burnfat at gmail.com (something healthy) Date: Tue, 18 Jan 2011 00:30:31 -0800 (PST) Subject: How to lose calories before your wedding Message-ID: <11ffdf1a-41b7-421c-820c-5f775666e90b@l24g2000vby.googlegroups.com> How to lose calories before your wedding http://healthyweightlossways.blogspot.com/2011/01/how-to-lose-calories-before-your.html From orasnita at gmail.com Tue Jan 18 03:49:42 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Tue, 18 Jan 2011 10:49:42 +0200 Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com><4d337983$0$29983$c3e8da3$5496439d@news.astraweb.com><044a5101-948d-4458-9c94-57dbb3e25f67@m35g2000vbn.googlegroups.com><4d3467bf$0$29983$c3e8da3$5496439d@news.astraweb.com> Message-ID: From: "Adam Skutt" Subject: Re: Tkinter: The good, the bad, and the ugly! On Jan 17, 3:08 pm, "Octavian Rasnita" wrote: >> From: "Adam Skutt" >> And we're not discussing those languages, we're discussing Python, >> which has an explicit policy of "batteries included". As such, >> criticism of the standard library is perfectly acceptable under the >> name "Python", whether you like it or not. Besides, it's inevitable >> anyway. > > "Batteries included"? > > Python doesn't follow this policy at all. We can say that maybe PHP > follows it, but not Python. > http://lmgtfy.com/?q=python+%22batteries+included%22&l=1 Well, this doesn't mean anything because Perl can also say that includes batteries, and PHP can say it also. > And if this is the wanted policy, why should it be "cheap batteries > included" and not "strong batteries included"? You'd have this same argument regardless of GUI toolkit you end up picking, or even if you choose to not include one at all. This would be because none of them are universal solutions, all of them have deficiencies (actual or perceived) that make them unsuitable for certain applications. Adam You are perfectly right. Then why favor Tkinter and not WxPython. Why not strip the Python package and offer WxPython and Tkinter separately? Octavian From orasnita at gmail.com Tue Jan 18 03:58:01 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Tue, 18 Jan 2011 10:58:01 +0200 Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com><4d337983$0$29983$c3e8da3$5496439d@news.astraweb.com><044a5101-948d-4458-9c94-57dbb3e25f67@m35g2000vbn.googlegroups.com><4d3467bf$0$29983$c3e8da3$5496439d@news.astraweb.com> <4D34B04E.8050309@web.de> Message-ID: <4266E8D7BA204BFEA5BF66C635CE1716@octavian> From: "Alexander Kapps" > On 17.01.2011 21:04, Octavian Rasnita wrote: >> I say probably not considering the availability of 3rd party >> downloads. What say you, Python community? > > Available as 3rd party downloads: > > XML,HTML,... > HTTP,FTP,SMTP,POP,IMAP/... > MD5,SHA,... > zip,bzip,... > > and so on and so on and so on. > > Remove them all just because they are available as 3rd party downloads? No, they should not be removed because they don't cause any damage, very bad damage as Tkinter does. > The "Batteries included" of Python is just *great* and I vote for *more* > not less batteries! Well, in that case, why don't you agree to also include WxPython in the Python package? >> And one more thing. Not all the Python programmers create desktop apps so >> a GUI lib is useless. Some of them use Python only for web programming or >> only for system administration. > > Not all Python programmers do web programming, so please remove the > useless HTML junk too. Why do you call it "html junk"? > Almost every beginner wants to do GUIs or at least some graphic stuff. > Removing the GUI module from the stdlib would be plain wrong IMHO. But I > don't understand the whole issue anyway. It isn't that you need to fire up > your torrent client and wait 48 hours for the Python download to complete. > Why remove useful (to many, not most) stuff from the lib? Yes it can be useful for some people, but why promote it instead of promoting a better library for beginners? Octavian From wxjmfauth at gmail.com Tue Jan 18 03:58:14 2011 From: wxjmfauth at gmail.com (jmfauth) Date: Tue, 18 Jan 2011 00:58:14 -0800 (PST) Subject: __pycache__, one more good reason to stck with Python 2? References: <23e02e0d-b2f1-4b52-85ea-d1feba99dd37@22g2000prx.googlegroups.com> <4d3466d3$0$29983$c3e8da3$5496439d@news.astraweb.com> <0c62aacd-e6d2-4778-81d6-e06924192add@j1g2000vbl.googlegroups.com> <87vd1m6ezq.fsf@benfinney.id.au> Message-ID: <992b11a0-d35d-4b08-98ab-d08c90a86ec7@j1g2000vbl.googlegroups.com> On Jan 18, 6:07?am, Terry Reedy wrote: > ... > This is the 21-year-old behavior now changed. > ... Yes, you summarized the situation very well. The way of working has changed and probably more deeply that one may think. It is now practically impossible to launch a Python application via a .pyc file. (For the fun, try to add the "parent directory" of a cached file to the sys.path). About the caches, I'am just fearing, they will become finally garbage collectors of orphan .pyc files, Python has seed/seeded(?). The .pyc files may not be very pleasant, but at least you can use them and you have that "feeling" of their existence. I my "computer experience", once you start to cache/hide something for simplicity, the problems start. May be it a good move for Python, I do not feel very comfortable with all this stuff. From orasnita at gmail.com Tue Jan 18 04:03:16 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Tue, 18 Jan 2011 11:03:16 +0200 Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com><79a8a$4d332d1a$4275d90a$3986@FUSE.NET><64976187-88ad-47c9-9bc6-c0712a657264@j32g2000yqc.googlegroups.com><3af4fd5e-8cc9-4cec-aad2-cbf82ad3bab3@l24g2000vby.googlegroups.com> <7c1928e5-ba2c-4034-9a5d-3f20cfe756ab@1g2000yqz.googlegroups.com> Message-ID: <6D0E5A2E17824D63B1E8D171F35D74A3@octavian> From: "rantingrick" You know we Python programmers are professional debaters. This has been my take on the Python community. However without the virtues of compromise and community spirit all we are going to do is fight like cats and dogs forever to the very detriment of the very community we wish to muster We need to look at these problems from a community perspective and tone down the rhetoric. The layer of thick sarcasm that exists is so viscous and putrid that any semblance of civility is completely impervious to it's gelatinous all encompassing mass. We need to get more folks involved in the decision process. We need more community discussion and less community corruption. Currently we have a small subset of the community making a large proportion of the decisions. We did have a monarchy ruled by our beloved dictator however it has degenerated into a banana republic! We need democracy and we need it now! Well, those who work have the latest word and they will decide what they will want to do. We can just show our opinions and hope that they will care and take the best decision. The problem is that some people don't care and want to demonstrate that this is very normal and that they are right, which is not good at all. Octavian From __peter__ at web.de Tue Jan 18 04:04:24 2011 From: __peter__ at web.de (Peter Otten) Date: Tue, 18 Jan 2011 10:04:24 +0100 Subject: __pycache__, one more good reason to stck with Python 2? References: <23e02e0d-b2f1-4b52-85ea-d1feba99dd37@22g2000prx.googlegroups.com> <4d3466d3$0$29983$c3e8da3$5496439d@news.astraweb.com> <0c62aacd-e6d2-4778-81d6-e06924192add@j1g2000vbl.googlegroups.com> <77ef8068-7f07-404f-8b0e-c039d1122659@e16g2000pri.googlegroups.com> Message-ID: Carl Banks wrote: > On Jan 17, 6:29 pm, Alice Bevan?McGregor wrote: >> find . -name \*.pyc -exec rm -f {} \; >> >> vs. >> >> rm -rf __pycache__ >> >> I do not see how this is more difficult, but I may be missing something. > > > Well the former deletes all the pyc files in the directory tree > whereas the latter only deletes the top level __pycache__, not the > __pycache__ for subpackages. To delete all the __pycache__s you'd > have to do something like this: > > file . -name __pycache__ -prune -exec rm -rf {} \; > > or, better, > > file . -name __pycache__ -prune | xargs rm -rf > > Still not anything really difficult. (I don't think a lot of people > know about -prune; it tells find don't recursively descend.) What's the advantage of 'find ... | xargs ...' over 'find ... -exec ...'? From orasnita at gmail.com Tue Jan 18 04:13:06 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Tue, 18 Jan 2011 11:13:06 +0200 Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com><79a8a$4d332d1a$4275d90a$3986@FUSE.NET><64976187-88ad-47c9-9bc6-c0712a657264@j32g2000yqc.googlegroups.com><3af4fd5e-8cc9-4cec-aad2-cbf82ad3bab3@l24g2000vby.googlegroups.com><7c1928e5-ba2c-4034-9a5d-3f20cfe756ab@1g2000yqz.googlegroups.com> <44dfe215-4e9d-4621-8999-1f46536df878@d1g2000pra.googlegroups.com> Message-ID: <26D977282CC948E99F7BA4AACCEE9A64@octavian> From: "rusi" Lehman Beladys entropy law http://en.wikipedia.org/wiki/Lehman%27s_laws_of_software_evolution says The quality of ... systems will decline unless they are rigorously maintained and adapted to operational environment changes. Yes. Pretty right. Tkinter -> WxPython change would be a very good one. Guido's 'benevolent dictatorship' has so far kept python the exception because - he give powerful batteries to start with With the exception of Tkinter. :-)) - does not introduce junk - is not afraid of backward incompatibility for the sake of clarity and cleanliness (python3) Well, on the long term this could be a very big disadvantage also. Of course, the beginners won't care, but the old users and the companies that would need to adapt the old code that might not work with newer versions of Python won't like this incompatibility. Gui (and web) frameworks are two of his more visible failures Well, Python has good GUI libs , at least WxPython, however it is not one of its included batteries. :-) Yes, for web programming Python is not as great as Perl, but I don't think this has something to do with the core Python. Octavian From stefan_ml at behnel.de Tue Jan 18 04:23:27 2011 From: stefan_ml at behnel.de (Stefan Behnel) Date: Tue, 18 Jan 2011 10:23:27 +0100 Subject: __pycache__, one more good reason to stck with Python 2? In-Reply-To: References: <23e02e0d-b2f1-4b52-85ea-d1feba99dd37@22g2000prx.googlegroups.com> <4d3466d3$0$29983$c3e8da3$5496439d@news.astraweb.com> <0c62aacd-e6d2-4778-81d6-e06924192add@j1g2000vbl.googlegroups.com> Message-ID: Terry Reedy, 18.01.2011 04:39: > Saving module code to the > filesystem speeds startup, which most find slow as it is. I've been using Jython recently, which, in addition to the huge JVM startup time, must also fire up the Jython runtime before actually doing anything useful. I must say that I never found CPython's startup time to be slow, quite the contrary. Stefan From stefan_ml at behnel.de Tue Jan 18 04:27:54 2011 From: stefan_ml at behnel.de (Stefan Behnel) Date: Tue, 18 Jan 2011 10:27:54 +0100 Subject: __pycache__, one more good reason to stck with Python 2? In-Reply-To: <992b11a0-d35d-4b08-98ab-d08c90a86ec7@j1g2000vbl.googlegroups.com> References: <23e02e0d-b2f1-4b52-85ea-d1feba99dd37@22g2000prx.googlegroups.com> <4d3466d3$0$29983$c3e8da3$5496439d@news.astraweb.com> <0c62aacd-e6d2-4778-81d6-e06924192add@j1g2000vbl.googlegroups.com> <87vd1m6ezq.fsf@benfinney.id.au> <992b11a0-d35d-4b08-98ab-d08c90a86ec7@j1g2000vbl.googlegroups.com> Message-ID: jmfauth, 18.01.2011 09:58: > About the caches, I'am just fearing, they will > become finally garbage collectors of orphan .pyc files, > Python has seeded I can't see how that is supposed to be any different than before. If you rename a file without deleting the .pyc file, you will end up with an orphaned .pyc file, right now and as it was for the last 21 years. The same applies to the new cache directory. Stefan From stefan_ml at behnel.de Tue Jan 18 04:29:04 2011 From: stefan_ml at behnel.de (Stefan Behnel) Date: Tue, 18 Jan 2011 10:29:04 +0100 Subject: __pycache__, one more good reason to stck with Python 2? In-Reply-To: References: <23e02e0d-b2f1-4b52-85ea-d1feba99dd37@22g2000prx.googlegroups.com> <4d3466d3$0$29983$c3e8da3$5496439d@news.astraweb.com> <0c62aacd-e6d2-4778-81d6-e06924192add@j1g2000vbl.googlegroups.com> <77ef8068-7f07-404f-8b0e-c039d1122659@e16g2000pri.googlegroups.com> Message-ID: Peter Otten, 18.01.2011 10:04: > What's the advantage of 'find ... | xargs ...' over 'find ... -exec ...'? The former runs in parallel, the latter runs sequentially. Stefan From tartley at tartley.com Tue Jan 18 04:54:26 2011 From: tartley at tartley.com (Jonathan Hartley) Date: Tue, 18 Jan 2011 01:54:26 -0800 (PST) Subject: Efficient python 2-d arrays? References: Message-ID: <6b865cda-5df4-4053-b5e4-f7deba45360e@l7g2000vbv.googlegroups.com> On Jan 17, 10:20?pm, Jake Biesinger wrote: > Hi all, > > Using numpy, I can create large 2-dimensional arrays quite easily. > > >>> import numpy > >>> mylist = numpy.zeros((100000000,2), dtype=numpy.int32) > > Unfortunately, my target audience may not have numpy so I'd prefer not to use it. > > Similarly, a list-of-tuples using standard python syntax. > > >>> mylist = [(0,0) for i in xrange(100000000) > > but this method uses way too much memory (>4GB for 100 million items, compared to 1.5GB for numpy method). > > Since I want to keep the two elements together during a sort, I *can't* use array.array. > > >>> mylist = [array.array('i',xrange(100000000)), array.array('i',xrange(100000000))] > > If I knew the size in advance, I could use ctypes arrays. > > >>> from ctypes import * > >>> class myStruct(Structure): > >>> ? ? _fields_ = [('x',c_int),('y',c_int)] > >>> mylist_type = myStruct * 100000000 > >>> mylist = mylist_type() > > but I don't know that size (and it can vary between 1 million-200 million), so preallocating doesn't seem to be an option. > > Is there a python standard library way of creating *efficient* 2-dimensional lists/arrays, still allowing me to sort and append? > > Thanks! Since you can't depend on your users installing the dependencies, is it vital that your users run from source? You could bundle up your application along with numpy and other dependencies using py2Exe or similar. This also means you wouldn't have to require users to have the right (or any) version of Python installed. From nambo4jb at gmail.com Tue Jan 18 05:01:57 2011 From: nambo4jb at gmail.com (Cathy James) Date: Tue, 18 Jan 2011 04:01:57 -0600 Subject: newby qn about functions Message-ID: #This has to be very simple, but I don't get it-please help def *lower_case*(s): #return s print(s) #return s.lower() print(s.lower()) s=*"Testing Functions-lower case: " * lower_case(s) *"""how can i use a return statement to write a function that returns the string "Testing Functions-lower case: "and the lowercase representation of its string parameter""" If I uncomment the above, nothing outputs to console:(* ** *Much appreciation as always.* -------------- next part -------------- An HTML attachment was scrubbed... URL: From sliwinski at red-sky.pl Tue Jan 18 05:22:45 2011 From: sliwinski at red-sky.pl (=?ISO-8859-2?Q?Grzegorz_=A6liwi=F1ski?=) Date: Tue, 18 Jan 2011 02:22:45 -0800 (PST) Subject: Python unicode utf-8 characters and MySQL unicode utf-8 characters Message-ID: <1914ba89-7ecc-43d5-8fbc-9a45f27ae8c8@z5g2000yqb.googlegroups.com> Hello, Recently I tried to insert some unicode object in utf-8 encoding into MySQL using MySQLdb, and got MySQL warnings on characters like: ???? i found somewhere in my data. I can't even read them. MySQL seems to cut the whole string after that characters off, so I get incomplete data. After a little bit of digging I found out, that MySQL usually supports utf-8 data but encoded into maximum three bytes. That's why I think it would help I f I was able to replace all larger unicode characters with replacement characters. Is there any way, I could adjust python unicode utf-8 encoded strings to be accepted by mysql utf-8 columns? From enalicho at gmail.com Tue Jan 18 05:42:08 2011 From: enalicho at gmail.com (Noah Hall) Date: Tue, 18 Jan 2011 10:42:08 +0000 Subject: newby qn about functions In-Reply-To: References: Message-ID: > """how can i use a return statement? to write a function that returns the > string "Testing?Functions-lower case: "and the lowercase representation of > its string parameter""" If I uncomment the above, nothing outputs to > console:( def lower_case(s): return "Testing Functions-lower case: %s" % (s.lower()) >>> print(lower_case("HeLLo")) Testing Functions-lower case: hello >>> d = lower_case("HeLLo") >>> print(d) Testing Functions-lower case: hello If a function returns something and you want it printed, you need to then tell Python to print the return. Please note that "return" and "print" aren't the same things, return returns a given variable or constant, and print simply prints a given variable or constant. From usernet at ilthio.net Tue Jan 18 05:52:06 2011 From: usernet at ilthio.net (Tim Harig) Date: Tue, 18 Jan 2011 10:52:06 +0000 (UTC) Subject: [OT] Python like lanugages [was Re: After C++, what with Python?] References: <86a904f8-05b0-435f-81d6-7450650f1679@glegroupsg2000goo.googlegroups.com> <4d329899$0$43988$742ec2ed@news.sonic.net> <7x8vylfcvz.fsf@ruckus.brouhaha.com> <4d32c7cf$0$29983$c3e8da3$5496439d@news.astraweb.com> <4d3425fe$0$29983$c3e8da3$5496439d@news.astraweb.com> <4d3522c5$0$29990$c3e8da3$5496439d@news.astraweb.com> Message-ID: On 2011-01-18, Steven D'Aprano wrote: > On Mon, 17 Jan 2011 19:41:54 +0000, Tim Harig wrote: > >> One of the arguments for Python has always made is that you can optimize >> it by writing the most important parts in C. Perhaps that is a crutch >> that has held the communty back from seeking higher performance >> solutions in the language itself. > > Are you aware of PyPy? Yes I have heard of PyPy, RPython, and Cython. If they were sufficient I probably wouldn't have to look around. These alternate Python projects have made some small gains; but, they still have a long way to go. > PyPy is now about double the speed of CPython for most things, and they > have set themselves the ambitious target of being faster than C. Let me know when they reach that target. When Java started there was hype that the JIT would be able to run faster then native C because the JIT could optimize at runtime based on the actual data that it encountered. That never really panned out either. From askutt at gmail.com Tue Jan 18 05:53:09 2011 From: askutt at gmail.com (Adam Skutt) Date: Tue, 18 Jan 2011 02:53:09 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com><4d337983$0$29983$c3e8da3$5496439d@news.astraweb.com><044a5101-948d-4458-9c94-57dbb3e25f67@m35g2000vbn.googlegroups.com><4d3467bf$0$29983$c3e8da3$5496439d@news.astraweb.com> Message-ID: <732431c3-b056-4a81-8ff8-c88a2181ef7c@fu15g2000vbb.googlegroups.com> On Jan 18, 3:49?am, "Octavian Rasnita" wrote: > From: "Adam Skutt" > Subject: Re: Tkinter: The good, the bad, and the ugly! > > On Jan 17, 3:08 pm, "Octavian Rasnita" wrote: > > "Batteries included"? > > > Python doesn't follow this policy at all. We can say that maybe PHP > > follows it, but not Python. > > http://lmgtfy.com/?q=python+%22batteries+included%22&l=1 > > Well, this doesn't mean anything because Perl can also say that includes > batteries, and PHP can say it also. It means that Python intentionally endeavorer to include some sort of rich and useful standard library as part of the language, ergo criticisms of the language may include criticisms of its library, like it or not. I'm not sure what makes you believe Perl or PHP are relevant here. > You are perfectly right. Then why favor Tkinter and not WxPython. Why not > strip the Python package and offer WxPython and Tkinter separately? As of now? There's no reason to remove what's there already as long as carrying it as a dependency isn't creating problems for building and distributing Python. But I already mentioned an important reason earlier: the dependencies of Tk are much, much smaller than the dependencies of WxWidgets (though eventually this may change with the X11 port getting complete). Another is that the scope and scale of WxWidgets is problematic: since it's a cross-platform C++ solution it provides a lot of things that it needs, but that Pyhton doesn't especially need or want. It creates incompatibility issues because you end up with a bunch of libraries that become useless when writing a GUI. This problem is minimized with Tk when compared to WxWidgets, and most other toolkits (certainly all the ones I've ever used). Adam From usernet at ilthio.net Tue Jan 18 06:37:34 2011 From: usernet at ilthio.net (Tim Harig) Date: Tue, 18 Jan 2011 11:37:34 +0000 (UTC) Subject: [OT] Python like lanugages [was Re: After C++, what with Python?] References: <86a904f8-05b0-435f-81d6-7450650f1679@glegroupsg2000goo.googlegroups.com> <4d329899$0$43988$742ec2ed@news.sonic.net> <7x8vylfcvz.fsf@ruckus.brouhaha.com> <4d32c7cf$0$29983$c3e8da3$5496439d@news.astraweb.com> <4d3425fe$0$29983$c3e8da3$5496439d@news.astraweb.com> Message-ID: On 2011-01-18, Stefan Behnel wrote: > Tim Harig, 17.01.2011 20:41: >> One of the arguments for Python has always made is that you can optimize >> it by writing the most important parts in C. Perhaps that is a crutch >> that has held the communty back from seeking higher performance solutions >> in the language itself. > > The good news with Cython is that you no longer need to "write the most > important parts in C". Instead, you type them statically and compile them. > You don't even need to sacrifice Python source compatibility for that. So > you get the best of Python at the speed of C (or 'c', as some would say ;). Well not quite. The fact that you still need a Python interpeter should tell you that the end result is not really just C. Effectively, you get the same thing that you might get from writing C modules for your performance sensitive loops. Cython just makes it a little easier to generate the C modules; but, there is still a lot of Python operating under the hood. >> I prefer a single language as opposed to a creolization of two. > > With the possible exception of Lisp, I find it hard to think of a language > that's still alive and not the creolisation of (at least) two other > languages. They all inherited from each other, sometimes right from the > start ("lessons learned") and always during their subsequent life time. I am not talking about language influences. Cython effectively requires two separate languages that interoperate. The end result is a mix of two code written in two separate langauges. That is not a single language solution. >> I certainly don't need to require anybody who >> wants to use a program I have compiled to install an interpreter. > > You will be happy to hear that you can link Cython programs against > libpython (even statically) to build an executable that embeds the > interpreter for you. Besides, on most operating systems, installing a Which means that you effectively end up with a py2exe style frozen binary. While that is a nice hack for solving some problems, it is hardly an elegant solution. It still effectively means that I have to package a redundant Python installation with every binary that I distribute. I just don't have to write installation routines that check for, and potentially install, a compatable version of Python. > interpreter for you. Besides, on most operating systems, installing a > dependency is done automatically, and Go code doesn't run natively on > Windows either, without first installing and running the compiler over it. Go works like C. If I compile my code on Windows, then I can give the binary to another Windows user and they can execute it without having to install any additional software (gcgo currently compiles everything using static binaries. Since the linker only includes the fuctions you actually use, you don't end up with the bloat of embedding entire libraries. I am not sure about gccgo.). The same holds true for Linux, BSD, OS X, and any other supported OS. Every go program includes a runtime componet that provides the garbage collection; but, all of that is included as 100% processor native code. That is quite a bit different from having to include an interpreter to run non-native code. From jeeva235 at hotmail.com Tue Jan 18 06:53:11 2011 From: jeeva235 at hotmail.com (superman) Date: Tue, 18 Jan 2011 03:53:11 -0800 (PST) Subject: THE TRUTH TO MAKING $13,693.94 IN 48 HOURS Message-ID: <6c2fe4f4-3251-4ca9-adef-01db764c7cdb@n32g2000pre.googlegroups.com> THE TRUTH TO MAKING $13,693.94 IN 48 HOURS You need to go and check this out right now! =>> https://secure.aischeckout.com/t/qraiI/nyPHA/subaffiliate It's an underground method to start making CRAZY cash by this time tomorrow! This method is responsible for making $112,075.22 just last month and has the guru's running scared! It even made $13,693.94 in just 48 hours! Forget everything you've been taught in the past and listen up. Go to this page NOW and learn how you can steal this exact $4.1 million business for yourself: =>> https://secure.aischeckout.com/t/qraiI/nyPHA/subaffiliate From marrina0012 at gmail.com Tue Jan 18 07:40:25 2011 From: marrina0012 at gmail.com (Marrina anderson tina) Date: Tue, 18 Jan 2011 04:40:25 -0800 (PST) Subject: Feel free to post your ads in our site. Message-ID: Frieds want to give personal ads as all other essential products which is now available in our site In www.webadlist.com. This is now fastest and growing site where already more than thousand of people uploaded and sold their products. Just now u can also registered and post your ads. Just visit at: http://www.webadlist.com/ From solipsis at pitrou.net Tue Jan 18 07:46:22 2011 From: solipsis at pitrou.net (Antoine Pitrou) Date: Tue, 18 Jan 2011 13:46:22 +0100 Subject: move to end, in Python 3.2 Really? References: <58c17709-d68e-4448-b618-b6f594d0e8c5@t35g2000yqj.googlegroups.com> <125db7fe-036e-47c9-be89-50f05106936f@n2g2000pre.googlegroups.com> Message-ID: <20110118134622.0c181cc4@pitrou.net> On Mon, 17 Jan 2011 21:20:48 -0800 (PST) Raymond Hettinger wrote: > On Jan 17, 6:51?pm, nn wrote: > > ...But the api on this baffles me a bit: > > > > >>> d = OrderedDict.fromkeys('abcde') > > >>> d.move_to_end('b', last=False) > > >>> ''.join(d.keys) > > > > 'bacde' > > > > I understand that "end" could potentially mean either end, but would > > "move_to_end" and "move_to_beginning" not have been clearer? > > The default (and normal usage) is to move an item to the last > position. > So, od.move_to_end(k) becomes a fast equivalent to v=d.pop(k) > followed by d[k]=v. > > The less common usage of moving to the beginning is done with > last=False. This parallels the existing API for od.popitem(): Well I have to agree that moving to the beginning using move_to_end() with a "last" argument looks completely bizarre and unexpected. "Parallels popitem()" is not really convincing since popitem() doesn't have "end" its name. > Those were the design considerations. Sorry you didn't like the > result. Design considerations? Where were they discussed? Regards Antoine. From arndt.roger at addcom.de Tue Jan 18 08:09:10 2011 From: arndt.roger at addcom.de (Arndt Roger Schneider) Date: Tue, 18 Jan 2011 14:09:10 +0100 Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <79a8a$4d332d1a$4275d90a$3986@FUSE.NET> <64976187-88ad-47c9-9bc6-c0712a657264@j32g2000yqc.googlegroups.com> <3af4fd5e-8cc9-4cec-aad2-cbf82ad3bab3@l24g2000vby.googlegroups.com> Message-ID: Terry Reedy schrieb: > On 1/16/2011 11:20 PM, rantingrick wrote: > >> Ok, try this... >> >> http://juicereceiver.sourceforge.net/screenshots/index.php >> http://www.sensi.org/~ak/pyslsk/pyslsk6.png >> http://www.wxwidgets.org/about/screensh.htm > > > Ok, wxwidgets can look at least as good as tk. Agreed that wxpython > might instead link to the excellent wxwidgets page. > Well, tosssing screenshots around doesn't prove wether a framwork/toolkit is good or not; It only displays the developers commitment to create a work of art. Lets examine one of your examples: http://juicereceiver.sourceforge.net/screenshots/index.php#mac Overall impression: The software was designed for windows; more or less following the windows hci-guidelines, The windows version is resonable good. About the Aqua screenshots: 1. Negative actions are located on the falling diagonale. 2-3. The select background and foreground inside the multi-column listbox have the wrong color--the used color originates from text fields. 4. The multi-column listbox should have vertical gridlines. 5-6. Too much top and bottom padding inside the column header. 7. The column texture is wrong --there is a visible line in the bottom. 8. There are white boxess around the input fields. 9. Header column label and lisstbox content are not aligned. 10. There is separator line between the status bar and the brusshed dialog. 11. Last picture: there is a single page inside the tabet control. 12. Last picture: The text "Select radio ..." is trucated, the dialog isn't large enough. 13. The Scheduler activation should come before customizing the scheduler. 14. The dialog uses sunken group boxes for some sections, these group should be 2% darker than their surrounding container. 15. The spacing rules from the aqua hci guidlines are violated. The inner tabset should have 20px distance from both sides, 20px from the bottom, 14px from top. 16. Second last picture: The button lables are truncated. 17. Tree: Uses the wrong folder symbols--from windows--, select background and foreground are wrong, too. - The Aqua hci-guidlines discourage group boxes, the same with the windows guidlines, too. Get rid off group boxes. - second last picture: There should be more top padding for the checkbutton inside the white rectangle; best the same as left-padding. - There no focus frames visilbe inside these screenshots, it would be interessting to see how those are realised. - The icon buttons should be brushed, likewise shoud the column header have brushed background. - Aqua hci guidelines: All dialogs should have a centered appearance. Back to rantingrick 21st century toolkit/framwork: Let's have a look at the numbers: Worlwide pc market are 300 Million pcs per year, this number includes desktops(2/3) and servers(1/3). Your gui app is not relevant on servers. Quite a good deal of the remaining pc's are sold in countries with rampant ilict software copies; Since there are no software cost for these copies the people tend to install the big, bloated software pieces from named computer companies --you wont sell linux there, because it is more expensive than an ilict windows+office++. ~ 100 Million potential new desktop users for you. Apple's projection for the ipad in 2011 are 65 Million pieces, iphone and ipod touch will be roughly the same. 130 Million ios pieces. ~ 130 Million new ios users for you. The android market is still unclear, but I do suppose it will rival ios, lets say 100 Million in 2011. ~ 100 Million new android users for you. Microsoft mobile and blueberry are wildcards; no serious forecast is possible for these devices. Lets assume: ~ 50 Million blueberry, windows mobile. Total is: 380 Million potential new user for your application. wxWidgets: 36000000 LOC, python: 1400000 LOC --these are very old numbers, but from the same time period. wxWidgets on desktop, present for windows, Aqua and X11. wxWidgets on ios, possible but unlikely, the thing is way to big for any ios device. wxWidgets on android not realistic. wxWidgets on blueberry not possible. wxWidgets on windows mobile; development is silverlight with .net, so wxWidgets would have to be ported to .net; not realistic. python on desktop, present. python on ios, possible --if not yet present. python on android, present. python on blueberry, possible. python on windows mobile, present--but .net support deprecated by ms. The smartphone and table market has only started, yet. In 2011 the mobile market is already larger than the desktop pc, almost 3 times largerv. The desktop pc market is in decline; there is however a shift toward pc-servers, instead. It is anybodies guess how far the pc-desktop decline will go. Every 21st century toolkit or framework must run on mobile platforms! wxWidgets was written ~1992, it is a copy of mfc, which in turn is a copy of MacApp. MacApp is also OSS, maintained through an industrie consortium. Why do you not use the original framework? Looking into wxWidgets: The treeview: Trees do not work well with touchscreens. Mutli-column-listbox: Doesn't work at all with touchscreens, instead use simple lists with multi-line entries. Interactivity: keyboard focus, shortcuts, function keys, active foreground, active background are obsolete. hovering tooltips obsolete, status bar to large, obsolete. scrolled dialogs, obsolete. OK, Cancel, Retry, Abort buttons, obsolete, file dialogs obsolete, old style printing obsolete, drag-and-drop obsolete... Screen resolution: The time of 72ppi CRT monitors is over. A GUI framework/toolkit must be resolution independent, including all icons and indicators; it should use decluttering (newspeak:ZUI). Summary wxWidgets: wxWidgets is large scale C++ library from the 20th century, solemnly dedicated toward desktop computers. wxWidgets originates from a time before templates were used in C++ and thus duplicates many of today's C++ features. wxWidgets is not suitable for a modern type GUI ad thus clearly not the toolkit/framework of the 21st century. -roger From orasnita at gmail.com Tue Jan 18 08:49:56 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Tue, 18 Jan 2011 15:49:56 +0200 Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <79a8a$4d332d1a$4275d90a$3986@FUSE.NET> <64976187-88ad-47c9-9bc6-c0712a657264@j32g2000yqc.googlegroups.com> <3af4fd5e-8cc9-4cec-aad2-cbf82ad3bab3@l24g2000vby.googlegroups.com> Message-ID: <2DC5227DF1F24BCB9AA9A7BA069719FE@octavian> From: "Arndt Roger Schneider" > > Overall impression: > The software was designed for windows; more or less > following the windows hci-guidelines, > The windows version is resonable good. This is the most important thing, because most users use Windows. Those who have other preferences are not forced to choose Windows, so it's their choice, and if the interface doesn't look so nice, that's it. > Back to rantingrick 21st century toolkit/framwork: > Let's have a look at the numbers: > Worlwide pc market are 300 Million pcs per year, > this number includes desktops(2/3) and servers(1/3). > Your gui app is not relevant on servers. > Quite a good deal of the remaining pc's are sold in > countries with rampant ilict software copies; > Since there are no software cost for these copies Python is an open source software and the programmers that use Python might also prefer to offer open source software for free so this is not important. And "not legal" is not a very correct term, because somebody from Iran or North Corea must respect the laws from his/her country and in her/his country some things might not be forbidden by law, so it may be perfectly legal. > ~ 100 Million potential new desktop users for you. > > Apple's projection for the ipad in 2011 are 65 Million pieces, > iphone and ipod touch will be roughly the same. > 130 Million ios pieces. > The android market is still unclear, but I do suppose > it will rival ios, lets say 100 Million in 2011. > > ~ 100 Million new android users for you. > > > Microsoft mobile and blueberry are wildcards; > no serious forecast is possible for these devices. > Lets assume: > > ~ 50 Million blueberry, windows mobile. > > Total is: 380 Million potential new user for your application. > > > wxWidgets: 36000000 LOC, python: 1400000 LOC > --these are very old numbers, but from the same time period. This is a bad comparison because the programs targetted to the mobile phones are in most cases very different than the programs that need to be used on the desktop. Do you want to say that WxPython is not good just because it doesn't work well on mobile phones? Those numbers show that only the mobile phones are important, because there are more mobile phones than computers. Well, Python needs a better GUI lib for using them on desktop computers, not on mobile phones. > The desktop pc market is in decline; there is > however a shift toward pc-servers, instead. What do you mean by declining? Are there fewer desktop PCs today than a year ago? > Looking into wxWidgets: > Interactivity: keyboard focus, shortcuts, function keys, > active foreground, active background are obsolete. > hovering tooltips obsolete, status bar to large, obsolete. > scrolled dialogs, obsolete. OK, Cancel, Retry, Abort > buttons, obsolete, file dialogs obsolete, old style printing > obsolete, drag-and-drop obsolete... Who says that they are obsolete? A good GUI interface should offer keyboard accessibility. Otherwise it is broken. > Summary wxWidgets: > wxWidgets is large scale C++ library from the 20th century, > solemnly dedicated toward desktop computers. Yes, Python should promote a good GUI lib for desktop computers, and not a poor GUI lib for desktop computers that might also work on other platforms. > wxWidgets is not suitable for a modern type > GUI ad thus clearly not the toolkit/framework > of the 21st century. Why do you think that everything what's modern is better? Octavian From ethan at stoneleaf.us Tue Jan 18 09:09:11 2011 From: ethan at stoneleaf.us (Ethan Furman) Date: Tue, 18 Jan 2011 06:09:11 -0800 Subject: __pycache__, one more good reason to stck with Python 2? In-Reply-To: <58b2111d-f0d5-499b-8339-6b27bb4743ca@z17g2000prz.googlegroups.com> References: <23e02e0d-b2f1-4b52-85ea-d1feba99dd37@22g2000prx.googlegroups.com> <4d3466d3$0$29983$c3e8da3$5496439d@news.astraweb.com> <0c62aacd-e6d2-4778-81d6-e06924192add@j1g2000vbl.googlegroups.com> <58b2111d-f0d5-499b-8339-6b27bb4743ca@z17g2000prz.googlegroups.com> Message-ID: <4D359F07.1020504@stoneleaf.us> Carl Banks wrote: > On Jan 17, 10:17 am, jmfauth wrote: >> ... >> If I get (stupidly, I agree) a .pyc file and want to test >> it. Should I create manually a cache alongside my test.py >> script? > > Nope: according to PEP 3147 a standalone *.pyc should not be put in > same directory where the source file would have been, not in the > __pycache__ directory (it'll be considered stale otherwise). Typo? According to PEP 3147 a standalone *.pyc *should* (not should not) be put in the same directory where the source file would have been. ~Ethan~ From rui.maciel at gmail.com Tue Jan 18 09:44:57 2011 From: rui.maciel at gmail.com (Rui Maciel) Date: Tue, 18 Jan 2011 14:44:57 +0000 Subject: [OT] Python like lanugages [was Re: After C++, what with Python?] References: <86a904f8-05b0-435f-81d6-7450650f1679@glegroupsg2000goo.googlegroups.com> <4d329899$0$43988$742ec2ed@news.sonic.net> <7x8vylfcvz.fsf@ruckus.brouhaha.com> <4d32c7cf$0$29983$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4d35a769$0$2258$a729d347@news.telepac.pt> Tim Harig wrote: > You still don't see many > companies doing large scale internal development using Python and you > definately don't see any doing external developement using a language > that gives the customers full access to the source code. What you refered as "full access to the source code" only goes as far as the license which was imposed by the copyright holders lets it to go. If you distribute the source code along with the binaries but you only license your code if the licencees accept that they may look at the source code but they can't touch it then distributing the source code is essentially meaningless. There is a good reason why "open source software" is not the same thing as "free software". Rui Maciel From sherm.pendley at gmail.com Tue Jan 18 09:45:33 2011 From: sherm.pendley at gmail.com (Sherm Pendley) Date: Tue, 18 Jan 2011 09:45:33 -0500 Subject: __pycache__, one more good reason to stck with Python 2? References: <23e02e0d-b2f1-4b52-85ea-d1feba99dd37@22g2000prx.googlegroups.com> <4d3466d3$0$29983$c3e8da3$5496439d@news.astraweb.com> <0c62aacd-e6d2-4778-81d6-e06924192add@j1g2000vbl.googlegroups.com> <77ef8068-7f07-404f-8b0e-c039d1122659@e16g2000pri.googlegroups.com> Message-ID: Peter Otten <__peter__ at web.de> writes: > Carl Banks wrote: > >> Well the former deletes all the pyc files in the directory tree >> whereas the latter only deletes the top level __pycache__, not the >> __pycache__ for subpackages. To delete all the __pycache__s you'd >> have to do something like this: >> >> file . -name __pycache__ -prune -exec rm -rf {} \; >> >> or, better, >> >> file . -name __pycache__ -prune | xargs rm -rf >> >> Still not anything really difficult. (I don't think a lot of people >> know about -prune; it tells find don't recursively descend.) > > What's the advantage of 'find ... | xargs ...' over 'find ... -exec ...'? Exec launches a new instance of 'rm' for each found file, while xargs launches a single instance, and passes the list of found files as arg- uments. Probably not a big deal in this case, but if you're passing a long list of files to a script that has a long startup time, it can make a big difference. sherm-- -- Sherm Pendley Cocoa Developer From usernet at ilthio.net Tue Jan 18 10:30:23 2011 From: usernet at ilthio.net (Tim Harig) Date: Tue, 18 Jan 2011 15:30:23 +0000 (UTC) Subject: [OT] Python like lanugages [was Re: After C++, what with Python?] References: <86a904f8-05b0-435f-81d6-7450650f1679@glegroupsg2000goo.googlegroups.com> <4d329899$0$43988$742ec2ed@news.sonic.net> <7x8vylfcvz.fsf@ruckus.brouhaha.com> <4d32c7cf$0$29983$c3e8da3$5496439d@news.astraweb.com> <4d35a769$0$2258$a729d347@news.telepac.pt> Message-ID: On 2011-01-18, Rui Maciel wrote: > Tim Harig wrote: > >> You still don't see many >> companies doing large scale internal development using Python and you >> definately don't see any doing external developement using a language >> that gives the customers full access to the source code. > > What you refered as "full access to the source code" only goes as far as > the license which was imposed by the copyright holders lets it to go. If > you distribute the source code along with the binaries but you only > license your code if the licencees accept that they may look at the source > code but they can't touch it then distributing the source code is > essentially meaningless. There is a good reason why "open source > software" is not the same thing as "free software". That argument is not going to fly with where commericial interests are concerned. The simple fact is that there is legality and then there is reality. People follow licenses like they follow the speed limit: only when they think they might get caught and punished. When people break the licenses, the only recourse is litigation; which is expensive. Even finding and proving license violations is difficult where source is availible. It is therefore in the corporate interest to make breaking licenses as difficult, uneconomical, and tracible as possible; and that is exactly what companies do. Even companies that don't really have any trade secrets to protect are protective about their source keeping it locked out of public view. Access to the source generally means signing an NDA so that if the source is somehow leaked, they know the most likely candidates for the origin [so as not to pun with "source"] of the leak. Whether or not you actually agree with that economic reality is irrelevant. Those who fund commerical projects do; and, any developement tool which violates the security of the source is going to find itself climbing an uphill battle in trying to gain market penetration with commericial software producers. From arndt.roger at addcom.de Tue Jan 18 11:10:25 2011 From: arndt.roger at addcom.de (Arndt Roger Schneider) Date: Tue, 18 Jan 2011 17:10:25 +0100 Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <79a8a$4d332d1a$4275d90a$3986@FUSE.NET> <64976187-88ad-47c9-9bc6-c0712a657264@j32g2000yqc.googlegroups.com> <3af4fd5e-8cc9-4cec-aad2-cbf82ad3bab3@l24g2000vby.googlegroups.com> Message-ID: Octavian Rasnita schrieb: > From: "Arndt Roger Schneider" > At least keep the disclaimer: >> Well, tosssing screenshots around doesn't prove wether >> a framwork/toolkit is good or not; >> It only displays the developers commitment to create >> a work of art. >> >> Overall impression: >> The software was designed for windows; more or less >> following the windows hci-guidelines, >> The windows version is resonable good. > > > > This is the most important thing, because most users use Windows. Those > who have other preferences are not forced to choose Windows, so it's > their choice, and if the interface doesn't look so nice, that's it. > See disclaimer. Since you mentioned "nice": I do not use such words to charcterize a gui. I think the developers of said software tried hard to make it "nice" and "beauty", hence the brushed background and group-boxes --BTW: the windows Guidelines also discourage using group-boxes for usability reasons (see Theo. Mandel object oriented user interfaces). >> Back to rantingrick 21st century toolkit/framwork: >> Let's have a look at the numbers: >> Worlwide pc market are 300 Million pcs per year, >> this number includes desktops(2/3) and servers(1/3). >> Your gui app is not relevant on servers. >> Quite a good deal of the remaining pc's are sold in >> countries with rampant ilict software copies; >> Since there are no software cost for these copies > > > Python is an open source software and the programmers that use Python > might also prefer to offer open source software for free so this is not > important. And "not legal" is not a very correct term, because somebody > from Iran or North Corea must respect the laws from his/her country and > in her/his country some things might not be forbidden by law, so it may > be perfectly legal. > Nice cropping, >>the people tend to install the big, bloated software >pieces from named computer companies >>--you wont sell linux there, because it is more >> expensive than an ilict windows+office++. Illict as in unlicensed. Law has nothing to do with it. And yes these unlicensed sofware has an negative impact on the distribution of free open source software. I wonder, what license do you use in your own work, and what do you think about people which violate your license? >> ~ 100 Million potential new desktop users for you. >> >> Apple's projection for the ipad in 2011 are 65 Million pieces, >> iphone and ipod touch will be roughly the same. >> 130 Million ios pieces. >> The android market is still unclear, but I do suppose >> it will rival ios, lets say 100 Million in 2011. >> >> ~ 100 Million new android users for you. >> >> >> Microsoft mobile and blueberry are wildcards; >> no serious forecast is possible for these devices. >> Lets assume: >> >> ~ 50 Million blueberry, windows mobile. >> >> Total is: 380 Million potential new user for your application. >> >> >> wxWidgets: 36000000 LOC, python: 1400000 LOC >> --these are very old numbers, but from the same time period. > > > This is a bad comparison because the programs targetted to the mobile > phones are in most cases very different than the programs that need to > be used on the desktop. This is the marketplace for all gui applications, and not a comparision. > Do you want to say that WxPython is not good just because it doesn't > work well on mobile phones? I do not comment on the quality of either wxWidgets nor wxPython. Both exist for certain reasons. The desktop pc was the sole target for all the big C++ gui class liraries in 1992. Over time a large code base evolved which makes it very difficult to get these class libraries into new markets--such as today with mobile devices. > Those numbers show that only the mobile phones are important, because > there are more mobile phones than computers. > No, it doesn't. There are billions of mobile phones with graphical user interfaces, still these phones weren't relevant for gui applications. > Well, Python needs a better GUI lib for using them on desktop computers, > not on mobile phones. > wxWidgets is suiteable for the desktop. >> The desktop pc market is in decline; there is >> however a shift toward pc-servers, instead. > > > What do you mean by declining? Are there fewer desktop PCs today than a > year ago? I am writing about graphical applications not computers. > >> Looking into wxWidgets: >> Interactivity: keyboard focus, shortcuts, function keys, >> active foreground, active background are obsolete. >> hovering tooltips obsolete, status bar to large, obsolete. >> scrolled dialogs, obsolete. OK, Cancel, Retry, Abort >> buttons, obsolete, file dialogs obsolete, old style printing >> obsolete, drag-and-drop obsolete... > > > Who says that they are obsolete? > A good GUI interface should offer keyboard accessibility. Otherwise it > is broken. OK, I take keyboard focus back. > >> Summary wxWidgets: >> wxWidgets is large scale C++ library from the 20th century, >> solemnly dedicated toward desktop computers. > > > > Yes, Python should promote a good GUI lib for desktop computers, and not > a poor GUI lib for desktop computers that might also work on other > platforms. > >> wxWidgets is not suitable for a modern type >> GUI ad thus clearly not the toolkit/framework >> of the 21st century. > > > Why do you think that everything what's modern is better? "I belive in the horse", Kaiser Wilhelm II -roger From robert.kern at gmail.com Tue Jan 18 11:25:15 2011 From: robert.kern at gmail.com (Robert Kern) Date: Tue, 18 Jan 2011 10:25:15 -0600 Subject: Efficient python 2-d arrays? In-Reply-To: <28a234f1-c4d7-41a4-a1c5-74ee48a1e9f0@glegroupsg2000goo.googlegroups.com> References: <28a234f1-c4d7-41a4-a1c5-74ee48a1e9f0@glegroupsg2000goo.googlegroups.com> Message-ID: On 1/17/11 7:32 PM, Jake Biesinger wrote: > On Monday, January 17, 2011 4:12:51 PM UTC-8, OAN wrote: >> Hi, >> >> what about pytables? It's built for big data collections and it doesn't >> clog up the memory. > > I thought PyTables depends on NumPy? It does. -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco From __peter__ at web.de Tue Jan 18 11:27:10 2011 From: __peter__ at web.de (Peter Otten) Date: Tue, 18 Jan 2011 17:27:10 +0100 Subject: __pycache__, one more good reason to stck with Python 2? References: <23e02e0d-b2f1-4b52-85ea-d1feba99dd37@22g2000prx.googlegroups.com> <4d3466d3$0$29983$c3e8da3$5496439d@news.astraweb.com> <0c62aacd-e6d2-4778-81d6-e06924192add@j1g2000vbl.googlegroups.com> <77ef8068-7f07-404f-8b0e-c039d1122659@e16g2000pri.googlegroups.com> Message-ID: Stefan Behnel wrote: > Peter Otten, 18.01.2011 10:04: >> What's the advantage of 'find ... | xargs ...' over 'find ... -exec ...'? > > The former runs in parallel, the latter runs sequentially. This may sometimes be relevant, but I doubt that it matters in this particular case. Peter From rantingrick at gmail.com Tue Jan 18 11:27:27 2011 From: rantingrick at gmail.com (rantingrick) Date: Tue, 18 Jan 2011 08:27:27 -0800 (PST) Subject: move to end, in Python 3.2 Really? References: <58c17709-d68e-4448-b618-b6f594d0e8c5@t35g2000yqj.googlegroups.com> <125db7fe-036e-47c9-be89-50f05106936f@n2g2000pre.googlegroups.com> Message-ID: On Jan 18, 6:46?am, Antoine Pitrou wrote: > Design considerations? Where were they discussed? They were never discussed with the bulk of this community and that is part of what i want to change. We have a very small group of folks making all the decisions and that is fine. However this small group of "privileged" folks needs to gather input from the rest of us (peasants) on the value of such changes before making rash decisions. Currently we have a closed set of intellectual inbreeding that is rotting the community gene pool. We need more diversity in this "milkshake" to bring about and foster healthy ideas. No wonder we get these "brain childs" (farts) with inherited diseases from birth. From __peter__ at web.de Tue Jan 18 11:28:34 2011 From: __peter__ at web.de (Peter Otten) Date: Tue, 18 Jan 2011 17:28:34 +0100 Subject: __pycache__, one more good reason to stck with Python 2? References: <23e02e0d-b2f1-4b52-85ea-d1feba99dd37@22g2000prx.googlegroups.com> <4d3466d3$0$29983$c3e8da3$5496439d@news.astraweb.com> <0c62aacd-e6d2-4778-81d6-e06924192add@j1g2000vbl.googlegroups.com> <77ef8068-7f07-404f-8b0e-c039d1122659@e16g2000pri.googlegroups.com> Message-ID: Sherm Pendley wrote: > Peter Otten <__peter__ at web.de> writes: > >> Carl Banks wrote: >> >>> Well the former deletes all the pyc files in the directory tree >>> whereas the latter only deletes the top level __pycache__, not the >>> __pycache__ for subpackages. To delete all the __pycache__s you'd >>> have to do something like this: >>> >>> file . -name __pycache__ -prune -exec rm -rf {} \; >>> >>> or, better, >>> >>> file . -name __pycache__ -prune | xargs rm -rf >>> >>> Still not anything really difficult. (I don't think a lot of people >>> know about -prune; it tells find don't recursively descend.) >> >> What's the advantage of 'find ... | xargs ...' over 'find ... -exec ...'? > > Exec launches a new instance of 'rm' for each found file, while xargs > launches a single instance, and passes the list of found files as arg- > uments. > > Probably not a big deal in this case, but if you're passing a long list > of files to a script that has a long startup time, it can make a big > difference. You can avoid that: $ touch {1..10}.txt $ find . -exec python -c'import sys; print sys.argv' {} \; ['-c', '.'] ['-c', './10.txt'] ['-c', './1.txt'] ['-c', './7.txt'] ['-c', './8.txt'] ['-c', './4.txt'] ['-c', './6.txt'] ['-c', './3.txt'] ['-c', './5.txt'] ['-c', './9.txt'] ['-c', './2.txt'] $ find . -exec python -c'import sys; print sys.argv' {} \+ ['-c', '.', './10.txt', './1.txt', './7.txt', './8.txt', './4.txt', './6.txt', './3.txt', './5.txt', './9.txt', './2.txt'] Peter From rantingrick at gmail.com Tue Jan 18 11:53:12 2011 From: rantingrick at gmail.com (rantingrick) Date: Tue, 18 Jan 2011 08:53:12 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <79a8a$4d332d1a$4275d90a$3986@FUSE.NET> <64976187-88ad-47c9-9bc6-c0712a657264@j32g2000yqc.googlegroups.com> <3af4fd5e-8cc9-4cec-aad2-cbf82ad3bab3@l24g2000vby.googlegroups.com> Message-ID: On Jan 18, 7:09?am, Arndt Roger Schneider wrote: > Summary wxWidgets: > wxWidgets is large scale C++ library from the 20th century, > solemnly dedicated toward desktop computers. > wxWidgets originates from a time before templates > were used in C++ and thus duplicates many of > today's C++ features. > wxWidgets is not suitable for a modern type > GUI ad thus clearly not the toolkit/framework > of the 21st century. Alight i'll except that Rodger. Wx may be unusable for the mobile market. And since the mobile market is exploding --and will continue to explode-- then we need to consider this. However, does any GUI library exist that can handle desktop, mobile, and accessibility and do it all in a 21st century way? You slaughtered wx but failed to provide any alternative, however i am listing to your advice contently because it is very good advice. Read on... We DO need to consider the mobile market in this decision. Maybe it is time for us to actually get on the cutting edge of GUI's. Maybe we should head an effort to create a REAL 21st century GUI that can handle desktop, mobile, and accessibility, and do it all whilst looking very sharp! Sure we rob from peter to pay paul. We will use Tkinters awesome API and geometry managers, wxPythons feature richness, and any other code we can steal to make this work! Then we can "advertise" python as the best GUI language available. I have nothing against seeing Python on more devices and this would no doubt bring that dream into fruition. There is a huge hole in the market at this very moment and we need to pounce on it like a hungry tiger on wildebeest. Just think how wonderful it would be to switch from mobile to desktop and still write beatiful Python code. From python at mrabarnett.plus.com Tue Jan 18 11:54:42 2011 From: python at mrabarnett.plus.com (MRAB) Date: Tue, 18 Jan 2011 16:54:42 +0000 Subject: move to end, in Python 3.2 Really? In-Reply-To: References: <58c17709-d68e-4448-b618-b6f594d0e8c5@t35g2000yqj.googlegroups.com> <125db7fe-036e-47c9-be89-50f05106936f@n2g2000pre.googlegroups.com> Message-ID: <4D35C5D2.7060606@mrabarnett.plus.com> On 18/01/2011 16:27, rantingrick wrote: > On Jan 18, 6:46 am, Antoine Pitrou wrote: > >> Design considerations? Where were they discussed? > > > They were never discussed with the bulk of this community and that is > part of what i want to change. We have a very small group of folks > making all the decisions and that is fine. However this small group of > "privileged" folks needs to gather input from the rest of us > (peasants) on the value of such changes before making rash decisions. > > Currently we have a closed set of intellectual inbreeding that is > rotting the community gene pool. We need more diversity in this > "milkshake" to bring about and foster healthy ideas. No wonder we get > these "brain childs" (farts) with inherited diseases from birth. Decisions are made after open discussion (although we're not sure about "move to end" :-)). You shouldn't complain about not being consulted if you don't take the time to join in... From rantingrick at gmail.com Tue Jan 18 12:10:48 2011 From: rantingrick at gmail.com (rantingrick) Date: Tue, 18 Jan 2011 09:10:48 -0800 (PST) Subject: move to end, in Python 3.2 Really? References: <58c17709-d68e-4448-b618-b6f594d0e8c5@t35g2000yqj.googlegroups.com> <125db7fe-036e-47c9-be89-50f05106936f@n2g2000pre.googlegroups.com> Message-ID: <99e7061d-20d5-434b-9404-bdafd6a013ac@i17g2000vbq.googlegroups.com> On Jan 18, 10:54?am, MRAB wrote: > Decisions are made after open discussion (although we're not sure about > "move to end" :-)). You shouldn't complain about not being consulted if > you don't take the time to join in... Well don't get wrong i want to join in --not that i have all the solutions-- however python-dev is a dangerous place for the uninitiated. And we can't have thousands and thousands of posts clogging up the main pool because that would only serve to slow the process to a grinding hault. However, we need some way that the average Python programmer can speak up and be heard when any subject that he/she is passionate about comes before the "council". These folks probably don't want to participate in the highly competitive environment of Python dev. However they may have very good ideas. I think we are doing this community a dis service by not giving these voices an outlet. We need either some way to vote outside of Python dev. i think it would be much easier to just have a site where all proposals can be viewed by anyone and they can offer input without clogging up Python dev with noob questions or bad ideas. Then the "council" can review these suggestions and make a more informed decision. Some might say "well that is what blogs and c.l.py is for" and i say wrong. I believe more folks would get involved if they felt that the medium was real. c.l.py is not that place (although it could be with some changes) and python.dev is not that place. I am open to any ideas you may have. From kushal.kumaran+python at gmail.com Tue Jan 18 12:15:00 2011 From: kushal.kumaran+python at gmail.com (Kushal Kumaran) Date: Tue, 18 Jan 2011 22:45:00 +0530 Subject: Python unicode utf-8 characters and MySQL unicode utf-8 characters In-Reply-To: <1914ba89-7ecc-43d5-8fbc-9a45f27ae8c8@z5g2000yqb.googlegroups.com> References: <1914ba89-7ecc-43d5-8fbc-9a45f27ae8c8@z5g2000yqb.googlegroups.com> Message-ID: 2011/1/18 Grzegorz ?liwi?ski : > Hello, > Recently I tried to insert some unicode object in utf-8 encoding into > MySQL using MySQLdb, and got MySQL warnings on characters like: > ???? i found somewhere in my data. I can't even read them. MySQL > seems to cut the whole string after that characters off, so I get > incomplete data. > After a little bit of digging I found out, that MySQL usually supports > utf-8 data but encoded into maximum three bytes. That's why I think it > would help I f I was able to replace all larger unicode characters > with replacement characters. > > Is there any way, I could adjust python unicode utf-8 encoded strings > to be accepted by mysql utf-8 columns? Did you pass the charset argument when creating your MySQLdb connection? -- regards, kushal From solipsis at pitrou.net Tue Jan 18 12:56:34 2011 From: solipsis at pitrou.net (Antoine Pitrou) Date: Tue, 18 Jan 2011 18:56:34 +0100 Subject: move to end, in Python 3.2 Really? References: <58c17709-d68e-4448-b618-b6f594d0e8c5@t35g2000yqj.googlegroups.com> <125db7fe-036e-47c9-be89-50f05106936f@n2g2000pre.googlegroups.com> <99e7061d-20d5-434b-9404-bdafd6a013ac@i17g2000vbq.googlegroups.com> Message-ID: <20110118185634.541cd9e1@pitrou.net> On Tue, 18 Jan 2011 09:10:48 -0800 (PST) rantingrick wrote: > > Well don't get wrong i want to join in --not that i have all the > solutions-- Take a look at http://docs.python.org/devguide/#contributing From debatem1 at gmail.com Tue Jan 18 12:57:03 2011 From: debatem1 at gmail.com (geremy condra) Date: Tue, 18 Jan 2011 09:57:03 -0800 Subject: [OT] Python like lanugages [was Re: After C++, what with Python?] In-Reply-To: References: <86a904f8-05b0-435f-81d6-7450650f1679@glegroupsg2000goo.googlegroups.com> <4d329899$0$43988$742ec2ed@news.sonic.net> <7x8vylfcvz.fsf@ruckus.brouhaha.com> <4d32c7cf$0$29983$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Mon, Jan 17, 2011 at 4:02 PM, Tim Harig wrote: >> Go is not an ideal language for high-performance code. Despite the >> occasional claims of others, Go is consistently outperformed by C, >> C++, and Java on a wide variety of benchmarks. Some claim that Ada and >> Haskell do as well, and my benchmarks (CPU bound, focused on speed of > > I much agree that Go doesn't beat C or C++. ?I really doubt that it could > with the runtime necessary to do garbage collction. ?Nevertheless, I find > that Go can be optimized to perform within tolerable limits of C given the > boost it gives in development. The question isn't whether you will use it; right or wrong, it seems certain that you will. The question is whether it will see significant uptake, and this is a big barrier for many. > I really question that you get Java anywhere even close to C performance. > Google reports they get within the same order of magnitude as C for > their long-lived server processes where the JIT has had time to optimize > its results. ?For shorter term processes such as desktop applications, > Java performance stinks -- even after you discount the JVM starup time. I'm sorry, but you're wrong on this. Java's performance can be excellent, particularly when it comes to mathematical functions. I recall reading a pretty smug paper a few years ago describing how they managed to beat C on a number of numerical benchmarks. > Ada is capable of C++ like performance *if* you compile it to remove *all* > of runtime checking. ?Depending what checks you enable, it can run much > slower. No idea, never used it. >> in line with the work of others. You can argue that it's good enough- >> it is, for most cases- but taking a 20% performance hit rules it out >> of a lot of systems work, and the C-Go gap in many cases is much >> larger than that. > > I don't work anything that involves and absolute need for performance. Then don't argue about performance, it makes you look like a hack just eager to shill for your language. > I could probably accept penalty several times that of C for higher > level functionality; but, sometimes the penalty for Python is just > too much. ?Many of my programs are very quick lived such that even > loading an interpeter or VM can eclipse the actual runtime. ?Given less > developmental effort required, I also find that I have more time to look > for ways to optimize Go. ?There are many things (such as using alternate > data structures rather then the build in slices and immutable strings) > that can be used to accelerate Go when time permits and I suspect many > more will be found as the language matures. This is inconsistent with your argument about PyPy. See my earlier comment. >> Go is also not an ideal language for enterprise development. It >> provides no compatibility or support guarantees; in fact, the website >> describes it as 'an experiment' and recommends it for 'adventurous > > There is no doubt that it is a young project and there are a number of > things that will need to be improved to be effective for some branches > of programming; but, that isn't a language restriction. It will nevertheless preclude its use in most enterprise software development. That's most systems software. > ?Frankly, I am > rather impressed by the sheer number of third party packages that have > already become available. ?No go isn't going to replace some of the other > top mainstream langauges today; but, I can easily see it starting to see > some market penetration 5 years from now. I suppose that for some small value of market penetration ('mom uses it!') you're right. I don't see any evidence of major movement at this moment though. >> users'. There are no independent experts in case something goes wrong, >> and if it goes belly up a year from now you will have a one year old >> piece of legacy infrastructure on your hands. Maybe you don't think >> that this will be the case; in any event, I would not want to try >> convincing a CFO of that. > > If I was trying to convince a CFO, I would ask if he really thought Google > was likely to simply drop the time and effort that Google has already > placed into the infrastructure. Hahahaha. You mean like wave? >?Furthermore, few dying languages already > have not one, but two, open source compilers available for use. Two compilers by the same people. Not two active projects. Big difference. > Database bindings are another weak link outside of the more common > open source databases. ?In both cases, Go readily capable of C library > functions as a stop-gap until a native wrapper is available. ?Yes it will > be nice once community has filled in the gaps; but, I am rather impressed > at what is already available in less then a years time. ?There are a few > libraries you may have missed here: Sounds like a two-language solution, ie, the thing you criticized Python for. > I will point out that Go's libraries are miles ahead of the standard C > library and other minimalistic standard libraries. ?Many things are > possible with even the most basic functionalities. ?I don't use Python > bindings when using GNUplot simply because its easier to access GNUplot > directly. And miles behind Python and other large standard libraries. > Finally, and most importantly, nothing about any third party tools and > libraries has any bearing on the generality language itself. Except for its uptake. >>> Support for concurrency is really icing on the cake. ?I find it rather >>> supprising that so many modern languages do not already support full >>> concurrency constructs. >> >> Go's most-lauded feature is its goroutines. I suspect that if this >> isn't a big deal for you, you aren't its primary use case. > > Actually, I would consider Go's implicit interfaces to be a far more > important innovation. ?The goroutines are nice but not ground breaking. > They are quite recognizable to other SCP concurrancy derivatives. I think if we did a poll of people who had heard of Go, they would generally say that concurrency was its big selling point. I suspect that its (ugly, IMHO) interface mechanism would not appear on the list. > C fails to be an object oriented language because it fails to provide > the syntactic sugar necessary to bind functions to the data that they > manipulate and because it doesn't provide the isolation necessary for > encapsilation of objects. No, it doesn't. I can add functions to structures using function pointers, and languages like Python only provide encapsulation by convention. There's no reason why that couldn't be true for C as well. Ergo, if Go is OO, then C is OO. > defer/panic/recover is conceptually a world closer to exceptions then is > setjmp/longjmp. ?It really isn't any further different then the variantions > in exceptions between different languages. We can agree to disagree here. As I say, I find it much closer to things like the with statement than true exceptions, and general internet rabble seems to agree. As a question, given how hot you are for this language I have to wonder how much of it you've actually written. Could you provide a link? Google code search turned up nada. Geremy Condra From joe at goldthwaites.com Tue Jan 18 13:01:19 2011 From: joe at goldthwaites.com (Joe Goldthwaite) Date: Tue, 18 Jan 2011 11:01:19 -0700 Subject: newby qn about functions In-Reply-To: References: Message-ID: <00710D8B61E1450BB05F97C22E27D6D9@NewMBP> I'm not sure I understand the question completely but maybe the function below does what you want. def lower_case(s): return ?Testing Functions-lower case: ? + s.lower() print lower_case(?AbCdEfG?) ________________________________________ From: python-list-bounces+joe=goldthwaites.com at python.org [mailto:python-list-bounces+joe=goldthwaites.com at python.org] On Behalf Of Cathy James Sent: Tuesday, January 18, 2011 3:02 AM To: python-list at python.org Subject: newby qn about functions #This has to be very simple, but I don't get it-please help ? def lower_case(s): ??? #return s ??? print(s) ??? #return s.lower() ??? print(s.lower()) s= "Testing?Functions-lower case: " lower_case(s) """how can i use a return statement? to write a function that returns the string "Testing?Functions-lower case: "and the lowercase representation of its string parameter""" If I uncomment the above, nothing outputs to console:( ? Much appreciation as always. From python at rcn.com Tue Jan 18 13:14:49 2011 From: python at rcn.com (Raymond Hettinger) Date: Tue, 18 Jan 2011 10:14:49 -0800 (PST) Subject: UTF-8 question from Dive into Python 3 References: Message-ID: <748ae354-c735-4bd6-95c7-8353ee5fb005@q8g2000prm.googlegroups.com> On Jan 17, 2:19?pm, carlo wrote: > Hi, > recently I had to study *seriously* Unicode and encodings for one > project in Python but I left with a couple of doubts arised after > reading the unicode chapter of Dive into Python 3 book by Mark > Pilgrim. > > 1- Mark says: > "Also (and you?ll have to trust me on this, because I?m not going to > show you the math), due to the exact nature of the bit twiddling, > there are no byte-ordering issues. A document encoded in UTF-8 uses > the exact same stream of bytes on any computer." . . . > 2- If that were true, can you point me to some documentation about the > math that, as Mark says, demonstrates this? I believe Mark was referring to the bit-twiddling described in the Design section at http://en.wikipedia.org/wiki/UTF-8 . Raymond From arndt.roger at addcom.de Tue Jan 18 13:25:44 2011 From: arndt.roger at addcom.de (Arndt Roger Schneider) Date: Tue, 18 Jan 2011 19:25:44 +0100 Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <79a8a$4d332d1a$4275d90a$3986@FUSE.NET> <64976187-88ad-47c9-9bc6-c0712a657264@j32g2000yqc.googlegroups.com> <3af4fd5e-8cc9-4cec-aad2-cbf82ad3bab3@l24g2000vby.googlegroups.com> Message-ID: rantingrick schrieb: > On Jan 18, 7:09 am, Arndt Roger Schneider > wrote: > > >>Summary wxWidgets: >>wxWidgets is large scale C++ library from the 20th century, >>solemnly dedicated toward desktop computers. >>wxWidgets originates from a time before templates >>were used in C++ and thus duplicates many of >>today's C++ features. >>wxWidgets is not suitable for a modern type >>GUI ad thus clearly not the toolkit/framework >>of the 21st century. > > > > Alight i'll except that Rodger. Wx may be unusable for the mobile > market. And since the mobile market is exploding --and will continue > to explode-- then we need to consider this. However, does any GUI > library exist that can handle desktop, mobile, and accessibility and > do it all in a 21st century way? You slaughtered wx but failed to > provide any alternative, however i am listing to your advice contently > because it is very good advice. Read on... Thanks! Again this is not about the quality of wxWidgets, wxWidgets grew large because there was vested interest in it. Its success is its undoing. > > We DO need to consider the mobile market in this decision. Maybe it is > time for us to actually get on the cutting edge of GUI's. Maybe we > should head an effort to create a REAL 21st century GUI that can > handle desktop, mobile, and accessibility, and do it all whilst > looking very sharp! Sure we rob from peter to pay paul. We will use > Tkinters awesome API and geometry managers, wxPythons feature > richness, and any other code we can steal to make this work! I am not sure whether this sarcasms or for real..., so I'll take for genuine. Tk is also doomed, and Tkinter isn't Tk. You are right about keeping the separate geometry managers, though. For starters: http://kenai.com/projects/swank Swank publishes java/swing classes as tk in jtcl, which is similar to what tkinter does for python and tk. It should be feasible to use swank with the tkinter interface for jpython--without jtcl. However, this doesn't make tkinter mobile, neither is swing available on android. When you look into the android developer documents concerning the gui, then you can see that the gui model is quite similar to tk. So I suppose android can be reached by jpython in a two stage process. The other devices are more difficult to reach, though. There is webkit on some, but not all. Webkit is available for the desktop, ios and android--today without svg. There are two ways to gain graphical independence: First a basic implementation for each platform and second through abstraction. With abstraction I mean to base the gui on a common graphical model present on all platforms and hence to implement the "toolkit" on-top of it in python (not C, C++, java,javascript), python! The single common graphical model is SVG. > > Then we can "advertise" python as the best GUI language available. I > have nothing against seeing Python on more devices and this would no > doubt bring that dream into fruition. There is a huge hole in the > market at this very moment and we need to pounce on it like a hungry > tiger on wildebeest. Just think how wonderful it would be to switch > from mobile to desktop and still write beatiful Python code. > So be it. -roger From tjreedy at udel.edu Tue Jan 18 13:26:07 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Tue, 18 Jan 2011 13:26:07 -0500 Subject: [OT] Python like lanugages [was Re: After C++, what with Python?] In-Reply-To: References: <86a904f8-05b0-435f-81d6-7450650f1679@glegroupsg2000goo.googlegroups.com> <4d329899$0$43988$742ec2ed@news.sonic.net> <7x8vylfcvz.fsf@ruckus.brouhaha.com> <4d32c7cf$0$29983$c3e8da3$5496439d@news.astraweb.com> <4d35a769$0$2258$a729d347@news.telepac.pt> Message-ID: On 1/18/2011 10:30 AM, Tim Harig wrote: > Whether or not you actually agree with that economic reality is > irrelevant. Those who fund commerical projects do; and, any developement > tool which violates the security of the source is going to find itself > climbing an uphill battle in trying to gain market penetration with > commericial software producers. Of course. When I submit or commit patches, I am doing it mostly for hobby, educational, and scientific users, and maybe website makers (who make site I can visit). If commercial users piggyback on top, ok. I do not know how many developers, if any, are after such market penetration. Shedskin compiles a slowly growing subset of Python to native code. But I do not know that it has gotten any commercial support. Maybe Mark should sell it instead of giving it away for commercial use (if he does now). -- Terry Jan Reedy From askutt at gmail.com Tue Jan 18 13:29:22 2011 From: askutt at gmail.com (Adam Skutt) Date: Tue, 18 Jan 2011 10:29:22 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <79a8a$4d332d1a$4275d90a$3986@FUSE.NET> <64976187-88ad-47c9-9bc6-c0712a657264@j32g2000yqc.googlegroups.com> <3af4fd5e-8cc9-4cec-aad2-cbf82ad3bab3@l24g2000vby.googlegroups.com> Message-ID: On Jan 18, 8:09?am, Arndt Roger Schneider wrote: > Back to rantingrick 21st century toolkit/framwork: > Let's have a look at the numbers: > Worlwide pc market are 300 Million pcs per year, > this number includes desktops(2/3) and servers(1/3). > Your gui app is not relevant on servers. You should tell this "fact" to just about every major enterprise software manufacturer out there. They all ship GUI tools intended to be used on the server. Some of them ship only GUI tools or CLI tools that are worthless, making you use the GUI tools. > The desktop pc market is in decline; there is > however a shift toward pc-servers, instead. > It is anybodies guess how far the pc-desktop decline will go. > Every 21st century toolkit or framework must run on > mobile platforms! Until we have pixel-perfect touch sensors, toolkits for devices with pointer interfaces (e.g., PCs) and toolkits for devices with touch interfaces (e.g., phones and tablets) will necessarily be different. You note this yourself: the UI paradigms that work well when you have a pixel-perfect pointer do not work at all when you have a touch screen, especially on a limited size and resolution display. Even if you're provided a "single" toolkit, you still end up with two, maybe three, different applications, each using different widgets targeted for the device they run on. And no one provides a "single" toolkit: while Silverlight can run on the desktop, the web, and now on Windows Phone, you can't use the same widgets everywhere; ditto with Cocoa for OS X and Cocoa Touch for iTouch devices. While some further unification is obviously possible, it's rather doubtful we'll ever have unified widgets that are truly workable on the web, on the "desktop", and on a portable touch screen device. > > wxWidgets was written ~1992, it is a copy of > mfc, which in turn is a copy of MacApp. MacApp > is also OSS, maintained through an industrie consortium. > Why do you not use the original framework? > Because it's not cross-platform, I'd imagine. The entire point of wxWidgets was to provide a cross-platform "OOP" UI toolkit. It closely copies MFC since MFC and XView were the two "backends" it supported. > Screen resolution: > ? ?The time of 72ppi CRT monitors is over. A GUI > ? ?framework/toolkit must be resolution independent, > ? ?including all icons and indicators; > ? ?it should use decluttering (newspeak:ZUI). > WPF is the only functional resolution-independent UI toolkit in existence. While I don't disagree with you in principal, practice is pretty heavily divorced from principal here. Principal doesn't help me write GUI applications today. > wxWidgets is not suitable for a modern type > GUI ad thus clearly not the toolkit/framework > of the 21st century. None of the toolkits accessible from CPython are suitable for a 21st century guy by your standard. If we talk about IronPython, Silverlight becomes the closest, but it isn't a panacea by any stretch of the imagination. Adam From rantingrick at gmail.com Tue Jan 18 13:33:45 2011 From: rantingrick at gmail.com (rantingrick) Date: Tue, 18 Jan 2011 10:33:45 -0800 (PST) Subject: move to end, in Python 3.2 Really? References: <58c17709-d68e-4448-b618-b6f594d0e8c5@t35g2000yqj.googlegroups.com> <125db7fe-036e-47c9-be89-50f05106936f@n2g2000pre.googlegroups.com> <99e7061d-20d5-434b-9404-bdafd6a013ac@i17g2000vbq.googlegroups.com> Message-ID: <665f862b-0d8f-476a-ae51-d8fdc9767f0a@g26g2000vbi.googlegroups.com> On Jan 18, 11:56?am, Antoine Pitrou wrote: > On Tue, 18 Jan 2011 09:10:48 -0800 (PST) > > rantingrick wrote: > > > Well don't get wrong i want to join in --not that i have all the > > solutions-- > > Take a look athttp://docs.python.org/devguide/#contributing Thanks for this link Antoine however i think you missed the point of my post. What i would like to see is an forum where the "noob" to "average" python programmer can voice his/her opinion about the current state or future state of Pythons syntax, stdlib, goals and dreams, etc, al the while not fearing attack from all sides. Currently such a place is non-existent. I believe many folks would get involved if this "place" existed however it does not exist. I also believe that these same folks have no interest in "debating" in the highly competitive environmental of python-dev, python-ideas. Heck, even c.l.py is far too competitive! They just basically want a forum were they can come in and give their two cents and leave. comp.lang.py would be a good place for this to happen since "after all" Usenet was created for like-minded people to collaborate in lively discussion. However c.l.py has a problem with criminals. We need to bring these "predators", "bullies", and "brow beaters" under control. I have seen many new voices come in and then get crucified by these scoundrels causing them to quickly "tuck tail" and run for cover --never to return again-- and nobody says a word!!!! And anyone who dares to speak out is threatened with the kill-file. This group has been handed over to the criminals who's only concern is chaos and anarchy all the while making sure that they control the speech and content herein. Now don't get me wrong we have a lot of good people here but they are too fearful to speak up. Sadly these folks don't realize that by staying quiet they only embolden the criminals to do more dastardly deeds. These criminals are cowards by nature, and when presented with a united front they will themselves "tuck tail" and run for the hills never to return. I am not saying we cannot have lively discussion, or even use the occasional sarcastic quip. No, what i am saying is that we need hear all sides of the argument. Remember this is a community of many different people wanting many different things. We must be willing to first listen, and then compromise on all sides -- if we want to move forward. Ask not... What is best for me? Instead ask yourself... What is best for the entire community? So the moral is... either we need to take back c.l.py (by force if needed!) or we need to abandon c.l.py and open a more friendly environment for Python discussions. Either way if this "forum" is not taken seriously by the "elite" then it will be yet another catastrophic failure! From alex.kapps at web.de Tue Jan 18 13:34:47 2011 From: alex.kapps at web.de (Alexander Kapps) Date: Tue, 18 Jan 2011 19:34:47 +0100 Subject: Tkinter: The good, the bad, and the ugly! In-Reply-To: <4D35DCE8.5030002@web.de> References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com><4d337983$0$29983$c3e8da3$5496439d@news.astraweb.com><044a5101-948d-4458-9c94-57dbb3e25f67@m35g2000vbn.googlegroups.com><4d3467bf$0$29983$c3e8da3$5496439d@news.astraweb.com> <4D34B04E.8050309@web.de> <4266E8D7BA204BFEA5BF66C635CE1716@octavian> <4D35DCE8.5030002@web.de> Message-ID: <4D35DD47.1070304@web.de> On 18.01.2011 09:58, Octavian Rasnita wrote: > From: "Alexander Kapps" >> On 17.01.2011 21:04, Octavian Rasnita wrote: >>> I say probably not considering the availability of 3rd party >>> downloads. What say you, Python community? >> >> Available as 3rd party downloads: >> >> XML,HTML,... >> HTTP,FTP,SMTP,POP,IMAP/... >> MD5,SHA,... >> zip,bzip,... >> >> and so on and so on and so on. >> >> Remove them all just because they are available as 3rd party >> downloads? > > No, they should not be removed because they don't cause any damage, > very bad damage as Tkinter does. Tkinter causes damage? Very bad damage? What are you talking about? >> The "Batteries included" of Python is just *great* and I vote for >> *more* not less batteries! > > Well, in that case, why don't you agree to also include WxPython in > the Python package? Well, I don't like wx that much and others have already highlighted some of the problems with it. I think that adding redundancy is bad and I really want a GUI toolkit that makes it easy to quickly write a simple GUI, so I do not want wx to replace Tkinter. But yes, I wouldn't mind the inclusion of a large GUI package. >>> And one more thing. Not all the Python programmers create desktop >>> apps so a GUI lib is useless. Some of them use Python only for >>> web programming or only for system administration. >> >> Not all Python programmers do web programming, so please remove >> the useless HTML junk too. > > Why do you call it "html junk"? You said a GUI lib is useless because not all programmers write GUIs. so I say an HTML lib is useless because not all programmers write web stuff. Got it? Both are useful and I'm absolutely against any attempt to remove either from the stdlib. *That* would cause damage. >> Almost every beginner wants to do GUIs or at least some graphic >> stuff. Removing the GUI module from the stdlib would be plain >> wrong IMHO. But I don't understand the whole issue anyway. It >> isn't that you need to fire up your torrent client and wait 48 >> hours for the Python download to complete. Why remove useful (to >> many, not most) stuff from the lib? > > Yes it can be useful for some people, but why promote it instead of > promoting a better library for beginners? Which one? That's the whole point. There currently is no better GUI lib than Tkinter which allows quick and easy GUI programming and still has a large widget set, is pythonic and so on. PyGUI might be in the future. If you care that much go on and help making it happen. I have absolutely no problem with a better GUI lib, I just don't care much and those who seem to care enough to start a war over and over again seem to be unwilling to really do anything. > Octavian > From pruebauno at latinmail.com Tue Jan 18 13:39:43 2011 From: pruebauno at latinmail.com (nn) Date: Tue, 18 Jan 2011 10:39:43 -0800 (PST) Subject: move to end, in Python 3.2 Really? References: <58c17709-d68e-4448-b618-b6f594d0e8c5@t35g2000yqj.googlegroups.com> <125db7fe-036e-47c9-be89-50f05106936f@n2g2000pre.googlegroups.com> Message-ID: <8c6c051c-cb76-4e38-97c0-ad9b658d3b41@37g2000prx.googlegroups.com> On Jan 18, 12:20?am, Raymond Hettinger wrote: > On Jan 17, 6:51?pm, nn wrote: > > > ...But the api on this baffles me a bit: > > > >>> d = OrderedDict.fromkeys('abcde') > > >>> d.move_to_end('b', last=False) > > >>> ''.join(d.keys) > > > 'bacde' > > > I understand that "end" could potentially mean either end, but would > > "move_to_end" and "move_to_beginning" not have been clearer? > > The default (and normal usage) is to move an item to the last > position. > So, od.move_to_end(k) becomes a fast equivalent to v=d.pop(k) > followed by d[k]=v. > > The less common usage of moving to the beginning is done with > last=False. ?This parallels the existing API for od.popitem(): > > >>> od = OrderedDict.fromkeys('abcdefghi') > >>> od.move_to_end('c') ? ? ? ? ? ? ? # default case: ?move to last > >>> od.popitem() ? ? ? ? ? ? ? ? ? ? ?# default case: ?pop from last > ('c', None) > >>> od.move_to_end('d', last=False) ? # other case: ? ?move to first > >>> od.popitem(last=False) ? ? ? ? ? ?# other case: ? ?pop from first > > ('d', None) > > The existing list.pop() API is similar (though it takes an index > value instead of a boolean): > > >>> mylist.pop() ? ? ? ? ? ? ? ? ? ? ?# default case: ?pop from last > >>> mylist.pop(0) ? ? ? ? ? ? ? ? ? ? # other case: ? ?pop from first > > Those were the design considerations. ?Sorry you didn't like the > result. > > Raymond Ah that is where it came from! I didn't remember popitem used that API too. If you use them together it has a nice symmetry. I guess it is just that "end" is more confusing than "pop" in that context. Considering the precedence of popitem I withdraw my objection. I still think it looks a bit odd but it is not unreasonable either. Sometimes ugly consistency trumps beautiful inconsistency; c'est la vie... From emile at fenx.com Tue Jan 18 13:55:57 2011 From: emile at fenx.com (Emile van Sebille) Date: Tue, 18 Jan 2011 10:55:57 -0800 Subject: move to end, in Python 3.2 Really? In-Reply-To: <99e7061d-20d5-434b-9404-bdafd6a013ac@i17g2000vbq.googlegroups.com> References: <58c17709-d68e-4448-b618-b6f594d0e8c5@t35g2000yqj.googlegroups.com> <125db7fe-036e-47c9-be89-50f05106936f@n2g2000pre.googlegroups.com> <99e7061d-20d5-434b-9404-bdafd6a013ac@i17g2000vbq.googlegroups.com> Message-ID: On 1/18/2011 9:10 AM rantingrick said... > On Jan 18, 10:54 am, MRAB wrote: > >> Decisions are made after open discussion (although we're not sure about >> "move to end" :-)). You shouldn't complain about not being consulted if >> you don't take the time to join in... > > Well don't get wrong i want to join in --not that i have all the > solutions-- however python-dev is a dangerous place for the > uninitiated. And we can't have thousands and thousands of posts > clogging up the main pool because that would only serve to slow the > process to a grinding hault. > > However, we need some way that the average Python programmer can speak > up and be heard when any subject that he/she is passionate about comes > before the "council". These folks probably don't want to participate > in the highly competitive environment of Python dev. However they may > have very good ideas. I think we are doing this community a dis > service by not giving these voices an outlet. > > We need either some way to vote outside of Python dev. i think it > would be much easier to just have a site where all proposals can be > viewed by anyone and they can offer input without clogging up Python > dev with noob questions or bad ideas. Then the "council" can review > these suggestions and make a more informed decision. Some might say > "well that is what blogs and c.l.py is for" and i say wrong. I believe > more folks would get involved if they felt that the medium was real. > c.l.py is not that place (although it could be with some changes) and > python.dev is not that place. > > I am open to any ideas you may have. Brett Cannon used to (still does?) prepare twice monthly summaries of activity on python-dev which provided insight as to what was happening on that side of things. I don't know if he or anyone else still does so, but if so, a copy to this list would at least let everyone know if something was happening that you might want to weigh in on. see http://article.gmane.org/gmane.comp.python.devel/43893 Emile From rantingrick at gmail.com Tue Jan 18 14:03:55 2011 From: rantingrick at gmail.com (rantingrick) Date: Tue, 18 Jan 2011 11:03:55 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <79a8a$4d332d1a$4275d90a$3986@FUSE.NET> <64976187-88ad-47c9-9bc6-c0712a657264@j32g2000yqc.googlegroups.com> <3af4fd5e-8cc9-4cec-aad2-cbf82ad3bab3@l24g2000vby.googlegroups.com> Message-ID: On Jan 18, 12:25?pm, Arndt Roger Schneider wrote: > rantingrick schrieb: > > On Jan 18, 7:09 am, Arndt Roger Schneider > > We DO need to consider the mobile market in this decision. Maybe it is > > time for us to actually get on the cutting edge of GUI's. Maybe we > > should head an effort to create a REAL 21st century GUI that can > > handle desktop, mobile, and accessibility, and do it all whilst > > looking very sharp! Sure we rob from peter to pay paul. We will use > > Tkinters awesome API and geometry managers, wxPythons feature > > richness, and any other code we can steal to make this work! > > I am not sure whether this sarcasms or for real..., > so I'll take for genuine. No this is real, albeit a bit fantastical. Thats probably why you thought it was sarcasm :). However, we need to start a revolution in the GUI world. Currently we (as developers) are slaves to the OEM's and OS's. This must change. We must unify GUI coding the same way OpenGL unified graphics coding. Multiplicity is ruining any and all advancements in Graphical User Interfaces. Sure multiplicity is great in emerging systems (language, culture, GUI, etc, etc) However at some point you must reign in this multiplicity and harness the collective knowledge into an all encompassing standard. OpenGUI is that standard. It should be shipped with every OS in the world. This is the only way we can have mobile, desktop, and accessibility all combined into one beautiful package. Then the contest come down to who can create the best abstraction API. > Tk is also doomed, and Tkinter isn't Tk. > You are right about keeping the separate geometry > managers, though. > > For starters:http://kenai.com/projects/swank This looks like a very young project (beta) and i could not find a widget set. However i will investigate more. Thanks However we need to think beyond even a Python community scale. This problem is inherent in every language community out there. We to unify the GUI standard. And we are a decade behind in development. (yes i am completely serious about all of this!). From usernet at ilthio.net Tue Jan 18 14:05:02 2011 From: usernet at ilthio.net (Tim Harig) Date: Tue, 18 Jan 2011 19:05:02 +0000 (UTC) Subject: [OT] Python like lanugages [was Re: After C++, what with Python?] References: <86a904f8-05b0-435f-81d6-7450650f1679@glegroupsg2000goo.googlegroups.com> <4d329899$0$43988$742ec2ed@news.sonic.net> <7x8vylfcvz.fsf@ruckus.brouhaha.com> <4d32c7cf$0$29983$c3e8da3$5496439d@news.astraweb.com> Message-ID: On 2011-01-18, geremy condra wrote: > On Mon, Jan 17, 2011 at 4:02 PM, Tim Harig wrote: >> I really question that you get Java anywhere even close to C performance. >> Google reports they get within the same order of magnitude as C for >> their long-lived server processes where the JIT has had time to optimize >> its results. ?For shorter term processes such as desktop applications, >> Java performance stinks -- even after you discount the JVM starup time. > > I'm sorry, but you're wrong on this. Java's performance can be > excellent, particularly when it comes to mathematical functions. I > recall reading a pretty smug paper a few years ago describing how they > managed to beat C on a number of numerical benchmarks. I have no doubt that Java *can* occasionally beat *some* C for *some* benchmarks; but, overall, Java has a terrible reputation for performance. I worked with a company a few years ago that tried replacing a C VNC client with a Java one so that its technical support contractor's wouldn't need to have the VNC client installed on the agent's workstations. Several of the contracters had to upgrade their systems in order to use the Java version because it slowed down the machines so much that the agents could not perform their jobs effectively; and that is pretty typical from what I have seen with Java overall. Java performs very well with some select tasks. For others, it does exceedingly poor. That kind of hit or miss is pretty typical for JIT compilers in general. That isn't usually the case for fully compiled langauges where you are pretty much guaranteed to get decent, if not always the absolute top, performance. >> Ada is capable of C++ like performance *if* you compile it to remove *all* >> of runtime checking. ?Depending what checks you enable, it can run much >> slower. > > No idea, never used it. > >>> in line with the work of others. You can argue that it's good enough- >>> it is, for most cases- but taking a 20% performance hit rules it out >>> of a lot of systems work, and the C-Go gap in many cases is much >>> larger than that. >> >> I don't work anything that involves and absolute need for performance. > > Then don't argue about performance, it makes you look like a hack just > eager to shill for your language. What you don't seem to realize is there is often a performance level that is good enough. For many things, Python is good enough. Many others, where Python is insufficient, may still be acceptable to use Java. Some things require the absolute best performance and will probably always need C/C++ or equivilantly low level language. >> I could probably accept penalty several times that of C for higher >> level functionality; but, sometimes the penalty for Python is just >> too much. ?Many of my programs are very quick lived such that even >> loading an interpeter or VM can eclipse the actual runtime. ?Given less >> developmental effort required, I also find that I have more time to look >> for ways to optimize Go. ?There are many things (such as using alternate >> data structures rather then the build in slices and immutable strings) >> that can be used to accelerate Go when time permits and I suspect many >> more will be found as the language matures. > > This is inconsistent with your argument about PyPy. See my earlier comment. I can accept 2 to 3 times the overall performance of C for almost all of the problems that I deal with. When that multiple gets into the double digits, it can start to cause some real headaches for some problems. When that number reaches the upper double digits, it is acceptable for even fewer problems. Python is great for those problems where performance isn't critical and I make extensive use of it. Different methods of mixing Python and C (including manual, PyPy, SWIG, boost, etc) can extend Python's useful range; but, I have not seen the kind of speed improvements that bring it to less then an order of magnitude of C's speed overall. Even assuming that PyPy does actually manage to reach within a magnitude of C with the extra effort required to leverage two languages, why would I bother when I can do it with one? PyPy and similar methods where great when there was no other mid level alternative that supported Python like features. Now it just seems like using Python as a hammer for every problem whether or not it is the right tool for the job. >>> Go is also not an ideal language for enterprise development. It >>> provides no compatibility or support guarantees; in fact, the website >>> describes it as 'an experiment' and recommends it for 'adventurous >> >> There is no doubt that it is a young project and there are a number of >> things that will need to be improved to be effective for some branches >> of programming; but, that isn't a language restriction. > > It will nevertheless preclude its use in most enterprise software > development. That's most systems software. So you conclude that because it is not quite ready for prime time yet that it never will be? I can remember when people said C++ would never amount to anything either. >> Database bindings are another weak link outside of the more common >> open source databases. ?In both cases, Go readily capable of C library >> functions as a stop-gap until a native wrapper is available. ?Yes it will >> be nice once community has filled in the gaps; but, I am rather impressed >> at what is already available in less then a years time. ?There are a few >> libraries you may have missed here: > > Sounds like a two-language solution, ie, the thing you criticized Python for. Not quite. 1. My arguments for dual language solutions where never directed at Python proper. They were directed at PyPy. I am rather amazed at the number of things that can be accomplished in Python without having to bind to C. 2. There is a difference in binding to a solution that is already written in another language so as to not reinvent a wheel and implementing a *new* library in another language to be used exclusively with Python. From rantingrick at gmail.com Tue Jan 18 14:11:36 2011 From: rantingrick at gmail.com (rantingrick) Date: Tue, 18 Jan 2011 11:11:36 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <79a8a$4d332d1a$4275d90a$3986@FUSE.NET> <64976187-88ad-47c9-9bc6-c0712a657264@j32g2000yqc.googlegroups.com> <3af4fd5e-8cc9-4cec-aad2-cbf82ad3bab3@l24g2000vby.googlegroups.com> Message-ID: <9d0d0f8a-9684-4405-897c-141f2241070d@fo10g2000vbb.googlegroups.com> On Jan 18, 12:29?pm, Adam Skutt wrote: > Until we have pixel-perfect touch sensors, toolkits for devices with > pointer interfaces (e.g., PCs) and toolkits for devices with touch > interfaces (e.g., phones and tablets) will necessarily be different. > > You note this yourself: the UI paradigms that work well when you have > a pixel-perfect pointer do not work at all when you have a touch > screen, especially on a limited size and resolution display. > > Even if you're provided a "single" toolkit, you still end up with two, > maybe three, different applications, each using different widgets > targeted for the device they run on. ?And no one provides a "single" > toolkit: while Silverlight can run on the desktop, the web, and now on > Windows Phone, you can't use the same widgets everywhere; ditto with > Cocoa for OS X and Cocoa Touch for iTouch devices. > > While some further unification is obviously possible, it's rather > doubtful we'll ever have unified widgets that are truly workable on > the web, on the "desktop", and on a portable touch screen device. Adam now you are making sense. Everything you said here is true. This is why we must push for the OpenGUI standard. The entropy in GUIs has exploded exponentially and rendered them all useless. We must unify the collective knowledge base into a single system and shake up the GUI world from top to bottom. Any other effort is just wasted energy. Forget WxPython, Forget WxWidgets, Forget any and all GUI libraries that exists, they are all moot at this point and we are -years- DECADES behind in development and integration. See my reply to Rodger for more detail.. From wxjmfauth at gmail.com Tue Jan 18 14:12:14 2011 From: wxjmfauth at gmail.com (jmfauth) Date: Tue, 18 Jan 2011 11:12:14 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <79a8a$4d332d1a$4275d90a$3986@FUSE.NET> <64976187-88ad-47c9-9bc6-c0712a657264@j32g2000yqc.googlegroups.com> <3af4fd5e-8cc9-4cec-aad2-cbf82ad3bab3@l24g2000vby.googlegroups.com> Message-ID: > > > If you think the site is bad, send me a ONE better screenshot, or link > > thereto, of wx on WinXP/Vista/7. I promise to look at it. Then urge > > Robin to update the page. > No wxWidgets, but real Python / wxPython applications, all updated on Windows 7. http://spinecho.ze.cx/ From brian.curtin at gmail.com Tue Jan 18 14:16:58 2011 From: brian.curtin at gmail.com (Brian Curtin) Date: Tue, 18 Jan 2011 13:16:58 -0600 Subject: move to end, in Python 3.2 Really? In-Reply-To: <665f862b-0d8f-476a-ae51-d8fdc9767f0a@g26g2000vbi.googlegroups.com> References: <58c17709-d68e-4448-b618-b6f594d0e8c5@t35g2000yqj.googlegroups.com> <125db7fe-036e-47c9-be89-50f05106936f@n2g2000pre.googlegroups.com> <99e7061d-20d5-434b-9404-bdafd6a013ac@i17g2000vbq.googlegroups.com> <665f862b-0d8f-476a-ae51-d8fdc9767f0a@g26g2000vbi.googlegroups.com> Message-ID: On Tue, Jan 18, 2011 at 12:33, rantingrick wrote: > > On Jan 18, 11:56 am, Antoine Pitrou wrote: > > On Tue, 18 Jan 2011 09:10:48 -0800 (PST) > > > > rantingrick wrote: > > > > > Well don't get wrong i want to join in --not that i have all the > > > solutions-- > > > > Take a look athttp://docs.python.org/devguide/#contributing > > Thanks for this link Antoine however i think you missed the point of > my post. What i would like to see is an forum where the "noob" to > "average" python programmer can voice his/her opinion about the > current state or future state of Pythons syntax, stdlib, goals and > dreams, etc, al the while not fearing attack from all sides. Currently > such a place is non-existent. I believe many folks would get involved > if this "place" existed however it does not exist. I'm unaware of "attack from all sides" on python-dev, but the standards are high, as they should be. The discussion is open to everyone, but it's not generally about opinions, goals, dreams, etc. -- it's mostly about getting work done. python-ideas might be a list that would work for what you are looking for. It's a list of possible ideas to implement in Python. Some are half-baked ideas needing community help and input, some are fully thought out implementations asking if the community thinks it's worthy of inclusion. I'm not sure why this list, python-list, isn't a good venue for any of that. A lot of the people who follow python-dev also follow this list, e.g., Raymond and Antoine who already commented on this. I also believe that > these same folks have no interest in "debating" in the highly > competitive environmental of python-dev, python-ideas. Heck, even > c.l.py is far too competitive! They just basically want a forum were > they can come in and give their two cents and leave. > Sorry, it's not that easy, for good reason. We're talking about a programming language that has been around for quite a while, is used in many places for many reasons by many people, and the numbers surrounding just about every category are always rising. We're also talking about a group of volunteers who spend their time working on Python. Drive-by commenting likely serves little purpose other than noise. If you want to bring something up, by all means bring it up, but you will probably have to fight for it. We can't just have everyone throw two cent suggestions in a hat and move along. -------------- next part -------------- An HTML attachment was scrubbed... URL: From mark at markroseman.com Tue Jan 18 14:17:20 2011 From: mark at markroseman.com (Mark Roseman) Date: Tue, 18 Jan 2011 12:17:20 -0700 Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> 9-4a9f-b0e7-54bb681a6ea0@l8g2000yqh.googlegrouppppppp <4d337983$0$29983$c3e8da3$5496439d@news.astraweb.com> <044a5101-948d-4458-9c94-57dbb3e25f67@m35g2000vbn.googlegroups.com> <4d3467bf$0$29983$c3e8da3$5496439d@news.astraweb.com> <4D34B04E.8050309@web.de> <4266E8D7BA204BFEA5BF66C635CE1716@octavian> <4D35DCE8.5030002@web.de> Message-ID: If you guys spent 1/10th as much time articulating the problems you see with Tkinter (and being willing to listen when people offer solutions) as you do trying to convince everyone else you're right, you'd probably have ... well, anyway, no sense in being practical. From solipsis at pitrou.net Tue Jan 18 14:17:22 2011 From: solipsis at pitrou.net (Antoine Pitrou) Date: Tue, 18 Jan 2011 20:17:22 +0100 Subject: move to end, in Python 3.2 Really? References: <58c17709-d68e-4448-b618-b6f594d0e8c5@t35g2000yqj.googlegroups.com> <125db7fe-036e-47c9-be89-50f05106936f@n2g2000pre.googlegroups.com> <99e7061d-20d5-434b-9404-bdafd6a013ac@i17g2000vbq.googlegroups.com> <665f862b-0d8f-476a-ae51-d8fdc9767f0a@g26g2000vbi.googlegroups.com> Message-ID: <20110118201722.4fae8aad@pitrou.net> On Tue, 18 Jan 2011 10:33:45 -0800 (PST) rantingrick wrote: > > On Jan 18, 11:56?am, Antoine Pitrou wrote: > > On Tue, 18 Jan 2011 09:10:48 -0800 (PST) > > > > rantingrick wrote: > > > > > Well don't get wrong i want to join in --not that i have all the > > > solutions-- > > > > Take a look athttp://docs.python.org/devguide/#contributing > > Thanks for this link Antoine however i think you missed the point of > my post. You did say "I want to join in". > What i would like to see is an forum where the "noob" to > "average" python programmer can voice his/her opinion about the > current state or future state of Pythons syntax, stdlib, goals and > dreams, etc, al the while not fearing attack from all sides. Well the only way for that to happen is to put it up yourself. Or to gather some people around you to put it up together. Regards Antoine. From rantingrick at gmail.com Tue Jan 18 14:22:53 2011 From: rantingrick at gmail.com (rantingrick) Date: Tue, 18 Jan 2011 11:22:53 -0800 (PST) Subject: move to end, in Python 3.2 Really? References: <58c17709-d68e-4448-b618-b6f594d0e8c5@t35g2000yqj.googlegroups.com> <125db7fe-036e-47c9-be89-50f05106936f@n2g2000pre.googlegroups.com> <99e7061d-20d5-434b-9404-bdafd6a013ac@i17g2000vbq.googlegroups.com> Message-ID: On Jan 18, 12:55?pm, Emile van Sebille wrote: > On 1/18/2011 9:10 AM rantingrick said... > > > > > > > > > > > On Jan 18, 10:54 am, MRAB ?wrote: > > >> Decisions are made after open discussion (although we're not sure about > >> "move to end" :-)). You shouldn't complain about not being consulted if > >> you don't take the time to join in... > > > Well don't get wrong i want to join in --not that i have all the > > solutions-- however python-dev is a dangerous place for the > > uninitiated. And we can't have thousands and thousands of posts > > clogging up the main pool because that would only serve to slow the > > process to a grinding hault. > > > However, we need some way that the average Python programmer can speak > > up and be heard when any subject that he/she is passionate about comes > > before the "council". These folks probably don't want to participate > > in the highly competitive environment of Python dev. However they may > > have very good ideas. I think we are doing this community a dis > > service by not giving these voices an outlet. > > > We need either some way to vote outside of Python dev. i think it > > would be much easier to just have a site where all proposals can be > > viewed by anyone and they can offer input without clogging up Python > > dev with noob questions or bad ideas. Then the "council" can review > > these suggestions and make a more informed decision. Some might say > > "well that is what blogs and c.l.py is for" and i say wrong. I believe > > more folks would get involved if they felt that the medium was real. > > c.l.py is not that place (although it could be with some changes) and > > python.dev is not that place. > > > I am open to any ideas you may have. > > Brett Cannon used to (still does?) prepare twice monthly summaries of > activity on python-dev which provided insight as to what was happening > on that side of things. ?I don't know if he or anyone else still does > so, but if so, a copy to this list would at least let everyone know if > something was happening that you might want to weigh in on. > > seehttp://article.gmane.org/gmane.comp.python.devel/43893 > > Emile That is dated 2002? :D Thanks for offering a suggestion it was very welcome however i need to emphasize that what i am proposing is sort of "community discussion suggestion box". Like a "Python Suggestions" group or something. Where any and all suggestions, rants, complaints, ideas, etc, are welcome from anyone without fear of reprisals. However, in order for this to succeed the "elite" must take the time to actually read it. Maybe we could have some trusted "proof readers" who could sift out the spam and useless stuff and then send a modified version to the senate for congressional reviewing. Of course at that point the senate can further narrow down the list before sending over to the white house. This is the only way (short of sending out warnings in the python releases) that you can actually get a feel for what Joe and Jane Python programmer are happy with. From rantingrick at gmail.com Tue Jan 18 14:26:13 2011 From: rantingrick at gmail.com (rantingrick) Date: Tue, 18 Jan 2011 11:26:13 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> 9-4a9f-b0e7-54bb681a6ea0@l8g2000yqh.googlegrouppppppp <4d337983$0$29983$c3e8da3$5496439d@news.astraweb.com> <044a5101-948d-4458-9c94-57dbb3e25f67@m35g2000vbn.googlegroups.com> <4d3467bf$0$29983$c3e8da3$5496439d@news.astraweb.com> <4D34B04E.8050309@web.de> <4266E8D7BA204BFEA5BF66C635CE1716@octavian> <4D35DCE8.5030002@web.de> Message-ID: On Jan 18, 1:17?pm, Mark Roseman wrote: > If you guys spent 1/10th as much time articulating the problems you see > with Tkinter (and being willing to listen when people offer solutions) > as you do trying to convince everyone else you're right, you'd probably > have ... well, anyway, no sense in being practical. Well mark why don't you offer some facts on the merits of Tkinter versus WxPython (or libray X) instead of just contributing nothing. Heck you did not even interject an opinion? This is just argumentative speech Mark, i would really like some soild input from you since you (like myself) are neck deep in Tkinter code. From debatem1 at gmail.com Tue Jan 18 14:50:33 2011 From: debatem1 at gmail.com (geremy condra) Date: Tue, 18 Jan 2011 11:50:33 -0800 Subject: [OT] Python like lanugages [was Re: After C++, what with Python?] In-Reply-To: References: <86a904f8-05b0-435f-81d6-7450650f1679@glegroupsg2000goo.googlegroups.com> <4d329899$0$43988$742ec2ed@news.sonic.net> <7x8vylfcvz.fsf@ruckus.brouhaha.com> <4d32c7cf$0$29983$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Tue, Jan 18, 2011 at 11:05 AM, Tim Harig wrote: > Even assuming that PyPy does actually manage to reach within a magnitude > of C with the extra effort required to leverage two languages, why > would I bother when I can do it with one? ?PyPy and similar methods > where great when there was no other mid level alternative that supported > Python like features. ?Now it just seems like using Python as a hammer > for every problem whether or not it is the right tool for the job. You clearly have no idea what you're talking about regarding PyPy. You could at least have googled it before speaking about it. >>>> Go is also not an ideal language for enterprise development. It >>>> provides no compatibility or support guarantees; in fact, the website >>>> describes it as 'an experiment' and recommends it for 'adventurous >>> >>> There is no doubt that it is a young project and there are a number of >>> things that will need to be improved to be effective for some branches >>> of programming; but, that isn't a language restriction. >> >> It will nevertheless preclude its use in most enterprise software >> development. That's most systems software. > > So you conclude that because it is not quite ready for prime time yet that it > never will be? ?I can remember when people said C++ would never amount to > anything either. We're a year past the initial announcement that it was ready. It's still 'an experiment'. It doesn't have a ratified standard, committee, or governing body. The company that developed it seems to have no interest in enterprise support. They haven't done any serious marketing for it since the initial release. Five years is, to put it mildly, an overly enthusiastic timeline for the development of broad-based industry support under those conditions. >>> Database bindings are another weak link outside of the more common >>> open source databases. ?In both cases, Go readily capable of C library >>> functions as a stop-gap until a native wrapper is available. ?Yes it will >>> be nice once community has filled in the gaps; but, I am rather impressed >>> at what is already available in less then a years time. ?There are a few >>> libraries you may have missed here: >> >> Sounds like a two-language solution, ie, the thing you criticized Python for. > > Not quite. > > 1. My arguments for dual language solutions where never directed at Python > ? ? ? ?proper. ? They were directed at PyPy. ?I am rather amazed at > ? ? ? ?the number of things that can be accomplished in Python without > ? ? ? ?having to bind to C. Again, you don't know what you're talking about WRT PyPy. > 2. There is a difference in binding to a solution that is already written > ? ? ? ?in another language so as to not reinvent a wheel and implementing > ? ? ? ?a *new* library in another language to be used exclusively > ? ? ? ?with Python. Even if that binding is done for performance reasons? Geremy Condra From usernet at ilthio.net Tue Jan 18 14:53:57 2011 From: usernet at ilthio.net (Tim Harig) Date: Tue, 18 Jan 2011 19:53:57 +0000 (UTC) Subject: [OT] Python like lanugages [was Re: After C++, what with Python?] References: <86a904f8-05b0-435f-81d6-7450650f1679@glegroupsg2000goo.googlegroups.com> <4d329899$0$43988$742ec2ed@news.sonic.net> <7x8vylfcvz.fsf@ruckus.brouhaha.com> <4d32c7cf$0$29983$c3e8da3$5496439d@news.astraweb.com> <4d35a769$0$2258$a729d347@news.telepac.pt> Message-ID: On 2011-01-18, Terry Reedy wrote: > On 1/18/2011 10:30 AM, Tim Harig wrote: > >> Whether or not you actually agree with that economic reality is >> irrelevant. Those who fund commerical projects do; and, any developement >> tool which violates the security of the source is going to find itself >> climbing an uphill battle in trying to gain market penetration with >> commericial software producers. > > Of course. When I submit or commit patches, I am doing it mostly for > hobby, educational, and scientific users, and maybe website makers (who > make site I can visit). If commercial users piggyback on top, ok. I do > not know how many developers, if any, are after such market penetration. You kind of over-extended the intentions of my comment. It does not apply to open source software in general. I agree that open source authors are not interested in the quantitative value of market penetration. However, I am betting that most authors of developement tools would like to be able to use their tools on the job. I am sure that more software developers would love to develop using Python as part of their job. For some this is a reality; but, many more are stuck using their employer's choice of language. One of the factors that employers consider, when they choose a language, if they produce retail software is that the process of compiling will sufficiently obfiscate their code. From brian.curtin at gmail.com Tue Jan 18 15:08:46 2011 From: brian.curtin at gmail.com (Brian Curtin) Date: Tue, 18 Jan 2011 14:08:46 -0600 Subject: move to end, in Python 3.2 Really? In-Reply-To: References: <58c17709-d68e-4448-b618-b6f594d0e8c5@t35g2000yqj.googlegroups.com> <125db7fe-036e-47c9-be89-50f05106936f@n2g2000pre.googlegroups.com> <99e7061d-20d5-434b-9404-bdafd6a013ac@i17g2000vbq.googlegroups.com> Message-ID: On Tue, Jan 18, 2011 at 13:22, rantingrick wrote: > > Thanks for offering a suggestion it was very welcome however i need to > emphasize that what i am proposing is sort of "community discussion > suggestion box". Like a "Python Suggestions" group or something. Where > any and all suggestions, rants, complaints, ideas, etc, are welcome > from anyone without fear of reprisals. What is it with all of this talk of fear? Is there some group of people who were shamed out of python-dev that I wasn't aware of? It's not a hostile mailing list, and I'm not sure why you keep saying that it is... I understand maybe I don't feel that way because I've been reading it for a while, but even thinking back to when I was new around there, I never felt any amount of fear. Sure, I've talked to people who had things shot down and they took it harshly, but they realized it was just part of the game and it wasn't personal and they weren't kicked out of the group or anything. -------------- next part -------------- An HTML attachment was scrubbed... URL: From arndt.roger at addcom.de Tue Jan 18 15:20:32 2011 From: arndt.roger at addcom.de (Arndt Roger Schneider) Date: Tue, 18 Jan 2011 21:20:32 +0100 Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <79a8a$4d332d1a$4275d90a$3986@FUSE.NET> <64976187-88ad-47c9-9bc6-c0712a657264@j32g2000yqc.googlegroups.com> <3af4fd5e-8cc9-4cec-aad2-cbf82ad3bab3@l24g2000vby.googlegroups.com> Message-ID: rantingrick schrieb: > On Jan 18, 12:25 pm, Arndt Roger Schneider > wrote: > >>rantingrick schrieb: >> >>>On Jan 18, 7:09 am, Arndt Roger Schneider > > >>>We DO need to consider the mobile market in this decision. Maybe it is >>>time for us to actually get on the cutting edge of GUI's. Maybe we >>>should head an effort to create a REAL 21st century GUI that can >>>handle desktop, mobile, and accessibility, and do it all whilst >>>looking very sharp! Sure we rob from peter to pay paul. We will use >>>Tkinters awesome API and geometry managers, wxPythons feature >>>richness, and any other code we can steal to make this work! >> >>I am not sure whether this sarcasms or for real..., >>so I'll take for genuine. > > > > No this is real, albeit a bit fantastical. Thats probably why you > thought it was sarcasm :). > > However, we need to start a revolution in the GUI world. Currently we > (as developers) are slaves to the OEM's and OS's. This must change. We > must unify GUI coding the same way OpenGL unified graphics coding. > Multiplicity is ruining any and all advancements in Graphical User > Interfaces. Sure multiplicity is great in emerging systems (language, > culture, GUI, etc, etc) However at some point you must reign in this > multiplicity and harness the collective knowledge into an all > encompassing standard. OpenGUI is that standard. It should be shipped > with every OS in the world. This is the only way we can have mobile, > desktop, and accessibility all combined into one beautiful package. > Then the contest come down to who can create the best abstraction API. > There has been no advancement in GUI-Design. Today it looks and behaves just the way Bill Atkinson designed it. Technical revolutions are made by disruptive thoughts, which are never collective. ...The problem with gui-design:It requires an graphical artist, a well versed writer, a software architect and a programmer. The first two job description are the important ones. ...No OS-vender is going to allow that, it equals lost control. > > >>Tk is also doomed, and Tkinter isn't Tk. >>You are right about keeping the separate geometry >>managers, though. >> >>For starters:http://kenai.com/projects/swank > > > This looks like a very young project (beta) and i could not find a > widget set. However i will investigate more. Thanks > alpha > However we need to think beyond even a Python community scale. This > problem is inherent in every language community out there. We to unify > the GUI standard. And we are a decade behind in development. (yes i am > completely serious about all of this!). > > Then we did find common ground. -roger From orasnita at gmail.com Tue Jan 18 15:23:43 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Tue, 18 Jan 2011 22:23:43 +0200 Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com><4d337983$0$29983$c3e8da3$5496439d@news.astraweb.com><044a5101-948d-4458-9c94-57dbb3e25f67@m35g2000vbn.googlegroups.com><4d3467bf$0$29983$c3e8da3$5496439d@news.astraweb.com> <4D34B04E.8050309@web.de><4266E8D7BA204BFEA5BF66C635CE1716@octavian><4D35DCE8.5030002@web.de> <4D35DD47.1070304@web.de> Message-ID: <7A0C7934E65D4B85A584C06ADD3B6ECF@teddy> From: "Alexander Kapps" > Tkinter causes damage? Very bad damage? What are you talking about? I am talking about the fact that Python promotes Tkinter, and many beginners will start using it, and they will start creating applications with it, and they will learn to use it better than WxPython, and they will start believing that Tkinter is better because it is easier to use than WxPython, so they will start convincing others that Tkinter is the best, and they will start finding many reasons that show that Tkinter is better. And after this, they will say that they don't care about the real problems generated by GUIs like Tk. And a very big problem is that the applications that use Tk/GTK are not accessible for screen readers, so those applications will be just blank for people with visual impairments which need to use a screen reader. Those applications won't be less nice, or just a little harder to use. They won't be accessible at all and they will help the discrimination of the blind people, and not because of technical problems, because those problems can be solved with a better interface like Wx, which is not perfectly accessible either, but it is much better. That discrimination appears just because some people say that they don't care. > Well, I don't like wx that much and others have already highlighted > some of the problems with it. I think that adding redundancy is bad It is a redundancy for you, but have you imagined that for some people the display is the redundant part of the computer? > You said a GUI lib is useless because not all programmers write > GUIs. so I say an HTML lib is useless because not all programmers > write web stuff. Got it? Both are useful and I'm absolutely against > any attempt to remove either from the stdlib. *That* would cause damage. I didn't say that a GUI lib is useless. The GUIS that create discrimination by offering access only for some users (when there are other GUIS that can offer access to everyone) create damage and they should be avoided, and for avoiding them, the beginners need to understand this. But Python promotes that bad GUI lib by including it in the default package instead of promoting a better lib. > Which one? That's the whole point. There currently is no better GUI > lib than Tkinter which allows quick and easy GUI programming and Are you a beginner? A good programmer is not interested only to create an application with 10 lines of code, no matter the results. The application need to have a good quality and to be accessible by everyone if the technology allows it. Why do we like the portable GUIS and don't really like the native interfaces that don't work on other platforms? Because we want our programs to be usable by as many people as possible. Well, some platforms render the output as sound and Tkinter are not "portable" on those platforms (screen readers). > I have absolutely no problem with a better GUI lib, I just don't care Well, I was sure that you are one of those who don't care... Octavian From orasnita at gmail.com Tue Jan 18 15:29:28 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Tue, 18 Jan 2011 22:29:28 +0200 Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com>9-4a9f-b0e7-54bb681a6ea0@l8g2000yqh.googlegrouppppppp<4d337983$0$29983$c3e8da3$5496439d@news.astraweb.com><044a5101-948d-4458-9c94-57dbb3e25f67@m35g2000vbn.googlegroups.com><4d3467bf$0$29983$c3e8da3$5496439d@news.astraweb.com> <4D34B04E.8050309@web.de><4266E8D7BA204BFEA5BF66C635CE1716@octavian><4D35DCE8.5030002@web.de> Message-ID: <495ABC6A7F6C48A1BBCC32F181E5C4F0@teddy> From: "Mark Roseman" > If you guys spent 1/10th as much time articulating the problems you see > with Tkinter (and being willing to listen when people offer solutions) > as you do trying to convince everyone else you're right, you'd probably > have ... well, anyway, no sense in being practical. The problem: The beginners use the first GUI lib they find in the default Python package and they learn how to create applications which are not accessible for screen readers (at all), while there are better solutions. Is there any other solution for the problem that Python promotes this bad GUI than removing it from the default package? Not only Python does this. For the reason that "it is more simple and we don't care about the problems it generates", ActiveState does the same and it does the same with ActivePerl, but it doesn't mean that it is something good. Octavian From askutt at gmail.com Tue Jan 18 15:37:17 2011 From: askutt at gmail.com (Adam Skutt) Date: Tue, 18 Jan 2011 12:37:17 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <79a8a$4d332d1a$4275d90a$3986@FUSE.NET> <64976187-88ad-47c9-9bc6-c0712a657264@j32g2000yqc.googlegroups.com> <3af4fd5e-8cc9-4cec-aad2-cbf82ad3bab3@l24g2000vby.googlegroups.com> <9d0d0f8a-9684-4405-897c-141f2241070d@fo10g2000vbb.googlegroups.com> Message-ID: On Jan 18, 2:11?pm, rantingrick wrote: > Adam now you are making sense. Everything you said here is true. > This > is why we must push for the OpenGUI standard. Funny, I write considerable detail about why such a thing is a pipedream and useless even if it came to fruition, and you somehow believe I'm in support of such an absurd idea. If you believe what I said is true, then you cannot seriously support any sort of "OpenGUI" standard, and I advise you to google that term before you use it again. Tell me, are you a political science major? Heck, to be totally honest, I've never been 100% convinced that cross- platform GUI APIs were even such a good idea. I certainly use them, but only in situations that are very simple or where I'm OK with accepting the fact my application will not be truly a first-class application[1][2]. Even minor differences in presentation can have large ramifications on how applications should function and therefore be written. > The entropy in GUIs has > exploded exponentially and rendered them all useless. Only if you have no clue what you're talking about whatsoever. You perceive them as useless because you're apparently incapable of understanding the simplest GUI precepts, nevermind APIs, which is why you've gone from Pure Python GUI to wxWidgets to this OpenGUI bullshit you're now espousing. Desperately clinging to a position doesn't make you look intelligent. Plus, I'm not sure what entropy you're talking about, but I'm not seeing it. MS continues to innovate, Apple continues to innovate, some portions of the Linux community do innovative things. Though most people just want to put something together and call it a day, and the functionality provided by a lot of toolkits is beyond adequate for that. Adam [1] Or solely on Linux where all of the "native" toolkits have cross- platform support. [2] To say nothing about the explosion of web "applications" in the world today... From usernet at ilthio.net Tue Jan 18 15:44:20 2011 From: usernet at ilthio.net (Tim Harig) Date: Tue, 18 Jan 2011 20:44:20 +0000 (UTC) Subject: [OT] Python like lanugages [was Re: After C++, what with Python?] References: <86a904f8-05b0-435f-81d6-7450650f1679@glegroupsg2000goo.googlegroups.com> <4d329899$0$43988$742ec2ed@news.sonic.net> <7x8vylfcvz.fsf@ruckus.brouhaha.com> <4d32c7cf$0$29983$c3e8da3$5496439d@news.astraweb.com> Message-ID: On 2011-01-18, geremy condra wrote: > On Tue, Jan 18, 2011 at 11:05 AM, Tim Harig wrote: >> Even assuming that PyPy does actually manage to reach within a magnitude >> of C with the extra effort required to leverage two languages, why >> would I bother when I can do it with one? ?PyPy and similar methods >> where great when there was no other mid level alternative that supported >> Python like features. ?Now it just seems like using Python as a hammer >> for every problem whether or not it is the right tool for the job. > > You clearly have no idea what you're talking about regarding PyPy. You > could at least have googled it before speaking about it. No, I have watched several such projects over the years. Pysco, Unladen Swallow, Cython, PyPy, Shedskin, etc. Source to source translators, JITs, and C language integration all just add to complexity. You can't do this, you can't do that, you have to learn a new way of doing something else, ad nauseum. So when something new that provided Python like capabilities without many of Python's drawbacks came along, I jumped on it. It provides a much cleaner solution to the problem without kludges. I will use Python for what it does well and cleanly. For the rest, there are now better tools. Once again, its about the right tool for the right job. > Again, you don't know what you're talking about WRT PyPy. Nor do I really want to. I have found a much simpler solution to the problem. I would recommend it to many others that like the Python language but who occassionaly struggle with its implementation constraints. I would say that I am sorry that it doesn't work for you; but, you seem to prefer Java and Pypy anyway so we are both happy. >> 2. There is a difference in binding to a solution that is already written >> ? ? ? ?in another language so as to not reinvent a wheel and implementing >> ? ? ? ?a *new* library in another language to be used exclusively >> ? ? ? ?with Python. > > Even if that binding is done for performance reasons? Yep, that is pretty much the summation of my dual language argument. I don't expect a pure Python implementation of curses since there is a perfectly good C library available to bind to. Why reinvent the wheel. Resorting to writing packages in another language or compiling Python code into another source language is a kludge necessary because of the performance characteristics of the language. I suppose that is an acceptable kludge when that is your only alternative. For me it no longer is. From askutt at gmail.com Tue Jan 18 15:46:36 2011 From: askutt at gmail.com (Adam Skutt) Date: Tue, 18 Jan 2011 12:46:36 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <79a8a$4d332d1a$4275d90a$3986@FUSE.NET> <64976187-88ad-47c9-9bc6-c0712a657264@j32g2000yqc.googlegroups.com> <3af4fd5e-8cc9-4cec-aad2-cbf82ad3bab3@l24g2000vby.googlegroups.com> Message-ID: On Jan 18, 3:20?pm, Arndt Roger Schneider wrote: > There has been no advancement in GUI-Design. Today it looks and > behaves just the way Bill Atkinson designed it. That doesn't even begin to equate to a lack of advancement. It's also not true in the least. > Technical revolutions are made by disruptive thoughts, > which are never collective. Revolutions are statistical anomalies, so it's best not to depend on them for progress. It's not even apparent what revolution is necessary here. > ...The problem with gui-design:It requires an graphical artist, > a well versed writer, a software architect and a programmer. > The first two job description are the important ones. > > ...No OS-vender is going to allow that, it equals > lost control. > You need to go look at the people Apple, MS, Google, et al. hire; this statement is just patently false too. Plus, after a certainly level of functionality, the OS vendor does become rather irrelevant. Otherwise, the web would have never taken off an application platform: the HTML standard provides the smallest widget set of just about anything discussed, though it's painting / layout capabilities are both simultaneously far advanced and far worse. Yet, it is likely the way of the future for a large portion of us, like it or not. Adam From python at mrabarnett.plus.com Tue Jan 18 16:05:04 2011 From: python at mrabarnett.plus.com (MRAB) Date: Tue, 18 Jan 2011 21:05:04 +0000 Subject: move to end, in Python 3.2 Really? In-Reply-To: References: <58c17709-d68e-4448-b618-b6f594d0e8c5@t35g2000yqj.googlegroups.com> <125db7fe-036e-47c9-be89-50f05106936f@n2g2000pre.googlegroups.com> <99e7061d-20d5-434b-9404-bdafd6a013ac@i17g2000vbq.googlegroups.com> Message-ID: <4D360080.3000901@mrabarnett.plus.com> On 18/01/2011 19:22, rantingrick wrote: > On Jan 18, 12:55 pm, Emile van Sebille wrote: >> On 1/18/2011 9:10 AM rantingrick said... >> >>> On Jan 18, 10:54 am, MRAB wrote: >> >>>> Decisions are made after open discussion (although we're not sure about >>>> "move to end" :-)). You shouldn't complain about not being consulted if >>>> you don't take the time to join in... >> >>> Well don't get wrong i want to join in --not that i have all the >>> solutions-- however python-dev is a dangerous place for the >>> uninitiated. And we can't have thousands and thousands of posts >>> clogging up the main pool because that would only serve to slow the >>> process to a grinding hault. >> >>> However, we need some way that the average Python programmer can speak >>> up and be heard when any subject that he/she is passionate about comes >>> before the "council". These folks probably don't want to participate >>> in the highly competitive environment of Python dev. However they may >>> have very good ideas. I think we are doing this community a dis >>> service by not giving these voices an outlet. >> >>> We need either some way to vote outside of Python dev. i think it >>> would be much easier to just have a site where all proposals can be >>> viewed by anyone and they can offer input without clogging up Python >>> dev with noob questions or bad ideas. Then the "council" can review >>> these suggestions and make a more informed decision. Some might say >>> "well that is what blogs and c.l.py is for" and i say wrong. I believe >>> more folks would get involved if they felt that the medium was real. >>> c.l.py is not that place (although it could be with some changes) and >>> python.dev is not that place. >> >>> I am open to any ideas you may have. >> >> Brett Cannon used to (still does?) prepare twice monthly summaries of >> activity on python-dev which provided insight as to what was happening >> on that side of things. I don't know if he or anyone else still does >> so, but if so, a copy to this list would at least let everyone know if >> something was happening that you might want to weigh in on. >> >> seehttp://article.gmane.org/gmane.comp.python.devel/43893 >> >> Emile > > That is dated 2002? :D > > Thanks for offering a suggestion it was very welcome however i need to > emphasize that what i am proposing is sort of "community discussion > suggestion box". Like a "Python Suggestions" group or something. Where > any and all suggestions, rants, complaints, ideas, etc, are welcome > from anyone without fear of reprisals. > > However, in order for this to succeed the "elite" must take the time > to actually read it. Maybe we could have some trusted "proof readers" > who could sift out the spam and useless stuff and then send a modified > version to the senate for congressional reviewing. Of course at that > point the senate can further narrow down the list before sending over > to the white house. This is the only way (short of sending out > warnings in the python releases) that you can actually get a feel for > what Joe and Jane Python programmer are happy with. > The Python community are volunteers. Nothing gets done until someone volunteers to do it. The "suggestion box" is your idea. Why don't you set it up and report back? From tjreedy at udel.edu Tue Jan 18 16:07:55 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Tue, 18 Jan 2011 16:07:55 -0500 Subject: move to end, in Python 3.2 Really? In-Reply-To: References: <58c17709-d68e-4448-b618-b6f594d0e8c5@t35g2000yqj.googlegroups.com> <125db7fe-036e-47c9-be89-50f05106936f@n2g2000pre.googlegroups.com> Message-ID: On 1/18/2011 11:27 AM, rantingrick wrote: > On Jan 18, 6:46 am, Antoine Pitrou wrote: > >> Design considerations? Where were they discussed? I far as I know, nowhere until that post in this thread. > They were never discussed with the bulk of this community and that is > part of what i want to change. We have a very small group of folks > making all the decisions and that is fine. However this small group of > "privileged" folks needs to gather input from the rest of us > (peasants) on the value of such changes before making rash decisions. When proposed features are listed on the tracker, as I think this one should have been, anyone who registers can comment. Real names are strongly preferred (and required for elevated tracker and repository access). > Currently we have a closed set of intellectual inbreeding that is > rotting the community gene pool. Do you actually believe this nonsense, or are you just ranting for effect? In 2010, 20 people were granted commit access. We have 2 more new and active people this month. The active subset of these 22 comprise a substantial fraction of active developers. Without a constant influx of new people, the Python project would slowly die as people left to do other things. One way to demonstrate the needed technical and social skills for commit access is to participate on the tracker with comments, reviews, and patches. > We need more diversity in this > "milkshake" to bring about and foster healthy ideas. Python leaders already know we need more diversity of knowledge and skills to target Python at diverse platforms with diverse batteries. Last summer Guido said that we should be a bit more liberal with commit access. Right now, Brett Cannon is working under a PSF grant to greatly improve the developer docs so new developers can more easily get up to speed. One of the stated goals of moving the repository from svn to hg (a non-trivial project) is to make it easier for more people to contribute, with or without 'commit privileges'. -- Terry Jan Reedy From drsalists at gmail.com Tue Jan 18 16:18:51 2011 From: drsalists at gmail.com (Dan Stromberg) Date: Tue, 18 Jan 2011 13:18:51 -0800 Subject: __pycache__, one more good reason to stck with Python 2? In-Reply-To: References: <23e02e0d-b2f1-4b52-85ea-d1feba99dd37@22g2000prx.googlegroups.com> <4d3466d3$0$29983$c3e8da3$5496439d@news.astraweb.com> <0c62aacd-e6d2-4778-81d6-e06924192add@j1g2000vbl.googlegroups.com> <77ef8068-7f07-404f-8b0e-c039d1122659@e16g2000pri.googlegroups.com> Message-ID: On Tue, Jan 18, 2011 at 8:27 AM, Peter Otten <__peter__ at web.de> wrote: > Stefan Behnel wrote: > >> Peter Otten, 18.01.2011 10:04: >>> What's the advantage of 'find ... | xargs ...' over 'find ... -exec ...'? >> >> The former runs in parallel, the latter runs sequentially. > > This may sometimes be relevant, but I doubt that it matters in this > particular case. I don't think xargs is ever parallel, but GNU parallel is supposed to be a parallel tool with options and usage similar to those/that of xargs: http://www.gnu.org/software/parallel/ xargs' main advantages are: 1) Simpler quoting (correctness), especially if you use (GNU) "find -print0" with "xargs -0" 2) Far fewer exec's, which usually means much better performance From alex.kapps at web.de Tue Jan 18 16:24:54 2011 From: alex.kapps at web.de (Alexander Kapps) Date: Tue, 18 Jan 2011 22:24:54 +0100 Subject: Tkinter: The good, the bad, and the ugly! In-Reply-To: <7A0C7934E65D4B85A584C06ADD3B6ECF@teddy> References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com><4d337983$0$29983$c3e8da3$5496439d@news.astraweb.com><044a5101-948d-4458-9c94-57dbb3e25f67@m35g2000vbn.googlegroups.com><4d3467bf$0$29983$c3e8da3$5496439d@news.astraweb.com> <4D34B04E.8050309@web.de><4266E8D7BA204BFEA5BF66C635CE1716@octavian><4D35DCE8.5030002@web.de> <4D35DD47.1070304@web.de> <7A0C7934E65D4B85A584C06ADD3B6ECF@teddy> Message-ID: <4D360526.7070706@web.de> On 18.01.2011 21:23, Octavian Rasnita wrote: > From: "Alexander Kapps" >> Tkinter causes damage? Very bad damage? What are you talking about? > > I am talking about the fact that Python promotes Tkinter, and many beginners will start using it, and they will start creating applications with it, and they will learn to use it better than WxPython, and they will start believing that Tkinter is better because it is easier to use than WxPython, so they will start convincing others that Tkinter is the best, and they will start finding many reasons that show that Tkinter is better. And after this, they will say that they don't care about the real problems generated by GUIs like Tk. > And a very big problem is that the applications that use Tk/GTK are not accessible for screen readers, so those applications will be just blank for people with visual impairments which need to use a screen reader. > > Those applications won't be less nice, or just a little harder to use. They won't be accessible at all and they will help the discrimination of the blind people, and not because of technical problems, because those problems can be solved with a better interface like Wx, which is not perfectly accessible either, but it is much better. That discrimination appears just because some people say that they don't care. > >> Well, I don't like wx that much and others have already highlighted >> some of the problems with it. I think that adding redundancy is bad > > It is a redundancy for you, but have you imagined that for some people the display is the redundant part of the computer? I was talking about redundancy as in duplication of already existing parts. However, for some people, networking is superfluous. That's not a reason to remove the networking modules from the stdlib. Anyway, If you think duplicating functionality is a good approach here, go on, I don't mind. Just remember to stop somewhen and don't include 10 GUI toolkits and 20 HTML parsers just because some people don't like the already existing ones. >> You said a GUI lib is useless because not all programmers write >> GUIs. so I say an HTML lib is useless because not all programmers >> write web stuff. Got it? Both are useful and I'm absolutely against >> any attempt to remove either from the stdlib. *That* would cause damage. > > I didn't say that a GUI lib is useless. The GUIS that create discrimination by offering access only for some users (when there are other GUIS that can offer access to everyone) create damage and they should be avoided, and for avoiding them, the beginners need to understand this. But Python promotes that bad GUI lib by including it in the default package instead of promoting a better lib. Please read your previous post. Anyway *which* GUI offers access to everyone? >> Which one? That's the whole point. There currently is no better GUI >> lib than Tkinter which allows quick and easy GUI programming and > > Are you a beginner? A good programmer is not interested only to create an application with 10 lines of code, no matter the results. I'm neither a beginner, nor really a professional programmer. I occasionally do paid coding and that often includes small tools and helper utilities and one thing I can tell you: In approx 90% of those cases, people want a GUI. It hasn't to be fancy, they just don't want no command line tools. Tkinter is just great for quickly hacking together a GUI or for prototyping if somebody wants something more advanced. > The application need to have a good quality and to be accessible by everyone if the technology allows it. > Why do we like the portable GUIS and don't really like the native interfaces that don't work on other platforms? > Because we want our programs to be usable by as many people as possible. Well, some platforms render the output as sound and Tkinter are not "portable" on those platforms (screen readers). > >> I have absolutely no problem with a better GUI lib, I just don't care > > Well, I was sure that you are one of those who don't care... You make that sound as if I should feel guilty now. From arndt.roger at addcom.de Tue Jan 18 16:45:48 2011 From: arndt.roger at addcom.de (Arndt Roger Schneider) Date: Tue, 18 Jan 2011 22:45:48 +0100 Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <79a8a$4d332d1a$4275d90a$3986@FUSE.NET> <64976187-88ad-47c9-9bc6-c0712a657264@j32g2000yqc.googlegroups.com> <3af4fd5e-8cc9-4cec-aad2-cbf82ad3bab3@l24g2000vby.googlegroups.com> Message-ID: Adam Skutt schrieb: > On Jan 18, 8:09 am, Arndt Roger Schneider > wrote: > >>Back to rantingrick 21st century toolkit/framwork: >>Let's have a look at the numbers: >>Worlwide pc market are 300 Million pcs per year, >>this number includes desktops(2/3) and servers(1/3). >>Your gui app is not relevant on servers. > > > You should tell this "fact" to just about every major enterprise > software manufacturer out there. They all ship GUI tools intended to > be used on the server. Some of them ship only GUI tools or CLI tools > that are worthless, making you use the GUI tools. > > >>The desktop pc market is in decline; there is >>however a shift toward pc-servers, instead. >>It is anybodies guess how far the pc-desktop decline will go. >>Every 21st century toolkit or framework must run on >>mobile platforms! > > > Until we have pixel-perfect touch sensors, toolkits for devices with > pointer interfaces (e.g., PCs) and toolkits for devices with touch > interfaces (e.g., phones and tablets) will necessarily be different. > > You note this yourself: the UI paradigms that work well when you have > a pixel-perfect pointer do not work at all when you have a touch > screen, especially on a limited size and resolution display. > Yes I did and that's how it is. > Even if you're provided a "single" toolkit, you still end up with two, > maybe three, different applications, each using different widgets > targeted for the device they run on. And no one provides a "single" > toolkit: while Silverlight can run on the desktop, the web, and now on > Windows Phone, you can't use the same widgets everywhere; ditto with > Cocoa for OS X and Cocoa Touch for iTouch devices. > > While some further unification is obviously possible, it's rather > doubtful we'll ever have unified widgets that are truly workable on > the web, on the "desktop", and on a portable touch screen device. > Think about all the programmers earning their butter and bread :-). Forget toolkits and widgets for awhile. What remains are specific types of human/computer interactions, a visual representation on a screen and a predefined behaviour for said human action. E.g. a button is: A function gets asychnronously performed in response to a finger/mouse click and release inside a certain screen area. --A widget is essentially a logical abstraction. > >>wxWidgets was written ~1992, it is a copy of >>mfc, which in turn is a copy of MacApp. MacApp >>is also OSS, maintained through an industrie consortium. >>Why do you not use the original framework? >> > > > Because it's not cross-platform, I'd imagine. The entire point of > wxWidgets was to provide a cross-platform "OOP" UI toolkit. It > closely copies MFC since MFC and XView were the two "backends" it > supported. > MacApp is/was cross-platform, Apple pulled the plug on the non-mac platforms; the industrie consortium took charge of the other platforms. > >>Screen resolution: >> The time of 72ppi CRT monitors is over. A GUI >> framework/toolkit must be resolution independent, >> including all icons and indicators; >> it should use decluttering (newspeak:ZUI). >> > > > WPF is the only functional resolution-independent UI toolkit in > existence. While I don't disagree with you in principal, practice is > pretty heavily divorced from principal here. Principal doesn't help > me write GUI applications today. > > >>wxWidgets is not suitable for a modern type >>GUI ad thus clearly not the toolkit/framework >>of the 21st century. > > > None of the toolkits accessible from CPython are suitable for a 21st > century guy by your standard. If we talk about IronPython, > Silverlight becomes the closest, but it isn't a panacea by any stretch > of the imagination. > > Adam > According to Microsoft neither is silverlight. -roger From tjreedy at udel.edu Tue Jan 18 17:18:44 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Tue, 18 Jan 2011 17:18:44 -0500 Subject: Tkinter: The good, the bad, and the ugly! In-Reply-To: <7A0C7934E65D4B85A584C06ADD3B6ECF@teddy> References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com><4d337983$0$29983$c3e8da3$5496439d@news.astraweb.com><044a5101-948d-4458-9c94-57dbb3e25f67@m35g2000vbn.googlegroups.com><4d3467bf$0$29983$c3e8da3$5496439d@news.astraweb.com> <4D34B04E.8050309@web.de><4266E8D7BA204BFEA5BF66C635CE1716@octavian><4D35DCE8.5030002@web.de> <4D35DD47.1070304@web.de> <7A0C7934E65D4B85A584C06ADD3B6ECF@teddy> Message-ID: On 1/18/2011 3:23 PM, Octavian Rasnita wrote: > I am talking about the fact that Python promotes Tkinter Python uses tkinter as the only choice available for the stdlib. Others choices not in the stdlib are available for those who want something better. > TK are not accessible for screen readers, I did not know that. You could ask on the tracker that that fact be added to the docs. I would consider it reason to consider another choice if there ever were to be a suitable one offered. >> I'm absolutely >> against any attempt to remove either from the stdlib. *That* would >> cause damage. I agree. Besides IDLE and turtle, there are tools in the Tools directory that depend on tkinter. -- Terry Jan Reedy From taylorzr at gmail.com Tue Jan 18 17:20:40 2011 From: taylorzr at gmail.com (Zach) Date: Tue, 18 Jan 2011 17:20:40 -0500 Subject: [OT] Python like lanugages [was Re: After C++, what with Python?] In-Reply-To: References: <86a904f8-05b0-435f-81d6-7450650f1679@glegroupsg2000goo.googlegroups.com> <4d329899$0$43988$742ec2ed@news.sonic.net> <7x8vylfcvz.fsf@ruckus.brouhaha.com> <4d32c7cf$0$29983$c3e8da3$5496439d@news.astraweb.com> Message-ID: Cobra seems to similar to python. Or it at least compares itself to python. -------------- next part -------------- An HTML attachment was scrubbed... URL: From taylorzr at gmail.com Tue Jan 18 17:22:31 2011 From: taylorzr at gmail.com (Zach) Date: Tue, 18 Jan 2011 17:22:31 -0500 Subject: [OT] Python like lanugages [was Re: After C++, what with Python?] In-Reply-To: References: <86a904f8-05b0-435f-81d6-7450650f1679@glegroupsg2000goo.googlegroups.com> <4d329899$0$43988$742ec2ed@news.sonic.net> <7x8vylfcvz.fsf@ruckus.brouhaha.com> <4d32c7cf$0$29983$c3e8da3$5496439d@news.astraweb.com> Message-ID: Anyone have thoughts on Cobra? On Jan 18, 2011 4:20 PM, "Zach" wrote: > Cobra seems to similar to python. Or it at least compares itself to python. -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjreedy at udel.edu Tue Jan 18 17:28:47 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Tue, 18 Jan 2011 17:28:47 -0500 Subject: Tkinter: The good, the bad, and the ugly! In-Reply-To: References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <79a8a$4d332d1a$4275d90a$3986@FUSE.NET> <64976187-88ad-47c9-9bc6-c0712a657264@j32g2000yqc.googlegroups.com> <3af4fd5e-8cc9-4cec-aad2-cbf82ad3bab3@l24g2000vby.googlegroups.com> Message-ID: On 1/18/2011 2:12 PM, jmfauth wrote: >> >>> If you think the site is bad, send me a ONE better screenshot, or link >>> thereto, of wx on WinXP/Vista/7. I promise to look at it. Then urge >>> Robin to update the page. >> > > No wxWidgets, but real Python / wxPython applications, all updated on > Windows 7. > > http://spinecho.ze.cx/ Yes wxWidgets, underneath wxPython. And yes, look very nice. -- Terry Jan Reedy From tjreedy at udel.edu Tue Jan 18 17:33:15 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Tue, 18 Jan 2011 17:33:15 -0500 Subject: Tkinter: The good, the bad, and the ugly! In-Reply-To: <495ABC6A7F6C48A1BBCC32F181E5C4F0@teddy> References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com>9-4a9f-b0e7-54bb681a6ea0@l8g2000yqh.googlegrouppppppp<4d337983$0$29983$c3e8da3$5496439d@news.astraweb.com><044a5101-948d-4458-9c94-57dbb3e25f67@m35g2000vbn.googlegroups.com><4d3467bf$0$29983$c3e8da3$5496439d@news.astraweb.com> <4D34B04E.8050309@web.de><4266E8D7BA204BFEA5BF66C635CE1716@octavian><4D35DCE8.5030002@web.de> <495ABC6A7F6C48A1BBCC32F181E5C4F0@teddy> Message-ID: On 1/18/2011 3:29 PM, Octavian Rasnita wrote: > Is there any other solution for the problem that Python promotes this > bad GUI than removing it from the default package? I am generally for better accessibility, but I consider the notion that if everyone cannot have something, then no one should, to be rather pernicious. > Not only Python does this. For the reason that "it is more simple and > we don't care about the problems it generates", ActiveState does the > same and it does the same with ActivePerl, but it doesn't mean that > it is something good. So persuade them or someone to make it better, or is ActiveState actively opposed to that? -- Terry Jan Reedy From jake.biesinger at gmail.com Tue Jan 18 17:35:10 2011 From: jake.biesinger at gmail.com (Jake Biesinger) Date: Tue, 18 Jan 2011 14:35:10 -0800 (PST) Subject: Efficient python 2-d arrays? In-Reply-To: <6b865cda-5df4-4053-b5e4-f7deba45360e@l7g2000vbv.googlegroups.com> Message-ID: > Since you can't depend on your users installing the dependencies, is > it vital that your users run from source? You could bundle up your > application along with numpy and other dependencies using py2Exe or > similar. This also means you wouldn't have to require users to have > the right (or any) version of Python installed. It's a good suggestion, though I am far from familiar with the process. I've just finished implementing another alternative-- I'm doing a merge sort, where the array chunks are zipped together and then sorted using python's builtin sort then unzipped back to their original arrays. This seems fast enough and the reduced memory requirement for 2 arrays vs 1 list-of-tuples is substantial (1.5 GB vs 4GB). Thanks for the great suggestions! From jake.biesinger at gmail.com Tue Jan 18 17:36:55 2011 From: jake.biesinger at gmail.com (Jake Biesinger) Date: Tue, 18 Jan 2011 14:36:55 -0800 (PST) Subject: Efficient python 2-d arrays? In-Reply-To: <3ab5326f-bf39-4dfa-9875-a1bfd5ccab68@w29g2000vba.googlegroups.com> Message-ID: > Without using third party libraries, no not really. numpy has it > covered so there's not really a lot of demand for it. If your users > are loading 1.5 GB arrays into memory, it's probably not unreasonable > to expect them to have numpy installed. My users are biologists, and I can't expect them to have numpy (and the barrier to entry for this group is particularly high). From invalid at invalid.invalid Tue Jan 18 17:44:50 2011 From: invalid at invalid.invalid (Grant Edwards) Date: Tue, 18 Jan 2011 22:44:50 +0000 (UTC) Subject: move to end, in Python 3.2 Really? References: <58c17709-d68e-4448-b618-b6f594d0e8c5@t35g2000yqj.googlegroups.com> <125db7fe-036e-47c9-be89-50f05106936f@n2g2000pre.googlegroups.com> <99e7061d-20d5-434b-9404-bdafd6a013ac@i17g2000vbq.googlegroups.com> Message-ID: On 2011-01-18, MRAB wrote: > On 18/01/2011 19:22, rantingrick wrote: >> Thanks for offering a suggestion it was very welcome however i need to >> emphasize that what i am proposing is sort of "community discussion >> suggestion box". Like a "Python Suggestions" group or something. Where >> any and all suggestions, rants, complaints, ideas, etc, are welcome >> from anyone without fear of reprisals. >> >> However, in order for this to succeed the "elite" must take the time >> to actually read it. Maybe we could have some trusted "proof readers" >> who could sift out the spam and useless stuff and then send a modified >> version to the senate for congressional reviewing. Of course at that >> point the senate can further narrow down the list before sending over >> to the white house. This is the only way (short of sending out >> warnings in the python releases) that you can actually get a feel for >> what Joe and Jane Python programmer are happy with. > The Python community are volunteers. Nothing gets done until someone > volunteers to do it. The "suggestion box" is your idea. Why don't you > set it up and report back? He goes by the name of "ranting rick", and you're suggesting that instead of talking he rolls up his sleeves and does something. I suspect you're barking into the wind... -- Grant Edwards grant.b.edwards Yow! Yes, but will I at see the EASTER BUNNY in gmail.com skintight leather at an IRON MAIDEN concert? From askutt at gmail.com Tue Jan 18 17:57:02 2011 From: askutt at gmail.com (Adam Skutt) Date: Tue, 18 Jan 2011 14:57:02 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <79a8a$4d332d1a$4275d90a$3986@FUSE.NET> <64976187-88ad-47c9-9bc6-c0712a657264@j32g2000yqc.googlegroups.com> <3af4fd5e-8cc9-4cec-aad2-cbf82ad3bab3@l24g2000vby.googlegroups.com> Message-ID: On Jan 18, 4:45?pm, Arndt Roger Schneider wrote: > Adam Skutt schrieb: > > Until we have pixel-perfect touch sensors, toolkits for devices with > > pointer interfaces (e.g., PCs) and toolkits for devices with touch > > interfaces (e.g., phones and tablets) will necessarily be different. > > > You note this yourself: the UI paradigms that work well when you have > > a pixel-perfect pointer do not work at all when you have a touch > > screen, especially on a limited size and resolution display. > > Yes I did and that's how it is. And then you go and advocate a single toolkit! Do you not see the inherent contradiction there? While it's certainly not impossible, the case is hardly obvious for one GUI toolkit for all possible UIs. You certainly have not presented it, and rantingrick never will. > Think about all the programmers earning their butter and bread :-). > Forget toolkits and widgets for awhile. > What remains are specific types of human/computer interactions, > a visual representation on a screen and a predefined behaviour > for said human action. Also known as "toolkits and widgets". Talking about such things are inescapable. > > E.g. a button is: > A function gets asychnronously performed in response to > a finger/mouse click and release inside a certain screen area. > No, that is not the definition of a 'button', not even when we choose to ignore how it is rendered, which you cannot ignore even if you wish to pretend you can. Otherwise, I could always treat hyperlinks and buttons as equivalent and even interchangeable. Unfortunately, they are no such things. > --A widget is essentially a logical abstraction. No, as much as we try we cannot divorce presentation from behavior fully. > > Because it's not cross-platform, I'd imagine. ?The entire point of > > wxWidgets was to provide a cross-platform "OOP" UI toolkit. ?It > > closely copies MFC since MFC and XView were the two "backends" it > > supported. > > MacApp is/was cross-platform, Apple pulled the plug > on the non-mac platforms; the industrie > consortium took charge of the other platforms. > MacApp didn't even see the start of cross-platform development until 1996, four years after wxWidgets. It was not cross-platform from the start and only became cross-platform when all of Apple's other cross- platform endeavours failed. Adam From rantingrick at gmail.com Tue Jan 18 18:04:30 2011 From: rantingrick at gmail.com (rantingrick) Date: Tue, 18 Jan 2011 15:04:30 -0800 (PST) Subject: move to end, in Python 3.2 Really? References: <58c17709-d68e-4448-b618-b6f594d0e8c5@t35g2000yqj.googlegroups.com> <125db7fe-036e-47c9-be89-50f05106936f@n2g2000pre.googlegroups.com> <99e7061d-20d5-434b-9404-bdafd6a013ac@i17g2000vbq.googlegroups.com> Message-ID: <00e5a59a-2819-49fe-b124-4e71b191e267@z19g2000yqb.googlegroups.com> On Jan 18, 3:05?pm, MRAB wrote: > The Python community are volunteers. Nothing gets done until someone > volunteers to do it. The "suggestion box" is your idea. Why don't you > set it up and report back? Agreed, i would gladly accept you nominating me as the Suggestion Box president. However we need to decide where the best place to put the "suggestion box" will be. Sure i could open a website called "pythonsuggestionbox.com" however i doubt anybody that *needs* to find it ever would. Heck i would feel "lucky" if a few trolls dropped by and asked for the GIL to be removed. ;-) In light of that, the only place --and i would argue the best place-- is the official website with a nice link on the home page although i don't expect that will happen. In that case c.l.py becomes the winner by default. Why? Well imagine you are a new python user. Where would you look for help after downloading the installer? Of course you might go back to check out python.org a bit more. The next logical step would be python help and then c.l.py. So either we add a suggestions area to the official site OR make this group more accessible to the average user. If it were my choice, i would just make this group more accessible to newcomers and be done with it. Much eaiser, much less work, and more results will be produced. How can we make c.l.py more accessible you ask? Well a good start would be for some of the well known "elites" to make a public announcement. If we could convince Guido to make a speech that would be wonderful however i know he cannot do everything. """ In this statement we must stress that a new age of community has dawned -- an age of freedom. That all pythoneers are created equal and in the image of Guido. No, not of his physical image, but of his vision, his wisdom, and his compassion. That we will admonish those that wish to belittle the most feeble among us and elevate those who would carry the torch of community at the very expense of their own selfless vanity. That we are moving forward as a collective group united in vision, in spirit, and in solidarity for the future evolution of Python -- and for the greater good of all programming languages! """ Once we get c.l.py back on track i believe it will take some time but eventually the masses will return and rejoin our efforts. New users will mold into he community and we shall all reape the benefits. Hopefully with enough good will and collaboration we can do great things and save Python from an untimely demise. However we must act quickly, because the time is ticking away... From rantingrick at gmail.com Tue Jan 18 18:22:43 2011 From: rantingrick at gmail.com (rantingrick) Date: Tue, 18 Jan 2011 15:22:43 -0800 (PST) Subject: move to end, in Python 3.2 Really? References: <58c17709-d68e-4448-b618-b6f594d0e8c5@t35g2000yqj.googlegroups.com> <125db7fe-036e-47c9-be89-50f05106936f@n2g2000pre.googlegroups.com> Message-ID: On Jan 18, 3:07?pm, Terry Reedy wrote: > On 1/18/2011 11:27 AM, rantingrick wrote: > When proposed features are listed on the tracker, as I think this one > should have been, anyone who registers can comment. Real names are > strongly preferred (and required for elevated tracker and repository > access). Agreed. However you cannot expect the ordinary python programmers to follow the tracker. They are not a political as we. However they do have a voice and we must listen. How can we call ourselves a community when there exists no means by which the "real" users can express themselves? > > Currently we have a closed set of intellectual inbreeding that is > > rotting the community gene pool. > > Do you actually believe this nonsense, or are you just ranting for effect? This was a strong statement and it was meant to be strong. On on the face of it some might take it as an insult to the intelligence of our leaders -- i can assure you that is not the case! Of course we have good people at the top, however they are not hearing the voices screaming from below. They are making decisions in a vacuum. This cannot produce positive results for very much longer. I fear we have already begun the downward spiral as a community. We must get a grip and pull ourselves together before inertia rips us apart at the seams. > One way to demonstrate the needed technical and social skills for commit > access is to participate on the tracker with comments, reviews, and patches. We cannot even discuss the tracker until we fix this abomination called c.l.py. We need to focus on c.l.py. We need to get it back on track. And i want everyone to participate even the outright bullies and predators (if they can tone done the rhetoric and be nice again!). We as a community are existing in a vacuum. Likewise Python dev is existing in a vacuum. However both of us are in parallel universes. We must combine the head with the tail or we have nothing but component parts. Can a car function without wheels? Can a plane function without it's wings? No, an we are just component parts idle in some intellectual factory collecting dust! > ?> We need more diversity in this > > > "milkshake" to bring about and foster healthy ideas. > > Python leaders already know we need more diversity of knowledge and > skills to target Python at diverse platforms with diverse batteries. > Last summer Guido said that we should be a bit more liberal with commit > access. Right now, Brett Cannon is working under a PSF grant to greatly > improve the developer docs so new developers can more easily get up to > speed. One of the stated goals of moving the repository from svn to hg > (a non-trivial project) is to make it easier for more people to > contribute, with or without 'commit privileges'. This is a great advancement! Keep them coming! From fathead9000 at gmail.com Tue Jan 18 18:26:08 2011 From: fathead9000 at gmail.com (Michael Rauh) Date: Tue, 18 Jan 2011 15:26:08 -0800 (PST) Subject: Swampy Module installation Message-ID: <9dd545a1-b0ea-408c-9fe2-a2ce7d6a5a0a@m7g2000vbn.googlegroups.com> I am new to python, and attempting to install the learning module swampy. http://www.greenteapress.com/thinkpython/swampy/install.html Unfortunately, I am attempting to do this on windows vista, which does not appear to be cooperating. Once I click on the install link, it puts the file on the computer, and even if I place the file into the source folder for python, it still says that there is no module swampy. How can I get python to recognize the module as being there, and to run the suite? I admit, I may be placing it in the wrong directory, as I have so far been unable to change the working directory. Online the command os.chdir is said to change the directory, but it keeps giving an error, and saying that os is not recognized. Variations on this code do not seem to work either. From rantingrick at gmail.com Tue Jan 18 18:36:27 2011 From: rantingrick at gmail.com (rantingrick) Date: Tue, 18 Jan 2011 15:36:27 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <79a8a$4d332d1a$4275d90a$3986@FUSE.NET> <64976187-88ad-47c9-9bc6-c0712a657264@j32g2000yqc.googlegroups.com> <3af4fd5e-8cc9-4cec-aad2-cbf82ad3bab3@l24g2000vby.googlegroups.com> Message-ID: On Jan 18, 4:57?pm, Adam Skutt wrote: > On Jan 18, 4:45?pm, Arndt Roger Schneider > > E.g. a button is: > > A function gets asychnronously performed in response to > > a finger/mouse click and release inside a certain screen area. > > No, that is not the definition of a 'button', not even when we choose > to ignore how it is rendered, which you cannot ignore even if you wish > to pretend you can. ?Otherwise, I could always treat hyperlinks and > buttons as equivalent and even interchangeable. ?Unfortunately, they > are no such things. What! YES it is Adam! And you just exposed yourself as an argumentative moron! A hyperlink and a button are EXACTLY the same thing "functionality" wise. The fact that they look different has nothing to do with the argument. Would you say that a Ford Escort and a Dodge Viper do not function in basically the same way. Sure one looks much prettier and goes much faster however they both have four wheels, and engine, a drivetrain, an outer shell, burn gasoline, and are basically people movers. In other words they are both cars! *slap* > > --A widget is essentially a logical abstraction. > > No, as much as we try we cannot divorce presentation from behavior > fully. More argumentative crap. Adam you are incapable of compromise or reason... or maybe both. Try more facts next time. From tjreedy at udel.edu Tue Jan 18 18:44:26 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Tue, 18 Jan 2011 18:44:26 -0500 Subject: move to end, in Python 3.2 Really? In-Reply-To: References: <58c17709-d68e-4448-b618-b6f594d0e8c5@t35g2000yqj.googlegroups.com> <125db7fe-036e-47c9-be89-50f05106936f@n2g2000pre.googlegroups.com> Message-ID: On 1/18/2011 6:22 PM, rantingrick wrote: > This was a strong statement and it was meant to be strong. However, it was falso. > We cannot even discuss the tracker until we fix this abomination > called c.l.py. I have nothing directly to do with c.l.p and care nothing for it. I read the gmane.comp.python.general mirror of python-list, which filters out some of the worse of the input from c.l.p. I mostly focus on getting real work done on the tracker and repository and am only temporarily spending this much time here as a diversion. -- Terry Jan Reedy From aahz at pythoncraft.com Tue Jan 18 18:53:36 2011 From: aahz at pythoncraft.com (Aahz) Date: 18 Jan 2011 15:53:36 -0800 Subject: issubclass(dict, Mapping) References: <4d127d5e$0$29997$c3e8da3$5496439d@news.astraweb.com> Message-ID: In article , kj wrote: > >standard OOP semantics "...some experts might say a C++ program is not object-oriented without inheritance and virtual functions. As one of the early Smalltalk implementors myself, I can say they are full of themselves." --zconcept -- Aahz (aahz at pythoncraft.com) <*> http://www.pythoncraft.com/ "The volume of a pizza of thickness 'a' and radius 'z' is given by pi*z*z*a" From rantingrick at gmail.com Tue Jan 18 18:54:48 2011 From: rantingrick at gmail.com (rantingrick) Date: Tue, 18 Jan 2011 15:54:48 -0800 (PST) Subject: move to end, in Python 3.2 Really? References: <58c17709-d68e-4448-b618-b6f594d0e8c5@t35g2000yqj.googlegroups.com> <125db7fe-036e-47c9-be89-50f05106936f@n2g2000pre.googlegroups.com> Message-ID: And were the hell is Steve Holden? Why has he not weighed in on these (or any) discussions. He (Steve Holden) is second in command to the entire community. Yet we have yet to hear a peep from this fella. What gives Steve? And if Steve is too busy, who is next in the chain of command? Who is going to take responsibility for this catastrophe we call c.l.py? Is there no one is man enough to step up for this community? Are all of our leaders just sticking their heads in the sand hoping for this to "solve" itself? I would really like for some heavy weights to get involved here. From ethan at stoneleaf.us Tue Jan 18 18:56:29 2011 From: ethan at stoneleaf.us (Ethan Furman) Date: Tue, 18 Jan 2011 15:56:29 -0800 Subject: move to end, in Python 3.2 Really? In-Reply-To: References: <58c17709-d68e-4448-b618-b6f594d0e8c5@t35g2000yqj.googlegroups.com> <125db7fe-036e-47c9-be89-50f05106936f@n2g2000pre.googlegroups.com> <99e7061d-20d5-434b-9404-bdafd6a013ac@i17g2000vbq.googlegroups.com> Message-ID: <4D3628AD.4040605@stoneleaf.us> Grant Edwards wrote: > On 2011-01-18, MRAB wrote: >> On 18/01/2011 19:22, rantingrick wrote: >>> ... > >> The Python community are volunteers. Nothing gets done until someone >> volunteers to do it. The "suggestion box" is your idea. Why don't you >> set it up and report back? > > He goes by the name of "ranting rick", and you're suggesting that > instead of talking he rolls up his sleeves and does something. > > I suspect you're barking into the wind... To borrow from Dilbert*, perhaps rr is more of an idea rat. ~Ethan~ *http://www.dilbert.com/strips/comic/1994-12-17/ From rantingrick at gmail.com Tue Jan 18 19:00:25 2011 From: rantingrick at gmail.com (rantingrick) Date: Tue, 18 Jan 2011 16:00:25 -0800 (PST) Subject: move to end, in Python 3.2 Really? References: <58c17709-d68e-4448-b618-b6f594d0e8c5@t35g2000yqj.googlegroups.com> <125db7fe-036e-47c9-be89-50f05106936f@n2g2000pre.googlegroups.com> Message-ID: <6ba96f41-a158-43e7-80d2-6c541587e5a4@r29g2000yqj.googlegroups.com> On Jan 18, 5:44?pm, Terry Reedy wrote: > I have nothing directly to do with c.l.p and care nothing for it. I read > the gmane.comp.python.general mirror of python-list, which filters out > some of the worse of the input from c.l.p. I mostly focus on getting > real work done on the tracker and repository and am only temporarily > spending this much time here as a diversion. Well first of all i want to commend you for your valiant efforts. You are one the most helpful folks (anoung others) around and i believe you are a virtuous soul. However, you really should not just write off c.l.py like you have. Many new users (and old hats) still hang around here. Sure there is a lot of spam, and some trolling. However, we CAN take c.l.py back IF some heavy weights will get on board. Please don't allow c.l.py to become the habitat of vermin due to neglect. Why should we move to the sub burbs just because these fowl creatures are polluting our city? We need to run them out of town. From ben+python at benfinney.id.au Tue Jan 18 19:09:36 2011 From: ben+python at benfinney.id.au (Ben Finney) Date: Wed, 19 Jan 2011 11:09:36 +1100 Subject: Swampy Module installation References: <9dd545a1-b0ea-408c-9fe2-a2ce7d6a5a0a@m7g2000vbn.googlegroups.com> Message-ID: <87y66h4uv3.fsf@benfinney.id.au> Michael Rauh writes: > I am new to python, and attempting to install the learning module > swampy. http://www.greenteapress.com/thinkpython/swampy/install.html > Unfortunately, I am attempting to do this on windows vista, which does > not appear to be cooperating. I'm not familiar with the specifics of that OS, but you should read the Python on Windows FAQ thoroughly to see if that gets you further. -- \ ?? one of the main causes of the fall of the Roman Empire was | `\ that, lacking zero, they had no way to indicate successful | _o__) termination of their C programs.? ?Robert Firth | Ben Finney From askutt at gmail.com Tue Jan 18 19:23:30 2011 From: askutt at gmail.com (Adam Skutt) Date: Tue, 18 Jan 2011 16:23:30 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <79a8a$4d332d1a$4275d90a$3986@FUSE.NET> <64976187-88ad-47c9-9bc6-c0712a657264@j32g2000yqc.googlegroups.com> <3af4fd5e-8cc9-4cec-aad2-cbf82ad3bab3@l24g2000vby.googlegroups.com> Message-ID: <0fa4603c-6e27-4ee5-9761-000a61cd19a4@fx12g2000vbb.googlegroups.com> On Jan 18, 6:36?pm, rantingrick wrote: On Jan 18, 4:57 pm, Adam Skutt wrote: > On Jan 18, 4:45 pm, Arndt Roger Schneider > > > E.g. a button is: > > > A function gets asychnronously performed in response to > > > a finger/mouse click and release inside a certain screen area. > > No, that is not the definition of a 'button', not even when we choose > > to ignore how it is rendered, which you cannot ignore even if you wish > > to pretend you can. Otherwise, I could always treat hyperlinks and > > buttons as equivalent and even interchangeable. Unfortunately, they > > are no such things. > What! YES it is Adam! And you just exposed yourself as an > argumentative moron! > > A hyperlink and a button are EXACTLY the same thing "functionality" > wise. :active, :visited:, :hover, and the concept of "onhover" all would like to have a word with you. They have different presentation which yields to different functionality: if it's important to tell a user "Hey, you've been there before", then a button is entirely unsuitable, while a hyperlink is designed precisely for that situation. Hyperlinks change their presentation to indicate mouse focus (nevermind the mouse cursor itself normally), buttons don't necessarily do either[1]. Hyperlinks can certainly decay to become button-like, but buttons cannot do everything hyperlinks can do. Checkboxes and radio buttons are a much better rebuttal, as they usually present "almost" the same API and expect the same model on part of the application programmer. It's the "almost" that kills us: radio buttons only behave in the desired way when part of a button group, forcing us to be cognizant of the fact we're creating radio buttons (since we must create button groups as well). Checkboxes support tri-state functionality, and sometimes radiobuttons do as well. Pushbuttons do no such thing[2]. It'd be nice to be able to support the abstract notion of a "button" and get what I wanted, but that requires guessing at intent and computers are notoriously lousy at that. > The fact that they look different has nothing to do with the > argument. Actually it does, but they not only look different, they /behave/ differently. Both in terms of how a user interacts with them, and in terms of how we interact with them in code. > More argumentative crap. Adam you are incapable of compromise or > reason... or maybe both. Try more facts next time. I'm not the one suggesting that the only difference between a hyperlink and a button is how they are rendered, FFS man, have you ever even used a modern GUI? Are you posting from tin? Adam [1] Even when they do, it's not intended to be controlled by the application. Native button widgets have no real built-in support for user-controlled styling on mouse focus, you'd have to do the drawing yourself (at which point you might as well write a custom widget). [2] I'm ignoring the UI problems with radio buttons and checkboxes, of course. Point is, even among things where the differences are subtle, the differences have inescapable ramifications on the code I write. From rantingrick at gmail.com Tue Jan 18 19:53:28 2011 From: rantingrick at gmail.com (rantingrick) Date: Tue, 18 Jan 2011 16:53:28 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <79a8a$4d332d1a$4275d90a$3986@FUSE.NET> <64976187-88ad-47c9-9bc6-c0712a657264@j32g2000yqc.googlegroups.com> <3af4fd5e-8cc9-4cec-aad2-cbf82ad3bab3@l24g2000vby.googlegroups.com> <0fa4603c-6e27-4ee5-9761-000a61cd19a4@fx12g2000vbb.googlegroups.com> Message-ID: <2510bf88-1045-411f-9ccd-7ca7c3665454@l24g2000vby.googlegroups.com> On Jan 18, 6:23?pm, Adam Skutt wrote: > I'm not the one suggesting that the only difference between a > hyperlink and a button is how they are rendered, FFS man, have you > ever even used a modern GUI? Yes i have logged many hours building GUI's... and from the comments you've made so far... obviously more that you have! But your defiance intrigues me. You still argue in the face of undeniable fact. Ok, i will lower the bar a bit this time. They (the buttons) are exactly the same thing except for a few superficial differences. Both "buttons" wait for activity (either by pointer, or touch) and then execute a linked block of code. The fact that hyper-link displays a visual clue that it has been "activated" before is just superficial. Heck a "button" displays a visual clue that it is a button and you are not arguing that point? And this moronic argument of ":onhover" ":visited", and ":active" is completely unfounded as buttons have mouse events such as "Enter" and "Leave", just to name a few. Adam, it is now evident that your view of the world is, at best, a superficial one. You are shallow and incapable of any coherent abstract reasoning abilities. I genuinely hope this is due to some emotional distress you are suffering and not a chronic condition, because if not, you need to give some deep mediative thoughts to how you are perceiving the world around you to heal your mind of this improper processing. Being argumentative just for the sake of being argumentative is a never ending cycle of foolishness. Now, at some point earlier you had begin to display some coherency and insights. I sure hope that behavior will return soon..? From kb1pkl at aim.com Tue Jan 18 20:19:17 2011 From: kb1pkl at aim.com (Corey Richardson) Date: Tue, 18 Jan 2011 20:19:17 -0500 Subject: Tkinter: The good, the bad, and the ugly! In-Reply-To: <2510bf88-1045-411f-9ccd-7ca7c3665454@l24g2000vby.googlegroups.com> References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <79a8a$4d332d1a$4275d90a$3986@FUSE.NET> <64976187-88ad-47c9-9bc6-c0712a657264@j32g2000yqc.googlegroups.com> <3af4fd5e-8cc9-4cec-aad2-cbf82ad3bab3@l24g2000vby.googlegroups.com> <0fa4603c-6e27-4ee5-9761-000a61cd19a4@fx12g2000vbb.googlegroups.com> <2510bf88-1045-411f-9ccd-7ca7c3665454@l24g2000vby.googlegroups.com> Message-ID: <4D363C15.7030306@aim.com> On 01/18/2011 07:53 PM, rantingrick wrote: > On Jan 18, 6:23 pm, Adam Skutt wrote: > > [snip] > > Adam, it is now evident that your view of the world is, at best, a > superficial one. You are shallow and incapable of any coherent > abstract reasoning abilities. I genuinely hope this is due to some > emotional distress you are suffering and not a chronic condition, > because if not, you need to give some deep mediative thoughts to how > you are perceiving the world around you to heal your mind of this > improper processing. Being argumentative just for the sake of being > argumentative is a never ending cycle of foolishness. Now, at some > point earlier you had begin to display some coherency and insights. I > sure hope that behavior will return soon..? Because insulting others is completely how things get done. As to the button/hyperlink, they may both share some common functionality and even a common ancestor, they are different beings, otherwise they wouldn't be two separate things. It may even be that a hyperlink is a type of button, but that doesn't make a button a hyperlink. (Plant/tree, rectangle/square type deal). I for one am quite pleased with Tkinter up to this point. It allowed me to come in with extremely minimal GUI experience, and make something that worked with minimal effort. It was simple to understand, no concepts of slots and signals to learn. A project I'm working on requires PyQt, so I use PyQt. Is the fact that it's not in the stdlib a detriment? No. I think Tkinter _should_ be in the stdlib because it's simple. If something else were to take it's place I would hope that it is as easy to learn/use as Tkinter is. But I think this whole thread has gotten off topic. Why should Tkinter be replaced? Why was it added there in the first place? What should replace it, and why? Instead of arguing about little piddly details like the difference between a button and a hyperlink, just stick to the task at hand that you yourself presented. My two cents, ~Corey From rantingrick at gmail.com Tue Jan 18 20:23:06 2011 From: rantingrick at gmail.com (rantingrick) Date: Tue, 18 Jan 2011 17:23:06 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <79a8a$4d332d1a$4275d90a$3986@FUSE.NET> <64976187-88ad-47c9-9bc6-c0712a657264@j32g2000yqc.googlegroups.com> <3af4fd5e-8cc9-4cec-aad2-cbf82ad3bab3@l24g2000vby.googlegroups.com> <9d0d0f8a-9684-4405-897c-141f2241070d@fo10g2000vbb.googlegroups.com> Message-ID: On Jan 18, 2:37?pm, Adam Skutt wrote: > On Jan 18, 2:11?pm, rantingrick wrote: > > The entropy in GUIs has > > exploded exponentially and rendered them all useless. > > Only if you have no clue what you're talking about whatsoever. ?You > perceive them as useless because you're apparently incapable of > understanding the simplest GUI precepts, nevermind APIs, which is why > you've gone from Pure Python GUI to wxWidgets to this OpenGUI bullshit > you're now espousing. ?Desperately clinging to a position doesn't make > you look intelligent. > > Plus, I'm not sure what entropy you're talking about, but I'm not > seeing it. ?MS continues to innovate, Apple continues to innovate, > some portions of the Linux community do innovative things. ?Though > most people just want to put something together and call it a day, and > the functionality provided by a lot of toolkits is beyond adequate for > that. Adam, i am speaking specifically about how multiplicity is ruining everything. The multiplicity is "entropy incarnate". And selfishness is the heathen prodigy of multiplicity. What we have today is a zig saw puzzle of GUI libraries. Not one of them can solve all the GUI problems we have before us because of selfishness and lack of true cooperation between the diverse parties. And to add insult to injury none of the pieces where ever made so that they could mate correctly. We have been the victims of you own selfishness and vanity begotten directly from our fostering of multiplicity. Once you understand what i am talking about, you will see how it applies to almost every system we humans have ever created. And more disturbingly, how difficult it will be to undo this backward facing inertia we have set in motion. Years, decades, centuries have been lost due to nothing more than selfishness. When will we see the light? From patty at cruzio.com Tue Jan 18 20:39:43 2011 From: patty at cruzio.com (Patty) Date: Tue, 18 Jan 2011 17:39:43 -0800 Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <79a8a$4d332d1a$4275d90a$3986@FUSE.NET> <64976187-88ad-47c9-9bc6-c0712a657264@j32g2000yqc.googlegroups.com> <3af4fd5e-8cc9-4cec-aad2-cbf82ad3bab3@l24g2000vby.googlegroups.com> <0fa4603c-6e27-4ee5-9761-000a61cd19a4@fx12g2000vbb.googlegroups.com><2510bf88-1045-411f-9ccd-7ca7c3665454@l24g2000vby.googlegroups.com> <4D363C15.7030306@aim.com> Message-ID: <94898B418AC54E0BBD4C64003D9D5BAF@mycomputer> ----- Original Message ----- From: "Corey Richardson" To: Sent: Tuesday, January 18, 2011 5:19 PM Subject: Re: Tkinter: The good, the bad, and the ugly! > On 01/18/2011 07:53 PM, rantingrick wrote: >> On Jan 18, 6:23 pm, Adam Skutt wrote: >> >> [snip] >> >> Adam, it is now evident that your view of the world is, at best, a >> superficial one. You are shallow and incapable of any coherent >> abstract reasoning abilities. I genuinely hope this is due to some >> emotional distress you are suffering and not a chronic condition, >> because if not, you need to give some deep mediative thoughts to how >> you are perceiving the world around you to heal your mind of this >> improper processing. Being argumentative just for the sake of being >> argumentative is a never ending cycle of foolishness. Now, at some >> point earlier you had begin to display some coherency and insights. I >> sure hope that behavior will return soon..? > > Because insulting others is completely how things get done. As to the > button/hyperlink, they may both share some common functionality and even > a common ancestor, they are different beings, otherwise they wouldn't be > two separate things. It may even be that a hyperlink is a type of > button, but that doesn't make a button a hyperlink. (Plant/tree, > rectangle/square type deal). > > I for one am quite pleased with Tkinter up to this point. It allowed me > to come in with extremely minimal GUI experience, and make something > that worked with minimal effort. It was simple to understand, no > concepts of slots and signals to learn. A project I'm working on > requires PyQt, so I use PyQt. Is the fact that it's not in the stdlib a > detriment? No. I think Tkinter _should_ be in the stdlib because it's > simple. If something else were to take it's place I would hope that it > is as easy to learn/use as Tkinter is. > > But I think this whole thread has gotten off topic. Why should Tkinter > be replaced? Why was it added there in the first place? What should > replace it, and why? Instead of arguing about little piddly details like > the difference between a button and a hyperlink, just stick to the task > at hand that you yourself presented. > > My two cents, > ~Corey > -- > http://mail.python.org/mailman/listinfo/python-list > > I agree with Corey - I also had very little experience with creating a GUI and using Tkinter combined with PIL plus a little help from various docs and getting a couple questions answered, I was pleased to find that it required very few actual lines of code to create a basic small window and display text and pictures that I am happy with and I am sure I can use this small module as a base to expand on if I want to. Regards, Patty From rantingrick at gmail.com Tue Jan 18 20:41:15 2011 From: rantingrick at gmail.com (rantingrick) Date: Tue, 18 Jan 2011 17:41:15 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <64976187-88ad-47c9-9bc6-c0712a657264@j32g2000yqc.googlegroups.com> <3af4fd5e-8cc9-4cec-aad2-cbf82ad3bab3@l24g2000vby.googlegroups.com> <0fa4603c-6e27-4ee5-9761-000a61cd19a4@fx12g2000vbb.googlegroups.com> <2510bf88-1045-411f-9ccd-7ca7c3665454@l24g2000vby.googlegroups.com> Message-ID: On Jan 18, 7:19?pm, Corey Richardson wrote: > I for one am quite pleased with Tkinter up to this point. It allowed me > to come in with extremely minimal GUI experience, and make something > that worked with minimal effort. It was simple to understand, no > concepts of slots and signals to learn. I agree. I have written tons of code with Tkinter and i love both the simplistic API and the geometry managers to name a few pros. > If something else were to take it's place (Tkinter) I would hope that it > is as easy to learn/use as Tkinter is. I completely agree! And we should expect it to be even better! > But I think this whole thread has gotten off topic. Why should Tkinter > be replaced? Well there are many good reasons and most are not apparent to those with minimal to average Tkinter experience. My main beef with Tkinter is that it is limited --both widget wise and extensible wise-- and that we must recognize that web and mobile platforms are getting bigger every day. We cannot ignore this fact. The GUI landscape is changing fast and whilst desktop support will be needed for many years to come, mobile and web must be addressed and addressed quickly! > Why was it added there in the first place? Well from what i understand (and feel free to correct me anyone) Guido wanted a GUI both for batteries included and for ease of introductory GUI programming. So he choose Tkinter because it would be both easy to integrate and easy to use. And i totally agree with these ideas. However that was circa 1990's and we are now in 2011. I think Tkinter (whilst still quite useful) is well pasted it's prime. We must consider keeping Pythons stdlib up to date. And doing that might mean we need to make some very tough decisions. Guido brought about Python3000 and i think he's on the right track, however more must be done. Change while painful is always necessary. "Change with the times or get left behind." > What should > replace it, and why? Well that seems to be the burning question. Now, after considering all the options i can't see anything that truly moves us forward to were we "should" be. I do think wx would be a move "forward" however only a very *small* move in the larger scope of things. We need to think bigger, we need to think of mobile and web interfaces if we want Python to compete in the next 10 years. So when considering anything we must consider all three. > Instead of arguing about little piddly details like > the difference between a button and a hyperlink, just stick to the task > at hand that you yourself presented. You are absolutely correct Corey. Thanks for getting us back on topic! From nstinemates at gmail.com Tue Jan 18 20:46:40 2011 From: nstinemates at gmail.com (Nick Stinemates) Date: Tue, 18 Jan 2011 17:46:40 -0800 Subject: Tkinter: The good, the bad, and the ugly! In-Reply-To: References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <79a8a$4d332d1a$4275d90a$3986@FUSE.NET> <64976187-88ad-47c9-9bc6-c0712a657264@j32g2000yqc.googlegroups.com> <3af4fd5e-8cc9-4cec-aad2-cbf82ad3bab3@l24g2000vby.googlegroups.com> <9d0d0f8a-9684-4405-897c-141f2241070d@fo10g2000vbb.googlegroups.com> Message-ID: You make it very hard for me to take what you say seriously. I lurk on this list and I have created a filter where emails from you go in to Spam. Good luck. Nick On Tue, Jan 18, 2011 at 5:23 PM, rantingrick wrote: > On Jan 18, 2:37 pm, Adam Skutt wrote: > > On Jan 18, 2:11 pm, rantingrick wrote: > > > > The entropy in GUIs has > > > exploded exponentially and rendered them all useless. > > > > Only if you have no clue what you're talking about whatsoever. You > > perceive them as useless because you're apparently incapable of > > understanding the simplest GUI precepts, nevermind APIs, which is why > > you've gone from Pure Python GUI to wxWidgets to this OpenGUI bullshit > > you're now espousing. Desperately clinging to a position doesn't make > > you look intelligent. > > > > Plus, I'm not sure what entropy you're talking about, but I'm not > > seeing it. MS continues to innovate, Apple continues to innovate, > > some portions of the Linux community do innovative things. Though > > most people just want to put something together and call it a day, and > > the functionality provided by a lot of toolkits is beyond adequate for > > that. > > > Adam, i am speaking specifically about how multiplicity is ruining > everything. The multiplicity is "entropy incarnate". And selfishness > is the heathen prodigy of multiplicity. What we have today is a zig > saw puzzle of GUI libraries. Not one of them can solve all the GUI > problems we have before us because of selfishness and lack of true > cooperation between the diverse parties. And to add insult to injury > none of the pieces where ever made so that they could mate correctly. > We have been the victims of you own selfishness and vanity begotten > directly from our fostering of multiplicity. Once you understand what > i am talking about, you will see how it applies to almost every system > we humans have ever created. And more disturbingly, how difficult it > will be to undo this backward facing inertia we have set in motion. > Years, decades, centuries have been lost due to nothing more than > selfishness. When will we see the light? > -- > http://mail.python.org/mailman/listinfo/python-list > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rantingrick at gmail.com Tue Jan 18 20:54:08 2011 From: rantingrick at gmail.com (rantingrick) Date: Tue, 18 Jan 2011 17:54:08 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <64976187-88ad-47c9-9bc6-c0712a657264@j32g2000yqc.googlegroups.com> <3af4fd5e-8cc9-4cec-aad2-cbf82ad3bab3@l24g2000vby.googlegroups.com> <0fa4603c-6e27-4ee5-9761-000a61cd19a4@fx12g2000vbb.googlegroups.com><2510bf88-1045-411f-9ccd-7ca7c3665454@l24g2000vby.googlegroups.com> <4D363C15.7030306@aim.com> Message-ID: <137c9df1-aa56-471a-92ad-9b222dadb196@u32g2000yqe.googlegroups.com> On Jan 18, 7:39?pm, "Patty" wrote: > I agree with Corey - I also had very little experience with creating a GUI > and using Tkinter combined with PIL plus a little help from various docs > and getting a couple questions answered, I was pleased to find that it > required very few actual lines of code to create a basic small window and > display text and pictures that ?I am happy with and I am sure I can use this > small module as a base to expand on if I want to. Hello Patty and welcome to the debate, I am happy to see the simplicity of Tkinter has helped moved you into the joys of GUI programming. I remember my initial days with Tkinter and i remember the delight in achieving my first small GUI utilities. Like you, i love the simplistic nature of Tkinter and if TclTk had as large a widget base and maturity as wxWidgets then we would be closer to the 21st century GUI library that Python desperately needs. However as i know --and you will find out over time-- Tkinter is greatly lacking in very important widgets. Widgets that are part of every major GUI app you could imagine. If all you do is create utilities for yourself or small apps you can get by with Tkinter just fine. However if you try to go any further you will then realize the limits of TclTk --and not Tkinter-- are really the culprits behind the scenes. But again, all this is moot because as this debate has evolved so too has my understanding of where we need to be focusing or efforts -- and *desktop only* is not going to cut it for the future of Python's std- GUI-lib. We need to take a step back and see the larger picture. Currently we have our heads stuck in the vacuum of python land, however this GUI problem is much, much larger! From kb1pkl at aim.com Tue Jan 18 20:59:32 2011 From: kb1pkl at aim.com (Corey Richardson) Date: Tue, 18 Jan 2011 20:59:32 -0500 Subject: Tkinter: The good, the bad, and the ugly! In-Reply-To: References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <64976187-88ad-47c9-9bc6-c0712a657264@j32g2000yqc.googlegroups.com> <3af4fd5e-8cc9-4cec-aad2-cbf82ad3bab3@l24g2000vby.googlegroups.com> <0fa4603c-6e27-4ee5-9761-000a61cd19a4@fx12g2000vbb.googlegroups.com> <2510bf88-1045-411f-9ccd-7ca7c3665454@l24g2000vby.googlegroups.com> Message-ID: <4D364584.3060603@aim.com> On 01/18/2011 08:41 PM, rantingrick wrote: > On Jan 18, 7:19 pm, Corey Richardson wrote: > >> I for one am quite pleased with Tkinter up to this point. It allowed me >> to come in with extremely minimal GUI experience, and make something >> that worked with minimal effort. It was simple to understand, no >> concepts of slots and signals to learn. > > I agree. I have written tons of code with Tkinter and i love both the > simplistic API and the geometry managers to name a few pros. > > >> If something else were to take it's place (Tkinter) I would hope that it >> is as easy to learn/use as Tkinter is. > > I completely agree! And we should expect it to be even better! What out there is there that meets those requirements? > > >> But I think this whole thread has gotten off topic. Why should Tkinter >> be replaced? > > Well there are many good reasons and most are not apparent to those > with minimal to average Tkinter experience. My main beef with Tkinter > is that it is limited --both widget wise and extensible wise-- and > that we must recognize that web and mobile platforms are getting > bigger every day. We cannot ignore this fact. The GUI landscape is > changing fast and whilst desktop support will be needed for many years > to come, mobile and web must be addressed and addressed quickly! Mobile and web certainly have their place, but it Python the place for it? Sure, Python can be used as the back-end of web sites, but not up front like Java or Flash (aside from Jython). Especially mobile. Python was not intended for a mobile platform not should it be made to fit that niche. Python has its place, but your cell phone is not it. > > [snip] >> What should >> replace it, and why? > > Well that seems to be the burning question. Now, after considering all > the options i can't see anything that truly moves us forward to were > we "should" be. I do think wx would be a move "forward" however only a > very *small* move in the larger scope of things. We need to think > bigger, we need to think of mobile and web interfaces if we want > Python to compete in the next 10 years. So when considering anything > we must consider all three. > >From that, it appears we need to: 1. Replace Tkinter with something more modern and feature-complete, but just as easy to use. 2. Add a web framework/web-GUI As a web interface are you thinking something like Java's Swing or something like Django? Given the above, what do you guys (python-list, not just rantingrick) think fills the spot the best? Would these items inclusion in the stdlib entail unnecessary cruft added on to the size of the stdlib, are they completely cross-platform (as far as Python itself is)? Let's try not to get off track like this thing has been since it was started. Either get things done or shut up ;-). I think this is almost ready to split into a "real" thread, not just a giant cyclic argument that this thread has been. ~Corey From rantingrick at gmail.com Tue Jan 18 21:16:54 2011 From: rantingrick at gmail.com (rantingrick) Date: Tue, 18 Jan 2011 18:16:54 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <3af4fd5e-8cc9-4cec-aad2-cbf82ad3bab3@l24g2000vby.googlegroups.com> <0fa4603c-6e27-4ee5-9761-000a61cd19a4@fx12g2000vbb.googlegroups.com> <2510bf88-1045-411f-9ccd-7ca7c3665454@l24g2000vby.googlegroups.com> Message-ID: <2ef2fa6c-2ccf-453a-8f50-0ef7dbd7834d@j32g2000yqc.googlegroups.com> On Jan 18, 7:59?pm, Corey Richardson wrote: > On 01/18/2011 08:41 PM, rantingrick wrote: > >From that, it appears we need to: > > 1. Replace Tkinter with something more modern and feature-complete, but > just as easy to use. > 2. Add a web framework/web-GUI That would be a HUGE step in the correct direction. It would not solve all our problems however its a start. Like i mentioned earlier with Tkinter it is fact that sooner or later you will come up against the glass ceiling. At that point your only alternative is to toss away everything you have learned/written and re-learn another GUI library like wxPython. This is what bothers me most about Tkinter. It just sums to wasted time and energy. If we had a simplistic wxGUI in the stdlib, when you hit the ceiling and need to go further you could then scale nicely to the feature richness of wxPython as a 3rd party download -- WITHOUT relearning/rewriting everything! > Given the above, what do you guys (python-list, not just rantingrick) > think fills the spot the best? Well i hope some heavy weights weigh in however i must tell you that it don't happen very often. From kb1pkl at aim.com Tue Jan 18 21:27:57 2011 From: kb1pkl at aim.com (Corey Richardson) Date: Tue, 18 Jan 2011 21:27:57 -0500 Subject: Tkinter: The good, the bad, and the ugly! In-Reply-To: <2ef2fa6c-2ccf-453a-8f50-0ef7dbd7834d@j32g2000yqc.googlegroups.com> References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <3af4fd5e-8cc9-4cec-aad2-cbf82ad3bab3@l24g2000vby.googlegroups.com> <0fa4603c-6e27-4ee5-9761-000a61cd19a4@fx12g2000vbb.googlegroups.com> <2510bf88-1045-411f-9ccd-7ca7c3665454@l24g2000vby.googlegroups.com> <2ef2fa6c-2ccf-453a-8f50-0ef7dbd7834d@j32g2000yqc.googlegroups.com> Message-ID: <4D364C2D.5060106@aim.com> On 01/18/2011 09:16 PM, rantingrick wrote: > On Jan 18, 7:59 pm, Corey Richardson wrote: >> On 01/18/2011 08:41 PM, rantingrick wrote: > >> >From that, it appears we need to: >> >> 1. Replace Tkinter with something more modern and feature-complete, but >> just as easy to use. >> 2. Add a web framework/web-GUI > > That would be a HUGE step in the correct direction. It would not solve > all our problems however its a start. Like i mentioned earlier with > Tkinter it is fact that sooner or later you will come up against the > glass ceiling. At that point your only alternative is to toss away > everything you have learned/written and re-learn another GUI library > like wxPython. This is what bothers me most about Tkinter. It just > sums to wasted time and energy. If we had a simplistic wxGUI in the > stdlib, when you hit the ceiling and need to go further you could then > scale nicely to the feature richness of wxPython as a 3rd party > download -- WITHOUT relearning/rewriting everything! > You mentioned having a segment of wxPython in the stdlib earlier. If this actually feasible from a legal standpoint, and would the maintainers of wxPython be willing to put it in the stdlib? Not to mention the wonderful people over at python-dev. Why would you add in only a part of wxPython, instead of all of it? Is the work to cut it down really an advantage over the size of the full toolkit? From what I just checked, the source tarball is 40MB. Can that much really be added to the Python stdlib? What other alternatives are there, besides wxPython, that are perhaps a bit smaller. > >> Given the above, what do you guys (python-list, not just rantingrick) >> think fills the spot the best? > > Well i hope some heavy weights weigh in however i must tell you that > it don't happen very often. > > From askutt at gmail.com Tue Jan 18 21:43:25 2011 From: askutt at gmail.com (Adam Skutt) Date: Tue, 18 Jan 2011 18:43:25 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <3af4fd5e-8cc9-4cec-aad2-cbf82ad3bab3@l24g2000vby.googlegroups.com> <0fa4603c-6e27-4ee5-9761-000a61cd19a4@fx12g2000vbb.googlegroups.com> <2510bf88-1045-411f-9ccd-7ca7c3665454@l24g2000vby.googlegroups.com> Message-ID: On Jan 18, 8:59?pm, Corey Richardson wrote: > > > I completely agree! And we should expect it to be even better! > > What out there is there that meets those requirements? Nothing, and I somewhat doubt there ever will be. Tk is somewhat of an anomaly at this point. Most of the trend in GUI toolkits is to become more HTML/JS/CSS like in nature, which isn't something I personally agree with. I certainly don't think it makes life any easier for the programmer, especially starting out. It might make certain types of applications (e.g., CRUD) easier, but that's not a laudable goal in the least. > Mobile and web certainly have their place, but it Python the place for > it? Sure, Python can be used as the back-end of web sites, but not up > front like Java or Flash (aside from Jython). Especially mobile. Python > was not intended for a mobile platform not should it be made to fit that > niche. Python has its place, but your cell phone is not it. I don't think that's true per se, but I don't think it's relevant. A single GUI toolkit for traditional computers, for web, and mobile is a difficult task, one that no one has accomplished. MS has gotten closest, and I'd hesitate to call Silverlight a success. Plus, Silverlight is plugin-based rich applications (ala Flash), not HTML/ CSS/Javascript which is what most people mean/want for the web. Adding HTML/CSS/Javascript to the mix takes the problem from bad to awful, in my opinion. I'm sure the various Pyjamas users might take issue with that, but what works best inside a web browser (with its various enforced limitations) isn't what works best inside a client- side application (be it web delivered or not). > As a web interface are you thinking something like Java's Swing or > something like Django? You pretty clearly need both. There are times when web pages are what I want, there are times when they are inadequate and I need more functionality. You certainly don't want either Swing or Django, though. > > Given the above, what do you guys (python-list, not just rantingrick) > think fills the spot the best? > Nothing, but I'm not even convinced the spot needs to be filled. Certainly no one's made an actual case for why, much less how. Regardless, if it's really what you want, you'd have to write it yourself. Personally, while Silverlight has some interesting ideas, I'd recommend not using it as a base, especially if Python is your target language. > Would these items inclusion in the stdlib entail unnecessary cruft added > on to the size of the stdlib, are they completely cross-platform (as far > as Python itself is)? > Depends on exactly what you do, but you'd likely end up no bigger than .NET or Java. I'll leave it to others to decide whether that's a good or bad thing. > Let's try not to get off track like this thing has been since it was > started. That was and rantingrick's goal from the get go and still is his goal. Otherwise, he wouldn't have changed his position three times now and be overdue for a fourth. Otherwise, he would have answered my / your question about why bother putting a minimized version of wxWidgets in the standard library by now as opposed to the whole damn thing. He dodges technical questions because he lacks even the most elementary understanding. He'll do the same to you and only offer absurd platitudes and insults in return, as opposed to actual working technical solutions. Hell, he can't even offer up a consistent problem to solve, and he's honestly over do for changing it altogether.. Adam From rantingrick at gmail.com Tue Jan 18 21:46:42 2011 From: rantingrick at gmail.com (rantingrick) Date: Tue, 18 Jan 2011 18:46:42 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <0fa4603c-6e27-4ee5-9761-000a61cd19a4@fx12g2000vbb.googlegroups.com> <2510bf88-1045-411f-9ccd-7ca7c3665454@l24g2000vby.googlegroups.com> <2ef2fa6c-2ccf-453a-8f50-0ef7dbd7834d@j32g2000yqc.googlegroups.com> Message-ID: <6de7ffb8-ef5a-4596-99ca-de1a6ab1d2ab@z5g2000yqb.googlegroups.com> On Jan 18, 8:27?pm, Corey Richardson wrote: > You mentioned having a segment of wxPython in the stdlib earlier. If > this actually feasible from a legal standpoint, and would the > maintainers of wxPython be willing to put it in the stdlib? Not to > mention the wonderful people over at python-dev. This might come as a shock to you, but it really doesn't matter what the wxPython folks think about the inclusion of wxPython into the stdlib. If they are against it (or simply don't care) then they can continue to focus their efforts on the full version. No harm done, really. As far as python-dev is concerned -- it does matter! However if the community wants change, and makes enough noise, they will have no choice either. ;) > Why would you add in only a part of wxPython, instead of all of it? see my next answer for detail... > Is > the work to cut it down really an advantage over the size of the full > toolkit? From what I just checked, the source tarball is 40MB. Can that > much really be added to the Python stdlib? 40MB is far too big. Much of wxPython is thousands of widgets that have no buisness in the stdlib. We only want a very limited set (much like what Tkinter is composed of now) and then for the people who want to create professional GUI's they can download the full 40MB. The great advantage here is scalability. Tkinter cannot do this. And anybody who alludes to this is a liar. > What other alternatives are > there, besides wxPython, that are perhaps a bit smaller. Well i am open to any and all alternatives. However no many have been brought forward. My dream would be to have something completely python based, although i realize that the work involved is far too enormous. So we must build from something that already exists. Nothing is really perfect. WxPython IS NOT perfect however it is a step forward. As far as alternative here is a list... http://docs.python.org/faq/gui From rantingrick at gmail.com Tue Jan 18 21:54:59 2011 From: rantingrick at gmail.com (rantingrick) Date: Tue, 18 Jan 2011 18:54:59 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <3af4fd5e-8cc9-4cec-aad2-cbf82ad3bab3@l24g2000vby.googlegroups.com> <0fa4603c-6e27-4ee5-9761-000a61cd19a4@fx12g2000vbb.googlegroups.com> <2510bf88-1045-411f-9ccd-7ca7c3665454@l24g2000vby.googlegroups.com> Message-ID: <7e3d9f6e-84a2-4b43-ac26-e05082453469@c39g2000yqi.googlegroups.com> On Jan 18, 8:43?pm, Adam Skutt wrote: > That was and rantingrick's goal from the get go and still is his goal. > Otherwise, he wouldn't have changed his position three times now and > be overdue for a fourth. ?Otherwise, he would have answered my / your > question about why bother putting a minimized version of wxWidgets in > the standard library by now as opposed to the whole damn thing. ? You know Adam i was just begining to like you again ;). I HAVE answered that question a many, many times and if you actually take the time to read my posts AND comprhend them you would have found that answer by now. psst! Just recently i answered it again. And no, i will not quote myself for your convince. Get off your lazy butt and find it yourself! [...snip: Character assassination ...] From kb1pkl at aim.com Tue Jan 18 22:02:19 2011 From: kb1pkl at aim.com (Corey Richardson) Date: Tue, 18 Jan 2011 22:02:19 -0500 Subject: Tkinter: The good, the bad, and the ugly! In-Reply-To: <6de7ffb8-ef5a-4596-99ca-de1a6ab1d2ab@z5g2000yqb.googlegroups.com> References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <0fa4603c-6e27-4ee5-9761-000a61cd19a4@fx12g2000vbb.googlegroups.com> <2510bf88-1045-411f-9ccd-7ca7c3665454@l24g2000vby.googlegroups.com> <2ef2fa6c-2ccf-453a-8f50-0ef7dbd7834d@j32g2000yqc.googlegroups.com> <6de7ffb8-ef5a-4596-99ca-de1a6ab1d2ab@z5g2000yqb.googlegroups.com> Message-ID: <4D36543B.8020602@aim.com> On 01/18/2011 09:46 PM, rantingrick wrote: > On Jan 18, 8:27 pm, Corey Richardson wrote: > >> You mentioned having a segment of wxPython in the stdlib earlier. If >> this actually feasible from a legal standpoint, and would the >> maintainers of wxPython be willing to put it in the stdlib? Not to >> mention the wonderful people over at python-dev. > > This might come as a shock to you, but it really doesn't matter what > the wxPython folks think about the inclusion of wxPython into the > stdlib. If they are against it (or simply don't care) then they can > continue to focus their efforts on the full version. No harm done, > really. As far as python-dev is concerned -- it does matter! However > if the community wants change, and makes enough noise, they will have > no choice either. ;) > >> Why would you add in only a part of wxPython, instead of all of it? > > see my next answer for detail... > >> Is >> the work to cut it down really an advantage over the size of the full >> toolkit? From what I just checked, the source tarball is 40MB. Can that >> much really be added to the Python stdlib? > > 40MB is far too big. Much of wxPython is thousands of widgets that > have no buisness in the stdlib. We only want a very limited set (much > like what Tkinter is composed of now) and then for the people who want > to create professional GUI's they can download the full 40MB. The > great advantage here is scalability. Tkinter cannot do this. And > anybody who alludes to this is a liar. > >> What other alternatives are >> there, besides wxPython, that are perhaps a bit smaller. > > Well i am open to any and all alternatives. However no many have been > brought forward. My dream would be to have something completely python > based, although i realize that the work involved is far too enormous. > So we must build from something that already exists. Nothing is really > perfect. WxPython IS NOT perfect however it is a step forward. > > As far as alternative here is a list... > > http://docs.python.org/faq/gui If that's what you believe, I don't think many (if any) here have an issue with replacing Tkinter with something that has more features and is just as easy to use. Write up a full-on proposal, including technical feasibility of splitting up wxPython, and send it to python-ideas. After they give some feedback, modify and send to python-dev. If it's well written and makes sense, I'm sure they'll lend an ear. Just don't keep getting off topic and I'm sure people will take you more seriously next time. The insulting doesn't help either side. From rantingrick at gmail.com Tue Jan 18 22:24:57 2011 From: rantingrick at gmail.com (rantingrick) Date: Tue, 18 Jan 2011 19:24:57 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <0fa4603c-6e27-4ee5-9761-000a61cd19a4@fx12g2000vbb.googlegroups.com> <2510bf88-1045-411f-9ccd-7ca7c3665454@l24g2000vby.googlegroups.com> <2ef2fa6c-2ccf-453a-8f50-0ef7dbd7834d@j32g2000yqc.googlegroups.com> <6de7ffb8-ef5a-4596-99ca-de1a6ab1d2ab@z5g2000yqb.googlegroups.com> Message-ID: <507653e8-215f-4e60-b1aa-c3642b053be2@c39g2000yqi.googlegroups.com> On Jan 18, 9:02?pm, Corey Richardson wrote: > If that's what you believe, I don't think many (if any) here have an > issue with replacing Tkinter with something that has more features and > is just as easy to use. Yea, and you're basing that on facts from where? If you haven't noticed by now NEWSFLASH! nobody from Python-dev has weighed in. Where is Steve Holden on the issue... who knows? Where is his subordinate on this? > Write up a full-on proposal, including technical > feasibility of splitting up wxPython, and send it to python-ideas. After > they give some feedback, modify and send to python-dev. If it's well > written and makes sense, I'm sure they'll lend an ear. Obviously you've never dealt with these folks before have you? > Just don't keep > getting off topic and I'm sure people will take you more seriously next > time. The insulting doesn't help either side. Yea, thats all it takes Corey. Obviously you have not been around here long and know that because your spirit is not broken yet. But don't worry Corey, because if you hang around long enough these monsters will crucify you. Then you will understand why i have to rant so much, and why we find ourselves a full decade behind in GUI libraries with no good solution in sight. They can find a thousand reasons not to remove Tkinter and not one of them have an once of vision or thought applied. These people live on emotion, one hand washes the other, and back door politics. That is the current state of Python-dev as it relates to the "peasents". We are nothing to them. Python has lost all vision as a community. This is no doubt the beginning of the end. Better check out GO... From kb1pkl at aim.com Tue Jan 18 22:47:01 2011 From: kb1pkl at aim.com (Corey Richardson) Date: Tue, 18 Jan 2011 22:47:01 -0500 Subject: Tkinter: The good, the bad, and the ugly! In-Reply-To: <507653e8-215f-4e60-b1aa-c3642b053be2@c39g2000yqi.googlegroups.com> References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <0fa4603c-6e27-4ee5-9761-000a61cd19a4@fx12g2000vbb.googlegroups.com> <2510bf88-1045-411f-9ccd-7ca7c3665454@l24g2000vby.googlegroups.com> <2ef2fa6c-2ccf-453a-8f50-0ef7dbd7834d@j32g2000yqc.googlegroups.com> <6de7ffb8-ef5a-4596-99ca-de1a6ab1d2ab@z5g2000yqb.googlegroups.com> <507653e8-215f-4e60-b1aa-c3642b053be2@c39g2000yqi.googlegroups.com> Message-ID: <4D365EB5.9010001@aim.com> On 01/18/2011 10:24 PM, rantingrick wrote: > On Jan 18, 9:02 pm, Corey Richardson wrote: > >> If that's what you believe, I don't think many (if any) here have an >> issue with replacing Tkinter with something that has more features and >> is just as easy to use. > > Yea, and you're basing that on facts from where? If you haven't > noticed by now NEWSFLASH! nobody from Python-dev has weighed in. Where > is Steve Holden on the issue... who knows? Where is his subordinate on > this? > >> Write up a full-on proposal, including technical >> feasibility of splitting up wxPython, and send it to python-ideas. After >> they give some feedback, modify and send to python-dev. If it's well >> written and makes sense, I'm sure they'll lend an ear. > > Obviously you've never dealt with these folks before have you? > >> Just don't keep >> getting off topic and I'm sure people will take you more seriously next >> time. The insulting doesn't help either side. > > Yea, thats all it takes Corey. Obviously you have not been around > here long and know that because your spirit is not broken yet. But > don't worry Corey, because if you hang around long enough these > monsters will crucify you. Then you will understand why i have to rant > so much, and why we find ourselves a full decade behind in GUI > libraries with no good solution in sight. They can find a thousand > reasons not to remove Tkinter and not one of them have an once of > vision or thought applied. These people live on emotion, one hand > washes the other, and back door politics. That is the current state of > Python-dev as it relates to the "peasents". We are nothing to them. > > Python has lost all vision as a community. This is no doubt the > beginning of the end. Better check out GO... > > Bye. From askutt at gmail.com Tue Jan 18 22:54:59 2011 From: askutt at gmail.com (Adam Skutt) Date: Tue, 18 Jan 2011 19:54:59 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <0fa4603c-6e27-4ee5-9761-000a61cd19a4@fx12g2000vbb.googlegroups.com> <2510bf88-1045-411f-9ccd-7ca7c3665454@l24g2000vby.googlegroups.com> <2ef2fa6c-2ccf-453a-8f50-0ef7dbd7834d@j32g2000yqc.googlegroups.com> Message-ID: <5c6ff40f-05c1-4e38-89bc-b8c4745db7ce@i18g2000yqn.googlegroups.com> On Jan 18, 9:27?pm, Corey Richardson wrote: > > Why would you add in only a part of wxPython, instead of all of it? Is > the work to cut it down really an advantage over the size of the full > toolkit? From what I just checked, the source tarball is 40MB. Can that > much really be added to the Python stdlib? What other alternatives are > there, besides wxPython, that are perhaps a bit smaller. > The source tarball from the wxPython.org website contains a full version of wxWidgets in addition to the actual wxPython functionality. A python distribution would certainly contain solely the latter and require the end user to already have wxWidgets installed in a suitable fashion. The actual full wxPython binding is ~100 MiB uncompressed, ~15 MiB compressed BZIP2, but it also includes a lot of stuff that could possibly be removed and/or reduced, like full documentation, examples, etc. It can be shrunk even further by taking a dependency on swig and regenerating the bindings at compile time (they're shipped prebuilt). At which point, it's pretty damn small. Not as small as all of the Tk functionality, I think, but well under 10MiB compressed. The problem to me isn't the size (though some might find it objectionable), but the system dependencies you have to take: wxWidgets requires GTK+ on UNIX, which requires a whole mess of crap in term, plus swig, plus whatever else I may or may not be missing. I'm also not 100% certain as to whether it's as portable as Tk is today. At any rate, if the size is an issue, culling widgets is a lot of an effort for not much of a gain, especially when you look at the bigger picture of, "Every file I have to download to build python from scratch" Minimizing what's in the Python distribution does not change the size of the dependency set one bit, and that dwarfs the python code in any case. That is what you want to avoid in my opinion. Adam From kb1pkl at aim.com Tue Jan 18 23:10:06 2011 From: kb1pkl at aim.com (Corey Richardson) Date: Tue, 18 Jan 2011 23:10:06 -0500 Subject: Tkinter: The good, the bad, and the ugly! In-Reply-To: <5c6ff40f-05c1-4e38-89bc-b8c4745db7ce@i18g2000yqn.googlegroups.com> References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <0fa4603c-6e27-4ee5-9761-000a61cd19a4@fx12g2000vbb.googlegroups.com> <2510bf88-1045-411f-9ccd-7ca7c3665454@l24g2000vby.googlegroups.com> <2ef2fa6c-2ccf-453a-8f50-0ef7dbd7834d@j32g2000yqc.googlegroups.com> <5c6ff40f-05c1-4e38-89bc-b8c4745db7ce@i18g2000yqn.googlegroups.com> Message-ID: <4D36641E.4010800@aim.com> On 01/18/2011 10:54 PM, Adam Skutt wrote: > On Jan 18, 9:27 pm, Corey Richardson wrote: >> >> Why would you add in only a part of wxPython, instead of all of it? Is >> the work to cut it down really an advantage over the size of the full >> toolkit? From what I just checked, the source tarball is 40MB. Can that >> much really be added to the Python stdlib? What other alternatives are >> there, besides wxPython, that are perhaps a bit smaller. >> > The source tarball from the wxPython.org website contains a full > version of wxWidgets in addition to the actual wxPython > functionality. A python distribution would certainly contain solely > the latter and require the end user to already have wxWidgets > installed in a suitable fashion. The actual full wxPython binding is > ~100 MiB uncompressed, ~15 MiB compressed BZIP2, but it also includes > a lot of stuff that could possibly be removed and/or reduced, like > full documentation, examples, etc. It can be shrunk even further by > taking a dependency on swig and regenerating the bindings at compile > time (they're shipped prebuilt). At which point, it's pretty damn > small. Not as small as all of the Tk functionality, I think, but well > under 10MiB compressed. > > The problem to me isn't the size (though some might find it > objectionable), but the system dependencies you have to take: > wxWidgets requires GTK+ on UNIX, which requires a whole mess of crap > in term, plus swig, plus whatever else I may or may not be missing. > I'm also not 100% certain as to whether it's as portable as Tk is > today. > > At any rate, if the size is an issue, culling widgets is a lot of an > effort for not much of a gain, especially when you look at the bigger > picture of, "Every file I have to download to build python from > scratch" Minimizing what's in the Python distribution does not change > the size of the dependency set one bit, and that dwarfs the python > code in any case. That is what you want to avoid in my opinion. > > Adam That is a pretty large dependency to rely on, and it is rather undesirable IMO. ~Corey From rantingrick at gmail.com Tue Jan 18 23:15:41 2011 From: rantingrick at gmail.com (rantingrick) Date: Tue, 18 Jan 2011 20:15:41 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <0fa4603c-6e27-4ee5-9761-000a61cd19a4@fx12g2000vbb.googlegroups.com> <2510bf88-1045-411f-9ccd-7ca7c3665454@l24g2000vby.googlegroups.com> <2ef2fa6c-2ccf-453a-8f50-0ef7dbd7834d@j32g2000yqc.googlegroups.com> <5c6ff40f-05c1-4e38-89bc-b8c4745db7ce@i18g2000yqn.googlegroups.com> Message-ID: <34c3bae6-369f-427c-a28f-90ac53dea8f5@v17g2000vbo.googlegroups.com> On Jan 18, 10:10?pm, Corey Richardson wrote: > That is a pretty large dependency to rely on, and it is rather > undesirable IMO. And what exactly is undesirable? Unless you actually back up your statements with fact they just ring hallow. Can you offer any specific reasons why wx is a bad choice. And more importantly can you offer any viable alternatives? From kb1pkl at aim.com Tue Jan 18 23:35:26 2011 From: kb1pkl at aim.com (Corey Richardson) Date: Tue, 18 Jan 2011 23:35:26 -0500 Subject: Tkinter: The good, the bad, and the ugly! In-Reply-To: <34c3bae6-369f-427c-a28f-90ac53dea8f5@v17g2000vbo.googlegroups.com> References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <0fa4603c-6e27-4ee5-9761-000a61cd19a4@fx12g2000vbb.googlegroups.com> <2510bf88-1045-411f-9ccd-7ca7c3665454@l24g2000vby.googlegroups.com> <2ef2fa6c-2ccf-453a-8f50-0ef7dbd7834d@j32g2000yqc.googlegroups.com> <5c6ff40f-05c1-4e38-89bc-b8c4745db7ce@i18g2000yqn.googlegroups.com> <34c3bae6-369f-427c-a28f-90ac53dea8f5@v17g2000vbo.googlegroups.com> Message-ID: <4D366A0E.1050903@aim.com> On 01/18/2011 11:15 PM, rantingrick wrote: > On Jan 18, 10:10 pm, Corey Richardson wrote: > >> That is a pretty large dependency to rely on, and it is rather >> undesirable IMO. > > And what exactly is undesirable? Unless you actually back up your > statements with fact they just ring hallow. Can you offer any specific > reasons why wx is a bad choice. And more importantly can you offer any > viable alternatives? Go ahead and read Adam's fine post about the dependencies of wxwidgets. As for alternatives? I think Tkinter is fine for most of my purposes. When I need something else, I use PyQt. I can install python-minimal on Windows/Linux/What-have-you and know that Tkinter will run without needing GTK+ and SWIG, as Adam mentioned. If you want to get something done, here's an idea - do it yourself. That's what OS is all about. Don't just write something, implement it. If the folks over in python-dev want nothing to do with it, that's fine - make a package using your minimal wxpython version, I'm sure people will use it, especially if you make it as easy to use as Tkinter. I'm done with this thread. I inserted my 12 cents. Have a nice day, and good luck with your ventures. ~Corey From rantingrick at gmail.com Tue Jan 18 23:45:25 2011 From: rantingrick at gmail.com (rantingrick) Date: Tue, 18 Jan 2011 20:45:25 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <0fa4603c-6e27-4ee5-9761-000a61cd19a4@fx12g2000vbb.googlegroups.com> <2510bf88-1045-411f-9ccd-7ca7c3665454@l24g2000vby.googlegroups.com> <2ef2fa6c-2ccf-453a-8f50-0ef7dbd7834d@j32g2000yqc.googlegroups.com> <5c6ff40f-05c1-4e38-89bc-b8c4745db7ce@i18g2000yqn.googlegroups.com> <34c3bae6-369f-427c-a28f-90ac53dea8f5@v17g2000vbo.googlegroups.com> Message-ID: On Jan 18, 10:35?pm, Corey Richardson wrote: > I'm done with this thread. I inserted my 12 cents. Have a nice day, and > good luck with your ventures. Bye From rantingrick at gmail.com Wed Jan 19 00:32:59 2011 From: rantingrick at gmail.com (rantingrick) Date: Tue, 18 Jan 2011 21:32:59 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <0fa4603c-6e27-4ee5-9761-000a61cd19a4@fx12g2000vbb.googlegroups.com> <2510bf88-1045-411f-9ccd-7ca7c3665454@l24g2000vby.googlegroups.com> <2ef2fa6c-2ccf-453a-8f50-0ef7dbd7834d@j32g2000yqc.googlegroups.com> <5c6ff40f-05c1-4e38-89bc-b8c4745db7ce@i18g2000yqn.googlegroups.com> Message-ID: <9a036db2-9f32-441f-aa0f-698ac22fb152@e20g2000vbn.googlegroups.com> On Jan 18, 9:54?pm, Adam Skutt wrote: > On Jan 18, 9:27?pm, Corey Richardson wrote: >?At which point, it's pretty damn > small. ?Not as small as all of the Tk functionality, I think, but well > under 10MiB compressed. Yea but look at all your gaining. I would rather sacrifice a few megs for the rich functionality and scalability any day. > The problem to me isn't the size (though some might find it > objectionable), but the system dependencies you have to take: > wxWidgets requires GTK+ on UNIX UNIX? are you kidding? Even if these dependancies are needed the "UNIX" folks are damn capable of finding and installing them with great ease. Besides most ship with this out the box already! We are not talking about the lemmings who use windows or even the weekend linuxers here. If they are using UNIX then there is no need for "hand holding". > , which requires a whole mess of crap > in term, plus swig, plus whatever else I may or may not be missing. Thats quite an exaggeration Adam. > I'm also not 100% certain as to whether it's as portable as Tk is > today. Wx is just as portable as Tk From rantingrick at gmail.com Wed Jan 19 00:49:16 2011 From: rantingrick at gmail.com (rantingrick) Date: Tue, 18 Jan 2011 21:49:16 -0800 (PST) Subject: newby qn about functions References: Message-ID: On Jan 18, 12:01?pm, "Joe Goldthwaite" wrote: > I'm not sure I understand the question completely but maybe the function > below does what you want. > > def lower_case(s): > > ? ? return ?Testing Functions-lower case: ? + s.lower() > > print lower_case(?AbCdEfG?) > > ________________________________________ > From: python-list-bounces+joe=goldthwaites.... at python.org > [mailto:python-list-bounces+joe=goldthwaites.... at python.org] On Behalf Of > Cathy James > Sent: Tuesday, January 18, 2011 3:02 AM > To: python-l... at python.org > Subject: newby qn about functions > > #This has to be very simple, but I don't get it-please help > ? > def > lower_case(s): > ??? #return s > ??? print(s) > ??? #return s.lower() > ??? print(s.lower()) > s= > "Testing?Functions-lower case: " > lower_case(s) > """how can i use a return statement? to write a function that returns the > string "Testing?Functions-lower case: "and the lowercase representation of > its string parameter""" If I uncomment the above, nothing outputs to > console:( > ? > Much appreciation as always. Please don't top post as it gets very confusing to follow especially when you did not follow proper quoting standards by using the preferred quote prefix of ">". Have a look at this wiki article for more information... http://en.wikipedia.org/wiki/Posting_style Thanks From kianseong.low at logisticsconsulting.asia Wed Jan 19 01:02:42 2011 From: kianseong.low at logisticsconsulting.asia (low kian seong) Date: Wed, 19 Jan 2011 14:02:42 +0800 Subject: [rotatingloghandler]: How to read the logs produced ? Message-ID: Dear people, I am currently using concurrentrotatingfilehandler to handle my Python logs. The situation is okay when it's only one log, but when it needs to spill over to the next log (I configured to have 2) say test.log.2 then I see that the output is sort of shared between the first log test.log and test.log.2. Am I supposed to concatenate all the logs together to get my logs back ? Google hasn't brought back any results, so I am wondering is it just me using or reading the resultant logs wrong? Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From debatem1 at gmail.com Wed Jan 19 01:04:17 2011 From: debatem1 at gmail.com (geremy condra) Date: Tue, 18 Jan 2011 22:04:17 -0800 Subject: move to end, in Python 3.2 Really? In-Reply-To: References: <58c17709-d68e-4448-b618-b6f594d0e8c5@t35g2000yqj.googlegroups.com> <125db7fe-036e-47c9-be89-50f05106936f@n2g2000pre.googlegroups.com> Message-ID: On Tue, Jan 18, 2011 at 3:54 PM, rantingrick wrote: > > And were the hell is Steve Holden? Why has he not weighed in on these > (or any) discussions. He (Steve Holden) is second in command to the > entire community. Yet we have yet to hear a peep from this fella. What > gives Steve? > > And if Steve is too busy, who is next in the chain of command? Who is > going to take responsibility for this catastrophe we call c.l.py? Is > there no one is man enough to step up for this community? Are all of > our leaders just sticking their heads in the sand hoping for this to > "solve" itself? There's no chain of command here, genius. It's a mailing list. Geremy Condra From orasnita at gmail.com Wed Jan 19 01:10:28 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Wed, 19 Jan 2011 08:10:28 +0200 Subject: [OT] Python like lanugages [was Re: After C++, what with Python?] References: <86a904f8-05b0-435f-81d6-7450650f1679@glegroupsg2000goo.googlegroups.com><4d329899$0$43988$742ec2ed@news.sonic.net><7x8vylfcvz.fsf@ruckus.brouhaha.com> <4d32c7cf$0$29983$c3e8da3$5496439d@news.astraweb.com><4d35a769$0$2258$a729d347@news.telepac.pt> Message-ID: <503D269987294E7A95D87C488F37BB25@octavian> From: "Tim Harig" > On 2011-01-18, Terry Reedy wrote: >> On 1/18/2011 10:30 AM, Tim Harig wrote: >> >>> Whether or not you actually agree with that economic reality is >>> irrelevant. Those who fund commerical projects do; and, any >>> developement >>> tool which violates the security of the source is going to find itself >>> climbing an uphill battle in trying to gain market penetration with >>> commericial software producers. >> >> Of course. When I submit or commit patches, I am doing it mostly for >> hobby, educational, and scientific users, and maybe website makers (who >> make site I can visit). If commercial users piggyback on top, ok. I do >> not know how many developers, if any, are after such market penetration. > > You kind of over-extended the intentions of my comment. It does not apply > to open source software in general. I agree that open source authors are > not interested in the quantitative value of market penetration. However, > I > am betting that most authors of developement tools would like to be able > to > use their tools on the job. > > I am sure that more software developers would love to develop using > Python as part of their job. For some this is a reality; but, many more > are stuck using their employer's choice of language. One of the factors > that employers consider, when they choose a language, if they produce > retail software is that the process of compiling will sufficiently > obfiscate their code. > -- True. But aren't the Pyton bytecode-compiled files considered secure enough? Can they be easily decompiled? Octavian From orasnita at gmail.com Wed Jan 19 01:20:40 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Wed, 19 Jan 2011 08:20:40 +0200 Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com><4d337983$0$29983$c3e8da3$5496439d@news.astraweb.com><044a5101-948d-4458-9c94-57dbb3e25f67@m35g2000vbn.googlegroups.com><4d3467bf$0$29983$c3e8da3$5496439d@news.astraweb.com> <4D34B04E.8050309@web.de><4266E8D7BA204BFEA5BF66C635CE1716@octavian><4D35DCE8.5030002@web.de> <4D35DD47.1070304@web.de><7A0C7934E65D4B85A584C06ADD3B6ECF@teddy> <4D360526.7070706@web.de> Message-ID: From: "Alexander Kapps" >> I didn't say that a GUI lib is useless. The GUIS that create >> discrimination by offering access only for some users (when there are >> other GUIS that can offer access to everyone) create damage and they >> should be avoided, and for avoiding them, the beginners need to >> understand this. But Python promotes that bad GUI lib by including it in >> the default package instead of promoting a better lib. > > Please read your previous post. Anyway *which* GUI offers access to > everyone? You are right. There are probably no GUIs that offer access to everyone, no matter the language they speak, their health problems or the platforms they use, but what I want to say is that those GUIS that offer access to as many people as possible are those that should be promoted, not those who discriminate people without even wanting to do this. Octavian From orasnita at gmail.com Wed Jan 19 01:29:49 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Wed, 19 Jan 2011 08:29:49 +0200 Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <0fa4603c-6e27-4ee5-9761-000a61cd19a4@fx12g2000vbb.googlegroups.com> <2510bf88-1045-411f-9ccd-7ca7c3665454@l24g2000vby.googlegroups.com> <2ef2fa6c-2ccf-453a-8f50-0ef7dbd7834d@j32g2000yqc.googlegroups.com> <5c6ff40f-05c1-4e38-89bc-b8c4745db7ce@i18g2000yqn.googlegroups.com> <34c3bae6-369f-427c-a28f-90ac53dea8f5@v17g2000vbo.googlegroups.com> <4D366A0E.1050903@aim.com> Message-ID: <41A6B56828FC467B8CA2703B2A33E920@octavian> From: "Corey Richardson" > On 01/18/2011 11:15 PM, rantingrick wrote: >> On Jan 18, 10:10 pm, Corey Richardson wrote: >> >>> That is a pretty large dependency to rely on, and it is rather >>> undesirable IMO. >> >> And what exactly is undesirable? Unless you actually back up your >> statements with fact they just ring hallow. Can you offer any specific >> reasons why wx is a bad choice. And more importantly can you offer any >> viable alternatives? > > Go ahead and read Adam's fine post about the dependencies of wxwidgets. > As for alternatives? I think Tkinter is fine for most of my purposes. > When I need something else, I use PyQt. I can install python-minimal on > Windows/Linux/What-have-you and know that Tkinter will run without > needing GTK+ and SWIG, as Adam mentioned. If you want to get something > done, here's an idea - do it yourself. That's what OS is all about. > Don't just write something, implement it. If the folks over in > python-dev want nothing to do with it, that's fine - make a package > using your minimal wxpython version, I'm sure people will use it, > especially if you make it as easy to use as Tkinter. I don't think this is what we are talking about on this thread. If any Python programmer wants to use WxPython because it is better than Tkinter, then he/she can use it without any problem. I think we are talking about the GUI lib included in Python, the GUI which is promoted by Python. This GUI should be one which is better from the users' perspective, which is accessible for as many users as possible because the GUI that's promoted by Python is very important for the beginners. If you or someone else wants to create a stripped-down application which doesn't offer so many features then it wouldn't be any problem to get Tkinter and use it, but the beginners shouldn't learn first to use a GUI lib like Tkinter. Octavian From orasnita at gmail.com Wed Jan 19 01:37:02 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Wed, 19 Jan 2011 08:37:02 +0200 Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com><4d337983$0$29983$c3e8da3$5496439d@news.astraweb.com><044a5101-948d-4458-9c94-57dbb3e25f67@m35g2000vbn.googlegroups.com><4d3467bf$0$29983$c3e8da3$5496439d@news.astraweb.com> <4D34B04E.8050309@web.de><4266E8D7BA204BFEA5BF66C635CE1716@octavian><4D35DCE8.5030002@web.de> <4D35DD47.1070304@web.de><7A0C7934E65D4B85A584C06ADD3B6ECF@teddy> Message-ID: <410E9EB9AF154FE6AF31742FD1093E96@octavian> From: "Terry Reedy" > On 1/18/2011 3:23 PM, Octavian Rasnita wrote: > >> I am talking about the fact that Python promotes Tkinter > > Python uses tkinter as the only choice available for the stdlib. > Others choices not in the stdlib are available for those who want > something better. The users shouldn't want something better. Everyone should create GUIs which are accessible for everyone by default, without making any special effort for doing this. The programmers should make special efforts for making GUIS which are not accessible for as many users as possible if they want this but this way shouldn't be promoted by Python. >> TK are not accessible for screen readers, > > I did not know that. Most of the programmers don't know that and they don't even need to know that, but if a lib that create accessible GUIS would be promoted, most of the Python programmers would use that lib and would create good apps by default, without even knowing this. On the other hand, if they started to learn to create a bad GUI, of course that after that they will think that a supplemental effort is necessary for creating good GUIS with another lib and they won't like it. Octavian From mukunda.lohani2 at gmail.com Wed Jan 19 01:38:55 2011 From: mukunda.lohani2 at gmail.com (Mukunda Lohani) Date: Tue, 18 Jan 2011 22:38:55 -0800 (PST) Subject: Standard Abroad Study Programs Message-ID: Don't forget to click on the website:www.abroadstudy4all.weebly.com This website will provide you the most important information about the universal abroad study plan and counseling and the worldwide top universities and colleges. Furthermore, It will also give you the most reliable message about GWC and the right way to join to study abroad. Major Specialties of this Website: Abroad Study as a student Pursuing educational opportunity in another country Top Universities of USA Universities of Europe GWC-Online Job From orasnita at gmail.com Wed Jan 19 01:39:48 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Wed, 19 Jan 2011 08:39:48 +0200 Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com>9-4a9f-b0e7-54bb681a6ea0@l8g2000yqh.googlegrouppppppp<4d337983$0$29983$c3e8da3$5496439d@news.astraweb.com><044a5101-948d-4458-9c94-57dbb3e25f67@m35g2000vbn.googlegroups.com><4d3467bf$0$29983$c3e8da3$5496439d@news.astraweb.com> <4D34B04E.8050309@web.de><4266E8D7BA204BFEA5BF66C635CE1716@octavian><4D35DCE8.5030002@web.de> <495ABC6A7F6C48A1BBCC32F181E5C4F0@teddy> Message-ID: From: "Terry Reedy" > On 1/18/2011 3:29 PM, Octavian Rasnita wrote: > >> Is there any other solution for the problem that Python promotes this >> bad GUI than removing it from the default package? > > I am generally for better accessibility, but I consider the notion that if > everyone cannot have something, then no one should, to be rather > pernicious. Of course. I have the same opinion. But if using WxPython everyone can have access and that's why I think it should be promoted. wxWIDGETS lib is not perfect but it is much better for more categories of users... Octavian From timr at probo.com Wed Jan 19 02:21:14 2011 From: timr at probo.com (Tim Roberts) Date: Tue, 18 Jan 2011 23:21:14 -0800 Subject: UTF-8 question from Dive into Python 3 References: Message-ID: Tim Harig wrote: >On 2011-01-17, carlo wrote: > >> 2- If that were true, can you point me to some documentation about the >> math that, as Mark says, demonstrates this? > >It is true because UTF-8 is essentially an 8 bit encoding that resorts >to the next bit once it exhausts the addressible space of the current >byte it moves to the next one. Since the bytes are accessed and assessed >sequentially, they must be in big-endian order. You were doing excellently up to that last phrase. Endianness only applies when you treat a series of bytes as a larger entity. That doesn't apply to UTF-8. None of the bytes is more "significant" than any other, so by definition it is neither big-endian or little-endian. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From clp2 at rebertia.com Wed Jan 19 02:25:04 2011 From: clp2 at rebertia.com (Chris Rebert) Date: Tue, 18 Jan 2011 23:25:04 -0800 Subject: [rotatingloghandler]: How to read the logs produced ? In-Reply-To: References: Message-ID: On Tue, Jan 18, 2011 at 10:02 PM, low kian seong wrote: > Dear people, > I am currently using concurrentrotatingfilehandler to handle my Python logs. > The situation is okay when it's only one log, but when it needs to spill > over to the next log (I configured to have 2) say test.log.2 then I see that > the output is sort of shared between the first log test.log and test.log.2. > Am I supposed to concatenate all the logs together to get my logs back ? > Google hasn't brought back any results, so I am wondering is it just me > using or reading the resultant logs wrong? Since this is apparently a 3rd-party library (http://pypi.python.org/pypi/ConcurrentLogHandler/ ), have you tried asking the maintainer? (Who is evidently Lowell Alleman .) Could very well be a bug. Cheers, Chris -- http://blog.rebertia.com From kianseong.low at lcalink.com Wed Jan 19 02:27:43 2011 From: kianseong.low at lcalink.com (Low Kian Seong) Date: Wed, 19 Jan 2011 15:27:43 +0800 Subject: [rotatingloghandler]: How to read the logs produced ? In-Reply-To: References: Message-ID: <091CCA9C-13DC-4235-8456-749B2E6269E7@lcalink.com> (iphone) On Jan 19, 2011, at 3:25 PM, Chris Rebert wrote: > On Tue, Jan 18, 2011 at 10:02 PM, low kian seong > wrote: >> Dear people, >> I am currently using concurrentrotatingfilehandler to handle my Python logs. >> The situation is okay when it's only one log, but when it needs to spill >> over to the next log (I configured to have 2) say test.log.2 then I see that >> the output is sort of shared between the first log test.log and test.log.2. >> Am I supposed to concatenate all the logs together to get my logs back ? >> Google hasn't brought back any results, so I am wondering is it just me >> using or reading the resultant logs wrong? > > Since this is apparently a 3rd-party library > (http://pypi.python.org/pypi/ConcurrentLogHandler/ ), have you tried > asking the maintainer? (Who is evidently Lowell Alleman at_sign gmail period com>.) Could very well be a bug. > > Cheers, > Chris Actually the default concurrent log handler produces similar results. > -- > http://blog.rebertia.com From sliwinski at red-sky.pl Wed Jan 19 02:31:17 2011 From: sliwinski at red-sky.pl (=?ISO-8859-2?Q?Grzegorz_=A6liwi=F1ski?=) Date: Tue, 18 Jan 2011 23:31:17 -0800 (PST) Subject: Python unicode utf-8 characters and MySQL unicode utf-8 characters References: <1914ba89-7ecc-43d5-8fbc-9a45f27ae8c8@z5g2000yqb.googlegroups.com> Message-ID: On 18 Sty, 18:15, Kushal Kumaran wrote: > 2011/1/18 Grzegorz ?liwi?ski : > > > Hello, > > Recently I tried to insert some unicode object in utf-8 encoding into > > MySQL using MySQLdb, and got MySQL warnings on characters like: > > ???? i found somewhere in my data. I can't even read them. MySQL > > seems to cut the whole string after that characters off, so I get > > incomplete data. > > After a little bit of digging I found out, that MySQL usually supports > > utf-8 data but encoded into maximum three bytes. That's why I think it > > would help I f I was able to replace all larger unicode characters > > with replacement characters. > > > Is there any way, I could adjust python unicode utf-8 encoded strings > > to be accepted by mysql utf-8 columns? > > Did you pass the charset argument when creating your MySQLdb connection? > > -- > regards, > kushal Hello, yes, although I usually just use SET NAMES utf8; after encountering the problem first, I tried the charset option as well, but there's no difference. From clp2 at rebertia.com Wed Jan 19 02:45:36 2011 From: clp2 at rebertia.com (Chris Rebert) Date: Tue, 18 Jan 2011 23:45:36 -0800 Subject: [rotatingloghandler]: How to read the logs produced ? In-Reply-To: <091CCA9C-13DC-4235-8456-749B2E6269E7@lcalink.com> References: <091CCA9C-13DC-4235-8456-749B2E6269E7@lcalink.com> Message-ID: On Tue, Jan 18, 2011 at 11:27 PM, Low Kian Seong wrote: > On Jan 19, 2011, at 3:25 PM, Chris Rebert wrote: >> On Tue, Jan 18, 2011 at 10:02 PM, low kian seong >> wrote: >>> Dear people, >>> I am currently using concurrentrotatingfilehandler to handle my Python logs. >>> The situation is okay when it's only one log, but when it needs to spill >>> over to the next log (I configured to have 2) say test.log.2 then I see that >>> the output is sort of shared between the first log test.log and test.log.2. >>> Am I supposed to concatenate all the logs together to get my logs back ? >>> Google hasn't brought back any results, so I am wondering is it just me >>> using or reading the resultant logs wrong? >> >> Since this is apparently a 3rd-party library >> (http://pypi.python.org/pypi/ConcurrentLogHandler/ ), have you tried >> asking the maintainer? (Who is evidently Lowell Alleman > at_sign gmail period com>.) Could very well be a bug. >> > Actually the default concurrent log handler produces similar results. That wouldn't be particularly surprising: "15.7.10. Logging to a single file from multiple processes Although logging is thread-safe, and logging to a single file from multiple threads in a single process is supported, logging to a single file from multiple processes is **not** supported [...]" -- http://docs.python.org/library/logging.html Cheers, Chris From michael.ricordeau at gmail.com Wed Jan 19 03:06:58 2011 From: michael.ricordeau at gmail.com (Michael Ricordeau) Date: Wed, 19 Jan 2011 09:06:58 +0100 Subject: [rotatingloghandler]: How to read the logs produced ? In-Reply-To: References: <091CCA9C-13DC-4235-8456-749B2E6269E7@lcalink.com> Message-ID: <20110119090658.678f8bb6@moriz.interne> I suggest SyslogHandler in logging package to centralize all logs . http://docs.python.org/library/logging.html#sysloghandler In my opinion, rotating, parsing, filtering logs is a different task (for a sysadmin not a developper). I'm doing this for all my projects at work : - using SyslogHandler for logging application servers - using one syslog server to get all logs from application servers Le Tue, 18 Jan 2011 23:45:36 -0800, Chris Rebert a ?crit : > On Tue, Jan 18, 2011 at 11:27 PM, Low Kian Seong > wrote: > > On Jan 19, 2011, at 3:25 PM, Chris Rebert wrote: > >> On Tue, Jan 18, 2011 at 10:02 PM, low kian seong > >> wrote: > >>> Dear people, > >>> I am currently using concurrentrotatingfilehandler to handle my Python logs. > >>> The situation is okay when it's only one log, but when it needs to spill > >>> over to the next log (I configured to have 2) say test.log.2 then I see that > >>> the output is sort of shared between the first log test.log and test.log.2. > >>> Am I supposed to concatenate all the logs together to get my logs back ? > >>> Google hasn't brought back any results, so I am wondering is it just me > >>> using or reading the resultant logs wrong? > >> > >> Since this is apparently a 3rd-party library > >> (http://pypi.python.org/pypi/ConcurrentLogHandler/ ), have you tried > >> asking the maintainer? (Who is evidently Lowell Alleman >> at_sign gmail period com>.) Could very well be a bug. > >> > > Actually the default concurrent log handler produces similar results. > > That wouldn't be particularly surprising: > > "15.7.10. Logging to a single file from multiple processes > > Although logging is thread-safe, and logging to a single file from > multiple threads in a single process is supported, logging to a single > file from multiple processes is **not** supported [...]" > -- http://docs.python.org/library/logging.html > > Cheers, > Chris From stefan_ml at behnel.de Wed Jan 19 03:21:38 2011 From: stefan_ml at behnel.de (Stefan Behnel) Date: Wed, 19 Jan 2011 09:21:38 +0100 Subject: [OT] Python like lanugages [was Re: After C++, what with Python?] In-Reply-To: <503D269987294E7A95D87C488F37BB25@octavian> References: <86a904f8-05b0-435f-81d6-7450650f1679@glegroupsg2000goo.googlegroups.com><4d329899$0$43988$742ec2ed@news.sonic.net><7x8vylfcvz.fsf@ruckus.brouhaha.com> <4d32c7cf$0$29983$c3e8da3$5496439d@news.astraweb.com><4d35a769$0$2258$a729d347@news.telepac.pt> <503D269987294E7A95D87C488F37BB25@octavian> Message-ID: Octavian Rasnita, 19.01.2011 07:10: > aren't the Pyton bytecode-compiled files considered secure enough? > Can they be easily decompiled? Yes. Stefan From okopnik at gmail.com Wed Jan 19 03:30:43 2011 From: okopnik at gmail.com (=?UTF-8?B?SOKCgjAucHk=?=) Date: Wed, 19 Jan 2011 00:30:43 -0800 (PST) Subject: __pycache__, one more good reason to stck with Python 2? References: <23e02e0d-b2f1-4b52-85ea-d1feba99dd37@22g2000prx.googlegroups.com> <4d3466d3$0$29983$c3e8da3$5496439d@news.astraweb.com> <0c62aacd-e6d2-4778-81d6-e06924192add@j1g2000vbl.googlegroups.com> <77ef8068-7f07-404f-8b0e-c039d1122659@e16g2000pri.googlegroups.com> Message-ID: <69fa24fc-b3de-4099-a99c-7fd6be50ba64@d8g2000yqf.googlegroups.com> On Jan 18, 4:04?am, Peter Otten <__pete... at web.de> wrote: > > What's the advantage of 'find ... | xargs ...' over 'find ... -exec ...'? Portability. Running the '-exec' version will work fine in a directory with a relatively small number of files, but will fail on a large one. 'xargs', which is designed to handle exactly that situations, splits the returned output into chunks that can be handled by 'rm' and such. '|xargs' is always the preferred option when you don't know how large the output is going to be. From orasnita at gmail.com Wed Jan 19 05:31:27 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Wed, 19 Jan 2011 12:31:27 +0200 Subject: [OT] Python like lanugages [was Re: After C++, what with Python?] References: <86a904f8-05b0-435f-81d6-7450650f1679@glegroupsg2000goo.googlegroups.com><4d329899$0$43988$742ec2ed@news.sonic.net><7x8vylfcvz.fsf@ruckus.brouhaha.com> <4d32c7cf$0$29983$c3e8da3$5496439d@news.astraweb.com><4d35a769$0$2258$a729d347@news.telepac.pt> <503D269987294E7A95D87C488F37BB25@octavian> Message-ID: <828053EDBB174148B9895ADD5B9A0780@octavian> From: "Stefan Behnel" > Octavian Rasnita, 19.01.2011 07:10: >> aren't the Pyton bytecode-compiled files considered secure enough? >> Can they be easily decompiled? > > Yes. > > Stefan > Would it be hard to introduce the possibility of adding encryption of the bytecode similar to what the Zend encoder does for PHP or Filter::Crypto for Perl? Octavian From stefan_ml at behnel.de Wed Jan 19 05:41:16 2011 From: stefan_ml at behnel.de (Stefan Behnel) Date: Wed, 19 Jan 2011 11:41:16 +0100 Subject: [OT] Python like lanugages [was Re: After C++, what with Python?] In-Reply-To: <828053EDBB174148B9895ADD5B9A0780@octavian> References: <86a904f8-05b0-435f-81d6-7450650f1679@glegroupsg2000goo.googlegroups.com><4d329899$0$43988$742ec2ed@news.sonic.net><7x8vylfcvz.fsf@ruckus.brouhaha.com> <4d32c7cf$0$29983$c3e8da3$5496439d@news.astraweb.com><4d35a769$0$2258$a729d347@news.telepac.pt> <503D269987294E7A95D87C488F37BB25@octavian> <828053EDBB174148B9895ADD5B9A0780@octavian> Message-ID: Octavian Rasnita, 19.01.2011 11:31: > From: "Stefan Behnel" >> Octavian Rasnita, 19.01.2011 07:10: >>> aren't the Pyton bytecode-compiled files considered secure enough? >>> Can they be easily decompiled? >> >> Yes. FYI, just take a look at the 'dis' module. There are also decompilers available. IIRC, one is called "decompyle". > Would it be hard to introduce the possibility of adding encryption of the > bytecode similar to what the Zend encoder does for PHP or Filter::Crypto > for Perl? You can use an import hook to do anything you like. That includes decrypting a file and extracting a normal .pyc from it that can then be imported. However, that won't prevent users from inspecting the code at runtime if they get a handle at it (which they likely will if they try). Stefan From usernet at ilthio.net Wed Jan 19 06:34:53 2011 From: usernet at ilthio.net (Tim Harig) Date: Wed, 19 Jan 2011 11:34:53 +0000 (UTC) Subject: UTF-8 question from Dive into Python 3 References: Message-ID: On 2011-01-19, Tim Roberts wrote: > Tim Harig wrote: >>On 2011-01-17, carlo wrote: >> >>> 2- If that were true, can you point me to some documentation about the >>> math that, as Mark says, demonstrates this? >> >>It is true because UTF-8 is essentially an 8 bit encoding that resorts >>to the next bit once it exhausts the addressible space of the current >>byte it moves to the next one. Since the bytes are accessed and assessed >>sequentially, they must be in big-endian order. > > You were doing excellently up to that last phrase. Endianness only applies > when you treat a series of bytes as a larger entity. That doesn't apply to > UTF-8. None of the bytes is more "significant" than any other, so by > definition it is neither big-endian or little-endian. It depends how you process it and it doesn't generally make much difference in Python. Accessing UTF-8 data from C can be much trickier if you use a multibyte type to store the data. In that case, if happen to be on a little-endian architecture, it may be necessary to remember that the data is not in the order that your processor expects it to be for numeric operations and comparisons. That is why the FAQ I linked to says yes to the fact that you can consider UTF-8 to always be in big-endian order. Essentially all byte based data is big-endian. From askutt at gmail.com Wed Jan 19 07:25:59 2011 From: askutt at gmail.com (Adam Skutt) Date: Wed, 19 Jan 2011 04:25:59 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com><4d337983$0$29983$c3e8da3$5496439d@news.astraweb.com><044a5101-948d-4458-9c94-57dbb3e25f67@m35g2000vbn.googlegroups.com><4d3467bf$0$29983$c3e8da3$5496439d@news.astraweb.com> <4D34B04E.8050309@web.de><4266E8D7BA204BFEA5BF66C635CE1716@octavian><4D35DCE8.5030002@web.de> <4D35DD47.1070304@web.de> Message-ID: <42924000-3ffb-40f5-9cf8-70a9d767b944@k25g2000vbl.googlegroups.com> On Jan 18, 3:23?pm, "Octavian Rasnita" wrote: > From: "Alexander Kapps" > > > Tkinter causes damage? Very bad damage? What are you talking about? > > I am talking about the fact that Python promotes Tkinter, and many beginners will start using it, and they will start creating applications with it, and they will learn to use it better than WxPython, and they will start believing that Tkinter is better because it is easier to use than WxPython, so they will start convincing others that Tkinter is the best, and they will start finding many reasons that show that Tkinter is better. And after this, they will say that they don't care about the real problems generated by GUIs like Tk. > And a very big problem is that the applications that use Tk/GTK are not accessible for screen readers, so those applications will be just blank for people with visual impairments which need to use a screen reader. If you want functional accessibility support, you're going to have to write it in Python yourself, and get the accessibility manufacturers to support it. All of the cross-platform toolkits have poor to non- existent accessibility support. Accessibility issues aren't going to be fixed by going to a different GUI toolkit in the standard library. The alternative is to fix the accessibility support issues in the underlying library, and Tk is no less amenable to that than wxWidgets. If that's what you want, start coding then. You have a long climb ahead of you. Accessibility will never be a particular good argument for switching toolkits. All of the cross-platform offerings with Python bindings are far too broken to be even remotely interesting. > Why do we like the portable GUIS and don't really like the native interfaces that don't work on other platforms? > Because we want our programs to be usable by as many people as possible. Well, some platforms render the output as sound and Tkinter are not "portable" on those platforms (screen readers). Or we have cross-platform support as a requirement and no desire to develop the GUI interface three times over. Hence the continued popularity of Java GUIs. Adam From askutt at gmail.com Wed Jan 19 07:28:05 2011 From: askutt at gmail.com (Adam Skutt) Date: Wed, 19 Jan 2011 04:28:05 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com><4d337983$0$29983$c3e8da3$5496439d@news.astraweb.com><044a5101-948d-4458-9c94-57dbb3e25f67@m35g2000vbn.googlegroups.com><4d3467bf$0$29983$c3e8da3$5496439d@news.astraweb.com> <4D34B04E.8050309@web.de><4266E8D7BA204BFEA5BF66C635CE1716@octavian><4D35DCE8.5030002@web.de> <4D35DD47.1070304@web.de><7A0C7934E65D4B85A584C06ADD3B6ECF@teddy> Message-ID: On Jan 19, 1:37?am, "Octavian Rasnita" wrote: > > The users shouldn't want something better. Everyone should create GUIs which > are accessible for everyone by default, without making any special effort > for doing this. Accessibility always requires special effort, and I don't see how changing toolkits gets away from this. Adam From askutt at gmail.com Wed Jan 19 07:31:33 2011 From: askutt at gmail.com (Adam Skutt) Date: Wed, 19 Jan 2011 04:31:33 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com><4d337983$0$29983$c3e8da3$5496439d@news.astraweb.com><044a5101-948d-4458-9c94-57dbb3e25f67@m35g2000vbn.googlegroups.com><4d3467bf$0$29983$c3e8da3$5496439d@news.astraweb.com> <4D34B04E.8050309@web.de><4266E8D7BA204BFEA5BF66C635CE1716@octavian><4D35DCE8.5030002@web.de> <4D35DD47.1070304@web.de><7A0C7934E65D4B85A584C06ADD3B6ECF@teddy> Message-ID: On Jan 19, 1:37?am, "Octavian Rasnita" wrote: > > Most of the programmers don't know that and they don't even need to know > that, but if a lib that create accessible GUIS would be promoted, most of > the Python programmers would use that lib and would create good apps by > default, without even knowing this. Have you written an accessible application in any toolkit whatsoever? It is not magic, and it does not happen by default, even when solely using the standard widgets. Adam From solipsis at pitrou.net Wed Jan 19 07:34:56 2011 From: solipsis at pitrou.net (Antoine Pitrou) Date: Wed, 19 Jan 2011 13:34:56 +0100 Subject: UTF-8 question from Dive into Python 3 References: Message-ID: <20110119133456.2389ed94@pitrou.net> On Wed, 19 Jan 2011 11:34:53 +0000 (UTC) Tim Harig wrote: > That is why the FAQ I linked to > says yes to the fact that you can consider UTF-8 to always be in big-endian > order. It certainly doesn't. Read better. > Essentially all byte based data is big-endian. This is pure nonsense. From usernet at ilthio.net Wed Jan 19 09:00:13 2011 From: usernet at ilthio.net (Tim Harig) Date: Wed, 19 Jan 2011 14:00:13 +0000 (UTC) Subject: UTF-8 question from Dive into Python 3 References: Message-ID: Considering you post contained no information or evidence for your negations, I shouldn't even bother responding. I will bite once. Hopefully next time your arguments will contain some pith. On 2011-01-19, Antoine Pitrou wrote: > On Wed, 19 Jan 2011 11:34:53 +0000 (UTC) > Tim Harig wrote: >> That is why the FAQ I linked to >> says yes to the fact that you can consider UTF-8 to always be in big-endian >> order. > > It certainly doesn't. Read better. - Q: Can a UTF-8 data stream contain the BOM character (in UTF-8 form)? If - yes, then can I still assume the remaining UTF-8 bytes are in big-endian ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - order? ^^^^^^ - - A: Yes, UTF-8 can contain a BOM. However, it makes no difference as ^^^ - to the endianness of the byte stream. UTF-8 always has the same byte ^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - order. An initial BOM is only used as a signature -- an indication that ^^^^^^ - an otherwise unmarked text file is in UTF-8. Note that some recipients of - UTF-8 encoded data do not expect a BOM. Where UTF-8 is used transparently - in 8-bit environments, the use of a BOM will interfere with any protocol - or file format that expects specific ASCII characters at the beginning, - such as the use of "#!" of at the beginning of Unix shell scripts. The question that was not addressed was whether you can consider UTF-8 to be little endian. I pointed out why you cannot always make that assumption in my previous post. UTF-8 has no apparent endianess if you only store it as a byte stream. It does however have a byte order. If you store it using multibytes (six bytes for all UTF-8 possibilites) , which is useful if you want to have one storage container for each letter as opposed to one for each byte(1), the bytes will still have the same order but you have interrupted its sole existance as a byte stream and have returned it to the underlying multibyte oriented representation. If you attempt any numeric or binary operations on what is now a multibyte sequence, the processor will interpret the data using its own endian rules. If your processor is big-endian, then you don't have any problems. The processor will interpret the data in the order that it is stored. If your processor is little endian, then it will effectively change the order of the bytes for its own evaluation. So, you can always assume a big-endian and things will work out correctly while you cannot always make the same assumption as little endian without potential issues. The same holds true for any byte stream data. That is why I say that byte streams are essentially big endian. It is all a matter of how you look at it. I prefer to look at all data as endian even if it doesn't create endian issues because it forces me to consider any endian issues that might arise. If none do, I haven't really lost anything. If you simply assume that any byte sequence cannot have endian issues you ignore the possibility that such issues might not arise. When an issue like the above does, you end up with a potential bug. (1) For unicode it is probably better to convert to characters to UTF-32/UCS-4 for internal processing; but, creating a container large enough to hold any length of UTF-8 character will work. From mark at markroseman.com Wed Jan 19 09:32:45 2011 From: mark at markroseman.com (Mark Roseman) Date: Wed, 19 Jan 2011 07:32:45 -0700 Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <4d337983$0$29983$c3e8da3$5496439d@news.astraweb.com> <044a5101-948d-4458-9c94-57dbb3e25f67@m35g2000vbn.googlegroups.com> <4d3467bf$0$29983$c3e8da3$5496439d@news.astraweb.com> <4D34B04E.8050309@web.de> <4266E8D7BA204BFEA5BF66C635CE1716@octavian> <4D35DCE8.5030002@web.de> Message-ID: Octavian, Thank you for clearly articulating your concern that Tk does not provide any support for screen readers. While I believe that people can have legitimate differences of opinion as to whether this merits its removal/replacement from stdlib, there is no question that this is a serious and significant limitation of Tk. I will attempt to find out if there has been any work done in this area with Tk, and what it would take to address this important issue. Thanks again Mark From solipsis at pitrou.net Wed Jan 19 09:41:00 2011 From: solipsis at pitrou.net (Antoine Pitrou) Date: Wed, 19 Jan 2011 15:41:00 +0100 Subject: UTF-8 question from Dive into Python 3 References: Message-ID: <20110119154100.2f3bbdda@pitrou.net> On Wed, 19 Jan 2011 14:00:13 +0000 (UTC) Tim Harig wrote: > > - Q: Can a UTF-8 data stream contain the BOM character (in UTF-8 form)? If > - yes, then can I still assume the remaining UTF-8 bytes are in big-endian > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ > - order? > ^^^^^^ > - > - A: Yes, UTF-8 can contain a BOM. However, it makes no difference as > ^^^ > - to the endianness of the byte stream. UTF-8 always has the same byte > ^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ > - order. > ^^^^^^ Which certainly doesn't mean that byte order can be called "big endian" for any recognized definition of the latter. Similarly, ASCII test has its own order which certainly can't be characterized as either "little endian" or "big endian". > UTF-8 has no apparent endianess if you only store it as a byte stream. > It does however have a byte order. If you store it using multibytes > (six bytes for all UTF-8 possibilites) , which is useful if you want > to have one storage container for each letter as opposed to one for > each byte(1) That's a ridiculous proposition. Why would you waste so much space? UTF-8 exists *precisely* so that you can save space with most scripts. If you are ready to use 4+ bytes per character, just use UTF-32 which has much nicer properties. Bottom line: you are not describing UTF-8, only your own foolish interpretation of it. UTF-8 does not have any endianness since it is a byte stream and does not care about "machine words". Antoine. From steve+comp.lang.python at pearwood.info Wed Jan 19 09:42:14 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 19 Jan 2011 14:42:14 GMT Subject: __pycache__, one more good reason to stck with Python 2? References: <23e02e0d-b2f1-4b52-85ea-d1feba99dd37@22g2000prx.googlegroups.com> <4d3466d3$0$29983$c3e8da3$5496439d@news.astraweb.com> <0c62aacd-e6d2-4778-81d6-e06924192add@j1g2000vbl.googlegroups.com> <87vd1m6ezq.fsf@benfinney.id.au> <992b11a0-d35d-4b08-98ab-d08c90a86ec7@j1g2000vbl.googlegroups.com> Message-ID: <4d36f846$0$29983$c3e8da3$5496439d@news.astraweb.com> On Tue, 18 Jan 2011 00:58:14 -0800, jmfauth wrote: > It is now practically impossible to launch a Python application via a > .pyc file. When has that ever been possible? .pyc files are Python byte-code. You can't run them directly using Python (except via the import machinery), you can't run them as a script, they're not machine code. Unless you write a wrapper to import the file as a module, you can't directly execute .pyc files. > (For the fun, try to add the "parent directory" of a cached > file to the sys.path). I don't understand what you're getting at there. > About the caches, I'am just fearing, they will become finally garbage > collectors of orphan .pyc files, Python has seed/seeded(?). The .pyc > files may not be very pleasant, but at least you can use them and you > have that "feeling" of their existence. I my "computer experience", once > you start to cache/hide something for simplicity, the problems start. I will say that in general I'm not very happy with what seems like every second application creating huge disk caches in random locations. It's a PITA, and I wish they'd standardize on a single cache location, to make it easy to exclude them from backups, to sanitize the bred-crumbs and data trails applications leave, and so forth. But having said that, the __pycache__ idea isn't too bad. If you have this directory structure: ./module.py ./module.pyc and import module, the top-level .pyc file will continue to be used. If you delete module.py, leaving only the top-level .pyc, it will still continue to be used. That much hasn't changed. The only difference is if you start with only a .py file: ./module.py and import it, the cached version will be placed into __pycache__ instead. Unlike orphaned .pyc files in the top level, orphaned .pyc in the __pycache__ are considered stale and will be ignored. So they're safe to ignore, and safe to delete, at any time. Nothing is stopping you from moving the .pyc file into the top level and deleting the .py file, if you so desire. -- Steven From python at bdurham.com Wed Jan 19 09:53:40 2011 From: python at bdurham.com (python at bdurham.com) Date: Wed, 19 Jan 2011 09:53:40 -0500 Subject: Screen readers for Tkinter (was Re: Tkinter: The good, the bad, and the ugly!) In-Reply-To: References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com><4d337983$0$29983$c3e8da3$5496439d@news.astraweb.com><044a5101-948d-4458-9c94-57dbb3e25f67@m35g2000vbn.googlegroups.com><4d3467bf$0$29983$c3e8da3$5496439d@news.astraweb.com> <4D34B04E.8050309@web.de><4266E8D7BA204BFEA5BF66C635CE1716@octavian><4D35DCE8.5030002@web.de> Message-ID: <1295448820.26438.1416115629@webmail.messagingengine.com> Mark/Octavian, It sounds like Tka11y (spelled with the digit '1' vs. the letter 'L') addresses this problem for Linux users. According to its website, adding accessability support is as simple as changing one import statement. Details follow my signature. Malcolm Tka11y - Tk Accessibility http://tkinter.unpythonic.net/wiki/Tka11y Note: Currently, accessibility is only available via ATK <=> AT-SPI on Linux. Sorry, no Windows MSAA support. Download http://pypi.python.org/pypi/Tka11y A modification to Tkinter to make widgets visible to the AT-SPI layer so that tools like dogtail and Accerciser can see them. Tka11y uses Papi, the Python Accessibility Programming Interface, which in turn uses ATK, the GNOME Accessibility Toolkit, to expose Tkinter widgets to AT-SPI, the Assistive Technologies Service Provider Interface. This allows a Tkinter application's widgets to be viewed and/or controlled by a variety of assistive technologies such as Orca and Accerciser, and automated GUI testing tools such as dogtail and LDTP. These client tools usually use either cspi (C) or pyatspi (Python). Typical usage: import Tka11y as Tkinter or from Tka11y import * From solipsis at pitrou.net Wed Jan 19 10:00:20 2011 From: solipsis at pitrou.net (Antoine Pitrou) Date: Wed, 19 Jan 2011 16:00:20 +0100 Subject: __pycache__, one more good reason to stck with Python 2? References: <23e02e0d-b2f1-4b52-85ea-d1feba99dd37@22g2000prx.googlegroups.com> <4d3466d3$0$29983$c3e8da3$5496439d@news.astraweb.com> <0c62aacd-e6d2-4778-81d6-e06924192add@j1g2000vbl.googlegroups.com> <87vd1m6ezq.fsf@benfinney.id.au> <992b11a0-d35d-4b08-98ab-d08c90a86ec7@j1g2000vbl.googlegroups.com> <4d36f846$0$29983$c3e8da3$5496439d@news.astraweb.com> Message-ID: <20110119160020.36e6975a@pitrou.net> On 19 Jan 2011 14:42:14 GMT Steven D'Aprano wrote: > On Tue, 18 Jan 2011 00:58:14 -0800, jmfauth wrote: > > > It is now practically impossible to launch a Python application via a > > .pyc file. > > > When has that ever been possible? > > > .pyc files are Python byte-code. You can't run them directly using Python > (except via the import machinery), you can't run them as a script, > they're not machine code. Unless you write a wrapper to import the file > as a module, you can't directly execute .pyc files. It seems to work here: $ echo "print 'foo'" > toto.py $ python -m compileall -l . Listing . ... Compiling ./toto.py ... $ rm toto.py $ python toto.pyc foo But it still works under 3.2 even though the incantation is less pretty: $ echo "import sys; print(sys.version)" > toto.py $ __svn__/python -m compileall -l . Listing . ... Compiling ./toto.py ... $ rm toto.py $ __svn__/python __pycache__/toto.cpython-32.pyc 3.2rc1+ (py3k:88095M, Jan 18 2011, 17:12:15) [GCC 4.4.3] Regards Antoine. From askutt at gmail.com Wed Jan 19 10:11:51 2011 From: askutt at gmail.com (Adam Skutt) Date: Wed, 19 Jan 2011 07:11:51 -0800 (PST) Subject: UTF-8 question from Dive into Python 3 References: Message-ID: On Jan 19, 9:00?am, Tim Harig wrote: > > So, you can always assume a big-endian and things will work out correctly > while you cannot always make the same assumption as little endian > without potential issues. ?The same holds true for any byte stream data. You need to spend some serious time programming a serial port or other byte/bit-stream oriented interface, and then you'll realize the folly of your statement. > That is why I say that byte streams are essentially big endian. It is > all a matter of how you look at it. It is nothing of the sort. Some byte streams are in fact, little endian: when the bytes are combined into larger objects, the least- significant byte in the object comes first. A lot of industrial/ embedded stuff has byte streams with LSB leading in the sequence, CAN comes to mind as an example. The only way to know is for the standard describing the stream to tell you what to do. > > I prefer to look at all data as endian even if it doesn't create > endian issues because it forces me to consider any endian issues that > might arise. ?If none do, I haven't really lost anything. ? > If you simply assume that any byte sequence cannot have endian issues you ignore the > possibility that such issues might not arise. No, you must assume nothing unless you're told how to combine the bytes within a sequence into a larger element. Plus, not all byte streams support such operations! Some byte streams really are just a sequence of bytes and the bytes within the stream cannot be meaningfully combined into larger data types. If I give you a series of 8-bit (so 1 byte) samples from an analog-to-digital converter, tell me how to combine them into a 16, 32, or 64-bit integer. You cannot do it without altering the meaning of the samples; it is a completely non-nonsensical operation. Adam From invalid at invalid.invalid Wed Jan 19 10:18:14 2011 From: invalid at invalid.invalid (Grant Edwards) Date: Wed, 19 Jan 2011 15:18:14 +0000 (UTC) Subject: move to end, in Python 3.2 Really? References: <58c17709-d68e-4448-b618-b6f594d0e8c5@t35g2000yqj.googlegroups.com> <125db7fe-036e-47c9-be89-50f05106936f@n2g2000pre.googlegroups.com> Message-ID: On 2011-01-19, geremy condra wrote: > On Tue, Jan 18, 2011 at 3:54 PM, rantingrick wrote: >> >> And were the hell is Steve Holden? Why has he not weighed in on these >> (or any) discussions. He (Steve Holden) is second in command to the >> entire community. Yet we have yet to hear a peep from this fella. What >> gives Steve? >> >> And if Steve is too busy, who is next in the chain of command? Who is >> going to take responsibility for this catastrophe we call c.l.py? Is >> there no one is man enough to step up for this community? Are all of >> our leaders just sticking their heads in the sand hoping for this to >> "solve" itself? > > There's no chain of command here, genius. It's a mailing list. And an unmoderated Usenet newsgroup (which has even less of a chain of command than a mailing list). -- Grant Edwards grant.b.edwards Yow! I hope something GOOD at came in the mail today so gmail.com I have a REASON to live!! From orasnita at gmail.com Wed Jan 19 10:41:41 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Wed, 19 Jan 2011 17:41:41 +0200 Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com><4d337983$0$29983$c3e8da3$5496439d@news.astraweb.com><044a5101-948d-4458-9c94-57dbb3e25f67@m35g2000vbn.googlegroups.com><4d3467bf$0$29983$c3e8da3$5496439d@news.astraweb.com><4D34B04E.8050309@web.de><4266E8D7BA204BFEA5BF66C635CE1716@octavian><4D35DCE8.5030002@web.de><4D35DD47.1070304@web.de> <42924000-3ffb-40f5-9cf8-70a9d767b944@k25g2000vbl.googlegroups.com> Message-ID: <7760D30AEB9545969E0BD603874A6A6A@teddy> From: "Adam Skutt" On Jan 18, 3:23 pm, "Octavian Rasnita" wrote: > From: "Alexander Kapps" > > > Tkinter causes damage? Very bad damage? What are you talking about? > > I am talking about the fact that Python promotes Tkinter, and many beginners will start using it, and they will start creating applications with it, and they will learn to use it better than WxPython, and they will start believing that Tkinter is better because it is easier to use than WxPython, so they will start convincing others that Tkinter is the best, and they will start finding many reasons that show that Tkinter is better. And after this, they will say that they don't care about the real problems generated by GUIs like Tk. > And a very big problem is that the applications that use Tk/GTK are not accessible for screen readers, so those applications will be just blank for people with visual impairments which need to use a screen reader. > If you want functional accessibility support, you're going to have to > write it in Python yourself, and get the accessibility manufacturers > to support it. All of the cross-platform toolkits have poor to non- > existent accessibility support. Accessibility issues aren't going to > be fixed by going to a different GUI toolkit in the standard library. Not true. WxPython uses wxWIDGETS which uses the default OS widgets which usually offer the accessibility features. (At least under Windows, but most users that need accessibility use Windows anyway). > The alternative is to fix the accessibility support issues in the > underlying library, and Tk is no less amenable to that than > wxWidgets. If that's what you want, start coding then. You have a > long climb ahead of you. The underlying libraries for Windows offer the necessary accessibility and WxPython uses it, but Tkinter uses Tk not those libraries. > Accessibility will never be a particular good argument for switching > toolkits. All of the cross-platform offerings with Python bindings > are far too broken to be even remotely interesting. WxPython is not perfect but most of the objects it offers are accessible so this is not true. Only Tk and GTK are bad. > Why do we like the portable GUIS and don't really like the native interfaces that don't work on other platforms? > Because we want our programs to be usable by as many people as possible. Well, some platforms render the output as sound and Tkinter are not "portable" on those platforms (screen readers). > Or we have cross-platform support as a requirement and no desire to > develop the GUI interface three times over. Hence the continued > popularity of Java GUIs. Java GUIS are accessible. Maybe that's the reason. SWT offers the same kind of accessibility as WxPython and for SWING there is Java Access Bridge. So they are not as accessible as the native Windows GUI objects, but they are accessible, unlike Tk and GTK which are not. Octavian From usernet at ilthio.net Wed Jan 19 10:42:54 2011 From: usernet at ilthio.net (Tim Harig) Date: Wed, 19 Jan 2011 15:42:54 +0000 (UTC) Subject: UTF-8 question from Dive into Python 3 References: Message-ID: On 2011-01-19, Adam Skutt wrote: > On Jan 19, 9:00?am, Tim Harig wrote: >> That is why I say that byte streams are essentially big endian. It is >> all a matter of how you look at it. > > It is nothing of the sort. Some byte streams are in fact, little > endian: when the bytes are combined into larger objects, the least- > significant byte in the object comes first. A lot of industrial/ > embedded stuff has byte streams with LSB leading in the sequence, CAN > comes to mind as an example. You are correct. Point well made. From usernet at ilthio.net Wed Jan 19 11:03:11 2011 From: usernet at ilthio.net (Tim Harig) Date: Wed, 19 Jan 2011 16:03:11 +0000 (UTC) Subject: UTF-8 question from Dive into Python 3 References: Message-ID: On 2011-01-19, Antoine Pitrou wrote: > On Wed, 19 Jan 2011 14:00:13 +0000 (UTC) > Tim Harig wrote: >> UTF-8 has no apparent endianess if you only store it as a byte stream. >> It does however have a byte order. If you store it using multibytes >> (six bytes for all UTF-8 possibilites) , which is useful if you want >> to have one storage container for each letter as opposed to one for >> each byte(1) > > That's a ridiculous proposition. Why would you waste so much space? Space is only one tradeoff. There are many others to consider. I have created data structures with much higher overhead than that because they happen to make the problem easier and significantly faster for the operations that I am performing on the data. For many operations, it is just much faster and simpler to use a single character based container opposed to having to process an entire byte stream to determine individual letters from the bytes or to having adaptive size containers to store the data. > UTF-8 exists *precisely* so that you can save space with most scripts. UTF-8 has many reasons for existing. One of the biggest is that it is compatible for tools that were designed to process ASCII and other 8bit encodings. > If you are ready to use 4+ bytes per character, just use UTF-32 which > has much nicer properties. I already mentioned UTF-32/UCS-4 as a probable alternative; but, I might not want to have to worry about converting the encodings back and forth before and after processing them. That said, and more importantly, many variable length byte streams may not have alternate representations as unicode does. From orasnita at gmail.com Wed Jan 19 11:09:08 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Wed, 19 Jan 2011 18:09:08 +0200 Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com><4d337983$0$29983$c3e8da3$5496439d@news.astraweb.com><044a5101-948d-4458-9c94-57dbb3e25f67@m35g2000vbn.googlegroups.com><4d3467bf$0$29983$c3e8da3$5496439d@news.astraweb.com><4D34B04E.8050309@web.de><4266E8D7BA204BFEA5BF66C635CE1716@octavian><4D35DCE8.5030002@web.de><4D35DD47.1070304@web.de><7A0C7934E65D4B85A584C06ADD3B6ECF@teddy> Message-ID: <28F98C116D2949619D9BC88DF3C0D278@teddy> From: "Adam Skutt" On Jan 19, 1:37 am, "Octavian Rasnita" wrote: > > The users shouldn't want something better. Everyone should create GUIs which > are accessible for everyone by default, without making any special effort > for doing this. > Accessibility always requires special effort, and I don't see how > changing toolkits gets away from this. > > Adam This is the most false thing I ever heard and the most dangerous. The GUIS like wxWIDGETS and SWT (at least under Windows), Win32 GUI, MFC, WindowsForms (.Net), are accessible out of the box and they don't require any effort from the programmer. The programmer doesn't even know that the application will also offer accessibility features. Java SWING is not accessible out of the box, but Sun offers Java Access Bridge, a program which can be installed by the user which needs accessibility, so finally SWING GUIS are also pretty accessible (also without any effort from the programmer). (Which is not the case of Tk, Gtk and QT.) Octavian From orasnita at gmail.com Wed Jan 19 11:14:34 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Wed, 19 Jan 2011 18:14:34 +0200 Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com><4d337983$0$29983$c3e8da3$5496439d@news.astraweb.com><044a5101-948d-4458-9c94-57dbb3e25f67@m35g2000vbn.googlegroups.com><4d3467bf$0$29983$c3e8da3$5496439d@news.astraweb.com><4D34B04E.8050309@web.de><4266E8D7BA204BFEA5BF66C635CE1716@octavian><4D35DCE8.5030002@web.de><4D35DD47.1070304@web.de><7A0C7934E65D4B85A584C06ADD3B6ECF@teddy> Message-ID: From: "Adam Skutt" On Jan 19, 1:37 am, "Octavian Rasnita" wrote: > > Most of the programmers don't know that and they don't even need to know > that, but if a lib that create accessible GUIS would be promoted, most of > the Python programmers would use that lib and would create good apps by > default, without even knowing this. > Have you written an accessible application in any toolkit whatsoever? > It is not magic, and it does not happen by default, even when solely > using the standard widgets. > > Adam Of course I did. Using WxPerl, Win32::GUI Perl module, SWT and DotNet. (And without doing absolutely anything special for making them accessible). But it is very simple to test this. You can download a demo version of JAWS screen reader from www.freedomscientific.com that will run for 40 minutes or so and then you will need to reboot the computer to make it work again. It is the most used and most powerful screen reader. You will be able to see how accessible (or not accessible) are the applications made with any GUI lib. Octavian From orasnita at gmail.com Wed Jan 19 11:18:47 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Wed, 19 Jan 2011 18:18:47 +0200 Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com><4d337983$0$29983$c3e8da3$5496439d@news.astraweb.com><044a5101-948d-4458-9c94-57dbb3e25f67@m35g2000vbn.googlegroups.com><4d3467bf$0$29983$c3e8da3$5496439d@news.astraweb.com> <4D34B04E.8050309@web.de><4266E8D7BA204BFEA5BF66C635CE1716@octavian><4D35DCE8.5030002@web.de> Message-ID: From: "Mark Roseman" > Octavian, > > Thank you for clearly articulating your concern that Tk does not provide > any support for screen readers. > > While I believe that people can have legitimate differences of opinion > as to whether this merits its removal/replacement from stdlib, there is > no question that this is a serious and significant limitation of Tk. > > I will attempt to find out if there has been any work done in this area > with Tk, and what it would take to address this important issue. > > Thanks again > Mark Thank you Mark. I don't have anything against Tk, Gtk or QT or other GUI libs, but I just shown why some interfaces are much better than others, for very important reasons, which unfortunately can't be seen, so many programmers don't know about them and promote the discrimination without wanting to do that. Octavian From orasnita at gmail.com Wed Jan 19 11:27:12 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Wed, 19 Jan 2011 18:27:12 +0200 Subject: Screen readers for Tkinter (was Re: Tkinter: The good, the bad, and the ugly!) References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com><4d337983$0$29983$c3e8da3$5496439d@news.astraweb.com><044a5101-948d-4458-9c94-57dbb3e25f67@m35g2000vbn.googlegroups.com><4d3467bf$0$29983$c3e8da3$5496439d@news.astraweb.com><4D34B04E.8050309@web.de><4266E8D7BA204BFEA5BF66C635CE1716@octavian><4D35DCE8.5030002@web.de> <1295448820.26438.1416115629@webmail.messagingengine.com> Message-ID: <5296E6FB68964C239A84C2AF4007D2DD@teddy> From: > Mark/Octavian, > > It sounds like Tka11y (spelled with the digit '1' vs. the letter 'L') > addresses this problem for Linux users. > > According to its website, adding accessability support is as simple as > changing one import statement. > > Details follow my signature. > > Malcolm > > > Tka11y - Tk Accessibility > http://tkinter.unpythonic.net/wiki/Tka11y > > > Note: Currently, accessibility is only available via ATK <=> AT-SPI on > Linux. Sorry, no Windows MSAA support. This project is good, a step ahead, but in order to be really useful it should be the one provided by the default Python package. And of course, it should also offer support for Windows, since most of the computer users use Windows, especially those who need accessibility features. Octavian From solipsis at pitrou.net Wed Jan 19 11:27:25 2011 From: solipsis at pitrou.net (Antoine Pitrou) Date: Wed, 19 Jan 2011 17:27:25 +0100 Subject: UTF-8 question from Dive into Python 3 References: Message-ID: <20110119172725.203ea1c2@pitrou.net> On Wed, 19 Jan 2011 16:03:11 +0000 (UTC) Tim Harig wrote: > > For many operations, it is just much faster and simpler to use a single > character based container opposed to having to process an entire byte > stream to determine individual letters from the bytes or to having > adaptive size containers to store the data. You *have* to "process the entire byte stream" in order to determine boundaries of individual letters from the bytes if you want to use a "character based container", regardless of the exact representation. Once you do that it shouldn't be very costly to compute the actual code points. So, "much faster" sounds a bit dubious to me; especially if you factor in the cost of memory allocation, and the fact that a larger container will fit less easily in a data cache. > That said, and more importantly, many > variable length byte streams may not have alternate representations as > unicode does. This whole thread is about UTF-8 (see title) so I'm not sure what kind of relevance this is supposed to have. From wxjmfauth at gmail.com Wed Jan 19 11:30:12 2011 From: wxjmfauth at gmail.com (jmfauth) Date: Wed, 19 Jan 2011 08:30:12 -0800 (PST) Subject: __pycache__, one more good reason to stck with Python 2? References: <23e02e0d-b2f1-4b52-85ea-d1feba99dd37@22g2000prx.googlegroups.com> <4d3466d3$0$29983$c3e8da3$5496439d@news.astraweb.com> <0c62aacd-e6d2-4778-81d6-e06924192add@j1g2000vbl.googlegroups.com> <87vd1m6ezq.fsf@benfinney.id.au> <992b11a0-d35d-4b08-98ab-d08c90a86ec7@j1g2000vbl.googlegroups.com> <4d36f846$0$29983$c3e8da3$5496439d@news.astraweb.com> Message-ID: My "nightmare" was mainly due, because when I read the the "What's new?", I did not understand too much this caching stuff. It's only later, after testing some applications, I really got the surprise to understand it. (Py3.1 and Py3.2 pyc's mixture). Having said this, to tell you the truth. I do really not feel comfortable with it -- two "working directories", a subdir in a working dir containing only a few scripts, filenames, cache multiplications (I would have 1202 caches on my hd now). There are certainly advantages, just wondering if the balance is positive ou negative. Just for the story, I'm already somwehow experencing some funny stuff. My test working dir has already a full bloated cache. You may argue, that's my fault. I may reply: bof, that Python which is doing it...) (As a Windows users, I just wondering how this will impact tools like py2exe or cx_freeze). ----- Antoine Pitrou Yes, I can launch a pyc, when I have a single file. But what happens, if one of your cached .pyc file import a module with a name as defined in the parent directory? The machinery is broken. The parent dir is not in the sys.path. (Unless I'm understanding nothing or I have done a huge mistake in my tests). jmf From askutt at gmail.com Wed Jan 19 11:47:06 2011 From: askutt at gmail.com (Adam Skutt) Date: Wed, 19 Jan 2011 08:47:06 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com><4d337983$0$29983$c3e8da3$5496439d@news.astraweb.com><044a5101-948d-4458-9c94-57dbb3e25f67@m35g2000vbn.googlegroups.com><4d3467bf$0$29983$c3e8da3$5496439d@news.astraweb.com><4D34B04E.8050309@web.de><4266E8D7BA204BFEA5BF66C635CE1716@octavian><4D35DCE8.5030002@web.de><4D35DD47.1070304@web.de> Message-ID: <954d6443-a0c7-49fd-8883-73a767088da0@k9g2000pre.googlegroups.com> On Jan 19, 10:41?am, "Octavian Rasnita" wrote: > > Not true. WxPython uses wxWIDGETS which uses the default OS widgets which usually offer the accessibility features. > (At least under Windows, but most users that need accessibility use Windows anyway). > Right, under Windows, which is a problem. By your line of reasoning, you really should be supporting PySide / PyQt and not wxWidgets, since they at least play at cross-platform support. > > The alternative is to fix the accessibility support issues in the > > underlying library, and Tk is no less amenable to that than > > wxWidgets. ?If that's what you want, start coding then. ?You have a > > long climb ahead of you. > > The underlying libraries for Windows offer the necessary accessibility and WxPython uses it, but Tkinter uses Tk not those libraries. wxWidgets' support is completely inadequate for a true cross-platform system, the developers are aware of this and acknowledge this and believe a rewrite is necessary. Thus, it is currently really in no better state than Tk. > > Or we have cross-platform support as a requirement and no desire to > > develop the GUI interface three times over. ?Hence the continued > > popularity of Java GUIs. > > Java GUIS are accessible. Maybe that's the reason. No, the reason is as I stated, no more, no less. Accessibility doesn't enter into most designs. Adam From askutt at gmail.com Wed Jan 19 11:53:49 2011 From: askutt at gmail.com (Adam Skutt) Date: Wed, 19 Jan 2011 08:53:49 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com><4d337983$0$29983$c3e8da3$5496439d@news.astraweb.com><044a5101-948d-4458-9c94-57dbb3e25f67@m35g2000vbn.googlegroups.com><4d3467bf$0$29983$c3e8da3$5496439d@news.astraweb.com><4D34B04E.8050309@web.de><4266E8D7BA204BFEA5BF66C635CE1716@octavian><4D35DCE8.5030002@web.de><4D35DD47.1070304@web.de><7A0C7934E65D4B85A584C06ADD3B6ECF@teddy> Message-ID: <2edb4353-6dd5-4c46-80ac-4b406ea1637d@k11g2000vbf.googlegroups.com> On Jan 19, 11:09?am, "Octavian Rasnita" wrote: > From: "Adam Skutt" > > Accessibility always requires special effort, and I don't see how > > changing toolkits gets away from this. > > This is the most false thing I ever heard and the most dangerous. O RLY? http://www.wxwidgets.org/docs/technote/wxaccesstips.htm sure looks like there's a whole host of things that I, the application programmer, must do manually to enable an accessible application[1]. I can't just plop down controls and have an accessible application. > The programmer doesn't even know that the application will also offer accessibility features. No, accessibility requires consideration in the design and implementation of the GUIs, in all of those toolkits. It is not transparent, nor can it be transparent. It requires both consideration when laying out the widgets, but also ensuring that the widgets have specific properties set. How many applications have you ever used that had focus order bugs? That's an accessibility issue that requires programmer intervention to get right. Adam [1] That list is not comprehensive by a long shot. From invalid at invalid.invalid Wed Jan 19 12:10:07 2011 From: invalid at invalid.invalid (Grant Edwards) Date: Wed, 19 Jan 2011 17:10:07 +0000 (UTC) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <4d337983$0$29983$c3e8da3$5496439d@news.astraweb.com> <044a5101-948d-4458-9c94-57dbb3e25f67@m35g2000vbn.googlegroups.com> <4d3467bf$0$29983$c3e8da3$5496439d@news.astraweb.com> <4D34B04E.8050309@web.de> <4266E8D7BA204BFEA5BF66C635CE1716@octavian> <4D35DCE8.5030002@web.de> <4D35DD47.1070304@web.de> <42924000-3ffb-40f5-9cf8-70a9d767b944@k25g2000vbl.googlegroups.com> Message-ID: On 2011-01-19, Octavian Rasnita wrote: > From: "Adam Skutt" >> If you want functional accessibility support, you're going to have to >> write it in Python yourself, and get the accessibility manufacturers >> to support it. All of the cross-platform toolkits have poor to non- >> existent accessibility support. Accessibility issues aren't going to >> be fixed by going to a different GUI toolkit in the standard library. > > > Not true. WxPython uses wxWIDGETS which uses the default OS widgets There's no such thing as "default OS widgets" on Linux/Unix/BSD/etc. > which usually offer the accessibility features. (At least under > Windows, but most users that need accessibility use Windows anyway). [...] > WxPython is not perfect but most of the objects it offers are > accessible so this is not true. Only Tk and GTK are bad. On all of my computers, wxPython uses Gtk. There are other choices for wxWidget backends on Linux, but Gtk is by far the most common. IOW, if Gtk is bad, then wxPython is bad. -- Grant Edwards grant.b.edwards Yow! People humiliating at a salami! gmail.com From debatem1 at gmail.com Wed Jan 19 12:17:41 2011 From: debatem1 at gmail.com (geremy condra) Date: Wed, 19 Jan 2011 09:17:41 -0800 Subject: [OT] Python like lanugages [was Re: After C++, what with Python?] In-Reply-To: <828053EDBB174148B9895ADD5B9A0780@octavian> References: <86a904f8-05b0-435f-81d6-7450650f1679@glegroupsg2000goo.googlegroups.com> <4d329899$0$43988$742ec2ed@news.sonic.net> <7x8vylfcvz.fsf@ruckus.brouhaha.com> <4d32c7cf$0$29983$c3e8da3$5496439d@news.astraweb.com> <4d35a769$0$2258$a729d347@news.telepac.pt> <503D269987294E7A95D87C488F37BB25@octavian> <828053EDBB174148B9895ADD5B9A0780@octavian> Message-ID: On Wed, Jan 19, 2011 at 2:31 AM, Octavian Rasnita wrote: > From: "Stefan Behnel" >> >> Octavian Rasnita, 19.01.2011 07:10: >>> >>> aren't the Pyton bytecode-compiled files considered secure enough? >>> Can they be easily decompiled? >> >> Yes. >> >> Stefan >> > > > Would it be hard to introduce the possibility of adding encryption of the > bytecode similar to what the Zend encoder does for PHP or Filter::Crypto for > Perl? > > Octavian The iron law of cryptography: there is no cryptographic solution to a problem in which the attacker and intended recipient are the same person. Schemes like this are at most an annoyance to people willing to reverse engineer your code. Geremy Condra From atagar1 at gmail.com Wed Jan 19 12:40:29 2011 From: atagar1 at gmail.com (Damian Johnson) Date: Wed, 19 Jan 2011 09:40:29 -0800 Subject: Detecting Remaining Thread Message-ID: Hi, I've been trying to track down a familiar concurrency problem without any success: Unhandled exception in thread started by Error in sys.excepthook: Original exception was: I realize that this is due to a background thread still being alive and kicking when the application terminates (ie, a missing join() on a helper thread). However, threading.enumerate() is reporting that nothing except for the main thread is running at that point: 1/19/2011 09:30:41 [INFO] Arm is shutting down. Remaining threads: [<_MainThread(MainThread, started -1217079616)>] What other methods are there for troubleshooting this sort of issue? I've triple checked that my threads are daemons and joined when quitting but I must be missing something... As would be expected of a timing issue, this happens intermittently (1/5 of the time) and goes away if I add a short sleep at the end. Any help would be much appreciated. Thanks! -Damian From sherm.pendley at gmail.com Wed Jan 19 12:47:41 2011 From: sherm.pendley at gmail.com (Sherm Pendley) Date: Wed, 19 Jan 2011 12:47:41 -0500 Subject: __pycache__, one more good reason to stck with Python 2? References: <23e02e0d-b2f1-4b52-85ea-d1feba99dd37@22g2000prx.googlegroups.com> <4d3466d3$0$29983$c3e8da3$5496439d@news.astraweb.com> <0c62aacd-e6d2-4778-81d6-e06924192add@j1g2000vbl.googlegroups.com> <77ef8068-7f07-404f-8b0e-c039d1122659@e16g2000pri.googlegroups.com> <69fa24fc-b3de-4099-a99c-7fd6be50ba64@d8g2000yqf.googlegroups.com> Message-ID: H?0.py writes: > On Jan 18, 4:04?am, Peter Otten <__pete... at web.de> wrote: >> >> What's the advantage of 'find ... | xargs ...' over 'find ... -exec ...'? > > Portability. Running the '-exec' version will work fine in a directory > with a relatively small number of files, but will fail on a large one. How? -exec passes each file name to a separate invocation of the given command - it doesn't build one large command line with multiple args. sherm-- -- Sherm Pendley Cocoa Developer From usernet at ilthio.net Wed Jan 19 13:02:22 2011 From: usernet at ilthio.net (Tim Harig) Date: Wed, 19 Jan 2011 18:02:22 +0000 (UTC) Subject: UTF-8 question from Dive into Python 3 References: Message-ID: On 2011-01-19, Antoine Pitrou wrote: > On Wed, 19 Jan 2011 16:03:11 +0000 (UTC) > Tim Harig wrote: >> >> For many operations, it is just much faster and simpler to use a single >> character based container opposed to having to process an entire byte >> stream to determine individual letters from the bytes or to having >> adaptive size containers to store the data. > > You *have* to "process the entire byte stream" in order to determine > boundaries of individual letters from the bytes if you want to use a > "character based container", regardless of the exact representation. Right, but I only have to do that once. After that, I can directly address any piece of the stream that I choose. If I leave the information as a simple UTF-8 stream, I would have to walk the stream again, I would have to walk through the the first byte of all the characters from the beginning to make sure that I was only counting multibyte characters once until I found the character that I actually wanted. Converting to a fixed byte representation (UTF-32/UCS-4) or separating all of the bytes for each UTF-8 into 6 byte containers both make it possible to simply index the letters by a constant size. You will note that Python does the former. UTF-32/UCS-4 conversion is definitly supperior if you are actually doing any major but it adds the complexity and overhead of requiring the bit twiddling to make the conversions (once in, once again out). Some programs don't really care enough about what the data actually contains to make it worth while. They just want to be able to use the characters as black boxes. > Once you do that it shouldn't be very costly to compute the actual code > points. So, "much faster" sounds a bit dubious to me; especially if you You could I suppose keep a separate list of pointers to each letter so that you could use the pointer list for indexing or keep a list of the character sizes so that you can add them and calculate the variable width index; but, that adds overhead as well. From solipsis at pitrou.net Wed Jan 19 13:03:23 2011 From: solipsis at pitrou.net (Antoine Pitrou) Date: Wed, 19 Jan 2011 19:03:23 +0100 Subject: __pycache__, one more good reason to stck with Python 2? References: <23e02e0d-b2f1-4b52-85ea-d1feba99dd37@22g2000prx.googlegroups.com> <4d3466d3$0$29983$c3e8da3$5496439d@news.astraweb.com> <0c62aacd-e6d2-4778-81d6-e06924192add@j1g2000vbl.googlegroups.com> <87vd1m6ezq.fsf@benfinney.id.au> <992b11a0-d35d-4b08-98ab-d08c90a86ec7@j1g2000vbl.googlegroups.com> <4d36f846$0$29983$c3e8da3$5496439d@news.astraweb.com> Message-ID: <20110119190323.1d23ecfc@pitrou.net> On Wed, 19 Jan 2011 08:30:12 -0800 (PST) jmfauth wrote: > Yes, I can launch a pyc, when I have a single file. > But what happens, if one of your cached .pyc file import > a module with a name as defined in the parent directory? > The machinery is broken. The parent dir is not in the > sys.path. Well, you don't have to launch a pyc file anyway. Put all your code in some (pyc) modules on the standard Python path, and use a clear-text script with some trivial code to invoke a function from the compiled modules. Otherwise you can customize sys.path a little from your script, using __file__ and os.path.dirname. Nothing complicated AFAICT. (by the way, the fact that pyc files are version-specific should discourage any use outside of version-specific directories, e.g. /usr/lib/pythonX.Y/site-packages) Regards Antoine. From patty at cruzio.com Wed Jan 19 13:22:18 2011 From: patty at cruzio.com (patty at cruzio.com) Date: Wed, 19 Jan 2011 10:22:18 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! In-Reply-To: <9a036db2-9f32-441f-aa0f-698ac22fb152@e20g2000vbn.googlegroups.com> References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <0fa4603c-6e27-4ee5-9761-000a61cd19a4@fx12g2000vbb.googlegroups.com> <2510bf88-1045-411f-9ccd-7ca7c3665454@l24g2000vby.googlegroups.com> <2ef2fa6c-2ccf-453a-8f50-0ef7dbd7834d@j32g2000yqc.googlegroups.com> <5c6ff40f-05c1-4e38-89bc-b8c4745db7ce@i18g2000yqn.googlegroups.com> <9a036db2-9f32-441f-aa0f-698ac22fb152@e20g2000vbn.googlegroups.com> Message-ID: > On Jan 18, 9:54?pm, Adam Skutt wrote: >> On Jan 18, 9:27?pm, Corey Richardson wrote: >>?At which point, it's pretty damn >> small. ?Not as small as all of the Tk functionality, I think, but well >> under 10MiB compressed. > > Yea but look at all your gaining. I would rather sacrifice a few megs > for the rich functionality and scalability any day. > > >> The problem to me isn't the size (though some might find it >> objectionable), but the system dependencies you have to take: >> wxWidgets requires GTK+ on UNIX > > UNIX? are you kidding? Even if these dependancies are needed the > "UNIX" folks are damn capable of finding and installing them with > great ease. Besides most ship with this out the box already! We are > not talking about the lemmings who use windows or even the weekend > linuxers here. If they are using UNIX then there is no need for "hand > holding". > >> , which requires a whole mess of crap >> in term, plus swig, plus whatever else I may or may not be missing. > > Thats quite an exaggeration Adam. > >> I'm also not 100% certain as to whether it's as portable as Tk is >> today. > > Wx is just as portable as Tk > -- > http://mail.python.org/mailman/listinfo/python-list > > Now I think I understand a little better where you all are coming from -- I am a Unix person and I guess I expected to have to learn GUI's using whatever is provided for me by default. Which isn't a bad thing. And if I had to add additional software - and learn that - so be it. I am using a Windows XP system and a Windows 7 system presently. Some day I would like to switch out the Windows XP for Unix. Thanks for the link to the Python page about the various packages, that was enlightening. Who or what group is actually in charge of what libraries (and programming commands/methods such as the Python 3.x rewrite of 'print') goes into Python? Is this huge discussion really a few feature requests for additional libraries to be included for Windows programming? And aren't some of these libraries developed by 3rd parties? And how is that handled by the people in charge? Do they have to pay to license it or is this all freely contributed software? Patty From solipsis at pitrou.net Wed Jan 19 13:45:35 2011 From: solipsis at pitrou.net (Antoine Pitrou) Date: Wed, 19 Jan 2011 19:45:35 +0100 Subject: UTF-8 question from Dive into Python 3 References: Message-ID: <20110119194535.6ed1018a@pitrou.net> On Wed, 19 Jan 2011 18:02:22 +0000 (UTC) Tim Harig wrote: > On 2011-01-19, Antoine Pitrou wrote: > > On Wed, 19 Jan 2011 16:03:11 +0000 (UTC) > > Tim Harig wrote: > >> > >> For many operations, it is just much faster and simpler to use a single > >> character based container opposed to having to process an entire byte > >> stream to determine individual letters from the bytes or to having > >> adaptive size containers to store the data. > > > > You *have* to "process the entire byte stream" in order to determine > > boundaries of individual letters from the bytes if you want to use a > > "character based container", regardless of the exact representation. > > Right, but I only have to do that once. You only have to decode once as well. > If I leave the information as a > simple UTF-8 stream, That's not what we are talking about. We are talking about the supposed benefits of your 6-byte representation scheme versus proper decoding into fixed width code points. > UTF-32/UCS-4 conversion is definitly supperior if you are actually > doing any major but it adds the complexity and overhead of requiring > the bit twiddling to make the conversions (once in, once again out). "Bit twiddling" is not something processors are particularly bad at. Actually, modern processors are much better at arithmetic and logic than at recovering from mispredicted branches, which seems to suggest that discovering boundaries probably eats most of the CPU cycles. > Converting to a fixed byte > representation (UTF-32/UCS-4) or separating all of the bytes for each > UTF-8 into 6 byte containers both make it possible to simply index the > letters by a constant size. You will note that Python does the > former. Indeed, Python chose the wise option. Actually, I'd be curious of any real-world software which successfully chose your proposed approach. From wxjmfauth at gmail.com Wed Jan 19 14:12:52 2011 From: wxjmfauth at gmail.com (jmfauth) Date: Wed, 19 Jan 2011 11:12:52 -0800 (PST) Subject: __pycache__, one more good reason to stck with Python 2? References: <23e02e0d-b2f1-4b52-85ea-d1feba99dd37@22g2000prx.googlegroups.com> <4d3466d3$0$29983$c3e8da3$5496439d@news.astraweb.com> <0c62aacd-e6d2-4778-81d6-e06924192add@j1g2000vbl.googlegroups.com> <87vd1m6ezq.fsf@benfinney.id.au> <992b11a0-d35d-4b08-98ab-d08c90a86ec7@j1g2000vbl.googlegroups.com> <4d36f846$0$29983$c3e8da3$5496439d@news.astraweb.com> Message-ID: <83eccf0d-5a7e-4434-b20b-4bcab44fddb1@k42g2000yqa.googlegroups.com> On Jan 19, 7:03?pm, Antoine Pitrou wrote: > On Wed, 19 Jan 2011 08:30:12 -0800 (PST) > > jmfauth wrote: > > Yes, I can launch a pyc, when I have a single file. > > But what happens, if one of your cached .pyc file import > > a module with a name as defined in the parent directory? > > The machinery is broken. The parent dir is not in the > > sys.path. > > Well, you don't have to launch a pyc file anyway. Put all your code in > some (pyc) modules on the standard Python path, and use a clear-text > script with some trivial code to invoke a function from the compiled > modules. That's not the point. I'm toying. And the "behaviour" from now is deeply different from what it was. > Otherwise you can customize sys.path a little from your script, > using __file__ and os.path.dirname. Nothing complicated AFAICT. That's not as simple. You have too prepare the py file in such a way, that it recognizes the path of its ancestor py file. The "home dir" is no more the same. > (by the way, the fact that pyc files are version-specific should > discourage any use outside of version-specific directories, > e.g. /usr/lib/pythonX.Y/site-packages) Here we are. I'm just wondering if all this stuff is not just here in order to satisfy the missmatched Python installation on *x platforms compared to Windows whre each Python version lives cleanely in its isolated space. (Please no os war). jmf compared to From invalid at invalid.invalid Wed Jan 19 14:16:32 2011 From: invalid at invalid.invalid (Grant Edwards) Date: Wed, 19 Jan 2011 19:16:32 +0000 (UTC) Subject: [OT] Python like lanugages [was Re: After C++, what with Python?] References: <86a904f8-05b0-435f-81d6-7450650f1679@glegroupsg2000goo.googlegroups.com> <4d329899$0$43988$742ec2ed@news.sonic.net> <7x8vylfcvz.fsf@ruckus.brouhaha.com> <4d32c7cf$0$29983$c3e8da3$5496439d@news.astraweb.com> <4d35a769$0$2258$a729d347@news.telepac.pt> <503D269987294E7A95D87C488F37BB25@octavian> <828053EDBB174148B9895ADD5B9A0780@octavian> Message-ID: On 2011-01-19, geremy condra wrote: > On Wed, Jan 19, 2011 at 2:31 AM, Octavian Rasnita wrote: >> Would it be hard to introduce the possibility of adding encryption of the >> bytecode similar to what the Zend encoder does for PHP or Filter::Crypto for >> Perl? > > The iron law of cryptography: there is no cryptographic solution to a > problem in which the attacker and intended recipient are the same > person. > > Schemes like this are at most an annoyance to people willing to > reverse engineer your code. And they somehow usually end up being an annoyance to customers who are not trying to reverse engineer your code but are merely trying to use it legally. -- Grant Edwards grant.b.edwards Yow! I'd like MY data-base at JULIENNED and stir-fried! gmail.com From usernet at ilthio.net Wed Jan 19 14:18:49 2011 From: usernet at ilthio.net (Tim Harig) Date: Wed, 19 Jan 2011 19:18:49 +0000 (UTC) Subject: UTF-8 question from Dive into Python 3 References: Message-ID: On 2011-01-19, Antoine Pitrou wrote: > On Wed, 19 Jan 2011 18:02:22 +0000 (UTC) > Tim Harig wrote: >> Converting to a fixed byte >> representation (UTF-32/UCS-4) or separating all of the bytes for each >> UTF-8 into 6 byte containers both make it possible to simply index the >> letters by a constant size. You will note that Python does the >> former. > > Indeed, Python chose the wise option. Actually, I'd be curious of any > real-world software which successfully chose your proposed approach. The point is basically the same. I created an example because it was simpler to follow for demonstration purposes then an actual UTF-8 conversion to any official multibyte format. You obviously have no other purpose then to be contrary, so we ended up following tangents. As soon as you start to convert to a multibyte format the endian issues occur. For UTF-8 on big endian hardware, this is anti-climactic because all of the bits are already stored in proper order. Little endian systems will probably convert to a native native endian format. If you choose to ignore that, that is your perogative. Have a nice day. From pavlovevidence at gmail.com Wed Jan 19 14:30:36 2011 From: pavlovevidence at gmail.com (Carl Banks) Date: Wed, 19 Jan 2011 11:30:36 -0800 (PST) Subject: __pycache__, one more good reason to stck with Python 2? References: <23e02e0d-b2f1-4b52-85ea-d1feba99dd37@22g2000prx.googlegroups.com> <4d3466d3$0$29983$c3e8da3$5496439d@news.astraweb.com> <0c62aacd-e6d2-4778-81d6-e06924192add@j1g2000vbl.googlegroups.com> <87vd1m6ezq.fsf@benfinney.id.au> <992b11a0-d35d-4b08-98ab-d08c90a86ec7@j1g2000vbl.googlegroups.com> <4d36f846$0$29983$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Jan 19, 6:42?am, Steven D'Aprano wrote: > But having said that, the __pycache__ idea isn't too bad. If you have > this directory structure: > > ./module.py > ./module.pyc > > and import module, the top-level .pyc file will continue to be used. Nope. PEP 3147 says it now always uses __pycache__. Carl Banks From debatem1 at gmail.com Wed Jan 19 14:37:44 2011 From: debatem1 at gmail.com (geremy condra) Date: Wed, 19 Jan 2011 11:37:44 -0800 Subject: Tkinter: The good, the bad, and the ugly! In-Reply-To: References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <0fa4603c-6e27-4ee5-9761-000a61cd19a4@fx12g2000vbb.googlegroups.com> <2510bf88-1045-411f-9ccd-7ca7c3665454@l24g2000vby.googlegroups.com> <2ef2fa6c-2ccf-453a-8f50-0ef7dbd7834d@j32g2000yqc.googlegroups.com> <5c6ff40f-05c1-4e38-89bc-b8c4745db7ce@i18g2000yqn.googlegroups.com> <9a036db2-9f32-441f-aa0f-698ac22fb152@e20g2000vbn.googlegroups.com> Message-ID: On Wed, Jan 19, 2011 at 10:22 AM, wrote: > > Now I think I understand a little better where you all are coming from -- > I am a Unix person and I guess I expected to have to learn GUI's using > whatever is provided for me by default. Which isn't a bad thing. ? And if > I had to add additional software - and learn that - so be it. ?I am using > a Windows XP system and a Windows 7 system presently. ?Some day I would > like to switch out the Windows XP for Unix. Just dual boot, it isn't hard. > Thanks for the link to the Python page about the various packages, that > was enlightening. > > Who or what group is actually in charge of what libraries (and programming > commands/methods such as the Python 3.x rewrite of 'print') goes into > Python? Python's developers. There isn't really any other formal structure beyond that. > ?Is this huge discussion really a few feature requests for > additional libraries to be included for Windows programming? No, it's about other operating systems too, but what it comes down to is that rantingrick has been on the warpath about tkinter for a while, and hasn't proposed a particularly viable alternative. The sad thing is that if he weren't so unhinged his proposal would probably fare much better- I know I > ?And aren't some of these libraries developed by 3rd parties? Any library to replace tkinter would come from a third party, yes. >And how is that handled by the people in charge? Again, there aren't really people 'in charge' on this. Whoever wanted to push for this would have to do the legwork to make sure that the library on offer was good enough to win a lot of support from the community, was cross-platform, etc. They'd also have to convince someone with commit privs that it was a great idea, convince the rest of the dev group not to oppose it. After that would come the difficult task of slowly phasing tkinter out, which would involve substantial long-term commitment. In other words, whoever wants to push for this is in for a hard, multi-year slog. Nobody has stepped up to the plate to do any real work towards that goal. > Do they have to pay to license it or is this all freely contributed software? I can't imagine non-free code making it in. Geremy Condra From debatem1 at gmail.com Wed Jan 19 14:40:40 2011 From: debatem1 at gmail.com (geremy condra) Date: Wed, 19 Jan 2011 11:40:40 -0800 Subject: Tkinter: The good, the bad, and the ugly! In-Reply-To: References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <0fa4603c-6e27-4ee5-9761-000a61cd19a4@fx12g2000vbb.googlegroups.com> <2510bf88-1045-411f-9ccd-7ca7c3665454@l24g2000vby.googlegroups.com> <2ef2fa6c-2ccf-453a-8f50-0ef7dbd7834d@j32g2000yqc.googlegroups.com> <5c6ff40f-05c1-4e38-89bc-b8c4745db7ce@i18g2000yqn.googlegroups.com> <9a036db2-9f32-441f-aa0f-698ac22fb152@e20g2000vbn.googlegroups.com> Message-ID: On Wed, Jan 19, 2011 at 11:37 AM, geremy condra wrote: > No, it's about other operating systems too, but what it comes down to > is that rantingrick has been on the warpath about tkinter for a while, > and hasn't proposed a particularly viable alternative. The sad thing > is that if he weren't so unhinged his proposal would probably fare > much better- I know I Sorry for the truncation. I was going to say that I know I would be more supportive of it if he was building support for something instead of tearing everything else down. Geremy Condra From solipsis at pitrou.net Wed Jan 19 14:44:17 2011 From: solipsis at pitrou.net (Antoine Pitrou) Date: Wed, 19 Jan 2011 20:44:17 +0100 Subject: UTF-8 question from Dive into Python 3 References: Message-ID: <20110119204417.3683e10a@pitrou.net> On Wed, 19 Jan 2011 19:18:49 +0000 (UTC) Tim Harig wrote: > On 2011-01-19, Antoine Pitrou wrote: > > On Wed, 19 Jan 2011 18:02:22 +0000 (UTC) > > Tim Harig wrote: > >> Converting to a fixed byte > >> representation (UTF-32/UCS-4) or separating all of the bytes for each > >> UTF-8 into 6 byte containers both make it possible to simply index the > >> letters by a constant size. You will note that Python does the > >> former. > > > > Indeed, Python chose the wise option. Actually, I'd be curious of any > > real-world software which successfully chose your proposed approach. > > The point is basically the same. I created an example because it > was simpler to follow for demonstration purposes then an actual UTF-8 > conversion to any official multibyte format. You obviously have no > other purpose then to be contrary [...] Right. You were the one who jumped in and tried to lecture everyone on how UTF-8 was "big-endian", and now you are abandoning the one esoteric argument you found in support of that. > As soon as you start to convert to a multibyte format the endian issues > occur. Ok. Good luck with your "endian issues" which don't exist. From orasnita at gmail.com Wed Jan 19 15:33:24 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Wed, 19 Jan 2011 22:33:24 +0200 Subject: [OT] Python like lanugages [was Re: After C++, what with Python?] References: <86a904f8-05b0-435f-81d6-7450650f1679@glegroupsg2000goo.googlegroups.com><4d329899$0$43988$742ec2ed@news.sonic.net><7x8vylfcvz.fsf@ruckus.brouhaha.com><4d32c7cf$0$29983$c3e8da3$5496439d@news.astraweb.com><4d35a769$0$2258$a729d347@news.telepac.pt><503D269987294E7A95D87C488F37BB25@octavian><828053EDBB174148B9895ADD5B9A0780@octavian> Message-ID: From: "geremy condra" > On Wed, Jan 19, 2011 at 2:31 AM, Octavian Rasnita wrote: >> From: "Stefan Behnel" >>> >>> Octavian Rasnita, 19.01.2011 07:10: >>>> >>>> aren't the Pyton bytecode-compiled files considered secure enough? >>>> Can they be easily decompiled? >>> >>> Yes. >>> >>> Stefan >>> >> >> >> Would it be hard to introduce the possibility of adding encryption of the >> bytecode similar to what the Zend encoder does for PHP or Filter::Crypto for >> Perl? >> >> Octavian > > The iron law of cryptography: there is no cryptographic solution to a > problem in which the attacker and intended recipient are the same > person. > > Schemes like this are at most an annoyance to people willing to > reverse engineer your code. > > Geremy Condra I don't know how the Python bytecode works... how it is executed. I thought that Python parses the .py file and generates the bytecode that doesn't contain all the necessary information for re-creating the source code. (But that I agree, that might mean real compilation which is not the case...) Octavian From orasnita at gmail.com Wed Jan 19 15:41:04 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Wed, 19 Jan 2011 22:41:04 +0200 Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com><4d337983$0$29983$c3e8da3$5496439d@news.astraweb.com><044a5101-948d-4458-9c94-57dbb3e25f67@m35g2000vbn.googlegroups.com><4d3467bf$0$29983$c3e8da3$5496439d@news.astraweb.com><4D34B04E.8050309@web.de><4266E8D7BA204BFEA5BF66C635CE1716@octavian><4D35DCE8.5030002@web.de><4D35DD47.1070304@web.de> <954d6443-a0c7-49fd-8883-73a767088da0@k9g2000pre.googlegroups.com> Message-ID: <0C06CA2A6C8C417AA94D3D4AEFECF728@teddy> From: "Adam Skutt" > wxWidgets' support is completely inadequate for a true cross-platform > system, the developers are aware of this and acknowledge this and > believe a rewrite is necessary. Thus, it is currently really in no > better state than Tk. It depends on what you mean by a "true cross-platform" system. wxWIDGETS run on more platforms, so it is cross-platform and it is also accessible for more categories of users. Other systems are bad not only because they are not accessible for everyone, but also because they don't use the underlying GUI of the operating system they are used on, so they have a different look and feel. Even the accessibility, the possibility of accessing the GUIs with a keyboard also means look and feel. > > Or we have cross-platform support as a requirement and no desire to > > develop the GUI interface three times over. Hence the continued > > popularity of Java GUIs. > > Java GUIS are accessible. Maybe that's the reason. > No, the reason is as I stated, no more, no less. Accessibility > doesn't enter into most designs. Which are those "most designs"? I've shown you that the most used GUIS are made to be accessible out of the box and all the GUIS should offer these facilities. Octavian From timothy.c.delaney at gmail.com Wed Jan 19 15:43:53 2011 From: timothy.c.delaney at gmail.com (Tim Delaney) Date: Thu, 20 Jan 2011 07:43:53 +1100 Subject: [OT] Python like lanugages [was Re: After C++, what with Python?] In-Reply-To: References: <86a904f8-05b0-435f-81d6-7450650f1679@glegroupsg2000goo.googlegroups.com> <4d329899$0$43988$742ec2ed@news.sonic.net> <7x8vylfcvz.fsf@ruckus.brouhaha.com> <4d32c7cf$0$29983$c3e8da3$5496439d@news.astraweb.com> <4d35a769$0$2258$a729d347@news.telepac.pt> <503D269987294E7A95D87C488F37BB25@octavian> <828053EDBB174148B9895ADD5B9A0780@octavian> Message-ID: On 20 January 2011 06:16, Grant Edwards wrote: > On 2011-01-19, geremy condra wrote: > > On Wed, Jan 19, 2011 at 2:31 AM, Octavian Rasnita > wrote: > > >> Would it be hard to introduce the possibility of adding encryption of > the > >> bytecode similar to what the Zend encoder does for PHP or Filter::Crypto > for > >> Perl? > > > > The iron law of cryptography: there is no cryptographic solution to a > > problem in which the attacker and intended recipient are the same > > person. > > > > Schemes like this are at most an annoyance to people willing to > > reverse engineer your code. > > And they somehow usually end up being an annoyance to customers who > are not trying to reverse engineer your code but are merely trying to > use it legally. Absolutely. If you feel you absolutely *must* obfuscate your object code more than the python bytecode, just put it all into a separate module and compile it with Cython . Then you end up with machine-specific object code which is somewhat harder to reverse engineer for most people (but quite a few people are experts at doing so). As a bonus, Cython might speed it up too. Tim Delaney -------------- next part -------------- An HTML attachment was scrubbed... URL: From patty at cruzio.com Wed Jan 19 15:45:22 2011 From: patty at cruzio.com (Patty) Date: Wed, 19 Jan 2011 12:45:22 -0800 Subject: Tkinter: The good, the bad, and the ugly! References: Message-ID: ----- Original Message ----- From: "geremy condra" To: Cc: "rantingrick" ; Sent: Wednesday, January 19, 2011 11:37 AM Subject: Re: Tkinter: The good, the bad, and the ugly! On Wed, Jan 19, 2011 at 10:22 AM, wrote: > > Now I think I understand a little better where you all are coming from -- > I am a Unix person and I guess I expected to have to learn GUI's using > whatever is provided for me by default. Which isn't a bad thing. And if > I had to add additional software - and learn that - so be it. I am using > a Windows XP system and a Windows 7 system presently. Some day I would > like to switch out the Windows XP for Unix. Just dual boot, it isn't hard. True. I have a Compaq Presario that is so old hardware-wise that I don't think it could handle Unix or Linux. > Thanks for the link to the Python page about the various packages, that > was enlightening. > > Who or what group is actually in charge of what libraries (and programming > commands/methods such as the Python 3.x rewrite of 'print') goes into > Python? Python's developers. There isn't really any other formal structure beyond that. > Is this huge discussion really a few feature requests for > additional libraries to be included for Windows programming? No, it's about other operating systems too, but what it comes down to is that rantingrick has been on the warpath about tkinter for a while, and hasn't proposed a particularly viable alternative. The sad thing is that if he weren't so unhinged his proposal would probably fare much better- I know I > And aren't some of these libraries developed by 3rd parties? Any library to replace tkinter would come from a third party, yes. >And how is that handled by the people in charge? Again, there aren't really people 'in charge' on this. Whoever wanted to push for this would have to do the legwork to make sure that the library on offer was good enough to win a lot of support from the community, was cross-platform, etc. They'd also have to convince someone with commit privs that it was a great idea, convince the rest of the dev group not to oppose it. After that would come the difficult task of slowly phasing tkinter out, which would involve substantial long-term commitment. In other words, whoever wants to push for this is in for a hard, multi-year slog. Nobody has stepped up to the plate to do any real work towards that goal. > Do they have to pay to license it or is this all freely contributed > software? I can't imagine non-free code making it in. Geremy Condra >From my past experience - I think you are right, this is the course of events that would have to happen and yes, it would literally take years. Patty From emile at fenx.com Wed Jan 19 15:50:36 2011 From: emile at fenx.com (Emile van Sebille) Date: Wed, 19 Jan 2011 12:50:36 -0800 Subject: Tkinter: The good, the bad, and the ugly! In-Reply-To: References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <0fa4603c-6e27-4ee5-9761-000a61cd19a4@fx12g2000vbb.googlegroups.com> <2510bf88-1045-411f-9ccd-7ca7c3665454@l24g2000vby.googlegroups.com> <2ef2fa6c-2ccf-453a-8f50-0ef7dbd7834d@j32g2000yqc.googlegroups.com> <5c6ff40f-05c1-4e38-89bc-b8c4745db7ce@i18g2000yqn.googlegroups.com> <9a036db2-9f32-441f-aa0f-698ac22fb152@e20g2000vbn.googlegroups.com> Message-ID: On 1/19/2011 11:37 AM geremy condra said... > On Wed, Jan 19, 2011 at 10:22 AM, wrote: >> And aren't some of these libraries developed by 3rd parties? > > Any library to replace tkinter would come from a third party, yes. > >> And how is that handled by the people in charge? > > Again, there aren't really people 'in charge' on this. Whoever wanted > to push for this would have to do the legwork to make sure that the > library on offer was good enough to win a lot of support from the > community, was cross-platform, etc. They'd also have to convince > someone with commit privs that it was a great idea, convince the rest > of the dev group not to oppose it. ... and that they'd forevermore support it, which is likely to be as much of an obstacle. I suspect that's why even established libraries like PIL, numpy, mxDateTime or win32all never made it into the standard library. Emile From steve+comp.lang.python at pearwood.info Wed Jan 19 16:01:04 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 19 Jan 2011 21:01:04 GMT Subject: __pycache__, one more good reason to stck with Python 2? References: <23e02e0d-b2f1-4b52-85ea-d1feba99dd37@22g2000prx.googlegroups.com> <4d3466d3$0$29983$c3e8da3$5496439d@news.astraweb.com> <0c62aacd-e6d2-4778-81d6-e06924192add@j1g2000vbl.googlegroups.com> <87vd1m6ezq.fsf@benfinney.id.au> <992b11a0-d35d-4b08-98ab-d08c90a86ec7@j1g2000vbl.googlegroups.com> <4d36f846$0$29983$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4d37510f$0$29983$c3e8da3$5496439d@news.astraweb.com> On Wed, 19 Jan 2011 16:00:20 +0100, Antoine Pitrou wrote: >> .pyc files are Python byte-code. You can't run them directly using >> Python (except via the import machinery), you can't run them as a >> script, they're not machine code. Unless you write a wrapper to import >> the file as a module, you can't directly execute .pyc files. > > It seems to work here: [snip incantation] Then I stand corrected, thank you. I know I've seen problems executing .pyc files from the shell in the past... perhaps I was conflating details of something else. Ah, I know! [steve at sylar ~]$ chmod u+x toto.pyc [steve at sylar ~]$ ./toto.pyc : command not found ?? ./toto.pyc: line 2: syntax error near unexpected token `(' ./toto.pyc: line 2: `P7Mc at s dGHdS(tfooN((((s ./ toto.pys' -- Steven From orasnita at gmail.com Wed Jan 19 16:04:10 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Wed, 19 Jan 2011 23:04:10 +0200 Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com><4d337983$0$29983$c3e8da3$5496439d@news.astraweb.com><044a5101-948d-4458-9c94-57dbb3e25f67@m35g2000vbn.googlegroups.com><4d3467bf$0$29983$c3e8da3$5496439d@news.astraweb.com><4D34B04E.8050309@web.de><4266E8D7BA204BFEA5BF66C635CE1716@octavian><4D35DCE8.5030002@web.de><4D35DD47.1070304@web.de><7A0C7934E65D4B85A584C06ADD3B6ECF@teddy> <2edb4353-6dd5-4c46-80ac-4b406ea1637d@k11g2000vbf.googlegroups.com> Message-ID: <852627E6406040D488A14225023CFFE1@teddy> From: "Adam Skutt" On Jan 19, 11:09 am, "Octavian Rasnita" wrote: > From: "Adam Skutt" > > Accessibility always requires special effort, and I don't see how > > changing toolkits gets away from this. > > This is the most false thing I ever heard and the most dangerous. O RLY? http://www.wxwidgets.org/docs/technote/wxaccesstips.htm sure looks like there's a whole host of things that I, the application programmer, must do manually to enable an accessible application[1]. I can't just plop down controls and have an accessible application. Well, to be sincere, I thought that you don't care, or even worse, and I am sorry because I was thinking that way, but I see that you don't understand what accessible means. A GUI can be more or less accessible and the most accessible is the standard Win32 GUI / MFC. wxWIDGETS is not perfect because it has some controls that steal the focus and don't allow moving it to another control by using the tab key, or it has the HTML widget which is not accessible at all, but the most used controls like the buttons, list boxes, list views, text fields, radio buttons, check boxes... are perfectly accessible out of the box. Those rules for creating an accessible application are obvious; like the fact that a button need to contain a text label and not only an image, or that an image needs to have a tooltip defined, or that a radio button needs to have a label attached to it, but all those things can be solved by the programmer and usually the programmer create those text labels. If the programmer doesn't create those labels, the application won't be totally inaccessible. The users will tab around and they will hear that there is a button without name, or a radio button without name, but the user can use the application and by trial and error he/she might learn that the second button does this and the third button does that. But the interfaces created with Tk, Gtk and QT are completely inaccessible. This means that no object confirms that it got the focus, no text field returns the text it contains, and so on. Those applications are like an opened notepad.exe program with an empty file in which you try to tab around to move the cursor, but of course, nothing happends and you can't find any button, or list box in it. In the Tk applications only the menus are accessible but that's the entire accessibility it offers. > The programmer doesn't even know that the application will also offer accessibility features. No, accessibility requires consideration in the design and implementation of the GUIs, in all of those toolkits. It is not transparent, nor can it be transparent. It requires both consideration when laying out the widgets, but also ensuring that the widgets have specific properties set. How many applications have you ever used that had focus order bugs? That's an accessibility issue that requires programmer intervention to get right. Adam Yes, those things should be followed for creating a better app, but what I wanted to say is that no matter if you do those things or not in a Tk, Gtk or QT GUI, they will be useless, because the screen readers can't understand those GUIS even they have text labels, and even if you will see a focus rectangle around buttons. They don't report that those objects have the focus so the screen readers won't speak anything. Octavian From orasnita at gmail.com Wed Jan 19 16:20:33 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Wed, 19 Jan 2011 23:20:33 +0200 Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com><4d337983$0$29983$c3e8da3$5496439d@news.astraweb.com><044a5101-948d-4458-9c94-57dbb3e25f67@m35g2000vbn.googlegroups.com><4d3467bf$0$29983$c3e8da3$5496439d@news.astraweb.com> <4D34B04E.8050309@web.de><4266E8D7BA204BFEA5BF66C635CE1716@octavian> <4D35DCE8.5030002@web.de><4D35DD47.1070304@web.de><42924000-3ffb-40f5-9cf8-70a9d767b944@k25g2000vbl.googlegroups.com> Message-ID: From: "Grant Edwards" > On 2011-01-19, Octavian Rasnita wrote: >> From: "Adam Skutt" > >>> If you want functional accessibility support, you're going to have to >>> write it in Python yourself, and get the accessibility manufacturers >>> to support it. All of the cross-platform toolkits have poor to non- >>> existent accessibility support. Accessibility issues aren't going to >>> be fixed by going to a different GUI toolkit in the standard library. >> >> >> Not true. WxPython uses wxWIDGETS which uses the default OS widgets > > There's no such thing as "default OS widgets" on Linux/Unix/BSD/etc. > >> which usually offer the accessibility features. (At least under >> Windows, but most users that need accessibility use Windows anyway). > > [...] > >> WxPython is not perfect but most of the objects it offers are >> accessible so this is not true. Only Tk and GTK are bad. > > On all of my computers, wxPython uses Gtk. There are other choices > for wxWidget backends on Linux, but Gtk is by far the most common. > IOW, if Gtk is bad, then wxPython is bad. Not true. Gtk is accessible under Linux but it is not accessible under Windows. I am not talking from the perspective of what the GUI creators say, but about the reality. Adobe and Microsoft say that Flash and Silverlight are accessible because they offer accessibility features, but this is practically absolutely unimportant for the users, because the current screen readers don't offer support for them, so they are hard accessible respectively not accessible. I don't know why Gtk is not accessible under Windows but it can be accessed fine under Linux with Orca screen reader. Either it doesn't offer the accessibility features in its Windows version, or it offers the same thing under Windows but the screen readers that work under Windows don't offer support for it. I'd say that Silverlight is pretty new and it is expected that it is not accessible, but Gtk, QT and Tk are old enough but there is no support for them yet. Under Windows there are open source screen readers also, one of them beeing NVDA, which is made in Python, so we are not talking only about commercial programs that might not offer this support because of a commercial interest, however those screen readers don't offer support for those GUIS. Orca, the most used screen reader used under Linux is also made in Python, but under Linux it can access fine the Gtk interface. So I don't know why, but maybe it is hard for the screen reader manufacturers to make them support absolutely all the possible interfaces so they choose to support only the most used GUI under each OS. So the better term would be "the most used GUI type" and not "the default GUI type" for each OS. But I as I said, all these things can be tested using that screen reader I told you about. If you use Windows, and you have an application which is made using QT, Tk or Gtk, you can download JAWS from www.freedomscientific.com, install it and try to see what you hear when you use that application and you will see that you won't hear anything, while in an application that uses wxWIDGETS or standard Win32 GUI or MFC, the most used controls are perfectly accessible. Octavian From steve+comp.lang.python at pearwood.info Wed Jan 19 16:21:29 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 19 Jan 2011 21:21:29 GMT Subject: Tkinter: The good, the bad, and the ugly! References: Message-ID: <4d3755d9$0$29983$c3e8da3$5496439d@news.astraweb.com> On Wed, 19 Jan 2011 12:45:22 -0800, Patty wrote: > On Wed, Jan 19, 2011 at 10:22 AM, wrote: >> >> Now I think I understand a little better where you all are coming from >> -- I am a Unix person and I guess I expected to have to learn GUI's >> using whatever is provided for me by default. Which isn't a bad thing. >> And if I had to add additional software - and learn that - so be it. I >> am using a Windows XP system and a Windows 7 system presently. Some day >> I would like to switch out the Windows XP for Unix. > > Just dual boot, it isn't hard. > > > True. I have a Compaq Presario that is so old hardware-wise that I > don't think it could handle Unix or Linux. I think you have that backwards. You can usually run recent Linux on *much* older and cruftier hardware than will run recent Windows. You may have to forgo using the two heavyweight window managers, Gnome and KDE, in favour of a lightweight window manager, but some people would argue that's a benefit rather than a loss :) Here's an article that might be of interest: http://www.desktoplinux.com/articles/AT6185716632.html -- Steven From rantingrick at gmail.com Wed Jan 19 16:24:07 2011 From: rantingrick at gmail.com (rantingrick) Date: Wed, 19 Jan 2011 13:24:07 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <0fa4603c-6e27-4ee5-9761-000a61cd19a4@fx12g2000vbb.googlegroups.com> <2510bf88-1045-411f-9ccd-7ca7c3665454@l24g2000vby.googlegroups.com> <2ef2fa6c-2ccf-453a-8f50-0ef7dbd7834d@j32g2000yqc.googlegroups.com> <5c6ff40f-05c1-4e38-89bc-b8c4745db7ce@i18g2000yqn.googlegroups.com> <9a036db2-9f32-441f-aa0f-698ac22fb152@e20g2000vbn.googlegroups.com> Message-ID: <889f649f-6c35-4210-bd8d-1bf1a5c255ea@w2g2000yqb.googlegroups.com> On Jan 19, 12:22?pm, pa... at cruzio.com wrote: > Who or what group is actually in charge of what libraries (and programming > commands/methods such as the Python 3.x rewrite of 'print') goes into > Python? ? Well it comes down to "Guido, some Guys, and a mailing list". see this link fro more detail... http://www.python.org/dev/intro/ > Is this huge discussion really a few feature requests for > additional libraries to be included for Windows programming? No, this HUGE discussion is primarily about the worth of Tkinter as our chosen GUI module and whether or not we should replace it. It also contains (and rightly so!) undertones as to the lost vision within this community as a whole. Not to mention the missing cohesiveness to move forward in the correct direction. > ?And aren't > some of these libraries developed by 3rd parties? ? Yes Python has many 3rd party packages available. You should familiarize yourself with both the current stdlib AND the packages list. Both are here... http://pypi.python.org/pypi?:action=index http://docs.python.org/release/3.0.1/modindex.html > And how is that handled > by the people in charge? ?Do they have to pay to license it or is this all > freely contributed software? This statement needs clarification because i cannot decide if you are asking from a Python stdlib perspective or a 3rd party package perspective. In any event Python and the stdlib should be all free and open software. And shame on anyone who releases closed source software! Shame on you greedies! Shame on you! >:( From martin at address-in-sig.invalid Wed Jan 19 16:38:30 2011 From: martin at address-in-sig.invalid (Martin Gregorie) Date: Wed, 19 Jan 2011 21:38:30 +0000 (UTC) Subject: Tkinter: The good, the bad, and the ugly! References: Message-ID: On Wed, 19 Jan 2011 12:45:22 -0800, Patty wrote: > ----- Original Message ----- > From: "geremy condra" To: > On Wed, Jan 19, 2011 at 10:22 AM, wrote: >> >> Now I think I understand a little better where you all are coming from >> -- I am a Unix person and I guess I expected to have to learn GUI's >> using whatever is provided for me by default. Which isn't a bad thing. >> And if I had to add additional software - and learn that - so be it. I >> am using a Windows XP system and a Windows 7 system presently. Some day >> I would like to switch out the Windows XP for Unix. > > Just dual boot, it isn't hard. > IME you'll find that networking a Windows box to an older, slower PC thats rescued from the attic will be much more useful than a single dual-boot arrangement. Linux will run at a usable speed on a PC with 512 MB RAM and an 866 MHz P3, though some things, such as logging in, will be slow with a graphical desktop (runlevel 5), but if it has more RAM or you run an X-server on another PC, which could be running Windows, you'll execute commands, including graphical ones - provided you have X.11 forwarding enabled, a lot faster. The Linux box can also be headless if you haven't a screen and keyboard to spare. In short, Linux will run well on a PC that can't run anything more recent than Win98 at an acceptable speed. It doesn't need a lot of disk either - anything more than 30 GB will do. However, an optical drive is needed for installation. You can install Fedora from a CD drive provided the box is networked so it can retrieve most of its packages over the net, but using a DVD drive would be easier for a first install. > True. I have a Compaq Presario that is so old hardware-wise that I > don't think it could handle Unix or Linux. > What speed and type of CPU does it use? How much RAM? What's about disk and optical drives? FWIW my house server is an IMB Netvista that is at least 10 years old - 866MHz P3, 512 GB RAM, LG DVD drive, new 160GB hdd and runs Fedora 13. It is a bit slow at runlevel 5 (graphical desktop) when driven from its own console, but I usually access it over the house net from a more modern Core Duo laptop that runs Fedora 14. The NetVista is more than adequate for web and RDBMS development (Apache and PostgreSQL) in Python or Java and very fast for C compilation. -- martin@ | Martin Gregorie gregorie. | Essex, UK org | From steve+comp.lang.python at pearwood.info Wed Jan 19 16:43:12 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 19 Jan 2011 21:43:12 GMT Subject: __pycache__, one more good reason to stck with Python 2? References: <23e02e0d-b2f1-4b52-85ea-d1feba99dd37@22g2000prx.googlegroups.com> <4d3466d3$0$29983$c3e8da3$5496439d@news.astraweb.com> <0c62aacd-e6d2-4778-81d6-e06924192add@j1g2000vbl.googlegroups.com> <87vd1m6ezq.fsf@benfinney.id.au> <992b11a0-d35d-4b08-98ab-d08c90a86ec7@j1g2000vbl.googlegroups.com> <4d36f846$0$29983$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4d375af0$0$29983$c3e8da3$5496439d@news.astraweb.com> On Wed, 19 Jan 2011 11:30:36 -0800, Carl Banks wrote: > On Jan 19, 6:42?am, Steven D'Aprano +comp.lang.pyt... at pearwood.info> wrote: >> But having said that, the __pycache__ idea isn't too bad. If you have >> this directory structure: >> >> ./module.py >> ./module.pyc >> >> and import module, the top-level .pyc file will continue to be used. > > Nope. PEP 3147 says it now always uses __pycache__. Looks like the PEP is outdated then. [steve at sylar ~]$ rm __pycache__/* [steve at sylar ~]$ echo "print('spam spam spam')" > spam.py [steve at sylar ~]$ python3.2 -m compileall spam.py Compiling spam.py ... [steve at sylar ~]$ mv __pycache__/spam.cpython-32.pyc ./spam.pyc [steve at sylar ~]$ python3.2 -m spam spam spam spam [steve at sylar ~]$ ls __pycache__/ [steve at sylar ~]$ -- Steven From invalid at invalid.invalid Wed Jan 19 16:51:22 2011 From: invalid at invalid.invalid (Grant Edwards) Date: Wed, 19 Jan 2011 21:51:22 +0000 (UTC) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <4d337983$0$29983$c3e8da3$5496439d@news.astraweb.com> <044a5101-948d-4458-9c94-57dbb3e25f67@m35g2000vbn.googlegroups.com> <4d3467bf$0$29983$c3e8da3$5496439d@news.astraweb.com> <4D34B04E.8050309@web.de> <4266E8D7BA204BFEA5BF66C635CE1716@octavian> <4D35DCE8.5030002@web.de> <4D35DD47.1070304@web.de> <42924000-3ffb-40f5-9cf8-70a9d767b944@k25g2000vbl.googlegroups.com> Message-ID: On 2011-01-19, Octavian Rasnita wrote: > From: "Grant Edwards" > >>> WxPython is not perfect but most of the objects it offers are >>> accessible so this is not true. Only Tk and GTK are bad. >> >> On all of my computers, wxPython uses Gtk. There are other choices >> for wxWidget backends on Linux, but Gtk is by far the most common. >> IOW, if Gtk is bad, then wxPython is bad. > > Not true. I think you're playing a bit fast and loose with your accusations. Which of my statements was "not true"? 1) On all of my computers wxPython uses Gtk. 2) There are other backend choices on Linux besides Gtk. 3) Gtk is by far the most common wxWidgets backend on Linux/Unix. 4) If Gtk is bad then wxPython is bad. Note that 4) follows logically from 3), so to say that 4) is "not true" you have to show that 3) is "not true". -- Grant Edwards grant.b.edwards Yow! WHOA!! Ken and Barbie at are having TOO MUCH FUN!! gmail.com It must be the NEGATIVE IONS!! From tjreedy at udel.edu Wed Jan 19 16:57:40 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Wed, 19 Jan 2011 16:57:40 -0500 Subject: Screen readers for Tkinter (was Re: Tkinter: The good, the bad, and the ugly!) In-Reply-To: <5296E6FB68964C239A84C2AF4007D2DD@teddy> References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com><4d337983$0$29983$c3e8da3$5496439d@news.astraweb.com><044a5101-948d-4458-9c94-57dbb3e25f67@m35g2000vbn.googlegroups.com><4d3467bf$0$29983$c3e8da3$5496439d@news.astraweb.com><4D34B04E.8050309@web.de><4266E8D7BA204BFEA5BF66C635CE1716@octavian><4D35DCE8.5030002@web.de> <1295448820.26438.1416115629@webmail.messagingengine.com> <5296E6FB68964C239A84C2AF4007D2DD@teddy> Message-ID: On 1/19/2011 11:27 AM, Octavian Rasnita wrote: >> Note: Currently, accessibility is only available via ATK<=> AT-SPI on >> Linux. Sorry, no Windows MSAA support. > > > This project is good, a step ahead, but in order to be really useful it should be the one provided by the default Python package. > And of course, it should also offer support for Windows, since most of the computer users use Windows, especially those who need accessibility features. Octavian Please consider adding an 'Accessibility' page to the Python wiki with your info and the above for those interested. -- Terry Jan Reedy From rantingrick at gmail.com Wed Jan 19 17:01:12 2011 From: rantingrick at gmail.com (rantingrick) Date: Wed, 19 Jan 2011 14:01:12 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <4d337983$0$29983$c3e8da3$5496439d@news.astraweb.com> <044a5101-948d-4458-9c94-57dbb3e25f67@m35g2000vbn.googlegroups.com> <4d3467bf$0$29983$c3e8da3$5496439d@news.astraweb.com> <4D34B04E.8050309@web.de> <4266E8D7BA204BFEA5BF66C635CE1716@octavian> <4D35DCE8.5030002@web.de> <4D35DD47.1070304@web.de> <42924000-3ffb-40f5-9cf8-70a9d767b944@k25g2000vbl.googlegroups.com> Message-ID: <2b782e9e-3b9a-4e95-9d4f-ac60b823078d@g25g2000yqn.googlegroups.com> On Jan 19, 3:51?pm, Grant Edwards wrote: > On 2011-01-19, Octavian Rasnita wrote: > Which of my statements was "not true"? > > ?1) On all of my computers wxPython uses Gtk. > > ?2) There are other backend choices on Linux besides Gtk. > > ?3) Gtk is by far the most common wxWidgets backend on Linux/Unix. > > ?4) If Gtk is bad then wxPython is bad. > > Note that 4) follows logically from 3), so to say that 4) is "not > true" you have to show that 3) is "not true". All of these folks that keep blabbing about how they may need "this" dependency or "that" dependency on Linux/Unix either need to shut up or convert to a windows box with a nice installer exe that will hold your wiener while you pee. Really, you're only going to fool the lemmings with such BS arguments! Stop whining, you choose to use an advanced OS and stop blaming the rest of the world because of your choices! From alice at gothcandy.com Wed Jan 19 17:31:15 2011 From: alice at gothcandy.com (=?utf-8?Q?Alice_Bevan=E2=80=93McGregor?=) Date: Wed, 19 Jan 2011 14:31:15 -0800 Subject: __pycache__, one more good reason to stck with Python 2? References: <23e02e0d-b2f1-4b52-85ea-d1feba99dd37@22g2000prx.googlegroups.com> <4d3466d3$0$29983$c3e8da3$5496439d@news.astraweb.com> <0c62aacd-e6d2-4778-81d6-e06924192add@j1g2000vbl.googlegroups.com> <87vd1m6ezq.fsf@benfinney.id.au> <992b11a0-d35d-4b08-98ab-d08c90a86ec7@j1g2000vbl.googlegroups.com> <4d36f846$0$29983$c3e8da3$5496439d@news.astraweb.com> <4d37510f$0$29983$c3e8da3$5496439d@news.astraweb.com> Message-ID: On 2011-01-19 13:01:04 -0800, Steven D'Aprano said: > I know I've seen problems executing .pyc files from the shell in the > past... perhaps I was conflating details of something else. Ah, I know! > > [steve at sylar ~]$ chmod u+x toto.pyc > [steve at sylar ~]$ ./toto.pyc > : command not found ?? > ./toto.pyc: line 2: syntax error near unexpected token `(' > ./toto.pyc: line 2: `P7Mc at s dGHdS(tfooN((((s ./ > toto.pys' ... don't do that. I do not know why that would be expected to work, ever. (Unless you're crafty and wrap a real shell script around the .pyc, in which case it's no longer a .pyc.) ? Alice. From tjreedy at udel.edu Wed Jan 19 17:33:43 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Wed, 19 Jan 2011 17:33:43 -0500 Subject: UTF-8 question from Dive into Python 3 In-Reply-To: References: Message-ID: On 1/19/2011 1:02 PM, Tim Harig wrote: > Right, but I only have to do that once. After that, I can directly address > any piece of the stream that I choose. If I leave the information as a > simple UTF-8 stream, I would have to walk the stream again, I would have to > walk through the the first byte of all the characters from the beginning to > make sure that I was only counting multibyte characters once until I found > the character that I actually wanted. Converting to a fixed byte > representation (UTF-32/UCS-4) or separating all of the bytes for each > UTF-8 into 6 byte containers both make it possible to simply index the > letters by a constant size. You will note that Python does the former. The idea of using a custom fixed-width padded version of a UTF-8 steams waw initially shocking to me, but I can imagine that there are specialized applications, which slice-and-dice uninterpreted segments, for which that is appropriate. However, it is not germane to the folly of prefixing standard UTF-8 steams with a 3-byte magic number, mislabelled a 'byte-order-mark, thus making them non-standard. -- Terry Jan Reedy From tyler at tysdomain.com Wed Jan 19 17:40:18 2011 From: tyler at tysdomain.com (Littlefield, Tyler) Date: Wed, 19 Jan 2011 15:40:18 -0700 Subject: Screen readers for Tkinter (was Re: Tkinter: The good, the bad, and the ugly! Message-ID: <4D376852.6040100@tysdomain.com> >And of course, it should also offer support for Windows, since most of the computer users use Windows, especially those who need accessibility features. uh. no, and no. Plenty of those utilizing screen readers are using macs nowadays, as well as vinux or some derivitave there of. -- Thanks, Ty From askutt at gmail.com Wed Jan 19 17:40:35 2011 From: askutt at gmail.com (Adam Skutt) Date: Wed, 19 Jan 2011 14:40:35 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com><4d337983$0$29983$c3e8da3$5496439d@news.astraweb.com><044a5101-948d-4458-9c94-57dbb3e25f67@m35g2000vbn.googlegroups.com><4d3467bf$0$29983$c3e8da3$5496439d@news.astraweb.com><4D34B04E.8050309@web.de><4266E8D7BA204BFEA5BF66C635CE1716@octavian><4D35DCE8.5030002@web.de><4D35DD47.1070304@web.de><7A0C7934E65D4B85A584C06ADD3B6ECF@teddy> Message-ID: <799d1f10-f2b3-41fb-ade2-d31ff19918e5@t23g2000vby.googlegroups.com> On Jan 19, 4:04?pm, "Octavian Rasnita" wrote: > Those rules for creating an accessible application are obvious; like the fact that a button need to contain a text label and not only an image, or that an image needs to have a tooltip defined, or that a radio button needs to have a label attached to it, but all those things can be solved by the programmer and usually the programmer create those text labels. > The fact that /every/ toolkit provides accessibility guidelines over and above whatever other UI guidelines they provide tells me that creating an accessible application is hardly obvious. Plus, if it were really that simple, the accessibility situation wouldn't be so poor. > Yes, those things should be followed for creating a better app, but what I wanted to say is that no matter if you do those things or not in a Tk, Gtk or QT GUI, they will be useless, because the screen readers can't understand those GUIS even they have text labels, and even if you will see a focus rectangle around buttons. They don't report that those objects have the focus so the screen readers won't speak anything. Your "something is better than nothing" argument isn't particularly compelling to me personally as a justification for ripping out TkInter. And Qt is the only toolkit with some level of functioning accessibility support on all three major platforms, assuming the library and software are built correctly, so again, your argument is really for Qt, not for wxWidgets. Adam From rantingrick at gmail.com Wed Jan 19 18:04:37 2011 From: rantingrick at gmail.com (rantingrick) Date: Wed, 19 Jan 2011 15:04:37 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <0fa4603c-6e27-4ee5-9761-000a61cd19a4@fx12g2000vbb.googlegroups.com> <2510bf88-1045-411f-9ccd-7ca7c3665454@l24g2000vby.googlegroups.com> <2ef2fa6c-2ccf-453a-8f50-0ef7dbd7834d@j32g2000yqc.googlegroups.com> <5c6ff40f-05c1-4e38-89bc-b8c4745db7ce@i18g2000yqn.googlegroups.com> <9a036db2-9f32-441f-aa0f-698ac22fb152@e20g2000vbn.googlegroups.com> Message-ID: <981140f7-79d4-421d-88c1-c819f38a3d49@w2g2000yqb.googlegroups.com> On Wed, Jan 19, 2011 at 1:40 PM, geremy condra wrote: > On Wed, Jan 19, 2011 at 11:37 AM, geremy condra wrote: >> No, it's about other operating systems too, but what it comes down to >> is that rantingrick has been on the warpath about tkinter for a while, >> and hasn't proposed a particularly viable alternative. The sad thing >> is that if he weren't so unhinged his proposal would probably fare >> much better Look, the folks are c.l.py are far too touchy and they really need to lighten up. Really! The fact that my speech style and delivery does not fit some "cookie cutter" pre-directive is just BS. The Python community is NOT a homogeneous block you know, and it should not be! People have said to me in the past..."""Well you could participate at python-dev or python-ideas or the tracker but NOT as ranting rick, you need to use a better name"""... What? What does it matter what my name is anyway. This is just being pedantic!! > Sorry for the truncation. I was going to say that I know I would be > more supportive of it if he was building support for something instead > of tearing everything else down. I am not "tearing down" anything, however that was a nice try Geremy *wink*. The only thing that is being "torn down" is the solid wall of rabid resistance that has been slowly built by this community over many years. We have become too centralized and many folks are being left out of the community decision process. You (and others) act like my only concern is to destroy what has been built (Tkinter) and that is not the case! But like old governments, YOU (the python elite!) have lost all vision for the future. And you've also lost all connection with the people. I am desperately trying to to snap you out of this psychosis before it is too late! Tkinter will be the downfall of Python if we cannot muster the resolve to replace it with something that is current (or more current) technology. Stop fearing change and re-ignite the vision that GvR once had. From rantingrick at gmail.com Wed Jan 19 18:12:15 2011 From: rantingrick at gmail.com (rantingrick) Date: Wed, 19 Jan 2011 15:12:15 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com><4d337983$0$29983$c3e8da3$5496439d@news.astraweb.com><044a5101-948d-4458-9c94-57dbb3e25f67@m35g2000vbn.googlegroups.com><4d3467bf$0$29983$c3e8da3$5496439d@news.astraweb.com><4D34B04E.8050309@web.de><4266E8D7BA204BFEA5BF66C635CE1716@octavian><4D35DCE8.5030002@web.de><4D35DD47.1070304@web.de><7A0C7934E65D4B85A584C06ADD3B6ECF@teddy> Message-ID: On Jan 19, 4:40?pm, Adam Skutt wrote: > On Jan 19, 4:04?pm, "Octavian Rasnita" wrote: > > > Those rules for creating an accessible application are obvious; like the fact that a button need to contain a text label and not only an image, or that an image needs to have a tooltip defined, or that a radio button needs to have a label attached to it, but all those things can be solved by the programmer and usually the programmer create those text labels. > > The fact that /every/ toolkit provides accessibility guidelines over > and above whatever other UI guidelines they provide tells me that > creating an accessible application is hardly obvious. ?Plus, if it > were really that simple, the accessibility situation wouldn't be so > poor. > > > Yes, those things should be followed for creating a better app, but what I wanted to say is that no matter if you do those things or not in a Tk, Gtk or QT GUI, they will be useless, because the screen readers can't understand those GUIS even they have text labels, and even if you will see a focus rectangle around buttons. They don't report that those objects have the focus so the screen readers won't speak anything. > > Your "something is better than nothing" argument isn't particularly > compelling to me personally as a justification for ripping out > TkInter. ?And Qt is the only toolkit with some level of functioning > accessibility support on all three major platforms, assuming the > library and software are built correctly, so again, your argument is > really for Qt, not for wxWidgets. > > Adam Adam, please use the following style when posting to this group...Thanks. On Jan 19, 4:04 pm, "Octavian Rasnita" wrote: > Those rules for creating an accessible application are obvious; like > the fact that a button need to contain a text label and not only an > image, or that an image needs to have a tooltip defined, or that a > radio button needs to have a label attached to it, but all those > things can be solved by the programmer and usually the programmer > create those text labels. The fact that /every/ toolkit provides accessibility guidelines over and above whatever other UI guidelines they provide tells me that creating an accessible application is hardly obvious. Plus, if it were really that simple, the accessibility situation wouldn't be so poor. > Yes, those things should be followed for creating a better app, but > what I wanted to say is that no matter if you do those things or not > in a Tk, Gtk or QT GUI, they will be useless, because the screen > readers can't understand those GUIS even they have text labels, and > even if you will see a focus rectangle around buttons. They don't > report that those objects have the focus so the screen readers won't > speak anything. Your "something is better than nothing" argument isn't particularly compelling to me personally as a justification for ripping out TkInter. And Qt is the only toolkit with some level of functioning accessibility support on all three major platforms, assuming the library and software are built correctly, so again, your argument is really for Qt, not for wxWidgets. Adam From patty at cruzio.com Wed Jan 19 18:16:01 2011 From: patty at cruzio.com (Patty) Date: Wed, 19 Jan 2011 15:16:01 -0800 Subject: Tkinter: The good, the bad, and the ugly! Message-ID: On Jan 19, 12:22 pm, pa... at cruzio.com wrote: > Who or what group is actually in charge of what libraries (and programming > commands/methods such as the Python 3.x rewrite of 'print') goes into > Python? Well it comes down to "Guido, some Guys, and a mailing list". see this link fro more detail... http://www.python.org/dev/intro/ Well that explains Everything! > Is this huge discussion really a few feature requests for > additional libraries to be included for Windows programming? No, this HUGE discussion is primarily about the worth of Tkinter as our chosen GUI module and whether or not we should replace it. It also contains (and rightly so!) undertones as to the lost vision within this community as a whole. Not to mention the missing cohesiveness to move forward in the correct direction. I see why you say this. I think I am playing catchup with what has been going on for some time amongst you all. > And aren't > some of these libraries developed by 3rd parties? Yes Python has many 3rd party packages available. You should familiarize yourself with both the current stdlib AND the packages list. Both are here... http://pypi.python.org/pypi?:action=index http://docs.python.org/release/3.0.1/modindex.html > And how is that handled > by the people in charge? Do they have to pay to license it or is this all > freely contributed software? This statement needs clarification because i cannot decide if you are asking from a Python stdlib perspective or a 3rd party package perspective. In any event Python and the stdlib should be all free and open software. And shame on anyone who releases closed source software! Shame on you greedies! Shame on you! >:( And I am coming from background working at SCO for commercial SCO Unix and also commercial applications software. So free software is not something I am used to :) And understand what is involved with obtaining 3rd party pieces either by necessity or because of an acquistion. And the money part. It was complicated. So I was thinking from the python stdlib perspective. But your comment turned my thinking around to where it should be to discuss open source software. I don't think I am ready for the py-dev mailing list yet ;) But I do have some big ideas because of UCSC (University of California, Santa Cruz) being so close, their Computer Engineering Dept. is Really Good and I have some connections up there..... Patty -- http://mail.python.org/mailman/listinfo/python-list -------------- next part -------------- An HTML attachment was scrubbed... URL: From rantingrick at gmail.com Wed Jan 19 18:21:53 2011 From: rantingrick at gmail.com (rantingrick) Date: Wed, 19 Jan 2011 15:21:53 -0800 (PST) Subject: move to end, in Python 3.2 Really? References: <58c17709-d68e-4448-b618-b6f594d0e8c5@t35g2000yqj.googlegroups.com> <125db7fe-036e-47c9-be89-50f05106936f@n2g2000pre.googlegroups.com> Message-ID: <62f52f79-ab73-4e1d-89b0-e832f50c8807@v17g2000yqv.googlegroups.com> On Jan 19, 9:18?am, Grant Edwards wrote: > And an unmoderated Usenet newsgroup (which has even less of a chain of > command than a mailing list). Moderated status has nothing to do with it. The fact is that the "elite" no longer feel it necessary to care about the troubles of the Python peasants. This is evident by no posting from GvR for many years, and no posting from his subordinate (and the PSF chair!) Steve Holden. The last time Steve and i "rubbed shoulders" was when i chastised him for engaging in trollish behavior. So now i get it... He has time for trolling and flaming but no time for real discussion on topics that concern the very future evolution of this language? hmm. From andre.roberge at gmail.com Wed Jan 19 18:26:10 2011 From: andre.roberge at gmail.com (=?ISO-8859-1?Q?Andr=E9?=) Date: Wed, 19 Jan 2011 15:26:10 -0800 (PST) Subject: move to end, in Python 3.2 Really? In-Reply-To: <62f52f79-ab73-4e1d-89b0-e832f50c8807@v17g2000yqv.googlegroups.com> Message-ID: <88d57c7f-47d1-4961-b0d2-7d3471fc6650@glegroupsg2000goo.googlegroups.com> On Wednesday, January 19, 2011 7:21:53 PM UTC-4, rantingrick wrote: > On Jan 19, 9:18?am, Grant Edwards wrote: > > > And an unmoderated Usenet newsgroup (which has even less of a chain of > > command than a mailing list). > > Moderated status has nothing to do with it. The fact is that the > "elite" no longer feel it necessary to care about the troubles of the > Python peasants. This is evident by no posting from GvR for many > years, and no posting from his subordinate (and the PSF chair!) Steve > Holden. The last time Steve and i "rubbed shoulders" was when i > chastised him for engaging in trollish behavior. So now i get it... He > has time for trolling and flaming but no time for real discussion on > topics that concern the very future evolution of this language? hmm. Perhaps it is because they are either busy programming and/or busy organizing Pycon 2011. Some people do a lot, some people talk/write a lot. It is hard to find the time to do both ... From patty at cruzio.com Wed Jan 19 18:36:18 2011 From: patty at cruzio.com (Patty) Date: Wed, 19 Jan 2011 15:36:18 -0800 Subject: Tkinter: The good, the bad, and the ugly! Message-ID: <1E425CF2D2A449209115BC876FDA3555@mycomputer> On Wed, 19 Jan 2011 12:45:22 -0800, Patty wrote: > ----- Original Message ----- > From: "geremy condra" To: > On Wed, Jan 19, 2011 at 10:22 AM, wrote: >> >> Now I think I understand a little better where you all are coming from >> -- I am a Unix person and I guess I expected to have to learn GUI's >> using whatever is provided for me by default. Which isn't a bad thing. >> And if I had to add additional software - and learn that - so be it. I >> am using a Windows XP system and a Windows 7 system presently. Some day >> I would like to switch out the Windows XP for Unix. > > Just dual boot, it isn't hard. > IME you'll find that networking a Windows box to an older, slower PC thats rescued from the attic will be much more useful than a single dual-boot arrangement. Linux will run at a usable speed on a PC with 512 MB RAM and an 866 MHz P3, though some things, such as logging in, will be slow with a graphical desktop (runlevel 5), but if it has more RAM or you run an X-server on another PC, which could be running Windows, you'll execute commands, including graphical ones - provided you have X.11 forwarding enabled, a lot faster. The Linux box can also be headless if you haven't a screen and keyboard to spare. In short, Linux will run well on a PC that can't run anything more recent than Win98 at an acceptable speed. It doesn't need a lot of disk either - anything more than 30 GB will do. However, an optical drive is needed for installation. You can install Fedora from a CD drive provided the box is networked so it can retrieve most of its packages over the net, but using a DVD drive would be easier for a first install. > True. I have a Compaq Presario that is so old hardware-wise that I > don't think it could handle Unix or Linux. > What speed and type of CPU does it use? How much RAM? What's about disk and optical drives? FWIW my house server is an IMB Netvista that is at least 10 years old - 866MHz P3, 512 GB RAM, LG DVD drive, new 160GB hdd and runs Fedora 13. It is a bit slow at runlevel 5 (graphical desktop) when driven from its own console, but I usually access it over the house net from a more modern Core Duo laptop that runs Fedora 14. The NetVista is more than adequate for web and RDBMS development (Apache and PostgreSQL) in Python or Java and very fast for C compilation. -- martin@ | Martin Gregorie gregorie. | Essex, UK org | -- http://mail.python.org/mailman/listinfo/python-list Martin and Geremy - thank you for the suggestions. My Compaq Presario I know is maxed out on memory and I checked and my Maxtor drive says it is 28624 MB. I don't know if that is enough? I have my HP Mini Netbook running Windows 7 and do my Python programming on it. It is awesome! I don't really care if my Compaq had Windows XP plus Linux or just Linux. I would be happy to just back up what I want and install Linux for the whole Compaq and just have the two communicate. I really use the Compaq more as an email and file archive. I would probably rethink which software programming tools and languages I would want on each machine. I consider myself a C programmer and SQL and I am a linguist - several programming languages - so I would be more likely to want compilers and interpreters, favorite IDEs installed on whichever system. Patty -------------- next part -------------- An HTML attachment was scrubbed... URL: From rantingrick at gmail.com Wed Jan 19 18:42:57 2011 From: rantingrick at gmail.com (rantingrick) Date: Wed, 19 Jan 2011 15:42:57 -0800 (PST) Subject: move to end, in Python 3.2 Really? References: <88d57c7f-47d1-4961-b0d2-7d3471fc6650@glegroupsg2000goo.googlegroups.com> Message-ID: <91b73dea-8ca6-4f27-a300-fb21619dbec0@l17g2000yqe.googlegroups.com> On Jan 19, 5:26?pm, Andr? wrote: > Perhaps it is because they are either busy programming and/or busy > organizing Pycon 2011. Some people do a lot, some people talk/write > a lot. It is hard to find the time to do both ... Well perhaps. I am not suggesting that these people are not working on important issues. I am just pointing out an incident with Steve that could have been better spent on real discussion and not a flame war. Look, i am no perfect person and i do not expect that Steve is either. However attempting to say that somehow my work --engaging the community through lively debate in an attempt to re-energize the Python spirit GvR created so long ago that has now waxed cold-- is somehow less important than Steve's or anyones work is a little condescending to say the least. It takes many stones to build a house. And sometimes after you build the house you find the foundation is cracking. This could be due to poor planning in the design phase (which is not the case with Tkinter!!) OR it could be due to soil that is grown unstable (This is the case with Tkinter!!). Repairing a foundation after the fact is always going to be hard work but someone has do it. Someone has to gather the crew and create a battle plan. Well, thats me. However i cannot do this alone. I need the rest of you guys to share the load. From debatem1 at gmail.com Wed Jan 19 19:01:01 2011 From: debatem1 at gmail.com (geremy condra) Date: Wed, 19 Jan 2011 16:01:01 -0800 Subject: Tkinter: The good, the bad, and the ugly! In-Reply-To: <981140f7-79d4-421d-88c1-c819f38a3d49@w2g2000yqb.googlegroups.com> References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <0fa4603c-6e27-4ee5-9761-000a61cd19a4@fx12g2000vbb.googlegroups.com> <2510bf88-1045-411f-9ccd-7ca7c3665454@l24g2000vby.googlegroups.com> <2ef2fa6c-2ccf-453a-8f50-0ef7dbd7834d@j32g2000yqc.googlegroups.com> <5c6ff40f-05c1-4e38-89bc-b8c4745db7ce@i18g2000yqn.googlegroups.com> <9a036db2-9f32-441f-aa0f-698ac22fb152@e20g2000vbn.googlegroups.com> <981140f7-79d4-421d-88c1-c819f38a3d49@w2g2000yqb.googlegroups.com> Message-ID: On Wed, Jan 19, 2011 at 3:04 PM, rantingrick wrote: > > On Wed, Jan 19, 2011 at 1:40 PM, geremy condra > wrote: >> On Wed, Jan 19, 2011 at 11:37 AM, geremy condra wrote: >>> No, it's about other operating systems too, but what it comes down to >>> is that rantingrick has been on the warpath about tkinter for a while, >>> and hasn't proposed a particularly viable alternative. The sad thing >>> is that if he weren't so unhinged his proposal would probably fare >>> much better > > Look, the folks are c.l.py are far too touchy and they really need to > lighten up. Really! The fact that my speech style and delivery does > not fit some "cookie cutter" pre-directive is just BS. The Python > community is NOT a homogeneous block you know, and it should not be! > People have said to me in the past..."""Well you could participate at > python-dev or python-ideas or the tracker but NOT as ranting rick, you > need to use a better name"""... What? What does it matter what my name > is anyway. This is just being pedantic!! I'm not telling you to change your behavior. I'm telling you that the way you're doing things isn't effective. You can take that advice or not, just as I can decide to listen to you... or not. I also wouldn't advise you to change your name again. I think you've already landed on a couple of spam lists for that. >> Sorry for the truncation. I was going to say that I know I would be >> more supportive of it if he was building support for something instead >> of tearing everything else down. > > I am not "tearing down" anything, however that was a nice try Geremy > *wink*. The only thing that is being "torn down" is the solid wall of > rabid resistance that has been slowly built by this community over > many years. I don't think this is the case, first because you aren't very good at getting anybody to take you seriously and second because I don't think that resistance on this issue is as mindless as you claim. > We have become too centralized and many folks are being > left out of the community decision process. I disagree with the first half. The second I'm more prone to agree with, although I don't have a lot of great ideas about how to solve the problem. You seem to be full of ideas (most of which I think are terrible) but very short on actually getting anything done. Until you begin to remedy that I doubt very many people here will take you as seriously as you seem to want. Also, be careful with where you say 'we'- I certainly don't recognize your authority to speak on behalf of the community, and I suspect that an overwhelming majority of the community's other members feel the same way. > You (and others) act like > my only concern is to destroy what has been built (Tkinter) and that > is not the case! Seems like it from where I'm sitting. YMMV, but I think you would do much better if you focused on the problem of building a system that addressed the concerns others have raised rather than pretending they aren't valid concerns. > But like old governments, YOU (the python elite!) > have lost all vision for the future. Hey, cool, I'm a member of the elite now. You wouldn't happen to know how to list that on a resume, would you? > And you've also lost all > connection with the people. I am desperately trying to to snap you out > of this psychosis before it is too late! Tkinter will be the downfall > of Python if we cannot muster the resolve to replace it with something > that is current (or more current) technology. Citation needed. Geremy Condra From debatem1 at gmail.com Wed Jan 19 19:41:18 2011 From: debatem1 at gmail.com (geremy condra) Date: Wed, 19 Jan 2011 16:41:18 -0800 Subject: move to end, in Python 3.2 Really? In-Reply-To: <91b73dea-8ca6-4f27-a300-fb21619dbec0@l17g2000yqe.googlegroups.com> References: <88d57c7f-47d1-4961-b0d2-7d3471fc6650@glegroupsg2000goo.googlegroups.com> <91b73dea-8ca6-4f27-a300-fb21619dbec0@l17g2000yqe.googlegroups.com> Message-ID: On Wed, Jan 19, 2011 at 3:42 PM, rantingrick wrote: > Look, i am no perfect person and i do not expect that Steve is either. > However attempting to say that somehow my work --engaging the > community through lively debate in an attempt to re-energize the > Python spirit GvR created so long ago that has now waxed cold-- is > somehow less important than Steve's or anyones work is a little > condescending to say the least. Condescending or not, it's true. Geremy Condra From ckaynor at zindagigames.com Wed Jan 19 19:51:23 2011 From: ckaynor at zindagigames.com (Chris Kaynor) Date: Wed, 19 Jan 2011 16:51:23 -0800 Subject: collections.Set Binary Reflected Operations Message-ID: I am implemented a custom set-like type which interacts with some third-party software when retrieving and mutating the set, and have derived my custom type off of collections.MutableSet, however I have noticed that some of the magic methods supported by the built-in set do not fully function with my custom type. From this, I looked over the MutableSet definition in and it seems to be missing all of the reflected operators (__rsub__, __rand__, __ror__, __rxor__, and friends) for the operators it has defined. I can post a simple example case if desired. I am using Python 2.6.4 (with some in-house customizations), however a quick look over the svn repository shown on python.org makes it appear that these are also not implemented in Python 3. I was wondering if there is some reason for this, or if it was merely an oversight. Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: From rantingrick at gmail.com Wed Jan 19 19:53:17 2011 From: rantingrick at gmail.com (rantingrick) Date: Wed, 19 Jan 2011 16:53:17 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <2ef2fa6c-2ccf-453a-8f50-0ef7dbd7834d@j32g2000yqc.googlegroups.com> <5c6ff40f-05c1-4e38-89bc-b8c4745db7ce@i18g2000yqn.googlegroups.com> <9a036db2-9f32-441f-aa0f-698ac22fb152@e20g2000vbn.googlegroups.com> <981140f7-79d4-421d-88c1-c819f38a3d49@w2g2000yqb.googlegroups.com> Message-ID: <0d74f3b6-e534-4762-b5f4-af1187ee3b38@32g2000yqz.googlegroups.com> On Jan 19, 6:01?pm, geremy condra wrote: > I'm not telling you to change your behavior. I'm telling you that the > way you're doing things isn't effective. You can take that advice or > not, just as I can decide to listen to you... or not. > > I also wouldn't advise you to change your name again. I think you've > already landed on a couple of spam lists for that. Yes i know! The whole "name" issue was blown out of proportion. Look i think i should explain how this whole name conundrum started. When i first came to this list you can imagine that i was not prepared to divulge every detail about my identity and personal life (as most should not!). So i choose a cryptic and nonsensical name. Yes, i made it up! And at the time i never had any inclination that i would want to get so involved with this group. Well that was then and this is now... However, after i became "known" within the community many folks started to debase any of my arguments simply on the fact that my name was anonymous. So at that time i started using my real name "Rick Johnson" and my nickname as "rantingrick". After this people then accused my of "identity hopping". Even some of the same folks who previously were complaining about my cryptic first name choice! Now they were complain that i choose to use my REAL name. Ironic eh! So what it boils down to is this... some people on this list just hate me and trying to please them is a waste of time. > > I am not "tearing down" anything, however that was a nice try Geremy > > *wink*. The only thing that is being "torn down" is the solid wall of > > rabid resistance that has been slowly built by this community over > > many years. > > I don't think this is the case, first because you aren't very good at > getting anybody to take you seriously How "self absorbed" must someone be to blame *ME* because *THEY* cannot take *ME* seriously. Is this a joke Geremy? Sadly i know it to be true however because you are not the only person who carries this attitude. > and second because I don't think > that resistance on this issue is as mindless as you claim. i have exposed the baseless, nonsensical, and argumentative stance taken by some in an effort to sway public opinion with FUD and BS. So i would say that arguing with baseless facts does constitute "rabid resistance". What else could it be? > > We have become too centralized and many folks are being > > left out of the community decision process. > > I disagree with the first half. The second I'm more prone to agree > with, although I don't have a lot of great ideas about how to solve > the problem. Well maybe you are not a visionary, however i believe we still need you in other areas. > You seem to be full of ideas (most of which I think are > terrible) but very short on actually getting anything done. Until you > begin to remedy that I doubt very many people here will take you as > seriously as you seem to want. Look, every organization needs workers, visionaries, liaisons, supervisors, etc. I seem to fit nicely into a Visionary role. Maybe that bothers you? I don't know? But we all have our place Geremy. Do you think any organization could survive simply with robotic workers and no guidance? No, and why not? Because workers cannot see the big picture. They are too focused (and rightly so) on some small detail that encompasses their job duty. Only the supervisor/visionary has the luxury of looking at the problem from a global perspective. Think of Python-dev as a car. A car is a machine. A very complicated machine that needs a driver to harness it's power and give it direction and purpose. -- someone who can see "beyond" the horizon. Someone who can read a road map and then re-calculate a path if road construction blocks the current one. Without the car the driver is nothing, and without the driver the car is nothing. But together, they are a force to reckoned with. Well, unless the driver is Asian -- then all bets are off! :-) > Also, be careful with where you say 'we'- I certainly don't recognize > your authority to speak on behalf of the community, and I suspect that > an overwhelming majority of the community's other members feel the > same way. You see! This is the resistance i am talking about. You (and others) don't want to accept me as part of the community. If you did accept me, then my speaking collectively (we) would not be troubling to you. However i do not blame you directly for this prejudice. I think it is more of a sub-conscience undercurrent that pervades this community as a whole. A fear of outsiders. A xenophobia if you will. We need to change this now! From atagar1 at gmail.com Wed Jan 19 22:11:22 2011 From: atagar1 at gmail.com (Damian Johnson) Date: Wed, 19 Jan 2011 19:11:22 -0800 Subject: Detecting Remaining Thread In-Reply-To: References: Message-ID: Disregard, I figured it out. It turns out that the threads spawned by "thread.start_new_thread" are unreported by threading.enumerate. Cheers! -Damian On Wed, Jan 19, 2011 at 9:40 AM, Damian Johnson wrote: > Hi, I've been trying to track down a familiar concurrency problem > without any success: > Unhandled exception in thread started by > Error in sys.excepthook: > > Original exception was: > > I realize that this is due to a background thread still being alive > and kicking when the application terminates (ie, a missing join() on a > helper thread). However, threading.enumerate() is reporting that > nothing except for the main thread is running at that point: > 1/19/2011 09:30:41 [INFO] Arm is shutting down. Remaining threads: > [<_MainThread(MainThread, started -1217079616)>] > > What other methods are there for troubleshooting this sort of issue? > I've triple checked that my threads are daemons and joined when > quitting but I must be missing something... > > As would be expected of a timing issue, this happens intermittently > (1/5 of the time) and goes away if I add a short sleep at the end. Any > help would be much appreciated. Thanks! -Damian > From torriem at gmail.com Wed Jan 19 22:20:47 2011 From: torriem at gmail.com (Michael Torrie) Date: Wed, 19 Jan 2011 20:20:47 -0700 Subject: Tkinter: The good, the bad, and the ugly! In-Reply-To: References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <0fa4603c-6e27-4ee5-9761-000a61cd19a4@fx12g2000vbb.googlegroups.com> <2510bf88-1045-411f-9ccd-7ca7c3665454@l24g2000vby.googlegroups.com> <2ef2fa6c-2ccf-453a-8f50-0ef7dbd7834d@j32g2000yqc.googlegroups.com> <5c6ff40f-05c1-4e38-89bc-b8c4745db7ce@i18g2000yqn.googlegroups.com> <9a036db2-9f32-441f-aa0f-698ac22fb152@e20g2000vbn.googlegroups.com> <981140f7-79d4-421d-88c1-c819f38a3d49@w2g2000yqb.googlegroups.com> Message-ID: <4D37AA0F.3010601@gmail.com> On 01/19/2011 05:01 PM, geremy condra wrote: > On Wed, Jan 19, 2011 at 3:04 PM, rantingrick wrote: >> And you've also lost all >> connection with the people. I am desperately trying to to snap you out >> of this psychosis before it is too late! Tkinter will be the downfall >> of Python if we cannot muster the resolve to replace it with something >> that is current (or more current) technology. I don't see the original bizarre rants for some reason (spam filter likely), but I have to say this is the most ridiculous thing I've heard in some time. Tkinter the downfall of python? Wow. All of the python programmers I know (we use python every day at work) would say, "what is tkinter?" It's just not relevant to any of them that I know. Google probably uses as much Python as anyone, and their programmers would probably agree. Perhaps that's an argument to remove tkinter entirely, but not really a good one. In the meantime they happily crank out code with Django, or PyQt, or PyGTK, or even Tkinter--whatever tool is appropriate for the job. > Citation needed. Perhaps a reference to Xah Lee's web site would suffice. From debatem1 at gmail.com Wed Jan 19 22:22:27 2011 From: debatem1 at gmail.com (geremy condra) Date: Wed, 19 Jan 2011 19:22:27 -0800 Subject: Tkinter: The good, the bad, and the ugly! In-Reply-To: <0d74f3b6-e534-4762-b5f4-af1187ee3b38@32g2000yqz.googlegroups.com> References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <2ef2fa6c-2ccf-453a-8f50-0ef7dbd7834d@j32g2000yqc.googlegroups.com> <5c6ff40f-05c1-4e38-89bc-b8c4745db7ce@i18g2000yqn.googlegroups.com> <9a036db2-9f32-441f-aa0f-698ac22fb152@e20g2000vbn.googlegroups.com> <981140f7-79d4-421d-88c1-c819f38a3d49@w2g2000yqb.googlegroups.com> <0d74f3b6-e534-4762-b5f4-af1187ee3b38@32g2000yqz.googlegroups.com> Message-ID: On Wed, Jan 19, 2011 at 4:53 PM, rantingrick wrote: >> I don't think this is the case, first because you aren't very good at >> getting anybody to take you seriously > > How "self absorbed" must someone be to blame *ME* because *THEY* > cannot take *ME* seriously. Is this a joke Geremy? Sadly i know it to > be true however because you are not the only person who carries this > attitude. Welcome to real life. You convince people that you're right or they don't do what you say. >> and second because I don't think >> that resistance on this issue is as mindless as you claim. > > i have exposed the baseless, nonsensical, and argumentative stance > taken by some in an effort to sway public opinion with FUD and BS. So > i would say that arguing with baseless facts does constitute "rabid > resistance". What else could it be? Reasoned resistance seen through the eyes of someone whose judgement should not be trusted. >> I disagree with the first half. The second I'm more prone to agree >> with, although I don't have a lot of great ideas about how to solve >> the problem. > > Well maybe you are not a visionary, however i believe we still need > you in other areas. Oh, do tell. >> You seem to be full of ideas (most of which I think are >> terrible) but very short on actually getting anything done. Until you >> begin to remedy that I doubt very many people here will take you as >> seriously as you seem to want. > > Look, every organization needs workers, visionaries, liaisons, > supervisors, etc. I seem to fit nicely into a Visionary role. Maybe > that bothers you? I don't know? But we all have our place Geremy. Do > you think any organization could survive simply with robotic workers > and no guidance? No, and why not? Because workers cannot see the big > picture. They are too focused (and rightly so) on some small detail > that encompasses their job duty. Only the supervisor/visionary has the > luxury of looking at the problem from a global perspective. > > Think of Python-dev as a car. A car is a machine. A very complicated > machine that needs a driver to harness it's power and give it > direction and purpose. -- someone who can see "beyond" the horizon. > Someone who can read a road map and then re-calculate a path if road > construction blocks the current one. Without the car the driver is > nothing, and without the driver the car is nothing. Python already has leadership. It does not have a command structure. There is a difference, one that you would need to understand to be an effective leader. > But together, they > are a force to reckoned with. Well, unless the driver is Asian -- then > all bets are off! :-) Hahaha, racism was so funny in the 1700's! Now it's just asinine. >> Also, be careful with where you say 'we'- I certainly don't recognize >> your authority to speak on behalf of the community, and I suspect that >> an overwhelming majority of the community's other members feel the >> same way. > > You see! This is the resistance i am talking about. You (and others) > don't want to accept me as part of the community. If you did accept > me, then my speaking collectively (we) would not be troubling to you. > However i do not blame you directly for this prejudice. I think it is > more of a sub-conscience undercurrent that pervades this community as > a whole. A fear of outsiders. A xenophobia if you will. We need to > change this now! There's a difference between 'we should' and 'we must'. One implies that you are trying to convince, which is what communities of equals do. The other implies that you are trying to command, which is what idiots think they can do to communities of equals. Geremy Condra From rantingrick at gmail.com Wed Jan 19 22:56:47 2011 From: rantingrick at gmail.com (rantingrick) Date: Wed, 19 Jan 2011 19:56:47 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <2ef2fa6c-2ccf-453a-8f50-0ef7dbd7834d@j32g2000yqc.googlegroups.com> <5c6ff40f-05c1-4e38-89bc-b8c4745db7ce@i18g2000yqn.googlegroups.com> <9a036db2-9f32-441f-aa0f-698ac22fb152@e20g2000vbn.googlegroups.com> <981140f7-79d4-421d-88c1-c819f38a3d49@w2g2000yqb.googlegroups.com> <0d74f3b6-e534-4762-b5f4-af1187ee3b38@32g2000yqz.googlegroups.com> Message-ID: On Jan 19, 9:22?pm, geremy condra wrote: > Welcome to real life. You convince people that you're right or they > don't do what you say. Again you "think" (or miscomprehended rather!) that "somehow" i am here to "make" you do anything. On the contrary Geremy, i am here to "guide", to "foster", and to "build" a cohesive community of python programmers united in a common goal WITH a clear vision for the future. > >> and second because I don't think > >> that resistance on this issue is as mindless as you claim. > > > i have exposed the baseless, nonsensical, and argumentative stance > > taken by some in an effort to sway public opinion with FUD and BS. So > > i would say that arguing with baseless facts does constitute "rabid > > resistance". What else could it be? > > Reasoned resistance seen through the eyes of someone whose judgement > should not be trusted. Why is my judgment in question here. As you claim i have no authority within in this group, so why does my judgment scare you? > > But together, they > > are a force to reckoned with. Well, unless the driver is Asian -- then > > all bets are off! :-) > > Hahaha, racism was so funny in the 1700's! Now it's just asinine. Actually the joke is on you Geremy. Obviously you cannot tell the difference between "stereotypes" and "racism". And there is a HUGE, HUGE, difference! Asians are stereotypical bad drivers, just as white guys are stereotypical bad dancers, just as black guys have stereotypical huge cucumbers. The fact that you cannot distinguish racism from stereotype exposes three things about your personality (1.) You have no sense of humor and cannot laugh at yourself, (2.) You'll jump on any bandwagon just to discredit the person you are debating with outlandish and controversial accusations, and (3.) you are extremely shallow. This shows lack of intelligence, humor, and worse of all humility. Anyhow, do you have any actual arguments or ideas on keeping Tkinter or replacing Tkinter. Remember that is why we are here Geremy. From rantingrick at gmail.com Wed Jan 19 23:06:58 2011 From: rantingrick at gmail.com (rantingrick) Date: Wed, 19 Jan 2011 20:06:58 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <2ef2fa6c-2ccf-453a-8f50-0ef7dbd7834d@j32g2000yqc.googlegroups.com> <5c6ff40f-05c1-4e38-89bc-b8c4745db7ce@i18g2000yqn.googlegroups.com> <9a036db2-9f32-441f-aa0f-698ac22fb152@e20g2000vbn.googlegroups.com> <981140f7-79d4-421d-88c1-c819f38a3d49@w2g2000yqb.googlegroups.com> Message-ID: On Jan 19, 9:20?pm, Michael Torrie wrote: > > All of the python programmers I know (we use python every day at > work) would say, "what is tkinter?" It's just not relevant to any of > them that I know. > And that is the very point i am trying to make Micheal! TclTk is SO old and dated that most people don't even know it exists -- MUCH LESS TKINTER! > > In the meantime they happily crank out code with Django, or PyQt, or > PyGTK, or even Tkinter--whatever tool is appropriate for the job. > I noticed wxPython did not make your list. Was that conscience or sub- conscience because i find it hard to believe that none of them use wxPython... ever. However the REAL point is that they obviously prefer *anything* except Tkinter and only use Tkinter as a last resort. This is very interesting Micheal. From brian.curtin at gmail.com Wed Jan 19 23:35:08 2011 From: brian.curtin at gmail.com (Brian Curtin) Date: Wed, 19 Jan 2011 22:35:08 -0600 Subject: Tkinter: The good, the bad, and the ugly! In-Reply-To: <0d74f3b6-e534-4762-b5f4-af1187ee3b38@32g2000yqz.googlegroups.com> References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <2ef2fa6c-2ccf-453a-8f50-0ef7dbd7834d@j32g2000yqc.googlegroups.com> <5c6ff40f-05c1-4e38-89bc-b8c4745db7ce@i18g2000yqn.googlegroups.com> <9a036db2-9f32-441f-aa0f-698ac22fb152@e20g2000vbn.googlegroups.com> <981140f7-79d4-421d-88c1-c819f38a3d49@w2g2000yqb.googlegroups.com> <0d74f3b6-e534-4762-b5f4-af1187ee3b38@32g2000yqz.googlegroups.com> Message-ID: On Wed, Jan 19, 2011 at 18:53, rantingrick wrote: > Without the car the driver is > nothing, and without the driver the car is nothing. But together, they > are a force to reckoned with. Well, unless the driver is Asian -- then > all bets are off! :-) Welcome to the auto-deletion filter. -------------- next part -------------- An HTML attachment was scrubbed... URL: From debatem1 at gmail.com Thu Jan 20 00:15:00 2011 From: debatem1 at gmail.com (geremy condra) Date: Wed, 19 Jan 2011 21:15:00 -0800 Subject: Tkinter: The good, the bad, and the ugly! In-Reply-To: References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <2ef2fa6c-2ccf-453a-8f50-0ef7dbd7834d@j32g2000yqc.googlegroups.com> <5c6ff40f-05c1-4e38-89bc-b8c4745db7ce@i18g2000yqn.googlegroups.com> <9a036db2-9f32-441f-aa0f-698ac22fb152@e20g2000vbn.googlegroups.com> <981140f7-79d4-421d-88c1-c819f38a3d49@w2g2000yqb.googlegroups.com> <0d74f3b6-e534-4762-b5f4-af1187ee3b38@32g2000yqz.googlegroups.com> Message-ID: On Wed, Jan 19, 2011 at 7:56 PM, rantingrick wrote: >> > But together, they >> > are a force to reckoned with. Well, unless the driver is Asian -- then >> > all bets are off! :-) >> >> Hahaha, racism was so funny in the 1700's! Now it's just asinine. > > Actually the joke is on you Geremy. Obviously you cannot tell the > difference between "stereotypes" and "racism". And there is a HUGE, > HUGE, difference! Asians are stereotypical bad drivers, just as white > guys are stereotypical bad dancers, just as black guys have > stereotypical huge cucumbers. Congratulations; you are the second person better than a decade to land in my bozo bin. Don't bother replying- I won't be hearing from you. Geremy Condra From urban.dani at gmail.com Thu Jan 20 01:02:21 2011 From: urban.dani at gmail.com (Daniel Urban) Date: Thu, 20 Jan 2011 07:02:21 +0100 Subject: collections.Set Binary Reflected Operations In-Reply-To: References: Message-ID: On Thu, Jan 20, 2011 at 01:51, Chris Kaynor wrote: > I am implemented a custom set-like type which interacts with some > third-party software when retrieving and mutating the set, and have derived > my custom type off of collections.MutableSet, however I have noticed that > some of the magic methods supported by the built-in set do not fully > function with my custom type. From this,?I looked over the > MutableSet?definition?in and it seems to be missing all of the reflected > operators (__rsub__, __rand__, __ror__, __rxor__, and friends) for the > operators it has defined. I can post a simple example case if desired. > I am using Python 2.6.4 (with some in-house customizations), however a quick > look over the svn?repository?shown on python.org makes it appear that these > are also not implemented in Python 3. I was wondering if there is some > reason for this, or if it was merely an oversight. > Chris See http://bugs.python.org/issue8743 and also http://bugs.python.org/issue2226 Daniel From user at compgroups.net/ Thu Jan 20 01:16:02 2011 From: user at compgroups.net/ (WellsSUZETTE21) Date: Thu, 20 Jan 2011 00:16:02 -0600 Subject: newb References: Message-ID: I received 1 st mortgage loans when I was 25 and that supported my family very much. But, I need the bank loan once more time. From orasnita at gmail.com Thu Jan 20 02:09:12 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Thu, 20 Jan 2011 09:09:12 +0200 Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com><4d337983$0$29983$c3e8da3$5496439d@news.astraweb.com><044a5101-948d-4458-9c94-57dbb3e25f67@m35g2000vbn.googlegroups.com><4d3467bf$0$29983$c3e8da3$5496439d@news.astraweb.com> <4D34B04E.8050309@web.de><4266E8D7BA204BFEA5BF66C635CE1716@octavian> <4D35DCE8.5030002@web.de><4D35DD47.1070304@web.de><42924000-3ffb-40f5-9cf8-70a9d767b944@k25g2000vbl.googlegroups.com> Message-ID: <39D3B37016074EDABBE6BAF6F433D942@octavian> From: "Grant Edwards" >>> On all of my computers, wxPython uses Gtk. There are other choices >>> for wxWidget backends on Linux, but Gtk is by far the most common. >>> IOW, if Gtk is bad, then wxPython is bad. >> >> Not true. > > I think you're playing a bit fast and loose with your accusations. :-) I've made no accusations, but I only try to inform the people about the accessibility of different GUI libs. > Which of my statements was "not true"? > > 1) On all of my computers wxPython uses Gtk. > > 2) There are other backend choices on Linux besides Gtk. > > 3) Gtk is by far the most common wxWidgets backend on Linux/Unix. > > 4) If Gtk is bad then wxPython is bad. > > Note that 4) follows logically from 3), so to say that 4) is "not > true" you have to show that 3) is "not true". The wrong conclusion is that if Gtk is bad, then WxPython is bad. Gtk is inaccessible under Windows, not under Linux, but WxPython doesn't use Gtk under Windows so WxPython is OK. Under Linux Gtk is OK, but I don't know about Motif. Under Linux Motif might not be accessible, however note that I am not sure about Motif's accessibility. Octavian From orasnita at gmail.com Thu Jan 20 02:22:05 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Thu, 20 Jan 2011 09:22:05 +0200 Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com><4d337983$0$29983$c3e8da3$5496439d@news.astraweb.com><044a5101-948d-4458-9c94-57dbb3e25f67@m35g2000vbn.googlegroups.com><4d3467bf$0$29983$c3e8da3$5496439d@news.astraweb.com><4D34B04E.8050309@web.de><4266E8D7BA204BFEA5BF66C635CE1716@octavian><4D35DCE8.5030002@web.de><4D35DD47.1070304@web.de><7A0C7934E65D4B85A584C06ADD3B6ECF@teddy> <799d1f10-f2b3-41fb-ade2-d31ff19918e5@t23g2000vby.googlegroups.com> Message-ID: From: "Adam Skutt" The fact that /every/ toolkit provides accessibility guidelines over and above whatever other UI guidelines they provide tells me that creating an accessible application is hardly obvious. Plus, if it were really that simple, the accessibility situation wouldn't be so poor. :-) Where do you got the conclusion that the accessibility is so poor? The accessibility is not so great under Mac and under Linux it is less advanced than under Windows, but under Windows the accessibility is usually very good for most apps. All the standard Windows programs are accessible, all the DotNet programs are generally accessible, SWT and wxWIDGETS - based programs are accessible, SWING-based GUIS are also pretty accessible and even more strange interfaces like the one found in Winamp are accessible. Even Flash have a very limited accessibility although I think it is too much to say that it is accessible. But You keep telling me that it is hard to create accessible programs, which is false, but you don't know and don't want to try to see. Try to create a WxPython app that doesn't do anything but only displays some menus, buttons, combo boxes, list boxes, list views, tree views, text fields, check boxes, radio buttons... and you will see that they are very accessible with that screen reader I told you about, without requiring you to do anything special that you wouldn't do otherwise. > Yes, those things should be followed for creating a better app, but what I > wanted to say is that no matter if you do those things or not in a Tk, Gtk > or QT GUI, they will be useless, because the screen readers can't > understand those GUIS even they have text labels, and even if you will see > a focus rectangle around buttons. They don't report that those objects > have the focus so the screen readers won't speak anything. Your "something is better than nothing" argument isn't particularly compelling to me personally as a justification for ripping out TkInter. And Qt is the only toolkit with some level of functioning accessibility support on all three major platforms, assuming the library and software are built correctly, so again, your argument is really for Qt, not for wxWidgets. How do you came to the conclusion that QT is accessible on all operating system? I haven't seen any QT-based accessible interface, but WxPython offers that thing without any effort. When you talk about accessibility, try it yourself and don't take the word of the GUI widgets developers. Octavian From orasnita at gmail.com Thu Jan 20 02:33:23 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Thu, 20 Jan 2011 09:33:23 +0200 Subject: Screen readers for Tkinter (was Re: Tkinter: The good, the bad, and the ugly!) References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com><4d337983$0$29983$c3e8da3$5496439d@news.astraweb.com><044a5101-948d-4458-9c94-57dbb3e25f67@m35g2000vbn.googlegroups.com><4d3467bf$0$29983$c3e8da3$5496439d@news.astraweb.com><4D34B04E.8050309@web.de><4266E8D7BA204BFEA5BF66C635CE1716@octavian><4D35DCE8.5030002@web.de> <1295448820.26438.1416115629@webmail.messagingengine.com><5296E6FB68964C239A84C2AF4007D2DD@teddy> Message-ID: From: "Terry Reedy" > On 1/19/2011 11:27 AM, Octavian Rasnita wrote: > >>> Note: Currently, accessibility is only available via ATK<=> AT-SPI on >>> Linux. Sorry, no Windows MSAA support. >> >> >> This project is good, a step ahead, but in order to be really useful it >> should be the one provided by the default Python package. >> And of course, it should also offer support for Windows, since most of >> the computer users use Windows, especially those who need accessibility >> features. > > Octavian > > Please consider adding an 'Accessibility' page to the Python wiki with > your info and the above for those interested. > > -- > Terry Jan Reedy Well, I am not sure this is an interesting thing for the programmers. The programmers (including me) are usually interested to have the job done as fast as possible, with as few efforts as possible and to be easy to maintain. The GUIs should be accessible by default like in case of wxWIDGETS, SWT or WindowsForms. That's why I said that that lib should be included in Python implicitely eventually because if it is just promoted, the beginners won't know about it and most of the programmers won't care to add accessibility features with aditional efforts. Too bad that it doesn't support the accessibility for Windows though. Octavian From stefan_ml at behnel.de Thu Jan 20 02:35:24 2011 From: stefan_ml at behnel.de (Stefan Behnel) Date: Thu, 20 Jan 2011 08:35:24 +0100 Subject: [OT] Python like lanugages [was Re: After C++, what with Python?] In-Reply-To: References: <86a904f8-05b0-435f-81d6-7450650f1679@glegroupsg2000goo.googlegroups.com> <4d329899$0$43988$742ec2ed@news.sonic.net> <7x8vylfcvz.fsf@ruckus.brouhaha.com> <4d32c7cf$0$29983$c3e8da3$5496439d@news.astraweb.com> <4d3425fe$0$29983$c3e8da3$5496439d@news.astraweb.com> Message-ID: Tim Harig, 18.01.2011 12:37: > On 2011-01-18, Stefan Behnel wrote: >> Tim Harig, 17.01.2011 20:41: >>> I prefer a single language as opposed to a creolization of two. >> >> With the possible exception of Lisp, I find it hard to think of a language >> that's still alive and not the creolisation of (at least) two other >> languages. They all inherited from each other, sometimes right from the >> start ("lessons learned") and always during their subsequent life time. > > I am not talking about language influences. Cython effectively requires > two separate languages that interoperate. The end result is a mix > of two code written in two separate langauges. That is not a single > language solution. I don't really agree with the word "separate", and especially not "two codes". I think of Cython more as Python with the addition of C data types, integrated by a smart compiler. So the language actually is Python, it's just that you can apply it to a broader set of data representations. Stefan From donotreply at flickr.com Thu Jan 20 03:06:11 2011 From: donotreply at flickr.com (Flickr Mail) Date: 20 Jan 2011 08:06:11 +0000 Subject: =?utf-8?Q?=5BFlickr=5D_Your_upload_has_failed_with_the_following_message=3A?= Message-ID: <20110120080848.1AF53EE981@mail.python.org> If you think you shouldn't be getting this error, you can search our FAQs or send us a help case from http://flickr.com/help/ and we'll do out best to help! Thanks, The Flickr Team ------------------------------------------------- This information might be of use to us when diagnosing what went wrong : To Address: york65good at photos.flickr.com Cc Address: >From Address: python-list at python.org Message ID: <20110120080606.D05292C1C1 at www120.flickr.mud.yahoo.com> Parsed Addresses: york65good at photos.flickr.com Handling Server: www120 Handler Version: 69900OH HAI Transaction Log: www120-1295510770.email Logged Date: 20-01-2011 User NSID: 8109696 at N02 Blog Id: From rde at audaxis.com Thu Jan 20 04:04:12 2011 From: rde at audaxis.com (Romaric DEFAUX) Date: Thu, 20 Jan 2011 10:04:12 +0100 Subject: Need advices for mysqldb connection best practice Message-ID: <4D37FA8C.9060108@audaxis.com> Hi all, I've a problem with a mysql connection. I run a client/server application. Every hour, clients contact the server, send datas, and the server updates the database. Everything works perfectly. But after a while, I get in trouble with my db connection. I've got the impression my server application "mix" the cursors... I've got this kind of strange errors in my log : Traceback (most recent call last): File "/usr/local/lib/audaxis/system_serverbox.py", line 519, in __update_in_db old_serverbox.load_from_db(cursor, self.__id) File "/usr/local/lib/audaxis/system_serverbox.py", line 131, in load_from_db self.__uuid = row['uuid'] TypeError: 'NoneType' object is unsubscriptable Traceback (most recent call last): File "/usr/local/lib/audaxis/system_server.py", line 168, in process_data result += my_serverbox.save_website_list(cursor) File "/usr/local/lib/audaxis/system_serverbox.py", line 1197, in save_website_list old_serverbox.load_from_db(cursor, self.__id) File "/usr/local/lib/audaxis/system_serverbox.py", line 143, in load_from_db self.__load_disk_list_from_db(cursor) File "/usr/local/lib/audaxis/system_serverbox.py", line 203, in __load_disk_list_from_db my_disk.load_from_db(cursor, disk_id) File "/usr/local/lib/audaxis/system_disk.py", line 54, in load_from_db self.__fs = row['fs'] KeyError: 'fs' Traceback (most recent call last): File "/usr/local/lib/audaxis/system_serverbox.py", line 521, in __update_in_db __uuid_host = self.is_virtual(cursor) File "/usr/local/lib/audaxis/system_serverbox.py", line 339, in is_virtual result = row['uuid'] KeyError: 'uuid' and a lot of KeyError (at every update) The requests that produce these errors were working perfectly. And if I restart my server, everything is working fine again ! Here's part of my code (I removed some parts): I create a db connection like this in my object server: def connect(): con = MySQLdb.connect (host = "localhost", user = "myuser", passwd = "good_password", db = "my_db", cursorclass=DictCursor) con.ping(True) <- this normally activate auto-reconnection (or I did a mistake ?) con.cursor().execute('SET AUTOCOMMIT=1') return con self.__db_connection = connect() Then, each time a client connects : cursor = self.__db_connection.cursor() ...process the datas... cursor.close() So , I thought about some solutions : - restarting the server every sometimes (but it's the worst solution in my mind) - creating a connection (not only cursor) at each client connection (but I'm afraid it overloads the mysql server) - trying to find where I did a mistake, and correct the bug (that why I'm doing by writing this list :), or send me a link that could help me (before writing I googled for one hour and found nothing interresting in my case...) Thanks in advance for your advices ! Romaric From davea at ieee.org Thu Jan 20 05:46:08 2011 From: davea at ieee.org (Dave Angel) Date: Thu, 20 Jan 2011 05:46:08 -0500 Subject: [OT] Python like lanugages [was Re: After C++, what with Python?] In-Reply-To: References: <86a904f8-05b0-435f-81d6-7450650f1679@glegroupsg2000goo.googlegroups.com><4d329899$0$43988$742ec2ed@news.sonic.net><7x8vylfcvz.fsf@ruckus.brouhaha.com><4d32c7cf$0$29983$c3e8da3$5496439d@news.astraweb.com><4d35a769$0$2258$a729d347@news.telepac.pt><503D269987294E7A95D87C488F37BB25@octavian><828053EDBB174148B9895ADD5B9A0780@octavian> Message-ID: <4D381270.5090105@ieee.org> On 01/-10/-28163 02:59 PM, Octavian Rasnita wrote: > From: "geremy condra" >> On Wed, Jan 19, 2011 at 2:31 AM, Octavian Rasnita wrote: >>> >>> >>> Would it be hard to introduce the possibility of adding encryption of the >>> bytecode similar to what the Zend encoder does for PHP or Filter::Crypto for >>> Perl? >>> >>> Octavian >> >> The iron law of cryptography: there is no cryptographic solution to a >> problem in which the attacker and intended recipient are the same >> person. >> >> Schemes like this are at most an annoyance to people willing to >> reverse engineer your code. >> >> Geremy Condra > > > I don't know how the Python bytecode works... how it is executed. > > I thought that Python parses the .py file and generates the bytecode that doesn't contain all the necessary information for re-creating the source code. > (But that I agree, that might mean real compilation which is not the case...) > > Octavian > It's not hard to experiment with. I've written disassemblers for other byte-code formats, but not for Python's. The following is pasted together, so it may not be completely correct. But it's close. Python 2.6.5 (r265:79063, Apr 16 2010, 13:09:56) [GCC 4.4.3] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> def test(arg1, arg2): ... if arg1 < 65: ... print arg2 ... >>> import dis >>> dis.dis(test) 2 0 LOAD_FAST 0 (arg1) 3 LOAD_CONST 1 (65) 6 COMPARE_OP 0 (<) 9 JUMP_IF_FALSE 9 (to 21) 12 POP_TOP 3 13 LOAD_FAST 1 (arg2) 16 PRINT_ITEM 17 PRINT_NEWLINE 18 JUMP_FORWARD 1 (to 22) >> 21 POP_TOP >> 22 LOAD_CONST 0 (None) 25 RETURN_VALUE >>> Now, there are tools which reverse that into something pretty similar to python source. But you can see even from the built-in features that lots of information is there. I'd assume that something very similar is in the byte code files themselves. DaveA From askutt at gmail.com Thu Jan 20 07:22:22 2011 From: askutt at gmail.com (Adam Skutt) Date: Thu, 20 Jan 2011 04:22:22 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com><4d337983$0$29983$c3e8da3$5496439d@news.astraweb.com><044a5101-948d-4458-9c94-57dbb3e25f67@m35g2000vbn.googlegroups.com><4d3467bf$0$29983$c3e8da3$5496439d@news.astraweb.com><4D34B04E.8050309@web.de><4266E8D7BA204BFEA5BF66C635CE1716@octavian><4D35DCE8.5030002@web.de><4D35DD47.1070304@web.de><7A0C7934E65D4B85A584C06ADD3B6ECF@teddy> Message-ID: <098df916-13f0-4dfa-b4c5-d4b0b5cddc13@r29g2000yqj.googlegroups.com> On Jan 20, 2:22?am, "Octavian Rasnita" wrote: > Where do you got the conclusion that the accessibility is so poor? By an examination of the facts. MSAA is universally hated and all screen readers actively have to work around it and its many limitations (meaning that as an application programmer, you can do the "right" thing and still get undesired behavior through no fault of your own). I have no clue if it's replacement is better, but I do know few programs use it, so it's little comfort. The situation on Linux is still an outright disaster. Neither Qt4 nor GTK enable accessibility functionality automatically and support from the various distribution vendors is pretty limited. It is improving, however. Accessibility still requires special effort "over and above" the norm by the programmer whether you believe this to be the case or not. Most programmers aren't even aware of the fact they must consider it (a point you've made yourself before!) and hence commit various accessibility sins. This is mostly a cultural problem, not a technical one, but it's still a real problem. Plus, out of the stuff I run daily on Windows: two of the applications are entirely inaccessible: the Adobe AIR one and the Gtk one. Songbird, the XUL based music player, has some accessibility, but none of the navigation controls seem to be enabled, which would make it very difficult to actually use, I imagine. It's also not particularly keyboard friendly: you don't even get a visual focus indicator most of the time, even though the focus is moving. > But You keep telling me that it is hard to create accessible programs, which > is false, but you don't know and don't want to try to see. > Try to create a WxPython app that doesn't do anything but only displays some > menus, buttons, combo boxes, list boxes, list views, tree views, text > fields, check boxes, radio buttons... and you will see that they are very > accessible with that screen reader I told you about, without requiring you > to do anything special that you wouldn't do otherwise. Applications that only display these things aren't very interesting. And no, they still require additional effort. Most developers can't even be assed to get a sane tab focus order set, to say nothing of keyboard shortcuts, accessibility descriptions / proper label associations for buttons and other controls. It gets even more complicated when you get away from controls only meant to display text. How many web pages have you visited where images are missing alt tags? Do you really thing those same people are going to bother trying to do the right thing if asked to create a desktop GUI application? No, they're not, and you're going to get whatever happens automatically. Which isn't nothing (in some toolkits), but it's also not what one really wants, either. > > How do you came to the conclusion that QT is accessible on all operating > system? By actually going out, reading, and even testing? Qt has had functional accessibility support on OS X and Windows since Qt3, and functional support on Linux, OS X, and Windows since Qt4. It even extends to PySide, with a few limitations: you can't write custom accessible widgets in PySide, though I'm pretty confident they'd enable support if someone wrote a patch to enable the bindings. > When you talk about accessibility, try it yourself and don't take the word > of the GUI widgets developers. > I just did, NVDA was able to read my button text and its accessibility description just fine, both in C++ and Python versions of my Qt application. I didn't bother testing Linux or OS X, but I'm sure it would work there too. Adam From subscriptions at cagttraining.com Thu Jan 20 07:30:02 2011 From: subscriptions at cagttraining.com (Bill Felton) Date: Thu, 20 Jan 2011 07:30:02 -0500 Subject: Tkinter: The good, the bad, and the ugly! In-Reply-To: <4D37AA0F.3010601@gmail.com> References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <0fa4603c-6e27-4ee5-9761-000a61cd19a4@fx12g2000vbb.googlegroups.com> <2510bf88-1045-411f-9ccd-7ca7c3665454@l24g2000vby.googlegroups.com> <2ef2fa6c-2ccf-453a-8f50-0ef7dbd7834d@j32g2000yqc.googlegroups.com> <5c6ff40f-05c1-4e38-89bc-b8c4745db7ce@i18g2000yqn.googlegroups.com> <9a036db2-9f32-441f-aa0f-698ac22fb152@e20g2000vbn.googlegroups.com> <981140f7-79d4-421d-88c1-c819f38a3d49@w2g2000yqb.googlegroups.com> <4D37AA0F.3010601@gmail.com> Message-ID: <953B2583-5609-4C0C-9B4F-CA46F9E570F4@cagttraining.com> On Jan 19, 2011, at 10:20 PM, Michael Torrie wrote: > On 01/19/2011 05:01 PM, geremy condra wrote: >> On Wed, Jan 19, 2011 at 3:04 PM, rantingrick wrote: >>> And you've also lost all >>> connection with the people. I am desperately trying to to snap you out >>> of this psychosis before it is too late! Tkinter will be the downfall >>> of Python if we cannot muster the resolve to replace it with something >>> that is current (or more current) technology. > > I don't see the original bizarre rants for some reason (spam filter > likely), but I have to say this is the most ridiculous thing I've heard > in some time. Tkinter the downfall of python? Wow. All of the python > programmers I know (we use python every day at work) would say, "what > is tkinter?" It's just not relevant to any of them that I know. Google > probably uses as much Python as anyone, and their programmers would > probably agree. Perhaps that's an argument to remove tkinter entirely, > but not really a good one. > With some hesitation, I feel a need to jump in here. I'm a complete newbie to Python. I'm still learning the language. And you know what? I've ignored Tkinter. I quickly discovered the alternatives and am already working with wxPython. I can't believe anyone is so hung up by their own arrogance that they honestly believe that the mere *presence* of a gui kit inside of the standard distribution would prevent a newbie from learning about the existence and possible benefits of alternatives. Sure, *they* can see alternatives and evaluate why Tkinter might not be a good choice under conditions x or y or z, but god forbid anyone new to the language should have to confront those issues or be asked to make such a decision. How could we trust those lowly newbies to think *properly* about the issue! ESPECIALLY in a language widely touted for the vast array of external libraries available. The attitude that the standard distribution needs this kind of obsessive, hysterically blinkered, focused on irrelevant minutiae is far more likely to be the downfall of the language than the presence of a sub-optimal gui kit that no one is required to use. As one of 'the people' who is presumably the focus of rantingrick's concern, let me assure him Tkinter is a non-issue. MIchael is more in touch with my issues than rr, and appears to be suffering fewer disconnects from the reality of a programming language that ships with a large standard library and offers a plethora of extensions and alternatives, widely available and easy to find. cheers, Bill From giacomo.boffi at polimi.it Thu Jan 20 07:34:06 2011 From: giacomo.boffi at polimi.it (Giacomo Boffi) Date: Thu, 20 Jan 2011 13:34:06 +0100 Subject: Should there be a 'core' python install? References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <4d337983$0$29983$c3e8da3$5496439d@news.astraweb.com> <044a5101-948d-4458-9c94-57dbb3e25f67@m35g2000vbn.googlegroups.com> <4d3467bf$0$29983$c3e8da3$5496439d@news.astraweb.com> <0947517d-a2c4-44af-83cb-8ed4299b143a@k25g2000vbl.googlegroups.com> <3ac4634f-1c6f-4552-9e7f-a2d912a77dc2@f35g2000vbl.googlegroups.com> Message-ID: <8639onzrcx.fsf@aiuole.stru.polimi.it> "Martin P. Hellwig" writes: > Yep when I started looking much more at other toolkits, I started to > like Tkinter more and more. Maybe its simplicity, maybe the good design of Tk, -- BOMBED BY AIRCRAFT. SINKING. U-824. From funthyme at gmail.com Thu Jan 20 08:09:50 2011 From: funthyme at gmail.com (John Pinner) Date: Thu, 20 Jan 2011 05:09:50 -0800 (PST) Subject: __pycache__, one more good reason to stck with Python 2? References: <23e02e0d-b2f1-4b52-85ea-d1feba99dd37@22g2000prx.googlegroups.com> <4d3466d3$0$29983$c3e8da3$5496439d@news.astraweb.com> <0c62aacd-e6d2-4778-81d6-e06924192add@j1g2000vbl.googlegroups.com> <87vd1m6ezq.fsf@benfinney.id.au> <992b11a0-d35d-4b08-98ab-d08c90a86ec7@j1g2000vbl.googlegroups.com> <4d36f846$0$29983$c3e8da3$5496439d@news.astraweb.com> Message-ID: <9b90b457-9436-4f38-956a-bfafe3d0acdb@h17g2000pre.googlegroups.com> Hi You have disturbe my slumber, Steven ;-) On Jan 19, 2:42?pm, Steven D'Aprano wrote: > On Tue, 18 Jan 2011 00:58:14 -0800, jmfauth wrote: > > It is now practically impossible to launch a Python application via a > > .pyc file. > > When has that ever been possible? > > .pyc files are Python byte-code. You can't run them directly using Python > (except via the import machinery), you can't run them as a script, > they're not machine code. Unless you write a wrapper to import the file > as a module, you can't directly execute .pyc files. Not true. 'python myprog.pyc' has worked for as long as I have been using Python. Whether or not it is a good idea is another matter. Probably it would be best to check what you're saying before posting such a bald assertion, even though you were 110% sure of what you were saying. I've been there, done that, bought the tee-shirt. Best wishes, John -- From orasnita at gmail.com Thu Jan 20 08:19:13 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Thu, 20 Jan 2011 15:19:13 +0200 Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com><4d337983$0$29983$c3e8da3$5496439d@news.astraweb.com><044a5101-948d-4458-9c94-57dbb3e25f67@m35g2000vbn.googlegroups.com><4d3467bf$0$29983$c3e8da3$5496439d@news.astraweb.com><4D34B04E.8050309@web.de><4266E8D7BA204BFEA5BF66C635CE1716@octavian><4D35DCE8.5030002@web.de><4D35DD47.1070304@web.de><7A0C7934E65D4B85A584C06ADD3B6ECF@teddy> <098df916-13f0-4dfa-b4c5-d4b0b5cddc13@r29g2000yqj.googlegroups.com> Message-ID: <9236E86791634EE69D94C1ED2C515C24@octavian> From: "Adam Skutt" On Jan 20, 2:22 am, "Octavian Rasnita" wrote: > Where do you got the conclusion that the accessibility is so poor? By an examination of the facts. MSAA is universally hated and all screen readers actively have to work around it and its many limitations (meaning that as an application programmer, you can do the "right" thing and still get undesired behavior through no fault of your own). I have no clue if it's replacement is better, but I do know few programs use it, so it's little comfort. The Windows applications are not accessible only if they use MSAA. The screen readers know how to get the necessary information for making the interfaces accessible in other ways, but of course, it is harder for the screen reader manufacturers if the GUIs don't respect a standard. And if MSAA is hated it doesn't mean that the accessibility is so poor as you might think. The situation on Linux is still an outright disaster. Neither Qt4 nor GTK enable accessibility functionality automatically and support from the various distribution vendors is pretty limited. It is improving, however. It might be true, I don't know, because I use Linux only in command line mode. Accessibility still requires special effort "over and above" the norm by the programmer whether you believe this to be the case or not. I don't understand how I need to "believe" this, while I made perfectly accessible applications without doing special efforts for making them to be accessible. Of course, I don't consider something special to put a text label on a button, or radio button or check box. Most programmers aren't even aware of the fact they must consider it (a point you've made yourself before!) and hence commit various accessibility sins. This is mostly a cultural problem, not a technical one, but it's still a real problem. Yes, that's a problem but we divagate. The programmers need to take care about those details, like putting text labels on buttons, or tooltips for images, but these things are relevant only for accessible widgets. It *doesn't matter* if they put those labels if they use GUIS like Tk because they won't be accessible at all anyway. Plus, out of the stuff I run daily on Windows: two of the applications are entirely inaccessible: the Adobe AIR one and the Gtk one. Songbird, the XUL based music player, has some accessibility, but none of the navigation controls seem to be enabled, which would make it very difficult to actually use, I imagine. It's also not particularly keyboard friendly: you don't even get a visual focus indicator most of the time, even though the focus is moving. Yes of course, Adobe's products are at most very hard accessible or not accessible at all and I already said that Gtk is not accessible under Windows, just like Tk. > But You keep telling me that it is hard to create accessible programs, > which > is false, but you don't know and don't want to try to see. > Try to create a WxPython app that doesn't do anything but only displays > some > menus, buttons, combo boxes, list boxes, list views, tree views, text > fields, check boxes, radio buttons... and you will see that they are very > accessible with that screen reader I told you about, without requiring you > to do anything special that you wouldn't do otherwise. Applications that only display these things aren't very interesting. And no, they still require additional effort. Most developers can't even be assed to get a sane tab focus order set, Well, I haven't used WxPython until now, but only WxPerl, however the WxPerl programmers don't need to set the tab focus because by default the tab focus is set in the order of the controls on the form and I thought it should be the same in WxPython. So no special effort would be necessary. Are you sure you are not confusing accessibility with usability? Of course that an application which respects more usability rules is easier to use, and this means that it should have the controls with a right tab order, with clear text labels and so on, but we can talk about usability only for an accessible GUI. JAWS screen reader has its own programming language and it can be used for improving the usability of a program. It can do very many things and it has more than 1000 functions, but it can't do anything in the case of inaccessible interfaces like Tk. > to say nothing of keyboard shortcuts, accessibility descriptions / proper > label associations for buttons and other controls. It gets even more complicated when you get away from controls only meant to display text. How many web pages have you visited where images are missing alt tags? Do you really thing those same people are going to bother trying to do the right thing if asked to create a desktop GUI application? No, they're not, and you're going to get whatever happens automatically. Which isn't nothing (in some toolkits), but it's also not what one really wants, either. Yes, that's true, but as I said, some GUIS like WxPython offer the accessibility, so those controls are visible, and it is less important if they are in a right tab order or if some of the controls are not labeled, because the screen reader can solve these things. But the screen reader can't solve the absolute inaccessibility of GUIS like Tk because it can't read anything from it. > How do you came to the conclusion that QT is accessible on all operating > system? By actually going out, reading, and even testing? Qt has had functional accessibility support on OS X and Windows since Qt3, and functional support on Linux, OS X, and Windows since Qt4. It even extends to PySide, with a few limitations: you can't write custom accessible widgets in PySide, though I'm pretty confident they'd enable support if someone wrote a patch to enable the bindings. A GUI which offers accessible widgets only if they are coded specially for beeing accessible are not accessible at all, because most programmers won't care to make the applications accessible so the results will be bad anyway. > When you talk about accessibility, try it yourself and don't take the word > of the GUI widgets developers. > I just did, NVDA was able to read my button text and its accessibility description just fine, both in C++ and Python versions of my Qt application. I didn't bother testing Linux or OS X, but I'm sure it would work there too. Have you created that QT application with its default options? Without doing anything special to make it accessible? And most important, have you tested it with JAWS screen reader? (Or WindowEyes at least) because these are the most used screen readers. NVDA is pretty poor and it can't be used for very complex things (yet). Octavian From orasnita at gmail.com Thu Jan 20 08:26:13 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Thu, 20 Jan 2011 15:26:13 +0200 Subject: Tkinter: The good, the bad, and the ugly! References: <953B2583-5609-4C0C-9B4F-CA46F9E570F4@cagttraining.com> Message-ID: From: "Bill Felton" > I'm a complete newbie to Python. To Python, or to programming in general? (Because it is important) > I'm still learning the language. And you know what? I've ignored > Tkinter. Why did you do that? > I quickly discovered the alternatives and am already working with > wxPython. > I can't believe anyone is so hung up by their own arrogance that they > honestly believe that the mere *presence* of a gui kit inside of the > standard distribution would prevent a newbie from learning about the > existence and possible benefits of alternatives. Sure, *they* can see > alternatives and evaluate why Tkinter might not be a good choice under > conditions x or y or z, Nobody said that the fact that Python promotes Tkinter *prevents" the beginners to learn to use another GUI. I just say that if Python promotes Tkinter, the beginners that might not have experience programming in other languages might not know at all which is the difference between all those GUI types, and it might not know at all that there are more GUI types and it won't know for sure which are the differences between them. And for a real beginner in programming it could be harder and less important to make the effort of finding and downloading and installing another GUI just because it offer some features which are not interesting for most users, so he/she will prefer using what Python offers and he/she won't know that that solution is bad. Octavian From python at bdurham.com Thu Jan 20 08:48:55 2011 From: python at bdurham.com (python at bdurham.com) Date: Thu, 20 Jan 2011 08:48:55 -0500 Subject: Tkinter: The good, the bad, and the ugly! In-Reply-To: <953B2583-5609-4C0C-9B4F-CA46F9E570F4@cagttraining.com> References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <0fa4603c-6e27-4ee5-9761-000a61cd19a4@fx12g2000vbb.googlegroups.com> <2510bf88-1045-411f-9ccd-7ca7c3665454@l24g2000vby.googlegroups.com> <2ef2fa6c-2ccf-453a-8f50-0ef7dbd7834d@j32g2000yqc.googlegroups.com> <5c6ff40f-05c1-4e38-89bc-b8c4745db7ce@i18g2000yqn.googlegroups.com> <9a036db2-9f32-441f-aa0f-698ac22fb152@e20g2000vbn.googlegroups.com> <981140f7-79d4-421d-88c1-c819f38a3d49@w2g2000yqb.googlegroups.com><4D37AA0F.3010601@gmail.com> <953B2583-5609-4C0C-9B4F-CA46F9E570F4@cagttraining.com> Message-ID: <1295531335.9910.1416305309@webmail.messagingengine.com> Bill, > I can't believe anyone is so hung up by their own arrogance that they honestly believe that the mere *presence* of a gui kit inside of the standard distribution would prevent a newbie from learning about the existence and possible benefits of alternatives ... ESPECIALLY in a language widely touted for the vast array of external libraries available. The attitude that the standard distribution needs this kind of obsessive, hysterically blinkered, focused on irrelevant minutiae is far more likely to be the downfall of the language than the presence of a sub-optimal gui kit that no one is required to use ... +1 (very well said) Malcolm From marrina0012 at gmail.com Thu Jan 20 08:51:00 2011 From: marrina0012 at gmail.com (Marrina anderson tina) Date: Thu, 20 Jan 2011 05:51:00 -0800 (PST) Subject: USA Free classified site for free ad posting !!! Message-ID: We are providing free services for all !!! Guys, are you looking for having nice opportunity to post or submit your advertisement without any impediments! Just visit and get gigantic chance to give free advertisement in our here !!! Just visit at: http://www.webadlist.com/ From user at compgroups.net/ Thu Jan 20 09:16:50 2011 From: user at compgroups.net/ (lakshmi) Date: Thu, 20 Jan 2011 08:16:50 -0600 Subject: difference between python and matlab Message-ID: Is the programming related to image processing in python is advantageous or else in MATLAB From jarausch at skynet.be Thu Jan 20 09:31:09 2011 From: jarausch at skynet.be (Helmut Jarausch) Date: 20 Jan 2011 14:31:09 GMT Subject: getdefaultencoding - how to change this? Message-ID: <4d38472d$0$14250$ba620e4c@news.skynet.be> Hi, I've searched the net but didn't find the information I need. Using Python-2.7.1, I know, I can't modify defaultencoding at run time. Python even ignores export PYTHONIOENCODING=ISO8859-1 locale.getdefaultlocale()[1] returns 'ISO8859-1' still sys.stdout is using the ascii codec. How can I recompile Python (itself) to change this to iso8859-1 ? (My favourite editor cannot be told to use unicode.) Many thanks for a hint, Helmut. From askutt at gmail.com Thu Jan 20 09:40:44 2011 From: askutt at gmail.com (Adam Skutt) Date: Thu, 20 Jan 2011 06:40:44 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com><4d337983$0$29983$c3e8da3$5496439d@news.astraweb.com><044a5101-948d-4458-9c94-57dbb3e25f67@m35g2000vbn.googlegroups.com><4d3467bf$0$29983$c3e8da3$5496439d@news.astraweb.com><4D34B04E.8050309@web.de><4266E8D7BA204BFEA5BF66C635CE1716@octavian><4D35DCE8.5030002@web.de><4D35DD47.1070304@web.de><7A0C7934E65D4B85A584C06ADD3B6ECF@teddy> Message-ID: <3dfec259-7b57-4ed2-9aba-d9f4476a25b3@32g2000yqz.googlegroups.com> On Jan 20, 8:19?am, "Octavian Rasnita" wrote: > The Windows applications are not accessible only if they use MSAA. The > screen readers know how to get the necessary information for making the > interfaces accessible in other ways, but of course, it is harder for the > screen reader manufacturers if the GUIs don't respect a standard. Actually, JAWS uses MSAA dead last, as I understand it, because the API is truly that awful. But MSAA is necessary whenever you're not using a Win32 common control or most of the other stuff developed by MS. That means essentially every non-MS toolkit that's been discussed. > And if MSAA is hated it doesn't mean that the accessibility is so poor as > you might think. No, but it does mean precisely what I said: application developers can do the "right" thing and get the wrong result. > Yes, that's a problem but we divagate. If you believe that is a problem then you cannot say, "Accessibility does not require special effort" without contradicting yourself. If it did not require effort over and above the norm, then the cultural problem would not exist. > Yes of course, Adobe's products are at most very hard accessible or not > accessible at all and I already said that Gtk is not accessible under > Windows, just like Tk. Which means you're excluding a large swath of applications in your analysis. > Well, I haven't used WxPython until now, but only WxPerl, however the WxPerl > programmers don't need to set the tab focus because by default the tab focus > is set in the order of the controls on the form and I thought it should be > the same in WxPython. It's set in the order you create the controls (with some exceptions), which may or may not be the correct tab focus order. Moreover, the same FAQ I linked tells you that you need to set special styles to support proper tab order when tabbed widgets and certain other controls are involved, to say nothing of fall backs for certain other controls that aren't provided automatically. > Yes, that's true, but as I said, some GUIS like WxPython offer the > accessibility, so those controls are visible, and it is less important if > they are in a right tab order or if some of the controls are not labeled, > because the screen reader can solve these things. You've said yourself that it often requires trial and error on the part of the user, so which is it? > A GUI which offers accessible widgets only if they are coded specially for > beeing accessible are not accessible at all, That's the case with every GUI API on the planet: if you write a custom widget you must provide accessibility support for it. This is nothing new. > Have you created that QT application with its default options? Without doing > anything special to make it accessible? Yes, you don't have to do a thing, unless you're custom building Qt yourself. On Linux, you have to set QT_ACCESSIBILITY = 1, but Linux is the exception. > And most important, have you tested it with JAWS screen reader? (Or > WindowEyes at least) because these are the most used screen readers. > NVDA is pretty poor and it can't be used for very complex things (yet). > No, and I have zero interest in doing so. Point was merely to demonstrate your statement was false. Adam From bkline at rksystems.com Thu Jan 20 10:08:40 2011 From: bkline at rksystems.com (Bob Kline) Date: Thu, 20 Jan 2011 10:08:40 -0500 Subject: Part of RFC 822 ignored by email module Message-ID: <4D384FF8.6060708@rksystems.com> I just noticed that the following passage in RFC 822: The process of moving from this folded multiple-line representation of a header field to its single line represen- tation is called "unfolding". Unfolding is accomplished by regarding CRLF immediately followed by a LWSP-char as equivalent to the LWSP-char. is not being honored by the email module. The following two invocations of message_from_string() should return the same value, but that's not what happens: >>> import email >>> email.message_from_string("Subject: blah").get('SUBJECT') 'blah' >>> email.message_from_string("Subject:\n blah").get('SUBJECT') ' blah' Note the space in front of the second value returned, but missing from the first. Can someone convince me that this is not a bug? -- Bob Kline http://www.rksystems.com mailto:bkline at rksystems.com From rantingrick at gmail.com Thu Jan 20 10:11:16 2011 From: rantingrick at gmail.com (rantingrick) Date: Thu, 20 Jan 2011 07:11:16 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <2ef2fa6c-2ccf-453a-8f50-0ef7dbd7834d@j32g2000yqc.googlegroups.com> <5c6ff40f-05c1-4e38-89bc-b8c4745db7ce@i18g2000yqn.googlegroups.com> <9a036db2-9f32-441f-aa0f-698ac22fb152@e20g2000vbn.googlegroups.com> <981140f7-79d4-421d-88c1-c819f38a3d49@w2g2000yqb.googlegroups.com> <4D37AA0F.3010601@gmail.com> Message-ID: <6d1bfa09-591b-47a4-9d3f-3edcd20019da@z5g2000yqb.googlegroups.com> On Jan 20, 6:30?am, Bill Felton wrote: > With some hesitation, I feel a need to jump in here. I'm a complete > newbie to Python. I'm still learning the language. And you know > what? I've ignored Tkinter. Well it is really not a good idea to show your ignorance of a subject matter directly before offering your opinion on that same subject matter. Most people don't listen to the uninformed. Just FYI. However lucky for you i am a fair guy and will give anyone a chance, sometimes even two. ;-) > I quickly discovered the alternatives and am already working with > wxPython. But is wxPython the correct alternative for you? What is so bad about Tkinter exactly?. Why did you choose to skip it? There must be a compelling reason. Why did you go out of your way to download another GUI library when one exists in the stdlib? These are all good questions that demand answers. So far you've offered opinion and no facts. You said you ignored Tkinter but you did not explain why. Now would be a good time to inject some facts into your argument. > I can't believe anyone is so hung up by their own arrogance that > they honestly believe that the mere *presence* of a gui kit inside > of the standard distribution would prevent a newbie from learning > about the existence and possible benefits of alternatives. No one has ever said such an outlandish thing as this. You have missed the entire point of this thread, congratulations! Now, go back and read over the entire thread again and again until you comprehend it completely before making another post. I look forward to your coherent and lively discussion based on facts and not simply opinions. > Sure, *they* can see alternatives and evaluate why Tkinter might not > be a good choice under conditions x or y or z, but god forbid anyone > new to the language should have to confront those issues or be asked > to make such a decision. How could we trust those lowly newbies to > think *properly* about the issue! We can't. Are you actually suggestion that someone with NO experience with ANY of the GUI library available somehow has a better insight into choosing the best GUI library than someone who (i don't know) ACTUALLY HAS USED ALL OF THEM! Who's sock puppet are you Bill? Really. And if you are not a sock puppet i HOPE you are just trolling because this is a bombastic display of ignorance!. You could not be more *uninformed* my friend. Heck with your mindset, the "Cookie Monster" should replace Guido as BDFL. He has NO experience with anything besides chowing down cookies, perfect choice! > ESPECIALLY in a language widely touted for the vast array of > external libraries available.The attitude that the standard > distribution needs this kind of obsessive, hysterically blinkered, > focused on irrelevant minutiae is far more likely to be the downfall > of the language than the presence of a sub-optimal gui kit that no > one is required to use. Yes, and you just hit the nail on the the head! Why leave the stdlib full of cruft (Tkinter)? > As one of 'the people' who is presumably the focus of rantingrick's > concern, let me assure him Tkinter is a non-issue. MIchael is more > in touch with my issues than rr. FYI you are NOT one of the people that is the focus of my concern because YOU only see the world from a limited viewpoint. And i never proposed to solve every Python programmers problems. You completely misunderstand my intentions (along with everyone else!). I do not believe in "Utopian dreams". Some people will never be happy with the state of Python and that is OK. However, the goal is to keep the majority happy AND keep Python "presentable" and "competitive" for the next decade. I am sorry you don't fit into any of these categories but that is your own fault. Why? Because you are not concerned with the community as a whole. You are only concerned with YOURSELF. You are displaying both selfishness and ignorance at the same time. We don't care what selfish people think and we care even less what the ignorant think. If you decide to become a "team player" then you will be a part of this community. Lucky for you ignorance and selfishness are reversible personality traits. From rantingrick at gmail.com Thu Jan 20 10:13:00 2011 From: rantingrick at gmail.com (rantingrick) Date: Thu, 20 Jan 2011 07:13:00 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <2ef2fa6c-2ccf-453a-8f50-0ef7dbd7834d@j32g2000yqc.googlegroups.com> <5c6ff40f-05c1-4e38-89bc-b8c4745db7ce@i18g2000yqn.googlegroups.com> <9a036db2-9f32-441f-aa0f-698ac22fb152@e20g2000vbn.googlegroups.com> <981140f7-79d4-421d-88c1-c819f38a3d49@w2g2000yqb.googlegroups.com><4D37AA0F.3010601@gmail.com> <953B2583-5609-4C0C-9B4F-CA46F9E570F4@cagttraining.com> Message-ID: <94d38d79-a64b-4976-8f7e-cbd083fa5ad5@d8g2000yqf.googlegroups.com> On Jan 20, 7:48?am, pyt... at bdurham.com wrote: > Bill, [...snip...] > +1 (very well said) Yes maybe Bill should be BDFL or a core developer. He has all the answers. But no FACTS! From jarausch at skynet.be Thu Jan 20 10:39:34 2011 From: jarausch at skynet.be (Helmut Jarausch) Date: 20 Jan 2011 15:39:34 GMT Subject: getdefaultencoding - how to change this? References: <4d38472d$0$14250$ba620e4c@news.skynet.be> Message-ID: <4d385736$0$14253$ba620e4c@news.skynet.be> On Thu, 20 Jan 2011 14:31:09 +0000, Helmut Jarausch wrote: > Hi, > I've searched the net but didn't find the information I need. Using > Python-2.7.1, I know, I can't modify defaultencoding at run time. Python > even ignores > export PYTHONIOENCODING=ISO8859-1 > > locale.getdefaultlocale()[1] > returns > 'ISO8859-1' > > still sys.stdout is using the ascii codec. How can I recompile Python > (itself) to change this to iso8859-1 ? (My favourite editor cannot be > told to use unicode.) > Sorry for answering myself. One last trial did succeed. My locale as root differed from my locale as non-root user. After changing the root locale and recompiling Python, it works now. -- From invalid at invalid.invalid Thu Jan 20 10:42:55 2011 From: invalid at invalid.invalid (Grant Edwards) Date: Thu, 20 Jan 2011 15:42:55 +0000 (UTC) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <2510bf88-1045-411f-9ccd-7ca7c3665454@l24g2000vby.googlegroups.com> <2ef2fa6c-2ccf-453a-8f50-0ef7dbd7834d@j32g2000yqc.googlegroups.com> <5c6ff40f-05c1-4e38-89bc-b8c4745db7ce@i18g2000yqn.googlegroups.com> <9a036db2-9f32-441f-aa0f-698ac22fb152@e20g2000vbn.googlegroups.com> <981140f7-79d4-421d-88c1-c819f38a3d49@w2g2000yqb.googlegroups.com> Message-ID: On 2011-01-20, Michael Torrie wrote: > I don't see the original bizarre rants for some reason (spam filter > likely), but I have to say this is the most ridiculous thing I've heard > in some time. Tkinter the downfall of python? Wow. All of the python > programmers I know (we use python every day at work) would say, "what > is tkinter?" It's just not relevant to any of them that I know. Google > probably uses as much Python as anyone, and their programmers would > probably agree. Perhaps that's an argument to remove tkinter entirely, > but not really a good one. > > In the meantime they happily crank out code with Django, or PyQt, or > PyGTK, or even Tkinter--whatever tool is appropriate for the job. Tkinter has it's flaws. For example, the fact that it inclues a Tcl interpreter inside the black box annoys me because I think Tcl is an awful, awful language. That's somewhat irrational, so perhaps that's my flaw and not Tkinter's. However, Tkinter is easy to use (especially for simple tasks) and it _works_. I wrote a moderatly complex (to me) UI in Tkinter 10+ years ago. It still works fine. I couldn't say that about some wxPython programs a quarter that old. > Perhaps a reference to Xah Lee's web site would suffice. :) -- Grant Edwards grant.b.edwards Yow! What GOOD is a at CARDBOARD suitcase ANYWAY? gmail.com From jarausch at skynet.be Thu Jan 20 10:43:05 2011 From: jarausch at skynet.be (Helmut Jarausch) Date: 20 Jan 2011 15:43:05 GMT Subject: printing a list with non-ascii strings Message-ID: <4d385809$0$14253$ba620e4c@news.skynet.be> Hi, I don't understand Python's behaviour when printing a list. The following example uses 2 German non-ascii characters. #!/usr/bin/python # _*_ coding: latin1 _*_ L=["abc","s??","def"] print L[1],L The output of L[1] is correct, while the output of L shows up as ['abc', 's\xfc\xdf', 'def'] How can this be changed? Thanks for hint, Helmut. From invalid at invalid.invalid Thu Jan 20 10:44:07 2011 From: invalid at invalid.invalid (Grant Edwards) Date: Thu, 20 Jan 2011 15:44:07 +0000 (UTC) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <4d337983$0$29983$c3e8da3$5496439d@news.astraweb.com> <044a5101-948d-4458-9c94-57dbb3e25f67@m35g2000vbn.googlegroups.com> <4d3467bf$0$29983$c3e8da3$5496439d@news.astraweb.com> <4D34B04E.8050309@web.de> <4266E8D7BA204BFEA5BF66C635CE1716@octavian> <4D35DCE8.5030002@web.de> <4D35DD47.1070304@web.de> <42924000-3ffb-40f5-9cf8-70a9d767b944@k25g2000vbl.googlegroups.com> Message-ID: On 2011-01-20, Octavian Rasnita wrote: > From: "Grant Edwards" >>>> On all of my computers, wxPython uses Gtk. There are other choices >>>> for wxWidget backends on Linux, but Gtk is by far the most common. >>>> IOW, if Gtk is bad, then wxPython is bad. >>> >>> Not true. >> >> I think you're playing a bit fast and loose with your accusations. > > >:-) > I've made no accusations, Yes you have. You claimed what I stated was not true. > but I only try to inform the people about the > accessibility of different GUI libs. > >> Which of my statements was "not true"? >> >> 1) On all of my computers wxPython uses Gtk. >> >> 2) There are other backend choices on Linux besides Gtk. >> >> 3) Gtk is by far the most common wxWidgets backend on Linux/Unix. >> >> 4) If Gtk is bad then wxPython is bad. >> >> Note that 4) follows logically from 3), so to say that 4) is "not >> true" you have to show that 3) is "not true". > > The wrong conclusion is that if Gtk is bad, then WxPython is bad. Gtk > is inaccessible under Windows, not under Linux, but WxPython doesn't > use Gtk under Windows so WxPython is OK. Ah. I didn't realize we were operating under the premise that Windows was the only OS that mattered. Sorry. -- Grant Edwards grant.b.edwards Yow! Maybe I should have at asked for my Neutron Bomb gmail.com in PAISLEY -- From orasnita at gmail.com Thu Jan 20 10:44:22 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Thu, 20 Jan 2011 17:44:22 +0200 Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com><4d337983$0$29983$c3e8da3$5496439d@news.astraweb.com><044a5101-948d-4458-9c94-57dbb3e25f67@m35g2000vbn.googlegroups.com><4d3467bf$0$29983$c3e8da3$5496439d@news.astraweb.com><4D34B04E.8050309@web.de><4266E8D7BA204BFEA5BF66C635CE1716@octavian><4D35DCE8.5030002@web.de><4D35DD47.1070304@web.de><7A0C7934E65D4B85A584C06ADD3B6ECF@teddy> <3dfec259-7b57-4ed2-9aba-d9f4476a25b3@32g2000yqz.googlegroups.com> Message-ID: <56E10397013948838919D68AA6A89BFA@teddy> From: "Adam Skutt" Actually, JAWS uses MSAA dead last, as I understand it, because the API is truly that awful. But MSAA is necessary whenever you're not using a Win32 common control or most of the other stuff developed by MS. That means essentially every non-MS toolkit that's been discussed. Yes, but WxPython uses wxWIDGETS and wxWIDGETS use the standard Win32 controls under Windows, so they are accessible. And they use Gtk under Linux and Gtk is accessible under Linux also. That's why I said that WxPython should be prefered. > And if MSAA is hated it doesn't mean that the accessibility is so poor as > you might think. No, but it does mean precisely what I said: application developers can do the "right" thing and get the wrong result. Yes of course they can do that if they use the wrong tool. They can't do the right thing if they believe that Tk or Silverlight or Flash is accessible no matter if they follow the recommendations for accessibility, because the screen readers don't support those interfaces. > Yes, that's a problem but we divagate. If you believe that is a problem then you cannot say, "Accessibility does not require special effort" without contradicting yourself. If it did not require effort over and above the norm, then the cultural problem would not exist. Nope, the cultural problem exists because the programmers use the wrong interface, not because they just don't make the efforts for making that interface more accessible. To be more clear and not to include in the discussion many interfaces, we are comparing Tkinter and WxPython. Most users that require accessibility are using Windows and under Windows WxPython use the underlying Win32 GUI which is accessible, while Tk is not accessible at all, no matter what the programmers do in order to make the interface accessible. > Yes of course, Adobe's products are at most very hard accessible or not > accessible at all and I already said that Gtk is not accessible under > Windows, just like Tk. Which means you're excluding a large swath of applications in your analysis. I am not excluding anything. I said that all the Tk-based programs are inaccessible no matter what the programmer does to make it accessible, because the screen readers can't work with that interface. And I have also said which are the accessible interfaces: wxWIDGETS (which use Win32 GUI under Windows and Gtk under Linux), SWT (which I think it does exactly the same thing as wxWIDGETS), WindowsForms (DotNet) and SWING (if the user installs Java Access Bridge). Some of the interfaces created with other GUI libs might be accessible but it is not sure. What is sure is that the Tk-based interfaces are not accessible. > Well, I haven't used WxPython until now, but only WxPerl, however the WxPerl > programmers don't need to set the tab focus because by default the tab focus > is set in the order of the controls on the form and I thought it should be > the same in WxPython. It's set in the order you create the controls (with some exceptions), which may or may not be the correct tab focus order. Moreover, the same FAQ I linked tells you that you need to set special styles to support proper tab order when tabbed widgets and certain other controls are involved, to say nothing of fall backs for certain other controls that aren't provided automatically. Yes, but with or without a proper tab order, WxPython creates accessible apps, while Tkinter doesn't. > Yes, that's true, but as I said, some GUIS like WxPython offer the > accessibility, so those controls are visible, and it is less important if > they are in a right tab order or if some of the controls are not labeled, > because the screen reader can solve these things. You've said yourself that it often requires trial and error on the part of the user, so which is it? It depends if there is a JAWS script defined. JAWS provides by default scripts for dozens of popular applications for making them more usable. Each user can create his/her own script, because JAWS include that scripting language and a programming interface so the user can create their own script for an application for improving its usability, for labeling some not-named controls, for reading some parts of the screen when some events occur and many other things. If the user doesn't want or don't know how to create that script for improving the usability, he/she might need to learn how to use the application by trial and error, but what I want to show is that the user is *able* to use that application, even if the interface is not very friendly, but it would be absolutely impossible to use an application created with Tkinter. > A GUI which offers accessible widgets only if they are coded specially for > beeing accessible are not accessible at all, That's the case with every GUI API on the planet: if you write a custom widget you must provide accessibility support for it. This is nothing new. I am not talking about custom controls. Those things are the worst thing possible from the perspective of accessibility, because usually nobody cares about providing accessibility features. I am talking about standard controls. The standard controls provided by WxPython are accessible, no matter how usable and friendly they are, while the standard controls offered by Tkinter are absolutely inaccessible. > Have you created that QT application with its default options? Without doing > anything special to make it accessible? Yes, you don't have to do a thing, unless you're custom building Qt yourself. On Linux, you have to set QT_ACCESSIBILITY = 1, but Linux is the exception. > And most important, have you tested it with JAWS screen reader? (Or > WindowEyes at least) because these are the most used screen readers. > NVDA is pretty poor and it can't be used for very complex things (yet). > No, and I have zero interest in doing so. Point was merely to demonstrate your statement was false. My point was that Tkinter which uses Tk is bad, and I didn't tried too many QT-based applications. It would be nice if now QT would be accessible, but this won't mean too much if it would be accessible just for NVDA and not for the most used screen readers. And I don't see what you demonstrate when you wanted to show Tkinter it is comparing with WxPython... Octavian From philip at semanchuk.com Thu Jan 20 10:47:54 2011 From: philip at semanchuk.com (Philip Semanchuk) Date: Thu, 20 Jan 2011 10:47:54 -0500 Subject: getdefaultencoding - how to change this? In-Reply-To: <4d385736$0$14253$ba620e4c@news.skynet.be> References: <4d38472d$0$14250$ba620e4c@news.skynet.be> <4d385736$0$14253$ba620e4c@news.skynet.be> Message-ID: <31001839-2E89-4D3E-B3D4-26BFA6D00EAD@semanchuk.com> On Jan 20, 2011, at 10:39 AM, Helmut Jarausch wrote: > On Thu, 20 Jan 2011 14:31:09 +0000, Helmut Jarausch wrote: > >> Hi, >> I've searched the net but didn't find the information I need. Using >> Python-2.7.1, I know, I can't modify defaultencoding at run time. Python >> even ignores >> export PYTHONIOENCODING=ISO8859-1 >> >> locale.getdefaultlocale()[1] >> returns >> 'ISO8859-1' >> >> still sys.stdout is using the ascii codec. How can I recompile Python >> (itself) to change this to iso8859-1 ? (My favourite editor cannot be >> told to use unicode.) >> > > Sorry for answering myself. One last trial did succeed. > My locale as root differed from my locale as non-root user. > After changing the root locale and recompiling Python, it works now. I'm glad that worked for you. Alternatively, it seems like you can set the default encoding in site.py which sounds easier than recompiling Python. Cheers Philip From rantingrick at gmail.com Thu Jan 20 10:58:53 2011 From: rantingrick at gmail.com (rantingrick) Date: Thu, 20 Jan 2011 07:58:53 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <4d3467bf$0$29983$c3e8da3$5496439d@news.astraweb.com> <4D34B04E.8050309@web.de> <4266E8D7BA204BFEA5BF66C635CE1716@octavian> <4D35DCE8.5030002@web.de> <4D35DD47.1070304@web.de> <42924000-3ffb-40f5-9cf8-70a9d767b944@k25g2000vbl.googlegroups.com> Message-ID: <165b3519-c7f7-4d4d-8137-1558d4dabc20@v26g2000yqf.googlegroups.com> On Jan 20, 9:44?am, Grant Edwards wrote: > > The wrong conclusion is that if Gtk is bad, then WxPython is bad. Gtk > > is inaccessible under Windows, not under Linux, but WxPython doesn't > > use Gtk under Windows so WxPython is OK. > > Ah. ?I didn't realize we were operating under the premise that Windows > was the only OS that mattered. ?Sorry. Windows IS the only OS that matters WHEN we are talking about "hand holding". Anyone who uses Unix/Linux and cries about downloading dependencies is just doing so for sake of discrediting the opposite position. Only the lemmings would believe such nonsense. Unix/Linux are NOT hand holding OS's. Thats what windows is for. And the argument presented earlier (i think Octavian) about how the majority of accessibility users are using windows is spot on! Anyone who also denies this fact is just contributing more BS to the "devils advocates" here. I am not suggesting that accessibility is not important to a small sub set of Linux users. However the fact is that the majority of "special needs" folks use windows. And thats a fact! From benjamin.kaplan at case.edu Thu Jan 20 11:03:32 2011 From: benjamin.kaplan at case.edu (Benjamin Kaplan) Date: Thu, 20 Jan 2011 11:03:32 -0500 Subject: printing a list with non-ascii strings In-Reply-To: <4d385809$0$14253$ba620e4c@news.skynet.be> References: <4d385809$0$14253$ba620e4c@news.skynet.be> Message-ID: On Thu, Jan 20, 2011 at 10:43 AM, Helmut Jarausch wrote: > Hi, > > I don't understand Python's behaviour when printing a list. > The following example uses 2 German non-ascii characters. > > #!/usr/bin/python > # _*_ coding: latin1 _*_ > L=["abc","s??","def"] > print L[1],L > > The output of L[1] is correct, while the output of L shows up as > ['abc', 's\xfc\xdf', 'def'] > > How can this be changed? > > Thanks for hint, > Helmut. > > Use Python 3 if you can. Printing a list calls the repr(). In python 2, that showed the bytes for non-ascii characters. Python 3 will print the characters. > -- > http://mail.python.org/mailman/listinfo/python-list > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rustompmody at gmail.com Thu Jan 20 11:36:20 2011 From: rustompmody at gmail.com (rusi) Date: Thu, 20 Jan 2011 08:36:20 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <2ef2fa6c-2ccf-453a-8f50-0ef7dbd7834d@j32g2000yqc.googlegroups.com> <5c6ff40f-05c1-4e38-89bc-b8c4745db7ce@i18g2000yqn.googlegroups.com> <9a036db2-9f32-441f-aa0f-698ac22fb152@e20g2000vbn.googlegroups.com> <981140f7-79d4-421d-88c1-c819f38a3d49@w2g2000yqb.googlegroups.com> <4D37AA0F.3010601@gmail.com> Message-ID: <8871b602-2cd4-43c4-b289-63e0bc167714@z17g2000prz.googlegroups.com> On Jan 20, 5:30?pm, Bill Felton wrote: > With some hesitation, I feel a need to jump in here. ? This thread is now at 239 posts (and so I too hesitate...) The arguments for size, dependencies etc are what may be termed 'sys- ad' perspectives. The questions of 'it looks nice/ancient etc' are user issues. What about some programmer perspective? Using something like VB-in-.NET allows a programmer to put up significant uis with close to zero coding. Many programmers would look down on these as 'non-programmers' [I should know: I inhabited a university CS dept for nearly 20 years where Turing machines and lambda calculus are fashionable and getchar/ putchar programs are more hip than pleasant-looking GUIs. Many of our problems stem from the fact that this academic hubris is justified as objective] So the (to me) relevant questions relating to GUIs are for example: 1. Is glade (and others such) equal to wxpython, tkinter and other such 'backends'? 2. Can glade (or whichever is the best such tool today) compare to VB in .NET or does it look like a bad joke in comparison (I guess the current thing may not be VB but WPF but I dont want to pretend to know too much about windows) From robert.kern at gmail.com Thu Jan 20 11:46:37 2011 From: robert.kern at gmail.com (Robert Kern) Date: Thu, 20 Jan 2011 10:46:37 -0600 Subject: getdefaultencoding - how to change this? In-Reply-To: <4d38472d$0$14250$ba620e4c@news.skynet.be> References: <4d38472d$0$14250$ba620e4c@news.skynet.be> Message-ID: On 1/20/11 8:31 AM, Helmut Jarausch wrote: > Hi, > I've searched the net but didn't find the information I need. > Using Python-2.7.1, I know, I can't modify defaultencoding at run time. You're not supposed to. It must remain 'ascii'. Otherwise, you will break dict lookups among other things. Can you be specific about why you think you want to change this? What are you trying to achieve? It looks like you are conflating a variety of different behaviors below. > Python even ignores > export PYTHONIOENCODING=ISO8859-1 > > locale.getdefaultlocale()[1] > returns > 'ISO8859-1' This does not introspect the same thing as sys.getdefaultencoding(). > still sys.stdout is using the ascii codec. This reflects your terminal settings, not sys.getdefaultencoding(). I'm not sure why the PYTHONIOENCODING variable isn't affecting that. It works fine for me. > How can I recompile Python (itself) to change this to iso8859-1 ? > (My favourite editor cannot be told to use unicode.) You wouldn't want to change sys.getdefaultencoding() for this. That parameter affects how str and unicode objects are converted between each other without an explicit .encode()/.decode() call, not what encoding Python assumes for the parsing of the code. Instead, you want to use an encoding declaration in each file: http://docs.python.org/reference/lexical_analysis.html#encoding-declarations -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco From robert.kern at gmail.com Thu Jan 20 11:47:42 2011 From: robert.kern at gmail.com (Robert Kern) Date: Thu, 20 Jan 2011 10:47:42 -0600 Subject: getdefaultencoding - how to change this? In-Reply-To: <31001839-2E89-4D3E-B3D4-26BFA6D00EAD@semanchuk.com> References: <4d38472d$0$14250$ba620e4c@news.skynet.be> <4d385736$0$14253$ba620e4c@news.skynet.be> <31001839-2E89-4D3E-B3D4-26BFA6D00EAD@semanchuk.com> Message-ID: On 1/20/11 9:47 AM, Philip Semanchuk wrote: > I'm glad that worked for you. Alternatively, it seems like you can set the default encoding in site.py which sounds easier than recompiling Python. Never do that. It breaks dicts and makes your code non-portable. -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco From subscriptions at cagttraining.com Thu Jan 20 11:48:21 2011 From: subscriptions at cagttraining.com (Bill Felton) Date: Thu, 20 Jan 2011 11:48:21 -0500 Subject: Tkinter: The good, the bad, and the ugly! In-Reply-To: <6d1bfa09-591b-47a4-9d3f-3edcd20019da@z5g2000yqb.googlegroups.com> References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <2ef2fa6c-2ccf-453a-8f50-0ef7dbd7834d@j32g2000yqc.googlegroups.com> <5c6ff40f-05c1-4e38-89bc-b8c4745db7ce@i18g2000yqn.googlegroups.com> <9a036db2-9f32-441f-aa0f-698ac22fb152@e20g2000vbn.googlegroups.com> <981140f7-79d4-421d-88c1-c819f38a3d49@w2g2000yqb.googlegroups.com> <4D37AA0F.3010601@gmail.com> <6d1bfa09-591b-47a4-9d3f-3edcd20019da@z5g2000yqb.googlegroups.com> Message-ID: On Jan 20, 2011, at 10:11 AM, rantingrick wrote: > On Jan 20, 6:30 am, Bill Felton > wrote: > >> With some hesitation, I feel a need to jump in here. I'm a complete >> newbie to Python. I'm still learning the language. And you know >> what? I've ignored Tkinter. > > Well it is really not a good idea to show your ignorance of a subject > matter directly before offering your opinion on that same subject > matter. Most people don't listen to the uninformed. Just FYI. However > lucky for you i am a fair guy and will give anyone a chance, sometimes > even two. ;-) > You are too kind. Given that the strong implication of your point about 'downfall' was that newcomers would somehow be negatively impacted by Tkinter, I would think you would welcome input from that part of the audience. >> I quickly discovered the alternatives and am already working with >> wxPython. > > But is wxPython the correct alternative for you? What is so bad about > Tkinter exactly?. Why did you choose to skip it? There must be a > compelling reason. Why did you go out of your way to download another > GUI library when one exists in the stdlib? These are all good > questions that demand answers. So far you've offered opinion and no > facts. You said you ignored Tkinter but you did not explain why. Now > would be a good time to inject some facts into your argument. Ah, ah, ah, not appropriate to the point at hand. This isn't about me, this is about the absurd claim that the inclusion of Tkinter in the Python standard distribution is a 'downfall' point for the language. I think that point has been disabused, although you may well still be sticking with it. [snip] >> [Sure, *they* can see alternatives and evaluate why Tkinter might not >> be a good choice under conditions x or y or z, but god forbid anyone >> new to the language should have to confront those issues or be asked >> to make such a decision. How could we trust those lowly newbies to >> think *properly* about the issue! > > We can't. Are you actually suggestion that someone with NO experience > with ANY of the GUI library available somehow has a better insight > into choosing the best GUI library than someone who (i don't know) > ACTUALLY HAS USED ALL OF THEM! Ahs, I see, you have been infected by "the best bug". There is no such thing as 'the best' anything absent the standard that is used to judge. And multiple standards apply. > Who's sock puppet are you Bill? Really. > And if you are not a sock puppet i HOPE you are just trolling because > this is a bombastic display of ignorance!. rantingrick, meet mirror, mirror, meet rantingrick. I can't say I'm surprised to see this kind of response from you, this leap from my post to the assumption that I know nothing about programming or about GUIs. FWIW, I have 20+ years of experience with Smalltalk and am well aware of GUI issues and the manifold ways in which they must be approached and judged. Your little 'one size must fit all" attitude is what will be the downfall of Python, or any other language infected with it. We saw that with Smalltalk and its community, we see it everywhere. [snip] > > Yes, and you just hit the nail on the the head! Why leave the stdlib > full of cruft (Tkinter)? At least two reasons, one big one, one little one. The little one: because TKinter provides the base for such things as IDLE, which are a genuine boon to the newcomer. The big one: because you have somehow failed to demonstrate that Tkiinter is cruft. You've demonstrated you don't like it, you've asserted, at great length and in a wide variety of ways and countless posts, that it is cruft, but somehow the proof remains absent. Yet you whine about others not providing 'FACTS'. Why should anyone listen to you on this matter, most especially when you labor under the tedious delusion that there is such a thing as 'the best GUI' without constraint. Of course, you could always produce one... > >> As one of 'the people' who is presumably the focus of rantingrick's >> concern, let me assure him Tkinter is a non-issue. MIchael is more >> in touch with my issues than rr. > > FYI you are NOT one of the people that is the focus of my concern > because YOU only see the world from a limited viewpoint. EVERYONE sees the world from a limited viewpoint. Most of us realize this, and find those of you who don't at least faintly annoying. cheers, Bill -------------- next part -------------- An HTML attachment was scrubbed... URL: From philip at semanchuk.com Thu Jan 20 11:58:41 2011 From: philip at semanchuk.com (Philip Semanchuk) Date: Thu, 20 Jan 2011 11:58:41 -0500 Subject: getdefaultencoding - how to change this? In-Reply-To: References: <4d38472d$0$14250$ba620e4c@news.skynet.be> <4d385736$0$14253$ba620e4c@news.skynet.be> <31001839-2E89-4D3E-B3D4-26BFA6D00EAD@semanchuk.com> Message-ID: On Jan 20, 2011, at 11:47 AM, Robert Kern wrote: > On 1/20/11 9:47 AM, Philip Semanchuk wrote: > >> I'm glad that worked for you. Alternatively, it seems like you can set the default encoding in site.py which sounds easier than recompiling Python. > > Never do that. It breaks dicts and makes your code non-portable. I've never been tempted for the very non-portability reason you cite. I didn't know that it would break dicts, though. Thanks for the education. bye Philip From ckaynor at zindagigames.com Thu Jan 20 12:01:51 2011 From: ckaynor at zindagigames.com (Chris Kaynor) Date: Thu, 20 Jan 2011 09:01:51 -0800 Subject: collections.Set Binary Reflected Operations In-Reply-To: References: Message-ID: Okay, thats what I was looking for, thanks. In my case, I'll just implement the (needed) reflected operators in my class. Chris On Wed, Jan 19, 2011 at 10:02 PM, Daniel Urban wrote: > On Thu, Jan 20, 2011 at 01:51, Chris Kaynor > wrote: > > I am implemented a custom set-like type which interacts with some > > third-party software when retrieving and mutating the set, and have > derived > > my custom type off of collections.MutableSet, however I have noticed that > > some of the magic methods supported by the built-in set do not fully > > function with my custom type. From this, I looked over the > > MutableSet definition in and it seems to be missing all of the reflected > > operators (__rsub__, __rand__, __ror__, __rxor__, and friends) for the > > operators it has defined. I can post a simple example case if desired. > > I am using Python 2.6.4 (with some in-house customizations), however a > quick > > look over the svn repository shown on python.org makes it appear that > these > > are also not implemented in Python 3. I was wondering if there is some > > reason for this, or if it was merely an oversight. > > Chris > > See http://bugs.python.org/issue8743 and also > http://bugs.python.org/issue2226 > > > Daniel > -------------- next part -------------- An HTML attachment was scrubbed... URL: From python at mrabarnett.plus.com Thu Jan 20 12:13:37 2011 From: python at mrabarnett.plus.com (MRAB) Date: Thu, 20 Jan 2011 17:13:37 +0000 Subject: Tkinter: The good, the bad, and the ugly! In-Reply-To: <6d1bfa09-591b-47a4-9d3f-3edcd20019da@z5g2000yqb.googlegroups.com> References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <2ef2fa6c-2ccf-453a-8f50-0ef7dbd7834d@j32g2000yqc.googlegroups.com> <5c6ff40f-05c1-4e38-89bc-b8c4745db7ce@i18g2000yqn.googlegroups.com> <9a036db2-9f32-441f-aa0f-698ac22fb152@e20g2000vbn.googlegroups.com> <981140f7-79d4-421d-88c1-c819f38a3d49@w2g2000yqb.googlegroups.com> <4D37AA0F.3010601@gmail.com> <6d1bfa09-591b-47a4-9d3f-3edcd20019da@z5g2000yqb.googlegroups.com> Message-ID: <4D386D41.7010506@mrabarnett.plus.com> On 20/01/2011 15:11, rantingrick wrote: > On Jan 20, 6:30 am, Bill Felton > wrote: > [snip] >> As one of 'the people' who is presumably the focus of rantingrick's >> concern, let me assure him Tkinter is a non-issue. MIchael is more >> in touch with my issues than rr. > > FYI you are NOT one of the people that is the focus of my concern > because YOU only see the world from a limited viewpoint. And i never > proposed to solve every Python programmers problems. You completely > misunderstand my intentions (along with everyone else!). I do not > believe in "Utopian dreams". Some people will never be happy with the > state of Python and that is OK. However, the goal is to keep the > majority happy AND keep Python "presentable" and "competitive" for the > next decade. I am sorry you don't fit into any of these categories but > that is your own fault. Why? Because you are not concerned with the > community as a whole. You are only concerned with YOURSELF. You are > displaying both selfishness and ignorance at the same time. We don't > care what selfish people think and we care even less what the ignorant > think. If you decide to become a "team player" then you will be a part > of this community. Lucky for you ignorance and selfishness are > reversible personality traits. > So you're going to lead the "peasants" (your word) whether they like it or not, and any who don't want to follow are clearly being selfish and ignorant? Have you ever thought that if everyone is misunderstanding your intentions, then perhaps you're doing something wrong? (BTW, welcome to Pythonia, Bill! Most of us are friendly. :-)) From jarausch at skynet.be Thu Jan 20 12:20:14 2011 From: jarausch at skynet.be (Helmut Jarausch) Date: 20 Jan 2011 17:20:14 GMT Subject: getdefaultencoding - how to change this? References: <4d38472d$0$14250$ba620e4c@news.skynet.be> Message-ID: <4d386ece$0$14262$ba620e4c@news.skynet.be> On Thu, 20 Jan 2011 10:46:37 -0600, Robert Kern wrote: > On 1/20/11 8:31 AM, Helmut Jarausch wrote: >> Hi, >> I've searched the net but didn't find the information I need. Using >> Python-2.7.1, I know, I can't modify defaultencoding at run time. > > You're not supposed to. It must remain 'ascii'. Otherwise, you will > break dict lookups among other things. Can you be specific about why you > think you want to change this? What are you trying to achieve? It looks > like you are conflating a variety of different behaviors below. > >> Python even ignores >> export PYTHONIOENCODING=ISO8859-1 >> >> locale.getdefaultlocale()[1] >> returns >> 'ISO8859-1' > > This does not introspect the same thing as sys.getdefaultencoding(). > >> still sys.stdout is using the ascii codec. > > This reflects your terminal settings, not sys.getdefaultencoding(). I'm > not sure why the PYTHONIOENCODING variable isn't affecting that. It > works fine for me. > >> How can I recompile Python (itself) to change this to iso8859-1 ? (My >> favourite editor cannot be told to use unicode.) > > You wouldn't want to change sys.getdefaultencoding() for this. That > parameter affects how str and unicode objects are converted between each > other without an explicit .encode()/.decode() call, not what encoding > Python assumes for the parsing of the code. > > Instead, you want to use an encoding declaration in each file: > > http://docs.python.org/reference/lexical_analysis.html#encoding- declarations Thanks Robert, probably I wasn't too clear about my issue. I couldn't "print" any non-ascii character to my console although my console has an en_US.iso88591 locale. I didn't modfiy anything in Python's source code. I noticed that my root account still had an ASCII locale. Now I have changed it such that the root account has the same locale as non-root accounts. Recompiling Python under such a root account has rectified things. Now I can print non-ascii characters if they are properly encoded. Thanks, Helmut. -- From pavlovevidence at gmail.com Thu Jan 20 12:23:11 2011 From: pavlovevidence at gmail.com (Carl Banks) Date: Thu, 20 Jan 2011 09:23:11 -0800 (PST) Subject: Part of RFC 822 ignored by email module References: Message-ID: On Jan 20, 7:08?am, Bob Kline wrote: > I just noticed that the following passage in RFC 822: > > ? ? ? ? ?The process of moving ?from ?this ?folded ? multiple-line > ? ? ? ? ?representation ?of a header field to its single line represen- > ? ? ? ? ?tation is called "unfolding". ?Unfolding ?is ?accomplished ?by > ? ? ? ? ?regarding ? CRLF ? immediately ?followed ?by ?a ?LWSP-char ?as > ? ? ? ? ?equivalent to the LWSP-char. > > is not being honored by the email module. ?The following two invocations > of message_from_string() should return the same value, but that's not > what happens: > > ?>>> import email > ?>>> email.message_from_string("Subject: blah").get('SUBJECT') > 'blah' > ?>>> email.message_from_string("Subject:\n blah").get('SUBJECT') > ' blah' > > Note the space in front of the second value returned, but missing from > the first. ?Can someone convince me that this is not a bug? That's correct, according to my reading of RFC 822 (I doubt it's changed so I didn't bother to look up what the latest RFC on that subject is.) The RFC says that in a folded line the whitespace on the following line is considered a part of the line. Relevant quite (section 3.1.1): Each header field can be viewed as a single, logical line of ASCII characters, comprising a field-name and a field-body. For convenience, the field-body portion of this conceptual entity can be split into a multiple-line representation; this is called "folding". The general rule is that wherever there may be linear-white-space (NOT simply LWSP-chars), a CRLF immediately followed by AT LEAST one LWSP-char may instead be inserted. Thus, the single line To: "Joe & J. Harvey" , JJV @ BBN can be represented as: To: "Joe & J. Harvey" , JJV at BBN and To: "Joe & J. Harvey" , JJV @BBN and To: "Joe & J. Harvey" , JJV @ BBN The process of moving from this folded multiple-line representation of a header field to its single line represen- tation is called "unfolding". Unfolding is accomplished by regarding CRLF immediately followed by a LWSP-char as equivalent to the LWSP-char. Carl Banks From subscriptions at cagttraining.com Thu Jan 20 12:24:08 2011 From: subscriptions at cagttraining.com (Bill Felton) Date: Thu, 20 Jan 2011 12:24:08 -0500 Subject: Tkinter: The good, the bad, and the ugly! In-Reply-To: <4D386D41.7010506@mrabarnett.plus.com> References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <2ef2fa6c-2ccf-453a-8f50-0ef7dbd7834d@j32g2000yqc.googlegroups.com> <5c6ff40f-05c1-4e38-89bc-b8c4745db7ce@i18g2000yqn.googlegroups.com> <9a036db2-9f32-441f-aa0f-698ac22fb152@e20g2000vbn.googlegroups.com> <981140f7-79d4-421d-88c1-c819f38a3d49@w2g2000yqb.googlegroups.com> <4D37AA0F.3010601@gmail.com> <6d1bfa09-591b-47a4-9d3f-3edcd20019da@z5g2000yqb.googlegroups.com> <4D386D41.7010506@mrabarnett.plus.com> Message-ID: <840B14A0-2050-4595-8014-5059BED9EEEE@cagttraining.com> On Jan 20, 2011, at 12:13 PM, MRAB wrote: > On 20/01/2011 15:11, rantingrick wrote: >> On Jan 20, 6:30 am, Bill Felton >> wrote: >> > [snip] >>> As one of 'the people' who is presumably the focus of rantingrick's >>> concern, let me assure him Tkinter is a non-issue. MIchael is more >>> in touch with my issues than rr. >> >> FYI you are NOT one of the people that is the focus of my concern >> because YOU only see the world from a limited viewpoint. And i never >> proposed to solve every Python programmers problems. You completely >> misunderstand my intentions (along with everyone else!). I do not >> believe in "Utopian dreams". Some people will never be happy with the >> state of Python and that is OK. However, the goal is to keep the >> majority happy AND keep Python "presentable" and "competitive" for the >> next decade. I am sorry you don't fit into any of these categories but >> that is your own fault. Why? Because you are not concerned with the >> community as a whole. You are only concerned with YOURSELF. You are >> displaying both selfishness and ignorance at the same time. We don't >> care what selfish people think and we care even less what the ignorant >> think. If you decide to become a "team player" then you will be a part >> of this community. Lucky for you ignorance and selfishness are >> reversible personality traits. >> > So you're going to lead the "peasants" (your word) whether they like it > or not, and any who don't want to follow are clearly being selfish and > ignorant? > > Have you ever thought that if everyone is misunderstanding your > intentions, then perhaps you're doing something wrong? > > (BTW, welcome to Pythonia, Bill! Most of us are friendly. :-))\ Thanks! And yes, I had noticed that in general this is a congenial, thoughtful, and helpful community. While a lot of what is discussed is not of particular interest to me, there's been a lot that has been of interest and/or of value. So far, I'm pretty impressed with the language as well as the community. And it's wonderful to be involved with a language that has such voluminous supporting materials of all sorts. [I self-taught Smalltalk back in the early and mid-80's when there were 3 books and that's about it...] Hopefully I'll be able to contribute code, learning materials, or such like, at some point ;-) cheers, Bill From rantingrick at gmail.com Thu Jan 20 12:26:32 2011 From: rantingrick at gmail.com (rantingrick) Date: Thu, 20 Jan 2011 09:26:32 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <2ef2fa6c-2ccf-453a-8f50-0ef7dbd7834d@j32g2000yqc.googlegroups.com> <5c6ff40f-05c1-4e38-89bc-b8c4745db7ce@i18g2000yqn.googlegroups.com> <9a036db2-9f32-441f-aa0f-698ac22fb152@e20g2000vbn.googlegroups.com> <981140f7-79d4-421d-88c1-c819f38a3d49@w2g2000yqb.googlegroups.com> <4D37AA0F.3010601@gmail.com> <8871b602-2cd4-43c4-b289-63e0bc167714@z17g2000prz.googlegroups.com> Message-ID: <3506b8ca-b831-4ce3-8bf7-b6776d856fb9@e4g2000vbg.googlegroups.com> On Jan 20, 10:36?am, rusi wrote: > On Jan 20, 5:30?pm, Bill Felton > > With some hesitation, I feel a need to jump in here. ? > This thread is now at 239 posts (and so I too hesitate...) Why hesitate? Whether it be one post or a million posts, if you have ideas, opinions, or suggestions then by all means jump in and share them. If your words are FUD, not based on fact, or just completely ignorant, don't worry, someone will correct you :-) > The arguments for size, dependencies etc are what may be termed > 'sys-ad' perspectives. The questions of 'it looks nice/ancient etc' > are user issues. What about some programmer perspective? Size is very important. Dependencies are very important (within context!). So too are aesthetics just as important when considering a "graphics" module. In the end, Python should aim to bring the best looking, most advanced (but well tested!), scalable modules we can muster into the stdlib. At the time of it's inclusion Guido believed Tkinter was the best choice -- and i agree with him! However we are talking now about ~20 years of time between then and now. Is anyone so bombastic as to suggest that GUI has not changed significantly in that time. And likewise, is anyone so bombastic as to suggest that the lowly Tkinter module (and even worse TclTk) is representative of 21st century GUI programming? Heck, when Tkinter was added GUIs where just in their infancy as far as popular adoption is concerned! TclTk have lacked vision from the beginning. NEWSFLASH! They did not support themes until version 8.5! (~2009) And they still have much work to do if they ever want to compete with the likes of wxPython however i know thay will never reach that level of sophistication. TclTk as a community are not concerned about keeping up with he times, so be it! However we should not degrade "our" stdlib and "our" community with such backward thinking communities. We must move forward. We must pull our heads out of the sand or mentality will be our undoing. > Using something like VB-in-.NET allows a programmer to put up > significant uis with close to zero coding. Many programmers would > look down on these as 'non-programmers' Well i don't look down on these folks i just feel they are missing out on the richness and abstract thinking that creating the GUI mentally evokes. However. I believe it would be of great benefit to have a graphical GUI builder as part of any GUI package we consider for the stdlib. Do i think it should be IN the stdlib? Probably not due to size. But the fact that it is available for those who would like it to be is great. My biggest complaint with Tkinter is that it lacks so much functionality (even outside the stdlib!) that you really end up wasting your time learning and using it. Because eventually you will be forced to throw away everything you've learned and written and convert to something else. > So the (to me) relevant questions relating to GUIs are for example: > 1. Is glade (and others such) equal to wxpython, tkinter and other > such 'backends'? 2. Can glade (or whichever is the best such tool > today) compare to VB in .NET or does it look like a bad joke in > comparison (I guess the current thing may not be VB but WPF but I > dont want to pretend to know too much about windows) I think we need to add a graphical GUI builder to the list of important attributes of a 21st century GUI library. Not the most important, but still quite important. Especially if we want to "market" Python as a GUI language. And I am not saying we should market Python that way. So the attributes we must demand of a 21st century GUI library are a follows: * Quality Documentation (our problem really) * Cross Platform (their problem) * Rich Full Featured Widget Set. (their problem) * Simplistic API (our problem) * Scalability (their problem) * Accessibility (their problem) * Graphical GUI Builder. (Either or) Also some attributes related to the "Big Picture" of GUI and Python: * Mobile and Web support From subscriptions at cagttraining.com Thu Jan 20 12:27:17 2011 From: subscriptions at cagttraining.com (Bill Felton) Date: Thu, 20 Jan 2011 12:27:17 -0500 Subject: Tkinter: The good, the bad, and the ugly! Message-ID: <91F2DC6A-5A05-4ECD-BD82-18323375C579@cagttraining.com> On Jan 20, 2011, at 8:26 AM, Octavian Rasnita wrote: > From: "Bill Felton" >> I'm a complete newbie to Python. > > > To Python, or to programming in general? (Because it is important) Not to rantingrick's point as I understand it. But since you ask, new to Python, not new to programming. >25 yrs experience, most of it with Smalltalk. > > >> I'm still learning the language. And you know what? I've ignored Tkinter. > > > Why did you do that? 2 main reasons -- it hasn't come up yet, and I was attracted to wxPython by the promise of host-compatible look&feel, and the plethora of resources available for self-study in my preferred modes. > > >> I quickly discovered the alternatives and am already working with wxPython. >> I can't believe anyone is so hung up by their own arrogance that they honestly believe that the mere *presence* of a gui kit inside of the standard distribution would prevent a newbie from learning about the existence and possible benefits of alternatives. Sure, *they* can see alternatives and evaluate why Tkinter might not be a good choice under conditions x or y or z, > > > Nobody said that the fact that Python promotes Tkinter *prevents" the beginners to learn to use another GUI. It's an iunavoidable implication of rantingrick's rant about Tkinter and the downfall of Python. I would like to agree that only a deranged minority hold that Tkinter is either a 'downfall point' or prevents individuals from learning and using alternative GUIs. > I just say that if Python promotes Tkinter, the beginners that might not have experience programming in other languages might not know at all which is the difference between all those GUI types, and it might not know at all that there are more GUI types and it won't know for sure which are the differences between them. I agree. > > And for a real beginner in programming it could be harder and less important to make the effort of finding and downloading and installing another GUI just because it offer some features which are not interesting for most users, so he/she will prefer using what Python offers and he/she won't know that that solution is bad. I tend to agree, but weakly. Python is touted for it's vast library support, and that library is pretty much "in your face" if you use the web to look for the language and resources on the language. I have a lot of trouble believing that anyone smart enough to program [i.e., smart enough to tie their own shoes, basically] would not find and investigate those resources. Mind you, I think more focus on Tkinter in the learning materials would be a nice thing to have. Although bear in mind I may have a skewed view of what counts as good introductions to GUI toolkits given my early and long exposure to Smalltalk... Where's Python's toothpaste, sketchpad, etc? cheers, Bill PS. Still not used to a mailing list that sets the 'reply to' to the author, not the list, so inadvertently sent this only to Octavian. Rectified herewith, along with a promise to pay more attention ;-) -------------- next part -------------- An HTML attachment was scrubbed... URL: From ilja.golshtein at gmail.com Thu Jan 20 12:32:14 2011 From: ilja.golshtein at gmail.com (ilejn) Date: Thu, 20 Jan 2011 09:32:14 -0800 (PST) Subject: statement level resumable exception Message-ID: Hello! I have a sequence of a function calls. Basically it looks like f(arg1) f(arg2) ... f(argN) though real arguments are complex multilayer lists. The problem is some arguments are not known and I get NameError exceptions. The solutions I know 1. wrap every f call in try/except block 2. make (currently global) argument attributes of a class and use __getattr__ to convert unknown attributes to something recognizable by f. Is it possible to use something more elegant? I had a hope decorators are helpful here, though apparently they are not ... Suggestions? Thanks. PS. The question is about Python 2.4 From askutt at gmail.com Thu Jan 20 12:32:20 2011 From: askutt at gmail.com (Adam Skutt) Date: Thu, 20 Jan 2011 09:32:20 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com><4d337983$0$29983$c3e8da3$5496439d@news.astraweb.com><044a5101-948d-4458-9c94-57dbb3e25f67@m35g2000vbn.googlegroups.com><4d3467bf$0$29983$c3e8da3$5496439d@news.astraweb.com><4D34B04E.8050309@web.de><4266E8D7BA204BFEA5BF66C635CE1716@octavian><4D35DCE8.5030002@web.de><4D35DD47.1070304@web.de><7A0C7934E65D4B85A584C06ADD3B6ECF@teddy> Message-ID: <513d0274-1878-49a6-9382-31b6ae7aaef3@y9g2000prf.googlegroups.com> On Jan 20, 10:44?am, "Octavian Rasnita" wrote: > From: "Adam Skutt" > Actually, JAWS uses MSAA dead last, as I understand it, because the > API is truly that awful. ?But MSAA is necessary whenever you're not > using a Win32 common control or most of the other stuff developed by > MS. ?That means essentially every non-MS toolkit that's been > discussed. > > Yes, but WxPython uses wxWIDGETS and wxWIDGETS use the standard Win32 controls under Windows, so they are accessible. > And they use Gtk under Linux and Gtk is accessible under Linux also. wxGTK is not, though. wxWidgets is only accessible under Windows. Qt is accessible under Windwos, OS X, and anything that supports AT- SPI[1]. Yet, for some unfathomable reason, you keep promoting wxWidgets even though it is plainly the inferior solution. > Yes of course they can do that if they use the wrong tool. They can't do the right thing if they believe that Tk or Silverlight or Flash is accessible no matter if they follow the recommendations for accessibility, because the screen readers don't support those interfaces. No, even using the right tools: http://doc.qt.nokia.com/qq/qq24-accessibility.html#dealingwithquirks (a few years old, but AFAIK still relevant). It's a crap shoot even if I use tools that support accessibility, because the APIs aren't very good. Some of the new APIs improve the problem, but some reading suggests there will still be the need for a lot of special case handling on both sides of the table. > Nope, the cultural problem exists because the programmers use the wrong interface, not because they just don't make the efforts for making that interface more accessible. No, they don't think about it, they don't test, they don't make the necessary calls to enable accessible applications. Plenty of applications with poor to non-existent accessibility support are written with toolkits that support accessibility. > To be more clear and not to include in the discussion many interfaces, we are comparing Tkinter and WxPython. No, we're not comparing just them, because they're hardly the only solutions. > I am not excluding anything. I said that all the Tk-based programs are inaccessible no matter what the programmer does to make it accessible, because the screen readers can't work with that interface. > And I have also said which are the accessible interfaces: wxWIDGETS (which use Win32 GUI under Windows and Gtk under Linux), SWT (which I think it does exactly the same thing as wxWIDGETS), WindowsForms (DotNet) and SWING (if the user installs Java Access Bridge). This is not a complete list, or even a correct list, which was my point. > It depends if there is a JAWS script defined. Stop. You've insisted many times that I need to not do anything special for making accessible applications. Yet, JAWS has an API entirely for the purpose of enhancing accessibility for specific applications! So, which is it? If I don't need to do anything special, then why does the API exist? Oh right, it exists so people can compensate for developers shortcomings. It's very hard to take anything you say seriously when you repeatedly get basic facts wrong and when you make claims that aren't consistent with the facts. > If the user doesn't want or don't know how to create that script for improving the usability, he/she might need to learn how to use the application by trial and error, but what I want to show is that the user is *able* to use that application, even if the interface is not very friendly, but it would be absolutely impossible to use an application created with Tkinter. He / she might be able to use the application. It's a "maybe", not a "for sure", yet you consistently imply it's the latter. > I am not talking about custom controls. Those things are the worst thing possible from the perspective of accessibility, because usually nobody cares about providing accessibility features. Yet I was talking about custom controls, and plenty of applications use custom controls, so you cannot ignore them even if you'd wish to do so. > My point was that Tkinter which uses Tk is bad, and I didn't tried too many QT-based applications. No, you explicitly stated that Qt has zero accessibility support, which is simply false. You didn't say, "The ones I tried haven't worked", which is certainly possible depending on version and how Qt was compiled (since Qt is normally shipped with the application on Windows). You said, "But the interfaces created with Tk, Gtk and QT are completely inaccessible." > And I don't see what you demonstrate when you wanted to show Tkinter it is comparing with WxPython... I never said I was going to demonstrate anything between Tkinter and wxPython. Such a demonstrate is in your imagination. Adam From rantingrick at gmail.com Thu Jan 20 12:36:15 2011 From: rantingrick at gmail.com (rantingrick) Date: Thu, 20 Jan 2011 09:36:15 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <2ef2fa6c-2ccf-453a-8f50-0ef7dbd7834d@j32g2000yqc.googlegroups.com> <5c6ff40f-05c1-4e38-89bc-b8c4745db7ce@i18g2000yqn.googlegroups.com> <9a036db2-9f32-441f-aa0f-698ac22fb152@e20g2000vbn.googlegroups.com> <981140f7-79d4-421d-88c1-c819f38a3d49@w2g2000yqb.googlegroups.com> <4D37AA0F.3010601@gmail.com> <6d1bfa09-591b-47a4-9d3f-3edcd20019da@z5g2000yqb.googlegroups.com> Message-ID: <8b9bb649-6ac2-4845-8893-3f2bdf882daf@g26g2000vbz.googlegroups.com> On Jan 20, 11:13?am, MRAB wrote: > So you're going to lead the "peasants" (your word) whether they like it > or not, and any who don't want to follow are clearly being selfish and > ignorant? If you could read Bill's words and not find them to be overly selfish and ignorant then i don't know what to say. He clearly stated many times that he NEVER used Tkinter. However somehow we are to believe that he has some "magical" insight on the merits (or lack there of) of Tkinter? This IS THE VERY DEFINITION OF IGNORANCE MRAB. Ignorance is defined as the lack of knowledge. Bill has presented just that. However, even in light of such bombastic ignorance and selfish display I in good humility and grace offered Bill advice on how he could present more facts instead of just baseless opinion. I asked him very specific questions THAT IF he would answer MIGHT inject some facts into his baseless argument. However I bet we won't get any answers from him. PS: You never cease to amaze me MRAB. From smokefloat at gmail.com Thu Jan 20 12:42:21 2011 From: smokefloat at gmail.com (David Hutto) Date: Thu, 20 Jan 2011 09:42:21 -0800 (PST) Subject: Os designers are morons Message-ID: Forgive me for the listening 'troll perspective', but is there any simple solution to intertwining proprietary and open source mentalities? Common ground seems to be the hardware offerings. So why does it seem that the summit has lost it's common ground, which is the hardware we operate on? Electricians know more about multiple applications of energy affecting different sources than most programmers here with there allocation and deallocation of a space on the 'board'. Spatial concepts aren't that hard, and neither is the allocation/deallocation concepts in spatial analysis. So, quit arguing, and get to what you know. From bkline at rksystems.com Thu Jan 20 12:55:44 2011 From: bkline at rksystems.com (Bob Kline) Date: Thu, 20 Jan 2011 12:55:44 -0500 Subject: Part of RFC 822 ignored by email module In-Reply-To: References: Message-ID: <4D387720.40408@rksystems.com> On 1/20/2011 12:23 PM, Carl Banks wrote: > On Jan 20, 7:08 am, Bob Kline wrote: >> I just noticed that the following passage in RFC 822: >> >> The process of moving from this folded multiple-line >> representation of a header field to its single line represen- >> tation is called "unfolding". Unfolding is accomplished by >> regarding CRLF immediately followed by a LWSP-char as >> equivalent to the LWSP-char. >> >> is not being honored by the email module. The following two invocations >> of message_from_string() should return the same value, but that's not >> what happens: >> >> >>> import email >> >>> email.message_from_string("Subject: blah").get('SUBJECT') >> 'blah' >> >>> email.message_from_string("Subject:\n blah").get('SUBJECT') >> ' blah' >> >> Note the space in front of the second value returned, but missing from >> the first. Can someone convince me that this is not a bug? > That's correct, according to my reading of RFC 822 (I doubt it's > changed so I didn't bother to look up what the latest RFC on that > subject is.) > > The RFC says that in a folded line the whitespace on the following > line is considered a part of the line. Thanks for responding. I think your interpretation of the RFC is the same is mine. What I'm saying is that by not returning the same value in the two cases above the module is not "regarding CRLF immediately followed by a LWSP-char as equivalent to the LWSP-char." -- Bob Kline http://www.rksystems.com mailto:bkline at rksystems.com From python at mrabarnett.plus.com Thu Jan 20 13:12:05 2011 From: python at mrabarnett.plus.com (MRAB) Date: Thu, 20 Jan 2011 18:12:05 +0000 Subject: Tkinter: The good, the bad, and the ugly! In-Reply-To: <8b9bb649-6ac2-4845-8893-3f2bdf882daf@g26g2000vbz.googlegroups.com> References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <2ef2fa6c-2ccf-453a-8f50-0ef7dbd7834d@j32g2000yqc.googlegroups.com> <5c6ff40f-05c1-4e38-89bc-b8c4745db7ce@i18g2000yqn.googlegroups.com> <9a036db2-9f32-441f-aa0f-698ac22fb152@e20g2000vbn.googlegroups.com> <981140f7-79d4-421d-88c1-c819f38a3d49@w2g2000yqb.googlegroups.com> <4D37AA0F.3010601@gmail.com> <6d1bfa09-591b-47a4-9d3f-3edcd20019da@z5g2000yqb.googlegroups.com> <8b9bb649-6ac2-4845-8893-3f2bdf882daf@g26g2000vbz.googlegroups.com> Message-ID: <4D387AF5.4000206@mrabarnett.plus.com> On 20/01/2011 17:36, rantingrick wrote: > On Jan 20, 11:13 am, MRAB wrote: > >> So you're going to lead the "peasants" (your word) whether they like it >> or not, and any who don't want to follow are clearly being selfish and >> ignorant? > > If you could read Bill's words and not find them to be overly selfish > and ignorant then i don't know what to say. He clearly stated many > times that he NEVER used Tkinter. However somehow we are to believe > that he has some "magical" insight on the merits (or lack there of) of > Tkinter? This IS THE VERY DEFINITION OF IGNORANCE MRAB. Ignorance is > defined as the lack of knowledge. Bill has presented just that. > > However, even in light of such bombastic ignorance and selfish display > I in good humility and grace offered Bill advice on how he could > present more facts instead of just baseless opinion. I asked him very > specific questions THAT IF he would answer MIGHT inject some facts > into his baseless argument. However I bet we won't get any answers > from him. > > PS: You never cease to amaze me MRAB. The feeling is mutual. From nstinemates at gmail.com Thu Jan 20 13:15:28 2011 From: nstinemates at gmail.com (Nick Stinemates) Date: Thu, 20 Jan 2011 10:15:28 -0800 Subject: Tkinter: The good, the bad, and the ugly! In-Reply-To: <8b9bb649-6ac2-4845-8893-3f2bdf882daf@g26g2000vbz.googlegroups.com> References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <2ef2fa6c-2ccf-453a-8f50-0ef7dbd7834d@j32g2000yqc.googlegroups.com> <5c6ff40f-05c1-4e38-89bc-b8c4745db7ce@i18g2000yqn.googlegroups.com> <9a036db2-9f32-441f-aa0f-698ac22fb152@e20g2000vbn.googlegroups.com> <981140f7-79d4-421d-88c1-c819f38a3d49@w2g2000yqb.googlegroups.com> <4D37AA0F.3010601@gmail.com> <6d1bfa09-591b-47a4-9d3f-3edcd20019da@z5g2000yqb.googlegroups.com> <8b9bb649-6ac2-4845-8893-3f2bdf882daf@g26g2000vbz.googlegroups.com> Message-ID: > > > > So you're going to lead the "peasants" (your word) whether they like it > > or not, and any who don't want to follow are clearly being selfish and > > ignorant? > > If you could read Bill's words and not find them to be overly selfish > and ignorant then i don't know what to say. He clearly stated many > times that he NEVER used Tkinter. However somehow we are to believe > that he has some "magical" insight on the merits (or lack there of) of > Tkinter? This IS THE VERY DEFINITION OF IGNORANCE MRAB. Ignorance is > defined as the lack of knowledge. Bill has presented just that. > No, he's refuting your point that newbies are somehow paralyzed and cannot make a decision about which toolkit they would like to use. > > PS: You never cease to amaze me MRAB. > I am also amazed. Nick -------------- next part -------------- An HTML attachment was scrubbed... URL: From emile at fenx.com Thu Jan 20 13:17:01 2011 From: emile at fenx.com (Emile van Sebille) Date: Thu, 20 Jan 2011 10:17:01 -0800 Subject: Tkinter: The good, the bad, and the ugly! In-Reply-To: <513d0274-1878-49a6-9382-31b6ae7aaef3@y9g2000prf.googlegroups.com> References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com><4d337983$0$29983$c3e8da3$5496439d@news.astraweb.com><044a5101-948d-4458-9c94-57dbb3e25f67@m35g2000vbn.googlegroups.com><4d3467bf$0$29983$c3e8da3$5496439d@news.astraweb.com><4D34B04E.8050309@web.de><4266E8D7BA204BFEA5BF66C635CE1716@octavian><4D35DCE8.5030002@web.de><4D35DD47.1070304@web.de><7A0C7934E65D4B85A584C06ADD3B6ECF@teddy>< ih53k2$pjf$1@dough.gmane.org> <513d0274-1878-49a6-9382-31b6ae7aaef3@y9g2000prf.googlegroups.com> Message-ID: On 1/20/2011 9:32 AM Adam Skutt said... > On Jan 20, 10:44 am, "Octavian Rasnita" wrote: >> From: "Adam Skutt" >> Actually, JAWS uses MSAA dead last, as I understand it, because the >> API is truly that awful. But MSAA is necessary whenever you're not >> using a Win32 common control or most of the other stuff developed by >> MS. That means essentially every non-MS toolkit that's been >> discussed. >> >> Yes, but WxPython uses wxWIDGETS and wxWIDGETS use the standard Win32 controls under Windows, so they are accessible. >> And they use Gtk under Linux and Gtk is accessible under Linux also. > > wxGTK is not, though. wxWidgets is only accessible under Windows. Qt > is accessible under Windwos, OS X, and anything that supports AT- > SPI[1]. Yet, for some unfathomable reason, you keep promoting > wxWidgets even though it is plainly the inferior solution. The problem with QT is the license. From http://qt.nokia.com/products/licensing/: Qt Commercial Developer License The Qt Commercial Developer License is the correct license to use for the development of proprietary and/or commercial software with Qt where you do not want to share any source code. You must purchase a Qt Commercial Developer License from us or from one of our authorized resellers before you start developing commercial software as you are not permitted to begin your development with an open source licensed Qt version and convert to the commercially license version at a later . The Qt Commercial Developer License includes a restriction that prevents the combining of code developed with the Qt GNU LGPL v. 2.1 or GNU GPL v. 3.0 license versions with commercially licensed Qt code. From __peter__ at web.de Thu Jan 20 13:42:10 2011 From: __peter__ at web.de (Peter Otten) Date: Thu, 20 Jan 2011 19:42:10 +0100 Subject: printing a list with non-ascii strings References: <4d385809$0$14253$ba620e4c@news.skynet.be> Message-ID: Helmut Jarausch wrote: > I don't understand Python's behaviour when printing a list. > The following example uses 2 German non-ascii characters. > > #!/usr/bin/python > # _*_ coding: latin1 _*_ > L=["abc","s??","def"] > print L[1],L > > The output of L[1] is correct, while the output of L shows up as > ['abc', 's\xfc\xdf', 'def'] > > How can this be changed? Use unicode and follow Martin's recipe: http://mail.python.org/pipermail/python-list/2011-January/1263783.html From bkline at rksystems.com Thu Jan 20 13:44:02 2011 From: bkline at rksystems.com (Bob Kline) Date: Thu, 20 Jan 2011 13:44:02 -0500 Subject: Part of RFC 822 ignored by email module In-Reply-To: References: <4D384FF8.6060708@rksystems.com> Message-ID: <4D388272.8090907@rksystems.com> On 1/20/2011 12:58 PM, Dennis Lee Bieber wrote: > > I'd first be concerned about the absence of the line ending sequence > specified by the RFC: carriage return (CR; \r) followed by line feed > (LF; \n). I realized after I posted the original message that this might distract from the issue I'm asking about. The module is a little sloppy about its own generation of CRLF tokens when it serializes messages (it leaves the insertion of the CR to processing further downstream), and I was mimicking that behavior in what I fed to the method in my example. I should have avoided that problem and included the \r. Let's pretend that I did: the behavior is unaffected by the absence or presence of the CR character. > ... > > However, the module does appear to trim leading whitespace that > occurs between the : and text (and the line end is considered for that > trimming, but not any whitespace after it). Exactly. I'm focusing on the word "equivalent" in the RFC. Either the module is going to strip leading white space from the value or it's not. Returning different values for the unwrapped header, depending on whether wrapping was present, is failing to treat the two sequences as equivalent. Logically, the processing sequence should be: 1. Unwrap the header ("Subject:\r\n foo" becomes "Subject: foo") 2. Trim leading white space (" foo" becomes "foo") Ideally, the behavior of trimming the leading white space would be reflected documentation (but it isn't). -- Bob Kline http://www.rksystems.com mailto:bkline at rksystems.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From subscriptions at cagttraining.com Thu Jan 20 13:55:14 2011 From: subscriptions at cagttraining.com (Bill Felton) Date: Thu, 20 Jan 2011 13:55:14 -0500 Subject: Tkinter: The good, the bad, and the ugly! In-Reply-To: References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <2ef2fa6c-2ccf-453a-8f50-0ef7dbd7834d@j32g2000yqc.googlegroups.com> <5c6ff40f-05c1-4e38-89bc-b8c4745db7ce@i18g2000yqn.googlegroups.com> <9a036db2-9f32-441f-aa0f-698ac22fb152@e20g2000vbn.googlegroups.com> <981140f7-79d4-421d-88c1-c819f38a3d49@w2g2000yqb.googlegroups.com> <4D37AA0F.3010601@gmail.com> <6d1bfa09-591b-47a4-9d3f-3edcd20019da@z5g2000yqb.googlegroups.com> <8b9bb649-6ac2-4845-8893-3f2bdf882daf@g26g2000vbz.googlegroups.com> Message-ID: On Jan 20, 2011, at 1:15 PM, Nick Stinemates wrote: > > > So you're going to lead the "peasants" (your word) whether they like it > > or not, and any who don't want to follow are clearly being selfish and > > ignorant? > > If you could read Bill's words and not find them to be overly selfish > and ignorant then i don't know what to say. He clearly stated many > times that he NEVER used Tkinter. However somehow we are to believe > that he has some "magical" insight on the merits (or lack there of) of > Tkinter? This IS THE VERY DEFINITION OF IGNORANCE MRAB. Ignorance is > defined as the lack of knowledge. Bill has presented just that. > > No, he's refuting your point that newbies are somehow paralyzed and cannot make a decision about which toolkit they would like to use. > Precisely. I neither said nor intended the nonsense that somehow rr reads into my post. Geez, he can't even count -- I believe I said once that I haven't used Tkinter. But even twice or thrice would not warrant 'many times'... Well, he does appear to be an output only device, who still hasn't output the canonical 'best' GUI toolset... My point was not that Tkinter obviates all other gui toolkits, only that it doesn't need to be ripped out of the standard distro because it is not the cause of the heinous results that rr fears and never hesitates to impute to it. cheers, Bill -------------- next part -------------- An HTML attachment was scrubbed... URL: From clp2 at rebertia.com Thu Jan 20 13:58:55 2011 From: clp2 at rebertia.com (Chris Rebert) Date: Thu, 20 Jan 2011 10:58:55 -0800 Subject: statement level resumable exception In-Reply-To: References: Message-ID: On Thu, Jan 20, 2011 at 9:32 AM, ilejn wrote: > Hello! > > I have a sequence of a function calls. Basically it looks like > > f(arg1) > f(arg2) > ... > f(argN) > > though real arguments are complex multilayer lists. > > The problem is some arguments are not known and I get NameError > exceptions. Why aren't they known? It's a very bad code smell to have possibly completely-undefined variables. Cheers, Chris -- http://blog.rebertia.com From jake.biesinger at gmail.com Thu Jan 20 14:36:35 2011 From: jake.biesinger at gmail.com (Jake Biesinger) Date: Thu, 20 Jan 2011 11:36:35 -0800 (PST) Subject: Efficient python 2-d arrays? In-Reply-To: Message-ID: > Thanks for the great suggestions! On a related note, is there no way to efficiently sort a python array? >>> x = array('f', xrange(10000000)) >>> x.sort() --------------------------------------------------------------------------- AttributeError Traceback (most recent call last) /home/wbiesing/src/python-sort/ in () AttributeError: 'array.array' object has no attribute 'sort' >>> type(sorted(x)) Seems like a common enough task, but no way to do it efficiently without scipy/numpy. From solipsis at pitrou.net Thu Jan 20 14:37:01 2011 From: solipsis at pitrou.net (Antoine Pitrou) Date: Thu, 20 Jan 2011 20:37:01 +0100 Subject: getdefaultencoding - how to change this? References: <4d38472d$0$14250$ba620e4c@news.skynet.be> <4d386ece$0$14262$ba620e4c@news.skynet.be> Message-ID: <20110120203701.332e58db@pitrou.net> On 20 Jan 2011 17:20:14 GMT Helmut Jarausch wrote: > Thanks Robert, > probably I wasn't too clear about my issue. > I couldn't "print" any non-ascii character to my console although > my console has an en_US.iso88591 locale. Well, if you want a correct answer, you should paste actual code as well as its result on your system, rather than start by asking how to change getdefaultencoding (which you shouldn't do as explained by others). > I didn't modfiy anything in Python's source code. > I noticed that my root account still had an ASCII locale. > Now I have changed it such that the root account has the same locale > as non-root accounts. Recompiling Python under such a root account > has rectified things. Recompiling Python doesn't change its behaviour wrt. locales and encodings. All this is done at runtime. > Now I can print non-ascii characters if they are > properly encoded. You can *always* print characters if they are properly encoded. What you are asking is for Python to guess and do the encoding by itself, which is a different matter (and a poorly supported one under 2.x; Python 3 behaves much better in that regard). Regards Antoine. From orasnita at gmail.com Thu Jan 20 14:38:33 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Thu, 20 Jan 2011 21:38:33 +0200 Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com><4d337983$0$29983$c3e8da3$5496439d@news.astraweb.com><044a5101-948d-4458-9c94-57dbb3e25f67@m35g2000vbn.googlegroups.com><4d3467bf$0$29983$c3e8da3$5496439d@news.astraweb.com> <4D34B04E.8050309@web.de><4266E8D7BA204BFEA5BF66C635CE1716@octavian> <4D35DCE8.5030002@web.de><4D35DD47.1070304@web.de><42924000-3ffb-40f5-9cf8-70a9d767b944@k25g2000vbl.googlegroups.com> Message-ID: <337490499C414976805B96DB2B2F36CC@teddy> From: "Grant Edwards" WxPython is bad. Gtk >> is inaccessible under Windows, not under Linux, but WxPython doesn't >> use Gtk under Windows so WxPython is OK. > > Ah. I didn't realize we were operating under the premise that Windows > was the only OS that mattered. Sorry. This conclusion is hatefully because you have already read that Gtk is accessible under Linux, so WxPython doesn't offer accessibility only for Windows. >From the perspective of most of those who need accessibility however, yes, Windows is most important. Octavian From ilja.golshtein at gmail.com Thu Jan 20 14:49:54 2011 From: ilja.golshtein at gmail.com (ilejn) Date: Thu, 20 Jan 2011 11:49:54 -0800 (PST) Subject: statement level resumable exception References: Message-ID: Chris, this is a long story why arguments may be not known. Briefly these arguments come (or may come) from XML and may be not specified. A function call which does not have all arguments defined must be skipped as gracefully as possible. What I am asking about is how to achieve this goal. Thanks. On Jan 20, 9:58?pm, Chris Rebert wrote: > On Thu, Jan 20, 2011 at 9:32 AM, ilejn wrote: > > Hello! > > > I have a sequence of a function calls. Basically it looks like > > > f(arg1) > Why aren't they known? It's a very bad code smell to have possibly > completely-undefined variables. > > Cheers, > Chris > --http://blog.rebertia.com Best regards, Ilja Golshtein. From arnodel at gmail.com Thu Jan 20 14:51:48 2011 From: arnodel at gmail.com (Arnaud Delobelle) Date: Thu, 20 Jan 2011 19:51:48 +0000 Subject: printing a list with non-ascii strings References: <4d385809$0$14253$ba620e4c@news.skynet.be> Message-ID: <87sjwn9wvf.fsf@gmail.com> Helmut Jarausch writes: > Hi, > > I don't understand Python's behaviour when printing a list. > The following example uses 2 German non-ascii characters. > > #!/usr/bin/python > # _*_ coding: latin1 _*_ > L=["abc","s??","def"] > print L[1],L > > The output of L[1] is correct, while the output of L shows up as > ['abc', 's\xfc\xdf', 'def'] > > How can this be changed? > > Thanks for hint, > Helmut. That's because when you print a list, the code executed is roughly: print "[" + ", ".join(repr(x) for x in L) + "]" Now try: print repr("s??") I don't think this can be changed in Python 2.X. I vaguely remember discussions about this issue for Python 3 I think, but I can't remember the outcome and it is different anyway as Python 3 strings are not the same as Python 2 strings (they are the same as Python 2 unicode strings). The issue though is that the python interpreter doesn't know what encoding is supposed to be used for a string - a string in Python 2.X is a sequence of bytes. If you print the string, then the terminal encodes the bytes according to its settings, which has nothing to do with python - so the appearance will differ according to the locale configuration of the terminal. However, the repr() of a string needs to be consistent irrespective of the configuration of the terminal - so the only viable option is to use nothing but ASCII characters. Hence the difference. HTH -- Arnaud From arnodel at gmail.com Thu Jan 20 14:58:17 2011 From: arnodel at gmail.com (Arnaud Delobelle) Date: Thu, 20 Jan 2011 19:58:17 +0000 Subject: statement level resumable exception References: Message-ID: <87oc7b9wkm.fsf@gmail.com> ilejn writes: > Hello! > > I have a sequence of a function calls. Basically it looks like > > f(arg1) > f(arg2) > ... > f(argN) > > though real arguments are complex multilayer lists. > > The problem is some arguments are not known and I get NameError > exceptions. > > The solutions I know > 1. wrap every f call in try/except block > 2. make (currently global) argument attributes of a class and use > __getattr__ to convert unknown attributes to something recognizable by > f. for name in 'arg1', 'arg2', ... 'argN': try: arg = globals()[name] except NameError: continue f(arg) But this is a strange problem... Sounds like you should do it differently. -- Arnaud From orasnita at gmail.com Thu Jan 20 15:02:28 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Thu, 20 Jan 2011 22:02:28 +0200 Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com><4d337983$0$29983$c3e8da3$5496439d@news.astraweb.com><044a5101-948d-4458-9c94-57dbb3e25f67@m35g2000vbn.googlegroups.com><4d3467bf$0$29983$c3e8da3$5496439d@news.astraweb.com><4D34B04E.8050309@web.de><4266E8D7BA204BFEA5BF66C635CE1716@octavian><4D35DCE8.5030002@web.de><4D35DD47.1070304@web.de><7A0C7934E65D4B85A584C06ADD3B6ECF@teddy> <513d0274-1878-49a6-9382-31b6ae7aaef3@y9g2000prf.googlegroups.com> Message-ID: From: "Adam Skutt" > Yet, for some unfathomable reason, you keep promoting wxWidgets even though it is plainly the inferior solution. Inferior to what? I would be glad if you could tell me about a portable solution which is accessible with JAWS and Window Eyes, the most used screen readers under Windows (real glad). > Yes of course they can do that if they use the wrong tool. They can't do the right thing if they believe that Tk or Silverlight or Flash is accessible no matter if they follow the recommendations for accessibility, because the screen readers don't support those interfaces. No, even using the right tools: http://doc.qt.nokia.com/qq/qq24-accessibility.html#dealingwithquirks (a few years old, but AFAIK still relevant). It's a crap shoot even if I use tools that support accessibility, because the APIs aren't very good. Some of the new APIs improve the problem, but some reading suggests there will still be the need for a lot of special case handling on both sides of the table. Exactly. When you will read that thing on a GUI creator site it means that that GUI is not accessible because the screen readers don't support it yet. The GUI libs manufacturers will say that the screen readers are bad because they don't offer support for their GUI, although that GUI offers accessibility features. Well, I don't care that the screen readers are bad and don't support some libs. I care only if the interfaces created with a certain GUI lib is accessible out of the box as WxPython is under Windows. > Nope, the cultural problem exists because the programmers use the wrong interface, not because they just don't make the efforts for making that interface more accessible. No, they don't think about it, they don't test, they don't make the necessary calls to enable accessible applications. Plenty of applications with poor to non-existent accessibility support are written with toolkits that support accessibility. You confuse again the accessibility with the usability or you think that if a GUI lib offers accessibility features it is accessible. Well, a GUI lib is accessible only if JAWS and Window Eyes offer support for it because those are the screen readers used by the majority and this is because they have the most features. > To be more clear and not to include in the discussion many interfaces, we are comparing Tkinter and WxPython. No, we're not comparing just them, because they're hardly the only solutions. We were starting from the idea that Tkinter is worse than WxPython so let's come to that idea and not divagate. > I am not excluding anything. I said that all the Tk-based programs are inaccessible no matter what the programmer does to make it accessible, because the screen readers can't work with that interface. > And I have also said which are the accessible interfaces: wxWIDGETS (which use Win32 GUI under Windows and Gtk under Linux), SWT (which I think it does exactly the same thing as wxWIDGETS), WindowsForms (DotNet) and SWING (if the user installs Java Access Bridge). This is not a complete list, or even a correct list, which was my point. My point was that Tkinter shouldn't be promoted by Python because it doesn't create accessible GUI out of the box at least for Windows as WxPython does. > It depends if there is a JAWS script defined. Stop. You've insisted many times that I need to not do anything special for making accessible applications. Yet, JAWS has an API entirely for the purpose of enhancing accessibility for specific applications! So, which is it? If I don't need to do anything special, then why does the API exist? Oh right, it exists so people can compensate for developers shortcomings. I've told you a lot of times that you confuse accessibility with usability. And I told you that the JAWS scripts can't make an absolutely inaccessible application made with Tk to be accessible. And that's why Tkinter is bad. The JAWS scripts can only improve the usability, can make the application be much friendly, but if it is not accessible, it can't make it accessible, because if it could do it, there would be no accessibility issues anymore. It's very hard to take anything you say seriously when you repeatedly get basic facts wrong and when you make claims that aren't consistent with the facts. Which are those facts? > If the user doesn't want or don't know how to create that script for improving the usability, he/she might need to learn how to use the application by trial and error, but what I want to show is that the user is *able* to use that application, even if the interface is not very friendly, but it would be absolutely impossible to use an application created with Tkinter. He / she might be able to use the application. It's a "maybe", not a "for sure", yet you consistently imply it's the latter. Yes, but there is a chance to be able to use that application while if the application is done with Tk, she/he would have absolutely no chance to use it. > I am not talking about custom controls. Those things are the worst thing possible from the perspective of accessibility, because usually nobody cares about providing accessibility features. Yet I was talking about custom controls, and plenty of applications use custom controls, so you cannot ignore them even if you'd wish to do so. If the application uses custom controls and the programmer adds custom accessibility features for them (which usually never happends), that application might be accessible if it uses an accessible GUI lib. But if the programmer adds accessibility features to a Tk GUI, that GUI won't be accessible because the screen readers don't offer the necessary support for Tk. > My point was that Tkinter which uses Tk is bad, and I didn't tried too many QT-based applications. No, you explicitly stated that Qt has zero accessibility support, which is simply false. You didn't say, "The ones I tried haven't worked", which is certainly possible depending on version and how Qt was compiled (since Qt is normally shipped with the application on Windows). You said, "But the interfaces created with Tk, Gtk and QT are completely inaccessible." If QT is not consistent and some versions can be accessible and other versions not, it means that QT should be avoided just because it is not consistent. A sane GUI should offer accessibility by default in all its versions without needing to activate anything in order to make the application accessible. Octavian From robert.kern at gmail.com Thu Jan 20 15:16:15 2011 From: robert.kern at gmail.com (Robert Kern) Date: Thu, 20 Jan 2011 14:16:15 -0600 Subject: Efficient python 2-d arrays? In-Reply-To: References: Message-ID: On 1/20/11 1:36 PM, Jake Biesinger wrote: >> Thanks for the great suggestions! > > On a related note, is there no way to efficiently sort a python array? No. >>>> x = array('f', xrange(10000000)) >>>> x.sort() > --------------------------------------------------------------------------- > AttributeError Traceback (most recent call last) > > /home/wbiesing/src/python-sort/ in() > > AttributeError: 'array.array' object has no attribute 'sort' > >>>> type(sorted(x)) > > > Seems like a common enough task, but no way to do it efficiently without scipy/numpy. It's not really common. The array module is mostly used for data accumulation and interchange. Most people who need to compute things over efficiently-implemented homogeneous arrays use numpy. -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco From rantingrick at gmail.com Thu Jan 20 15:17:06 2011 From: rantingrick at gmail.com (rantingrick) Date: Thu, 20 Jan 2011 12:17:06 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com><4d337983$0$29983$c3e8da3$5496439d@news.astraweb.com><044a5101-948d-4458-9c94-57dbb3e25f67@m35g2000vbn.googlegroups.com><4d3467bf$0$29983$c3e8da3$5496439d@news.astraweb.com><4D34B04E.8050309@web.de><4266E8D7BA204BFEA5BF66C635CE1716@octavian><4D35DCE8.5030002@web.de><4D35DD47.1070304@web.de><7A0C7934E65D4B85A584C06ADD3B6ECF@teddy>< Message-ID: On Jan 20, 12:17?pm, Emile van Sebille wrote: > The problem with QT is the license. > > ?Fromhttp://qt.nokia.com/products/licensing/: > > Qt Commercial Developer License > The Qt Commercial Developer License is the correct license to use for > the development of proprietary and/or commercial software with Qt where > you do not want to share any source code. Well as far as i am concerned that takes QT out of the contest. So that leaves WxPython and pyGTK as the only viable options that are mature libraries. Both carry the LGPL license. http://www.pygtk.org/ http://www.wxwidgets.org/about/newlicen.htm One more is FLTK however it looks like a mirror of Tkinter so back in the same place: http://pyfltk.sourceforge.net/index.php#download From ilja.golshtein at gmail.com Thu Jan 20 15:32:56 2011 From: ilja.golshtein at gmail.com (ilejn) Date: Thu, 20 Jan 2011 12:32:56 -0800 (PST) Subject: statement level resumable exception References: <87oc7b9wkm.fsf@gmail.com> Message-ID: <62658b12-34b7-4ed5-9ecd-5182b53f7b31@t35g2000yqj.googlegroups.com> Arnaud, good idea, though I think it is not applicable in my case, because my arg1 ... argN are "complex multilayer lists". In reality it is not just f(arg1), it is more like f([[subarg1, 'aa', subarg2], []]) Regarding your remark it is a strange problem ... well, may be it is ;) Thanks anyway. On Jan 20, 10:58?pm, Arnaud Delobelle wrote: > ilejn writes: > > Hello! > > > I have a sequence of a function calls. Basically it looks like > > > f(arg1) > > f(arg2) > > ... > > f(argN) > > > though real arguments are complex multilayer lists. > > > The problem is some arguments are not known and I get NameError > > exceptions. > > > The solutions I know > > 1. wrap every f call in try/except block > > 2. make (currently global) argument attributes of a class and use > > __getattr__ to convert unknown attributes to something recognizable by > > f. > > for name in 'arg1', 'arg2', ... 'argN': > ? ? try: > ? ? ? ? arg = globals()[name] > ? ? except NameError: > ? ? ? ? continue > ? ? f(arg) > > But this is a strange problem... ?Sounds like you should do it > differently. > > -- > Arnaud Best regards, Ilja Golshtein. From askutt at gmail.com Thu Jan 20 15:37:21 2011 From: askutt at gmail.com (Adam Skutt) Date: Thu, 20 Jan 2011 12:37:21 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com><4d337983$0$29983$c3e8da3$5496439d@news.astraweb.com><044a5101-948d-4458-9c94-57dbb3e25f67@m35g2000vbn.googlegroups.com><4d3467bf$0$29983$c3e8da3$5496439d@news.astraweb.com><4D34B04E.8050309@web.de><4266E8D7BA204BFEA5BF66C635CE1716@octavian><4D35DCE8.5030002@web.de><4D35DD47.1070304@web.de><7A0C7934E65D4B85A584C06ADD3B6ECF@teddy>< Message-ID: <9003ae0f-0cb8-4ada-87d4-4a994747e89f@w29g2000vba.googlegroups.com> On Jan 20, 1:17?pm, Emile van Sebille wrote: > > The problem with QT is the license. Qt and wxWidgets are both LGPL and equally non-starters due to license, today. There was a hypothetical assumption on my part that the library would be made license compatible somehow, through the entire discussion. I didn't think it worth mentioning because I didn't think it all that relevant to any of the discussions that end ed up occurring here. Adam From arnodel at gmail.com Thu Jan 20 15:42:33 2011 From: arnodel at gmail.com (Arnaud Delobelle) Date: Thu, 20 Jan 2011 20:42:33 +0000 Subject: statement level resumable exception References: <87oc7b9wkm.fsf@gmail.com> <62658b12-34b7-4ed5-9ecd-5182b53f7b31@t35g2000yqj.googlegroups.com> Message-ID: <87k4hz9uiu.fsf@gmail.com> ilejn writes: > Arnaud, > > good idea, though I think it is not applicable in my case, > because my arg1 ... argN are "complex multilayer lists". > > In reality it is not just > f(arg1), > it is more like > f([[subarg1, 'aa', subarg2], []]) > > Regarding your remark it is a strange problem ... well, may be it > is ;) > > Thanks anyway. Are these lists automatically generated? -- Arnaud From martin at address-in-sig.invalid Thu Jan 20 15:48:19 2011 From: martin at address-in-sig.invalid (Martin Gregorie) Date: Thu, 20 Jan 2011 20:48:19 +0000 (UTC) Subject: Part of RFC 822 ignored by email module References: Message-ID: On Thu, 20 Jan 2011 12:55:44 -0500, Bob Kline wrote: > On 1/20/2011 12:23 PM, Carl Banks wrote: >> On Jan 20, 7:08 am, Bob Kline wrote: >>> I just noticed that the following passage in RFC 822: >>> >>> The process of moving from this folded multiple-line >>> representation of a header field to its single line >>> represen- tation is called "unfolding". Unfolding is >>> accomplished by regarding CRLF immediately followed >>> by a LWSP-char as equivalent to the LWSP-char. >>> >>> is not being honored by the email module. The following two >>> invocations of message_from_string() should return the same value, but >>> that's not what happens: >>> >>> >>> import email >>> >>> email.message_from_string("Subject: blah").get('SUBJECT') >>> 'blah' >>> >>> email.message_from_string("Subject:\n blah").get('SUBJECT') >>> ' blah' >>> >>> Note the space in front of the second value returned, but missing from >>> the first. Can someone convince me that this is not a bug? >> That's correct, according to my reading of RFC 822 (I doubt it's >> changed so I didn't bother to look up what the latest RFC on that >> subject is.) >> >> The RFC says that in a folded line the whitespace on the following line >> is considered a part of the line. > > Thanks for responding. I think your interpretation of the RFC is the > same is mine. What I'm saying is that by not returning the same value > in the two cases above the module is not "regarding CRLF immediately > followed by a LWSP-char as equivalent to the LWSP-char." > That's only a problem if your code cares about the composition of the whitespace and this, IMO is incorrect behaviour. When the separator between syntactic elements in a header is 'whitespace' it should not matter what combination of newlines, tabs and spaces make up the whitespace element. -- martin@ | Martin Gregorie gregorie. | Essex, UK org | From drsalists at gmail.com Thu Jan 20 15:48:37 2011 From: drsalists at gmail.com (Dan Stromberg) Date: Thu, 20 Jan 2011 12:48:37 -0800 Subject: Efficient python 2-d arrays? In-Reply-To: References: Message-ID: On Thu, Jan 20, 2011 at 11:36 AM, Jake Biesinger wrote: >> Thanks for the great suggestions! > > On a related note, is there no way to efficiently sort a python array? > > >>>> x = array('f', xrange(10000000)) >>>> x.sort() > --------------------------------------------------------------------------- > AttributeError ? ? ? ? ? ? ? ? ? ? ? ? ? ?Traceback (most recent call last) > > /home/wbiesing/src/python-sort/ in () > > AttributeError: 'array.array' object has no attribute 'sort' > >>>> type(sorted(x)) > > > Seems like a common enough task, but no way to do it efficiently without scipy/numpy. Tap, tap: Is this thing on? I keep sending messages to this list, but no one seems to "hear" what I'm writing. Anyway, I have a bunch of sorts in python (pure or cython, your option) at http://stromberg.dnsalias.org/cgi-bin/viewvc.cgi/sorts/compare/trunk/?root=svn The pure python versions should all work out of the box with an array.array. I tested the timsort on an array.array, and it worked well. Also, I just made a trivial modification (not checked in! ...but I did test it) to make the cythonized timsort support sorting arrays - just change the "list" type declarations to "object" (or perhaps "array.array") prior to compiling. I also just changed the license on them from GPL v3 to Apache v2. timsort truly is a somewhat supernatural algorithm. From askutt at gmail.com Thu Jan 20 15:49:46 2011 From: askutt at gmail.com (Adam Skutt) Date: Thu, 20 Jan 2011 12:49:46 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com><4d337983$0$29983$c3e8da3$5496439d@news.astraweb.com><044a5101-948d-4458-9c94-57dbb3e25f67@m35g2000vbn.googlegroups.com><4d3467bf$0$29983$c3e8da3$5496439d@news.astraweb.com><4D34B04E.8050309@web.de><4266E8D7BA204BFEA5BF66C635CE1716@octavian><4D35DCE8.5030002@web.de><4D35DD47.1070304@web.de><7A0C7934E65D4B85A584C06ADD3B6ECF@teddy> Message-ID: On Jan 20, 3:02?pm, "Octavian Rasnita" wrote: > From: "Adam Skutt" > Yet, for some unfathomable reason, you keep promoting > I would be glad if you could tell me about a portable solution which is accessible with JAWS and Window Eyes, the most used screen readers under Windows (real glad). I did, Qt. I'm not yournanny and I'm not going to go test it for you. There are bugs in the Qt database relating to JAWS functionality, so it others have plainly gotten it working to some degree. But honestly, why should I waste my time replying to you when you're too damn lazy to even use Google? I certainly won't be doing so in the future. "Lead a ignorant, thirsty horse to water, watch it die of thirst" and all that. > Exactly. When you will read that thing on a GUI creator site it means that that GUI is not accessible because the screen readers don't support it yet. > The GUI libs manufacturers will say that the screen readers are bad because they don't offer support for their GUI, although that GUI offers accessibility features. No, that's not what that page says or means. But I'm not going to be able to explain it to you any more clearly, so if you'd prefer to keep living in your own delusional, illydic world, that's your decision. Qt has been pretty clear in painting the blame on who it belongs on, which is not the screen reader vendors. Adam From rantingrick at gmail.com Thu Jan 20 15:51:58 2011 From: rantingrick at gmail.com (rantingrick) Date: Thu, 20 Jan 2011 12:51:58 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com><4d337983$0$29983$c3e8da3$5496439d@news.astraweb.com><044a5101-948d-4458-9c94-57dbb3e25f67@m35g2000vbn.googlegroups.com><4d3467bf$0$29983$c3e8da3$5496439d@news.astraweb.com><4D34B04E.8050309@web.de><4266E8D7BA204BFEA5BF66C635CE1716@octavian><4D35DCE8.5030002@web.de><4D35DD47.1070304@web.de><7A0C7934E65D4B85A584C06ADD3B6ECF@teddy>< <9003ae0f-0cb8-4ada-87d4-4a994747e89f@w29g2000vba.googlegroups.com> Message-ID: <4c3b90c9-6ab2-40bd-9ef2-29c81463dc71@l17g2000yqe.googlegroups.com> On Jan 20, 2:37?pm, Adam Skutt wrote: > On Jan 20, 1:17?pm, Emile van Sebille wrote: > > > > > The problem with QT is the license. > > Qt and wxWidgets are both LGPL and equally non-starters due to > license, today. Everything out there is LGPL! But you cannot just use that argument to keep Tkinter. So are you suggesting that we just hold on Tkinter forver! Are you mad? Can you image Python still lugging around the antiquated Tkinter module in 2020? That's a nightmare. You know damn good and well that even nine years from now TclTk will be two decades behind in development. AND SLOWER THAN EVER! From emile at fenx.com Thu Jan 20 15:55:39 2011 From: emile at fenx.com (Emile van Sebille) Date: Thu, 20 Jan 2011 12:55:39 -0800 Subject: statement level resumable exception In-Reply-To: References: Message-ID: On 1/20/2011 11:49 AM ilejn said... > Chris, > > this is a long story why arguments may be not known. > Briefly these arguments come (or may come) from XML and may be not > specified. > > A function call which does not have all arguments defined must be > skipped as gracefully as possible. > What I am asking about is how to achieve this goal. I might try using sets: required = set(('a','b','c')) if not (required - set(locals())): f(a,b,c) HTH, Emile From namekuseijin at gmail.com Thu Jan 20 15:59:18 2011 From: namekuseijin at gmail.com (namekuseijin) Date: Thu, 20 Jan 2011 12:59:18 -0800 (PST) Subject: Google AI challenge: planet war. Lisp won. References: <44a8f48f-e291-463e-a042-d0cbc31a2a4e@z17g2000prz.googlegroups.com> <1a10a457-6492-4ed6-98fd-bbb0829637c0@o23g2000prh.googlegroups.com> Message-ID: <5d2ce6df-08f9-44b1-9604-0a139d2d0d84@d8g2000yqf.googlegroups.com> On Dec 22 2010, 12:46?pm, Xah Lee wrote: > On Dec 20, 10:06?pm, "Jon Harrop" wrote: > > > Wasn't that the "challenge" where they wouldn't even accept solutions > > written in many other languages (including both OCaml and F#)? > > Ocaml is one of the supported lang. See: > > http://ai-contest.com/starter_packages.php > > there are 12 teams using OCaml. See:http://ai-contest.com/rankings.php > (click on the lang to see all teams using that lang) > > ?Xah PWNED From ilja.golshtein at gmail.com Thu Jan 20 16:03:04 2011 From: ilja.golshtein at gmail.com (ilejn) Date: Thu, 20 Jan 2011 13:03:04 -0800 (PST) Subject: statement level resumable exception References: <87oc7b9wkm.fsf@gmail.com> <62658b12-34b7-4ed5-9ecd-5182b53f7b31@t35g2000yqj.googlegroups.com> <87k4hz9uiu.fsf@gmail.com> Message-ID: Arnaud, these lists are not generated. Actually these lists are a sort of interpreted programs and contain some application logic. Here is an example [ [PUSH, [get_modified_interface, req]], [TIMEOUT, 3], [PULL, [out_interface, '']], [PULL, [err_interface, '']], [PULL, [out_mined_interface, req]], ] If any interface name is unknown the list must not be invoked (in other words, f function call with this list must be somehow bypassed). Thanks. On Jan 20, 11:42?pm, Arnaud Delobelle wrote: > ilejn writes: > > Arnaud, > > > good idea, though I think it is not applicable in my case, > > because my arg1 ... argN are "complex multilayer lists". > > > In reality it is not just > > f(arg1), > > it is more like > > f([[subarg1, 'aa', subarg2], []]) > > > Regarding your remark it is a strange problem ... well, may be it > > is ;) > > > Thanks anyway. > > Are these lists automatically generated? > > -- > Arnaud Best regards, Ilja Golshtein. From emile at fenx.com Thu Jan 20 16:06:48 2011 From: emile at fenx.com (Emile van Sebille) Date: Thu, 20 Jan 2011 13:06:48 -0800 Subject: Tkinter: The good, the bad, and the ugly! In-Reply-To: References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com><4d337983$0$29983$c3e8da3$5496439d@news.astraweb.com><044a5101-948d-4458-9c94-57dbb3e25f67@m35g2000vbn.googlegroups.com><4d3467bf$0$29983$c3e8da3$5496439d@news.astraweb.com><4D34B04E.8050309@web.de><4266E8D7BA204BFEA5BF66C635CE1716@octavian><4D35DCE8.5030002@web.de><4D35DD47.1070304@web.de><7A0C7934E65D4B85A584C06ADD3B6ECF@teddy>< Message-ID: On 1/20/2011 12:17 PM rantingrick said... > Well as far as i am concerned that takes QT out of the contest. So > that leaves WxPython and pyGTK as the only viable options that are > mature libraries. Both carry the LGPL license. > > http://www.pygtk.org/ > http://www.wxwidgets.org/about/newlicen.htm > You might find this interesting... http://mail.python.org/pipermail/python-announce-list/2000-November/000572.html Yes, it's old. That's part of the reason you get no traction on this. Emile From wxjmfauth at gmail.com Thu Jan 20 16:15:21 2011 From: wxjmfauth at gmail.com (jmfauth) Date: Thu, 20 Jan 2011 13:15:21 -0800 (PST) Subject: UTF-8 question from Dive into Python 3 References: Message-ID: On Jan 19, 11:33?pm, Terry Reedy wrote: > On 1/19/2011 1:02 PM, Tim Harig wrote: > > > Right, but I only have to do that once. ?After that, I can directly address > > any piece of the stream that I choose. ?If I leave the information as a > > simple UTF-8 stream, I would have to walk the stream again, I would have to > > walk through the the first byte of all the characters from the beginning to > > make sure that I was only counting multibyte characters once until I found > > the character that I actually wanted. ?Converting to a fixed byte > > representation (UTF-32/UCS-4) or separating all of the bytes for each > > UTF-8 into 6 byte containers both make it possible to simply index the > > letters by a constant size. ?You will note that Python does the former. > > The idea of using a custom fixed-width padded version of a UTF-8 steams > waw initially shocking to me, but I can imagine that there are > specialized applications, which slice-and-dice uninterpreted segments, > for which that is appropriate. However, it is not germane to the folly > of prefixing standard UTF-8 steams with a 3-byte magic number, > mislabelled a 'byte-order-mark, thus making them non-standard. > Unicode Book, 5.2.0, Chapter 2, Section 14, Page 51 - Paragraphe *Unicode Signature*. From bkline at rksystems.com Thu Jan 20 16:25:52 2011 From: bkline at rksystems.com (Bob Kline) Date: Thu, 20 Jan 2011 16:25:52 -0500 Subject: Part of RFC 822 ignored by email module In-Reply-To: References: Message-ID: <4D38A860.7060706@rksystems.com> On 1/20/2011 3:48 PM, Martin Gregorie wrote: > That's only a problem if your code cares about the composition of the > whitespace and this, IMO is incorrect behaviour. When the separator > between syntactic elements in a header is 'whitespace' it should not > matter what combination of newlines, tabs and spaces make up the > whitespace element. That would be true for what the RFC calls "structured" fields, but not for the others (such as the Subject header). -- Bob Kline http://www.rksystems.com mailto:bkline at rksystems.com From rantingrick at gmail.com Thu Jan 20 16:52:29 2011 From: rantingrick at gmail.com (rantingrick) Date: Thu, 20 Jan 2011 13:52:29 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com><4d337983$0$29983$c3e8da3$5496439d@news.astraweb.com><044a5101-948d-4458-9c94-57dbb3e25f67@m35g2000vbn.googlegroups.com><4d3467bf$0$29983$c3e8da3$5496439d@news.astraweb.com><4D34B04E.8050309@web.de><4266E8D7BA204BFEA5BF66C635CE1716@octavian><4D35DCE8.5030002@web.de><4D35DD47.1070304@web.de><7A0C7934E65D4B85A584C06ADD3B6ECF@teddy>< Message-ID: On Jan 20, 3:06?pm, Emile van Sebille wrote: > You might find this interesting... > http://mail.python.org/pipermail/python-announce-list/2000-November/0... > Yes, it's old. ?That's part of the reason you get no traction on this. Thanks Emile. This read was both hair raising and informative. Following is the relevant Tkinter parts posted verbatim with my comments sprinkled throughout... > However, this process is still in its infancy, and the announcement > caused much worrying in the Tcl/Tk user community about the > language's future and its continued maintenance. This affects > Python because Tk, through the Tkinter module, is the most GUI most > commonly used with Python. Tkinter is included in the source > distribution, it's the most extensively documented, and it's the > most portable, supported on the Big Three platforms, namely Windows, > Unix, and MacOS. It seems at the time (a decade ago) fantasies abounded about the importance of Tkinter. I find it highly unlikely that Tkinter was OR IS the "Most commonly used GUI with Python". Maybe the most commonly used GUI library for utilities, but that's about it > Fredrik Lundh first posted a note about the announcement, and Eric > S. Raymond raised the question of what this meant for Tkinter: "This > raises anew a question I've been meaning to bring up for the last > week: is it finally time to move away from Python's dependence on > Tcl/Tk for GUI support?" Yes (even a decade later!). > People were split on this question, though Guido was receptive to > the idea ("Yes, it may be time to have this discussion again.") and > pointed out some reasons to stick with Tkinter: "Tk has two very > high quality widgets: the Canvas and Text widgets are unsurpassed in > functionality and robustness by other widget sets. Not anymore Guido! > You can draw > more lines or characters per second in most toolkits, but few > toolkits offer the convenience of marks and tags, not having to deal > with refresh events, being able to group objects, move them around, > change attributes, etc., etc., etc." Thats a very weak argument. While i'll agree that the tagging system employed by the TK::Canvas widget is helpful, the same functionality can be reproduced by the programmer very easily. And i always prefer to work with objects as opposed to tags because of the obvious limitations. > Greg Wilson's reaction was "Yes please", and he went on to explain > what factors kept him using Tkinter for a recent course: http://www.python.org/pipermail/python-dev/2000-October/016757.html Well that link is broken so we will never know what greg said? > /F thought Tk was still a good choice, and said " ... and trust me, > the Python 2.0/Tk8.4/Tkinter3000 combo will rock ;-)". Tkinter3000 > is an improved Tk interface that /F has been working on, with more > flexibility and better performance. > http://tkinter.effbot.org Yea Frederic maybe Tkinter < exaggeration >"rocked the casba" in 2000, however we are building with steel and glass now, not rock and stone. > /F also hoped that the Tcl Core Team would become more receptive to > making it easier to use Tk from other languages without Tcl having > to be in the middle, which would let the maintainers of Tkinter and > the Perl/Tk interface participate more in Tk's development. Why in the world do WE -- THE Python community-- give two figs as to how useful TclTk is to OTHER communities? > Eric S. Raymond speculated about the success of Tcl's new > development model: "Good for Tcl: Osterhout's rather lame attempts > to develop under a mixed model have almost certainly come to an end > in favor of an Apache-like model funded by big Tcl users." > http://www.python.org/pipermail/python-dev/2000-October/016763.html > > Greg Ewing wondered if stdwin should be revived. GvR and Raymond > both thought that far too much work, and not productive of very good > results. "And stdwin would really look pathetic in this time", GvR > observed. Well Guido, just imagine how bad Tkinter will look in 10 years ;-) > Python isn't tied very tightly to Tk, of course; well-maintained and > reasonably complete bindings exist for many different GUI toolkits, > such as Qt, GTk+, wxWindows, Windows MFC, and a few more. > http://www.thekompany.com/projects/pykde/ > http://www.daa.com.au/~james/pygtk/ http://wxpython.org/ > http://http://www.oreillynet.com/pub/a/217 Well i'd have to disagree being that Tkinter is IN the STDLIB!!!! > wxWindows is probably the most obvious second candidate, since it > actually supports all of the Big Three platforms, and no other > toolkit does. Robin Dunn, author of the wxPython binding, posted to > discuss the status of wxWindows on the Mac: "My understanding is > that the version in CVS is nearly up to date with the features in > the MSW and GTK versions, though I haven't had a chance to use it > myself. ... The next step I guess is getting it wrapped up in > wxPython..." http://www.python.org/pipermail/python- > dev/2000-October/016764.html Finally some sanity in this thread! > There was no clear final decision, and my crystal ball didn't deign > to give an answer. Given all the uncertainties, it's probably best > to wait and see. If Tk's development continues to progress and > becomes more open to languages other than Tcl, Tkinter will probably > continue to be the most common Python GUI. Thats ridiculous. Just because Tk becomes more open to other developers (namely Perl, and Ruby) does not mean we should keep it around for the same reason. > If not, we can consider > this question in another 6 months, which will give wxWindows and > wxPython time to develop on the Mac platform. And who knows? Maybe > something else will happen, such as Qt or GTk+ being ported to the > Macintosh. Yea, i'll bet the author did not expect what has happened. * Very slow if any advancement of Tk. * wxPython became rich GUI library. * Tkinter used only for utility and toy apps. * An apathy for Tkinter within the community. * and more From sridharr at activestate.com Thu Jan 20 17:18:11 2011 From: sridharr at activestate.com (Sridhar Ratnakumar) Date: Thu, 20 Jan 2011 14:18:11 -0800 Subject: ANN: ActivePython 2.6.6.18 is now available Message-ID: <4D38B4A3.5030900@activestate.com> ActiveState is pleased to announce ActivePython 2.6.6.18, a complete, ready-to-install binary distribution of Python 2.6. Among other updates, this releases brings "postinstall" support to PyPM to facilitate installation of modules such as PyIMSL. http://www.activestate.com/activepython/downloads What's New in ActivePython-2.6.6.18 =================================== New Features & Upgrades ----------------------- - Upgrade to Tcl/Tk 8.5.9 (`changes `_) - Security upgrade to openssl-0.9.8q - [MacOSX] Tkinter now requires ActiveTcl 8.5 64-bit (not Apple's Tcl/Tk 8.5 on OSX) - Upgrade to PyPM 1.3.0: - Programmatic use via ``pypm.cmd(['install', 'foo'])`` - Support for postinstall and conditional user-notes - Package updates: - pip-0.8.2 Noteworthy Changes & Bug Fixes ------------------------------ - [Windows 64-bit] `issue8275 `_: turn off optimization for the ctypes module - PyPM bug fixes: - Fix needless truncation of output when piping (eg: ``pypm list | less``) - Respect download cache of ``*.pypm`` packages (don't redownload) - Bug #88882: Fix pickle incompatability (sqlite) on Python 3.x What is ActivePython? ===================== ActivePython is ActiveState's binary distribution of Python. Builds for Windows, Mac OS X, Linux are made freely available. Solaris, HP-UX and AIX builds, and access to older versions are available in ActivePython Business, Enterprise and OEM editions: http://www.activestate.com/python ActivePython includes the Python core and the many core extensions: zlib and bzip2 for data compression, the Berkeley DB (bsddb) and SQLite (sqlite3) database libraries, OpenSSL bindings for HTTPS support, the Tix GUI widgets for Tkinter, ElementTree for XML processing, ctypes (on supported platforms) for low-level library access, and others. The Windows distribution ships with PyWin32 -- a suite of Windows tools developed by Mark Hammond, including bindings to the Win32 API and Windows COM. ActivePython also includes a binary package manager for Python (PyPM) that can be used to install packages much easily. For example: C:\>pypm install mysql-python [...] C:\>python >>> import MySQLdb >>> See this page for full details: http://docs.activestate.com/activepython/2.6/whatsincluded.html As well, ActivePython ships with a wealth of documentation for both new and experienced Python programmers. In addition to the core Python docs, ActivePython includes the "What's New in Python" series, "Dive into Python", the Python FAQs & HOWTOs, and the Python Enhancement Proposals (PEPs). An online version of the docs can be found here: http://docs.activestate.com/activepython/2.6/ We would welcome any and all feedback to: activepython-feedback at activestate.com Please file bugs against ActivePython at: http://bugs.activestate.com/enter_bug.cgi?product=ActivePython Supported Platforms =================== ActivePython is available for the following platforms: - Windows (x86 and x64) - Mac OS X (x86 and x86_64; 10.5+) - Linux (x86 and x86_64) - Solaris/SPARC (32-bit and 64-bit) (Business, Enterprise or OEM edition only) - Solaris/x86 (32-bit) (Business, Enterprise or OEM edition only) - HP-UX/PA-RISC (32-bit) (Business, Enterprise or OEM edition only) - HP-UX/IA-64 (32-bit and 64-bit) (Enterprise or OEM edition only) - AIX/PowerPC (32-bit and 64-bit) (Business, Enterprise or OEM edition only) More information about the Business Edition can be found here: http://www.activestate.com/business-edition Custom builds are available in the Enterprise Edition: http://www.activestate.com/enterprise-edition Thanks, and enjoy! The Python Team -- Sridhar Ratnakumar sridharr at activestate.com From martin at address-in-sig.invalid Thu Jan 20 17:34:01 2011 From: martin at address-in-sig.invalid (Martin Gregorie) Date: Thu, 20 Jan 2011 22:34:01 +0000 (UTC) Subject: Part of RFC 822 ignored by email module References: Message-ID: On Thu, 20 Jan 2011 16:25:52 -0500, Bob Kline wrote: > On 1/20/2011 3:48 PM, Martin Gregorie wrote: >> That's only a problem if your code cares about the composition of the >> whitespace and this, IMO is incorrect behaviour. When the separator >> between syntactic elements in a header is 'whitespace' it should not >> matter what combination of newlines, tabs and spaces make up the >> whitespace element. > > That would be true for what the RFC calls "structured" fields, but not > for the others (such as the Subject header). Subject text comparisons should work correctly if you were to split the subject text using the 'whitespace' definition and then reassemble it using a single space in place of each whitespace separator. Its either that or assuming that all MUAs use the same line length and all use a line split of "CRLF " - the whitespace that's needed to align the continuation with the test on the first subject line. Many MUAs will do that, but its unlikely that all will. -- martin@ | Martin Gregorie gregorie. | Essex, UK org | From bkline at rksystems.com Thu Jan 20 17:58:36 2011 From: bkline at rksystems.com (Bob Kline) Date: Thu, 20 Jan 2011 17:58:36 -0500 Subject: Part of RFC 822 ignored by email module In-Reply-To: References: Message-ID: <4D38BE1C.2050209@rksystems.com> On 1/20/2011 5:34 PM, Martin Gregorie wrote: > On Thu, 20 Jan 2011 16:25:52 -0500, Bob Kline wrote: > >> On 1/20/2011 3:48 PM, Martin Gregorie wrote: >>> That's only a problem if your code cares about the composition of the >>> whitespace and this, IMO is incorrect behaviour. When the separator >>> between syntactic elements in a header is 'whitespace' it should not >>> matter what combination of newlines, tabs and spaces make up the >>> whitespace element. >> That would be true for what the RFC calls "structured" fields, but not >> for the others (such as the Subject header). > Subject text comparisons should work correctly if you were to split the > subject text using the 'whitespace' definition and then reassemble it > using a single space in place of each whitespace separator. Its either > that or assuming that all MUAs use the same line length and all use a > line split of "CRLF " - the whitespace that's needed to align the > continuation with the test on the first subject line. Many MUAs will do > that, but its unlikely that all will. Thanks. I'm not sure everyone would agree that it's OK to collapse multiple consecutive spaces into one, but I'm beginning to suspect that those more concerned with preserving as much as possible of the original message are in the minority. It sounds like my take-home distillation from this thread is "yes, the module ignores what the spec says about unfolding, but it doesn't matter." I guess I can live with that. -- Bob Kline http://www.rksystems.com mailto:bkline at rksystems.com From malaclypse2 at gmail.com Thu Jan 20 18:01:22 2011 From: malaclypse2 at gmail.com (Jerry Hill) Date: Thu, 20 Jan 2011 18:01:22 -0500 Subject: Tkinter: The good, the bad, and the ugly! In-Reply-To: References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <4d337983$0$29983$c3e8da3$5496439d@news.astraweb.com> <044a5101-948d-4458-9c94-57dbb3e25f67@m35g2000vbn.googlegroups.com> <4d3467bf$0$29983$c3e8da3$5496439d@news.astraweb.com> <4D34B04E.8050309@web.de> <4266E8D7BA204BFEA5BF66C635CE1716@octavian> <4D35DCE8.5030002@web.de> <4D35DD47.1070304@web.de> <7A0C7934E65D4B85A584C06ADD3B6ECF@teddy> Message-ID: On Thu, Jan 20, 2011 at 4:52 PM, rantingrick wrote: >> Greg Wilson's reaction was "Yes please", and he went on to explain >> what factors kept him using Tkinter for a recent course: > ? ? ? ?http://www.python.org/pipermail/python-dev/2000-October/016757.html > > Well that link is broken so we will never know what greg said? I think that's referring to this email: http://mail.python.org/pipermail/python-dev/2000-October/010046.html -- Jerry From python at mrabarnett.plus.com Thu Jan 20 18:08:11 2011 From: python at mrabarnett.plus.com (MRAB) Date: Thu, 20 Jan 2011 23:08:11 +0000 Subject: Tkinter: The good, the bad, and the ugly! In-Reply-To: References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com><4d337983$0$29983$c3e8da3$5496439d@news.astraweb.com><044a5101-948d-4458-9c94-57dbb3e25f67@m35g2000vbn.googlegroups.com><4d3467bf$0$29983$c3e8da3$5496439d@news.astraweb.com><4D34B04E.8050309@web.de><4266E8D7BA204BFEA5BF66C635CE1716@octavian><4D35DCE8.5030002@web.de><4D35DD47.1070304@web.de><7A0C7934E65D4B85A584C06ADD3B6ECF@teddy>< Message-ID: <4D38C05B.3090908@mrabarnett.plus.com> On 20/01/2011 21:52, rantingrick wrote: > On Jan 20, 3:06 pm, Emile van Sebille wrote: > [snip] >> Greg Wilson's reaction was "Yes please", and he went on to explain >> what factors kept him using Tkinter for a recent course: > http://www.python.org/pipermail/python-dev/2000-October/016757.html > > Well that link is broken so we will never know what greg said? > [snip] Yes: http://mail.python.org/pipermail/python-dev/2000-October.txt From rantingrick at gmail.com Thu Jan 20 18:14:11 2011 From: rantingrick at gmail.com (rantingrick) Date: Thu, 20 Jan 2011 15:14:11 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <4d337983$0$29983$c3e8da3$5496439d@news.astraweb.com> <044a5101-948d-4458-9c94-57dbb3e25f67@m35g2000vbn.googlegroups.com> <4d3467bf$0$29983$c3e8da3$5496439d@news.astraweb.com> <4D34B04E.8050309@web.de> <4266E8D7BA204BFEA5BF66C635CE1716@octavian> <4D35DCE8.5030002@web.de> <4D35DD47.1070304@web.de> <7A0C7934E65D4B85A584C06ADD3B6ECF@teddy> Message-ID: On Jan 20, 5:01?pm, Jerry Hill wrote: > On Thu, Jan 20, 2011 at 4:52 PM, rantingrick wrote: > >> Greg Wilson's reaction was "Yes please", and he went on to explain > >> what factors kept him using Tkinter for a recent course: > > ? ? ? ?http://www.python.org/pipermail/python-dev/2000-October/016757.html > > > Well that link is broken so we will never know what greg said? > > I think that's referring to this email:http://mail.python.org/pipermail/python-dev/2000-October/010046.html > > -- > Jerry Thanks Jerry this was the thread i was looking for. Two points for you ;-) From rantingrick at gmail.com Thu Jan 20 18:15:42 2011 From: rantingrick at gmail.com (rantingrick) Date: Thu, 20 Jan 2011 15:15:42 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com><4d337983$0$29983$c3e8da3$5496439d@news.astraweb.com><044a5101-948d-4458-9c94-57dbb3e25f67@m35g2000vbn.googlegroups.com><4d3467bf$0$29983$c3e8da3$5496439d@news.astraweb.com><4D34B04E.8050309@web.de><4266E8D7BA204BFEA5BF66C635CE1716@octavian><4D35DCE8.5030002@web.de><4D35DD47.1070304@web.de><7A0C7934E65D4B85A584C06ADD3B6ECF@teddy>< Message-ID: <699a37e4-e67c-4e32-b954-0866acb398fe@z19g2000yqb.googlegroups.com> On Jan 20, 5:08?pm, MRAB wrote: > On 20/01/2011 21:52, rantingrick wrote:> On Jan 20, 3:06 pm, Emile van Sebille ?wrote: > > [snip] > >> Greg Wilson's reaction was "Yes please", and he went on to explain > >> what factors kept him using Tkinter for a recent course: > > ? ?http://www.python.org/pipermail/python-dev/2000-October/016757.html > > > Well that link is broken so we will never know what greg said? > > [snip] > Yes: > ? ? ?http://mail.python.org/pipermail/python-dev/2000-October.txt Sorry MRAB. I could not find Greg's reply in this mountain of Usenet you posted a link to. You lose two points :(, oh wait, why should i be unhappy ;-) From rantingrick at gmail.com Thu Jan 20 18:31:59 2011 From: rantingrick at gmail.com (rantingrick) Date: Thu, 20 Jan 2011 15:31:59 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <4d337983$0$29983$c3e8da3$5496439d@news.astraweb.com> <044a5101-948d-4458-9c94-57dbb3e25f67@m35g2000vbn.googlegroups.com> <4d3467bf$0$29983$c3e8da3$5496439d@news.astraweb.com> <4D34B04E.8050309@web.de> <4266E8D7BA204BFEA5BF66C635CE1716@octavian> <4D35DCE8.5030002@web.de> <4D35DD47.1070304@web.de> <7A0C7934E65D4B85A584C06ADD3B6ECF@teddy> Message-ID: On Jan 20, 5:01?pm, Jerry Hill wrote: > I think that's referring to this email:http://mail.python.org/pipermail/python-dev/2000-October/010046.html ---- Greg Wilson ----- I thought about using wxPython in the most recent run of my Python course, but decided to stick to Tkinter because: - There isn't a wxWindows/wxPython book (matters a lot when organizations are trying to decide what to adopt for long-term use). ---- Greg Wilson ----- WxPython could use better docs even today (not sure of what books are available) however when we decide to integrate wx into the stdlib that would be the best time to write a comprihensive "python specific tutorial/docs ---- Greg Wilson ----- - Tkinter came packaged with the 1.5.2 installer, wxPython didn't. ---- Greg Wilson ----- Duh! And if wxPython came prepackaged this post whould never have existed eh? ---- Greg Wilson ----- - There aren't as many tools on top of wxPython as there are on top of Tkinter. In particular, I think that a vector drawing package on top of wxPython that did what Sketch does, but on Windows as well as Linux, would make a great subject for a book on Python, non-trivial OO, and HCI (hint, hint...) ---- Greg Wilson ----- Oh come on, this is about as weak as Guido's "tag" rant. A vector drawing app is not a tool it's an app! An besides more "tools" or apps will be written in wx when we integrate it into the stdlib, no doubt. These are really ridiculous reasons for not choosing wxPython and i suspect that you are just another one of the mindless "Tkinter" zombies who base their judgments on friendships and constituents. From nstinemates at gmail.com Thu Jan 20 18:42:42 2011 From: nstinemates at gmail.com (Nick Stinemates) Date: Thu, 20 Jan 2011 15:42:42 -0800 Subject: Tkinter: The good, the bad, and the ugly! In-Reply-To: References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <4d337983$0$29983$c3e8da3$5496439d@news.astraweb.com> <044a5101-948d-4458-9c94-57dbb3e25f67@m35g2000vbn.googlegroups.com> <4d3467bf$0$29983$c3e8da3$5496439d@news.astraweb.com> <4D34B04E.8050309@web.de> <4266E8D7BA204BFEA5BF66C635CE1716@octavian> <4D35DCE8.5030002@web.de> <4D35DD47.1070304@web.de> <7A0C7934E65D4B85A584C06ADD3B6ECF@teddy> Message-ID: > > ---- Greg Wilson ----- > I thought about using wxPython in the most recent run of my Python > course, but > decided to stick to Tkinter because: > > - There isn't a wxWindows/wxPython book (matters a lot when > organizations are > trying to decide what to adopt for long-term use). > ---- Greg Wilson ----- > > WxPython could use better docs even today (not sure of what books are > available) however when we decide to integrate wx into the stdlib that > would be the best time to write a comprihensive "python specific > tutorial/docs > > I disagree. All of the ducks should be in a row* **before* making a decision like this as it shows commitment from the community to making it happen. Nothing happens because we wish it to. Nick -------------- next part -------------- An HTML attachment was scrubbed... URL: From martin at address-in-sig.invalid Thu Jan 20 18:52:18 2011 From: martin at address-in-sig.invalid (Martin Gregorie) Date: Thu, 20 Jan 2011 23:52:18 +0000 (UTC) Subject: Part of RFC 822 ignored by email module References: Message-ID: On Thu, 20 Jan 2011 17:58:36 -0500, Bob Kline wrote: > Thanks. I'm not sure everyone would agree that it's OK to collapse > multiple consecutive spaces into one, but I'm beginning to suspect that > those more concerned with preserving as much as possible of the original > message are in the minority. It sounds like my take-home distillation > from this thread is "yes, the module ignores what the spec says about > unfolding, but it doesn't matter." I guess I can live with that. > I've been doing stuff in this area with the JavaMail package, though not as yet in Python. I've learnt that you parse the headers you can extract values that work well for comparisons, as database keys, etc. but are not guaranteed to let you reconstitute the original header byte for byte. If preserving the message exactly as received the solution is to parse the message to extract the headers and MIME parts you need for the application to carry out its function, but keep the original, unparsed message so you can pass it on. The other gotcha is assuming that the MUA author read and understood the RFCs. Very many barely glanced at RFCs and/or misunderstood them. Consequently, if you use strict parsing you'll be surprised how many messages get rejected for having invalid headers or MIME headers. Fot instance, the mistakes some MUAs make when outputting To, CC and BCC headers with multiple addresses have to be seen to be believed. If the Python e-mail module lets you, set it to use lenient parsing. If this isn't an option you may well find yourself having to fix up messages before you can parse them successfully. -- martin@ | Martin Gregorie gregorie. | Essex, UK org | From steve+comp.lang.python at pearwood.info Thu Jan 20 19:02:41 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 21 Jan 2011 00:02:41 GMT Subject: __pycache__, one more good reason to stck with Python 2? References: <23e02e0d-b2f1-4b52-85ea-d1feba99dd37@22g2000prx.googlegroups.com> <4d3466d3$0$29983$c3e8da3$5496439d@news.astraweb.com> <0c62aacd-e6d2-4778-81d6-e06924192add@j1g2000vbl.googlegroups.com> <87vd1m6ezq.fsf@benfinney.id.au> <992b11a0-d35d-4b08-98ab-d08c90a86ec7@j1g2000vbl.googlegroups.com> <4d36f846$0$29983$c3e8da3$5496439d@news.astraweb.com> <9b90b457-9436-4f38-956a-bfafe3d0acdb@h17g2000pre.googlegroups.com> Message-ID: <4d38cd20$0$29984$c3e8da3$5496439d@news.astraweb.com> On Thu, 20 Jan 2011 05:09:50 -0800, John Pinner wrote: > Hi > > You have disturbe my slumber, Steven ;-) > > On Jan 19, 2:42?pm, Steven D'Aprano +comp.lang.pyt... at pearwood.info> wrote: >> On Tue, 18 Jan 2011 00:58:14 -0800, jmfauth wrote: >> > It is now practically impossible to launch a Python application via a >> > .pyc file. >> >> When has that ever been possible? >> >> .pyc files are Python byte-code. You can't run them directly using >> Python (except via the import machinery), you can't run them as a >> script, they're not machine code. Unless you write a wrapper to import >> the file as a module, you can't directly execute .pyc files. > > Not true. 'python myprog.pyc' has worked for as long as I have been > using Python. Whether or not it is a good idea is another matter. > > Probably it would be best to check what you're saying before posting > such a bald assertion, even though you were 110% sure of what you were > saying. I've been there, done that, bought the tee-shirt. Yes, thank you, I've already been corrected over this :) But you got me thinking... how far back does this behaviour go? Apparently it goes back as long as I've been using Python too: [steve at sylar ~]$ echo "print 'spam spam spam'" > spam.py [steve at sylar ~]$ python1.5 Python 1.5.2 (#1, Apr 1 2009, 22:55:54) [GCC 4.1.2 20070925 (Red Hat 4.1.2-27)] on linux2 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> import spam spam spam spam >>> [steve at sylar ~]$ python1.5 spam.pyc spam spam spam But of course, .pyc files1.5 are version specific: [steve at sylar ~]$ python2.5 spam.pyc RuntimeError: Bad magic number in .pyc file -- Steven From shankarphy at gmail.com Thu Jan 20 19:03:59 2011 From: shankarphy at gmail.com (SANKAR .) Date: Fri, 21 Jan 2011 11:03:59 +1100 Subject: CRC 16bit function Message-ID: Hi There, I am looking for buitin function to calculate 16 bit checksum values of the lines in text file using python. I could find one for 32 bit but not for 16 bit. Can some one help me? Thanks Sankar -------------- next part -------------- An HTML attachment was scrubbed... URL: From jake.biesinger at gmail.com Thu Jan 20 19:07:35 2011 From: jake.biesinger at gmail.com (Jacob Biesinger) Date: Thu, 20 Jan 2011 16:07:35 -0800 Subject: Efficient python 2-d arrays? In-Reply-To: References: Message-ID: On Thu, Jan 20, 2011 at 12:48 PM, Dan Stromberg wrote: > On Thu, Jan 20, 2011 at 11:36 AM, Jake Biesinger > wrote: >>> Thanks for the great suggestions! >> >> On a related note, is there no way to efficiently sort a python array? >> >> >>>>> x = array('f', xrange(10000000)) >>>>> x.sort() >> --------------------------------------------------------------------------- >> AttributeError ? ? ? ? ? ? ? ? ? ? ? ? ? ?Traceback (most recent call last) >> >> /home/wbiesing/src/python-sort/ in () >> >> AttributeError: 'array.array' object has no attribute 'sort' >> >>>>> type(sorted(x)) >> >> >> Seems like a common enough task, but no way to do it efficiently without scipy/numpy. > > Tap, tap: Is this thing on? ?I keep sending messages to this list, but > no one seems to "hear" what I'm writing. Hey Dan, indeed thanks for the code; I pulled it down and played around with timsort a while ago. Timsort is indeed a beast. My current solution is to do an argsort. Since I can't roll with your cython implementations (pure python *only*), this seems a bit faster than sorting the original two lists using a modified pure-python timsort. Something along the lines of: args = sorted(range(len(seq1)), key=seq1.__getitem__) seq1 = [seq1[i] for i in args] seq2 = [seq2[i] for i in args] but the method suffers from a fairly high memory usage (big list of int's for args). If this barrier is too high, I will be switching over to your pure-python timsort. > Anyway, I have a bunch of sorts in python (pure or cython, your > option) at http://stromberg.dnsalias.org/cgi-bin/viewvc.cgi/sorts/compare/trunk/?root=svn > > The pure python versions should all work out of the box with an > array.array. ?I tested the timsort on an array.array, and it worked > well. your pylint runs fail for me, saying you should use disable, not disable-msg. pylint 0.23.0, astng 0.21.1, common 0.54.0 Python 2.6.6 (r266:84292, Sep 15 2010, 16:22:56) [GCC 4.4.5] > Also, I just made a trivial modification (not checked in! ...but I did > test it) to make the cythonized timsort support sorting arrays - just > change the "list" type declarations to "object" (or perhaps > "array.array") prior to compiling. I'm not very familiar with cython syntax-- how do you bring in the array module? cimport array? import array? I see you need to change cdef list to cdef array.array or something like that. Perhaps you could send a diff? Thanks! From python at mrabarnett.plus.com Thu Jan 20 19:10:19 2011 From: python at mrabarnett.plus.com (MRAB) Date: Fri, 21 Jan 2011 00:10:19 +0000 Subject: Tkinter: The good, the bad, and the ugly! In-Reply-To: <699a37e4-e67c-4e32-b954-0866acb398fe@z19g2000yqb.googlegroups.com> References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com><4d337983$0$29983$c3e8da3$5496439d@news.astraweb.com><044a5101-948d-4458-9c94-57dbb3e25f67@m35g2000vbn.googlegroups.com><4d3467bf$0$29983$c3e8da3$5496439d@news.astraweb.com><4D34B04E.8050309@web.de><4266E8D7BA204BFEA5BF66C635CE1716@octavian><4D35DCE8.5030002@web.de><4D35DD47.1070304@web.de><7A0C7934E65D4B85A584C06ADD3B6ECF@teddy>< <699a37e4-e67c-4e32-b954-0866acb398fe@z19g2000yqb.googlegroups.com> Message-ID: <4D38CEEB.9020408@mrabarnett.plus.com> On 20/01/2011 23:15, rantingrick wrote: > On Jan 20, 5:08 pm, MRAB wrote: >> On 20/01/2011 21:52, rantingrick wrote:> On Jan 20, 3:06 pm, Emile van Sebille wrote: >> >> [snip] >>>> Greg Wilson's reaction was "Yes please", and he went on to explain >>>> what factors kept him using Tkinter for a recent course: >>> http://www.python.org/pipermail/python-dev/2000-October/016757.html >> >>> Well that link is broken so we will never know what greg said? >> >> [snip] >> Yes: >> http://mail.python.org/pipermail/python-dev/2000-October.txt > > Sorry MRAB. I could not find Greg's reply in this mountain of Usenet > you posted a link to. You lose two points :(, oh wait, why should i be > unhappy ;-) > Did you try searching for "yes please"? It takes just seconds... From debatem1 at gmail.com Thu Jan 20 20:11:35 2011 From: debatem1 at gmail.com (geremy condra) Date: Thu, 20 Jan 2011 17:11:35 -0800 Subject: CRC 16bit function In-Reply-To: References: Message-ID: On Thu, Jan 20, 2011 at 4:03 PM, SANKAR . wrote: > Hi There, > > I am looking for buitin function to calculate? 16 bit checksum values of the > lines in text file using python. > I could find one for 32 bit but not for 16 bit. Can some one help me? Google's your friend. http://efreedom.com/Question/1-1767910/Checksum-Udp-Calculation-Python Geremy Condra From martin at v.loewis.de Thu Jan 20 20:19:47 2011 From: martin at v.loewis.de (Martin v. Loewis) Date: Fri, 21 Jan 2011 02:19:47 +0100 Subject: __pycache__, one more good reason to stck with Python 2? In-Reply-To: <4d37510f$0$29983$c3e8da3$5496439d@news.astraweb.com> References: <23e02e0d-b2f1-4b52-85ea-d1feba99dd37@22g2000prx.googlegroups.com> <4d3466d3$0$29983$c3e8da3$5496439d@news.astraweb.com> <0c62aacd-e6d2-4778-81d6-e06924192add@j1g2000vbl.googlegroups.com> <87vd1m6ezq.fsf@benfinney.id.au> <992b11a0-d35d-4b08-98ab-d08c90a86ec7@j1g2000vbl.googlegroups.com> <4d36f846$0$29983$c3e8da3$5496439d@news.astraweb.com> <4d37510f$0$29983$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4D38DF33.9030404@v.loewis.de> > I know I've seen problems executing .pyc files from the shell in the > past... perhaps I was conflating details of something else. Ah, I know! > > [steve at sylar ~]$ chmod u+x toto.pyc > [steve at sylar ~]$ ./toto.pyc > : command not found ?? > ./toto.pyc: line 2: syntax error near unexpected token `(' > ./toto.pyc: line 2: `P7Mc at s dGHdS(tfooN((((s ./ > toto.pys' Works fine here: martin at mira:/tmp$ cat >a.py print "Hello, world" martin at mira:/tmp$ python Python 2.6.6 (r266:84292, Dec 26 2010, 22:31:48) [GCC 4.4.5] on linux2 Type "help", "copyright", "credits" or "license" for more information. py> import a Hello, world py> martin at mira:/tmp$ chmod +x a.pyc martin at mira:/tmp$ ./a.pyc Hello, world Notice that it is a Linux feature that it can support Python bytecode as a "native" executable when properly configured. Windows has a very similar feature, though. I think OSX can support it as well, but I haven't tried. Regards, Martin From martin at v.loewis.de Thu Jan 20 20:30:58 2011 From: martin at v.loewis.de (Martin v. Loewis) Date: Fri, 21 Jan 2011 02:30:58 +0100 Subject: __pycache__, one more good reason to stck with Python 2? In-Reply-To: <4d38cd20$0$29984$c3e8da3$5496439d@news.astraweb.com> References: <23e02e0d-b2f1-4b52-85ea-d1feba99dd37@22g2000prx.googlegroups.com> <4d3466d3$0$29983$c3e8da3$5496439d@news.astraweb.com> <0c62aacd-e6d2-4778-81d6-e06924192add@j1g2000vbl.googlegroups.com> <87vd1m6ezq.fsf@benfinney.id.au> <992b11a0-d35d-4b08-98ab-d08c90a86ec7@j1g2000vbl.googlegroups.com> <4d36f846$0$29983$c3e8da3$5496439d@news.astraweb.com> <9b90b457-9436-4f38-956a-bfafe3d0acdb@h17g2000pre.googlegroups.com> <4d38cd20$0$29984$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4D38E1D2.70007@v.loewis.de> > But you got me thinking... how far back does this behaviour go? ================================= ==> Release 1.1 (11 Oct 1994) <== ================================= - Passing the interpreter a .pyc file as script argument will execute the code in that file. (On the Mac such files can be double-clicked!) - New module compileall generates .pyc files for all modules in a directory (tree) without also executing them [Notice that "on the Mac" refers to Mac System 7 here] ======================================= ==> Release 1.0.0 (26 January 1994) <== ======================================= * It is now possible to have a .pyc file without a corresponding .py file. (Warning: this may break existing installations if you have an old .pyc file lingering around somewhere on your module search path without a corresponding .py file, when there is a .py file for a module of the same name further down the path -- the new interpreter will find the first .pyc file and complain about it, while the old interpreter would ignore it and use the .py file further down.) Regards, Martin From drsalists at gmail.com Thu Jan 20 21:10:35 2011 From: drsalists at gmail.com (Dan Stromberg) Date: Thu, 20 Jan 2011 18:10:35 -0800 Subject: Efficient python 2-d arrays? In-Reply-To: References: Message-ID: On Thu, Jan 20, 2011 at 4:07 PM, Jacob Biesinger wrote: > On Thu, Jan 20, 2011 at 12:48 PM, Dan Stromberg wrote: >> On Thu, Jan 20, 2011 at 11:36 AM, Jake Biesinger >> wrote: >>>> Thanks for the great suggestions! >>> >>> On a related note, is there no way to efficiently sort a python array? >>> >>> >>>>>> x = array('f', xrange(10000000)) >>>>>> x.sort() >>> --------------------------------------------------------------------------- >>> AttributeError ? ? ? ? ? ? ? ? ? ? ? ? ? ?Traceback (most recent call last) >>> >>> /home/wbiesing/src/python-sort/ in () >>> >>> AttributeError: 'array.array' object has no attribute 'sort' >>> >>>>>> type(sorted(x)) >>> >>> >>> Seems like a common enough task, but no way to do it efficiently without scipy/numpy. >> >> Tap, tap: Is this thing on? ?I keep sending messages to this list, but >> no one seems to "hear" what I'm writing. > > Hey Dan, indeed thanks for the code; I pulled it down and played > around with timsort a while ago. Timsort is indeed a beast. My current > solution is to do an argsort. ?Since I can't roll with your cython > implementations (pure python *only*), this seems a bit faster than > sorting the original two lists using a modified pure-python timsort. > Something along the lines of: > > args = sorted(range(len(seq1)), key=seq1.__getitem__) > seq1 = [seq1[i] for i in args] > seq2 = [seq2[i] for i in args] > > but the method suffers from a fairly high memory usage (big list of > int's for args). ?If this barrier is too high, I will be switching > over to your pure-python timsort. Oh, cool. I guess I'm not a ghost after all. :) And an argsort sounds like a nice solution. >> Anyway, I have a bunch of sorts in python (pure or cython, your >> option) at http://stromberg.dnsalias.org/cgi-bin/viewvc.cgi/sorts/compare/trunk/?root=svn >> >> The pure python versions should all work out of the box with an >> array.array. ?I tested the timsort on an array.array, and it worked >> well. > > your pylint runs fail for me, saying you should use disable, not disable-msg. > pylint 0.23.0, > astng 0.21.1, common 0.54.0 > Python 2.6.6 (r266:84292, Sep 15 2010, 16:22:56) > [GCC 4.4.5] Earlier today I updated the code to deal with newer pylints - including the disable vs disable-msg thing. If you "svn update", you should get these changes. >> Also, I just made a trivial modification (not checked in! ...but I did >> test it) to make the cythonized timsort support sorting arrays - just >> change the "list" type declarations to "object" (or perhaps >> "array.array") prior to compiling. > > I'm not very familiar with cython syntax-- how do you bring in the array module? > cimport array? import array? I see you need to change cdef list to > cdef array.array or something like that. ?Perhaps you could send a > diff? http://stromberg.dnsalias.org/svn/sorts/compare/branches/arrays now has a version of timsort that expects objects (IOW, about anything, duck typed) instead of lists. I tried briefly to declare some of the types to be array.array, but perhaps Cython doesn't like that - I was getting compile-time errors from it. HTH. From nhodgson at bigpond.net.au Thu Jan 20 21:34:03 2011 From: nhodgson at bigpond.net.au (Neil Hodgson) Date: Fri, 21 Jan 2011 13:34:03 +1100 Subject: Tkinter: The good, the bad, and the ugly! In-Reply-To: References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com><4d337983$0$29983$c3e8da3$5496439d@news.astraweb.com><044a5101-948d-4458-9c94-57dbb3e25f67@m35g2000vbn.googlegroups.com><4d3467bf$0$29983$c3e8da3$5496439d@news.astraweb.com><4D34B04E.8050309@web.de><4266E8D7BA204BFEA5BF66C635CE1716@octavian><4D35DCE8.5030002@web.de><4D35DD47.1070304@web.de><7A0C7934E65D4B85A584C06ADD3B6ECF@teddy>< ih53k2$pjf$1@dough.gmane.org> <513d0274-1878-49a6-9382-31b6ae7aaef3@y9g2000prf.googlegroups.com> Message-ID: Emile van Sebille: > The problem with QT is the license. > > From http://qt.nokia.com/products/licensing/: > > Qt Commercial Developer License > The Qt Commercial Developer License is the correct license to use for > the development of proprietary and/or commercial software ... The LGPL version is also useful for producing commercial software. >From the same web page: """ Qt GNU LGPL v. 2.1 Version This version is available for development of proprietary and commercial applications in accordance with the terms and conditions of the GNU Lesser General Public License version 2.1. """ Developing a proprietary (closed source) application using LGPL libraries is normally not a problem as the only pieces of code you have to publish are changes to those LGPL libraries, not the application code. Most applications do not change the libraries. The "can't reuse LGPL code" clause is a restriction on what can be done with the Qt Commercial Developer License not on what can be done with the LGPL license. GTK+ has always been LGPL and that license has not been an obstacle to either open source or closed source projects. Neil From jeanfrancois.leberre at gmail.com Thu Jan 20 21:35:46 2011 From: jeanfrancois.leberre at gmail.com (Jean-Francois) Date: Thu, 20 Jan 2011 18:35:46 -0800 (PST) Subject: New instance of a class : not reset? Message-ID: Hi, In the following example, I don't understand why attribute 'data' is not reset when I get the new instance of Bag It works if I make a copy (data[:]) but I want to understand why Thanks class Bag(object): def __init__(self, data = []): self.data = data #self.data = data[:] def add(self, x): self.data.append(x) bag = Bag() print bag.data bag.add('toto') print bag.data bag = Bag() # new instance of Bag, all attributes clear? print bag.data # 'toto' is still there !!! From andre.roberge at gmail.com Thu Jan 20 21:46:26 2011 From: andre.roberge at gmail.com (=?ISO-8859-1?Q?Andr=E9?=) Date: Thu, 20 Jan 2011 18:46:26 -0800 (PST) Subject: New instance of a class : not reset? In-Reply-To: Message-ID: On Thursday, January 20, 2011 10:35:46 PM UTC-4, Jean-Francois wrote: > Hi, > > In the following example, I don't understand why attribute 'data' is > not reset when I get the new instance of Bag > It works if I make a copy (data[:]) but I want to understand why > > Thanks > > > class Bag(object): > def __init__(self, data = []): See http://docs.python.org/tutorial/controlflow.html#default-argument-values Read the text following "Important warning: The default value is evaluated only once.". Andr? > self.data = data > #self.data = data[:] > def add(self, x): > self.data.append(x) > > bag = Bag() > print bag.data > bag.add('toto') > print bag.data > bag = Bag() # new instance of Bag, all attributes clear? > print bag.data # 'toto' is still there !!! From python at mrabarnett.plus.com Thu Jan 20 21:55:16 2011 From: python at mrabarnett.plus.com (MRAB) Date: Fri, 21 Jan 2011 02:55:16 +0000 Subject: New instance of a class : not reset? In-Reply-To: References: Message-ID: <4D38F594.8050602@mrabarnett.plus.com> On 21/01/2011 02:35, Jean-Francois wrote: > Hi, > > In the following example, I don't understand why attribute 'data' is > not reset when I get the new instance of Bag > It works if I make a copy (data[:]) but I want to understand why > > Thanks > > > class Bag(object): > def __init__(self, data = []): > self.data = data > #self.data = data[:] > def add(self, x): > self.data.append(x) > > bag = Bag() > print bag.data > bag.add('toto') > print bag.data > bag = Bag() # new instance of Bag, all attributes clear? > print bag.data # 'toto' is still there !!! See: http://effbot.org/zone/default-values.htm From davea at ieee.org Thu Jan 20 22:10:00 2011 From: davea at ieee.org (Dave Angel) Date: Thu, 20 Jan 2011 22:10:00 -0500 Subject: CRC 16bit function In-Reply-To: References: Message-ID: <4D38F908.5060807@ieee.org> On 01/-10/-28163 02:59 PM, geremy condra wrote: > On Thu, Jan 20, 2011 at 4:03 PM, SANKAR . wrote: >> Hi There, >> >> I am looking for buitin function to calculate 16 bit checksum values of the >> lines in text file using python. >> I could find one for 32 bit but not for 16 bit. Can some one help me? > > Google's your friend. > > http://efreedom.com/Question/1-1767910/Checksum-Udp-Calculation-Python > > Geremy Condra > There are at least 3 commonly used checksum algorithms that give 16bit results. Two of them are CRC's, with different polynomials. And the third is the one's complement that Geremy posted the link to, used in tcp/ip traffic. Try http://bytes.com/topic/python/answers/27677-crc-16-a or http://bytes.com/topic/python/insights/887357-python-check-crc-frame-crc-16-ccitt The latter is likely to be extremely slow. DaveA From albert at spenarnc.xs4all.nl Thu Jan 20 23:51:46 2011 From: albert at spenarnc.xs4all.nl (Albert van der Horst) Date: 21 Jan 2011 04:51:46 GMT Subject: examples of realistic multiprocessing usage? References: <2011011611053732597-tomfsessile@gmailcom> Message-ID: In article , Adam Tauno Williams wrote: >On Mon, 2011-01-17 at 13:55 +0000, Albert van der Horst wrote: >> In article , >> Philip Semanchuk wrote: >> >> >I grepped through the code to see that it's using = >> >multiprocessing.Listener. I didn't go any further than that because our = >> >project is BSD licensed and the license for Gluino is unclear. Until I = >> >find out whether or not its under an equally permissive license, I can't = >> >borrow ideas and/or code from it. >> You have been brain washed by the Intellectual Properties congsy. >> Of course you can read through code to borrow idea's from it. > >I wouldn't; and there is no brain-washing. > >It is very unwise to look at GPL'd code if you are working on a non-GPL >project; the GPL is specifically and intentionally viral. The >distinction between reading-through-code-and-borrowing-ideas and >copying-code is thin and best left to lawyers. This is what some people want you to believe. Arm twisting by GPL-ers when you borrow their ideas? That is really unheard of. GPL-ers are not keen on getting the most monetary award by setting lawyers on you and go to court only reluctantly to enforce the license. > >Aside: Comments to the contrary often stand-on-their-head to make such >cases. For example: > >"You do have a choice under the GPL license: you can stop using the >stolen code and write your own, or you can decide you'd rather release >under the GPL. But the choice is yours. If you say, I choose neither, >then the court can impose an injunction to stop you from further >distribution, but it won't order your code released under the GPL. ... >Of course, you could avoid all such troubles in the first place by not >stealing GPL code to begin with" > Stealing code means just that, verbatim copies. When you read this carefully, you can see that reimplementing the stolen code is an option. Exactly what you say is legally impossible. It doesn't say: "you can stop using the stolen code, and now you're forever banned from writing your own, since you have seen our code" > >Seriously? What that basically means is you can't use GPL'd code in a >non-GPL'd product/project. Saying if you do it is OK, but you'll be >required to replace the code or change your license is >standing-on-ones-head. Risking a forced reimplementation of a core >component of an existing application is 'just nuts'. GPL-code is protected under *copyright law*, not patents or some such. That means that reimplementing idea's is okay. That is one of the things GPL tries to protect. Also we recognize the fact that the wheel is reinvented all the time and that there are a limited number of solutions to a problem. You could easily have come up with the same idea as me. Then you overlook another possibility. I have a lot of GPL-ed code on my site. If you want to use some of it commercially, you could contact me and negotiate a non-GPL license. You might be surprised how easy I'm on you, as long as you recognize where the code comes from. If you want to use it BSD-licensed, I would be even more lenient (unless strategic issues are at stake.) So pardon me, but not even looking at code you might learn from is pretty hysteric. Groetjes Albert -- -- Albert van der Horst, UTRECHT,THE NETHERLANDS Economic growth -- being exponential -- ultimately falters. albert at spe&ar&c.xs4all.nl &=n http://home.hccnet.nl/a.w.m.van.der.horst From longqian9509 at gmail.com Thu Jan 20 23:52:15 2011 From: longqian9509 at gmail.com (longqian9509 at gmail.com) Date: Thu, 20 Jan 2011 20:52:15 -0800 (PST) Subject: is it a bug in exec? Message-ID: <0629ea10-b667-4630-a99f-78168a3e0979@u6g2000yqk.googlegroups.com> In pyhton 3.1, I found the following code will succeed with argument 1 to 4 and fail with argument 5 to 9. It is really strange to me. I suspect it may be a buy in exec() function. Does anyone have some idea about it? Thanks. t1=""" class foo: def fun(): print('foo') def main(): global foo foo.fun() main() """ t2=""" class foo: def fun(): print('foo') def main(): foo.fun() main() """ import sys import copy if sys.argv[1]=='1': exec(t1) elif sys.argv[1]=='2': exec(t2) elif sys.argv[1]=='3': exec(t1,{},{}) elif sys.argv[1]=='4': exec(t2,globals(),locals()) elif sys.argv[1]=='5': exec(t2,{},{}) elif sys.argv[1]=='6': exec(t2,globals(),{}) elif sys.argv[1]=='7': exec(t2,{},locals()) elif sys.argv[1]=='8': exec(t2,copy.copy(globals()),locals()) elif sys.argv[1]=='9': exec(t2,globals(),copy.copy(locals())) From pavlovevidence at gmail.com Fri Jan 21 00:48:29 2011 From: pavlovevidence at gmail.com (Carl Banks) Date: Thu, 20 Jan 2011 21:48:29 -0800 (PST) Subject: Part of RFC 822 ignored by email module References: Message-ID: <6b41e8ba-aefc-443d-8c7e-d9caa8808c7e@y9g2000prf.googlegroups.com> On Jan 20, 9:55?am, Bob Kline wrote: > On 1/20/2011 12:23 PM, Carl Banks wrote: > > > > > On Jan 20, 7:08 am, Bob Kline ?wrote: > >> I just noticed that the following passage in RFC 822: > > >> ? ? ? ? ? The process of moving ?from ?this ?folded ? multiple-line > >> ? ? ? ? ? representation ?of a header field to its single line represen- > >> ? ? ? ? ? tation is called "unfolding". ?Unfolding ?is ?accomplished ?by > >> ? ? ? ? ? regarding ? CRLF ? immediately ?followed ?by ?a ?LWSP-char ?as > >> ? ? ? ? ? equivalent to the LWSP-char. > > >> is not being honored by the email module. ?The following two invocations > >> of message_from_string() should return the same value, but that's not > >> what happens: > > >> ? >>> ?import email > >> ? >>> ?email.message_from_string("Subject: blah").get('SUBJECT') > >> 'blah' > >> ? >>> ?email.message_from_string("Subject:\n blah").get('SUBJECT') > >> ' blah' > > >> Note the space in front of the second value returned, but missing from > >> the first. ?Can someone convince me that this is not a bug? > > That's correct, according to my reading of RFC 822 (I doubt it's > > changed so I didn't bother to look up what the latest RFC on that > > subject is.) > > > The RFC says that in a folded line the whitespace on the following > > line is considered a part of the line. > > Thanks for responding. ?I think your interpretation of the RFC is the > same is mine. ?What I'm saying is that by not returning the same value > in the two cases above the module is not "regarding CRLF immediately > followed by a LWSP-char as equivalent to the LWSP-char." That makes sense. The space after \n is part of the reconstructed subject and the email module should have treated it same as if the line hadn't been folded. I agree that it's a bug. The line-folding needs to be moved earlier in the parse process. Carl Banks From pavlovevidence at gmail.com Fri Jan 21 01:38:28 2011 From: pavlovevidence at gmail.com (Carl Banks) Date: Thu, 20 Jan 2011 22:38:28 -0800 (PST) Subject: Part of RFC 822 ignored by email module References: <4D384FF8.6060708@rksystems.com> Message-ID: On Jan 20, 9:58?am, Dennis Lee Bieber wrote: > On Thu, 20 Jan 2011 10:08:40 -0500, Bob Kline > declaimed the following in gmane.comp.python.general: > > > > > I just noticed that the following passage in RFC 822: > > > ? ? ? ? ?The process of moving ?from ?this ?folded ? multiple-line > > ? ? ? ? ?representation ?of a header field to its single line represen- > > ? ? ? ? ?tation is called "unfolding". ?Unfolding ?is ?accomplished ?by > > ? ? ? ? ?regarding ? CRLF ? immediately ?followed ?by ?a ?LWSP-char ?as > > ? ? ? ? ?equivalent to the LWSP-char. > > > is not being honored by the email module. ?The following two invocations > > of message_from_string() should return the same value, but that's not > > what happens: > > > ?>>> import email > > ?>>> email.message_from_string("Subject: blah").get('SUBJECT') > > 'blah' > > ?>>> email.message_from_string("Subject:\n blah").get('SUBJECT') > > ' blah' > > > Note the space in front of the second value returned, but missing from > > the first. ?Can someone convince me that this is not a bug? > > ? ? ? ? I'd first be concerned about the absence of the line ending sequence > specified by the RFC: carriage return (CR; \r) followed by line feed > (LF; \n). > > ? ? ? ? \n by itself is not an RFC compliant line ending (even if writing to > a file on Windows in text mode converts \n into \r\n). Though it does > appear the module accepts it as such. Well, I think that message_from_string() would have to accept any RFC822-compatible message, since it's documented as such, but it doesn't necessarily have to reject technically invalid ones. Well, the RFC is concerned mainly with the transmission format, and doesn't require libraries to force the user to input CRLF, so in general there's no reason \n isn't acceptable if the library allows it. However, message_from_string() is part of the transmission (it's documented as being able to accept RFC822-formatted messages) so it has to respect RFC 822 formatting. But I think it is ok for it to accept non-compliant messages that use LF or CR. (Any tool that isn't brain dead should, too.) The RFC doesn't specifically prohibit this. > ? ? ? ? Secondly, nothing in the spec says it trims leading whitespace from > the unwrapped lines. In fact, all it says is that the line ending itself > is removed from the string. > > >>> email.message_from_string("Subject:\r\n ? ? blah").get('SUBJECT') > > ' ? ? blah' I don't think this behavior is covered in the RFC since this happens after transmission. I.e., message_from_string "receives" the RFC822- compliant message, then it's mostly free to do what it wants with it, including stripping leading whitespace of header values. > ? ? ? ? However, the module does appear to trim leading whitespace that > occurs between the : and text (and the line end is considered for that > trimming, but not any whitespace after it). > > >>> email.message_from_string("Subject: ? ? ?blah\r\n ? ? blah").get('SUBJECT') > 'blah\r\n ? ? blah' > >>> email.message_from_string("Subject: ? ? ?blah\r\n ? ? blah").get('SUBJECT') > 'blah\r\n ? ? blah' > >>> email.message_from_string("Subject: ? ? ?blah\r\n ? ? blah ? ").get('SUBJECT') > > 'blah\r\n ? ? blah ? '>>> email.message_from_string("Subject: \r\n ? ? blah ? ").get('SUBJECT') > ' ? ? blah ? ' In this case the RFC does address the behavior downstream of transmission: it says that the whitespace following a folded line is equivalent to that line with just the whitespace, yet the email module treats them differently. This is unquestionably a bug. Carl Banks From arnodel at gmail.com Fri Jan 21 02:41:02 2011 From: arnodel at gmail.com (Arnaud Delobelle) Date: Fri, 21 Jan 2011 07:41:02 +0000 Subject: statement level resumable exception References: <87oc7b9wkm.fsf@gmail.com> <62658b12-34b7-4ed5-9ecd-5182b53f7b31@t35g2000yqj.googlegroups.com> <87k4hz9uiu.fsf@gmail.com> Message-ID: <87fwsmaelt.fsf@gmail.com> ilejn writes: > Arnaud, > > these lists are not generated. > > Actually these lists are a sort of interpreted programs and contain > some application logic. > > Here is an example > [ > [PUSH, [get_modified_interface, req]], > [TIMEOUT, 3], > [PULL, [out_interface, '']], > [PULL, [err_interface, '']], > [PULL, [out_mined_interface, req]], > ] > > If any interface name is unknown the list must not be invoked (in > other words, f function > call with this list must be somehow bypassed). > > Thanks. You could still use the same idea and delay evaluation of the lists. E.g. prg1 = """[ [PUSH, [get_modified_interface, req]], [TIMEOUT, 3], ... """ prg2 = """[ [OPCODE, [arguments, blah]], ... """ ... prgN = """...""" for prg in prg1, prg2, ..., prgN: try: prg = eval(prg) except NameError: continue f(prg) -- Arnaud From steve+comp.lang.python at pearwood.info Fri Jan 21 03:01:14 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 21 Jan 2011 08:01:14 GMT Subject: __pycache__, one more good reason to stck with Python 2? References: <23e02e0d-b2f1-4b52-85ea-d1feba99dd37@22g2000prx.googlegroups.com> <4d3466d3$0$29983$c3e8da3$5496439d@news.astraweb.com> <0c62aacd-e6d2-4778-81d6-e06924192add@j1g2000vbl.googlegroups.com> <87vd1m6ezq.fsf@benfinney.id.au> <992b11a0-d35d-4b08-98ab-d08c90a86ec7@j1g2000vbl.googlegroups.com> <4d36f846$0$29983$c3e8da3$5496439d@news.astraweb.com> <4d37510f$0$29983$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4d393d4a$0$29983$c3e8da3$5496439d@news.astraweb.com> On Wed, 19 Jan 2011 14:31:15 -0800, Alice Bevan?McGregor wrote: > On 2011-01-19 13:01:04 -0800, Steven D'Aprano said: >> I know I've seen problems executing .pyc files from the shell in the >> past... perhaps I was conflating details of something else. Ah, I know! >> >> [steve at sylar ~]$ chmod u+x toto.pyc >> [steve at sylar ~]$ ./toto.pyc >> : command not found ?? >> ./toto.pyc: line 2: syntax error near unexpected token `(' ./toto.pyc: >> line 2: `P7Mc at s dGHdS(tfooN((((s ./ toto.pys' > > ... don't do that. I do not know why that would be expected to work, > ever. (Unless you're crafty and wrap a real shell script around the > .pyc, in which case it's no longer a .pyc.) I didn't expect it to work, but I have seen others do it and be surprised that it doesn't. This is why I was pleasantly surprised to learn that `python toto.pyc` does work -- I was conflating the above failure with the issue under discussion. -- Steven From orasnita at gmail.com Fri Jan 21 03:05:24 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Fri, 21 Jan 2011 10:05:24 +0200 Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com><4d337983$0$29983$c3e8da3$5496439d@news.astraweb.com><044a5101-948d-4458-9c94-57dbb3e25f67@m35g2000vbn.googlegroups.com><4d3467bf$0$29983$c3e8da3$5496439d@news.astraweb.com><4D34B04E.8050309@web.de><4266E8D7BA204BFEA5BF66C635CE1716@octavian><4D35DCE8.5030002@web.de><4D35DD47.1070304@web.de><7A0C7934E65D4B85A584C06ADD3B6ECF@teddy> Message-ID: > From: "Adam Skutt" > Yet, for some unfathomable reason, > you keep promoting > I would be glad if you could tell me about a portable solution which is > accessible with JAWS and Window Eyes, the most used screen readers under > Windows (real glad). I did, Qt. I'm not yournanny and I'm not going to go test it for you. There are bugs in the Qt database relating to JAWS functionality, so it others have plainly gotten it working to some degree. But honestly, why should I waste my time replying to you when you're too damn lazy to even use Google? I certainly won't be doing so in the future. "Lead a ignorant, thirsty horse to water, watch it die of thirst" and all that. I have tried more QT-based apps and I couldn't find one to be accessible, while most widgets offered by WxPython are accessible out of the box. QT is really bad, but you hijacked the tread because as you can see even in the subject, we are talking about Tkinter, not about QT. If QT is not included by default in Python, it is not such a big problem because only those who care more about the visual aspect than about the accessibility use it, but Tkinter is bad because it is promoted and many beginners will start using it witout knowing how bad it is and why. You keep telling that you searched on the web for finding what the others say about accessibility but this is a very wrong way. Don't say anything about accessibility if you haven't tried personally. Octavian From steve+comp.lang.python at pearwood.info Fri Jan 21 03:14:52 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 21 Jan 2011 08:14:52 GMT Subject: is it a bug in exec? References: <0629ea10-b667-4630-a99f-78168a3e0979@u6g2000yqk.googlegroups.com> Message-ID: <4d39407c$0$29983$c3e8da3$5496439d@news.astraweb.com> On Thu, 20 Jan 2011 20:52:15 -0800, longqian9509 at gmail.com wrote: > In pyhton 3.1, I found the following code will succeed with argument 1 > to 4 and fail with argument 5 to 9. It is really strange to me. I > suspect it may be a buy in exec() function. Does anyone have some idea > about it? Thanks. What makes you think it's a bug? Is there anything in the documentation of exec that suggests to you that some other behaviour should occur? What version of Python are you using? Without knowing what behaviour you expect and what behaviour you see, how are we supposed to know if you've found a bug or not? I suggest you fire up the interactive interpreter and try this: t1 = """ class foo: def fun(): print('foo') def main(): global foo foo.fun() main() """ dg = {} dl = {} exec(t1, dg, dl) then inspect the values of dg and dl and see if it helps. If not, write back with what you expect to happen, and what you see instead. -- Steven From timr at probo.com Fri Jan 21 03:39:53 2011 From: timr at probo.com (Tim Roberts) Date: Fri, 21 Jan 2011 00:39:53 -0800 Subject: Part of RFC 822 ignored by email module References: Message-ID: <7chij6lnm3ln7phdr7536rvb0sb4iuqpbh@4ax.com> Bob Kline wrote: > >I just noticed that the following passage in RFC 822: For future interest, RFC 822 has LONG since been replaced, first by RFC 2822, then by RFC 5322. I believe the white space folding requirement is still there, but something that violates 822 but not 5322 (and there are several such things) is not all that important. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From ilja.golshtein at gmail.com Fri Jan 21 03:41:21 2011 From: ilja.golshtein at gmail.com (ilejn) Date: Fri, 21 Jan 2011 00:41:21 -0800 (PST) Subject: statement level resumable exception References: <87oc7b9wkm.fsf@gmail.com> <62658b12-34b7-4ed5-9ecd-5182b53f7b31@t35g2000yqj.googlegroups.com> <87k4hz9uiu.fsf@gmail.com> <87fwsmaelt.fsf@gmail.com> Message-ID: <52e20ce1-0e0c-4817-a61d-91437291883a@i18g2000yqn.googlegroups.com> Arnaud, it looks like a solution. Perhaps it is better than plain try/accept and than proxy class with __getattr__. It is not for free, e.g. because syntax check such as parentheses matching is lazy too, though looks very interesting. Thanks a lot! On Jan 21, 10:41?am, Arnaud Delobelle wrote: > ilejn writes: > > Arnaud, > > > these lists are not generated. > > > Actually these lists are a sort of interpreted programs and contain > > some application logic. > > > Here is an example > > ? ? ? ? [ > > ? ? ? ? [PUSH, [get_modified_interface, req]], > > ? ? ? ? [TIMEOUT, 3], > > ? ? ? ? [PULL, [out_interface, '']], > > ? ? ? ? [PULL, [err_interface, '']], > > ? ? ? ? [PULL, [out_mined_interface, req]], > > ? ? ? ? ] > > > If any interface name is unknown the list must not be invoked (in > > other words, f function > > call with this list must be somehow bypassed). > > > Thanks. > > You could still use the same idea and delay evaluation of the lists. E.g. > > prg1 = """[ > ? ? [PUSH, [get_modified_interface, req]], > ? ? [TIMEOUT, 3], > ? ? ... > """ > > prg2 = """[ > ? ? [OPCODE, [arguments, blah]], > ? ? ... > """ > > ... > > prgN = """...""" > > for prg in prg1, prg2, ..., prgN: > ? ? try: > ? ? ? ? prg = eval(prg) > ? ? except NameError: > ? ? ? ? continue > ? ? f(prg) > > -- > Arnaud Best regards, Ilja Golshtein From alt.mcarter at gmail.com Fri Jan 21 05:12:51 2011 From: alt.mcarter at gmail.com (Mark Carter) Date: Fri, 21 Jan 2011 02:12:51 -0800 (PST) Subject: Printing RTF file under win32 Message-ID: <2608cc6e-a385-4a31-ab9e-f740d231bf06@k11g2000vbf.googlegroups.com> I'm using Python 2.6.5 on win32. I would like to print a batch of RTF files on a printer. I don't want to use the win32api.ShellExecute command because that invokes Word, and Word has been configured in a strange way by one of our admins, making it inconvenient to use. What should I do? From research at johnohagan.com Fri Jan 21 05:20:29 2011 From: research at johnohagan.com (John O'Hagan) Date: Fri, 21 Jan 2011 10:20:29 +0000 Subject: Sending changed parameters into nested generators In-Reply-To: <201101210329.53456.research@johnohagan.com> References: <201101210329.53456.research@johnohagan.com> Message-ID: <201101211020.29967.research@johnohagan.com> On Fri, 21 Jan 2011, cbrown wrote: > On Nov 12, 10:52 pm, "John O'Hagan" wrote: > > On Sat, 13 Nov 2010, Steven D'Aprano wrote: > > > On Fri, 12 Nov 2010 09:47:26 +0000, John O'Hagan wrote: > > > > I have a generator function which takes as arguments another > > > > generator and a dictionary of other generators like this: > > > > > > > > def modgen(gen, gendict): > > > > for item in gen(): > > > > for k, v in gendict: > > > > do_something_called_k(item, v.next()) > > > > > > > > yield item > > > > > > [snip] > > > > > > > If anyone's still reading :) , how can I send new values to arbitrary > > > > sub- generators? > > > > > > I have a headache after reading your problem :( > > > > > > I think it's a good time to point you at the Zen, particularly these > > > five maxims: > > > > > > Beautiful is better than ugly. > > > Simple is better than complex. > > > Complex is better than complicated. > > > Flat is better than nested. > > > If the implementation is hard to explain, it's a bad idea. > > > > > > I'm afraid that your nested generators inside another generator idea > > > fails all of those... it's not elegant (beautiful), it's complicated, > > > it's nested, and the implementation is hard to explain. > > > > > > You could probably replace generators with full-blown iterators, but I > > > wonder what you're trying to accomplish that is so complicated that it > > > needs such complexity to solve it. What are you actually trying to > > > accomplish? Can you give a simple example of what practical task you > > > hope to perform? I suspect there's probably a more elegant way to > > > solve the problem. > > > > I hope there is! > > > > The project not practical but artistic; it's a real-time musical > > composition program. > > > > A (simplified) description: one module contains number-list generating > > functions, others contain functions designed to filter and modify the > > number lists produced, according to various parameters. Each such stream > > of number lists is assigned a musical meaning (e.g. pitch, rhythm, > > volume, etc) and they are combined to produce representations of musical >>phrases, which are sent to a backend which plays the music > >as it is produced, and makes PDF scores. > > >Each such "instrument" runs as a separate thread, so several can play >>together in acoordinated fashion. > > > > All the compositional interest lies in the selection of number-list >>generators and how their output is modified. For example, if I say "Play >>every third note up an octave" it's not very interesting, compared to "Play >>every nth note up an interval of m", where n and m vary according to some >>pattern. It gets even more interesting when that pattern is a function of x >>and y, which also vary according to another pattern, and so on. > > > > To that end, I have each parameter of each modifier set by another > > generator, such that the value may change with each iteration. This may > > continue recursively, until at some level we give a parameter a simple > > value. > > > > That's all working, but I also want it to be interactive. Each thread > > opens a terminal where new options can be entered, but so far it only >>works, as I mentioned, for changing the values in a top-level mutable >>object. > > I might first suggest this, although I have some caveats to add: > > def genfilter(evaluator, **param_sources): > while True: > params = {} > for param, gen in param_sources.iteritems(): > params[param] = gen.next() > yield evaluator(**params) > > You can then do things like: > >>> def concat(in1, in2): > >>> return str(in1)+"|"+str(in2) > >>> > >>> a = (i for i in range(1,5)) # generator based on a list > >>> b = (2*i for i in xrange(1,5)) # 'pure' generator > >>> c = genfilter(concat, in1=a, in2=b) [...] > or, more relevant to your original question regarding modifying things > > mid-stream: > >>> class Mult(): > >>> def __init__(self, multiplier): > >>> self.mulitplier = multiplier > >>> > >>> def multi(self, val): > >>> return val*self.multiplier > >>> > >>> m = Mult(2) > >>> a = (i for i in range(1,10)) > >>> b = (i for i in range(1,10)) > >>> c = genfilter(m.multi, val=b) > >>> d = genfilter(concat, in1=a, in2=c) > >>> d.next() [...] > But a real problem with this whole strategy is that a generator's > next() function is called every time it is evaluated. If the > relationship between your various generators forms a rooted tree, > that's not a problem, but I would think the relationships form a > directed acyclic graph, and in that case, you end up 'double > incrementing' nodes in a way you don't want: [...] > To solve that problem, you need a somewhat more complex solution: a > class that ensures that each previous stage is only invoked once per > 'pass'. I've got an idea for that, if that is of interest. Going for the record for pregnant pauses, I've taken on board the replies to my post (from Nov 12!), for which I thank you, and have come up with a solution. A simplified version follows. Chas's mention of trees made me realise that my program _is_ actually a tree of iterators, with each node receiving arguments from its children, so I made this class: class IterNode(object): """Iterator wrapper to give access to arguments to allow recursive updating""" def __init__(self, iterobj, arg): """Takes an iterator class or generator function, and its single arg""" self.arg = arg self.iterobj = iterobj self.iterator = iterobj(arg) def __iter__(self): return self def next(self): return self.iterator.next() def __eq__(self, other): return self.iterobj == other.iterobj and self.arg == other.arg def __ne__(self, other): return not self == other def deepdate(self, other): """Deep-update a nested IterNode""" if self != other: arg1, arg2 = self.arg, other.arg if arg1 != arg2: if isinstance(arg1, dict) and isinstance(arg2, dict): for k in arg1.copy().iterkeys(): if k not in arg2: del arg1[k] for k, v in arg2.iteritems(): if k in arg1: arg1[k].deepdate(v) else: arg1[k] = v else: self.__init__(other.iterobj, other.arg) ...And two custom iterator classes: for the root of the tree, the PhraseMaker iterator class is the only part really specific to music, in that it combines sequences from iterators into representations of musical phrases, assigning them to pitch, duration, volume etc.: class PhraseMaker(object): def __init__(self, iterdict): self.iterdict = iterdict self.iterator = self.phriterate() def __iter__(self): return self def next(self): return self.iterator.next() ##Omitting for brevity methods to combine ##sequences into musical phrases def phriterate(self): "Generate phrases" while True: phrase = [] for k, v in self.iterdict.iteritems(): getattr(self, k)(phrase, v.next()) yield phrase and for the branches, "SeqGen" is a fairly generic iterator which takes any sequence generators, and filters and modifies their output according to simple functions, whose arguments come from iterators themselves, like this: class SeqGen(object): def __init__(self, iterdict): self.iterdict = iterdict self.iterator = self.squiterate() def next(self): return self.iterator.next() def __iter__(self): return self def squiterate(self): generators = self.iterdict.pop('generator') genargs = self.iterdict.pop('genargs') for gen in generators: #Where "gens" is a module containing sequence generators: generator = getattr(gens, gen)(genargs.next()) current_values = [(k, v.next()) for k, v in self.iterdict.iteritems()] for seq in generator: for k, v in current_values: #Where "seqmods" is a module containing functions #which test or modify a sequence: if getattr(seqmods, k)(seq, v) is False: #Test for False because in-place modifiers return None break else: current_values = [(k, v.next()) for k, v in self.iterdict.iteritems()] yield seq The leaves of the tree are IterNodes whose arg is a list and which use this simple generator: def cycle(iterable): while True: for i in iterable: yield i I can build a tree of IterNodes from a nested dictionary like this: def itertree(dic, iterator=PhraseMaker): for k, v in dic.iteritems() : if isinstance(v, dict): dic[k] = itertree(v, SeqGen) else: dic[k] = IterNode(cycle, v) return IterNode(iterator, dic) d = {'a':[1,2,3], 'b':{'a':[4,5,6]}, 'c':{'a':{'a':[7,8,9], 'b':{'c':[10]}}}} itnod = itertree(d) and update it at any time, even during iteration, like this: new_d = {'a':[1,2,3], 'b':{'a':[4,5,6]}, 'c':{'a':{ 'b':[4]}}, 'd':{}} new_itnod = itertree(new_d) itnod.deepdate(new_itnod) (In real life the dictionary keys are the names of attributes of PhraseMaker, gens, or seqmods.) The problem Chas mentioned of consuming next() multiple times still applies to a tree because if a sequence fails a test on a particular value, we want to stay on that value till the test succeeds - which is why the SeqGen class has the "current_values" list in the squiterate method. (The real version actually has to keep count for each key in iterdict.) I would of course be interested in any other ideas. It works and is relatively easy to understand, but I still have feeling that I'm breathing my own exhaust and this is too complex... Regards, John From ahsanbagwan at gmail.com Fri Jan 21 05:39:48 2011 From: ahsanbagwan at gmail.com (sl33k_) Date: Fri, 21 Jan 2011 02:39:48 -0800 (PST) Subject: Namespaces Message-ID: What is namespace? And what is built-in namespace? From askutt at gmail.com Fri Jan 21 06:20:59 2011 From: askutt at gmail.com (Adam Skutt) Date: Fri, 21 Jan 2011 03:20:59 -0800 (PST) Subject: examples of realistic multiprocessing usage? References: <2011011611053732597-tomfsessile@gmailcom> Message-ID: <4bff00a3-09e8-43f4-a62d-5e12838b217e@n10g2000yqd.googlegroups.com> On Jan 20, 11:51?pm, Albert van der Horst wrote: > This is what some people want you to believe. Arm twisting by > GPL-ers when you borrow their ideas? That is really unheard of. Doesn't matter, you're still legally liable if your work is found to be derivative and lacking a fair use defense. It's not borrowing "ideas" that's problematic, it's proving that's all you did. For those of us with legal departments, we have no choice: if they don't believe we can prove our case, we're not using the code, period. The risk simply isn't worth it. > GPL-ers are not keen on getting the most monetary award by > setting lawyers on you and go to court only reluctantly to > enforce the license. And? Monetary award is hardly the only issue. > Stealing code means just that, verbatim copies. When you read this > carefully, you can see that reimplementing the stolen code is > an option. Exactly what you say is legally impossible. No, in the United States it means anything that constitutes a derivative work, since derivative works of GPL-licensed works must be released under the GPL. Merely copying ideas does not make one a derivative work, but one also must be prepared to show that's all that happened. As such, it would have to be a substantially different implementation, generally with some sort of added or useful value. Proving that can be difficult and may very well depend on what court you land in. > > So pardon me, but not even looking at code you might learn from > is pretty hysteric. Not at all. Separating ideas from implementation can be difficult, and convincing a judge of that vastly more so. It's a legitimate concern, and people who intend to ship proprietary software should definitely resort to GPL-licensed software last when looking for inspiration. Adam From funthyme at gmail.com Fri Jan 21 06:43:31 2011 From: funthyme at gmail.com (John Pinner) Date: Fri, 21 Jan 2011 03:43:31 -0800 (PST) Subject: getdefaultencoding - how to change this? References: <4d38472d$0$14250$ba620e4c@news.skynet.be> Message-ID: On Jan 20, 4:46?pm, Robert Kern wrote: > > Instead, you want to use an encoding declaration in each file: > > http://docs.python.org/reference/lexical_analysis.html#encoding-decla... All that this does is tell the interpreter how the source file is encoded, it does not affect default encodings etc. John -- From andreas.tawn at ubisoft.com Fri Jan 21 06:47:04 2011 From: andreas.tawn at ubisoft.com (Andreas Tawn) Date: Fri, 21 Jan 2011 12:47:04 +0100 Subject: Namespaces In-Reply-To: References: Message-ID: <654D9D97DA51AD479973BC2D5578603C0B9C4D8795@PDC-MAIL-CMS01.ubisoft.org> > What is namespace? And what is built-in namespace? > -- > http://mail.python.org/mailman/listinfo/python-list http://lmgtfy.com/?q=python+namespace From alex at moreati.org.uk Fri Jan 21 06:55:39 2011 From: alex at moreati.org.uk (Alex Willmer) Date: Fri, 21 Jan 2011 03:55:39 -0800 (PST) Subject: Namespaces References: Message-ID: On Jan 21, 10:39?am, sl33k_ wrote: > What is namespace? And what is built-in namespace? A namespace is a container for names, like a directory is a container for files. Names are the labels we use to refer to python objects (e.g. int, bool, sys), and each Python object - particularly modules and classes - provides separate namespace. The idea of a namespace is to isolate names from one another - so that if you import module_a and module_b and both have an object called foo then module_a.foo doesn't interfere with module_b.foo. The built-in namespace is where the core objects of Python are named. When you refer to an object such as int Python first searches the local scope (was it defined in the current function/method, i.e. the output of locals()), then module scope (was it defined in the current .py file, i.e. output of globals()) and finally in the object __builtins__. Hope that makes sense. I realised as I typed this my understanding of Python namespaces is not as 100% tight as I thought. Alex From funthyme at gmail.com Fri Jan 21 07:15:30 2011 From: funthyme at gmail.com (John Pinner) Date: Fri, 21 Jan 2011 04:15:30 -0800 (PST) Subject: getdefaultencoding - how to change this? References: <4d38472d$0$14250$ba620e4c@news.skynet.be> Message-ID: To answer the OP's original question: On Jan 20, 2:31?pm, Helmut Jarausch wrote: > Hi, > I've searched the net but didn't find the information I need. > Using Python-2.7.1, I know, I can't modify defaultencoding at run time. I think you can. There is a function setdefaultencoding in the sys module, but at startup when site.py runs the function gets deleted after it has been used, because as others have said it is a *bad* idea to change the default encoding (although I *think* changing it to utf8 should cause no harm). so if you reload sys, setdefaultencoding() becomes available again, and you can use it, with all the caveats mentioned: import sys reload(sys) sys.setdefaultencoding( 'utf-8' ) This works on a Unicode build of Python only. As has been said, you can change the default encoding in site.py, but this means that it gets changed for everyone/every Python program on the system, using setdefaultencoding() as above only changes it for the running program, and hopefully the change will have been made by someone who knows what they are doing and is aware of the possible consequences. > Python even ignores > export PYTHONIOENCODING=ISO8859-1 > > locale.getdefaultlocale()[1] > returns > 'ISO8859-1' > > still sys.stdout is using the ascii codec. > How can I recompile Python (itself) to change this to iso8859-1 ? You don't need to, nor should you. > (My favourite editor cannot be told to use unicode.) Maybe you need a new editor. scite works well with Python, and is cross-platform. John -- From joncle at googlemail.com Fri Jan 21 07:20:26 2011 From: joncle at googlemail.com (Jon Clements) Date: Fri, 21 Jan 2011 04:20:26 -0800 (PST) Subject: statement level resumable exception References: <87oc7b9wkm.fsf@gmail.com> <62658b12-34b7-4ed5-9ecd-5182b53f7b31@t35g2000yqj.googlegroups.com> <87k4hz9uiu.fsf@gmail.com> <87fwsmaelt.fsf@gmail.com> <52e20ce1-0e0c-4817-a61d-91437291883a@i18g2000yqn.googlegroups.com> Message-ID: <834fd020-f70a-44bc-8faf-f4f34e1ae73b@fo10g2000vbb.googlegroups.com> On Jan 21, 8:41?am, ilejn wrote: > Arnaud, > > it looks like a solution. > Perhaps it is better than plain try/accept and than proxy class with > __getattr__. > It is not for free, e.g. because syntax check such as parentheses > matching is lazy too, though looks > very interesting. > > Thanks a lot! > > On Jan 21, 10:41?am, Arnaud Delobelle wrote: > > > > > ilejn writes: > > > Arnaud, > > > > these lists are not generated. > > > > Actually these lists are a sort of interpreted programs and contain > > > some application logic. > > > > Here is an example > > > ? ? ? ? [ > > > ? ? ? ? [PUSH, [get_modified_interface, req]], > > > ? ? ? ? [TIMEOUT, 3], > > > ? ? ? ? [PULL, [out_interface, '']], > > > ? ? ? ? [PULL, [err_interface, '']], > > > ? ? ? ? [PULL, [out_mined_interface, req]], > > > ? ? ? ? ] > > > > If any interface name is unknown the list must not be invoked (in > > > other words, f function > > > call with this list must be somehow bypassed). > > > > Thanks. > > > You could still use the same idea and delay evaluation of the lists. E.g. > > > prg1 = """[ > > ? ? [PUSH, [get_modified_interface, req]], > > ? ? [TIMEOUT, 3], > > ? ? ... > > """ > > > prg2 = """[ > > ? ? [OPCODE, [arguments, blah]], > > ? ? ... > > """ > > > ... > > > prgN = """...""" > > > for prg in prg1, prg2, ..., prgN: > > ? ? try: > > ? ? ? ? prg = eval(prg) > > ? ? except NameError: > > ? ? ? ? continue > > ? ? f(prg) > > > -- > > Arnaud > > Best regards, > Ilja Golshtein Not sure if a good idea or not, but: I would probably use pyparsing and create a small grammar to parse your list data. If parsing an entry with an unknown interface, then skip to the next list entry. If the entire list parses, then you can execute your function calls. hth Jon. From davea at ieee.org Fri Jan 21 08:01:59 2011 From: davea at ieee.org (Dave Angel) Date: Fri, 21 Jan 2011 08:01:59 -0500 Subject: Namespaces In-Reply-To: References: Message-ID: <4D3983C7.70600@ieee.org> On 01/-10/-28163 02:59 PM, sl33k_ wrote: > What is namespace? And what is built-in namespace? > A namespace is a mapping from names to objects. When you write a statement xyz = 42 the system looks up "xyz" in some namespace and associates that "variable" with the object int(42). The key is that there are multiple namespaces defined. The built-in namespace (containing things such as open, help, next, input, and lots more) is always available. The global namespace, for symbols defined globally in the current module, is another namespace. If you're inside a function, there's a separate namespace for symbols defined in there (and they behave just a little differently). And you can explicitly specify a namespace with a prefix, which is one way you access symbols in another module, or within an instance of an object. Perhaps look at: http://bytebaker.com/2008/07/30/python-namespaces/ though I haven't personally studied the whole thing for accuracy. One other thing: dir() can be used to show you the names in a particular namespace. For example, dir(__builtins__) shows you the built-in namespace, while dir() shows you the global one. And after an import, dir() can show you those names: import os dir(os) DaveA From sparks.m at gmail.com Fri Jan 21 08:26:47 2011 From: sparks.m at gmail.com (Michael Sparks) Date: Fri, 21 Jan 2011 05:26:47 -0800 (PST) Subject: Namespaces References: Message-ID: <2775e396-9a3b-4a06-acff-be249448b840@w29g2000vba.googlegroups.com> On Jan 21, 10:39?am, sl33k_ wrote: > What is namespace? And what is built-in namespace? tl;dr - Namespaces are sets that contain names. You can think of namespaces as being /like/ boxes. A namespace is therefore an organisational tool, forming a similar purpose to human names & surnames - to identify the right value. (eg "Sparks" is a namespace, "Smith" is another.) The built-in namespace contains all the values which python understands which you _don't_ define that don't have dots in. (eg "int", "True", "None") Looking at this in more detail... We can create a simple namespace using an empty class Family: class Family(object): pass Sparks = Family() Smith = Family() Now clearly Sparks is a name, and Smith is a name. Those names are defined to be two different Family objects/values. (I'm going to deliberately sidestep which namespace "Sparks" and "Smith" sit inside for the moment.) The neat trick is that namespaces are values themselves. In fact the really neat trick is that every value contains a namespace. How do I define a name inside a namespace? Suppose I want to define the name "Michael" as a person inside the Sparks namespace, I can do that like this: class Person(object): pass Sparks.Michael = Person() I can then define the name Michael inside the Smith namespace as well: Smith.Michael = Person() As you can see, I can now refer to two different values with the same name - "Michael". This may look a little like sophistry, so let's suppose the Person we're referring to as Sparks.Michael has an height of 180cm, and a favourite colour of green, and Smith.Michael has a height of 120cm and a favourite colour of 120. In both cases, it makes sense for use to name the height value "height", and name the favourite colour value as "favourite_colour". If we did this though ... height = 180 favourite_colour = "green" height = 120 favourite_colour = "purple" .. python would only remember the most recent value of each. By recognising that every value is a namespace too, we can define those names inside their namespace. Sparks.Michael.height = 180 Sparks.Michael.favourite_colour = "green" Smith.Michael.height = 120 Smith.Michael.favourite_colour = "purple" Now the question that might arise is this: Given I can rewrite the examples above like this... class Family(object): pass class Person(object): pass Sparks = Family() Smith = Family() Sparks_Michael = Person() Smith_Michael = Person() Sparks_Michael_height = 180 Sparks_Michael_favourite_colour = "green" Smith_Michael_height = 120 Smith_Michael_favourite_colour = "purple" ... how is this different from before? Well in this latter version we're not using namespaces to organise our names. This means that if I want to write a function that prints a person's height and favourite colour, it has to look like this: def describe_person(height, favourite_colour): print "The person is", height, "cm tall" print "Their favourite colour is", favourite_colour Then if I want to use this, I have to do this: describe_person(Sparks_Michael_height, Sparks_Michael_favourite_colour) describe_person(Smith_Michael_height, Smith_Michael_favourite_colour) That's quite messy. What does it look like for the namespace version? def describe_person(somePerson): print "The person is", somePerson.height, "cm tall" print "Their favourite colour is", somePerson.favourite_colour describe_person(Sparks.Michael) describe_person(Smith.Michael) describe_person now expects to recieve a single value. Inside that value's namespace it expects to find the values "height" and "colour", and just uses them. As a result, when we use it, rather than passing in each low level attribute (height, colour) we can work at a more convenient level of working with People, and the higher level code becomes clearer. Not only this, if we decide to add an another name to both People ... Sparks.Michael.Pythonista = True Sparks.Michael.Pythonista = False ... we can change describe_person to use this: def describe_person(somePerson): print "The person is", somePerson.height, "cm tall" print "Their favourite colour is", somePerson.favourite_colour if somePerson.Pythonista: print "And they like python!" else: print "They don't know python" Then our code for describing them remains the same: describe_person(Sparks.Michael) describe_person(Smith.Michael) So far so good I hope. Namespaces can contain code as well as basic values. This means we can have ... tiggles = Cat() rover = Dog() jemima = Duck() tiggles.name = "tiggles" rover.name = "rover" jemima.name = "jemima" ... and we can get them all to have some behaviour called "make_noise" defined by the call to Cat(), Dog(), Duck() inside their namespace, which allows us to write: >>> tiggles.make_noise() Meow! >>> rover.make_noise() Woof! >>> jemima.make_noise() Quack! And again that means we can do things like: def describe_animal(animal): print animal.name, "goes", animal.make_noise() And use it like this: >>> describe_animal(tiggles) tiggles goes Meow! >>> describe_animal(rover) rover goes Woof! >>> describe_animal(jemima) jemima goes Quack! In addition to defining namespaces though with classes, I can define them using files. Suppose I have two files: humans.py animals.py And I have another one which is my main program: main.py Furthermore suppose that we decide to put the classes "Family", and "Person" into humans.py We also decide to put "Cat", "Dog" and "Duck into animals.py Inside main.py we need someone of pulling in these names and values in such a way that we can pull them in cleanly, which is where python's "import" function comes in. If we use it like this: import humans import animals This creates two namespaces - humans and animals. The namespace "humans" contains "Family" and "Person", mirroring the fact the functionality is defined in the file humans.py. The namespace "animals" contains "Cat", "Dog" and "Duck", mirroring the fact the functionality is defined in the file animals.py. So our code using this would look like this: Sparks = humans.Family() Smith = humans.Family() Sparks.Michael = humans.Person() Smith.Michael = humans.Person() tiggles = animals.Cat() rover = animals.Dog() jemima = animals.Duck() This can be a bit clunky if you're doing it a lot, so let's revisit where I said "I'm going to deliberately sidestep which namespace "Sparks" and "Smith" sit inside for the moment.". I mentioned that names like: - object - list - int - True .. ie names that you can use without defining are defined inside a namespace built-in to python - which is referred to as the built-in namespace. In particular, if I type: >>> object >>> int >>> True True Those names are defined from within the built-in namespace. Where are names like ... Sparks Smith humans animals ... being defined ? Well,it turns out that python (like many other languages) has global values (amongst others), and that global values are accessed via the global namespace: >>> import animals >>> import humans >>> Sparks = humans.Family() >>> Smith = humans.Family() >>> globals() {'animals': , 'humans': , 'Smith': , 'Sparks': , '__builtins__': , '__package__': None, '__name__': '__main__', '__doc__': None} As a result every name sits inside some namespace of some kind. A namespace is used for organising things, and so namespaces can themselves be names and treated as values. Inside a namespace a name can only refer to one value. (Though that value can be a list/tuple/ dict of course, or a piece of behaviour - such as a method or function) Python modules form namespaces. Python classes form namespaces. Python objects form namespaces. In the case of import this also explains the fact there are two forms of import. This version: import humans import animals Simply defines two names, based on the filename containing interesting functionality, which are namespaces containing other names and is used as above. The other looks like this: from humans import Family, Person from animals import Cat, Dog, Duck And still pulls in the same two files, but says "I'm only interested in these 5 things, and please use them to define the names Family, Person, Cat, Dog, Duck" in my global namespace so I can use it like this: Sparks = Family() Smith = Family() Sparks.Michael = Person() Smith.Michael = Person() tiggles = Cat() rover = Dog() jemima = Duck() Which is pretty useful. So what are they? "Namespaces are one honking great idea -- let's do more of those!" :-) Michael. From awilliam at whitemice.org Fri Jan 21 08:32:47 2011 From: awilliam at whitemice.org (Adam Tauno Williams) Date: Fri, 21 Jan 2011 08:32:47 -0500 Subject: examples of realistic multiprocessing usage? In-Reply-To: <4bff00a3-09e8-43f4-a62d-5e12838b217e@n10g2000yqd.googlegroups.com> References: <2011011611053732597-tomfsessile@gmailcom> <4bff00a3-09e8-43f4-a62d-5e12838b217e@n10g2000yqd.googlegroups.com> Message-ID: <1295616767.4129.5.camel@linux-yu4c.site> On Fri, 2011-01-21 at 03:20 -0800, Adam Skutt wrote: > On Jan 20, 11:51 pm, Albert van der Horst > wrote: > > This is what some people want you to believe. Arm twisting by > > GPL-ers when you borrow their ideas? That is really unheard of. > Doesn't matter, you're still legally liable if your work is found to > be derivative and lacking a fair use defense. It's not borrowing > "ideas" that's problematic, it's proving that's all you did. For > those of us with legal departments, we have no choice: if they don't > believe we can prove our case, we're not using the code, period. The > risk simply isn't worth it. +1, exactly. "reimplementation" is the defense of GPL is very often treated as *trivial*. Changing function names and variable names and indenting style is not "reimplementation". Reimplementation can be very difficult, time consuming, and error-prone. Anyway, legally define: "reimplementation". Have fun. > > So pardon me, but not even looking at code you might learn from > > is pretty hysteric. > Not at all. Separating ideas from implementation can be difficult, Honestly, IMNSHO, it is borders on *impossible*. Even statistical analysis of written prose or off-hand speech will reveal how pathologically derivative humans are in their use of language. And as that language gets forcibly more structured as in programming or technical documentation even more so. > and convincing a judge of that vastly more so. It's a legitimate > concern, and people who intend to ship proprietary software should > definitely resort to GPL-licensed software last when looking for > inspiration. From razajaffrey77 at gmail.com Fri Jan 21 08:38:09 2011 From: razajaffrey77 at gmail.com (RizlaJ) Date: Fri, 21 Jan 2011 05:38:09 -0800 (PST) Subject: Problems with FTP Message-ID: <58a2ada5-69d6-421b-a0c9-50b34ab8960a@v26g2000yqf.googlegroups.com> Hi all, I'm very new to python. I'm using Python 2.7, in a corporate environment, therefore am behind a proxy server, firewalls etc. I can ftp to a barclays capital ftp site ok in internet explorer, but I can't get the FTP from ftplib to work for me. Can someone please help! I've tried the following commands from my home personal machine (thefore no proxies etc) and the commands work fine and I'm able to enter my username and password and login successfuly - however in teh corporate environment I can't. I'm wondering if this is soemthing to do with security permissioning at work etc? At the shell I'm typing:- >>> from ftplib import FTP >>> ftp = FTP('indexftp.barcap.com') and get the following error: Traceback (most recent call last): File "", line 1, in ftp = FTP('indexftp.barcap.com') File "C:\Python27\lib\ftplib.py", line 117, in __init__ self.connect(host) File "C:\Python27\lib\ftplib.py", line 132, in connect self.sock = socket.create_connection((self.host, self.port), self.timeout) File "C:\Python27\lib\socket.py", line 571, in create_connection raise err error: [Errno 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond I wasn't expecting this error message next, i was expecting to be able to log on using the followign command :- >> ftp.login("username","password") Please help! thanks! From rde at audaxis.com Fri Jan 21 09:14:39 2011 From: rde at audaxis.com (Romaric DEFAUX) Date: Fri, 21 Jan 2011 15:14:39 +0100 Subject: Need advices for mysqldb connection best practice In-Reply-To: References: <4D37FA8C.9060108@audaxis.com> Message-ID: <4D3994CF.1020101@audaxis.com> Le 20/01/2011 18:58, Dennis Lee Bieber a ?crit : > On Thu, 20 Jan 2011 10:04:12 +0100, Romaric DEFAUX > declaimed the following in gmane.comp.python.general: > > >> So , I thought about some solutions : >> - restarting the server every sometimes (but it's the worst solution in >> my mind) >> - creating a connection (not only cursor) at each client connection (but >> I'm afraid it overloads the mysql server) >> - trying to find where I did a mistake, and correct the bug (that why >> I'm doing by writing this list :), or send me a link that could help me >> (before writing I googled for one hour and found nothing interresting in >> my case...) >> > Do you have multiple clients active at the same time -- using a > common code/process... (does each client connection start a thread)? > >>>> import MySQLdb >>>> MySQLdb.threadsafety > 1 > > From PEP 249: > """ > threadsafety > > Integer constant stating the level of thread safety the > interface supports. Possible values are: > > 0 Threads may not share the module. > 1 Threads may share the module, but not connections. > 2 Threads may share the module and connections. > 3 Threads may share the module, connections and > cursors. > > Sharing in the above context means that two threads may > use a resource without wrapping it using a mutex semaphore > to implement resource locking. Note that you cannot always > make external resources thread safe by managing access > using a mutex: the resource may rely on global variables > or other external sources that are beyond your control. > > """ > > > Also: > >> con.cursor().execute('SET AUTOCOMMIT=1') > Using .execute() for that may set the MySQL side for autocommit, but > the MySQLdb adapter will likely still be in the db-api specified mode of > NO autocommit. There is a low-level (that is, it is part of the DLL/SO > and not Python source) function for connections: > > con.autocommit(True) > > (the db-api creates connections and invokes con.autocommit(False)) > > This function should both set MySQL AND the db-api adapter for > autocommit operations. > > Personally -- it is better when running multiple clients to ensure > that each client is running as a complete transaction. That means the > each get their own connection and cursor(s), and manually do > con.commit() at the end of the transaction; if any errors happen, one > does a con.rollback() and can inform the user that the sequence failed. Thanks Dennis for your reply. I don't use thread. The reason is : - the time of connection between client and server is really quick, around one second - I've only around 120 clients, updating once an hour, so percent of collision is really low, and client can wait few seconds for the connection Now, I create a new db_connection at each client connection and it seems stable (no crash since yesterday vs 1 crash every 2 hours before). I understand why it's better to commit manually, but if I want to do that I have to rewrite lots of things, and it's not my priority at this time, because it's stable enough. So I kept the con.autocommit(True). But I keep your advices in an "improvements list" :) I know if number of clients increase a lot, I can search in these directions : - using thread - commiting manually to avoid inconsistents datas - using a pool of connections to reduce MySQL load Thanks again Romaric -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/pkcs7-signature Size: 5361 bytes Desc: S/MIME Cryptographic Signature URL: From neilc at norwich.edu Fri Jan 21 09:21:46 2011 From: neilc at norwich.edu (Neil Cerutti) Date: 21 Jan 2011 14:21:46 GMT Subject: Dealing with xml namespaces with ElementTree Message-ID: <8ptj3qF437U1@mid.individual.net> I have to parse many xml documents that senselessly(?) specify a single namespace for the whole document. After a couple of years, my approach has boiled down to the following three little helpers, for use with ElementTree: def insert_namespace(xpath): # Enable *simple* xpath searches by inserting the fscking namespace. return '/'.join('{{{}}}{}'.format(XMLNS, n) for n in xpath.split('/')) def find(et, xpath): return et.find(insert_namespace(xpath)) def findall(et, xpath): return et.findall(insert_namespace(xpath)) Instead of writing, e.g., et.find('{{0}}ab/{{0}}cd'.format(XMLNS), et al, I can use find(et, 'ab/cd'). Is there a better ElemenTree based approach I'm missing out on? And on the other hand, am I circumventing something important, or inviting bad limitations of some kind? -- Neil Cerutti From arndt.roger at addcom.de Fri Jan 21 09:38:09 2011 From: arndt.roger at addcom.de (Arndt Roger Schneider) Date: Fri, 21 Jan 2011 15:38:09 +0100 Subject: Screen readers for Tkinter (was Re: Tkinter: The good, the bad, and the ugly! References: Message-ID: Littlefield, Tyler schrieb: > >And of course, it should also offer support for Windows, since most of > the computer users use Windows, especially those who need accessibility > features. > uh. no, and no. > Plenty of those utilizing screen readers are using macs nowadays, as > well as vinux or some derivitave there of. > Do you have first hand experience with it under AQUA? I think Tk-aqua (also 8.6) should work out-of-the-box with brail-lines, text-to-speech and such; the older carbon built however wont... -roger From longqian9509 at gmail.com Fri Jan 21 10:29:04 2011 From: longqian9509 at gmail.com (long) Date: Fri, 21 Jan 2011 07:29:04 -0800 (PST) Subject: is it a bug in exec? References: <0629ea10-b667-4630-a99f-78168a3e0979@u6g2000yqk.googlegroups.com> <4d39407c$0$29983$c3e8da3$5496439d@news.astraweb.com> Message-ID: <90b84747-5057-44c0-ae81-42fbb277a817@t35g2000yqj.googlegroups.com> Of cause your code runs well. But if you remove the "global foo" in main(), it will fail. And it will succeed again if you call exec(t1) directly. I think this behavior is strange. Even I pass a shadow copy of globals and locals to exec, it still fails. So perhaps there is a basic difference between exec(t1,dg,dl) and exec(t1,globals(),locals()). What do you think about it? Thanks. On Jan 21, 2:14?am, Steven D'Aprano wrote: > On Thu, 20 Jan 2011 20:52:15 -0800, longqian9... at gmail.com wrote: > > In pyhton 3.1, I found the following code will succeed with argument 1 > > to 4 and fail with argument 5 to 9. It is really strange to me. I > > suspect it may be a buy in exec() function. Does anyone have some idea > > about it? Thanks. > > What makes you think it's a bug? Is there anything in the documentation > of exec that suggests to you that some other behaviour should occur? What > version of Python are you using? > > Without knowing what behaviour you expect and what behaviour you see, how > are we supposed to know if you've found a bug or not? > > I suggest you fire up the interactive interpreter and try this: > > t1 = """ > class foo: > ? ? def fun(): > ? ? ? ? print('foo') > > def main(): > ? ? global foo > ? ? foo.fun() > > main() > """ > > dg = {} > dl = {} > > exec(t1, dg, dl) > > then inspect the values of dg and dl and see if it helps. If not, write > back with what you expect to happen, and what you see instead. > > -- > Steven From rolf.oltmans at gmail.com Fri Jan 21 10:39:26 2011 From: rolf.oltmans at gmail.com (Oltmans) Date: Fri, 21 Jan 2011 07:39:26 -0800 (PST) Subject: Line breaks in list causing a small formatting problem while joining the list Message-ID: Hi Python gurus, hope you're doing well. I've a small problem. When I run the following code ___________________________________________________ >>> names = ['oltmans','abramhovic','\n','sal','lee'] >>> print '| ' + ' | '.join(names) | oltmans | abramhovic | | sal | lee ___________________________________________________ I get the output like above. However, I want it to output like below | oltmans | abramhovic | | sal | lee That is, there shouldn't be a space in the beginning of second line. The list can of course contain more than 5 elements. Any ideas? I will appreciate any hint. Thanks in advance. From __peter__ at web.de Fri Jan 21 11:25:35 2011 From: __peter__ at web.de (Peter Otten) Date: Fri, 21 Jan 2011 17:25:35 +0100 Subject: Line breaks in list causing a small formatting problem while joining the list References: Message-ID: Oltmans wrote: > Hi Python gurus, hope you're doing well. I've a small problem. > > When I run the following code > ___________________________________________________ >>>> names = ['oltmans','abramhovic','\n','sal','lee'] >>>> print '| ' + ' | '.join(names) > | oltmans | abramhovic | > | sal | lee > ___________________________________________________ > > I get the output like above. However, I want it to output like below > > | oltmans | abramhovic | > | sal | lee > > > That is, there shouldn't be a space in the beginning of second line. > The list can of course contain more than 5 elements. Any ideas? I will > appreciate any hint. Thanks in advance. >>> print "|%s|" % "|".join(n if n == "\n" else " %s " % n for n in names) | oltmans | abramhovic | | sal | lee | From robert.kern at gmail.com Fri Jan 21 11:31:51 2011 From: robert.kern at gmail.com (Robert Kern) Date: Fri, 21 Jan 2011 10:31:51 -0600 Subject: getdefaultencoding - how to change this? In-Reply-To: References: <4d38472d$0$14250$ba620e4c@news.skynet.be> Message-ID: On 1/21/11 5:43 AM, John Pinner wrote: > On Jan 20, 4:46 pm, Robert Kern wrote: > > > >> >> Instead, you want to use an encoding declaration in each file: >> >> http://docs.python.org/reference/lexical_analysis.html#encoding-decla... > > All that this does is tell the interpreter how the source file is > encoded, it does not affect default encodings etc. Yes! In the part of the OP's message that you snipped "(My favourite editor cannot be told to use unicode.)", that seemed to be part of his actual problem, not the default encoding. -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco From __peter__ at web.de Fri Jan 21 12:00:32 2011 From: __peter__ at web.de (Peter Otten) Date: Fri, 21 Jan 2011 18:00:32 +0100 Subject: is it a bug in exec? References: <0629ea10-b667-4630-a99f-78168a3e0979@u6g2000yqk.googlegroups.com> Message-ID: longqian9509 at gmail.com wrote: > In pyhton 3.1, I found the following code will succeed with argument 1 > to 4 and fail with argument 5 to 9. It is really strange to me. I > suspect it may be a buy in exec() function. Does anyone have some idea > about it? Thanks. > > > t1=""" > class foo: > def fun(): > print('foo') > def main(): > global foo > foo.fun() > main() > """ > t2=""" > class foo: > def fun(): > print('foo') > def main(): > foo.fun() > main() > """ > > import sys > import copy > if sys.argv[1]=='1': > exec(t1) > elif sys.argv[1]=='2': > exec(t2) > elif sys.argv[1]=='3': > exec(t1,{},{}) > elif sys.argv[1]=='4': > exec(t2,globals(),locals()) > elif sys.argv[1]=='5': > exec(t2,{},{}) > elif sys.argv[1]=='6': > exec(t2,globals(),{}) > elif sys.argv[1]=='7': > exec(t2,{},locals()) > elif sys.argv[1]=='8': > exec(t2,copy.copy(globals()),locals()) > elif sys.argv[1]=='9': > exec(t2,globals(),copy.copy(locals())) There are only two cases that matter: identical local/global namespaces and distinct local/global namespaces: >>> code = """\ ... x = 42 # put x into the local namespace ... def f(): ... print(x) # look up x in the global namespace ... f() ... """ >>> exec(code, {}, {}) Traceback (most recent call last): File "", line 1, in File "", line 4, in File "", line 3, in f NameError: global name 'x' is not defined >>> ns = {} >>> exec(code, ns, ns) 42 Also note that >>> globals() is locals() True on the module level. Peter From thomas at jollybox.de Fri Jan 21 12:05:51 2011 From: thomas at jollybox.de (Thomas Jollans) Date: Fri, 21 Jan 2011 18:05:51 +0100 Subject: Problems with FTP In-Reply-To: <58a2ada5-69d6-421b-a0c9-50b34ab8960a@v26g2000yqf.googlegroups.com> References: <58a2ada5-69d6-421b-a0c9-50b34ab8960a@v26g2000yqf.googlegroups.com> Message-ID: <201101211805.52455.thomas@jollybox.de> On Friday 21 January 2011, it occurred to RizlaJ to exclaim: > Hi all, I'm very new to python. I'm using Python 2.7, in a corporate > environment, therefore am behind a proxy server, firewalls etc. > > I can ftp to a barclays capital ftp site ok in internet explorer, but > I can't get the FTP from ftplib to work for me. Can someone please > help! It sounds very much like, as you said, you're behind a proxy, and have to use that proxy to connect to the FTP server. If you don't know the proxy settings, you might be able to find them in the IE configuration, or ask the local sysadmin. http://stackoverflow.com/questions/1293518/proxies-in-python-ftp-application It looks like you will have to ftp to the proxy server. Depending on the application, you might be able to use urllib2 instead. Thomas > > I've tried the following commands from my home personal machine > (thefore no proxies etc) and the commands work fine and I'm able to > enter my username and password and login successfuly - however in teh > corporate environment I can't. I'm wondering if this is soemthing to > do with security permissioning at work etc? > > At the shell I'm typing:- > > >>> from ftplib import FTP > >>> ftp = FTP('indexftp.barcap.com') > > and get the following error: > Traceback (most recent call last): > File "", line 1, in > ftp = FTP('indexftp.barcap.com') > File "C:\Python27\lib\ftplib.py", line 117, in __init__ > self.connect(host) > File "C:\Python27\lib\ftplib.py", line 132, in connect > self.sock = socket.create_connection((self.host, self.port), > self.timeout) > File "C:\Python27\lib\socket.py", line 571, in create_connection > raise err > error: [Errno 10060] A connection attempt failed because the connected > party did not properly respond after a period of time, or established > connection failed because connected host has failed to respond > > I wasn't expecting this error message next, i was expecting to be able > to log on using the followign command :- > > >> ftp.login("username","password") > > Please help! > > thanks! From thomas at jollybox.de Fri Jan 21 12:17:36 2011 From: thomas at jollybox.de (Thomas Jollans) Date: Fri, 21 Jan 2011 18:17:36 +0100 Subject: difference between python and matlab In-Reply-To: References: Message-ID: <201101211817.36951.thomas@jollybox.de> On Thursday 20 January 2011, it occurred to lakshmi to exclaim: > Is the programming related to image processing in python is advantageous or > else in MATLAB Tell us what you want to do, and what you know about doing this in Python and in MATLAB, if possible, ask a specific question. Then, somebody might be able to give you an educated and useful response. From rantingrick at gmail.com Fri Jan 21 12:36:42 2011 From: rantingrick at gmail.com (rantingrick) Date: Fri, 21 Jan 2011 09:36:42 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com><4d337983$0$29983$c3e8da3$5496439d@news.astraweb.com><044a5101-948d-4458-9c94-57dbb3e25f67@m35g2000vbn.googlegroups.com><4d3467bf$0$29983$c3e8da3$5496439d@news.astraweb.com><4D34B04E.8050309@web.de><4266E8D7BA204BFEA5BF66C635CE1716@octavian><4D35DCE8.5030002@web.de><4D35DD47.1070304@web.de><7A0C7934E65D4B85A584C06ADD3B6ECF@teddy>< Message-ID: <4749ad6d-ef08-4dfb-bfb7-144efed4d761@d8g2000yqf.googlegroups.com> On Jan 20, 8:34?pm, Neil Hodgson wrote: This is exactly what Aristotle meant when he said... """ Tolerance and Apathy are the last virtues of a dying society! """ Specifically no one here has the nerve to question/argue Guido when he offers such weak arguments like the "tag" argument. Can you really base the worth of any library on such a limited argument. I would bet that most people who use Tkinter ARE NOT using the canvas anyway. They are not interested in drawing simple lines and rects and just looking at them. No. They are intersted in creating GUIs with frames, buttons, labels, radiobuttons, checkbuttons, listboxes, textboxes, notebooks, comboboxes, and dialogs just to name a few. However in light of such a weak argument presented TEN YEARS AGO not one person dared to even question the BDFL. If i were Guido i would be disappointed. The very community he has built has degenerated into mindless goose stepping "yes" men. AND THAT WAS TEN YEARS AGO! Congratulations "yes men" you are the genesis of this self destruction. I think i should find a fiddle... From clp2 at rebertia.com Fri Jan 21 12:55:30 2011 From: clp2 at rebertia.com (Chris Rebert) Date: Fri, 21 Jan 2011 09:55:30 -0800 Subject: Printing RTF file under win32 In-Reply-To: <2608cc6e-a385-4a31-ab9e-f740d231bf06@k11g2000vbf.googlegroups.com> References: <2608cc6e-a385-4a31-ab9e-f740d231bf06@k11g2000vbf.googlegroups.com> Message-ID: On Fri, Jan 21, 2011 at 2:12 AM, Mark Carter wrote: > I'm using Python 2.6.5 on win32. I would like to print a batch of RTF > files on a printer. I don't want to use the win32api.ShellExecute > command because that invokes Word, and Word has been configured in a > strange way by one of our admins, making it inconvenient to use. > > What should I do? Invoke WordPad instead? http://en.wikipedia.org/wiki/WordPad Cheers, Chris From andreambu at gmail.com Fri Jan 21 13:06:04 2011 From: andreambu at gmail.com (Andrea Ambu) Date: Fri, 21 Jan 2011 19:06:04 +0100 Subject: difference between python and matlab In-Reply-To: References: Message-ID: On 20 January 2011 15:16, lakshmi wrote: > Is the programming related to image processing in python is advantageous or else in MATLAB > Matlab comes with a lot of builtins for image processing, pattern recognition and many other engineering-related things. If it's just a quick hack and you're familiar with matlab probably you'd get the job done more easily with it. But Thomas is right, it depends a lot on what you really need to do. -- Andrea From enleverLesX_XXmcX at XmclavXeauX.com.invalid Fri Jan 21 13:20:52 2011 From: enleverLesX_XXmcX at XmclavXeauX.com.invalid (Michel Claveau - MVP) Date: Fri, 21 Jan 2011 19:20:52 +0100 Subject: Printing RTF file under win32 References: <2608cc6e-a385-4a31-ab9e-f740d231bf06@k11g2000vbf.googlegroups.com> Message-ID: <4d39ce8c$0$32469$ba4acef3@reader.news.orange.fr> Hi! Try this line: "C:\Program Files\Windows NT\Accessories\wordpad.exe" /p D:\data\fil.rtf (change the path if you have a windows 64 bits) @-salutations -- Michel Claveau From python at mrabarnett.plus.com Fri Jan 21 13:54:23 2011 From: python at mrabarnett.plus.com (MRAB) Date: Fri, 21 Jan 2011 18:54:23 +0000 Subject: Line breaks in list causing a small formatting problem while joining the list In-Reply-To: References: Message-ID: <4D39D65F.3050506@mrabarnett.plus.com> On 21/01/2011 16:25, Peter Otten wrote: > Oltmans wrote: > >> Hi Python gurus, hope you're doing well. I've a small problem. >> >> When I run the following code >> ___________________________________________________ >>>>> names = ['oltmans','abramhovic','\n','sal','lee'] >>>>> print '| ' + ' | '.join(names) >> | oltmans | abramhovic | >> | sal | lee >> ___________________________________________________ >> >> I get the output like above. However, I want it to output like below >> >> | oltmans | abramhovic | >> | sal | lee >> >> >> That is, there shouldn't be a space in the beginning of second line. >> The list can of course contain more than 5 elements. Any ideas? I will >> appreciate any hint. Thanks in advance. > >>>> print "|%s|" % "|".join(n if n == "\n" else " %s " % n for n in names) > | oltmans | abramhovic | > | sal | lee | > Or: print ('| ' + ' | '.join(names)).replace("\n ", "\n") From g.rodola at gmail.com Fri Jan 21 14:32:57 2011 From: g.rodola at gmail.com (=?ISO-8859-1?Q?Giampaolo_Rodol=E0?=) Date: Fri, 21 Jan 2011 20:32:57 +0100 Subject: Problems with FTP In-Reply-To: <201101211805.52455.thomas@jollybox.de> References: <58a2ada5-69d6-421b-a0c9-50b34ab8960a@v26g2000yqf.googlegroups.com> <201101211805.52455.thomas@jollybox.de> Message-ID: The solution proposed on stackoverflow: from ftplib import FTP site = FTP('my_proxy') site.set_debuglevel(1) msg = site.login('anonymous at ftp.download.com', 'password') site.cwd('/pub') ...can not work. The "anonymous at ftp.download.com" part is pure fiction. Nothing like that has ever been mentioned in any RFC or implemented/supported by any server, as far as I know. I'd say the only way to proxy FTP is by using a SOCKS proxy. By looking at the error message it's likely that the company firewall is just blocking the FTP traffic. --- Giampaolo http://code.google.com/p/pyftpdlib/ http://code.google.com/p/psutil/ 2011/1/21 Thomas Jollans : > On Friday 21 January 2011, it occurred to RizlaJ to exclaim: >> Hi all, I'm very new to python. I'm using Python 2.7, in a corporate >> environment, therefore am behind a proxy server, firewalls etc. >> >> I can ftp to a barclays capital ftp site ok in internet explorer, but >> I can't get the FTP from ftplib to work for me. Can someone please >> help! > > It sounds very much like, as you said, you're behind a proxy, and have to use > that proxy to connect to the FTP server. If you don't know the proxy settings, > you might be able to find them in the IE configuration, or ask the local > sysadmin. > > http://stackoverflow.com/questions/1293518/proxies-in-python-ftp-application > > It looks like you will have to ftp to the proxy server. Depending on the > application, you might be able to use urllib2 instead. > > Thomas > >> >> I've tried the following commands from my home personal machine >> (thefore no proxies etc) and the commands work fine and I'm able to >> enter my username and password and login successfuly - however in teh >> corporate environment I can't. I'm wondering if this is soemthing to >> do with security permissioning at work etc? >> >> At the shell I'm typing:- >> >> >>> from ftplib import FTP >> >>> ftp = FTP('indexftp.barcap.com') >> >> and get the following error: >> Traceback (most recent call last): >> ? File "", line 1, in >> ? ? ftp = FTP('indexftp.barcap.com') >> ? File "C:\Python27\lib\ftplib.py", line 117, in __init__ >> ? ? self.connect(host) >> ? File "C:\Python27\lib\ftplib.py", line 132, in connect >> ? ? self.sock = socket.create_connection((self.host, self.port), >> self.timeout) >> ? File "C:\Python27\lib\socket.py", line 571, in create_connection >> ? ? raise err >> error: [Errno 10060] A connection attempt failed because the connected >> party did not properly respond after a period of time, or established >> connection failed because connected host has failed to respond >> >> I wasn't expecting this error message next, i was expecting to be able >> to log on using the followign command :- >> >> >> ftp.login("username","password") >> >> Please help! >> >> thanks! > -- > http://mail.python.org/mailman/listinfo/python-list > From gerald.britton at gmail.com Fri Jan 21 14:53:55 2011 From: gerald.britton at gmail.com (Gerald Britton) Date: Fri, 21 Jan 2011 14:53:55 -0500 Subject: PEP8, line continuations and string formatting operations Message-ID: Style question: PEP 8 suggests that line continuations be done by enclosing expressions in parentheses rather than using the line continuation character. In the same paragraph, it states a preference to put binary operators at the end of the line to be continued, so: x = (a + b) is preferred over: x = (a + b) Fair enough. What about string formatting operations (old style) though? The % symbols is a binary operator between a string and the substitution values. Strictly reading PEP 8 leads to: my_string = ("A long string with %s substitutions that %s the line should be %s." % ("many", "suggest", "continued") ) However, I often see the % on the continued line, immediately preceding the substitution variables, like this: my_string = ("A long string with %s substitutions that %s the line should be %s." % ("many", "suggest", "continued") ) This goes against the PEP 8 guidelines, but I prefer it since it makes the substitution variables "jump out" a bit more -- at least to me. So....what's the general feeling about this? Adhere to the PEP 8 binary operators style, or modify it for string formatting? -- Gerald Britton From razajaffrey77 at gmail.com Fri Jan 21 15:01:48 2011 From: razajaffrey77 at gmail.com (RizlaJ) Date: Fri, 21 Jan 2011 12:01:48 -0800 (PST) Subject: Problems with FTP References: <58a2ada5-69d6-421b-a0c9-50b34ab8960a@v26g2000yqf.googlegroups.com> <201101211805.52455.thomas@jollybox.de> Message-ID: <0f31a234-4cd0-452a-8204-5fd3ba7e7d45@k22g2000yqh.googlegroups.com> Hi Tom, Giampaolo, Thank you both for your swift replies. I have asked our IT dept to see if it is the firewall that is blocking the FTP. They are working on that side of things. However I would have thought that the following or some version of it would have worked:- >>> import urllib >>> proxies = ({'ftp':proxyserveraddress'}) >>> some_url = ({'ftp':'indexftp.barcap.com'}) >>> filehandle = urllib.urlopen(some_url, proxies=proxies) Traceback (most recent call last): File "", line 1, in filehandle = urllib.urlopen(some_url, proxies=proxies) File "C:\Python27\lib\urllib.py", line 84, in urlopen return opener.open(url) File "C:\Python27\lib\urllib.py", line 177, in open fullurl = unwrap(toBytes(fullurl)) File "C:\Python27\lib\urllib.py", line 1026, in unwrap url = url.strip() AttributeError: 'dict' object has no attribute 'strip' However as you can see there is an error - is this again related to the firewall do you think? Sorry for asking stupid questions! and thank you for your help in advance. From benjamin.kaplan at case.edu Fri Jan 21 15:19:58 2011 From: benjamin.kaplan at case.edu (Benjamin Kaplan) Date: Fri, 21 Jan 2011 15:19:58 -0500 Subject: Problems with FTP In-Reply-To: <0f31a234-4cd0-452a-8204-5fd3ba7e7d45@k22g2000yqh.googlegroups.com> References: <58a2ada5-69d6-421b-a0c9-50b34ab8960a@v26g2000yqf.googlegroups.com> <201101211805.52455.thomas@jollybox.de> <0f31a234-4cd0-452a-8204-5fd3ba7e7d45@k22g2000yqh.googlegroups.com> Message-ID: On Fri, Jan 21, 2011 at 3:01 PM, RizlaJ wrote: > Hi Tom, Giampaolo, > > Thank you both for your swift replies. I have asked our IT dept to see > if it is the firewall that is blocking the FTP. They are working on > that side of things. > > However I would have thought that the following or some version of it > would have worked:- > >>>> import urllib >>>> proxies = ({'ftp':proxyserveraddress'}) >>>> some_url = ({'ftp':'indexftp.barcap.com'}) >>>> filehandle = urllib.urlopen(some_url, proxies=proxies) > > Traceback (most recent call last): > ?File "", line 1, in > ? ?filehandle = urllib.urlopen(some_url, proxies=proxies) > ?File "C:\Python27\lib\urllib.py", line 84, in urlopen > ? ?return opener.open(url) > ?File "C:\Python27\lib\urllib.py", line 177, in open > ? ?fullurl = unwrap(toBytes(fullurl)) > ?File "C:\Python27\lib\urllib.py", line 1026, in unwrap > ? ?url = url.strip() > AttributeError: 'dict' object has no attribute 'strip' > > However as you can see there is an error - is this again related to > the firewall do you think? > > Sorry for asking stupid questions! and thank you for your help in > advance. The one has nothing to do with a firewall. It's telling you that the function is trying to call url.strip(). But url is a dict object which doesn't have a strip method. Which should tell you that some_url is being constructed incorrectly- it's supposed to be a string. > -- > http://mail.python.org/mailman/listinfo/python-list > From g.rodola at gmail.com Fri Jan 21 15:24:41 2011 From: g.rodola at gmail.com (=?ISO-8859-1?Q?Giampaolo_Rodol=E0?=) Date: Fri, 21 Jan 2011 21:24:41 +0100 Subject: Problems with FTP In-Reply-To: <0f31a234-4cd0-452a-8204-5fd3ba7e7d45@k22g2000yqh.googlegroups.com> References: <58a2ada5-69d6-421b-a0c9-50b34ab8960a@v26g2000yqf.googlegroups.com> <201101211805.52455.thomas@jollybox.de> <0f31a234-4cd0-452a-8204-5fd3ba7e7d45@k22g2000yqh.googlegroups.com> Message-ID: The standard FTP protocol does not supporty any kind of proxy-ing feature natively. The only closest thing to the concept of a "proxy" we can find in the FTP protocol is the site-to-site transfer feature: http://code.google.com/p/pyftpdlib/wiki/FAQ#What_is_FXP? ...but it's something different. By taking a look at your code, though, this is out of question anyway since you can't even connect to the server, let alone send proxy-like (non-standard) commands. I'd focus on investigating whether it's something with the internal network and forget about proxy-related problems since from here I can connect to indexftp.barcap.com. As for urllib's proxy option I'd say it's only valid for HTTP protocol. --- Giampaolo http://code.google.com/p/pyftpdlib/ http://code.google.com/p/psutil/ 2011/1/21 RizlaJ : > Hi Tom, Giampaolo, > > Thank you both for your swift replies. I have asked our IT dept to see > if it is the firewall that is blocking the FTP. They are working on > that side of things. > > However I would have thought that the following or some version of it > would have worked:- > >>>> import urllib >>>> proxies = ({'ftp':proxyserveraddress'}) >>>> some_url = ({'ftp':'indexftp.barcap.com'}) >>>> filehandle = urllib.urlopen(some_url, proxies=proxies) > > Traceback (most recent call last): > ?File "", line 1, in > ? ?filehandle = urllib.urlopen(some_url, proxies=proxies) > ?File "C:\Python27\lib\urllib.py", line 84, in urlopen > ? ?return opener.open(url) > ?File "C:\Python27\lib\urllib.py", line 177, in open > ? ?fullurl = unwrap(toBytes(fullurl)) > ?File "C:\Python27\lib\urllib.py", line 1026, in unwrap > ? ?url = url.strip() > AttributeError: 'dict' object has no attribute 'strip' > > However as you can see there is an error - is this again related to > the firewall do you think? > > Sorry for asking stupid questions! and thank you for your help in > advance. > -- > http://mail.python.org/mailman/listinfo/python-list > From razajaffrey77 at gmail.com Fri Jan 21 15:32:07 2011 From: razajaffrey77 at gmail.com (RizlaJ) Date: Fri, 21 Jan 2011 12:32:07 -0800 (PST) Subject: Problems with FTP References: <58a2ada5-69d6-421b-a0c9-50b34ab8960a@v26g2000yqf.googlegroups.com> <201101211805.52455.thomas@jollybox.de> <0f31a234-4cd0-452a-8204-5fd3ba7e7d45@k22g2000yqh.googlegroups.com> Message-ID: <816c0a8e-9eab-4292-8291-35afc48634be@29g2000yqq.googlegroups.com> Thanks Giampaolo, Benjamin for your responses. You are correct, if I can connect to the ftp site from home and you can connect too then the problem (as you state) lies at the firewall or some security issue. Thanks for your detailed responses, they've been very helpful to me. Kind Regards From drsalists at gmail.com Fri Jan 21 15:36:25 2011 From: drsalists at gmail.com (Dan Stromberg) Date: Fri, 21 Jan 2011 12:36:25 -0800 Subject: examples of realistic multiprocessing usage? In-Reply-To: <4bff00a3-09e8-43f4-a62d-5e12838b217e@n10g2000yqd.googlegroups.com> References: <2011011611053732597-tomfsessile@gmailcom> <4bff00a3-09e8-43f4-a62d-5e12838b217e@n10g2000yqd.googlegroups.com> Message-ID: On Fri, Jan 21, 2011 at 3:20 AM, Adam Skutt wrote: > On Jan 20, 11:51?pm, Albert van der Horst > wrote: >> This is what some people want you to believe. Arm twisting by >> GPL-ers when you borrow their ideas? That is really unheard of. > > Doesn't matter, you're still legally liable if your work is found to > be derivative and lacking a fair use defense. ?It's not borrowing > "ideas" that's problematic, it's proving that's all you did. ?For > those of us with legal departments, we have no choice: if they don't > believe we can prove our case, we're not using the code, period. ?The > risk simply isn't worth it. Many legal departments have an overblown sense of risk, I'm afraid. And I suppose that's somewhat natural, as it's mostly the legal people who are putting their necks on the line over such issues - though I wouldn't be surprised to see a disciplinary action or even firing of a techie over same. I worked at DATAllegro when it was acquired by Microsoft. The DATAllegro product had significant portions that were opensource code; Microsoft, of course, decided that they needed to "quarantine" (meaning "eliminate", in a weird, half-way sense) the opensource portions. Why did Microsoft do this? Why knowingly go through with the purchase of a product that had large opensource parts? Why was what they did considered "enough" as part of a complex due diligence process, to satisfy even Microsoft's copyright-extensionist lawyers? When I say "copyright extensionist", I mean: 1) Their legal department once told me that a small python module could not just be rewritten under a different license, legally, because a small module could not be made different enough to avoid issues. 2) Their onboarding process literally said "don't look at example code in programming books - it entails a legal risk for the company." What made them think DATAllegro's purchase price was still worth it, despite this perspective on copyright? I don't know; I have no first-hand knowledge of that process, though ironically I did help quarantine the "offending" code. But obviously Microsoft management, their board and their lawyers felt it was worth the risk at the price. I know it had something to do with contracting out to a 3rd party company to assess the risk and ascertain what portions "required" excising. Here's one such company: http://www.blackducksoftware.com/black-duck-suite A former coworker (not of Microsoft) suggested they were the only company in this business. I believe Black Duck has software that automatically detects opensource code in a body of work. IOW, it's quite possible to demonstrate that something isn't a derivative work, enough so to make even Microsoft's lawyers happy, given adequate funding for the purpose. So yeah, sometimes a programmer peeking at opensource code might be more of a risk (== expense) than a closed-source company is willing to take, but so might studying a book intended to help you learn programming. And how many programmers haven't studied a programming book at some time in their life? My intuition tells me (I'm not going into details - that feels too dangerous to me personally) that part of the issue Microsoft was trying to prevent, wasn't so much a matter of copyright safety, as trying to avoid being called hypocritical; they've made a lot of noise about how dangerous opensource is. If they then turn around and distribute opensource code artifacts as part of a Microsoft product, then they'll probably eventually get beaten up in the tech press yet again over the new matter. From python.list at tim.thechases.com Fri Jan 21 15:40:15 2011 From: python.list at tim.thechases.com (Tim Chase) Date: Fri, 21 Jan 2011 14:40:15 -0600 Subject: PEP8, line continuations and string formatting operations In-Reply-To: References: Message-ID: <4D39EF2F.3090303@tim.thechases.com> On 01/21/2011 01:53 PM, Gerald Britton wrote: > What about string formatting operations (old style) though? The % > symbols is a binary operator between a string and the substitution > values. Strictly reading PEP 8 leads to: > > my_string = ("A long string with %s substitutions that %s the line > should be %s." % > ("many", "suggest", "continued") > ) Depending on whether I have one item to map or multiple, I either bite the bullet and leave them all on one line: my_string = "A long string with only one %s substitution in it" % adjective if it's one substitution and the string is particularly long, I'll occasionally break the string itself: my_string = ("A long string with only one %s " "substitution in it that suggests " "being broken with a newline") % adjective For multiple parameters (a tuple), I'll usually cram both the "%" and the "(" on the same line: my_string = "A long %s with %s substitution%s in it" % ( "sentence", "several", "s", # plural ) which makes it a little easier to see all my parameters. Finally, a combination of the *really* long string and multiple parameters, I usually use a secondary variable for readability, something like fmt_string = ( "this is a %s %s with %s substitution%s in it " "and it extends over several %s" ) my_string = fmt_string % ( "long", "string", "multiple", "s", # plural "lines", ) I like to have the parameters on their own line (and a trailing comma) because it makes my diffs uncluttered when things are added/removed. That's just my own personal taste -- I too am interested in the perspectives of others on the list. -tkc From clp2 at rebertia.com Fri Jan 21 15:53:49 2011 From: clp2 at rebertia.com (Chris Rebert) Date: Fri, 21 Jan 2011 12:53:49 -0800 Subject: PEP8, line continuations and string formatting operations In-Reply-To: References: Message-ID: On Fri, Jan 21, 2011 at 11:53 AM, Gerald Britton wrote: > Style question: > > PEP 8 suggests that line continuations be done by enclosing > expressions in parentheses rather than using the line continuation > character. ?In the same paragraph, it states a preference to put > binary operators at the end of the line to be continued, so: > > x = (a + > ? ? ? b) > > is preferred over: > > x = (a > ? ? ? + b) > > Fair enough. > > What about string formatting operations (old style) though? Fair warning: They're deprecated and liable to possibly be removed: http://docs.python.org/dev/library/stdtypes.html#old-string-formatting-operations > The % > symbols is a binary operator between a string and the substitution > values. ?Strictly reading PEP 8 leads to: > > my_string = ("A long string with %s substitutions that %s the line > should be %s." % > ? ? ? ? ? ? ? ? ? ("many", "suggest", "continued") > ? ? ? ? ? ? ? ? ?) > > However, I often see the % on the continued line, immediately > preceding the substitution variables, like this: > > my_string = ("A long string with %s substitutions that %s the line > should be %s." > ? ? ? ? ? ? ? ? ? % ("many", "suggest", "continued") > ? ? ? ? ? ? ? ? ?) > > This goes against the PEP 8 guidelines, but I prefer it since it makes > the substitution variables "jump out" a bit more -- at least to me. Remember that PEP 8 itself says: "A Foolish Consistency is the Hobgoblin of Little Minds [...] But most importantly: know when to be inconsistent -- sometimes the style guide just doesn't apply. When in doubt, use your best judgment. Look at other examples and decide what looks best." i.e. Generally, don't read PEP 8 super-strictly. FWIW, your style seems reasonable and slightly preferable to me. Cheers, Chris -- http://blog.rebertia.com From philip at semanchuk.com Fri Jan 21 15:57:57 2011 From: philip at semanchuk.com (Philip Semanchuk) Date: Fri, 21 Jan 2011 15:57:57 -0500 Subject: examples of realistic multiprocessing usage? In-Reply-To: References: <2011011611053732597-tomfsessile@gmailcom> <4bff00a3-09e8-43f4-a62d-5e12838b217e@n10g2000yqd.googlegroups.com> Message-ID: On Jan 21, 2011, at 3:36 PM, Dan Stromberg wrote: > On Fri, Jan 21, 2011 at 3:20 AM, Adam Skutt wrote: >> On Jan 20, 11:51 pm, Albert van der Horst >> wrote: >>> This is what some people want you to believe. Arm twisting by >>> GPL-ers when you borrow their ideas? That is really unheard of. >> >> Doesn't matter, you're still legally liable if your work is found to >> be derivative and lacking a fair use defense. It's not borrowing >> "ideas" that's problematic, it's proving that's all you did. For >> those of us with legal departments, we have no choice: if they don't >> believe we can prove our case, we're not using the code, period. The >> risk simply isn't worth it. > > Many legal departments have an overblown sense of risk, I'm afraid. I carefully avoid GPLed code on our BSD-licensed project not because I need fear anyone's legal department, but out of respect for the author(s) of the GPL-ed code. The way I see it, the author of GPL-ed code gives away something valuable and asks for just one thing in return: respect the license. It strikes me as very selfish to deny them the one thing they ask for. JMHO, Philip From howe.steven at gmail.com Fri Jan 21 16:04:24 2011 From: howe.steven at gmail.com (GrayShark) Date: Fri, 21 Jan 2011 15:04:24 -0600 Subject: Line breaks in list causing a small formatting problem while joining the list References: Message-ID: On Fri, 21 Jan 2011 07:39:26 -0800, Oltmans wrote: > Hi Python gurus, hope you're doing well. I've a small problem. > > When I run the following code > ___________________________________________________ >>>> names = ['oltmans','abramhovic','\n','sal','lee'] print '| ' + ' | >>>> '.join(names) > | oltmans | abramhovic | > | sal | lee > ___________________________________________________ > > I get the output like above. However, I want it to output like below > > | oltmans | abramhovic | > | sal | lee > > > That is, there shouldn't be a space in the beginning of second line. The > list can of course contain more than 5 elements. Any ideas? I will > appreciate any hint. Thanks in advance. It looks like your trying to print a formatted list. With your code you are: 1) creating a string from a list, with added characters. 2) printing the new string. So, look at your string: names = ['oltmans','abramhovic','\n','sal','lee'] newNames = '| ' + ' | '.join( names ) >> newNames '| oltmans | abramhovic | \n | sal | lee' Now you can see your space after the newline (and a missing pipe symbol at the end). When you ask the compiler for newNames, you can see there is a space after the newline character. Naturally, the print operator prints out the space. If this is indeed a formatted list, you should try something else. Something like: # first get rid of you formatting element in the list '\n'. names = [ 'oltmans','abramhovic','sal','lee' ] # next iterate by twos via the function 'range( start, stop, step )' range( 0, len( names ), 2 ) [ 0, 2 ] # now fix up the printing by twos. >>> for x in range( 0, len( names ), 2 ): ... print '| %s | %s |' % ( names[ x ], names[ x + 1 ] ) ... | oltmans | abramhovic | | sal | lee | Next, make it pretty. The next step would be to find the longest string in your list. >>> def max( theList ): ... theMax = 0 ... for element in theList: ... if len( element ) > theMax: ... theMax = len( element ) ... return theMax >>> max( names ) 10 Now some centering of strings, from you list. >>> for x in range( 0, len( names ), 2 ): ... print '| %s | %s |' % \ ( names[ x ].center(10), \ names[ x +1 ].center(10) ) ... | oltmans | abramhovic | | sal | lee | Pretty list. Now make it obscure, like you are a perl programmer; don't forget to eat up memory as you go along .... def maxElement( aList ): lenList = [] for x in aList: lenList.append( len( x ) ) return sorted( lenList, reverse=True )[0] def formatLine( firstName, secondName, width ): return '| %s | %s | % \ ( firstName.center( width ), \ secondName.center( width ) ) theWidth = maxElement( names ) for x in range( 0, len( names ), 2 ): aLine = formatLines( names[x], names[x+1], theWidth ) print aLine Make sure to create at lest two additions files to store maxElement and formatLine, create an __init__.py and make a package, turn in the project and get expelled for being grandiose. steven. From longqian9509 at gmail.com Fri Jan 21 16:19:47 2011 From: longqian9509 at gmail.com (long) Date: Fri, 21 Jan 2011 13:19:47 -0800 (PST) Subject: is it a bug in exec? In-Reply-To: Message-ID: <5722cabf-9635-4795-8117-e1383f37e0ce@glegroupsg2000goo.googlegroups.com> I see now. Thank you so much. I think namespace is really a confusing part in Python. On Friday, January 21, 2011 11:00:32 AM UTC-6, Peter Otten wrote: > There are only two cases that matter: identical local/global namespaces and > distinct local/global namespaces: > > >>> code = """\ > ... x = 42 # put x into the local namespace > ... def f(): > ... print(x) # look up x in the global namespace > ... f() > ... """ > >>> exec(code, {}, {}) > Traceback (most recent call last): > File "", line 1, in > File "", line 4, in > File "", line 3, in f > NameError: global name 'x' is not defined > >>> ns = {} > >>> exec(code, ns, ns) > 42 > > Also note that > > >>> globals() is locals() > True > > on the module level. > > Peter From drsalists at gmail.com Fri Jan 21 16:34:44 2011 From: drsalists at gmail.com (Dan Stromberg) Date: Fri, 21 Jan 2011 13:34:44 -0800 Subject: examples of realistic multiprocessing usage? In-Reply-To: References: <2011011611053732597-tomfsessile@gmailcom> <4bff00a3-09e8-43f4-a62d-5e12838b217e@n10g2000yqd.googlegroups.com> Message-ID: On Fri, Jan 21, 2011 at 12:57 PM, Philip Semanchuk wrote: > On Jan 21, 2011, at 3:36 PM, Dan Stromberg wrote: >> On Fri, Jan 21, 2011 at 3:20 AM, Adam Skutt wrote: >>> On Jan 20, 11:51 pm, Albert van der Horst >>> wrote: >>>> This is what some people want you to believe. Arm twisting by >>>> GPL-ers when you borrow their ideas? That is really unheard of. >>> >>> Doesn't matter, you're still legally liable if your work is found to >>> be derivative and lacking a fair use defense. ?It's not borrowing >>> "ideas" that's problematic, it's proving that's all you did. ?For >>> those of us with legal departments, we have no choice: if they don't >>> believe we can prove our case, we're not using the code, period. ?The >>> risk simply isn't worth it. >> >> Many legal departments have an overblown sense of risk, I'm afraid. > > I carefully avoid GPLed code on our BSD-licensed project not because I need fear anyone's legal department, but out of respect for the author(s) of the GPL-ed code. The way I see it, the author of GPL-ed code gives away something valuable and asks for just one thing in return: respect the license. It strikes me as very selfish to deny them the one thing they ask for. That's very considerate, and yet, I think there are multiple senses of the word "avoid" above. If you're avoiding inspecting GPL'd code for ideas, I think if you ask most authors of GPL'd code, they'd be more than happy to allow you to. I've released GPL'd code quite a few times, and personally, I'm flattered when others want to look it over. If you're avoiding cutting and pasting from (or linking against) GPL'd code into something that isn't GPL-licensed, then that's very sensible. From cce at clarkevans.com Fri Jan 21 16:45:43 2011 From: cce at clarkevans.com (Clark C. Evans) Date: Fri, 21 Jan 2011 16:45:43 -0500 Subject: HTSQL 2.0 RC1 -- a Query Language for the Accidental Programmer Message-ID: <1295646343.4767.1416569759@webmail.messagingengine.com> Kirill Simonov and myself would like to introduce HTSQL, a novel approach to relational database access which is neither an ORM nor raw SQL. HTSQL is a URI-based high-level query language for relational databases. It's implemented as a Python WSGI application. Currently it supports PostgreSQL and SQLite (more databases & juicy features forthcoming). Homepage: http://htsql.org Download: http://pypi.python.org/pypi/HTSQL/ Source: http://bitbucket.org/prometheus/htsql At this point, HTSQL 2.0 may not be mature enough for production use; we expect to fill in any remaining gaps in the coming months. We're curious what you think. Join us in #htsql on freenode [1], subscribe to the mailing list [2] and please come to our PyCon 2011 talk [3]. Clark & Kirill [1] irc://irc.freenode.net/#htsql [2] http://lists.htsql.org/mailman/listinfo/htsql-users [3] http://us.pycon.org/2011/schedule/sessions/264/ From ddasilva at umd.edu Fri Jan 21 17:41:56 2011 From: ddasilva at umd.edu (Daniel da Silva) Date: Fri, 21 Jan 2011 14:41:56 -0800 (PST) Subject: Best way to administer code updates to server daemon Message-ID: Hi, I am writing a custom IRC server, and I was wondering would be the best way to administer code updates to the daemon. Am I doomed to have to restart the server every time I want to do an update (which would disconnect all clients)? I don't mind doing something a little more advanced if it means I can keep close to continuous uptime. Thanks, Daniel From mcnutt at utk.edu Fri Jan 21 17:59:33 2011 From: mcnutt at utk.edu (McNutt Jr, William R) Date: Fri, 21 Jan 2011 22:59:33 +0000 Subject: Python, Solaris 10, and Mailman Message-ID: <0CD7A72044B75D478D36624D96C5D4412FBB10@kmbx1.utk.tennessee.edu> I am attempting to install Mailman on a Sun Sunfire x4100 box running Solaris ten. I keep running into brick walls that the Mailman group looks at, shrugs, and says, that's a Python problem. Has ANYBODY actually made this work? Currently, I'm attempting to compile Python 2.4.4, which is the recommended distro for Mailman, and I'm getting: gcc -o python \ Modules/ccpython.o \ libpython2.4.a -lresolv -lsocket -lnsl -lrt -ldl -lm Undefined first referenced symbol in file __gxx_personality_v0 Modules/ccpython.o ld: fatal: Symbol referencing errors. No output written to python collect2: ld returned 1 exit status *** Error code 1 make: Fatal error: Command failed for target `python' -------------- next part -------------- An HTML attachment was scrubbed... URL: From python at mrabarnett.plus.com Fri Jan 21 18:26:43 2011 From: python at mrabarnett.plus.com (MRAB) Date: Fri, 21 Jan 2011 23:26:43 +0000 Subject: Best way to administer code updates to server daemon In-Reply-To: References: Message-ID: <4D3A1633.3040106@mrabarnett.plus.com> On 21/01/2011 22:41, Daniel da Silva wrote: > Hi, > > I am writing a custom IRC server, and I was wondering would be the > best way to administer code updates to the daemon. Am I doomed to have > to restart the server every time I want to do an update (which would > disconnect all clients)? I don't mind doing something a little more > advanced if it means I can keep close to continuous uptime. > As I see it, the server listens for a new client, starts a handler for that client (it might be starting the handler in a new thread), and then tidies up when the client disconnects. The server code could be split into the core and the handler. The core of the server might not be updated very often, so it would stay running, and the handler would be in another module. There could be more than one version of the handler available. When the core wanted to start a handler for a new client it would use the latest version of the handler, and when an old version of the handler was no longer being used by any client then it could be discarded. From edwinconnell at gmail.com Fri Jan 21 18:33:59 2011 From: edwinconnell at gmail.com (Ed Connell) Date: Fri, 21 Jan 2011 17:33:59 -0600 Subject: Short circuting Message-ID: Hi, Consider the following please: (re_section, re_name, etc are previously compiled patterns) result1 = re_section.search(line); result2 = re_name.search(line); result3 = re_data1.search(line); result4 = re_data2.search(line); if result1: last_section = result1.group()[18:-5] elif result2: last_name = result2.group(0)[6:-1] elif result3: data[last_section] = {last_name: result3.group()[13:-5]} elif result4: data[last_section] = {last_name: result4.group()[17:-5]} It gets my goat to have to obtain all resultx when I just want the first that is not None. (In theory, the number of results can be much longer.) I can think of alternatives (raising exceptions), but they all use deep indenting. Ideas? Ed -------------- next part -------------- An HTML attachment was scrubbed... URL: From pavlovevidence at gmail.com Fri Jan 21 18:39:31 2011 From: pavlovevidence at gmail.com (Carl Banks) Date: Fri, 21 Jan 2011 15:39:31 -0800 (PST) Subject: PEP8, line continuations and string formatting operations References: Message-ID: <1ecf312b-5154-4578-9301-5610f8d530ab@k14g2000pre.googlegroups.com> On Jan 21, 11:53?am, Gerald Britton wrote: > So....what's the general feeling about this? Adhere to the PEP 8 > binary operators style, or modify it for string formatting? Well, personally I ignore the "operator at end of first line" guideline altogether; I think it's much more readable with the operator on the following line, not even close. I'm starting to not fold lines with parentheses as much, either. Sometimes the parentheses break the flow too much, or suggest grouping where it isn't desirable. Carl Banks From alex.kapps at web.de Fri Jan 21 19:10:41 2011 From: alex.kapps at web.de (Alexander Kapps) Date: Sat, 22 Jan 2011 01:10:41 +0100 Subject: Short circuting In-Reply-To: References: Message-ID: <4D3A2081.1010509@web.de> On 22.01.2011 00:33, Ed Connell wrote: > Hi, > > Consider the following please: (re_section, re_name, etc are > previously compiled patterns) > > result1 = re_section.search(line); > result2 = re_name.search(line); > result3 = re_data1.search(line); > result4 = re_data2.search(line); > > if result1: > last_section = result1.group()[18:-5] > elif result2: > last_name = result2.group(0)[6:-1] > elif result3: > data[last_section] = {last_name: > result3.group()[13:-5]} > elif result4: > data[last_section] = {last_name: > result4.group()[17:-5]} > > It gets my goat to have to obtain all resultx when I just want the > first that is not None. (In theory, the number of results can be > much longer.) I can think of alternatives (raising exceptions), but > they all use deep indenting. > > Ideas? > > Ed > Maybe something like this (totally untested and probably wrong, I'm already quite tired): for pattern in (re_section, re_name, re_data1, re_data2): result = pattern.search(line): if result: if pattern == re_section: last_section = result1.group()[18:-5] elif pattern == re_name: last_name = result2.group(0)[6:-1] elif pattern == re_data1: data[last_section] = {last_name: result3.group()[13:-5]} elif pattern == re_data2: data[last_section] = {last_name: result4.group()[17:-5]} Also, if you have long if/elif ladders, look if you can apply the dictionary dispatch pattern. From alex.kapps at web.de Fri Jan 21 19:35:22 2011 From: alex.kapps at web.de (Alexander Kapps) Date: Sat, 22 Jan 2011 01:35:22 +0100 Subject: Short circuting In-Reply-To: <4D3A2081.1010509@web.de> References: <4D3A2081.1010509@web.de> Message-ID: <4D3A264A.1020503@web.de> On 22.01.2011 01:10, Alexander Kapps wrote: > On 22.01.2011 00:33, Ed Connell wrote: >> Hi, >> >> Consider the following please: (re_section, re_name, etc are >> previously compiled patterns) >> >> result1 = re_section.search(line); >> result2 = re_name.search(line); >> result3 = re_data1.search(line); >> result4 = re_data2.search(line); >> >> if result1: >> last_section = result1.group()[18:-5] >> elif result2: >> last_name = result2.group(0)[6:-1] >> elif result3: >> data[last_section] = {last_name: >> result3.group()[13:-5]} >> elif result4: >> data[last_section] = {last_name: >> result4.group()[17:-5]} >> >> It gets my goat to have to obtain all resultx when I just want the >> first that is not None. (In theory, the number of results can be >> much longer.) I can think of alternatives (raising exceptions), but >> they all use deep indenting. >> >> Ideas? >> >> Ed >> > > > Maybe something like this (totally untested and probably wrong, I'm > already quite tired): > > > for pattern in (re_section, re_name, re_data1, re_data2): > result = pattern.search(line): > if result: > if pattern == re_section: > last_section = result1.group()[18:-5] > elif pattern == re_name: > last_name = result2.group(0)[6:-1] > elif pattern == re_data1: > data[last_section] = {last_name: result3.group()[13:-5]} > elif pattern == re_data2: > data[last_section] = {last_name: result4.group()[17:-5]} > > > Also, if you have long if/elif ladders, look if you can apply the > dictionary dispatch pattern. Correction. Of course you need to break out of the loop as soon as a not None result is found: if result: if pattern == re_section: last_section = result1.group()[18:-5] ... break ... From solipsis at pitrou.net Fri Jan 21 20:10:38 2011 From: solipsis at pitrou.net (Antoine Pitrou) Date: Sat, 22 Jan 2011 02:10:38 +0100 Subject: Python, Solaris 10, and Mailman References: <0CD7A72044B75D478D36624D96C5D4412FBB10@kmbx1.utk.tennessee.edu> Message-ID: <20110122021038.42011cb1@pitrou.net> On Fri, 21 Jan 2011 22:59:33 +0000 "McNutt Jr, William R" wrote: > I am attempting to install Mailman on a Sun Sunfire x4100 box running Solaris ten. I keep running into brick walls that the Mailman group looks at, shrugs, and says, that's a Python problem. > > Has ANYBODY actually made this work? > > Currently, I'm attempting to compile Python 2.4.4, which is the recommended distro for Mailman, 2.4.4?? Do yourself a favour and choose a modern release. 2.4 hasn't been supported for years, and besides, the latest in that branch in 2.4.6. You can probably use whatever version of Python comes with Solaris, no need to build your own. Oh, and tell the Mailman guys that their recommendations are totally obsolete. Regards Antoine. From brenNOSPAMbarn at NObrenSPAMbarn.net Fri Jan 21 20:48:01 2011 From: brenNOSPAMbarn at NObrenSPAMbarn.net (OKB (not okblacke)) Date: Sat, 22 Jan 2011 01:48:01 +0000 (UTC) Subject: Krippendorff's alpha Message-ID: Does anyone know of a Python implementation of calculating Krippendorff's alpha? ( http://en.wikipedia.org/wiki/Krippendorff%27s_Alpha ) Thanks, -- --OKB (not okblacke) Brendan Barnwell "Do not follow where the path may lead. Go, instead, where there is no path, and leave a trail." --author unknown From debatem1 at gmail.com Fri Jan 21 21:03:13 2011 From: debatem1 at gmail.com (geremy condra) Date: Fri, 21 Jan 2011 18:03:13 -0800 Subject: Krippendorff's alpha In-Reply-To: References: Message-ID: On Fri, Jan 21, 2011 at 5:48 PM, OKB (not okblacke) wrote: > ? ? ? ?Does anyone know of a Python implementation of calculating > Krippendorff's alpha? ?( > http://en.wikipedia.org/wiki/Krippendorff%27s_Alpha ) First hit on google is [0], which has a full implementation, worked out example of how to use it, and a link to an excellent description of how it works and when to use it. Geremy Condra [0]: http://cswww.essex.ac.uk/Research/nle/arrau/alpha.html From steve+comp.lang.python at pearwood.info Fri Jan 21 21:21:45 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 22 Jan 2011 02:21:45 GMT Subject: Krippendorff's alpha References: Message-ID: <4d3a3f38$0$29983$c3e8da3$5496439d@news.astraweb.com> On Sat, 22 Jan 2011 01:48:01 +0000, OKB (not okblacke) wrote: > Does anyone know of a Python implementation of calculating > Krippendorff's alpha? ( > http://en.wikipedia.org/wiki/Krippendorff%27s_Alpha ) Google is your friend. Search for "Krippendorff's alpha python" and the very first link takes you to one. http://www.google.co.uk/search?q=Krippendorff%27s+alpha+python&ie=UTF-8&oe=UTF-8 -- Steven From python.list at tim.thechases.com Fri Jan 21 21:59:43 2011 From: python.list at tim.thechases.com (Tim Chase) Date: Fri, 21 Jan 2011 20:59:43 -0600 Subject: Short circuting In-Reply-To: References: Message-ID: <4D3A481F.7050601@tim.thechases.com> On 01/21/2011 05:33 PM, Ed Connell wrote: > Consider the following please: (re_section, re_name, etc are previously > compiled patterns) > > result1 = re_section.search(line); > result2 = re_name.search(line); > result3 = re_data1.search(line); > result4 = re_data2.search(line); > > if result1: > last_section = result1.group()[18:-5] > elif result2: > last_name = result2.group(0)[6:-1] > elif result3: > data[last_section] = {last_name: > result3.group()[13:-5]} > elif result4: > data[last_section] = {last_name: > result4.group()[17:-5]} > > It gets my goat to have to obtain all resultx when I just want the first > that is not None. (In theory, the number of results can be much longer.) The problem isn't so much the elif structure, but that you're doing different things with each result. If they were attributes of a class and value assignments (instead of top-level variables, sometimes calling .group() with no params & sometimes with "0", and a mix of strings/dicts), you could do something like line = "..." info = object() # some class with attributes to update for name, r, slc in ( ("section", re_section, slice(18,-5)), ("name", re_name, slice(6,-1)), ("data1", re_data1, slice(13,-5)), ("data2", re_data2, slice(17,-5)), ): result = r.search(line) if result: setattr(info, name, result.group(0)[slc]) break else: woah_none_matched(fail, fail, fail, do_I_care) So if you're doing predictable things with each, it's not too bad. -tkc From robert.kern at gmail.com Fri Jan 21 23:19:30 2011 From: robert.kern at gmail.com (Robert Kern) Date: Fri, 21 Jan 2011 22:19:30 -0600 Subject: Short circuting In-Reply-To: References: Message-ID: On 1/21/11 5:33 PM, Ed Connell wrote: > Hi, > > Consider the following please: (re_section, re_name, etc are previously > compiled patterns) > > result1 = re_section.search(line); > result2 = re_name.search(line); > result3 = re_data1.search(line); > result4 = re_data2.search(line); > > if result1: > last_section = result1.group()[18:-5] > elif result2: > last_name = result2.group(0)[6:-1] > elif result3: > data[last_section] = {last_name: > result3.group()[13:-5]} > elif result4: > data[last_section] = {last_name: > result4.group()[17:-5]} > > It gets my goat to have to obtain all resultx when I just want the first that is > not None. (In theory, the number of results can be much longer.) I can think > of alternatives (raising exceptions), but they all use deep indenting. parsers = [ ('section', re_section, lambda r: r.group()[18:-5]), ('name', re_name, lambda r: r.group()[6:-1]), ('data1', re_data1, lambda r: r.group()[13:-5]), ('data2', re_data2, lambda r: r.group()[17:-5]), ] data = {} for line in lines: values = {} for key, regex, extract in parsers: m = regex.search(line) if m is not None: values[key] = extract(m) break if 'data1' in values: data[values['section']] = {values['name']: values['data1']} elif 'data2' in values: data[values['section']] = {values['name']: values['data2']} -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco From brenNOSPAMbarn at NObrenSPAMbarn.net Fri Jan 21 23:51:10 2011 From: brenNOSPAMbarn at NObrenSPAMbarn.net (OKB (not okblacke)) Date: Sat, 22 Jan 2011 04:51:10 +0000 (UTC) Subject: Krippendorff's alpha References: <4d3a3f38$0$29983$c3e8da3$5496439d@news.astraweb.com> Message-ID: Steven D'Aprano wrote: > On Sat, 22 Jan 2011 01:48:01 +0000, OKB (not okblacke) wrote: > >> Does anyone know of a Python implementation of calculating >> Krippendorff's alpha? ( >> http://en.wikipedia.org/wiki/Krippendorff%27s_Alpha ) > > Google is your friend. Search for "Krippendorff's alpha python" and > the very first link takes you to one. > > http://www.google.co.uk/search?q=Krippendorff%27s+alpha+python&ie=UT > F-8&oe=UTF-8 Thanks to you and Geremy Condra for pointing me at this. I had done a search but somehow did not come upon that page. Perhaps I mistyped something. -- --OKB (not okblacke) Brendan Barnwell "Do not follow where the path may lead. Go, instead, where there is no path, and leave a trail." --author unknown From rustompmody at gmail.com Sat Jan 22 00:25:43 2011 From: rustompmody at gmail.com (rusi) Date: Fri, 21 Jan 2011 21:25:43 -0800 (PST) Subject: HTSQL 2.0 RC1 -- a Query Language for the Accidental Programmer References: Message-ID: On Jan 22, 2:45?am, "Clark C. Evans" wrote: > Kirill Simonov and myself would like to introduce HTSQL, a novel > approach to relational database access which is neither an ORM nor raw SQL. : > We're curious what you think. Thanks -- looks interesting. Given the claim htsql is higher level than sql I am interested in bill-of-materials type (recursive) queries. From no.email at nospam.invalid Sat Jan 22 00:27:01 2011 From: no.email at nospam.invalid (Paul Rubin) Date: Fri, 21 Jan 2011 21:27:01 -0800 Subject: Best way to administer code updates to server daemon References: Message-ID: <7xy66dwlsq.fsf@ruckus.brouhaha.com> Daniel da Silva writes: > I am writing a custom IRC server, and I was wondering would be the > best way to administer code updates to the daemon. Am I doomed to have > to restart the server every time I want to do an update (which would > disconnect all clients)? I don't mind doing something a little more > advanced if it means I can keep close to continuous uptime. There are several possible approaches: 1) load new code into the server with the import function, being careful about what data structures you can mess with etc. 2) have a simple front end proxy that maintains the inbound tcp connections to clients, and uses a connectionless or restartable protocol to pass the info to the server. Of course now you have the issue of how to update the proxy. But for a serious HA system you have to do stuff like this anyway. 3) Start the new server in a new process, and use the Linux SCM_RIGHTS message that lets you pass open file descriptors through Unix domain sockets, to hand off any open TCP connections from the old server to the new one. Maybe there are other ideas possible too. From premjee07 at gmail.com Sat Jan 22 02:24:49 2011 From: premjee07 at gmail.com (Free Online Jobs) Date: Fri, 21 Jan 2011 23:24:49 -0800 (PST) Subject: 3-Easy Steps to make your FREE Website using Free WEB SITE Software,.,..,To Earn Extra Online Money Message-ID: <17f72c0e-65dd-4882-879c-55eb34bec86b@c13g2000prc.googlegroups.com> http://freewebsitesoftware.info How to make free website , Earning tricks with FREE website ,.,.., Way to make free website using FREE website software,.,.,.,., http://freewebsitesoftware.info From torriem at gmail.com Sat Jan 22 02:36:57 2011 From: torriem at gmail.com (Michael Torrie) Date: Sat, 22 Jan 2011 00:36:57 -0700 Subject: Tkinter: The good, the bad, and the ugly! In-Reply-To: References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com><4d337983$0$29983$c3e8da3$5496439d@news.astraweb.com><044a5101-948d-4458-9c94-57dbb3e25f67@m35g2000vbn.googlegroups.com><4d3467bf$0$29983$c3e8da3$5496439d@news.astraweb.com><4D34B04E.8050309@web.de><4266E8D7BA204BFEA5BF66C635CE1716@octavian><4D35DCE8.5030002@web.de><4D35DD47.1070304@web.de><7A0C7934E65D4B85A584C06ADD3B6ECF@teddy>< ih53k2$pjf$1@dough.gmane.org> <513d0274-1878-49a6-9382-31b6ae7aaef3@y9g2000prf.googlegroups.com> Message-ID: <4D3A8919.5030303@gmail.com> On 01/20/2011 11:17 AM, Emile van Sebille wrote: > The problem with QT is the license. PyQT indeed is licensed poorly for anything that's not GPL. But Qt itself is dual-licensed under GPL and the LGPL, as of version 4.6 I think. The LGPL license would seem to be quite acceptable even for commercial, closed-source programs. Is this not so? The license is at parity with GTK+. Eventually PySide will be stable and fast, and so the licensing issues involving PyQt won't matter. From user at compgroups.net/ Sat Jan 22 10:02:25 2011 From: user at compgroups.net/ (BurchALTA) Date: Sat, 22 Jan 2011 09:02:25 -0600 Subject: tilted text in the turtle module References: Message-ID: Every one remembers that men's life seems to be expensive, nevertheless different people require cash for various issues and not every person earns enough money. Thus to receive quick personal loans and bank loan should be a right solution. From cce at clarkevans.com Sat Jan 22 12:13:11 2011 From: cce at clarkevans.com (Clark C. Evans) Date: Sat, 22 Jan 2011 12:13:11 -0500 Subject: HTSQL 2.0 RC1 -- a Query Language for the Accidental Programmer In-Reply-To: References: Message-ID: <1295716391.32152.1416665025@webmail.messagingengine.com> On Fri, 21 Jan 2011 21:25 -0800, "rusi" wrote: > On Jan 22, 2:45?am, "Clark C. Evans" wrote: > > Kirill Simonov and myself would like to introduce HTSQL, a novel > > approach to relational database access which is neither an ORM > > nor raw SQL. > > Given the claim htsql is higher level than sql I am interested in > bill-of-materials type (recursive) queries. Rusi, HTSQL 2.0 does not yet support SQL's common table expressions. However, this particular use case, along with CUBE, server-side stored procedures, and related needs is what made us branch from our 1.X production release. Our immediate focus is SQL-92. Once we cover most SELECT patterns and SQL back-ends, we'll be looking at SQL:1999, SQL:2003, and SQL:2008 (as well as proprietary equivalents such as Oracle's CONNECT BY). Best, Clark From xi at gamma.dn.ua Sat Jan 22 12:20:07 2011 From: xi at gamma.dn.ua (Kirill Simonov) Date: Sat, 22 Jan 2011 12:20:07 -0500 Subject: HTSQL 2.0 RC1 -- a Query Language for the Accidental Programmer In-Reply-To: References: Message-ID: <4D3B11C7.7000108@gamma.dn.ua> On 01/22/2011 12:25 AM, rusi wrote: > On Jan 22, 2:45 am, "Clark C. Evans" wrote: >> Kirill Simonov and myself would like to introduce HTSQL, a novel >> approach to relational database access which is neither an ORM nor raw SQL. > : >> We're curious what you think. > > Thanks -- looks interesting. > > Given the claim htsql is higher level than sql I am interested in > bill-of-materials type (recursive) queries. Currently HTSQL does not support recursive queries. That said, it's certainly within the reach of HTSQL and I could sketch here how the support may look like: We add an operator `closure()` that, given a self-referential link `link`, produces a transitive closure `closure(link)` of the link. For example, take a table `program` with a link `program.part_of`. Then `program.closure(part_of)` is a plural link mapping a program to its super-programs, which you can use just like a regular plural link, for instance, in aggregate expressions. To return, for each program, a list of its super-programs: /program{code, /closure(part_of){code}} To return all sub-programs of a specific program 'xxx': /program?exists(closure(part_of).code='xxx') Compare that with /program{code, part_of.code} /program?part_of.code='xxx' I think it would be a modest improvement over a SQL alternative. I'm adding it to the roadmap right now, but don't hold your breath -- Q4 this year or early next year is a realistic ETA. I expect the implementation to be at least moderately painful and, obviously, it could only work with those backends that support WITH RECURSIVE. Thanks, Kirill From rustompmody at gmail.com Sat Jan 22 12:36:54 2011 From: rustompmody at gmail.com (rusi) Date: Sat, 22 Jan 2011 09:36:54 -0800 (PST) Subject: HTSQL 2.0 RC1 -- a Query Language for the Accidental Programmer References: Message-ID: <10d3ec9c-5444-4a51-9195-6bd7318618d7@j19g2000prh.googlegroups.com> On Jan 22, 10:20?pm, Kirill Simonov wrote: > On 01/22/2011 12:25 AM, rusi wrote: > > > On Jan 22, 2:45 am, "Clark C. Evans" ?wrote: > >> Kirill Simonov and myself would like to introduce HTSQL, a novel > >> approach to relational database access which is neither an ORM nor raw SQL. > > : > >> We're curious what you think. > > > Thanks -- looks interesting. > > > Given the claim htsql is higher level than sql I am interested in > > bill-of-materials type (recursive) queries. > > Currently HTSQL does not support recursive queries. ?That said, it's > certainly within the reach of HTSQL and I could sketch here how the > support may look like: > > We add an operator `closure()` that, given a self-referential link > `link`, produces a transitive closure `closure(link)` of the link. > > For example, take a table `program` with a link `program.part_of`. ?Then > `program.closure(part_of)` is a plural link mapping a program to its > super-programs, which you can use just like a regular plural link, for > instance, in aggregate expressions. > > To return, for each program, a list of its super-programs: > > ? ? ?/program{code, /closure(part_of){code}} > > To return all sub-programs of a specific program 'xxx': > > ? ? ?/program?exists(closure(part_of).code='xxx') > > Compare that with > > ? ? ?/program{code, part_of.code} > ? ? ?/program?part_of.code='xxx' > > I think it would be a modest improvement over a SQL alternative. > > I'm adding it to the roadmap right now, but don't hold your breath -- Q4 > this year or early next year is a realistic ETA. ?I expect the > implementation to be at least moderately painful and, obviously, it > could only work with those backends that support WITH RECURSIVE. O well... I was hoping for some some quick-queries (one-liners?) to probe firefox's bookmarks (which are in sqlite) From skunkworks at rikishi42.net Sat Jan 22 15:22:27 2011 From: skunkworks at rikishi42.net (Rikishi42) Date: Sat, 22 Jan 2011 21:22:27 +0100 Subject: Need GUI pop-up to edit a (unicode ?) string Message-ID: <3tqr08-bj2.ln1@murmur.very.softly> I'm in need for a graphical pop-up that will display a (unicode ?) string in a field, allow the user to change it and return the modified string. Maybe also keep the original one displayed above it. Something like this: +-------------------------------------------------+ | Please confirm or edit the following string | | | | Original_example_string | | | | +-------------------------------------------+ | | | Original_about_to_be_changed | | | +-------------------------------------------+ | | | | OK | | | +-------------------------------------------------+ I've never used any kind of graphical interface programing before, so I don't have a clue where to start. This would, however, be the *only* GUI part in the app at this point. >From what I can see the solution lays with PyQT, but the docs I find are courses that aim to teach the whole GUI tool. I only need a little pop-up to alow a user to edit part of a filename, for instance. I'm using Python 2.6.x on various Linux platforms (mainly openSUSE and Mint) and on Windows. Windows support is not important, in this case. -- When in doubt, use brute force. -- Ken Thompson From kb1pkl at aim.com Sat Jan 22 16:10:01 2011 From: kb1pkl at aim.com (Corey Richardson) Date: Sat, 22 Jan 2011 16:10:01 -0500 Subject: Need GUI pop-up to edit a (unicode ?) string In-Reply-To: <3tqr08-bj2.ln1@murmur.very.softly> References: <3tqr08-bj2.ln1@murmur.very.softly> Message-ID: <4D3B47A9.4080303@aim.com> On 01/22/2011 03:22 PM, Rikishi42 wrote: > > I'm in need for a graphical pop-up that will display a (unicode ?) string in > a field, allow the user to change it and return the modified string. > > Maybe also keep the original one displayed above it. > > > Something like this: > +-------------------------------------------------+ > | Please confirm or edit the following string | > | | > | Original_example_string | > | | > | +-------------------------------------------+ | > | | Original_about_to_be_changed | | > | +-------------------------------------------+ | > | | > | OK | > | | > +-------------------------------------------------+ > > > I've never used any kind of graphical interface programing before, so I > don't have a clue where to start. > This would, however, be the *only* GUI part in the app at this point. > >> From what I can see the solution lays with PyQT, but the docs I find are > courses that aim to teach the whole GUI tool. I only need a little pop-up to > alow a user to edit part of a filename, for instance. > > > I'm using Python 2.6.x on various Linux platforms (mainly openSUSE and Mint) > and on Windows. Windows support is not important, in this case. > > > If that is all you need, I suggest Tkinter. Nice and easy, comes built into Python. Looks like you need two labels, an entry, and a button. When I was learning Tkinter I used http://effbot.org/tkinterbook/. Hope it helped, ~Corey From debatem1 at gmail.com Sat Jan 22 17:57:58 2011 From: debatem1 at gmail.com (geremy condra) Date: Sat, 22 Jan 2011 14:57:58 -0800 Subject: Need GUI pop-up to edit a (unicode ?) string In-Reply-To: <3tqr08-bj2.ln1@murmur.very.softly> References: <3tqr08-bj2.ln1@murmur.very.softly> Message-ID: On Sat, Jan 22, 2011 at 12:22 PM, Rikishi42 wrote: > > I'm in need for a graphical pop-up that will display a (unicode ?) string in > a field, allow the user to change it and return the modified string. > > Maybe also keep the original one displayed above it. > > > Something like this: > +-------------------------------------------------+ > | ? Please confirm or edit the following string ? | > | ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? | > | ? ? Original_example_string ? ? ? ? ? ? ? ? ? ? | > | ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? | > | ?+-------------------------------------------+ ?| > | ?| ?Original_about_to_be_changed ? ? ? ? ? ? | ?| > | ?+-------------------------------------------+ ?| > | ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? | > | ? ? ? ? ? ? ? ? ? ? OK ? ? ? ? ? ? ? ? ? ? ? ? ?| > | ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? | > +-------------------------------------------------+ > > > I've never used any kind of graphical interface programing before, so I > don't have a clue where to start. > This would, however, be the *only* GUI part in the app at this point. > > >From what I can see the solution lays with PyQT, but the docs I find are > courses that aim to teach the whole GUI tool. I only need a little pop-up to > alow a user to edit part of a filename, for instance. > > > I'm using Python 2.6.x on various Linux platforms (mainly openSUSE and Mint) > and on Windows. Windows support is not important, in this case. If windows doesn't matter to you, just use Zenity. Here's a python function wrapping zenity that does what you want: import commands def confirm_or_edit(s): zenity = 'zenity' mode = '--entry' text = "--text='Please confirm or edit the following string:'" title = "--title='confirm or edit'" entry = "--entry-text='%s'" % s cmd = ' '.join([zenity, mode, text, title, entry]) status, output = commands.getstatusoutput(cmd) if status: raise Exception("Couldn't run zenity") return output There's also a full-blown API for zenity, but this should do what you want. Geremy Condra From skunkworks at rikishi42.net Sat Jan 22 18:27:13 2011 From: skunkworks at rikishi42.net (Rikishi42) Date: Sun, 23 Jan 2011 00:27:13 +0100 Subject: Need GUI pop-up to edit a (unicode ?) string References: <3tqr08-bj2.ln1@murmur.very.softly> Message-ID: On 2011-01-22, Corey Richardson wrote: > On 01/22/2011 03:22 PM, Rikishi42 wrote: >> >> I'm in need for a graphical pop-up that will display a (unicode ?) string in >> a field, allow the user to change it and return the modified string. >> > If that is all you need, I suggest Tkinter. Nice and easy, comes built > into Python. Looks like you need two labels, an entry, and a button. > When I was learning Tkinter I used http://effbot.org/tkinterbook/. I had to add Tkinter, which was not isntalled on my machine. But it looks easy enough, I'll definitively look into it. Thanks ! -- When in doubt, use brute force. -- Ken Thompson From pavlovevidence at gmail.com Sat Jan 22 18:38:42 2011 From: pavlovevidence at gmail.com (Carl Banks) Date: Sat, 22 Jan 2011 15:38:42 -0800 (PST) Subject: Best way to administer code updates to server daemon References: <7xy66dwlsq.fsf@ruckus.brouhaha.com> Message-ID: <3090b1fe-0d42-494b-9a05-36d4febcdcaf@k9g2000pre.googlegroups.com> On Jan 21, 9:27?pm, Paul Rubin wrote: > Maybe there are other ideas possible too. I don't know of any off-hand but there are probably virtual network drivers that sit between your server and the network stack that can keep a connection open. It seems like it'd be a common enough need that someone's figured out an easy way to handle it. Carl Banks From rantingrick at gmail.com Sat Jan 22 19:07:31 2011 From: rantingrick at gmail.com (rantingrick) Date: Sat, 22 Jan 2011 16:07:31 -0800 (PST) Subject: [Code Challenge] WxPython versus Tkinter. Message-ID: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> WxPython versus Tkinter (A code battle to the death!) by Rick Johnson. I have in many threads declared that Tkinter (and TclTk) is currently --and has been for a decade-- the wrong choice for Python's stdlib GUI. Throughout the 90's Tkinter was fine. However we have been in the 21st century for more than a decade and Tkinter is no longer relevant. Many people have argued (weakly) that Tkinter is still valid. However their arguments have been mostly baseless opinions that sadly lack vision for the future. In this thread i intend to slay my enemies with cold hard facts based on code. It is time to put your code where your mouth is (or you foot). This will be an open challenge to *anyone* in this community, in the world, and *even* the great Guido van Rossum himself! It is now time for you (python community) to prove the worth of Tkinter or accept its demise at my hands! Some of you may think this sounds like an impossible challenge. How can one man defend his position against the entire world! Yes, it would seem impossible for one man to face an entire community in open challenge! And in most cases only a fool would challenge the world. However, i have not one ounce of fear within me while facing these odds because my position is the correct position. My position is based on facts and NOT friendship, truth and NOT tantrums, and finally vision NOT vengance! I am on the correct side of history! It is time to prove once and for all how dated and worthless Tkinter is compared to wxPython. Yes, WxPython is not as advanced as i would like it to be for a 21st century GUI library. However compared to Tkinter, Wx is light years ahead! Wx is our best hope to move Python into the 21st century. So now is the time for all you naysayers, trolls, and minions to face me in mortal combat within the arena of truth and righteousness. Ready your minds and wield your text editors for we shall battle for the glory of Python! And when i have slayed the fools with their own foolishness then ye all shall be enlightened! So PUT UP OR SHUT THE HELL UP! --------------------------------------- Challenge 1: (Simple Directory Viewer) --------------------------------------- Create a simple Directory Viewer GUI. You CANNOT use a treectrl! The point of this challenge is to show that Tkinter has no support for a true ListCtrl widget. However the Wx::ListCtrl is fully featured! For wxPython the code is simply wielding a few built in classes. For Tkinter no such ListCtrl functionality exists. You CAN create the functionality yourself (and i know this because i HAVE created it!) however it involves tons of work and still can't hold a candle to the wx::ListCtrl --------------- Requirements: --------------- How the user navigates to a folder is not important but you must display the list of files/folders in two view modes with icons; 1. Display files in both ReportView and ListView. * Reportview: ...scrollable vertical list with three columns. * Listview: ...scrollable horizontal-ly wrapping list. Note: If you do not understand the view modes just run my code for an example. But the user must be able to switch between these two modes easily. How the switching is done is unimportant -- I simply used two buttons. 2. Columns * Minimum of three cols; Name, Size, and Type (reportview). * the "Name" column must include an icon AND label (both views). * columns must be sortable by the user (reportview). * columns must be sizable by the user (reportview). 3. Items * All must be editable in place (no popup editing allowed!). * All items must be selectable/deselectable by user. * All items must be delete-able by the user. That is the challenge. Step forth and battle if you can! ----------------- WxPython code: ----------------- https://sites.google.com/site/thefutureofpython/home/code-challenges I await any challengers... From no.email at nospam.invalid Sat Jan 22 19:37:49 2011 From: no.email at nospam.invalid (Paul Rubin) Date: Sat, 22 Jan 2011 16:37:49 -0800 Subject: Best way to administer code updates to server daemon References: <7xy66dwlsq.fsf@ruckus.brouhaha.com> <3090b1fe-0d42-494b-9a05-36d4febcdcaf@k9g2000pre.googlegroups.com> Message-ID: <7xhbd0xxnm.fsf@ruckus.brouhaha.com> Carl Banks writes: > I don't know of any off-hand but there are probably virtual network > drivers that sit between your server and the network stack that can > keep a connection open. > > It seems like it'd be a common enough need that someone's figured out > an easy way to handle it. I don't see big conceptual obstacles to making a network stack itself be able to package up the internal state of a TCP or even SSL connection, and hand it off to another computer over a LAN, so that you could have graceful turnover of live connections. They could even cross-update info about the connection for hardware failover. I woder if (e.g.) Erlang OTP already does something like that. I worked on a device with such a feature a while back, based on very special purpose hardware and software and a special (hardware) communication bus for the purpose, but with some careful coding it can probably be done with stock hardware and ethernet. From kwa at kuwata-lab.com Sat Jan 22 21:00:43 2011 From: kwa at kuwata-lab.com (Makoto Kuwata) Date: Sun, 23 Jan 2011 11:00:43 +0900 Subject: [ANN] Oktest 0.6.0 released - a new-style testing library Message-ID: Hi all, I released Oktest 0.6.0. http://pypi.python.org/pypi/Oktest/ http://packages.python.org/Oktest/ Oktest is a new-style testing library for Python. :: from oktest import ok ok (x) > 0 # same as assert_(x > 0) ok (s) == 'foo' # same as assertEqual(s, 'foo') ok (s) != 'foo' # same as assertNotEqual(s, 'foo') ok (f).raises(ValueError) # same as assertRaises(ValueError, f) ok (u'foo').is_a(unicode) # same as assert_(isinstance(u'foo', unicode)) not_ok (u'foo').is_a(int) # same as assert_(not isinstance(u'foo', int)) ok ('A.txt').is_file() # same as assert_(os.path.isfile('A.txt')) not_ok ('A.txt').is_dir() # same as assert_(not os.path.isdir('A.txt')) See http://packages.python.org/Oktest/ for details. NOTICE!! Oktest is a young project and specification may change in the future. New features in this release ---------------------------- Oktest supports Tracer class which can be mock or stub of function or method. Example to create fake object:: ## create fake objects from oktest.tracer import Tracer tr = Tracer() foo = tr.fake_obj(m1=100, m2=200) # method name and return-value bar = tr.fake_obj(m3=lambda self, x: x+1) # method name and body ## call fake methods ok (bar.m3(0)) == 1 ok (foo.m2(1,2,3)) == 200 # any argument can be passed ok (foo.m1(x=123)) == 100 # any argument can be passed ## check results ok (repr(tr[0])) == 'm3(0) #=> 1' ok (repr(tr[1])) == 'm2(1, 2, 3) #=> 200' ok (repr(tr[2])) == 'm1(x=123) #=> 100' There are several ways to check results:: from oktest.tracer import Tracer tr = Tracer() obj = tr.fake_obj(meth=9) ok (obj.meth(1, 2, x=3)) == 9 ## check results ok (repr(tr[0])) == 'meth(1, 2, x=3) #=> 9' ## or ok (tr[0].list()) == [obj, 'meth', (1, 2), {'x': 3}, 9] ## or ok (tr[0]) == [obj, 'meth', (1, 2), {'x': 3}, 9] ## or ok (tr[0].receiver).is_(obj) ok (tr[0].name) == 'meth' ok (tr[0].args) == (1, 2) ok (tr[0].kwargs) == {'x': 3} ok (tr[0].ret) == 9 Example to trace method call:: class Foo(object): def m1(self, x): return x + 1 def m2(self, y): return y + 1 obj = Foo() ## trace methods from oktest.tracer import Tracer tr = Tracer() def dummy(original_func, *args, **kwargs): #return original_func(*args, **kwargs) return 100 tr.fake_method(obj, m1=dummy, m2=200) ## call methods ok (obj.m1(1)) == 100 ok (obj.m2(2)) == 200 ## check results ok (tr[0]) == [obj, 'm1', (1,), {}, 100] ok (tr[1]) == [obj, 'm2', (2,), {}, 200] Example to trace function call:: def f(x): return x+1 def g(y): return f(y+1) + 1 ## trace functions from oktest.tracer import Tracer tr = Tracer() f = tr.trace_func(f) g = tr.trace_func(g) ## call functions ok (g(0)) == 3 ## check results ok (tr[0]) == [None, 'g', (0,), {}, 3] ok (tr[1]) == [None, 'f', (1,), {}, 2] Example to fake method call:: class Foo(object): def m1(self, x): return x + 1 def m2(self, y): return y + 1 obj = Foo() ## fake methods from oktest.tracer import Tracer tr = Tracer() def dummy(original_func, *args, **kwargs): #return original_func(*args, **kwargs) return 100 tr.fake_method(obj, m1=dummy, m2=200) ## call method ok (obj.m1(1)) == 100 ok (obj.m2(2)) == 200 ## check results ok (tr[0]) == [obj, 'm1', (1,), {}, 100] ok (tr[1]) == [obj, 'm2', (2,), {}, 200] Example to fake function call:: def f(x): return x*2 ## fake a function def dummy(original_func, x): #return original_func(x) return 'x=%s' % repr(x) from oktest.tracer import Tracer tr = Tracer() f = tr.fake_func(f, dummy) ## call function ok (f(3)) == 'x=3' ## check results ok (tr[0]) == [None, 'f', (3,), {}, 'x=3'] Have a nice weekend! -- regards, makoto kuwata From tjreedy at udel.edu Sat Jan 22 22:39:47 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Sat, 22 Jan 2011 22:39:47 -0500 Subject: [Code Challenge] WxPython versus Tkinter. In-Reply-To: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> Message-ID: On 1/22/2011 7:07 PM, rantingrick wrote: Near the beginning of this thread, I gently challenged you to produce a concrete, practical proposal for an stdlib addition that could be critiqued and improved. When you asked for problems with wxwidgets/wxpython, I gave some. Still waiting. > So PUT UP OR SHUT THE HELL UP! -- Terry Jan Reedy From dirk at pfln.invalid Sun Jan 23 01:15:38 2011 From: dirk at pfln.invalid (Deadly Dirk) Date: Sun, 23 Jan 2011 06:15:38 +0000 (UTC) Subject: Which non SQL Database ? References: Message-ID: On Sat, 04 Dec 2010 16:42:36 -0600, Jorge Biquez wrote: > Hello all. > > Newbie question. Sorry. > > As part of my process to learn python I am working on two personal > applications. Both will do it fine with a simple structure of data > stored in files. I now there are lot of databases around I can use but I > would like to know yoor advice on what other options you would consider > for the job (it is training so no pressure on performance). One > application will run as a desktop one,under Windows, Linux, Macintosh, > being able to update data, not much, not complex, not many records. The > second application, running behind web pages, will do the same, I mean, > process simple data, updating showing data. not much info, not complex. > As an excersice it is more than enough I guess and will let me learn > what I need for now. Talking with a friend about what he will do (he use > C only) he suggest to take a look on dBase format file since it is a > stable format, fast and the index structure will be fine or maybe go > with BD (Berkley) database file format (I hope I understood this one > correctly) . Plain files it is not an option since I would like to have > option to do rapid searches. > > What would do you suggest to take a look? If possible available under > the 3 plattforms. > > Thanks in advance for your comments. > > Jorge Biquez Well, two NoSQL databases that I have some experience with are MongoDB and CouchDB. The choice among them depends on your application. CouchDB is an extremely simple to set up, it is all about the web interface, as a matter of fact it communicates with the outside world using HTTP protocol, returning JSON objects. You can configure it using curl. It is also extremely fast but it doesn't allow you to run ad hoc queries. You have to create something called a "view". This is more akin to what people in the RDBMS world call a "materialized view". Views are created by running JavaScript function on every document in the database. Results are stored in B*Tree index and then modified as documents are being inserted, updated or deleted. It is completely schema free, there are no tables, collections or "shards". The primary language for programming Couch is JavaScript. The same thing applies to MongoDB which is equally fast but does allow ad hoc queries and has quite a few options how to do them. It allows you to do the same kind of querying as RDBMS software, with the exception of joins. No joins. It also allows map/reduce queries using JavaScript and is not completely schema free. Databases have sub-objects called "collections" which can be indexed or partitioned across several machines ("sharding"), which is an excellent thing for building shared-nothing clusters. Collections can be indexed and can be aggregated using JavaScript and Google's map/reduce. Scripting languages like Python are very well supported and linked against MongoDB, which tends to be faster then communicating using HTTP. I find MongoDB well suited for what is traditionally known as data warehousing. Of course, traditional RDBMS specimens like MySQL, PostgreSQL, Firebird, Oracle, MS SQL Server or DB2 still rule supreme and most of the MVC tools like Django or Turbo Gears are made for RDBMS schemas and can read things like the primary or foreign keys and include that into the application. In short, there is no universal answer to your question. If prices are a consideration, Couch, Mongo, MySQL, PostgreSQL, Firebird and SQL Lite 3 all cost about the same: $0. You will have to learn significantly less for starting with a NoSQL database, but if you need to create a serious application fast, RDBMS is still the right answer. You may want to look at this Youtube clip entitled "MongoDB is web scale": http://www.youtube.com/watch?v=b2F-DItXtZs -- I don't think, therefore I am not. From stackslip at gmail.com Sun Jan 23 01:43:04 2011 From: stackslip at gmail.com (Slie) Date: Sat, 22 Jan 2011 21:43:04 -0900 Subject: I'm interested in calculating time down to the femtosecond. Message-ID: <076E4FFD-54FA-4665-9F32-E446731D52C7@gmail.com> I found that there was a code submission at NumPy 1.4 but I can not find in the documentation search for Date nor have found anything other then that discussion of the ability. Anyone have any ideas suggestions? I just want my program to be able to calculate it nothing special. Thanks, From orasnita at gmail.com Sun Jan 23 02:53:25 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Sun, 23 Jan 2011 09:53:25 +0200 Subject: [Code Challenge] WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> Message-ID: From: "rantingrick" > > WxPython versus Tkinter (A code battle to the death!) > > by Rick Johnson. > > I have in many threads declared that Tkinter (and TclTk) is currently > --and has been for a decade-- the wrong choice for Python's stdlib > GUI. Throughout the 90's Tkinter was fine. However we have been in the > 21st century for more than a decade and Tkinter is no longer relevant. > Many people have argued (weakly) that Tkinter is still valid. However > their arguments have been mostly baseless opinions that sadly lack > vision for the future. > > In this thread i intend to slay my enemies with cold hard facts based > on code. It is time to put your code where your mouth is (or you > foot). This will be an open challenge to *anyone* in this community, > in the world, and *even* the great Guido van Rossum himself! It is now > time for you (python community) to prove the worth of Tkinter or > accept its demise at my hands! > > Some of you may think this sounds like an impossible challenge. How > can one man defend his position against the entire world! Yes, it > would seem impossible for one man to face an entire community in open > challenge! And in most cases only a fool would challenge the world. > However, i have not one ounce of fear within me while facing these > odds because my position is the correct position. My position is based > on facts and NOT friendship, truth and NOT tantrums, and finally > vision NOT vengance! I am on the correct side of history! > > It is time to prove once and for all how dated and worthless Tkinter > is compared to wxPython. Yes, WxPython is not as advanced as i would > like it to be for a 21st century GUI library. However compared to > Tkinter, Wx is light years ahead! Wx is our best hope to move Python > into the 21st century. > > So now is the time for all you naysayers, trolls, and minions to face > me in mortal combat within the arena of truth and righteousness. Ready > your minds and wield your text editors for we shall battle for the > glory of Python! And when i have slayed the fools with their own > foolishness then ye all shall be enlightened! > > So PUT UP OR SHUT THE HELL UP! > > > --------------------------------------- > Challenge 1: (Simple Directory Viewer) > --------------------------------------- > > Create a simple Directory Viewer GUI. You CANNOT use a treectrl! The > point of this challenge is to show that Tkinter has no support for a > true ListCtrl widget. However the Wx::ListCtrl is fully featured! For > wxPython the code is simply wielding a few built in classes. For > Tkinter no such ListCtrl functionality exists. You CAN create the > functionality yourself (and i know this because i HAVE created it!) > however it involves tons of work and still can't hold a candle to the > wx::ListCtrl > > --------------- > Requirements: > --------------- > > How the user navigates to a folder is not important but you must > display the list of files/folders in two view modes with icons; > > 1. Display files in both ReportView and ListView. > > * Reportview: > ...scrollable vertical list with three columns. > > * Listview: > ...scrollable horizontal-ly wrapping list. > > Note: If you do not understand the view modes just run my code for an > example. But the user must be able to switch between these two modes > easily. How the switching is done is unimportant -- I simply used two > buttons. > > 2. Columns > * Minimum of three cols; Name, Size, and Type (reportview). > * the "Name" column must include an icon AND label (both views). > * columns must be sortable by the user (reportview). > * columns must be sizable by the user (reportview). > > 3. Items > * All must be editable in place (no popup editing allowed!). > * All items must be selectable/deselectable by user. > * All items must be delete-able by the user. > > That is the challenge. Step forth and battle if you can! > > ----------------- > WxPython code: > ----------------- > > https://sites.google.com/site/thefutureofpython/home/code-challenges I have downloaded that simple program, launched it, and I've tested it with JAWS screen reader. It was fully accessible out of the box. Have you done something special for making it accessible for screen readers? (I guess not). Can be the same thing done with Tkinter? Octavian From stefan_ml at behnel.de Sun Jan 23 05:10:25 2011 From: stefan_ml at behnel.de (Stefan Behnel) Date: Sun, 23 Jan 2011 11:10:25 +0100 Subject: [Code Challenge] WxPython versus Tkinter. In-Reply-To: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> Message-ID: rantingrick, 23.01.2011 01:07: > I have in many threads declared that Tkinter (and TclTk) is currently > --and has been for a decade-- the wrong choice for Python's stdlib > GUI. [...] > It is time to prove once and for all how dated and worthless Tkinter > is compared to wxPython. What's the aim of that prove? If you are trying to pave the ground for getting wxPython in the stdlib instead of tkinter, I think that's bound to fail. Similar proposals have been rejected with the simple argument that adding a large library with a huge C dependency to the standard library without having a rock solid maintainer for both of them is not going to happen. Are you volunteering to maintain both wxPython and wxWidgets in the standard library for, say, twenty years to come? Stefan From rustompmody at gmail.com Sun Jan 23 05:18:34 2011 From: rustompmody at gmail.com (rusi) Date: Sun, 23 Jan 2011 02:18:34 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> Message-ID: On Jan 23, 5:07?am, rantingrick wrote: > WxPython versus Tkinter (A code battle to the death!) > > by Rick Johnson. > > I have in many threads declared that Tkinter (and TclTk) is currently > --and has been for a decade-- the wrong choice for Python's stdlib > GUI. Throughout the 90's Tkinter was fine. However we have been in the > 21st century for more than a decade and Tkinter is no longer relevant. > Many people have argued (weakly) that Tkinter is still valid. However > their arguments have been mostly baseless opinions that sadly lack > vision for the future. > > In this thread i intend to slay my enemies with cold hard facts based > on code. It is time to put your code where your mouth is (or you > foot). This will be an open challenge to *anyone* in this community, > in the world, and *even* the great Guido van Rossum himself! It is now > time for you (python community) to prove the worth of Tkinter or > accept its demise at my hands! > > Some of you may think this sounds like an impossible challenge. How > can one man defend his position against the entire world! Yes, it > would seem impossible for one man to face an entire community in open > challenge! And in most cases only a fool would challenge the world. > However, i have not one ounce of fear within me while facing these > odds because my position is the correct position. My position is based > on facts and NOT friendship, truth and NOT tantrums, and finally > vision NOT vengance! I am on the correct side of history! > > It is time to prove once and for all how dated and worthless Tkinter > is compared to wxPython. Yes, WxPython is not as advanced as i would > like it to be for a 21st century GUI library. However compared to > Tkinter, Wx is light years ahead! Wx is our best hope to move Python > into the 21st century. > > So now is the time for all you naysayers, trolls, and minions to face > me in mortal combat within the arena of truth and righteousness. Ready > your minds and wield your text editors for we shall battle for the > glory of Python! And when i have slayed the fools with their own > foolishness then ye all shall be enlightened! > > So PUT UP OR SHUT THE HELL UP! > > --------------------------------------- > ?Challenge 1: (Simple Directory Viewer) > --------------------------------------- > > Create a simple Directory Viewer GUI. You CANNOT use a treectrl! ?The > point of this challenge is to show that Tkinter has no support for a > true ListCtrl widget. However the Wx::ListCtrl is fully featured! For > wxPython the code is simply wielding a few built in classes. For > Tkinter no such ListCtrl functionality exists. You CAN create the > functionality yourself (and i know this because i HAVE created it!) > however it involves tons of work and still can't hold a candle to the > wx::ListCtrl > > --------------- > ?Requirements: > --------------- > > How the user navigates to a folder is not important but you must > display the list of files/folders in two view modes with icons; > > ?1. Display files in both ReportView and ListView. > > ? * Reportview: > ? ? ...scrollable vertical list with three columns. > > ? * Listview: > ? ? ...scrollable horizontal-ly wrapping list. > > Note: If you do not understand the view modes just run my code for an > example. But the user must be able to switch between these two modes > easily. How the switching is done is unimportant -- I simply used two > buttons. > > ?2. Columns > ? * Minimum of three cols; Name, Size, and Type (reportview). > ? * the "Name" column must include an icon AND label (both views). > ? * columns must be sortable by the user (reportview). > ? * columns must be sizable by the user (reportview). > > ?3. Items > ? * All must be editable in place (no popup editing allowed!). > ? * All items must be selectable/deselectable by user. > ? * All items must be delete-able by the user. > > That is the challenge. Step forth and battle if you can! > > ----------------- > ?WxPython code: > ----------------- > > https://sites.google.com/site/thefutureofpython/home/code-challenges > > I await any challengers... Tried the code with debian sid and default python (2.6) I get (after some loading... statements) Segmentation fault [Actually this is the first time in my 10 years of python that Ive seen a pure python module segfault :-) ] From steve+comp.lang.python at pearwood.info Sun Jan 23 05:30:14 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 23 Jan 2011 10:30:14 GMT Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> Message-ID: <4d3c0336$0$29983$c3e8da3$5496439d@news.astraweb.com> On Sun, 23 Jan 2011 02:18:34 -0800, rusi wrote: >> ?WxPython code: [...] > Tried the code with debian sid and default python (2.6) > > I get (after some loading... statements) > > Segmentation fault > > [Actually this is the first time in my 10 years of python that Ive seen > a pure python module segfault :-) ] wxPython is a front end to the wxWidgets (formerly wxWindows) toolkit, which is C++. I imagine that's what seg faulted. -- Steven From askutt at gmail.com Sun Jan 23 08:35:06 2011 From: askutt at gmail.com (Adam Skutt) Date: Sun, 23 Jan 2011 05:35:06 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> Message-ID: <480571f5-5731-4f8b-9cb4-1468478711bf@c39g2000yqi.googlegroups.com> On Jan 22, 7:07?pm, rantingrick wrote: > So PUT UP OR SHUT THE HELL UP! You first. Write actual working code first and then you can challenge people. I found 5 bugs in your code before I quit looking[1]. Can you find and fix them all? Also, I'm entirely ignoring the bad styling, bad default sizing, horrible UI, the fact you call rename "Edit", and the fact the context menu doesn't do anything. All of the are legitimate technical errors, i.e., you coded the program wrong. In the spirit of community I open the bug finding to everyone, but humbly ask you don't tell Mr. "rantingrick" Johnson about them. It can be our little secret ;) Adam [1] I think there might even be more, but I got lazy. From roy at panix.com Sun Jan 23 11:12:35 2011 From: roy at panix.com (Roy Smith) Date: Sun, 23 Jan 2011 11:12:35 -0500 Subject: Which non SQL Database ? References: Message-ID: In article , Deadly Dirk wrote: > The same thing applies to MongoDB which is equally fast but does allow ad > hoc queries and has quite a few options how to do them. It allows you to > do the same kind of querying as RDBMS software, with the exception of > joins. No joins. Well, sort of. You can use forEach() to get some join-like functionality. You don't get the full join optimization that SQL gives you, but at least you get to do some processing on the server side so you don't have to ship 40 gazillion records over the network to pick the three you wanted. > It also allows map/reduce queries using JavaScript and > is not completely schema free. What do you mean by "not completely schema free"? > Databases have sub-objects called "collections" which can be indexed > or partitioned across several machines ("sharding"), which is an > excellent thing for building shared-nothing clusters. We've been running Mongo 1.6.x for a few months. Based on our experiences, I'd say sharding is definitely not ready for prime time. There's two issues; stability and architecture. First, stability. We see mongos (the sharding proxy) crash a couple of times a week. We finally got the site stabilized by rigging upstart to monitor and automatically restart mongos when it crashes. Fortunately, mongos crashing doesn't cause any data loss (at least not that we've noticed). Hopefully this is something the 10gen folks will sort out in the 1.8 release. The architectural issues are more complex. Mongo can enforce uniqueness on a field, but only on non-sharded collection. Security (i.e. password authentication) does not work in a sharded environment. If I understand the release notes correctly, that's something which may get fixed in some future release. > Scripting languages like Python are > very well supported and linked against MongoDB The Python interface is very nice. In some ways, the JS interface is nicer, only because you can get away with less quoting, i.e. JS: find({inquisition: {$ne: 'spanish'}} Py: find({'inquisition': {'$ne': 'spanish'}} The PHP interface is (like everything in PHP), sucky: PHP: find(array('inquisition' => array('$ne' => 'spanish')) The common thread here is that unlike SQL, you're not feeding the database a string which it parses, you're feeding it a data structure. You're stuck with whatever data structure syntax the host language supports. Well, actually, that's not true. If you wanted to, you could write a front end which lets you execute: "find where inquisition != spanish" and have code to parse that and turn it into the required data structure. The odds of anybody doing that are pretty low, however. It would just feel wrong. In much the same way that SQLAlchemy's functional approach to building a SQL query just feels wrong to somebody who knows SQL. > I find MongoDB well suited for what is > traditionally known as data warehousing. I'll go along with that. It's a way to build a fast (possibly distributed, if they get sharding to work right) network datastore with some basic query capability. Compared to SQL, you end up doing a lot more work on the application side, and take on a lot more of the responsibility to enforce data integrity yourself. > You may want to look > at this Youtube clip entitled "MongoDB is web scale": > > http://www.youtube.com/watch?v=b2F-DItXtZs That's the funniest thing I've seen in a long time. The only sad part is that it's all true. There are some nice things to NO-SQL databases (particularly the schema-free part). A while ago, we discovered that about 200 of the 300,000 documents in one of our collections were effectively duplicates of other documents ("document" in mongo-speak means "record" or perhaps "row" in SQL-speak). It was trivial to add "is_dup_of" fields to just those 200 records, and a little bit of code in our application to check the retrieved documents for that field and retrieve the pointed-to document. In SQL, that would have meant adding another column, or perhaps another table. Either way would have been far more painful than the fix we were able to do in mongo. From rantingrick at gmail.com Sun Jan 23 11:57:50 2011 From: rantingrick at gmail.com (rantingrick) Date: Sun, 23 Jan 2011 08:57:50 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> Message-ID: On Jan 22, 9:39?pm, Terry Reedy wrote: > On 1/22/2011 7:07 PM, rantingrick wrote: > > Near the beginning of this thread, I gently challenged you to produce a > concrete, practical proposal for an stdlib addition that could be > critiqued and improved. When you asked for problems with > wxwidgets/wxpython, I gave some. Still waiting. You may have done this however i do not remember. With all the trolling that was going on (not you) i may have missed it. From rantingrick at gmail.com Sun Jan 23 11:59:59 2011 From: rantingrick at gmail.com (rantingrick) Date: Sun, 23 Jan 2011 08:59:59 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> Message-ID: <8e180134-c19b-4762-ae08-d78ed9034f29@j32g2000yqc.googlegroups.com> On Jan 23, 1:53?am, "Octavian Rasnita" wrote: > I have downloaded that simple program, launched it, and I've tested it with JAWS screen reader. > It was fully accessible out of the box. Excellent! > Have you done something special for making it accessible for screen readers? (I guess not). I did nothing to make the code more accessible, that is just another great attribute of 21st cenury GUI libraries. > Can be the same thing done with Tkinter? Not that i am aware of. From arndt.roger at addcom.de Sun Jan 23 12:06:57 2011 From: arndt.roger at addcom.de (Arndt Roger Schneider) Date: Sun, 23 Jan 2011 18:06:57 +0100 Subject: [Code Challenge] WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> Message-ID: rantingrick schrieb: [snip] 1. You cannot define the terms--restrict your opponent-- and battle it yourselves. 2. Your specified directory browser is useless. --At least define that the directory browser must have constant complexity to work with volatile data over a network... -roger From rantingrick at gmail.com Sun Jan 23 12:09:56 2011 From: rantingrick at gmail.com (rantingrick) Date: Sun, 23 Jan 2011 09:09:56 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> Message-ID: <033c3f90-03fb-4f65-bbae-bbc80a262685@l22g2000vbp.googlegroups.com> On Jan 23, 4:18?am, rusi wrote: > On Jan 23, 5:07?am, rantingrick wrote: > > > > > > > > > > > WxPython versus Tkinter (A code battle to the death!) > > > by Rick Johnson. > > > I have in many threads declared that Tkinter (and TclTk) is currently > > --and has been for a decade-- the wrong choice for Python's stdlib > > GUI. Throughout the 90's Tkinter was fine. However we have been in the > > 21st century for more than a decade and Tkinter is no longer relevant. > > Many people have argued (weakly) that Tkinter is still valid. However > > their arguments have been mostly baseless opinions that sadly lack > > vision for the future. > > > In this thread i intend to slay my enemies with cold hard facts based > > on code. It is time to put your code where your mouth is (or you > > foot). This will be an open challenge to *anyone* in this community, > > in the world, and *even* the great Guido van Rossum himself! It is now > > time for you (python community) to prove the worth of Tkinter or > > accept its demise at my hands! > > > Some of you may think this sounds like an impossible challenge. How > > can one man defend his position against the entire world! Yes, it > > would seem impossible for one man to face an entire community in open > > challenge! And in most cases only a fool would challenge the world. > > However, i have not one ounce of fear within me while facing these > > odds because my position is the correct position. My position is based > > on facts and NOT friendship, truth and NOT tantrums, and finally > > vision NOT vengance! I am on the correct side of history! > > > It is time to prove once and for all how dated and worthless Tkinter > > is compared to wxPython. Yes, WxPython is not as advanced as i would > > like it to be for a 21st century GUI library. However compared to > > Tkinter, Wx is light years ahead! Wx is our best hope to move Python > > into the 21st century. > > > So now is the time for all you naysayers, trolls, and minions to face > > me in mortal combat within the arena of truth and righteousness. Ready > > your minds and wield your text editors for we shall battle for the > > glory of Python! And when i have slayed the fools with their own > > foolishness then ye all shall be enlightened! > > > So PUT UP OR SHUT THE HELL UP! > > > --------------------------------------- > > ?Challenge 1: (Simple Directory Viewer) > > --------------------------------------- > > > Create a simple Directory Viewer GUI. You CANNOT use a treectrl! ?The > > point of this challenge is to show that Tkinter has no support for a > > true ListCtrl widget. However the Wx::ListCtrl is fully featured! For > > wxPython the code is simply wielding a few built in classes. For > > Tkinter no such ListCtrl functionality exists. You CAN create the > > functionality yourself (and i know this because i HAVE created it!) > > however it involves tons of work and still can't hold a candle to the > > wx::ListCtrl > > > --------------- > > ?Requirements: > > --------------- > > > How the user navigates to a folder is not important but you must > > display the list of files/folders in two view modes with icons; > > > ?1. Display files in both ReportView and ListView. > > > ? * Reportview: > > ? ? ...scrollable vertical list with three columns. > > > ? * Listview: > > ? ? ...scrollable horizontal-ly wrapping list. > > > Note: If you do not understand the view modes just run my code for an > > example. But the user must be able to switch between these two modes > > easily. How the switching is done is unimportant -- I simply used two > > buttons. > > > ?2. Columns > > ? * Minimum of three cols; Name, Size, and Type (reportview). > > ? * the "Name" column must include an icon AND label (both views). > > ? * columns must be sortable by the user (reportview). > > ? * columns must be sizable by the user (reportview). > > > ?3. Items > > ? * All must be editable in place (no popup editing allowed!). > > ? * All items must be selectable/deselectable by user. > > ? * All items must be delete-able by the user. > > > That is the challenge. Step forth and battle if you can! > > > ----------------- > > ?WxPython code: > > ----------------- > > >https://sites.google.com/site/thefutureofpython/home/code-challenges > > > I await any challengers... > > Tried the code with debian sid and default python (2.6) > > I get (after some loading... statements) > > Segmentation fault > > [Actually this is the first time in my 10 years of python that Ive > seen a pure python module segfault :-) ] Congratulations genius! However if you are really smart you would have read the note in the source that says "tested on windows only!". Segfault. Thanks for the laugh! From rantingrick at gmail.com Sun Jan 23 12:21:27 2011 From: rantingrick at gmail.com (rantingrick) Date: Sun, 23 Jan 2011 09:21:27 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <480571f5-5731-4f8b-9cb4-1468478711bf@c39g2000yqi.googlegroups.com> Message-ID: <2c951199-3dba-4d24-a5c2-f84081688f7e@u6g2000yqk.googlegroups.com> On Jan 23, 7:35?am, Adam Skutt wrote: > On Jan 22, 7:07?pm, rantingrick wrote: > You first. ?Write actual working code first and then you can challenge > people. The code does work. You just lack the skill to run it. > I found 5 bugs in your code before I quit looking[1]. What are these "so-called" bugs exactly? Remember this code is not meant to WOW anyone. It is a challenge to anybody who can reproduce the same functionality in Tkinter. The main point is to create a ListCtrl that has two view modes, icons, and editable items. You lack simple reading and comprehension skills Adam. > Can you > find and fix them all? ?Also, I'm entirely ignoring the bad styling, This is not a challenge about code styling. > bad default sizing, This is not a challenge about pretty GUIs. > horrible UI, the fact you call rename "Edit", pedantic troll! > and > the fact the context menu doesn't do anything. THIS IS A SIMPLE EXAMPLE FILE VIEWER. We don't to actually rename and delete files you moron. Get a life. Adam you were one of the biggest trolls in the "other" thread. We don't need you trolling up this one too. Can you write any code? I have produced code and no one has offered a rebuttal using the Tkinter module. This is because only a handful of the entire community has the skills to create something like this with Tkinter. I am one of them, Kevin is another, Guido is another, and there are a very few more. HOWEVER YOU ARE NOT IN THIS GROUP ADAM. You are a troll, and that is all you can do. Prove me wrong if you can... From rantingrick at gmail.com Sun Jan 23 12:21:57 2011 From: rantingrick at gmail.com (rantingrick) Date: Sun, 23 Jan 2011 09:21:57 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> Message-ID: <1a1b0e40-ac98-4234-a95d-80ed05de4e72@s5g2000yqm.googlegroups.com> On Jan 23, 4:10?am, Stefan Behnel wrote: > rantingrick, 23.01.2011 01:07: > > > I have in many threads declared that Tkinter (and TclTk) is currently > > --and has been for a decade-- the wrong choice for Python's stdlib > > GUI. ?[...] > > It is time to prove once and for all how dated and worthless Tkinter > > is compared to wxPython. > > What's the aim of that prove? If you are trying to pave the ground for > getting wxPython in the stdlib instead of tkinter, I think that's bound to > fail. Similar proposals have been rejected with the simple argument that > adding a large library with a huge C dependency to the standard library > without having a rock solid maintainer for both of them is not going to happen. Wait a minute, i am confused? What language is Python written in? Oh thats right Lisp! I am so dumb. How did i even get this job? :-) > Are you volunteering to maintain both wxPython and wxWidgets in the > standard library for, say, twenty years to come? WxPython needs lots of proper documentation aimed at beginners (so does Tkinter!). WxPython also needs a better API (however only VERY sightly!!). These are some areas where i can be very helpful. From rantingrick at gmail.com Sun Jan 23 12:23:35 2011 From: rantingrick at gmail.com (rantingrick) Date: Sun, 23 Jan 2011 09:23:35 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> Message-ID: On Jan 23, 11:06?am, Arndt Roger Schneider wrote: > rantingrick schrieb: > > [snip] > > 1. You cannot define the terms--restrict your opponent-- > ? ? and battle it yourselves. > 2. Your specified directory browser is useless. > ? ? --At least define that the directory browser must have > ? ? ? constant complexity to work with volatile > ? ? ? data over a network... > > -roger Get a life moron and post some code, if you can! From rantingrick at gmail.com Sun Jan 23 12:31:25 2011 From: rantingrick at gmail.com (rantingrick) Date: Sun, 23 Jan 2011 09:31:25 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> Message-ID: On Jan 22, 6:07?pm, rantingrick wrote: > I await any challengers... So far only trolls (besides Terry, Octavian, D'Aprano) have replied. In my time here within the Python community i have only met one person who shares my in-depth knowledge of Tkinter. That person is Kevin Waltzer. So outside of Python-dev and Guido. Kevin and I are are the ONLY people qualified to offer opinions on the worth or worthlessness of Tkinter. If anyone in this entire community thinks that they also are qualified then prove your worth by creating a ListCtrl in Tkinter that mirrors the wxPython ListCtrl in functionality. When you have done that, i will elevate you to my circle of enlightenment. Than and only then shall i even entertain you BS. Until then, anyone who tries to devalue my argument is just an ignorant troll. From invalid at invalid.invalid Sun Jan 23 12:33:09 2011 From: invalid at invalid.invalid (Grant Edwards) Date: Sun, 23 Jan 2011 17:33:09 +0000 (UTC) Subject: Need GUI pop-up to edit a (unicode ?) string References: <3tqr08-bj2.ln1@murmur.very.softly> Message-ID: On 2011-01-22, Corey Richardson wrote: > If that is all you need, I suggest Tkinter. Nice and easy, comes built > into Python. In some Linux distros, that is. Not in all of them. -- Grant From steve+comp.lang.python at pearwood.info Sun Jan 23 12:43:49 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 23 Jan 2011 17:43:49 GMT Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> Message-ID: <4d3c68d5$0$29983$c3e8da3$5496439d@news.astraweb.com> On Sun, 23 Jan 2011 09:31:25 -0800, rantingrick wrote: > So far only trolls (besides Terry, Octavian, D'Aprano) have replied. So apart from the non-trolls, only trolls have replied? -- Steven From kb1pkl at aim.com Sun Jan 23 12:54:41 2011 From: kb1pkl at aim.com (Corey Richardson) Date: Sun, 23 Jan 2011 12:54:41 -0500 Subject: WxPython versus Tkinter. In-Reply-To: References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> Message-ID: <4D3C6B61.2000807@aim.com> On 01/23/2011 05:18 AM, rusi wrote: > > Tried the code with debian sid and default python (2.6) > > I get (after some loading... statements) > > Segmentation fault > > [Actually this is the first time in my 10 years of python that Ive > seen a pure python module segfault :-) ] I also have a segfault. You should fix that, rantingrick :) From steve+comp.lang.python at pearwood.info Sun Jan 23 13:07:37 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 23 Jan 2011 18:07:37 GMT Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <1a1b0e40-ac98-4234-a95d-80ed05de4e72@s5g2000yqm.googlegroups.com> Message-ID: <4d3c6e69$0$29983$c3e8da3$5496439d@news.astraweb.com> On Sun, 23 Jan 2011 09:21:57 -0800, rantingrick wrote: > Wait a minute, i am confused? What language is Python written in? Oh > thats right Lisp! I am so dumb. How did i even get this job? :-) Python is written in C, Java, C#, Javascript, Haskell, Ocaml, and, yes, even Lisp. There's even a Python interpreter written in Python. Admittedly, the Ocaml implementation seems to be abandoned, and some of the others are more experimental, but they're all Python. -- Steven From askutt at gmail.com Sun Jan 23 13:09:47 2011 From: askutt at gmail.com (Adam Skutt) Date: Sun, 23 Jan 2011 10:09:47 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <480571f5-5731-4f8b-9cb4-1468478711bf@c39g2000yqi.googlegroups.com> <2c951199-3dba-4d24-a5c2-f84081688f7e@u6g2000yqk.googlegroups.com> Message-ID: <3e603997-5539-4660-bd83-7398bdab34a4@k30g2000vbn.googlegroups.com> On Jan 23, 12:21?pm, rantingrick wrote: > The code does work. You just lack the skill to run it. I not only possess the skill to run it, but to find fault it in through simple inspection. All of the bugs I found, but one, I found through reading the .py file. Heck, I'm so good that I guessed two of the bugs before I downloaded the code because both are rank amateur mistakes, and I'm not convinced you even rise to the level of amateur. > > What are these "so-called" bugs exactly? 1. There's a bug related to loading of your resources. 2. There's a bug related to when file I/O is performed. 3/4. There's at least two bugs related to handling of a specific mouse event. 5. There's a bug related to reporting errors to the user. All of these bugs, except one[1], show a grave misunderstanding about how GUI toolkits operate and/or how the underlying operating systems behave. >Remember this code is not meant to WOW anyone. That's apparent from simple inspection of the code! Not only does it not wow, it doesn't even illustrate your own example to a degree that could be reasonably considered competent. It demonstrates you didn't even test the functionality you provided in your own code, or that if you did, you're entirely clueless about GUI design fundamentals. > The main point is to create a > ListCtrl that has two view modes, icons, and editable items. You lack > simple reading and comprehension skills Adam. And your code will not do that in a whole host of common situations that a GUI application is reasonably expected to handle. It is not sufficiently robust to be interesting. > Adam you were one of the biggest trolls in the "other" thread. We > don't need you trolling up this one too. Can you write any code? I > have produced code and no one has offered a rebuttal using the Tkinter > module. This is because only a handful of the entire community has the > skills to create something like this with Tkinter. No, it's because your code is complete and utter shite and there's zero point in attempting to replicate it. Your code does not work, even if you think it does. I'm not the only person who's noted this. > HOWEVER YOU ARE NOT IN THIS GROUP ADAM. You are a troll, and that is > all you can do. Prove me wrong if you can... I already have. Confirmation of some of the bugs I've noted exists in this very thread. Thus, I'm quite capable of reading and comprehending Python code. The same remains to be seen with you. Adam [1] Which is only because wxWidgets has a bug in this regard. That being said, a workaround exists and trivial to find online. From tyler at tysdomain.com Sun Jan 23 13:30:51 2011 From: tyler at tysdomain.com (Littlefield, Tyler) Date: Sun, 23 Jan 2011 11:30:51 -0700 Subject: WxPython versus Tkinter. Message-ID: <4D3C73DB.5090608@tysdomain.com> >I also have a segfault. You should fix that, rantingrick It's clear that the mighty text editor he's wielding in his arena of champions while taking on the world all by himself does not come with a debugger, or even the ability to run the code. Might I suggest throwing your current weapon of mass destruction away and finding another? It's clearly lacking in some key features. -- Thanks, Ty From scottybmeup at earthlink.net Sun Jan 23 13:41:02 2011 From: scottybmeup at earthlink.net (Scott Meup) Date: Sun, 23 Jan 2011 11:41:02 -0700 Subject: documentation / reference help Message-ID: I'm trying tolearn Python. The documentation tells syntax, and other things about a command. But for too many commands, it doesn't tell what it does. for instance, in VB the 'return' command tells the program what line to execute after some event (usually an error). In Python it appears to return a value. Where does it return it to? I couldn't find anywhere on the Python website to find out or to ask Python to upgrade their documentation. Can somebody please recommend a source. From rantingrick at gmail.com Sun Jan 23 14:07:11 2011 From: rantingrick at gmail.com (rantingrick) Date: Sun, 23 Jan 2011 11:07:11 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <480571f5-5731-4f8b-9cb4-1468478711bf@c39g2000yqi.googlegroups.com> <2c951199-3dba-4d24-a5c2-f84081688f7e@u6g2000yqk.googlegroups.com> <3e603997-5539-4660-bd83-7398bdab34a4@k30g2000vbn.googlegroups.com> Message-ID: On Jan 23, 12:09?pm, Adam Skutt wrote: > On Jan 23, 12:21?pm, rantingrick wrote: > > What are these "so-called" bugs exactly? > > 1. There's a bug related to loading of your resources. > 2. There's a bug related to when file I/O is performed. > 3/4. There's at least two bugs related to handling of a specific mouse > event. > 5. There's a bug related to reporting errors to the user. Well then post a traceback. However you still miss the point. You will do anything to distract from the point. And what IS that point? Well that Tkinter is lackluster 20 years old rotware and you need to resort to these BS tactics to discredit me because 1). You cannot even create a Tkinter GUI at the basic level, and 2) you have no real argument based on facts! Post CODE Adam. Code! Surely you can handle copy/pasting a traceback i hope! From tyler at tysdomain.com Sun Jan 23 14:38:35 2011 From: tyler at tysdomain.com (Littlefield, Tyler) Date: Sun, 23 Jan 2011 12:38:35 -0700 Subject: documentation / reference help In-Reply-To: References: Message-ID: <4D3C83BB.8050701@tysdomain.com> The return value simply returns a value to the calling function, which the function can handle, however it wants. so: for example def add(a, b): return (a+b) That simply returns the value a+b, which you can use however you like, like so: i=add(2,3) will assign the return value to add. I recommend you check out the tutorial on python.org, which explains all of this; the documentation does not need updating, at least not in that respect. On 1/23/2011 11:41 AM, Scott Meup wrote: > I'm trying tolearn Python. The documentation tells syntax, and other things > about a command. But for too many commands, it doesn't tell what it does. > for instance, in VB the 'return' command tells the program what line to > execute after some event (usually an error). In Python it appears to return > a value. Where does it return it to? I couldn't find anywhere on the > Python website to find out or to ask Python to upgrade their documentation. > Can somebody please recommend a source. > > -- Thanks, Ty From askutt at gmail.com Sun Jan 23 14:42:24 2011 From: askutt at gmail.com (Adam Skutt) Date: Sun, 23 Jan 2011 11:42:24 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <480571f5-5731-4f8b-9cb4-1468478711bf@c39g2000yqi.googlegroups.com> <2c951199-3dba-4d24-a5c2-f84081688f7e@u6g2000yqk.googlegroups.com> <3e603997-5539-4660-bd83-7398bdab34a4@k30g2000vbn.googlegroups.com> Message-ID: <5edded76-fdac-4eb5-8480-25e3381e2fd4@g26g2000vbz.googlegroups.com> On Jan 23, 2:07?pm, rantingrick wrote: > Well then post a traceback. None of these issues will supply a traceback; in fact, in some of these cases, you went out of your way to ensure that would not happen. That's an additional bug (or 5 additional bugs depending how mean your tester/QA staff are). > ?However you still miss the point. You will do anything to distract > from the point. And what IS that point? Well that Tkinter is > lackluster 20 years old rotware The fact it doesn't provide a control found almost exclusively in file browsers and open/save dialogs does not mean that it is "20 years old rotware". > and you need to resort to these BS tactics to discredit me because 1). You cannot even create a Tkinter > GUI at the basic level, I certainly can, but there's no point in demonstrating my skill when you cannot create a wxWidgets GUI at a basic level. You made the challenge, you intentionally styled it as "rantingrick v. the world", so you need to actually bring something challenge worthy to the table first. That includes picking a challenge that's interesting and not over a relatively minor widget in the grand scheme of things. Qt, Swing, Gtk, and Win32 common controls[1] don't provide the same exact control either, should we view it as deficient? But regardless of the challenge, I don't think you're capable of posting a worthwhile example, which is why you dismiss all the problems found with it instead of actually fixing the code. > Post CODE Adam. Code! Surely you can handle copy/pasting a traceback i > hope! I certainly can. I don't have much hope for you writing code that provides tracebacks, much less actually useful ones. Adam [1] Hell, I'm not sure /any/ toolkit provides the whole of wxListCtrl functionality OOB, besides wxWidgets itself. Like I said, it's specific functionality isn't well suited. From emile at fenx.com Sun Jan 23 14:48:59 2011 From: emile at fenx.com (Emile van Sebille) Date: Sun, 23 Jan 2011 11:48:59 -0800 Subject: documentation / reference help In-Reply-To: References: Message-ID: On 1/23/2011 10:41 AM Scott Meup said... > I'm trying tolearn Python. The documentation tells syntax, and other things > about a command. But for too many commands, it doesn't tell what it does. > for instance, in VB the 'return' command tells the program what line to > execute after some event (usually an error). In Python it appears to return > a value. Where does it return it to? I couldn't find anywhere on the > Python website to find out or to ask Python to upgrade their documentation. > Can somebody please recommend a source. > > If you've had any programming experience or can otherwise make sense of it, start with the tutorial at http://docs.python.org/tutorial/ otherwise there're good resource links at http://wiki.python.org/moin/BeginnersGuide to get you started. Emile From cmpython at gmail.com Sun Jan 23 14:52:13 2011 From: cmpython at gmail.com (CM) Date: Sun, 23 Jan 2011 11:52:13 -0800 (PST) Subject: documentation / reference help References: Message-ID: <77562432-5369-45ec-b572-79adb93c818a@f20g2000vbc.googlegroups.com> On Jan 23, 2:38?pm, "Littlefield, Tyler" wrote: > The return value simply returns a value to the calling function, which > the function can handle, however it wants. so: for example > def add(a, b): > ? ?return (a+b) > > That simply returns the value a+b, which you can use however you like, > like so: i=add(2,3) will assign the return value to add. And return doesn't have to return a value(s). It can just cause the program's execution to not proceed further but to go back to the calling function, like: def checkAplusB(a, b): if a + b > 5: return > > I recommend you check out the tutorial on python.org, which explains all > of this; the documentation does not need updating, at least not in that > respect. > On 1/23/2011 11:41 AM, Scott Meup wrote: > > > I'm trying tolearn Python. ?The documentation tells syntax, and other things > > about a command. ?But for too many commands, it doesn't tell what it does. > > for instance, in VB the 'return' command tells the program what line to > > execute after some event (usually an error). In Python it appears to return > > a value. ?Where does it return it to? ?I couldn't find anywhere on the > > Python website to find out or to ask Python to upgrade their documentation. > > Can somebody please recommend a source. > > -- > > Thanks, > Ty From clp2 at rebertia.com Sun Jan 23 15:18:35 2011 From: clp2 at rebertia.com (Chris Rebert) Date: Sun, 23 Jan 2011 12:18:35 -0800 Subject: documentation / reference help In-Reply-To: <77562432-5369-45ec-b572-79adb93c818a@f20g2000vbc.googlegroups.com> References: <77562432-5369-45ec-b572-79adb93c818a@f20g2000vbc.googlegroups.com> Message-ID: On Sun, Jan 23, 2011 at 11:52 AM, CM wrote: > On Jan 23, 2:38?pm, "Littlefield, Tyler" wrote: >> The return value simply returns a value to the calling function, which >> the function can handle, however it wants. so: for example >> def add(a, b): >> ? ?return (a+b) >> >> That simply returns the value a+b, which you can use however you like, >> like so: i=add(2,3) will assign the return value to add. > > And return doesn't have to return a value(s). Pedantic nitpick: Technically it does; you're just not required to always explicitly provide one. Python uses None if you don't specify anything (i.e. a bare `return` === `return None`). By definition, every function returns *some* value. Cheers, Chris -- http://blog.rebertia.com From nagle at animats.com Sun Jan 23 15:19:38 2011 From: nagle at animats.com (John Nagle) Date: Sun, 23 Jan 2011 12:19:38 -0800 Subject: Which non SQL Database ? In-Reply-To: References: Message-ID: <4d3c8d53$0$44021$742ec2ed@news.sonic.net> On 1/22/2011 10:15 PM, Deadly Dirk wrote: > On Sat, 04 Dec 2010 16:42:36 -0600, Jorge Biquez wrote: > >> Hello all. >> >> Newbie question. Sorry. >> >> As part of my process to learn python I am working on two personal >> applications. Both will do it fine with a simple structure of data >> stored in files. I now there are lot of databases around I can use but I >> would like to know yoor advice on what other options you would consider >> for the job (it is training so no pressure on performance). For something like that, I'd suggest just using SQLite. It comes with the Python distribution, it's well documented, and reasonably easy to use. The "NoSQL" stuff is mostly for people doing really big databases for large web sites. The kind of operations where you have multiple data centers, thousands of rackmount servers, a huge traffic load, and smart people thinking about the implications of "eventually consistent". Google's BigTable and Facebook's Cassandra offer impressive performance at very large scale. But they're way overkill for a desktop app. Even the midrange systems, like CouchDB, are far too much machinery for a desktop app. John Nagle From rantingrick at gmail.com Sun Jan 23 15:23:13 2011 From: rantingrick at gmail.com (rantingrick) Date: Sun, 23 Jan 2011 12:23:13 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <480571f5-5731-4f8b-9cb4-1468478711bf@c39g2000yqi.googlegroups.com> <2c951199-3dba-4d24-a5c2-f84081688f7e@u6g2000yqk.googlegroups.com> <3e603997-5539-4660-bd83-7398bdab34a4@k30g2000vbn.googlegroups.com> <5edded76-fdac-4eb5-8480-25e3381e2fd4@g26g2000vbz.googlegroups.com> Message-ID: <1d7fdb0c-9f82-45ab-bf0e-99d210042f0d@j21g2000vbn.googlegroups.com> On Jan 23, 1:42?pm, Adam Skutt wrote: > On Jan 23, 2:07?pm, rantingrick wrote: > > > Well then post a traceback. > > None of these issues will supply a traceback; in fact, in some of > these cases, you went out of your way to ensure that would not > happen. ? psst: thats because they are FEATURES and NOT BUGS you idiot! I am not trying to create a working file browser so you can steal my code. No. I am displaying one use case for a very useful widget. I repeat, i am not going to code up a free file browser for you Adam. Get a life! > > ?However you still miss the point. You will do anything to distract > > from the point. And what IS that point? Well that Tkinter is > > lackluster 20 years old rotware > > The fact it doesn't provide a control found almost exclusively in file > browsers and open/save dialogs does not mean that it is "20 years old > rotware". A ListCtrl is useful for many, many purposes. Just one of them happens to be a file browser. Your statement comes as no great surprise to us because we all know how you severely lack any kind of vision or abstract reasoning abilities. > > and you need to resort to these BS tactics to discredit me because 1). You cannot even create a Tkinter > > GUI at the basic level, > > I certainly can, but there's no point in demonstrating my skill when > you cannot create a wxWidgets GUI at a basic level. BS. You're scared, You're under qualified. And it shows. BIGTIME! > ?You made the > challenge, you intentionally styled it as "rantingrick v. the world", > so you need to actually bring something challenge worthy to the table > first. Where is the world Adam? I am the only one who has summited code. > That includes picking a challenge that's interesting and not over a > relatively minor widget in the grand scheme of things. ListCtrl's are very useful. And i have many more challenges coming. WxPython outshines all the competition by leaps and bounds. The ListCtrl is just the beginning. > ?Qt, Swing, > Gtk, and Win32 common controls[1] don't provide the same exact control > either, should we view it as deficient? Yes. > But regardless of the challenge, You keep trying to divert attention from the point. Sorry but you're not going to fool anyone with this foolishness. > I don't think you're capable of > posting a worthwhile example, which is why you dismiss all the > problems found with it instead of actually fixing the code. Ditto! But at least i have some code to work with. Something to create a fact based argument from. You have nothing but your own foolishness to build from. > > Post CODE Adam. Code! Surely you can handle copy/pasting a traceback i > > hope! > > I certainly can. ?I don't have much hope for you writing code that > provides tracebacks, much less actually useful ones. I suppose you gauge the quality of code by how many tracebacks are printed. And it seems even more perverse that you expect code to spit exceptions! And when code fails to spit exceptions you get angry about it and claim the programmer is insufficient. Hmm, this would explain why you have yet to provide us with working (or even semi-working) code. Adam you are by far the most foolish person i have ever met. From cmpython at gmail.com Sun Jan 23 16:05:12 2011 From: cmpython at gmail.com (CM) Date: Sun, 23 Jan 2011 13:05:12 -0800 (PST) Subject: A and B but not C in list Message-ID: <8cae2caf-d3df-4ed3-9afb-29de97772298@m13g2000yqb.googlegroups.com> In Python, is there a recommended way to write conditionals of the form: "if A and B but not C or D in my list, do something." ? I may also have variations on this, like "if A but not B, C, or D". Do I have to just write out all the if and elifs with all possible conditions, or is there a handier and more code-maintainable way to deal with this? Thanks. From tyler at tysdomain.com Sun Jan 23 16:11:29 2011 From: tyler at tysdomain.com (Littlefield, Tyler) Date: Sun, 23 Jan 2011 14:11:29 -0700 Subject: WxPython versus Tkinter. In-Reply-To: <1d7fdb0c-9f82-45ab-bf0e-99d210042f0d@j21g2000vbn.googlegroups.com> References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <480571f5-5731-4f8b-9cb4-1468478711bf@c39g2000yqi.googlegroups.com> <2c951199-3dba-4d24-a5c2-f84081688f7e@u6g2000yqk.googlegroups.com> <3e603997-5539-4660-bd83-7398bdab34a4@k30g2000vbn.googlegroups.com> <5edded76-fdac-4eb5-8480-25e3381e2fd4@g26g2000vbz.googlegroups.com> <1d7fdb0c-9f82-45ab-bf0e-99d210042f0d@j21g2000vbn.googlegroups.com> Message-ID: <4D3C9981.8020107@tysdomain.com> RR, I have not seen anything useful from you thus far, except: 1) "you disagree with me, troll you must be," "2) who cares if my programs have bugs and don't compile cross-platform, defective code is code, none the less. 3) And a lot of unfounded arrogance in stating that no one understands Tkinter quite like yourself and a select handful of people. I hardly think that your tone, attitude and arguments are going to help you in your battle to prove that WXPython is superior to anything at all, if you can't manage to provide cross-platform bug-free code. No, no one else has yet provided code in this thread from what I have seen, since that's the point you keep making time and time again in numerous messages that keep cluttering my inbox, but no one really has to. You are making an argument with a lot of anger and faulty code, which is supposed to prove that the library, in which you can't write an application that is bug free (or as bug free as any program can be) and also maintain the cross-platform goal, which is a huge part of Python currently, is superior to another that you are screaming and throwing tantrums over. So I await your response, though my psychic powers tells me the response will be one of silence, "stfu, you're just a troll," or "where's the code, I'm not going to produce bug-free code so you can rip off -my- top security amazing file browser," since such things don't already exist anyway. On 1/23/2011 1:23 PM, rantingrick wrote: > On Jan 23, 1:42 pm, Adam Skutt wrote: >> On Jan 23, 2:07 pm, rantingrick wrote: >> >>> Well then post a traceback. >> None of these issues will supply a traceback; in fact, in some of >> these cases, you went out of your way to ensure that would not >> happen. > psst: thats because they are FEATURES and NOT BUGS you idiot! I am not > trying to create a working file browser so you can steal my code. No. > I am displaying one use case for a very useful widget. I repeat, i am > not going to code up a free file browser for you Adam. Get a life! > >>> However you still miss the point. You will do anything to distract >>> from the point. And what IS that point? Well that Tkinter is >>> lackluster 20 years old rotware >> The fact it doesn't provide a control found almost exclusively in file >> browsers and open/save dialogs does not mean that it is "20 years old >> rotware". > A ListCtrl is useful for many, many purposes. Just one of them happens > to be a file browser. Your statement comes as no great surprise to us > because we all know how you severely lack any kind of vision or > abstract reasoning abilities. > >>> and you need to resort to these BS tactics to discredit me because 1). You cannot even create a Tkinter >>> GUI at the basic level, >> I certainly can, but there's no point in demonstrating my skill when >> you cannot create a wxWidgets GUI at a basic level. > BS. You're scared, You're under qualified. And it shows. BIGTIME! > >> You made the >> challenge, you intentionally styled it as "rantingrick v. the world", >> so you need to actually bring something challenge worthy to the table >> first. > Where is the world Adam? I am the only one who has summited code. > > >> That includes picking a challenge that's interesting and not over a >> relatively minor widget in the grand scheme of things. > ListCtrl's are very useful. And i have many more challenges coming. > WxPython outshines all the competition by leaps and bounds. The > ListCtrl is just the beginning. > >> Qt, Swing, >> Gtk, and Win32 common controls[1] don't provide the same exact control >> either, should we view it as deficient? > Yes. > >> But regardless of the challenge, > You keep trying to divert attention from the point. Sorry but you're > not going to fool anyone with this foolishness. > >> I don't think you're capable of >> posting a worthwhile example, which is why you dismiss all the >> problems found with it instead of actually fixing the code. > Ditto! But at least i have some code to work with. Something to create > a fact based argument from. You have nothing but your own foolishness > to build from. > >>> Post CODE Adam. Code! Surely you can handle copy/pasting a traceback i >>> hope! >> I certainly can. I don't have much hope for you writing code that >> provides tracebacks, much less actually useful ones. > I suppose you gauge the quality of code by how many tracebacks are > printed. And it seems even more perverse that you expect code to spit > exceptions! And when code fails to spit exceptions you get angry about > it and claim the programmer is insufficient. Hmm, this would explain > why you have yet to provide us with working (or even semi-working) > code. Adam you are by far the most foolish person i have ever met. -- Thanks, Ty From kb1pkl at aim.com Sun Jan 23 16:13:24 2011 From: kb1pkl at aim.com (Corey Richardson) Date: Sun, 23 Jan 2011 16:13:24 -0500 Subject: A and B but not C in list In-Reply-To: <8cae2caf-d3df-4ed3-9afb-29de97772298@m13g2000yqb.googlegroups.com> References: <8cae2caf-d3df-4ed3-9afb-29de97772298@m13g2000yqb.googlegroups.com> Message-ID: <4D3C99F4.4000103@aim.com> On 01/23/2011 04:05 PM, CM wrote: > In Python, is there a recommended way to write conditionals of the > form: > > "if A and B but not C or D in my list, do something." ? > > I may also have variations on this, like "if A but not B, C, or D". > > Do I have to just write out all the if and elifs with all possible > conditions, or is there a handier and more code-maintainable way to > deal with this? > > Thanks. > > > > if (A in list and B in list) and (C not in list or D not in list): pass I'm sure the gurus on this list can come up with something better. From clp2 at rebertia.com Sun Jan 23 16:21:05 2011 From: clp2 at rebertia.com (Chris Rebert) Date: Sun, 23 Jan 2011 13:21:05 -0800 Subject: A and B but not C in list In-Reply-To: <8cae2caf-d3df-4ed3-9afb-29de97772298@m13g2000yqb.googlegroups.com> References: <8cae2caf-d3df-4ed3-9afb-29de97772298@m13g2000yqb.googlegroups.com> Message-ID: On Sun, Jan 23, 2011 at 1:05 PM, CM wrote: > In Python, is there a recommended way to write conditionals of the > form: > > "if A and B but not C or D in my list, do something." ?? > > I may also have variations on this, like "if A but not B, C, or D". > > Do I have to just write out all the if and elifs with all possible > conditions, or is there a handier and more code-maintainable way to > deal with this? Assuming your conditions all involve membership testing... Use the built-in any() and all() functions. For your first example: wanteds = [A, B] unwanteds = [C, D] if all(wanted in your_list for wanted in wanteds) and \ not any(unwanted in your_list for unwanted in unwanteds): do_whatever() You could pull this out into a separate function if you wish. Cheers, Chris -- http://blog.rebertia.com From g.rodola at gmail.com Sun Jan 23 16:22:56 2011 From: g.rodola at gmail.com (=?ISO-8859-1?Q?Giampaolo_Rodol=E0?=) Date: Sun, 23 Jan 2011 22:22:56 +0100 Subject: ANN: pyftpdlib 0.6.0 released Message-ID: Hi, I'm pleased to announce release 0.6.0 of Python FTP Server library (pyftpdlib). http://code.google.com/p/pyftpdlib/ === About === Python FTP server library provides an high-level portable interface to easily write asynchronous FTP/S servers with Python. Based on asyncore framework pyftpdlib is currently the most complete RFC-959 FTP server implementation available for Python programming language. === Major changes === This new version, aside from fixing some bugs, includes some important new features: * (finally) full FTPS (FTP over SSL/TS) support * configurable command line options * a standardized and improved logging system for commands and transfers * possibility to serve both IPv4 and IPv6 by using a single socket * enhanced Unix and Windows authorizers, moved from demo directory and included in main library with a set of new options such as the possibility to specify which users should be granted for access. * enabled TCP_NODELAY socket option for the FTP command channels resulting in pyftpdlib being twice faster. * a new UnixFilesystem class which permits the client to escape its home directory and navigate the real filesystem. A complete list of changes including enhancements, bug fixes and instructions for using the new functionalities is available here: http://code.google.com/p/pyftpdlib/wiki/ReleaseNotes06 If you think pyftpdlib is worth a donation you can do so by going here: http://code.google.com/p/pyftpdlib/wiki/Donate === More links === * Source tarball: http://pyftpdlib.googlecode.com/files/pyftpdlib-0.6.0.tar.gz * Online docs: http://code.google.com/p/pyftpdlib/wiki/Tutorial * FAQs: http://code.google.com/p/pyftpdlib/wiki/FAQ * RFCs compliance paper: http://code.google.com/p/pyftpdlib/wiki/RFCsCompliance * Issue tracker: http://code.google.com/p/pyftpdlib/issues/list Thanks, -- Giampaolo Rodola' < g.rodola [at] gmail [dot] com > From skunkworks at rikishi42.net Sun Jan 23 16:31:42 2011 From: skunkworks at rikishi42.net (Rikishi42) Date: Sun, 23 Jan 2011 22:31:42 +0100 Subject: Need GUI pop-up to edit a (unicode ?) string References: <3tqr08-bj2.ln1@murmur.very.softly> Message-ID: On 2011-01-22, geremy condra wrote: > If windows doesn't matter to you, just use Zenity. Here's a python > function wrapping zenity that does what you want: > > import commands > > def confirm_or_edit(s): > zenity = 'zenity' > mode = '--entry' > text = "--text='Please confirm or edit the following string:'" > title = "--title='confirm or edit'" > entry = "--entry-text='%s'" % s > cmd = ' '.join([zenity, mode, text, title, entry]) > status, output = commands.getstatusoutput(cmd) > if status: raise Exception("Couldn't run zenity") > return output > > There's also a full-blown API for zenity, but this should do what you want. Very, very nice. Thanks ! I'm amazed at how many GUI's are available. No wonder I couldn't find "the" interface, there are too many. :-) -- When in doubt, use brute force. -- Ken Thompson From lists at cheimes.de Sun Jan 23 16:34:33 2011 From: lists at cheimes.de (Christian Heimes) Date: Sun, 23 Jan 2011 22:34:33 +0100 Subject: A and B but not C in list In-Reply-To: <8cae2caf-d3df-4ed3-9afb-29de97772298@m13g2000yqb.googlegroups.com> References: <8cae2caf-d3df-4ed3-9afb-29de97772298@m13g2000yqb.googlegroups.com> Message-ID: Am 23.01.2011 22:05, schrieb CM: > In Python, is there a recommended way to write conditionals of the > form: > > "if A and B but not C or D in my list, do something." ? > > I may also have variations on this, like "if A but not B, C, or D". > > Do I have to just write out all the if and elifs with all possible > conditions, or is there a handier and more code-maintainable way to > deal with this? It's easier and faster if you convert the lists to sets first: your_set = set(your_list) if your_set.issuperset(set([A, B])) and your_set.isdisjoint(set([C, D])): ... Christian From tdldev at gmail.com Sun Jan 23 16:41:05 2011 From: tdldev at gmail.com (Verde Denim) Date: Sun, 23 Jan 2011 16:41:05 -0500 Subject: Which non SQL Database ? In-Reply-To: <4d3c8d53$0$44021$742ec2ed@news.sonic.net> References: <4d3c8d53$0$44021$742ec2ed@news.sonic.net> Message-ID: On Sun, Jan 23, 2011 at 3:19 PM, John Nagle wrote: > On 1/22/2011 10:15 PM, Deadly Dirk wrote: > >> On Sat, 04 Dec 2010 16:42:36 -0600, Jorge Biquez wrote: >> >> Hello all. >>> >>> Newbie question. Sorry. >>> >>> As part of my process to learn python I am working on two personal >>> applications. Both will do it fine with a simple structure of data >>> stored in files. I now there are lot of databases around I can use but I >>> would like to know yoor advice on what other options you would consider >>> for the job (it is training so no pressure on performance). >>> >> > For something like that, I'd suggest just using SQLite. It comes > with the Python distribution, it's well documented, and reasonably easy > to use. > > The "NoSQL" stuff is mostly for people doing really big databases > for large web sites. The kind of operations where you have multiple > data centers, thousands of rackmount servers, a huge traffic load, > and smart people thinking about the implications of "eventually > consistent". > > Google's BigTable and Facebook's Cassandra offer impressive > performance at very large scale. But they're way overkill for > a desktop app. Even the midrange systems, like CouchDB, are > far too much machinery for a desktop app. > > John Nagle > This may sound a bit 'old school', but if it's a non-sql solution you're after, what about c-isam ? Data is indexed and stored in flat files. For a personal app that maintains a small footprint, it's relative performance is acceptable. If the number of entities and attributes rises above a handful, however, I would recommend investing more thought in whether this is a permanent solution. Regards Jack > -- > http://mail.python.org/mailman/listinfo/python-list > -------------- next part -------------- An HTML attachment was scrubbed... URL: From askutt at gmail.com Sun Jan 23 17:03:26 2011 From: askutt at gmail.com (Adam Skutt) Date: Sun, 23 Jan 2011 14:03:26 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <480571f5-5731-4f8b-9cb4-1468478711bf@c39g2000yqi.googlegroups.com> <2c951199-3dba-4d24-a5c2-f84081688f7e@u6g2000yqk.googlegroups.com> <3e603997-5539-4660-bd83-7398bdab34a4@k30g2000vbn.googlegroups.com> <5edded76-fdac-4eb5-8480-25e3381e2fd4@g26g2000vbz.googlegroups.com> <1d7fdb0c-9f82-45ab-bf0e-99d210042f0d@j21g2000vbn.googlegroups.com> Message-ID: <4d34f9f4-25d1-4132-90e9-255bfdd2b506@d8g2000yqf.googlegroups.com> On Jan 23, 3:23?pm, rantingrick wrote: > psst: thats because they are FEATURES and NOT BUGS you idiot! Your application not displaying a directory listing, due to one of these "features", is desirable behavior? I think not. Your application hanging, due to one of these "features" is desirable behavior? I think not, nor do the wxWidgets, Qt, Swing, Cocoa, Gtk, Win32, et al. toolkit developers. > I am not trying to create a working file browser so you can steal my code. I have ethics, morals, and standards, all of which forbid me from stealing anything you write. > I am displaying one use case for a very useful widget. So useful that you've only found one toolkit that provides it OOB! > A ListCtrl is useful for many, many purposes. Just one of them happens > to be a file browser. The specific functionality the wxWidgets ListCtrl has over its alternatives in other toolkits is only really seen in file browsers. Your challenge explicitly relies on making use of that functionality and in no way, shape, or form illustrates the general utility of a wxListCtrl. When you amend the challenge, you can make the claim it's not about wxListCtrl's unique functionality. > > Qt, Swing, > > Gtk, and Win32 common controls[1] don't provide the same exact control > > either, should we view it as deficient? > Yes. Funny, given that the original purpose of wxWidgets was to provide a cross-platform MFC wrapper, I think you're in the minority of thought among those developers, to say nothing of developers in general. > I suppose you gauge the quality of code by how many tracebacks are > printed. And it seems even more perverse that you expect code to spit > exceptions! You're the one who asked for them originally, not I. I merely posited that since you provided code that prints no tracebacks and expected them (i.e., what you expect your code to do and what it does are two different things), that it is highly unlikely you're capable of providing me code that actually prints tracebacks, much less tracebacks that assist you in debugging. Put plainly, you have no clue whatsoever what your code actually does or how it accomplishes it, which is exactly what we'd expect. Adam From misnomer at gmail.com Sun Jan 23 17:07:40 2011 From: misnomer at gmail.com (Nicholas Devenish) Date: Sun, 23 Jan 2011 22:07:40 +0000 Subject: WxPython versus Tkinter. In-Reply-To: <3e603997-5539-4660-bd83-7398bdab34a4@k30g2000vbn.googlegroups.com> References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <480571f5-5731-4f8b-9cb4-1468478711bf@c39g2000yqi.googlegroups.com> <2c951199-3dba-4d24-a5c2-f84081688f7e@u6g2000yqk.googlegroups.com> <3e603997-5539-4660-bd83-7398bdab34a4@k30g2000vbn.googlegroups.com> Message-ID: Hi Adam, I'm still learning my way around wxPython and gui programming, been mostly linux and CLI since Visual Basic 5, and only recently started learning it. On 23/01/2011 18:09, Adam Skutt wrote: > 1. There's a bug related to loading of your resources. > 2. There's a bug related to when file I/O is performed. > 3/4. There's at least two bugs related to handling of a specific mouse > event. > 5. There's a bug related to reporting errors to the user. > > All of these bugs, except one[1], show a grave misunderstanding about > how GUI toolkits operate and/or how the underlying operating systems > behave. > > [1] Which is only because wxWidgets has a bug in this regard. That > being said, a workaround exists and trivial to find online. I'd be curious as to what these bugs are, as a learning exercise, if you don't mind. I don't mind a direct mail if you wish not to subject yourself to any more abuse on the list, as would almost certainly come. I'd especially like to be pointed at the error you refer to in [1]. On to the topic of the program direct, the 'List view' button doesn't seem to work on my platform, showing a blank folder icon and nothing else, but I don't know if that is related to any of these bugs. I actually looked around when I wanted to start learning gui programming, and chose wxPython because it seemed to use 'native' controls on all of the platforms. This file viewer just looks awful (is it supposed to flicker so much when I try to change the column size?) so I'm not exactly sure what it is supposed to prove. Nick From rantingrick at gmail.com Sun Jan 23 17:08:35 2011 From: rantingrick at gmail.com (rantingrick) Date: Sun, 23 Jan 2011 14:08:35 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <480571f5-5731-4f8b-9cb4-1468478711bf@c39g2000yqi.googlegroups.com> <2c951199-3dba-4d24-a5c2-f84081688f7e@u6g2000yqk.googlegroups.com> <3e603997-5539-4660-bd83-7398bdab34a4@k30g2000vbn.googlegroups.com> <5edded76-fdac-4eb5-8480-25e3381e2fd4@g26g2000vbz.googlegroups.com> <1d7fdb0c-9f82-45ab-bf0e-99d210042f0d@j21g2000vbn.googlegroups.com> Message-ID: <72084832-a4d5-43b5-9f7a-d6359013ebe9@s5g2000yqm.googlegroups.com> On Jan 23, 3:11?pm, "Littlefield, Tyler" wrote: > if you can't manage to provide cross-platform bug-free code. No one has posted even one traceback Tyler (including yourself!). And until they do i will assume that my code is bug free. I know it to be bug free on windows. If and when someone *actually* provides proof (supported by a traceback) then i will take them seriously. From david at boddie.org.uk Sun Jan 23 17:13:00 2011 From: david at boddie.org.uk (David Boddie) Date: Sun, 23 Jan 2011 23:13:00 +0100 Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> Message-ID: On Sunday 23 January 2011 17:57, rantingrick wrote: > On Jan 22, 9:39?pm, Terry Reedy wrote: >> On 1/22/2011 7:07 PM, rantingrick wrote: >> >> Near the beginning of this thread, I gently challenged you to produce a >> concrete, practical proposal for an stdlib addition that could be >> critiqued and improved. When you asked for problems with >> wxwidgets/wxpython, I gave some. Still waiting. > > You may have done this however i do not remember. With all the > trolling that was going on (not you) i may have missed it. ^^^ +1 QOTW David From hidura at gmail.com Sun Jan 23 17:21:05 2011 From: hidura at gmail.com (hidura at gmail.com) Date: Sun, 23 Jan 2011 22:21:05 +0000 Subject: How to execute foreing code from Python Message-ID: <20cf30433cec39ebdb049a8ae637@google.com> Hello i want to code from different languages using a Python script i know i can use os.system, but i don't know how to receive data or send arguments using that method if theres any another way to make it or there's a way to send arguments and receive data using os.system? Thanks in advance. -------------- next part -------------- An HTML attachment was scrubbed... URL: From kb1pkl at aim.com Sun Jan 23 17:25:10 2011 From: kb1pkl at aim.com (Corey Richardson) Date: Sun, 23 Jan 2011 17:25:10 -0500 Subject: WxPython versus Tkinter. In-Reply-To: <72084832-a4d5-43b5-9f7a-d6359013ebe9@s5g2000yqm.googlegroups.com> References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <480571f5-5731-4f8b-9cb4-1468478711bf@c39g2000yqi.googlegroups.com> <2c951199-3dba-4d24-a5c2-f84081688f7e@u6g2000yqk.googlegroups.com> <3e603997-5539-4660-bd83-7398bdab34a4@k30g2000vbn.googlegroups.com> <5edded76-fdac-4eb5-8480-25e3381e2fd4@g26g2000vbz.googlegroups.com> <1d7fdb0c-9f82-45ab-bf0e-99d210042f0d@j21g2000vbn.googlegroups.com> <72084832-a4d5-43b5-9f7a-d6359013ebe9@s5g2000yqm.googlegroups.com> Message-ID: <4D3CAAC6.7070000@aim.com> On 01/23/2011 05:08 PM, rantingrick wrote: > On Jan 23, 3:11 pm, "Littlefield, Tyler" wrote: > >> if you can't manage to provide cross-platform bug-free code. > > No one has posted even one traceback Tyler (including yourself!). And > until they do i will assume that my code is bug free. I know it to be > bug free on windows. If and when someone *actually* provides proof > (supported by a traceback) then i will take them seriously. > > There are more types of bugs than syntax errors, which are one of the only types of bug that raise exceptions in Python. Try looking at [1] or [2]. Here is the output on my system (Linux Mint 64bit): /home/corey/Downloads/Wx_Tk_Challenge/Bitmaps Loading Images: -- /home/corey/Downloads/Wx_Tk_Challenge/Bitmaps/file.bmp file.bmp -- /home/corey/Downloads/Wx_Tk_Challenge/Bitmaps/folder.bmp folder.bmp -- /home/corey/Downloads/Wx_Tk_Challenge/Bitmaps/link.bmp link.bmp ['folder', 'link', 'file'] Segmentation fault [1] http://en.wikipedia.org/wiki/Software_bug#Common_types_of_computer_bugs [2] http://msdn.microsoft.com/en-us/library/s9ek7a19%28v=vs.80%29.aspx From steve+comp.lang.python at pearwood.info Sun Jan 23 18:13:01 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 23 Jan 2011 23:13:01 GMT Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <480571f5-5731-4f8b-9cb4-1468478711bf@c39g2000yqi.googlegroups.com> <2c951199-3dba-4d24-a5c2-f84081688f7e@u6g2000yqk.googlegroups.com> <3e603997-5539-4660-bd83-7398bdab34a4@k30g2000vbn.googlegroups.com> <5edded76-fdac-4eb5-8480-25e3381e2fd4@g26g2000vbz.googlegroups.com> <1d7fdb0c-9f82-45ab-bf0e-99d210042f0d@j21g2000vbn.googlegroups.com> Message-ID: <4d3cb5fc$0$29983$c3e8da3$5496439d@news.astraweb.com> On Sun, 23 Jan 2011 12:23:13 -0800, rantingrick wrote: > I am not > trying to create a working file browser so you can steal my code. Dammit! There goes my brilliant idea for getting rich. Step 1: Start company. Step 2: Steal working file browser from Internet. Step 4: Profit! I think rantingrick's comment inadvertently shows in a nutshell everything wrong with this thread and why there is so little interest in his proposal. If RR is right about the GUI toolkit making or breaking the entire Python community, there should be hundreds of people with an opinion, not just a handful. (1) rantingrick is willing to spend *hours* brow-beating people, insulting them, and cajoling them into doing things *his* way, supposedly because of his deep concern for the Python community, but isn't willing to donate a lousy *file browser* to the community. (2) GUI programming is TOO DAMN HARD, and until that fact is addressed, it's difficult for the majority of people to care whether the toolkit used (or, more likely, not used at all) is Tkinter, or wxPython, or something else. For something as common as displaying a file browser, it should be as simple as this: import gui_toolkit # whichever path = gui_toolkit.select_file() Something like zenity: [steve at sylar ~]$ zenity --file-selection /home/steve/python/findsingle.py Of course there are times when you need to do more complicated things, and a decent toolkit should allow you to do so. But simple things should be simple, and as far as I can see, there are no GUI toolkits that make *anything* simple. -- Steven From steve+comp.lang.python at pearwood.info Sun Jan 23 18:21:31 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 23 Jan 2011 23:21:31 GMT Subject: A and B but not C in list References: <8cae2caf-d3df-4ed3-9afb-29de97772298@m13g2000yqb.googlegroups.com> Message-ID: <4d3cb7fb$0$29983$c3e8da3$5496439d@news.astraweb.com> On Sun, 23 Jan 2011 22:34:33 +0100, Christian Heimes wrote: > It's easier and faster if you convert the lists to sets first: > > your_set = set(your_list) > > if your_set.issuperset(set([A, B])) and your_set.isdisjoint(set([C, > D])): > ... "Easier" is a close thing. I find this easier to remember and write than set processing, even if it is a couple of characters longer: if all(x in your_list for x in (A, B)) and not any(x in your_list for x in (C, D)): ... And as for "faster", surely that will depend on the number of elements in your_list? The conversion from list to set doesn't happen for free, and it's likely that for small enough lists, that time may exceed any time savings you would otherwise gain. -- Steven From kw at codebykevin.com Sun Jan 23 18:23:47 2011 From: kw at codebykevin.com (Kevin Walzer) Date: Sun, 23 Jan 2011 18:23:47 -0500 Subject: [Code Challenge] WxPython versus Tkinter. In-Reply-To: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> Message-ID: <70498$4d3cb87c$4275d90a$4428@FUSE.NET> I found this code in the Demo/tkinter/ttk directory of the Python 2.7.1 source distribution. I'm NOT the author (credit should probably go to Guilherme Polo, developer of the Tkinter wrapper for the ttk themed widgets that is now in the stdlib). But, using a tree/listview widget that is part of the Tk/Tkinter core (NOT an extension), it presents a decent, simple file browser: """A directory browser using Ttk Treeview. Based on the demo found in Tk 8.5 library/demos/browse """ import os import glob import Tkinter import ttk def populate_tree(tree, node): if tree.set(node, "type") != 'directory': return path = tree.set(node, "fullpath") tree.delete(*tree.get_children(node)) parent = tree.parent(node) special_dirs = [] if parent else glob.glob('.') + glob.glob('..') for p in special_dirs + os.listdir(path): ptype = None p = os.path.join(path, p).replace('\\', '/') if os.path.isdir(p): ptype = "directory" elif os.path.isfile(p): ptype = "file" fname = os.path.split(p)[1] id = tree.insert(node, "end", text=fname, values=[p, ptype]) if ptype == 'directory': if fname not in ('.', '..'): tree.insert(id, 0, text="dummy") tree.item(id, text=fname) elif ptype == 'file': size = os.stat(p).st_size tree.set(id, "size", "%d bytes" % size) def populate_roots(tree): dir = os.path.abspath('.').replace('\\', '/') node = tree.insert('', 'end', text=dir, values=[dir, "directory"]) populate_tree(tree, node) def update_tree(event): tree = event.widget populate_tree(tree, tree.focus()) def change_dir(event): tree = event.widget node = tree.focus() if tree.parent(node): path = os.path.abspath(tree.set(node, "fullpath")) if os.path.isdir(path): os.chdir(path) tree.delete(tree.get_children('')) populate_roots(tree) def autoscroll(sbar, first, last): """Hide and show scrollbar as needed.""" first, last = float(first), float(last) if first <= 0 and last >= 1: sbar.grid_remove() else: sbar.grid() sbar.set(first, last) root = Tkinter.Tk() vsb = ttk.Scrollbar(orient="vertical") hsb = ttk.Scrollbar(orient="horizontal") tree = ttk.Treeview(columns=("fullpath", "type", "size"), displaycolumns="size", yscrollcommand=lambda f, l: autoscroll(vsb, f, l), xscrollcommand=lambda f, l:autoscroll(hsb, f, l)) vsb['command'] = tree.yview hsb['command'] = tree.xview tree.heading("#0", text="Directory Structure", anchor='w') tree.heading("size", text="File Size", anchor='w') tree.column("size", stretch=0, width=100) populate_roots(tree) tree.bind('<>', update_tree) tree.bind('', change_dir) # Arrange the tree and its scrollbars in the toplevel tree.grid(column=0, row=0, sticky='nswe') vsb.grid(column=1, row=0, sticky='ns') hsb.grid(column=0, row=1, sticky='ew') root.grid_columnconfigure(0, weight=1) root.grid_rowconfigure(0, weight=1) root.mainloop() -- Kevin Walzer Code by Kevin http://www.codebykevin.com From martin at v.loewis.de Sun Jan 23 18:27:53 2011 From: martin at v.loewis.de (Martin v. Loewis) Date: Mon, 24 Jan 2011 00:27:53 +0100 Subject: WxPython versus Tkinter. In-Reply-To: <033c3f90-03fb-4f65-bbae-bbc80a262685@l22g2000vbp.googlegroups.com> References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <033c3f90-03fb-4f65-bbae-bbc80a262685@l22g2000vbp.googlegroups.com> Message-ID: >> Segmentation fault >> >> [Actually this is the first time in my 10 years of python that Ive >> seen a pure python module segfault :-) ] > > Congratulations genius! However if you are really smart you would have > read the note in the source that says "tested on windows only!". > Segfault. Thanks for the laugh! I get the same: /tmp/Wx_Tk_Challenge/Bitmaps Loading Images: -- /tmp/Wx_Tk_Challenge/Bitmaps/file.bmp file.bmp -- /tmp/Wx_Tk_Challenge/Bitmaps/link.bmp link.bmp -- /tmp/Wx_Tk_Challenge/Bitmaps/folder.bmp folder.bmp ['folder', 'link', 'file'] Speicherzugriffsfehler Since you are asking for a traceback, here is one: Program received signal SIGSEGV, Segmentation fault. 0x00007ffff554c8cd in wxListMainWindow::InsertItem(wxListItem&) () from /usr/lib/libwx_gtk2u_core-2.6.so.0 (gdb) bt #0 0x00007ffff554c8cd in wxListMainWindow::InsertItem(wxListItem&) () from /usr/lib/libwx_gtk2u_core-2.6.so.0 #1 0x00007ffff554c940 in wxGenericListCtrl::InsertItem(wxListItem&) () from /usr/lib/libwx_gtk2u_core-2.6.so.0 #2 0x00007ffff554f012 in wxGenericListCtrl::InsertItem(long, wxString const&, int) () from /usr/lib/libwx_gtk2u_core-2.6.so.0 #3 0x00007fffee58c460 in ?? () from /usr/lib/python2.6/dist-packages/wx-2.6-gtk2-unicode/wx/_controls_.so #4 0x00000000004a794b in PyEval_EvalFrameEx () #5 0x00000000004a95c1 in PyEval_EvalCodeEx () #6 0x00000000004a7752 in PyEval_EvalFrameEx () #7 0x00000000004a84a0 in PyEval_EvalFrameEx () #8 0x00000000004a95c1 in PyEval_EvalCodeEx () #9 0x0000000000538b0d in ?? () #10 0x000000000041ef47 in PyObject_Call () #11 0x0000000000427c1f in ?? () #12 0x000000000041ef47 in PyObject_Call () #13 0x00000000004778ff in ?? () #14 0x000000000046f16f in ?? () #15 0x000000000041ef47 in PyObject_Call () #16 0x00000000004a72b8 in PyEval_EvalFrameEx () #17 0x00000000004a95c1 in PyEval_EvalCodeEx () #18 0x00000000004a9692 in PyEval_EvalCode () #19 0x00000000004c98be in PyRun_FileExFlags () #20 0x00000000004c9ad4 in PyRun_SimpleFileExFlags () #21 0x000000000041a6bd in Py_Main () #22 0x00007ffff69eac4d in __libc_start_main () from /lib/libc.so.6 #23 0x00000000004198d9 in _start () If you had expected a Python traceback, sorry Rick: it didn't produce one, since it crashed. So Rick you managed to crash wxPython, in just 248 lines of code. This doesn't give a very good impression of wxPython - "regular" Python libraries shouldn't crash the interpreter. Regards, Martin From clp2 at rebertia.com Sun Jan 23 18:30:45 2011 From: clp2 at rebertia.com (Chris Rebert) Date: Sun, 23 Jan 2011 15:30:45 -0800 Subject: How to execute foreing code from Python In-Reply-To: <20cf30433cec39ebdb049a8ae637@google.com> References: <20cf30433cec39ebdb049a8ae637@google.com> Message-ID: On Sun, Jan 23, 2011 at 2:21 PM, wrote: > Hello i want to code from different languages using a Python script i know i > can use os.system, but i don't know how to receive data or send arguments > using that method if theres any another way to make it or there's a way to > send arguments and receive data using os.system? Which other languages specifically? Also, the `subprocess` module (http://docs.python.org/library/subprocess.html ) is preferred over os.system(). Cheers, Chris -- http://blog.rebertia.com From martin at v.loewis.de Sun Jan 23 18:44:57 2011 From: martin at v.loewis.de (Martin v. Loewis) Date: Mon, 24 Jan 2011 00:44:57 +0100 Subject: WxPython versus Tkinter. In-Reply-To: <4d3cb5fc$0$29983$c3e8da3$5496439d@news.astraweb.com> References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <480571f5-5731-4f8b-9cb4-1468478711bf@c39g2000yqi.googlegroups.com> <2c951199-3dba-4d24-a5c2-f84081688f7e@u6g2000yqk.googlegroups.com> <3e603997-5539-4660-bd83-7398bdab34a4@k30g2000vbn.googlegroups.com> <5edded76-fdac-4eb5-8480-25e3381e2fd4@g26g2000vbz.googlegroups.com> <1d7fdb0c-9f82-45ab-bf0e-99d210042f0d@j21g2000vbn.googlegroups.com> <4d3cb5fc$0$29983$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4D3CBD79.3000905@v.loewis.de> > For something as common as displaying a file browser, it should be as > simple as this: > > import gui_toolkit # whichever > path = gui_toolkit.select_file() > > Something like zenity: > > [steve at sylar ~]$ zenity --file-selection > /home/steve/python/findsingle.py And indeed, it is that simple: python -c "import tkFileDialog as tkfd;print tkfd.askopenfilename()" Regards, Martin From rantingrick at gmail.com Sun Jan 23 19:07:43 2011 From: rantingrick at gmail.com (rantingrick) Date: Sun, 23 Jan 2011 16:07:43 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> Message-ID: <3a96fee1-995f-49f7-a967-f125cc3f1cdc@v26g2000yqf.googlegroups.com> On Jan 22, 6:07?pm, rantingrick wrote: > I await any challengers... WxPython Challenge 1 code updated... * Fixed tab traveral * Removed hand-holding code * Removed some cruft https://sites.google.com/site/thefutureofpython/home/code-challenges Good luck! From davea at ieee.org Sun Jan 23 19:24:36 2011 From: davea at ieee.org (Dave Angel) Date: Sun, 23 Jan 2011 19:24:36 -0500 Subject: How to execute foreing code from Python In-Reply-To: <20cf30433cec39ebdb049a8ae637@google.com> References: <20cf30433cec39ebdb049a8ae637@google.com> Message-ID: <4D3CC6C4.3060502@ieee.org> On 01/-10/-28163 02:59 PM, hidura at gmail.com wrote: > Hello i want to code from different languages using a Python script i > know i can use os.system, but i don't know how to receive data or send > arguments using that method if theres any another way to make it or > there's a way to send arguments and receive data using os.system? > > Thanks in advance. > That sentence runs on, and makes no sense to me. But I can guess that you would like to be able to write code in other languages, and call it from within a Python script. If you're on Windows, and the other language is a compiled one like C, compile it into a DLL, and call that DLL from Python. Ctypes is the first module to study. If you're on Linux, and the code in the other language was written by someone else, and is already compiled into an executable you cannot change, you probably should invoke it using the subprocess module. You can supply information to the executable via the commandline arguments and also via stdin, and you can receive results via the exit code, and via stdout. Any more details and options would need lots more information about your environment and your constraints. DaveA From kb1pkl at aim.com Sun Jan 23 19:30:26 2011 From: kb1pkl at aim.com (Corey Richardson) Date: Sun, 23 Jan 2011 19:30:26 -0500 Subject: WxPython versus Tkinter. In-Reply-To: <3a96fee1-995f-49f7-a967-f125cc3f1cdc@v26g2000yqf.googlegroups.com> References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <3a96fee1-995f-49f7-a967-f125cc3f1cdc@v26g2000yqf.googlegroups.com> Message-ID: <4D3CC822.4010703@aim.com> On 01/23/2011 07:07 PM, rantingrick wrote: > On Jan 22, 6:07 pm, rantingrick wrote: > >> I await any challengers... > > > WxPython Challenge 1 code updated... > > * Fixed tab traveral > * Removed hand-holding code > * Removed some cruft > > https://sites.google.com/site/thefutureofpython/home/code-challenges > > Good luck! Still doesn't fix the problem of the code not working on Linux boxes. Maybe wxPython isn't the best option, it doesn't appear very cross-platform. Still getting: Loading Images: -- /home/corey/Downloads/Wx_Tk_Challenge/Bitmaps/file.bmp, file.bmp -- /home/corey/Downloads/Wx_Tk_Challenge/Bitmaps/folder.bmp, folder.bmp -- /home/corey/Downloads/Wx_Tk_Challenge/Bitmaps/link.bmp, link.bmp imageMap.keys -> ['folder', 'link', 'file'] Segmentation fault From martin at v.loewis.de Sun Jan 23 19:31:43 2011 From: martin at v.loewis.de (Martin v. Loewis) Date: Mon, 24 Jan 2011 01:31:43 +0100 Subject: WxPython versus Tkinter. In-Reply-To: <3a96fee1-995f-49f7-a967-f125cc3f1cdc@v26g2000yqf.googlegroups.com> References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <3a96fee1-995f-49f7-a967-f125cc3f1cdc@v26g2000yqf.googlegroups.com> Message-ID: > WxPython Challenge 1 code updated... > > * Fixed tab traveral > * Removed hand-holding code > * Removed some cruft > > https://sites.google.com/site/thefutureofpython/home/code-challenges > > Good luck! Still crashes the interpreter. Regards, Martin From tjreedy at udel.edu Sun Jan 23 19:35:13 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Sun, 23 Jan 2011 19:35:13 -0500 Subject: A and B but not C in list In-Reply-To: <8cae2caf-d3df-4ed3-9afb-29de97772298@m13g2000yqb.googlegroups.com> References: <8cae2caf-d3df-4ed3-9afb-29de97772298@m13g2000yqb.googlegroups.com> Message-ID: On 1/23/2011 4:05 PM, CM wrote: > In Python, is there a recommended way to write conditionals of the > form: > > "if A and B but not C or D in my list, do something." ? > > I may also have variations on this, like "if A but not B, C, or D". > > Do I have to just write out all the if and elifs with all possible > conditions, or is there a handier and more code-maintainable way to > deal with this? The straightforward code if a in L and b in L and c not in L and d not in L scans the list 4 times. One scan be be done generically as follows: def req_pro(iterable, required = set(), prohibited = set()): for item in iterable: if item in prohibited: return False elif item in required: required.remove(item) else: return not required # should now be empty if req_pro(my_list, {A,B}, {C,D}): ... # untested, of course.. -- Terry Jan Reedy From tjreedy at udel.edu Sun Jan 23 19:48:00 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Sun, 23 Jan 2011 19:48:00 -0500 Subject: documentation / reference help In-Reply-To: References: Message-ID: On 1/23/2011 1:41 PM, Scott Meup wrote: > I'm trying tolearn Python. The documentation tells syntax, and other things > about a command. But for too many commands, it doesn't tell what it does. > for instance, in VB the 'return' command tells the program what line to > execute after some event (usually an error). In Python it appears to return > a value. Where does it return it to? The return object replaces the function call in the expression that contains the function call. Given: x = 1; j = [2,3]; def f(): return 4 the expression: x + y[1] + f() becomes: 1 + 3 + 4 In other words, names are looked up in the appropriate namespace and replaced with the object they are associated with in that namespace. Names followed by square brackets are replaced by the result of an indexing operation. Names followed by parentheses are called and replaced by the object returned. -- Terry Jan Reedy From rantingrick at gmail.com Sun Jan 23 20:12:27 2011 From: rantingrick at gmail.com (rantingrick) Date: Sun, 23 Jan 2011 17:12:27 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <70498$4d3cb87c$4275d90a$4428@FUSE.NET> Message-ID: On Jan 23, 5:23?pm, Kevin Walzer wrote: > I found this code in the Demo/tkinter/ttk directory of the Python 2.7.1 > source distribution. I'm NOT the author (credit should probably go to > Guilherme Polo, developer of the Tkinter wrapper for the ttk themed > widgets that is now in the stdlib). But, using a tree/listview widget > that is part of the Tk/Tkinter core (NOT an extension), ?it presents a > decent, simple file browser: > > """A directory browser using Ttk Treeview. The only way i can respond to this is to quite the requirements for my challenge... --------------------------------------- Challenge 1: (Simple Directory Viewer) --------------------------------------- Create a simple Directory Viewer GUI. You CANNOT use a treectrl! Any questions? From kw at codebykevin.com Sun Jan 23 20:16:52 2011 From: kw at codebykevin.com (Kevin Walzer) Date: Sun, 23 Jan 2011 20:16:52 -0500 Subject: WxPython versus Tkinter. In-Reply-To: References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <70498$4d3cb87c$4275d90a$4428@FUSE.NET> Message-ID: <63eea$4d3cd2fd$4275d90a$14984@FUSE.NET> On 1/23/11 8:12 PM, rantingrick wrote: > The only way i can respond to this is to quite the requirements for my > challenge... > > --------------------------------------- > Challenge 1: (Simple Directory Viewer) > --------------------------------------- > Create a simple Directory Viewer GUI. You CANNOT use a treectrl! > > > Any questions? Why not? I'd understand if this code made use of some Tk extension, as that's not quite an apples-to-apples comparison. But the treectrl is part of the core Tkinter widget set. There's no reason to exclude it unless you are deliberately trying to handicap Tk in your comparison. --Kevin -- Kevin Walzer Code by Kevin http://www.codebykevin.com From steve+comp.lang.python at pearwood.info Sun Jan 23 20:18:22 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 24 Jan 2011 01:18:22 GMT Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <480571f5-5731-4f8b-9cb4-1468478711bf@c39g2000yqi.googlegroups.com> <2c951199-3dba-4d24-a5c2-f84081688f7e@u6g2000yqk.googlegroups.com> <3e603997-5539-4660-bd83-7398bdab34a4@k30g2000vbn.googlegroups.com> <5edded76-fdac-4eb5-8480-25e3381e2fd4@g26g2000vbz.googlegroups.com> <1d7fdb0c-9f82-45ab-bf0e-99d210042f0d@j21g2000vbn.googlegroups.com> <4d3cb5fc$0$29983$c3e8da3$5496439d@news.astraweb.com> <4D3CBD79.3000905@v.loewis.de> Message-ID: <4d3cd35e$0$29974$c3e8da3$5496439d@news.astraweb.com> On Mon, 24 Jan 2011 00:44:57 +0100, Martin v. Loewis wrote: >> For something as common as displaying a file browser, it should be as >> simple as this: >> >> import gui_toolkit # whichever >> path = gui_toolkit.select_file() >> >> Something like zenity: >> >> [steve at sylar ~]$ zenity --file-selection >> /home/steve/python/findsingle.py > > And indeed, it is that simple: > > python -c "import tkFileDialog as tkfd;print tkfd.askopenfilename()" Brilliant! Pity that it is so ugly under Linux :( -- Steven From rantingrick at gmail.com Sun Jan 23 20:18:30 2011 From: rantingrick at gmail.com (rantingrick) Date: Sun, 23 Jan 2011 17:18:30 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <033c3f90-03fb-4f65-bbae-bbc80a262685@l22g2000vbp.googlegroups.com> Message-ID: On Jan 23, 5:27?pm, "Martin v. Loewis" wrote: > Since you are asking for a traceback, here is one: [...snip: barf...] > If you had expected a Python traceback, sorry Rick: it didn't produce > one, since it crashed. Well i did "expect" that you would at least include some info as to your OS and version. That would be helpful also. Obviously the wx.ImageList is barfing. Do you have the Bitmap folder containing the three images. Did you try to comment out the "_createImages()" line. Simple debug skills we are talking about here Martin, simple. But yet again this is only tested on Windows. I clearly noted that in the source. From rantingrick at gmail.com Sun Jan 23 20:25:12 2011 From: rantingrick at gmail.com (rantingrick) Date: Sun, 23 Jan 2011 17:25:12 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <480571f5-5731-4f8b-9cb4-1468478711bf@c39g2000yqi.googlegroups.com> <2c951199-3dba-4d24-a5c2-f84081688f7e@u6g2000yqk.googlegroups.com> <3e603997-5539-4660-bd83-7398bdab34a4@k30g2000vbn.googlegroups.com> <5edded76-fdac-4eb5-8480-25e3381e2fd4@g26g2000vbz.googlegroups.com> <1d7fdb0c-9f82-45ab-bf0e-99d210042f0d@j21g2000vbn.googlegroups.com> <4d3cb5fc$0$29983$c3e8da3$5496439d@news.astraweb.com> <4D3CBD79.3000905@v.loewis.de> Message-ID: <47190643-c3e1-4229-a456-fc505a13c10b@k22g2000yqh.googlegroups.com> On Jan 23, 5:44?pm, "Martin v. Loewis" wrote: > > For something as common as displaying a file browser, it should be as > > simple as this: > > > import gui_toolkit ?# whichever > > path = gui_toolkit.select_file() > > > Something like zenity: > > > [steve at sylar ~]$ zenity --file-selection > > /home/steve/python/findsingle.py > > And indeed, it is that simple: > > python -c "import tkFileDialog as tkfd;print tkfd.askopenfilename()" Martin the tkFileDialog.ask* uses the platform specific Open, Save dialogs which DO contain a ListCtrl. Obviously this ListCtrl is not available to Tkinter uses. You just exposed your weak knowledge of Tkinter and sadly you are very high on the community totem pole. Very sad :( From rantingrick at gmail.com Sun Jan 23 20:26:13 2011 From: rantingrick at gmail.com (rantingrick) Date: Sun, 23 Jan 2011 17:26:13 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <3a96fee1-995f-49f7-a967-f125cc3f1cdc@v26g2000yqf.googlegroups.com> Message-ID: <5aa673d3-bb9e-4905-b8eb-7c51b8a174d0@v17g2000yqv.googlegroups.com> On Jan 23, 6:31?pm, "Martin v. Loewis" wrote: > > WxPython Challenge 1 code updated... > > > ?* Fixed tab traveral > > ?* Removed hand-holding code > > ?* Removed some cruft > > > ?https://sites.google.com/site/thefutureofpython/home/code-challenges > > > Good luck! > > Still crashes the interpreter. What OS are you using? You failed to answer this last question lastime. From rantingrick at gmail.com Sun Jan 23 20:28:13 2011 From: rantingrick at gmail.com (rantingrick) Date: Sun, 23 Jan 2011 17:28:13 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <3a96fee1-995f-49f7-a967-f125cc3f1cdc@v26g2000yqf.googlegroups.com> Message-ID: <4ef41c75-8372-4a94-a93c-1b4e7a6e0759@m13g2000yqb.googlegroups.com> On Jan 23, 6:30?pm, Corey Richardson wrote: > On 01/23/2011 07:07 PM, rantingrick wrote: > > > On Jan 22, 6:07 pm, rantingrick ?wrote: > > >> I await any challengers... > > > WxPython Challenge 1 code updated... > > > ? * Fixed tab traveral > > ? * Removed hand-holding code > > ? * Removed some cruft > > > ? ?https://sites.google.com/site/thefutureofpython/home/code-challenges > > > Good luck! > > Still doesn't fix the problem of the code not working on Linux boxes. > Maybe wxPython isn't the best option, it doesn't appear very cross-platform. > Still getting: > > Loading Images: > ? -- /home/corey/Downloads/Wx_Tk_Challenge/Bitmaps/file.bmp, file.bmp > ? -- /home/corey/Downloads/Wx_Tk_Challenge/Bitmaps/folder.bmp, folder.bmp > ? -- /home/corey/Downloads/Wx_Tk_Challenge/Bitmaps/link.bmp, link.bmp > imageMap.keys -> ['folder', 'link', 'file'] > Segmentation fault Have you tried any debugging? Maybe Linux has some specific needs and NOT wxPython. Stop jumping to conclusions. From rantingrick at gmail.com Sun Jan 23 20:33:22 2011 From: rantingrick at gmail.com (rantingrick) Date: Sun, 23 Jan 2011 17:33:22 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <70498$4d3cb87c$4275d90a$4428@FUSE.NET> <63eea$4d3cd2fd$4275d90a$14984@FUSE.NET> Message-ID: <69465430-08b3-4069-99c7-72f4d3034c66@s5g2000yqm.googlegroups.com> On Jan 23, 7:16?pm, Kevin Walzer wrote: > On 1/23/11 8:12 PM, rantingrick wrote: > > > The only way i can respond to this is to quite the requirements for my > > challenge... > > > --------------------------------------- > > ? Challenge 1: (Simple Directory Viewer) > > --------------------------------------- > > Create a simple Directory Viewer GUI. You CANNOT use a treectrl! > > > Any questions? > > Why not? > > I'd understand if this code made use of some Tk extension, as that's not > quite an apples-to-apples comparison. But the treectrl is part of the > core Tkinter widget set. Well wxPython ha a treectrl too. And if we were comparing apples to apples then we would compare the wx.TreeCtrl to the Tk::TreeCtrl. However there are many things that a ListCtrl can do that a treectrl can't. The biggest difference.... COLUMNS > There's no reason to exclude it (Tk::TreeCtrl) unless you are > deliberately trying to handicap Tk in your comparison. I am not handicapping TclTk. They already did that themselves by refusing to keep up with 21st century GUI libraries. Sure, you can say Tkinter is a knife and wxPython is an AK47 but who's to blame when you bring a knife to gun fight Kevin? Switch to wx and enjoy the bloodbath. From rantingrick at gmail.com Sun Jan 23 20:36:21 2011 From: rantingrick at gmail.com (rantingrick) Date: Sun, 23 Jan 2011 17:36:21 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <480571f5-5731-4f8b-9cb4-1468478711bf@c39g2000yqi.googlegroups.com> <2c951199-3dba-4d24-a5c2-f84081688f7e@u6g2000yqk.googlegroups.com> <3e603997-5539-4660-bd83-7398bdab34a4@k30g2000vbn.googlegroups.com> <5edded76-fdac-4eb5-8480-25e3381e2fd4@g26g2000vbz.googlegroups.com> <1d7fdb0c-9f82-45ab-bf0e-99d210042f0d@j21g2000vbn.googlegroups.com> <4d3cb5fc$0$29983$c3e8da3$5496439d@news.astraweb.com> <4D3CBD79.3000905@v.loewis.de> <4d3cd35e$0$29974$c3e8da3$5496439d@news.astraweb.com> Message-ID: <743a0bfa-49ff-42b3-a462-f5976b653b21@l19g2000yqo.googlegroups.com> On Jan 23, 7:18?pm, Steven D'Aprano wrote: > On Mon, 24 Jan 2011 00:44:57 +0100, Martin v. Loewis wrote: > >> For something as common as displaying a file browser, it should be as > >> simple as this: > > >> import gui_toolkit ?# whichever > >> path = gui_toolkit.select_file() > > >> Something like zenity: > > >> [steve at sylar ~]$ zenity --file-selection > >> /home/steve/python/findsingle.py > > > And indeed, it is that simple: > > > python -c "import tkFileDialog as tkfd;print tkfd.askopenfilename()" > > Brilliant! No, that was even weaker than Guido's tag argument. At LEAST when Guido parrots off minor issues he uses some fact based argument. This is just pathetic! Only the lemmings would believe such nonsense. > Pity that it is so ugly under Linux :( And who's fault is that i wonder? From kb1pkl at aim.com Sun Jan 23 20:40:34 2011 From: kb1pkl at aim.com (Corey Richardson) Date: Sun, 23 Jan 2011 20:40:34 -0500 Subject: WxPython versus Tkinter. In-Reply-To: <47190643-c3e1-4229-a456-fc505a13c10b@k22g2000yqh.googlegroups.com> References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <480571f5-5731-4f8b-9cb4-1468478711bf@c39g2000yqi.googlegroups.com> <2c951199-3dba-4d24-a5c2-f84081688f7e@u6g2000yqk.googlegroups.com> <3e603997-5539-4660-bd83-7398bdab34a4@k30g2000vbn.googlegroups.com> <5edded76-fdac-4eb5-8480-25e3381e2fd4@g26g2000vbz.googlegroups.com> <1d7fdb0c-9f82-45ab-bf0e-99d210042f0d@j21g2000vbn.googlegroups.com> <4d3cb5fc$0$29983$c3e8da3$5496439d@news.astraweb.com> <4D3CBD79.3000905@v.loewis.de> <47190643-c3e1-4229-a456-fc505a13c10b@k22g2000yqh.googlegroups.com> Message-ID: <4D3CD892.1070103@aim.com> On 01/23/2011 08:25 PM, rantingrick wrote: > On Jan 23, 5:44 pm, "Martin v. Loewis" wrote: >>> For something as common as displaying a file browser, it should be as >>> simple as this: >> >>> import gui_toolkit # whichever >>> path = gui_toolkit.select_file() >> >>> Something like zenity: >> >>> [steve at sylar ~]$ zenity --file-selection >>> /home/steve/python/findsingle.py >> >> And indeed, it is that simple: >> >> python -c "import tkFileDialog as tkfd;print tkfd.askopenfilename()" > > > Martin the tkFileDialog.ask* uses the platform specific Open, Save > dialogs which DO contain a ListCtrl. Obviously this ListCtrl is not > available to Tkinter uses. You just exposed your weak knowledge of > Tkinter and sadly you are very high on the community totem pole. Very > sad :( > Actually, the people on the top of the totem pole were of less social status. http://podcasts.howstuffworks.com/hsw/podcasts/sysk/2009-11-17-sysk-totem-poles.mp3?_kip_ipx=1723793795-1295833113 (Finally, useful knowledge from listening to podcasts in my off-time!) You have also ignored that I gave the same information as him (minus the traceback), saying that I am on Linux Mint 64bit. Why can't we use a TreeCtrl? If we can't use all our widgets, why can you use all yours? ~Corey From rantingrick at gmail.com Sun Jan 23 20:50:24 2011 From: rantingrick at gmail.com (rantingrick) Date: Sun, 23 Jan 2011 17:50:24 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <480571f5-5731-4f8b-9cb4-1468478711bf@c39g2000yqi.googlegroups.com> <2c951199-3dba-4d24-a5c2-f84081688f7e@u6g2000yqk.googlegroups.com> <3e603997-5539-4660-bd83-7398bdab34a4@k30g2000vbn.googlegroups.com> <5edded76-fdac-4eb5-8480-25e3381e2fd4@g26g2000vbz.googlegroups.com> <1d7fdb0c-9f82-45ab-bf0e-99d210042f0d@j21g2000vbn.googlegroups.com> <4d3cb5fc$0$29983$c3e8da3$5496439d@news.astraweb.com> <4D3CBD79.3000905@v.loewis.de> <47190643-c3e1-4229-a456-fc505a13c10b@k22g2000yqh.googlegroups.com> Message-ID: <26ca9b38-3ecc-4276-a8cf-95bea74fc41c@r14g2000yqn.googlegroups.com> On Jan 23, 7:40?pm, Corey Richardson wrote: > Why can't we use a TreeCtrl? If we can't use all our widgets, why can > you use all yours? > > ~Corey Columns Corey, the key word here is "columns". One more time...COOOOOOLLLLLUUUMMMNNNSSSS. Is this starting to sink in yet Corey? From drsalists at gmail.com Sun Jan 23 21:06:36 2011 From: drsalists at gmail.com (Dan Stromberg) Date: Sun, 23 Jan 2011 18:06:36 -0800 Subject: How to execute foreing code from Python In-Reply-To: <4D3CC6C4.3060502@ieee.org> References: <20cf30433cec39ebdb049a8ae637@google.com> <4D3CC6C4.3060502@ieee.org> Message-ID: On Sun, Jan 23, 2011 at 4:24 PM, Dave Angel wrote: > On 01/-10/-28163 02:59 PM, hidura at gmail.com wrote: >> >> Hello i want to code from different languages using a Python script i >> know i can use os.system, but i don't know how to receive data or send >> arguments using that method if theres any another way to make it or >> there's a way to send arguments and receive data using os.system? >> >> Thanks in advance. >> > > That sentence runs on, and makes no sense to me. ?But I can guess that you > would like to be able to write code in other languages, and call it from > within a Python script. Well, clearly it made some sense, or you wouldn't be responding. > If you're on Windows, and the other language is a compiled one like C, > compile it into a DLL, and call that DLL from Python. ?Ctypes is the first > module to study. The DLL is but a weak mimicry of what *ix had for a long time before. On most *ix's, the .so is the analog to the windows DLL, though only AIX appears to suffer from the same kind of "DLL hell" that windows suffers from (which makes some historical if not technical sense, given that windows is related to OS/2, which like AIX is also from IBM). Using a .so, you can still use ctypes. You also have the option of using Cython, which is perhaps a bit better supported on *ix, but will likely now work on windows too. > If you're on Linux, and the code in the other language was written by > someone else, and is already compiled into an executable you cannot change, This is rare on Linux - almost everything is changeable on Linux, because it is almost entirely opensource - sometimes entirely so, depending on distribution choice and what 3rd party apps you install after the OS install. > you probably should invoke it using the subprocess module. This is an option on almost any OS, and in fact is probably a pretty good one on almost any OS, even if you do have source. Sadly, few windows programs are written to take advantage of this, perhaps because of the historical (dos/windows) command.com's fake pipes. You can communicate with a subprocess using pipes, or command line arguments, or files, or sockets, or shared memory. There are probably other options that aren't coming to mind just now. But usually, using pipes gives the loosest (best) coupling between processes. Microsoft appears to have recognized this to some extent by releasing powershell - though it uses object pipes rather than byte stream pipes. Object pipes appear to require less serialization, but also appear to be less loosely coupled. For remote pipes, powershell serializes to XML, while *ix pipes serialize exactly the same way remote local or remote. From kb1pkl at aim.com Sun Jan 23 21:06:57 2011 From: kb1pkl at aim.com (Corey Richardson) Date: Sun, 23 Jan 2011 21:06:57 -0500 Subject: WxPython versus Tkinter. In-Reply-To: <26ca9b38-3ecc-4276-a8cf-95bea74fc41c@r14g2000yqn.googlegroups.com> References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <480571f5-5731-4f8b-9cb4-1468478711bf@c39g2000yqi.googlegroups.com> <2c951199-3dba-4d24-a5c2-f84081688f7e@u6g2000yqk.googlegroups.com> <3e603997-5539-4660-bd83-7398bdab34a4@k30g2000vbn.googlegroups.com> <5edded76-fdac-4eb5-8480-25e3381e2fd4@g26g2000vbz.googlegroups.com> <1d7fdb0c-9f82-45ab-bf0e-99d210042f0d@j21g2000vbn.googlegroups.com> <4d3cb5fc$0$29983$c3e8da3$5496439d@news.astraweb.com> <4D3CBD79.3000905@v.loewis.de> <47190643-c3e1-4229-a456-fc505a13c10b@k22g2000yqh.googlegroups.com> <26ca9b38-3ecc-4276-a8cf-95bea74fc41c@r14g2000yqn.googlegroups.com> Message-ID: <4D3CDEC1.80102@aim.com> On 01/23/2011 08:50 PM, rantingrick wrote: > On Jan 23, 7:40 pm, Corey Richardson wrote: > >> Why can't we use a TreeCtrl? If we can't use all our widgets, why can >> you use all yours? >> >> ~Corey > > Columns Corey, the key word here is "columns". One more > time...COOOOOOLLLLLUUUMMMNNNSSSS. Is this starting to sink in yet > Corey? I sent that email before you sent your email explaining why (responded to Kevin), sorry that I can't see the future. From kb1pkl at aim.com Sun Jan 23 21:07:33 2011 From: kb1pkl at aim.com (Corey Richardson) Date: Sun, 23 Jan 2011 21:07:33 -0500 Subject: WxPython versus Tkinter. In-Reply-To: <4ef41c75-8372-4a94-a93c-1b4e7a6e0759@m13g2000yqb.googlegroups.com> References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <3a96fee1-995f-49f7-a967-f125cc3f1cdc@v26g2000yqf.googlegroups.com> <4ef41c75-8372-4a94-a93c-1b4e7a6e0759@m13g2000yqb.googlegroups.com> Message-ID: <4D3CDEE5.4010309@aim.com> On 01/23/2011 08:28 PM, rantingrick wrote: > On Jan 23, 6:30 pm, Corey Richardson wrote: >> On 01/23/2011 07:07 PM, rantingrick wrote: >> >>> On Jan 22, 6:07 pm, rantingrick wrote: >> >>>> I await any challengers... >> >>> WxPython Challenge 1 code updated... >> >>> * Fixed tab traveral >>> * Removed hand-holding code >>> * Removed some cruft >> >>> https://sites.google.com/site/thefutureofpython/home/code-challenges >> >>> Good luck! >> >> Still doesn't fix the problem of the code not working on Linux boxes. >> Maybe wxPython isn't the best option, it doesn't appear very cross-platform. >> Still getting: >> >> Loading Images: >> -- /home/corey/Downloads/Wx_Tk_Challenge/Bitmaps/file.bmp, file.bmp >> -- /home/corey/Downloads/Wx_Tk_Challenge/Bitmaps/folder.bmp, folder.bmp >> -- /home/corey/Downloads/Wx_Tk_Challenge/Bitmaps/link.bmp, link.bmp >> imageMap.keys -> ['folder', 'link', 'file'] >> Segmentation fault > > Have you tried any debugging? Maybe Linux has some specific needs and > NOT wxPython. Stop jumping to conclusions. Python (and supposedly wxPython) are cross-platform. Code that runs on one should run on the other unmodified. This is obviously not the case. Line 151 fails (determined from a simple binary search using print statements): index = self.InsertImageStringItem(sys.maxint, name, imageIdx) Maybe wxPython (really wxwidgets, python doesn't throw segfaults...that I've ever seen) isn't suited for the stdlib, unless this is a just a really silly bug somewhere in your programming (which I doubt it is). Looks like an issue with the method, because imageIdx is just a dictionary, sys.maxint is a (surprise!) integer, and name is a string. From hidura at gmail.com Sun Jan 23 21:16:26 2011 From: hidura at gmail.com (Hidura) Date: Sun, 23 Jan 2011 22:16:26 -0400 Subject: How to execute foreing code from Python In-Reply-To: References: <20cf30433cec39ebdb049a8ae637@google.com> <4D3CC6C4.3060502@ieee.org> Message-ID: Thanks to all for your fast responses. I will use this on a server running on Linux, so there is no problem with the OS and probably i will try to pipes and subprocess, but the pipes worry me because i can't stop the process using timeout or i don't found how to stop it... 2011/1/23, Dan Stromberg : > On Sun, Jan 23, 2011 at 4:24 PM, Dave Angel wrote: >> On 01/-10/-28163 02:59 PM, hidura at gmail.com wrote: >>> >>> Hello i want to code from different languages using a Python script i >>> know i can use os.system, but i don't know how to receive data or send >>> arguments using that method if theres any another way to make it or >>> there's a way to send arguments and receive data using os.system? >>> >>> Thanks in advance. >>> >> >> That sentence runs on, and makes no sense to me. ?But I can guess that you >> would like to be able to write code in other languages, and call it from >> within a Python script. > > Well, clearly it made some sense, or you wouldn't be responding. > >> If you're on Windows, and the other language is a compiled one like C, >> compile it into a DLL, and call that DLL from Python. ?Ctypes is the first >> module to study. > > The DLL is but a weak mimicry of what *ix had for a long time before. > On most *ix's, the .so is the analog to the windows DLL, though only > AIX appears to suffer from the same kind of "DLL hell" that windows > suffers from (which makes some historical if not technical sense, > given that windows is related to OS/2, which like AIX is also from > IBM). Using a .so, you can still use ctypes. You also have the > option of using Cython, which is perhaps a bit better supported on > *ix, but will likely now work on windows too. > >> If you're on Linux, and the code in the other language was written by >> someone else, and is already compiled into an executable you cannot >> change, > > This is rare on Linux - almost everything is changeable on Linux, > because it is almost entirely opensource - sometimes entirely so, > depending on distribution choice and what 3rd party apps you install > after the OS install. > >> you probably should invoke it using the subprocess module. > > This is an option on almost any OS, and in fact is probably a pretty > good one on almost any OS, even if you do have source. Sadly, few > windows programs are written to take advantage of this, perhaps > because of the historical (dos/windows) command.com's fake pipes. > > You can communicate with a subprocess using pipes, or command line > arguments, or files, or sockets, or shared memory. There are probably > other options that aren't coming to mind just now. But usually, using > pipes gives the loosest (best) coupling between processes. > > Microsoft appears to have recognized this to some extent by releasing > powershell - though it uses object pipes rather than byte stream > pipes. Object pipes appear to require less serialization, but also > appear to be less loosely coupled. For remote pipes, powershell > serializes to XML, while *ix pipes serialize exactly the same way > remote local or remote. > -- Enviado desde mi dispositivo m?vil Diego I. Hidalgo D. From kw at codebykevin.com Sun Jan 23 21:16:49 2011 From: kw at codebykevin.com (Kevin Walzer) Date: Sun, 23 Jan 2011 21:16:49 -0500 Subject: WxPython versus Tkinter. In-Reply-To: <69465430-08b3-4069-99c7-72f4d3034c66@s5g2000yqm.googlegroups.com> References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <70498$4d3cb87c$4275d90a$4428@FUSE.NET> <63eea$4d3cd2fd$4275d90a$14984@FUSE.NET> <69465430-08b3-4069-99c7-72f4d3034c66@s5g2000yqm.googlegroups.com> Message-ID: <705ad$4d3ce0fc$4275d90a$29144@FUSE.NET> On 1/23/11 8:33 PM, rantingrick wrote: > Well wxPython ha a treectrl too. And if we were comparing apples to > apples then we would compare the wx.TreeCtrl to the Tk::TreeCtrl. > However there are many things that a ListCtrl can do that a treectrl > can't. The biggest difference.... COLUMNS The ttk::treeview widget can also function as a multi-column listbox, and can include both tree and multi-column listbox features in a single window. It's a very flexible widget. -- Kevin Walzer Code by Kevin http://www.codebykevin.com From rantingrick at gmail.com Sun Jan 23 21:27:34 2011 From: rantingrick at gmail.com (rantingrick) Date: Sun, 23 Jan 2011 18:27:34 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <480571f5-5731-4f8b-9cb4-1468478711bf@c39g2000yqi.googlegroups.com> <2c951199-3dba-4d24-a5c2-f84081688f7e@u6g2000yqk.googlegroups.com> <3e603997-5539-4660-bd83-7398bdab34a4@k30g2000vbn.googlegroups.com> <5edded76-fdac-4eb5-8480-25e3381e2fd4@g26g2000vbz.googlegroups.com> <1d7fdb0c-9f82-45ab-bf0e-99d210042f0d@j21g2000vbn.googlegroups.com> <4d3cb5fc$0$29983$c3e8da3$5496439d@news.astraweb.com> <4D3CBD79.3000905@v.loewis.de> <47190643-c3e1-4229-a456-fc505a13c10b@k22g2000yqh.googlegroups.com> <26ca9b38-3ecc-4276-a8cf-95bea74fc41c@r14g2000yqn.googlegroups.com> Message-ID: <3a500c4d-d780-45da-bdef-bbc3d7c5d3e7@u6g2000yqk.googlegroups.com> On Jan 23, 8:06?pm, Corey Richardson wrote: > > Columns Corey, the key word here is "columns". One more > > time...COOOOOOLLLLLUUUMMMNNNSSSS. Is this starting to sink in yet > > Corey? > > I sent that email before you sent your email explaining why (responded > to Kevin), sorry that I can't see the future. Don't worry, I forgive you Corey. We can't *all* be visionaries ;-) From rantingrick at gmail.com Sun Jan 23 21:29:41 2011 From: rantingrick at gmail.com (rantingrick) Date: Sun, 23 Jan 2011 18:29:41 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <3a96fee1-995f-49f7-a967-f125cc3f1cdc@v26g2000yqf.googlegroups.com> <4ef41c75-8372-4a94-a93c-1b4e7a6e0759@m13g2000yqb.googlegroups.com> Message-ID: <127931eb-239e-4dce-a06e-b10132b83214@k3g2000yqc.googlegroups.com> On Jan 23, 8:07?pm, Corey Richardson wrote: > because imageIdx is just a dictionary, No, imageIdx is an integer. From rantingrick at gmail.com Sun Jan 23 21:34:18 2011 From: rantingrick at gmail.com (rantingrick) Date: Sun, 23 Jan 2011 18:34:18 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <70498$4d3cb87c$4275d90a$4428@FUSE.NET> <63eea$4d3cd2fd$4275d90a$14984@FUSE.NET> <69465430-08b3-4069-99c7-72f4d3034c66@s5g2000yqm.googlegroups.com> <705ad$4d3ce0fc$4275d90a$29144@FUSE.NET> Message-ID: <3d68e6fe-be68-4713-8330-20886d914547@r29g2000yqj.googlegroups.com> On Jan 23, 8:16?pm, Kevin Walzer wrote: > The ttk::treeview widget can also function as a multi-column listbox, > and can include both tree and multi-column listbox features in a single > window. It's a very flexible widget. Can we see some working code? I would love to see some code Kevin. You might satisfy the column requirement however you also need editable labels and two veiw modes; reportview and listview. Actually it sounds pretty much like a (wait for it...) TreeCtrl to me. PS: Be sure not to cause any segfaults because these linux folks can't debug for shite! From kb1pkl at aim.com Sun Jan 23 21:40:41 2011 From: kb1pkl at aim.com (Corey Richardson) Date: Sun, 23 Jan 2011 21:40:41 -0500 Subject: WxPython versus Tkinter. In-Reply-To: <127931eb-239e-4dce-a06e-b10132b83214@k3g2000yqc.googlegroups.com> References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <3a96fee1-995f-49f7-a967-f125cc3f1cdc@v26g2000yqf.googlegroups.com> <4ef41c75-8372-4a94-a93c-1b4e7a6e0759@m13g2000yqb.googlegroups.com> <127931eb-239e-4dce-a06e-b10132b83214@k3g2000yqc.googlegroups.com> Message-ID: <4D3CE6A9.4070707@aim.com> On 01/23/2011 09:29 PM, rantingrick wrote: > On Jan 23, 8:07 pm, Corey Richardson wrote: > >> because imageIdx is just a dictionary, > > No, imageIdx is an integer. You're right. imageIdx = self.imageMap[iconname] I confused imageIdx with self.imageMap. But that still doesn't fix my problem, so before I go diving into the wxPython source, anyone have a 'quick fix'? From rantingrick at gmail.com Sun Jan 23 21:47:31 2011 From: rantingrick at gmail.com (rantingrick) Date: Sun, 23 Jan 2011 18:47:31 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> Message-ID: <2092760a-1f32-48aa-aee1-d7d648b23c66@32g2000yqz.googlegroups.com> On Jan 22, 6:07?pm, rantingrick wrote: > I await any challengers... CODE UPDATE: * removed sys.maxint (not sure how it got there?) https://sites.google.com/site/thefutureofpython/home/code-challenges From steve+comp.lang.python at pearwood.info Sun Jan 23 21:48:08 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 24 Jan 2011 02:48:08 GMT Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <480571f5-5731-4f8b-9cb4-1468478711bf@c39g2000yqi.googlegroups.com> <2c951199-3dba-4d24-a5c2-f84081688f7e@u6g2000yqk.googlegroups.com> <3e603997-5539-4660-bd83-7398bdab34a4@k30g2000vbn.googlegroups.com> <5edded76-fdac-4eb5-8480-25e3381e2fd4@g26g2000vbz.googlegroups.com> <1d7fdb0c-9f82-45ab-bf0e-99d210042f0d@j21g2000vbn.googlegroups.com> <4d3cb5fc$0$29983$c3e8da3$5496439d@news.astraweb.com> <4D3CBD79.3000905@v.loewis.de> <47190643-c3e1-4229-a456-fc505a13c10b@k22g2000yqh.googlegroups.com> <26ca9b38-3ecc-4276-a8cf-95bea74fc41c@r14g2000yqn.googlegroups.com> Message-ID: <4d3ce868$0$29974$c3e8da3$5496439d@news.astraweb.com> On Sun, 23 Jan 2011 17:50:24 -0800, rantingrick wrote: > On Jan 23, 7:40?pm, Corey Richardson wrote: > >> Why can't we use a TreeCtrl? If we can't use all our widgets, why can >> you use all yours? >> >> ~Corey > > Columns Corey, the key word here is "columns". One more > time...COOOOOOLLLLLUUUMMMNNNSSSS. Is this starting to sink in yet Corey? When I run the code snippet Martin provided under Linux, the file selection box shows files in columns. That's part of the reason why I consider it ugly -- I'm an old Mac guy, and I still dislike file selection tools that use the Windows 95 style 2-D layout: a-file e-file ... b-file f-file y-file c-file g-file z-file d-file h-file instead of a simple vertical list: a-file b-file c-file ... z-file Call me a dinosaur if you will, but I hate horizontal scrolling. -- Steven From ian.g.kelly at gmail.com Sun Jan 23 22:05:49 2011 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Sun, 23 Jan 2011 20:05:49 -0700 Subject: A and B but not C in list In-Reply-To: References: <8cae2caf-d3df-4ed3-9afb-29de97772298@m13g2000yqb.googlegroups.com> Message-ID: On Sun, Jan 23, 2011 at 2:34 PM, Christian Heimes wrote: > your_set = set(your_list) > > if your_set.issuperset(set([A, B])) and your_set.isdisjoint(set([C, D])): if your_set.intersection([A, B, C, D]) == set([A, B]): ... Cheers, Ian From kb1pkl at aim.com Sun Jan 23 22:25:10 2011 From: kb1pkl at aim.com (Corey Richardson) Date: Sun, 23 Jan 2011 22:25:10 -0500 Subject: WxPython versus Tkinter. In-Reply-To: <2092760a-1f32-48aa-aee1-d7d648b23c66@32g2000yqz.googlegroups.com> References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <2092760a-1f32-48aa-aee1-d7d648b23c66@32g2000yqz.googlegroups.com> Message-ID: <4D3CF116.2020504@aim.com> On 01/23/2011 09:47 PM, rantingrick wrote: > On Jan 22, 6:07 pm, rantingrick wrote: > >> I await any challengers... > > CODE UPDATE: > > * removed sys.maxint (not sure how it got there?) > > > https://sites.google.com/site/thefutureofpython/home/code-challenges In the example at http://www.wxpython.org/OSCON2004/advanced/wxPython-Advanced-OSCON2004.pdf they use sys.maxint, which may be where you got it (wild shot in the dark!). The following result in a segfault: -------item-1--------------------- list_item = wx.ListItem() list_item.SetId(idx) list_item.SetText(name) list_item.SetWidth(50) index = self.InsertItem(list_item) -----------end-------------------- ------item-2---------------------- self.InsertStringItem(idx, name) -----------end-------------------- The following will launch the application: (drop in replacement for line 151): index = self.SetStringItem(idx, 0, name) No idea why, I've never used wxPython before today. Unfortunately, it doesn't actually show the items in the directory. Since I'm definitely not a wxPython user, would you mind making the above work, rantingrick? Not trying to worm out of anything, but this is way over my head. ~Corey From tyler at tysdomain.com Sun Jan 23 23:16:15 2011 From: tyler at tysdomain.com (Littlefield, Tyler) Date: Sun, 23 Jan 2011 21:16:15 -0700 Subject: WxPython versus Tkinter. In-Reply-To: <3d68e6fe-be68-4713-8330-20886d914547@r29g2000yqj.googlegroups.com> References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <70498$4d3cb87c$4275d90a$4428@FUSE.NET> <63eea$4d3cd2fd$4275d90a$14984@FUSE.NET> <69465430-08b3-4069-99c7-72f4d3034c66@s5g2000yqm.googlegroups.com> <705ad$4d3ce0fc$4275d90a$29144@FUSE.NET> <3d68e6fe-be68-4713-8330-20886d914547@r29g2000yqj.googlegroups.com> Message-ID: <4D3CFD0F.1080502@tysdomain.com> >PS: Be sure not to cause any segfaults because these linux folks can't >debug for shite! Or maybe it is that the person fighting and throwing insults around like candy at a parade can't code for shite. Or *gasp* the library that is supposedly cross-platform has issues on certain platforms. You provided a challenge to show how superior wxPython was. If it segfaults, that tells me that: 1) you can't code worth "shite," or 2) the library you are drooling over sucks and shouldn't be cross-platform. Which is it? I highly doubt there is a third option, but please feel free to tell me, rather than insulting again. On 1/23/2011 7:34 PM, rantingrick wrote: > On Jan 23, 8:16 pm, Kevin Walzer wrote: > >> The ttk::treeview widget can also function as a multi-column listbox, >> and can include both tree and multi-column listbox features in a single >> window. It's a very flexible widget. > Can we see some working code? I would love to see some code Kevin. You > might satisfy the column requirement however you also need editable > labels and two veiw modes; reportview and listview. Actually it > sounds pretty much like a (wait for it...) TreeCtrl to me. > > PS: Be sure not to cause any segfaults because these linux folks can't > debug for shite! -- Thanks, Ty From rustompmody at gmail.com Mon Jan 24 01:06:48 2011 From: rustompmody at gmail.com (rusi) Date: Sun, 23 Jan 2011 22:06:48 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <70498$4d3cb87c$4275d90a$4428@FUSE.NET> <63eea$4d3cd2fd$4275d90a$14984@FUSE.NET> <69465430-08b3-4069-99c7-72f4d3034c66@s5g2000yqm.googlegroups.com> <705ad$4d3ce0fc$4275d90a$29144@FUSE.NET> <3d68e6fe-be68-4713-8330-20886d914547@r29g2000yqj.googlegroups.com> Message-ID: On Jan 24, 9:16?am, "Littlefield, Tyler" wrote: > ?>PS: Be sure not to cause any segfaults because these linux folks can't > ?>debug for shite! > Or maybe it is that the person fighting and throwing insults around like > candy at a parade can't code for shite. Or *gasp* the library that is > supposedly cross-platform has issues on certain platforms. You provided > a challenge to show how superior wxPython was. If it segfaults, that > tells me that: 1) you can't code worth "shite," or 2) the library you > are drooling over sucks and shouldn't be cross-platform. Which is it? I > highly doubt there is a third option, but please feel free to tell me, > rather than insulting again. I think there is a third option About rr's code-ing ability... this thread is long enough :-) Likewise if a certain library not in python standard distribution does not work properly its the problem of the library. But if python crashes its not good for the image of python. Personal note 1: I am often teaching python with code I am seeing for the first time -- typically something the class presents me which we understand/debug/refactor together. Usually I am not afraid of python because errors are helpful and gentle. Segfaulting on the other hand is the last thing I want to see in such a context :-) Personal note 2: I dont regard myself as a gui programmer and Ive often wondered which toolkit to demonstrate. I probably wont be looking at wx now unless someone gives a convincing argument that the segfault did not happen "inside" wx. Of course as Steven pointed out wx is written in C++ which is almost certainly where the crash is occurring. But this is technical nitpicking. The real issue is that when coding in C/C++ segfaults are a daily affair. Whereas for python its the first time I am seeing it in 10 years... From santhosh.vkumar at gmail.com Mon Jan 24 01:10:10 2011 From: santhosh.vkumar at gmail.com (Santhosh Kumar) Date: Mon, 24 Jan 2011 11:40:10 +0530 Subject: Get input in Python Message-ID: Hi all, I am trying to get input from the file* open(sys.argv[1]). *So, while executing I will refer it as python filename.py sample_file.txt this will root to my sys.argv[]. So I need to follow the same but I also need to give input Example : python filename.py . How should I do coding for this. Thanks in Advance, Santhosh V.Kumar -------------- next part -------------- An HTML attachment was scrubbed... URL: From clp2 at rebertia.com Mon Jan 24 01:37:08 2011 From: clp2 at rebertia.com (Chris Rebert) Date: Sun, 23 Jan 2011 22:37:08 -0800 Subject: Get input in Python In-Reply-To: References: Message-ID: On Sun, Jan 23, 2011 at 10:10 PM, Santhosh Kumar wrote: > Hi all, > ?? ? ? ? ?I am trying to get input from the file?open(sys.argv[1]). So, > while executing I will refer it as python filename.py ?sample_file.txt ?this > will root to my sys.argv[]. So I need to follow the same but I also need to > give input Example : ?python filename.py . How > should I do coding for this. Just access the text using sys.argv like before. It's just another element in the list; there's nothing special about it. You just need to change the indices accordingly: from sys import argv text = argv[1] filepath = argv[2] # alternatively: # text, filepath = argv[1:] print("Your text input was:") print(text) print("The file's contents are:") with file(filepath, 'r') as f: print(f.read()) Usage: $ python 'Hello there Santhosh' something.txt Your text input was: Hello there Santhosh The file's contents are: Note that the text is quoted; this is required if your text contains spaces and/or shell special characters. Cheers, Chris -- http://blog.rebertia.com From orasnita at gmail.com Mon Jan 24 01:52:18 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Mon, 24 Jan 2011 08:52:18 +0200 Subject: [Code Challenge] WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <70498$4d3cb87c$4275d90a$4428@FUSE.NET> Message-ID: <682981AD3E82477BBF5C16E4514ECD60@octavian> From: "Kevin Walzer" >I found this code in the Demo/tkinter/ttk directory of the Python 2.7.1 >source distribution. I'm NOT the author (credit should probably go to >Guilherme Polo, developer of the Tkinter wrapper for the ttk themed widgets >that is now in the stdlib). But, using a tree/listview widget that is part >of the Tk/Tkinter core (NOT an extension), it presents a decent, simple >file browser: > Well, I have also tested the program dirbrowser.py, but it is not decent at all. I have tested it with JAWS screen reader and it is absolutely inaccessible. The single "accessible" things in it are the title bar which is "tk". It can't compare with the same program made using WxPython. And it can't be made to be more accessible than it is, because it uses Tk. So Tkinter is really bad. Octavian From orasnita at gmail.com Mon Jan 24 01:54:16 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Mon, 24 Jan 2011 08:54:16 +0200 Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com><70498$4d3cb87c$4275d90a$4428@FUSE.NET><63eea$4d3cd2fd$4275d90a$14984@FUSE.NET><69465430-08b3-4069-99c7-72f4d3034c66@s5g2000yqm.googlegroups.com> <705ad$4d3ce0fc$4275d90a$29144@FUSE.NET> Message-ID: From: "Kevin Walzer" > The ttk::treeview widget can also function as a multi-column listbox, and > can include both tree and multi-column listbox features in a single > window. It's a very flexible widget. But unfortunately it is not accessible for screen readers and it discriminates many potential users. Octavian From orasnita at gmail.com Mon Jan 24 01:58:29 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Mon, 24 Jan 2011 08:58:29 +0200 Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <70498$4d3cb87c$4275d90a$4428@FUSE.NET> <63eea$4d3cd2fd$4275d90a$14984@FUSE.NET> <69465430-08b3-4069-99c7-72f4d3034c66@s5g2000yqm.googlegroups.com> <705ad$4d3ce0fc$4275d90a$29144@FUSE.NET><3d68e6fe-be68-4713-8330-20886d914547@r29g2000yqj.googlegroups.com> <4D3CFD0F.1080502@tysdomain.com> Message-ID: <58325C0B6449487E97D2523C1685624F@octavian> From: "Littlefield, Tyler" > >PS: Be sure not to cause any segfaults because these linux folks can't > >debug for shite! > Or maybe it is that the person fighting and throwing insults around like > candy at a parade can't code for shite. Or *gasp* the library that is > supposedly cross-platform has issues on certain platforms. You provided a > challenge to show how superior wxPython was. If it segfaults, that tells > me that: 1) you can't code worth "shite," or 2) the library you are > drooling over sucks and shouldn't be cross-platform. Which is it? I highly > doubt there is a third option, but please feel free to tell me, rather > than insulting again. Hi Tyler, Are you able to use Tkinter-based applications under Windows? Or you have started to use Linux and now you don't care about the majority of users that need to use a screen reader? Octavian From israelu at elbit.co.il Mon Jan 24 02:02:25 2011 From: israelu at elbit.co.il (iu2) Date: Sun, 23 Jan 2011 23:02:25 -0800 (PST) Subject: Converting functions Message-ID: <6c099cc0-9772-4151-86b9-d72242fbbdea@k13g2000vbq.googlegroups.com> Hi all, I'm trying to convert functions - pass a few functions to a converting function, which change their behaviour and return the changed functions: >>> def cfuncs(*funcs): n = [] for f in funcs: def ff(*args, **key): print 'Start!', f.func_name res = f(*args, **key) print 'End', f.func_name return res n.append(ff) return n then I try it using two functions: >>> def f1(): print 'hello' >>> def f2(x): return 2 * x Eventually: >>> newfuncs = cfuncs(f1, f2) I would expect newfuncs to hold changed versions of f1 and f2, but what is actually contained in newfuncs is twice the changed version of f2. That is: >>> newfuncs[1](100) Start! f2 End f2 200 which is what I expected, but: >>> newfuncs[0]() Start! f2 Traceback (most recent call last): File "", line 1, in newfuncs[0]() File "", line 6, in ff res = f(*args, **key) TypeError: f2() takes exactly 1 argument (0 given) which is not. I'll appreciate your help in pointing out the mistake in defining cfuncs and how to fix it. Thank you very much! From orasnita at gmail.com Mon Jan 24 02:05:02 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Mon, 24 Jan 2011 09:05:02 +0200 Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com><480571f5-5731-4f8b-9cb4-1468478711bf@c39g2000yqi.googlegroups.com><2c951199-3dba-4d24-a5c2-f84081688f7e@u6g2000yqk.googlegroups.com><3e603997-5539-4660-bd83-7398bdab34a4@k30g2000vbn.googlegroups.com><5edded76-fdac-4eb5-8480-25e3381e2fd4@g26g2000vbz.googlegroups.com><1d7fdb0c-9f82-45ab-bf0e-99d210042f0d@j21g2000vbn.googlegroups.com><4d3cb5fc$0$29983$c3e8da3$5496439d@news.astraweb.com><4D3CBD79.3000905@v.loewis.de> <47190643-c3e1-4229-a456-fc505a13c10b@k22g2000yqh.googlegroups.com> Message-ID: <7AF6F130FBC2447BA7D595777B8723FF@octavian> From: "rantingrick" On Jan 23, 5:44 pm, "Martin v. Loewis" wrote: > > For something as common as displaying a file browser, it should be as > > simple as this: > > > import gui_toolkit # whichever > > path = gui_toolkit.select_file() > > > Something like zenity: > > > [steve at sylar ~]$ zenity --file-selection > > /home/steve/python/findsingle.py > > And indeed, it is that simple: > > python -c "import tkFileDialog as tkfd;print tkfd.askopenfilename()" Martin the tkFileDialog.ask* uses the platform specific Open, Save dialogs which DO contain a ListCtrl. Obviously this ListCtrl is not available to Tkinter uses. You just exposed your weak knowledge of Tkinter and sadly you are very high on the community totem pole. Very sad :( Aha, that's why that Open File window was accessible for JAWS screen reader, although it uses Tk... because actually it doesn't use Tk. Octavian From user at compgroups.net/ Mon Jan 24 02:18:08 2011 From: user at compgroups.net/ (fara) Date: Mon, 24 Jan 2011 01:18:08 -0600 Subject: switch from default env to virtualenv and back in script Message-ID: Hi, My default environment uses Python2.6 but I have a also virtualenv with Python2.7 with different packages. Is it possible to write a script where some parts are executed in the default Python2.6 environment and some others in the Python2.7 virtualenv. Something like this: ##### Start of pseudoscript import (Python2.6) packages execute code in Python2.6 switch to Python2.7 virtualenv import (Python2.7) packages execute code in the Python2.7 virtualenv and store information for later use switch back to default Python2.6 import (Python2.6) packages execute Python2.6 functions ##### End of pseudoscript Thanks Fara From enalicho at gmail.com Mon Jan 24 02:46:34 2011 From: enalicho at gmail.com (Noah Hall) Date: Mon, 24 Jan 2011 07:46:34 +0000 Subject: WxPython versus Tkinter. In-Reply-To: References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> Message-ID: On Sun, Jan 23, 2011 at 5:31 PM, rantingrick wrote: > So far only trolls (besides Terry, Octavian, D'Aprano) have replied. > In my time here within the Python community i have only met one person > who shares my in-depth knowledge of Tkinter. That person is Kevin > Waltzer. So outside of Python-dev and Guido. Kevin and I are are the > ONLY people qualified to offer opinions on the worth or worthlessness > of Tkinter. If anyone in this entire community thinks that they also > are qualified then prove your worth by creating a ListCtrl in Tkinter > that mirrors the wxPython ListCtrl in functionality. When you have > done that, i will elevate you to my circle of enlightenment. Than and > only then shall i even entertain you BS. Wow, someone's certainly feeling very self-important, ignoring the fact he can't follow conventions nor write cross-platform software. And before you start, no, I don't want to steal your "file browser". From __peter__ at web.de Mon Jan 24 02:51:24 2011 From: __peter__ at web.de (Peter Otten) Date: Mon, 24 Jan 2011 08:51:24 +0100 Subject: Converting functions References: <6c099cc0-9772-4151-86b9-d72242fbbdea@k13g2000vbq.googlegroups.com> Message-ID: iu2 wrote: > I'm trying to convert functions - pass a few functions to a converting > function, which change their behaviour and return the changed > functions: > > >>> def cfuncs(*funcs): > n = [] > for f in funcs: > def ff(*args, **key): > print 'Start!', f.func_name > res = f(*args, **key) > print 'End', f.func_name > return res > n.append(ff) > return n > > then I try it using two functions: > > >>> def f1(): > print 'hello' > > > >>> def f2(x): > return 2 * x > > Eventually: > >>> newfuncs = cfuncs(f1, f2) > > I would expect newfuncs to hold changed versions of f1 and f2, but > what is actually contained in newfuncs is twice the changed version of > f2. That is because the inner ff() references f which is a local variable of cfuncs(). By the time you invoke your newly created functions cfuncs() and thus the 'for f in funcs' loop has finished and the value of f is that of the last item in the funcs tuple. You can avoid the problem with another indirection def make_ff(f): def ff(*args, **key): print 'Start!', f.func_name res = f(*args, **key) print 'End', f.func_name return res return ff def cfuncs(*funcs): return [make_ff(f) for f in funcs] Peter From firedtoad at gmail.com Mon Jan 24 02:55:54 2011 From: firedtoad at gmail.com (wenhao zhang) Date: Mon, 24 Jan 2011 15:55:54 +0800 Subject: attend Message-ID: attend&& Join -------------- next part -------------- An HTML attachment was scrubbed... URL: From __peter__ at web.de Mon Jan 24 03:32:33 2011 From: __peter__ at web.de (Peter Otten) Date: Mon, 24 Jan 2011 09:32:33 +0100 Subject: documentation / reference help References: Message-ID: Scott Meup wrote: > I'm trying tolearn Python. The documentation tells syntax, and other > things > about a command. But for too many commands, it doesn't tell what it does. > for instance, in VB the 'return' command tells the program what line to > execute after some event (usually an error). In Python it appears to > return > a value. Where does it return it to? I couldn't find anywhere on the > Python website to find out or to ask Python to upgrade their > documentation. Can somebody please recommend a source. Python's return has nothing to do with with gosub ... return in Basic. I believe the analog to Python's return in VB is = exit function I. e. Function f(a, b) If a > b Then f = 42 Exit Function End If f = a + b End Function translates to def f(a, b): if a > b: return 42 return a + b in Python. From __peter__ at web.de Mon Jan 24 03:47:01 2011 From: __peter__ at web.de (Peter Otten) Date: Mon, 24 Jan 2011 09:47:01 +0100 Subject: A and B but not C in list References: <8cae2caf-d3df-4ed3-9afb-29de97772298@m13g2000yqb.googlegroups.com> Message-ID: Ian Kelly wrote: > On Sun, Jan 23, 2011 at 2:34 PM, Christian Heimes > wrote: >> your_set = set(your_list) >> >> if your_set.issuperset(set([A, B])) and your_set.isdisjoint(set([C, D])): > > if your_set.intersection([A, B, C, D]) == set([A, B]): > ... You can avoid converting your_list to a set with (using 2.7/3.x notation) if {A, B, C, D}.intersection(your_list) == {A, B}: ... The items in your_list still have to be hashable, so the approach is not as general as if (all(required in your_list for required in (A, B)) and not any(forbidden in your_list for forbidden in (C, D))): ... or similar. Also, it's not as easy to understand, so don't forget the explaining comment if you use the set-based approach. Peter From martin at v.loewis.de Mon Jan 24 03:56:16 2011 From: martin at v.loewis.de (Martin v. Loewis) Date: Mon, 24 Jan 2011 09:56:16 +0100 Subject: WxPython versus Tkinter. In-Reply-To: References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <033c3f90-03fb-4f65-bbae-bbc80a262685@l22g2000vbp.googlegroups.com> Message-ID: > Well i did "expect" that you would at least include some info as to > your OS and version. OS is Linux, wxPython is Debian python-wxgtk2.6 2.6.3.2.2-5+b1. > That would be helpful also. Obviously the > wx.ImageList is barfing. Do you have the Bitmap folder containing the > three images. Did you try to comment out the "_createImages()" line. If I do, I get Traceback (most recent call last): File "wxtk_challenge_1.py", line 222, in frame = AppFrame() File "wxtk_challenge_1.py", line 206, in __init__ self.listWidget.showDirectory(sys.prefix) File "wxtk_challenge_1.py", line 150, in showDirectory imageIdx = self.imageMap[iconname] KeyError: 'folder' If I then also comment out lines 150..154, I get a window, but it's empty (of course). > Simple debug skills we are talking about here Martin, simple. But yet > again this is only tested on Windows. I clearly noted that in the > source. Well Rick, this doesn't make look wxPython any better. Regards, Martin From israelu at elbit.co.il Mon Jan 24 04:19:40 2011 From: israelu at elbit.co.il (iu2) Date: Mon, 24 Jan 2011 01:19:40 -0800 (PST) Subject: Converting functions References: <6c099cc0-9772-4151-86b9-d72242fbbdea@k13g2000vbq.googlegroups.com> Message-ID: On Jan 24, 9:51?am, Peter Otten <__pete... at web.de> wrote: > iu2 wrote: > > I'm trying to convert functions - pass a few functions to a converting > > function, which change their behaviour and return the changed > > functions: > > > >>> def cfuncs(*funcs): > > ? ? ? ? n = [] > > ? ? ? ? for f in funcs: > > ? ? ? ? ? ? ? ? def ff(*args, **key): > > ? ? ? ? ? ? ? ? ? ? ? ? print 'Start!', f.func_name > > ? ? ? ? ? ? ? ? ? ? ? ? res = f(*args, **key) > > ? ? ? ? ? ? ? ? ? ? ? ? print 'End', f.func_name > > ? ? ? ? ? ? ? ? ? ? ? ? return res > > ? ? ? ? ? ? ? ? n.append(ff) > > ? ? ? ? return n > > > then I try it using two functions: > > > >>> def f1(): > > ? ? ? ? print 'hello' > > > >>> def f2(x): > > ? ? ? ? return 2 * x > > > Eventually: > > >>> newfuncs = cfuncs(f1, f2) > > > I would expect newfuncs to hold changed versions of f1 and f2, but > > what is actually contained in newfuncs is twice the changed version of > > f2. > > That is because the inner ff() references f which is a local variable of > cfuncs(). By the time you invoke your newly created functions cfuncs() and > thus the 'for f in funcs' loop has finished and the value of f is that of > the last item in the funcs tuple. You can avoid the problem with another > indirection > > def make_ff(f): > ? ? def ff(*args, **key): > ? ? ? ? print 'Start!', f.func_name > ? ? ? ? res = f(*args, **key) > ? ? ? ? print 'End', f.func_name > ? ? ? ? return res > ? ? return ff ? ? ? ? > > def cfuncs(*funcs): > ? ? return [make_ff(f) for f in funcs] > > Peter- Hide quoted text - > > - Show quoted text - Thanks! I thought a function definition creates a closure around all used vars. As I understand now only variables that are passed as function arguments can participate in a closure. From __peter__ at web.de Mon Jan 24 04:50:46 2011 From: __peter__ at web.de (Peter Otten) Date: Mon, 24 Jan 2011 10:50:46 +0100 Subject: Converting functions References: <6c099cc0-9772-4151-86b9-d72242fbbdea@k13g2000vbq.googlegroups.com> Message-ID: iu2 wrote: > I thought a function definition creates a closure around all used > vars. > As I understand now only variables that are passed as function > arguments can participate in a closure. No, it's just that all closures see the value of a variable at the time when the closure is run, not when it's defined. I don't know how to express it more clearly, so here's another example: >>> def f(): ... def g(): return a * a ... def h(): return a + a ... a = 5 ... return g, h ... >>> g, h = f() >>> g(), h() (25, 10) As you can see the local variable is not yet set when g() and h() are defined; but only the value by the time they are invoked matters. Here's a more involved generator version where the value may change between invocations: >>> def f(items): ... def g(): return a * a ... def h(): return a + a ... yield g, h ... for a in items: ... yield a ... >>> ff = f([2,3,4]) >>> g, h = next(ff) >>> g() Traceback (most recent call last): File "", line 1, in File "", line 2, in g NameError: free variable 'a' referenced before assignment in enclosing scope >>> next(ff) 2 >>> g(), h() (4, 4) >>> next(ff) 3 >>> g(), h() (9, 6) I think this behaviour is also called "late binding". Peter From james at funkymonkeysoftware.com Mon Jan 24 05:02:55 2011 From: james at funkymonkeysoftware.com (James Ravenscroft) Date: Mon, 24 Jan 2011 10:02:55 +0000 Subject: List behaviours with Clustering Algorithm Message-ID: <4D3D4E4F.1070705@funkymonkeysoftware.com> Dear All, I am currently trying to write a simple Agglomerative Clustering algorithm which sorts through my MP3 collection and uses associated Last.FM tags to cluster files into 'genres'. Unfortunately, I'm having some trouble with my algorithm and some tracks are ending up in multiple clusters. I have a feeling this is because of (my lack of understanding of) list behaviours within Python. This is all purely a learning exercise, so any input would be greatly appreciated The actual clustering method can be seen described here. Each Cluster is stored within the 'clusters' array and has two elements: the data containing song metadata such as artist, title and most importantly tags, and a weight: that is, the overall Euclidean weight of the cluster (based on the song data within). In theory, the algorithm runs in a loop until all clusters have been merged into a hierarchy. It takes the weight of each cluster and merges each cluster with their closest counterpart. My code has a lot of comments so it should be fairly easy to understand. Please see below: #-----------------------------Code Snippet -----------------------------------------------# def cluster(self): '''Run the clustering operation on the files ''' #add a cluster for each track to clusters for song in self.music.keys(): self.clusters.append({ 'data' : [song], 'weight' : long(0) }) currentLevel = 0 #current level of hierarchy #while there is more than one cluster in the sorting bank # i.e. we haven't achieved hierachy yet, run the algorithm while( len(self.clusters) > 1): print "Currently at Level %d" % currentLevel print "There are %d clusters at this level" % len(self.clusters) #store the level in the levels array self.levels.append(self.clusters) #empty the clusters list self.clusters = [] #find the weight of each current cluster for c in self.levels[currentLevel]: self.clusters.append({'data' : c['data'], 'weight' : self.__getClusterWeight(c['data'])}) #do the actual clustering tmp = [] for c in self.clusters: closestCluster = None closestDelta = float('inf') for c2 in self.clusters: #skip if this is the same node if(c == c2): continue delta = abs(c2['weight'] - c['weight']) if(delta < closestDelta): closestCluster = c2 closestDelta = delta print "Merging clusters %(c1)d and %(c2)d" % {'c1' : self.clusters.index(c), 'c2' : self.clusters.index(closestCluster)} #now merge the two clusters self.clusters.remove(closestCluster) self.clusters.remove(c) c['data'].extend(closestCluster['data']) tmp.append(c) #increment the level of the hierarchy self.clusters = tmp currentLevel += 1 #--------------------------------End Code Snippet ----------------------------# Thanks, James -- James Ravenscroft http://blog.funkymonkeysoftware.com/ From mailing at franzoni.eu Mon Jan 24 05:13:49 2011 From: mailing at franzoni.eu (Alan Franzoni) Date: Mon, 24 Jan 2011 11:13:49 +0100 Subject: Behaviour-based interface/protocol implementation? Message-ID: Hello, I'd like to have a system which lets me do certain actions if the duck-type of a certain objects matches what I expect, i.e. I'd like to have a formalization of what it's sometimes done through getattr() calls: if getattr(myobj, "somemethod", None) is not None: myobj.somemethod(somevalue) The above approach is sometimes too naive, because a) clutters code with many getattr calls and ifs b) I might want to check for multiple attributes and c) only checks for the method name and not for the method's signature. After looking at PyProtocols, zope.interface and python's own abc module, I'm left with a doubt: does any behaviour-based "interface testing" system exist for Python? I mean: all these three libraries use a register-based or inheritance-based approach; in abc, if I want instances of a class of mine "FooClass" to be "BarInterface" instances, I can either a) inherit from BarInterface or b) run "BarInterface.register(FooClass)". This poses some issues in a purely duck-typed context, IMHO. If an object perfectly satisfies the "BarInterface" signature, but it doesn't inherit from MyInterface and its class wasn't registered as a BarInterface implementor, the check "isinstance(myobj, BarInterface)" will yield a False result. This might not be a big deal if a) python >= 2.6 is used b) just checking for builtin interfaces - e.g. those defined in the "collections" module is required and c) you just require checking on basic types or on python builtin types (which correctly register builtin ABCs). What happens if I define my own ABC for my own purpose? There might be builtin objects, or third party libraries, which already offer objects that satisfy such interface, but I'd need to import such modules and register such classes as implementing my ABC, which is suboptimal. What I'd like to do is: class MyType(object): def someMethod(self, a, b): pass def otherMethod(self): pass class OtherType(object): def someMethod(self): pass def otherMethod(self): pass @DuckType class MyDuckType(object): def someMethod(self, a, b): pass def otherMethod(self): pass class TestDuckTypes(TestCase): def test_mytype_is_compatible_with_ducktype(self): myobj = MyType() self.assertEquals(True, MyDuckType.maybe_implemented_by(myobj)) def test_othertype_is_not_compatible_with_ducktype(self): myobj = OtherType() self.assertEquals(False, MyDuckType.maybe_implemented_by(myobj)) I'd like to do a kind of runtime-check for signatures. Of course there couldn't be an absolute certainty of interface implementation, because a runtime dynamic proxy method (accepting *args and **kwargs in its signature, as an example) might just fool my signature check. So, my questions are: a) does anything like that already exist in the python ecosystem? b) can anybody see any flaw either in what I'd like to do ("you shouldn't do that because...") or in the way I want to do it ("It won't work because...") -- Alan Franzoni -- contact me at public@[mysurname].eu From edmunds at laivas.lv Mon Jan 24 06:12:17 2011 From: edmunds at laivas.lv (Edmunds Cers) Date: Mon, 24 Jan 2011 12:12:17 +0100 Subject: Converting functions References: <6c099cc0-9772-4151-86b9-d72242fbbdea@k13g2000vbq.googlegroups.com> Message-ID: <4d3d5e93$0$1071$afc38c87@read01.usenet4all.se> Peter Otten <__peter__ at web.de> writes: > I don't know how to express it more clearly, so here's another example: > >>>> def f(): > ... def g(): return a * a > ... def h(): return a + a > ... a = 5 > ... return g, h > ... >>>> g, h = f() >>>> g(), h() > (25, 10) IMHO this whole confusion just shows that mingling assignment and binding makes understanding scope harder. In Python, the first assignment inside a function body also creates a binding (unless told not to do so by global) the scope of which is the _whole_ of the function body. A variable reference refers to the lexically innermost surrounding binding of said variable. Now, while it might seem that some magic happens in the example on the return of the function, this is in fact not so, since the assignment "a = 5" actually creates a binding for /a/ that is visible from the body of /g/, because the lexical scope of the binding is the whole body of /f/, so that the capture of the variable happens inside of the def expression (as one would expect) and not on return as you seem to imply. Slightly OT -- the above also explains why closed over variables are read only in Python. An assignment inside a closure would implicitly create a binding, so that all (even previous) references to that variable would refer to this new binding. > I think this behaviour is also called "late binding". "Retroactive implicit scope" would be closer. -- A change in perspective is worth 80 IQ points. --- Alan Kay From tchsprt.box at gmail.com Mon Jan 24 06:28:19 2011 From: tchsprt.box at gmail.com (Tech Support Box) Date: Mon, 24 Jan 2011 03:28:19 -0800 (PST) Subject: Multiple python installations mix their sys.prefix Message-ID: Hi there I have several versions of python2.4 installed: - the OS, rpm-installed one in /usr - Several other versions in /usr/local, installed with --prefix /usr/ local/inst-shared/ --exec-prefix /usr/local/inst/ My problem is when starting one of the versions from /usr/local, sys.prefix is set as "/usr" instead of the compile-time setting "/usr/ local/inst-shared/" and as a result sys.path contains paths from /usr, which shouldn't be there. After strace-ing the pythons from /usr/local and the one from /usr, it seems that python determines sys.prefix by first looking for os.py in every path component of the interpreter executable and adding "/lib/ python2.4/os.py" to it (i.e. stat()-ing for /usr/local/inst// bin/lib/python2.4/os.py, then /usr/local/inst//lib/python2.4/ os.py and so on) and only after it doesn't find os.py in any one of those paths does it look at the compile-time PREFIX setting. When doing this, it finds /usr/lib/python2.4/os.py (which belongs to the python installed at /usr) and determines that sys.prefix is /usr, which is wrong. The only fix I could come up with is setting PYTHONHOME before running python (which should be set differently for every version, and won't work in scripts using a shebang line) or moving /usr/lib/python2.4 to a different location (which is plain ugly). Is there a better way to make python take its compile-time option of prefix and *not* try to guess at runtime where it should be? Thanks. From __peter__ at web.de Mon Jan 24 06:43:34 2011 From: __peter__ at web.de (Peter Otten) Date: Mon, 24 Jan 2011 12:43:34 +0100 Subject: List behaviours with Clustering Algorithm References: Message-ID: James Ravenscroft wrote: > Dear All, > > I am currently trying to write a simple Agglomerative Clustering > algorithm which sorts through my MP3 collection and uses associated > Last.FM tags to cluster files into 'genres'. Unfortunately, I'm having > some trouble with my algorithm and some tracks are ending up in multiple > clusters. I have a feeling this is because of (my lack of understanding > of) list behaviours within Python. This is all purely a learning > exercise, so any input would be greatly appreciated > > The actual clustering method can be seen described here. Each Cluster is > stored within the 'clusters' array and has two elements: the data > containing song metadata such as artist, title and most importantly > tags, and a weight: that is, the overall Euclidean weight of the cluster > (based on the song data within). > > In theory, the algorithm runs in a loop until all clusters have been > merged into a hierarchy. It takes the weight of each cluster and merges > each cluster with their closest counterpart. My code has a lot of > comments so it should be fairly easy to understand. > tmp = [] > > for c in self.clusters: > > closestCluster = None > closestDelta = float('inf') > > for c2 in self.clusters: > > #skip if this is the same node > if(c == c2): > continue > > delta = abs(c2['weight'] - c['weight']) > > if(delta < closestDelta): > closestCluster = c2 > closestDelta = delta > > > print "Merging clusters %(c1)d and %(c2)d" % {'c1' : > self.clusters.index(c), > 'c2' : > self.clusters.index(closestCluster)} > #now merge the two clusters > self.clusters.remove(closestCluster) > self.clusters.remove(c) > > c['data'].extend(closestCluster['data']) > > tmp.append(c) I can't run your code because you didn't make it standalone, but I believe that the problem (at least one of them) is that you iterate over self.clusters and modify it from within the loop. That's a big no-no in python. A simple example to demonstrate the effects: >>> import random >>> old = range(10) >>> new = [] >>> for item in old: ... closest = random.choice(old) ... new.append((item, closest)) ... old.remove(item) ... old.remove(closest) ... >>> old [3, 4] >>> new [(0, 8), (2, 1), (5, 7), (9, 6)] The remedy is normally to iterate over a copy for item in list(old): ... but in your case that is probably not enough. Try something along these lines: # untested while len(self.clusters) > 1: c = self.clusters.pop() # find closest index for i, c2 in enumerate(self.clusters): ... if ...: closest_index = i closest = self.clusters.pop(closest_index) tmp.append(c + closest) if self.clusters: tmp.append(self.clusters[0]) Peter From __peter__ at web.de Mon Jan 24 06:55:07 2011 From: __peter__ at web.de (Peter Otten) Date: Mon, 24 Jan 2011 12:55:07 +0100 Subject: Converting functions References: <6c099cc0-9772-4151-86b9-d72242fbbdea@k13g2000vbq.googlegroups.com> <4d3d5e93$0$1071$afc38c87@read01.usenet4all.se> Message-ID: Edmunds Cers wrote: > Peter Otten <__peter__ at web.de> writes: > >> I don't know how to express it more clearly, so here's another example: >> >>>>> def f(): >> ... def g(): return a * a >> ... def h(): return a + a >> ... a = 5 >> ... return g, h >> ... >>>>> g, h = f() >>>>> g(), h() >> (25, 10) > > IMHO this whole confusion just shows that mingling assignment and > binding makes understanding scope harder. In Python, the first > assignment inside a function body also creates a binding (unless told > not to do so by global) the scope of which is the _whole_ of the > function body. A variable reference refers to the lexically innermost > surrounding binding of said variable. Now, while it might seem that some > magic happens in the example on the return of the function, this is in > fact not so, since the assignment "a = 5" actually creates a binding for > /a/ that is visible from the body of /g/, because the lexical scope of > the binding is the whole body of /f/, so that the capture of the > variable happens inside of the def expression (as one would expect) and > not on return as you seem to imply. > > Slightly OT -- the above also explains why closed over variables are > read only in Python. An assignment inside a closure would implicitly > create a binding, so that all (even previous) references to that > variable would refer to this new binding. Well, in Python 3 they no longer are, courtesy of the nonlocal statement: >>> def f(): ... def set(x): ... nonlocal a ... a = x ... def get(): ... return a ... return get, set ... a = 42 ... >>> get, set = f() >>> get() Traceback (most recent call last): File "", line 1, in File "", line 6, in get NameError: free variable 'a' referenced before assignment in enclosing scope >>> set(42) >>> get() 42 That closed-over variables are read-only by default is just to avoid the ambiguity about the scope they are supposed to live in, just like global variables that are to be changed from within a function. Peter From shrikant12 at ymail.com Mon Jan 24 07:19:08 2011 From: shrikant12 at ymail.com (shrikant kesharwani) Date: Mon, 24 Jan 2011 12:19:08 GMT Subject: Multiple python installations mix their sys.prefix References: Message-ID: <201112471852usenet@eggheadcafe.com> Hi, I have a web page through this page when I try to add a new user then users created successfully but when try resetting their password then I am getting errors? add New user successfully public static void AddUser(ADUser adUser) { // Local variables DirectoryEntry oDE = null; DirectoryEntry oDENewUser = null; DirectoryEntries oDEs = null; try { oDE = GetDirectoryEntry(GetADPath(PROD, adUser.UserType)); // 1. Create user account oDEs = oDE.Children; oDENewUser = oDEs.Add("CN=" + adUser.UserName, "user"); // 2. Set properties SetProperty(oDENewUser, "givenName", adUser.FirstName); SetProperty(oDENewUser, "sn", adUser.LastName); SetProperty(oDENewUser, "mail", adUser.Email); SetProperty(oDENewUser, "sAMAccountName", adUser.UserName); oDENewUser.CommitChanges(); /// 4. Enable account EnableAccount(oDENewUser); // 3. Set password //SetPassword(oDENewUser, adUser.Password); SetPassword1(oDENewUser.Path, adUser.Password); oDENewUser.CommitChanges(); oDENewUser.Close(); oDE.Close(); } catch (Exception ex) { throw ex; } } I have try the following 2 SetPassword methods but getting error. Method 1. internal static void SetPassword1(string path, string userPassword) { //Local variables DirectoryEntry usr = null; try { usr = new DirectoryEntry(); usr.Path = path; usr.AuthenticationType = AuthenticationTypes.Secure; object ret = usr.Invoke("SetPassword", userPassword); usr.CommitChanges(); usr.Close(); } catch (Exception ex) { throw ex; } } The exception raised (Error Code 80072035: The server is unwilling to process the request) Method 2. internal static void SetPassword(DirectoryEntry de, string userPassword) { //Local variables //DirectoryEntry usr = null; string quotePwd; byte[] pwdBin; try { quotePwd = String.Format(@"""{0}""", userPassword); pwdBin = System.Text.Encoding.Unicode.GetBytes(quotePwd); de.Properties["unicodePwd"].Value = pwdBin; de.CommitChanges(); //usr.Close(); } catch (Exception ex) { throw ex; } } The exception raised ("Exception has been thrown by the target of an invocation.") Is there an easy way to tell if there is a problem with changing a password? Please reply me as soon as possible. Thanks. Submitted via EggHeadCafe JSONP AJAX and ASP.NET Demystified http://www.eggheadcafe.com/tutorials/aspnet/b71ea548-93e0-4cec-9fb1-35f641b83e65/jsonp-ajax-and-aspnet-demystified.aspx From bryan.oakley at gmail.com Mon Jan 24 07:33:50 2011 From: bryan.oakley at gmail.com (Bryan) Date: Mon, 24 Jan 2011 04:33:50 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> Message-ID: <100e192f-9a6c-4c3a-8092-a65cd04eef64@o14g2000yqe.googlegroups.com> On Jan 23, 11:31?am, rantingrick wrote: > On Jan 22, 6:07?pm, rantingrick wrote: > > > I await any challengers... > > So far only trolls (besides Terry, Octavian, D'Aprano) have replied. > In my time here within the Python community i have only met one person > who shares my in-depth knowledge of Tkinter. That person is Kevin > Waltzer. So outside of Python-dev and Guido. Kevin and I are are the > ONLY people qualified to offer opinions on the worth or worthlessness > of Tkinter. If anyone in this entire community thinks that they also > are qualified then prove your worth by creating a ListCtrl in Tkinter > that mirrors the wxPython ListCtrl in functionality. When you have > done that, i will elevate you to my circle of enlightenment. Than and > only then shall i even entertain you BS. > > Until then, anyone who tries to devalue my argument is just an > ignorant troll. I think I'm qualified, though I guess only you can tell me if I measure up to your standards. I have 15 years or so of tk development, though admittedly mostly with Tcl. Most recently I've spent about the past year and a half with wxPython. For what it's worth, I am the only person on stackoverflow.com with the "tkinter" badge, which only means I've answered a bunch of questions on tkinter that others find helpful, nothing more. No offense, but your challenge is worthless, and your own entry in the challenge is remarkably weak. About the only thing you've proven is that wxPython has some built-in widgets that tkinter does not have, and that wxPython makes it hard to do cross-platform development. Does that surprise anyone? I'll give you a challenge: create a vector graphics program. wxPython doesn't have anything that can compare to the ease of use and power of tkinter's canvas. What does that prove? Only that tkinter has widgets wxPython does not. I don't think that will come as news to anyone. I could easily come up with other challenges where tkinter shines and wxPython falls flat on its face, but that proves nothing. What's really amusing is that your program segfaults on linux yet is supposed to show wxPython superiority. In my 15-20 years of tk development, you know how many segfaults I've seen? Approximately zero. Maybe there was one or two there somewhere, I don't know for certain. wxPython? It segfaults on me on a weekly basis (literally, thats not hyperbole). Which is the better toolkit? Fortunately for wxPython, the segfaults are mostly due to coding errors (typically, for lack of documentation). For the most part they don't happen once I release the code. All your challenges are going to prove is what we already know: both toolkits have strengths and weaknesses, and neither is perfect. I'll choose the tkinter binding event handling over wxPython any day of the week and twice on Sundays. It is _clearly_ and _by_far_ superior in every way. In fact, of the dozen or so toolkits I've used extensively over the last 20+ years, nothing comes close to the power of tkinter bindtags. The same can be said about tkinter's pack, place and grid geometry managers over wxPython's sizers. Tkinter wins _hands_down_. Easily. Not even close. Does that make tkinter better? No, just easier to use to do layout. Ultimately you can do pretty much the same thing with wxPython, just with more (and, arguably, less readable) code. On the other hand, wxPython clearly has more widgets. Some are very useful for very common tasks, such as file and image browsers. wxPython has the nice ability to draw on top of any widget, and the aui library shows a lot of promise. I spend a little less of my time "rolling my own" with wxPython. If you're doing a programmers editor it's hard to beat (and hard to program!) the styledtextctrl available with wxPython. It has features unique to coding editors that the tkinter text editor does not. That being said, the tkinter text editor is a marvel of simplicity and power. A project I'm doing now with a very specialized editor would be orders of magnitude easier to do with tkinter's text widget. So, all you've proven is that wxPython has different widgets than tkinter, and that it's hard to create a cross-platform GUI that looks nice in wxPython. It would be hard (but not impossible, by any stretch) for me to duplicate your code. Certainly, it would take more lines of code but that's about it. OTOH, it would be very difficult indeed to create a tkinter program that works on windows but segfaults on linux. That's also quite hard in tkinter. Frankly, I think a set of real-world challenges for all toolkits would be useful. The problem is, you have no intention of staging a fair fight. Your very first choice was to tie the hands of tkinter behind its back, so it's hard to take your challenge seriously. If you're serious, you'll find a disinterested third party and ask them to come up with a handful of use cases for testing toolkits, without giving them knowledge of which toolkits you intend to test. Anything less will be just a bunch of grandstanding. From lists at cheimes.de Mon Jan 24 07:34:25 2011 From: lists at cheimes.de (Christian Heimes) Date: Mon, 24 Jan 2011 13:34:25 +0100 Subject: A and B but not C in list In-Reply-To: References: <8cae2caf-d3df-4ed3-9afb-29de97772298@m13g2000yqb.googlegroups.com> Message-ID: Am 24.01.2011 04:05, schrieb Ian Kelly: > On Sun, Jan 23, 2011 at 2:34 PM, Christian Heimes wrote: >> your_set = set(your_list) >> >> if your_set.issuperset(set([A, B])) and your_set.isdisjoint(set([C, D])): > > if your_set.intersection([A, B, C, D]) == set([A, B]): > ... Ingenious but tricky :) Christian From rantingrick at gmail.com Mon Jan 24 07:38:18 2011 From: rantingrick at gmail.com (rantingrick) Date: Mon, 24 Jan 2011 04:38:18 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <480571f5-5731-4f8b-9cb4-1468478711bf@c39g2000yqi.googlegroups.com> <2c951199-3dba-4d24-a5c2-f84081688f7e@u6g2000yqk.googlegroups.com> <3e603997-5539-4660-bd83-7398bdab34a4@k30g2000vbn.googlegroups.com> <5edded76-fdac-4eb5-8480-25e3381e2fd4@g26g2000vbz.googlegroups.com> <1d7fdb0c-9f82-45ab-bf0e-99d210042f0d@j21g2000vbn.googlegroups.com> <4d3cb5fc$0$29983$c3e8da3$5496439d@news.astraweb.com> <4D3CBD79.3000905@v.loewis.de> <47190643-c3e1-4229-a456-fc505a13c10b@k22g2000yqh.googlegroups.com> <26ca9b38-3ecc-4276-a8cf-95bea74fc41c@r14g2000yqn.googlegroups.com> <4d3ce868$0$29974$c3e8da3$5496439d@news.astraweb.com> Message-ID: <722e9fe3-4cc4-444a-86a7-ca52a19b5bd7@o4g2000yqd.googlegroups.com> On Jan 23, 8:48?pm, Steven D'Aprano wrote: > When I run the code snippet Martin provided under Linux, the file > selection box shows files in columns. That's part of the reason why I > consider it ugly -- I'm an old Mac guy, and I still dislike file > selection tools that use the Windows 95 style 2-D layout: > > a-file ? ? ?e-file ? ? ?... > b-file ? ? ?f-file ? ? ?y-file > c-file ? ? ?g-file ? ? ?z-file > d-file ? ? ?h-file > > instead of a simple vertical list: > > a-file > b-file > c-file > ... > z-file > > Call me a dinosaur if you will, but I hate horizontal scrolling. Oh gawd Steven i hope you are just playing devils advocate here because now you are just being completely ridiculous. And if you want to see the list in vertical mode push the "Reportveiw" button. Wait, you *really* are a dinosaur! From rantingrick at gmail.com Mon Jan 24 08:04:44 2011 From: rantingrick at gmail.com (rantingrick) Date: Mon, 24 Jan 2011 05:04:44 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <033c3f90-03fb-4f65-bbae-bbc80a262685@l22g2000vbp.googlegroups.com> Message-ID: On Jan 24, 2:56?am, "Martin v. Loewis" wrote: > Well Rick, this doesn't make look wxPython any better. Well Martin this seems to be a Linux problem. And it may be a debian problem. Every Google search i landed on with wxPython+imagelist +sefault the user mentioned "debian"...hmm?. Has anybody tested this on Unbuntu? And if it segfaults on Ubuntu that just means you Linux guys need to do some debugging and offer a solution instead of pointing fingers. Linux OS is not a hand holding OS so stop your belly aching. All you guys know damn good and we can make wxPython completely cross platform. However the fact is that you DO NOT want to consider wxPython so you're NOT going to actually put forth some solutions. This thread has been an eye opener for myself and many people in the fact that this community has both lost vision and the apathy is so demoralizing that we cannot even work together to get some simple code debugged. The spirit of community, and each helping one another, does not exists! Congratulations python community, you have failed yourself! :( From bryan.oakley at gmail.com Mon Jan 24 08:06:22 2011 From: bryan.oakley at gmail.com (Bryan) Date: Mon, 24 Jan 2011 05:06:22 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <480571f5-5731-4f8b-9cb4-1468478711bf@c39g2000yqi.googlegroups.com> <2c951199-3dba-4d24-a5c2-f84081688f7e@u6g2000yqk.googlegroups.com> <3e603997-5539-4660-bd83-7398bdab34a4@k30g2000vbn.googlegroups.com> <5edded76-fdac-4eb5-8480-25e3381e2fd4@g26g2000vbz.googlegroups.com> <1d7fdb0c-9f82-45ab-bf0e-99d210042f0d@j21g2000vbn.googlegroups.com> <4d3cb5fc$0$29983$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Jan 23, 5:13?pm, Steven D'Aprano wrote: > On Sun, 23 Jan 2011 12:23:13 -0800, rantingrick wrote: > > I am not > > trying to create a working file browser so you can steal my code. > > Dammit! There goes my brilliant idea for getting rich. > > Step 1: Start company. > Step 2: Steal working file browser from Internet. > Step 4: Profit! > > I think rantingrick's comment inadvertently shows in a nutshell > everything wrong with this thread and why there is so little interest in > his proposal. If RR is right about the GUI toolkit making or breaking the > entire Python community, there should be hundreds of people with an > opinion, not just a handful. > > (1) rantingrick is willing to spend *hours* brow-beating people, > insulting them, and cajoling them into doing things *his* way, supposedly > because of his deep concern for the Python community, but isn't willing > to donate a lousy *file browser* to the community. > > (2) GUI programming is TOO DAMN HARD, and until that fact is addressed, > it's difficult for the majority of people to care whether the toolkit > used (or, more likely, not used at all) is Tkinter, or wxPython, or > something else. > > For something as common as displaying a file browser, it should be as > simple as this: > > import gui_toolkit ?# whichever > path = gui_toolkit.select_file() > You mean like: >>> import tkFileDialog >>> path=tkFileDialog.askopenfiles() >>> print path [] :-) (I think the actual point of contention isn't a file dialog, but a file browser like the windows explorer. From bryan.oakley at gmail.com Mon Jan 24 08:13:08 2011 From: bryan.oakley at gmail.com (Bryan) Date: Mon, 24 Jan 2011 05:13:08 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <70498$4d3cb87c$4275d90a$4428@FUSE.NET> Message-ID: <46c407b5-9bfe-406a-a2fe-c63caa771bf3@f2g2000vby.googlegroups.com> On Jan 23, 7:12?pm, rantingrick wrote: > On Jan 23, 5:23?pm, Kevin Walzer wrote: > > > I found this code in the Demo/tkinter/ttk directory of the Python 2.7.1 > > source distribution. I'm NOT the author (credit should probably go to > > Guilherme Polo, developer of the Tkinter wrapper for the ttk themed > > widgets that is now in the stdlib). But, using a tree/listview widget > > that is part of the Tk/Tkinter core (NOT an extension), ?it presents a > > decent, simple file browser: > > > """A directory browser using Ttk Treeview. > > The only way i can respond to this is to quite the requirements for my > challenge... > > --------------------------------------- > ?Challenge 1: (Simple Directory Viewer) > --------------------------------------- > Create a simple Directory Viewer GUI. You CANNOT use a treectrl! > > Any questions? So, what you're saying is, the real challenge you are presenting is "using the toolkit of your choice, open up a wx.ListCtrl widget". If you want a fair challenge don't say "you can't use widget X". All you're trying to prove is that tkinter doesn't have a wx.ListCtrl widget. I think most people can agree with you on that point. From bryan.oakley at gmail.com Mon Jan 24 08:16:12 2011 From: bryan.oakley at gmail.com (Bryan) Date: Mon, 24 Jan 2011 05:16:12 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <70498$4d3cb87c$4275d90a$4428@FUSE.NET> <63eea$4d3cd2fd$4275d90a$14984@FUSE.NET> <69465430-08b3-4069-99c7-72f4d3034c66@s5g2000yqm.googlegroups.com> Message-ID: On Jan 23, 7:33?pm, rantingrick wrote: > On Jan 23, 7:16?pm, Kevin Walzer wrote: > > > > > > > On 1/23/11 8:12 PM, rantingrick wrote: > > > > The only way i can respond to this is to quite the requirements for my > > > challenge... > > > > --------------------------------------- > > > ? Challenge 1: (Simple Directory Viewer) > > > --------------------------------------- > > > Create a simple Directory Viewer GUI. You CANNOT use a treectrl! > > > > Any questions? > > > Why not? > > > I'd understand if this code made use of some Tk extension, as that's not > > quite an apples-to-apples comparison. But the treectrl is part of the > > core Tkinter widget set. > > Well wxPython ha a treectrl too. And if we were comparing apples to > apples then we would compare the wx.TreeCtrl to the Tk::TreeCtrl. > However there are many things that a ListCtrl can do that a treectrl > can't. The biggest difference.... COLUMNS > > > There's no reason to exclude it (Tk::TreeCtrl) unless you are > > deliberately trying to handicap Tk in your comparison. > > I am not handicapping TclTk. They already did that themselves by > refusing to keep up with ?21st century GUI libraries. Sure, you can > say Tkinter is a knife and wxPython is an AK47 but who's to blame when > you bring a knife to gun fight Kevin? Switch to wx and enjoy the > bloodbath. "switch to wx and enjoy the bloodbath" That has *got* to be quote-of-the-week material. Sometimes when I've spent a day wrestling with wxPython I do indeed feel like I've been in a bloodbath! (I'm not picking on wxPython per se -- it's what I'm using for my current project -- just that the analogy was perhaps a bit more on target than rantingrick intended :-) From rantingrick at gmail.com Mon Jan 24 08:24:06 2011 From: rantingrick at gmail.com (rantingrick) Date: Mon, 24 Jan 2011 05:24:06 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <70498$4d3cb87c$4275d90a$4428@FUSE.NET> <46c407b5-9bfe-406a-a2fe-c63caa771bf3@f2g2000vby.googlegroups.com> Message-ID: <05fd32ee-e542-4622-afa8-a7cf4549df45@k42g2000yqa.googlegroups.com> On Jan 24, 7:13?am, Bryan wrote: > So, what you're saying is, the real challenge you are presenting is > "using the toolkit of your choice, open up a wx.ListCtrl widget". read the very first post which outlines the challenge. > If you want a fair challenge don't say "you can't use widget X". All > you're trying to prove is that tkinter doesn't have a wx.ListCtrl > widget. I think most people can agree with you on that point. Bryan you are clearly an idiot. I am demanding that from now on, you must have at least a 120 or higher IQ before participating in any of my threads. Really, if you are an idiot then you should not be allowed to vote or reproduce. However for this group i may have set the bar too high! From bryan.oakley at gmail.com Mon Jan 24 08:24:58 2011 From: bryan.oakley at gmail.com (Bryan) Date: Mon, 24 Jan 2011 05:24:58 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <70498$4d3cb87c$4275d90a$4428@FUSE.NET> <63eea$4d3cd2fd$4275d90a$14984@FUSE.NET> <69465430-08b3-4069-99c7-72f4d3034c66@s5g2000yqm.googlegroups.com> <705ad$4d3ce0fc$4275d90a$29144@FUSE.NET> <3d68e6fe-be68-4713-8330-20886d914547@r29g2000yqj.googlegroups.com> Message-ID: On Jan 24, 12:06?am, rusi wrote: > On Jan 24, 9:16?am, "Littlefield, Tyler" wrote: > > Of course as Steven pointed out wx is written in C++ which is almost > certainly where the crash is occurring. > But this is technical nitpicking. > The real issue is that when coding in C/C++ segfaults are a daily > affair. > Whereas for python its the first time I am seeing it in 10 years... In my experience, segfaults with wxPython aren't daily, but they are pretty much weekly. There are weeks that can go by without them, but then I'll have several in a week to bump up the average. wxPython is fairly sensitive to coding mistakes, and the documentation is sufficiently weak that it's easy to make coding mistakes. There are a lot of things you can do that aren't valid in particular contexts, and instead of throwing a catchable error you get a segfault. Plus, as we've seen, it's platform specific. So it's easy to create code that works great on one platform even with some bad code in it, and that same code will segfault on another platform. This shouldn't be enough to keep you from using wxPython, it just means you have to be a bit more diligent and you can't assume that your linux code will work on windows or visa versa without testing. tkinter seems far less susceptible to that. Mostly with tkinter the platform issues are true platform issues (font availability, file paths, etc). From orasnita at gmail.com Mon Jan 24 08:27:22 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Mon, 24 Jan 2011 15:27:22 +0200 Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <100e192f-9a6c-4c3a-8092-a65cd04eef64@o14g2000yqe.googlegroups.com> Message-ID: <1D826CCAB24E43ECB2C0AC790D17042F@octavian> From: "Bryan" > It would be hard (but not impossible, by any > stretch) for me to duplicate your code. Certainly, it would take more > lines of code but that's about it. OTOH, it would be very difficult > indeed to create a tkinter program that works on windows but segfaults > on linux. That's also quite hard in tkinter. I doubt you could do a program that offers the same features using Tkinter. That program will not be accessible for screen readers and this is a big problem, a vital problem for those that use a screen reader, because the program won't be accessible at all. Octavian From __peter__ at web.de Mon Jan 24 08:32:04 2011 From: __peter__ at web.de (Peter Otten) Date: Mon, 24 Jan 2011 14:32:04 +0100 Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <70498$4d3cb87c$4275d90a$4428@FUSE.NET> <46c407b5-9bfe-406a-a2fe-c63caa771bf3@f2g2000vby.googlegroups.com> <05fd32ee-e542-4622-afa8-a7cf4549df45@k42g2000yqa.googlegroups.com> Message-ID: rantingrick wrote: > I am demanding that from now on, you > must have at least a 120 or higher IQ before participating in any of > my threads. You mean, you are putting yourself in your own killfile ;) From rantingrick at gmail.com Mon Jan 24 08:32:42 2011 From: rantingrick at gmail.com (rantingrick) Date: Mon, 24 Jan 2011 05:32:42 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <70498$4d3cb87c$4275d90a$4428@FUSE.NET> <63eea$4d3cd2fd$4275d90a$14984@FUSE.NET> <69465430-08b3-4069-99c7-72f4d3034c66@s5g2000yqm.googlegroups.com> <705ad$4d3ce0fc$4275d90a$29144@FUSE.NET> <3d68e6fe-be68-4713-8330-20886d914547@r29g2000yqj.googlegroups.com> Message-ID: <2e6deec8-bdca-40ec-a759-6fa2951585fb@s5g2000yqm.googlegroups.com> On Jan 24, 7:24?am, Bryan wrote: > On Jan 24, 12:06?am, rusi wrote: > > > On Jan 24, 9:16?am, "Littlefield, Tyler" wrote: > > > Of course as Steven pointed out wx is written in C++ which is almost > > certainly where the crash is occurring. > > But this is technical nitpicking. > > The real issue is that when coding in C/C++ segfaults are a daily > > affair. > > Whereas for python its the first time I am seeing it in 10 years... > > In my experience, segfaults with wxPython aren't daily, but they are > pretty much weekly. hmm > There are weeks that can go by without them, but > then I'll have several in a week to bump up the average. Yes, and this could not be your problem, it must be wxPython. Right? *rolls-eyes* > wxPython is fairly sensitive to coding mistakes, Oh so now we get the picture... > and the documentation > is sufficiently weak that it's easy to make coding mistakes. That is somewhat true. > There are > a lot of things you can do that aren't valid in particular contexts, > and instead of throwing a catchable error you get a segfault. And we need to fix that instead just disqualifying a feature rich toolkit. > Plus, as > we've seen, it's platform specific. So it's easy to create code that > works great on one platform even with some bad code in it, and that > same code will segfault on another platform. Again, were is the community spirit. I have windows and you have linux. Let's write some code and do cross testing and then fix the bugs. > This shouldn't be enough to keep you from using wxPython, it just > means you have to be a bit more diligent and you can't assume that > your linux code will work on windows or visa versa without testing. Thank you! > tkinter seems far less susceptible to that. Mostly with tkinter the > platform issues are true platform issues (font availability, file > paths, etc). Yes because Tkinter is lacking. Because Tkinter is not even half the library that wx is. From g.rodola at gmail.com Mon Jan 24 08:36:19 2011 From: g.rodola at gmail.com (=?ISO-8859-1?Q?Giampaolo_Rodol=E0?=) Date: Mon, 24 Jan 2011 14:36:19 +0100 Subject: WxPython versus Tkinter. In-Reply-To: References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <033c3f90-03fb-4f65-bbae-bbc80a262685@l22g2000vbp.googlegroups.com> Message-ID: 2011/1/24 rantingrick : > On Jan 24, 2:56?am, "Martin v. Loewis" wrote: > >> Well Rick, this doesn't make look wxPython any better. > > Well Martin this seems to be a Linux problem. And it may be a debian > problem. Every Google search i landed on with wxPython+imagelist > +sefault the user mentioned "debian"...hmm?. Has anybody tested this > on Unbuntu? And if it segfaults on Ubuntu that just means you Linux > guys need to do some debugging and offer a solution instead of > pointing fingers. Linux OS is not a hand holding OS so stop your belly > aching. > > All you guys know damn good and we can make wxPython completely cross > platform. However the fact is that you DO NOT want to consider > wxPython so you're NOT going to actually put forth some solutions. > This thread has been an eye opener for myself and many people in the > fact that this community has both lost vision and the apathy is so > demoralizing that we cannot even work together to get some simple code > debugged. The spirit of community, and each helping one another, does > not exists! > > Congratulations python community, you have failed yourself! :( > -- > http://mail.python.org/mailman/listinfo/python-list > This is nonsense and you are clearly a troll. =) --- Giampaolo Rodol? http://code.google.com/p/pyftpdlib/ http://code.google.com/p/psutil/ From kw at codebykevin.com Mon Jan 24 08:40:43 2011 From: kw at codebykevin.com (Kevin Walzer) Date: Mon, 24 Jan 2011 08:40:43 -0500 Subject: [Code Challenge] WxPython versus Tkinter. In-Reply-To: References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <70498$4d3cb87c$4275d90a$4428@FUSE.NET> Message-ID: <20d8f$4d3d8140$4275d90a$14327@FUSE.NET> On 1/24/11 1:52 AM, Octavian Rasnita wrote: > > Well, I have also tested the program dirbrowser.py, but it is not decent > at all. > I have tested it with JAWS screen reader and it is absolutely inaccessible. > > The single "accessible" things in it are the title bar which is "tk". > It can't compare with the same program made using WxPython. > And it can't be made to be more accessible than it is, because it uses Tk. > > So Tkinter is really bad. If accessibility leads your criteria, then yes, Tk may be deficient. I can't speak to this on other platforms or with other toolkits. -- Kevin Walzer Code by Kevin http://www.codebykevin.com From kw at codebykevin.com Mon Jan 24 08:48:14 2011 From: kw at codebykevin.com (Kevin Walzer) Date: Mon, 24 Jan 2011 08:48:14 -0500 Subject: WxPython versus Tkinter. In-Reply-To: <05fd32ee-e542-4622-afa8-a7cf4549df45@k42g2000yqa.googlegroups.com> References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <70498$4d3cb87c$4275d90a$4428@FUSE.NET> <46c407b5-9bfe-406a-a2fe-c63caa771bf3@f2g2000vby.googlegroups.com> <05fd32ee-e542-4622-afa8-a7cf4549df45@k42g2000yqa.googlegroups.com> Message-ID: On 1/24/11 8:24 AM, rantingrick wrote: > > Bryan you are clearly an idiot. I am demanding that from now on, you > must have at least a 120 or higher IQ before participating in any of > my threads. Really, if you are an idiot then you should not be allowed > to vote or reproduce. However for this group i may have set the bar > too high! Rick, I've tried to give you the benefit of the doubt during this discussion, but I've had enough. Bryan Oakley is no idiot. You said elsewhere in this thread that my expertise with Tkinter was worth something, but Bryan's is worth far more. He is one of the foremost Tcl/Tk developers alive, author of many widely-used Tk widgets, and a long-term helpful presence on comp.lang.tcl. He's patiently answered many inflammatory questions from inexperienced or arrogant developers, and I've learned a tremendous amount from him. Job circumstances forced him to move into Python development a few years ago, and he now uses wxPython on a daily basis, while being active on Stack Overflow and elsewhere with answering questions about Tkinter. In short, I'd have a hard time imagining anyone more qualified to compare wxPython and Tkinter than Bryan Oakley. Also, it's not helpful for you to respond to people who disagree with you with this kind of name-calling. It certainly does not earn any respect for your arguments. --Kevin -- Kevin Walzer Code by Kevin http://www.codebykevin.com From rantingrick at gmail.com Mon Jan 24 09:15:55 2011 From: rantingrick at gmail.com (rantingrick) Date: Mon, 24 Jan 2011 06:15:55 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <100e192f-9a6c-4c3a-8092-a65cd04eef64@o14g2000yqe.googlegroups.com> Message-ID: <1ed86ac9-e8a9-48b3-8f27-bf480782eb82@w17g2000yqh.googlegroups.com> On Jan 24, 6:33?am, Bryan wrote: > I think I'm qualified, though I guess only you can tell me if I > measure up to your standards. Go on... > I have 15 years or so of tk development, > though admittedly mostly with Tcl. Most recently I've spent about the > past year and a half with wxPython. A year and a half and you are still producing buggy code? (you yourself admitted this!) > For what it's worth, I am the only > person on stackoverflow.com with the "tkinter" badge, which only means > I've answered a bunch of questions on tkinter that others find > helpful, nothing more. Well could we see a link to a few answered questions or get your nick so we can corroborate this statement ourselves? > No offense, but your challenge is worthless, and your own entry in the > challenge is remarkably weak. First rule when given a challenge you cannot answer due to ignorance: question the validity of the challenge. > About the only thing you've proven is > that wxPython has some built-in widgets that tkinter does not have, Well this is ONLY the first challenge Bryan. More will come. However, not until someone has the balls to answer my first challenge. > and that wxPython makes it hard to do cross-platform development. I don't think that is completely accurate Bryan. Harder than Tkinter, yes. Anything else is hyperbole. > Does > that surprise anyone? I'll give you a challenge: create a vector > graphics program. Answer my challenge first, then we talk. And obviously you do not understand the power of wx's Open Graphics Library (OGL). You'd better go check that out before you stick your Tkinter loving foot into your big mouth. > wxPython doesn't have anything that can compare to > the ease of use and power of tkinter's canvas. Thats more uninformed BS. You are really hurting your public image here bryan! > What does that prove? > Only that tkinter has widgets wxPython does not. I don't think that > will come as news to anyone. I could easily come up with other > challenges where tkinter shines and wxPython falls flat on its face, And these challenges are what? You see when you make empty challenges like this you look dumb. > What's really amusing is that your program segfaults on linux yet is > supposed to show wxPython superiority. Segfault or not wx is superior. > In my 15-20 years of tk > development, you know how many segfaults I've seen? Approximately > zero. BULLSHITE! > Maybe there was one or two there somewhere, Ah yes, the old conscience catches up fast to the habitual liars. > I don't know for > certain. Finally some truth! > wxPython? It segfaults on me on a weekly basis (literally, > thats not hyperbole). LIAR! LIAR! PANTS ON FIRE! ------------bryan------------- In my experience, segfaults with wxPython aren't daily, but they are pretty much weekly. There are weeks that can go by without them ------------bryan------------- > Which is the better toolkit? Fortunately for > wxPython, the segfaults are mostly due to coding errors Yea, ya think? > For the most part they don't happen once I > release the code. And yet you cannot offer a solution for this segfault. Interesting. > All your challenges are going to prove is what we already know: both > toolkits have strengths and weaknesses, and neither is perfect. And sadly that IS ALL you know. More fruits must be weighed in this decision. Like the fact that Tkinter is legacy and wxPython is current technology. > I'll > choose the tkinter binding event handling over wxPython any day of the > week and twice on Sundays. So will i. We should change the wxPython API! > It is _clearly_ and _by_far_ superior in > every way. True. We should change the wxPython API! > In fact, of the dozen or so toolkits I've used extensively > over the last 20+ years, nothing comes close to the power of tkinter > bindtags. *yawn*. Guido's advocate! > The same can be said about tkinter's pack, place and grid geometry > managers over wxPython's sizers. Agreed! We should change the wxPython API! > Does that make tkinter better? No, just easier to use > to do layout. Agreed! Because if we were really smart we would just change the wxPython API so that we have the simplicity of Tkinter and the feature richness of wxPython. See wax for ideas... http://wiki.wxpython.org/Wax > Ultimately you can do pretty much the same thing with > wxPython, just with more (and, arguably, less readable) code. Wrong. You can do much much more with wxPython. The ugliness of the code depends on the coders ability to create good or bad code. > On the other hand, wxPython clearly has more widgets. Some are very > useful for very common tasks, such as file and image browsers. and spreadsheets, and validated input, and multi-choice directory choosing, and multi choice lists, and Rich Text, and book controls, and Calendars, and Toolbars, and full image support, and masked edit controls, and scrolled panels, and styled text, and print support, and listctrl, and virtual listctrl and editable list ctrl, and REAL DND ,and GC, and GLCanvas, and JoyStick, and OGL, and shaped windows, and more, more, more... > wxPython has the nice ability to draw on top of any widget, and the > aui library shows a lot of promise. I spend a little less of my time > "rolling my own" with wxPython. You will always spend less time rolling in wxPython. > If you're doing a programmers editor it's hard to beat (and hard to > program!) the styledtextctrl available with wxPython. It has features > unique to coding editors that the tkinter text editor does not. That > being said, the tkinter text editor is a marvel of simplicity and > power. A project I'm doing now with a very specialized editor would be > orders of magnitude easier to do with tkinter's text widget. Which do you want, simplistic confinement or expansive elegance. You can't have both. And besides. One could easily create a simplistic "Tkinter like" textbox API using wxPython. You lack vision Bryan. We can bring all this into reality! > It would be hard (but not impossible, by any > stretch) for me to duplicate your code. PUT UP OR SHUT THE HELL UP! From tyler at tysdomain.com Mon Jan 24 09:16:01 2011 From: tyler at tysdomain.com (Littlefield, Tyler) Date: Mon, 24 Jan 2011 07:16:01 -0700 Subject: WxPython versus Tkinter. In-Reply-To: <58325C0B6449487E97D2523C1685624F@octavian> References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <70498$4d3cb87c$4275d90a$4428@FUSE.NET> <63eea$4d3cd2fd$4275d90a$14984@FUSE.NET> <69465430-08b3-4069-99c7-72f4d3034c66@s5g2000yqm.googlegroups.com> <705ad$4d3ce0fc$4275d90a$29144@FUSE.NET><3d68e6fe-be68-4713-8330-20886d914547@r29g2000yqj.googlegroups.com> <4D3CFD0F.1080502@tysdomain.com> <58325C0B6449487E97D2523C1685624F@octavian> Message-ID: <4D3D89A1.8050206@tysdomain.com> >Or you have started to use Linux and now you don't care about the majority of >users that need to use a screen reader? I said nothing the like. TkInter does have problemns with Jaws, but I'm not going to sit here and say the same thing over and over as you are doing. Get off the soapbox already. On 1/23/2011 11:58 PM, Octavian Rasnita wrote: > From: "Littlefield, Tyler" >> >PS: Be sure not to cause any segfaults because these linux folks can't >> >debug for shite! >> Or maybe it is that the person fighting and throwing insults around >> like candy at a parade can't code for shite. Or *gasp* the library >> that is supposedly cross-platform has issues on certain platforms. >> You provided a challenge to show how superior wxPython was. If it >> segfaults, that tells me that: 1) you can't code worth "shite," or 2) >> the library you are drooling over sucks and shouldn't be >> cross-platform. Which is it? I highly doubt there is a third option, >> but please feel free to tell me, rather than insulting again. > > > Hi Tyler, > > Are you able to use Tkinter-based applications under Windows? > Or you have started to use Linux and now you don't care about the > majority of users that need to use a screen reader? > > Octavian > -- Thanks, Ty From rantingrick at gmail.com Mon Jan 24 09:36:26 2011 From: rantingrick at gmail.com (rantingrick) Date: Mon, 24 Jan 2011 06:36:26 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <70498$4d3cb87c$4275d90a$4428@FUSE.NET> <46c407b5-9bfe-406a-a2fe-c63caa771bf3@f2g2000vby.googlegroups.com> <05fd32ee-e542-4622-afa8-a7cf4549df45@k42g2000yqa.googlegroups.com> Message-ID: <2eedabb5-7ce4-444a-abba-74d96cc93188@i18g2000yqn.googlegroups.com> On Jan 24, 7:48?am, Kevin Walzer wrote: > Rick, > > I've tried to give you the benefit of the doubt during this discussion, > but I've had enough. Bryan Oakley is no idiot. He is obviously lying to discredit me. And I have posted evidence of his hyperbole. > You said elsewhere in > this thread that my expertise with Tkinter was worth something, but > Bryan's is worth far more. He is one of the foremost Tcl/Tk developers > alive, author of many widely-used Tk widgets, and a long-term helpful > presence on comp.lang.tcl. He's patiently answered many inflammatory > questions from inexperienced or arrogant developers, and I've learned a > tremendous amount from him. Job circumstances forced him to move into > Python development a few years ago, and he now uses wxPython on a daily > basis, while being active on Stack Overflow and elsewhere with answering > questions about Tkinter. ?In short, I'd have a hard time imagining > anyone more qualified to compare wxPython and Tkinter than Bryan Oakley. Yet he has NO knowledge of wxPython and his Tkinter knowledge is lacking. > Also, it's not helpful for you to respond to people who disagree with > you with this kind of name-calling. It certainly does not earn any > respect for your arguments. Well i agree with that. However these people keep coming back with the same BS arguments... * the challenge is impossible. No the challenge is not impossible to complete. However due to Tkinters lacking richness. It is impossible to win against wxPython. So they resort to all this BS because they KNOW they cannot win. Just admit that wxPython wins this round and i'll move on to the next challenge. * wxPython is not cross platform. Total BS. * Yes wxPython has many widgets but most are not useful. Even more BS. And you wonder why i call people ignorant? I did give them the benefit of the doubt before saying these things. Bryan has yet to post any links so i can corroborate his "Tkinter" guru status. He has also clearly lied many times in his posts (which i have documented). And most importantly no one but myself has offered any code. From kyosohma at gmail.com Mon Jan 24 09:49:53 2011 From: kyosohma at gmail.com (Mike Driscoll) Date: Mon, 24 Jan 2011 06:49:53 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <70498$4d3cb87c$4275d90a$4428@FUSE.NET> <63eea$4d3cd2fd$4275d90a$14984@FUSE.NET> <69465430-08b3-4069-99c7-72f4d3034c66@s5g2000yqm.googlegroups.com> <705ad$4d3ce0fc$4275d90a$29144@FUSE.NET> <3d68e6fe-be68-4713-8330-20886d914547@r29g2000yqj.googlegroups.com> Message-ID: On Jan 24, 7:24?am, Bryan wrote: > On Jan 24, 12:06?am, rusi wrote: > > > On Jan 24, 9:16?am, "Littlefield, Tyler" wrote: > > > Of course as Steven pointed out wx is written in C++ which is almost > > certainly where the crash is occurring. > > But this is technical nitpicking. > > The real issue is that when coding in C/C++ segfaults are a daily > > affair. > > Whereas for python its the first time I am seeing it in 10 years... > > In my experience, segfaults with wxPython aren't daily, but they are > pretty much weekly. There are weeks that can go by without them, but > then I'll have several in a week to bump up the average. I've only run my code on Windows and Linux, but I haven't had this issue. The only time I've had segfaults was when I was first learning how to get threading and wx to work properly and when I was creating binaries with py2exe. On a completely different note, as a heavy wxPython user for almost 5 years, I have never seen the OP on our mailing list, dev group or IRC channel. While I like wx more than Tk, I think this thread is a terrible way to try to show that wx is better. I like the concept of creating a challenge to see which toolkit can do what, but this is not the way to go about it. Bryan, on the other hand, has been a Tkinter luminary who has helped me in the past when I was learning Tkinter and I won't be too surprised if he helps me again. I'm sorry he's had so much trouble with wx though. ------------------- Mike Driscoll Blog: http://blog.pythonlibrary.org From rantingrick at gmail.com Mon Jan 24 10:02:43 2011 From: rantingrick at gmail.com (rantingrick) Date: Mon, 24 Jan 2011 07:02:43 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <70498$4d3cb87c$4275d90a$4428@FUSE.NET> <63eea$4d3cd2fd$4275d90a$14984@FUSE.NET> <69465430-08b3-4069-99c7-72f4d3034c66@s5g2000yqm.googlegroups.com> <705ad$4d3ce0fc$4275d90a$29144@FUSE.NET> <3d68e6fe-be68-4713-8330-20886d914547@r29g2000yqj.googlegroups.com> Message-ID: <7d701221-cdf4-4679-beb3-90492dd52bce@i13g2000yqe.googlegroups.com> On Jan 24, 8:49?am, Mike Driscoll wrote: > On Jan 24, 7:24?am, Bryan wrote: > > In my experience, segfaults with wxPython aren't daily, but they are > > pretty much weekly. There are weeks that can go by without them, but > > then I'll have several in a week to bump up the average. > > I've only run my code on Windows and Linux, but I haven't had this > issue. The only time I've had segfaults was when I was first learning > how to get threading and wx to work properly and when I was creating > binaries with py2exe. Thanks. I knew these guys were full of it. > On a completely different note, as a heavy wxPython user for almost 5 > years, I have never seen the OP on our mailing list, dev group or IRC > channel. Thats because i have not been there. And yet i can produce code (maybe not perfectly). However those that have been around wx list for longer cannot. Interesting. > I like the concept of > creating a challenge to see which toolkit can do what, but this is not > the way to go about it. Well by all means offer some input. You have offered opinions but no ideas. I would love to hear any ideas you may have. And yes, Tkinter has a very likable API. I have mentioned this fact many times and in many threads. However when weighed on all factors wx will win. Because even though we may need to mold the wx API a bit, at least with wx we have a solid feature rich platform to work from. > Bryan, on the other hand, has been a Tkinter luminary who has helped > me in the past when I was learning Tkinter and I won't be too > surprised if he helps me again. I'm sorry he's had so much trouble > with wx though. :) From mauro.caceres at gmail.com Mon Jan 24 10:53:37 2011 From: mauro.caceres at gmail.com (Mauro Caceres) Date: Mon, 24 Jan 2011 12:53:37 -0300 Subject: Short circuting In-Reply-To: References: Message-ID: Another option could be something like this: You can add ids to your regexp, so you can retrive them latter using groupdict. Once you have the ids in place, you can join in a new regexp with the "|" operator which is not greedy, it will stop after the first match. pattern = (?P
re_section)|?Pre_section|... Then you can have another structure with the previous id and the actions you want to perform on them. actions = {'section': lambda r: r[18:-5], 'name': lambda r: r[6:-1]), ...} Finally you just need to iterate over the result. In this case the dictionary will have only one pair. result = pattern.search(line) if result: for key,val in result.groupdict().iteritems(): actions[key](val) .... -- Mauro C?ceres -------------- next part -------------- An HTML attachment was scrubbed... URL: From invalid at invalid.invalid Mon Jan 24 11:13:48 2011 From: invalid at invalid.invalid (Grant Edwards) Date: Mon, 24 Jan 2011 16:13:48 +0000 (UTC) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <70498$4d3cb87c$4275d90a$4428@FUSE.NET> <46c407b5-9bfe-406a-a2fe-c63caa771bf3@f2g2000vby.googlegroups.com> <05fd32ee-e542-4622-afa8-a7cf4549df45@k42g2000yqa.googlegroups.com> Message-ID: On 2011-01-24, rantingrick wrote: > Bryan you are clearly an idiot. I am demanding that from now on, you > must have at least a 120 or higher IQ before participating in any of > my threads. Rantingrick thinks certain threads belong to him. 'nuf said. -- Grant Edwards grant.b.edwards Yow! I'm gliding over a at NUCLEAR WASTE DUMP near gmail.com ATLANTA, Georgia!! From invalid at invalid.invalid Mon Jan 24 11:15:54 2011 From: invalid at invalid.invalid (Grant Edwards) Date: Mon, 24 Jan 2011 16:15:54 +0000 (UTC) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <3a96fee1-995f-49f7-a967-f125cc3f1cdc@v26g2000yqf.googlegroups.com> <4ef41c75-8372-4a94-a93c-1b4e7a6e0759@m13g2000yqb.googlegroups.com> Message-ID: On 2011-01-24, Corey Richardson wrote: > Python (and supposedly wxPython) are cross-platform. Code that runs on > one should run on the other unmodified. No, that's not what "cross-platform" really means. Cross-platform means that it's possible (and reasonably stright-forward) to write code that will run unmodified on multiple platforms. It doesn't mean that it's impossible to write code that will only work on one platform. -- Grant Edwards grant.b.edwards Yow! Someone in DAYTON, at Ohio is selling USED gmail.com CARPETS to a SERBO-CROATIAN From bborcic at gmail.com Mon Jan 24 11:31:26 2011 From: bborcic at gmail.com (Boris Borcic) Date: Mon, 24 Jan 2011 17:31:26 +0100 Subject: A and B but not C in list In-Reply-To: References: <8cae2caf-d3df-4ed3-9afb-29de97772298@m13g2000yqb.googlegroups.com> Message-ID: Terry Reedy wrote: > > The straightforward code > > if a in L and b in L and c not in L and d not in L > > scans the list 4 times. of course for a single scan one can setify the list and write S=set(L) if a in S and b in S and c not in S and d not in S or even, I guess, something like {a,b} <= S and not S & {c,d} also, I suppose that in some settings a,b,c,d could be made to belong to a class that has defined eg __nonzero__ = __bool__ = S.__contains__ so that the if statement would become if a and b and not c and not d btw, did anybody ask the OP which if any of A,B,C,D otoh and L otoh would vary fastest ? Whatever, BB From rantingrick at gmail.com Mon Jan 24 11:36:18 2011 From: rantingrick at gmail.com (rantingrick) Date: Mon, 24 Jan 2011 08:36:18 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <70498$4d3cb87c$4275d90a$4428@FUSE.NET> <46c407b5-9bfe-406a-a2fe-c63caa771bf3@f2g2000vby.googlegroups.com> <05fd32ee-e542-4622-afa8-a7cf4549df45@k42g2000yqa.googlegroups.com> Message-ID: <42b2e26f-54e4-4319-977b-66fc94ad64b5@e4g2000vbg.googlegroups.com> On Jan 24, 10:13?am, Grant Edwards wrote: > On 2011-01-24, rantingrick wrote: > > > Bryan you are clearly an idiot. I am demanding that from now on, you > > must have at least a 120 or higher IQ before participating in any of > > my threads. > > Rantingrick thinks certain threads belong to him. No these are free and open forums and all are welcome to come and listen to what i say :). Notice i only specified an IQ level and i made no demands as to how much Python knowledge was required. You can be a noob or a pro and participate. However i am not about to entertain trolls and ignorants because these people do not have the basic tools to contribute anything helpful. Whereas someone who has meager Python skills (but a reasonable IQ) CAN participate in lively and coherent debate all the while contributing in a positive way. These are the people i want to talk with. Some have dropped in already but failed to offer good debate. NOW IS YOUR CHANCE! Many folks here don't understand how to contribute in a positive way. NEWSFLASH! You can both disagree with me AND contribute to the debate in a positive way at the same time. Oh yes! One example would be for the "Linux whiners" to post a fix to my example code. If they are not going to answer the challenge with Tkinter code, then they should at least fix ONE measly little bug to prove their worth to this community. So far you have all failed BOTH challenges. From kyosohma at gmail.com Mon Jan 24 11:38:41 2011 From: kyosohma at gmail.com (Mike Driscoll) Date: Mon, 24 Jan 2011 08:38:41 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <70498$4d3cb87c$4275d90a$4428@FUSE.NET> <63eea$4d3cd2fd$4275d90a$14984@FUSE.NET> <69465430-08b3-4069-99c7-72f4d3034c66@s5g2000yqm.googlegroups.com> <705ad$4d3ce0fc$4275d90a$29144@FUSE.NET> <3d68e6fe-be68-4713-8330-20886d914547@r29g2000yqj.googlegroups.com> <7d701221-cdf4-4679-beb3-90492dd52bce@i13g2000yqe.googlegroups.com> Message-ID: On Jan 24, 9:02?am, rantingrick wrote: > On Jan 24, 8:49?am, Mike Driscoll wrote: > > > On Jan 24, 7:24?am, Bryan wrote: > > > In my experience, segfaults with wxPython aren't daily, but they are > > > pretty much weekly. There are weeks that can go by without them, but > > > then I'll have several in a week to bump up the average. > > > I've only run my code on Windows and Linux, but I haven't had this > > issue. The only time I've had segfaults was when I was first learning > > how to get threading and wx to work properly and when I was creating > > binaries with py2exe. > > Thanks. I knew these guys were full of it. Not necessarily. He may been using some of the generic widgets, like the agw stuff. The agw set is awesome, but they haven't been tested extensively on anything other than Windows because their author is a Windows programmer. > > I like the concept of > > creating a challenge to see which toolkit can do what, but this is not > > the way to go about it. > > Well by all means offer some input. You have offered opinions but no > ideas. I would love to hear any ideas you may have. And yes, Tkinter > has a very likable API. I have mentioned this fact many times and in > many threads. However when weighed on all factors wx will win. Because > even though we may need to mold the wx API a bit, at least with wx we > have a solid feature rich platform to work from. > I haven't gotten my ideas fleshed out yet. When I do, I will describe them. ------------------- Mike Driscoll Blog: http://blog.pythonlibrary.org From orasnita at gmail.com Mon Jan 24 12:02:22 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Mon, 24 Jan 2011 19:02:22 +0200 Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <70498$4d3cb87c$4275d90a$4428@FUSE.NET> <63eea$4d3cd2fd$4275d90a$14984@FUSE.NET> <69465430-08b3-4069-99c7-72f4d3034c66@s5g2000yqm.googlegroups.com> <705ad$4d3ce0fc$4275d90a$29144@FUSE.NET><3d68e6fe-be68-4713-8330-20886d914547@r29g2000yqj.googlegroups.com> <4D3CFD0F.1080502@tysdomain.com><58325C0B6449487E97D2523C1685624F@octavian> <4D3D89A1.8050206@tysdomain.com> Message-ID: From: "Littlefield, Tyler" > >Or you have started to use Linux and now you don't care about the > majority of >users that need to use a screen reader? > I said nothing the like. TkInter does have problemns with Jaws, but I'm > not going to sit here and say the same thing over and over as you are > doing. Get off the soapbox already. If something's wrong, the people need to know that what they like is wrong and the wrong things need to be changed with something better. And I just shown why Tkinter is a very bad tool. I'm not in love with wxWIDGETS because they also provide a few widgets which have problems. I like MFC, but unfortunately it is not portable. Octavian From santosh.tronics at gmail.com Mon Jan 24 12:09:31 2011 From: santosh.tronics at gmail.com (santosh hs) Date: Mon, 24 Jan 2011 09:09:31 -0800 (PST) Subject: Which is the best book to learn python Message-ID: <188c0a9f-4e93-4fae-b3f9-e7c84f8030fd@v31g2000pri.googlegroups.com> Hi All, i am beginner to python please tell me which is the best available reference for beginner to start from novice From ethan at stoneleaf.us Mon Jan 24 12:12:25 2011 From: ethan at stoneleaf.us (Ethan Furman) Date: Mon, 24 Jan 2011 09:12:25 -0800 Subject: [Code Challenge] WxPython versus Tkinter. In-Reply-To: References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> Message-ID: <4D3DB2F9.3090303@stoneleaf.us> Octavian Rasnita wrote: > From: "rantingrick" >> WxPython versus Tkinter (A code battle to the death!) >> >> by Rick Johnson. [...] Octavian, Please do not repost rr's crap in its entirety, or you'll find yourself added to many killfiles -- just like he is. ~Ethan~ From robert.kern at gmail.com Mon Jan 24 12:12:33 2011 From: robert.kern at gmail.com (Robert Kern) Date: Mon, 24 Jan 2011 11:12:33 -0600 Subject: I'm interested in calculating time down to the femtosecond. In-Reply-To: <076E4FFD-54FA-4665-9F32-E446731D52C7@gmail.com> References: <076E4FFD-54FA-4665-9F32-E446731D52C7@gmail.com> Message-ID: On 1/23/11 12:43 AM, Slie wrote: > > > I found that there was a code submission at NumPy 1.4 but I can not find in the documentation search for Date nor have found anything other then that discussion of the ability. > > Anyone have any ideas suggestions? I just want my program to be able to calculate it nothing special. You will want to ask questions about numpy on the numpy-discussion mailing list. http://www.scipy.org/Mailing_Lists It's difficult to understand your question, but I suspect that you are asking about the datetime and timedelta dtypes that were going to be added in 1.4. They were removed since the necessary modifications caused an unintended ABI break. They will return in a future release. -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco From rantingrick at gmail.com Mon Jan 24 12:17:01 2011 From: rantingrick at gmail.com (rantingrick) Date: Mon, 24 Jan 2011 09:17:01 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <70498$4d3cb87c$4275d90a$4428@FUSE.NET> <46c407b5-9bfe-406a-a2fe-c63caa771bf3@f2g2000vby.googlegroups.com> <05fd32ee-e542-4622-afa8-a7cf4549df45@k42g2000yqa.googlegroups.com> Message-ID: <709769f9-f99a-46c8-bcc1-7a03adf303c6@v17g2000vbo.googlegroups.com> On Jan 24, 7:32?am, Peter Otten <__pete... at web.de> wrote: > rantingrick wrote: > > I am demanding that from now on, you > > must have at least a 120 or higher IQ before participating in any of > > my threads. > > You mean, you are putting yourself in your own killfile ;) :) Actually i never use the killfile and never will. The main reason is because i believe in the old adage: "Keep friends close and enemies closer". But i don't have any enemies here (as far as i am concerned). However the real reason i will not use the killfile is because i believe that people can change. Even very wise people are not immune to bad decisions. Case in point: My initial disgust with Ruby was completely unfounded. Ruby has a lot to offer the programming world and while it is not my preferred language, we as Python programmers can learn much from Ruby and likewise Ruby can learn from us. I was being a closed minded idiot at the time. I have since evolved. In any event the killfile only serves as instant gratification for the selfish "one dimensional" folks among us. If you are so fearful of someone's words that you must hide your eyes from them then you lack basic self control. And in the end, the only thing you kill is your own humanity. :( From rantingrick at gmail.com Mon Jan 24 12:17:25 2011 From: rantingrick at gmail.com (rantingrick) Date: Mon, 24 Jan 2011 09:17:25 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <70498$4d3cb87c$4275d90a$4428@FUSE.NET> <63eea$4d3cd2fd$4275d90a$14984@FUSE.NET> <69465430-08b3-4069-99c7-72f4d3034c66@s5g2000yqm.googlegroups.com> <705ad$4d3ce0fc$4275d90a$29144@FUSE.NET> <3d68e6fe-be68-4713-8330-20886d914547@r29g2000yqj.googlegroups.com> <7d701221-cdf4-4679-beb3-90492dd52bce@i13g2000yqe.googlegroups.com> Message-ID: <31a0a893-6d0f-40cd-b84c-a7d3363138cb@f20g2000vbc.googlegroups.com> On Jan 24, 10:38?am, Mike Driscoll wrote: > I haven't gotten my ideas fleshed out yet. When I do, I will describe > them. I look forward to any proposals and i would like to be a part of this challenge both for wxPython and Tkinter since i have used both. From rantingrick at gmail.com Mon Jan 24 12:28:32 2011 From: rantingrick at gmail.com (rantingrick) Date: Mon, 24 Jan 2011 09:28:32 -0800 (PST) Subject: Need GUI pop-up to edit a (unicode ?) string References: <3tqr08-bj2.ln1@murmur.very.softly> Message-ID: On Jan 22, 2:22?pm, Rikishi42 wrote: > I'm in need for a graphical pop-up that will display a (unicode ?) string in > a field, allow the user to change it and return the modified string. > > Maybe also keep the original one displayed above it. > > Something like this: > +-------------------------------------------------+ > | ? Please confirm or edit the following string ? | > | ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? | > | ? ? Original_example_string ? ? ? ? ? ? ? ? ? ? | > | ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? | > | ?+-------------------------------------------+ ?| > | ?| ?Original_about_to_be_changed ? ? ? ? ? ? | ?| > | ?+-------------------------------------------+ ?| > | ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? | > | ? ? ? ? ? ? ? ? ? ? OK ? ? ? ? ? ? ? ? ? ? ? ? ?| > | ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? | > +-------------------------------------------------+ If you download wxPython and build it with unicdode support (i did not for my version!) you can use a simple textctrl and a statictext to display this. For an example of how to do this download the wxPython demo and in the tree menu under the "miscellaneous" node pick the "Unicode" example. You will be able to see both the source code and run a demo of this example strait from the demo GUI! If you need help turning the demo code into something usable for your script then post back here and i will help you create whatever you want. From hnsri49 at gmail.com Mon Jan 24 12:31:09 2011 From: hnsri49 at gmail.com (srinivas hn) Date: Mon, 24 Jan 2011 23:01:09 +0530 Subject: Which is the best book to learn python In-Reply-To: <188c0a9f-4e93-4fae-b3f9-e7c84f8030fd@v31g2000pri.googlegroups.com> References: <188c0a9f-4e93-4fae-b3f9-e7c84f8030fd@v31g2000pri.googlegroups.com> Message-ID: search for byte of python in google its good book for beginners . . CHEERS CNA 9986229891 On Mon, Jan 24, 2011 at 10:39 PM, santosh hs wrote: > Hi All, > i am beginner to python please tell me which is the best available > reference for beginner to start from novice > -- > http://mail.python.org/mailman/listinfo/python-list > -------------- next part -------------- An HTML attachment was scrubbed... URL: From jeanmichel at sequans.com Mon Jan 24 12:38:29 2011 From: jeanmichel at sequans.com (Jean-Michel Pichavant) Date: Mon, 24 Jan 2011 18:38:29 +0100 Subject: Which is the best book to learn python In-Reply-To: <188c0a9f-4e93-4fae-b3f9-e7c84f8030fd@v31g2000pri.googlegroups.com> References: <188c0a9f-4e93-4fae-b3f9-e7c84f8030fd@v31g2000pri.googlegroups.com> Message-ID: <4D3DB915.9060601@sequans.com> santosh hs wrote: > Hi All, > i am beginner to python please tell me which is the best available > reference for beginner to start from novice > Hi, You could have searched the archive, this question was raised many times. http://wiki.python.org/moin/IntroductoryBooks I read "Learning Python" when I started. Since it's the only one I read I cannot tell you which one is the best (if there is). Python is easy to learn, I'm not sure it's possible to write a bad book about it. JM From mark at markroseman.com Mon Jan 24 12:39:56 2011 From: mark at markroseman.com (Mark Roseman) Date: Mon, 24 Jan 2011 10:39:56 -0700 Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> 7c$4275d90a$44222222222222 <63eea$4d3cd2fd$4275d90a$14984@FUSE.NET> <69465430-08b3-4069-99c7-72f4d3034c66@s5g2000yqm.googlegroups.com> <705ad$4d3ce0fc$4275d90a$29144@FUSE.NET> Message-ID: "Octavian Rasnita" wrote: > But unfortunately it is not accessible for screen readers and it > discriminates many potential users. Octavian, thank you for very clearly making and repeating your point about screen readers. It is very obvious that at this point in time Tk (and hence Tkinter) is not a suitable candidate if screen readers are an important concern. In an ideal world, every GUI would be fully accessible. The reality is that sometimes, competing requirements will lead to accessibility being lower in the priority list than other things. So with different requirements and priorities, the "best" solution will be different. I don't object and in fact commend you for advocating for accessibility. I do feel you are not acknowledging and fully respecting that others may be in situations where accessibility may not be the primary concern. Thanks again Mark From cjwilliams43 at gmail.com Mon Jan 24 12:45:45 2011 From: cjwilliams43 at gmail.com (Colin J. Williams) Date: Mon, 24 Jan 2011 12:45:45 -0500 Subject: Which is the best book to learn python In-Reply-To: References: <188c0a9f-4e93-4fae-b3f9-e7c84f8030fd@v31g2000pri.googlegroups.com> Message-ID: On 24-Jan-11 12:38 PM, Jean-Michel Pichavant wrote: > santosh hs wrote: >> Hi All, >> i am beginner to python please tell me which is the best available >> reference for beginner to start from novice > > Hi, > > You could have searched the archive, this question was raised many times. > > http://wiki.python.org/moin/IntroductoryBooks > > I read "Learning Python" when I started. Since it's the only one I read > I cannot tell you which one is the best (if there is). > Python is easy to learn, I'm not sure it's possible to write a bad book > about it. > > JM > I liked Alex Martelli's Python in a nutshell, but it's a bit dated now. Colin W. From rantingrick at gmail.com Mon Jan 24 12:57:55 2011 From: rantingrick at gmail.com (rantingrick) Date: Mon, 24 Jan 2011 09:57:55 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> 7c$4275d90a$44222222222222 <63eea$4d3cd2fd$4275d90a$14984@FUSE.NET> <69465430-08b3-4069-99c7-72f4d3034c66@s5g2000yqm.googlegroups.com> <705ad$4d3ce0fc$4275d90a$29144@FUSE.NET> Message-ID: <73b412bc-5414-4747-8ee0-ce08cedb5cb3@v17g2000prc.googlegroups.com> On Jan 24, 11:39?am, Mark Roseman wrote: > ?"Octavian Rasnita" wrote: > > > But unfortunately it is not accessible for screen readers and it > > discriminates many potential users. > > Octavian, thank you for very clearly making and repeating your point > about screen readers. ?It is very obvious that at this point in time Tk > (and hence Tkinter) is not a suitable candidate if screen readers are an > important concern. > > In an ideal world, every GUI would be fully accessible. ?The reality is > that sometimes, competing requirements will lead to accessibility being > lower in the priority list than other things. ?So with different > requirements and priorities, the "best" solution will be different. > > I don't object and in fact commend you for advocating for accessibility. ? > I do feel you are not acknowledging and fully respecting that others may > be in situations where accessibility may not be the primary concern. ? Why don't you just tell him to shut the hell up Mark? Anyone can see that SHUT THE HELL UP is what you are implying here. Obviously you guys are worried terribly about accessibility hurting your "one dimensional" position of supporting the legacy TclTk. Otherwise you would not make veiled threats like this. Your post is an obvious veiled threat to anyone of average intelligence! Octavian has already been threatened with the kill file by Ethan for accidentally quoting me too much. You guys are very disappointing to this community. Everyone here needs a voice. We must never engage in behaviors that would limit speech from our community members who have the intelligence to offer reasonable arguments. Octavian is not a troll or spammer and should not be treated as such! Stop this threating of our community members NOW! From krzysztof.t.bieniasz at gmail.com Mon Jan 24 12:59:46 2011 From: krzysztof.t.bieniasz at gmail.com (Krzysztof Bieniasz) Date: Mon, 24 Jan 2011 17:59:46 +0000 (UTC) Subject: Which is the best book to learn python References: <188c0a9f-4e93-4fae-b3f9-e7c84f8030fd@v31g2000pri.googlegroups.com> Message-ID: Dnia Mon, 24 Jan 2011 09:09:31 -0800, santosh hs napisa?(a): > Hi All, > i am beginner to python please tell me which is the best available > reference for beginner to start from novice For most CS stuff O'Reilly is most often a good bet. Therefore I think you'll find Mark Lutz's "Learning Python" useful. From bryan.oakley at gmail.com Mon Jan 24 13:00:16 2011 From: bryan.oakley at gmail.com (Bryan) Date: Mon, 24 Jan 2011 10:00:16 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <100e192f-9a6c-4c3a-8092-a65cd04eef64@o14g2000yqe.googlegroups.com> Message-ID: On Jan 24, 7:27?am, "Octavian Rasnita" wrote: > From: "Bryan" > > > It would be hard (but not impossible, by any > > stretch) for me to duplicate your code. Certainly, it would take more > > lines of code but that's about it. OTOH, it would be very difficult > > indeed to create atkinterprogram that works on windows but segfaults > > on linux. That's also quite hard intkinter. > > I doubt you could do a program that offers the same features usingTkinter. > That program will not be accessible for screen readers and this is a big > problem, a vital problem for those that use a screen reader, because the > program won't be accessible at all. > > Octavian I wish I could respond to that, but I have no experience with screen readers. Are there any free ones, or ones with free trials, that I could try out? I'm not yet convinced it's any better or worse than wxPython since you're only a single datapoint, but of course it's possible. If you know of any free tools I can use to experiment, I'd appreciate you posting them in this newsgroup. Accessibility, like internationalization, is something few programmers spend much time thinking about. I can only imagine the frustration one must experience if all interactions had to be through a screen reader. From rantingrick at gmail.com Mon Jan 24 13:05:14 2011 From: rantingrick at gmail.com (rantingrick) Date: Mon, 24 Jan 2011 10:05:14 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <100e192f-9a6c-4c3a-8092-a65cd04eef64@o14g2000yqe.googlegroups.com> Message-ID: <668d4047-58a8-4208-8bd0-92a7c7344d2f@o9g2000pre.googlegroups.com> On Jan 24, 12:00?pm, Bryan wrote: > Accessibility, like internationalization, is something few programmers > spend much time thinking about. Thats another uninformed statement by you we can add to the mountains of useless cruft you have offered so far. Unicode IS internationalization and Guido thought it was SO important that Python3000 auto converts all strings to Unicode strings. Obviously he is moving us toward full Unicode only in the future (AS SHOULD ALL IMPLEMENTATIONS!). We need one and only one obvious way to do it. And Unicode is that way. From bryan.oakley at gmail.com Mon Jan 24 13:11:32 2011 From: bryan.oakley at gmail.com (Bryan) Date: Mon, 24 Jan 2011 10:11:32 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <70498$4d3cb87c$4275d90a$4428@FUSE.NET> <63eea$4d3cd2fd$4275d90a$14984@FUSE.NET> <69465430-08b3-4069-99c7-72f4d3034c66@s5g2000yqm.googlegroups.com> <705ad$4d3ce0fc$4275d90a$29144@FUSE.NET> <3d68e6fe-be68-4713-8330-20886d914547@r29g2000yqj.googlegroups.com> <2e6deec8-bdca-40ec-a759-6fa2951585fb@s5g2000yqm.googlegroups.com> Message-ID: <32a5f619-f085-4a1e-adf1-54290610cad0@u13g2000prd.googlegroups.com> On Jan 24, 7:32?am, rantingrick wrote: > On Jan 24, 7:24?am, Bryan wrote: > > > On Jan 24, 12:06?am, rusi wrote: > > > > On Jan 24, 9:16?am, "Littlefield, Tyler" wrote: > > > > Of course as Steven pointed out wx is written in C++ which is almost > > > certainly where the crash is occurring. > > > But this is technical nitpicking. > > > The real issue is that when coding in C/C++ segfaults are a daily > > > affair. > > > Whereas forpythonits the first time I am seeing it in 10 years... > > > In my experience, segfaults withwxPythonaren't daily, but they are > > pretty much weekly. > > hmm > > > There are weeks that can go by without them, but > > then I'll have several in a week to bump up the average. > > Yes, and this could not be your problem, it must bewxPython. Right? > *rolls-eyes* Correct. A scripting language should *never* segfault. If it does, it is a bug in the language or library. It is a provable fact that wxPython segfaults. You yourself proved that. That is, in and of itself, *not* a reason to pick some other toolkit. It's merely a datapoint. It's not a datapoint you can just sweep under the rug, however, like you seem to want to do. > > > ?There are > > a lot of things you can do that aren't valid in particular contexts, > > and instead of throwing a catchable error you get a segfault. > > And we need to fix that instead just disqualifying a feature rich > toolkit. I think if you re-read my post you'll see I don't disqualify it as a rich toolkit. wxPython is a fine toolkit. Better than tkinter in some ways, worse in others. segfaults is one aspect in which it is measurably worse. From tyler at tysdomain.com Mon Jan 24 13:21:07 2011 From: tyler at tysdomain.com (Littlefield, Tyler) Date: Mon, 24 Jan 2011 11:21:07 -0700 Subject: WxPython versus Tkinter. In-Reply-To: References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> 7c$4275d90a$44222222222222 <63eea$4d3cd2fd$4275d90a$14984@FUSE.NET> <69465430-08b3-4069-99c7-72f4d3034c66@s5g2000yqm.googlegroups.com> <705ad$4d3ce0fc$4275d90a$29144@FUSE.NET> Message-ID: <4D3DC313.8040905@tysdomain.com> Hello, I have been on another list with Octavian, and he takes his accessibility a bit to seriously. If things went his way, he wants laws where -everything- has to be accessible, and it is illegal not to do so. As a sidenote, I would like to preface everything I'm going to say by mentioning the fact that I have been using a screen reader for many years, so I understand some of where he is coming from. I think my goal, (and I differ from Octavian here), is to try to find fixes for things, rather than saying "this sucks, it does not work with a reader, and thus it shouldn't be used). Having done a lot of development work in the past, I can't say "hey you, I want you to make this app accessible, and because you used TKInter it's not, so use something else, but nothing that isn't accessible." Rather, I believe those pushing accessibility should concentrate on the root cause; that of fixing TKInter, and not forcing everyone else to use a different library. I believe that the approach is the main key here, and I have had this argument many times. If I wrote an app, and someone said something along the lines of "you need to change a core library because it doesn't work with this program," my first response would be who the hell are you to say what I need to use? We need to take the approach of "This is what is wrong, this is why, this is possibly how it could be fixed. Would you be willing to do so?" So, with all of this said, TKInter -is- unaccesssible for us. My arguments have not been for or against one or the other in this thread, but more to get RR to make a better point. Because eventually, WX would benafit those using a screen reader a lot more than say, TKInter will. That doesn't mean that I'm saying that we need to make it a part of the stdlib as of yesterday, because segfaults from someone with 10+ years of experience (multiple people, actually) says a lot, whether or not RR wants to acknowledge said facts. I can not with good conchence say that the switch should be done just for accessibility purposes. Obviously it would be awesome, but I think Octavian is just focusing on himself, and not the actual big picture here. From rantingrick at gmail.com Mon Jan 24 13:26:54 2011 From: rantingrick at gmail.com (rantingrick) Date: Mon, 24 Jan 2011 10:26:54 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <70498$4d3cb87c$4275d90a$4428@FUSE.NET> <63eea$4d3cd2fd$4275d90a$14984@FUSE.NET> <69465430-08b3-4069-99c7-72f4d3034c66@s5g2000yqm.googlegroups.com> <705ad$4d3ce0fc$4275d90a$29144@FUSE.NET> <3d68e6fe-be68-4713-8330-20886d914547@r29g2000yqj.googlegroups.com> <2e6deec8-bdca-40ec-a759-6fa2951585fb@s5g2000yqm.googlegroups.com> <32a5f619-f085-4a1e-adf1-54290610cad0@u13g2000prd.googlegroups.com> Message-ID: On Jan 24, 12:11?pm, Bryan wrote: > It is a provable fact that wxPython segfaults. You yourself proved > that. That is, in and of itself, *not* a reason to pick some other > toolkit. It's merely a datapoint. It's not a datapoint you can just > sweep under the rug, however, like you seem to want to do. Ok, now you are talking with facts and we can have a real debate! Yes wxPython can be made to segfault by the user in some circumstances. And YES this is very undesirable and it is the direct product of a poorly written API. However! I do not blame the wxPython creators or even Robin Dunn himself for this problem. Robin has stated many times that he wants to keep wxPython as close to wxWidgets as possible and he also said there is room for a "top level" API. This is why wxPython proper has no business in the stdlib! We need an abstraction API written in Python. So my point is, we need to create this API independent of wxPython. You can think of it as "wx-inter" if you like. > I think if you re-read my post you'll see I don't disqualify it as a > rich toolkit. wxPython is a fine toolkit. Better than tkinter in some > ways, worse in others. segfaults is one aspect in which it is > measurably worse. Again: good argument! And i stand on my last reply. If you would be interested i would like to work on this abstraction API with you. Are you interested? How free are you? We need to work together to solve this problem. From ethan at stoneleaf.us Mon Jan 24 13:28:31 2011 From: ethan at stoneleaf.us (Ethan Furman) Date: Mon, 24 Jan 2011 10:28:31 -0800 Subject: WxPython versus Tkinter. In-Reply-To: References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> 7c$4275d90a$44222222222222 <63eea$4d3cd2fd$4275d90a$14984@FUSE.NET> <69465430-08b3-4069-99c7-72f4d3034c66@s5g2000yqm.googlegroups.com> <705ad$4d3ce0fc$4275d90a$29144@FUSE.NET> Message-ID: <4D3DC4CF.3020606@stoneleaf.us> Mark Roseman wrote: > > I don't object and in fact commend you for advocating for accessibility. > I do feel you are not acknowledging and fully respecting that others may > be in situations where accessibility may not be the primary concern. Well said. ~Ethan~ From tyler at tysdomain.com Mon Jan 24 13:31:41 2011 From: tyler at tysdomain.com (Littlefield, Tyler) Date: Mon, 24 Jan 2011 11:31:41 -0700 Subject: WxPython versus Tkinter. In-Reply-To: References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <100e192f-9a6c-4c3a-8092-a65cd04eef64@o14g2000yqe.googlegroups.com> Message-ID: <4D3DC58D.3010407@tysdomain.com> Bryan: Here's a pretty good list for you. Windows: Jaws for Windows (http://freedomscientific.com). Not free, but you get a 40 minute demo before you need to reboot. Nonvisual Desktop Access: http://www.nvda-project.org/ Free, open source, written in python (with some core stuff in c/c++). Linux: Orca live.gnome.org/Orca Fre, open source. If you don't want to install that bloated mess on a box (I sympathise), and you can grab a vmware vinux or a live cd or whatever from: http://vinux.org.uk OSX: OSX comes built in with Voiceover, just hold down the command key and hit F5. Use the same keystroke to turn it off. Enjoy! From enalicho at gmail.com Mon Jan 24 13:33:40 2011 From: enalicho at gmail.com (Noah Hall) Date: Mon, 24 Jan 2011 18:33:40 +0000 Subject: WxPython versus Tkinter. In-Reply-To: <73b412bc-5414-4747-8ee0-ce08cedb5cb3@v17g2000prc.googlegroups.com> References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <63eea$4d3cd2fd$4275d90a$14984@FUSE.NET> <69465430-08b3-4069-99c7-72f4d3034c66@s5g2000yqm.googlegroups.com> <705ad$4d3ce0fc$4275d90a$29144@FUSE.NET> <73b412bc-5414-4747-8ee0-ce08cedb5cb3@v17g2000prc.googlegroups.com> Message-ID: On Mon, Jan 24, 2011 at 5:57 PM, rantingrick wrote: > Why don't you just tell him to shut the hell up Mark? > accidentally quoting me too much. You guys are very disappointing to > this community. Everyone here needs a voice. We must never engage in > behaviors that would limit speech from our community members who have > the intelligence to offer reasonable arguments. Octavian is not a > troll or spammer and should not be treated as such! Stop this > threating of our community members NOW! Oh, the irony. It's not so much what you're saying, but the way you're saying it. You're not allowed to treat people like that - no matter how much you *think* you're right. You've done nothing but accuse anyone disagreeing with you of being a troll and then proceed to curse them. I don't know why you're surprised people won't discuss matters with you. It sounds like you have a lot of growing up you need to do. From bryan.oakley at gmail.com Mon Jan 24 13:39:59 2011 From: bryan.oakley at gmail.com (Bryan) Date: Mon, 24 Jan 2011 10:39:59 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <100e192f-9a6c-4c3a-8092-a65cd04eef64@o14g2000yqe.googlegroups.com> <1ed86ac9-e8a9-48b3-8f27-bf480782eb82@w17g2000yqh.googlegroups.com> Message-ID: On Jan 24, 8:15?am, rantingrick wrote: > On Jan 24, 6:33?am, Bryan wrote: > > > I think I'm qualified, though I guess only you can tell me if I > > measure up to your standards. > > Go on... > > > I have 15 years or so of tk development, > > though admittedly mostly with Tcl. Most recently I've spent about the > > past year and a half withwxPython. > > A year and a half and you are still producing buggy code? (you > yourself admitted this!) Of course! You'll not find a single programmer who creates bug-free code. (I'm beginning to think we're dealing with a software-based troll programmed to focus in on specific words in order to set up strawman arguments) > > > For what it's worth, I am the only > > person on stackoverflow.com with the "tkinter" badge, which only means > > I've answered a bunch of questions ontkinterthat others find > > helpful, nothing more. > > Well could we see a link to a few answered questions or get your nick > so we can corroborate this statement ourselves? Sure! I don't feel compelled to answer your demands but this one is harmless enough. http://stackoverflow.com/users/7432/bryan-oakley if you want, you can also do a search on google groups for my other email address "oakley at bardo.clearlight.com". I have a history in comp.lang.tcl that goes back to almost the dawn of time. I'm the 8th most prolific poster (and pretty much all answers, very few questions), though I'd be higher except I used a different email for a year or so back in 2002-2004 http://groups.google.com/group/comp.lang.tcl/about > > > No offense, but your challenge is worthless, and your own entry in the > > challenge is remarkably weak. > > First rule when given a challenge you cannot answer due to ignorance: > question the validity of the challenge. And the first rule for dealing with someone who gives facts that don't agree with you is to call them names. > > > ?About the only thing you've proven is > > thatwxPythonhas some built-in widgets thattkinterdoes not have, > > Well this is ONLY the first challenge Bryan. More will come. However, > not until someone has the balls to answer my first challenge. Honestly, your challenge is childish. The rules are self-serving and the outcome proves nothing. Your challenge serves nothing but to prove wxPython has a built-in widget that tkinter does not. Nobody disputes that. Proving it in code is pointless when it's a well known, documented fact. > > > and thatwxPythonmakes it hard to do cross-platform development. > > I don't think that is completely accurate Bryan. Harder thanTkinter, > yes. Anything else is hyperbole. > > > Does > > that surprise anyone? I'll give you a challenge: create a vector > > graphics program. > > Answer my challenge first, then we talk. And obviously you do not > understand the power of wx's Open Graphics Library (OGL). You'd better > go check that out before you stick yourTkinterloving foot into your > big mouth. I stand corrected. It was early, that was the first thing that came to mind. >... > > What's really amusing is that your program segfaults on linux yet is > > supposed to showwxPythonsuperiority. > > Segfault or not wx is superior. I don't know if you realize it, but that's a funny statement. > > > In my 15-20 years of tk > > development, you know how many segfaults I've seen? Approximately > > zero. > > BULLSHITE! No, seriously. Tcl/tk and python/tkinter are both remarkably stable in this regard. You want a programming challenge? Try creating an app using either of those combinations to get a segfault. I'm not saying it can't be done, but it _is_ challenging. > ... > LIAR! LIAR! PANTS ON FIRE! Ok, now I'm pretty certain I'm responding to a bot. Time to move on. From rantingrick at gmail.com Mon Jan 24 13:48:53 2011 From: rantingrick at gmail.com (rantingrick) Date: Mon, 24 Jan 2011 10:48:53 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> 7c$4275d90a$44222222222222 <63eea$4d3cd2fd$4275d90a$14984@FUSE.NET> <69465430-08b3-4069-99c7-72f4d3034c66@s5g2000yqm.googlegroups.com> <705ad$4d3ce0fc$4275d90a$29144@FUSE.NET> Message-ID: <5f8c1256-f07c-43be-8307-d36991e9be24@m35g2000vbn.googlegroups.com> On Jan 24, 12:21?pm, "Littlefield, Tyler" wrote: [...snip: good discussion...] > Rather, I believe > those pushing accessibility should concentrate on the root cause; that > of fixing TKInter, and not forcing everyone else to use a different library. Now you go too far! And this is an ironic position from someone who supports the stdlib GUI that IS forced on us by default. Sure you can choose a different library, but in the case of a user (and accessibility is a big USER concern when that user is handicapped!) the library is already chosen (Tkinter:which does not support accessibility) by the developer . I can also argue that Tkinter's inclusion in the stdlib is proliferating non-compliance with accessibility. I'll bet you would not park in a handicap spot however you support a GUI library that ignores handicap people? IRONIC! > I believe that the approach is the main key here, and I have had this > argument many times. If I wrote an app, and someone said something along > the lines of "you need to change a core library because it doesn't work > with this program," my first response would be who the hell are you to > say what I need to use? Well these people you are chastising are disabled people. Who the hell are YOU to be high and mighty about it? I guess these "disabled" people get what they deserve huh! Maybe we should just do the world a favor and exterminate them like the Nazis? That way we don't have to cater to their selfish needs! > We need to take the approach of "This is what is > wrong, this is why, this is possibly how it could be fixed. Would you be > willing to do so?" WE ALL NEED TO TAKE THAT APPROACH TYLER, INCLUDING YOURSELF!!! > So, with all of this said, TKInter -is- unaccesssible for us. My > arguments have not been for or against one or the other in this thread, > but more to get RR to make a better point. Yea, and i just made it. > Because eventually, WX would > benafit those using a screen reader a lot more than say, TKInter will. > That doesn't mean that I'm saying that we need to make it a part of the > stdlib as of yesterday, because segfaults from someone with 10+ years of > experience (multiple people, actually) says a lot, whether or not RR > wants to acknowledge said facts. I can not with good conchence say that > the switch should be done just for accessibility purposes. No one said accessibility was the only argument. However it IS very important in todays time. We are not living in the dark ages, much less under Hitlers rule! If a GUI library has refused to recognize accessibility concerns a decade into the 21st century, just how long must we wait Tyler? HOW LONG? > Obviously it > would be awesome, but I think Octavian is just focusing on himself, and > not the actual big picture here. Yes Octavian is the only disabled person in the world. What a selfish, selfish person he is. Shame on you Octavian, Shame on You! You just showed your true colors Tyler, very sad. :( From bryan.oakley at gmail.com Mon Jan 24 14:00:43 2011 From: bryan.oakley at gmail.com (Bryan) Date: Mon, 24 Jan 2011 11:00:43 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <70498$4d3cb87c$4275d90a$4428@FUSE.NET> <63eea$4d3cd2fd$4275d90a$14984@FUSE.NET> <69465430-08b3-4069-99c7-72f4d3034c66@s5g2000yqm.googlegroups.com> <705ad$4d3ce0fc$4275d90a$29144@FUSE.NET> <3d68e6fe-be68-4713-8330-20886d914547@r29g2000yqj.googlegroups.com> Message-ID: On Jan 24, 8:49?am, Mike Driscoll wrote: > > Bryan, on the other hand, has been aTkinterluminary who has helped > me in the past when I was learningTkinterand I won't be too > surprised if he helps me again. I'm sorry he's had so much trouble > with wx though. Thanks for the kind words, I appreciate it. I'm puzzled by the problems I have with wxPython, too. It's taken me longer to get a grasp on some concepts that I would have guessed. The first time I got a segfault I was stunned but shrugged it off. A segfault in a scripting language? Blasphemy! Now I'm not so stunned anymore, but I still shrug them off. Part of the blame certainly rests on my shoulder. With only a year and a half or so under my belt with wxPython there's still lots I have to learn and the documentation only gets me so far. What's the rule of thumb -- it takes 10 years to become an expert on a subject? The underlying architecture of tk is so solid, so well designed (IMHO) that you (well, I) take a lot of stuff for granted. Then you switch to something like wxPython where the foundation is maybe a little shaky in exchange for a much richer library of widgets, and the transition is bound to be bumpy. It's not generally a matter of "better" or "worse", just "different". The key to success is to realize both of the toolkits are just that -- toolkits. They aren't religion, they aren't an assault on family values or a threat to national security. They are tools to get the job done. Instead of saying "mine is better than yours" it's better to learn the strengths and weaknesses of both (or all) and pick the right one for the job. Attempting to prove that any of these toolkits is "best" is tilting at windmills. Personally, I think tkinter is the right choice as a built-in toolkit but I'll admit to bias. The basics are really simple, and for 90% of the stuff you're going to code in a scripting language it has all the features you need. If you specifically need something like the styledtextctrl or grid of wxPython, or maybe you're concerned with accessibility or some feature that's not built in to tkinter, by all means switch to a different toolkit. That's the beauty of these GUI toolkits -- you can keep the language you love (python, in the case of this newsgroup) yet pick the GUI toolkit that best helps you solve the problem at hand. Instead of fighting over the differences, raise a pint in celebration of their diversity. :-) From mark at markroseman.com Mon Jan 24 14:21:02 2011 From: mark at markroseman.com (Mark Roseman) Date: Mon, 24 Jan 2011 12:21:02 -0700 Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <63eea$4d3cd2fd$4275d90a$14984@FUSE.NET> <69465430-08b3-4069-99c7-72f4d3034c66@s5g2000yqm.googlegroups.com> <705ad$4d3ce0fc$4275d90a$29144@FUSE.NET> Message-ID: "Littlefield, Tyler" wrote: > Rather, I believe > those pushing accessibility should concentrate on the root cause; that > of fixing TKInter, and not forcing everyone else to use a different library. Here, here. From my queries to some of the Tcl/Tk folks, it seems that while the knowledge and expertise is not present in the core developer community, they would be more than happy to help people who do have some knowledge in this area so that Tk could be made to be more accessible. Grand conspiracies aside, I think the development communities behind most GUI toolkits would be very receptive to people who could help make developing accessible applications with their toolkits feasible. (And if/when this does get done for Tk, I promise at least to make sure that the tutorial at http:///www.tkdocs.com covers this topic). Mark From bryan.oakley at gmail.com Mon Jan 24 14:23:32 2011 From: bryan.oakley at gmail.com (Bryan) Date: Mon, 24 Jan 2011 11:23:32 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <100e192f-9a6c-4c3a-8092-a65cd04eef64@o14g2000yqe.googlegroups.com> <668d4047-58a8-4208-8bd0-92a7c7344d2f@o9g2000pre.googlegroups.com> Message-ID: On Jan 24, 12:05?pm, rantingrick wrote: > On Jan 24, 12:00?pm, Bryan wrote: > > > Accessibility, like internationalization, is something few programmers > > spend much time thinking about. > > Thats another uninformed statement by you we can add to the mountains > of useless cruft you have offered so far. Unicode IS > internationalization and Guido thought it was SO important that > Python3000 auto converts all strings to Unicode strings. Obviously he > is moving us toward full Unicode only in the future (AS SHOULD ALL > IMPLEMENTATIONS!). We need one and only one obvious way to do it. And > Unicode is that way. Ok, great. You've identified one programmer who thinks about internationalization. Not much of a compelling argument there. However, I think you missed my point. My point wasn't that people like Guido don't think of these topics. It's that the people in the trenches who use these tools don't think about these topics. How many of your co-workers actively think about internationalization and accessibility? I'm guessing none, but maybe you're lucking and work in a particularly enlightened team. I've perhaps worked closely with a few hundred programmers in my career, and very few of them thought of these subjects. In my experience it's just not something the programmer in the trenches thinks about. That is the point I was trying to make. From python at mrabarnett.plus.com Mon Jan 24 14:25:23 2011 From: python at mrabarnett.plus.com (MRAB) Date: Mon, 24 Jan 2011 19:25:23 +0000 Subject: WxPython versus Tkinter. In-Reply-To: <668d4047-58a8-4208-8bd0-92a7c7344d2f@o9g2000pre.googlegroups.com> References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <100e192f-9a6c-4c3a-8092-a65cd04eef64@o14g2000yqe.googlegroups.com> <668d4047-58a8-4208-8bd0-92a7c7344d2f@o9g2000pre.googlegroups.com> Message-ID: <4D3DD223.4080602@mrabarnett.plus.com> On 24/01/2011 18:05, rantingrick wrote: > On Jan 24, 12:00 pm, Bryan wrote: > >> Accessibility, like internationalization, is something few programmers >> spend much time thinking about. > > Thats another uninformed statement by you we can add to the mountains > of useless cruft you have offered so far. Unicode IS > internationalization and Guido thought it was SO important that > Python3000 auto converts all strings to Unicode strings. Obviously he > is moving us toward full Unicode only in the future (AS SHOULD ALL > IMPLEMENTATIONS!). We need one and only one obvious way to do it. And > Unicode is that way. > There's more to internationalization than just Unicode. There's the ability to handle messages in various languages which have a different syntax and grammar. There's an interesting Perl-oriented article on it here: http://search.cpan.org/dist/Locale-Maketext/lib/Locale/Maketext/TPJ13.pod#A_Localization_Horror_Story:_It_Could_Happen_To_You From bryan.oakley at gmail.com Mon Jan 24 14:25:39 2011 From: bryan.oakley at gmail.com (Bryan) Date: Mon, 24 Jan 2011 11:25:39 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <100e192f-9a6c-4c3a-8092-a65cd04eef64@o14g2000yqe.googlegroups.com> Message-ID: On Jan 24, 12:31?pm, "Littlefield, Tyler" wrote: > Bryan: Here's a pretty good list for you. > Windows: > Jaws for Windows (http://freedomscientific.com). Not free, but you get a > 40 minute demo before you need to reboot. > Nonvisual Desktop Access:http://www.nvda-project.org/ > Free, open source, written in python (with some core stuff in c/c++). > Linux: > Orca live.gnome.org/Orca > Fre, open source. If you don't want to install that bloated mess on a > box (I sympathise), and you can grab a vmware vinux or a live cd or > whatever from:http://vinux.org.uk > OSX: > OSX comes built in with Voiceover, just hold down the command key and > hit F5. Use the same keystroke to turn it off. > Enjoy! Thanks! I appreciate it. From tyler at tysdomain.com Mon Jan 24 14:26:44 2011 From: tyler at tysdomain.com (Littlefield, Tyler) Date: Mon, 24 Jan 2011 12:26:44 -0700 Subject: WxPython versus Tkinter. In-Reply-To: <5f8c1256-f07c-43be-8307-d36991e9be24@m35g2000vbn.googlegroups.com> References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> 7c$4275d90a$44222222222222 <63eea$4d3cd2fd$4275d90a$14984@FUSE.NET> <69465430-08b3-4069-99c7-72f4d3034c66@s5g2000yqm.googlegroups.com> <705ad$4d3ce0fc$4275d90a$29144@FUSE.NET> <5f8c1256-f07c-43be-8307-d36991e9be24@m35g2000vbn.googlegroups.com> Message-ID: <4D3DD274.7030301@tysdomain.com> RR, I do hate to break the news to you, but I am -blind-, which is why I am using a screen reader. So I'm not parking anywhere--the DMV refuses to give me a license for some odd reason. What was that post about IQ you made earlier?... From emile at fenx.com Mon Jan 24 14:30:45 2011 From: emile at fenx.com (Emile van Sebille) Date: Mon, 24 Jan 2011 11:30:45 -0800 Subject: WxPython versus Tkinter. In-Reply-To: References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <70498$4d3cb87c$4275d90a$4428@FUSE.NET> <46c407b5-9bfe-406a-a2fe-c63caa771bf3@f2g2000vby.googlegroups.com> <05fd32ee-e542-4622-afa8-a7cf4549df45@k42g2000yqa.googlegroups.com> Message-ID: On 1/24/2011 8:13 AM Grant Edwards said... > On 2011-01-24, rantingrick wrote: > >> Bryan you are clearly an idiot. I am demanding that from now on, you >> must have at least a 120 or higher IQ before participating in any of >> my threads. > > Rantingrick thinks certain threads belong to him. > > 'nuf said. > Can we reopen the python-gui list? That'd be the appropriate place to hammer together a PEP to replace tkinter in the standard library. Emile From python at mrabarnett.plus.com Mon Jan 24 14:34:27 2011 From: python at mrabarnett.plus.com (MRAB) Date: Mon, 24 Jan 2011 19:34:27 +0000 Subject: WxPython versus Tkinter. In-Reply-To: <5f8c1256-f07c-43be-8307-d36991e9be24@m35g2000vbn.googlegroups.com> References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> 7c$4275d90a$44222222222222 <63eea$4d3cd2fd$4275d90a$14984@FUSE.NET> <69465430-08b3-4069-99c7-72f4d3034c66@s5g2000yqm.googlegroups.com> <705ad$4d3ce0fc$4275d90a$29144@FUSE.NET> <5f8c1256-f07c-43be-8307-d36991e9be24@m35g2000vbn.googlegroups.com> Message-ID: <4D3DD443.5070906@mrabarnett.plus.com> On 24/01/2011 18:48, rantingrick wrote: > On Jan 24, 12:21 pm, "Littlefield, Tyler" wrote: > > [...snip: good discussion...] > >> Rather, I believe >> those pushing accessibility should concentrate on the root cause; that >> of fixing TKInter, and not forcing everyone else to use a different library. > > Now you go too far! > > And this is an ironic position from someone who supports the stdlib > GUI that IS forced on us by default. Sure you can choose a different > library, but in the case of a user (and accessibility is a big USER > concern when that user is handicapped!) the library is already chosen > (Tkinter:which does not support accessibility) by the developer . I > can also argue that Tkinter's inclusion in the stdlib is proliferating > non-compliance with accessibility. I'll bet you would not park in a > handicap spot however you support a GUI library that ignores handicap > people? IRONIC! > >> I believe that the approach is the main key here, and I have had this >> argument many times. If I wrote an app, and someone said something along >> the lines of "you need to change a core library because it doesn't work >> with this program," my first response would be who the hell are you to >> say what I need to use? > > Well these people you are chastising are disabled people. Who the hell > are YOU to be high and mighty about it? I guess these "disabled" > people get what they deserve huh! Maybe we should just do the world a > favor and exterminate them like the Nazis? That way we don't have to > cater to their selfish needs! > [snip] I'd like to invoke Godwin's law at this point. From ellen.crawford at verigy.com Mon Jan 24 14:41:31 2011 From: ellen.crawford at verigy.com (Crawford, Ellen) Date: Mon, 24 Jan 2011 13:41:31 -0600 Subject: Convert month name to month number faster Message-ID: From jim at lsfdev.com Mon Jan 24 14:42:26 2011 From: jim at lsfdev.com (thompjs) Date: Mon, 24 Jan 2011 11:42:26 -0800 (PST) Subject: Python 3.1 cx_Oracle 5.0.2 "ImportError: DLL load failed: The specified module could not be found." In-Reply-To: References: <1e071bb5-3d28-4cc2-9541-83c08a474164@v15g2000prn.googlegroups.com> Message-ID: <30748079.post@talk.nabble.com> I'm having similar issue but everything seems to be installed in correct places. Loaded "CX_ORACLE.PYD" at address 0x6BD80000. Successfully hooked module. Loaded "OCI.DLL" at address 0x10000000. Successfully hooked module. Unloaded "CX_ORACLE.PYD" at address 0x6BD80000. Unloaded "OCI.DLL" at address 0x10000000. LoadLibraryExA("C:\JSTData\Python27\lib\site-packages\cx_Oracle.pyd", 0x00000000, LOAD_WITH_ALTERED_SEARCH_PATH) returned NULL. Error: The specified procedure could not be found (127). Why is cx_Oracle not found after it has been hooked? Thanks to anyone that can shed some light on this. -- View this message in context: http://old.nabble.com/Python-3.1-cx_Oracle-5.0.2-%22ImportError%3A-DLL-load-failed%3A-The--specified-module-could-not-be-found.%22-tp26422168p30748079.html Sent from the Python - python-list mailing list archive at Nabble.com. From dmaziuk at bmrb.wisc.edu Mon Jan 24 14:44:55 2011 From: dmaziuk at bmrb.wisc.edu (dmaziuk) Date: Mon, 24 Jan 2011 11:44:55 -0800 (PST) Subject: how to tell if cursor is sqlite.Cursor or psycopg2.Cursor Message-ID: <7f1931cd-a15b-44a9-8cf9-b0af0bdfec7d@d8g2000yqf.googlegroups.com> Hi everyone, I've wrapper class around some sql statements and I'm trying to add a method that does: if my_cursor is a sqlite cursor, then run "select last_insert_rowid()" else if it's a psycopg2 cursor, then run "select currval( 'my_sequence' )" etc. The best I can come up with is import both psycopg2 and sqlite and then do if isinstance( self._curs, sqlite.Cursor ) : ... elif isinstance( self._curs, psycopg2._psycopg.cursor ) : ... and I can't help thinking there has to be another way to find out what kind of thing self._curs is. Is there a better way? TIA Dima From robin at alldunn.com Mon Jan 24 14:57:54 2011 From: robin at alldunn.com (Robin Dunn) Date: Mon, 24 Jan 2011 11:57:54 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <3a96fee1-995f-49f7-a967-f125cc3f1cdc@v26g2000yqf.googlegroups.com> Message-ID: On Jan 23, 4:31?pm, "Martin v. Loewis" wrote: > > WxPython Challenge 1 code updated... > > > ?* Fixed tab traveral > > ?* Removed hand-holding code > > ?* Removed some cruft > > > ?https://sites.google.com/site/thefutureofpython/home/code-challenges > > > Good luck! > > Still crashes the interpreter. The crash on Linux is due to SetSingleStyle removing the all items and the columns when the mode of the listctrl is changed, and then the code continues on with the assumption that the columns still exist and the crash happens when an item is added to column zero and there is no column zero. Apparently the native widget on Windows doesn't have that limitation. BTW, if the linux wx packages had the runtime assertions turned on then you would have seen a Python exception with some clues that would probably help solve the problem. I don't know about others but on Ubuntu you can install the *wx*-dbg packages to get a version with the assertions turned on. Hopefully that will change starting with 2.9 as wx now turns on the assertions by default for builds configured normally, and the wx-dev team recommends that the assertions are not turned off, except in rare circumstances. BTW, on behalf of the wxPython community I'd like to apologize for the havoc caused by the flaming troll escaping from his cage. In general wxPython users are much less militant and zealotty and honor everyone's freedom to choose which ever UI tool kit works the best for their own needs. --Robin From orasnita at gmail.com Mon Jan 24 14:58:10 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Mon, 24 Jan 2011 21:58:10 +0200 Subject: [Code Challenge] WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <4D3DB2F9.3090303@stoneleaf.us> Message-ID: <5199876F801C41E08F3E4969745F3E47@teddy> From: "Ethan Furman" > Octavian Rasnita wrote: >> From: "rantingrick" >>> WxPython versus Tkinter (A code battle to the death!) >>> >>> by Rick Johnson. > [...] > > Octavian, > > Please do not repost rr's crap in its entirety, or you'll find yourself > added to many killfiles -- just like he is. :-) I am not posting anyone's crap. I just informed why Tkinter is bad. And I also don't say that WxPython is ideal, but just that it has some very important features that Tk doesn't offer. Octavian From rantingrick at gmail.com Mon Jan 24 15:00:16 2011 From: rantingrick at gmail.com (rantingrick) Date: Mon, 24 Jan 2011 12:00:16 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> 7c$4275d90a$44222222222222 <63eea$4d3cd2fd$4275d90a$14984@FUSE.NET> <69465430-08b3-4069-99c7-72f4d3034c66@s5g2000yqm.googlegroups.com> <705ad$4d3ce0fc$4275d90a$29144@FUSE.NET> <5f8c1256-f07c-43be-8307-d36991e9be24@m35g2000vbn.googlegroups.com> Message-ID: On Jan 24, 1:34?pm, MRAB wrote: > [snip] > I'd like to invoke Godwin's law at this point. Actually no. And i'll give good reason. Tyler's argument, which lacked greatly in compassion for people with disabilities brought out my accusation. It was not an accusation meant to merely insult just to invoke a flame war; which is the definition of Godwins Law. It is a fact that Tyler displayed despicable intolerance for people who have disabilities and such a correlation to totalitarian regimes was not only the correct response but in fact the only response to such veiled hate speech. We cannot allow such displays to slip by unchallenged by this community. And hopefully Tyler will see the unjust position he has taken and beg for forgiveness. From rantingrick at gmail.com Mon Jan 24 15:03:29 2011 From: rantingrick at gmail.com (rantingrick) Date: Mon, 24 Jan 2011 12:03:29 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <3a96fee1-995f-49f7-a967-f125cc3f1cdc@v26g2000yqf.googlegroups.com> Message-ID: On Jan 24, 1:57?pm, Robin Dunn wrote: > On Jan 23, 4:31?pm, "Martin v. Loewis" wrote: > > > > WxPython Challenge 1 code updated... > > > > ?* Fixed tab traveral > > > ?* Removed hand-holding code > > > ?* Removed some cruft > > > > ?https://sites.google.com/site/thefutureofpython/home/code-challenges > > > > Good luck! > > > Still crashes the interpreter. > > The crash on Linux is due to SetSingleStyle removing the all items and > the columns when the mode of the listctrl is changed, and then the > code continues on with the assumption that the columns still exist and > the crash happens when an item is added to column zero and there is no > column zero. ?Apparently the native widget on Windows doesn't have > that limitation. ?BTW, if the linux wx packages had the runtime > assertions turned on then you would have seen a Python exception with > some clues that would probably help solve the problem. In your face Linux users! Learn how to debug already! > BTW, on behalf of the wxPython community I'd like to apologize for the > havoc caused by the flaming troll escaping from his cage. ?In general > wxPython users are much less militant and zealotty and honor > everyone's freedom to choose which ever UI tool kit works the best for > their own needs. Well we forgive Byran, but we will not forget! :) From rantingrick at gmail.com Mon Jan 24 15:11:07 2011 From: rantingrick at gmail.com (rantingrick) Date: Mon, 24 Jan 2011 12:11:07 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> Message-ID: <66b4baf9-7714-45ae-9cac-39b06ee3f70e@k42g2000yqa.googlegroups.com> On Jan 22, 6:07?pm, rantingrick wrote: > I await any challengers... CODE UPDATE * fixed linux whiners bug https://sites.google.com/site/thefutureofpython/home/code-challenges From orasnita at gmail.com Mon Jan 24 15:14:16 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Mon, 24 Jan 2011 22:14:16 +0200 Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com>7c$4275d90a$44222222222222 <63eea$4d3cd2fd$4275d90a$14984@FUSE.NET><69465430-08b3-4069-99c7-72f4d3034c66@s5g2000yqm.googlegroups.com><705ad$4d3ce0fc$4275d90a$29144@FUSE.NET> Message-ID: <2C62A0CDCAEF4D4DA1CBC37C10149006@teddy> From: "Mark Roseman" > Octavian, thank you for very clearly making and repeating your point > about screen readers. It is very obvious that at this point in time Tk > (and hence Tkinter) is not a suitable candidate if screen readers are an > important concern. The screen readers are always an important concern if the GUI is used in a program that could be interesting for those who need a screen reader. Of course that if that program is Corel Draw or Photoshop or a video-editing application it is not important to offer accessibility for screen readers, but most of the programs are not that kind of apps. > In an ideal world, every GUI would be fully accessible. The reality is > that sometimes, competing requirements will lead to accessibility being > lower in the priority list than other things. So with different > requirements and priorities, the "best" solution will be different. Yes of course I agree with this. But if... let's say Python would promote a better GUI than Tkinter, most Python programmers would probably start to learn to use that GUI, and they would be able to use it better than other GUIS, and the competing requirements might force them to use that GUI because they will be able to code the GUI easier with it and so on. And if something doesn't work in that GUI, (segfaults for example) more and more programmers might become interested to solve those bugs in order to have a better GUI, and finally it would be much better than now, and... for more people. > I don't object and in fact commend you for advocating for accessibility. > I do feel you are not acknowledging and fully respecting that others may > be in situations where accessibility may not be the primary concern. I think that the accessibility shouldn't be a concern at all, because I think it is too much to ask for such a thing from the programmers. The applications should be accessible by default, by just using the right GUI which offer the necessary accessibility features. Well yes, if some fields are not labeled or some images don't have a text associated with them... if somebody is interested he/she could ask those features added later and it would be very simple to add them, but if the program is made with Tkinter... then nothing could be made to improve the accessibility. Let's imagine that Python doesn't offer any GUI lib and that no Python programmer knows to use a GUI lib. What would the majority of Python programmer choose if Python would start to offer support for WxPython and Tkinter and WxPython would be packaged in the default distribution? I think that the preference for Tk is because it is old and there are very many programmers that know to use it very well because these days the size of a program is not important. I have also heard that there is no enough support for WxPython in order to maintain it very well. This is a problem indeed and if it is true it can be a valid reason why WxPython is not considered, but WxPython is pretty well maintained. Aren't the WxPython developers willing to continue to maintain it if it will be added to Python distribution? Octavian From robin at alldunn.com Mon Jan 24 15:24:24 2011 From: robin at alldunn.com (Robin Dunn) Date: Mon, 24 Jan 2011 12:24:24 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <3a96fee1-995f-49f7-a967-f125cc3f1cdc@v26g2000yqf.googlegroups.com> Message-ID: On Jan 24, 12:03?pm, rantingrick wrote: > On Jan 24, 1:57?pm, Robin Dunn wrote: > > BTW, on behalf of the wxPython community I'd like to apologize for the > > havoc caused by the flaming troll escaping from his cage. ?In general > > wxPython users are much less militant and zealotty and honor > > everyone's freedom to choose which ever UI tool kit works the best for > > their own needs. > > Well we forgive Byran, but we will not forget! :) For the record, that is not who I was referring to. --Robin From rantingrick at gmail.com Mon Jan 24 15:33:32 2011 From: rantingrick at gmail.com (rantingrick) Date: Mon, 24 Jan 2011 12:33:32 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <100e192f-9a6c-4c3a-8092-a65cd04eef64@o14g2000yqe.googlegroups.com> <668d4047-58a8-4208-8bd0-92a7c7344d2f@o9g2000pre.googlegroups.com> Message-ID: <7228de23-5fb8-42bf-9916-b579d61583f9@f9g2000vbq.googlegroups.com> On Jan 24, 1:23?pm, Bryan wrote: > Ok, great. You've identified one programmer who thinks about > internationalization. Not much of a compelling argument there. Oh Bryan your view so simplistic. There is a whole world out there you know. > However, I think you missed my point. My point wasn't that people like > Guido don't think of these topics. It's that the people in the > trenches who use these tools don't think about these topics. How many > of your co-workers actively think about internationalization and > accessibility? No, you've missed the point AGAIN! It doesn't matter what the developers "think" about accessibility. It matters what they "DO" about it. Most people in YOUR organization don't consider accessibility because accessibility does not concern them . Just like people who dump toxic chemicals into your drinking water don't concern themselves when you get cancer. They don't care because they are unaffected. SELFISHNESS is the key word here! These people have 20/20 vision, perfect hearing, and all their extremities still attached. Sadly however they lack a brain that can comprehend even the most basic form of compassion for those who don't have these luxuries! If ANY of these selfish idiots was in a car accident and lost an arm and both eyes, i'd bet a million dollars that the next time they sit down to use a computer they will realize just how important accessibility is. I would bet that accessibility would become a major buzz word around your office then! > I'm guessing none, but maybe you're lucking and work in > a particularly enlightened team. I've perhaps worked closely with a > few hundred programmers in my career, and very few of them thought of > these subjects. In my experience it's just not something the > programmer in the trenches thinks about. That is the point I was > trying to make. Yes and you made your selfishness quite clear! Be careful my friend, because as Tyler found out, this mindset becomes a slippery slope *very* quickly! From orasnita at gmail.com Mon Jan 24 15:33:34 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Mon, 24 Jan 2011 22:33:34 +0200 Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> 7c$4275d90a$44222222222222<63eea$4d3cd2fd$4275d90a$14984@FUSE.NET> <69465430-08b3-4069-99c7-72f4d3034c66@s5g2000yqm.googlegroups.com> <705ad$4d3ce0fc$4275d90a$29144@FUSE.NET> <4D3DC313.8040905@tysdomain.com> Message-ID: From: "Littlefield, Tyler" > Hello, > > I have been on another list with Octavian, and he takes his > accessibility a bit to seriously. If things went his way, he wants laws > where -everything- has to be accessible, and it is illegal not to do so. Is the discrimination legal in your country? If you create a program only for a part of the population knowing very well that you do that, without having technical issues, (because as you know, there are very well known technical solutions for it), it means that you discriminate a part of the population. Of course, as I explained, if you want to create a drawing program or a video-editing application, there are technical issues that don't allow you to offer that program to everyone, so it is not your fault at all in that case. > As a sidenote, I would like to preface everything I'm going to say by > mentioning the fact that I have been using a screen reader for many > years, so I understand some of where he is coming from. > > I think my goal, (and I differ from Octavian here), is to try to find > fixes for things, rather than saying "this sucks, it does not work with > a reader, and thus it shouldn't be used). Having done a lot of > development work in the past, I can't say "hey you, I want you to make > this app accessible, and because you used TKInter it's not, so use > something else, but nothing that isn't accessible." Rather, I believe > those pushing accessibility should concentrate on the root cause; that > of fixing TKInter, and not forcing everyone else to use a different library. This is like saying that those who need a screen reader should better find a solution for their health problems and after they will find it, they won't need a screen reader. >From the accessibility perspective there are already accessible interfaces so that's solved and it just need to be used. Making Tkinter would be great, but it would not be a solution if it won't be used after it will be accessible. If Tk would be made accessible but Python would start including a QT GUI or another one that wouldn't be accessible and the programmers would start using that GUI, the result is that the apps won't be accessible. If there is a solution now for this problem, and not in a bad GUI lib that doesn't many features, but one which is very fast and full of widgets, then that solution should be promoted by Python. I don't say (as you pretend) that all the programmers should be forced to use it or at least to prefer it. I said that it should be promoted because it is the right tool. I think that the political corectness term was invented in USA... > I believe that the approach is the main key here, and I have had this > argument many times. If I wrote an app, and someone said something along > the lines of "you need to change a core library because it doesn't work > with this program," my first response would be who the hell are you to > say what I need to use? We need to take the approach of "This is what is > wrong, this is why, this is possibly how it could be fixed. Would you be > willing to do so?" With other words, you are very happy when you can't use a program because it is not accessible, thinking that as a programmer you won't be forced by someone else or laws to learn to use the right tool. Or you may be willing to change all the programs in the world which are not accessible because they use a bad GUI. > So, with all of this said, TKInter -is- unaccesssible for us. My > arguments have not been for or against one or the other in this thread, > but more to get RR to make a better point. Because eventually, WX would > benafit those using a screen reader a lot more than say, TKInter will. > That doesn't mean that I'm saying that we need to make it a part of the > stdlib as of yesterday, because segfaults from someone with 10+ years of > experience (multiple people, actually) says a lot, whether or not RR > wants to acknowledge said facts. Those segfaults would disappear much faster if WxPython would become more interesting and if it would become a part of Python distribution because there would be much more programmers interested about it and willing to solve its problems under some platforms. WxPython has some problems under some platforms used by a minority of users. Tkinter has some problems for another minority of users. The big picture is the worst thing possible and it is not that I can't see it, but I can't agree with it. The big picture is that very many people simply don't care and this is not something good. Octavian From joncle at googlemail.com Mon Jan 24 15:41:46 2011 From: joncle at googlemail.com (Jon Clements) Date: Mon, 24 Jan 2011 12:41:46 -0800 (PST) Subject: how to tell if cursor is sqlite.Cursor or psycopg2.Cursor References: <7f1931cd-a15b-44a9-8cf9-b0af0bdfec7d@d8g2000yqf.googlegroups.com> Message-ID: <7edfe2ce-5d8f-43b3-9eea-b8121012d309@v17g2000prc.googlegroups.com> On Jan 24, 7:44?pm, dmaziuk wrote: > Hi everyone, > > I've wrapper class around some sql statements and I'm trying to add a > method that does: > ? if my_cursor is a sqlite cursor, then run "select > last_insert_rowid()" > ? else if it's a psycopg2 cursor, then run "select > currval( 'my_sequence' )" > ? etc. > The best I can come up with is import both psycopg2 and sqlite and > then do > ?if isinstance( self._curs, sqlite.Cursor ) : ... > ?elif isinstance( self._curs, psycopg2._psycopg.cursor ) : ... > and I can't help thinking there has to be another way to find out what > kind of thing self._curs is. Is there a better way? > > TIA > Dima I'm not 100% sure but maybe look at SQLAlchemy (or other Python ORMs) as a wrapper. That *might* abstract the "last ID" across different DB's. And still enable direct SQL querying. Jon. From orasnita at gmail.com Mon Jan 24 15:45:13 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Mon, 24 Jan 2011 22:45:13 +0200 Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com>7c$4275d90a$44222222222222 <63eea$4d3cd2fd$4275d90a$14984@FUSE.NET><69465430-08b3-4069-99c7-72f4d3034c66@s5g2000yqm.googlegroups.com><705ad$4d3ce0fc$4275d90a$29144@FUSE.NET> <5f8c1256-f07c-43be-8307-d36991e9be24@m35g2000vbn.googlegroups.com> Message-ID: From: "rantingrick" > Obviously it > would be awesome, but I think Octavian is just focusing on himself, and > not the actual big picture here. Yes Octavian is the only disabled person in the world. What a selfish, selfish person he is. Shame on you Octavian, Shame on You! You just showed your true colors Tyler, very sad. :( I understand Tyler because I know some blind people. It is very frustrating to be able to think better than many other sighted people and to be able to do very many complex things, but to not be able to do very basic things while they can do them very easy. Because of this, many blind people try to show that they are like the sighted, that they can do everything, that they are independent, so they like to talk about the movies they watch, they like to have touch-pad mobile phones and so on, even though the accessibility of those gadgets is really low. I don't speak from the perspective of a programmer because a programmer, even a blind one, can create the program he wants, to be accessible of course, but I speak from the perspective of the users because they are not programmers, they can't do anything to improve the accessibility of the programs that other people can use very easy. And what's worst is that most of those inaccessible programs are not that way because the programmer that created them consciously chosen the GUI lib because of who know what specific reasons, competitive or of other kind. Most of the time the programmer uses the GUI lib that she/he knows better and think that would be easier to create the program with. Most of them don't even know about accessibility, there are very many programmers in some countries that don't even imagine that some people can use a computer with a screen reader. Octavian From python at mrabarnett.plus.com Mon Jan 24 15:46:09 2011 From: python at mrabarnett.plus.com (MRAB) Date: Mon, 24 Jan 2011 20:46:09 +0000 Subject: how to tell if cursor is sqlite.Cursor or psycopg2.Cursor In-Reply-To: <7f1931cd-a15b-44a9-8cf9-b0af0bdfec7d@d8g2000yqf.googlegroups.com> References: <7f1931cd-a15b-44a9-8cf9-b0af0bdfec7d@d8g2000yqf.googlegroups.com> Message-ID: <4D3DE511.7010206@mrabarnett.plus.com> On 24/01/2011 19:44, dmaziuk wrote: > Hi everyone, > > I've wrapper class around some sql statements and I'm trying to add a > method that does: > if my_cursor is a sqlite cursor, then run "select > last_insert_rowid()" > else if it's a psycopg2 cursor, then run "select > currval( 'my_sequence' )" > etc. > The best I can come up with is import both psycopg2 and sqlite and > then do > if isinstance( self._curs, sqlite.Cursor ) : ... > elif isinstance( self._curs, psycopg2._psycopg.cursor ) : ... > and I can't help thinking there has to be another way to find out what > kind of thing self._curs is. Is there a better way? > I quick hack might be to look at repr(my_cursor). For sqlite3 I get: '' From bryan.oakley at gmail.com Mon Jan 24 15:49:08 2011 From: bryan.oakley at gmail.com (Bryan) Date: Mon, 24 Jan 2011 12:49:08 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <100e192f-9a6c-4c3a-8092-a65cd04eef64@o14g2000yqe.googlegroups.com> <668d4047-58a8-4208-8bd0-92a7c7344d2f@o9g2000pre.googlegroups.com> <7228de23-5fb8-42bf-9916-b579d61583f9@f9g2000vbq.googlegroups.com> Message-ID: On Jan 24, 2:33?pm, rantingrick wrote: > > Yes and you made your selfishness quite clear! Be careful my friend, > because as Tyler found out, this mindset becomes a slippery slope > *very* quickly! I merely made the observation that most programmers don't think about these topics and it would be good to get some more enlightenment, you now you're accusing me of selfishness? That's an impressive mental leap, though I don't think you quite made it to the other side. Did you perhaps interpret my comment as "programmers SHOULDN'T think about..."? I'm not saying programmers shouldn't think about these things. On the contrary, all programmers _should_ think about them. They don't, at least in my experience. That's a problem, it needs to be fixed. If you think that's a mindset that's on a slippery slope, you're the only one. From orasnita at gmail.com Mon Jan 24 15:49:20 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Mon, 24 Jan 2011 22:49:20 +0200 Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com><63eea$4d3cd2fd$4275d90a$14984@FUSE.NET><69465430-08b3-4069-99c7-72f4d3034c66@s5g2000yqm.googlegroups.com><705ad$4d3ce0fc$4275d90a$29144@FUSE.NET> Message-ID: From: "Mark Roseman" > "Littlefield, Tyler" wrote: >> Rather, I believe >> those pushing accessibility should concentrate on the root cause; that >> of fixing TKInter, and not forcing everyone else to use a different library. > > > Here, here. From my queries to some of the Tcl/Tk folks, it seems that > while the knowledge and expertise is not present in the core developer > community, they would be more than happy to help people who do have some > knowledge in this area so that Tk could be made to be more accessible. > > Grand conspiracies aside, I think the development communities behind > most GUI toolkits would be very receptive to people who could help make > developing accessible applications with their toolkits feasible. > > (And if/when this does get done for Tk, I promise at least to make sure > that the tutorial at http:///www.tkdocs.com covers this topic). > > Mark It would be great if the Tk/Tkinter developers would be interested in making this GUI lib accessible. There are no many people that know about this thing, but there are standards like MSAA that can be followed by them if they really want to offer accessibility. I guess that if Tkinter would support MSAA (Microsoft Active Accessibility) in its Windows version, the screen readers would be able to offer support for Tk (or it might be offered by default... I don't know). Octavian From orasnita at gmail.com Mon Jan 24 15:53:57 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Mon, 24 Jan 2011 22:53:57 +0200 Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com><100e192f-9a6c-4c3a-8092-a65cd04eef64@o14g2000yqe.googlegroups.com> Message-ID: <42F739DFCE5E4A5F9C953F816A0C55FE@teddy> From: "Bryan" I wish I could respond to that, but I have no experience with screen readers. Are there any free ones, or ones with free trials, that I could try out? I'm not yet convinced it's any better or worse than wxPython since you're only a single datapoint, but of course it's possible. If you know of any free tools I can use to experiment, I'd appreciate you posting them in this newsgroup. Accessibility, like internationalization, is something few programmers spend much time thinking about. I can only imagine the frustration one must experience if all interactions had to be through a screen reader. Hi Bryan, (And thank you for your interest) The most used screen reader and the one that have the most features is JAWS that can be downloaded from: http://www.freedomscientific.com/downloads/jaws/jaws-downloads.asp You can use it for 40 minutes after which you need to restart the computer to be able to use it again. You can test that simple sample WxPython app and compare it with any Tk-based app. Please tell us what you find. Octavian From orasnita at gmail.com Mon Jan 24 15:58:31 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Mon, 24 Jan 2011 22:58:31 +0200 Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <100e192f-9a6c-4c3a-8092-a65cd04eef64@o14g2000yqe.googlegroups.com> <668d4047-58a8-4208-8bd0-92a7c7344d2f@o9g2000pre.googlegroups.com> <4D3DD223.4080602@mrabarnett.plus.com> Message-ID: <8D90F9A9A31F428E855A6787FDFDFC0C@teddy> From: "MRAB" > On 24/01/2011 18:05, rantingrick wrote: >> On Jan 24, 12:00 pm, Bryan wrote: >> >>> Accessibility, like internationalization, is something few programmers >>> spend much time thinking about. >> >> Thats another uninformed statement by you we can add to the mountains >> of useless cruft you have offered so far. Unicode IS >> internationalization and Guido thought it was SO important that >> Python3000 auto converts all strings to Unicode strings. Obviously he >> is moving us toward full Unicode only in the future (AS SHOULD ALL >> IMPLEMENTATIONS!). We need one and only one obvious way to do it. And >> Unicode is that way. >> > There's more to internationalization than just Unicode. There's the > ability to handle messages in various languages which have a different > syntax and grammar. > > There's an interesting Perl-oriented article on it here: > > http://search.cpan.org/dist/Locale-Maketext/lib/Locale/Maketext/TPJ13.pod#A_Localization_Horror_Story:_It_Could_Happen_To_You > -- Perl offers a great support for I18n/L10N including its native support for UTF-8, and I am glad that Python 3 will also have improvements for it. Just like the I18N, it would be a good idea if Python will also start to promote the accessibility, because just like the internationalization, it is targetted to make the programs accessible by as many users as possible. Octavian From orasnita at gmail.com Mon Jan 24 16:09:40 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Mon, 24 Jan 2011 23:09:40 +0200 Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com>7c$4275d90a$44222222222222 <63eea$4d3cd2fd$4275d90a$14984@FUSE.NET><69465430-08b3-4069-99c7-72f4d3034c66@s5g2000yqm.googlegroups.com><705ad$4d3ce0fc$4275d90a$29144@FUSE.NET><5f8c1256-f07c-43be-8307-d36991e9be24@m35g2000vbn.googlegroups.com> Message-ID: <4F28A96E8FD64E3CB793D5FFEEC748D5@teddy> From: "rantingrick" Tyler's argument, which lacked greatly in compassion for people with disabilities brought out my accusation. It was not an accusation meant to merely insult just to invoke a flame war; which is the definition of Godwins Law. It is a fact that Tyler displayed despicable intolerance for people who have disabilities and such a correlation to totalitarian regimes was not only the correct response but in fact the only response to such veiled hate speech. We cannot allow such displays to slip by unchallenged by this community. And hopefully Tyler will see the unjust position he has taken and beg for forgiveness. Tyler is not intolerant. He is a blind person. He is one that cares more to please the others that might help it more in its life than to advocate for the benefit of the entire world. Octavian From james at funkymonkeysoftware.com Mon Jan 24 16:15:23 2011 From: james at funkymonkeysoftware.com (James Ravenscroft) Date: Mon, 24 Jan 2011 21:15:23 +0000 Subject: List behaviours with Clustering Algorithm In-Reply-To: References: Message-ID: <4D3DEBEB.1020700@funkymonkeysoftware.com> Peter > > I can't run your code because you didn't make it standalone, Thanks for the heads up, I've made a simple version of the clusterer which you can view on pastebin: http://pastebin.com/7HmAkmfj If you have time to look through my code I would be very grateful! > > but in your case that is probably not enough. > > Try something along these lines: > > > > # untested > > while len(self.clusters) > 1: > > c = self.clusters.pop() > > # find closest index > > for i, c2 in enumerate(self.clusters): > > ... > > if ...: > > closest_index = i > > closest = self.clusters.pop(closest_index) > > tmp.append(c + closest) > > if self.clusters: > > tmp.append(self.clusters[0]) I had a go at implementing something along the lines above and I'm still getting very bizarre results. There does appear to be some sort of logic to it though, if you look at the graph chart, you can see that It seems to be doing the clustering right and then forgetting to remove the old groupings providing this "cloning" effect for some cluster groups. Chart: http://img826.imageshack.us/i/clusters.png/ Thanks, James -- James Ravenscroft Funky Monkey Software - Bespoke Web and Software Solutions http://www.funkymonkeysoftware.com/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From rantingrick at gmail.com Mon Jan 24 16:17:36 2011 From: rantingrick at gmail.com (rantingrick) Date: Mon, 24 Jan 2011 13:17:36 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <100e192f-9a6c-4c3a-8092-a65cd04eef64@o14g2000yqe.googlegroups.com> <668d4047-58a8-4208-8bd0-92a7c7344d2f@o9g2000pre.googlegroups.com> <7228de23-5fb8-42bf-9916-b579d61583f9@f9g2000vbq.googlegroups.com> Message-ID: On Jan 24, 2:49?pm, Bryan wrote: > On Jan 24, 2:33?pm, rantingrick wrote: > > > Yes and you made your selfishness quite clear! Be careful my friend, > > because as Tyler found out, this mindset becomes a slippery slope > > *very* quickly! > > I merely made the observation that most programmers don't think about > these topics and it would be good to get some more enlightenment, you > now you're accusing me of selfishness? If you are not part of the solution then you are part of the problem. I think you *do* want to help proliferate accessibility. However, you have not displayed the attitude that we need to win the fight. You see, selfishness is a natural human trait. We all harbor selfishness to some degree. Even myself! We cannot fully ever be free of this selfishness. However we can fight and suppress selfishness until it's ill effects have no "noticeable" effect. This is what i am speaking of when i say that you are part of the problem. You need to educate your co-workers about accessibility. You need to make them aware of their own selfish and erroneous ways. Then and only then shall *you* be part of the solution. But don't expect that they will just roll over! This will be an uphill battle so we must be persistent! They need to choose libraries that are supporting accessibility. Or at least choose a library that is *aware* of accessibility and is moving forward into full blown support of accessibility. A comment was made earlier by Mark Roseman about how he would document accessibly in Tkinter *if* someone else would bring Tk accessibility into being. This is just one more example of someone paying lip service to a problem without actually suppressing his selfishness and producing some action. Mark needs to sound the battle call at his site. He needs to send an email to the TclTk-dev team daily and ask how they are coming along with accessibility. Then he needs to post the response -- or lack there of-- on his site for all to see. He needs to change his attitude from passive to aggressive. Then and only then shall change come. Change happens only when people demand change. And sadly the power to change accessibility lies not in the hands of those directly affected but in the hands of those twice removed from the torments of accessibility. This is the same problem all GUI developers face with the multiplicity of GUI libraries. If we could get these selfish and moronic OS developers to agree on one GUI standard then our lives, and the lives of our users would be bliss. Then we could have universal accessibility, universal rich widget sets, universal cross platform- ability, universal speed, universal look and feel, etc, etc. From ethan at stoneleaf.us Mon Jan 24 16:23:51 2011 From: ethan at stoneleaf.us (Ethan Furman) Date: Mon, 24 Jan 2011 13:23:51 -0800 Subject: WxPython versus Tkinter. In-Reply-To: References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <033c3f90-03fb-4f65-bbae-bbc80a262685@l22g2000vbp.googlegroups.com> Message-ID: <4D3DEDE7.5020302@stoneleaf.us> On Sun, 23 Jan 2011 12:23:13 -0800, rantingrick wrote: > I am not > trying to create a working file browser so you can steal my code. 2011/1/24 rantingrick : > This thread has been an eye opener for myself [...] > we cannot even work together to get some simple code > debugged. Aha! So you want to steal our code to fix yours? Why am I not surprised? ~Ethan~ From nhodgson at bigpond.net.au Mon Jan 24 16:47:36 2011 From: nhodgson at bigpond.net.au (Neil Hodgson) Date: Tue, 25 Jan 2011 08:47:36 +1100 Subject: WxPython versus Tkinter. In-Reply-To: References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com><63eea$4d3cd2fd$4275d90a$14984@FUSE.NET><69465430-08b3-4069-99c7-72f4d3034c66@s5g2000yqm.googlegroups.com><705ad$4d3ce0fc$4275d90a$29144@FUSE.NET> Message-ID: <2sm%o.8695$gM3.6118@viwinnwfe01.internal.bigpond.com> Octavian Rasnita: > There are no many people that know about this thing, > but there are standards like MSAA that can be followed > by them if they really want to offer accessibility. I > guess that if Tkinter would support MSAA (Microsoft > Active Accessibility) in its Windows version, the screen > readers would be able to offer support for Tk (or it > might be offered by default... I don't know). MSAA was superseded by Microsoft UI Automation in 2005 which in turn was superseded by Windows Automation API in Windows 7. http://msdn.microsoft.com/en-us/library/dd561932(v=vs.85).aspx Making Tk as accessible as Windows or GTK+ would be a huge job. Neil From alan.isaac at gmail.com Mon Jan 24 16:51:20 2011 From: alan.isaac at gmail.com (Alan) Date: Mon, 24 Jan 2011 13:51:20 -0800 (PST) Subject: why are functions greater than numbers? Message-ID: <2773df41-2a43-46bc-b2bd-7cbdd91aff55@u18g2000prh.googlegroups.com> Why do function objects compare in this way to numbers? Thanks, Alan Isaac >>> def f(): return ... >>> f>5 True From tyler at tysdomain.com Mon Jan 24 16:53:50 2011 From: tyler at tysdomain.com (Littlefield, Tyler) Date: Mon, 24 Jan 2011 14:53:50 -0700 Subject: WxPython versus Tkinter. In-Reply-To: <4D3DD443.5070906@mrabarnett.plus.com> References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> 7c$4275d90a$44222222222222 <63eea$4d3cd2fd$4275d90a$14984@FUSE.NET> <69465430-08b3-4069-99c7-72f4d3034c66@s5g2000yqm.googlegroups.com> <705ad$4d3ce0fc$4275d90a$29144@FUSE.NET> <5f8c1256-f07c-43be-8307-d36991e9be24@m35g2000vbn.googlegroups.com> <4D3DD443.5070906@mrabarnett.plus.com> Message-ID: <4D3DF4EE.2020900@tysdomain.com> RR, you idiot. Did you -not- read that I was blind and using a screen reader? And wasn't it -you- yelling at someone about reading and comprehention? On 1/24/2011 12:34 PM, MRAB wrote: > On 24/01/2011 18:48, rantingrick wrote: >> On Jan 24, 12:21 pm, "Littlefield, Tyler" wrote: >> >> [...snip: good discussion...] >> >>> Rather, I believe >>> those pushing accessibility should concentrate on the root cause; that >>> of fixing TKInter, and not forcing everyone else to use a different >>> library. >> >> Now you go too far! >> >> And this is an ironic position from someone who supports the stdlib >> GUI that IS forced on us by default. Sure you can choose a different >> library, but in the case of a user (and accessibility is a big USER >> concern when that user is handicapped!) the library is already chosen >> (Tkinter:which does not support accessibility) by the developer . I >> can also argue that Tkinter's inclusion in the stdlib is proliferating >> non-compliance with accessibility. I'll bet you would not park in a >> handicap spot however you support a GUI library that ignores handicap >> people? IRONIC! >> >>> I believe that the approach is the main key here, and I have had this >>> argument many times. If I wrote an app, and someone said something >>> along >>> the lines of "you need to change a core library because it doesn't work >>> with this program," my first response would be who the hell are you to >>> say what I need to use? >> >> Well these people you are chastising are disabled people. Who the hell >> are YOU to be high and mighty about it? I guess these "disabled" >> people get what they deserve huh! Maybe we should just do the world a >> favor and exterminate them like the Nazis? That way we don't have to >> cater to their selfish needs! >> > [snip] > I'd like to invoke Godwin's law at this point. -- Thanks, Ty From rantingrick at gmail.com Mon Jan 24 16:54:59 2011 From: rantingrick at gmail.com (rantingrick) Date: Mon, 24 Jan 2011 13:54:59 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com><63eea$4d3cd2fd$4275d90a$14984@FUSE.NET><69465430-08b3-4069-99c7-72f4d3034c66@s5g2000yqm.googlegroups.com><705ad$4d3ce0fc$4275d90a$29144@FUSE.NET> <2sm%o.8695$gM3.6118@viwinnwfe01.internal.bigpond.com> Message-ID: <0c3c61b0-d056-4757-b7e4-fecdf9a6e217@fm22g2000vbb.googlegroups.com> On Jan 24, 3:47?pm, Neil Hodgson wrote: > ? ?Making Tk as accessible as Windows or GTK+ would be a huge job. Not if we used the underlying MS library! Windows has such a rich library why not use it? Why must we constantly re-invent the wheel? Windowing GUIs are not recent technology. These things have been around for decades. When are we going to agree on a damn standard. Is it not far passed time to drop the selfishness and work together? I said it before... "Multiplicity is very important in emerging systems however at some point we must reign in the madness else entropy will destroy the entire system." Selfishness = Multiplicity = Entropy = Shock = Stagnation = None From andrea.gavana at gmail.com Mon Jan 24 16:58:36 2011 From: andrea.gavana at gmail.com (Infinity77) Date: Mon, 24 Jan 2011 13:58:36 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <3a96fee1-995f-49f7-a967-f125cc3f1cdc@v26g2000yqf.googlegroups.com> Message-ID: <023e19ed-69d1-4155-a114-0d00c227b8f6@u18g2000prh.googlegroups.com> On Jan 24, 9:57?pm, Robin Dunn wrote: > On Jan 23, 4:31?pm, "Martin v. Loewis" wrote: > > > > WxPython Challenge 1 code updated... > > > > ?* Fixed tab traveral > > > ?* Removed hand-holding code > > > ?* Removed some cruft > > > > ?https://sites.google.com/site/thefutureofpython/home/code-challenges > > > > Good luck! > > > Still crashes the interpreter. > > The crash on Linux is due to SetSingleStyle removing the all items and > the columns when the mode of the listctrl is changed, and then the > code continues on with the assumption that the columns still exist and > the crash happens when an item is added to column zero and there is no > column zero. ?Apparently the native widget on Windows doesn't have > that limitation. ?BTW, if the linux wx packages had the runtime > assertions turned on then you would have seen a Python exception with > some clues that would probably help solve the problem. I don't know > about others but on Ubuntu you can install the *wx*-dbg packages to > get a version with the assertions turned on. ?Hopefully that will > change starting with 2.9 as wx now turns on the assertions by default > for builds configured normally, and the wx-dev team recommends that > the assertions are not turned off, except in rare circumstances. > > BTW, on behalf of the wxPython community I'd like to apologize for the > havoc caused by the flaming troll escaping from his cage. ?In general > wxPython users are much less militant and zealotty and honor > everyone's freedom to choose which ever UI tool kit works the best for > their own needs. I have been involved in the wxPython development for many years (mostly on implementation of custom widgets, in the AGW library), and I share Robin's concerns about this kind of "publicity" given to wxPython. Python comes with TK as a "battery included" UI toolkit. I'm perfectly fine with this, as I am not going to use it anyway. Whether in the future TK will be replaced by PyGTK, PyQT, PySide, etc... in the standard library, it won't make any difference to those aficionados developers who use wxPython. We'll still download the wxPython binaries/sources/whatever and use it to develop our own GUIs. There is simply no match between wxPython and X (substitute X with whatever GUI toolkit you like). This is obviously my very biased opinion. It is very unfortunate that this topic "wxPython vs. Tkinter" has drifted to another flame war, as there is really no point in this kind of discussion. As a general rule, a GUI-newbie should try all the GUI toolkits out there and settle with the one which looks easier/nicer/ more convenient/more feature rich. As usual, it is a matter of personal taste. For those experiencing with wxPython for the first time, I highly suggest you to join our wxPython mailing list: you'll find a friendly place, with many experienced developers answering questions and a BDFL who's there (almost) every day offering solutions for the toughest problems. Andrea. From tyler at tysdomain.com Mon Jan 24 17:02:43 2011 From: tyler at tysdomain.com (Littlefield, Tyler) Date: Mon, 24 Jan 2011 15:02:43 -0700 Subject: WxPython versus Tkinter. In-Reply-To: References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com><63eea$4d3cd2fd$4275d90a$14984@FUSE.NET><69465430-08b3-4069-99c7-72f4d3034c66@s5g2000yqm.googlegroups.com><705ad$4d3ce0fc$4275d90a$29144@FUSE.NET> Message-ID: <4D3DF703.7080506@tysdomain.com> >It would be great if the Tk/Tkinter developers would be interested in making >this GUI lib accessible. They're not going to do it without knowing what makes accessible accessible, and why it needs to be so. So, rather than tell the world about how -some- blind people want to be like sighted people (we call that independence in my world), why not go help out? It's bad, you want a switch, and you've already said that they're using a lib that is unaccessible. So fix the lib, and you will have fixed tons of programs without fixing the program. That is all I ment by finding the root of the problem, not "everyone with readers should fix their health problems." You take my words, blow them out of perportion and at the end of the day, you are still sitting here complaining about the lack of accessibility, rather than doing something about it. This is awesome. We for sure need more complainers and less people to do what the complainers are complaining about! On 1/24/2011 1:49 PM, Octavian Rasnita wrote: > From: "Mark Roseman" >> "Littlefield, Tyler" wrote: >>> Rather, I believe >>> those pushing accessibility should concentrate on the root cause; that >>> of fixing TKInter, and not forcing everyone else to use a different library. >> >> Here, here. From my queries to some of the Tcl/Tk folks, it seems that >> while the knowledge and expertise is not present in the core developer >> community, they would be more than happy to help people who do have some >> knowledge in this area so that Tk could be made to be more accessible. >> >> Grand conspiracies aside, I think the development communities behind >> most GUI toolkits would be very receptive to people who could help make >> developing accessible applications with their toolkits feasible. >> >> (And if/when this does get done for Tk, I promise at least to make sure >> that the tutorial at http:///www.tkdocs.com covers this topic). >> >> Mark > > It would be great if the Tk/Tkinter developers would be interested in making this GUI lib accessible. > There are no many people that know about this thing, but there are standards like MSAA that can be followed by them if they really want to offer accessibility. > I guess that if Tkinter would support MSAA (Microsoft Active Accessibility) in its Windows version, the screen readers would be able to offer support for Tk (or it might be offered by default... I don't know). > > Octavian > -- Thanks, Ty From nhodgson at bigpond.net.au Mon Jan 24 17:08:10 2011 From: nhodgson at bigpond.net.au (Neil Hodgson) Date: Tue, 25 Jan 2011 09:08:10 +1100 Subject: WxPython versus Tkinter. In-Reply-To: <0c3c61b0-d056-4757-b7e4-fecdf9a6e217@fm22g2000vbb.googlegroups.com> References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com><63eea$4d3cd2fd$4275d90a$14984@FUSE.NET><69465430-08b3-4069-99c7-72f4d3034c66@s5g2000yqm.googlegroups.com><705ad$4d3ce0fc$4275d90a$29144@FUSE.NET> <2sm%o.8695$gM3.6118@viwinnwfe01.internal.bigpond.com> <0c3c61b0-d056-4757-b7e4-fecdf9a6e217@fm22g2000vbb.googlegroups.com> Message-ID: rantingrick: > Not if we used the underlying MS library! Windows has such a rich > library why not use it? Why must we constantly re-invent the wheel? It is up to the GUI toolkit or application to implement the interfaces defined by Windows Automation API on every object it displays. The standard Windows controls have this implemented. Tk does not use these controls so would have to do all that work again. Neil From rantingrick at gmail.com Mon Jan 24 17:16:53 2011 From: rantingrick at gmail.com (rantingrick) Date: Mon, 24 Jan 2011 14:16:53 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <3a96fee1-995f-49f7-a967-f125cc3f1cdc@v26g2000yqf.googlegroups.com> <023e19ed-69d1-4155-a114-0d00c227b8f6@u18g2000prh.googlegroups.com> Message-ID: <06dd3a10-03a4-4d43-a10e-cadf5105a7c4@t23g2000vby.googlegroups.com> On Jan 24, 3:58?pm, Infinity77 wrote: > I have been involved in the wxPython development for many years > (mostly on implementation of custom widgets, in the AGW library), and > I share Robin's concerns about this kind of "publicity" given to > wxPython. Who cares what you think about wxPython's publicity. A module was created and put on public display and can be ridiculed or supported by anyone who so desires. > Python comes with TK as a "battery included" UI toolkit. I'm perfectly > fine with this, as I am not going to use it anyway. Whether in the > future TK will be replaced by PyGTK, PyQT, PySide, etc... in the > standard library, it won't make any difference to those aficionados > developers who use wxPython. We'll still download the wxPython > binaries/sources/whatever and use it to develop our own GUIs. Good, and again i cannot stress how little we care about your opinion. Why do we not care. Well because you are looking at this from a wxPython perspective. You are being selfish. We are considering this from a global Python perspective. What is good for Python may not be good for you, in any event, it is for us to decide. You can join our discussion when your perspective changes from "me" to "us". And the "us" is the Python langauge NOT wxPython. > It is very unfortunate that this topic "wxPython vs. Tkinter" has > drifted to another flame war, There is no flame war here > as there is really no point in this kind > of discussion. Says you. but who are you to say what is important to us. Go back to wxPython. > As a general rule, a GUI-newbie should try all the GUI > toolkits out there and settle with the one which looks easier/nicer/ > more convenient/more feature rich. As usual, it is a matter of > personal taste. And i agree. I think any sane person could agree also. However you miss the point of this conversation. We are looking at Python from a global perspective. You are limited in your views, and obviously very biased. And i know the real reason you and Robin do not want wxPython in the stdlib. Because you do not want to lose your selfish status within the wxPython community. When wxPython becomes a stdlib module then you will answer directly to Guido and Python-dev. You are not fooling anyone with this grandstanding. Selfishness = Multiplicity = Entropy = Shock = Stagnation = None From tyler at tysdomain.com Mon Jan 24 17:19:03 2011 From: tyler at tysdomain.com (Littlefield, Tyler) Date: Mon, 24 Jan 2011 15:19:03 -0700 Subject: WxPython versus Tkinter. In-Reply-To: References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com>7c$4275d90a$44222222222222 <63eea$4d3cd2fd$4275d90a$14984@FUSE.NET><69465430-08b3-4069-99c7-72f4d3034c66@s5g2000yqm.googlegroups.com><705ad$4d3ce0fc$4275d90a$29144@FUSE.NET> <5f8c1256-f07c-43be-8307-d36991e9be24@m35g2000vbn.googlegroups.com> Message-ID: <4D3DFAD7.40902@tysdomain.com> >Because of this, many blind people try to show that they are like the sighted, that they can do everything, that they are >independent, so they like to >talk about the movies they watch, they like to have touch-pad mobile phones and so on, even though the accessibility of >those gadgets is really low. While I am getting off topic here, I just had to comment... Yes, I do talk about "watching" tv. Not having working eyeballs doesn't limit me from using a word that people with common sense can just equate to listening to tv. And neither does not having working eyeballs limit me from -listening- to tv, which is what I and other blind people that want to "watch" tv do. And guess what? I can use a phone with a touch screen. It's called an IPhone, and it's got a screen reader built in. Nifty, huh? It just helps me in my goal to be just like sighted people, blame Apple for making a touch screen accessible. I say this all because I want to make a point. I don't expect the world to revolve around what is and isn't accessible. While laws do exist, if I ran around quoting the ADA (Americans with Disabilities Act) at everyone who didn't make things accessible (whether on the computer, at school, at a store), I'd just be wasting time. Rather I like to blend in, be independant and adapt things. Now, since i am a programmer this means that I am able to do a lot more in the form of adaptation on the computer, and this is my goal; if something is broke, fix the root or work with the developer. Don't just whine about it not being accessible. It will get you nowhere, and it's people like Octavian I dread having had people meat before because by golly, -everything- better be accessible. So, call me a Nazi or whatever, that's just how I feel. The world doesn't come on a silver platter, and so if Octavian, or I, or anyone else wants any sort of changes done (as in the changes to TkInter), work needs to go into helping these changes come about. Making a library part of the STDLib and then worrying about the fact that it segfaults later is foolish, especially if you are going to do it just for accessibility. And regardless of whether RR gets his deepest wish and it is made part of the STDLib, people will still use TKInter. What then, for those with readers? Should we just abolish TKInter altogether? On 1/24/2011 1:45 PM, Octavian Rasnita wrote: > From: "rantingrick" >> Obviously it >> would be awesome, but I think Octavian is just focusing on himself, and >> not the actual big picture here. > Yes Octavian is the only disabled person in the world. What > a selfish, selfish person he is. Shame on you Octavian, Shame on You! > > > You just showed your true colors Tyler, very sad. :( > > > I understand Tyler because I know some blind people. > It is very frustrating to be able to think better than many other sighted people and to be able to do very many complex things, but to not be able to do very basic things while they can do them very easy. > Because of this, many blind people try to show that they are like the sighted, that they can do everything, that they are independent, so they like to talk about the movies they watch, they like to have touch-pad mobile phones and so on, even though the accessibility of those gadgets is really low. > > I don't speak from the perspective of a programmer because a programmer, even a blind one, can create the program he wants, to be accessible of course, but I speak from the perspective of the users because they are not programmers, they can't do anything to improve the accessibility of the programs that other people can use very easy. > > And what's worst is that most of those inaccessible programs are not that way because the programmer that created them consciously chosen the GUI lib because of who know what specific reasons, competitive or of other kind. Most of the time the programmer uses the GUI lib that she/he knows better and think that would be easier to create the program with. Most of them don't even know about accessibility, there are very many programmers in some countries that don't even imagine that some people can use a computer with a screen reader. > Octavian > -- Thanks, Ty From mgroth86 at gmail.com Mon Jan 24 17:25:09 2011 From: mgroth86 at gmail.com (Matthew Roth) Date: Mon, 24 Jan 2011 14:25:09 -0800 (PST) Subject: trouble installing MySQLdb (cygwin) + Bonus question Message-ID: Hi, I'm a python newbie. By newbie I mean two days ago. It was suggested to me that I work with python. Unfortunately at work I must run this on a windows machiene. However, I am having difficultly installing MySQLdb. First is it even possible under my current environment? I am using python(2.6.5) through cygwin, and have mySQL(Ver 14.14 Distrib 5.5.8 for Win32) installed in windows 7 which mysql returns: /cygdrive/c/Program Files/MySQL/MySQL Server 5.5/bin/mysql when I run python setup.py build it returns: -- $ python setup.py build /bin/sh: mysql_config: command not found Traceback (most recent call last): File "setup.py", line 15, in metadata, options = get_config() File "/home/Matt/MySQL-python-1.2.3/setup_posix.py", line 43, in get_config libs = mysql_config("libs_r") File "/home/Matt/MySQL-python-1.2.3/setup_posix.py", line 24, in mysql_config raise EnvironmentError("%s not found" % (mysql_config.path,)) EnvironmentError: mysql_config not found -- I've explored various avenues all day to no avail. Can anyone offer a solution or a direction to work towards. One avenue was ignorning the check for posix, and having it run setup_windows, but this just brings in problems with _winreg(?) seeing how I have a posix version of python through cygwin. Lastly, for the bonus question. Why MySQLdb why not something like this: -- import os cmd = 'mysql -uroot -pxxx db -e "SELECT * FROM tblxxx;"' os.system(cmd) -- why is this a poor idea? Best, Matt From rantingrick at gmail.com Mon Jan 24 17:30:38 2011 From: rantingrick at gmail.com (rantingrick) Date: Mon, 24 Jan 2011 14:30:38 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> 7c$4275d90a$44222222222222 <63eea$4d3cd2fd$4275d90a$14984@FUSE.NET> <69465430-08b3-4069-99c7-72f4d3034c66@s5g2000yqm.googlegroups.com> <705ad$4d3ce0fc$4275d90a$29144@FUSE.NET> <5f8c1256-f07c-43be-8307-d36991e9be24@m35g2000vbn.googlegroups.com> <4D3DD443.5070906@mrabarnett.plus.com> Message-ID: On Jan 24, 3:53?pm, "Littlefield, Tyler" wrote: > RR, you idiot. Did you -not- read that I was blind and using a screen > reader? And wasn't it -you- yelling at someone about reading and > comprehention? > On 1/24/2011 12:34 PM, MRAB wrote: Are you telling me that you are blind? You better not be lying about this Tyler because the only thing worse than an compassionate person is who impersonates a blind person for sake of winning an argument. Now, if you really are blind then why the heck would you be supporting Tkinter? Tkinter has no support for accessibility -- as Octavian pointed out. However, you seem to want to keep Tkinter at all costs. Why? And furthermore why are you so rabidly resistive to wxPython? From benjamin.kaplan at case.edu Mon Jan 24 17:36:44 2011 From: benjamin.kaplan at case.edu (Benjamin Kaplan) Date: Mon, 24 Jan 2011 17:36:44 -0500 Subject: why are functions greater than numbers? In-Reply-To: <2773df41-2a43-46bc-b2bd-7cbdd91aff55@u18g2000prh.googlegroups.com> References: <2773df41-2a43-46bc-b2bd-7cbdd91aff55@u18g2000prh.googlegroups.com> Message-ID: On Jan 24, 2011 5:31 PM, "Alan" wrote: > > Why do function objects compare in this way to numbers? > Thanks, > Alan Isaac > > > >>> def f(): return > ... > >>> f>5 > True > Python 2 returned an arbitrary but consistent ordering for almost all comparisons, just in case you were doing something weird like sorting a list with mixed types. Python 3 will throw an exception if you try doing something silly like compare a function to a number. -------------- next part -------------- An HTML attachment was scrubbed... URL: From ian.g.kelly at gmail.com Mon Jan 24 17:39:40 2011 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Mon, 24 Jan 2011 15:39:40 -0700 Subject: why are functions greater than numbers? In-Reply-To: <2773df41-2a43-46bc-b2bd-7cbdd91aff55@u18g2000prh.googlegroups.com> References: <2773df41-2a43-46bc-b2bd-7cbdd91aff55@u18g2000prh.googlegroups.com> Message-ID: On Mon, Jan 24, 2011 at 2:51 PM, Alan wrote: > Why do function objects compare in this way to numbers? > Thanks, > Alan Isaac > > >>>> def f(): return > ... >>>> f>5 > True http://docs.python.org/library/stdtypes.html#comparisons Python 3 fixes this particular wart. From drsalists at gmail.com Mon Jan 24 17:40:45 2011 From: drsalists at gmail.com (Dan Stromberg) Date: Mon, 24 Jan 2011 14:40:45 -0800 Subject: why are functions greater than numbers? In-Reply-To: <2773df41-2a43-46bc-b2bd-7cbdd91aff55@u18g2000prh.googlegroups.com> References: <2773df41-2a43-46bc-b2bd-7cbdd91aff55@u18g2000prh.googlegroups.com> Message-ID: On Mon, Jan 24, 2011 at 1:51 PM, Alan wrote: > Why do function objects compare in this way to numbers? > Thanks, > Alan Isaac > > >>>> def f(): return > ... >>>> f>5 > True > > -- > http://mail.python.org/mailman/listinfo/python-list > They shouldn't, but did in 2.x, and no longer do in 3.x: $ /usr/local/cpython-3.1/bin/python3 cmd started 2011 Mon Jan 24 02:39:50 PM Python 3.1.2 (r312:79147, Aug 18 2010, 18:21:44) [GCC 4.4.3] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> def f(): ... return 'abc' ... >>> f > 5 Traceback (most recent call last): File "", line 1, in TypeError: unorderable types: function() > int() >>> From rantingrick at gmail.com Mon Jan 24 17:41:03 2011 From: rantingrick at gmail.com (rantingrick) Date: Mon, 24 Jan 2011 14:41:03 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com>7c$4275d90a$44222222222222 <63eea$4d3cd2fd$4275d90a$14984@FUSE.NET><69465430-08b3-4069-99c7-72f4d3034c66@s5g2000yqm.googlegroups.com><705ad$4d3ce0fc$4275d90a$29144@FUSE.NET> <5f8c1256-f07c-43be-8307-d36991e9be24@m35g2000vbn.googlegroups.com> Message-ID: On Jan 24, 4:19?pm, "Littlefield, Tyler" wrote: > I say this all because I want to make a point. I don't expect the world > to revolve around what is and isn't accessible. While laws do exist, if > I ran around quoting the ADA (Americans with Disabilities Act) at > everyone who didn't make things accessible (whether on the computer, at > school, at a store), I'd just be wasting time. I disagree, you would be educating people and you would be suppressing selfishness. > Rather I like to blend > in, be independant and adapt things. Now, since i am a programmer this > means that I am able to do a lot more in the form of adaptation on the > computer, and this is my goal; if something is broke, fix the root or > work with the developer. Have you tried to "fix" Tkinters non-existent accessibility? Have you campaigned for change? Have you written any code? Just FYI: Tkinter has been around for 20 plus years! > Don't just whine about it not being accessible. > It will get you nowhere, and it's people like Octavian I dread having > had people meat before because by golly, -everything- better be accessible. You know Tyler for someone that depends on accessibility as much as you you sure are a supporter of non-compliance. I think you are lying about being blind. And if you are, i am disgusted. > So, call me a Nazi or whatever, that's just how I feel. The world > doesn't come on a silver platter, and so if Octavian, or I, or anyone > else wants any sort of changes done (as in the changes to TkInter), work > needs to go into helping these changes come about. Yes and making an argument is part of that work. Good arguments change minds. > Making a library part > of the STDLib and then worrying about the fact that it segfaults later > is foolish, Of course it's foolish to do that. No one is suggesting that we throw wxPython in the stdlib as is. We know some work needs to be done. Heck maybe an abstraction API needs to be written. Don't be so theatrical Tyler, it wins you no points. > especially if you are going to do it just for accessibility. We are not doing it JUST for accessibility! Accessibility is just one of many reasons. The most important reason is to keep Python relevant in the 21st century. > And regardless of whether RR gets his deepest wish and it is made part > of the STDLib, people will still use TKInter. Yes, i am not trying to destroy Tkinter. I am trying to tell you that Tkinter is dead weight for Python. > What then, for those with > readers? Should we just abolish TKInter altogether? > On 1/24/2011 1:45 PM, Octavian Rasnita wrote: Well if i were a blind person i would use the most accessible GUI available. From python at mrabarnett.plus.com Mon Jan 24 17:56:48 2011 From: python at mrabarnett.plus.com (MRAB) Date: Mon, 24 Jan 2011 22:56:48 +0000 Subject: why are functions greater than numbers? In-Reply-To: <2773df41-2a43-46bc-b2bd-7cbdd91aff55@u18g2000prh.googlegroups.com> References: <2773df41-2a43-46bc-b2bd-7cbdd91aff55@u18g2000prh.googlegroups.com> Message-ID: <4D3E03B0.8080104@mrabarnett.plus.com> On 24/01/2011 21:51, Alan wrote: > Why do function objects compare in this way to numbers? > Thanks, > Alan Isaac > > >>>> def f(): return > ... >>>> f>5 > True > In Python 2 any object can be compared in this way to any other. The result is arbitrary but consistent. In Python 3 that has changed because in practice it's more trouble than it's worth: >>> def f(): return >>> f>5 Traceback (most recent call last): File "", line 1, in f>5 TypeError: unorderable types: function() > int() It's usually a good sign that there's a bug somewhere. From bryan.oakley at gmail.com Mon Jan 24 17:57:38 2011 From: bryan.oakley at gmail.com (Bryan) Date: Mon, 24 Jan 2011 14:57:38 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <3a96fee1-995f-49f7-a967-f125cc3f1cdc@v26g2000yqf.googlegroups.com> <023e19ed-69d1-4155-a114-0d00c227b8f6@u18g2000prh.googlegroups.com> <06dd3a10-03a4-4d43-a10e-cadf5105a7c4@t23g2000vby.googlegroups.com> Message-ID: <62841207-105b-4d47-8e64-574e03180c41@15g2000vbz.googlegroups.com> On Jan 24, 4:16?pm, rantingrick wrote: > ... > Good, and again i cannot stress how little we care about your opinion. You keep using the word "we". I do not think it means what you think it means. From steve+comp.lang.python at pearwood.info Mon Jan 24 18:04:03 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 24 Jan 2011 23:04:03 GMT Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <3a96fee1-995f-49f7-a967-f125cc3f1cdc@v26g2000yqf.googlegroups.com> Message-ID: <4d3e0563$0$29983$c3e8da3$5496439d@news.astraweb.com> On Mon, 24 Jan 2011 12:24:24 -0800, Robin Dunn wrote: > On Jan 24, 12:03?pm, rantingrick wrote: >> On Jan 24, 1:57?pm, Robin Dunn wrote: > >> > BTW, on behalf of the wxPython community I'd like to apologize for >> > the havoc caused by the flaming troll escaping from his cage. ?In >> > general wxPython users are much less militant and zealotty and honor >> > everyone's freedom to choose which ever UI tool kit works the best >> > for their own needs. >> >> Well we forgive Byran, but we will not forget! :) > > For the record, that is not who I was referring to. I don't believe that anyone in their right mind could have imagined even for a second that you were referring to Bryan. -- Steven From tjreedy at udel.edu Mon Jan 24 18:13:45 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Mon, 24 Jan 2011 18:13:45 -0500 Subject: why are functions greater than numbers? In-Reply-To: <2773df41-2a43-46bc-b2bd-7cbdd91aff55@u18g2000prh.googlegroups.com> References: <2773df41-2a43-46bc-b2bd-7cbdd91aff55@u18g2000prh.googlegroups.com> Message-ID: On 1/24/2011 4:51 PM, Alan wrote: > Why do function objects compare in this way to numbers? > Thanks, > Alan Isaac > > >>>> def f(): return > ... >>>> f>5 > True In 3.x >>> def f(): pass >>> f > 5 Traceback (most recent call last): File "", line 1, in f > 5 TypeError: unorderable types: function() > int() There is a historical explanation in many past posts and probably in the FAQ. -- Terry Jan Reedy From emile at fenx.com Mon Jan 24 18:17:47 2011 From: emile at fenx.com (Emile van Sebille) Date: Mon, 24 Jan 2011 15:17:47 -0800 Subject: why are functions greater than numbers? In-Reply-To: <2773df41-2a43-46bc-b2bd-7cbdd91aff55@u18g2000prh.googlegroups.com> References: <2773df41-2a43-46bc-b2bd-7cbdd91aff55@u18g2000prh.googlegroups.com> Message-ID: On 1/24/2011 1:51 PM Alan said... > Why do function objects compare in this way to numbers? To provide ordering capabilities. IIRC, comparisons of differing types are arbitrary but consistent. Emile > Thanks, > Alan Isaac > > >>>> def f(): return > ... >>>> f>5 > True > From steve+comp.lang.python at pearwood.info Mon Jan 24 18:23:54 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 24 Jan 2011 23:23:54 GMT Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <70498$4d3cb87c$4275d90a$4428@FUSE.NET> <46c407b5-9bfe-406a-a2fe-c63caa771bf3@f2g2000vby.googlegroups.com> <05fd32ee-e542-4622-afa8-a7cf4549df45@k42g2000yqa.googlegroups.com> <709769f9-f99a-46c8-bcc1-7a03adf303c6@v17g2000vbo.googlegroups.com> Message-ID: <4d3e0a0a$0$29983$c3e8da3$5496439d@news.astraweb.com> On Mon, 24 Jan 2011 09:17:01 -0800, rantingrick wrote: > I was > being a closed minded idiot at the time. I have since evolved. "Was"? It's been fun (for some definition of fun) watching your grandstanding, your haranguing the community into doing things your way, your insulting the blind for being insufficiently demanding of screen-reader support, and generally bullying everyone here. Unfortunately I've wasted far too much time reading your theatrics. It's time for another six months in the kill-file, I think. -- Steven From dmaziuk at bmrb.wisc.edu Mon Jan 24 18:25:01 2011 From: dmaziuk at bmrb.wisc.edu (dmaziuk) Date: Mon, 24 Jan 2011 15:25:01 -0800 (PST) Subject: how to tell if cursor is sqlite.Cursor or psycopg2.Cursor In-Reply-To: Message-ID: For psycopg2: '' (of course, this could also be due to RHEL5's ancient python). Dima From dmaziuk at bmrb.wisc.edu Mon Jan 24 18:25:01 2011 From: dmaziuk at bmrb.wisc.edu (dmaziuk) Date: Mon, 24 Jan 2011 15:25:01 -0800 (PST) Subject: how to tell if cursor is sqlite.Cursor or psycopg2.Cursor In-Reply-To: Message-ID: For psycopg2: '' (of course, this could also be due to RHEL5's ancient python). Dima From invalid at invalid.invalid Mon Jan 24 18:31:50 2011 From: invalid at invalid.invalid (Grant Edwards) Date: Mon, 24 Jan 2011 23:31:50 +0000 (UTC) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <70498$4d3cb87c$4275d90a$4428@FUSE.NET> <46c407b5-9bfe-406a-a2fe-c63caa771bf3@f2g2000vby.googlegroups.com> <05fd32ee-e542-4622-afa8-a7cf4549df45@k42g2000yqa.googlegroups.com> <709769f9-f99a-46c8-bcc1-7a03adf303c6@v17g2000vbo.googlegroups.com> <4d3e0a0a$0$29983$c3e8da3$5496439d@news.astraweb.com> Message-ID: On 2011-01-24, Steven D'Aprano wrote: > On Mon, 24 Jan 2011 09:17:01 -0800, rantingrick wrote: > >> I was being a closed minded idiot at the time. I have since evolved. > > "Was"? > > It's been fun (for some definition of fun) watching your > grandstanding, your haranguing the community into doing things your > way, your insulting the blind for being insufficiently demanding of > screen-reader support, and generally bullying everyone here. > Unfortunately I've wasted far too much time reading your theatrics. Unfortunately, some of us have been guilty of poking him with a stick just to watch him jump and yell. > It's time for another six months in the kill-file, I think. That doesn't really help much. RR has been in my killfile since before his first posting. But, thanks to people who quote his rantings in their entirety, I think I've seen pretty much all of them. -- Grant Edwards grant.b.edwards Yow! FROZEN ENTREES may at be flung by members of gmail.com opposing SWANSON SECTS ... From rantingrick at gmail.com Mon Jan 24 19:07:30 2011 From: rantingrick at gmail.com (rantingrick) Date: Mon, 24 Jan 2011 16:07:30 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <70498$4d3cb87c$4275d90a$4428@FUSE.NET> <46c407b5-9bfe-406a-a2fe-c63caa771bf3@f2g2000vby.googlegroups.com> <05fd32ee-e542-4622-afa8-a7cf4549df45@k42g2000yqa.googlegroups.com> <709769f9-f99a-46c8-bcc1-7a03adf303c6@v17g2000vbo.googlegroups.com> <4d3e0a0a$0$29983$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4829dc4d-be50-417b-b292-bea118472c0c@k13g2000vbq.googlegroups.com> On Jan 24, 5:31?pm, Grant Edwards wrote: > On 2011-01-24, Steven D'Aprano wrote: > > > On Mon, 24 Jan 2011 09:17:01 -0800, rantingrick wrote: > > >> I was being a closed minded idiot at the time. I have since evolved. > > > "Was"? > [...snip: Steven Trolling...] > > Unfortunately I've wasted far too much time reading your theatrics. > > Unfortunately, some of us have been guilty of poking him with a stick > just to watch him jump and yell. Every one of my threads (or threads i replied to) Steven has trolled them all. He never engages me in direct battle because he lacks the mental prowess i possess. He fears me and it shows. He fears me because i have a vision and he has none. He fears me because HE fears change. Should i post links to all the threads you have trolled up Steven as evidence of your trollish behavior? You never had the balls to engage me and you never will! Sadly you are one of the most knowledgeable within this group yet you spend 99% of your time trolling for your own self gratification. Why have you not offered any opinions on Wx versus Tkinter? Why have you not offered any code? BECAUSE YOU ARE A TROLL! Plain and simple. > > It's time for another six months in the kill-file, I think. Good riddance! Make it a year, ten years, i don't care! > That doesn't really help much. ?RR has been in my killfile since > before his first posting. But, thanks to people who quote his rantings > in their entirety, I think I've seen pretty much all of them. Well kill file D'Aprano and just shrink your listener even more. The funny thing about selfishness and arrogance is that they are both self defeating. However many in this group wear these attributes with pride. Yes, go ahead and stick your head in the sand and imagine the world does not exist -- because when you do you leave your backside sticking out in a good position for kicking! *kick* From robin at alldunn.com Mon Jan 24 19:32:39 2011 From: robin at alldunn.com (Robin Dunn) Date: Mon, 24 Jan 2011 16:32:39 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <3a96fee1-995f-49f7-a967-f125cc3f1cdc@v26g2000yqf.googlegroups.com> <023e19ed-69d1-4155-a114-0d00c227b8f6@u18g2000prh.googlegroups.com> <06dd3a10-03a4-4d43-a10e-cadf5105a7c4@t23g2000vby.googlegroups.com> Message-ID: On Jan 24, 2:16?pm, rantingrick wrote: > And i know the real reason you and Robin do not want wxPython > in the stdlib. Because you do not want to lose your selfish status > within the wxPython community. When wxPython becomes a stdlib module > then you will answer directly to Guido and Python-dev. You are not > fooling anyone with this grandstanding. Oh my, the BS certainly is getting deep around here. It doesn't look like my hip-waders will be enough... Now where did I put that full- body bio-hazard environment suit? --Robin From alex.kapps at web.de Mon Jan 24 19:37:18 2011 From: alex.kapps at web.de (Alexander Kapps) Date: Tue, 25 Jan 2011 01:37:18 +0100 Subject: WxPython versus Tkinter. In-Reply-To: <4d3e0563$0$29983$c3e8da3$5496439d@news.astraweb.com> References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <3a96fee1-995f-49f7-a967-f125cc3f1cdc@v26g2000yqf.googlegroups.com> <4d3e0563$0$29983$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4D3E1B3E.5010105@web.de> There are two completely different issues here: 1. Tyler's/Octavian's very valid (but AFAICT now somewhat over-expressed) point that Tk/Tkinter isn't accessible. I accept this, but don't see any point against Tk(inter) in this per se. Tk(inter) could be advanced to support screen readers and such. 2. RR's aggressive, insulting, self-praising war against Tk(inter) (which, IIRC, he ones praised) I *really* don't understand why RR gets so much attention. He has (massively!) insulted everybody around, has shown his low knowledge and understanding, his selfish and arrogant behaviour, etc. As I see it, please don't fall trap when RR now supports the accessible issue. I'm quite sure, that he just misuses that. Now that Godwin has been called, let me say also this: Check some earlier posts of RR (especially unicode related, but also his whole "command structure", "leader", "one for all", etc stuff) and it should be clear who is the izan. (*) Wake me, if RR is chased out of town and we can start a real discussion about the future of Python GUIs and accessibility. (*) I'm German and I just *KNOW* what to think about people who accuse random opponents as aniz. Our politicians do that quite regularly and the *ONLY* aim behind this is plain and simply to discredit the opponent when the arguments run out. From steve+comp.lang.python at pearwood.info Mon Jan 24 20:41:52 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 25 Jan 2011 01:41:52 GMT Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <3a96fee1-995f-49f7-a967-f125cc3f1cdc@v26g2000yqf.googlegroups.com> <4d3e0563$0$29983$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4d3e2a5f$0$29970$c3e8da3$5496439d@news.astraweb.com> On Tue, 25 Jan 2011 01:37:18 +0100, Alexander Kapps wrote: > I *really* don't understand why RR gets so much attention. He has > (massively!) insulted everybody around, has shown his low knowledge and > understanding, his selfish and arrogant behaviour, etc. http://xkcd.com/386/ -- Steven From rantingrick at gmail.com Mon Jan 24 21:58:48 2011 From: rantingrick at gmail.com (rantingrick) Date: Mon, 24 Jan 2011 18:58:48 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <66b4baf9-7714-45ae-9cac-39b06ee3f70e@k42g2000yqa.googlegroups.com> Message-ID: <438a06b0-eefa-423d-af6b-497e34ce6ce0@u6g2000yqk.googlegroups.com> On Jan 24, 2:11?pm, rantingrick wrote: > On Jan 22, 6:07?pm, rantingrick wrote: > > > I await any challengers... > > CODE UPDATE > > ?* fixed linux whiners bug > > https://sites.google.com/site/thefutureofpython/home/code-challenges So what? Now that the code runs without segfault nobody has nothing to say? I guess you have nothing to complain about now huh? So go ahead and admit wxPython won this round so we can move on to round two, our post some Tkinter ListCtrl code. From tyler at tysdomain.com Mon Jan 24 22:28:55 2011 From: tyler at tysdomain.com (Littlefield, Tyler) Date: Mon, 24 Jan 2011 20:28:55 -0700 Subject: WxPython versus Tkinter. Message-ID: <4D3E4377.3060807@tysdomain.com> >I think you are lying about being blind. And if you are, i am disgusted. By golly, you caught me in the act! shhh, don't tell everyone; it's all an elaborate front. The braille, the screen reader, the cane... I just like to fake it. block quote Well if i were a blind person i would use the most accessible GUI>available. block quote end And we already do. I haven't campaigned for changes with TKInter or spoken to anyone about them, because I haven't downloaded a program to find out it was written to use TKInter, and thus unacccessible. I'm not saying that there aren't any, just saying it's not something I have had problems with mainstream to need to make things accessible. If I want a program that's not accessible, chances are I can make it accessible, or I can find a program that does just as much, or better yet, I can ask the developer to work with me on it. While quoting ADA at people might provide for some education, eventually people are going to get tired of it and I've done nothing useful at the end of the day. There -is- a point when it's useful, but I suppose it comes down to who you are. If you want to sit around and say "TKInter == horrible and bad and evil and cruel because it doesn't work with my reader," over and over, so be it. If you want to scream and yell and start quoting laws at people who just may not know that there are people with screen readers out there (I've explained some of this to many different people many times, in terms of what a reader is), then that's your loss, because they more than likely are not going to care to work with you. -- Thanks, Ty From ameyer2 at yahoo.com Mon Jan 24 22:38:52 2011 From: ameyer2 at yahoo.com (Alan Meyer) Date: Mon, 24 Jan 2011 22:38:52 -0500 Subject: Swampy Module installation In-Reply-To: <9dd545a1-b0ea-408c-9fe2-a2ce7d6a5a0a@m7g2000vbn.googlegroups.com> References: <9dd545a1-b0ea-408c-9fe2-a2ce7d6a5a0a@m7g2000vbn.googlegroups.com> Message-ID: On 01/18/2011 06:26 PM, Michael Rauh wrote: > I am new to python, and attempting to install the learning module > swampy. http://www.greenteapress.com/thinkpython/swampy/install.html > Unfortunately, I am attempting to do this on windows vista, which does > not appear to be cooperating. Once I click on the install link, it > puts the file on the computer, and even if I place the file into the > source folder for python, it still says that there is no module > swampy. How can I get python to recognize the module as being there, > and to run the suite? I admit, I may be placing it in the wrong > directory, as I have so far been unable to change the working > directory. Online the command os.chdir is said to change the > directory, but it keeps giving an error, and saying that os is not > recognized. Variations on this code do not seem to work either. Did you run: python setup.py install After you unzip the package you should see a program named "setup.py" which is a standard convention for a program to install a package. There's information about all this, for example at: http://docs.python.org/install/index.html, however you might find it a little overwhelming until you get further into Python. Good luck. Alan From me+list/python at ixokai.io Mon Jan 24 22:54:07 2011 From: me+list/python at ixokai.io (Stephen Hansen) Date: Mon, 24 Jan 2011 19:54:07 -0800 Subject: WxPython versus Tkinter. In-Reply-To: <06dd3a10-03a4-4d43-a10e-cadf5105a7c4@t23g2000vby.googlegroups.com> References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <3a96fee1-995f-49f7-a967-f125cc3f1cdc@v26g2000yqf.googlegroups.com> <023e19ed-69d1-4155-a114-0d00c227b8f6@u18g2000prh.googlegroups.com> <06dd3a10-03a4-4d43-a10e-cadf5105a7c4@t23g2000vby.googlegroups.com> Message-ID: <4D3E495F.7010201@ixokai.io> On 1/24/11 2:16 PM, rantingrick wrote: > On Jan 24, 3:58 pm, Infinity77 wrote: > >> I have been involved in the wxPython development for many years >> (mostly on implementation of custom widgets, in the AGW library), and >> I share Robin's concerns about this kind of "publicity" given to >> wxPython. > > Who cares what you think about wxPython's publicity. A module was > created and put on public display and can be ridiculed or supported by > anyone who so desires. > >> Python comes with TK as a "battery included" UI toolkit. I'm perfectly >> fine with this, as I am not going to use it anyway. Whether in the >> future TK will be replaced by PyGTK, PyQT, PySide, etc... in the >> standard library, it won't make any difference to those aficionados >> developers who use wxPython. We'll still download the wxPython >> binaries/sources/whatever and use it to develop our own GUIs. > > Good, and again i cannot stress how little we care about your opinion. > Why do we not care. Well because you are looking at this from a > wxPython perspective. You are being selfish. We are considering this > from a global Python perspective. What is good for Python may not be > good for you, in any event, it is for us to decide. You can join our > discussion when your perspective changes from "me" to "us". And the > "us" is the Python langauge NOT wxPython. > > >> It is very unfortunate that this topic "wxPython vs. Tkinter" has >> drifted to another flame war, > > There is no flame war here > >> as there is really no point in this kind >> of discussion. > > Says you. but who are you to say what is important to us. Go back to > wxPython. > >> As a general rule, a GUI-newbie should try all the GUI >> toolkits out there and settle with the one which looks easier/nicer/ >> more convenient/more feature rich. As usual, it is a matter of >> personal taste. > > And i agree. I think any sane person could agree also. However you > miss the point of this conversation. We are looking at Python from a > global perspective. You are limited in your views, and obviously very > biased. And i know the real reason you and Robin do not want wxPython > in the stdlib. Because you do not want to lose your selfish status > within the wxPython community. When wxPython becomes a stdlib module > then you will answer directly to Guido and Python-dev. You are not > fooling anyone with this grandstanding. I can't believe I'm actually getting into this, but-- wxPython is open source, and technically anyone has the legal right to include it in whatever they want -- but no module goes into stdlib, period, without it being donated by its authors for that purpose. Period. Python-dev is not so discourteous as to absorb someone elses code without their go-ahead (and more then that: they don't generally absorb anyone elses code without that person making a _commitment_ to supporting it, in the stdlib, for multiple years). So: no author answers to Guido unless they decide they want to. Not that I'm suggesting Robin wouldn't go for it if someone with actual standing asked: but I'm not suggesting he would, either. I have no idea if the stdlib development cycle fits the wxPython one, since wxPython tracks wxWidgets releases. (Totally notwithstanding the elephant in the room that nothing new is going to go into 2.x at all, and wxPython doesn't presently support 3.x.) Robin actually has an unappealable veto over the whole idea, if he so chose to exercise it. Just thought I'd interject some reality into your delusion that there is some Python Kingdom and that King Guido can "decide" all manner of things and it'll cause them to happen. But we've had this conversation before, you and I. Also, rick != the_community. You don't get to speak for "we". But we've had that conversation too, you and I. -- Stephen Hansen ... Also: Ixokai ... Mail: me+list/python (AT) ixokai (DOT) io ... Blog: http://meh.ixokai.io/ -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 487 bytes Desc: OpenPGP digital signature URL: From rantingrick at gmail.com Mon Jan 24 23:32:00 2011 From: rantingrick at gmail.com (rantingrick) Date: Mon, 24 Jan 2011 20:32:00 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <3a96fee1-995f-49f7-a967-f125cc3f1cdc@v26g2000yqf.googlegroups.com> <023e19ed-69d1-4155-a114-0d00c227b8f6@u18g2000prh.googlegroups.com> <06dd3a10-03a4-4d43-a10e-cadf5105a7c4@t23g2000vby.googlegroups.com> Message-ID: <34a0ffa4-1fa9-46eb-a53f-4338e8ffd1ed@i17g2000vbq.googlegroups.com> On Jan 24, 9:54?pm, Stephen Hansen wrote: > On 1/24/11 2:16 PM, rantingrick wrote: > wxPython is open source, and technically anyone has the legal right to > include it in whatever they want -- but no module goes into stdlib, > period, without it being donated by its authors for that purpose. Ok. So you are saying that wxPython *could* possibly go into the stdlib and equally wxPython could possibly *not* go into th stdlib? Ok, go on... > Period. Python-dev is not so discourteous as to absorb someone elses > code without their go-ahead (and more then that: they don't generally > absorb anyone elses code without that person making a _commitment_ to > supporting it, in the stdlib, for multiple years). > > So: no author answers to Guido unless they decide they want to. Ok? So you are saying that wxPython *could* possibly go into the stdlib and equally wxPython could possibly *not* go into th stdlib? Ok, go on... > Not that I'm suggesting Robin wouldn't go for it if someone with actual > standing asked: but I'm not suggesting he would, either. Ok! So you are saying that wxPython *could* possibly go into the stdlib and equally wxPython could possibly *not* go into th stdlib? Ok, go on... > I have no idea > if the stdlib development cycle fits the wxPython one, since wxPython > tracks wxWidgets releases. (Totally notwithstanding the elephant in the > room that nothing new is going to go into 2.x at all, and wxPython > doesn't presently support 3.x.) OK,OK,OK!! So you are saying that wxPython *could* possibly go into the stdlib and equally wxPython could possibly *not* go into th stdlib? HOWEVER no matter what it FOR SURE can't go into Python2.x! Ok, go on... > Robin actually has an unappealable veto over the whole idea, if he so > chose to exercise it. GEESH!! So you are saying that wxPython *could* possibly go into the stdlib and equally wxPython could possibly *not* go into th stdlib? Ok, go on... > Just thought I'd interject some reality into your delusion that there is > some Python Kingdom and that King Guido can "decide" all manner of > things and it'll cause them to happen. Stephen can i sum up your post as..."it could go either way"? PS: And you guys wonder why i rant so much! :-) From jason.swails at gmail.com Mon Jan 24 23:39:07 2011 From: jason.swails at gmail.com (Jason Swails) Date: Mon, 24 Jan 2011 23:39:07 -0500 Subject: WxPython versus Tkinter. In-Reply-To: <4D3E495F.7010201@ixokai.io> References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <3a96fee1-995f-49f7-a967-f125cc3f1cdc@v26g2000yqf.googlegroups.com> <023e19ed-69d1-4155-a114-0d00c227b8f6@u18g2000prh.googlegroups.com> <06dd3a10-03a4-4d43-a10e-cadf5105a7c4@t23g2000vby.googlegroups.com> <4D3E495F.7010201@ixokai.io> Message-ID: Oddly enough, this post STARTED right around the time I joined the list. (Tkinter: The good, the bad, the ugly) It's been an interesting metamorphosis to watch as the ranting(rick) started quasi-civil and "discussionary", then evolved within a matter of weeks to violence and hyperbole. A lot of rather hyperbolic comparisons have been drawn (i.e. Nazis, limitless selfishness, complete idiocy, etc.), but I think I may have one avoids hyperbole altogether. This thread is a fast-forwarded, condensed version of the US political rhetoric as it's evolved over the past 200 years, culminating in today's ridiculous environment in which opposing opinions can do no better than condemn the entire country (or world in *our* view) to utter destruction. And I may add that today's US government, and the arguments upon which it throws itself, is probably one of the most ineffective in the country's history (of course this comparison will probably be tossed away as unrelated, irrelevant, and moronic; doesn't change its uncanny similarity :) ). In this rendition, however, we have both sides being played by the same actor (perhaps with 1 or 2 supporting roles). Two valuable things I have taken away from this extended argument: 1) This being my first super-high volume mailing list with the occasional neurotically opinionated poster, MRAB introduced me to Godwin's law for the first time. Considering its context, much to my amusement (thank you). 2) Steven's XKCD comic that I had not seen before. Also, considering its context, much to my amusement. For any comments as to my post's uselessness and my overall idiocy, etc., I've provided the below space for you to have as much fun as you'd like. --------------------------------- --------------------------------- While that may not be enough space, a couple well-placed carriage returns should do the trick. I suppose the only reason some people respond is that it's fun to poke the fire harmlessly and watch small flaming ash go flying everywhere. The internet is inflammable after all (how else could it still be here after so many flame wars?) Hoping you all have a peaceful night, Jason On Mon, Jan 24, 2011 at 10:54 PM, Stephen Hansen wrote: > On 1/24/11 2:16 PM, rantingrick wrote: > > On Jan 24, 3:58 pm, Infinity77 wrote: > > > >> I have been involved in the wxPython development for many years > >> (mostly on implementation of custom widgets, in the AGW library), and > >> I share Robin's concerns about this kind of "publicity" given to > >> wxPython. > > > > Who cares what you think about wxPython's publicity. A module was > > created and put on public display and can be ridiculed or supported by > > anyone who so desires. > > > >> Python comes with TK as a "battery included" UI toolkit. I'm perfectly > >> fine with this, as I am not going to use it anyway. Whether in the > >> future TK will be replaced by PyGTK, PyQT, PySide, etc... in the > >> standard library, it won't make any difference to those aficionados > >> developers who use wxPython. We'll still download the wxPython > >> binaries/sources/whatever and use it to develop our own GUIs. > > > > Good, and again i cannot stress how little we care about your opinion. > > Why do we not care. Well because you are looking at this from a > > wxPython perspective. You are being selfish. We are considering this > > from a global Python perspective. What is good for Python may not be > > good for you, in any event, it is for us to decide. You can join our > > discussion when your perspective changes from "me" to "us". And the > > "us" is the Python langauge NOT wxPython. > > > > > >> It is very unfortunate that this topic "wxPython vs. Tkinter" has > >> drifted to another flame war, > > > > There is no flame war here > > > >> as there is really no point in this kind > >> of discussion. > > > > Says you. but who are you to say what is important to us. Go back to > > wxPython. > > > >> As a general rule, a GUI-newbie should try all the GUI > >> toolkits out there and settle with the one which looks easier/nicer/ > >> more convenient/more feature rich. As usual, it is a matter of > >> personal taste. > > > > And i agree. I think any sane person could agree also. However you > > miss the point of this conversation. We are looking at Python from a > > global perspective. You are limited in your views, and obviously very > > biased. And i know the real reason you and Robin do not want wxPython > > in the stdlib. Because you do not want to lose your selfish status > > within the wxPython community. When wxPython becomes a stdlib module > > then you will answer directly to Guido and Python-dev. You are not > > fooling anyone with this grandstanding. > > I can't believe I'm actually getting into this, but-- > > wxPython is open source, and technically anyone has the legal right to > include it in whatever they want -- but no module goes into stdlib, > period, without it being donated by its authors for that purpose. > Period. Python-dev is not so discourteous as to absorb someone elses > code without their go-ahead (and more then that: they don't generally > absorb anyone elses code without that person making a _commitment_ to > supporting it, in the stdlib, for multiple years). > > So: no author answers to Guido unless they decide they want to. > > Not that I'm suggesting Robin wouldn't go for it if someone with actual > standing asked: but I'm not suggesting he would, either. I have no idea > if the stdlib development cycle fits the wxPython one, since wxPython > tracks wxWidgets releases. (Totally notwithstanding the elephant in the > room that nothing new is going to go into 2.x at all, and wxPython > doesn't presently support 3.x.) > > Robin actually has an unappealable veto over the whole idea, if he so > chose to exercise it. > > Just thought I'd interject some reality into your delusion that there is > some Python Kingdom and that King Guido can "decide" all manner of > things and it'll cause them to happen. > > But we've had this conversation before, you and I. > > Also, rick != the_community. You don't get to speak for "we". > > But we've had that conversation too, you and I. > > > -- > > Stephen Hansen > ... Also: Ixokai > ... Mail: me+list/python (AT) ixokai (DOT) io > ... Blog: http://meh.ixokai.io/ > > > -- > http://mail.python.org/mailman/listinfo/python-list > > -- Jason M. Swails Quantum Theory Project, University of Florida Ph.D. Graduate Student 352-392-4032 -------------- next part -------------- An HTML attachment was scrubbed... URL: From me+list/python at ixokai.io Mon Jan 24 23:51:12 2011 From: me+list/python at ixokai.io (Stephen Hansen) Date: Mon, 24 Jan 2011 20:51:12 -0800 Subject: WxPython versus Tkinter. In-Reply-To: <34a0ffa4-1fa9-46eb-a53f-4338e8ffd1ed@i17g2000vbq.googlegroups.com> References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <3a96fee1-995f-49f7-a967-f125cc3f1cdc@v26g2000yqf.googlegroups.com> <023e19ed-69d1-4155-a114-0d00c227b8f6@u18g2000prh.googlegroups.com> <06dd3a10-03a4-4d43-a10e-cadf5105a7c4@t23g2000vby.googlegroups.com> <34a0ffa4-1fa9-46eb-a53f-4338e8ffd1ed@i17g2000vbq.googlegroups.com> Message-ID: <4D3E56C0.40207@ixokai.io> On 1/24/11 8:32 PM, rantingrick wrote: > On Jan 24, 9:54 pm, Stephen Hansen wrote: >> On 1/24/11 2:16 PM, rantingrick wrote: > >> wxPython is open source, and technically anyone has the legal right to >> include it in whatever they want -- but no module goes into stdlib, >> period, without it being donated by its authors for that purpose. > > Ok. So you are saying that wxPython *could* possibly go into the > stdlib and equally wxPython could possibly *not* go into th stdlib? > Ok, go on... No. I am saying as a matter of legal permissibility, it may be included in the stdlib. But, as a matter of both policy and ethical behavior, it will not without it being donated by the author. The words are not big. You can understand them, if you try, really hard. Honest. -- Stephen Hansen ... Also: Ixokai ... Mail: me+list/python (AT) ixokai (DOT) io ... Blog: http://meh.ixokai.io/ -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 487 bytes Desc: OpenPGP digital signature URL: From chris.gonnerman at newcenturycomputers.net Mon Jan 24 23:52:13 2011 From: chris.gonnerman at newcenturycomputers.net (Chris Gonnerman) Date: Mon, 24 Jan 2011 22:52:13 -0600 Subject: [Python] how to tell if cursor is sqlite.Cursor or psycopg2.Cursor In-Reply-To: <7f1931cd-a15b-44a9-8cf9-b0af0bdfec7d@d8g2000yqf.googlegroups.com> References: <7f1931cd-a15b-44a9-8cf9-b0af0bdfec7d@d8g2000yqf.googlegroups.com> Message-ID: <4D3E56FD.1090601@newcenturycomputers.net> You're looking at it wrong. It doesn't matter what type of cursor it is, only if you can get the correct number. So use a try...except: try: cursor.execute(""" select last_insert_rowid() """) except: cursor.execute(""" select currval('my_sequence') """) That's just a quick-and-dirty example; you might need to pretty it up, or actually declare the type of exception you're expecting (always a good idea, but I didn't feel like looking up the right sqlite exception). Good luck! From tshinnic at io.com Tue Jan 25 00:02:48 2011 From: tshinnic at io.com (Thomas L. Shinnick) Date: Mon, 24 Jan 2011 23:02:48 -0600 Subject: WxPython versus Tkinter. In-Reply-To: References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <3a96fee1-995f-49f7-a967-f125cc3f1cdc@v26g2000yqf.googlegroups.com> <023e19ed-69d1-4155-a114-0d00c227b8f6@u18g2000prh.googlegroups.com> <06dd3a10-03a4-4d43-a10e-cadf5105a7c4@t23g2000vby.googlegroups.com> <4D3E495F.7010201@ixokai.io> Message-ID: <28.8A.00963.7895E3D4@hrndva-omtalb.mail.rr.com> At 10:39 PM 1/24/2011, Jason Swails wrote: [snip] >Two valuable things I have taken away from this extended >argument: 1) This being my first super-high volume mailing list >with the occasional neurotically opinionated poster, MRAB introduced >me to Godwin's law for the first time. Considering its context, >much to my amusement (thank you). 2) Steven's XKCD comic that I had >not seen before. Also, considering its context, much to my amusement. More wisdom therein ... http://xkcd.com/438/ -- I'm a pessimist about probabilities; I'm an optimist about possibilities. Lewis Mumford (1895-1990) From rantingrick at gmail.com Tue Jan 25 00:16:11 2011 From: rantingrick at gmail.com (rantingrick) Date: Mon, 24 Jan 2011 21:16:11 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <3a96fee1-995f-49f7-a967-f125cc3f1cdc@v26g2000yqf.googlegroups.com> <023e19ed-69d1-4155-a114-0d00c227b8f6@u18g2000prh.googlegroups.com> <06dd3a10-03a4-4d43-a10e-cadf5105a7c4@t23g2000vby.googlegroups.com> <34a0ffa4-1fa9-46eb-a53f-4338e8ffd1ed@i17g2000vbq.googlegroups.com> Message-ID: <3cf33238-dff6-487d-be19-e3fd0b020163@j1g2000vbl.googlegroups.com> On Jan 24, 10:51?pm, Stephen Hansen wrote: > No. I am saying as a matter of legal permissibility, it may be included > in the stdlib. > > But, as a matter of both policy and ethical behavior, it will not > without it being donated by the author. I don't think you have any idea of what you are saying because you keep parroting off the same thing in slightly different ways. I'm having flashbacks to Forrest Gump... Bubba: Anyway, like I was sayin', shrimp is the fruit of the sea. You can barbecue it, boil it, broil it, bake it, saute it. Dey's uh, shrimp-kabobs, shrimp creole, shrimp gumbo. Pan fried, deep fried, stir-fried. There's pineapple shrimp, lemon shrimp, coconut shrimp, pepper shrimp, shrimp soup, shrimp stew, shrimp salad, shrimp and potatoes, shrimp burger, shrimp sandwich. That- that's about it. So after presenting us with well known knowledge (and repeating it many times) i feel compelled to bring us back to the subject matter at hand. Do you have any actual argument to present that adds some compelling ideas about Tkinters worth, or non worth? From jeanfrancois.leberre at gmail.com Tue Jan 25 01:06:30 2011 From: jeanfrancois.leberre at gmail.com (Jean-Francois) Date: Mon, 24 Jan 2011 22:06:30 -0800 (PST) Subject: New instance of a class : not reset? References: Message-ID: Great thank you From jason.swails at gmail.com Tue Jan 25 01:18:14 2011 From: jason.swails at gmail.com (Jason Swails) Date: Tue, 25 Jan 2011 01:18:14 -0500 Subject: WxPython versus Tkinter. In-Reply-To: <3cf33238-dff6-487d-be19-e3fd0b020163@j1g2000vbl.googlegroups.com> References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <3a96fee1-995f-49f7-a967-f125cc3f1cdc@v26g2000yqf.googlegroups.com> <023e19ed-69d1-4155-a114-0d00c227b8f6@u18g2000prh.googlegroups.com> <06dd3a10-03a4-4d43-a10e-cadf5105a7c4@t23g2000vby.googlegroups.com> <34a0ffa4-1fa9-46eb-a53f-4338e8ffd1ed@i17g2000vbq.googlegroups.com> <3cf33238-dff6-487d-be19-e3fd0b020163@j1g2000vbl.googlegroups.com> Message-ID: On Tue, Jan 25, 2011 at 12:16 AM, rantingrick wrote: > On Jan 24, 10:51 pm, Stephen Hansen wrote: > > > No. I am saying as a matter of legal permissibility, it may be included > > in the stdlib. > > > > But, as a matter of both policy and ethical behavior, it will not > > without it being donated by the author. > > I don't think you have any idea of what you are saying because you > keep parroting off the same thing in slightly different ways. I'm > having flashbacks to Forrest Gump... > > Bubba: Anyway, like I was sayin', shrimp is the fruit of the sea. You > can barbecue it, boil it, broil it, bake it, saute it. Dey's uh, > shrimp-kabobs, shrimp creole, shrimp gumbo. Pan fried, deep fried, > stir-fried. There's pineapple shrimp, lemon shrimp, coconut shrimp, > pepper shrimp, shrimp soup, shrimp stew, shrimp salad, shrimp and > potatoes, shrimp burger, shrimp sandwich. That- that's about it. > > So after presenting us with well known knowledge (and repeating it > many times) i feel compelled to bring us back to the subject matter at > hand. Do you have any actual argument to present that adds some > compelling ideas about Tkinters worth, or non worth? > It is worth more than everything you have said on this topic to date. (At least one useful application has been written with Tkinter.) Not a single useful application has been written from a single one of your (all too many and all too often irrelevant) words so far. In just this email you managed to write 2 senseless paragraphs filled with gibberish, rambling garbage that serves literally no purpose, just to say that the previous poster deviated from topic. You have destroyed the initial meaning behind your very first post with countless misspelled, poorly constructed insults. Nobody is listening to what few points you may (but probably don't) have left. And here's the kicker: if any of your points are even close to valid and the community does decide to depart from Tkinter (mobile computing is probably the biggest argument for it), then it will be pioneered by the next sane person that suggests it and you'll still be the crazy relegated to so many people's spam box. (All of whom have contributed more to Python than the last 3 weeks of your life spent on this web of trash). While you may claim to understand computers and computing (although I'd argue you no longer see it as a tool, which it is, but rather as a religion to be wielded as so many others have in the past), they are programmed and designed by people. What is this "people" thing I'm talking about? It's ok, you wouldn't understand. Suffice it to say that nearly all projects of the magnitude you seem to be projecting requires joint collaboration and participation of these people things that have long since forgotten your point and stopped listening to you. Here's to hoping that affords you some sense of success and accomplishment, Jason P.S. I appreciated the other XKCD comic, though that one I had seen. :) > -- > http://mail.python.org/mailman/listinfo/python-list > -- Jason M. Swails Quantum Theory Project, University of Florida Ph.D. Graduate Student 352-392-4032 -------------- next part -------------- An HTML attachment was scrubbed... URL: From orasnita at gmail.com Tue Jan 25 01:28:17 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Tue, 25 Jan 2011 08:28:17 +0200 Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com><3a96fee1-995f-49f7-a967-f125cc3f1cdc@v26g2000yqf.googlegroups.com> <023e19ed-69d1-4155-a114-0d00c227b8f6@u18g2000prh.googlegroups.com> Message-ID: <9ED792CC7FD646868946501493090F96@octavian> From: "Infinity77" > As a general rule, a GUI-newbie should try all the GUI > toolkits out there and settle with the one which looks easier/nicer/ Yes it would be nice, but... does it happen that way usually? :-) Octavian From orasnita at gmail.com Tue Jan 25 01:44:54 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Tue, 25 Jan 2011 08:44:54 +0200 Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com><63eea$4d3cd2fd$4275d90a$14984@FUSE.NET><69465430-08b3-4069-99c7-72f4d3034c66@s5g2000yqm.googlegroups.com><705ad$4d3ce0fc$4275d90a$29144@FUSE.NET> <4D3DF703.7080506@tysdomain.com> Message-ID: <7986537898554D59A141CA00BCA7A44B@octavian> From: "Littlefield, Tyler" > >It would be great if the Tk/Tkinter developers would be interested in > making >this GUI lib accessible. > They're not going to do it without knowing what makes accessible > accessible, and why it needs to be so. So, rather than tell the world > about how -some- blind people want to be like sighted people (we call that > independence in my world), why not go help out? It's bad, you want a > switch, and you've already said that they're using a lib that is > unaccessible. So fix the lib, and you will have fixed tons of programs > without fixing the program. That is all I ment by finding the root of the > problem, not "everyone with readers should fix their health problems." You > take my words, blow them out of perportion and at the end of the day, you > are still sitting here complaining about the lack of accessibility, rather > than doing something about it. This is awesome. We for sure need more > complainers and less people to do what the complainers are complaining > about! The solution for accessibility doesn't need to be found because it is already found. Making Tkinter accessible won't matter if it won't be used in Python anymore. Or is there a God law that tells that only Tk-based GUIs can be included in Python? Octavian From clp2 at rebertia.com Tue Jan 25 01:55:52 2011 From: clp2 at rebertia.com (Chris Rebert) Date: Mon, 24 Jan 2011 22:55:52 -0800 Subject: Behaviour-based interface/protocol implementation? In-Reply-To: References: Message-ID: On Mon, Jan 24, 2011 at 2:13 AM, Alan Franzoni wrote: > Hello, > I'd like to have a system which lets me do certain actions if the > duck-type of a certain objects matches what I expect, i.e. I'd like to > have a formalization of what it's sometimes done through getattr() > calls: > > if getattr(myobj, "somemethod", None) is not None: > ? ?myobj.somemethod(somevalue) > > > The above approach is sometimes too naive, because a) clutters code > with many getattr calls and ifs b) I might want to check for multiple > attributes and c) only checks for the method name and not for the > method's signature. > > After looking at PyProtocols, zope.interface and python's own abc > module, I'm left with a doubt: does any behaviour-based "interface > testing" system exist for Python? > > > I mean: > all these three libraries use a register-based or inheritance-based > approach; in abc, if I want instances of a class of mine "FooClass" to > be "BarInterface" instances, I can either a) inherit from BarInterface > or b) run "BarInterface.register(FooClass)". Not true actually: Python 2.7.1 (r271:86832, Dec 5 2010, 00:12:20) [GCC 4.2.1 (Apple Inc. build 5664)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> class MyContainer(object):# no special inheritance ... def __len__(self): ... return 42 ... >>> # didn't do any registration. >>> from collections import Sized >>> issubclass(MyContainer, Sized) True >>> isinstance(MyContainer(), Sized) True Several of the other ABCs in the `collections` module (which are based on the `abc` module) work similarly. Registration and subclassing are just additional ways to indicate support for an interface. Provided the ABC is properly coded, registration/subclassing isn't mandatory. > What happens if I define my own ABC for my own purpose? There might be > builtin objects, or third party libraries, which already offer objects > that satisfy such interface, but I'd need to import such modules and > register such classes as implementing my ABC, which is suboptimal. > I'd like to do a kind of runtime-check for signatures. Of course there > couldn't be an absolute certainty of interface implementation, because > a runtime dynamic proxy method (accepting *args and **kwargs in its > signature, as an example) ?might ?just fool my signature check. > > So, my questions are: > > a) does anything like that already exist in the python ecosystem? Not precisely that I know of, no. The `abc`/`collections` system comes closest, but it does not check method signatures; it merely verifies methods' existence. You could *definitely* write something like that by combining the `abc` and `inspect` modules though: http://docs.python.org/library/inspect.html#inspect.getargspec http://docs.python.org/library/abc.html#abc.ABCMeta.__subclasshook__ > b) can anybody see any flaw either in what I'd like to do ("you > shouldn't do that because...") Duck typing partisans would question what the point of such an elaborate mechanism would be when it won't change the fact that your type errors will still occur at run-time and be of essentially the same character as if you didn't use such a mechanism in the first place. But I'm not such a partisan; not that they wouldn't have a point though. At /some/ point, you're just fighting the inherent nature of the language, which is a losing battle (unless perhaps the language is a Lisp). Cheers, Chris -- http://blog.rebertia.com From orasnita at gmail.com Tue Jan 25 02:00:10 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Tue, 25 Jan 2011 09:00:10 +0200 Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com>7c$4275d90a$44222222222222 <63eea$4d3cd2fd$4275d90a$14984@FUSE.NET><69465430-08b3-4069-99c7-72f4d3034c66@s5g2000yqm.googlegroups.com><705ad$4d3ce0fc$4275d90a$29144@FUSE.NET> <5f8c1256-f07c-43be-8307-d36991e9be24@m35g2000vbn.googlegroups.com> <4D3DFAD7.40902@tysdomain.com> Message-ID: <25327AB5A2244628B2732C061A4488BF@octavian> From: "Littlefield, Tyler" > >Because of this, many blind people try to show that they are like the > sighted, that they can do everything, that they are >independent, so they > like to > >talk about the movies they watch, they like to have touch-pad mobile > phones and so on, even though the accessibility of >those gadgets is > really low. > While I am getting off topic here, I just had to comment... > Yes, I do talk about "watching" tv. Not having working eyeballs doesn't > limit me from using a word that people with common sense can just equate > to listening to tv. And neither does not having working eyeballs limit me > from -listening- to tv, which is what I and other blind people that want > to "watch" tv do. And guess what? I can use a phone with a touch screen. > It's called an IPhone, and it's got a screen reader built in. Nifty, huh? > It just helps me in my goal to be just like sighted people, blame Apple > for making a touch screen accessible. >From your messages I was sure that you are one of those guys. :-) But can you imagine that not everyone is 20 years old and not everyone is passionate about "cool" gadgets and not everyone is motivated to test as much things as possible and look cool in their gang? Try to care more about the others and not only about yourself just because that way is more easy and effective. > I say this all because I want to make a point. I don't expect the world to > revolve around what is and isn't accessible. Nobody cares about what you expect, because it seems that you are interested only in what helps you immediately as easy as possible. Nobody should think about what is accessible or not accessible because ideally, everything should be designed to be accessible to everyone or at least to as many people as possible. > While laws do exist, if I ran around quoting the ADA (Americans with > Disabilities Act) at everyone who didn't make things accessible (whether > on the computer, at school, at a store), I'd just be wasting time. Oh, and you care more about your insignifiant time than the potential to promote the accessibility for millions of users worldwide? I don't blame you because everyone is a little selfish, some more and some less, but at least don't try to demonstrate that the selfish atitude is the one that should be folowed because it is more efective on the short term and more simple. > Rather I like to blend in, be independant and adapt things. Now, since i > am a programmer this means that I am able to do a lot more in the form of > adaptation on the computer, and this is my goal; This is a selfish atitude again. As I already said, any blind programmer can choose the right language and/or GUI lib to make an accessible app so he/she will be very happy, but what about the rest of the people? Do you think that the discrimination is something normal? > So, call me a Nazi or whatever, that's just how I feel. Ok, nazi is just another political party and there are very many people like you, so this is not a problem. But don't try to convince the others that the nazist opinions are those that should be promoted. Octavian From orasnita at gmail.com Tue Jan 25 02:19:20 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Tue, 25 Jan 2011 09:19:20 +0200 Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com> Message-ID: From: "Littlefield, Tyler" > And we already do. I haven't campaigned for changes with TKInter or spoken > to anyone about them, because I haven't downloaded a program to find out > it was > written to use TKInter, and thus unacccessible. I'm not saying that there > aren't any, just saying it's not something I have had problems with > mainstream > to need to make things accessible. If I want a program that's not > accessible, chances are I can make it accessible, or I can find a program > that does just > as much, or better yet, I can ask the developer to work with me on it. > While quoting ADA at people might provide for some education, eventually > people > are going to get tired of it and I've done nothing useful at the end of > the day. There -is- a point when it's useful, but I suppose it comes down > to who > you are. If you want to sit around and say "TKInter == horrible and bad > and evil and cruel because it doesn't work with my reader," over and over, > so be > it. If you want to scream and yell and start quoting laws at people who > just may not know that there are people with screen readers out there > (I've explained > some of this to many different people many times, in terms of what a > reader is), then that's your loss, because they more than likely are not > going to > care to work with you. Wow! I, I, I, I... is there a sentence that doesn't talk about your self interests? When I informed the Python community about Tkinter's problems and why it shouldn't be promoted I didn't do it only for my selfish interests, because for my private use I can create the programs as I want, so if I don't like WxPython I don't use WxPython, and if I don't like Tkinter I don't use Tkinter so it is not a problem if Python promotes a bad GUI from this perspective. You haven't downloaded any inaccessible program made with Tkinter, you didn't have any problems, You can create an accessible program if you can't find an accessible one, you care only to please the other for working with you and so on. But don't you care about the millions of blind people like you which are not programmers? Don't you care that most programmers don't know about accessibility and they just don't create accessible programs not because they don't want, but because they don't know about this thing? Retorical question... It is obviously that you don't care. Ok, you don't care. There are very many like you. But do you think that this is the right atitude? To not care about the others at all but only about your selfish interests because the alternative is a loss of time? Can't you see that this isn't normal? Can't you see that some people don't even believe you that you are blind but you still promote the non-accessible programs? But there could be an explanation for this too. You might look great in your gang if the other blind people you know are not able to use some programs but you are able to create your own which are accessible. You will appear really special. Octavian From bob.martin at excite.com Tue Jan 25 03:02:28 2011 From: bob.martin at excite.com (Bob Martin) Date: Tue, 25 Jan 2011 08:02:28 GMT Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> Message-ID: <8q7eckF9ilU2@mid.individual.net> in 650595 20110124 192332 Bryan wrote: >On Jan 24, 12:05=A0pm, rantingrick wrote: >> On Jan 24, 12:00=A0pm, Bryan wrote: >> >> > Accessibility, like internationalization, is something few programmers >> > spend much time thinking about. >> >> Thats another uninformed statement by you we can add to the mountains >> of useless cruft you have offered so far. Unicode IS >> internationalization and Guido thought it was SO important that >> Python3000 auto converts all strings to Unicode strings. Obviously he >> is moving us toward full Unicode only in the future (AS SHOULD ALL >> IMPLEMENTATIONS!). We need one and only one obvious way to do it. And >> Unicode is that way. > >Ok, great. You've identified one programmer who thinks about >internationalization. Not much of a compelling argument there. > >However, I think you missed my point. My point wasn't that people like >Guido don't think of these topics. It's that the people in the >trenches who use these tools don't think about these topics. How many >of your co-workers actively think about internationalization and >accessibility? I'm guessing none, but maybe you're lucking and work in >a particularly enlightened team. I've perhaps worked closely with a >few hundred programmers in my career, and very few of them thought of >these subjects. In my experience it's just not something the >programmer in the trenches thinks about. That is the point I was >trying to make. Sorry, but I have to disagree with you here. I spent my working life as a programmer with a very large multi-national IT company and all software had to be fully "internationalized" (otherwise known as NLS) or it didn't get used. Do you think the whole world speaks US English? From me+list/python at ixokai.io Tue Jan 25 03:28:59 2011 From: me+list/python at ixokai.io (Stephen Hansen) Date: Tue, 25 Jan 2011 00:28:59 -0800 Subject: WxPython versus Tkinter. In-Reply-To: <7986537898554D59A141CA00BCA7A44B@octavian> References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com><63eea$4d3cd2fd$4275d90a$14984@FUSE.NET><69465430-08b3-4069-99c7-72f4d3034c66@s5g2000yqm.googlegroups.com><705ad$4d3ce0fc$4275d90a$29144@FUSE.NET> <4D3DF703.7080506@tysdomain.com> <7986537898554D59A141CA00BCA7A44B@octavian> Message-ID: <4D3E89CB.4010400@ixokai.io> On 1/24/11 10:44 PM, Octavian Rasnita wrote: > Or is there a God law that tells that only Tk-based GUIs can be included > in Python? There is no other viable option at this time for inclusion in the standard library; that's simple fact. There are options for people to write GUI's in python that are accessible. Those options do include the requirement of installing a third-party library. That's not onerous. Removing TK from the standard library at this point can't happen (at least until a theoretical Python 4K): at least not without a 100% compatible replacement which is functionally impossible (since it would have to be compatible with TK addons, too). Adding a secondary GUI framework would have to have an incredibly compelling argument behind it: and developers pledging years of maintenance in the python stdlib tree and with the python stdlib development practices, because python-dev is overworked as it is. It would need to be based on python 3.[2|3], need extensive tests and documentation in a format compatible with python.org's documentation, and solid cross-platform capability AND it be free of segfaultness, AND the more code it is the harder it is to support its inclusion, as the maintenance burden just becomes untenable-- and it would need to be PEP-8 compliant-- and-- All of that doesn't hold for wxPython. I use wxPython in my day job. I like wxPython a lot. It belongs outside of the standard library. If someone wants to devote man-years of development time to solve all of the above to make it fit the stdlib, all power to you. So far, it seems there maybe is two people who think it may be worth their time. I'm fine with installing wxPython as a third-party library. -- Stephen Hansen ... Also: Ixokai ... Mail: me+list/python (AT) ixokai (DOT) io ... Blog: http://meh.ixokai.io/ -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 487 bytes Desc: OpenPGP digital signature URL: From me+list/python at ixokai.io Tue Jan 25 03:50:46 2011 From: me+list/python at ixokai.io (Stephen Hansen) Date: Tue, 25 Jan 2011 00:50:46 -0800 Subject: [Code Challenge] WxPython versus Tkinter. In-Reply-To: <5199876F801C41E08F3E4969745F3E47@teddy> References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <4D3DB2F9.3090303@stoneleaf.us> <5199876F801C41E08F3E4969745F3E47@teddy> Message-ID: <4D3E8EE6.7020601@ixokai.io> On 1/24/11 11:58 AM, Octavian Rasnita wrote: >> From: "Ethan Furman" >> Please do not repost rr's crap in its entirety, or you'll find yourself >> added to many killfiles -- just like he is. > I am not posting anyone's crap. I just informed why Tkinter is bad. > And I also don't say that WxPython is ideal, but just that it has some very important features that Tk doesn't offer. Belatedly: The complaint was not that you had something to say in reply, but that as you replied, you quoted the entire original post. Netiquette holds that you should edit out your replies to include only those things / statements you're actually responding to. By just blanket replying and including the whole rant, you are posting that whole rant. Needlessly, as its already been said. If you cut it down and only include the points that you're responding to, you include the specific context needed to understand your statements, while minimizing the need for people to parse through noise. -- Stephen Hansen ... Also: Ixokai ... Mail: me+list/python (AT) ixokai (DOT) io ... Blog: http://meh.ixokai.io/ -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 487 bytes Desc: OpenPGP digital signature URL: From list at qtrac.plus.com Tue Jan 25 03:56:03 2011 From: list at qtrac.plus.com (Mark Summerfield) Date: Tue, 25 Jan 2011 00:56:03 -0800 (PST) Subject: Which is the best book to learn python References: <188c0a9f-4e93-4fae-b3f9-e7c84f8030fd@v31g2000pri.googlegroups.com> Message-ID: On Jan 24, 5:09?pm, santosh hs wrote: > Hi All, > i am beginner to python please tell me which is the best available > reference for beginner to start from novice If you want to learn Python 3 and have some prior programming experience (in any modern procedural or object oriented language), you might find "Programming in Python 3" (http://www.qtrac.eu/py3book.html) to be a good choice. (I'm biased though since I wrote it;-) From nospam at example.com Tue Jan 25 04:24:02 2011 From: nospam at example.com (Adam) Date: Tue, 25 Jan 2011 22:24:02 +1300 Subject: which scipy binary for Win32 Message-ID: Am looking at http://sourceforge.net/projects/scipy/files/scipy/0.8.0/ and I wonder which is the binary to install on WinXP ? As pointed to by this page, http://www.scipy.org/Download All I can see on that sourceforge page are the huge python2.6 and python2.7 Powerpacks, at 43megs or so each. The scipy-0.8.0.zip seems to require compilation. FYI: I'm installing Python 2.7, so have uninstalled all Python2.5 and Python2.6, including older numpy, scipy and matplotlib. Presently, prior to installation, I have; python-2.7.1.msi (15.628 meg) numpy-1.5.1-win32-superpack-python2.7.exe (5.354 meg) matplotlib-1.0.1.win32-py2.7.exe (8.105 meg) Does the scipy 2.7 Powerpack include numpy anyway ? Any recommendations or pointers appreciated. Thanks. From dave.hirschfeld at gmail.com Tue Jan 25 04:34:58 2011 From: dave.hirschfeld at gmail.com (Dave Hirschfeld) Date: Tue, 25 Jan 2011 09:34:58 +0000 (UTC) Subject: which scipy binary for Win32 References: Message-ID: Adam example.com> writes: > > Am looking at > http://sourceforge.net/projects/scipy/files/scipy/0.8.0/ > and I wonder which is the binary to install on WinXP ? > As pointed to by this page, http://www.scipy.org/Download > > All I can see on that sourceforge page are the huge > python2.6 and python2.7 Powerpacks, at 43megs or so > each. The scipy-0.8.0.zip seems to require compilation. > > > Any recommendations or pointers appreciated. Thanks. > > I'd say the easiest thing to do would be to get one of the superpack binaries. I would probably go for the 9.0rc (http://sourceforge.net/projects/scipy/files/scipy/0.9.0rc1/) as it will likely have fewer bugs that 8.0 and will make your code more future-proof in a fast changing world. That said, not everyone likes living on the bleeding edge... AFAIK the superpack binaries don't include numpy but are so big because they contain several versions of scipy depending on whether your cpu supports SSE1/SSE2 or not at all. The correct version will be detected and installed automatically. HTH, Dave From geoff.bache at gmail.com Tue Jan 25 05:25:53 2011 From: geoff.bache at gmail.com (Geoff Bache) Date: Tue, 25 Jan 2011 02:25:53 -0800 (PST) Subject: Finding the right Python executable on Windows Message-ID: <38326da6-8b30-4f88-b232-acdcd33b7d61@o14g2000yqe.googlegroups.com> Hi all, I have a Python process on Windows and would like to start a Python subprocess using the same interpreter. I wonder how to go about this? First, I tried the obvious subprocess.Popen([ sys.executable, "subproc.py", ... ]) but that fails, because my process has a "native launcher", (i.e. C: \path\mylauncher.exe, which is just a wrapper around the Python program) and hence sys.executable returns this path instead of the interpreter location. It isn't appropriate to use the launcher for the subprocess. I also tried using sys.exec_prefix but there didn't seem to be any standard location for the interpreter under this directory in any case. I feel certain there must be some way to do this as it seems a rather basic thing somehow, can anyone give me a hint? Regards, Geoff Bache From bryan.oakley at gmail.com Tue Jan 25 06:50:33 2011 From: bryan.oakley at gmail.com (Bryan) Date: Tue, 25 Jan 2011 03:50:33 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <8q7eckF9ilU2@mid.individual.net> Message-ID: On Jan 25, 2:02?am, Bob Martin wrote: > in 650595 20110124 192332 Bryan wrote: > > > > > > >On Jan 24, 12:05=A0pm, rantingrick wrote: > >> On Jan 24, 12:00=A0pm, Bryan wrote: > > >> > Accessibility, like internationalization, is something few programmers > >> > spend much time thinking about. > > >> Thats another uninformed statement by you we can add to the mountains > >> of useless cruft you have offered so far. Unicode IS > >> internationalization and Guido thought it was SO important that > >> Python3000 auto converts all strings to Unicode strings. Obviously he > >> is moving us toward full Unicode only in the future (AS SHOULD ALL > >> IMPLEMENTATIONS!). We need one and only one obvious way to do it. And > >> Unicode is that way. > > >Ok, great. You've identified one programmer who thinks about > >internationalization. Not much of a compelling argument there. > > >However, I think you missed my point. My point wasn't that people like > >Guido don't think of these topics. It's that the people in the > >trenches who use these tools don't think about these topics. How many > >of your co-workers actively think about internationalization and > >accessibility? I'm guessing none, but maybe you're lucking and work in > >a particularly enlightened team. I've perhaps worked closely with a > >few hundred programmers in my career, and very few of them thought of > >these subjects. In my experience it's just not something the > >programmer in the trenches thinks about. That is the point I was > >trying to make. > > Sorry, but I have to disagree with you here. ?I spent my working life as a programmer > with a very large multi-national IT company and all software had to be fully > "internationalized" (otherwise known as NLS) or it didn't get used. ? > Do you think the whole world speaks US English? No, absolutely not. I don't see how you go from "I don't think all developers think about i18n" to "I think everyone speaks english". Most very large companies think about this a lot. Most hugely successful software is probably internationalized. Together those two groups make up a tiny fraction of all software. Think about all the free software you use -- how much of it is internationalized and optimized for accessibility? I bet not much. I wish I could say more than half of all software is internationalized but I just don't believe that to be true based on my own personal observation. I definitely agree that many companies, both large and small, do the right thing here. From my experience though, many != most. I hope I'm wrong though, because that means the we're all headed in the right direction. From bob.martin at excite.com Tue Jan 25 07:03:30 2011 From: bob.martin at excite.com (Bob Martin) Date: Tue, 25 Jan 2011 12:03:30 GMT Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> Message-ID: <8q7sgiF5tpU1@mid.individual.net> in 650672 20110125 115033 Bryan wrote: >On Jan 25, 2:02=A0am, Bob Martin wrote: >> in 650595 20110124 192332 Bryan wrote: >> >> >> >> >> >> >On Jan 24, 12:05=3DA0pm, rantingrick wrote: >> >> On Jan 24, 12:00=3DA0pm, Bryan wrote: >> >> >> > Accessibility, like internationalization, is something few programme= >rs >> >> > spend much time thinking about. >> >> >> Thats another uninformed statement by you we can add to the mountains >> >> of useless cruft you have offered so far. Unicode IS >> >> internationalization and Guido thought it was SO important that >> >> Python3000 auto converts all strings to Unicode strings. Obviously he >> >> is moving us toward full Unicode only in the future (AS SHOULD ALL >> >> IMPLEMENTATIONS!). We need one and only one obvious way to do it. And >> >> Unicode is that way. >> >> >Ok, great. You've identified one programmer who thinks about >> >internationalization. Not much of a compelling argument there. >> >> >However, I think you missed my point. My point wasn't that people like >> >Guido don't think of these topics. It's that the people in the >> >trenches who use these tools don't think about these topics. How many >> >of your co-workers actively think about internationalization and >> >accessibility? I'm guessing none, but maybe you're lucking and work in >> >a particularly enlightened team. I've perhaps worked closely with a >> >few hundred programmers in my career, and very few of them thought of >> >these subjects. In my experience it's just not something the >> >programmer in the trenches thinks about. That is the point I was >> >trying to make. >> >> Sorry, but I have to disagree with you here. =A0I spent my working life a= >s a programmer >> with a very large multi-national IT company and all software had to be fu= >lly >> "internationalized" (otherwise known as NLS) or it didn't get used. =A0 >> Do you think the whole world speaks US English? > >No, absolutely not. I don't see how you go from "I don't think all >developers think about i18n" to "I think everyone speaks english". I said "US English", not just English, and you didn't say "I don't think all developers think about i18n", you said "I'm guessing none". Big difference. I think your attitude to this is US-only. > >Most very large companies think about this a lot. Most hugely >successful software is probably internationalized. Together those two >groups make up a tiny fraction of all software. Think about all the >free software you use -- how much of it is internationalized and >optimized for accessibility? I bet not much. I wish I could say more >than half of all software is internationalized but I just don't >believe that to be true based on my own personal observation. "I bet not much" - there you go again ;-) You'll find that nearly all software used in Europe (and most other parts) is internationalized or it wouldn't stand a chance. > >I definitely agree that many companies, both large and small, do the >right thing here. From my experience though, many !=3D most. I hope I'm >wrong though, because that means the we're all headed in the right >direction. From python at bdurham.com Tue Jan 25 08:17:14 2011 From: python at bdurham.com (python at bdurham.com) Date: Tue, 25 Jan 2011 08:17:14 -0500 Subject: WxPython versus Tkinter. In-Reply-To: References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com><63eea$4d3cd2fd$4275d90a$14984@FUSE.NET><69465430-08b3-4069-99c7-72f4d3034c66@s5g2000yqm.googlegroups.com><705ad$4d3ce0fc$4275d90a$29144@FUSE.NET> Message-ID: <1295961434.16173.1417116997@webmail.messagingengine.com> Mark, > From my queries to some of the Tcl/Tk folks, it seems that while the knowledge and expertise is not present in the core developer community, they would be more than happy to help people who do have some knowledge in this area so that Tk could be made to be more accessible. Some ideas here: Linux: Linux users can use the free and small Tka11y library from the site below. To use this library, one replaces "import Tkinter" with "import Tka11y" - couldn't be easier! http://tkinter.unpythonic.net/wiki/Tka11y Mac OS X: Quoting Arndt Roger Schneider from this list: "I think Tk-aqua (also 8.6) should work out-of-the-box with brail-lines, text-to-speech and such; the older carbon built however won't." I'm not sure what is involved in using an independent version of Tkinter that's newer than the build of Tkinter that ships with the standard library? Windows: While there appears(?) to be no built-in accessability for Windows versions of Tkinter I've seen Windows Tkinter applications that have used Windows native TTS functionality to provide a limited form of accessability for users with poor vision. > And if/when this does get done for Tk, I promise at least to make sure that the tutorial at http:///www.tkdocs.com covers this topic I really enjoyed your tkdocs.com site!! Based on the new ttk functionality you covered on your site, my company actually began moving GUI projects from wxPython back to Tkinter. How's that for an odd trend?! :) Malcolm From ethan at stoneleaf.us Tue Jan 25 08:57:03 2011 From: ethan at stoneleaf.us (Ethan Furman) Date: Tue, 25 Jan 2011 05:57:03 -0800 Subject: WxPython versus Tkinter. In-Reply-To: References: <4D3E4377.3060807@tysdomain.com> Message-ID: <4D3ED6AF.7020601@stoneleaf.us> -plonk- From tyler at tysdomain.com Tue Jan 25 09:11:10 2011 From: tyler at tysdomain.com (Littlefield, Tyler) Date: Tue, 25 Jan 2011 07:11:10 -0700 Subject: WxPython versus Tkinter. In-Reply-To: References: <4D3E4377.3060807@tysdomain.com> Message-ID: <4D3ED9FE.1070304@tysdomain.com> >Wow! I, I, I, I... is there a sentence that doesn't talk about your self interests? It is clear you have been taking lessons from RR; the word I does not convey self interest, in fact, it is the best word suited to speaking of oppinions (which is all that these are), in the first person. Lets move on, shall we? >You haven't downloaded any inaccessible program made with Tkinter, you didn't have any problems, You can create an accessible program if you can't find >an accessible one, you care only to please the other for working with you and so on. No. I said, I can find a program that is accessible, if I find one that isn't. Totally different from making one, and any user at all has said power. Granted, there are conditions where this doesn't work, but my idea of -fixing- TKInter would solve a lot of problems. >Don't you care that most programmers don't know about accessibility and they just don't create accessible programs not because they don't want, but because >they don't know about this thing? Of course I do. Non accessibility hurts you, as much as me, as much as anyone else when I have to take time away to try to make a program accessible. But, here is the thing; I have suggested work on TKInter to make such programs accessible, and I am perfectly willing to participate, as much as time allows, in such work. You are trying to make me come across as some evil cruel person because I don't submit to "hit them over the head with the hammer that is the ADA and force compliance," but rather I want to work with someone. At the end of the day, you lose, I win in general. People have made comments about the fact that all you did was parrot the evilness of TKInter to many threads, and now you've made comments on laws in existance that will help us. If you will note, no one even blinked at said laws. Now, the idea of fixing the problem (and not just switching libraries out of the STDLib, because as Ixokai already pointed out in another post, that won't happen), will get us much farther; whether or not Python, or anything else uses TKInter, it will be accessible, with some work put into talking to the community and I'll probably jump in the trenches myself and hammer out some code. >Retorical question... It is obviously that you don't care. Nope. I, as a blind person obviously don't care. Which is why I've spent so much time trying to push the idea of fixing TKInter. what a horrible horrible person I am. >Ok, you don't care. There are very many like you. But do you think that this is the right atitude? To not care about the >others at all but only about your selfish interests because the alternative is a loss of time? A loss of time? Where. I am not a proponent of forcing a lib into the STDLib while said library currently has problems (RR's segfaults, I'm "looking" at you). I know and accept the fact that Python is not going to become unstable with a library, in the hopes that some day people will start using wx since it's just there and voila, everything will be peaches and cream for us screen-reader using folks. >Can't you see that this isn't normal? Can't you see that some people don't even believe you that you are blind but you >still promote the non-accessible programs? RR's non-belief of me being blind or otherwise was to help his own argument, not because I'm promoting anything. >But there could be an explanation for this too. You might look great in your gang if the other blind people you know are >not able to use some programs but you are able to create your own which are accessible. You will appear really special. Yep. I'm talking about fixing a library to be more accessible so I can look great in my "gang" of sighted people I try so hard to blend in with, by daring to use such words as "watch." You mentioned the millions of people that I may help by quoting accessibility laws at, and here I say, you over estimate your self importance. If I went into my school and started yelling about the ADA, I would possibly get somewhere, but they would end up doing the bear minimum in order to comply with such laws. As a result, I don't really get what I want, and someone walks away from the encounter with the idea that all the blind people are the same, which may be a problem for someone who wishes to get employed. Now, on the other hand, if I were to walk into somewhere, say "hey, this is really unaccessible, and this is how we can fix it," from my experience, 9 times out of ten it will get fixed. That other 10% is where the ADA and other such laws come in. Through this encounter, someone walks away with a lot more respect for me, and if something should come up later, I can generally go talk to them. You have this "pity me," "I don't want to be a part of the sighted community," attitude, which will get you nowhere. If you limit yourself (by not doing such things as watching tv, or using phones with touchpads), that is -your- own fault, and no one elses. I say this because I used to be the same way, and I can garentee, if you give it time and start being a lot different with people, rather than just promoting your ADA laws and hiding behind your wall you've put up to save you from having to deal with things, you will be much happier. My preaching done with, I'd like to urge everyone to put this in a bit of perspective; essentially, what I don't want is someone walking away with Octavian's attitude as a stariotype for us all. From brian.curtin at gmail.com Tue Jan 25 09:24:08 2011 From: brian.curtin at gmail.com (Brian Curtin) Date: Tue, 25 Jan 2011 08:24:08 -0600 Subject: Finding the right Python executable on Windows In-Reply-To: <38326da6-8b30-4f88-b232-acdcd33b7d61@o14g2000yqe.googlegroups.com> References: <38326da6-8b30-4f88-b232-acdcd33b7d61@o14g2000yqe.googlegroups.com> Message-ID: On Tue, Jan 25, 2011 at 04:25, Geoff Bache wrote: > Hi all, > > I have a Python process on Windows and would like to start a Python > subprocess using the same interpreter. I wonder how to go about this? > > First, I tried the obvious > > subprocess.Popen([ sys.executable, "subproc.py", ... ]) > > but that fails, because my process has a "native launcher", (i.e. C: > \path\mylauncher.exe, which is just a wrapper around the Python > program) and hence sys.executable returns this path instead of the > interpreter location. It isn't appropriate to use the launcher for the > subprocess. > > I also tried using sys.exec_prefix but there didn't seem to be any > standard location for the interpreter under this directory in any > case. > > I feel certain there must be some way to do this as it seems a rather > basic thing somehow, can anyone give me a hint? > > Regards, > Geoff Bache If sys.executable doesn't work due to this "native launcher", you could try something like this: >>> import os >>> import sys >>> full_path = None >>> for path in sys.path: ... full = os.path.join(path, "python.exe") ... if os.path.exists(full): ... full_path = full ... >>> full_path 'c:\\python31\\python.exe' -------------- next part -------------- An HTML attachment was scrubbed... URL: From cournape at gmail.com Tue Jan 25 09:33:04 2011 From: cournape at gmail.com (David Cournapeau) Date: Tue, 25 Jan 2011 23:33:04 +0900 Subject: which scipy binary for Win32 In-Reply-To: References: Message-ID: On Tue, Jan 25, 2011 at 6:24 PM, Adam wrote: > Am looking at > http://sourceforge.net/projects/scipy/files/scipy/0.8.0/ > and I wonder which is the binary to install on WinXP ? > As pointed to by this page, http://www.scipy.org/Download > > All I can see on that sourceforge page are the huge > python2.6 and python2.7 Powerpacks, at 43megs or so > each. The scipy-0.8.0.zip seems to require compilation. What make you think those are not the right ones ? The size is caused by the presence of three architectures (sse2, sse3 and no sse support) inside the binary installer. > Does the scipy 2.7 Powerpack include numpy anyway ? No, you need to install numpy first. cheers, David From mgroth86 at gmail.com Tue Jan 25 10:05:50 2011 From: mgroth86 at gmail.com (Matthew Roth) Date: Tue, 25 Jan 2011 07:05:50 -0800 (PST) Subject: trouble installing MySQLdb (cygwin) + Bonus question References: Message-ID: <501470fc-c588-47d2-954d-17d825c5191c@v17g2000prc.googlegroups.com> On Jan 25, 4:30?am, Dennis Lee Bieber wrote: > On Mon, 24 Jan 2011 14:25:09 -0800 (PST), Matthew Roth > declaimed the following in > gmane.comp.python.general: > > > > > I've explored various avenues all day to no avail. Can anyone offer a > > solution or a direction to work towards. One avenue was ignorning the > > check for posix, and having it run setup_windows, but this just brings > > in problems with _winreg(?) seeing how I have a posix version of > > python through cygwin. > > ? ? ? ? Maybe you need the development headers for MySQL? -- I do believe I have them. Perhaps I need to find the correct way to point to them. I believe it is looking for the dev headers for a linux client when I am using a client for windows via cygwin. Or perhaps I should look into installing a separate linux mysql client in cygwin. I read of a similiar problem with perl, but the documentation felt a bit dated and several steps would no longer function correctly. > > > Lastly, for the bonus question. > > Why MySQLdb why not something like this: > > -- > > import os > > cmd = 'mysql -uroot -pxxx db -e "SELECT * FROM tblxxx;"' > > os.system(cmd) > > ? ? ? ? Passing username/password to a shell command that might be parsed by > some outside process? Security leak! -- I do indeed see that. However, all my python calls will be done within my local intranet. But is this a reason to not use os module at all? fetching a dirlisting or mkdir is still a valid reason to use the os Module, correct? > > ? ? ? ? Second -- MySQL is a server model DBMS; it doesn't have to be on the > local machine. -- unfortunately, for my use it does. We do have an old centOs box here, but the mysql running on that is severely outdated and so too is the python. I have been discouraged from upgrading the former, and the latter I was told only if I could do it through yum. Making an altinstall form source seems to be discouraged. Good news is I think they have decided to upgrade our development box. > > ? ? ? ? Third -- ever heard of TRANSACTIONS? How would you handle a > transaction if every SQL statement was a totally independent process? > -- No. quite to my embarrassment I haven't. But this is not to say I have not used them. It sounds as if I have. But, you can put more than one sql statement into a cmdline. mysql = "mysql -uuser -ppass db -e \"SELECT CURTIME(); CREATE TABLE tempTBL ( freq INT, x INT, y VARCHAR(255), PRIMARY KEY(x, y); LOAD XML INFLE 'doc' INTO TABLE tempTBL ROWS IDENTIFIED BY ''; INSERT INTO freqTbl(x,y,freq) SELECT x,y,freq FROM tempTBL ON DUPLICATE KEY UPDATE freq=tempTbl.freq+freqTbl.freq; SELECT CURTIME();\" os.system(mysql) I haven't tested that, but I know it works at the command line. I do fully intend to use MySQLdb through python and conduct more of the processing and parsing in python. It will be a learning experience. I have a background in anthropology, not computer science. But I love learning all this, and love that my place of employment encourages me to learn this. Unfortunately with self-learning you can sometimes miss out on important concepts and still accomplish tasks. Thank you for your reply. > ? ? ? ? Wulfraed ? ? ? ? ? ? ? ? Dennis Lee Bieber ? ? ? ? AF6VN > ? ? ? ? wlfr... at ix.netcom.com ? ?HTTP://wlfraed.home.netcom.com/ From misnomer at gmail.com Tue Jan 25 10:13:08 2011 From: misnomer at gmail.com (Nicholas Devenish) Date: Tue, 25 Jan 2011 15:13:08 +0000 Subject: WxPython versus Tkinter. In-Reply-To: References: <4D3E4377.3060807@tysdomain.com> Message-ID: <9MB%o.14110$%64.6074@unlimited.newshosting.com> On 25/01/2011 14:11, Littlefield, Tyler wrote: > My preaching done with, I'd like to urge everyone to put this in a bit of > perspective; essentially, what I don't want is someone walking away with > Octavian's attitude as a stariotype for us all. I can't speak for everyone (I don't have that presumption), but to me, given the two data points, you are certainly coming across as more level-headed, and thus representative. Octavians posts sound more and more like rantingricks as time goes on, which is not a good thing. This entire debate is silly, anyway; wx is doing perfectly well as a separate, but easily installed library, and I can't forsee a situation where it's inclusion in the standard library would happen. Even if a python newbie does start with TK, learning a second GUI toolkit shouldn't be that much of a struggle for them. I think even more damaging to any python newcomers than choosing the 'wrong' gui toolkit would be stumbling across this thread whilst looking for a toolkit; and thinking some of the behaviour here was representative of the python (or wx) community as a whole, which couldn't be further from the truth. I know that if I had found this thread when looking around I would certainly have been put off of wx (which is the toolkit I decided on when looking around). Perhaps there is room for a balanced, adult discussion on the future of GUI toolkits in python; But I don't believe that this can happen here without substantial changes to a certain persons attitudes (or other peoples kill files). From nitinpawar432 at gmail.com Tue Jan 25 10:16:48 2011 From: nitinpawar432 at gmail.com (Nitin Pawar) Date: Tue, 25 Jan 2011 20:46:48 +0530 Subject: trouble installing MySQLdb (cygwin) + Bonus question In-Reply-To: <501470fc-c588-47d2-954d-17d825c5191c@v17g2000prc.googlegroups.com> References: <501470fc-c588-47d2-954d-17d825c5191c@v17g2000prc.googlegroups.com> Message-ID: Nothing againest mysqlDB but I had tried using it sometimes and found it little difficult to use when you left the connections open idle for sometime . I had used PySQLPool then to solve my issues. Give it a try, I would recommend it. Thanks, nitin On Tue, Jan 25, 2011 at 8:35 PM, Matthew Roth wrote: > On Jan 25, 4:30 am, Dennis Lee Bieber wrote: > > On Mon, 24 Jan 2011 14:25:09 -0800 (PST), Matthew Roth > > declaimed the following in > > gmane.comp.python.general: > > > > > > > > > I've explored various avenues all day to no avail. Can anyone offer a > > > solution or a direction to work towards. One avenue was ignorning the > > > check for posix, and having it run setup_windows, but this just brings > > > in problems with _winreg(?) seeing how I have a posix version of > > > python through cygwin. > > > > Maybe you need the development headers for MySQL? > -- > I do believe I have them. Perhaps I need to find the correct way to > point to them. > I believe it is looking for the dev headers for a linux client when I > am using a client for windows via cygwin. > > Or perhaps I should look into installing a separate linux mysql client > in cygwin. > I read of a similiar problem with perl, but the documentation felt a > bit dated and several steps would no longer function correctly. > > > > > > Lastly, for the bonus question. > > > Why MySQLdb why not something like this: > > > -- > > > import os > > > cmd = 'mysql -uroot -pxxx db -e "SELECT * FROM tblxxx;"' > > > os.system(cmd) > > > > Passing username/password to a shell command that might be parsed > by > > some outside process? Security leak! > -- > I do indeed see that. However, all my python calls will be done within > my local intranet. > But is this a reason to not use os module at all? fetching a > dirlisting or mkdir is still > a valid reason to use the os Module, correct? > > > > Second -- MySQL is a server model DBMS; it doesn't have to be on > the > > local machine. > -- > unfortunately, for my use it does. We do have an old centOs box here, > but the mysql running on that is severely outdated and so too is the > python. > I have been discouraged from upgrading the former, and the latter I > was told only if I could do it through yum. Making an altinstall form > source seems to be > discouraged. Good news is I think they have decided to upgrade our > development box. > > > > Third -- ever heard of TRANSACTIONS? How would you handle a > > transaction if every SQL statement was a totally independent process? > > -- > No. quite to my embarrassment I haven't. But this is not to say I have > not used them. It sounds as if I have. > But, you can put more than one sql statement into a cmdline. > mysql = "mysql -uuser -ppass db -e \"SELECT CURTIME(); > CREATE TABLE tempTBL ( > freq INT, > x INT, > y VARCHAR(255), > PRIMARY KEY(x, y); > > LOAD XML INFLE 'doc' > INTO TABLE tempTBL > ROWS IDENTIFIED BY ''; > > INSERT INTO freqTbl(x,y,freq) > SELECT x,y,freq FROM tempTBL > ON DUPLICATE KEY UPDATE freq=tempTbl.freq+freqTbl.freq; > > SELECT CURTIME();\" > os.system(mysql) > > I haven't tested that, but I know it works at the command line. > I do fully intend to use MySQLdb through python and conduct more of > the processing and parsing in python. It will be a learning > experience. I have a background in anthropology, not computer science. > But I love learning all this, and love that my place of employment > encourages me to learn this. Unfortunately with self-learning you can > sometimes miss out on important concepts and still accomplish tasks. > > Thank you for your reply. > > > > Wulfraed Dennis Lee Bieber AF6VN > > wlfr... at ix.netcom.com HTTP://wlfraed.home.netcom.com/ > > -- > http://mail.python.org/mailman/listinfo/python-list > -- Nitin Pawar -------------- next part -------------- An HTML attachment was scrubbed... URL: From bryan.oakley at gmail.com Tue Jan 25 10:19:01 2011 From: bryan.oakley at gmail.com (Bryan) Date: Tue, 25 Jan 2011 07:19:01 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <8q7sgiF5tpU1@mid.individual.net> Message-ID: <19891784-d6a3-41ac-a097-5902a6323bc0@o21g2000prn.googlegroups.com> On Jan 25, 6:03?am, Bob Martin wrote: > in 650672 20110125 115033 Bryan wrote: > >> Do you think the whole world speaks US English? > > >No, absolutely not. I don't see how you go from "I don't think all > >developers think about i18n" to "I think everyone speaks english". > > I said "US English", not just English, and you didn't say > "I don't think all developers think about i18n", you said "I'm guessing none". > Big difference. ?I think your attitude to this is US-only. Ah! Now I understand your comment. Yes, without realizing it I was referring only to software developers in the US not having an internationalization mindset. I should have been more clear, and obviously I was making a poor generalization. Do non-US-based developers focus a lot on accessibility too, since that's what really started this whole sub-thread? From rustompmody at gmail.com Tue Jan 25 10:29:05 2011 From: rustompmody at gmail.com (rusi) Date: Tue, 25 Jan 2011 07:29:05 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <8q7sgiF5tpU1@mid.individual.net> <19891784-d6a3-41ac-a097-5902a6323bc0@o21g2000prn.googlegroups.com> Message-ID: <0b12cdb1-45b4-41e4-9bdb-074ee669d76b@k14g2000pre.googlegroups.com> Just trying to sift the BS from the real issues Heres a list of the issues relating to GUI toolkits Look Nativity-1 (as in apps look like other apps on the OS) Nativity-2 (as in uses 'bare-metal' and not a separate interpreter) Themeing (ttk) Efficiency (extra interpreter) Cross Platform Stability (crashes on some OSes) Programmability Accessibility i18n Availability of gui builder Licence From mailing at franzoni.eu Tue Jan 25 10:32:19 2011 From: mailing at franzoni.eu (Alan Franzoni) Date: Tue, 25 Jan 2011 16:32:19 +0100 Subject: Behaviour-based interface/protocol implementation? In-Reply-To: References: Message-ID: On Tue, Jan 25, 2011 at 7:55 AM, Chris Rebert wrote: > Not true actually: > > Python 2.7.1 (r271:86832, Dec ?5 2010, 00:12:20) > [GCC 4.2.1 (Apple Inc. build 5664)] on darwin > Type "help", "copyright", "credits" or "license" for more information. >>>> class MyContainer(object):# no special inheritance > ... ? ? def __len__(self): > ... ? ? ? ? return 42 > ... >>>> # didn't do any registration. >>>> from collections import Sized >>>> issubclass(MyContainer, Sized) > True >>>> isinstance(MyContainer(), Sized) > True You're right, I forgot about subclass check. But that's really a placebo, because it statically checks the object's *class* for such method, not the actual instance: from collections import Sized class MyObj(object): pass mo = MyObj() mo.__len__ = lambda: 1 print isinstance(mo, Sized) False > Not precisely that I know of, no. The `abc`/`collections` system comes > closest, but it does not check method signatures; it merely verifies > methods' existence. It only verifies the method's existence on the class. It does nothing of what I'd like at runtime. > You could *definitely* write something like that by combining the > `abc` and `inspect` modules though: > http://docs.python.org/library/inspect.html#inspect.getargspec > http://docs.python.org/library/abc.html#abc.ABCMeta.__subclasshook__ Yes, I'm experimenting with inspect for signature matching. > Duck typing partisans would question what the point of such an > elaborate mechanism would be when it won't change the fact that your > type errors will still occur at run-time and be of essentially the > same character as if you didn't use such a mechanism in the first > place. The point is that this way I might identify ducktypes - at runtime - in a way that doesn't clutter code. getattr() blocks are simply boring. Of course the runtime exception-check approach might work as well (call the method and see whether it crashes) and I may finally pick that approach, but I'd like not to clutter my code with explicit try...except blocks. The very same approach might help. The chance for signature mismatch is of course high when using extreme runtime dynamic proxies (methods with *args, **kwargs signature), but at least I won't try faking static typing. Anything I fetch would just be runtime information. -- Alan Franzoni -- contact me at public@[mysurname].eu From bob.martin at excite.com Tue Jan 25 10:37:07 2011 From: bob.martin at excite.com (Bob Martin) Date: Tue, 25 Jan 2011 15:37:07 GMT Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <19891784-d6a3-41ac-a097-5902a6323bc0@o21g2000prn.googlegroups.com> Message-ID: <8q8913F2slU1@mid.individual.net> in 650680 20110125 151901 Bryan wrote: >On Jan 25, 6:03=A0am, Bob Martin wrote: >> in 650672 20110125 115033 Bryan wrote: >> >> Do you think the whole world speaks US English? >> >> >No, absolutely not. I don't see how you go from "I don't think all >> >developers think about i18n" to "I think everyone speaks english". >> >> I said "US English", not just English, and you didn't say >> "I don't think all developers think about i18n", you said "I'm guessing n= >one". >> Big difference. =A0I think your attitude to this is US-only. > >Ah! Now I understand your comment. Yes, without realizing it I was >referring only to software developers in the US not having an >internationalization mindset. I should have been more clear, and >obviously I was making a poor generalization. > >Do non-US-based developers focus a lot on accessibility too, since >that's what really started this whole sub-thread? I don't think so; it was never a requirement for the software I wrote, though I know I had some blind users. But NLS was a must and it has to be designed in from the start - very difficult to add it later. From funthyme at gmail.com Tue Jan 25 11:02:08 2011 From: funthyme at gmail.com (John Pinner) Date: Tue, 25 Jan 2011 08:02:08 -0800 (PST) Subject: Which is the best book to learn python References: <188c0a9f-4e93-4fae-b3f9-e7c84f8030fd@v31g2000pri.googlegroups.com> Message-ID: On Jan 25, 8:56?am, Mark Summerfield wrote: > On Jan 24, 5:09?pm, santosh hs wrote: > > > Hi All, > > i am beginner to python please tell me which is the best available > > reference for beginner to start from novice > > If you want to learn Python 3 and have some prior programming > experience (in any modern procedural or object oriented language), you > might find > "Programming in Python 3" (http://www.qtrac.eu/py3book.html) to be a > good choice. (I'm biased though since I wrote it;-) You may be biased, but you're right :-) Nice book. John -- From orasnita at gmail.com Tue Jan 25 11:16:06 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Tue, 25 Jan 2011 18:16:06 +0200 Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com> <4D3ED9FE.1070304@tysdomain.com> Message-ID: <19272564BBF2480085CE52D8304895D7@teddy> From: "Littlefield, Tyler" > >Wow! I, I, I, I... is there a sentence that doesn't talk about your > self interests? > It is clear you have been taking lessons from RR; the word I does not > convey self interest, in fact, it is the best word suited to speaking of > oppinions (which is all that these are), in the first person. Lets move > on, shall we? The opinions can also be about other people, not only about your own interests. And in that case you might start by telling what *they* like, or what *they* need, or about *they* want or other things that involves *they* and not only you. > >You haven't downloaded any inaccessible program made with Tkinter, you > didn't have any problems, You can create an accessible program if you > can't find > >an accessible one, you care only to please the other for working with > you and so on. > No. I said, I can find a program that is accessible, if I find one that > isn't. Totally different from making one, and any user at all has said > power. Granted, there are conditions where this doesn't work, but my > idea of -fixing- TKInter would solve a lot of problems. The idea has no value when it is just an idea. Tk is a very old GUI so there may be many reasons why it is not accessible yet. When it will be accessible, then we will be able to consider it useful, but until then... it is useful but not for everyone. > >Don't you care that most programmers don't know about accessibility > and they just don't create accessible programs not because they don't > want, but because > >they don't know about this thing? > Of course I do. Non accessibility hurts you, as much as me, as much as > anyone else when I have to take time away to try to make a program > accessible. But, here is the thing; I have suggested work on TKInter to > make such programs accessible, and I am perfectly willing to > participate, as much as time allows, in such work. You are trying to > make me come across as some evil cruel person because I don't submit to > "hit them over the head with the hammer that is the ADA and force > compliance," but rather I want to work with someone. At the end of the > day, you lose, I win in general. People have made comments about the > fact that all you did was parrot the evilness of TKInter to many > threads, and now you've made comments on laws in existance that will > help us. If you will note, no one even blinked at said laws. Now, the What laws are you talking about? I have told only about the discrimination. Are you talking about another law, or do you really think that the discrimination is OK from your perspective if this opinion can help you to have a good image in a potential employer's eyes, in order to have a personal benefit? > >Retorical question... It is obviously that you don't care. > Nope. I, as a blind person obviously don't care. Which is why I've spent > so much time trying to push the idea of fixing TKInter. what a horrible > horrible person I am. It is very good if you spend time to make Tkinter accessible, but until it will really be accessible, it is not accessible at all so your efforts have absolutely no value for those who try to use a program but can't do it because it is not accessible. MS and Adobe also pretend that Silverlight and Flash are accessible, but who cares about they say when I have seen that they are not really accessible? > >Ok, you don't care. There are very many like you. But do you think > that this is the right atitude? To not care about the >others at all but > only about your selfish interests because the alternative is a loss of > time? > A loss of time? Where. I am not a proponent of forcing a lib into the > STDLib while said library currently has problems (RR's segfaults, I'm > "looking" at you). I know and accept the fact that Python is not going > to become unstable with a library, in the hopes that some day people > will start using wx since it's just there and voila, everything will be > peaches and cream for us screen-reader using folks. Why do you think that WxPython won't work fine? WxPerl works very well and WxPython even has a better documentation than WxPerl. Why do you think that WxPython can't be improved? Why do you think that only Tkinter can be improved to be accessible, which mean a lot of changes, but WxPython can't be corrected to not give that segfault? > >Can't you see that this isn't normal? Can't you see that some people > don't even believe you that you are blind but you >still promote the > non-accessible programs? > RR's non-belief of me being blind or otherwise was to help his own > argument, not because I'm promoting anything. Oh yes you are promoting Tkinter just because you see that the majority of Python users prefer Tkinter, because you are interested much more on adapting to the society than helping the society to know why it needs to change. As you said, it is easier and much more effective of course. > >But there could be an explanation for this too. You might look great > in your gang if the other blind people you know are >not able to use > some programs but you are able to create your own which are accessible. > You will appear really special. > Yep. I'm talking about fixing a library to be more accessible so I can > look great in my "gang" of sighted people I try so hard to blend in > with, by daring to use such words as "watch." I'm sorry, I don't have anything against you, but I can tell you that I don't like the guys that like to appear great for just talking about something. If you want to be great, make Tkinter to be accessible and convince the Python developers to include your fork in the Python distribution. That thing would be great, not only talking about what you intend to do. Until then, there is another solution which is already available. > You mentioned the millions of people that I may help by quoting > accessibility laws at, and here I say, you over estimate your self > importance. If I went into my school and started yelling about the ADA, > I would possibly get somewhere, but they would end up doing the bear > minimum in order to comply with such laws. As a result, I don't really > get what I want, and someone walks away from the encounter with the idea > that all the blind people are the same, which may be a problem for > someone who wishes to get employed. And what do you think it is more important? To know that your atitude helped millions of blind people like you all over the world to have a much more accessible life, or only to play nice, to not disturb anyone and hope to have bigger chances to get a job? > You have this "pity me," "I don't want to be a part of the sighted > community," attitude, which will get you nowhere. I don't think that you as a blind person should have the atitude of "pitty me" as you say, because the others shouldn't make special applications for you with bigger efforts because of pitty. The other should make common applications like for anybody else that doesn't have that health problem, applications that should be accessible by default, and they should do it from the respect for you as to any other person, thinking that his/her application need to be accessible to the people, and that some of the people access it using their eyes, other people access it using their ears or hands, and so on. If the person that makes that application doesn't care about some potential users that simply can't use it because of some health problems, than that person should not be respected. It is very simple. She/he should not be respected because she/he has a wrong atitude. But in most cases the programmers create inaccessible applications not because they don't care, but because they are not informed, because Python promotes a bad GUI lib, and they start learning to use it, and finally they prefer it. Well, I think that the programmers need to be better informed, that's why I have lost so much time answering to this thread. > I'd like to urge everyone to put this in a bit of > perspective; essentially, what I don't want is someone walking away with > Octavian's attitude as a stariotype for us all. Your atitude is really one of a sclave that tries to make pleasure for those who might help you to get a job or let you integrate in a society that otherwise don't respect the disabled people which are different than them. And if somebody tries to advocate for the benefit of the majority of simple users which are not programmers but simple computer users, you don't care at all about them because you just want to show that you are exactly like the sighted people, meaning that you also want to show that you also don't care about those who are different. Nice atitude. Octavian From rantingrick at gmail.com Tue Jan 25 11:36:05 2011 From: rantingrick at gmail.com (rantingrick) Date: Tue, 25 Jan 2011 08:36:05 -0800 (PST) Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com> <9MB%o.14110$%64.6074@unlimited.newshosting.com> Message-ID: <607ba3a8-838c-46fc-be56-829c303f2544@c13g2000prc.googlegroups.com> On Jan 25, 9:13?am, Nicholas Devenish wrote: > I think even more damaging to any python newcomers than choosing the > 'wrong' gui toolkit would be stumbling across this thread whilst looking > for a toolkit; and thinking some of the behaviour here was > representative of the python (or wx) community as a whole, which > couldn't be further from the truth. I know that if I had found this > thread when looking around I would certainly have been put off of wx > (which is the toolkit I decided on when looking around). Well then that would show how shallow and jealous you are. It would also show how you have no ability to think for yourself. That you are an emotional creature who refuses to use reason and logic in your decision process. Stop jumping on the troll wagon and start thinking for yourself! From rantingrick at gmail.com Tue Jan 25 11:46:30 2011 From: rantingrick at gmail.com (rantingrick) Date: Tue, 25 Jan 2011 08:46:30 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <8q7sgiF5tpU1@mid.individual.net> <19891784-d6a3-41ac-a097-5902a6323bc0@o21g2000prn.googlegroups.com> <0b12cdb1-45b4-41e4-9bdb-074ee669d76b@k14g2000pre.googlegroups.com> Message-ID: <6172f40f-3ab5-4626-aabc-7e5a44953dcf@f20g2000prn.googlegroups.com> On Jan 25, 9:29?am, rusi wrote: > Just trying to sift the BS from the real issues > > Heres a list of the issues relating to GUI toolkits Finally someone who knows what the argument is really about! Thanks rusi! > Look There is no doubt wxPython has better look and feel. (+1 wx) > Nativity-1 (as in apps look like other apps on the OS) Again (+1 wx) > Nativity-2 (as in uses 'bare-metal' and not a separate interpreter) Well Tk uses a separate interpretor so (+1 wx) > Themeing (ttk) Yes Tk has themes now. Not sure about how useful they are and what wx offers so (+0 both) > Efficiency (extra interpreter) Well wx is by far more efficient (+1 wx) > Cross Platform Wx is cross platform but has some warts. We need to create an abstraction API to insulate the new users from segfaults and make wx a safe cross platform GUI so (+1 Tkinter) > Stability (crashes on some OSes) Wx is stable but does has some warts as is. (+1 Tkinter) > Programmability Wx needs a better API whereas Tkinter is ok (+1 Tkinter) > Accessibility Well we know Tkinter in not accessable (+1 wx) > i18n (+1 wx) > Availability of gui builder +0 both > Licence Tkinter is completely open source and wx is LGPL. Some find this to be a problem however i don't (+0 both) Tkinter: 3 wxPython: 6 From rantingrick at gmail.com Tue Jan 25 11:53:43 2011 From: rantingrick at gmail.com (rantingrick) Date: Tue, 25 Jan 2011 08:53:43 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <19891784-d6a3-41ac-a097-5902a6323bc0@o21g2000prn.googlegroups.com> <8q8913F2slU1@mid.individual.net> Message-ID: <7a6f53b6-d729-4be1-8ebe-b29b6b1c184d@21g2000prv.googlegroups.com> On Jan 25, 9:37?am, Bob Martin wrote: > I don't think so; it was never a requirement for the software I wrote, > though I know I had some blind users. ?But NLS was a must and it has > to be designed in from the start - very difficult to add it later. Thats the point i keep trying to make about accessibility. Those who are affected directly by accessibility (the users) are not in control of accessibilities inclusion. However those that are in control are twice removed from the torments of needing accessibility. What is wrong with this picture? Well specifically, if the developers refuse (or are oblivious) to include accessibility support then the users are just screwed! Plain and simple. GUI library developers have a responsibility to include support for accessibility because if they don't no one else can! From dmaziuk at bmrb.wisc.edu Tue Jan 25 12:22:05 2011 From: dmaziuk at bmrb.wisc.edu (dmaziuk) Date: Tue, 25 Jan 2011 09:22:05 -0800 (PST) Subject: [Python] how to tell if cursor is sqlite.Cursor or psycopg2.Cursor In-Reply-To: Message-ID: <5b13a8df-b1be-410d-b116-5c4f38ca287a@glegroupsg2000goo.googlegroups.com> D'oh. You're right, of course. Thank you Dima From tjreedy at udel.edu Tue Jan 25 12:48:15 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Tue, 25 Jan 2011 12:48:15 -0500 Subject: Behaviour-based interface/protocol implementation? In-Reply-To: References: Message-ID: On 1/25/2011 10:32 AM, Alan Franzoni wrote: > You're right, I forgot about subclass check. But that's really a > placebo, because it statically checks the object's *class* for such > method, That is exactly the proper check. Instance *methods* are defined on the class. > not the actual instance: Function attributes of instances are not methods. This is especially true of special methods. > from collections import Sized > > class MyObj(object): > pass > > mo = MyObj() > mo.__len__ = lambda: 1 > > > print isinstance(mo, Sized) > False This is correct! print(len(mo)) TypeError: object of type 'MyObj' has no len() -- Terry Jan Reedy From usernet at ilthio.net Tue Jan 25 13:01:14 2011 From: usernet at ilthio.net (Tim Harig) Date: Tue, 25 Jan 2011 18:01:14 +0000 (UTC) Subject: Which is the best book to learn python References: <188c0a9f-4e93-4fae-b3f9-e7c84f8030fd@v31g2000pri.googlegroups.com> Message-ID: On 2011-01-25, Mark Summerfield wrote: > On Jan 24, 5:09?pm, santosh hs wrote: >> Hi All, >> i am beginner to python please tell me which is the best available >> reference for beginner to start from novice > > If you want to learn Python 3 and have some prior programming > experience (in any modern procedural or object oriented language), you > might find > "Programming in Python 3" (http://www.qtrac.eu/py3book.html) to be a > good choice. (I'm biased though since I wrote it;-) I am usually a big fan for O'reilly books and I started learning Python from the first edition of _Learning Python_. It's not a bad book and it will get you started. I cannot speak for the latest edition which seems to contain quite a bit more then the version I read. When Python 3 was released, I decided to try relearn Python 3 from scratch rather then trying to simply figure out the differences between versions. I picked up Mr. Summerfield's book because it seemed to be the first book to cover Python 3 excusively and I was rather impressed. I would definitely recommend it to others. [OT] P.S. to Mark Summerfield. You have been hanging around in the Go Nuts mailing list. Is that any indication that you might be considering writing a book on Go? If you do, you will have at least one customer. From tjreedy at udel.edu Tue Jan 25 13:07:31 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Tue, 25 Jan 2011 13:07:31 -0500 Subject: WxPython versus Tkinter. In-Reply-To: <8q7sgiF5tpU1@mid.individual.net> References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <8q7sgiF5tpU1@mid.individual.net> Message-ID: On 1/25/2011 7:03 AM, Bob Martin wrote: > "I bet not much" - there you go again ;-) > You'll find that nearly all software used in Europe (and most other parts) > is internationalized or it wouldn't stand a chance. I suspected that is true of today's Europe, but do you have any evidence that software written in Japan, for instance, is any more internationalized than US software? I would expect the opposite since they tend to use, and still use their Japanese-only encodings with their unique writing system. -- Terry Jan Reedy From cralef at earthlink.net Tue Jan 25 13:08:34 2011 From: cralef at earthlink.net (Craig Leffel) Date: Tue, 25 Jan 2011 11:08:34 -0700 Subject: documentation / reference help References: Message-ID: Where does it return the value to? What do I need to put in the calling function so that I can use that value? I need a variable name to refer to. Shouldn't I have to define that variable someplace? "Littlefield, Tyler" wrote in message news:mailman.1103.1295811520.6505.python-list at python.org... > The return value simply returns a value to the calling function, which the > function can handle, however it wants. so: for example > def add(a, b): > return (a+b) > > That simply returns the value a+b, which you can use however you like, > like so: i=add(2,3) will assign the return value to add. > > I recommend you check out the tutorial on python.org, which explains all > of this; the documentation does not need updating, at least not in that > respect. > On 1/23/2011 11:41 AM, Scott Meup wrote: >> I'm trying tolearn Python. The documentation tells syntax, and other >> things >> about a command. But for too many commands, it doesn't tell what it >> does. >> for instance, in VB the 'return' command tells the program what line to >> execute after some event (usually an error). In Python it appears to >> return >> a value. Where does it return it to? I couldn't find anywhere on the >> Python website to find out or to ask Python to upgrade their >> documentation. >> Can somebody please recommend a source. >> >> > > > -- > > Thanks, > Ty > From tjreedy at udel.edu Tue Jan 25 13:15:19 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Tue, 25 Jan 2011 13:15:19 -0500 Subject: WxPython versus Tkinter. In-Reply-To: <0b12cdb1-45b4-41e4-9bdb-074ee669d76b@k14g2000pre.googlegroups.com> References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <8q7sgiF5tpU1@mid.individual.net> <19891784-d6a3-41ac-a097-5902a6323bc0@o21g2000prn.googlegroups.com> <0b12cdb1-45b4-41e4-9bdb-074ee669d76b@k14g2000pre.googlegroups.com> Message-ID: On 1/25/2011 10:29 AM, rusi wrote: > Just trying to sift the BS from the real issues > > Heres a list of the issues relating to GUI toolkits > > > Look > Nativity-1 (as in apps look like other apps on the OS) > Nativity-2 (as in uses 'bare-metal' and not a separate interpreter) > Themeing (ttk) > Efficiency (extra interpreter) > Cross Platform > Stability (crashes on some OSes) > Programmability > Accessibility > i18n > Availability of gui builder > Licence Good as far as it goes, but this list leaves out several requirements (already posted by me, Steve Hansen, and others) for a Python 3 new stdlib module. It does not matter for the stdlib if wxpython is 3 times as good as tkinter, by some measure, as long as it is ineligible. -- Terry Jan Reedy From benjamin.kaplan at case.edu Tue Jan 25 13:32:48 2011 From: benjamin.kaplan at case.edu (Benjamin Kaplan) Date: Tue, 25 Jan 2011 13:32:48 -0500 Subject: documentation / reference help Message-ID: On Jan 25, 2011 1:19 PM, "Craig Leffel" wrote: > > Where does it return the value to? > > What do I need to put in the calling function so that I can use that value? > I need a variable name to refer to. Shouldn't I have to define that variable > someplace? > Python functions are like mathematical functions. The function call itself evaluates to a value (whatever is returned) which can be stored to a variable. y = f(x) You can even use the result without directly storing it in a variable. print f(g(x)) > "Littlefield, Tyler" wrote in message > news:mailman.1103.1295811520.6505.python-list at python.org... > > The return value simply returns a value to the calling function, which the > > function can handle, however it wants. so: for example > > def add(a, b): > > return (a+b) > > > > That simply returns the value a+b, which you can use however you like, > > like so: i=add(2,3) will assign the return value to add. > > > > I recommend you check out the tutorial on python.org, which explains all > > of this; the documentation does not need updating, at least not in that > > respect. > > On 1/23/2011 11:41 AM, Scott Meup wrote: > >> I'm trying tolearn Python. The documentation tells syntax, and other > >> things > >> about a command. But for too many commands, it doesn't tell what it > >> does. > >> for instance, in VB the 'return' command tells the program what line to > >> execute after some event (usually an error). In Python it appears to > >> return > >> a value. Where does it return it to? I couldn't find anywhere on the > >> Python website to find out or to ask Python to upgrade their > >> documentation. > >> Can somebody please recommend a source. > >> > >> > > > > > > -- > > > > Thanks, > > Ty > > > > > > -- > http://mail.python.org/mailman/listinfo/python-list -------------- next part -------------- An HTML attachment was scrubbed... URL: From smokefloat at gmail.com Tue Jan 25 13:38:33 2011 From: smokefloat at gmail.com (David Hutto) Date: Tue, 25 Jan 2011 10:38:33 -0800 (PST) Subject: Which is the best book to learn python References: <188c0a9f-4e93-4fae-b3f9-e7c84f8030fd@v31g2000pri.googlegroups.com> Message-ID: <504ce080-c77b-4b69-a19e-75eca4c4e099@v31g2000pri.googlegroups.com> Building Skills In Python has been a great learning tool, and reference(I don't exactly learn linearly): homepage.mac.com/s_lott/books/python.html From cmpython at gmail.com Tue Jan 25 14:16:05 2011 From: cmpython at gmail.com (CM) Date: Tue, 25 Jan 2011 11:16:05 -0800 (PST) Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com> <9MB%o.14110$%64.6074@unlimited.newshosting.com> Message-ID: On Jan 25, 10:13?am, Nicholas Devenish wrote: Nicholas, > I think even more damaging to any python newcomers than choosing the > 'wrong' gui toolkit would be stumbling across this thread whilst looking > for a toolkit; and thinking some of the behaviour here was > representative of the python (or wx) community as a whole, which > couldn't be further from the truth. I know that if I had found this > thread when looking around I would certainly have been put off of wx > (which is the toolkit I decided on when looking around). I don't know--you sound too reasonable to extrapolate from this goofy thread to a huge toolkit project that has been around for years and is used in project such as Audacity (that's the wxWidgets version, but close enough). But yes, it almost at times seemed like--from what I could manage to read--this thread was a "psy-ops" (psychological operations) trick to turn off wxPython adopters by associating it with juvenile nonsense, and yes, on a quick scan it could turn people off. Which would be a shame, because, as you, Andrea, and others have noted, wxPython is a nice toolkit. For those interested, download it and make sure to download the Demo, that shows what can be done with it. (Very early in this discussion the screenshots on the website came up; they are horrifically out of date and wxPython deserves better and looks great on, say, Windows 7 or Ubuntu....well, it looks native, and that's the point). > Perhaps there is room for a balanced, adult discussion on the future of > GUI toolkits in python; But I don't believe that this can happen here > without substantial changes to a certain persons attitudes (or other > peoples kill files). It would be more likely that wxPython would be in the stdlib than those attitudes will change. :D But what I would enjoy is a discussion about GUIs in terms of "develop once, deploy many". For example, pyjamas, since I think being able to develop one GUI that works as desktop or web-based is kind of exciting. Unfortunately, it seems it is far off from anything easily usable at this point. Part of that might be it doesn't have a big enough community of developers yet. It's also just really difficult, I'm sure. Another interesting issue in this is mobile phone app development. It is frustrating to devote a lot of time to learning a desktop widget toolkit and Python and while that is occurring the culture moves more and more toward app use in which that is not too applicable. Some of that cannot be helped if Apple, e.g., restricts what can be used on their phones. I guess for Android one can already develop with PyQt and it will run on desktop or phone? From orasnita at gmail.com Tue Jan 25 14:24:55 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Tue, 25 Jan 2011 21:24:55 +0200 Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com> <9MB%o.14110$%64.6074@unlimited.newshosting.com> Message-ID: <4A48EDF6D7634F2E994661A457451E87@teddy> From: "Nicholas Devenish" > I can't speak for everyone (I don't have that presumption), but to me, > given the two data points, you are certainly coming across as more > level-headed, and thus representative. Octavians posts sound more and > more like rantingricks as time goes on, which is not a good thing. Can you tell why? Because you probably don't care about those who can't use the programs made with Tkinter or because you consider the discrimination something normal, right? And you said that it is not a good thing. Good thing for whom? For the blind people Tkinter is the worst thing possible. Or do you want to say that it is not true? > This entire debate is silly, anyway; wx is doing perfectly well as a > separate, but easily installed library, and I can't forsee a situation > where it's inclusion in the standard library would happen. Even if a > python newbie does start with TK, learning a second GUI toolkit > shouldn't be that much of a struggle for them. No, it shouldn't be, but I see that you don't understand after this long thread why Tkinter should be avoided. WxPython shouldn't be the second choice. WxPython shouldn't be the first choice or the single choice. The single choices should be always only those who don't introduce discrimination. Don't you agree with this? Well, for the moment only WxPython doesn't include discrimination if we are talking about portable GUIs. Please tell me if I wasn't clear enough or what you don't agree with. > I think even more damaging to any python newcomers than choosing the > 'wrong' gui toolkit would be stumbling across this thread whilst looking > for a toolkit; and thinking some of the behaviour here was > representative of the python (or wx) community as a whole, which > couldn't be further from the truth. I know that if I had found this > thread when looking around I would certainly have been put off of wx > (which is the toolkit I decided on when looking around). Why? You are not clear at all. What damage generates this thread to WxPython? > Perhaps there is room for a balanced, adult discussion on the future of > GUI toolkits in python; But I don't believe that this can happen here > without substantial changes to a certain persons attitudes (or other > peoples kill files). The atitude that needs to be changed is the one that considerates the majority more important than a minority which is a minority because of health problems, a minority that is a minority without its will. In my country there is a law that says that the society should adapt to the people with disabilities (and not viceversa), and that law is probably copied from the legislation of other european countries. That law is a very good one, but the problem is that nobody cares to respect it, because most of the people have Tyler's opinion. Yes, I know, that's life, which is not right, that's faith, bla bla, but it doesn't mean that my atitude need to be changed. The atitude that needs to be changed is the one that considers the discrimination something normal and the one that considers that the disabled people should adapt to the society even though most of them can't do that because of their health problems. Octavian From rantingrick at gmail.com Tue Jan 25 14:25:06 2011 From: rantingrick at gmail.com (rantingrick) Date: Tue, 25 Jan 2011 11:25:06 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <8q7sgiF5tpU1@mid.individual.net> <19891784-d6a3-41ac-a097-5902a6323bc0@o21g2000prn.googlegroups.com> <0b12cdb1-45b4-41e4-9bdb-074ee669d76b@k14g2000pre.googlegroups.com> Message-ID: <7bb56aba-0f96-4b7e-a78d-3398003a0e38@c39g2000yqi.googlegroups.com> On Jan 25, 12:15?pm, Terry Reedy wrote: > On 1/25/2011 10:29 AM, rusi wrote: > > > > > > > > > > > Just trying to sift the BS from the real issues > > > Heres a list of the issues relating to GUI toolkits > > > Look > > Nativity-1 (as in apps look like other apps on the OS) > > Nativity-2 (as in uses 'bare-metal' and not a separate interpreter) > > Themeing (ttk) > > Efficiency (extra interpreter) > > Cross Platform > > Stability (crashes on some OSes) > > Programmability > > Accessibility > > i18n > > Availability of gui builder > > Licence > > It does not matter for the stdlib if wxpython is 3 times > as good as tkinter, by some measure, as long as it is ineligible. Terry, i think rusi was just posting a general list of some likable attributes of a 21st century GUI library. No were did he mention the words "wx" or "python". ------------------ The Sad Reality ------------------ Sadly the fact is that the "elite" have already made a decision. And they don't care how bad "Tkinter" is for Python's stdlib or how good "GUI library X" is for Python's stdlib. They do not want to make a change. They are in bed with TclTk. They have lost all vision. This is the reality. --------------------------- What can we do about it? --------------------------- However, like all totalitarian regimes, when the peasants start demanding equality and then storm the castle... then and only then will the closed minded and selfish elite listen! So we need to make noise, a lot of noise. And we need to be persistent. We need to demand equality through accessibility. We need to demand feature rich libraries that do not cripple us like Tkinter. We need to demand that Pythons community re-establish a vision for the future. A vision that is representative of ALL the people -- and not a few fat cats at the top. -------------------------------- From Dictatorship to Democracy -------------------------------- I have time and time again given examples of how python-dev can get a real idea of what the wider community is thinking. One of these ideas would be to send out a "Tkinter Removal Warning" that would be displayed when the Python installer was run and every time Tkinter is imported. The warning would show a website were people could vote to keep Tkinter in the stdlib. This is the only way we can truly understand what our community members are thinking about Tkinter. Anything else is purely speculation. ----------------------------------------------- The silence of the peasants, and an awakening ----------------------------------------------- Many folks out there share our views that Tkinter is a weight around Python's neck, however they are too fearful to speak out for fear of excommunication (the kill file!). However i must tell all of you that just as other nations have risen against their own brutal governments and survived, so to shall you IF you combine your voices as one. There is power in numbers that no "elite theocracy" can deny. United we can re-establish the original dream that build Python. Guido forged the path and we must not let his work be in vain. But now the community has been so overrun with trolls, naysayers, and negative mind sets that infect any semblance of civility and remove good judgment from our coffers. We are doomed unless we re-awake the dream. From orasnita at gmail.com Tue Jan 25 14:32:15 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Tue, 25 Jan 2011 21:32:15 +0200 Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com><8q7sgiF5tpU1@mid.individual.net> <19891784-d6a3-41ac-a097-5902a6323bc0@o21g2000prn.googlegroups.com> Message-ID: From: "Bryan" Do non-US-based developers focus a lot on accessibility too, since that's what really started this whole sub-thread? Almost nobody focuses on accessibility, and nobody should focus on accessibility. If you target a program for your national population and your national population speak a single language, then no, you won't need to use I18N. If you create a graphic design application so you evidently target it to the sighted people, it is obviously that you won't need to make an accessible application. But if you make a program that could be used by the whole world then you should use I18N and that program should also be accessible to everyone, not only sighted, or only English-speakers, because otherwise that application creates discrimination. Usually I18N is offered using gettext so the users that want that application translated in their language can do the translation themselves, but if the application uses Tkinter, those who need a screen reader cannot do absolutely anything to make it accessible. And Tyler's idea that if he finds an inaccessible application he can try to makes its own is not a valid idea, because not all the millions of users are programmers. Octavian From debatem1 at gmail.com Tue Jan 25 14:33:52 2011 From: debatem1 at gmail.com (geremy condra) Date: Tue, 25 Jan 2011 11:33:52 -0800 Subject: WxPython versus Tkinter. In-Reply-To: References: <4D3E4377.3060807@tysdomain.com> <9MB%o.14110$%64.6074@unlimited.newshosting.com> Message-ID: On Tue, Jan 25, 2011 at 11:16 AM, CM wrote: > Another interesting issue in this is mobile phone app development. ?It > is frustrating to devote a lot of time to learning a desktop widget > toolkit and Python and while that is occurring the culture moves more > and more toward app use in which that is not too applicable. ?Some of > that cannot be helped if Apple, e.g., restricts what can be used on > their phones. ?I guess for Android one can already develop with PyQt > and it will run on desktop or phone? No. It's very difficult to do real development on android unless you're using Java, and even if that weren't the case Qt itself would require an enormous effort to port. Perhaps you meant MeeGo? Geremy Condra From orasnita at gmail.com Tue Jan 25 14:35:31 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Tue, 25 Jan 2011 21:35:31 +0200 Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com><8q7sgiF5tpU1@mid.individual.net><19891784-d6a3-41ac-a097-5902a6323bc0@o21g2000prn.googlegroups.com><0b12cdb1-45b4-41e4-9bdb-074ee669d76b@k14g2000pre.googlegroups.com> <6172f40f-3ab5-4626-aabc-7e5a44953dcf@f20g2000prn.googlegroups.com> Message-ID: From: "rantingrick" > Availability of gui builder +0 both I thought that there are a few GUI builders for Wx. Isn't this true? Octavian From orasnita at gmail.com Tue Jan 25 14:38:08 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Tue, 25 Jan 2011 21:38:08 +0200 Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <8q7sgiF5tpU1@mid.individual.net> <19891784-d6a3-41ac-a097-5902a6323bc0@o21g2000prn.googlegroups.com><0b12cdb1-45b4-41e4-9bdb-074ee669d76b@k14g2000pre.googlegroups.com> Message-ID: <048FB74272D440A0915ABC7D76AE262B@teddy> From: "Terry Reedy" > Good as far as it goes, but this list leaves out several requirements > (already posted by me, Steve Hansen, and others) for a Python 3 new > stdlib module. It does not matter for the stdlib if wxpython is 3 times > as good as tkinter, by some measure, as long as it is ineligible. Why is WxPython ineligible? I ask because I want to be sure I understand. I remember just that reason that there are no enough maintainers in order to be a good default GUI for Python, which is a real problem if it is true. Octavian From cmpython at gmail.com Tue Jan 25 14:40:05 2011 From: cmpython at gmail.com (CM) Date: Tue, 25 Jan 2011 11:40:05 -0800 (PST) Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com> <9MB%o.14110$%64.6074@unlimited.newshosting.com> Message-ID: <7948346b-6c91-4896-8d41-75a9010fc29d@x6g2000prf.googlegroups.com> On Jan 25, 2:33?pm, geremy condra wrote: > On Tue, Jan 25, 2011 at 11:16 AM, CM wrote: > > Another interesting issue in this is mobile phone app development. ?It > > is frustrating to devote a lot of time to learning a desktop widget > > toolkit and Python and while that is occurring the culture moves more > > and more toward app use in which that is not too applicable. ?Some of > > that cannot be helped if Apple, e.g., restricts what can be used on > > their phones. ?I guess for Android one can already develop with PyQt > > and it will run on desktop or phone? > > No. It's very difficult to do real development on android unless > you're using Java, and even if that weren't the case Qt itself would > require an enormous effort to port. Perhaps you meant MeeGo? I think insted of Android I should have said "Nokia phones". Is that closer? I am completely out of the mobile phones loop, so I have no sense of any of this. What is MeeGo? At this point, can Python be used for app development on any mobile phone (realistically)? Thanks. From orasnita at gmail.com Tue Jan 25 14:43:43 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Tue, 25 Jan 2011 21:43:43 +0200 Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com><19891784-d6a3-41ac-a097-5902a6323bc0@o21g2000prn.googlegroups.com> <8q8913F2slU1@mid.individual.net> Message-ID: <2B2DA9107A06420C8A9EE32CD593EE8E@teddy> From: "Bob Martin" ... >>Do non-US-based developers focus a lot on accessibility too, since >>that's what really started this whole sub-thread? > > I don't think so; it was never a requirement for the software I wrote, > though I know I had some blind users. But NLS was a must and it has > to be designed in from the start - very difficult to add it later. :-) Remembering about MSAA (MS Active Accessibility), what you said makes me think to "Active Discrimination". It seems that for comercial reasons those who need to use a screen reader are discriminated because it is not profitable to make the effort to make an accessible program. This is a valid problem and the companies can't and shouldn't be forced to offer accessibility if this causes them financial damages. That's why the prefered solutions for creating a GUI should be one which is relatively accessible out of the box, because in that case the programmers don't even need to think to accessibility, but it is offered. Octavian From orasnita at gmail.com Tue Jan 25 14:53:45 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Tue, 25 Jan 2011 21:53:45 +0200 Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <8q7sgiF5tpU1@mid.individual.net> Message-ID: <21AC916D59AC48828C7552D4BBB2129D@teddy> From: "Terry Reedy" To: Sent: Tuesday, January 25, 2011 8:07 PM Subject: Re: WxPython versus Tkinter. > On 1/25/2011 7:03 AM, Bob Martin wrote: > >> "I bet not much" - there you go again ;-) >> You'll find that nearly all software used in Europe (and most other parts) >> is internationalized or it wouldn't stand a chance. > > I suspected that is true of today's Europe, but do you have any evidence > that software written in Japan, for instance, is any more > internationalized than US software? I would expect the opposite since > they tend to use, and still use their Japanese-only encodings with their > unique writing system. Yes Terry, you are right. In the cases where the software is targetted only to japanese speakers (but I can't imagine an example) making only japanese applications is OK. But as probably most of the software could be used by those who can't read hiragana/katakana/kanji if it would offer I18N, then it is not OK. Nobody should be blamed for making a bad software. Not the americans, not the japanese and not the europeans (because in Europe there are also a lot of uni-lingual applications). The bad software which is not accessible for some people, (because the language is not accessible or because the interface is not accessible) is usually made because of commercial constraints, or because of time constraints, or simply because of lack of knowledge about these issues. The people should be very well informed, and constantly, and not only on a single thread ona single mailing list and after many years or even generations, the things will change hopefully. The ones that should be blamed are those who know about these inaccessibility problems but simply don't care. Octavian From debatem1 at gmail.com Tue Jan 25 14:56:38 2011 From: debatem1 at gmail.com (geremy condra) Date: Tue, 25 Jan 2011 11:56:38 -0800 Subject: WxPython versus Tkinter. In-Reply-To: <7948346b-6c91-4896-8d41-75a9010fc29d@x6g2000prf.googlegroups.com> References: <4D3E4377.3060807@tysdomain.com> <9MB%o.14110$%64.6074@unlimited.newshosting.com> <7948346b-6c91-4896-8d41-75a9010fc29d@x6g2000prf.googlegroups.com> Message-ID: On Tue, Jan 25, 2011 at 11:40 AM, CM wrote: > On Jan 25, 2:33?pm, geremy condra wrote: >> On Tue, Jan 25, 2011 at 11:16 AM, CM wrote: >> >?I guess for Android one can already develop with PyQt >> > and it will run on desktop or phone? >> >> No. It's very difficult to do real development on android unless >> you're using Java, and even if that weren't the case Qt itself would >> require an enormous effort to port. Perhaps you meant MeeGo? > > I think insted of Android I should have said "Nokia phones". ?Is that > closer? ?I am completely out of the mobile phones loop, so I have no > sense of any of this. ?What is MeeGo? MeeGo is Nokia's next generation mobile OS, and Symbian is its current one. > At this point, can Python be used for app development on any mobile > phone (realistically)? Python development on either Symbian or MeeGo is reasonably painless. Geremy Condra From debatem1 at gmail.com Tue Jan 25 15:01:01 2011 From: debatem1 at gmail.com (geremy condra) Date: Tue, 25 Jan 2011 12:01:01 -0800 Subject: WxPython versus Tkinter. In-Reply-To: <4A48EDF6D7634F2E994661A457451E87@teddy> References: <4D3E4377.3060807@tysdomain.com> <9MB%o.14110$%64.6074@unlimited.newshosting.com> <4A48EDF6D7634F2E994661A457451E87@teddy> Message-ID: On Tue, Jan 25, 2011 at 11:24 AM, Octavian Rasnita wrote: > Yes, I know, that's life, which is not right, that's faith, bla bla, but it doesn't mean that my atitude need to be changed. There's a difference between having an opinion and having an attitude. You have both, and it doesn't do you a lot of favors. Geremy Condra From rantingrick at gmail.com Tue Jan 25 15:05:56 2011 From: rantingrick at gmail.com (rantingrick) Date: Tue, 25 Jan 2011 12:05:56 -0800 (PST) Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com> <9MB%o.14110$%64.6074@unlimited.newshosting.com> <7948346b-6c91-4896-8d41-75a9010fc29d@x6g2000prf.googlegroups.com> Message-ID: On Jan 25, 1:40?pm, CM wrote: > At this point, can Python be used for app development on any mobile > phone (realistically)? No as long as Tkinter is in the stdlib (if your talking stdlib?) From rantingrick at gmail.com Tue Jan 25 15:09:46 2011 From: rantingrick at gmail.com (rantingrick) Date: Tue, 25 Jan 2011 12:09:46 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com><8q7sgiF5tpU1@mid.individual.net><19891784-d6a3-41ac-a097-5902a6323bc0@o21g2000prn.googlegroups.com><0b12cdb1-45b4-41e4-9bdb-074ee669d76b@k14g2000pre.googlegroups.com> <6172f40f-3ab5-4626-aabc-7e5a44953dcf@f20g2000prn.googlegroups.com> Message-ID: On Jan 25, 1:35?pm, "Octavian Rasnita" wrote: > From: "rantingrick" > > > Availability of gui builder > > +0 both > > I thought that there are a few GUI builders for Wx. Isn't this true? Oops! Yes it seems there are. I was unaware of them since i never use GUI builders. So another +1 for wxPython! Here are a few i found... http://wxglade.sourceforge.net/index.php#description http://boa-constructor.sourceforge.net/ Thanks for correcting me Octavian. From mafunk at nmsu.edu Tue Jan 25 15:13:02 2011 From: mafunk at nmsu.edu (Matt Funk) Date: Tue, 25 Jan 2011 13:13:02 -0700 Subject: numpy/matlab compatibility Message-ID: <4D3F2ECE.8070200@nmsu.edu> Hi, i am fairly new to python. I was wondering of the following is do-able in python: 1) a = rand(10,1) 2) Y = a 3) mask = Y > 100; 4) Y(mask) = 100; 5) a = a+Y Basically i am getting stuck on line 4). I was wondering if it is possible or not with python? (The above is working matlab code) thanks matt From rantingrick at gmail.com Tue Jan 25 15:15:06 2011 From: rantingrick at gmail.com (rantingrick) Date: Tue, 25 Jan 2011 12:15:06 -0800 (PST) Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com> <9MB%o.14110$%64.6074@unlimited.newshosting.com> <4A48EDF6D7634F2E994661A457451E87@teddy> Message-ID: <9684e450-36df-4036-89b8-951543b8adf5@w29g2000vba.googlegroups.com> On Jan 25, 2:01?pm, geremy condra wrote: > On Tue, Jan 25, 2011 at 11:24 AM, Octavian Rasnita wrote: > > Yes, I know, that's life, which is not right, that's faith, bla bla, but it doesn't mean that my atitude need to be changed. > > There's a difference between having an opinion and having an attitude. > You have both, and it doesn't do you a lot of favors. There is likewise a difference between reading someones words (objectively) uninfluenced by emotions or personal prejudices, or not. You understand? From mgroth86 at gmail.com Tue Jan 25 15:17:49 2011 From: mgroth86 at gmail.com (Matthew Roth) Date: Tue, 25 Jan 2011 12:17:49 -0800 (PST) Subject: trouble installing MySQLdb (cygwin) + Bonus question References: <501470fc-c588-47d2-954d-17d825c5191c@v17g2000prc.googlegroups.com> Message-ID: Thank you. I appreciate you explanation and tolerance of my ignorance. However unfortunate, this still does not solve my major issue. From emile at fenx.com Tue Jan 25 15:29:23 2011 From: emile at fenx.com (Emile van Sebille) Date: Tue, 25 Jan 2011 12:29:23 -0800 Subject: WxPython versus Tkinter. In-Reply-To: <7bb56aba-0f96-4b7e-a78d-3398003a0e38@c39g2000yqi.googlegroups.com> References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <8q7sgiF5tpU1@mid.individual.net> <19891784-d6a3-41ac-a097-5902a6323bc0@o21g2000prn.googlegroups.com> <0b12cdb1-45b4-41e4-9bdb-074ee669d76b@k14g2000pre.googlegroups.com> <7bb56aba-0f96-4b7e-a78d-3398003a0e38@c39g2000yqi.googlegroups.com> Message-ID: On 1/25/2011 11:25 AM rantingrick said... Classic insanity. Emile From emile at fenx.com Tue Jan 25 15:36:11 2011 From: emile at fenx.com (Emile van Sebille) Date: Tue, 25 Jan 2011 12:36:11 -0800 Subject: WxPython versus Tkinter. In-Reply-To: <048FB74272D440A0915ABC7D76AE262B@teddy> References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <8q7sgiF5tpU1@mid.individual.net> <19891784-d6a3-41ac-a097-5902a6323bc0@o21g2000prn.googlegroups.com><0b12cdb1-45b4-41e4-9bdb-074ee669d76b@k14g2000pre.googlegroups.com> <048FB74272D440A0915ABC7D76AE262B@teddy> Message-ID: On 1/25/2011 11:38 AM Octavian Rasnita said... > From: "Terry Reedy" >> Good as far as it goes, but this list leaves out several requirements >> (already posted by me, Steve Hansen, and others) for a Python 3 new >> stdlib module. It does not matter for the stdlib if wxpython is 3 times >> as good as tkinter, by some measure, as long as it is ineligible. > > > > Why is WxPython ineligible? I think Terry's point was compatibility with python3 -- which wx apparently isn't yet. Emile From smokefloat at gmail.com Tue Jan 25 15:40:31 2011 From: smokefloat at gmail.com (David Hutto) Date: Tue, 25 Jan 2011 12:40:31 -0800 (PST) Subject: python challenges Message-ID: <350ae5f3-8172-4461-b9b1-055e80868f38@r40g2000prh.googlegroups.com> Python is, of course, a language based on a lower level to allow higher level interactivity and ease of use. So, to define the challenges of python, are to define the challenges of what it wraps around. Moving from lower level to the higher level of python, what needs to take place at each level of the hierarchy it's placed on in order for it to become 'perfect'? From malaclypse2 at gmail.com Tue Jan 25 15:51:49 2011 From: malaclypse2 at gmail.com (Jerry Hill) Date: Tue, 25 Jan 2011 15:51:49 -0500 Subject: numpy/matlab compatibility In-Reply-To: <4D3F2ECE.8070200@nmsu.edu> References: <4D3F2ECE.8070200@nmsu.edu> Message-ID: On Tue, Jan 25, 2011 at 3:13 PM, Matt Funk wrote: > 1) a = rand(10,1) > 2) Y = a > 3) mask = Y > 100; > 4) Y(mask) = 100; > 5) a = a+Y > > Basically i am getting stuck on line 4). I was wondering if it is > possible or not with python? > (The above is working matlab code) > For those of us who don't know Matlab, what does that code do? -- Jerry -------------- next part -------------- An HTML attachment was scrubbed... URL: From orasnita at gmail.com Tue Jan 25 15:55:43 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Tue, 25 Jan 2011 22:55:43 +0200 Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com><9MB%o.14110$%64.6074@unlimited.newshosting.com> Message-ID: <59F6E65E3D9A46AD8D7A3863F3C1DC84@teddy> > this thread was a "psy-ops" (psychological operations) trick to turn off wxPython adopters by associating it with juvenile nonsense Do you think the need for accessibility is a nonsense? Or do you think it is something juvenile? Octavian From rouzbeh.t at gmail.com Tue Jan 25 15:56:11 2011 From: rouzbeh.t at gmail.com (Rouzbeh Torki) Date: Wed, 26 Jan 2011 00:26:11 +0330 Subject: PyBluez for iPhone Message-ID: Hi, My name is Rouzbeh. I work with Python and PyBluez on my laptop. I have already installed Python on my iPhone. But I want to work with iPhone-Bluetooth so I need Bluetooth Library in Python ( like PyBluez ). Is there any Bluetooth library for iphone in python or not ? where can I download the library ? thank you best regards -- *** < Rouzbeh > *** -------------- next part -------------- An HTML attachment was scrubbed... URL: From orasnita at gmail.com Tue Jan 25 16:03:19 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Tue, 25 Jan 2011 23:03:19 +0200 Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com><9MB%o.14110$%64.6074@unlimited.newshosting.com><4A48EDF6D7634F2E994661A457451E87@teddy> Message-ID: From: "geremy condra" > On Tue, Jan 25, 2011 at 11:24 AM, Octavian Rasnita wrote: > >> Yes, I know, that's life, which is not right, that's faith, bla bla, but it doesn't mean that my atitude need to be changed. > > There's a difference between having an opinion and having an attitude. > You have both, and it doesn't do you a lot of favors. I don't understand. Please be more clear. Have I said something wrong? Did I use bad words? Or what was it wrong? I have just an opinion, but that opinion won't change until the opinion of those who pretend that the discrimination is something normal. Do you think that this is not normal? Or you recommend me to be just like Tyler that can't use all the apps he could use if they were accessible, but he doesn't care because he cares much more to play nice in order to be accepted in this not-right society? Octavian From nagle at animats.com Tue Jan 25 16:34:26 2011 From: nagle at animats.com (John Nagle) Date: Tue, 25 Jan 2011 13:34:26 -0800 Subject: trouble installing MySQLdb (cygwin) + Bonus question In-Reply-To: <501470fc-c588-47d2-954d-17d825c5191c@v17g2000prc.googlegroups.com> References: <501470fc-c588-47d2-954d-17d825c5191c@v17g2000prc.googlegroups.com> Message-ID: <4d3f41d9$0$44021$742ec2ed@news.sonic.net> On 1/25/2011 7:05 AM, Matthew Roth wrote: > On Jan 25, 4:30 am, Dennis Lee Bieber wrote: >> On Mon, 24 Jan 2011 14:25:09 -0800 (PST), Matthew Roth >> declaimed the following in >> gmane.comp.python.general: >> Second -- MySQL is a server model DBMS; it doesn't have to be on the >> local machine. > -- > unfortunately, for my use it does. We do have an old centOs box here, > but the mysql running on that is severely outdated and so too is the > python. You can install a MySQL server under Windows, and talk to the server from the Cygwin environment. That's a useful way to test. John Nagle From kb1pkl at aim.com Tue Jan 25 16:41:58 2011 From: kb1pkl at aim.com (Corey Richardson) Date: Tue, 25 Jan 2011 16:41:58 -0500 Subject: WxPython versus Tkinter. In-Reply-To: <59F6E65E3D9A46AD8D7A3863F3C1DC84@teddy> References: <4D3E4377.3060807@tysdomain.com><9MB%o.14110$%64.6074@unlimited.newshosting.com> <59F6E65E3D9A46AD8D7A3863F3C1DC84@teddy> Message-ID: <4D3F43A6.2080703@aim.com> On 01/25/2011 03:55 PM, Octavian Rasnita wrote: > >> this thread was a "psy-ops" (psychological >> operations) trick to turn off wxPython adopters by associating it with >> juvenile nonsense > > Do you think the need for accessibility is a nonsense? > Or do you think it is something juvenile? > > > Octavian > Do you honestly think he was talking about the accessibility problem? IMO that should move to another thread, because this one is simply about, as the subject suggests, "WxPython versus Tkinter". From bryan.oakley at gmail.com Tue Jan 25 16:54:29 2011 From: bryan.oakley at gmail.com (Bryan) Date: Tue, 25 Jan 2011 13:54:29 -0800 (PST) Subject: Need GUI pop-up to edit a (unicode ?) string References: <3tqr08-bj2.ln1@murmur.very.softly> Message-ID: <7691fe98-37af-4ddf-a8a8-eadeef0d4a6e@y2g2000prf.googlegroups.com> On Jan 22, 2:22?pm, Rikishi42 wrote: > I'm in need for a graphical pop-up that will display a (unicode ?) string in > a field, allow the user to change it and return the modified string. > > Maybe also keep the original one displayed above it. > > Something like this: > +-------------------------------------------------+ > | ? Please confirm or edit the following string ? | > | ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? | > | ? ? Original_example_string ? ? ? ? ? ? ? ? ? ? | > | ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? | > | ?+-------------------------------------------+ ?| > | ?| ?Original_about_to_be_changed ? ? ? ? ? ? | ?| > | ?+-------------------------------------------+ ?| > | ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? | > | ? ? ? ? ? ? ? ? ? ? OK ? ? ? ? ? ? ? ? ? ? ? ? ?| > | ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? | > +-------------------------------------------------+ > > I've never used any kind of graphical interface programing before, so I > don't have a clue where to start. > This would, however, be the *only* GUI part in the app at this point. > > From what I can see the solution lays with PyQT, but the docs I find are > courses that aim to teach the whole GUI tool. I only need a little pop-up to > alow a user to edit part of a filename, for instance. > > I'm using Python 2.6.x on various Linux platforms (mainly openSUSE and Mint) > and on Windows. Windows support is not important, in this case. tkinter is likely the easiest solution. Here's a quick hack, assuming you want a program with a single window, rather than dialog you can pop up. This has no cancel button since you didn't specify you wanted one. It just pops up a window, and when you press ok, or dismiss via the window manager, the edited value will be printed to stdout. It's not a perfect solution but it gives you a feel for how easy it is to do with tkinter. import Tkinter as tk class App(tk.Tk): def __init__(self, s): tk.Tk.__init__(self) self.wm_title("Edit the string") # the main layout is composed of four areas: # 1) the label / instructions # 2) the original value # 3) the edit field # 4) a row of buttons label = tk.Label(self, text="Please confirm or edit the following string:") oframe = tk.LabelFrame(text="Original:") eframe = tk.LabelFrame(text="Edited:") buttons = tk.Frame(self) orig = tk.Entry(self, width=40) edit = tk.Entry(self, width=40) edit.insert(0, s) orig.insert(0, s) orig.config(state="disabled") ok = tk.Button(self, text="Ok", command=self.ok, default="active") # this does all the layout label.pack(side="top", fill="both", expand=True) oframe.pack(side="top", fill="both", expand=True, padx=4) eframe.pack(side="top", fill="both", expand=True, padx=4, pady=(4,0)) orig.pack(in_=oframe, side="top", fill="x", padx=4, pady=4) edit.pack(in_=eframe, side="top", fill="x", padx=4, pady=4) buttons.pack(side="bottom", fill="x", pady=4) ok.pack(in_=buttons, expand=True) edit.select_range(0, "end") edit.bind("", lambda event: self.ok) self.wm_protocol("WM_DELETE_WINDOW", self.ok) edit.focus() # keep a reference so self.ok can access it self.edit = edit def ok(self): value = self.edit.get() print value self.destroy() if __name__ == "__main__": import sys try: s = sys.argv[1] except: s = "Hello, world" app = App(s) app.mainloop() From steve+comp.lang.python at pearwood.info Tue Jan 25 16:56:49 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 25 Jan 2011 21:56:49 GMT Subject: numpy/matlab compatibility References: Message-ID: <4d3f4721$0$29983$c3e8da3$5496439d@news.astraweb.com> On Tue, 25 Jan 2011 13:13:02 -0700, Matt Funk wrote: > Hi, > > i am fairly new to python. I was wondering of the following is do-able > in python: > > 1) a = rand(10,1) > 2) Y = a > 3) mask = Y > 100; > 4) Y(mask) = 100; > 5) a = a+Y > > Basically i am getting stuck on line 4). I was wondering if it is > possible or not with python? > (The above is working matlab code) Not everybody here uses Matlab. Considering that this is a Python list, not a Matlab list, it may be that the only person who understands what the above code does is you. (Unlikely, but not *that* unlikely.) If you want us to help you, you should help us by telling us what the above code does, and what you've tried (if anything), and what error you get when you try. Alternatively, you could try a Matlab forum, and ask for help converting it to Python there, or much more likely to succeed, a specialist numpy mailing list. You're very likely to find people with experience in both numpy and Matlab there. -- Steven From mafunk at nmsu.edu Tue Jan 25 16:58:00 2011 From: mafunk at nmsu.edu (Matt Funk) Date: Tue, 25 Jan 2011 14:58:00 -0700 Subject: numpy/matlab compatibility In-Reply-To: References: <4D3F2ECE.8070200@nmsu.edu> Message-ID: <4D3F4768.402@nmsu.edu> Hi, thank you Andrea. That is exactly what i was looking for. Great. Andrea explained what the Matlab code does below. Sorry about the confusion. I was under the impression that numpy was leaning very heavily on Matlab for its syntax and thus i assumed that Matlab was mostly known for those using numpy. Andrea: you are right about the value 100. It should have been 0.5. The original code has a different vector which is tested against 100. I tried to simply reproduce the functionality with a random vector. Thus the confusion. Again, thanks for the input. matt On 1/25/2011 2:36 PM, Andrea Ambu wrote: > > > On Tue, Jan 25, 2011 at 9:13 PM, Matt Funk > wrote: > > Hi, > > i am fairly new to python. I was wondering of the following is do-able > in python: > > 1) a = rand(10,1) > 2) Y = a > 3) mask = Y > 100; > 4) Y(mask) = 100; > 5) a = a+Y > > > No. Not like that. > > You do literally: > a = rand(10, 1) > Y = a > mask = Y>100 > Y = where(mask, 100, Y) > a = a+Y > > > More Pythonically: > a = rand(10, 1) > a = where(a > 100, a + 100, a + a) > > > For those who don't speak Matlab: > > 1) a = rand(10,1) ; generates a 10x1 matrix for random number 0 < n < 1 > 2) Y = a > 3) mask = Y > 100; similar to: mask = [i>100 for i in Y] > 4) Y(mask) = 100; sets to 100 elements of Y with index i for which > mask[i] = True > 5) a = a+Y ; sums the two matrices element by element (like you do in > linear algebra) > > > Anyway... rand generates number from 0 up to 1 (both in python and > matlab)... when are they > 100? > > > > Basically i am getting stuck on line 4). I was wondering if it is > possible or not with python? > (The above is working matlab code) > > thanks > matt > -- > http://mail.python.org/mailman/listinfo/python-list > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From steve+comp.lang.python at pearwood.info Tue Jan 25 16:58:49 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 25 Jan 2011 21:58:49 GMT Subject: python challenges References: <350ae5f3-8172-4461-b9b1-055e80868f38@r40g2000prh.googlegroups.com> Message-ID: <4d3f4799$0$29983$c3e8da3$5496439d@news.astraweb.com> On Tue, 25 Jan 2011 12:40:31 -0800, David Hutto wrote: > Python is, of course, a language based on a lower level to allow higher > level interactivity and ease of use. So, to define the challenges of > python, are to define the challenges of what it wraps around. Moving > from lower level to the higher level of python, what needs to take place > at each level of the hierarchy it's placed on in order for it to become > 'perfect'? Define "perfect". -- Steven From misnomer at gmail.com Tue Jan 25 17:03:20 2011 From: misnomer at gmail.com (Nicholas Devenish) Date: Tue, 25 Jan 2011 22:03:20 +0000 Subject: numpy/matlab compatibility In-Reply-To: References: Message-ID: On 25/01/2011 20:13, Matt Funk wrote: > 1) a = rand(10,1) > 2) Y = a > 3) mask = Y> 100; > 4) Y(mask) = 100; > 5) a = a+Y > > Basically i am getting stuck on line 4). I was wondering if it is > possible or not with python? > (The above is working matlab code) I don't understand this matlab code completely (I would expect rand to return in the range 0-1, so would expect (Y > 100) to match nothing). Nonetheless, to achieve line 4 I believe you are looking for: >>> Y[mask] = 100 However, you can also do directly: >>> Y[Y>100] = 100 This won't work exactly as you anticipate, because presumably in matlab the line 'Y = a' makes a copy of 'a' (it has been a long time since I used matlab). In python, Y and a will still refer to the same object, so altering Y will also alter a. The *most literal* translation to python of your sample is probably: >> import numpy >> a = numpy.random.rand(10,1) >> Y = a.copy() >> mask = Y > 100 >> Y[mask] = 100 >> a = a + Y From backgoodoo at gmail.com Tue Jan 25 17:12:52 2011 From: backgoodoo at gmail.com (Back9) Date: Tue, 25 Jan 2011 14:12:52 -0800 (PST) Subject: A http server Message-ID: Hi, I'm trying to set up a http server to handle a single POST request. That POST request is to upload a huge file and the server is supposed to handle it with the just POST request. With my python sample code, multiple post requests are working well, but that is not my solution. I need a single POST request handling in the http server side. Does anyone have a good idea for this case or sample code? TIA From robert.kern at gmail.com Tue Jan 25 17:21:43 2011 From: robert.kern at gmail.com (Robert Kern) Date: Tue, 25 Jan 2011 16:21:43 -0600 Subject: numpy/matlab compatibility In-Reply-To: <4D3F2ECE.8070200@nmsu.edu> References: <4D3F2ECE.8070200@nmsu.edu> Message-ID: On 1/25/11 2:13 PM, Matt Funk wrote: > Hi, > > i am fairly new to python. I was wondering of the following is do-able > in python: > > 1) a = rand(10,1) > 2) Y = a > 3) mask = Y> 100; > 4) Y(mask) = 100; > 5) a = a+Y > > Basically i am getting stuck on line 4). I was wondering if it is > possible or not with python? > (The above is working matlab code) You will want to ask numpy questions on the numpy-discussion mailing list instead of here. http://www.scipy.org/Mailing_Lists When asking how to replicate a particular MATLAB behavior, please describe (and preferably also *show*) what the given MATLAB code does. We're not all familiar with MATLAB, and even if we are, we may not know which specific aspect of the code you want us to replicate. You will also want to check out this page: http://www.scipy.org/NumPy_for_Matlab_Users To answer your specific questions: 1) a = numpy.random.random_sample([10, 1]) 2) Y = a.copy() # In Python assignment to a new name does not copy the object. You seem to want a copy in this case. numpy arrays have a .copy() method, though most Python objects don't. 3) mask = Y > 0.5 # Note that Y only has values in [0..1) at this point, so using 100 here will create a boolean mask with only False entries. This is probably not what you wanted to show, so I used 0.5 instead. 4) Y[mask] = 100 5) a = a + Y # Or "a += Y" if you want to modify "a" in-place. -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco From misnomer at gmail.com Tue Jan 25 17:45:54 2011 From: misnomer at gmail.com (Nicholas Devenish) Date: Tue, 25 Jan 2011 22:45:54 +0000 Subject: WxPython versus Tkinter. In-Reply-To: References: <4D3E4377.3060807@tysdomain.com> <9MB%o.14110$%64.6074@unlimited.newshosting.com> Message-ID: On 25/01/2011 19:24, Octavian Rasnita wrote: > Can you tell why? Because you probably don't care about those who can't use the programs made with Tkinter or because you consider the discrimination something normal, right? > And you said that it is not a good thing. Good thing for whom? For the blind people Tkinter is the worst thing possible. Or do you want to say that it is not true? > No, it shouldn't be, but I see that you don't understand after this long thread why Tkinter should be avoided. > WxPython shouldn't be the second choice. WxPython shouldn't be the first choice or the single choice. The single choices should be always only those who don't introduce discrimination. Don't you agree with this? > Well, for the moment only WxPython doesn't include discrimination if we are talking about portable GUIs. > Please tell me if I wasn't clear enough or what you don't agree with. > The atitude that needs to be changed is the one that considerates the majority more important than a minority which is a minority because of health problems, a minority that is a minority without its will. > > In my country there is a law that says that the society should adapt to the people with disabilities (and not viceversa), and that law is probably copied from the legislation of other european countries. That law is a very good one, but the problem is that nobody cares to respect it, because most of the people have Tyler's opinion. > Yes, I know, that's life, which is not right, that's faith, bla bla, but it doesn't mean that my atitude need to be changed. The atitude that needs to be changed is the one that considers the discrimination something normal and the one that considers that the disabled people should adapt to the society even though most of them can't do that because of their health problems. Octavian, we get it - you are on the warpath about accessibility. And this is, in a way, a good thing, because, yes, programmers should in general think more about accessibility when designing their programs. But nobody was ever persuaded to consider a complicated and subtle issue by hostile holier-than-thou arrogance, which is what rantingricks posts started out with, and what your posts have been slowly turning into. This is what is 'not a good thing', in case you genuinely didn't understand the context of my previous message. Look at the response your earlier posts got, with experienced developers showing an interest in actually trying out accessibility tools. Compare this with the defensive replies you have been getting more recently. But this thread is not about that, and the accessibility issue is mostly a red herring that rantingrick has grabbed hold of to swing around like a battleaxe, because nobody is going to say that accessibility doesn't matter. Discrimination in many forms, is a real problem in our societies, and one that is not going to be solved overnight, much as you might wish it. Stigmatizing perfectly repectful people who haven't encountered your needs before, or don't agree that accessibility is the only thing that matters, is not going to solve any issues. From debatem1 at gmail.com Tue Jan 25 17:55:34 2011 From: debatem1 at gmail.com (geremy condra) Date: Tue, 25 Jan 2011 14:55:34 -0800 Subject: WxPython versus Tkinter. In-Reply-To: References: <4D3E4377.3060807@tysdomain.com> <9MB%o.14110$%64.6074@unlimited.newshosting.com> <4A48EDF6D7634F2E994661A457451E87@teddy> Message-ID: On Tue, Jan 25, 2011 at 1:03 PM, Octavian Rasnita wrote: > From: "geremy condra" >> On Tue, Jan 25, 2011 at 11:24 AM, Octavian Rasnita wrote: >> >>> Yes, I know, that's life, which is not right, that's faith, bla bla, but it doesn't mean that my atitude need to be changed. >> >> There's a difference between having an opinion and having an attitude. >> You have both, and it doesn't do you a lot of favors. > > > I don't understand. Please be more clear. There's a difference between what you say and how you say it. If a friend came up to you and said "give me $100 right now!", you probably wouldn't do it. If the same friend came up to you and said "I know this is a big thing to ask, but I really need $100 and I can't guarantee I'll be able to pay you back. Could you please help me?" I don't know very many people who would refuse if they were able to help. The reason is simple: the first does not acknowledge the value of the person doing the favor, and the second does. More concretely, you have an opinion that not supporting accessibility is discrimination. Tyler has an opinion that not supporting accessibility is a bug. Are you going to demand that he change his opinion? Or are you going to ask that he consider yours? > Have I said something wrong? Did I use bad words? Or what was it wrong? I think it was uncivil. It was rude, unkind, and generally disagreeable. I lost respect for you, and by proxy, for your point of view. In other words, you lost support not because fewer people agree with your position, but because fewer people want to agree with you. > I have just an opinion, but that opinion won't change until the opinion of those who pretend that the discrimination is something normal. > Do you think that this is not normal? I didn't ask you to change your opinion. I told you that you would be more effective if you changed your attitude. Like rantingrick, you're free to ignore that advice, but it is good advice for both you and the community, and I urge you to take it. > Or you recommend me to be just like Tyler that can't use all the apps he could use if they were accessible, but he doesn't care because he cares much more to play nice in order to be accepted in this not-right society? I would recommend that you learn to be civil to those you disagree with. The alternative is to be surrounded by them. Geremy Condra From mgroth86 at gmail.com Tue Jan 25 17:59:25 2011 From: mgroth86 at gmail.com (Matthew Roth) Date: Tue, 25 Jan 2011 14:59:25 -0800 (PST) Subject: trouble installing MySQLdb (cygwin) + Bonus question References: <501470fc-c588-47d2-954d-17d825c5191c@v17g2000prc.googlegroups.com> <4d3f41d9$0$44021$742ec2ed@news.sonic.net> Message-ID: On Jan 25, 9:34?pm, John Nagle wrote: > On 1/25/2011 7:05 AM, Matthew Roth wrote: > > > On Jan 25, 4:30 am, Dennis Lee Bieber ?wrote: > >> On Mon, 24 Jan 2011 14:25:09 -0800 (PST), Matthew Roth > >> ?declaimed the following in > >> gmane.comp.python.general: > >> ? ? ? ? ?Second -- MySQL is a server model DBMS; it doesn't have to be on the > >> local machine. > > -- > > unfortunately, for my use it does. We do have an old centOs box here, > > but the mysql running on that is severely outdated and so too is the > > python. > > ? ? You can install a MySQL server under Windows, and talk to the server > from the Cygwin environment. ?That's a useful way to test. > > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? John Nagle Right, that is precisely what I have. I am able to talk to it from cygwin, however, during the installing of the MySQLdb module it cannot find the mysql_config. This is because It is not installed? The setup sees that I am on a posix system not windows, as python is installed in cygwin, a virtual posix system. I am trying to bulid a mysql client from source for cygwin, however, I am running into an error there. Unless, can I talk to the windows mysql_config? if so, what does that look like From misnomer at gmail.com Tue Jan 25 18:01:48 2011 From: misnomer at gmail.com (Nicholas Devenish) Date: Tue, 25 Jan 2011 23:01:48 +0000 Subject: WxPython versus Tkinter. In-Reply-To: References: <4D3E4377.3060807@tysdomain.com> <9MB%o.14110$%64.6074@unlimited.newshosting.com> Message-ID: On 25/01/2011 19:16, CM wrote: > On Jan 25, 10:13 am, Nicholas Devenish wrote: > > I don't know--you sound too reasonable to extrapolate from this goofy > thread to a huge toolkit project that has been around for years and is > used in project such as Audacity (that's the wxWidgets version, but > close enough). But yes, it almost at times seemed like--from what I > could manage to read--this thread was a "psy-ops" (psychological > operations) trick to turn off wxPython adopters by associating it with > juvenile nonsense, and yes, on a quick scan it could turn people > off. Personally, no, it probably wouldn't have caused me not to use wx. But it certainly would have put a mental tick in the against box, because a frameworks community matters. As a little aside, a personal example is Django, whose tutorial contained what to my un-django-trained eye looked like an inconsistency bug, without explanation. I filed a bug report, and apparently many other people have had the same misassumption (indicating a problem with the tutorial). The bug was closed with words effectively equivalent to "Stupid newbie". Ignoring the fact that documentation being consistently misinterpreted should indicate a real problem, why should I put my time and effort into learning a framework with a community that is so hostile, when there are plenty of alternatives? > Which would be a shame, because, as you, Andrea, and others have > noted, wxPython is a nice toolkit. For those interested, download it > and make sure to download the Demo, that shows what can be done with > it. (Very early in this discussion the screenshots on the website > came up; they are horrifically out of date and wxPython deserves > better and looks great on, say, Windows 7 or Ubuntu....well, it looks > native, and that's the point). I actually chose wxPython partly on the strength of it's native-ness - it looks like other mac applications, and doesn't run through X11, but I was also extremely impressed by the comprehensive wxPython demo. That, and installation seemed to be pretty easy, whereas GTK looked a little like a minefield (QT I have a personal bias against, because for whatever reason I associate it with KDE and in general dislike kde's 'look' and design philosopy). > But what I would enjoy is a discussion about GUIs in terms of "develop > once, deploy many". For example, pyjamas, since I think being able to > develop one GUI that works as desktop or web-based is kind of > exciting. Unfortunately, it seems it is far off from anything easily > usable at this point. Part of that might be it doesn't have a big > enough community of developers yet. It's also just really difficult, > I'm sure. I was only aware of pyjamas as a "Python to Javascript" compiler, and didn't know you could write desktop applications in it too. One to watch! From rantingrick at gmail.com Tue Jan 25 18:02:18 2011 From: rantingrick at gmail.com (rantingrick) Date: Tue, 25 Jan 2011 15:02:18 -0800 (PST) Subject: Need GUI pop-up to edit a (unicode ?) string References: <3tqr08-bj2.ln1@murmur.very.softly> <7691fe98-37af-4ddf-a8a8-eadeef0d4a6e@y2g2000prf.googlegroups.com> Message-ID: <541c02df-b1fc-4376-bf17-e0531fe5c4bf@r29g2000yqj.googlegroups.com> On Jan 25, 3:54?pm, Bryan wrote: > tkinter is likely the easiest solution. Here's a quick hack, [...snip code...] Well this is nice Bryan however it should be much easier than this. Basically your code is creating most of the functionality that should be wrapped up in a Dialog class. Tkinter has the tkSimpleDialog from which one can inherit and build custom dialogs like the one you have here however it has a major flaw! Fredrick choose not give the class a show method and instead just threw all the code that should be in a "show" method into the __init__ method. This is not a good idea. And i'll explain why... What Fredrick was trying to do was to make noob programmers life easier. And he accomplished this in a specific way! However by NOT creating a show method he has at the same time handicapped these same people! The proper way to use a dialog class is... * Subclass a built-in in Dialog class and insert some widgets. class MyDialog(tkSimpleDialog.Dialog): blah * Create and instance of your custom dialog. dlg = MyDialog(blah) * Configure any widget values (if needed!) dlg.origText['text'] = unicodestring * and show the dialog dlg.show(blah) This design pattern promotes reuse-ability and encapsulation. However with Fredricks design you cannot configure the contained widgets after creating the instance because the dialog has entered a local event loop brought on by "self.wait_window(self)" which is in the DAMN INITIAL METHOD! This is a major flaw in the design and i would be happy to fix the flaw. However our "friend" Fredrick decided to copyright the module to himself! What a jerk! Which is quite disgusting considering that Tkinter, and TclTk are completely open source! And i don't want to hear any arguments about invoking the __init__ method because if you read the source you will see why doing that is completely ridiculous because of Fredericks design. This is another example of how few people actually use Tkinter. If many people where using the module obviously bad code such as this would not exist for 14 years! Someone would have complained. If Frederic wants some pointers for how to create a proper dialog he should contact me, or we should have a discussion here. The sad thing is that this dialog has not been fixed since 1997. And you people wonder why i hate Tkinter! From drobinow at gmail.com Tue Jan 25 18:20:26 2011 From: drobinow at gmail.com (David Robinow) Date: Tue, 25 Jan 2011 18:20:26 -0500 Subject: trouble installing MySQLdb (cygwin) + Bonus question In-Reply-To: References: <501470fc-c588-47d2-954d-17d825c5191c@v17g2000prc.googlegroups.com> <4d3f41d9$0$44021$742ec2ed@news.sonic.net> Message-ID: On Tue, Jan 25, 2011 at 5:59 PM, Matthew Roth wrote: > On Jan 25, 9:34?pm, John Nagle wrote: ... >> ? ? You can install a MySQL server under Windows, and talk to the server >> from the Cygwin environment. ?That's a useful way to test. >> >> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? John Nagle > > Right, that is precisely what I have. I am able to talk to it from > cygwin, however, during the installing of the MySQLdb module it cannot > find the mysql_config. This is because It is not installed? The setup > sees that I am on a posix system not windows, as python is installed > in cygwin, a virtual posix system. I am trying to bulid a mysql client > from source for cygwin, however, I am running into an error there. > > Unless, can I talk to the windows mysql_config? if so, what does that > look like The obvious answer is to use a Windows python. You haven't explained why you think you need to run a cygwin python. Can you explain that? From harijay at gmail.com Tue Jan 25 18:28:32 2011 From: harijay at gmail.com (harijay) Date: Tue, 25 Jan 2011 15:28:32 -0800 (PST) Subject: Using select.kqueue to monitor garageband transcode completion Message-ID: I want to automate a series of functions in python that trigger when the OSX application Garagband finishes writing to a file called "todays_recording.mp3". A Typical transcode process takes 20 minutes , and I fancy starting the python program immediately after I start the transcode and then walking away. For the present moment I have a silly implementation that does something like the code pasted below. I was looking online for smarter I/O monitoring and I came across the kqueue classes inside of the select module which could be used to monitor the kernel events in BSD - so it should work on OSX. However being a newbie , I cannot understand how to setup the select.kqueue event to look for garageband closing , i.e finish writing the transcoded mp3 file. I did see some code on comp.lang.python about this in a post from Ritesh Nadhani (pasted below as well). But I dont understand what the events mean . Looking for help to monitor the file closing using select.kqueue. Thanks Hari My Pseudocode for clunky monitoring of file i/o completion: while True: try: today_file = open("todays_recording.mp3","r") my_custom_function_to_process_file(today_file) except IOError: print "File not ready yet..continuing to wait" ############### Some source code I came across on comp.lang.python ( courtesy Ritesh Vadvani) related to this ############## import select26 as select import os kq = select.kqueue() fd = os.open("/tmp/a.txt", os.O_RDONLY) # I dont understand this line below ev = [select.kevent(fd, filter=select.KQ_FILTER_VNODE, flags=select.KQ_EV_ADD | select.KQ_EV_ENABLE | select.KQ_EV_ONESHOT, fflags=select.KQ_NOTE_WRITE | select.KQ_NOTE_DELETE | select.KQ_NOTE_EXTEND)] kq.control(ev, 0, 0) try: while True: evts = kq.control(ev, 1, None) if len(evts): print evts except KeyboardInterrupt: pass else: kq.close() os.close(fd) From ben+python at benfinney.id.au Tue Jan 25 18:29:46 2011 From: ben+python at benfinney.id.au (Ben Finney) Date: Wed, 26 Jan 2011 10:29:46 +1100 Subject: python challenges References: <350ae5f3-8172-4461-b9b1-055e80868f38@r40g2000prh.googlegroups.com> Message-ID: <87pqrk36l1.fsf@benfinney.id.au> David Hutto writes: > Python is, of course, a language based on a lower level to allow > higher level interactivity and ease of use. So, to define the > challenges of python, are to define the challenges of what it wraps > around. That seems like a framing of the issue designed to get a particular kind of answer. Why frame it that way? Why is the above forumlation better than, for example: Python is, of course, a language based on the English language. So, to define the challenges of Python is to define the challenges of the English lexis and grammar. For one thing, I don't agree that Python is ?a language based on a lower level?. A lower level of what? Python doesn't have any particular ?lower level?. Its *implementations* do ? each implementation wraps around different lower levels ? but you're talking about the language, aren't you? > Moving from lower level to the higher level of python, what needs to > take place at each level of the hierarchy it's placed on in order for > it to become 'perfect'? Perhaps you'd like to present what you think the answer to this question is, and we can discuss that. -- \ ?If we listen only to those who are like us, we will squander | `\ the great opportunity before us: To live together peacefully in | _o__) a world of unresolved differences.? ?David Weinberger | Ben Finney From rantingrick at gmail.com Tue Jan 25 18:33:03 2011 From: rantingrick at gmail.com (rantingrick) Date: Tue, 25 Jan 2011 15:33:03 -0800 (PST) Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com><9MB%o.14110$%64.6074@unlimited.newshosting.com> <59F6E65E3D9A46AD8D7A3863F3C1DC84@teddy> Message-ID: <27f53f8c-7862-4366-9352-82ae9a2f3970@k3g2000yqc.googlegroups.com> On Jan 25, 3:41?pm, Corey Richardson wrote: > Do you honestly think he was talking about the accessibility problem? > IMO that should move to another thread, because this one is simply > about, as the subject suggests, "WxPython versus Tkinter". Corey again (like many) you lack a global perspective. Anybody who has read along with his thread knows we are covering some pretty big issues here. WxPython is just the vehicle. The big picture is simply: Tkinter is old and in many ways insufficient for 21st century GUIs. We need to decide what should come next. I believe wxPython is our best hope. Wx may not be the best it can be, but it is the best we have at this time. There is more than "meets the eye" Corey! From rantingrick at gmail.com Tue Jan 25 18:39:13 2011 From: rantingrick at gmail.com (rantingrick) Date: Tue, 25 Jan 2011 15:39:13 -0800 (PST) Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com> <9MB%o.14110$%64.6074@unlimited.newshosting.com> Message-ID: <6fa3089d-f085-4929-9136-1eafeea436e7@f30g2000yqa.googlegroups.com> On Jan 25, 4:45?pm, Nicholas Devenish wrote: > But this thread is not about that, and the accessibility issue is mostly > a red herring that rantingrick has grabbed hold of to swing around like > a battleaxe, because nobody is going to say that accessibility doesn't > matter. Stop trying to exacerbate the situation Nick. You are one of the folks that has no fact based arguments to present so now you are plating the victim of my fact based argument. You are losing, and losing sucks! Stop trying to gain ground simply by hiding facts from the voters. Losers hate fact, because a fact based argument will dissolve BS faster than the speed of light. Get off the troll wagon and start contributing to the discussion in a positive way. From rantingrick at gmail.com Tue Jan 25 18:45:27 2011 From: rantingrick at gmail.com (rantingrick) Date: Tue, 25 Jan 2011 15:45:27 -0800 (PST) Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com> <9MB%o.14110$%64.6074@unlimited.newshosting.com> <4A48EDF6D7634F2E994661A457451E87@teddy> Message-ID: On Jan 25, 4:55?pm, geremy condra wrote: > There's a difference between what you say and how you say it. If a > friend came up to you and said "give me $100 right now!", you probably > wouldn't do it. What if someone was extorting him and he really needed the money "right now"? > If the same friend came up to you and said "I know > this is a big thing to ask, but I really need $100 and I can't > guarantee I'll be able to pay you back. Could you please help me?" I > don't know very many people who would refuse if they were able to > help. The reason is simple: the first does not acknowledge the value > of the person doing the favor, and the second does. No i see what this is about. YOU ARE PART OF THE ELITE and WE are part of the piss on peasants. We need to grovel at your feet and stroke your ego before you will give us an audience. We are nothing, we are pathetic, and you are all knowing. Ok, NOW i get it! > I would recommend that you learn to be civil to those you disagree > with. The alternative is to be surrounded by them. That sounds like a veiled threat to me Geremy! Your scare tactics are not working so go home. From emile at fenx.com Tue Jan 25 18:47:07 2011 From: emile at fenx.com (Emile van Sebille) Date: Tue, 25 Jan 2011 15:47:07 -0800 Subject: WxPython versus Tkinter. In-Reply-To: <59F6E65E3D9A46AD8D7A3863F3C1DC84@teddy> References: <4D3E4377.3060807@tysdomain.com><9MB%o.14110$%64.6074@unlimited.newshosting.com> <59F6E65E3D9A46AD8D7A3863F3C1DC84@teddy> Message-ID: On 1/25/2011 12:55 PM Octavian Rasnita said... > >> this thread was a "psy-ops" (psychological > operations) trick to turn off wxPython adopters by associating it with > juvenile nonsense > > Do you think the need for accessibility is a nonsense? > Or do you think it is something juvenile? Are third party installations nonsense? Or should python come with all libraries for all potential applications? And then always keep up with best of breed? Emile From rantingrick at gmail.com Tue Jan 25 18:49:46 2011 From: rantingrick at gmail.com (rantingrick) Date: Tue, 25 Jan 2011 15:49:46 -0800 (PST) Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com> <9MB%o.14110$%64.6074@unlimited.newshosting.com> Message-ID: <5a5e15f3-ae0f-4561-8969-e9afde3829dc@g26g2000vba.googlegroups.com> On Jan 25, 5:01?pm, Nicholas Devenish wrote: > why should I put my time and effort into learning a framework > with a community that is so hostile, when there are plenty of alternatives? That is exactly the point i have been making about this community (at c.l.py) We are not as noob friendly as we should be. If anyone dares commit ideas and they are not "accepted" yet, then that person will be pounced on and beaten. I have seen it time and time again. I have experienced this firsthand! From mgroth86 at gmail.com Tue Jan 25 18:51:06 2011 From: mgroth86 at gmail.com (Matthew Roth) Date: Tue, 25 Jan 2011 15:51:06 -0800 (PST) Subject: trouble installing MySQLdb (cygwin) + Bonus question References: <501470fc-c588-47d2-954d-17d825c5191c@v17g2000prc.googlegroups.com> <4d3f41d9$0$44021$742ec2ed@news.sonic.net> Message-ID: On Jan 25, 6:20?pm, David Robinow wrote: > On Tue, Jan 25, 2011 at 5:59 PM, Matthew Roth wrote: > > On Jan 25, 9:34?pm, John Nagle wrote: > ... > >> ? ? You can install a MySQL server under Windows, and talk to the server > >> from the Cygwin environment. ?That's a useful way to test. > > >> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? John Nagle > > > Right, that is precisely what I have. I am able to talk to it from > > cygwin, however, during the installing of the MySQLdb module it cannot > > find the mysql_config. This is because It is not installed? The setup > > sees that I am on a posix system not windows, as python is installed > > in cygwin, a virtual posix system. I am trying to bulid a mysql client > > from source for cygwin, however, I am running into an error there. > > > Unless, can I talk to the windows mysql_config? if so, what does that > > look like > > ?The obvious answer is to use a Windows python. You haven't explained > why you think you need to run a cygwin python. Can you explain that? Good question. There isn't a solid explanation. heretofore, I have been using a lot of bash scripting in combination with awk sed and some perl. I was directed to look into python. My tasks were becoming increasingly complex and memory intensive. I started with a desire to connect to a mysql server. For that I needed to install the MySQLdb module. I am having difficultly in acomplishment of this task. I suppose for the time it has taken, using windows python would have been the simpler route. Anyway, I have done some tinkering and have moved passed the mysql_config problem. Thanks to Davids reminder that I have mysql on windows. Meaning when setup.py called setup_posix.py It was essentially calling mysql_config. Well mysql_config was in a far off folder. I setup a symbolic link and that worked. However I was then presented with a new problem. In direct relation to that far off folder. Dreaded spaces. (i headed the log) -- running build running build_py copying MySQLdb/release.py -> build/lib.cygwin-1.7.7-i686-2.6/MySQLdb running build_ext building '_mysql' extension creating build/temp.cygwin-1.7.7-i686-2.6 gcc -fno-strict-aliasing -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict- prototypes -Dversion_info=(1,2,3,'final' ,0) -D__version__=1.2.3 -I/usr/include/python2.6 -c _mysql.c -o build/ temp.cygwin-1.7.7-i686-2.6/_mysql. o "-I/cygdrive/c/Program Files/MySQL/MySQL Server 5.5/include" "/MT" "/Zi" "/O2" "/Ob1" "/D" "NDEBUG" "- DDBUG_OFF" gcc: "-I/cygdrive/c/Program: No such file or directory -- there is much more, but obviously the problem is " gcc: "-I/cygdrive/c/ Program: No such file or directory" what I need to do is have it point to /cygdrive/c/Program\ Files/MySQL/ MySQL\ Server\ 5.5/include and not cygdrive/c/Program Files/MySQL/ MySQL Server 5.5/include. I am currently trying to track that down. I think I am going to leave work and go grab some dinner. perhaps I will solve this later tonight. Best, Matt From sohel807 at gmail.com Tue Jan 25 18:52:37 2011 From: sohel807 at gmail.com (Akand Islam) Date: Tue, 25 Jan 2011 15:52:37 -0800 (PST) Subject: adding "Print" menu in wxPython Message-ID: <05c1f4b3-941c-45b1-9370-a88653d1083a@e16g2000pri.googlegroups.com> To make a simple editor using wxPython, sample code is available in wxPython's tutorial page (http://wiki.wxpython.org/ WxHowtoSmallEditor). However, in addition I want to add "print" menu which will print the contents of editor (i.e. whatever written in editor). I will appreciate if someone please show me how to add printing option. Thanks, Akand From martin at v.loewis.de Tue Jan 25 18:56:59 2011 From: martin at v.loewis.de (Martin v. Loewis) Date: Wed, 26 Jan 2011 00:56:59 +0100 Subject: WxPython versus Tkinter. In-Reply-To: <8q7sgiF5tpU1@mid.individual.net> References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <8q7sgiF5tpU1@mid.individual.net> Message-ID: <4D3F634B.3040804@v.loewis.de> > You'll find that nearly all software used in Europe (and most other parts) > is internationalized or it wouldn't stand a chance. You mean, in lines of code? I very much doubt that. A lot of software gets written, in particular for web servers, that is only German, around here. Nobody thinks this is wrong, since the audience is expected to speak German, anyway. I think all the shell scripts that people write every day account for more lines of code than operating systems, office software, server applications, web frameworks combined. And these one-time use pieces of software are certainly not internationalized - not even in companies that have a policy that all software must support i18n. If you want examples, here are some: http://www.heise.de/ct/foren/ (web forum) http://arztsuche.spiegel.de/ (medical directory) http://portal.mytum.de/termine/index_html (university calendar - the software itself is bilingual; the content is not at all) etc. Regards, Martin From rantingrick at gmail.com Tue Jan 25 18:57:44 2011 From: rantingrick at gmail.com (rantingrick) Date: Tue, 25 Jan 2011 15:57:44 -0800 (PST) Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com><9MB%o.14110$%64.6074@unlimited.newshosting.com> <59F6E65E3D9A46AD8D7A3863F3C1DC84@teddy> Message-ID: On Jan 25, 5:47?pm, Emile van Sebille wrote: > Are third party installations nonsense? Of course not. > Or should python come with all > libraries for all potential applications? Again, of course not. No one has suggested such bombastic ideas in this thread, you are the first. > And then always keep up with > best of breed? Yes, Python should be as close to the "cutting edge" as possible. What does that mean exactly? Well we don't wont to be so close that we cut a finger (web interfaces). However at the same time we don't want to find ourselves two decades behind in evolution (Tkinter). There must be some middle ground. I believe some form of modified wxPython IS that middle ground. Five to tens years from now, web/mobile interfaces may be the middle ground. How much longer are we going to wait? How much longer can we wait without making a move? The Tkinter module is like a scared rabbit, frozen with fear, and unable to move. So too are we. Change with the times are get left behind! From andreambu at gmail.com Tue Jan 25 18:58:48 2011 From: andreambu at gmail.com (Andrea Ambu) Date: Wed, 26 Jan 2011 00:58:48 +0100 Subject: Fwd: numpy/matlab compatibility In-Reply-To: References: <4D3F2ECE.8070200@nmsu.edu> Message-ID: I replied to Matt only ARGH! ---------- Forwarded message ---------- From: Andrea Ambu Date: 25 January 2011 22:36 Subject: Re: numpy/matlab compatibility To: Matt Funk On Tue, Jan 25, 2011 at 9:13 PM, Matt Funk wrote: > > Hi, > > i am fairly new to python. I was wondering of the following is do-able > in python: > > 1) a = rand(10,1) > 2) Y = a > 3) mask = Y > 100; > 4) Y(mask) = 100; > 5) a = a+Y > No. Not like that. You do literally: a = rand(10, 1) Y = a mask = Y>100 Y = where(mask, 100, Y) a = a+Y More Pythonically: a = rand(10, 1) a = where(a > 100, a + 100, a + a) For those who don't speak Matlab: 1) a = rand(10,1) ; generates a 10x1 matrix for random number 0 < n < 1 2) Y = a 3) mask = Y > 100; similar to: mask = [i>100 for i in Y] 4) Y(mask) = 100; sets to 100 elements of Y with index i for which mask[i] = True 5) a = a+Y ; sums the two?matrices element by element (like you do in linear algebra) Anyway... rand generates number from 0 up to 1 (both in python and matlab)... when are they > 100? > > Basically i am getting stuck on line 4). I was wondering if it is > possible or not with python? > (The above is working matlab code) > > thanks > matt > -- > http://mail.python.org/mailman/listinfo/python-list -- Andrea From emile at fenx.com Tue Jan 25 19:14:01 2011 From: emile at fenx.com (Emile van Sebille) Date: Tue, 25 Jan 2011 16:14:01 -0800 Subject: WxPython versus Tkinter. In-Reply-To: <27f53f8c-7862-4366-9352-82ae9a2f3970@k3g2000yqc.googlegroups.com> References: <4D3E4377.3060807@tysdomain.com><9MB%o.14110$%64.6074@unlimited.newshosting.com> <59F6E65E3D9A46AD8D7A3863F3C1DC84@teddy> <27f53f8c-7862-4366-9352-82ae9a2f3970@k3g2000yqc.googlegroups.com> Message-ID: On 1/25/2011 3:33 PM rantingrick said... > Tkinter is old and in many ways insufficient for 21st century GUIs. We > need to decide what should come next. I believe wxPython is our best > hope. Wx may not be the best it can be, but it is the best we have at > this time. Then you should immediately volunteer to bring wxPython to python3 compatibility -- as it is, it's not even close... Start thinking about upping your game from ranting to doing. Emile From rantingrick at gmail.com Tue Jan 25 19:30:54 2011 From: rantingrick at gmail.com (rantingrick) Date: Tue, 25 Jan 2011 16:30:54 -0800 (PST) Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com><9MB%o.14110$%64.6074@unlimited.newshosting.com> <59F6E65E3D9A46AD8D7A3863F3C1DC84@teddy> <27f53f8c-7862-4366-9352-82ae9a2f3970@k3g2000yqc.googlegroups.com> Message-ID: On Jan 25, 6:14?pm, Emile van Sebille wrote: > On 1/25/2011 3:33 PM rantingrick said... > > > Tkinter is old and in many ways insufficient for 21st century GUIs. We > > need to decide what should come next. I believe wxPython is our best > > hope. Wx may not be the best it can be, but it is the best we have at > > this time. > > Then you should immediately volunteer to bring wxPython to python3 > compatibility -- as it is, it's not even close... Thats the kind of advice i want to hear. Now we are engaging in positive discussion. Now we (you and I) are acting like fellow members of the same community. Thank You Emile. With this sort of positive outlook we can move forward. But how do "you" feel about wxPython. If "you" had a choice would "you" volunteer for wxPython and move it towards Python 3 standards? If not, then what would "you" do. I think we can both agree that there is room to grow beyond the capabilities of Tkinter. From ian.g.kelly at gmail.com Tue Jan 25 19:40:46 2011 From: ian.g.kelly at gmail.com (Ian) Date: Tue, 25 Jan 2011 16:40:46 -0800 (PST) Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com> <9MB%o.14110$%64.6074@unlimited.newshosting.com> Message-ID: <3a0595be-695a-41aa-aba9-504bcc3d16d4@fm22g2000vbb.googlegroups.com> On Jan 25, 4:01?pm, Nicholas Devenish wrote: > Personally, no, it probably wouldn't have caused me not to use wx. But > it certainly would have put a mental tick in the against box, because a > frameworks community matters. As a little aside, a personal example is > Django, whose tutorial contained what to my un-django-trained eye looked > like an inconsistency bug, without explanation. I filed a bug report, > and apparently many other people have had the same misassumption > (indicating a problem with the tutorial). The bug was closed with words > effectively equivalent to "Stupid newbie". Ignoring the fact that > documentation being consistently misinterpreted should indicate a real > problem, why should I put my time and effort into learning a framework > with a community that is so hostile, when there are plenty of alternatives? Speaking as a Django user and occasional developer, I'm sorry to hear that you had a bad experience with the Django community. I have generally found it to be friendly and helpful, at least on the mailing list and the IRC channel. The ticket triagers have 1800+ open tickets to organize, so they can get ornery about duplicates at times. Are you referring to ticket #14081? I expect the reason this hasn't been addressed is because nobody has submitted a patch or suggested an improved wording. If you were to make a suggestion, I doubt that anybody would be hostile to the idea of improving the tutorial. Cheers, Ian From luismgz at gmail.com Tue Jan 25 19:43:38 2011 From: luismgz at gmail.com (=?ISO-8859-1?Q?Luis_M=2E_Gonz=E1lez?=) Date: Tue, 25 Jan 2011 16:43:38 -0800 (PST) Subject: Which is the best book to learn python References: <188c0a9f-4e93-4fae-b3f9-e7c84f8030fd@v31g2000pri.googlegroups.com> Message-ID: <53fd6f58-594e-48de-bc19-1408b4dcb580@29g2000prb.googlegroups.com> On Jan 24, 2:09?pm, santosh hs wrote: > Hi All, > i am beginner to python please tell me which is the best available > reference for beginner to start from novice If you are a complete beginner to programming, I suggest start with a tutorial such as "A Byte of Python" (google this). I learned my first steps with Josh Cogliati's "Non-Programmers Tutorial For Python" http://www.oopweb.com/Python/Documents/easytut/VolumeFrames.html . The suggestions above are very good if you are new to programming en general (not only to python). If you have some experience, you may look to something more advanced, such as "Dive into Python". All these resources are available online for free. If you want to but a book, I like "Beginning Python: From Novice to Professional". Hope this helps... Luis From rantingrick at gmail.com Tue Jan 25 19:54:43 2011 From: rantingrick at gmail.com (rantingrick) Date: Tue, 25 Jan 2011 16:54:43 -0800 (PST) Subject: adding "Print" menu in wxPython References: <05c1f4b3-941c-45b1-9370-a88653d1083a@e16g2000pri.googlegroups.com> Message-ID: On Jan 25, 5:52?pm, Akand Islam wrote: > > I will appreciate if someone please show me how to add > printing option. Hello Akand, Well the first step would be to create a stub "OnPrint" method and add a command to the File menu named "Print" that calls the "OnPrint" method. Can you do this part yourself? All the answers you need are in the source you linked to. Give it your best shot and then post some code with a specific question if you get stuck. From emile at fenx.com Tue Jan 25 19:55:34 2011 From: emile at fenx.com (Emile van Sebille) Date: Tue, 25 Jan 2011 16:55:34 -0800 Subject: WxPython versus Tkinter. In-Reply-To: <5a5e15f3-ae0f-4561-8969-e9afde3829dc@g26g2000vba.googlegroups.com> References: <4D3E4377.3060807@tysdomain.com> <9MB%o.14110$%64.6074@unlimited.newshosting.com> <5a5e15f3-ae0f-4561-8969-e9afde3829dc@g26g2000vba.googlegroups.com> Message-ID: On 1/25/2011 3:49 PM rantingrick said... > On Jan 25, 5:01 pm, Nicholas Devenish wrote: > >> why should I put my time and effort into learning a framework >> with a community that is so hostile, when there are plenty of alternatives? > > That is exactly the point i have been making about this community (at > c.l.py) We are not as noob friendly as we should be. If anyone dares > commit ideas and they are not "accepted" yet, then that person will be > pounced on and beaten. I have seen it time and time again. I have > experienced this firsthand! Oh, that everyone should blindly accept you as is and without regard for established protocols -- we certainly should all jump to your slightest whim. Get a fucking clue. Emile From emile at fenx.com Tue Jan 25 20:06:19 2011 From: emile at fenx.com (Emile van Sebille) Date: Tue, 25 Jan 2011 17:06:19 -0800 Subject: WxPython versus Tkinter. In-Reply-To: References: <4D3E4377.3060807@tysdomain.com><9MB%o.14110$%64.6074@unlimited.newshosting.com> <59F6E65E3D9A46AD8D7A3863F3C1DC84@teddy> Message-ID: On 1/25/2011 3:57 PM rantingrick said... > On Jan 25, 5:47 pm, Emile van Sebille wrote: > >> Are third party installations nonsense? > > Of course not. > So install wxPython and move on. Or start doing. Join one of the many GUI projects that would like to be in the standard library and do more than make a smelly breeze. Emile From rantingrick at gmail.com Tue Jan 25 20:07:07 2011 From: rantingrick at gmail.com (rantingrick) Date: Tue, 25 Jan 2011 17:07:07 -0800 (PST) Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com> <9MB%o.14110$%64.6074@unlimited.newshosting.com> <5a5e15f3-ae0f-4561-8969-e9afde3829dc@g26g2000vba.googlegroups.com> Message-ID: <1b955dcf-77e2-4130-9b5b-276cfedccd9c@a10g2000vby.googlegroups.com> On Jan 25, 6:55?pm, Emile van Sebille wrote: > Oh, that everyone should blindly accept you as is and without regard for > established protocols What protocols? Where is this standard posted? Can you give me a link? I would like to know what is expected of me. > -- we certainly should all jump to your slightest > whim. > > Get a [CENSORED] clue. Thats not very nice Emile. What is it going to take for you (and others) to take me seriously? I have been within this group for more than four years and you still do not accept me. I have been ridiculed, brow beaten, laughed at, trolled, and any negative thing that can be done to someone. Heck, in my very first post i was crucified by the community. I'll admit that I have made some mistakes -- and i have apologized for them. Maybe you need to be a little more accepting of me. Maybe this group IS not a homogeneous block as you would like. Maybe we ALL need to be a little more humble to each other. What do you think Emile? From misnomer at gmail.com Tue Jan 25 20:10:51 2011 From: misnomer at gmail.com (Nicholas Devenish) Date: Wed, 26 Jan 2011 01:10:51 +0000 Subject: WxPython versus Tkinter In-Reply-To: <3a0595be-695a-41aa-aba9-504bcc3d16d4@fm22g2000vbb.googlegroups.com> References: <4D3E4377.3060807@tysdomain.com> <9MB%o.14110$%64.6074@unlimited.newshosting.com> <3a0595be-695a-41aa-aba9-504bcc3d16d4@fm22g2000vbb.googlegroups.com> Message-ID: On 26/01/2011 00:40, Ian wrote: > Are you referring to ticket #14081? I expect the reason this hasn't > been addressed is because nobody has submitted a patch or suggested an > improved wording. If you were to make a suggestion, I doubt that > anybody would be hostile to the idea of improving the tutorial. Actually, it was that ticket, good hunting. It's not so much that it was marked as duplicate, but that the bug it's marked "Yet another" duplicate of is marked 'invalid', implying that the Django developers consider it not a bug (i.e. user error, and not something to be patched or reworded). If it was open, even as a long-term low-priority documentation bug, then closing and marking the duplicate report wouldn't have felt prickly at all. I did some digging at the time, and there were indeed several more instances of this confusion arising (that I failed to find in my cursory search before posting the report); if intelligent people are getting confused over the tutorial, (a document specifically designed for people unfamiliar with the framework), then it sure sounds like a documentation bug. Especially as, in some of the tickets, the responder explained the issue (so, a need to explain) before closing the ticket. Essentially, if people are hostile to the idea of accepting a documentation problem, surely they might react the same way to a patch for it. And this is the first impression I got of the django community; because I am only a casual user, I subsequently didn't feel any need to potentially 'fight against the system' over the issue. I'll take your encouraging comments on the general friend-and-helpful-ness of the Django community onboard. Thanks, Nick From rantingrick at gmail.com Tue Jan 25 20:12:21 2011 From: rantingrick at gmail.com (rantingrick) Date: Tue, 25 Jan 2011 17:12:21 -0800 (PST) Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com><9MB%o.14110$%64.6074@unlimited.newshosting.com> <59F6E65E3D9A46AD8D7A3863F3C1DC84@teddy> Message-ID: On Jan 25, 7:06?pm, Emile van Sebille wrote: > On 1/25/2011 3:57 PM rantingrick said... > > > On Jan 25, 5:47 pm, Emile van Sebille ?wrote: > > >> Are third party installations nonsense? > > > Of course not. > > So install wxPython and move on. ? See you are missing the point again. The point behind this whole challenge is that Tkinter is antiquity and Tkinter is making Python into antiquity simply by being in the stdlib. That is the entire point. Also, i have said many times that NO GUI library is TRULY 21st century however wxPython would be a far better base to start from than Tkinter. TclTk is never going to scale properly. The TclTk folks do not have a vision for the future. We need to move Python forward. And Tkinter is not forward. Tkinter is stagnation. 1990's stagnation. This is 2011. THAT, is my point. From rantingrick at gmail.com Tue Jan 25 20:17:03 2011 From: rantingrick at gmail.com (rantingrick) Date: Tue, 25 Jan 2011 17:17:03 -0800 (PST) Subject: WxPython versus Tkinter References: <4D3E4377.3060807@tysdomain.com> <9MB%o.14110$%64.6074@unlimited.newshosting.com> <3a0595be-695a-41aa-aba9-504bcc3d16d4@fm22g2000vbb.googlegroups.com> Message-ID: On Jan 25, 7:10?pm, Nicholas Devenish wrote: > Essentially, if people are hostile to the idea of accepting a > documentation problem, surely they might react the same way to a patch > for it. This is my very point about writing any code. Only a fool would spend years developing a code base if he had no assurances anyone would use it. First, a smart developer will test the waters through discussion. This is the first step. First garner support. Then code. Then publish. Then maintain. These are the essential steps for productivity. From torriem at gmail.com Tue Jan 25 20:18:01 2011 From: torriem at gmail.com (Michael Torrie) Date: Tue, 25 Jan 2011 18:18:01 -0700 Subject: WxPython versus Tkinter. In-Reply-To: <4D3C9981.8020107@tysdomain.com> References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <480571f5-5731-4f8b-9cb4-1468478711bf@c39g2000yqi.googlegroups.com> <2c951199-3dba-4d24-a5c2-f84081688f7e@u6g2000yqk.googlegroups.com> <3e603997-5539-4660-bd83-7398bdab34a4@k30g2000vbn.googlegroups.com> <5edded76-fdac-4eb5-8480-25e3381e2fd4@g26g2000vbz.googlegroups.com> <1d7fdb0c-9f82-45ab-bf0e-99d210042f0d@j21g2000vbn.googlegroups.com> <4D3C9981.8020107@tysdomain.com> Message-ID: <4D3F7649.7080309@gmail.com> On 01/23/2011 02:11 PM, Littlefield, Tyler wrote: > I hardly think that your tone, attitude and arguments are going to help > you in your battle to prove that WXPython is superior to anything at > all, if you can't manage to provide cross-platform bug-free code. Sadly you're wasting your breath. He just doesn't understand what you are saying. Further he honestly does not think he has an attitude or fallacious arguments. I find his posts fascinating, really. In the meantime I suppose we can reply for sport (not a fair fight really), or just leave him be. From craigyk at me.com Tue Jan 25 20:19:00 2011 From: craigyk at me.com (Craig Yoshioka) Date: Tue, 25 Jan 2011 17:19:00 -0800 Subject: help with multiprocessing pool Message-ID: Hi all, I could really use some help with a problem I'm having. I wrote a function that can take a pattern of actions and it apply it to the filesystem. It takes a list of starting paths, and a pattern like this: pattern = { InGlob('Test/**'):{ MatchRemove('DS_Store'):[], NoMatchAdd('(alhpaID_)|(DS_Store)','warnings'):[], MatchAdd('alphaID_','alpha_found'):[], InDir('alphaID_'):{ NoMatchAdd('(betaID_)|(DS_Store)','warnings'):[], InDir('betaID_'):{ NoMatchAdd('(gammaID_)|(DS_Store)','warnings'):[], MatchAdd('gammaID_','gamma_found'):[] }}}} so if you run evalFSPattern(['Volumes/**'],pattern) it'll return a dictionary where: dict['gamma_found'] = [list of paths that matched] (i.e. '/Volumes/HD1/Test/alphaID_3382/betaID_38824/gammaID_848384') dict['warning'] = [list of paths that failed to match] (ie. '/Volumes/HD1/Test/alphaID_3382/gammaID_47383') Since some of these volumes are on network shares I also wanted to parallelize this so that it would not block on IO. I started the parallelization by using multiprocessing.Pool and got it to work if I ran the fsparser from the interpreter. It ran in *much* less time and produced correct output that matched the non-parallelized version. The problem begins if I then try to use the parallelized function from within the code. For example I wrote a class whose instances are created around valid FS paths, that are cached to reduce expensive FS lookups. class Experiment(object): SlidePaths = None @classmethod def getSlidePaths(cls): if cls.SlidePaths == None: cls.SlidePaths = fsparser(['/Volumes/**'],pattern) return cls.SlidePaths @classmethod def lookupPathWithGammaID(cls,id): paths = cls.getSlidePaths() ... return paths[selected] @classmethod def fromGamaID(cls,id): path = cls.lookupPathWithGammaID(id) return cls(path) def __init__(self,path) self.Path = path ... ... If I do the following from the interpreter it works: >>>from experiment import Experiment >>>expt = Experiment.fromGammaID(10102) but if I write a script called test.py: from experiment import Experiment expt1 = Experiment.fromGammaID(10102) expt2 = Experiment.fromGammaID(10103) comparison = expt1.compareTo(expt2) it fails, if I try to import it or run it from bash prompt: >>> from test import comparison (hangs forever) $ python test.py (hangs forever) I would really like some help trying to figure this out... I thought it should work easily since all the spawned processes don't share data or state (their results are merged in the main thread). The classes used in the pattern are also simple python objects (use python primitives). These are the main functions: def mapAction(pool,paths,action): merge = {'next':[]} for result in pool.map(action,paths): if result == None: continue merge = mergeDicts(merge,result) return merge def mergeDicts(d1,d2): for key in d2: if key not in d1: d1[key] = d2[key] else: d1[key] += d2[key] return d1 def evalFSPattern(paths,pattern): pool = Pool(10) results = {} for action in pattern: tomerge1 = mapAction(pool,paths,action) tomerge2 = evalFSPattern(tomerge1['next'],pattern[action]) del tomerge1['next'] results = mergeDicts(results,tomerge1) results = mergeDicts(results,tomerge2) return results the classes used in the pattern (InGlob,NoMatchAdd,etc.) are callable classes that take a single parameter (a path) and return a dict result or None which makes them trivial to adapt to Pool.map. Note if I change the mapAction function to: def mapAction(pool,paths,action): merge = {'next':[]} for path in paths: result = action(path) if result == None: continue merge = mergeDicts(merge,result) return merge everything works just fine. Thanks. From torriem at gmail.com Tue Jan 25 20:19:42 2011 From: torriem at gmail.com (Michael Torrie) Date: Tue, 25 Jan 2011 18:19:42 -0700 Subject: WxPython versus Tkinter. In-Reply-To: <4d3c6e69$0$29983$c3e8da3$5496439d@news.astraweb.com> References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <1a1b0e40-ac98-4234-a95d-80ed05de4e72@s5g2000yqm.googlegroups.com> <4d3c6e69$0$29983$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4D3F76AE.9080500@gmail.com> On Sun, 23 Jan 2011 09:21:57 -0800, rantingrick wrote: > Wait a minute, i am confused? What language is Python written in? Oh > thats right Lisp! I am so dumb. How did i even get this job? :-) What job is this? Inquiring minds wish to know. From rantingrick at gmail.com Tue Jan 25 20:50:53 2011 From: rantingrick at gmail.com (rantingrick) Date: Tue, 25 Jan 2011 17:50:53 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <1a1b0e40-ac98-4234-a95d-80ed05de4e72@s5g2000yqm.googlegroups.com> <4d3c6e69$0$29983$c3e8da3$5496439d@news.astraweb.com> Message-ID: <5fbb428b-cc00-46c7-81f5-66ae6d8706f7@r14g2000yqn.googlegroups.com> On Jan 25, 7:19?pm, Michael Torrie wrote: > On Sun, 23 Jan 2011 09:21:57 -0800, rantingrick wrote: > > Wait a minute, i am confused? What language is Python written in? Oh > > thats right Lisp! I am so dumb. How did i even get this job? :-) > > What job is this? ?Inquiring minds wish to know. On Jan 25, 7:19pm, Michael Torrie wrote: > What job is this? Inquiring minds wish to know. Well my job is that of any humble community member. To be an intrical part of a large heterogeneous group of folks all working toward a common goal, who may *not* always and completely agree, however, all of whom respect one another on a basic and fundamental level. Each member has a responsibility to listen contently to his fellow members ideas and offer objective responses devoid of emotional baggage. Each member should gracefully and selflessly help those who are new to the group to feel more welcome. And most importantly we should all collectively keep our minds focused for the future of Python. We must not let Python grow stagnate. No, we must constantly push for further evolution. These changes will at times seem too painful to bear, that can be expected. However the changes are vital for our future evolution. For without change we would squander all the hard work of the many who have come before us. But together, united in community, and in vision, we shall keep the Python dream alive for many years to come! From python.list at tim.thechases.com Tue Jan 25 21:12:23 2011 From: python.list at tim.thechases.com (Tim Chase) Date: Tue, 25 Jan 2011 20:12:23 -0600 Subject: WxPython versus Tkinter. In-Reply-To: <1b955dcf-77e2-4130-9b5b-276cfedccd9c@a10g2000vby.googlegroups.com> References: <4D3E4377.3060807@tysdomain.com> <9MB%o.14110$%64.6074@unlimited.newshosting.com> <5a5e15f3-ae0f-4561-8969-e9afde3829dc@g26g2000vba.googlegroups.com> <1b955dcf-77e2-4130-9b5b-276cfedccd9c@a10g2000vby.googlegroups.com> Message-ID: <4D3F8307.1030309@tim.thechases.com> On 01/25/2011 07:07 PM, rantingrick wrote: > What is it going to take for you (and others) to take me seriously? Easy: Stop ranting, start writing quality code. -tkc From bryan.oakley at gmail.com Tue Jan 25 21:13:53 2011 From: bryan.oakley at gmail.com (Bryan) Date: Tue, 25 Jan 2011 18:13:53 -0800 (PST) Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com> <9MB%o.14110$%64.6074@unlimited.newshosting.com> <5a5e15f3-ae0f-4561-8969-e9afde3829dc@g26g2000vba.googlegroups.com> <1b955dcf-77e2-4130-9b5b-276cfedccd9c@a10g2000vby.googlegroups.com> Message-ID: On Jan 25, 7:07?pm, rantingrick wrote: > What is it going to take for you (and others) to take me seriously? If somebody answers that question, will you listen? That will be the first step. I know that may sound facetious but that's not my intention. It's my honest opinion based entirely on this single thread. Take a deep breath and listen to what people are telling you. You need to stop being intolerably illogical, childish, contentious and abusive. You are screaming in a room while covering your ears and closing your eyes and stomping your feet. Even if your argument had merit, nobody cares because you are too difficult to deal with to the point that it has become sadly humorous. You are very effectively sabotaging the very cause you are trying to promote due entirely to your poor attitude. From andre.roberge at gmail.com Tue Jan 25 22:10:54 2011 From: andre.roberge at gmail.com (=?ISO-8859-1?Q?Andr=E9?=) Date: Tue, 25 Jan 2011 19:10:54 -0800 (PST) Subject: WxPython versus Tkinter. In-Reply-To: Message-ID: <2b6f6afc-9150-4478-8c80-e7b4f9d74363@glegroupsg2000goo.googlegroups.com> On Tuesday, January 25, 2011 10:12:23 PM UTC-4, Tim Chase wrote: > On 01/25/2011 07:07 PM, rantingrick wrote: > > What is it going to take for you (and others) to take me seriously? > > Easy: Stop ranting, start writing quality code. > +1 Andr? > -tkc From andre.roberge at gmail.com Tue Jan 25 22:10:54 2011 From: andre.roberge at gmail.com (=?ISO-8859-1?Q?Andr=E9?=) Date: Tue, 25 Jan 2011 19:10:54 -0800 (PST) Subject: WxPython versus Tkinter. In-Reply-To: Message-ID: <2b6f6afc-9150-4478-8c80-e7b4f9d74363@glegroupsg2000goo.googlegroups.com> On Tuesday, January 25, 2011 10:12:23 PM UTC-4, Tim Chase wrote: > On 01/25/2011 07:07 PM, rantingrick wrote: > > What is it going to take for you (and others) to take me seriously? > > Easy: Stop ranting, start writing quality code. > +1 Andr? > -tkc From python at mrabarnett.plus.com Tue Jan 25 22:32:08 2011 From: python at mrabarnett.plus.com (MRAB) Date: Wed, 26 Jan 2011 03:32:08 +0000 Subject: WxPython versus Tkinter. In-Reply-To: <2b6f6afc-9150-4478-8c80-e7b4f9d74363@glegroupsg2000goo.googlegroups.com> References: <2b6f6afc-9150-4478-8c80-e7b4f9d74363@glegroupsg2000goo.googlegroups.com> Message-ID: <4D3F95B8.6060701@mrabarnett.plus.com> On 26/01/2011 03:10, Andr? wrote: > On Tuesday, January 25, 2011 10:12:23 PM UTC-4, Tim Chase wrote: >> On 01/25/2011 07:07 PM, rantingrick wrote: >>> What is it going to take for you (and others) to take me seriously? >> >> Easy: Stop ranting, start writing quality code. >> > +1 > Andr? > +1 From sohel807 at gmail.com Tue Jan 25 22:51:01 2011 From: sohel807 at gmail.com (Akand Islam) Date: Tue, 25 Jan 2011 19:51:01 -0800 (PST) Subject: adding "Print" menu in wxPython References: <05c1f4b3-941c-45b1-9370-a88653d1083a@e16g2000pri.googlegroups.com> Message-ID: <66d035ae-cb4f-4ad3-836d-f8394ad90475@q8g2000prm.googlegroups.com> Thanks for your response. Actually I already know I have to create "OnPrint" method followed by adding the menu named "Print" that calls "OnPrint" method. But the problem I am facing is to implement it. Here are the codes I am adding (from Tutorial) which make an editor and I want to add printing option so that I can print whatever is written in the editor. I will appreciate if you add coding with this file. =========================================================================================== import wx import os.path class MainWindow(wx.Frame): def __init__(self, filename='noname.txt'): super(MainWindow, self).__init__(None, size=(400,200)) self.filename = filename self.dirname = '.' self.CreateInteriorWindowComponents() self.CreateExteriorWindowComponents() def CreateInteriorWindowComponents(self): ''' Create "interior" window components. In this case it is just a simple multiline text control. ''' self.control = wx.TextCtrl(self, style=wx.TE_MULTILINE) def CreateExteriorWindowComponents(self): ''' Create "exterior" window components, such as menu and status bar. ''' self.CreateMenu() self.CreateStatusBar() self.SetTitle() def CreateMenu(self): fileMenu = wx.Menu() for id, label, helpText, handler in \ [(wx.ID_ABOUT, '&About', 'Information about this program', self.OnAbout), (wx.ID_OPEN, '&Open', 'Open a new file', self.OnOpen), (wx.ID_SAVE, '&Save', 'Save the current file', self.OnSave), (wx.ID_SAVEAS, 'Save &As', 'Save the file under a different name', self.OnSaveAs), (None, None, None, None), (wx.ID_EXIT, 'E&xit', 'Terminate the program', self.OnExit)]: if id == None: fileMenu.AppendSeparator() else: item = fileMenu.Append(id, label, helpText) self.Bind(wx.EVT_MENU, handler, item) menuBar = wx.MenuBar() menuBar.Append(fileMenu, '&File') # Add the fileMenu to the MenuBar self.SetMenuBar(menuBar) # Add the menuBar to the Frame def SetTitle(self): # MainWindow.SetTitle overrides wx.Frame.SetTitle, so we have to # call it using super: super(MainWindow, self).SetTitle('Editor %s'%self.filename) # Helper methods: def defaultFileDialogOptions(self): ''' Return a dictionary with file dialog options that can be used in both the save file dialog as well as in the open file dialog. ''' return dict(message='Choose a file', defaultDir=self.dirname, wildcard='*.*') def askUserForFilename(self, **dialogOptions): dialog = wx.FileDialog(self, **dialogOptions) if dialog.ShowModal() == wx.ID_OK: userProvidedFilename = True self.filename = dialog.GetFilename() self.dirname = dialog.GetDirectory() self.SetTitle() # Update the window title with the new filename else: userProvidedFilename = False dialog.Destroy() return userProvidedFilename # Event handlers: def OnAbout(self, event): dialog = wx.MessageDialog(self, 'A sample editor\n' 'in wxPython', 'About Sample Editor', wx.OK) dialog.ShowModal() dialog.Destroy() def OnExit(self, event): self.Close() # Close the main window. def OnSave(self, event): textfile = open(os.path.join(self.dirname, self.filename), 'w') textfile.write(self.control.GetValue()) textfile.close() def OnOpen(self, event): if self.askUserForFilename(style=wx.OPEN, **self.defaultFileDialogOptions()): textfile = open(os.path.join(self.dirname, self.filename), 'r') self.control.SetValue(textfile.read()) textfile.close() def OnSaveAs(self, event): if self.askUserForFilename(defaultFile=self.filename, style=wx.SAVE, **self.defaultFileDialogOptions()): self.OnSave(event) app = wx.App() frame = MainWindow() frame.Show() app.MainLoop() ==================================================================================== -- Akand On Jan 25, 6:54?pm, rantingrick wrote: > On Jan 25, 5:52?pm, Akand Islam wrote: > > > > > I will appreciate if someone please show me how to add > > printing option. > > Hello Akand, > > Well the first step would be to create a stub "OnPrint" method and add > a command to the File menu named "Print" that calls the "OnPrint" > method. Can you do this part yourself? All the answers you need are in > the source you linked to. Give it your best shot and then post some > code with a specific question if you get stuck. From steve+comp.lang.python at pearwood.info Tue Jan 25 23:21:40 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 26 Jan 2011 04:21:40 GMT Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com> <9MB%o.14110$%64.6074@unlimited.newshosting.com> <5a5e15f3-ae0f-4561-8969-e9afde3829dc@g26g2000vba.googlegroups.com> <1b955dcf-77e2-4130-9b5b-276cfedccd9c@a10g2000vby.googlegroups.com> Message-ID: <4d3fa153$0$29983$c3e8da3$5496439d@news.astraweb.com> On Tue, 25 Jan 2011 20:12:23 -0600, Tim Chase wrote: > On 01/25/2011 07:07 PM, rantingrick wrote: >> What is it going to take for you (and others) to take me seriously? > > Easy: Stop ranting, start writing quality code. Quality code is a good thing, but there are people who write good code but are so obnoxious that you wouldn't listen to a word they have to say, and people who are only mediocre or average coders, but are otherwise helpful and friendly. I'm amazed that Rick actually asked that question. Was he being sarcastic? In virtually every thread he takes part in, he is implicitly or explicitly told what he needs to do to be taken seriously: - stop ranting; - it's not all about him; - stop using "we" when he really means "me"; - he is not the conscience of the Python community; - stop pretending to be speaking for the community when it's obvious the community doesn't agree with him; - stop insulting everyone unless they agree with him; - if people don't agree with Rick, that doesn't mean they're in thrall to a hide-bound reactionary elite that has lost all touch with what makes Python good; - enough with the hero-worship of Guido (except when he's insulting Guido as well); - stop demanding others do all the work -- if Rick thinks something should be done, he should start a project and begin building it, then ask for volunteers to help; - listen to others' criticisms, don't just dismiss them without thought; - there's no shame in being mistaken if you are big enough to admit, and learn from, your errors; - enough with the over-blown melodrama, Python isn't going to be destroyed just because there's some tiny little corner that doesn't meet Rick's idea of perfection. That would do for starters. TL;DR. The shorter version: stop being a dick, and people will treat you seriously. -- Steven From tyler at tysdomain.com Tue Jan 25 23:37:06 2011 From: tyler at tysdomain.com (Littlefield, Tyler) Date: Tue, 25 Jan 2011 21:37:06 -0700 Subject: WxPython versus Tkinter. In-Reply-To: <1b955dcf-77e2-4130-9b5b-276cfedccd9c@a10g2000vby.googlegroups.com> References: <4D3E4377.3060807@tysdomain.com> <9MB%o.14110$%64.6074@unlimited.newshosting.com> <5a5e15f3-ae0f-4561-8969-e9afde3829dc@g26g2000vba.googlegroups.com> <1b955dcf-77e2-4130-9b5b-276cfedccd9c@a10g2000vby.googlegroups.com> Message-ID: <4D3FA4F2.6070307@tysdomain.com> >What do you think Emile? I think that that starts with you. You want to be more accepting when it comes to you, but you've had no problems calling people an idiot and otherwise insulting them just as you are complaining about. On 1/25/2011 6:07 PM, rantingrick wrote: > On Jan 25, 6:55 pm, Emile van Sebille wrote: > >> Oh, that everyone should blindly accept you as is and without regard for >> established protocols > What protocols? Where is this standard posted? Can you give me a link? > I would like to know what is expected of me. > >> -- we certainly should all jump to your slightest >> whim. >> >> Get a [CENSORED] clue. > Thats not very nice Emile. > > What is it going to take for you (and others) to take me seriously? I > have been within this group for more than four years and you still do > not accept me. I have been ridiculed, brow beaten, laughed at, > trolled, and any negative thing that can be done to someone. Heck, in > my very first post i was crucified by the community. I'll admit that I > have made some mistakes -- and i have apologized for them. Maybe you > need to be a little more accepting of me. Maybe this group IS not a > homogeneous block as you would like. Maybe we ALL need to be a little > more humble to each other. > > What do you think Emile? > -- Thanks, Ty From rustompmody at gmail.com Wed Jan 26 00:26:45 2011 From: rustompmody at gmail.com (rusi) Date: Tue, 25 Jan 2011 21:26:45 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <8q7sgiF5tpU1@mid.individual.net> <19891784-d6a3-41ac-a097-5902a6323bc0@o21g2000prn.googlegroups.com> <0b12cdb1-45b4-41e4-9bdb-074ee669d76b@k14g2000pre.googlegroups.com> Message-ID: <68c131c6-4d70-4587-a16f-8fc5a6f44de3@m13g2000yqb.googlegroups.com> On Jan 25, 11:15?pm, Terry Reedy wrote: > On 1/25/2011 10:29 AM, rusi wrote: > > > > > Just trying to sift the BS from the real issues > > > Heres a list of the issues relating to GUI toolkits > > > Look > > Nativity-1 (as in apps look like other apps on the OS) > > Nativity-2 (as in uses 'bare-metal' and not a separate interpreter) > > Themeing (ttk) > > Efficiency (extra interpreter) > > Cross Platform > > Stability (crashes on some OSes) > > Programmability > > Accessibility > > i18n > > Availability of gui builder > > Licence > > Good as far as it goes, but this list leaves out several requirements > (already posted by me, Steve Hansen, and others) for a Python 3 new > stdlib module. It does not matter for the stdlib if wxpython is 3 times > as good as tkinter, by some measure, as long as it is ineligible. > > -- > Terry Jan Reedy Thanks Terry -- so I add that to the list Works with Python 3 Look Nativity-1 (as in apps look like other apps on the OS) Nativity-2 (as in uses 'bare-metal' and not a separate interpreter) Themeing (ttk) Efficiency (extra interpreter) Cross Platform Stability (crashes on some OSes) Programmability Accessibility i18n Availability of gui builder Licence I should have mentioned earlier (doing it now) -- it maybe better to deal with this list breadth-first -- ie to expand it to include all the issues rather than going depth-first into each one. There are surely others like: Fun to use (very important when teaching/learning but hard to quantify) RR: You gave equal weights to each point. This does not work in general. eg I am chary about using a toolkit that crashes (If crashes are ok why not use C/C++ ?) And there is another dimension to the "breadth" which needs inclusion -- Qt and Gtk are equally contenders with Tkinter and Wx. (Any others Ive missed?) From nair331 at gmail.com Wed Jan 26 00:54:31 2011 From: nair331 at gmail.com (nair rajiv) Date: Wed, 26 Jan 2011 11:24:31 +0530 Subject: python interpreter Message-ID: Hi, I was exploring python. I wanted to know more about the python interpreter i.e the technical details of how it has been written. If I am directed to the code that also will be fine. The implementation of python data structures lists, tuples and dictionaries. If there exists any online documentation on the implementation aspects of python, please direct me to it. Rajiv Nair -------------- next part -------------- An HTML attachment was scrubbed... URL: From hidura at gmail.com Wed Jan 26 00:55:02 2011 From: hidura at gmail.com (Hidura) Date: Wed, 26 Jan 2011 01:55:02 -0400 Subject: How to execute foreing code from Python In-Reply-To: References: <20cf30433cec39ebdb049a8ae637@google.com> <4D3CC6C4.3060502@ieee.org> Message-ID: Hello, i understand how to execute a command on the terminal in linux, but what i can't get it is the execution of programs and send the data as arguments, the problem is that i can't execute the program and when i execute the program give me an error with the stdin... This is the code: argPath = "test1" args = open(argPath, 'w') if self.extract.getByAttr(self.block, 'name', 'args') != None: args.write(""+self.extract.getByAttr(self.block, 'name', 'args')[0].toxml()+"") else: args.write('') car = Popen(shlex.split('python3.1 /home/hidura/webapps/karinapp/Suite/ForeingCode/saveCSS.py', stdin=args, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True) args.close() dataOut = car.stdout.read().decode() log = car.stderr.read().decode() if dataOut!='': return dataOut.split('\n') elif log != '': return log.split('\n')[0] else: return None And the code from the saveCSS.py from xml.dom.minidom import parseString import os import sys class savCSS: """This class has to save the changes on the css file. """ def __init__(self, args): document = parseString(args) request = document.firstChild address = request.getElementsByTagName('element')[0] newdata = request.getElementsByTagName('element')[1] cssfl = open("/webapps/karinapp/Suite/"+address.getAttribute('value'), 'r') cssData = cssfl.read() cssfl.close() dataCSS = '' for child in newdata.childNodes: if child.nodeType == 3: dataCSS += child.nodeValue nwcssDict = {} for piece in dataCSS.split('}'): nwcssDict[piece.split('{')[0]] = piece.split('{')[1] cssDict = {} for piece in cssData.split('}'): cssDict[piece.split('{')[0]] = piece.split('{')[1] for key in nwcssDict: if key in cssDict == True: del cssDict[key] cssDict[key] = nwcssDict[key] result = '' for key in cssDict: result += key+"{"+cssDict[key]+"}" cssfl = open(cssfl.name, 'a') cssfl.write(result) cssfl.close() if __name__ == "__main__": print(sys.stdin) savCSS(input) On Sun, Jan 23, 2011 at 10:16 PM, Hidura wrote: > Thanks to all for your fast responses. I will use this on a server > running on Linux, so there is no problem with the OS and probably i > will try to pipes and subprocess, but the pipes worry me because i > can't stop the process using timeout or i don't found how to stop > it... > > > 2011/1/23, Dan Stromberg : > > On Sun, Jan 23, 2011 at 4:24 PM, Dave Angel wrote: > >> On 01/-10/-28163 02:59 PM, hidura at gmail.com wrote: > >>> > >>> Hello i want to code from different languages using a Python script i > >>> know i can use os.system, but i don't know how to receive data or send > >>> arguments using that method if theres any another way to make it or > >>> there's a way to send arguments and receive data using os.system? > >>> > >>> Thanks in advance. > >>> > >> > >> That sentence runs on, and makes no sense to me. But I can guess that > you > >> would like to be able to write code in other languages, and call it from > >> within a Python script. > > > > Well, clearly it made some sense, or you wouldn't be responding. > > > >> If you're on Windows, and the other language is a compiled one like C, > >> compile it into a DLL, and call that DLL from Python. Ctypes is the > first > >> module to study. > > > > The DLL is but a weak mimicry of what *ix had for a long time before. > > On most *ix's, the .so is the analog to the windows DLL, though only > > AIX appears to suffer from the same kind of "DLL hell" that windows > > suffers from (which makes some historical if not technical sense, > > given that windows is related to OS/2, which like AIX is also from > > IBM). Using a .so, you can still use ctypes. You also have the > > option of using Cython, which is perhaps a bit better supported on > > *ix, but will likely now work on windows too. > > > >> If you're on Linux, and the code in the other language was written by > >> someone else, and is already compiled into an executable you cannot > >> change, > > > > This is rare on Linux - almost everything is changeable on Linux, > > because it is almost entirely opensource - sometimes entirely so, > > depending on distribution choice and what 3rd party apps you install > > after the OS install. > > > >> you probably should invoke it using the subprocess module. > > > > This is an option on almost any OS, and in fact is probably a pretty > > good one on almost any OS, even if you do have source. Sadly, few > > windows programs are written to take advantage of this, perhaps > > because of the historical (dos/windows) command.com's fake pipes. > > > > You can communicate with a subprocess using pipes, or command line > > arguments, or files, or sockets, or shared memory. There are probably > > other options that aren't coming to mind just now. But usually, using > > pipes gives the loosest (best) coupling between processes. > > > > Microsoft appears to have recognized this to some extent by releasing > > powershell - though it uses object pipes rather than byte stream > > pipes. Object pipes appear to require less serialization, but also > > appear to be less loosely coupled. For remote pipes, powershell > > serializes to XML, while *ix pipes serialize exactly the same way > > remote local or remote. > > > > -- > Enviado desde mi dispositivo m?vil > > Diego I. Hidalgo D. > -- Diego I. Hidalgo D. -------------- next part -------------- An HTML attachment was scrubbed... URL: From orasnita at gmail.com Wed Jan 26 01:08:40 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Wed, 26 Jan 2011 08:08:40 +0200 Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <8q7sgiF5tpU1@mid.individual.net> <19891784-d6a3-41ac-a097-5902a6323bc0@o21g2000prn.googlegroups.com><0b12cdb1-45b4-41e4-9bdb-074ee669d76b@k14g2000pre.googlegroups.com> <048FB74272D440A0915ABC7D76AE262B@teddy> Message-ID: <5782E9AD8A8342D691EB3549E5E0ED7B@octavian> From: "Emile van Sebille" >> Why is WxPython ineligible? > > I think Terry's point was compatibility with python3 -- which wx > apparently isn't yet. > > Emile Well, I didn't know this, and it is a valid reason. This means that it is true that there is no enough maintainance force to keep WxPython updated. Did I understand correctly? Octavian From orasnita at gmail.com Wed Jan 26 01:18:37 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Wed, 26 Jan 2011 08:18:37 +0200 Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com><9MB%o.14110$%64.6074@unlimited.newshosting.com><59F6E65E3D9A46AD8D7A3863F3C1DC84@teddy> <27f53f8c-7862-4366-9352-82ae9a2f3970@k3g2000yqc.googlegroups.com> Message-ID: <7F4FDC467BCF47D4A069B29246FBDB17@octavian> From: "rantingrick" On Jan 25, 3:41 pm, Corey Richardson wrote: > Do you honestly think he was talking about the accessibility problem? > IMO that should move to another thread, because this one is simply > about, as the subject suggests, "WxPython versus Tkinter". Corey again (like many) you lack a global perspective. Anybody who has read along with his thread knows we are covering some pretty big issues here. WxPython is just the vehicle. The big picture is simply: Tkinter is old and in many ways insufficient for 21st century GUIs. We need to decide what should come next. I believe wxPython is our best hope. Wx may not be the best it can be, but it is the best we have at this time. There is more than "meets the eye" Corey! -- I will tell you what I think and many of you won't like this. :-) I think that nothing is "sufficient" and nothing should last forever. The people don't need Tkinter. They don't need WxPython. They don't need Python. Do you think that Python is a language that will be used forever? The people don't necessarily need to use a computer. Do you think that the computers as they are today will be used until the end of the time? The people do need to have an easier life, to make as little efforts as possible and to obtain as much benefit as possible and for the moment the computers and Python and a GUI lib help them do this, so these things are just some other means for obtaining what they need. What we don't agree is that some of the list members think that only the selfishness is the right ATITUDE AND SAY THAT I should change mine because I should care more about my own benefits and don't care at all about the others. Octavian From rantingrick at gmail.com Wed Jan 26 01:19:28 2011 From: rantingrick at gmail.com (rantingrick) Date: Tue, 25 Jan 2011 22:19:28 -0800 (PST) Subject: adding "Print" menu in wxPython References: <05c1f4b3-941c-45b1-9370-a88653d1083a@e16g2000pri.googlegroups.com> <66d035ae-cb4f-4ad3-836d-f8394ad90475@q8g2000prm.googlegroups.com> Message-ID: <7775b108-b04b-44a9-abae-1e58842b3186@b25g2000vbz.googlegroups.com> On Jan 25, 9:51?pm, Akand Islam wrote: > Thanks for your response. Actually I already know I have to create > "OnPrint" method followed by adding the menu named "Print" that calls > "OnPrint" method. But the problem I am facing is to implement it. Here > are the codes I am adding (from Tutorial) which make an editor and I > want to add printing option so that I can print whatever is written in > the editor. I will appreciate if you add coding with this file. Well i don't see where you added the methods or the menu command. * scratches head* Man I've got to tell you that this code is a horrible example to learn from! The styling abominations and obfuscation is just simply atrocious! It seems the author was trying to confuse everyone including himself! So i modified it just a bit. I added the OnPrint method however i am leaving it up to you to build the Print menu and do the binding. I put some comments where you need to add the print menu. Just look at how the other menus are created and you'll figure it out ;) Let us know if you need more help. #--START CODE--# import wx import os.path, sys class MainWindow(wx.Frame): def __init__(self, filename='noname.txt'): wx.Frame.__init__(self, None, size=(400,200)) self.filename = filename self.dirname = '.' self.control = wx.TextCtrl(self, style=wx.TE_MULTILINE) self.CreateMenu() self.CreateStatusBar() self.SetTitle() def CreateMenu(self): fileMenu = wx.Menu() item = fileMenu.Append(wx.ID_ABOUT, '&About', 'Info') self.Bind(wx.EVT_MENU, self.OnAbout, item) item = fileMenu.Append( wx.ID_OPEN, '&Open', 'Info') self.Bind(wx.EVT_MENU, self.OnOpen, item) item = fileMenu.Append(wx.ID_SAVE, '&Save', 'Info') self.Bind(wx.EVT_MENU, self.OnSave, item) item = fileMenu.Append(wx.ID_SAVEAS, 'Save &As', 'Info') self.Bind(wx.EVT_MENU, self.OnSaveAs, item) # psst: Hey put the print menu here!!!! # psst: do the binding here!!!! fileMenu.AppendSeparator() item = fileMenu.Append(wx.ID_EXIT, 'E&xit', 'Terminate the program') self.Bind(wx.EVT_MENU, self.OnExit, item) menuBar = wx.MenuBar() menuBar.Append(fileMenu, '&File') # Add the fileMenu to the MenuBar self.SetMenuBar(menuBar) # Add the menuBar to the Frame def SetTitle(self): # MainWindow.SetTitle overrides wx.Frame.SetTitle, so we have to # call it using super: super(MainWindow, self).SetTitle('Editor %s'%self.filename) def defaultFileDialogOptions(self): ''' Return a dictionary with file dialog options that can be used in both the save file dialog as well as in the open file dialog. ''' return dict( message='Choose a file', defaultDir=self.dirname, wildcard='*.*' ) def askUserForFilename(self, **dialogOptions): dialog = wx.FileDialog(self, **dialogOptions) if dialog.ShowModal() == wx.ID_OK: userProvidedFilename = True self.filename = dialog.GetFilename() self.dirname = dialog.GetDirectory() self.SetTitle() # Update the window title with the new filename else: userProvidedFilename = False dialog.Destroy() return userProvidedFilename # Event handlers: def OnAbout(self, event): dialog = wx.MessageDialog(self, 'A sample editor\n' 'in wxPython', 'About Sample Editor', wx.OK) dialog.ShowModal() dialog.Destroy() def OnExit(self, event): self.Close() # Close the main window. def OnSave(self, event): textfile = open(os.path.join(self.dirname, self.filename), 'w') textfile.write(self.control.GetValue()) textfile.close() def OnOpen(self, event): if self.askUserForFilename( style=wx.OPEN,**self.defaultFileDialogOptions() ): textfile = open(os.path.join(self.dirname, self.filename), 'r') self.control.SetValue(textfile.read()) textfile.close() def OnSaveAs(self, event): if self.askUserForFilename( defaultFile=self.filename, style=wx.SAVE, **self.defaultFileDialogOptions() ): self.OnSave(event) def OnPrint(self, event): sys.stdout.write(self.control.GetValue()) app = wx.App() frame = MainWindow() frame.Show() app.MainLoop() #--END CODE--# From orasnita at gmail.com Wed Jan 26 01:25:22 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Wed, 26 Jan 2011 08:25:22 +0200 Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com><9MB%o.14110$%64.6074@unlimited.newshosting.com> <59F6E65E3D9A46AD8D7A3863F3C1DC84@teddy> <27f53f8c-7862-4366-9352-82ae9a2f3970@k3g2000yqc.googlegroups.com> Message-ID: <718D13777F254C839F9564BC4275DE0A@octavian> From: "Emile van Sebille" > On 1/25/2011 3:33 PM rantingrick said... > >> Tkinter is old and in many ways insufficient for 21st century GUIs. We >> need to decide what should come next. I believe wxPython is our best >> hope. Wx may not be the best it can be, but it is the best we have at >> this time. > > Then you should immediately volunteer to bring wxPython to python3 > compatibility -- as it is, it's not even close... > > Start thinking about upping your game from ranting to doing. > > Emile Hi Emile, >From my point of view this discussion is finished for the moment, because you are right, WxPython is not as fast developed as it needs, because Python 3 is not compatible with Python 2. If no solution is found for this big problem, then yes, WxPython can't be included in the Python distribution because there is nothing that can be included. I don't know why you didn't say this before. :-) The other part of the discussion is related to the accessibility and care for accessibility and that discussion is not nice at all, because it shows how selfish are most of the people and they consider this a virtue. Octavian From orasnita at gmail.com Wed Jan 26 01:33:25 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Wed, 26 Jan 2011 08:33:25 +0200 Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com><9MB%o.14110$%64.6074@unlimited.newshosting.com> <59F6E65E3D9A46AD8D7A3863F3C1DC84@teddy> Message-ID: <1A345664905B4009B482F0EDF4ECE7DA@octavian> From: "Emile van Sebille" > Are third party installations nonsense? Or should python come with all > libraries for all potential applications? And then always keep up with > best of breed? Python should not include all the libraries for all the potential applications, but it should promote the tools that don't generate discrimination without even willing to do that. If there is no accessible portable GUI lib for Python 3 as you said, then it is very normal that Python can't promote it, because there is nothing to promote if Python 3 doesn't offer accessible portable interfaces. But this is the real reason and not the fact that the accessibility shouldn't be important nor that my atitude of caring for the others is not right and should be changed with a more selfish one. Octavian From tjreedy at udel.edu Wed Jan 26 01:53:06 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Wed, 26 Jan 2011 01:53:06 -0500 Subject: Need GUI pop-up to edit a (unicode ?) string In-Reply-To: <541c02df-b1fc-4376-bf17-e0531fe5c4bf@r29g2000yqj.googlegroups.com> References: <3tqr08-bj2.ln1@murmur.very.softly> <7691fe98-37af-4ddf-a8a8-eadeef0d4a6e@y2g2000prf.googlegroups.com> <541c02df-b1fc-4376-bf17-e0531fe5c4bf@r29g2000yqj.googlegroups.com> Message-ID: On 1/25/2011 6:02 PM, rantingrick wrote: > This design pattern promotes reuse-ability and encapsulation. However > with Fredricks design you cannot configure the contained widgets after > creating the instance because the dialog has entered a local event > loop brought on by "self.wait_window(self)" which is in the DAMN > INITIAL METHOD! I only see "self.wait_window(self)" in the Dialog base class and not in SimpleDialog, which is what I though you were talking about. It is the last line of Dialog.__init__. It appears that the intention is that all configuration be done in the body and button_box methods which are called earlier. > This is a major flaw in the design and i would be > happy to fix the flaw. However our "friend" Fredrick decided to > copyright the module to himself! As far as I know, anything contributed to the stdlib has been licensed by the author to be redistributed under the Python license and can be patched by the developers. (This is one reason for people to not contribute their code to the stdlib.) -- Terry Jan Reedy From rantingrick at gmail.com Wed Jan 26 01:54:47 2011 From: rantingrick at gmail.com (rantingrick) Date: Tue, 25 Jan 2011 22:54:47 -0800 (PST) Subject: adding "Print" menu in wxPython References: <05c1f4b3-941c-45b1-9370-a88653d1083a@e16g2000pri.googlegroups.com> <66d035ae-cb4f-4ad3-836d-f8394ad90475@q8g2000prm.googlegroups.com> <7775b108-b04b-44a9-abae-1e58842b3186@b25g2000vbz.googlegroups.com> Message-ID: On Jan 26, 12:19?am, rantingrick wrote: Actually i found more cruft. Here is something that would be acceptable although i had to wrap lines shorter than i normally would for the sake of Usenet. Who ever wrote that code should be lashed 50 times! You still need some error handling for the open and save file methods but crikey i can't do everything ;-) #--STARTCODE--# import wx import os.path, sys class MainWindow(wx.Frame): def __init__(self, filename='noname.txt'): wx.Frame.__init__(self, None, size=(400,200)) self.filename = filename self.dirname = '.' self.control = wx.TextCtrl(self, style=wx.TE_MULTILINE) self.CreateMenu() self.CreateStatusBar() self.SetTitle('Editor %s'%self.filename) self.dlgdefaults = { 'message':'Choose a file', 'defaultDir':self.dirname, 'wildcard':'*.*' } def CreateMenu(self): fileMenu = wx.Menu() item = fileMenu.Append(wx.ID_ABOUT, '&About', 'Info') self.Bind(wx.EVT_MENU, self.OnAbout, item) item = fileMenu.Append( wx.ID_OPEN, '&Open', 'Info') self.Bind(wx.EVT_MENU, self.OnOpen, item) item = fileMenu.Append(wx.ID_SAVE, '&Save', 'Info') self.Bind(wx.EVT_MENU, self.OnSave, item) item = fileMenu.Append(wx.ID_SAVEAS, 'Save &As', 'Info') self.Bind(wx.EVT_MENU, self.OnSaveAs, item) # # psst: Hey put the print menu here!!!! # psst: do the binding here!!!! # fileMenu.AppendSeparator() item = fileMenu.Append(wx.ID_EXIT, 'E&xit', 'Exit') self.Bind(wx.EVT_MENU, self.OnExit, item) menuBar = wx.MenuBar() # Add the fileMenu to the MenuBar menuBar.Append(fileMenu, '&File') # Add the menuBar to the Frame self.SetMenuBar(menuBar) def askUserForFilename(self, **kw): dialog = wx.FileDialog(self, **kw) if dialog.ShowModal() == wx.ID_OK: userProvidedFilename = True self.filename = dialog.GetFilename() self.dirname = dialog.GetDirectory() self.SetTitle('Editor %s'%(self.filename)) else: userProvidedFilename = False dialog.Destroy() return userProvidedFilename def OnAbout(self, event): dialog = wx.MessageDialog( self, 'A sample editor in wxPython', 'About Sample Editor', wx.OK ) dialog.ShowModal() dialog.Destroy() def OnExit(self, event): self.Close() def OnSave(self, event): textfile = open(os.path.join(self.dirname, self.filename), 'w') textfile.write(self.control.GetValue()) textfile.close() def OnOpen(self, event): if self.askUserForFilename( style=wx.OPEN, **self.dlgdefaults ): textfile = open(os.path.join(self.dirname, self.filename), 'r') self.control.SetValue(textfile.read()) textfile.close() def OnSaveAs(self, event): if self.askUserForFilename( defaultFile=self.filename, style=wx.SAVE, **self.dlgdefaults ): self.OnSave(event) def OnPrint(self, event): sys.stdout.write(self.control.GetValue()) app = wx.App() frame = MainWindow() frame.Show() app.MainLoop() #--ENDCODE--# From orasnita at gmail.com Wed Jan 26 02:10:27 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Wed, 26 Jan 2011 09:10:27 +0200 Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com><9MB%o.14110$%64.6074@unlimited.newshosting.com><4A48EDF6D7634F2E994661A457451E87@teddy> Message-ID: <753A4C5A6658470085804B13C80340F2@octavian> From: "geremy condra" > There's a difference between what you say and how you say it. If a > friend came up to you and said "give me $100 right now!", you probably > wouldn't do it. If the same friend came up to you and said "I know > this is a big thing to ask, but I really need $100 and I can't > guarantee I'll be able to pay you back. Could you please help me?" I Are you even thinking that the second sentence is much harder to express? Do you imagine that my knowledge of English is limited by the fact that it is not my native language and it is a language not spoken by very many people in my country? I simply might not be able to express so nice as you like that I need 100 bucks from you, but I might be able to just tell you that "need 100 dollars. now". I could argue much more nice and expressive if we were speaking Romanian and not English. But I don't condemn you for this, because many years ago when I was in school I had the opinion that some foreign colleagues are a little stupid just because they were not able to express very well the ideas which were not very simple, and well, they were not stupid at all, but they didn't know my language well enough and they probably would think the same thing about me if we were speaking in Russian. > don't know very many people who would refuse if they were able to > help. The reason is simple: the first does not acknowledge the value > of the person doing the favor, and the second does. Exactly what I said. They are doing the same mistake as I did 20 years ago. By the way, can't you see any syntactic dissacords in my phrases? Haven't you think that my English might not be as fluent to be able to express everything I want to say very well? > More concretely, you have an opinion that not supporting accessibility > is discrimination. Tyler has an opinion that not supporting > accessibility is a bug. This is not always true. Not supporting accessibility when *it is not possible* yes, it is a bug as you say, so we agree here. But not supporting accessibility because the programmer *doesn't want this*, it is not a bug, but discrimination. Don't you agree with this? And if Python would have been able to support accessibility it would have mean that it promotes discrimination because it promotes the wrong tool, but it seems that Python 3 doesn't have an accessible GUI lib for the moment, so no, it is not discrimination (but Emile told us that there is no support for WxPython in Python 3 just today, so I didn't know this and I already wondered why nobody told about this real problem). > Are you going to demand that he change his > opinion? Or are you going to ask that he consider yours? It seems that the discrimination should be something that should be discussed if and when it should be applied, isn't it? Well, I think that everyone should understand why the programs must be accessible and why everybody should care about all the users of an application and that it is not normal to not care. >> Have I said something wrong? Did I use bad words? Or what was it wrong? > > I think it was uncivil. It was rude, unkind, and generally > disagreeable. I lost respect for you, and by proxy, for your point of > view. In other words, you lost support not because fewer people agree > with your position, but because fewer people want to agree with you. You are also very unkind and rude when you say that the disabled that need to use a screen reader should be a kind of second hand people that need to beg for a little accessibility. When you create a program, why do you create a visual interface for it? Why don't you create just an audio interface? You do this because otherwise you would not please those who can see. Why shouldn't be something normal, and that *should be not be discussable at all* to offer the same accessibility to everyone? And you didn't say what was rude from what I said. You said just that it was rude. Oh yes I know that it is unkind because most of the people don't even like to talk personally with disabled people, but this doesn't mean that the disabled people are something not normal, but those who have those biases towards those who are very different. >> I have just an opinion, but that opinion won't change until the opinion >> of those who pretend that the discrimination is something normal. >> Do you think that this is not normal? > > I didn't ask you to change your opinion. I told you that you would be > more effective if you changed your attitude. Like rantingrick, you're > free to ignore that advice, but it is good advice for both you and the > community, and I urge you to take it. About what community? It would be better for the community of the disabled? Or you don't care about that community? >> Or you recommend me to be just like Tyler that can't use all the apps he >> could use if they were accessible, but he doesn't care because he cares >> much more to play nice in order to be accepted in this not-right society? > > I would recommend that you learn to be civil to those you disagree > with. The alternative is to be surrounded by them. Aha, you show that old fact that the majority is more important because it has more power, the fact Tyler is afraid. The majority can be also wrong, the majority can also have bad feelings, and that majority that have the power to change things should be informed and convinced to change them. If the majority doesn't care about the minorities which are minorities without willing to be so, then it means that it is wrong. Octavian From rantingrick at gmail.com Wed Jan 26 02:11:27 2011 From: rantingrick at gmail.com (rantingrick) Date: Tue, 25 Jan 2011 23:11:27 -0800 (PST) Subject: Need GUI pop-up to edit a (unicode ?) string References: <3tqr08-bj2.ln1@murmur.very.softly> <7691fe98-37af-4ddf-a8a8-eadeef0d4a6e@y2g2000prf.googlegroups.com> <541c02df-b1fc-4376-bf17-e0531fe5c4bf@r29g2000yqj.googlegroups.com> Message-ID: <3f724ff2-d571-4f50-92e1-45eaf9ab163d@r16g2000prh.googlegroups.com> On Jan 26, 12:53?am, Terry Reedy wrote: > I only see "self.wait_window(self)" in the Dialog base class and not in > SimpleDialog, which is what I though you were talking about. It is the > last line of Dialog.__init__. Yes. In the module "tkSimpleDialog" the class "Dialog" is what i am referring to. Sorry for the confusion. > It appears that the intention is that all > configuration be done in the body and button_box methods which are > called earlier. Yes exactly. And this works well most of the time. However there are many times where you may want to create a dialog with say a Label. And you do not want to hard code the string displayed on the label. However you cannot change the string once you initialize the dialog because it enters a "modal wait loop". So what i am proposing is that we change tkSimpleDialog to be like any other modal dialogs out there. We move the modal code into a show method and use the dialog like i suggested. I can send you a patch if you would be interested. My patch does break backward compatibility. However we can make it compatible somehow. Or an alternative approach would be to create a new dialog module and then depreciate tkSimpleDialog. Let me know on or off list if you are interested. > As far as I know, anything contributed to the stdlib has been licensed > by the author to be redistributed under the Python license and can be > patched by the developers. (This is one reason for people to not > contribute their code to the stdlib.) I don't understand what that means. Are you suggesting that contributing code is bad? From orasnita at gmail.com Wed Jan 26 02:27:43 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Wed, 26 Jan 2011 09:27:43 +0200 Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com> <9MB%o.14110$%64.6074@unlimited.newshosting.com> Message-ID: <10BC7C2D6ECE4DAE8D7866CDFDA51911@octavian> From: "Nicholas Devenish" > Octavian, we get it - you are on the warpath about accessibility. And this > is, in a way, a good thing, because, yes, programmers should in general > think more about accessibility when designing their programs. But nobody > was ever persuaded to consider a complicated and subtle issue by hostile > holier-than-thou arrogance, which is what rantingricks posts started out > with, and what your posts have been slowly turning into. This is what is > 'not a good thing', in case you genuinely didn't understand the context of > my previous message. Look at the response your earlier posts got, with > experienced developers showing an interest in actually trying out > accessibility tools. Compare this with the defensive replies you have been > getting more recently. Hi Nicholas, Thank you for your nice words. I admit that I don't understand absolutely everything (for example I have met "holier-than-thou" only in a song of Metallica, but I don't know what it really means :-) I know only that Tk is very old and it is still not accessible and it doesn't mean too much if some developers say that they are interested in making it accessible, because even with a hard work, a GUI lib like Tkinter may be made accessible only after years of work, because the accessibility standards change, the main OS used by the majority of users also change... and I thought that Python already offers a solution for this problem. However I can see that for the moment it doesn't offer it because WxPython is not compatible with Python 3. (I am wondering if there would be any change if Python 3 could be used with WxPython). > But this thread is not about that, and the accessibility issue is mostly a > red herring that rantingrick has grabbed hold of to swing around like a > battleaxe, because nobody is going to say that accessibility doesn't > matter. Discrimination in many forms, is a real problem in our societies, > and one that is not going to be solved overnight, much as you might wish > it. Stigmatizing perfectly repectful people who haven't encountered your > needs before, or don't agree that accessibility is the only thing that > matters, is not going to solve any issues. Well, I am on this list just for a few weeks, and I don't know yet who is respectable and who is not, who is an expert or not, and so on. I just expressed my opinion that if there is a solution for accessibility it should be prefered and it should be promoted by Python. Actually this is the main idea. Nobody should force the developers to use that accessible solution, but those who don't use it should understand and accept that they are using a not recommended and a wrong tool. Of course that there may be many cases in which such a wrong tool would be prefered for commercial reasons, but the developers that do that should understand that they are doing something wrong. Octavian From orasnita at gmail.com Wed Jan 26 02:40:41 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Wed, 26 Jan 2011 09:40:41 +0200 Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com><9MB%o.14110$%64.6074@unlimited.newshosting.com><5a5e15f3-ae0f-4561-8969-e9afde3829dc@g26g2000vba.googlegroups.com><1b955dcf-77e2-4130-9b5b-276cfedccd9c@a10g2000vby.googlegroups.com> <4d3fa153$0$29983$c3e8da3$5496439d@news.astraweb.com> Message-ID: <5DA17921A6C04D0EB337FBDFD9B5D41E@octavian> From: "Steven D'Aprano" > Quality code is a good thing, but there are people who write good code > but are so obnoxious that you wouldn't listen to a word they have to say, > and people who are only mediocre or average coders, but are otherwise > helpful and friendly. > > I'm amazed that Rick actually asked that question. Was he being sarcastic? > > In virtually every thread he takes part in, he is implicitly or > explicitly told what he needs to do to be taken seriously: > > - stop ranting; > - it's not all about him; > - stop using "we" when he really means "me"; > - he is not the conscience of the Python community; > - stop pretending to be speaking for the community when it's > obvious the community doesn't agree with him; > - stop insulting everyone unless they agree with him; > - if people don't agree with Rick, that doesn't mean they're in > thrall to a hide-bound reactionary elite that has lost all > touch with what makes Python good; > - enough with the hero-worship of Guido (except when he's > insulting Guido as well); > - stop demanding others do all the work -- if Rick thinks > something should be done, he should start a project and begin > building it, then ask for volunteers to help; > - listen to others' criticisms, don't just dismiss them without > thought; > - there's no shame in being mistaken if you are big enough to > admit, and learn from, your errors; > - enough with the over-blown melodrama, Python isn't going to be > destroyed just because there's some tiny little corner that > doesn't meet Rick's idea of perfection. > > > That would do for starters. > > > TL;DR. The shorter version: stop being a dick, and people will treat you > seriously. > Wow! now I think I understand some of the atitudes on this list. It seems that some of the list members know each other very well, and they have strong opinions, maybe for good reasons, I don't know, and I just dropped some messages without knowing who is considered good, who is the bad, who are those with valuable opinions and so on. I am sorry if I offended someone, but the main idea I just wanted to express was that Python should promote the accessibility and deprecate those tools which are not accessible. That's all. It should not force anyone to use anything but it just promote the right tools (which is not the case now, but it seems that there is a technical reason for this... the fact that WxPython can't be used in Python 3). Octavian From me+list/python at ixokai.io Wed Jan 26 03:08:01 2011 From: me+list/python at ixokai.io (Stephen Hansen) Date: Wed, 26 Jan 2011 00:08:01 -0800 Subject: WxPython versus Tkinter. In-Reply-To: <4d3fa153$0$29983$c3e8da3$5496439d@news.astraweb.com> References: <4D3E4377.3060807@tysdomain.com> <9MB%o.14110$%64.6074@unlimited.newshosting.com> <5a5e15f3-ae0f-4561-8969-e9afde3829dc@g26g2000vba.googlegroups.com> <1b955dcf-77e2-4130-9b5b-276cfedccd9c@a10g2000vby.googlegroups.com> <4d3fa153$0$29983$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4D3FD661.6050508@ixokai.io> On 1/25/11 8:21 PM, Steven D'Aprano wrote: > TL;DR. The shorter version: stop being a dick, and people will treat you > seriously. I actually read the original list, and agreed with every point. But this concise summary spells it out perfectly. Stop being a dick, rick. -- Stephen Hansen ... Also: Ixokai ... Mail: me+list/python (AT) ixokai (DOT) io ... Blog: http://meh.ixokai.io/ -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 487 bytes Desc: OpenPGP digital signature URL: From ahsanbagwan at gmail.com Wed Jan 26 03:08:41 2011 From: ahsanbagwan at gmail.com (sl33k_) Date: Wed, 26 Jan 2011 00:08:41 -0800 (PST) Subject: Syntax help Message-ID: <5029d50e-06e2-408f-b9ef-be7c649d8616@fu15g2000vbb.googlegroups.com> How to read syntax like this given in the documentation of python? (Newbie) defparameter ::= parameter ["=" expression] http://docs.python.org/reference/compound_stmts.html#function-definitions From arnodel at gmail.com Wed Jan 26 03:10:23 2011 From: arnodel at gmail.com (Arnaud Delobelle) Date: Wed, 26 Jan 2011 08:10:23 +0000 Subject: A and B but not C in list References: <8cae2caf-d3df-4ed3-9afb-29de97772298@m13g2000yqb.googlegroups.com> Message-ID: <87zkqo9jbk.fsf@gmail.com> Terry Reedy writes: > On 1/23/2011 4:05 PM, CM wrote: >> In Python, is there a recommended way to write conditionals of the >> form: >> >> "if A and B but not C or D in my list, do something." ? >> >> I may also have variations on this, like "if A but not B, C, or D". >> >> Do I have to just write out all the if and elifs with all possible >> conditions, or is there a handier and more code-maintainable way to >> deal with this? > > The straightforward code > > if a in L and b in L and c not in L and d not in L > > scans the list 4 times. One scan be be done generically as follows: > > def req_pro(iterable, required = set(), prohibited = set()): > for item in iterable: > if item in prohibited: > return False > elif item in required: > required.remove(item) > else: > return not required # should now be empty > > if req_pro(my_list, {A,B}, {C,D}): ... > # untested, of course.. But what's better? Four fast list scans or one slow one? -- Arnaud From tjreedy at udel.edu Wed Jan 26 03:11:55 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Wed, 26 Jan 2011 03:11:55 -0500 Subject: Need GUI pop-up to edit a (unicode ?) string In-Reply-To: <3f724ff2-d571-4f50-92e1-45eaf9ab163d@r16g2000prh.googlegroups.com> References: <3tqr08-bj2.ln1@murmur.very.softly> <7691fe98-37af-4ddf-a8a8-eadeef0d4a6e@y2g2000prf.googlegroups.com> <541c02df-b1fc-4376-bf17-e0531fe5c4bf@r29g2000yqj.googlegroups.com> <3f724ff2-d571-4f50-92e1-45eaf9ab163d@r16g2000prh.googlegroups.com> Message-ID: On 1/26/2011 2:11 AM, rantingrick wrote: > On Jan 26, 12:53 am, Terry Reedy wrote: > >> I only see "self.wait_window(self)" in the Dialog base class and not in >> SimpleDialog, which is what I though you were talking about. It is the >> last line of Dialog.__init__. > > Yes. In the module "tkSimpleDialog" In 3.x, the module is now tk.simpledialog -- all lower case. The purpose of all lowercase module names is to avoid confusion with upper case class names. > the class "Dialog" is what i am > referring to. Sorry for the confusion. and there is also a SimpleDialog class. > >> It appears that the intention is that all >> configuration be done in the body and button_box methods which are >> called earlier. > > Yes exactly. And this works well most of the time. However there are > many times where you may want to create a dialog with say a Label. And > you do not want to hard code the string displayed on the label. > However you cannot change the string once you initialize the dialog > because it enters a "modal wait loop". So what i am proposing is that > we change tkSimpleDialog to be like any other modal dialogs out there. SimpleDialog has a go method. Dialog does not, but I see no reason (yet) why it could not. > We move the modal code into a show method and use the dialog like i > suggested. I can send you a patch if you would be interested. I saw that first and was puzzled what you were asking. Clearer now. > My patch > does break backward compatibility. However we can make it compatible > somehow. Or an alternative approach would be to create a new dialog > module and then depreciate tkSimpleDialog. Let me know on or off list > if you are interested. > >> As far as I know, anything contributed to the stdlib has been licensed >> by the author to be redistributed under the Python license and can be >> patched by the developers. (This is one reason for people to not >> contribute their code to the stdlib.) > > I don't understand what that means. Are you suggesting that > contributing code is bad? If you write code and want to keep absolute control over it -- the api, the doc, the coding style, and the test methods -- then yes it can be bad, especially for people who are not active core developers. Contributing can also be a great -- if the module already meets with approval or if one is flexible and wants the critical review and likely improvement and increased usage. It depends on one's goal in writing the code. -- Terry Jan Reedy From geoff.bache at gmail.com Wed Jan 26 03:17:33 2011 From: geoff.bache at gmail.com (Geoff Bache) Date: Wed, 26 Jan 2011 09:17:33 +0100 Subject: Finding the right Python executable on Windows In-Reply-To: References: <38326da6-8b30-4f88-b232-acdcd33b7d61@o14g2000yqe.googlegroups.com> Message-ID: On Tue, Jan 25, 2011 at 3:24 PM, Brian Curtin wrote: > On Tue, Jan 25, 2011 at 04:25, Geoff Bache wrote: >> >> Hi all, >> >> I have a Python process on Windows and would like to start a Python >> subprocess using the same interpreter. I wonder how to go about this? >> >> First, I tried the obvious >> >> subprocess.Popen([ sys.executable, "subproc.py", ... ]) >> >> but that fails, because my process has a "native launcher", (i.e. C: >> \path\mylauncher.exe, which is just a wrapper around the Python >> program) and hence sys.executable returns this path instead of the >> interpreter location. It isn't appropriate to use the launcher for the >> subprocess. >> >> I also tried using sys.exec_prefix but there didn't seem to be any >> standard location for the interpreter under this directory in any >> case. >> >> I feel certain there must be some way to do this as it seems a rather >> basic thing somehow, can anyone give me a hint? >> >> Regards, >> Geoff Bache > > If?sys.executable doesn't work due to this "native launcher", you could > try?something like this: >>>> import os >>>> import sys >>>> full_path = None >>>> for path in sys.path: > ... ? ? full = os.path.join(path, "python.exe") > ... ? ? if os.path.exists(full): > ... ? ? ? ? ? ? full_path = full > ... >>>> full_path > 'c:\\python31\\python.exe' Thanks Brian! It never occurred to me that the Python executable would be on sys.path, but it seems to be on the installations I've tried on Windows. It isn't on other platforms of course, but it's easy enough to only do this on Windows. I wonder why it's like this? I can't see anything in that directory I could import... Regards, Geoff From nagle at animats.com Wed Jan 26 03:18:20 2011 From: nagle at animats.com (John Nagle) Date: Wed, 26 Jan 2011 00:18:20 -0800 Subject: trouble installing MySQLdb (cygwin) + Bonus question In-Reply-To: References: <501470fc-c588-47d2-954d-17d825c5191c@v17g2000prc.googlegroups.com> <4d3f41d9$0$44021$742ec2ed@news.sonic.net> Message-ID: <4d3fd8c2$0$44011$742ec2ed@news.sonic.net> On 1/25/2011 3:51 PM, Matthew Roth wrote: > On Jan 25, 6:20 pm, David Robinow wrote: >> On Tue, Jan 25, 2011 at 5:59 PM, Matthew Roth wrote: >>> On Jan 25, 9:34 pm, John Nagle wrote: >> ... >>>> You can install a MySQL server under Windows, and talk to the server >>>> from the Cygwin environment. That's a useful way to test. >> >>>> John Nagle >> >>> Right, that is precisely what I have. I am able to talk to it from >>> cygwin, however, during the installing of the MySQLdb module it cannot >>> find the mysql_config. This is because It is not installed? The setup >>> sees that I am on a posix system not windows, as python is installed >>> in cygwin, a virtual posix system. I am trying to bulid a mysql client >>> from source for cygwin, however, I am running into an error there. >> >>> Unless, can I talk to the windows mysql_config? if so, what does that >>> look like >> >> The obvious answer is to use a Windows python. You haven't explained >> why you think you need to run a cygwin python. Can you explain that? > > > Good question. There isn't a solid explanation. heretofore, I have > been using a lot of bash scripting in combination with awk sed and > some perl. I was directed to look into python. My tasks were becoming > increasingly complex and memory intensive. I started with a desire to > connect to a mysql server. For that I needed to install the MySQLdb > module. I am having difficultly in acomplishment of this task. I > suppose for the time it has taken, using windows python would have > been the simpler route. Oh. And all this time, I thought it was because you needed to run on a Linux server and were using Cygwin for debugging. I routinely develop Python on Windows and run on Linux servers. This works fine, provided that you can find versions of any necessary C modules for Python for both platforms. John Nagle From rustompmody at gmail.com Wed Jan 26 03:33:52 2011 From: rustompmody at gmail.com (rusi) Date: Wed, 26 Jan 2011 00:33:52 -0800 (PST) Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com><9MB%o.14110$%64.6074@unlimited.newshosting.com><59F6E65E3D9A46AD8D7A3863F3C1DC84@teddy> <27f53f8c-7862-4366-9352-82ae9a2f3970@k3g2000yqc.googlegroups.com> Message-ID: On Jan 26, 11:18?am, "Octavian Rasnita" wrote: > From: "rantingrick" > On Jan 25, 3:41 pm, Corey Richardson wrote: > > > Do you honestly think he was talking about the accessibility problem? > > IMO that should move to another thread, because this one is simply > > about, as the subject suggests, "WxPython versus Tkinter". > > Corey again (like many) you lack a global perspective. Anybody who has > read along with his thread knows we are covering some pretty big > issues here. WxPython is just the vehicle. The big picture is simply: > Tkinter is old and in many ways insufficient for 21st century GUIs. We > need to decide what should come next. I believe wxPython is our best > hope. Wx may not be the best it can be, but it is the best we have at > this time. There is more than "meets the eye" Corey! > -- > > I will tell you what I think and many of you won't like this. :-) > I think that nothing is "sufficient" and nothing should last forever. > > The people don't need Tkinter. They don't need WxPython. They don't need > Python. Do you think that Python is a language that will be used forever? > The people don't necessarily need to use a computer. Do you think that the > computers as they are today will be used until the end of the time? > > The people do need to have an easier life, to make as little efforts as > possible and to obtain as much benefit as possible and for the moment the > computers and Python and a GUI lib help them do this, so these things are > just some other means for obtaining what they need. > > What we don't agree is that some of the list members think that only the > selfishness is the right ATITUDE AND SAY THAT I should change mine because I > should care more about my own benefits and don't care at all about the > others. > > Octavian Hi Octavian, Normally I would expect talks of selfishness etc to be too OT for a python list. However since nobody is saying that (yet) let me point you to a passage from the upanishads: http://www.hindu-blog.com/2007/10/brihadaranyaka-upanishads-quotes-sage.html From steve+comp.lang.python at pearwood.info Wed Jan 26 03:40:40 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 26 Jan 2011 08:40:40 GMT Subject: Syntax help References: <5029d50e-06e2-408f-b9ef-be7c649d8616@fu15g2000vbb.googlegroups.com> Message-ID: <4d3fde08$0$29983$c3e8da3$5496439d@news.astraweb.com> On Wed, 26 Jan 2011 00:08:41 -0800, sl33k_ wrote: > How to read syntax like this given in the documentation of python? > (Newbie) > > defparameter ::= parameter ["=" expression] > > http://docs.python.org/reference/compound_stmts.html#function- definitions See here for an explanation: http://docs.python.org/reference/introduction.html#notation What you are looking at is not Python code, instead it is a formal description of what Python syntax looks like, based on a slightly modified BNF syntax: http://en.wikipedia.org/wiki/Backus?Naur_Form This tells you that a "defparameter" looks like a "parameter" followed optionally by an equals sign and an expression. For example, here is a line of Python code: def function(x, y=42**3): "x" is a defparameter made up of a parameter on it's own, while "y=42**3" is a defparameter made up of three parts: the parameter part "y", the equals sign, and the expression part "42**3". -- Steven From ch at thansen.de Wed Jan 26 03:51:47 2011 From: ch at thansen.de (ch at thansen.de) Date: Wed, 26 Jan 2011 09:51:47 +0100 Subject: Syntax help In-Reply-To: <5029d50e-06e2-408f-b9ef-be7c649d8616@fu15g2000vbb.googlegroups.com> References: <5029d50e-06e2-408f-b9ef-be7c649d8616@fu15g2000vbb.googlegroups.com> Message-ID: On 26.01.2011 09:08, sl33k_ wrote: > How to read syntax like this given in the documentation of python? > (Newbie) > > defparameter ::= parameter ["=" expression] http://en.wikipedia.org/wiki/Backus-Naur_Form From mailing at franzoni.eu Wed Jan 26 04:00:57 2011 From: mailing at franzoni.eu (Alan Franzoni) Date: Wed, 26 Jan 2011 10:00:57 +0100 Subject: Behaviour-based interface/protocol implementation? In-Reply-To: References: Message-ID: On Tue, Jan 25, 2011 at 6:48 PM, Terry Reedy wrote: > This is correct! > > print(len(mo)) > TypeError: object of type 'MyObj' has no len() That's interesting. I must admit I was not thinking about special methods in my original post, I used that example just because of Chris response. by the way, define 'correct' - if that means 'that's how this works in python', it's a tautology, not correctness :-) Instead I think this highlights an asymmetry in how python handles special methods, and makes it less ducktyped than I wanted. Consider this: class MyObject(object): @staticmethod def __len__(): return 1 mo = MyObject() print mo.__len__ print len(mo) class LenObj(object): def __len__(self): return 3 lo = LenObj() print lo.__len__ print len(lo) import types class OtherObj(object): pass oo = OtherObj() def __len__(self): return 2 oo.__len__ = types.MethodType(__len__, oo, OtherObj) print oo.__len__ print len(oo) Output: 1 > 3 > Traceback (most recent call last): File "pymethods.py", line 34, in print len(oo) TypeError: object of type 'OtherObj' has no len() The problem is not "function attributes" - the problem is that the __len__() method must be set on the class, not on the instance. I think this is not completely clear here: http://docs.python.org/reference/datamodel.html By the way, my original post didn't take into account special methods - let's suppose they don't exist for a moment. I'd just like to check *at runtime* whether an object *any object!* respects a certain signature. *I don't want to care about the class of that object because I want true duck typing*. I mean, I should be able to pass *anything* that responds to a certain contract: @DuckType class MyInterface(object): def someMethod(self): pass def otherMethod(self, a, b): pass class SomeObj(object): @classmethod def someMethod(cls): pass @classmethod def otherMethod(cls, a, b): pass class OtherObj(object): def someMethod(self): pass def otherMethod(cls, a, b): pass class ThirdObj(object): pass oo = OtherObj() to = ThirdObj() to.someMethod = lambda: None to.otherMethod = lambda a,b: None MyInterface.maybe_implemented_by(oo) # -> True MyInterface.maybe_implemented_by(to) # -> True MyInterface.maybe_implemented_by(SomeObj) # -> True That's just what I'd like and I suppose can't be currently done with current ABC, PyProtocols or zope.interface implementations, right? -- Alan Franzoni -- contact me at public@[mysurname].eu From johann.spies at gmail.com Wed Jan 26 04:07:33 2011 From: johann.spies at gmail.com (Johann Spies) Date: Wed, 26 Jan 2011 11:07:33 +0200 Subject: Convert XML to SQL Message-ID: I an not a Python newbie but working with xml is new to me. I get data through a soap connection, using suds, and want to convert that to objects which I can use to populate a rather complex database. I have been able to parse the xml using tree = etree.iterparse(infile,events=("start","end")) but it seems like a lot of work to get that to sql-objects. I have seen references to lxml.objectify and have created a object containing the contents of a whole file using tree = objectify.parse(fileobject) That object contains for example the data of 605 records and I do not know how to use it. I could not figure out from the lxml.objectify documentation how to do it. In the end I want to use data from about 54 fields of each records. I would like to have a list of dictionaries as a result of the parsing. From there it should not be too difficult to create sql. I have seen some references to BeautifulSoap but I am not sure which is the best way to go. So: Is there a better tool than lxml to do this? Is it possible to do it just using suds? The suds documentation did not really help me to do this with complex data. Are there good tutorials for the xml->sql process? Regards Johann -- May grace and peace be yours in abundance through the full knowledge of God and of Jesus our Lord! His divine power has given us everything we need for life and godliness through the full knowledge of the one who called us by his own glory and excellence. 2 Pet. 1:2b,3a -------------- next part -------------- An HTML attachment was scrubbed... URL: From orasnita at gmail.com Wed Jan 26 04:29:11 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Wed, 26 Jan 2011 11:29:11 +0200 Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com><9MB%o.14110$%64.6074@unlimited.newshosting.com><59F6E65E3D9A46AD8D7A3863F3C1DC84@teddy><27f53f8c-7862-4366-9352-82ae9a2f3970@k3g2000yqc.googlegroups.com> Message-ID: From: "rusi" On Jan 26, 11:18 am, "Octavian Rasnita" wrote: > From: "rantingrick" > On Jan 25, 3:41 pm, Corey Richardson wrote: > > > Do you honestly think he was talking about the accessibility problem? > > IMO that should move to another thread, because this one is simply > > about, as the subject suggests, "WxPython versus Tkinter". > > Corey again (like many) you lack a global perspective. Anybody who has > read along with his thread knows we are covering some pretty big > issues here. WxPython is just the vehicle. The big picture is simply: > Tkinter is old and in many ways insufficient for 21st century GUIs. We > need to decide what should come next. I believe wxPython is our best > hope. Wx may not be the best it can be, but it is the best we have at > this time. There is more than "meets the eye" Corey! > -- > > I will tell you what I think and many of you won't like this. :-) > I think that nothing is "sufficient" and nothing should last forever. > > The people don't need Tkinter. They don't need WxPython. They don't need > Python. Do you think that Python is a language that will be used forever? > The people don't necessarily need to use a computer. Do you think that the > computers as they are today will be used until the end of the time? > > The people do need to have an easier life, to make as little efforts as > possible and to obtain as much benefit as possible and for the moment the > computers and Python and a GUI lib help them do this, so these things are > just some other means for obtaining what they need. > > What we don't agree is that some of the list members think that only the > selfishness is the right ATITUDE AND SAY THAT I should change mine because > I > should care more about my own benefits and don't care at all about the > others. > > Octavian Hi Octavian, Normally I would expect talks of selfishness etc to be too OT for a python list. However since nobody is saying that (yet) let me point you to a passage from the upanishads: http://www.hindu-blog.com/2007/10/brihadaranyaka-upanishads-quotes-sage.html -- Nice passage, but I think that you have also noticed that the most important things it talks about are the closed people, the gods, the brahmana and kshatriya, but well, in India there other chasts than brahmana and kshatriya but only these 2 chasts of priests - the spiritual power and the military - the force power are considered important. The indian culture is great for many things, but it is not great when talking about discrimination, because even now that their laws forbid the chasts-based discrimination, many people there still believe that somebody from brahman or kshatriya chasts have a bigger value than the others. I don't say that those people are not right, nor that those who have the power are not more valuable than the others right now, but I say that it is not normal to consider this way of thinking a right way, because on the long term this should change and there should be no privileged group. Octavian From stefan_ml at behnel.de Wed Jan 26 04:29:35 2011 From: stefan_ml at behnel.de (Stefan Behnel) Date: Wed, 26 Jan 2011 10:29:35 +0100 Subject: Convert XML to SQL In-Reply-To: References: Message-ID: Johann Spies, 26.01.2011 10:07: > I an not a Python newbie but working with xml is new to me. > > I get data through a soap connection, using suds, and want to convert that > to objects which I can use to populate a rather complex database. Your problem description is pretty comprehensive in general. It would be helpful to see an example snippet of the XML that you parse. > I have been able to parse the xml using > > tree = etree.iterparse(infile,events=("start","end")) but it seems like a > lot of work to get that to sql-objects. > > I have seen references to lxml.objectify and have created a object > containing the contents of a whole file using > > tree = objectify.parse(fileobject) > > That object contains for example the data of 605 records and I do not know > how to use it. I could not figure out from the lxml.objectify documentation > how to do it. > > In the end I want to use data from about 54 fields of each records. I would > like to have a list of dictionaries as a result of the parsing. From there > it should not be too difficult to create sql. I think iterparse() is a good way to deal with this, as is objectify. iterparse() has the advantage that you can dispose of handled records, thus keeping memory usage low (if that's an issue here). Using objectify, you would usually do something like this: tree = objectify.parse(fileobject) root = tree.getroot() for record in root.xml_record_tag: title_name = record.title.text It really just depends on what your XML looks like. In the above, I assumed that each record hangs directly below the root tag and is called "xml_record_tag". I also assumed that each record has a "title" tag with text content. With iterparse(), you would intercept on your record elements and then use the ElementTree API, commonly the findtext() and findall() methods of the root object, to get at the specific record fields. Like this: for _, element in ET.iterparse(fileobject): if element.tag == 'xml_record_tag': title_name = element.findtext('title') Does this help? Stefan From __peter__ at web.de Wed Jan 26 04:43:06 2011 From: __peter__ at web.de (Peter Otten) Date: Wed, 26 Jan 2011 10:43:06 +0100 Subject: List behaviours with Clustering Algorithm References: <4D3DEBEB.1020700@funkymonkeysoftware.com> Message-ID: James Ravenscroft wrote: >> > I can't run your code because you didn't make it standalone, > Thanks for the heads up, I've made a simple version of the clusterer > which you can view on pastebin: http://pastebin.com/7HmAkmfj If you have > time to look through my code I would be very grateful! > > > >> > but in your case that is probably not enough. >> > Try something along these lines: >> > >> > # untested >> > while len(self.clusters) > 1: >> > c = self.clusters.pop() >> > # find closest index >> > for i, c2 in enumerate(self.clusters): >> > ... >> > if ...: >> > closest_index = i >> > closest = self.clusters.pop(closest_index) >> > tmp.append(c + closest) >> > if self.clusters: >> > tmp.append(self.clusters[0]) > I had a go at implementing something along the lines above and I'm still > getting very bizarre results. There does appear to be some sort of logic > to it though, if you look at the graph chart, you can see that It seems > to be doing the clustering right and then forgetting to remove the old > groupings providing this "cloning" effect for some cluster groups. I'm sorry I can't infer the intended algorithm from the code you provide. Perhaps you can give a short description in plain English? However, here's the implementation of the algorithm you mention as described on wikipedia: http://en.wikipedia.org/wiki/Cluster_analysis#Agglomerative_hierarchical_clustering Repeatedly merge the two closest clusters until there's only one left. To keep track of the two merged clusters I've added a "children" key to your node dictionaries. The intermediate states of the tree are also put into the levels variable (I suppose that's the purpose of your levels attribute). The main difference to your code is that (1) list modifications occur only in the outer while loop, so both inner loops can become for-loops again. (2) test all pairs before choosing the pair debug = True def cluster(self): '''Run the clustering operation on the files ''' clusters = [] #add a cluster for each track to clusters for song in self.music: clusters.append({'data' : [song]}) levels = [] while len(clusters) > 1: # calculate weights for c in clusters: c["weight"] = self.__getClusterWeight(c['data']) # find closest pair closestDelta = float('inf') closestPair = None for i, a in enumerate(clusters): for k, b in enumerate(clusters): if i == k: break delta = abs(a['weight'] - b['weight']) if delta < closestDelta: closestPair = i, k closestDelta = delta # merge closest pair hi, lo = closestPair left = clusters[lo] right = clusters.pop(hi) clusters[lo] = {"data": left["data"] + right["data"], "children": [left, right]} # keep track of the intermediate tree states levels.append(list(clusters)) if self.debug: print ("stage %d" % len(levels)).center(40, "-") for c in clusters: print c["data"] # store tree self.clusters = clusters self.levels = levels Note that there's some potential for optimisation. For example, you could move the weight calculation out of the while-loop and just calculate the weight for the newly merged node. Peter From jeanmichel at sequans.com Wed Jan 26 05:05:51 2011 From: jeanmichel at sequans.com (Jean-Michel Pichavant) Date: Wed, 26 Jan 2011 11:05:51 +0100 Subject: Syntax help In-Reply-To: <5029d50e-06e2-408f-b9ef-be7c649d8616@fu15g2000vbb.googlegroups.com> References: <5029d50e-06e2-408f-b9ef-be7c649d8616@fu15g2000vbb.googlegroups.com> Message-ID: <4D3FF1FF.1000808@sequans.com> sl33k_ wrote: > How to read syntax like this given in the documentation of python? > (Newbie) > > defparameter ::= parameter ["=" expression] > > http://docs.python.org/reference/compound_stmts.html#function-definitions > Just in case you're about to learn python using these defintions: Nobody's learning a syntax that way. They are not meant to be understood by newcommers. They are accurate, non amiguous, exhaustive definition of the syntax. Some people familiar with working on grammars may effectively use it, but the majority of the people will prefer a fine explanation with examples (provided right after the grammar defintions). Unless you really need to work on some python parsing stuff, you can just ignore them. JM From stefan_ml at behnel.de Wed Jan 26 05:51:06 2011 From: stefan_ml at behnel.de (Stefan Behnel) Date: Wed, 26 Jan 2011 11:51:06 +0100 Subject: Convert XML to SQL In-Reply-To: References: Message-ID: Stefan Behnel, 26.01.2011 10:29: > Johann Spies, 26.01.2011 10:07: >> I an not a Python newbie but working with xml is new to me. >> >> I get data through a soap connection, using suds, and want to convert that >> to objects which I can use to populate a rather complex database. > > Your problem description is pretty comprehensive in general. It would be > helpful to see an example snippet of the XML that you parse. [example received in private e-mail] >> I have been able to parse the xml using >> >> tree = etree.iterparse(infile,events=("start","end")) but it seems like a >> lot of work to get that to sql-objects. >> >> I have seen references to lxml.objectify and have created a object >> containing the contents of a whole file using >> >> tree = objectify.parse(fileobject) >> >> That object contains for example the data of 605 records and I do not know >> how to use it. I could not figure out from the lxml.objectify documentation >> how to do it. >> >> In the end I want to use data from about 54 fields of each records. I would >> like to have a list of dictionaries as a result of the parsing. From there >> it should not be too difficult to create sql. > > I think iterparse() is a good way to deal with this, as is objectify. > iterparse() has the advantage that you can dispose of handled records, thus > keeping memory usage low (if that's an issue here). > > Using objectify, you would usually do something like this: > > tree = objectify.parse(fileobject) > root = tree.getroot() > for record in root.xml_record_tag: > title_name = record.title.text > > It really just depends on what your XML looks like. In the above, I assumed > that each record hangs directly below the root tag and is called > "xml_record_tag". I also assumed that each record has a "title" tag with > text content. The example you sent me is almost perfect for lxml.objectify. Basically, you'd do something like this: for record in root.REC: refs = [ ref.text for ref in record.item.refs.ref ] publisher = record.item.copyright.publisher.text for issue in record.issue: units = [ unit.text for unit in issue.units.unit ] and so on. The same in ET: for record in root.findall('REC'): refs = [ ref.text for ref in record.findall('item/refs/ref') ] publisher = record.findtext('item/copyright/publisher') for issue in record.findall('issue'): units = [ unit.text for unit in issue.findall('units/unit') ] Not much harder either. Stefan From xheruacles at gmail.com Wed Jan 26 05:59:26 2011 From: xheruacles at gmail.com (Xavier Heruacles) Date: Wed, 26 Jan 2011 18:59:26 +0800 Subject: how to read the last line of a huge file??? Message-ID: I have do some log processing which is usually huge. The length of each line is variable. How can I get the last line?? Don't tell me to use readlines or something like linecache... -------------- next part -------------- An HTML attachment was scrubbed... URL: From davea at ieee.org Wed Jan 26 06:59:52 2011 From: davea at ieee.org (Dave Angel) Date: Wed, 26 Jan 2011 06:59:52 -0500 Subject: python interpreter In-Reply-To: References: Message-ID: <4D400CB8.90300@ieee.org> On 01/-10/-28163 02:59 PM, nair rajiv wrote: > Hi, > > I was exploring python. I wanted to know more about the python > interpreter i.e the technical details of how it has been written. If I am > directed > to the code that also will be fine. The implementation of python data > structures lists, tuples and dictionaries. > If there exists any online documentation on the implementation aspects > of python, please direct me to it. > > > Rajiv Nair > For sources: Go to www.Python.org, and click on the link on the left side called "Source Distribution" If yo do that in the 2.7.1 section you'll get a file called python-2.7.1.tar.bz2 Or you could click a little lower, and get the sources to 3.1.3 DaveA From johann.spies at gmail.com Wed Jan 26 07:22:14 2011 From: johann.spies at gmail.com (Johann Spies) Date: Wed, 26 Jan 2011 14:22:14 +0200 Subject: Convert XML to SQL In-Reply-To: References: Message-ID: On 26 January 2011 12:51, Stefan Behnel wrote: > > The example you sent me is almost perfect for lxml.objectify. Basically, > you'd do something like this: > > Thank you very much. You have helped me a lot. Regards Johann -- May grace and peace be yours in abundance through the full knowledge of God and of Jesus our Lord! His divine power has given us everything we need for life and godliness through the full knowledge of the one who called us by his own glory and excellence. 2 Pet. 1:2b,3a -------------- next part -------------- An HTML attachment was scrubbed... URL: From stefan_ml at behnel.de Wed Jan 26 07:37:21 2011 From: stefan_ml at behnel.de (Stefan Behnel) Date: Wed, 26 Jan 2011 13:37:21 +0100 Subject: Convert XML to SQL In-Reply-To: References: Message-ID: Johann Spies, 26.01.2011 13:22: > On 26 January 2011 12:51, Stefan Behnel wrote: >> The example you sent me is almost perfect for lxml.objectify. Basically, >> you'd do something like this: >> > Thank you very much. You have helped me a lot. You're welcome. If you have any suggestions how to improve the documentation of lxml.objectify, you can take the opportunity to give something back. Stefan From python.list at tim.thechases.com Wed Jan 26 07:39:50 2011 From: python.list at tim.thechases.com (Tim Chase) Date: Wed, 26 Jan 2011 06:39:50 -0600 Subject: Syntax help In-Reply-To: <4D3FF1FF.1000808@sequans.com> References: <5029d50e-06e2-408f-b9ef-be7c649d8616@fu15g2000vbb.googlegroups.com> <4D3FF1FF.1000808@sequans.com> Message-ID: <4D401616.5090209@tim.thechases.com> On 01/26/2011 04:05 AM, Jean-Michel Pichavant wrote: >> How to read syntax like this given in the documentation of python? >> (Newbie) >> >> defparameter ::= parameter ["=" expression] > > Just in case you're about to learn python using these defintions: > > Nobody's learning a syntax that way. > They are not meant to be understood by newcommers. They are accurate, > non amiguous, exhaustive definition of the syntax. I second Jen-Michel's suggestion -- it's like learning to drive by reading the Chilton's (mechanic's manual) and all your local/national laws on transportation. I suppose it's theoretically possible, but you likely want something geared at teaching, and only reach for this when you're in trouble :) -tkc From tyler at tysdomain.com Wed Jan 26 09:20:56 2011 From: tyler at tysdomain.com (Littlefield, Tyler) Date: Wed, 26 Jan 2011 07:20:56 -0700 Subject: WxPython versus Tkinter. Message-ID: <4D402DC8.6080806@tysdomain.com> >Exactly what I said. They are doing the same mistake as I did 20 years ago. and are still making now... Lack of English and grammar isn't the problem... From tyler at tysdomain.com Wed Jan 26 09:23:20 2011 From: tyler at tysdomain.com (Littlefield, Tyler) Date: Wed, 26 Jan 2011 07:23:20 -0700 Subject: WxPython versus Tkinter. Message-ID: <4D402E58.9090001@tysdomain.com> >I don't know why you didn't say this before. Comprehention, Octavian. I've made that point multiple times, but your to stuck on talking about how selfish people are. >The other part of the discussion is related to the accessibility and care for >accessibility and that discussion is not nice at all, because it shows how >selfish are most of the people and they consider this a virtue. Selfish? We've had multiple people get interested, and I've had a couple of messages off-list about the accessibility, (probably so they wouldn't have to deal with you). We've even had one person ask for a list of screen readers, (and I note you only gave him the one -you- use for the OS -you- use). There's no selfishness, just your not knowing when to jump off the soapbox and stop parroting something just for the sake of complaining about it. It's been admitted that TKInter is not accessible, and discussion has even been made about fixing it. Yes, it will take a while, but nothing comes in over night. And getting WXPython to the point where it is usable in python 3, as has also been mentioned before by many people is going to take a lot of work, as well. On 1/25/2011 11:25 PM, Octavian Rasnita wrote: block quote From: "Emile van Sebille" block quote On 1/25/2011 3:33 PM rantingrick said... block quote Tkinter is old and in many ways insufficient for 21st century GUIs. We need to decide what should come next. I believe wxPython is our best hope. Wx may not be the best it can be, but it is the best we have at this time. block quote end Then you should immediately volunteer to bring wxPython to python3 compatibility -- as it is, it's not even close... Start thinking about upping your game from ranting to doing. Emile block quote end Hi Emile, block quote From my point of view this discussion is finished for the moment, because block quote end you are right, WxPython is not as fast developed as it needs, because Python 3 is not compatible with Python 2. If no solution is found for this big problem, then yes, WxPython can't be included in the Python distribution because there is nothing that can be included. I don't know why you didn't say this before. The other part of the discussion is related to the accessibility and care for accessibility and that discussion is not nice at all, because it shows how selfish are most of the people and they consider this a virtue. Octavian block quote end -- Thanks, Ty From orasnita at gmail.com Wed Jan 26 10:26:18 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Wed, 26 Jan 2011 17:26:18 +0200 Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com><9MB%o.14110$%64.6074@unlimited.newshosting.com> <59F6E65E3D9A46AD8D7A3863F3C1DC84@teddy> <27f53f8c-7862-4366-9352-82ae9a2f3970@k3g2000yqc.googlegroups.com> <718D13777F254C839F9564BC4275DE0A@octavian> <4D402C42.1030407@tysdomain.com> Message-ID: From: "Littlefield, Tyler" > >I don't know why you didn't say this before. > Comprehention, Octavian. I've made that point multiple times, but your > to stuck on talking about how selfish people are. You didn't say that WxPython can't be used with Python 3. Have you said that? > >The other part of the discussion is related to the accessibility and > care for >accessibility and that discussion is not nice at all, because > it shows how > >selfish are most of the people and they consider this a virtue. > Selfish? We've had multiple people get interested, I am not interested if the people are getting interested. I am interested to have a solution right now, and at least for Python 2, a solution is already available. > and I've had a couple > of messages off-list about the accessibility, (probably so they wouldn't > have to deal with you). We've even had one person ask for a list of > screen readers, (and I note you only gave him the one you use for the OS For the majority of blind users it is less relevant if a GUI is accessible under Linux or Mac. I gave that example because a GUI should be first accessible with JAWS because it is the most used screen reader. Octavian From orasnita at gmail.com Wed Jan 26 10:47:49 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Wed, 26 Jan 2011 17:47:49 +0200 Subject: WxPython versus Tkinter. References: <4D402E58.9090001@tysdomain.com> Message-ID: From: "Littlefield, Tyler" > >I don't know why you didn't say this before. > Comprehention, Octavian. I've made that point multiple times, but your > to stuck on talking about how selfish people are. You didn't say that WxPython doesn't work on Python 3, so I don't know what you are talking about. > >The other part of the discussion is related to the accessibility and > care for >accessibility and that discussion is not nice at all, because > it shows > how > >selfish are most of the people and they consider this a virtue. > Selfish? We've had multiple people get interested, and I've had a couple > of messages off-list about the accessibility, (probably so they wouldn't > have > to deal with you). We've even had one person ask for a list of screen > readers, (and I note you only gave him the one -you- use for the OS > -you- use). There's > no selfishness, just your not knowing when to jump off the soapbox and I couldn't find the word soapbox in the dictionary so I don't know what it means. I guess that not the soap + box. Please be more clear and not talk like the high school kids. > stop parroting something just for the sake of complaining about it. It's > been admitted that TKInter is not accessible, And I was saying the same thing. What's the problem? Because I keep telling it? > and discussion has even > been made about fixing it. Yes, it will take a while, but nothing comes > in over night. And getting WXPython to the point where it is usable in > python 3, as has also been mentioned before by many people is going to > take a lot of work, as well. Do you think that this really matters? Do you think that if Python 3 will have support for WxPython much earlier than Tkinter will be accessible, and if WxPython will be fixed to not give segfaults, WxPython will be included in the Python distribution? I guess that it won't, so it is less important that WxPython has bugs or that it is not available for Python 3. But we'll see. I can assure you that if after 5 years WxPython will be available for Python 3 but Tk will still be inaccessible for the most used screen reader, Tkinter will still be the default GUI lib. (And 5 years doesn't mean overnight) Octavian From mail2bansi at gmail.com Wed Jan 26 10:51:19 2011 From: mail2bansi at gmail.com (bansi) Date: Wed, 26 Jan 2011 07:51:19 -0800 (PST) Subject: Is it possible to pass CSV Reader Object As Argument to another Python File ??? Message-ID: <2c35653e-3565-48c6-8939-b6b09b885e3f@d23g2000prj.googlegroups.com> I have following two python scripts -namelookupWrapper.py -namelookup.py The namelookupWrapper.py takes input of "memberId", "memberName" from CLI and has following code snippet idf = sys.argv[1] namef = sys.argv[2] real_script = "C:\\Splunk\\etc\\apps\\search\\bin\\namelookup.py" r = csv.reader(sys.stdin) os.execv(python_executable, [ python_executable, real_script ] + sys.argv[1:] ) Wondering how would i pass csv reader object "r" as an argument using os.execv() to another python script i.e. namelookup.py From emile at fenx.com Wed Jan 26 10:54:02 2011 From: emile at fenx.com (Emile van Sebille) Date: Wed, 26 Jan 2011 07:54:02 -0800 Subject: WxPython versus Tkinter. In-Reply-To: <1b955dcf-77e2-4130-9b5b-276cfedccd9c@a10g2000vby.googlegroups.com> References: <4D3E4377.3060807@tysdomain.com> <9MB%o.14110$%64.6074@unlimited.newshosting.com> <5a5e15f3-ae0f-4561-8969-e9afde3829dc@g26g2000vba.googlegroups.com> <1b955dcf-77e2-4130-9b5b-276cfedccd9c@a10g2000vby.googlegroups.com> Message-ID: On 1/25/2011 5:07 PM rantingrick said... > On Jan 25, 6:55 pm, Emile van Sebille wrote: > >> Oh, that everyone should blindly accept you as is and without regard for >> established protocols > > What protocols? Where is this standard posted? Can you give me a link? > I would like to know what is expected of me. Do your homework. Roughly as follows: Write a PEP. See http://www.python.org/dev/peps/pep-0001/ Petition to reopen the GUI SIG list (probably not a major hurdle) and beat out the details there. Submit the PEP and defend it. Submit a prototype implementation. Substantiate that the project will be long term supportable. And finally, get it accepted. Emile From tyler at tysdomain.com Wed Jan 26 10:57:48 2011 From: tyler at tysdomain.com (Littlefield, Tyler) Date: Wed, 26 Jan 2011 08:57:48 -0700 Subject: WxPython versus Tkinter. In-Reply-To: References: <4D3E4377.3060807@tysdomain.com><9MB%o.14110$%64.6074@unlimited.newshosting.com> <59F6E65E3D9A46AD8D7A3863F3C1DC84@teddy> <27f53f8c-7862-4366-9352-82ae9a2f3970@k3g2000yqc.googlegroups.com> <718D13777F254C839F9564BC4275DE0A@octavian> <4D402C42.1030407@tysdomain.com> Message-ID: <4D40447C.4010108@tysdomain.com> >with JAWS because it is the most used screen reader. Get off your me soapbox. Jaws is not the most used. NVDA is taking over, quite fast, and lots of people have totally switched to mac or Vinux because of the problems with Jaws. It's most used in corporate sektors still maybe, but lots of end-users are migrating to Window Eyes, NVDA or OSX because of the fact that it is both cheaper and NVDA is open source, not to mention free. Just because Jaws -was- most used and -you- use it, doesn't mean it still remains so. On 1/26/2011 8:26 AM, Octavian Rasnita wrote: > From: "Littlefield, Tyler" >>> I don't know why you didn't say this before. >> Comprehention, Octavian. I've made that point multiple times, but your >> to stuck on talking about how selfish people are. > You didn't say that WxPython can't be used with Python 3. Have you said that? > >>> The other part of the discussion is related to the accessibility and >> care for>accessibility and that discussion is not nice at all, because >> it shows how >>> selfish are most of the people and they consider this a virtue. >> Selfish? We've had multiple people get interested, > I am not interested if the people are getting interested. I am interested to have a solution right now, and at least for Python 2, a solution is already available. > >> and I've had a couple >> of messages off-list about the accessibility, (probably so they wouldn't >> have to deal with you). We've even had one person ask for a list of >> screen readers, (and I note you only gave him the one you use for the OS > For the majority of blind users it is less relevant if a GUI is accessible under Linux or Mac. I gave that example because a GUI should be first accessible with JAWS because it is the most used screen reader. > > Octavian > -- Thanks, Ty From emile at fenx.com Wed Jan 26 11:00:01 2011 From: emile at fenx.com (Emile van Sebille) Date: Wed, 26 Jan 2011 08:00:01 -0800 Subject: WxPython versus Tkinter. In-Reply-To: <5782E9AD8A8342D691EB3549E5E0ED7B@octavian> References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <8q7sgiF5tpU1@mid.individual.net> <19891784-d6a3-41ac-a097-5902a6323bc0@o21g2000prn.googlegroups.com><0b12cdb1-45b4-41e4-9bdb-074ee669d76b@k14g2000pre.googlegroups.com> <048FB74272D440A0915ABC7D76AE262B@teddy> <5782E9AD8A8342D691EB3549E5E0ED7B@octavian> Message-ID: On 1/25/2011 10:08 PM Octavian Rasnita said... > From: "Emile van Sebille" >>> Why is WxPython ineligible? >> >> I think Terry's point was compatibility with python3 -- which wx >> apparently isn't yet. >> >> Emile > > > Well, I didn't know this, and it is a valid reason. > This means that it is true that there is no enough maintainance force to > keep WxPython updated. > Did I understand correctly? Not at all -- wxPython is an active funded ongoing project. Review the roadmap at http://wiki.wxpython.org/TentativeRoadmap and particularly the final paragraph on Python3.x support. Emile From bryan.oakley at gmail.com Wed Jan 26 11:00:25 2011 From: bryan.oakley at gmail.com (Bryan) Date: Wed, 26 Jan 2011 08:00:25 -0800 (PST) Subject: WxPython versus Tkinter. References: <4D402E58.9090001@tysdomain.com> Message-ID: <79f15901-3a0b-4749-8cd9-d2560406bee7@l15g2000prg.googlegroups.com> On Jan 26, 9:47?am, "Octavian Rasnita" wrote: > I couldn't find the word soapbox in the dictionary so I don't know what it means. I guess that not the soap + box. > Please be more clear and not talk like the high school kids. http://en.wikipedia.org/wiki/Soapbox From rantingrick at gmail.com Wed Jan 26 11:00:30 2011 From: rantingrick at gmail.com (rantingrick) Date: Wed, 26 Jan 2011 08:00:30 -0800 (PST) Subject: Bugs/issues in tkinter.simpledialog!! Message-ID: I just installed Python 3,0 on my machine. I cannot use 3.0 exclusively yet however i was interested in just poking around and acquiring a taste if you will. I was happy to find that the new Tkinter module names now follow convention and are placed correctly... example: "tkinter.simpledialog" However some things never change it seems and some improvements are actually a step backwards. The same problems with the unit test in 2.x got ported to 3.x. And the new SimpleDialog is just more lackluster code like we've seen before. I was hoping to be amazed, i am disappointed and disgusted. It is obvious that whoever is writing/ maintaining the tkinter code base does NOT understand tkinter completely and this is blinding apparent by reading the source code! ----------- Issues ----------- First lets start with the problems that migrated from 2.x... (tkinter.simpledialog) #-- ISSUE 1 --# In the test() function we still have code that uses the "quit" method instead of "destroy". Calling the "quit" method only tells Tkinter to stop processing events, IT DOES NOT DESTROY THE WIDGET!! And on windows the the root will then become unresponsive -- you cannot close the window, you cannot do anything. I have said time and time again. DO NOT USE THE QUIT METHOD UNLESS YOU KNOW WHAT THE HECK YOU ARE DOING! So the code needs to be this... OLD: q = Button(root, text='Quit', command=t.quit) NEW: q = Button(root, text='Quit', command=root.destroy) #-- ISSUE 2: --# The author used a very strange method by which to denote the default button in the SimpleDialog class. He choose to set the relief to RIDGE and the border "8". This not only looks horrible (and exposes the authors ignorance of tkinter) but a much more elegant solution is provided by the TclTk folks. All buttons have a "default" option that will display the button with a nice border so the user can visually see which button is active. So the code should be this.... OLD: if num == default: b.config(relief=RIDGE, borderwidth=8) NEW: if num == default: b.config(default=ACTIVE) Last but not least i am puzzled as to why we choose the method name "go" over "show". for "showing" the dialog. SimpleDialog uses no inheritance so name clashes are mum. Why would anyone choose "go" over "show" for a modal dialog? I would really like an explanation for this. Other minor issues exists. I may describe them later. At this time we need to fix these grave abominations first. From sohel807 at gmail.com Wed Jan 26 11:07:39 2011 From: sohel807 at gmail.com (Akand Islam) Date: Wed, 26 Jan 2011 08:07:39 -0800 (PST) Subject: adding "Print" menu in wxPython References: <05c1f4b3-941c-45b1-9370-a88653d1083a@e16g2000pri.googlegroups.com> <66d035ae-cb4f-4ad3-836d-f8394ad90475@q8g2000prm.googlegroups.com> <7775b108-b04b-44a9-abae-1e58842b3186@b25g2000vbz.googlegroups.com> Message-ID: <3517483e-3222-4d29-9198-1f1d4fc396f1@w17g2000yqh.googlegroups.com> On Jan 26, 12:54?am, rantingrick wrote: > On Jan 26, 12:19?am, rantingrick wrote: > > Actually i found more cruft. Here is something that would be > acceptable although i had to wrap lines shorter than i normally would > for the sake of Usenet. Who ever wrote that code should be lashed 50 > times! You still need some error handling for the open and save file > methods but crikey i can't do everything ;-) > > #--STARTCODE--# > import wx > import os.path, sys > > class MainWindow(wx.Frame): > ? ? def __init__(self, filename='noname.txt'): > ? ? ? ? wx.Frame.__init__(self, None, size=(400,200)) > ? ? ? ? self.filename = filename > ? ? ? ? self.dirname = '.' > ? ? ? ? self.control = wx.TextCtrl(self, style=wx.TE_MULTILINE) > ? ? ? ? self.CreateMenu() > ? ? ? ? self.CreateStatusBar() > ? ? ? ? self.SetTitle('Editor %s'%self.filename) > ? ? ? ? self.dlgdefaults = { > ? ? ? ? ? ? 'message':'Choose a file', > ? ? ? ? ? ? 'defaultDir':self.dirname, > ? ? ? ? ? ? 'wildcard':'*.*' > ? ? ? ? ? ? } > > ? ? def CreateMenu(self): > ? ? ? ? fileMenu = wx.Menu() > ? ? ? ? item = fileMenu.Append(wx.ID_ABOUT, '&About', 'Info') > ? ? ? ? self.Bind(wx.EVT_MENU, self.OnAbout, item) > ? ? ? ? item = fileMenu.Append( wx.ID_OPEN, '&Open', 'Info') > ? ? ? ? self.Bind(wx.EVT_MENU, self.OnOpen, item) > ? ? ? ? item = fileMenu.Append(wx.ID_SAVE, '&Save', 'Info') > ? ? ? ? self.Bind(wx.EVT_MENU, self.OnSave, item) > ? ? ? ? item = fileMenu.Append(wx.ID_SAVEAS, 'Save &As', 'Info') > ? ? ? ? self.Bind(wx.EVT_MENU, self.OnSaveAs, item) > ? ? ? ? # > ? ? ? ? # psst: Hey put the print menu here!!!! > ? ? ? ? # psst: do the binding here!!!! > ? ? ? ? # > ? ? ? ? fileMenu.AppendSeparator() > ? ? ? ? item = fileMenu.Append(wx.ID_EXIT, 'E&xit', 'Exit') > ? ? ? ? self.Bind(wx.EVT_MENU, self.OnExit, item) > ? ? ? ? menuBar = wx.MenuBar() > ? ? ? ? # Add the fileMenu to the MenuBar > ? ? ? ? menuBar.Append(fileMenu, '&File') > ? ? ? ? # Add the menuBar to the Frame > ? ? ? ? self.SetMenuBar(menuBar) > > ? ? def askUserForFilename(self, **kw): > ? ? ? ? dialog = wx.FileDialog(self, **kw) > ? ? ? ? if dialog.ShowModal() == wx.ID_OK: > ? ? ? ? ? ? userProvidedFilename = True > ? ? ? ? ? ? self.filename = dialog.GetFilename() > ? ? ? ? ? ? self.dirname = dialog.GetDirectory() > ? ? ? ? ? ? self.SetTitle('Editor %s'%(self.filename)) > ? ? ? ? else: > ? ? ? ? ? ? userProvidedFilename = False > ? ? ? ? dialog.Destroy() > ? ? ? ? return userProvidedFilename > > ? ? def OnAbout(self, event): > ? ? ? ? dialog = wx.MessageDialog( > ? ? ? ? ? ? self, > ? ? ? ? ? ? 'A sample editor in wxPython', > ? ? ? ? ? ? 'About Sample Editor', > ? ? ? ? ? ? wx.OK > ? ? ? ? ? ? ) > ? ? ? ? dialog.ShowModal() > ? ? ? ? dialog.Destroy() > > ? ? def OnExit(self, event): > ? ? ? ? self.Close() > > ? ? def OnSave(self, event): > ? ? ? ? textfile = open(os.path.join(self.dirname, self.filename), > 'w') > ? ? ? ? textfile.write(self.control.GetValue()) > ? ? ? ? textfile.close() > > ? ? def OnOpen(self, event): > ? ? ? ? if self.askUserForFilename( > ? ? ? ? ? ? style=wx.OPEN, > ? ? ? ? ? ? **self.dlgdefaults > ? ? ? ? ? ? ): > ? ? ? ? ? ? textfile = open(os.path.join(self.dirname, self.filename), > 'r') > ? ? ? ? ? ? self.control.SetValue(textfile.read()) > ? ? ? ? ? ? textfile.close() > > ? ? def OnSaveAs(self, event): > ? ? ? ? if self.askUserForFilename( > ? ? ? ? ? ? defaultFile=self.filename, > ? ? ? ? ? ? style=wx.SAVE, > ? ? ? ? ? ? **self.dlgdefaults > ? ? ? ? ? ? ): > ? ? ? ? ? ? self.OnSave(event) > > ? ? def OnPrint(self, event): > ? ? ? ? sys.stdout.write(self.control.GetValue()) > > app = wx.App() > frame = MainWindow() > frame.Show() > app.MainLoop() > > #--ENDCODE--# I really appreciate your cooperation. The codes you have written print in command window, but I want to print (i.e. a popup window will appear to select printer in order to print). Please assist me regarding this. I am optimist that I can take care menu creating, binding, error handling by myself. Therefore you can only show me the "OnPrint" function to fulfill my purpose. -- Akand From tgrav at mac.com Wed Jan 26 11:11:55 2011 From: tgrav at mac.com (Tommy Grav) Date: Wed, 26 Jan 2011 11:11:55 -0500 Subject: WxPython versus Tkinter. In-Reply-To: References: <4D3E4377.3060807@tysdomain.com> <9MB%o.14110$%64.6074@unlimited.newshosting.com> <59F6E65E3D9A46AD8D7A3863F3C1DC84@teddy> <27f53f8c-7862-4366-9352-82ae9a2f3970@k3g2000yqc.googlegroups.com> <718D13777F254C839F9564BC4275DE0A@octavian> <4D402C42.1030407@tysdomain.com> Message-ID: <39327F93-9814-42D0-9EA2-92F6A5E783D7@mac.com> On Jan 26, 2011, at 10:26 AM, Octavian Rasnita wrote: > You didn't say that WxPython can't be used with Python 3. Have you said that? Some besides Peter pointed this out a few days ago. >>> The other part of the discussion is related to the accessibility and >> care for >accessibility and that discussion is not nice at all, because >> it shows how >>> selfish are most of the people and they consider this a virtue. >> Selfish? We've had multiple people get interested, > > I am not interested if the people are getting interested. I am interested to have a solution right now, and at least for Python 2, a solution is already available. Python 2 is in bug-fix mode and no major modifications will be done to this version of Python. This means that Tkinter will not be replaced in Python 2. If you want a fix now, you either have to fix Tkinter in a backwards compatible way to work with Python 2, or you have to get wxPython (or some other GUI package) ready for Python 3. Cheers Tommy From mail2bansi at gmail.com Wed Jan 26 11:16:02 2011 From: mail2bansi at gmail.com (Bansilal Haudakari) Date: Wed, 26 Jan 2011 11:16:02 -0500 Subject: Is it possible to pass CSV Reader Object As Argument to another Python File ??? Options Message-ID: I have following two python scripts -namelookupWrapper.py -namelookup.py The namelookupWrapper.py takes input of "memberId", "memberName" from CLI and has following code snippet idf = sys.argv[1] namef = sys.argv[2] real_script = "C:\\Splunk\\etc\\apps\\search\\bin\\namelookup.py" r = csv.reader(sys.stdin) os.execv(python_executable, [ python_executable, real_script ] + sys.argv[1:] ) Wondering how would i pass csv reader object "r" as an argument using os.execv() to another python script i.e. namelookup.py Regards, Bansi ----------------------------------------------------- Bansilal Haudakari SUN Certified Enterprise JAVA Architect / Programmer http://bansihaudakari.wordpress.com/ L:703-445-2894 -------------- next part -------------- An HTML attachment was scrubbed... URL: From emile at fenx.com Wed Jan 26 11:30:15 2011 From: emile at fenx.com (Emile van Sebille) Date: Wed, 26 Jan 2011 08:30:15 -0800 Subject: Is it possible to pass CSV Reader Object As Argument to another Python File ??? In-Reply-To: <2c35653e-3565-48c6-8939-b6b09b885e3f@d23g2000prj.googlegroups.com> References: <2c35653e-3565-48c6-8939-b6b09b885e3f@d23g2000prj.googlegroups.com> Message-ID: On 1/26/2011 7:51 AM bansi said... > I have following two python scripts > -namelookupWrapper.py > -namelookup.py > > > The namelookupWrapper.py takes input of "memberId", "memberName" from > CLI and has following code snippet > > idf = sys.argv[1] > namef = sys.argv[2] > real_script = "C:\\Splunk\\etc\\apps\\search\\bin\\namelookup.py" > r = csv.reader(sys.stdin) > os.execv(python_executable, [ python_executable, real_script ] + > sys.argv[1:] ) > > > > Wondering how would i pass csv reader object "r" as an argument using > os.execv() to another python script i.e. namelookup.py > I suspect you're on the wrong path. You probably want to import namelookup within namelooupWrapper to use the functions it defines. Consider: [root at fcfw2 src]# cat > test1.py def say(what): print what [root at fcfw2 src]# cat > test2.py #!/usr/local/bin/python import sys from test1 import say say(sys.argv[1]) [root at fcfw2 src]# chmod a+x test2.py [root at fcfw2 src]# ./test2.py hello hello HTH, Emile From mpnordland at gmail.com Wed Jan 26 11:32:03 2011 From: mpnordland at gmail.com (mpnordland) Date: Wed, 26 Jan 2011 11:32:03 -0500 Subject: open() mode args Message-ID: What is the correct file mode to pass to open() when I want to both read and write on the open file? From robert.kern at gmail.com Wed Jan 26 11:35:04 2011 From: robert.kern at gmail.com (Robert Kern) Date: Wed, 26 Jan 2011 10:35:04 -0600 Subject: WxPython versus Tkinter. In-Reply-To: References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <8q7sgiF5tpU1@mid.individual.net> <19891784-d6a3-41ac-a097-5902a6323bc0@o21g2000prn.googlegroups.com><0b12cdb1-45b4-41e4-9bdb-074ee669d76b@k14g2000pre.googlegroups.com> <048FB74272D440A0915ABC7D76AE262B@teddy> <5782E9AD8A8342D691EB3549E5E0ED7B@octavian> Message-ID: On 1/26/11 10:00 AM, Emile van Sebille wrote: > On 1/25/2011 10:08 PM Octavian Rasnita said... >> From: "Emile van Sebille" >>>> Why is WxPython ineligible? >>> >>> I think Terry's point was compatibility with python3 -- which wx >>> apparently isn't yet. >>> >>> Emile >> >> >> Well, I didn't know this, and it is a valid reason. >> This means that it is true that there is no enough maintainance force to >> keep WxPython updated. >> Did I understand correctly? > > Not at all -- wxPython is an active funded ongoing project. Review the roadmap > at http://wiki.wxpython.org/TentativeRoadmap and particularly the final > paragraph on Python3.x support. That's not Terry's point. The reasons he's referring to (and stated previously) are as follows: 1. The license of wxWidgets and wxPython is not as permissive as Python's. The Python developers, as a matter of policy, do not want to include code into the standard library that is less permissive than the current license. 2. The Python developers require someone to commit to maintaining contributed code for a number of years. No one has done so. See reason #3. 3. The wxPython developers do not want wxPython in the standard library, not least because they want to develop and release wxPython at a different pace and release cycle than the standard library. 4. The Python developers have committed to maintaining backwards compatibility in the standard library for a very long time. Even if they included wxPython into the standard library, they would have to provide a Tkinter module that works like the current one. I do not believe it is feasible to write a Tkinter workalike that uses wxPython, so we would still be relying on Tcl/Tk. There is certainly enough maintenance force to keep wxPython updated and ported to Python 3, but only *outside* of the standard library. -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco From emile at fenx.com Wed Jan 26 11:43:36 2011 From: emile at fenx.com (Emile van Sebille) Date: Wed, 26 Jan 2011 08:43:36 -0800 Subject: Bugs/issues in tkinter.simpledialog!! In-Reply-To: References: Message-ID: On 1/26/2011 8:00 AM rantingrick said... > > I just installed Python 3,0 on my machine. Try it again on the current release candidate -- http://www.python.org/download/releases/3.2/ -- testing old first release code and reporting on its problems won't get any traction. Verify the problem continues to exist in the current maintained version and then ask. If you get confirmation that the behavior is likely a bug, file a bug report so those who can and do can do (or at least consider). See http://docs.python.org/bugs.html http://www.python.org/dev/peps/pep-0003/ Emile From rantingrick at gmail.com Wed Jan 26 11:45:01 2011 From: rantingrick at gmail.com (rantingrick) Date: Wed, 26 Jan 2011 08:45:01 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> Message-ID: <80914a32-527c-445c-828e-20066fdc2b8c@y19g2000prb.googlegroups.com> On Jan 22, 6:07?pm, rantingrick wrote: > --------------------------------------- > ?Challenge 1: (Simple Directory Viewer) > --------------------------------------- > > Create a simple Directory Viewer GUI. You CANNOT use a treectrl! ?The > point of this challenge is to show that Tkinter has no support for a > true ListCtrl widget. However the Wx::ListCtrl is fully featured! For > wxPython the code is simply wielding a few built in classes. For > Tkinter no such ListCtrl functionality exists. You CAN create the > functionality yourself (and i know this because i HAVE created it!) > however it involves tons of work and still can't hold a candle to the > wx::ListCtrl > > --------------- > ?Requirements: > --------------- > > How the user navigates to a folder is not important but you must > display the list of files/folders in two view modes with icons; > > ?1. Display files in both ReportView and ListView. > > ? * Reportview: > ? ? ...scrollable vertical list with three columns. > > ? * Listview: > ? ? ...scrollable horizontal-ly wrapping list. > > Note: If you do not understand the view modes just run my code for an > example. But the user must be able to switch between these two modes > easily. How the switching is done is unimportant -- I simply used two > buttons. > > ?2. Columns > ? * Minimum of three cols; Name, Size, and Type (reportview). > ? * the "Name" column must include an icon AND label (both views). > ? * columns must be sortable by the user (reportview). > ? * columns must be sizable by the user (reportview). > > ?3. Items > ? * All must be editable in place (no popup editing allowed!). > ? * All items must be selectable/deselectable by user. > ? * All items must be delete-able by the user. > > That is the challenge. Step forth and battle if you can! > > ----------------- > ?WxPython code: > ----------------- > > https://sites.google.com/site/thefutureofpython/home/code-challenges > > I await any challengers... So we have come this far and still not one challenger. Neither can one person admit that the wxPython ListCtrl is far superior than widget TclTk contains. But that really does not matter now. The point is that TclTk have grown stagnate and have been that way for many years. Whilst Tkinter does sport a beautiful API we have no way to scale the module because TclTk is limited. New Python programmers will start out (like i did) with Tkinter and love its simplicity, however eventually they will come to understand that all their spend energy writing Tkinter has been for nothing. They will realize that Tkinter is 1990's technology migrated into the 21st century. That is point i am making. Some people can handle the truth. Denial is to be expected. If you are out there and your not one of the redundant trolls who keep parroting off and assassination my character please drop by and insert your opinion on the value of Tkinter. Just make sure to use facts and not emotion driven drivel. If you choose to be a troll i cannot stop you, and i would not. However i will not respond to trollish posts anymore. It is quite clear that a hand full of the same old folks want to stop me at all costs -- even at the expense of their own soul. Psst: If you notice they are not yelling about the code anymore because it is bug free. They are only interested in spreading discontent and not solving problems. That is a blindingly apparent fact. Anyway i still await a solid challenge. Either in code or in words based on facts. Until then i will consider myself victorious by default. From steve+comp.lang.python at pearwood.info Wed Jan 26 11:53:23 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 26 Jan 2011 16:53:23 GMT Subject: open() mode args References: Message-ID: <4d405182$0$29983$c3e8da3$5496439d@news.astraweb.com> On Wed, 26 Jan 2011 11:32:03 -0500, mpnordland wrote: > What is the correct file mode to pass to open() when I want to both read > and write on the open file? open("filename", "r+") for text mode, "r+b" for binary mode. If your operating system does not distinguish between the two, you can use either. More detail is available in the Fine Manual, or in the interactive help: help(open) at the Python prompt. -- Steven From rantingrick at gmail.com Wed Jan 26 11:53:58 2011 From: rantingrick at gmail.com (rantingrick) Date: Wed, 26 Jan 2011 08:53:58 -0800 (PST) Subject: Bugs/issues in tkinter.simpledialog!! References: Message-ID: <412e4d83-f750-441d-bfc5-d96c0559e069@e9g2000prn.googlegroups.com> On Jan 26, 10:43?am, Emile van Sebille wrote: > On 1/26/2011 8:00 AM rantingrick said... > > I just installed Python 3,0 on my machine. > > Try it again on the current release candidate --http://www.python.org/download/releases/3.2/-- testing old first > > Seehttp://docs.python.org/bugs.htmlhttp://www.python.org/dev/peps/pep-0003/ Why would i want to waste bandwidth downloading an RC? Can i not just browse the source online? I only need to check one module. Where is the source available for viewing "simpledialog" online? Thanks PS: The version i have now is 3.1.1 (but i would like to see the newest version available, just not download it!) From ms419 at freezone.co.uk Wed Jan 26 12:04:56 2011 From: ms419 at freezone.co.uk (Jack Bates) Date: Wed, 26 Jan 2011 09:04:56 -0800 Subject: method-to-instance binding, callable generator decorator Message-ID: <1296061496.1121.10.camel@selene> Am struggling to understand Python method-to-instance binding Anyone know why this example throws a TypeError? > #!/usr/bin/env python > > import functools > > # Take a generator function (i.e. a callable which returns a generator) and > # return a callable which calls .send() > class coroutine: > def __init__(self, function): > self.function = function > > functools.update_wrapper(self, function) > > def __call__(self, *args, **kwds): > try: > return self.generator.send(args) > > except AttributeError: > self.generator = self.function(*args, **kwds) > > return self.generator.next() > > # Each time we're called, advance to next yield > @coroutine > def test(): > yield 'call me once' > yield 'call me twice' > > # Works like a charm : ) > assert 'call me once' == test() > assert 'call me twice' == test() > > class Test: > > # Each time we're called, advance to next yield > @coroutine > def test(self): > yield 'call me once' > yield 'call me twice' > > test = Test() > > # TypeError, WTF? > assert 'call me once' == test.test() > assert 'call me twice' == test.test() https://gist.github.com/797019 Am trying to write a decorator such that each time I call a function, it advances to the next "yield" - I plan to use functions like this as fixtures in tests Does a decorator like this already exist in the Python standard library? From orasnita at gmail.com Wed Jan 26 12:04:57 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Wed, 26 Jan 2011 19:04:57 +0200 Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com><9MB%o.14110$%64.6074@unlimited.newshosting.com> <59F6E65E3D9A46AD8D7A3863F3C1DC84@teddy> <27f53f8c-7862-4366-9352-82ae9a2f3970@k3g2000yqc.googlegroups.com> <718D13777F254C839F9564BC4275DE0A@octavian> <4D402C42.1030407@tysdomain.com> <4D40447C.4010108@tysdomain.com> Message-ID: <33C68A0874BE4C66AB478EDFB64C2C1D@teddy> From: "Littlefield, Tyler" > >with JAWS because it is the most used screen reader. > Get off your me soapbox. Jaws is not the most used. NVDA is taking over, > quite fast, and lots of people have totally switched to mac or Vinux Lots of people means an insignifiant percent of users compared with the percent of Windows users. NVDA is mostly used as a second screen reader in case that something wrong happends with the first one. It doesn't support a good voice synthesizer like Eloquence or IBM Via voice, but only eSpeak which sounds horrible, it doesn't have a scripting language ready to use as JAWS and Window Eyes do, it doesn't offer the possibility of reading with the mouse cursor as JAWS does with its so called JAWS cursor, it offers a poor accessibility in many applications and many other issues. > because of the problems with Jaws. It's most used in corporate sektors > still maybe, but lots of end-users are migrating to Window Eyes, NVDA or > OSX because of the fact that it is both cheaper and NVDA is open source, > not to mention free. Just because Jaws -was- most used and -you- use it, > doesn't mean it still remains so. Window Eyes always was cheaper than JAWS, however it was never the most used screen reader because it also have its problems. I don't understand why you care so much about what will *probably* happen in the future and don't care about the present. An indian saying says that on the long term will be everything fine (because we will be all dead:) But you are talking just to show how right you are. If you remember about our discussion, we were talking about how inaccessible is Tkinter, and well Tkinter has the same inaccessibility level under Window Eyes and NVDA just like under JAWS, so I don't know why is it so important to name all those screen readers if someone wants to test Tkinter. I thought that if someone wants to test how inaccessible is Tkinter, JAWS would be enough because Tkinter is also inaccessible for the other screen readers, and I thought that it would be normally to test the accessibility using the screen reader that offer the most features. Octavian From orasnita at gmail.com Wed Jan 26 12:09:33 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Wed, 26 Jan 2011 19:09:33 +0200 Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com> <9MB%o.14110$%64.6074@unlimited.newshosting.com> <59F6E65E3D9A46AD8D7A3863F3C1DC84@teddy> <27f53f8c-7862-4366-9352-82ae9a2f3970@k3g2000yqc.googlegroups.com> <718D13777F254C839F9564BC4275DE0A@octavian> <4D402C42.1030407@tysdomain.com> <39327F93-9814-42D0-9EA2-92F6A5E783D7@mac.com> Message-ID: From: "Tommy Grav" >> You didn't say that WxPython can't be used with Python 3. Have you said that? > > Some besides Peter pointed this out a few days ago. I don't remember to have read that. But who knows, maybe I have missed it. Does anyone have that message? > Python 2 is in bug-fix mode and no major modifications will be done to this version of Python. This means that Tkinter will not be replaced in Python 2. Of course. That's why I said that this is a real problem and that I understand the real reason why WxPython can't be included in the Python distribution. Octavian From mail2bansi at gmail.com Wed Jan 26 12:14:48 2011 From: mail2bansi at gmail.com (bansi) Date: Wed, 26 Jan 2011 09:14:48 -0800 (PST) Subject: Is it possible to pass CSV Reader Object As Argument to another Python File ??? References: <2c35653e-3565-48c6-8939-b6b09b885e3f@d23g2000prj.googlegroups.com> Message-ID: <29813d68-75c9-49cb-a14c-e62f4304d6c5@z26g2000prf.googlegroups.com> On Jan 26, 11:30?am, Emile van Sebille wrote: > On 1/26/2011 7:51 AM bansi said... > > > > > > > I have following two python scripts > > -namelookupWrapper.py > > -namelookup.py > > > The namelookupWrapper.py takes input of "memberId", "memberName" from > > CLI and has following code snippet > > > idf = sys.argv[1] > > namef = sys.argv[2] > > real_script = "C:\\Splunk\\etc\\apps\\search\\bin\\namelookup.py" > > r = csv.reader(sys.stdin) > > os.execv(python_executable, [ python_executable, real_script ] + > > sys.argv[1:] ) > > > Wondering how would i pass csv reader object "r" as an argument using > > os.execv() to another python script i.e. namelookup.py > > I suspect you're on the wrong path. ?You probably want to import > namelookup within namelooupWrapper to use the functions it defines. > > Consider: > > [root at fcfw2 src]# cat > test1.py > > def say(what): print what > > [root at fcfw2 src]# cat > test2.py > > #!/usr/local/bin/python > import sys > from test1 import say > say(sys.argv[1]) > > [root at fcfw2 src]# chmod a+x test2.py > > [root at fcfw2 src]# ./test2.py hello > hello > > HTH, > > Emile- Hide quoted text - > > - Show quoted text - Emile, Thanks for quick response. I am not sure if "import namelookup within namelooupWrapper" helps because they are two independent scripts which has to be executed in sequence. First namelookupWrapper.py running under Python 2.6 accept arguments from stdin and uses csv reader object to read it i.e. r=csv.reader(sys.stdin) And then it has to pass csv reader object to another python script namelookup.py running under Python 2.7 because it uses pyodbc to connect to database and iterates thru reader object Any better ideas/suggestions will be greatly appreciated From orasnita at gmail.com Wed Jan 26 12:19:17 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Wed, 26 Jan 2011 19:19:17 +0200 Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <8q7sgiF5tpU1@mid.individual.net> <19891784-d6a3-41ac-a097-5902a6323bc0@o21g2000prn.googlegroups.com><0b12cdb1-45b4-41e4-9bdb-074ee669d76b@k14g2000pre.googlegroups.com> <048FB74272D440A0915ABC7D76AE262B@teddy> <5782E9AD8A8342D691EB3549E5E0ED7B@octavian> Message-ID: <43FCB75BBC57406799C87AD6FC781EFC@teddy> From: "Emile van Sebille" ... >> Well, I didn't know this, and it is a valid reason. >> This means that it is true that there is no enough maintainance force to >> keep WxPython updated. >> Did I understand correctly? > > Not at all -- wxPython is an active funded ongoing project. Review the > roadmap at http://wiki.wxpython.org/TentativeRoadmap and particularly > the final paragraph on Python3.x support. > > Emile But somebody said that the core Python developers, or Guido said that WxPython won't be included in the core distribution because it doesn't have a strong team of maintainers... with other words but this was the idea. So I still don't understand why WxPython can't be a good solution. If WxPython is well maintained, let's pretend that the maintainers solved that bug that make the apps give a segfault, and let's pretend that it works under Python 3. Can it be a good choice for replacing Tkinter? I don't know why, but I have a feeling that even in these cases WxPython is still not wanted and I don't understand why. I can see that the people try to find some false arguments like the one that WxPython is bigger than Tkinter, but really, who cares today about a few aditional megabytes? What do you think it is more important, to offer accessibility for most of the users, or to create small applications? (Note that I didn't say that Tkinter should be forbidden, so if somebody in some edge cases need to make a very small program, he/she could do it very well.) So I still don't understand why WxPython wouldn't be prefered even all its problems would be solved. Octavian From gerald.britton at gmail.com Wed Jan 26 12:20:06 2011 From: gerald.britton at gmail.com (Gerald Britton) Date: Wed, 26 Jan 2011 12:20:06 -0500 Subject: Slice lists and extended slicing Message-ID: I'm looking at extended slicing and wondering when and how to use slice lists: slicing ::= simple_slicing | extended_slicing simple_slicing ::= primary "[" short_slice "]" extended_slicing ::= primary "[" slice_list "]" slice_list ::= slice_item ("," slice_item)* [","] slice_item ::= expression | proper_slice | ellipsis proper_slice ::= short_slice | long_slice short_slice ::= [lower_bound] ":" [upper_bound] long_slice ::= short_slice ":" [stride] lower_bound ::= expression upper_bound ::= expression stride ::= expression ellipsis The semantics for an extended slicing are as follows. The primary must evaluate to a mapping object, and it is indexed with a key that is constructed from the slice list, as follows. If the slice list contains at least one comma, the key is a tuple containing the conversion of the slice items; otherwise, the conversion of the lone slice item is the key. The conversion of a slice item that is an expression is that expression. The conversion of an ellipsis slice item is the built-in Ellipsis object. The conversion of a proper slice is a slice object (see section The standard type hierarchy) whose start, stop and step attributes are the values of the expressions given as lower bound, upper bound and stride, respectively, substituting None for missing expressions. I'd thought that I could do this: >>> l = [1,2,3,4,5] >>> l[0:1, 3:4] Traceback (most recent call last): File "", line 1, in TypeError: list indices must be integers, not tuple but that clearly doesn't work! So, when and how can one use slice lists? -- Gerald Britton From mpnordland at gmail.com Wed Jan 26 12:21:38 2011 From: mpnordland at gmail.com (mpnordland) Date: Wed, 26 Jan 2011 12:21:38 -0500 Subject: open() mode args In-Reply-To: <4d405182$0$29983$c3e8da3$5496439d@news.astraweb.com> References: <4d405182$0$29983$c3e8da3$5496439d@news.astraweb.com> Message-ID: thanks From emile at fenx.com Wed Jan 26 12:28:20 2011 From: emile at fenx.com (Emile van Sebille) Date: Wed, 26 Jan 2011 09:28:20 -0800 Subject: method-to-instance binding, callable generator decorator In-Reply-To: <1296061496.1121.10.camel@selene> References: <1296061496.1121.10.camel@selene> Message-ID: On 1/26/2011 9:04 AM Jack Bates said... > Am struggling to understand Python method-to-instance binding > > Anyone know why this example throws a TypeError? > >> > #!/usr/bin/env python >> > >> > import functools >> > >> > # Take a generator function (i.e. a callable which returns a generator) and >> > # return a callable which calls .send() >> > class coroutine: >> > def __init__(self, function): >> > self.function = function >> > >> > functools.update_wrapper(self, function) >> > >> > def __call__(self, *args, **kwds): >> > try: >> > return self.generator.send(args) >> > >> > except AttributeError: >> > self.generator = self.function(*args, **kwds) >> > >> > return self.generator.next() >> > >> > # Each time we're called, advance to next yield >> > @coroutine >> > def test(): >> > yield 'call me once' >> > yield 'call me twice' define test >> > >> > # Works like a charm : ) >> > assert 'call me once' == test() >> > assert 'call me twice' == test() >> > >> > class Test: >> > >> > # Each time we're called, advance to next yield >> > @coroutine >> > def test(self): >> > yield 'call me once' >> > yield 'call me twice' >> > >> > test = Test() I'm not sure, but you've shadowed the test function above here. >> > >> > # TypeError, WTF? >> > assert 'call me once' == test.test() >> > assert 'call me twice' == test.test() > https://gist.github.com/797019 > > Am trying to write a decorator such that each time I call a function, it > advances to the next "yield" - I plan to use functions like this as > fixtures in tests > > Does a decorator like this already exist in the Python standard library? From rantingrick at gmail.com Wed Jan 26 12:38:12 2011 From: rantingrick at gmail.com (rantingrick) Date: Wed, 26 Jan 2011 09:38:12 -0800 (PST) Subject: adding "Print" menu in wxPython References: <05c1f4b3-941c-45b1-9370-a88653d1083a@e16g2000pri.googlegroups.com> <66d035ae-cb4f-4ad3-836d-f8394ad90475@q8g2000prm.googlegroups.com> <7775b108-b04b-44a9-abae-1e58842b3186@b25g2000vbz.googlegroups.com> <3517483e-3222-4d29-9198-1f1d4fc396f1@w17g2000yqh.googlegroups.com> Message-ID: <79983aa5-01a4-421e-b6d9-7f45119c10b0@f21g2000prn.googlegroups.com> On Jan 26, 10:07?am, Akand Islam wrote: > I really appreciate your cooperation. The codes you have written print > in command window, but I want to print (i.e. a popup window will > appear to select printer in order to print). Please assist me > regarding this. Ok, read on... > I am optimist that I can take care menu creating, > binding, error handling by myself. Therefore you can only show me the > "OnPrint" function to fulfill my purpose. Yes but how can i be sure? You still failed to post code proving that you can do this. I don't mind helping folks and i will go out on a limb for anyone however i will not build the tree of knowledge for you. You must prove that you are at least making an attempt to learn. If i do all the work then you won't learn anything. Heck, i even cleaned up the horrible code and put comments exactly where you need to create the menu. I could not have made this challenge any easier. So show me some proof that you are trying then we will move on to next step. You must attack problems step by step. From orasnita at gmail.com Wed Jan 26 12:46:07 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Wed, 26 Jan 2011 19:46:07 +0200 Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <8q7sgiF5tpU1@mid.individual.net> <19891784-d6a3-41ac-a097-5902a6323bc0@o21g2000prn.googlegroups.com><0b12cdb1-45b4-41e4-9bdb-074ee669d76b@k14g2000pre.googlegroups.com> <048FB74272D440A0915ABC7D76AE262B@teddy> <5782E9AD8A8342D691EB3549E5E0ED7B@octavian> Message-ID: From: "Robert Kern" > That's not Terry's point. The reasons he's referring to (and stated previously) > are as follows: > > 1. The license of wxWidgets and wxPython is not as permissive as Python's. The > Python developers, as a matter of policy, do not want to include code into the > standard library that is less permissive than the current license. This is the worst and... sorry for the word, but real stupid thing. I mean, I don't consider a correct thinking to care more about the permissiveness of a licence which is anyway open source, more than about the accessibility. Try to think that for some people Tkinter displays just a black filled rectangle. In that case would you still think that it is "correct" to keep that kind of GUI because of some differences between open source licences? > 2. The Python developers require someone to commit to maintaining contributed > code for a number of years. No one has done so. See reason #3. In that case I understand that there are enough WxPython developers, well funded, but there is no commitment from them. >From Python's perspective, there are not enough maintainers that can offer that commitment and yes, this is a real reason why the core Python developers can't include WxPython. > 3. The wxPython developers do not want wxPython in the standard library, not > least because they want to develop and release wxPython at a different pace and > release cycle than the standard library. >From the message of a list member which (but maybe I am wrong) appear to be a WxPython developer, I suspected that the WxPython developers might not want their work to be included in the Python distribution. I am not really sure about this because I haven't seen any message from a WxPython developer telling that yes, I am a WxPython developer and we don't want to allow including WxPython in the Python distro, and I almost don't believe that, but if it is true, I don't know why they didn't said that, because WxPython is their work and of course that if they don't accept to maintain a WxPython as apart of Python distribution, then this discussion doesn't have any meaning. I have only heard that WxPython will never be included, but without beeing more clear. Who knows, maybe some of those who said that are WxPython developers but for me they are just some names because I don't know them... The next (or previous) points are not important anymore if the WxPython developers don't want their work to be included in the Python distribution. So, is it true? That was the cause for which WxPython can't be promoted by Python? Because the WxPython developers don't want this? If the answer is yes, then too bad, because as I said, it's their work and they can do whatever they like with it. Octavian From benjamin.kaplan at case.edu Wed Jan 26 12:52:41 2011 From: benjamin.kaplan at case.edu (Benjamin Kaplan) Date: Wed, 26 Jan 2011 12:52:41 -0500 Subject: Slice lists and extended slicing In-Reply-To: References: Message-ID: On Wed, Jan 26, 2011 at 12:20 PM, Gerald Britton wrote: > I'm looking at extended slicing and wondering when and how to use slice lists: > > slicing ? ? ? ? ?::= ?simple_slicing | extended_slicing > simple_slicing ? ::= ?primary "[" short_slice "]" > extended_slicing ::= ?primary "[" slice_list "]" > slice_list ? ? ? ::= ?slice_item ("," slice_item)* [","] > slice_item ? ? ? ::= ?expression | proper_slice | ellipsis > proper_slice ? ? ::= ?short_slice | long_slice > short_slice ? ? ?::= ?[lower_bound] ":" [upper_bound] > long_slice ? ? ? ::= ?short_slice ":" [stride] > lower_bound ? ? ?::= ?expression > upper_bound ? ? ?::= ?expression > stride ? ? ? ? ? ::= ?expression > ellipsis > > The semantics for an extended slicing are as follows. The primary must > evaluate to a mapping object, and it is indexed with a key that is > constructed from the slice list, as follows. If the slice list > contains at least one comma, the key is a tuple containing the > conversion of the slice items; otherwise, the conversion of the lone > slice item is the key. The conversion of a slice item that is an > expression is that expression. The conversion of an ellipsis slice > item is the built-in Ellipsis object. The conversion of a proper slice > is a slice object (see section The standard type hierarchy) whose > start, stop and step attributes are the values of the expressions > given as lower bound, upper bound and stride, respectively, > substituting None for missing expressions. > > I'd thought that I could do this: > >>>> l = [1,2,3,4,5] >>>> l[0:1, 3:4] > Traceback (most recent call last): > ?File "", line 1, in > TypeError: list indices must be integers, not tuple > > but that clearly doesn't work! ?So, when and how can one use slice lists? > > -- > Gerald Britton If you're trying to learn a language, I would suggest reading tutorials, not the grammar. As you can see from the error thrown, the operation is syntactically valid (you don't get a syntax error). It's just that lists don't accept them. I don't know of any built-in data type that takes slice lists but numpy matrices will. >>> a = numpy.matrix([[1,2,3],[4,5,6],[7,8,9]]) matrix([[1, 2, 3], [4, 5, 6], [7, 8, 9]]) >>> a[0:2,1:3] matrix([[2, 3], [5, 6]]) > -- > http://mail.python.org/mailman/listinfo/python-list > From benjamin.kaplan at case.edu Wed Jan 26 12:55:18 2011 From: benjamin.kaplan at case.edu (Benjamin Kaplan) Date: Wed, 26 Jan 2011 12:55:18 -0500 Subject: Bugs/issues in tkinter.simpledialog!! In-Reply-To: <412e4d83-f750-441d-bfc5-d96c0559e069@e9g2000prn.googlegroups.com> References: <412e4d83-f750-441d-bfc5-d96c0559e069@e9g2000prn.googlegroups.com> Message-ID: On Wed, Jan 26, 2011 at 11:53 AM, rantingrick wrote: > On Jan 26, 10:43?am, Emile van Sebille wrote: >> On 1/26/2011 8:00 AM rantingrick said... > >> > I just installed Python 3,0 on my machine. >> >> Try it again on the current release candidate --http://www.python.org/download/releases/3.2/-- testing old first >> >> Seehttp://docs.python.org/bugs.htmlhttp://www.python.org/dev/peps/pep-0003/ > > Why would i want to waste bandwidth downloading an RC? Can i not just > browse the source online? I only need to check one module. Where is > the source available for viewing "simpledialog" online? > > Thanks > > PS: The version i have now is 3.1.1 (but i would like to see the > newest version available, just not download it!) The code is hosted on http://svn.python.org If you just one that one file, it's at http://svn.python.org/view/python/trunk/Lib/lib-tk/tkSimpleDialog.py?view=markup > -- > http://mail.python.org/mailman/listinfo/python-list > From jeanmichel at sequans.com Wed Jan 26 12:55:53 2011 From: jeanmichel at sequans.com (Jean-Michel Pichavant) Date: Wed, 26 Jan 2011 18:55:53 +0100 Subject: method-to-instance binding, callable generator decorator In-Reply-To: <1296061496.1121.10.camel@selene> References: <1296061496.1121.10.camel@selene> Message-ID: <4D406029.8060809@sequans.com> Jack Bates wrote: > Am struggling to understand Python method-to-instance binding > > Anyone know why this example throws a TypeError? > > >> #!/usr/bin/env python >> >> import functools >> >> # Take a generator function (i.e. a callable which returns a generator) and >> # return a callable which calls .send() >> class coroutine: >> def __init__(self, function): >> self.function = function >> >> functools.update_wrapper(self, function) >> >> def __call__(self, *args, **kwds): >> try: >> return self.generator.send(args) >> >> except AttributeError: >> self.generator = self.function(*args, **kwds) >> >> return self.generator.next() >> >> # Each time we're called, advance to next yield >> @coroutine >> def test(): >> yield 'call me once' >> yield 'call me twice' >> >> # Works like a charm : ) >> assert 'call me once' == test() >> assert 'call me twice' == test() >> >> class Test: >> >> # Each time we're called, advance to next yield >> @coroutine >> def test(self): >> yield 'call me once' >> yield 'call me twice' >> >> test = Test() >> >> # TypeError, WTF? >> assert 'call me once' == test.test() >> assert 'call me twice' == test.test() >> > > https://gist.github.com/797019 > > Am trying to write a decorator such that each time I call a function, it > advances to the next "yield" - I plan to use functions like this as > fixtures in tests > > Does a decorator like this already exist in the Python standard library? > At the time you set the self.function attribute, its value is an unbound method, and thus must be called with the instance as first attribute. Since "self.generator = self.function(*args, **kwds)" doesn't pass the self arguement as 1st parameter, you have to do it yourself. replace your last 2 lines by assert 'call me once' == test.test(test) assert 'call me twice' == test.test(test) One alternative is to decorate, once the instance is created, ie. the method is bound to the instance and does not require to pass the instance as 1st argument: class Test2: def test2(self): yield 'call me once' yield 'call me twice' test2 = Test2() test2.test2 = coroutine(test2.test2) assert 'call me once' == test2.test2() assert 'call me twice' == test2.test2() I'm not sure it's a standard way to proceed though, it looks rather strange. I'm not familiar with decorators, but my guess is that one decorator cannot (except through the above tricks) decorate functions AND unbound methods. In order to make your original coroutine decorator work with unbound methods, and only unbound methods, change self.generator = self.function(*args, **kwds) into self.generator = self.function(self, *args, **kwds) Hope it helps, JM From robert.kern at gmail.com Wed Jan 26 13:06:24 2011 From: robert.kern at gmail.com (Robert Kern) Date: Wed, 26 Jan 2011 12:06:24 -0600 Subject: Slice lists and extended slicing In-Reply-To: References: Message-ID: On 1/26/11 11:20 AM, Gerald Britton wrote: > I'm looking at extended slicing and wondering when and how to use slice lists: > > slicing ::= simple_slicing | extended_slicing > simple_slicing ::= primary "[" short_slice "]" > extended_slicing ::= primary "[" slice_list "]" > slice_list ::= slice_item ("," slice_item)* [","] > slice_item ::= expression | proper_slice | ellipsis > proper_slice ::= short_slice | long_slice > short_slice ::= [lower_bound] ":" [upper_bound] > long_slice ::= short_slice ":" [stride] > lower_bound ::= expression > upper_bound ::= expression > stride ::= expression > ellipsis > > The semantics for an extended slicing are as follows. The primary must > evaluate to a mapping object, and it is indexed with a key that is > constructed from the slice list, as follows. If the slice list > contains at least one comma, the key is a tuple containing the > conversion of the slice items; otherwise, the conversion of the lone > slice item is the key. The conversion of a slice item that is an > expression is that expression. The conversion of an ellipsis slice > item is the built-in Ellipsis object. The conversion of a proper slice > is a slice object (see section The standard type hierarchy) whose > start, stop and step attributes are the values of the expressions > given as lower bound, upper bound and stride, respectively, > substituting None for missing expressions. > > I'd thought that I could do this: > >>>> l = [1,2,3,4,5] >>>> l[0:1, 3:4] > Traceback (most recent call last): > File "", line 1, in > TypeError: list indices must be integers, not tuple > > but that clearly doesn't work! So, when and how can one use slice lists? The object just needs to implement its __getitem__(self, key) method appropriately. list objects have an implementation that only processes integer indices and slices. The original semantics that motivated this syntax feature is not to take several slices from a sequence and concatenate them together. Rather, it was to support multidimensional slices for numpy arrays (or rather, numpy's predecessor Numeric). [~] |1> from numpy import arange [~] |2> A = arange(20).reshape([4,5]) [~] |3> A array([[ 0, 1, 2, 3, 4], [ 5, 6, 7, 8, 9], [10, 11, 12, 13, 14], [15, 16, 17, 18, 19]]) [~] |4> A[1:3, 2:4] array([[ 7, 8], [12, 13]]) list objects could be written to interpret a tuple of slices any way it wants to, including the semantics you seem to have expected. I would suggest, though, that the need for those semantics isn't common enough to warrant the syntactic sugar. -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco From clp2 at rebertia.com Wed Jan 26 13:17:45 2011 From: clp2 at rebertia.com (Chris Rebert) Date: Wed, 26 Jan 2011 10:17:45 -0800 Subject: Slice lists and extended slicing In-Reply-To: References: Message-ID: On Wed, Jan 26, 2011 at 9:20 AM, Gerald Britton wrote: > I'm looking at extended slicing and wondering when and how to use slice lists: > > slicing ? ? ? ? ?::= ?simple_slicing | extended_slicing > simple_slicing ? ::= ?primary "[" short_slice "]" > extended_slicing ::= ?primary "[" slice_list "]" > slice_list ? ? ? ::= ?slice_item ("," slice_item)* [","] > slice_item ? ? ? ::= ?expression | proper_slice | ellipsis > proper_slice ? ? ::= ?short_slice | long_slice > short_slice ? ? ?::= ?[lower_bound] ":" [upper_bound] > long_slice ? ? ? ::= ?short_slice ":" [stride] > lower_bound ? ? ?::= ?expression > upper_bound ? ? ?::= ?expression > stride ? ? ? ? ? ::= ?expression > ellipsis > > The semantics for an extended slicing are as follows. The primary must > evaluate to a mapping object, and it is indexed with a key that is > constructed from the slice list, as follows. If the slice list > contains at least one comma, the key is a tuple containing the > conversion of the slice items; otherwise, the conversion of the lone > slice item is the key. The conversion of a slice item that is an > expression is that expression. The conversion of an ellipsis slice > item is the built-in Ellipsis object. The conversion of a proper slice > is a slice object (see section The standard type hierarchy) whose > start, stop and step attributes are the values of the expressions > given as lower bound, upper bound and stride, respectively, > substituting None for missing expressions. > > I'd thought that I could do this: > >>>> l = [1,2,3,4,5] >>>> l[0:1, 3:4] > Traceback (most recent call last): > ?File "", line 1, in > TypeError: list indices must be integers, not tuple > > but that clearly doesn't work! ?So, when and how can one use slice lists? When the object you're slicing supports it, which is rarely. None of the built-in types support multiple proper_slices like your example; I know of no std lib classes that do either. However, the 3rd party matrix library NumPy very well might. Normally, one would instead write your example as: l[0:1] + l[3:4] Cheers, Chris -- http://blog.rebertia.com From rantingrick at gmail.com Wed Jan 26 13:19:39 2011 From: rantingrick at gmail.com (rantingrick) Date: Wed, 26 Jan 2011 10:19:39 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <8q7sgiF5tpU1@mid.individual.net> <19891784-d6a3-41ac-a097-5902a6323bc0@o21g2000prn.googlegroups.com><0b12cdb1-45b4-41e4-9bdb-074ee669d76b@k14g2000pre.googlegroups.com> <048FB74272D440A0915ABC7D76AE262B@teddy> <5782E9AD8A8342D691EB3549E5E0ED7B@octavian> Message-ID: <9649b12c-46b3-475a-8c33-2790d13f5a46@j19g2000prh.googlegroups.com> On Jan 26, 10:35?am, Robert Kern wrote: > On 1/26/11 10:00 AM, Emile van Sebille wrote: > That's not Terry's point. The reasons he's referring to (and stated previously) > are as follows: > > 1. The license of wxWidgets and wxPython is not as permissive as Python's. The > Python developers, as a matter of policy, do not want to include code into the > standard library that is less permissive than the current license. This is actually a weak argument and i'll explain why. GUI libraries are very complicated and time consuming projects. Just think of all the work involved just to get a library working on one platform... much less THREE or more platforms! And while i am a huge believer in 100% open source software you've got to understand why most libraries are restrictive for commercial usage or worse. Yes TclTk IS fully opensource and i applaud them for it! However like the old adage say: "You get what you pay for". > 2. The Python developers require someone to commit to maintaining contributed > code for a number of years. No one has done so. See reason #3. > > 3. The wxPython developers do not want wxPython in the standard library, not > least because they want to develop and release wxPython at a different pace and > release cycle than the standard library. I have already shown why this does not matter. The current wxPython API is NOT good for Python. We DO NOT want segfaults and "C++ looking" code written by the users of a Python stdlib module. Robin has stated that there exists room for an abstraction layer on top of wxPython and he is correct. He has also stated that he wants to keep "his wxPython" as close to WxWidgets as possible. So be it! We will never want to include wxPython "proper" in the stdlib anyway because it is SO unpythonic!! No. All we have to do is create an abstraction API that calls wxPython until we can create OUR OWN wxPython from WxWidgets. Call it Wxpy if you like. > 4. The Python developers have committed to maintaining backwards compatibility > in the standard library for a very long time. Even if they included wxPython > into the standard library, they would have to provide a Tkinter module that > works like the current one. I do not believe it is feasible to write a Tkinter > workalike that uses wxPython, so we would still be relying on Tcl/Tk. Fine support Tkinter until Python4000 i don't care. But we must move forward. We must accept that Tkinter is already legacy and there is no moving forward now. We will support Tkinter for backwards compadibility however we will start to integrate a truly Pythonic WxPython abstraction API and include just the API module in the stdlib. Then we don't have to maintain a huge library, just a small module with a wxPython 3rd party dependency. Then at some point in the future when the stdlib is ripe, we can THEN include some form of wxWidgets, and dump Tkinter forever. At least then we would be moving towards something. Currently we are stagnate. > > There is certainly enough maintenance force to keep wxPython updated and ported > to Python 3, but only *outside* of the standard library. So let wxPython due what wxPython does best. We will use them as long as we need until we can create a stdlib compliant wxPython ourselves. They would be fools not to work with us! Because eventually when no 3rd party download is needed, all their work would go into the bit bucket. I doubt Robin is that foolish. He seems like a smart fellow to me -- even though he refuses to comply with PEP8 :) SUMMARY: We create an abstraction API atop "Robin's WxPython". We include only the API in the stdlib at this time and we keep Tkinter in maintenance. Then over the next few years we start a fresh wxPython project that will be acceptable for the stdlib. Something that we can plug our API into. We steal as much from Robin as we can (or get him to cooperate). Then when the time is right, we dump Tkinter and integrate the new Wxpy module into the stdlib. Then we will be back on track. From malaclypse2 at gmail.com Wed Jan 26 13:21:12 2011 From: malaclypse2 at gmail.com (Jerry Hill) Date: Wed, 26 Jan 2011 13:21:12 -0500 Subject: Bugs/issues in tkinter.simpledialog!! In-Reply-To: <412e4d83-f750-441d-bfc5-d96c0559e069@e9g2000prn.googlegroups.com> References: <412e4d83-f750-441d-bfc5-d96c0559e069@e9g2000prn.googlegroups.com> Message-ID: On Wed, Jan 26, 2011 at 11:53 AM, rantingrick wrote: > Why would i want to waste bandwidth downloading an RC? Can i not just > browse the source online? If I understand what you're asking for, the answer is http://svn.python.org/view . If you're specifically looking for 3.2rc1, then I believe you could look at http://svn.python.org/view/python/tags/r32rc1/ > I only need to check one module. Where is > the source available for viewing "simpledialog" online? > Again, assuming you're looking for the 3.2rc1 code in particular: http://svn.python.org/view/python/tags/r32rc1/Lib/tkinter/simpledialog.py?view=markup -- Jerry -------------- next part -------------- An HTML attachment was scrubbed... URL: From emile at fenx.com Wed Jan 26 13:22:13 2011 From: emile at fenx.com (Emile van Sebille) Date: Wed, 26 Jan 2011 10:22:13 -0800 Subject: Slice lists and extended slicing In-Reply-To: References: Message-ID: On 1/26/2011 9:20 AM Gerald Britton said... > I'm looking at extended slicing and wondering when and how to use slice lists: I think the use of the term slice_list below is simply as the content between the encompassing brackets, eg in mylist[1:2:3] slice_list refers to 1:2:3. So, you don't actually 'use' a slice_list - that's what the passed in value is called. So, here are some example of how slicing is used: >>> a = range(10) [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] >>> a[:3] # the first three [0, 1, 2] >>> a[-3:] # the last three [7, 8, 9] >>> a[3:-3] # start and stop [3, 4, 5, 6] >>> a[::2] # take every other [0, 2, 4, 6, 8] >>> a[::-2] # take every other from the end [9, 7, 5, 3, 1] >>> a[3:-3:2] # take every other within start stop [3, 5] >>> a[3:-3:-2] # I'm not sure exactly why I didn't get something here [] >>> a[-3:3:-2] # but apparently the polarity of stride within start stop matters [7, 5] >>> HTH Emile > > slicing ::= simple_slicing | extended_slicing > simple_slicing ::= primary "[" short_slice "]" > extended_slicing ::= primary "[" slice_list "]" > slice_list ::= slice_item ("," slice_item)* [","] > slice_item ::= expression | proper_slice | ellipsis > proper_slice ::= short_slice | long_slice > short_slice ::= [lower_bound] ":" [upper_bound] > long_slice ::= short_slice ":" [stride] > lower_bound ::= expression > upper_bound ::= expression > stride ::= expression > ellipsis > > The semantics for an extended slicing are as follows. The primary must > evaluate to a mapping object, and it is indexed with a key that is > constructed from the slice list, as follows. If the slice list > contains at least one comma, the key is a tuple containing the > conversion of the slice items; otherwise, the conversion of the lone > slice item is the key. The conversion of a slice item that is an > expression is that expression. The conversion of an ellipsis slice > item is the built-in Ellipsis object. The conversion of a proper slice > is a slice object (see section The standard type hierarchy) whose > start, stop and step attributes are the values of the expressions > given as lower bound, upper bound and stride, respectively, > substituting None for missing expressions. > > I'd thought that I could do this: > >>>> l = [1,2,3,4,5] >>>> l[0:1, 3:4] > Traceback (most recent call last): > File "", line 1, in > TypeError: list indices must be integers, not tuple > > but that clearly doesn't work! So, when and how can one use slice lists? > From urban.dani at gmail.com Wed Jan 26 13:23:36 2011 From: urban.dani at gmail.com (Daniel Urban) Date: Wed, 26 Jan 2011 19:23:36 +0100 Subject: Behaviour-based interface/protocol implementation? In-Reply-To: References: Message-ID: > That's just what I'd like and I suppose can't be currently done with > current ABC, PyProtocols or zope.interface implementations, right? It can. With __instancecheck__ you can override isinstance. It is possible (for example) to write a subclass of abc.ABCMeta, which extends __instancecheck__ to use an _instancehook classmethod similarly to __subclasshook__. Then in your MyInterface class you can implement _instancehook to check for methods/signatures/whatever you want. Daniel From debatem1 at gmail.com Wed Jan 26 13:28:45 2011 From: debatem1 at gmail.com (geremy condra) Date: Wed, 26 Jan 2011 10:28:45 -0800 Subject: WxPython versus Tkinter. In-Reply-To: <753A4C5A6658470085804B13C80340F2@octavian> References: <4D3E4377.3060807@tysdomain.com> <9MB%o.14110$%64.6074@unlimited.newshosting.com> <4A48EDF6D7634F2E994661A457451E87@teddy> <753A4C5A6658470085804B13C80340F2@octavian> Message-ID: On Tue, Jan 25, 2011 at 11:10 PM, Octavian Rasnita wrote: > From: "geremy condra" >> >> There's a difference between what you say and how you say it. If a >> friend came up to you and said "give me $100 right now!", you probably >> wouldn't do it. If the same friend came up to you and said "I know >> this is a big thing to ask, but I really need $100 and I can't >> guarantee I'll be able to pay you back. Could you please help me?" I > > Are you even thinking that the second sentence is much harder to express? > Do you imagine that my knowledge of English is limited by the fact that it > is not my native language and it is a language not spoken by very many > people in my country? > I simply might not be able to express so nice as you like that I need 100 > bucks from you, but I might be able to just tell you that "need 100 dollars. > now". > I could argue much more nice and expressive if we were speaking Romanian and > not English. At least 40% of my coworkers do not speak English as their native language. Your problem is not the language. Your problem is your attitude. > But I don't condemn you for this, because many years ago when I was in > school I had the opinion that some foreign colleagues are a little stupid > just because they were not able to express very well the ideas which were > not very simple, and well, they were not stupid at all, but they didn't know > my language well enough and they probably would think the same thing about > me if we were speaking in Russian. I don't have that problem. >> don't know very many people who would refuse if they were able to >> help. The reason is simple: the first does not acknowledge the value >> of the person doing the favor, and the second does. > > Exactly what I said. They are doing the same mistake as I did 20 years ago. > By the way, can't you see any syntactic dissacords in my phrases? Haven't > you think that my English might not be as fluent to be able to express > everything I want to say very well? As I mentioned earlier, you'll find I don't have a lot of pity for you in this. >> More concretely, you have an opinion that not supporting accessibility >> is discrimination. Tyler has an opinion that not supporting >> accessibility is a bug. > > This is not always true. Not supporting accessibility when *it is not > possible* yes, it is a bug as you say, so we agree here. > But not supporting accessibility because the programmer *doesn't want this*, > it is not a bug, but discrimination. Don't you agree with this? > And if Python would have been able to support accessibility it would have > mean that it promotes discrimination because it promotes the wrong tool, but > it seems that Python 3 doesn't have an accessible GUI lib for the moment, so > no, it is not discrimination (but Emile told us that there is no support for > WxPython in Python 3 just today, so I didn't know this and I already > wondered why nobody told about this real problem). Keep in mind, I'm not saying this. This is a sketch of your point of view and Tyler's point of view. >> Are you going to demand that he change his >> opinion? Or are you going to ask that he consider yours? > > It seems that the discrimination should be something that should be > discussed if and when it should be applied, isn't it? > Well, I think that everyone should understand why the programs must be > accessible and why everybody should care about all the users of an > application and that it is not normal to not care. Ah! I think I see where you're going wrong. It *is* normal not to care- not just about this, but about any given special interest other than your own. You have to convince people to care, or they don't- and you're not convincing, just yelling. >>> Have I said something wrong? Did I use bad words? Or what was it wrong? >> >> I think it was uncivil. It was rude, unkind, and generally >> disagreeable. I lost respect for you, and by proxy, for your point of >> view. In other words, you lost support not because fewer people agree >> with your position, but because fewer people want to agree with you. > > You are also very unkind and rude when you say that the disabled that need > to use a screen reader should be a kind of second hand people that need to > beg for a little accessibility. I don't say this. Don't try to stuff me into a strawman argument. > When you create a program, why do you create a visual interface for it? Why > don't you create just an audio interface? I don't create a visual interface. I have never found it necessary for my line of work, and have little stake in this discussion besides that of advocating civility on this list. > You do this because otherwise you would not please those who can see. Why > shouldn't be something normal, and that *should be not be discussable at > all* to offer the same accessibility to everyone? You can discuss it. You just have to convince others that you're right, and you're not doing that well. I offered you some advice on how to go about doing it better. > And you didn't say what was rude from what I said. You said just that it was > rude. I can provide quotes, if you like. > Oh yes I know that it is unkind because most of the people don't even like > to talk personally with disabled people, but this doesn't mean that the > disabled people are something not normal, but those who have those biases > towards those who are very different. I don't have this problem. >> I didn't ask you to change your opinion. I told you that you would be >> more effective if you changed your attitude. Like rantingrick, you're >> free to ignore that advice, but it is good advice for both you and the >> community, and I urge you to take it. > > About what community? It would be better for the community of the disabled? > Or you don't care about that community? I think it would be better for the Python community if you were more civil and for the disabled community if you were more successful. The two go hand in hand. >>> Or you recommend me to be just like Tyler that can't use all the apps he >>> could use if they were accessible, but he doesn't care because he cares much >>> more to play nice in order to be accepted in this not-right society? >> >> I would recommend that you learn to be civil to those you disagree >> with. The alternative is to be surrounded by them. > > Aha, you show that old fact that the majority is more important because it > has more power, the fact Tyler is afraid. More people have the power to accomplish what fewer cannot. You want big changes, you will need big support, and people won't just move to your side because you're angry. You have to convince them. > The majority can be also wrong, the majority can also have bad feelings, and > that majority that have the power to change things should be informed and > convinced to change them. Yes, absolutely. > If the majority doesn't care about the minorities which are minorities > without willing to be so, then it means that it is wrong. I don't know that's the case, and I suspect there are shades of grey you are not acknowledging here. Geremy Condra From clp2 at rebertia.com Wed Jan 26 13:31:43 2011 From: clp2 at rebertia.com (Chris Rebert) Date: Wed, 26 Jan 2011 10:31:43 -0800 Subject: Is it possible to pass CSV Reader Object As Argument to another Python File ??? In-Reply-To: <2c35653e-3565-48c6-8939-b6b09b885e3f@d23g2000prj.googlegroups.com> References: <2c35653e-3565-48c6-8939-b6b09b885e3f@d23g2000prj.googlegroups.com> Message-ID: On Wed, Jan 26, 2011 at 7:51 AM, bansi wrote: > I have following two python scripts > -namelookupWrapper.py > -namelookup.py > > > The namelookupWrapper.py takes input of "memberId", "memberName" from > CLI and has following code snippet > > idf = sys.argv[1] > namef = sys.argv[2] > real_script = "C:\\Splunk\\etc\\apps\\search\\bin\\namelookup.py" > r = csv.reader(sys.stdin) > os.execv(python_executable, [ python_executable, real_script ] + > sys.argv[1:] ) > > Wondering how would i pass csv reader object "r" as an argument using > os.execv() to another python script i.e. namelookup.py It's not possible to pass Python objects between processes in such a manner. Given that "independent" scripts can't directly take objects as input anyway, I doubt the two scripts are truly independent from each other. I would therefore concur with van Sebille that you should just rewrite them so that one script imports from the other rather than spawning the other. It should not be too hard to port the Python 2.6 script to Python 2.7 (or vice-versa if necessary). Cheers, Chris -- http://blog.rebertia.com From nstinemates at gmail.com Wed Jan 26 13:42:24 2011 From: nstinemates at gmail.com (Nick Stinemates) Date: Wed, 26 Jan 2011 10:42:24 -0800 Subject: Bugs/issues in tkinter.simpledialog!! In-Reply-To: References: Message-ID: > However some things never change it seems and some improvements are > actually a step backwards. The same problems with the unit test in 2.x > got ported to 3.x. And the new SimpleDialog is just more lackluster > code like we've seen before. I was hoping to be amazed, i am > disappointed and disgusted. It is obvious that whoever is writing/ > maintaining the tkinter code base does NOT understand tkinter > completely and this is blinding apparent by reading the source code! > ----------- > Issues > ----------- > > First lets start with the problems that migrated from 2.x... > (tkinter.simpledialog) > > #-- ISSUE 1 --# > In the test() function we still have code that uses the "quit" method > instead of "destroy". Calling the "quit" method only tells Tkinter to > stop processing events, IT DOES NOT DESTROY THE WIDGET!! And on > windows the the root will then become unresponsive -- you cannot close > the window, you cannot do anything. I have said time and time again. > DO NOT USE THE QUIT METHOD UNLESS YOU KNOW WHAT THE HECK YOU ARE > DOING! So the code needs to be this... > > OLD: > q = Button(root, text='Quit', command=t.quit) > > NEW: > q = Button(root, text='Quit', command=root.destroy) > > > #-- ISSUE 2: --# > The author used a very strange method by which to denote the default > button in the SimpleDialog class. He choose to set the relief to RIDGE > and the border "8". This not only looks horrible (and exposes the > authors ignorance of tkinter) but a much more elegant solution is > provided by the TclTk folks. All buttons have a "default" option that > will display the button with a nice border so the user can visually > see which button is active. So the code should be this.... > > OLD: > if num == default: > b.config(relief=RIDGE, borderwidth=8) > > NEW: > if num == default: > b.config(default=ACTIVE) > > > Last but not least i am puzzled as to why we choose the method name > "go" over "show". for "showing" the dialog. SimpleDialog uses no > inheritance so name clashes are mum. Why would anyone choose "go" over > "show" for a modal dialog? I would really like an explanation for > this. > > Sounds like you need to help by: Creating a bug report Attaching a patch Thanks for the help, Rick. Nick -------------- next part -------------- An HTML attachment was scrubbed... URL: From subhabangalore at gmail.com Wed Jan 26 13:47:05 2011 From: subhabangalore at gmail.com (Subhabrata) Date: Wed, 26 Jan 2011 10:47:05 -0800 (PST) Subject: Question on Open Project Message-ID: <076881d4-6437-487b-a061-252dab625460@k21g2000prb.googlegroups.com> Dear Room, I am a python programmer, from India(New Delhi area), and was in Bangalore for long days. My specialization is Natural Language Processing, -Machine Learning(worked on Naive Bayes, SVM, HMM, CRF). I am looking for some open projects in Python-in Machine Learning/NLP area, preferably from India(as many a times personal interaction is helpful) which I can do from home. If anyone knows of any reliable link. Best, Subhabrata. From robert.kern at gmail.com Wed Jan 26 14:00:23 2011 From: robert.kern at gmail.com (Robert Kern) Date: Wed, 26 Jan 2011 13:00:23 -0600 Subject: WxPython versus Tkinter. In-Reply-To: References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <8q7sgiF5tpU1@mid.individual.net> <19891784-d6a3-41ac-a097-5902a6323bc0@o21g2000prn.googlegroups.com><0b12cdb1-45b4-41e4-9bdb-074ee669d76b@k14g2000pre.googlegroups.com> <048FB74272D440A0915ABC7D76AE262B@teddy> <5782E9AD8A8342D691EB3549E5E0ED7B@octavian> Message-ID: On 1/26/11 11:46 AM, Octavian Rasnita wrote: > From: "Robert Kern" >> That's not Terry's point. The reasons he's referring to (and stated previously) >> are as follows: >> >> 1. The license of wxWidgets and wxPython is not as permissive as Python's. The >> Python developers, as a matter of policy, do not want to include code into the >> standard library that is less permissive than the current license. > > This is the worst and... sorry for the word, but real stupid thing. > I mean, I don't consider a correct thinking to care more about the permissiveness of a licence which is anyway open source, more than about the accessibility. Being able to say that all of a project is available under the substantively the same license is really important. It's very hard to get people to use your software if some parts are under one license and other parts are under a substantively different one. You are free to decide what licenses you want to distribute software under; the PSF has that freedom as well. > Try to think that for some people Tkinter displays just a black filled rectangle. In that case would you still think that it is "correct" to keep that kind of GUI because of some differences between open source licences? This is a reason for application developers to use wxPython, not for the Python developers to include wxPython in the standard library. The standard library neither claims nor aims to do everything. There are many things that Tkinter cannot do that wxPython can. None of those things are reasons to replace Tkinter with wxPython in the standard library. Not everything useful has to be in the standard library. Python has a vibrant ecosystem of third party packages. wxPython is probably the most widely used GUI toolkit in Python. It has not been harmed (and I would argue that it has been very much helped) by not being in the standard library. Nor has it been harmed by the presence of Tkinter in the standard library. If wxPython had been included in the Python standard library, it would not have been able to easily follow the advancements of the underlying wxWidgets toolkit, and it would be a much less strong GUI toolkit. >> 2. The Python developers require someone to commit to maintaining contributed >> code for a number of years. No one has done so. See reason #3. > > In that case I understand that there are enough WxPython developers, well funded, but there is no commitment from them. Correct, they have not committed to maintaining wxPython as part of the standard library (although they are committed to maintaining wxPython outside of it). They have not even suggested that wxPython should be part of the standard library. >> From Python's perspective, there are not enough maintainers that can offer that commitment and yes, this is a real reason why the core Python developers can't include WxPython. > >> 3. The wxPython developers do not want wxPython in the standard library, not >> least because they want to develop and release wxPython at a different pace and >> release cycle than the standard library. > > >> From the message of a list member which (but maybe I am wrong) appear to be a WxPython developer, I suspected that the WxPython developers might not want their work to be included in the Python distribution. > I am not really sure about this because I haven't seen any message from a WxPython developer telling that yes, I am a WxPython developer and we don't want to allow including WxPython in the Python distro, and I almost don't believe that, but if it is true, I don't know why they didn't said that, because WxPython is their work and of course that if they don't accept to maintain a WxPython as apart of Python distribution, then this discussion doesn't have any meaning. Robin, if you're still paying attention to this thread, would you mind chiming in? Robin Dunn is the wxPython project lead. > I have only heard that WxPython will never be included, but without beeing more clear. > Who knows, maybe some of those who said that are WxPython developers but for me they are just some names because I don't know them... > > The next (or previous) points are not important anymore if the WxPython developers don't want their work to be included in the Python distribution. > > So, is it true? That was the cause for which WxPython can't be promoted by Python? There is a large difference between the being "promoted by Python" and being "included in Python's standard library. The latter is the issue at hand, not the former. wxPython is already "promoted" by Python's documentation: http://docs.python.org/library/othergui.html -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco From misnomer at gmail.com Wed Jan 26 14:02:37 2011 From: misnomer at gmail.com (Nicholas Devenish) Date: Wed, 26 Jan 2011 19:02:37 +0000 Subject: WxPython versus Tkinter. In-Reply-To: <9649b12c-46b3-475a-8c33-2790d13f5a46@j19g2000prh.googlegroups.com> References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <8q7sgiF5tpU1@mid.individual.net> <19891784-d6a3-41ac-a097-5902a6323bc0@o21g2000prn.googlegroups.com><0b12cdb1-45b4-41e4-9bdb-074ee669d76b@k14g2000pre.googlegroups.com> <048FB74272D440A0915ABC7D76AE262B@teddy> <5782E9AD8A8342D691EB3549E5E0ED7B@octavian> <9649b12c-46b3-475a-8c33-2790d13f5a46@j19g2000prh.googlegroups.com> Message-ID: On 26/01/2011 18:19, rantingrick wrote: > SUMMARY: We create an abstraction API atop "Robin's WxPython". We > include only the API in the stdlib at this time and we keep Tkinter in > maintenance. Then over the next few years we start a fresh wxPython > project that will be acceptable for the stdlib. Something that we can > plug our API into. We steal as much from Robin as we can (or get him > to cooperate). Then when the time is right, we dump Tkinter and > integrate the new Wxpy module into the stdlib. Then we will be back on > track. I look forward to reading your PEP and initial design documents, though I suspect you would need the latter and to get some a decent portion of work done before it would even be considered as an inclusion into the standard library. I strongly suspect that your response to this suggestion would be the ironic "more talk and no action from X". Many capable developers have their own occupations and might not have the spare time or desire to spend on a project where all evidence suggests would be a (non-benevolent) dictatorship where they would be endlessly browbeaten. You have continuously tried to outright present yourself as a 'visionary' and speaker for the python community and then asked why people don't take you seriously. People would take you a lot more seriously if you showed that you had the vision and capability to drive development of such a serious undertaking, and manage such a team of developers, whom you have first managed to attract to the project. If you actually seriously believe this should happen and that you are the best person to drive it, the way to go about it is probably: - Write some design documents, or even code, laying out what you think the interface should be. - Put it out to the community, listen to advice, make changes (it will NOT be perfect) and gather support. - Provide an initial implementation Somebody in the old thread said something which made sense, which I paraphrase as: "Only idiots think they can command communities of equals." This is something to keep closely in mind in your continuing, what can only be described as 'crusades'. This, along with the fact that people remember first impressions, and are usually cautious about reversing opinions developed through many examples of uncivility. Heck, I am probably wasting my time with this post; but you come across as genuine in your held central beliefs, and so either serious or the most dedicated and adept troll I have ever encountered. In the case of the former, I hold an optimistic view that most people are capable of self-asessment. In the case of the latter, consider me successfully trolled. Nick From robert.kern at gmail.com Wed Jan 26 14:05:29 2011 From: robert.kern at gmail.com (Robert Kern) Date: Wed, 26 Jan 2011 13:05:29 -0600 Subject: WxPython versus Tkinter. In-Reply-To: <43FCB75BBC57406799C87AD6FC781EFC@teddy> References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <8q7sgiF5tpU1@mid.individual.net> <19891784-d6a3-41ac-a097-5902a6323bc0@o21g2000prn.googlegroups.com><0b12cdb1-45b4-41e4-9bdb-074ee669d76b@k14g2000pre.googlegroups.com> <048FB74272D440A0915ABC7D76AE262B@teddy> <5782E9AD8A8342D691EB3549E5E0ED7B@octavian> <43FCB75BBC57406799C87AD6FC781EFC@teddy> Message-ID: On 1/26/11 11:19 AM, Octavian Rasnita wrote: > From: "Emile van Sebille" > ... >>> Well, I didn't know this, and it is a valid reason. >>> This means that it is true that there is no enough maintainance force to >>> keep WxPython updated. >>> Did I understand correctly? >> >> Not at all -- wxPython is an active funded ongoing project. Review the >> roadmap at http://wiki.wxpython.org/TentativeRoadmap and particularly >> the final paragraph on Python3.x support. >> >> Emile > > But somebody said that the core Python developers, or Guido said that WxPython won't be included in the core distribution because it doesn't have a strong team of maintainers... with other words but this was the idea. No, you are misrepresenting what was said. What is required is that someone make an active commitment to maintain wxPython as part of the standard library *specifically*. That means that the package has to follow Python's release cycle. The wxPython developers do not wish to do that. They can develop wxPython much better outside of the standard library. -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco From alex.kapps at web.de Wed Jan 26 14:16:49 2011 From: alex.kapps at web.de (Alexander Kapps) Date: Wed, 26 Jan 2011 20:16:49 +0100 Subject: WxPython versus Tkinter. In-Reply-To: <33C68A0874BE4C66AB478EDFB64C2C1D@teddy> References: <4D3E4377.3060807@tysdomain.com><9MB%o.14110$%64.6074@unlimited.newshosting.com> <59F6E65E3D9A46AD8D7A3863F3C1DC84@teddy> <27f53f8c-7862-4366-9352-82ae9a2f3970@k3g2000yqc.googlegroups.com> <718D13777F254C839F9564BC4275DE0A@octavian> <4D402C42.1030407@tysdomain.com> <4D40447C.4010108@tysdomain.com> <33C68A0874BE4C66AB478EDFB64C2C1D@teddy> Message-ID: <4D407321.3090705@web.de> On 26.01.2011 18:04, Octavian Rasnita wrote: > From: "Littlefield, Tyler" >>> with JAWS because it is the most used screen reader. >> Get off your me soapbox. Jaws is not the most used. NVDA is taking over, >> quite fast, and lots of people have totally switched to mac or Vinux > > Lots of people means an insignifiant percent of users compared with the percent of Windows users. Please don't use the lower Linux user percentage as an argument here. If you follow that path further, you would need to agree that it's only an "insignificant" percent of people who need a screen reader, so why bother? Note carefully: I am *not* saying that one shouldn't bother about the "minority" of people who need accessibility, just that you can't use an argument that ignores another minority (Linux user) if you fight for your minority (and no, Linux isn't anymore a "freak-os". Several countries (getting more) have started to migrate governmental IT infrastructures to Linux, so if you mean it serious, you just need to care for their, possibly impaired, workers too.) (Also please don't weigh my words to strong; I'm no native english speaker and my wording might be clumsy. Try to understand what I really wanted to say or ask back.) From tyler at tysdomain.com Wed Jan 26 14:17:07 2011 From: tyler at tysdomain.com (Littlefield, Tyler) Date: Wed, 26 Jan 2011 12:17:07 -0700 Subject: WxPython versus Tkinter. In-Reply-To: <33C68A0874BE4C66AB478EDFB64C2C1D@teddy> References: <4D3E4377.3060807@tysdomain.com><9MB%o.14110$%64.6074@unlimited.newshosting.com> <59F6E65E3D9A46AD8D7A3863F3C1DC84@teddy> <27f53f8c-7862-4366-9352-82ae9a2f3970@k3g2000yqc.googlegroups.com> <718D13777F254C839F9564BC4275DE0A@octavian> <4D402C42.1030407@tysdomain.com> <4D40447C.4010108@tysdomain.com> <33C68A0874BE4C66AB478EDFB64C2C1D@teddy> Message-ID: <4D407333.1070301@tysdomain.com> It doesn't support a good voice synthesizer like Eloquence or IBM Via voice, but only eSpeak which sounds horrible, it doesn't have a scripting language ready to use as JAWS and Window Eyes do, it doesn't offer the possibility of reading with the mouse cursor as JAWS does with its so called JAWS cursor, it offers a poor accessibility in many applications and many other issues. You are wrong, on all accounts. On 1/26/2011 10:04 AM, Octavian Rasnita wrote: > From: "Littlefield, Tyler" >>> with JAWS because it is the most used screen reader. >> Get off your me soapbox. Jaws is not the most used. NVDA is taking over, >> quite fast, and lots of people have totally switched to mac or Vinux > Lots of people means an insignifiant percent of users compared with the percent of Windows users. > NVDA is mostly used as a second screen reader in case that something wrong happends with the first one. > It doesn't support a good voice synthesizer like Eloquence or IBM Via voice, but only eSpeak which sounds horrible, it doesn't have a scripting language ready to use as JAWS and Window Eyes do, it doesn't offer the possibility of reading with the mouse cursor as JAWS does with its so called JAWS cursor, it offers a poor accessibility in many applications and many other issues. > >> because of the problems with Jaws. It's most used in corporate sektors >> still maybe, but lots of end-users are migrating to Window Eyes, NVDA or >> OSX because of the fact that it is both cheaper and NVDA is open source, >> not to mention free. Just because Jaws -was- most used and -you- use it, >> doesn't mean it still remains so. > > Window Eyes always was cheaper than JAWS, however it was never the most used screen reader because it also have its problems. > I don't understand why you care so much about what will *probably* happen in the future and don't care about the present. > An indian saying says that on the long term will be everything fine (because we will be all dead:) > > But you are talking just to show how right you are. If you remember about our discussion, we were talking about how inaccessible is Tkinter, and well Tkinter has the same inaccessibility level under Window Eyes and NVDA just like under JAWS, so I don't know why is it so important to name all those screen readers if someone wants to test Tkinter. > I thought that if someone wants to test how inaccessible is Tkinter, JAWS would be enough because Tkinter is also inaccessible for the other screen readers, and I thought that it would be normally to test the accessibility using the screen reader that offer the most features. > > Octavian > > > -- Thanks, Ty From rustompmody at gmail.com Wed Jan 26 14:17:58 2011 From: rustompmody at gmail.com (rusi) Date: Wed, 26 Jan 2011 11:17:58 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <8q7sgiF5tpU1@mid.individual.net> <19891784-d6a3-41ac-a097-5902a6323bc0@o21g2000prn.googlegroups.com><0b12cdb1-45b4-41e4-9bdb-074ee669d76b@k14g2000pre.googlegroups.com> <048FB74272D440A0915ABC7D76AE262B@teddy> <5782E9AD8A8342D691EB3549E5E0ED7B@octavian> <9649b12c-46b3-475a-8c33-2790d13f5a46@j19g2000prh.googlegroups.com> Message-ID: <9c8e1ceb-df66-4ed1-9a2c-087343bf7351@j32g2000prh.googlegroups.com> On Jan 27, 12:02?am, Nicholas Devenish wrote: > > Heck, I am probably wasting my time with this post; but you come across > as genuine in your held central beliefs, and so either serious or the > most dedicated and adept troll I have ever encountered. In the case of > the former, I hold an optimistic view that most people are capable of > self-asessment. In the case of the latter, consider me successfully trolled. RR: I'd just like to add -- Do consider whom your verbal violence hurts most. You may also want to google for Erik Naggum From rantingrick at gmail.com Wed Jan 26 14:59:11 2011 From: rantingrick at gmail.com (rantingrick) Date: Wed, 26 Jan 2011 11:59:11 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <8q7sgiF5tpU1@mid.individual.net> <19891784-d6a3-41ac-a097-5902a6323bc0@o21g2000prn.googlegroups.com><0b12cdb1-45b4-41e4-9bdb-074ee669d76b@k14g2000pre.googlegroups.com> <048FB74272D440A0915ABC7D76AE262B@teddy> <5782E9AD8A8342D691EB3549E5E0ED7B@octavian> <9649b12c-46b3-475a-8c33-2790d13f5a46@j19g2000prh.googlegroups.com> Message-ID: <65232137-9ac6-485b-a663-9379a1622c8c@w29g2000vba.googlegroups.com> On Jan 26, 1:02?pm, Nicholas Devenish wrote: > I look forward to reading your PEP and initial design documents, though > I suspect you would need the latter and to get some a decent portion of > work done before it would even be considered as an inclusion into the > standard library. Yes i want to create an API similar to Tkinter but we cannot mirror exactly Tkinter because wx takes a completely different approach to GUI building. We need to steal all the good attributes of Tkinter (and there are quite a few!), learn from them, and evolve the next generation of API. Tkinter will not be a waste because we will stand on the shoulders of Tkinter and reach even higher! Some of the worthwhile "must haves" are: * Geometry managers (pack, place, grid) The geometry managers of Tkinter are just too beautiful to let die. Wx forces you to use Sizers which are a terrible obstacle to the new GUI programmer. And if you want focus traversal then you must also use Panels. This multiplicity is just too ugly for a high level API like i am suggesting. We will need some auto generation of panels and easier to use Sizers wrapped up in a nice Tkinter Geometry Manager like API. This will take some work. However it can be done. * Tagging systems for a TextCtrl and Canvas. Although i challenged Guido on his argument about tagging, i do much agree that tagging is a *very* powerful feature of the TK::Text and TK::Canvas widgets and we should no doubt incorporate this into the API. And this would be one of the easier aspects of the design. * Event binding Here is another area for improvement. While wx has been moving towards a more "Tkinter like" binding of widget events there is still much to be desired. However the binding is not all bad so we should not spend too much time here if only for very small payoffs. * Segfaults We must protect Python users from segfaults. This is really a wxPython's problem however we could insulate the programmer through many techniques on our end. Like for instance: Recreating the columns of a list control after configuration of a single style. However configuration needs a look at also! * Styles One of the things that always bothered me about Tkinter was lack of styles. I know this has been addressed however in the past one would create many widgets that should share a similar style but Tkinter forced you to feed redundant style options to all of them. We need a way to create style objects and then use them everywhere. I think wx supports this already. This is just a very meager list. Much more needs consideration. However this would be a good launch point toward some stated and attainable goals. There is already a quite mature (citaion needed) start with a project called wax. Check it out here... http://wiki.wxpython.org/Wax > Many capable developers have > their own occupations and might not have the spare time or desire to > spend on a project where all evidence suggests would be a > (non-benevolent) dictatorship where they would be endlessly browbeaten. Well i don't want to be a dictator. I believe that in any healthy community, every member should be a king, however no ONE member ever wears the crown. What i mean is, everyone has a special skill that makes them stand out from the crowd. Something that you do better than the other members. So when the needs of my skill-set are present, i will step forth and lead, and when the needs of your skill-set are present, i will sit back and listen and follow YOUR lead. This is how the strongest groups tackle the largest problems with ease. > You have continuously tried to outright present yourself as a > 'visionary' and speaker for the python community and then asked why > people don't take you seriously. People would take you a lot more > seriously if you showed that you had the vision and capability to drive > development of such a serious undertaking, and manage such a team of > developers, whom you have first managed to attract to the project. Agreed, and i hope to demonstrate these skills soon. However like i mentioned in my last statement, i am not a god, much less a dictator. No single man or woman can accomplish these huge problems alone. It takes a team of united folks all simultaneousness willing to lead AND follow when the time is right for the greater good of a common goal. > > ? - Write some design documents, or even code, laying out what you think > the interface should be. > ? - Put it out to the community, listen to advice, make changes (it will > NOT be perfect) and gather support. > I believe we are in this stage now. However much more discussion is needed. From me+list/python at ixokai.io Wed Jan 26 15:07:35 2011 From: me+list/python at ixokai.io (Stephen Hansen) Date: Wed, 26 Jan 2011 12:07:35 -0800 Subject: WxPython versus Tkinter. In-Reply-To: <43FCB75BBC57406799C87AD6FC781EFC@teddy> References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <8q7sgiF5tpU1@mid.individual.net> <19891784-d6a3-41ac-a097-5902a6323bc0@o21g2000prn.googlegroups.com><0b12cdb1-45b4-41e4-9bdb-074ee669d76b@k14g2000pre.googlegroups.com> <048FB74272D440A0915ABC7D76AE262B@teddy> <5782E9AD8A8342D691EB3549E5E0ED7B@octavian> <43FCB75BBC57406799C87AD6FC781EFC@teddy> Message-ID: <4D407F07.6020808@ixokai.io> On 1/26/11 9:19 AM, Octavian Rasnita wrote: > From: "Emile van Sebille" > ... >>> Well, I didn't know this, and it is a valid reason. >>> This means that it is true that there is no enough maintainance force to >>> keep WxPython updated. >>> Did I understand correctly? >> >> Not at all -- wxPython is an active funded ongoing project. Review the >> roadmap at http://wiki.wxpython.org/TentativeRoadmap and particularly >> the final paragraph on Python3.x support. > > But somebody said that the core Python developers, or Guido said that WxPython won't be included in the core distribution because it doesn't have a strong team of maintainers... with other words but this was the idea. That isn't, at all, what people said. What they said was that for a new library to be included in the stdlib, it must have maintainers willing to *commit* for years to *maintain* it IN the stdlib. Maintaining something in the stdlib is very different then maintaining something out of the stdlib. The stdlib has quite a few rules: and it evolves at a certain set speed. wxPython is a wrapper around a third-party library which evolves at a totally different rate: if wxPython were included in the stdlib, these two completely separate development cycles could result in significant hardship for the maintainers and more importantly, for the USERS. Does Python now hold up a release waiting for the wxWidgets team to put out a new version with great new features? Or, does Python release as normal, and just by happenstance does wxWidgets release a great new release a month later-- and now Python users can't get it for a year or two when the next feature release of Python is available? Either way, the maintainers job is more difficult, and users are harmed. There's a reason that libs that go into the stdlib tend to be very static and extremely slow paced in their evolution. Now, Robin could decide to maintain wxPython in two places: as a third-party library, and every release cycle sync in the latest to the core stdlib. That's been done: but its actually extremely problematic itself, and is asking for a lot of extra work. wxPython as a third-party library is maintained: certainly. But that doesn't mean wxPython in the stdlib would be maintained. Then again, it may be that they would be fine with moving into the stdlib-- but since its not a viable option for numerous other reasons, they never bothered to give it any real consideration. > So I still don't understand why WxPython can't be a good solution. > If WxPython is well maintained, let's pretend that the maintainers solved that bug that make the apps give a segfault, and let's pretend that it works under Python 3. > Can it be a good choice for replacing Tkinter? That's hand-waving a LOT of stuff with "let's pretend", but okay. Let's pretend that the lib is modified and fixed up so that segfaults don't happen (and, IIUC, the next version may be); and let's pretend it works under Python 3 (does that leave me in the dust, as someone who would love to get some wxPython updates but who is only using Python 2.5?). There's a bunch of hurdles that would need solving before its a candidate for inclusion: (off the top of my head) 1. Tkinter can not be removed without a 100% compatible replacement for the forseeable future. 100%. No exception on that 100%. This includes people downloading TK extensions and using them in their Python apps: because if thats not possible, real applications will fail. Please understand before you move on. This is one of the hurdles of the stdlib that make maintaining something in it harder then maintaining something out of it: there are strict compatibility requirements and rules. It might be a great thing for humanity to have Python include an accessible GUI toolkit in the standard library: but that doesn't mean the rules can be broken in doing it. Since its basically impossible to be compatible as such, what you'd have to do is add wx while leaving tk, not replacing it. So: 2. New additions must be PEP-8 compliant; wx is not. 3. New additions must include unit tests; I actually don't know if wx does. I've always found it a pain in the butt to test GUI stuff-- but TK is tested (to some degree, I'm not sure how good the coverage is: I just remember tweaking my buildslave to make it run the tests :)). 4. The documentation would have to all be totally rewritten to fit the stdlib documentation format 5. The license thing needs solving from a legal standpoint (new code is traditionally donated to the PSF under the Apache license, which then in turn re-licenses the code under the Python license). You may think its stupid to let something like that get in the way, but sorry: we live in a lawyer's world. 6. Someone would have to commit to maintaining it _in_ the stdlib. 7. Someone would have to work on integrating the wx build requirements with the stdlib's build requirements for all the platforms -- and this can be quite a bit. If this makes the release maintainers jobs a lot harder ... well, they may need some more hands on deck. ... and more. There's a lot of work there. A lot. A lot a lot. And that's just hand-waving away some really significant obstacles with Let's Pretend. Besides: did you know a not insignificant number of people would like to do away with the stdlib in its entirety? And, more then a few actually are pushing for the stdlib to be forked off of CPython, and instead end up shared by all the major Python implementations (CPython, Jython, PyPy, IronPython, what else?) as a common resource? Not saying either group would win (though the latter sounds like a very cool thing to me), but what does either say about the implication of including wxPython? > I can see that the people try to find some false arguments like the one that WxPython is bigger than Tkinter, but really, who cares today about a few aditional megabytes? I'm sorry, but you're confusing what you care about with what other people care about. You do it a lot. But you seem actually honest in your efforts, so I give you the benefit of the doubt. Size does matter to some people, and legitimately so. Still others care deeply about what is bundled with Python because they're in environments where installing third-party libraries isn't allowed: these two interests can stand in opposition to one-another, but that does not make either /false/, and it does not mean that either is /right/. There are many interests involved in a language like Python which has broad usage in extremely varied fields and endeavors: most of which never come near this list. And some people have absolutely no need-- no need at all-- for any sort of GUI programming at all. This group is actually really, really big. The argument is not false: for YOU it is not compelling, and hell, for me I don't find it compelling either. But it is a valid issue which has to be weighed and taken into consideration. Maybe after that is done, on balance, its deemed to be not that big of a deal. But maybe when added up with other concerns, it is. > What do you think it is more important, to offer accessibility for most of the users, or to create small applications? I think its important to do both. And wxPython living on in a third-party library fits that perfectly well. -- Stephen Hansen ... Also: Ixokai ... Mail: me+list/python (AT) ixokai (DOT) io ... Blog: http://meh.ixokai.io/ -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 487 bytes Desc: OpenPGP digital signature URL: From mail2bansi at gmail.com Wed Jan 26 15:24:33 2011 From: mail2bansi at gmail.com (bansi) Date: Wed, 26 Jan 2011 12:24:33 -0800 (PST) Subject: Is it possible to pass CSV Reader Object As Argument to another Python File ??? References: <2c35653e-3565-48c6-8939-b6b09b885e3f@d23g2000prj.googlegroups.com> Message-ID: <876b6c52-1a6d-4afa-83e9-fa987c9359a5@v31g2000pri.googlegroups.com> On Jan 26, 1:31?pm, Chris Rebert wrote: > On Wed, Jan 26, 2011 at 7:51 AM, bansi wrote: > > I have following two python scripts > > -namelookupWrapper.py > > -namelookup.py > > > The namelookupWrapper.py takes input of "memberId", "memberName" from > > CLI and has following code snippet > > > idf = sys.argv[1] > > namef = sys.argv[2] > > real_script = "C:\\Splunk\\etc\\apps\\search\\bin\\namelookup.py" > > r = csv.reader(sys.stdin) > > os.execv(python_executable, [ python_executable, real_script ] + > > sys.argv[1:] ) > > > Wondering how would i pass csv reader object "r" as an argument using > > os.execv() to another python script i.e. namelookup.py > > It's not possible to pass Python objects between processes in such a > manner. Given that "independent" scripts can't directly take objects > as input anyway, I doubt the two scripts are truly independent from > each other. I would therefore concur with van Sebille that you should > just rewrite them so that one script imports from the other rather > than spawning the other. It should not be too hard to port the Python > 2.6 script to Python 2.7 (or vice-versa if necessary). > > Cheers, > Chris > --http://blog.rebertia.com- Hide quoted text - > > - Show quoted text - Thanks Chris. Sorry for mis-communicating, the two python scripts are dependant in a way that namelookupWrapper.py needs to pass csv record object to another python script If thats not possible then please let me know how to do the workaround i didnt understood the import thing and not sure if it helps in my case Here are the details namelookupwrapper.py - takes input from stdin. Using csv reader object i iterate thru the input which looks like as shown below [MemberId, MemberName] [123, ] [456, ] [989, ] Now i have another script i.e. namelookup.py running under Python 2.7 using pyodbc to retrieve Member Names from database for a given Member Id in namelooupWrapper.py So please let me know how to accomplish this From ahsanbagwan at gmail.com Wed Jan 26 15:26:25 2011 From: ahsanbagwan at gmail.com (sl33k_) Date: Wed, 26 Jan 2011 12:26:25 -0800 (PST) Subject: Return Statement Message-ID: How does "return True" and "return False" affect the execution of the calling function? From rantingrick at gmail.com Wed Jan 26 15:37:24 2011 From: rantingrick at gmail.com (rantingrick) Date: Wed, 26 Jan 2011 12:37:24 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <8q7sgiF5tpU1@mid.individual.net> <19891784-d6a3-41ac-a097-5902a6323bc0@o21g2000prn.googlegroups.com><0b12cdb1-45b4-41e4-9bdb-074ee669d76b@k14g2000pre.googlegroups.com> <048FB74272D440A0915ABC7D76AE262B@teddy> <5782E9AD8A8342D691EB3549E5E0ED7B@octavian> <43FCB75BBC57406799C87AD6FC781EFC@teddy> Message-ID: <7952a09c-4e61-4661-9873-7e0bd897b1ee@y2g2000prf.googlegroups.com> On Jan 26, 2:07?pm, Stephen Hansen wrote: > And some people have absolutely no need-- no need at all-- for any sort > of GUI programming at all. This group is actually really, really big. Stephen "Strawman" Hansen: If he only had a brain! :-) That is the most obvious straw-man to date in this thread. What about the large portion of folks who don't use all the datatypes (queue, weakref, etc) or how about numeric and math modules (fractions, decimal, etc) or how about data persistence, or Cryptograhic, or curses! or, multimedia services, or, or. You see NOT everyone uses everything in the stdlib and most use much less than half. However we would be fools to claim "batteries included" and NOT support GUI! From rantingrick at gmail.com Wed Jan 26 15:40:38 2011 From: rantingrick at gmail.com (rantingrick) Date: Wed, 26 Jan 2011 12:40:38 -0800 (PST) Subject: Return Statement References: Message-ID: On Jan 26, 2:26?pm, sl33k_ wrote: > How does "return True" and "return False" affect the execution of the > calling function? >>> def f1(): pass >>> print f1() None >>> def f2(): return >>> print f2() None >>> def f3(): return True >>> print f3() True >>> def f4(): return False >>> print f4() False >>> def f5(): return 'Strawman' >>> print f5() Strawman ...any questions? From rantingrick at gmail.com Wed Jan 26 15:41:52 2011 From: rantingrick at gmail.com (rantingrick) Date: Wed, 26 Jan 2011 12:41:52 -0800 (PST) Subject: Bugs/issues in tkinter.simpledialog!! References: <412e4d83-f750-441d-bfc5-d96c0559e069@e9g2000prn.googlegroups.com> Message-ID: On Jan 26, 11:55?am, Benjamin Kaplan wrote: > The code is hosted onhttp://svn.python.org Thanks! From orasnita at gmail.com Wed Jan 26 15:46:18 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Wed, 26 Jan 2011 22:46:18 +0200 Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com><9MB%o.14110$%64.6074@unlimited.newshosting.com><4A48EDF6D7634F2E994661A457451E87@teddy><753A4C5A6658470085804B13C80340F2@octavian> Message-ID: From: "geremy condra" > At least 40% of my coworkers do not speak English as their native > language. Your problem is not the language. Your problem is your > attitude. The atitude considered nice is just duplicity for convincing others, and I don't like duplicity. I like to know exactly what the people think and I want them know what I think. I don't want to convince anyone, but I just want to inform the others and let them know if they are doing something not recommended. I agree, telling the people that they are doing something wrong, directly, without sugar, might be considered a bad atitude by those who prefer duplicity and nice words just for the sake of socializing, but is that atitude worst than of those who don't care about discriminatory practices? >> But I don't condemn you for this, because many years ago when I was in >> school I had the opinion that some foreign colleagues are a little stupid >> just because they were not able to express very well the ideas which were >> not very simple, and well, they were not stupid at all, but they didn't know >> my language well enough and they probably would think the same thing about >> me if we were speaking in Russian. > > I don't have that problem. Oh yes you do as well as many others and it is obvious because I have seen that some of you consider me to be very angry, but I am not angry nor nervous at all so there may be something else. If I say that I don't like a certain country because it attacks other countries, it doesn't mean that I am nervous or angry. I am just expressing my opinions about that country. About those who use Tkinter I can't even say that I don't like them or something like that, because it is very normal that most of Python programmers should prefer it, because it was promoted a long time by Python. What I said is that it is not OK that Python promoted and keeps promoting a GUI lib that creates discrimination, but I don't know where you have seen that anger. >> Exactly what I said. They are doing the same mistake as I did 20 years ago. >> By the way, can't you see any syntactic dissacords in my phrases? Haven't >> you think that my English might not be as fluent to be able to express >> everything I want to say very well? > > As I mentioned earlier, you'll find I don't have a lot of pity for you in this. I don't need your pitty, but I can see that you misunderstand me, thinking that I am angry, thinking that I want to force everyone to use a GUI lib, and I thought that my English may not be clear enough to make you understand what I want to say. >> But not supporting accessibility because the programmer *doesn't want this*, >> it is not a bug, but discrimination. Don't you agree with this? >> And if Python would have been able to support accessibility it would have >> mean that it promotes discrimination because it promotes the wrong tool, but >> it seems that Python 3 doesn't have an accessible GUI lib for the moment, so >> no, it is not discrimination (but Emile told us that there is no support for >> WxPython in Python 3 just today, so I didn't know this and I already >> wondered why nobody told about this real problem). > > Keep in mind, I'm not saying this. Saying what? I don't understand what you were not saying. > This is a sketch of your point of view and Tyler's point of view. What has the phrase I told above with what Tyler said? I said that if somebody can create accessible programs but doesn't *want* to do that, this generates discrimination. Don't you agree with this? >> Well, I think that everyone should understand why the programs must be >> accessible and why everybody should care about all the users of an >> application and that it is not normal to not care. > > Ah! I think I see where you're going wrong. It *is* normal not to > care- not just about this, but about any given special interest other > than your own. You have to convince people to care, or they don't- and > you're not convincing, just yelling. Where did I say that it is normal to not care about other things? I have also agreed that it is important to have support for Python 3, that it is also important the commercial point of view, it is also important to have a GUI lib without bugs that generates errors, and you are again and again misunderstanding me thinking that I am yelling, even though I am writing all these things very calm. And I am not trying to convince anyone. I mean, we are not in the previous century and I hope that I don't need to convince anyone that offering accessibility for everyone is very important. Do you think that on this list there still are members that need to be convinced about this things? Do you really think that there are members that can't understand the importance of accessibility and they need to be convinced, persuaded, motivated with nice words? Do you have such a bad idea about them? I am sure that they all know very well why the accessibility is important and I was just trying to tell them that Tkinter doesn't create accessible apps. >> You are also very unkind and rude when you say that the disabled that need >> to use a screen reader should be a kind of second hand people that need to >> beg for a little accessibility. > > I don't say this. Don't try to stuff me into a strawman argument. Then why do you ask nice words from me and an atitude which should be nice for the others? We are not negociating here and I am not trying to convince anyone. I am just giving them the information that Tkinter creates inaccessible apps, and this creates discrimination, which is very true. It is not nice to talk about these things, , but first it is not nice for those discriminated, not for the others. >> When you create a program, why do you create a visual interface for it? Why >> don't you create just an audio interface? > > I don't create a visual interface. I have never found it necessary for > my line of work, and have little stake in this discussion besides that > of advocating civility on this list. You are confusing civility with dupplicity. I was very civilized here. I didn't called names, I didn't used bad words but I am just trying to show why what the majority does is bad. Well, from its point of view this may mean that it is not civilized because it doesn't like it. >> You do this because otherwise you would not please those who can see. Why >> shouldn't be something normal, and that *should be not be discussable at >> all* to offer the same accessibility to everyone? > > You can discuss it. You just have to convince others that you're > right, and you're not doing that well. I offered you some advice on > how to go about doing it better. Well, I see that you really think than now in 2011 the people need to be convinced that the accessibility is important. >> And you didn't say what was rude from what I said. You said just that it was >> rude. > > I can provide quotes, if you like. Yes please do it. >> Oh yes I know that it is unkind because most of the people don't even like >> to talk personally with disabled people, but this doesn't mean that the >> disabled people are something not normal, but those who have those biases >> towards those who are very different. > > I don't have this problem. Oh yes you do have it, because otherwise you wouldn't consider my messages as angry and not civilized just because they are not nice and candy and they don't try to convince the others that they should do something, because they are different from what you expect. > I think it would be better for the Python community if you were more > civil and for the disabled community if you were more successful. The > two go hand in hand. I see that you see me as a paid advocate that should succeed convincing a certain group to do a certain thing, but I already told that I am not trying to convince anyone. I just said that now in our era all the people should be very well convinced about the importance of accessibility, and there are very many resources on the net that talk about accessibility if there is somebody that doesn't know what we are talking about, so I don't need to convince anyone. But I think that this is a false argument, because I doubt that there are list members that don't know the importance of accessibility. > More people have the power to accomplish what fewer cannot. You want > big changes, you will need big support, and people won't just move to > your side because you're angry. You have to convince them. I am not angry, but I am not trying to convince anyone about the importance of accessibility because its importance is very well known. The problems are those who are aware about the accessibility but that still don't care. They are the people that should be taken with nice words? Doesn't that mean begging for a little accessibility as I said above? >> If the majority doesn't care about the minorities which are minorities >> without willing to be so, then it means that it is wrong. > > I don't know that's the case, and I suspect there are shades of grey > you are not acknowledging here. If you are acknowledging, then please give some examples of shades of gray. Octavian From rantingrick at gmail.com Wed Jan 26 15:47:04 2011 From: rantingrick at gmail.com (rantingrick) Date: Wed, 26 Jan 2011 12:47:04 -0800 (PST) Subject: Bugs/issues in tkinter.simpledialog!! References: <412e4d83-f750-441d-bfc5-d96c0559e069@e9g2000prn.googlegroups.com> Message-ID: <3ae4f147-646d-4b81-84ec-dc95c3c89021@h17g2000pre.googlegroups.com> On Jan 26, 11:55?am, Benjamin Kaplan wrote: [...snip...] Well i should have looked before i leaped :) This looks like an old 2.x version. I am looking for the newest version with is renamed to "simpledialog" and contains a new class called "SimpleDialog". Do you know were i can view this module? Thanks again. From bryan.oakley at gmail.com Wed Jan 26 16:05:07 2011 From: bryan.oakley at gmail.com (Bryan) Date: Wed, 26 Jan 2011 13:05:07 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <8q7sgiF5tpU1@mid.individual.net> <19891784-d6a3-41ac-a097-5902a6323bc0@o21g2000prn.googlegroups.com><0b12cdb1-45b4-41e4-9bdb-074ee669d76b@k14g2000pre.googlegroups.com> <048FB74272D440A0915ABC7D76AE262B@teddy> <5782E9AD8A8342D691EB3549E5E0ED7B@octavian> <43FCB75BBC57406799C87AD6FC781EFC@teddy> <7952a09c-4e61-4661-9873-7e0bd897b1ee@y2g2000prf.googlegroups.com> Message-ID: On Jan 26, 2:37?pm, rantingrick wrote: > On Jan 26, 2:07?pm, Stephen Hansen wrote: > > > And some people have absolutely no need-- no need at all-- for any sort > > of GUI programming at all. This group is actually really, really big. > > Stephen "Strawman" Hansen: If he only had a brain! :-) > > That is the most obvious straw-man to date in this thread. What about > the large portion of folks who don't use all the datatypes (queue, > weakref, etc) or how about numeric and math modules (fractions, > decimal, etc) or how about data persistence, or Cryptograhic, or > curses! or, multimedia services, or, or. > > You see NOT everyone uses everything in the stdlib and most use much > less than half. However we would be fools to claim "batteries > included" and NOT support GUI! You show a remarkable, awe-inspiring ability to completely miss every salient point of a well articulated argument. From rantingrick at gmail.com Wed Jan 26 16:08:39 2011 From: rantingrick at gmail.com (rantingrick) Date: Wed, 26 Jan 2011 13:08:39 -0800 (PST) Subject: Need GUI pop-up to edit a (unicode ?) string References: <3tqr08-bj2.ln1@murmur.very.softly> <7691fe98-37af-4ddf-a8a8-eadeef0d4a6e@y2g2000prf.googlegroups.com> <541c02df-b1fc-4376-bf17-e0531fe5c4bf@r29g2000yqj.googlegroups.com> <3f724ff2-d571-4f50-92e1-45eaf9ab163d@r16g2000prh.googlegroups.com> Message-ID: On Jan 26, 2:11?am, Terry Reedy wrote: > In 3.x, the module is now tk.simpledialog -- all lower case. The purpose > of all lowercase module names is to avoid confusion with upper case > class names. Yes Terry, i found the new module and documented the bugs in a new thread. I am not sure if the bugs are still present in the current RC (Note: i have 3.1.1 installed) however i would bet they are. As soon as i can find the current source in svn i'll update the "bug thread". However i cannot find it. If you can give a link that would be great! From emile at fenx.com Wed Jan 26 16:11:41 2011 From: emile at fenx.com (Emile van Sebille) Date: Wed, 26 Jan 2011 13:11:41 -0800 Subject: how to read the last line of a huge file??? In-Reply-To: References: Message-ID: On 1/26/2011 2:59 AM Xavier Heruacles said... > I have do some log processing which is usually huge. The length of each line > is variable. How can I get the last line?? Don't tell me to use readlines or > something like linecache... > > seek -rw-rw---- 1 autofax mail 1061716366 Jan 26 12:45 autofax [root at wsgfw3 root]# python2 Python 2.3.5 (#1, Aug 3 2005, 08:40:39) [GCC 3.2.3 20030502 (Red Hat Linux 3.2.3-52)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> f = open('/var/spool/mail/autofax') >>> f.seek(1061710000) >>> lines = f.read() >>> len(lines) 6366 >>> flavor to taste. Emile From python at mrabarnett.plus.com Wed Jan 26 16:22:44 2011 From: python at mrabarnett.plus.com (MRAB) Date: Wed, 26 Jan 2011 21:22:44 +0000 Subject: how to read the last line of a huge file??? In-Reply-To: References: Message-ID: <4D4090A4.3030403@mrabarnett.plus.com> On 26/01/2011 10:59, Xavier Heruacles wrote: > I have do some log processing which is usually huge. The length of each > line is variable. How can I get the last line?? Don't tell me to use > readlines or something like linecache... > Seek to somewhere near the end and then read use readlines(). If you get fewer than 2 lines then you can't be sure that you have the entire last line, so seek a little farther from the end and try again. From williem75 at gmail.com Wed Jan 26 16:25:04 2011 From: williem75 at gmail.com (williem75 at gmail.com) Date: Wed, 26 Jan 2011 15:25:04 -0600 Subject: Python-list Digest, Vol 88, Issue 69 Message-ID: Sent from my LG phone python-list-request at python.org wrote: >Send Python-list mailing list submissions to > python-list at python.org > >To subscribe or unsubscribe via the World Wide Web, visit > http://mail.python.org/mailman/listinfo/python-list >or, via email, send a message with subject or body 'help' to > python-list-request at python.org > >You can reach the person managing the list at > python-list-owner at python.org > >When replying, please edit your Subject line so it is more specific >than "Re: Contents of Python-list digest..." > >Today's Topics: > > 1. Re: Python use growing fast (Alice Bevan?McGregor) > 2. Re: order of importing modules (Chris Rebert) > 3. Re: How to Buffer Serialized Objects to Disk (MRAB) > 4. Re: How to Buffer Serialized Objects to Disk (Chris Rebert) > 5. Re: How to Buffer Serialized Objects to Disk (Peter Otten) > 6. Re: Best way to automatically copy out attachments from an > email (Chris Rebert) > 7. Re: Parsing string for " " (Aahz) > 8. Re: Nested structures question (Tim Harig) > 9. Re: How to Buffer Serialized Objects to Disk (Scott McCarty) > >On 2011-01-10 19:49:47 -0800, Roy Smith said: > >> One of the surprising (to me, anyway) uses of JavaScript is as the >> scripting language for MongoDB (http://www.mongodb.org/). > >I just wish they'd drop spidermonkey and go with V8 or another, faster >and more modern engine. :( > > - Alice. > > > > >> Dan Stromberg wrote: >>> On Tue, Jan 11, 2011 at 4:30 PM, Catherine Moroney >>> wrote: >>>> >>>> In what order does python import modules on a Linux system? ?I have a >>>> package that is both installed in /usr/lib64/python2.5/site-packages, >>>> and a newer version of the same module in a working directory. >>>> >>>> I want to import the version from the working directory, but when I >>>> print module.__file__ in the interpreter after importing the module, >>>> I get the version that's in site-packages. >>>> >>>> I've played with the PYTHONPATH environmental variable by setting it >>>> to just the path of the working directory, but when I import the module >>>> I still pick up the version in site-packages. >>>> >>>> /usr/lib64 is in my PATH variable, but doesn't appear anywhere else. ?I >>>> don't want to remove /usr/lib64 from my PATH because that will break >>>> a lot of stuff. >>>> >>>> Can I force python to import from my PYTHONPATH first, before looking >>>> in the system directory? >>>> >>> Please import sys and inspect sys.path; this defines the search path >>> for imports. >>> >>> By looking at sys.path, you can see where in the search order your >>> $PYTHONPATH is going. >>> >On Wed, Jan 12, 2011 at 11:07 AM, Catherine Moroney > wrote: >> I've looked at my sys.path variable and I see that it has >> a whole bunch of site-package directories, followed by the >> contents of my $PYTHONPATH variable, followed by a list of >> misc site-package variables (see below). > >> But, I'm curious as to where the first bunch of 'site-package' >> entries come from. ?The >> /usr/lib64/python2.5/site-packages/pyhdfeos-1.0_r57_58-py2.5-linux-x86_64.egg >> is not present in any of my environmental variables yet it shows up >> as one of the first entries in sys.path. > >You probably have a .pth file somewhere that adds it (since it's an >egg, probably site-packages/easy-install.pth). >See http://docs.python.org/install/index.html#modifying-python-s-search-path > >Cheers, >Chris >-- >http://blog.rebertia.com > > >On 12/01/2011 21:05, Scott McCarty wrote: >> Sorry to ask this question. I have search the list archives and googled, >> but I don't even know what words to find what I am looking for, I am >> just looking for a little kick in the right direction. >> >> I have a Python based log analysis program called petit >> (http://crunchtools.com/petit). I am trying to modify it to manage the >> main object types to and from disk. >> >> Essentially, I have one object which is a list of a bunch of "Entry" >> objects. The Entry objects have date, time, date, etc fields which I use >> for analysis techniques. At the very beginning I build up the list of >> objects then would like to start pickling it while building to save >> memory. I want to be able to process more entries than I have memory. >> With a strait list it looks like I could build from xreadlines(), but >> once you turn it into a more complex object, I don't quick know where to go. >> >> I understand how to pickle the entire data structure, but I need >> something that will manage the memory/disk allocation? Any thoughts? >> >To me it sounds like you need to use a database. > > >On Wed, Jan 12, 2011 at 1:05 PM, Scott McCarty wrote: >> Sorry to ask this question. I have search the list archives and googled, but >> I don't even know what words to find what I am looking for, I am just >> looking for a little kick in the right direction. >> I have a Python based log analysis program called petit >> (http://crunchtools.com/petit). I am trying to modify it to manage the main >> object types to and from disk. >> Essentially, I have one object which is a list of a bunch of "Entry" >> objects. The Entry objects have date, time, date, etc fields which I use for >> analysis techniques. At the very beginning I build up the list of objects >> then would like to start pickling it while building to save memory. I want >> to be able to process more entries than I have memory. With a strait list it >> looks like I could build from xreadlines(), but once you turn it into a more >> complex object, I don't quick know where to go. >> I understand how to pickle the entire data structure, but I need something >> that will manage the memory/disk allocation? ?Any thoughts? > >You could subclass `list` and use sys.getsizeof() >[http://docs.python.org/library/sys.html#sys.getsizeof ] to keep track >of the size of the elements, and then start pickling them to disk once >the total size reaches some preset limit. >But like MRAB said, using a proper database, e.g. SQLite >(http://docs.python.org/library/sqlite3.html ), wouldn't be a bad idea >either. > >Cheers, >Chris >-- >http://blog.rebertia.com > > >Scott McCarty wrote: > >> Sorry to ask this question. I have search the list archives and googled, >> but I don't even know what words to find what I am looking for, I am just >> looking for a little kick in the right direction. >> >> I have a Python based log analysis program called petit ( >> http://crunchtools.com/petit). I am trying to modify it to manage the main >> object types to and from disk. >> >> Essentially, I have one object which is a list of a bunch of "Entry" >> objects. The Entry objects have date, time, date, etc fields which I use >> for analysis techniques. At the very beginning I build up the list of >> objects then would like to start pickling it while building to save >> memory. I want to be able to process more entries than I have memory. With >> a strait list it looks like I could build from xreadlines(), but once you >> turn it into a more complex object, I don't quick know where to go. >> >> I understand how to pickle the entire data structure, but I need something >> that will manage the memory/disk allocation? Any thoughts? > >You can write multiple pickled objects into a single file: > >import cPickle as pickle > >def dump(filename, items): > with open(filename, "wb") as out: > dump = pickle.Pickler(out).dump > for item in items: > dump(item) > >def load(filename): > with open(filename, "rb") as instream: > load = pickle.Unpickler(instream).load > while True: > try: > item = load() > except EOFError: > break > yield item > >if __name__ == "__main__": > filename = "tmp.pickle" > from collections import namedtuple > T = namedtuple("T", "alpha beta") > dump(filename, (T(a, b) for a, b in zip("abc", [1,2,3]))) > for item in load(filename): > print item > >To get random access you'd have to maintain a list containing the offsets of >the entries in the file. >However, a simple database like SQLite is probably sufficient for the kind >of entries you have in mind, and it allows operations like aggregation, >sorting and grouping out of the box. > >Peter > > > >On Wed, Jan 12, 2011 at 10:59 AM, Matty Sarro wrote: >> As of now here is my situation: >> I am working on a system to aggregate IT data and logs. A number of >> important data are gathered by a third party system. The only >> immediate way I have to access the data is to have their system >> automatically email me updates in CSV format every hour. If I set up a >> mail client on the server, this shouldn't be a huge issue. >> >> However, is there a way to automatically open the emails, and copy the >> attachments to a directory based on the filename? Kind of a weird >> project, I know. Just looking for some ideas hence posting this on two >> lists. > >Parsing out email attachments: >http://docs.python.org/library/email.parser.html >http://docs.python.org/library/email.message.html#module-email.message > >Parsing the extension from a filename: >http://docs.python.org/library/os.path.html#os.path.splitext > >Retrieving email from a mail server: >http://docs.python.org/library/poplib.html >http://docs.python.org/library/imaplib.html > >You could poll for new messages via a cron job or the `sched` module >(http://docs.python.org/library/sched.html ). Or if the messages are >being delivered locally, you could use inotify bindings or similar to >watch the appropriate directory for incoming mail. Integration with a >mail server itself is also a possibility, but I don't know much about >that. > >Cheers, >Chris >-- >http://blog.rebertia.com > > >In article <0d7143ca-45cf-44c3-9e8d-acb867c52037 at f30g2000yqa.googlegroups.com>, >Daniel da Silva wrote: >> >>I have come across a task where I would like to scan a short 20-80 >>character line of text for instances of " ". Ideally >> could be of any tense. > >In Soviet Russia, you! >-- >Aahz (aahz at pythoncraft.com) <*> http://www.pythoncraft.com/ > >"Think of it as evolution in action." --Tony Rand > > >In case you still need help: > >- # Set the initial values >- the_number= random.randrange(100) + 1 >- tries = 0 >- guess = None >- >- # Guessing loop >- while guess != the_number and tries < 7: >- guess = int(raw_input("Take a guess: ")) >- if guess > the_number: >- print "Lower..." >- elif guess < the_number: >- print "Higher..." >- tries += 1 >- >- # did the user guess correctly to make too many guesses? >- if guess == the_number: >- print "You guessed it! The number was", the_number >- print "And it only took you", tries, "tries!\n" >- else: >- print "Wow you suck! It should only take at most 7 tries!" >- >- raw_input("Press Enter to exit the program.") > > >Been digging ever since I posted this. I suspected that the response might >be use a database. I am worried I am trying to reinvent the wheel. The >problem is I don't want any dependencies and I also don't need persistence >program runs. I kind of wanted to keep the use of petit very similar to cat, >head, awk, etc. But, that said, I have realized that if I provide the >analysis features as an API, you very well, might want persistence between >runs. > >What about using an array inside a shelve? > >Just got done messing with this in python shell: > >import shelve > >d = shelve.open(filename="/root/test.shelf", protocol=-1) > >d["log"] = () >d["log"].append("test1") >d["log"].append("test2") >d["log"].append("test3") > >Then, always interacting with d["log"], for example: > >for i in d["log"]: > print i > >Thoughts? > > >I know this won't manage memory, but it will keep the footprint down right? >On Wed, Jan 12, 2011 at 5:04 PM, Peter Otten <__peter__ at web.de> wrote: > >> Scott McCarty wrote: >> >> > Sorry to ask this question. I have search the list archives and googled, >> > but I don't even know what words to find what I am looking for, I am just >> > looking for a little kick in the right direction. >> > >> > I have a Python based log analysis program called petit ( >> > http://crunchtools.com/petit). I am trying to modify it to manage the >> main >> > object types to and from disk. >> > >> > Essentially, I have one object which is a list of a bunch of "Entry" >> > objects. The Entry objects have date, time, date, etc fields which I use >> > for analysis techniques. At the very beginning I build up the list of >> > objects then would like to start pickling it while building to save >> > memory. I want to be able to process more entries than I have memory. >> With >> > a strait list it looks like I could build from xreadlines(), but once you >> > turn it into a more complex object, I don't quick know where to go. >> > >> > I understand how to pickle the entire data structure, but I need >> something >> > that will manage the memory/disk allocation? Any thoughts? >> >> You can write multiple pickled objects into a single file: >> >> import cPickle as pickle >> >> def dump(filename, items): >> with open(filename, "wb") as out: >> dump = pickle.Pickler(out).dump >> for item in items: >> dump(item) >> >> def load(filename): >> with open(filename, "rb") as instream: >> load = pickle.Unpickler(instream).load >> while True: >> try: >> item = load() >> except EOFError: >> break >> yield item >> >> if __name__ == "__main__": >> filename = "tmp.pickle" >> from collections import namedtuple >> T = namedtuple("T", "alpha beta") >> dump(filename, (T(a, b) for a, b in zip("abc", [1,2,3]))) >> for item in load(filename): >> print item >> >> To get random access you'd have to maintain a list containing the offsets >> of >> the entries in the file. >> However, a simple database like SQLite is probably sufficient for the kind >> of entries you have in mind, and it allows operations like aggregation, >> sorting and grouping out of the box. >> >> Peter >> >> -- >> http://mail.python.org/mailman/listinfo/python-list >> > >-- >http://mail.python.org/mailman/listinfo/python-list From williem75 at gmail.com Wed Jan 26 16:25:26 2011 From: williem75 at gmail.com (williem75 at gmail.com) Date: Wed, 26 Jan 2011 15:25:26 -0600 Subject: Python-list Digest, Vol 88, Issue 69 Message-ID: Sent from my LG phone python-list-request at python.org wrote: >Send Python-list mailing list submissions to > python-list at python.org > >To subscribe or unsubscribe via the World Wide Web, visit > http://mail.python.org/mailman/listinfo/python-list >or, via email, send a message with subject or body 'help' to > python-list-request at python.org > >You can reach the person managing the list at > python-list-owner at python.org > >When replying, please edit your Subject line so it is more specific >than "Re: Contents of Python-list digest..." > >Today's Topics: > > 1. Re: Python use growing fast (Alice Bevan?McGregor) > 2. Re: order of importing modules (Chris Rebert) > 3. Re: How to Buffer Serialized Objects to Disk (MRAB) > 4. Re: How to Buffer Serialized Objects to Disk (Chris Rebert) > 5. Re: How to Buffer Serialized Objects to Disk (Peter Otten) > 6. Re: Best way to automatically copy out attachments from an > email (Chris Rebert) > 7. Re: Parsing string for " " (Aahz) > 8. Re: Nested structures question (Tim Harig) > 9. Re: How to Buffer Serialized Objects to Disk (Scott McCarty) > >On 2011-01-10 19:49:47 -0800, Roy Smith said: > >> One of the surprising (to me, anyway) uses of JavaScript is as the >> scripting language for MongoDB (http://www.mongodb.org/). > >I just wish they'd drop spidermonkey and go with V8 or another, faster >and more modern engine. :( > > - Alice. > > > > >> Dan Stromberg wrote: >>> On Tue, Jan 11, 2011 at 4:30 PM, Catherine Moroney >>> wrote: >>>> >>>> In what order does python import modules on a Linux system? ?I have a >>>> package that is both installed in /usr/lib64/python2.5/site-packages, >>>> and a newer version of the same module in a working directory. >>>> >>>> I want to import the version from the working directory, but when I >>>> print module.__file__ in the interpreter after importing the module, >>>> I get the version that's in site-packages. >>>> >>>> I've played with the PYTHONPATH environmental variable by setting it >>>> to just the path of the working directory, but when I import the module >>>> I still pick up the version in site-packages. >>>> >>>> /usr/lib64 is in my PATH variable, but doesn't appear anywhere else. ?I >>>> don't want to remove /usr/lib64 from my PATH because that will break >>>> a lot of stuff. >>>> >>>> Can I force python to import from my PYTHONPATH first, before looking >>>> in the system directory? >>>> >>> Please import sys and inspect sys.path; this defines the search path >>> for imports. >>> >>> By looking at sys.path, you can see where in the search order your >>> $PYTHONPATH is going. >>> >On Wed, Jan 12, 2011 at 11:07 AM, Catherine Moroney > wrote: >> I've looked at my sys.path variable and I see that it has >> a whole bunch of site-package directories, followed by the >> contents of my $PYTHONPATH variable, followed by a list of >> misc site-package variables (see below). > >> But, I'm curious as to where the first bunch of 'site-package' >> entries come from. ?The >> /usr/lib64/python2.5/site-packages/pyhdfeos-1.0_r57_58-py2.5-linux-x86_64.egg >> is not present in any of my environmental variables yet it shows up >> as one of the first entries in sys.path. > >You probably have a .pth file somewhere that adds it (since it's an >egg, probably site-packages/easy-install.pth). >See http://docs.python.org/install/index.html#modifying-python-s-search-path > >Cheers, >Chris >-- >http://blog.rebertia.com > > >On 12/01/2011 21:05, Scott McCarty wrote: >> Sorry to ask this question. I have search the list archives and googled, >> but I don't even know what words to find what I am looking for, I am >> just looking for a little kick in the right direction. >> >> I have a Python based log analysis program called petit >> (http://crunchtools.com/petit). I am trying to modify it to manage the >> main object types to and from disk. >> >> Essentially, I have one object which is a list of a bunch of "Entry" >> objects. The Entry objects have date, time, date, etc fields which I use >> for analysis techniques. At the very beginning I build up the list of >> objects then would like to start pickling it while building to save >> memory. I want to be able to process more entries than I have memory. >> With a strait list it looks like I could build from xreadlines(), but >> once you turn it into a more complex object, I don't quick know where to go. >> >> I understand how to pickle the entire data structure, but I need >> something that will manage the memory/disk allocation? Any thoughts? >> >To me it sounds like you need to use a database. > > >On Wed, Jan 12, 2011 at 1:05 PM, Scott McCarty wrote: >> Sorry to ask this question. I have search the list archives and googled, but >> I don't even know what words to find what I am looking for, I am just >> looking for a little kick in the right direction. >> I have a Python based log analysis program called petit >> (http://crunchtools.com/petit). I am trying to modify it to manage the main >> object types to and from disk. >> Essentially, I have one object which is a list of a bunch of "Entry" >> objects. The Entry objects have date, time, date, etc fields which I use for >> analysis techniques. At the very beginning I build up the list of objects >> then would like to start pickling it while building to save memory. I want >> to be able to process more entries than I have memory. With a strait list it >> looks like I could build from xreadlines(), but once you turn it into a more >> complex object, I don't quick know where to go. >> I understand how to pickle the entire data structure, but I need something >> that will manage the memory/disk allocation? ?Any thoughts? > >You could subclass `list` and use sys.getsizeof() >[http://docs.python.org/library/sys.html#sys.getsizeof ] to keep track >of the size of the elements, and then start pickling them to disk once >the total size reaches some preset limit. >But like MRAB said, using a proper database, e.g. SQLite >(http://docs.python.org/library/sqlite3.html ), wouldn't be a bad idea >either. > >Cheers, >Chris >-- >http://blog.rebertia.com > > >Scott McCarty wrote: > >> Sorry to ask this question. I have search the list archives and googled, >> but I don't even know what words to find what I am looking for, I am just >> looking for a little kick in the right direction. >> >> I have a Python based log analysis program called petit ( >> http://crunchtools.com/petit). I am trying to modify it to manage the main >> object types to and from disk. >> >> Essentially, I have one object which is a list of a bunch of "Entry" >> objects. The Entry objects have date, time, date, etc fields which I use >> for analysis techniques. At the very beginning I build up the list of >> objects then would like to start pickling it while building to save >> memory. I want to be able to process more entries than I have memory. With >> a strait list it looks like I could build from xreadlines(), but once you >> turn it into a more complex object, I don't quick know where to go. >> >> I understand how to pickle the entire data structure, but I need something >> that will manage the memory/disk allocation? Any thoughts? > >You can write multiple pickled objects into a single file: > >import cPickle as pickle > >def dump(filename, items): > with open(filename, "wb") as out: > dump = pickle.Pickler(out).dump > for item in items: > dump(item) > >def load(filename): > with open(filename, "rb") as instream: > load = pickle.Unpickler(instream).load > while True: > try: > item = load() > except EOFError: > break > yield item > >if __name__ == "__main__": > filename = "tmp.pickle" > from collections import namedtuple > T = namedtuple("T", "alpha beta") > dump(filename, (T(a, b) for a, b in zip("abc", [1,2,3]))) > for item in load(filename): > print item > >To get random access you'd have to maintain a list containing the offsets of >the entries in the file. >However, a simple database like SQLite is probably sufficient for the kind >of entries you have in mind, and it allows operations like aggregation, >sorting and grouping out of the box. > >Peter > > > >On Wed, Jan 12, 2011 at 10:59 AM, Matty Sarro wrote: >> As of now here is my situation: >> I am working on a system to aggregate IT data and logs. A number of >> important data are gathered by a third party system. The only >> immediate way I have to access the data is to have their system >> automatically email me updates in CSV format every hour. If I set up a >> mail client on the server, this shouldn't be a huge issue. >> >> However, is there a way to automatically open the emails, and copy the >> attachments to a directory based on the filename? Kind of a weird >> project, I know. Just looking for some ideas hence posting this on two >> lists. > >Parsing out email attachments: >http://docs.python.org/library/email.parser.html >http://docs.python.org/library/email.message.html#module-email.message > >Parsing the extension from a filename: >http://docs.python.org/library/os.path.html#os.path.splitext > >Retrieving email from a mail server: >http://docs.python.org/library/poplib.html >http://docs.python.org/library/imaplib.html > >You could poll for new messages via a cron job or the `sched` module >(http://docs.python.org/library/sched.html ). Or if the messages are >being delivered locally, you could use inotify bindings or similar to >watch the appropriate directory for incoming mail. Integration with a >mail server itself is also a possibility, but I don't know much about >that. > >Cheers, >Chris >-- >http://blog.rebertia.com > > >In article <0d7143ca-45cf-44c3-9e8d-acb867c52037 at f30g2000yqa.googlegroups.com>, >Daniel da Silva wrote: >> >>I have come across a task where I would like to scan a short 20-80 >>character line of text for instances of " ". Ideally >> could be of any tense. > >In Soviet Russia, you! >-- >Aahz (aahz at pythoncraft.com) <*> http://www.pythoncraft.com/ > >"Think of it as evolution in action." --Tony Rand > > >In case you still need help: > >- # Set the initial values >- the_number= random.randrange(100) + 1 >- tries = 0 >- guess = None >- >- # Guessing loop >- while guess != the_number and tries < 7: >- guess = int(raw_input("Take a guess: ")) >- if guess > the_number: >- print "Lower..." >- elif guess < the_number: >- print "Higher..." >- tries += 1 >- >- # did the user guess correctly to make too many guesses? >- if guess == the_number: >- print "You guessed it! The number was", the_number >- print "And it only took you", tries, "tries!\n" >- else: >- print "Wow you suck! It should only take at most 7 tries!" >- >- raw_input("Press Enter to exit the program.") > > >Been digging ever since I posted this. I suspected that the response might >be use a database. I am worried I am trying to reinvent the wheel. The >problem is I don't want any dependencies and I also don't need persistence >program runs. I kind of wanted to keep the use of petit very similar to cat, >head, awk, etc. But, that said, I have realized that if I provide the >analysis features as an API, you very well, might want persistence between >runs. > >What about using an array inside a shelve? > >Just got done messing with this in python shell: > >import shelve > >d = shelve.open(filename="/root/test.shelf", protocol=-1) > >d["log"] = () >d["log"].append("test1") >d["log"].append("test2") >d["log"].append("test3") > >Then, always interacting with d["log"], for example: > >for i in d["log"]: > print i > >Thoughts? > > >I know this won't manage memory, but it will keep the footprint down right? >On Wed, Jan 12, 2011 at 5:04 PM, Peter Otten <__peter__ at web.de> wrote: > >> Scott McCarty wrote: >> >> > Sorry to ask this question. I have search the list archives and googled, >> > but I don't even know what words to find what I am looking for, I am just >> > looking for a little kick in the right direction. >> > >> > I have a Python based log analysis program called petit ( >> > http://crunchtools.com/petit). I am trying to modify it to manage the >> main >> > object types to and from disk. >> > >> > Essentially, I have one object which is a list of a bunch of "Entry" >> > objects. The Entry objects have date, time, date, etc fields which I use >> > for analysis techniques. At the very beginning I build up the list of >> > objects then would like to start pickling it while building to save >> > memory. I want to be able to process more entries than I have memory. >> With >> > a strait list it looks like I could build from xreadlines(), but once you >> > turn it into a more complex object, I don't quick know where to go. >> > >> > I understand how to pickle the entire data structure, but I need >> something >> > that will manage the memory/disk allocation? Any thoughts? >> >> You can write multiple pickled objects into a single file: >> >> import cPickle as pickle >> >> def dump(filename, items): >> with open(filename, "wb") as out: >> dump = pickle.Pickler(out).dump >> for item in items: >> dump(item) >> >> def load(filename): >> with open(filename, "rb") as instream: >> load = pickle.Unpickler(instream).load >> while True: >> try: >> item = load() >> except EOFError: >> break >> yield item >> >> if __name__ == "__main__": >> filename = "tmp.pickle" >> from collections import namedtuple >> T = namedtuple("T", "alpha beta") >> dump(filename, (T(a, b) for a, b in zip("abc", [1,2,3]))) >> for item in load(filename): >> print item >> >> To get random access you'd have to maintain a list containing the offsets >> of >> the entries in the file. >> However, a simple database like SQLite is probably sufficient for the kind >> of entries you have in mind, and it allows operations like aggregation, >> sorting and grouping out of the box. >> >> Peter >> >> -- >> http://mail.python.org/mailman/listinfo/python-list >> > >-- >http://mail.python.org/mailman/listinfo/python-list From williem75 at gmail.com Wed Jan 26 16:25:54 2011 From: williem75 at gmail.com (williem75 at gmail.com) Date: Wed, 26 Jan 2011 15:25:54 -0600 Subject: Python-list Digest, Vol 88, Issue 67 Message-ID: Sent from my LG phone python-list-request at python.org wrote: >Send Python-list mailing list submissions to > python-list at python.org > >To subscribe or unsubscribe via the World Wide Web, visit > http://mail.python.org/mailman/listinfo/python-list >or, via email, send a message with subject or body 'help' to > python-list-request at python.org > >You can reach the person managing the list at > python-list-owner at python.org > >When replying, please edit your Subject line so it is more specific >than "Re: Contents of Python-list digest..." > >Today's Topics: > > 1. Re: Python use growing fast (Colin J. Williams) > 2. Career path - where next? (Alan Harris-Reid) > 3. Re: Career path - where next? (Terry Reedy) > 4. Re: Python use growing fast (Terry Reedy) > 5. Re: Ideas for a module to process command line arguments > (Alice Bevan?McGregor) > 6. Re: Python use growing fast (Krzysztof Bieniasz) > 7. Re: Career path - where next? (Jon Clements) > 8. Re: Career path - where next? (Philip Semanchuk) > 9. Best way to automatically copy out attachments from an email > (Matty Sarro) > 10. How to populate all possible hierarchical clusterings from a > set of elements? (justin) > >On 10-Jan-11 16:02 PM, MRAB wrote: >> On 10/01/2011 20:29, Dan Stromberg wrote: >>> I invite folks to check out Tiobe's Language Popularity Rankings: >>> >>> http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html >>> >>> The gist is: Python grew faster than any other programming language >>> over the last year, according to this (slightly arbitrary, but better >>> than no indicator) ranking. >>> >>> ...despite our wikipedia page whose first paragraph almost seems like >>> it was written with the intention of scaring off new converts, with >>> its "unusual" comment: >>> >>> http://en.wikipedia.org/wiki/Python_%28programming_language%29 >>> >>> (Like it or not, people do frequently confuse the descriptive for the >>> normative) >> >> It shows an example of Python code, which happens to have 2 syntax >> errors! > >Why not correct the Wikipedia entry? > >Colin W. > > > >Hi there, I wonder if any Python folk out there can help me. > >For many years I was a contractor developing desktop and web >applications using Visual Foxpro as my main language, with Foxpro, >SQL-server and Oracle as back-end databases. Unfortunately Foxpro was >killed-off by Microsoft, hence my work dried-up and my last 'big' >contract ended about a year ago. Since then I have taken time off >programming doing house-renovation, and in the last 6 months I have been >updating my programming skills by learning Python (3) with SQLite, >JavaScript, HTML and CSS to a level where I can create and deploy >data-based web-sites. > >My situation now is that I am reasonably comfortable with the above >languages and am now in a position where I wish to return to employment >using my new and/or existing skills (contract/permanent, full/part-time >or teleworking). However, I have yet to find any UK vacancy which will >accept a relative 'beginner' - they all require at least 2-3 years >Python in a commercial environment. It's a catch-22 situation - it's >hard to get a job without experience, but you need a job to get >experience in the 1st place! > >I would even consider doing small projects for nothing so that I can >'get my foot in the door' (although I hope to be wise-enough to know >when I am being taken advantage of!). I am also mailing CVs to agencies >I think may be interested. > >If anyone out has ideas as to how to proceed towards achieving my goal, >I would be grateful for any advice. > >Regards, >Alan Harris-Reid > > > >On 1/12/2011 11:37 AM, Alan Harris-Reid wrote: > >... >> updating my programming skills by learning Python (3) with SQLite, >> JavaScript, HTML and CSS to a level where I can create and deploy >> data-based web-sites. >... >> I would even consider doing small projects for nothing so that I can >> 'get my foot in the door' (although I hope to be wise-enough to know > >I believe both Roundup/Python tracker and PyPI (Python package index) >are based on sqlite and have small projects available/needed. I cannot >help you otherwise. Good luck. > >-- >Terry Jan Reedy > > > >On 1/12/2011 9:51 AM, Colin J. Williams wrote: > >>> It shows an example of Python code, which happens to have 2 syntax >>> errors! >> >> Why not correct the Wikipedia entry? > >As I reported early, the errors, if any, are in .png and .svg images of >text, which would have to be replaced, not corrected. Would be good >since the imaged snippet is a haphazard except from a much larger file >and inane out of context. > >-- >Terry Jan Reedy > > > >On 2011-01-11 21:41:24 -0800, Michele Simionato said: > >> Originally plac too was able to recognize flags automatically by >> looking at the default value (if the default value is a boolean then >> the option is a flag); however I removed that functionality because I >> wanted to be able to differentiate between flag and (smart) options >> (see >> http://micheles.googlecode.com/hg/plac/doc/plac.html#scripts-with-options-and-smart-options). > >Not >> >entirely sure what you mean by 'smart' options. If your'e referring to >using a single hyphen and a list of characters to represent a long >option (which, to the rest of the world, use two leading hyphens) then >that's pretty weird. ;) > >Consider most of the GNU tools: > > ls -lvh > tar -xzvf file.tgz (goes so far as to make the leading hyphen optional!) > less -ceF logfile > bc -qw > ps -aux (same as tar) > >And even third-party tools: > > mysql -fH > pg_dump -abO ... > >One major system in the world that doesn't really differentiate between >long and short options is... DOS, and by extension, Windows. But they >also use / as a switch character. > >Anyway; I'm happy with what I have wrought (and am continuing to update >with support for class-based sub-command dispatch) and will be >utilizing it for all scripts in the Marrow suite. To each their own, >but reinvention itself can be for motivations other than NIH. I wanted >something pure-Python, portable across the 3k barrier without code >modification (no 2to3), that didn't use optparse, getopt, or argparse >and basically be a translation layer. It can be simpler than that, as >marrow.script demonstrates. > > - Alice. > > > > >> As I reported early, the errors, if any, are in .png and .svg images of >> text, which would have to be replaced, not corrected. Would be good >> since the imaged snippet is a haphazard except from a much larger file >> and inane out of context. > >I don't think it really is a big deal. I mean, this is merely an >illustration for the syntax-highlighted python code. So the message >isn't: "Go ahead and try it with your Python". It's rather "Look, you can >have colorful highlighting of python code, isn't that cool?!" It actually >presents the specific indentation of Python code and therefore it is >mostly useful to someone who never used Python. And actually I wouldn't >expect any Python programmer to look for feedback on Wikipedia. It's not >that I have anything against Wikipedia -- on the contrary, I use it all >the time. But remember that it's an encyclopedia not a Python manual. > > >On Jan 12, 4:37?pm, Alan Harris-Reid >wrote: >> Hi there, I wonder if any Python folk out there can help me. >> >> For many years I was a contractor developing desktop and web >> applications using Visual Foxpro as my main language, with Foxpro, >> SQL-server and Oracle as back-end databases. ?Unfortunately Foxpro was >> killed-off by Microsoft, hence my work dried-up and my last 'big' >> contract ended about a year ago. ?Since then I have taken time off >> programming doing house-renovation, and in the last 6 months I have been >> updating my programming skills by learning Python (3) with SQLite, >> JavaScript, HTML and CSS to a level where I can create and deploy >> data-based web-sites. >> >> My situation now is that I am reasonably comfortable with the above >> languages and am now in a position where I wish to return to employment >> using my new and/or existing skills (contract/permanent, full/part-time >> or teleworking). ? However, I have yet to find any UK vacancy which will >> accept a relative 'beginner' - they all require at least 2-3 years >> Python in a commercial environment. ?It's a catch-22 situation - it's >> hard to get a job without experience, but you need a job to get >> experience in the 1st place! >> >> I would even consider doing small projects for nothing so that I can >> 'get my foot in the door' (although I hope to be wise-enough to know >> when I am being taken advantage of!). ?I am also mailing CVs to agencies >> I think may be interested. >> >> If anyone out has ideas as to how to proceed towards achieving my goal, >> I would be grateful for any advice. >> >> Regards, >> Alan Harris-Reid > >Hi Alan, > >Just some ideas (not in any order, just as they're thought of):- > >- Emphasise your experience with Oracle & SQL Server, and use Python >as a "I also have". It may be someone will accept that as viable >(saves them a DBA or something), and maybe you'll get into an >experienced group and get on the job training. (I assume you have good >SQL skills). > >- Look at cwjobs.co.uk / monster / etc..., and search for Python. Get >a list of agencies there. Phone them *first*, explain what is it >you've done, and what you can do. If the person seems to know what >they're talking about send your CV - but chase often. > >- Look at web-frameworks. Django seems to be the most listed for >"required"/"nice to have". Also check out javascript-frameworks - >jquery & extjs are the biggest 2, so at least you can say you've had >some experience. > >- Perhaps phone your local job centre, and ask for a contact for their >local volunteer centre. They might have something like work for a >small charity that just needs a couple of pages done. The idea being: >1) If it's a cause you believe in, it makes up for not getting paid; >2) You can use it as an example and reference; 3) You might be able to >use it as networking - might get a free lunch from an event and meet >someone with money, that's impressed with your good will and work, and >just happens to have a job going spare... > >- Build a copy of your CV designed for the web. Make sure it looks >good, is HTML/CSS compliant, and even add some nice interactive stuff >to it, and include it as a link in your CV. [The other thing you can >do, is only display the CV on entry of a short PIN (different for each >one you send - '2431' or something'), then you can log who's bothered >looking at it, and when, enabling timing of a follow-up better)]. > >- Look in local papers for local companies that offer not necessarily >web design, but possibly just print design. See if you can't have a >chat with them and get some work your way. Other options might be new- >starts up, non-chain pubs, community/sports clubs, a local church for >fund-raising, your local chinese/indian takeaway - wouldn't hurt to >put their menu online with an online order form would it!? [What you >might find about this, is that as they're not likely to be technical, >you can take your own time, charge a reasonable amount, experiment a >little and learn, and not have too tight deadlines or someone looking >over your shoulder]. > >Brain (or somewhere else) dump finished. > >hth > >Jon. > > > > >On Jan 12, 2011, at 11:37 AM, Alan Harris-Reid wrote: > >> >> Hi there, I wonder if any Python folk out there can help me. >> >> For many years I was a contractor developing desktop and web applications using Visual Foxpro as my main language, with Foxpro, SQL-server and Oracle as back-end databases. Unfortunately Foxpro was killed-off by Microsoft, hence my work dried-up and my last 'big' contract ended about a year ago. Since then I have taken time off programming doing house-renovation, and in the last 6 months I have been updating my programming skills by learning Python (3) with SQLite, JavaScript, HTML and CSS to a level where I can create and deploy data-based web-sites. >> >> My situation now is that I am reasonably comfortable with the above languages and am now in a position where I wish to return to employment using my new and/or existing skills (contract/permanent, full/part-time or teleworking). However, I have yet to find any UK vacancy which will accept a relative 'beginner' - they all require at least 2-3 years Python in a commercial environment. It's a catch-22 situation - it's hard to get a job without experience, but you need a job to get experience in the 1st place! >> >> I would even consider doing small projects for nothing so that I can 'get my foot in the door' (although I hope to be wise-enough to know when I am being taken advantage of!). I am also mailing CVs to agencies I think may be interested. >> >> If anyone out has ideas as to how to proceed towards achieving my goal, I would be grateful for any advice. > >Contributing to open source projects (your own or someone else's) will help to convince some employers that you're worth taking a look at. If nothing else it gives you a public example of the work that you can point them to. > >Good luck >Philip > >As of now here is my situation: >I am working on a system to aggregate IT data and logs. A number of >important data are gathered by a third party system. The only >immediate way I have to access the data is to have their system >automatically email me updates in CSV format every hour. If I set up a >mail client on the server, this shouldn't be a huge issue. > >However, is there a way to automatically open the emails, and copy the >attachments to a directory based on the filename? Kind of a weird >project, I know. Just looking for some ideas hence posting this on two >lists. > >Thanks all, and happy hump day! >-Matty > > >The title sounds too complex, but my question is actually simple. > >Suppose I have [1,2,3,4,5], then there are many ways of making >clustering. >Among them, I want to pair up terminals until there is only one left >at the end. >For example, ((((1,2),3),4),5), (1,(2,(3,(4,5)))), or (((1,2),(3,4)), >5) would be legitimate ones. > >How do you think can I, using the modules of Python such as itertools >as much as possible, make all possible such clusterings? > >Thanks in advance, >Justin. > > >-- >http://mail.python.org/mailman/listinfo/python-list From me+list/python at ixokai.io Wed Jan 26 16:33:15 2011 From: me+list/python at ixokai.io (Stephen Hansen) Date: Wed, 26 Jan 2011 13:33:15 -0800 Subject: Return Statement In-Reply-To: References: Message-ID: <4D40931B.5030003@ixokai.io> On 1/26/11 12:26 PM, sl33k_ wrote: > How does "return True" and "return False" affect the execution of the > calling function? It doesn't -- the value 'True' or 'False' is simply returned, and assigned to a name if the calling function does so explicitly. But there's no built in affects. If you want it to alter the execution, you have to do so yourself, i.e.: def myfun(): return True def myfun2(): return False if myfun(): print "Something is true!" myfun2() print "I'm called. Cuz, the return value of myfun2 was simply discarded." -- Stephen Hansen ... Also: Ixokai ... Mail: me+list/python (AT) ixokai (DOT) io ... Blog: http://meh.ixokai.io/ -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 487 bytes Desc: OpenPGP digital signature URL: From kb1pkl at aim.com Wed Jan 26 16:34:43 2011 From: kb1pkl at aim.com (Corey Richardson) Date: Wed, 26 Jan 2011 16:34:43 -0500 Subject: WxPython versus Tkinter. In-Reply-To: <7F4FDC467BCF47D4A069B29246FBDB17@octavian> References: <4D3E4377.3060807@tysdomain.com><9MB%o.14110$%64.6074@unlimited.newshosting.com><59F6E65E3D9A46AD8D7A3863F3C1DC84@teddy> <27f53f8c-7862-4366-9352-82ae9a2f3970@k3g2000yqc.googlegroups.com> <7F4FDC467BCF47D4A069B29246FBDB17@octavian> Message-ID: <4D409373.80908@aim.com> On 01/26/2011 01:18 AM, Octavian Rasnita wrote: > From: "rantingrick" > On Jan 25, 3:41 pm, Corey Richardson wrote: > >> Do you honestly think he was talking about the accessibility problem? >> IMO that should move to another thread, because this one is simply >> about, as the subject suggests, "WxPython versus Tkinter". > > Corey again (like many) you lack a global perspective. Anybody who has > read along with his thread knows we are covering some pretty big > issues here. WxPython is just the vehicle. The big picture is simply: > Tkinter is old and in many ways insufficient for 21st century GUIs. We > need to decide what should come next. I believe wxPython is our best > hope. Wx may not be the best it can be, but it is the best we have at > this time. There is more than "meets the eye" Corey! I think he was referring to the large amount of trolling and immature behaviour displayed. It would be a horrible thing to think that accessibility is _bad_, unless of course it takes away from usability to sighted users or is tons harder to implement (the technical reasons you mentioned earlier). I understand that this thread is about the deficiencies of Tkinter (and many other GUI toolkits) and that Wx is far better than lots of what we have (but still has its issues). I personally despise writing GUI's, but I do it when I have to. I'm a fan of tkinter and wx because they are (in my very little experience) very easy to use. The issue I was raising with your post was really context. He wasn't bashing specifically on accessibility or a toolkit, but more of the attitudes and overall tone of some of the posts. Hope that cleared it up for you. (This would be a good time for python-gui to be opened up IMO, since it appears lots of discussion is being generated) ~Corey From brendan.simon at etrix.com.au Wed Jan 26 16:35:43 2011 From: brendan.simon at etrix.com.au (Brendan Simon (eTRIX)) Date: Thu, 27 Jan 2011 08:35:43 +1100 Subject: WxPython versus Tkinter. In-Reply-To: References: Message-ID: <4D4093AF.80806@etrix.com.au> Since it seems the python motto is "Batteries included", then it would seem to me that wxPython is the natural fit as it also has "Batteries included" (e.g. accessibility, native look-n-feel, mature and evolving, can produce simple or complex gui programs, etc, etc). -- Brendan Simon www.etrix.com.au From ben+python at benfinney.id.au Wed Jan 26 16:36:51 2011 From: ben+python at benfinney.id.au (Ben Finney) Date: Thu, 27 Jan 2011 08:36:51 +1100 Subject: Is it possible to pass CSV Reader Object As Argument to another Python File ??? References: <2c35653e-3565-48c6-8939-b6b09b885e3f@d23g2000prj.googlegroups.com> <876b6c52-1a6d-4afa-83e9-fa987c9359a5@v31g2000pri.googlegroups.com> Message-ID: <87lj272vpo.fsf@benfinney.id.au> bansi writes: > Thanks Chris. Sorry for mis-communicating, the two python scripts are > dependant in a way that namelookupWrapper.py needs to pass csv record > object to another python script Why have you structured them that way, though? What constraint is keeping you from doing the work in a single process, where the CSV reader object can be shared? > If thats not possible then please let me know how to do the workaround > i didnt understood the import thing and not sure if it helps in my > case The problem as you've described it so far is best solved by having a single process accessing the CSV reader object in memory. If that doesn't suit your use case, you'll need to explain why not. -- \ ?To have the choice between proprietary software packages, is | `\ being able to choose your master. Freedom means not having a | _o__) master.? ?Richard M. Stallman, 2007-05-16 | Ben Finney From alan.isaac at gmail.com Wed Jan 26 16:37:20 2011 From: alan.isaac at gmail.com (Alan) Date: Wed, 26 Jan 2011 13:37:20 -0800 (PST) Subject: use class factory to set required class variables? Message-ID: I have a class ``A`` that is intentionally incomplete: it has methods that refer to class variables that do not exist. The class ``A`` has several complicated methods, a number of which reference the "missing" class variables. Obviously, I do not directly use ``A``. I have a class factory ``f``` that subclasses ``A`` *only* in order to define the class variables. The motivation/problem: I did this because I need many versions of class ``A``, which differ only in the class variables, which are not known until run time. Q: On the face of it, did I pick a reasonable solution to my problem? If so is this a standard pattern? If not, can you mention a better approach? My solution is working for me, but the class ``A`` is bugging me, because of the odd (to me) way in which it is incomplete. Obviously, I'm not a computer science type ... Thanks, Alan Isaac From k.bx at ya.ru Wed Jan 26 16:40:01 2011 From: k.bx at ya.ru (kost BebiX) Date: Wed, 26 Jan 2011 23:40:01 +0200 Subject: how to read the last line of a huge file??? In-Reply-To: References: Message-ID: <132701296078004@web19.yandex.ru> 26.01.2011, 12:59, "Xavier Heruacles" : > I have do some log processing which is usually huge. The length of each line is variable. How can I get the last line?? Don't tell me to use readlines or something like linecache... -- > http://mail.python.org/mailman/listinfo/python-list Well, it's very simple. Don't store the whole log in one file. Create new one and archive the old one every night. You will also get a lot of free space this way. Or store it in some MongoDB's capped collection. It's fast and queryable (if you need). Good luck! -- jabber: k.bx at ya.ru From emile at fenx.com Wed Jan 26 16:41:47 2011 From: emile at fenx.com (Emile van Sebille) Date: Wed, 26 Jan 2011 13:41:47 -0800 Subject: Return Statement In-Reply-To: References: Message-ID: On 1/26/2011 12:26 PM sl33k_ said... > How does "return True" and "return False" affect the execution of the > calling function? That depends on the calling function. It will control what it does next generally based on the returned value, but it could also simply store the result. def isACustomer(custID): 1 return custID in currentCustList def isActive(custId): 2 return custID in openInvoicesByCustID for custID in custList: 3 if isACustomer(custID): 4 activeFlag = isActive(custID) Here, 1 and 2 return True or False depending on the inclusion test. 3 causes the subsequent code block to be executed when True is returned 4 stores True of False in activeFlag for subsequent use. Emile From alan.isaac at gmail.com Wed Jan 26 16:45:54 2011 From: alan.isaac at gmail.com (Alan) Date: Wed, 26 Jan 2011 13:45:54 -0800 (PST) Subject: use class factory to set required class variables? References: Message-ID: <6a08e86a-b400-4d11-b440-f7888f99b8c3@f21g2000prn.googlegroups.com> On Jan 26, 4:37?pm, Alan wrote: > I have a class factory ``f``` that subclasses ``A`` *only* in > order to define the class variables. I suppose it would be clearer to say that `f` *returns* subclasses of `A`. Hopefully that was clear ... Alan Isaac From alex.kapps at web.de Wed Jan 26 16:46:02 2011 From: alex.kapps at web.de (Alexander Kapps) Date: Wed, 26 Jan 2011 22:46:02 +0100 Subject: Return Statement In-Reply-To: References: Message-ID: <4D40961A.1050206@web.de> On 26.01.2011 21:26, sl33k_ wrote: > How does "return True" and "return False" affect the execution of the > calling function? If only affects the calling function if you use the return value: def foo(): return True def bar1(): foo() # nothing difference, whether foo() returns True or False def bar2() if foo(): print "foo returned True or any other non-false value" else: print "foo returned False or any other non-True value" From invalid at invalid.invalid Wed Jan 26 16:48:02 2011 From: invalid at invalid.invalid (Grant Edwards) Date: Wed, 26 Jan 2011 21:48:02 +0000 (UTC) Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com> <9MB%o.14110$%64.6074@unlimited.newshosting.com> <4A48EDF6D7634F2E994661A457451E87@teddy> <753A4C5A6658470085804B13C80340F2@octavian> Message-ID: On 2011-01-26, Octavian Rasnita wrote: > From: "geremy condra" >> At least 40% of my coworkers do not speak English as their native >> language. Your problem is not the language. Your problem is your >> attitude. > > The atitude considered nice is just duplicity for convincing others, > and I don't like duplicity. And, based on your behavior, you apparently don't like convincing others or advancing the cause of accessibility. It seems you prefer to annoy and alienate others. > I like to know exactly what the people think and I want them know > what I think. That can be accomplished in a polite and respectful manner. You claim to be advocating for , and trying to accomplish , yet your actions indicate the opposite by their counter-productive nature. > I don't want to convince anyone, but I just want to inform the others > and let them know if they are doing something not recommended. IOW, you don't really care about increasing accessibility, you just want to hear the sound of your own voice as you shout into the wind. If you actually cared about accessibility for the handicapped, you would care about convincing others to care also -- because that's the only way the situation can be improved. > I agree, telling the people that they are doing something wrong, > directly, without sugar, might be considered a bad atitude by those > who prefer duplicity and nice words just for the sake of socializing, > but is that atitude worst than of those who don't care about > discriminatory practices? Yes, it is worse. People who don't care are neither helping nor hurting your cause. However, you're actively hurting it. People will not separate your personality from the cause you espouse. You may not like it, but that's a fact. If you are in favor of XYZ, and act rude and insulting while espousing XYZ, people will react against not only you but _also_ XYZ. You can claim that's neither "right" nor "fair" nor "good" nor whatever. But it's a fact -- just like gravity. You may not like it or find it convenient. But if you insist on ignoring it you're just going to crash into the ground over and over and over again. -- Grant Edwards grant.b.edwards Yow! I smell a RANCID at CORN DOG! gmail.com From mpnordland at gmail.com Wed Jan 26 16:50:01 2011 From: mpnordland at gmail.com (mpnordland) Date: Wed, 26 Jan 2011 16:50:01 -0500 Subject: replacing lines in a file Message-ID: Attached are a config file parser that i'm working on, and a example config file. Basically, what my problem is is in write_config, it should search through the file, and replace the lines with whatever the modified version is, it is also designed to ignore comments. To see my problem (which is hard to describe) please first look at the config file, and then run config-parse.py then look at the config file again. One of two things should happen: nothing, or something weird should happen on the last line. -------------- next part -------------- A non-text attachment was scrubbed... Name: config-parse.py Type: text/x-python Size: 1382 bytes Desc: not available URL: -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: net-responsibility.conf2 URL: From ben+python at benfinney.id.au Wed Jan 26 16:51:55 2011 From: ben+python at benfinney.id.au (Ben Finney) Date: Thu, 27 Jan 2011 08:51:55 +1100 Subject: Return Statement References: Message-ID: <87hbcv2v0k.fsf@benfinney.id.au> sl33k_ writes: > How does "return True" and "return False" affect the execution of the > calling function? The object ?True?, or the object ?False?, is returned to the calling statement, and the function call evaluates to that return value. That may sound facetious, but it's as specific as I can be without knowing what aspect of the return semantics are confusing you. You will probably find great benefit in working through the entire Python tutorial . Not just read, but *do*: perform each example, experiment with each section until you understand it, and only then go on. -- \ ?Ladies, leave your clothes here and spend the afternoon having | `\ a good time.? ?laundry, Rome | _o__) | Ben Finney From mpnordland at gmail.com Wed Jan 26 16:56:05 2011 From: mpnordland at gmail.com (mpnordland) Date: Wed, 26 Jan 2011 16:56:05 -0500 Subject: Return Statement In-Reply-To: References: Message-ID: On 01/26/2011 03:26 PM, sl33k_ wrote: > How does "return True" and "return False" affect the execution of the > calling function? Basically it will affect it in whatever way you design it to for example: def lie_test(statement): if statement is True: return False else: return False Now, this is psuedo code somewhat. "if statement is True:" would always equate to "True" unless statement was an empty string, None, or 0. As to return False if statement equals true, look at the function name. It is testing to see if it is a lie, and if it is true, then it's not a lie. From tjreedy at udel.edu Wed Jan 26 16:57:20 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Wed, 26 Jan 2011 16:57:20 -0500 Subject: Bugs/issues in tkinter.simpledialog!! In-Reply-To: <412e4d83-f750-441d-bfc5-d96c0559e069@e9g2000prn.googlegroups.com> References: <412e4d83-f750-441d-bfc5-d96c0559e069@e9g2000prn.googlegroups.com> Message-ID: On 1/26/2011 11:53 AM, rantingrick wrote: To answer your other post, one of the main people to touch tkinter in the last 3 years was Guilherme Polo, who worked on it during and after a Google Summer of Code project. He does not seen to be active currently. There are currently 63 open issues on the tracker listing tkinter as a component. There are probably a few that could be closed. When I have learned more, I should be able to review any patched sitting around. > On Jan 26, 10:43 am, Emile van Sebille wrote: >> On 1/26/2011 8:00 AM rantingrick said... >>> I just installed Python 3,0 on my machine. >> >> Try it again on the current release candidate --http://www.python.org/download/releases/3.2/-- testing old first >> >> Seehttp://docs.python.org/bugs.htmlhttp://www.python.org/dev/peps/pep-0003/ > > Why would i want to waste bandwidth downloading an RC? Can i not just > browse the source online? I only need to check one module. Where is > the source available for viewing "simpledialog" online? > > Thanks > > PS: The version i have now is 3.1.1 (but i would like to see the > newest version available, just not download it!) I was hoping you meant 3.1.something, not 3.0. Latest is 3.1.3. 3.2c2 will be out very soon, and 3.2 2 weeks after if no problems arise. As far as the doc and stdlib go, 3.2 is probably one of the most improved releases ever, as they got almost all the attention with no syntax changes allowed. When it is out, I will strongly recommend upgrading, absent a really good reason not to. >(but i would like to see the > newest version available, just not download it!) http://svn.python.org/view/python/branches/py3k/Lib/tkinter/simpledialog.py?revision=81010&view=markup go back up a step and you can look at the log of changes. For current python 3 in general: http://svn.python.org/view/python/branches/py3k/ If you install TortoiseSVN, it is trivial to download the whole source tree. I believe you could also just download a subtree, like the tkinter and/or idlelib subtrees. Sometime after 3.2 is out, we will move from svn to hg and above will change. -- Terry Jan Reedy From mpnordland at gmail.com Wed Jan 26 17:00:35 2011 From: mpnordland at gmail.com (mpnordland) Date: Wed, 26 Jan 2011 17:00:35 -0500 Subject: WxPython versus Tkinter. In-Reply-To: References: <4D402E58.9090001@tysdomain.com> Message-ID: Segfaults in wxPython are caused by the debug assertions not being turned on. see Robin Dunn's (the creator of wxPython) response From tjreedy at udel.edu Wed Jan 26 17:08:14 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Wed, 26 Jan 2011 17:08:14 -0500 Subject: Slice lists and extended slicing In-Reply-To: References: Message-ID: On 1/26/2011 12:52 PM, Benjamin Kaplan wrote: > If you're trying to learn a language, I would suggest reading > tutorials, not the grammar. I second that. > As you can see from the error thrown, the > operation is syntactically valid (you don't get a syntax error). It's > just that lists don't accept them. I don't know of any built-in data > type that takes slice lists but numpy matrices will. > >>>> a = numpy.matrix([[1,2,3],[4,5,6],[7,8,9]]) > matrix([[1, 2, 3], > [4, 5, 6], > [7, 8, 9]]) > >>>> a[0:2,1:3] > matrix([[2, 3], > [5, 6]]) Which is to say, slice lists are a specialized feature added specifically for numerical python, now numpy. Ignore then unless and until you happen to install and use numpy, or something similar that also uses them. -- Terry Jan Reedy From rantingrick at gmail.com Wed Jan 26 17:35:36 2011 From: rantingrick at gmail.com (rantingrick) Date: Wed, 26 Jan 2011 14:35:36 -0800 (PST) Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com> <9MB%o.14110$%64.6074@unlimited.newshosting.com> <4A48EDF6D7634F2E994661A457451E87@teddy> <753A4C5A6658470085804B13C80340F2@octavian> Message-ID: On Jan 26, 3:48?pm, Grant Edwards wrote: > People will not separate your personality from the cause you espouse. > You may not like it, but that's a fact. ?If you are in favor of XYZ, > and act rude and insulting while espousing XYZ, people will react > against not only you but _also_ XYZ. A certain small subset of any group will always be emotionally driven. However we should not concern ourselves with this sort of non- objectivity. Some people make rash decisions not based in reality. What we *should* concern ourselves with is fostering pure objectivity. Because objectivity is the virtue of intelligent beings. Objectivity fosters creativity of which progress is the direct progeny. From debatem1 at gmail.com Wed Jan 26 17:38:28 2011 From: debatem1 at gmail.com (geremy condra) Date: Wed, 26 Jan 2011 14:38:28 -0800 Subject: WxPython versus Tkinter. In-Reply-To: References: <4D3E4377.3060807@tysdomain.com> <9MB%o.14110$%64.6074@unlimited.newshosting.com> <4A48EDF6D7634F2E994661A457451E87@teddy> <753A4C5A6658470085804B13C80340F2@octavian> Message-ID: On Wed, Jan 26, 2011 at 12:46 PM, Octavian Rasnita wrote: > I am not trying to convince anyone. I mean, we are not in the previous century and I hope that I don't need to convince anyone that offering accessibility for everyone is very important. Do you think that on this list there still are members that need to be convinced about this things? Do you really think that there are members that can't understand the importance of accessibility and they need to be convinced, persuaded, motivated with nice words? Do you have such a bad idea about them? > I am sure that they all know very well why the accessibility is important and I was just trying to tell them that Tkinter doesn't create accessible apps. The rest of your email seems to hinge on this point, so I'm just going to address it here and if you feel like I left something out, let me know. The bottom line is that, yes, you do still have to convince people that accessibility is important if you want them to do anything about it. I have to do almost exactly the same thing in my field- everybody knows that security is important, but every time I go to disclose a vulnerability I have to be very careful if I want to convince the vendor to fix the problem. During those discussions, an ounce of civility is worth more than ten tons of righteousness, not only because it helps convince people to do what you want but because they frequently walk away from it feeling good about the experience and eager to not make the same mistake again. Geremy Condra From tjreedy at udel.edu Wed Jan 26 17:57:22 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Wed, 26 Jan 2011 17:57:22 -0500 Subject: WxPython versus Tkinter. In-Reply-To: References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <8q7sgiF5tpU1@mid.individual.net> <19891784-d6a3-41ac-a097-5902a6323bc0@o21g2000prn.googlegroups.com><0b12cdb1-45b4-41e4-9bdb-074ee669d76b@k14g2000pre.googlegroups.com> <048FB74272D440A0915ABC7D76AE262B@teddy> <5782E9AD8A8342D691EB3549E5E0ED7B@octavian> Message-ID: On 1/26/2011 11:35 AM, Robert Kern wrote: > On 1/26/11 10:00 AM, Emile van Sebille wrote: >> On 1/25/2011 10:08 PM Octavian Rasnita said... >>> From: "Emile van Sebille" >>>>> Why is WxPython ineligible? >>>> >>>> I think Terry's point was compatibility with python3 -- which wx >>>> apparently isn't yet. >>>> >>>> Emile >>> >>> >>> Well, I didn't know this, and it is a valid reason. >>> This means that it is true that there is no enough maintainance force to >>> keep WxPython updated. >>> Did I understand correctly? >> >> Not at all -- wxPython is an active funded ongoing project. Review the >> roadmap >> at http://wiki.wxpython.org/TentativeRoadmap and particularly the final >> paragraph on Python3.x support. > > That's not Terry's point. The reasons he's referring to (and stated > previously) are as follows: > > 1. The license of wxWidgets and wxPython is not as permissive as > Python's. The Python developers, as a matter of policy, do not want to > include code into the standard library that is less permissive than the > current license. > > 2. The Python developers require someone to commit to maintaining > contributed code for a number of years. No one has done so. See reason #3. > > 3. The wxPython developers do not want wxPython in the standard library, > not least because they want to develop and release wxPython at a > different pace and release cycle than the standard library. > > 4. The Python developers have committed to maintaining backwards > compatibility in the standard library for a very long time. Even if they > included wxPython into the standard library, they would have to provide > a Tkinter module that works like the current one. I do not believe it is > feasible to write a Tkinter workalike that uses wxPython, so we would > still be relying on Tcl/Tk. Yes, very well put. Another point is non-gui baggage. In my opinion, and I suspect others, this should be minimal to absent. Tk itself is purely a gui package -- abstract widgits, geometry placers to make them visible, and an event system to make them active. But it does have the baggage of needing tcl included. About a decade ago, some people had the idea of removing the tcl dependency, but nothing seems to have come of that. For some people, the tcl baggage is reason enough to be rid of tk. Qt, in contrast to tk, is not a gui package, but an application framework and library that includes QtGui as one of about 10 modules. There is also, for instance QtSockets and QtScript (now included in QtCore). Qt as a whole could not go into the stdlib. From what I remember when I looked at the WxWidgets feature list some years ago, WxWidgets does not come with a scripting language, but also has more that strictly gui stuff. So I think it would also need to be subsetted. PyGui seems to be purely a gui package, but it appear to be aimed only at 2.x with no interest in 3.x. > There is certainly enough maintenance force to keep wxPython updated and > ported to Python 3, but only *outside* of the standard library. I got the opposite impression from the link above. As of last May, 3.x support is deferred until a new C++ code generator is written, and that is deferred until new features are added and released. So it seems the project needs another person to either code the new code generator or learn how to port Capi code (or both). Since there is no 2to3 for Capi (as opposed to Python code), I do not even know is a single code base is possible. I am sure that whoever works on a wxPython port could learn from whoever did the numpy port. -- Terry Jan Reedy From tyler at tysdomain.com Wed Jan 26 18:06:18 2011 From: tyler at tysdomain.com (Littlefield, Tyler) Date: Wed, 26 Jan 2011 16:06:18 -0700 Subject: WxPython versus Tkinter. In-Reply-To: <7952a09c-4e61-4661-9873-7e0bd897b1ee@y2g2000prf.googlegroups.com> References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <8q7sgiF5tpU1@mid.individual.net> <19891784-d6a3-41ac-a097-5902a6323bc0@o21g2000prn.googlegroups.com><0b12cdb1-45b4-41e4-9bdb-074ee669d76b@k14g2000pre.googlegroups.com> <048FB74272D440A0915ABC7D76AE262B@teddy> <5782E9AD8A8342D691EB3549E5E0ED7B@octavian> <43FCB75BBC57406799C87AD6FC781EFC@teddy> <7952a09c-4e61-4661-9873-7e0bd897b1ee@y2g2000prf.googlegroups.com> Message-ID: <4D40A8EA.5020008@tysdomain.com> >Stephen "Strawman" Hansen: If he only had a brain! And you want -us- to take -you- seriously? Tell me, what did you accomplish with that insult? Beyond elevating your own ego and trolling some more, anyway. On 1/26/2011 1:37 PM, rantingrick wrote: > On Jan 26, 2:07 pm, Stephen Hansen wrote: > >> And some people have absolutely no need-- no need at all-- for any sort >> of GUI programming at all. This group is actually really, really big. > Stephen "Strawman" Hansen: If he only had a brain! :-) > > That is the most obvious straw-man to date in this thread. What about > the large portion of folks who don't use all the datatypes (queue, > weakref, etc) or how about numeric and math modules (fractions, > decimal, etc) or how about data persistence, or Cryptograhic, or > curses! or, multimedia services, or, or. > > You see NOT everyone uses everything in the stdlib and most use much > less than half. However we would be fools to claim "batteries > included" and NOT support GUI! -- Thanks, Ty From tyler at tysdomain.com Wed Jan 26 18:08:47 2011 From: tyler at tysdomain.com (Littlefield, Tyler) Date: Wed, 26 Jan 2011 16:08:47 -0700 Subject: WxPython versus Tkinter. In-Reply-To: References: <4D3E4377.3060807@tysdomain.com><9MB%o.14110$%64.6074@unlimited.newshosting.com><4A48EDF6D7634F2E994661A457451E87@teddy><753A4C5A6658470085804B13C80340F2@octavian> Message-ID: <4D40A97F.8090209@tysdomain.com> >I don't want to convince anyone, but I just want to inform the others and let >them know if they are doing something not recommended. not recommended by -you-, which is different than by a community or the subset of people you are attempting to represent. furthermore, your attidude is that of "comply to my definition of what is needed, or you are selfish, rude, mean, cruel, etc." Then when that fails, you try cramming words in people's mouth to make them feel like they kick puppies, and to bring everyone else to this same conclusion. On 1/26/2011 1:46 PM, Octavian Rasnita wrote: > From: "geremy condra" >> At least 40% of my coworkers do not speak English as their native >> language. Your problem is not the language. Your problem is your >> attitude. > The atitude considered nice is just duplicity for convincing others, and I don't like duplicity. I like to know exactly what the people think and I want them know what I think. > I don't want to convince anyone, but I just want to inform the others and let them know if they are doing something not recommended. > > I agree, telling the people that they are doing something wrong, directly, without sugar, might be considered a bad atitude by those who prefer duplicity and nice words just for the sake of socializing, but is that atitude worst than of those who don't care about discriminatory practices? > > >>> But I don't condemn you for this, because many years ago when I was in >>> school I had the opinion that some foreign colleagues are a little stupid >>> just because they were not able to express very well the ideas which were >>> not very simple, and well, they were not stupid at all, but they didn't know >>> my language well enough and they probably would think the same thing about >>> me if we were speaking in Russian. >> I don't have that problem. > Oh yes you do as well as many others and it is obvious because I have seen that some of you consider me to be very angry, but I am not angry nor nervous at all so there may be something else. > If I say that I don't like a certain country because it attacks other countries, it doesn't mean that I am nervous or angry. I am just expressing my opinions about that country. > About those who use Tkinter I can't even say that I don't like them or something like that, because it is very normal that most of Python programmers should prefer it, because it was promoted a long time by Python. What I said is that it is not OK that Python promoted and keeps promoting a GUI lib that creates discrimination, but I don't know where you have seen that anger. > >>> Exactly what I said. They are doing the same mistake as I did 20 years ago. >>> By the way, can't you see any syntactic dissacords in my phrases? Haven't >>> you think that my English might not be as fluent to be able to express >>> everything I want to say very well? >> As I mentioned earlier, you'll find I don't have a lot of pity for you in this. > I don't need your pitty, but I can see that you misunderstand me, thinking that I am angry, thinking that I want to force everyone to use a GUI lib, and I thought that my English may not be clear enough to make you understand what I want to say. > >>> But not supporting accessibility because the programmer *doesn't want this*, >>> it is not a bug, but discrimination. Don't you agree with this? >>> And if Python would have been able to support accessibility it would have >>> mean that it promotes discrimination because it promotes the wrong tool, but >>> it seems that Python 3 doesn't have an accessible GUI lib for the moment, so >>> no, it is not discrimination (but Emile told us that there is no support for >>> WxPython in Python 3 just today, so I didn't know this and I already >>> wondered why nobody told about this real problem). >> Keep in mind, I'm not saying this. > Saying what? I don't understand what you were not saying. > >> This is a sketch of your point of view and Tyler's point of view. > What has the phrase I told above with what Tyler said? > I said that if somebody can create accessible programs but doesn't *want* to do that, this generates discrimination. > Don't you agree with this? > >>> Well, I think that everyone should understand why the programs must be >>> accessible and why everybody should care about all the users of an >>> application and that it is not normal to not care. >> Ah! I think I see where you're going wrong. It *is* normal not to >> care- not just about this, but about any given special interest other >> than your own. You have to convince people to care, or they don't- and >> you're not convincing, just yelling. > Where did I say that it is normal to not care about other things? > I have also agreed that it is important to have support for Python 3, that it is also important the commercial point of view, it is also important to have a GUI lib without bugs that generates errors, and you are again and again misunderstanding me thinking that I am yelling, even though I am writing all these things very calm. > > And I am not trying to convince anyone. I mean, we are not in the previous century and I hope that I don't need to convince anyone that offering accessibility for everyone is very important. Do you think that on this list there still are members that need to be convinced about this things? Do you really think that there are members that can't understand the importance of accessibility and they need to be convinced, persuaded, motivated with nice words? Do you have such a bad idea about them? > I am sure that they all know very well why the accessibility is important and I was just trying to tell them that Tkinter doesn't create accessible apps. > > >>> You are also very unkind and rude when you say that the disabled that need >>> to use a screen reader should be a kind of second hand people that need to >>> beg for a little accessibility. >> I don't say this. Don't try to stuff me into a strawman argument. > Then why do you ask nice words from me and an atitude which should be nice for the others? > We are not negociating here and I am not trying to convince anyone. I am just giving them the information that Tkinter creates inaccessible apps, and this creates discrimination, which is very true. It is not nice to talk about these things, , but first it is not nice for those discriminated, not for the others. > > >>> When you create a program, why do you create a visual interface for it? Why >>> don't you create just an audio interface? >> I don't create a visual interface. I have never found it necessary for >> my line of work, and have little stake in this discussion besides that >> of advocating civility on this list. > You are confusing civility with dupplicity. I was very civilized here. I didn't called names, I didn't used bad words but I am just trying to show why what the majority does is bad. Well, from its point of view this may mean that it is not civilized because it doesn't like it. > > >>> You do this because otherwise you would not please those who can see. Why >>> shouldn't be something normal, and that *should be not be discussable at >>> all* to offer the same accessibility to everyone? >> You can discuss it. You just have to convince others that you're >> right, and you're not doing that well. I offered you some advice on >> how to go about doing it better. > Well, I see that you really think than now in 2011 the people need to be convinced that the accessibility is important. > > >>> And you didn't say what was rude from what I said. You said just that it was >>> rude. >> I can provide quotes, if you like. > Yes please do it. > >>> Oh yes I know that it is unkind because most of the people don't even like >>> to talk personally with disabled people, but this doesn't mean that the >>> disabled people are something not normal, but those who have those biases >>> towards those who are very different. >> I don't have this problem. > Oh yes you do have it, because otherwise you wouldn't consider my messages as angry and not civilized just because they are not nice and candy and they don't try to convince the others that they should do something, because they are different from what you expect. > >> I think it would be better for the Python community if you were more >> civil and for the disabled community if you were more successful. The >> two go hand in hand. > I see that you see me as a paid advocate that should succeed convincing a certain group to do a certain thing, but I already told that I am not trying to convince anyone. > I just said that now in our era all the people should be very well convinced about the importance of accessibility, and there are very many resources on the net that talk about accessibility if there is somebody that doesn't know what we are talking about, so I don't need to convince anyone. > But I think that this is a false argument, because I doubt that there are list members that don't know the importance of accessibility. > > >> More people have the power to accomplish what fewer cannot. You want >> big changes, you will need big support, and people won't just move to >> your side because you're angry. You have to convince them. > I am not angry, but I am not trying to convince anyone about the importance of accessibility because its importance is very well known. > The problems are those who are aware about the accessibility but that still don't care. They are the people that should be taken with nice words? Doesn't that mean begging for a little accessibility as I said above? > > >>> If the majority doesn't care about the minorities which are minorities >>> without willing to be so, then it means that it is wrong. >> I don't know that's the case, and I suspect there are shades of grey >> you are not acknowledging here. > If you are acknowledging, then please give some examples of shades of gray. > > Octavian > -- Thanks, Ty From tjreedy at udel.edu Wed Jan 26 18:09:25 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Wed, 26 Jan 2011 18:09:25 -0500 Subject: WxPython versus Tkinter. In-Reply-To: <79f15901-3a0b-4749-8cd9-d2560406bee7@l15g2000prg.googlegroups.com> References: <4D402E58.9090001@tysdomain.com> <79f15901-3a0b-4749-8cd9-d2560406bee7@l15g2000prg.googlegroups.com> Message-ID: On 1/26/2011 11:00 AM, Bryan wrote: > On Jan 26, 9:47 am, "Octavian Rasnita" wrote: > >> I couldn't find the word soapbox in the dictionary Then get a better dictionary, or use on of the free, online ones. http://www.merriam-webster.com/dictionary/soapbox Definition of SOAPBOX : an improvised platform used by a self-appointed, spontaneous, or informal orator; broadly : something that provides an outlet for delivering opinions Soap used to be delivered to local general stores in sturdy wooden boxes, a bit longer than milk cartons. Flipped top down on the grass of a public area, the bottom was used as a speaking platform. Being sturdy, kids sometimes put wheels on them to ride in and even race. Hence, 'soapbox (or soap box) derby'. >> Please be more clear and not talk like the high school kids. Please give up the insults. I have stopped reading your repetitive posts and only saw this one because Bryan quoted it. > http://en.wikipedia.org/wiki/Soapbox -- Terry Jan Reedy From mail2bansi at gmail.com Wed Jan 26 18:10:49 2011 From: mail2bansi at gmail.com (bansi) Date: Wed, 26 Jan 2011 15:10:49 -0800 (PST) Subject: Is it possible to pass CSV Reader Object As Argument to another Python File ??? References: <2c35653e-3565-48c6-8939-b6b09b885e3f@d23g2000prj.googlegroups.com> <876b6c52-1a6d-4afa-83e9-fa987c9359a5@v31g2000pri.googlegroups.com> <87lj272vpo.fsf@benfinney.id.au> Message-ID: <5b4183bc-45f2-4fca-a0d4-25537306ebec@u13g2000prd.googlegroups.com> On Jan 26, 4:36?pm, Ben Finney wrote: > bansi writes: > > Thanks Chris. Sorry for mis-communicating, the two python scripts are > > dependant in a way that namelookupWrapper.py needs to pass csv record > > object to another python script > > Why have you structured them that way, though? What constraint is > keeping you from doing the work in a single process, where the CSV > reader object can be shared? > > > If thats not possible then please let me know how to do the workaround > > i didnt understood the import thing and not sure if it helps in my > > case > > The problem as you've described it so far is best solved by having a > single process accessing the CSV reader object in memory. If that > doesn't suit your use case, you'll need to explain why not. > > -- > ?\ ? ? ? ?To have the choice between proprietary software packages, is | > ? `\ ? ? ?being able to choose your master. Freedom means not having a | > _o__) ? ? ? ? ? ? ? ? ? ? ? ?master.? ?Richard M. Stallman, 2007-05-16 | > Ben Finney Thanks Ben for quick response. The constraint is in using third party tool called Splunk which has in-built Python 2.6 which doesnt support pyodbc on Windows 64 bit OS. Hence i have to install Python 2.7 for pyodbc. That means namelookupwrapper.py acts as a wrapper running under Splunk environment taking input from Splunk via stdin and storing it in csv reader object and then needs to call actual script namelookup.py under Python 2.7 for making connection to database Hope i have clarified a bit From me+list/python at ixokai.io Wed Jan 26 18:13:50 2011 From: me+list/python at ixokai.io (Stephen Hansen) Date: Wed, 26 Jan 2011 15:13:50 -0800 Subject: WxPython versus Tkinter. In-Reply-To: <4D4093AF.80806@etrix.com.au> References: <4D4093AF.80806@etrix.com.au> Message-ID: <4D40AAAE.80102@ixokai.io> On 1/26/11 1:35 PM, Brendan Simon (eTRIX) wrote: > Since it seems the python motto is "Batteries included", then it would > seem to me that wxPython is the natural fit as it also has "Batteries > included" (e.g. accessibility, native look-n-feel, mature and evolving, > can produce simple or complex gui programs, etc, etc). That is not the Python motto. It is a philosophy which factors into decisions of things to add to the standard library; but there are other factors as well. It emphatically doesn't mean to include everything, or even most things. It means providing broad support for a wide range of common tasks and generally encourages including mature, best-of-breed modules that emerge out in the wider ecosystem that are suitable for inclusion. wxPython is mature: best-of-breed is a long-debated, and its not suitable for inclusion for various reasons discussed elsewhere. -- Stephen Hansen ... Also: Ixokai ... Mail: me+list/python (AT) ixokai (DOT) io ... Blog: http://meh.ixokai.io/ -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 487 bytes Desc: OpenPGP digital signature URL: From ethan at stoneleaf.us Wed Jan 26 18:25:17 2011 From: ethan at stoneleaf.us (Ethan Furman) Date: Wed, 26 Jan 2011 15:25:17 -0800 Subject: Is it possible to pass CSV Reader Object As Argument to another Python File ??? In-Reply-To: <87lj272vpo.fsf@benfinney.id.au> References: <2c35653e-3565-48c6-8939-b6b09b885e3f@d23g2000prj.googlegroups.com> <876b6c52-1a6d-4afa-83e9-fa987c9359a5@v31g2000pri.googlegroups.com> <87lj272vpo.fsf@benfinney.id.au> Message-ID: <4D40AD5D.8020301@stoneleaf.us> bansi wrote: > First namelookupWrapper.py running under Python 2.6 accept arguments > from stdin and uses csv reader object to read it i.e. > r=csv.reader(sys.stdin) > > And then it has to pass csv reader object to another python script > namelookup.py running under Python 2.7 because it uses pyodbc to > connect to database and iterates thru reader object Ben Finney wrote: > bansi writes: > >> Thanks Chris. Sorry for mis-communicating, the two python scripts are >> dependant in a way that namelookupWrapper.py needs to pass csv record >> object to another python script > > Why have you structured them that way, though? What constraint is > keeping you from doing the work in a single process, where the CSV > reader object can be shared? > >> If thats not possible then please let me know how to do the workaround >> i didnt understood the import thing and not sure if it helps in my >> case > > The problem as you've described it so far is best solved by having a > single process accessing the CSV reader object in memory. If that > doesn't suit your use case, you'll need to explain why not. > In other words, why can't you use Python 2.7 to accept input and generate a csv.reader? ~Ethan~ From me+list/python at ixokai.io Wed Jan 26 18:27:08 2011 From: me+list/python at ixokai.io (Stephen Hansen) Date: Wed, 26 Jan 2011 15:27:08 -0800 Subject: WxPython versus Tkinter. In-Reply-To: <7952a09c-4e61-4661-9873-7e0bd897b1ee@y2g2000prf.googlegroups.com> References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <8q7sgiF5tpU1@mid.individual.net> <19891784-d6a3-41ac-a097-5902a6323bc0@o21g2000prn.googlegroups.com><0b12cdb1-45b4-41e4-9bdb-074ee669d76b@k14g2000pre.googlegroups.com> <048FB74272D440A0915ABC7D76AE262B@teddy> <5782E9AD8A8342D691EB3549E5E0ED7B@octavian> <43FCB75BBC57406799C87AD6FC781EFC@teddy> <7952a09c-4e61-4661-9873-7e0bd897b1ee@y2g2000prf.googlegroups.com> Message-ID: <4D40ADCC.3080505@ixokai.io> On 1/26/11 12:37 PM, rantingrick wrote: > On Jan 26, 2:07 pm, Stephen Hansen wrote: > >> And some people have absolutely no need-- no need at all-- for any sort >> of GUI programming at all. This group is actually really, really big. > > Stephen "Strawman" Hansen: If he only had a brain! :-) > > That is the most obvious straw-man to date in this thread. What about > the large portion of folks who don't use all the datatypes (queue, > weakref, etc) or how about numeric and math modules (fractions, > decimal, etc) or how about data persistence, or Cryptograhic, or > curses! or, multimedia services, or, or. > > You see NOT everyone uses everything in the stdlib and most use much > less than half. However we would be fools to claim "batteries > included" and NOT support GUI! As usual, you selectively quote and completely miss the point. Hint: the quoted portion was not an argument for or against inclusion of anything. The funny thing is, by selectively quoting the phrase and using it to imply that I was making a straw-man argument against inclusion with that statement -- which, point of fact, I was not -- you are yourself, making a straw-man argument. http://en.wikipedia.org/wiki/Straw_man "To "attack a straw man" is to create the illusion of having refuted a proposition by substituting it with a superficially similar yet unequivalent proposition (the "straw man"), and refuting it, without ever having actually refuted the original position." I can't decide if you're just ignorant or if you're an artful troll with a sense of irony and did it on purpose. -- Stephen Hansen ... Also: Ixokai ... Mail: me+list/python (AT) ixokai (DOT) io ... Blog: http://meh.ixokai.io/ -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 487 bytes Desc: OpenPGP digital signature URL: From hidura at gmail.com Wed Jan 26 18:27:31 2011 From: hidura at gmail.com (hidura at gmail.com) Date: Wed, 26 Jan 2011 23:27:31 +0000 Subject: Problems receiving arguments on a subprocess Message-ID: <20cf304341ce5a013a049ac82df4@google.com> Hello i am trying to make a subprocess that will have to send data as an arguments and is executing the script but don't receiving anything. Here is the code of the subprocess: car = Popen(shlex.split(self.block.getAttribute('cmd')), stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) data = car.communicate(str(""+self.extract.getByAttr(self.block, 'name', 'args')[0].toxml()+"").encode()) dataOut = data[0].decode() log = data[1].decode() print(dataOut) if car.returncode < 1: return dataOut.split('\n') else: print(log) return log Here is the code of the script: """ Created By: hidura On Date: Jan 25, 2011 """ from xml.dom.minidom import parseString import os import sys class savCSS: """This class has to save the changes on the css file. """ def __init__(self, args): document = parseString(args) request = document.firstChild address = request.getElementsByTagName('element')[0] newdata = request.getElementsByTagName('element')[1] cssfl = open("/webapps/karinapp/Suite/"+address.getAttribute('value'), 'r') cssData = cssfl.read() cssfl.close() dataCSS = '' for child in newdata.childNodes: if child.nodeType == 3: dataCSS += child.nodeValue nwcssDict = {} for piece in dataCSS.split('}'): nwcssDict[piece.split('{')[0]] = piece.split('{')[1] cssDict = {} for piece in cssData.split('}'): cssDict[piece.split('{')[0]] = piece.split('{')[1] for key in nwcssDict: if key in cssDict == True: del cssDict[key] cssDict[key] = nwcssDict[key] result = '' for key in cssDict: result += key+"{"+cssDict[key]+"}" cssfl = open(cssfl.name, 'a') cssfl.write(result) cssfl.close() if __name__ == "__main__": print(sys.stdin.read()) savCSS(sys.stdin.read()) Thanks in advance -------------- next part -------------- An HTML attachment was scrubbed... URL: From python at mrabarnett.plus.com Wed Jan 26 18:49:00 2011 From: python at mrabarnett.plus.com (MRAB) Date: Wed, 26 Jan 2011 23:49:00 +0000 Subject: replacing lines in a file In-Reply-To: References: Message-ID: <4D40B2EC.1070309@mrabarnett.plus.com> On 26/01/2011 21:50, mpnordland wrote: > Attached are a config file parser that i'm working on, and a example > config file. Basically, what my problem is is in write_config, it should > search through the file, and replace the lines with whatever the > modified version is, it is also designed to ignore comments. To see my > problem (which is hard to describe) please first look at the config > file, and then run config-parse.py then look at the config file again. > One of two things should happen: nothing, or something weird should > happen on the last line. > > #!/usr/bin/python > import fileinput > > def read_config(file): > config={} > if isinstance(file, type('str')) : > config_file=open_config_file(file, 'r') > if not config_file: > return 1 > for option in config_file: > option=option.replace('\n','') > if option!='' and '#' not in option: > option=option.split(':') > config[option[0]]=option[1] > config_file.close() > return config > else: > print "the file paramenter should be a string contianing a file path" > return 1 > Sometimes the function returns the config (a dict) and sometimes it returns 1. The Pythonic way would be to raise an exception if there's an error. > def write_config(config, file): > if isinstance(config, type({})) and isinstance(file, type('str')): > config_file=open_config_file(file,'r+') > if not config_file: > return 1 > > for line in config_file: > line=line.replace('\n','') > if line!='' and '#' not in line: > option=line.split(':') > new_line = option[0]+':'+config[option[0]] + '\n' > > print config_file.write(line.replace(line, new_line)) You're reading a line from the file and then writing the new line over whatever follows it. Suppose you have a file containing "123\n45\n678\n". You open the file. You're at position 0. You read the first line "123\n". You're now at position 4. You write "XYZ\n". You're now at position 8. The file now contains "123\nXYZ\n78\n". You've just overwritten the second line and part of the third line. > config_file.close() > else: > print "The config arg must be a dictionary and/or the file arg must be a string containing a file path" > def open_config_file(file, mode): > try: > config_file=open(file,mode) > except IOError: > print "That File Doesn't exist!" > return None > return config_file > > if __name__ == '__main__': > file = './net-responsibility.conf2' > config=read_config(file) > print config > config["logfile"]=' 5' > file = './net-responsibility.conf2' > write_config(config, file) From rantingrick at gmail.com Wed Jan 26 18:57:46 2011 From: rantingrick at gmail.com (rantingrick) Date: Wed, 26 Jan 2011 15:57:46 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <8q7sgiF5tpU1@mid.individual.net> <19891784-d6a3-41ac-a097-5902a6323bc0@o21g2000prn.googlegroups.com><0b12cdb1-45b4-41e4-9bdb-074ee669d76b@k14g2000pre.googlegroups.com> <048FB74272D440A0915ABC7D76AE262B@teddy> <5782E9AD8A8342D691EB3549E5E0ED7B@octavian> Message-ID: <0338ce09-e954-4dcd-b164-e23db77986da@g26g2000vba.googlegroups.com> On Jan 26, 4:57?pm, Terry Reedy wrote: > PyGui seems to be purely a gui package, but it appear to be aimed only > at 2.x with no interest in 3.x. I really like pyGUI. We would have to do a ton of work to get it even to the scale of Tkinter. In hindsight the project seems like something Python should have considered from the beginning. Had we have started with something like pyGUI 20 years ago, i'd bet we would be better off today since we could control the development internally. PROS: * small * cross platform?? * pythonic * under our control * unlimited possibilities CONS: * not feature rich * huge amount of work needed Although pyGUI would probably never measure up to wxPython. I still have a special place in my heart for such an ambitious and visionary undertaking. You can read the goals at Greg's site. Every time i do i get a tear in my eye thinking of the possibilities. http://www.cosc.canterbury.ac.nz/greg.ewing/python_gui/ From robert.kern at gmail.com Wed Jan 26 19:23:44 2011 From: robert.kern at gmail.com (Robert Kern) Date: Wed, 26 Jan 2011 18:23:44 -0600 Subject: WxPython versus Tkinter. In-Reply-To: References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <8q7sgiF5tpU1@mid.individual.net> <19891784-d6a3-41ac-a097-5902a6323bc0@o21g2000prn.googlegroups.com><0b12cdb1-45b4-41e4-9bdb-074ee669d76b@k14g2000pre.googlegroups.com> <048FB74272D440A0915ABC7D76AE262B@teddy> <5782E9AD8A8342D691EB3549E5E0ED7B@octavian> Message-ID: On 1/26/11 4:57 PM, Terry Reedy wrote: > From what I remember when I looked at the WxWidgets feature list some years > ago, WxWidgets does not come with a scripting language, but also has more that > strictly gui stuff. So I think it would also need to be subsetted. For what it's worth, wxPython tries not to wrap parts of wxWidgets that can be replicated by the standard library. I do believe they wrap some non-GUI parts of wxWidgets that are needed to work with certain GUI widgets, but don't quote me on that. > On 1/26/2011 11:35 AM, Robert Kern wrote: >> There is certainly enough maintenance force to keep wxPython updated and >> ported to Python 3, but only *outside* of the standard library. > > I got the opposite impression from the link above. As of last May, 3.x support > is deferred until a new C++ code generator is written, and that is deferred > until new features are added and released. So it seems the project needs another > person to either code the new code generator or learn how to port Capi code (or > both). Since there is no 2to3 for Capi (as opposed to Python code), I do not > even know is a single code base is possible. I am sure that whoever works on a > wxPython port could learn from whoever did the numpy port. In loose terms, what we learned from the experience was that it actually isn't so bad once you knuckle down to it. But yes, it does look like some more volunteer effort would be needed to get Python 3 support soon. I note that I did not specify any particular deadline. :-) I just wanted to disabuse Octavian of the idea that we are claiming that the wxPython team is inadequate in general. -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco From tjreedy at udel.edu Wed Jan 26 19:46:09 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Wed, 26 Jan 2011 19:46:09 -0500 Subject: WxPython versus Tkinter. In-Reply-To: <4D407F07.6020808@ixokai.io> References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <8q7sgiF5tpU1@mid.individual.net> <19891784-d6a3-41ac-a097-5902a6323bc0@o21g2000prn.googlegroups.com><0b12cdb1-45b4-41e4-9bdb-074ee669d76b@k14g2000pre.googlegroups.com> <048FB74272D440A0915ABC7D76AE262B@teddy> <5782E9AD8A8342D691EB3549E5E0ED7B@octavian> <43FCB75BBC57406799C87AD6FC781EFC@teddy> <4D407F07.6020808@ixokai.io> Message-ID: On 1/26/2011 3:07 PM, Stephen Hansen wrote: > And, more then a few actually > are pushing for the stdlib to be forked off of CPython, and instead end > up shared by all the major Python implementations (CPython, Jython, > PyPy, IronPython, what else?) as a common resource? This would be a 'split', not a 'fork' (important difference). There are really two ideas here. 1. As many modules as possible would have a pure Python reference implementation. Any implementation could use that until it choose to replace or supplement with a native-language implementation. For instance, itertools in coded in C for speed, but the docs give Python (near) equivalents for clarity. A common Python stdlib would have a Python-coded itertools. CPython would actually run the C-coded equivalent renamed _itertools. Maintaining both versions in parallel would be more work, so this could only happen if other implementors chipped in to help. Stephen, you are the first I know of to ask whether such a project would affect addition of new modules. Hard to say. 2. Separate tests that test compliance with the Python specs (for both language and stdlib) from tests that test implementation-specific behaviors. The current CPython test suite mixes both together. If separated, other implementations could (and would) use the Python tests, and their people would be more willing to help improve the Python tests. Many stdlib modules are not at 100% coverage and need expansion. For instance, "1+1 == 2" tests Python behavior, while "a,b=1,1; id(a)==id(b)" tests a CPython implementation detail. Last I knew, both types of tests are in the same test file. Reference count tests, for example, are also CPython-specific. Both of these ideas will be looked at after the hg migration. -- Terry Jan Reedy From mail2bansi at gmail.com Wed Jan 26 19:57:41 2011 From: mail2bansi at gmail.com (bansi) Date: Wed, 26 Jan 2011 16:57:41 -0800 (PST) Subject: Is it possible to pass CSV Reader Object As Argument to another Python File ??? References: <2c35653e-3565-48c6-8939-b6b09b885e3f@d23g2000prj.googlegroups.com> <876b6c52-1a6d-4afa-83e9-fa987c9359a5@v31g2000pri.googlegroups.com> <87lj272vpo.fsf@benfinney.id.au> Message-ID: On Jan 26, 6:25?pm, Ethan Furman wrote: > bansi wrote: > > ?> First namelookupWrapper.py running under Python 2.6 accept arguments > ?> from stdin and uses csv reader object to read it i.e. > ?> r=csv.reader(sys.stdin) > ?> > ?> And then it has to pass csv reader object to another python script > ?> namelookup.py running under Python 2.7 because it uses pyodbc to > ?> connect to database and iterates thru reader object > > > > > > Ben Finney wrote: > > bansi writes: > > >> Thanks Chris. Sorry for mis-communicating, the two python scripts are > >> dependant in a way that namelookupWrapper.py needs to pass csv record > >> object to another python script > > > Why have you structured them that way, though? What constraint is > > keeping you from doing the work in a single process, where the CSV > > reader object can be shared? > > >> If thats not possible then please let me know how to do the workaround > >> i didnt understood the import thing and not sure if it helps in my > >> case > > > The problem as you've described it so far is best solved by having a > > single process accessing the CSV reader object in memory. If that > > doesn't suit your use case, you'll need to explain why not. > > In other words, why can't you use Python 2.7 to accept input and > generate a csv.reader? > > ~Ethan~- Hide quoted text - > > - Show quoted text - Ethan, The python script takes the input from Splunk (http://www.splunk.com/ base/Documentation/) which supports only Python 2.6 So the real constraint is Splunk supports only Python 2.6 . As you know Python 2.6 doesnt support or doesnt have pyodbc install for Windows 64 bit OS So i installed Python 2.7 and thereafter pyodbc install for Windows 64 bit OS for Python 2.7 From clp2 at rebertia.com Wed Jan 26 20:24:36 2011 From: clp2 at rebertia.com (Chris Rebert) Date: Wed, 26 Jan 2011 17:24:36 -0800 Subject: Problems receiving arguments on a subprocess In-Reply-To: <20cf304341ce5a013a049ac82df4@google.com> References: <20cf304341ce5a013a049ac82df4@google.com> Message-ID: On Wed, Jan 26, 2011 at 3:27 PM, wrote: > Hello i am trying to make a subprocess that will have to send data as an > arguments and is executing the script but don't receiving anything. Command-line arguments, or stream/file input via stdin? I think you mean the latter. The term "argument(s)" is not typically used to describe the latter. How exactly did you conclude that the script isn't receiving anything? > Here is the code of the subprocess: > car = Popen(shlex.split(self.block.getAttribute('cmd')), > stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) > data = car.communicate(str(""+self.extract.getByAttr(self.block, > 'name', 'args')[0].toxml()+"").encode()) > > dataOut = data[0].decode() > log = data[1].decode() > print(dataOut) > > if car.returncode < 1: > return dataOut.split('\n') > > else: > print(log) > return log If you still have problems, try printing `log` unconditionally and then checking that you still get no output. Also, please ensure future posts preserve the indentation in your code. It's rather annoying (and imprecise) to have to infer it. > Here is the code of the script: > > if __name__ == "__main__": > > print(sys.stdin.read()) > savCSS(sys.stdin.read()) You do realize the second .read() will *always* return an empty string, right? The first .read() already read all of the stdin stream, so there's nothing left for the second .read() to get. I suspect this is the cause of your problem. Remove the line involving print(). Cheers, Chris -- http://blog.rebertia.com From hidura at gmail.com Wed Jan 26 20:29:24 2011 From: hidura at gmail.com (Hidura) Date: Wed, 26 Jan 2011 21:29:24 -0400 Subject: Problems receiving arguments on a subprocess In-Reply-To: <20cf304341ce5a013a049ac82df4@google.com> References: <20cf304341ce5a013a049ac82df4@google.com> Message-ID: The print line it doesn't print anything that's why i say is not receiving anything. 2011/1/26, hidura at gmail.com : > Hello i am trying to make a subprocess that will have to send data as an > arguments and is executing the script but don't receiving anything. > > Here is the code of the subprocess: > car = Popen(shlex.split(self.block.getAttribute('cmd')), > stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) > data = > car.communicate(str(""+self.extract.getByAttr(self.block, 'name', > 'args')[0].toxml()+"").encode()) > > > > dataOut = data[0].decode() > log = data[1].decode() > print(dataOut) > > if car.returncode < 1: > return dataOut.split('\n') > > else: > print(log) > return log > > Here is the code of the script: > > """ > Created By: hidura > On Date: Jan 25, 2011 > """ > from xml.dom.minidom import parseString > import os > import sys > > class savCSS: > """This class has to save > the changes on the css file. > """ > > def __init__(self, args): > > document = parseString(args) > request = document.firstChild > > address = request.getElementsByTagName('element')[0] > newdata = request.getElementsByTagName('element')[1] > > cssfl = open("/webapps/karinapp/Suite/"+address.getAttribute('value'), 'r') > cssData = cssfl.read() > cssfl.close() > > dataCSS = '' > for child in newdata.childNodes: > if child.nodeType == 3: > dataCSS += child.nodeValue > > nwcssDict = {} > > for piece in dataCSS.split('}'): > nwcssDict[piece.split('{')[0]] = piece.split('{')[1] > > > cssDict = {} > > for piece in cssData.split('}'): > cssDict[piece.split('{')[0]] = piece.split('{')[1] > > > for key in nwcssDict: > if key in cssDict == True: > del cssDict[key] > > cssDict[key] = nwcssDict[key] > > > result = '' > for key in cssDict: > result += key+"{"+cssDict[key]+"}" > > > cssfl = open(cssfl.name, 'a') > cssfl.write(result) > cssfl.close() > > > > if __name__ == "__main__": > > print(sys.stdin.read()) > savCSS(sys.stdin.read()) > > > Thanks in advance > -- Enviado desde mi dispositivo m?vil Diego I. Hidalgo D. From python at mrabarnett.plus.com Wed Jan 26 20:31:03 2011 From: python at mrabarnett.plus.com (MRAB) Date: Thu, 27 Jan 2011 01:31:03 +0000 Subject: Is it possible to pass CSV Reader Object As Argument to another Python File ??? In-Reply-To: References: <2c35653e-3565-48c6-8939-b6b09b885e3f@d23g2000prj.googlegroups.com> <876b6c52-1a6d-4afa-83e9-fa987c9359a5@v31g2000pri.googlegroups.com> <87lj272vpo.fsf@benfinney.id.au> Message-ID: <4D40CAD7.1000301@mrabarnett.plus.com> On 27/01/2011 00:57, bansi wrote: > On Jan 26, 6:25 pm, Ethan Furman wrote: >> bansi wrote: >> >> > First namelookupWrapper.py running under Python 2.6 accept arguments >> > from stdin and uses csv reader object to read it i.e. >> > r=csv.reader(sys.stdin) >> > >> > And then it has to pass csv reader object to another python script >> > namelookup.py running under Python 2.7 because it uses pyodbc to >> > connect to database and iterates thru reader object >> >> >> >> >> >> Ben Finney wrote: >>> bansi writes: >> >>>> Thanks Chris. Sorry for mis-communicating, the two python scripts are >>>> dependant in a way that namelookupWrapper.py needs to pass csv record >>>> object to another python script >> >>> Why have you structured them that way, though? What constraint is >>> keeping you from doing the work in a single process, where the CSV >>> reader object can be shared? >> >>>> If thats not possible then please let me know how to do the workaround >>>> i didnt understood the import thing and not sure if it helps in my >>>> case >> >>> The problem as you've described it so far is best solved by having a >>> single process accessing the CSV reader object in memory. If that >>> doesn't suit your use case, you'll need to explain why not. >> >> In other words, why can't you use Python 2.7 to accept input and >> generate a csv.reader? >> >> ~Ethan~- Hide quoted text - >> >> - Show quoted text - > > Ethan, > The python script takes the input from Splunk (http://www.splunk.com/ > base/Documentation/) which supports only Python 2.6 > So the real constraint is Splunk supports only Python 2.6 . > > As you know Python 2.6 doesnt support or doesnt have pyodbc install > for Windows 64 bit OS > So i installed Python 2.7 and thereafter pyodbc install for Windows 64 > bit OS for Python 2.7 Have you actually tried Splunk with Python 2.7? It might not work with versions which are earlier than Python 2.6, but that doesn't necessarily mean that it won't work with versions of Python 2 which are later than Python 2.6 (unless the documentation says that it must be Python 2.6). From jbravado at gmail.com Wed Jan 26 21:00:51 2011 From: jbravado at gmail.com (JB) Date: Wed, 26 Jan 2011 18:00:51 -0800 (PST) Subject: Executing multiple subprocesses and waiting Message-ID: <106dca00-5ad8-4f10-af99-01525e72f9fb@z26g2000prf.googlegroups.com> One of my python scripts that takes a bunch of inputs from a tKinter gui, generates a set of command line stings, and then threads them off to subprocess for calls to other programs like Nuke and our render farm has recently started randomly crashing pythonw.exe. I'm taking a look at my threading setup and attempting to clean it up. I was wondering what a smart way of doing what I describe is? Take a list of strings containing command line calls to other programs, process them one at a time (waiting for the previous one to complete before starting the next) and then finishing elegantly. Currently, the gui passes them all to a "workerThread" which loops through each string, sending it to a "processThread" which makes a call to subprocess to execute it. This has worked fine for over a year so the recent crashing is mystifying me. I'm wondering if it's increased network stress (we've grown) or something similar? Any thoughts and suggestions on waiting for threads to complete are appreciated. From reilly.christopher at gmail.com Wed Jan 26 21:17:23 2011 From: reilly.christopher at gmail.com (Chris) Date: Wed, 26 Jan 2011 18:17:23 -0800 (PST) Subject: Decorator question Message-ID: <5c4ce9cb-c68d-457e-ad63-c320f3a46224@p7g2000prb.googlegroups.com> I have a class (A, for instance) that possesses a boolean (A.b, for instance) that is liable to change over an instance's lifetime. Many of the methods of this class (A.foo, for instance) should not execute as long as this boolean is false, but should instead raise an exception. Can I use a decorator to implement this functionality? More exactly, could I define a function called 'checker' that accomplishes this: def checker(f): ... class A(): b = True @checker def foo(self,...): print 'in foo' a = A() a.foo() a.b = False a.foo() would result in: 'in foo' Exception: ... This exact solution isn't necessary, just something that doesn't require me to have the clunky: def foo(self,...): if self.b: ... else: raise Exception('b attribute must be true before executing this method') in every method. Thanks, Chris From reilly.christopher at gmail.com Wed Jan 26 21:37:57 2011 From: reilly.christopher at gmail.com (Chris) Date: Wed, 26 Jan 2011 18:37:57 -0800 (PST) Subject: Decorator question References: <5c4ce9cb-c68d-457e-ad63-c320f3a46224@p7g2000prb.googlegroups.com> Message-ID: On Jan 26, 6:17?pm, Chris wrote: > I have a class (A, for instance) that possesses a boolean (A.b, for > instance) that is liable to change over an instance's lifetime. > > Many of the methods of this class (A.foo, for instance) should not > execute as long as this boolean is false, but should instead raise an > exception. > > Can I use a decorator to implement this functionality? ?More exactly, > could I define a function called 'checker' that accomplishes this: > > def checker(f): > ? ? ... > > class A(): > > ? ? b = True > > ? ? @checker > ? ? def foo(self,...): > ? ? ? ? print 'in foo' > > a = A() > a.foo() > a.b = False > a.foo() > > would result in: > > 'in foo' > Exception: ... > > This exact solution isn't necessary, just something that doesn't > require me to have the clunky: > > def foo(self,...): > ? ? if self.b: > ? ? ? ? ... > ? ? else: raise Exception('b attribute must be true before executing > this method') > > in every method. > > Thanks, > > Chris Sorry, discovered answer here: http://stackoverflow.com/questions/2309124/get-class-in-python-decorator From python at mrabarnett.plus.com Wed Jan 26 21:40:59 2011 From: python at mrabarnett.plus.com (MRAB) Date: Thu, 27 Jan 2011 02:40:59 +0000 Subject: Decorator question In-Reply-To: <5c4ce9cb-c68d-457e-ad63-c320f3a46224@p7g2000prb.googlegroups.com> References: <5c4ce9cb-c68d-457e-ad63-c320f3a46224@p7g2000prb.googlegroups.com> Message-ID: <4D40DB3B.1050201@mrabarnett.plus.com> On 27/01/2011 02:17, Chris wrote: > I have a class (A, for instance) that possesses a boolean (A.b, for > instance) that is liable to change over an instance's lifetime. > > Many of the methods of this class (A.foo, for instance) should not > execute as long as this boolean is false, but should instead raise an > exception. > > Can I use a decorator to implement this functionality? More exactly, > could I define a function called 'checker' that accomplishes this: > > def checker(f): > ... > > class A(): > > b = True > > @checker > def foo(self,...): > print 'in foo' > > a = A() > a.foo() > a.b = False > a.foo() > > would result in: > > 'in foo' > Exception: ... > > This exact solution isn't necessary, just something that doesn't > require me to have the clunky: > > def foo(self,...): > if self.b: > ... > else: raise Exception('b attribute must be true before executing > this method') > > in every method. > How about this: def checker(func): def wrapper(self, *args, **kwargs): if not self.b: raise Exception('b attribute must be true before executing this method') return func(self, *args, **kwargs) return wrapper From tshinnic at io.com Wed Jan 26 21:42:04 2011 From: tshinnic at io.com (Thomas L. Shinnick) Date: Wed, 26 Jan 2011 20:42:04 -0600 Subject: Decorator question In-Reply-To: <5c4ce9cb-c68d-457e-ad63-c320f3a46224@p7g2000prb.googlegrou ps.com> References: <5c4ce9cb-c68d-457e-ad63-c320f3a46224@p7g2000prb.googlegroups.com> Message-ID: At 08:17 PM 1/26/2011, Chris wrote: >I have a class (A, for instance) that possesses a boolean (A.b, for >instance) that is liable to change over an instance's lifetime. > >Many of the methods of this class (A.foo, for instance) should not >execute as long as this boolean is false, but should instead raise an >exception. > >Can I use a decorator to implement this functionality? More exactly, >could I define a function called 'checker' that accomplishes this: Mark Summerfield's book "Programming in Python 3" has an example something like this (p.357) called 'positive_result'. I hesitate to quote the entire thing, so I'll quote only the inner 'half' of the decorator: def wrapper(*args, **kwargs): result = function(*args, **kwargs) assert result >= 0, function.__name__ + "() result isn't >= 0" return result I would guess you would have to count on the first item in the methods' args to be self, and use that to test whether your attribute is false/true? Mark? >def checker(f): > ... > >class A(): > > b = True > > @checker > def foo(self,...): > print 'in foo' > >a = A() >a.foo() >a.b = False >a.foo() > >would result in: > >'in foo' >Exception: ... > >This exact solution isn't necessary, just something that doesn't >require me to have the clunky: > >def foo(self,...): > if self.b: > ... > else: raise Exception('b attribute must be true before executing >this method') > >in every method. > >Thanks, > >Chris >-- From wuwei23 at gmail.com Wed Jan 26 21:59:01 2011 From: wuwei23 at gmail.com (alex23) Date: Wed, 26 Jan 2011 18:59:01 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <8q7sgiF5tpU1@mid.individual.net> <19891784-d6a3-41ac-a097-5902a6323bc0@o21g2000prn.googlegroups.com> <0b12cdb1-45b4-41e4-9bdb-074ee669d76b@k14g2000pre.googlegroups.com> <7bb56aba-0f96-4b7e-a78d-3398003a0e38@c39g2000yqi.googlegroups.com> Message-ID: On Jan 26, 5:25?am, rantingrick wrote: > A vision that > is representative of ALL the people -- and not a few fat cats at the > top. [...] > This is the only way we can truly > understand what our community members are thinking about Tkinter. > Anything else is purely speculation. [...] > Many folks out there share our views that Tkinter is a weight around > Python's neck, however they are too fearful to speak out for fear of > excommunication (the kill file!). So even though the majority of opinions are counter to yours, those people are the arrogant 'fat cats' who aren't listening to 'the people'? You criticise others for making generalised statements about the desires of other coders, but you believe that you speak for a silent majority, whose presence is somehow known and sensed by you through some magical force? Can we all just accept that rr/rantingrick is a troll and let these thread die? This is, what, the 3rd? 4th? year of his endless tirade against TKinter. Most people with an actual problem WOULD HAVE RELEASED CODE BY NOW. From wuwei23 at gmail.com Wed Jan 26 22:11:29 2011 From: wuwei23 at gmail.com (alex23) Date: Wed, 26 Jan 2011 19:11:29 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com><63eea$4d3cd2fd$4275d90a$14984@FUSE.NET><69465430-08b3-4069-99c7-72f4d3034c66@s5g2000yqm.googlegroups.com><705ad$4d3ce0fc$4275d90a$29144@FUSE.NET> <2sm%o.8695$gM3.6118@viwinnwfe01.internal.bigpond.com> <0c3c61b0-d056-4757-b7e4-fecdf9a6e217@fm22g2000vbb.googlegroups.com> Message-ID: <94c48579-aed0-4987-aaa4-0f7b6209d9bb@8g2000prt.googlegroups.com> rantingrick wrote: > Not if we used the underlying MS library! Windows has such a rich > library why not use it? Why must we constantly re-invent the wheel? Isn't restricting a GUI toolkit to just one of the major OSes the absolute opposite of 'accessible'? From wuwei23 at gmail.com Wed Jan 26 22:35:10 2011 From: wuwei23 at gmail.com (alex23) Date: Wed, 26 Jan 2011 19:35:10 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <3a96fee1-995f-49f7-a967-f125cc3f1cdc@v26g2000yqf.googlegroups.com> <023e19ed-69d1-4155-a114-0d00c227b8f6@u18g2000prh.googlegroups.com> Message-ID: <6a71b56a-81bc-4983-91db-ca672560ab2c@f30g2000yqa.googlegroups.com> Infinity77 wrote: > It is very unfortunate that this topic "wxPython vs. Tkinter" has > drifted to another flame war, as there is really no point in this kind > of discussion. I don't think it's wxPython that's causing the flames in this thread :) From bryan.oakley at gmail.com Wed Jan 26 22:36:24 2011 From: bryan.oakley at gmail.com (Bryan) Date: Wed, 26 Jan 2011 19:36:24 -0800 (PST) Subject: Need GUI pop-up to edit a (unicode ?) string References: <3tqr08-bj2.ln1@murmur.very.softly> <7691fe98-37af-4ddf-a8a8-eadeef0d4a6e@y2g2000prf.googlegroups.com> <541c02df-b1fc-4376-bf17-e0531fe5c4bf@r29g2000yqj.googlegroups.com> Message-ID: <9d072d4b-325e-4b41-82ef-d97d8cfd3c5a@y11g2000yqa.googlegroups.com> On Jan 25, 5:02?pm, rantingrick wrote: > On Jan 25, 3:54?pm, Bryan wrote: > ... And you people wonder why i hate Tkinter! Honestly, I don't think anyone wonders why _you_ hate Tkinter, you've made that abundantly clear. From wuwei23 at gmail.com Wed Jan 26 22:53:16 2011 From: wuwei23 at gmail.com (alex23) Date: Wed, 26 Jan 2011 19:53:16 -0800 (PST) Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com><9MB%o.14110$%64.6074@unlimited.newshosting.com><5a5e15f3-ae0f-4561-8969-e9afde3829dc@g26g2000vba.googlegroups.com><1b955dcf-77e2-4130-9b5b-276cfedccd9c@a10g2000vby.googlegroups.com> <4d3fa153$0$29983$c3e8da3$5496439d@news.astraweb.com> Message-ID: <880f2a34-52a2-4e49-a12c-02c8062dd23e@e13g2000yqb.googlegroups.com> "Octavian Rasnita" wrote: > I am sorry if I offended someone, but the main idea I just wanted to express > was that Python should promote the accessibility and deprecate those tools > which are not accessible. That's all. Thank you, I was having a hard time understanding your position from the 3,493,027 posts you made to this thread reiterating that point. From rustompmody at gmail.com Wed Jan 26 22:54:29 2011 From: rustompmody at gmail.com (rusi) Date: Wed, 26 Jan 2011 19:54:29 -0800 (PST) Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com> <9MB%o.14110$%64.6074@unlimited.newshosting.com> <4A48EDF6D7634F2E994661A457451E87@teddy> <753A4C5A6658470085804B13C80340F2@octavian> Message-ID: <9a799be3-e4d9-4f64-9bf9-194eca79256f@r5g2000yql.googlegroups.com> On Jan 27, 3:35?am, rantingrick wrote: > On Jan 26, 3:48?pm, Grant Edwards wrote: > > > People will not separate your personality from the cause you espouse. > > You may not like it, but that's a fact. ?If you are in favor of XYZ, > > and act rude and insulting while espousing XYZ, people will react > > against not only you but _also_ XYZ. > > A certain small subset of any group will always be emotionally driven. > However we should not concern ourselves with this sort of non- > objectivity. Some people make rash decisions not based in reality. > What we *should* concern ourselves with is fostering pure objectivity. > Because objectivity is the virtue of intelligent beings. Objectivity > fosters creativity of which progress is the direct progeny. Man is a rational animal. All my life I've been trying to find evidence of this -- Bertrand Russel From me+list/python at ixokai.io Wed Jan 26 23:48:28 2011 From: me+list/python at ixokai.io (Stephen Hansen) Date: Wed, 26 Jan 2011 20:48:28 -0800 Subject: Need GUI pop-up to edit a (unicode ?) string In-Reply-To: <541c02df-b1fc-4376-bf17-e0531fe5c4bf@r29g2000yqj.googlegroups.com> References: <3tqr08-bj2.ln1@murmur.very.softly> <7691fe98-37af-4ddf-a8a8-eadeef0d4a6e@y2g2000prf.googlegroups.com> <541c02df-b1fc-4376-bf17-e0531fe5c4bf@r29g2000yqj.googlegroups.com> Message-ID: <4D40F91C.7060208@ixokai.io> On 1/25/11 3:02 PM, rantingrick wrote: > This is a major flaw in the design and i would be > happy to fix the flaw. However our "friend" Fredrick decided to > copyright the module to himself! What a jerk! Which is quite > disgusting considering that Tkinter, and TclTk are completely open > source! Uh. ... LOL. Copyright doesn't mean what you think it means. Tkinter is copyrighted. Python is copyrighted. Tcl/TK is copyrgithed. In fact: everything that is "open source" is copyrighted. By definition[* see footnote]. Open source is simply copyrighted material that has been released under a *license* that allows you to copy it, too: sometimes with some significant catches (i.e., GPL), sometimes with basically no strings at all except not to sue (i.e., MIT). So. Its a major flaw? Well! Go fix it, you have every right to. Python's source is released under a rather liberal license, allowing you to do just about anything you want with it. Including fix it and even-- gasp-- submit those fixes to the bug-tracker for inclusion. -- Stephen Hansen ... Also: Ixokai ... Mail: me+list/python (AT) ixokai (DOT) io ... Blog: http://meh.ixokai.io/ * Some software has no copyright, such as SQLITE: it has been released into the public domain. But that is exceedingly rare, and can be a bit complicated as public domain and its meaning varies from jurisdiction to jurisdiction. Whereas copyright is pretty standard across the board and subject to a whole lot of international treaties. I'm really not sure you can legitimately call public domain software open source: its free to use, modify, and do anything you want with (provided you're in a jurisdiction which recognizes public domain), but it has its own particular legal ... issues. Then again, IANAL. -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 487 bytes Desc: OpenPGP digital signature URL: From rantingrick at gmail.com Thu Jan 27 00:11:28 2011 From: rantingrick at gmail.com (rantingrick) Date: Wed, 26 Jan 2011 21:11:28 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <8q7sgiF5tpU1@mid.individual.net> <19891784-d6a3-41ac-a097-5902a6323bc0@o21g2000prn.googlegroups.com> <0b12cdb1-45b4-41e4-9bdb-074ee669d76b@k14g2000pre.googlegroups.com> <7bb56aba-0f96-4b7e-a78d-3398003a0e38@c39g2000yqi.googlegroups.com> Message-ID: <2cb3435a-b489-40f5-8392-1edb47ff1311@o10g2000vbg.googlegroups.com> On Jan 26, 8:59?pm, alex23 wrote: > This is, what, the 3rd? 4th? year of his endless tirade > against TKinter. Alex, i have not been against Tkinter for 4 years. I just recently realized (about a year ago) the limitations of Tkinter and started thinking of alternatives. Tip of the day: Before misrepresenting someone's position and overshooting an estimate by three years, first make sure you've actually read most of what they have written. HTH From rantingrick at gmail.com Thu Jan 27 00:12:40 2011 From: rantingrick at gmail.com (rantingrick) Date: Wed, 26 Jan 2011 21:12:40 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com><63eea$4d3cd2fd$4275d90a$14984@FUSE.NET><69465430-08b3-4069-99c7-72f4d3034c66@s5g2000yqm.googlegroups.com><705ad$4d3ce0fc$4275d90a$29144@FUSE.NET> <2sm%o.8695$gM3.6118@viwinnwfe01.internal.bigpond.com> <0c3c61b0-d056-4757-b7e4-fecdf9a6e217@fm22g2000vbb.googlegroups.com> <94c48579-aed0-4987-aaa4-0f7b6209d9bb@8g2000prt.googlegroups.com> Message-ID: <704dd789-0eb2-4a33-9f2b-2363d3f5793f@s18g2000vbe.googlegroups.com> On Jan 26, 9:11?pm, alex23 wrote: > rantingrick wrote: > > Not if we used the underlying MS library! Windows has such a rich > > library why not use it? Why must we constantly re-invent the wheel? > > Isn't restricting a GUI toolkit to just one of the major OSes the > absolute opposite of 'accessible'? You'll need to read that snippet in context to understand what i was talking about. Again, see my "tip of the day" in my last post to you. From orasnita at gmail.com Thu Jan 27 02:02:41 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Thu, 27 Jan 2011 09:02:41 +0200 Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <8q7sgiF5tpU1@mid.individual.net> <19891784-d6a3-41ac-a097-5902a6323bc0@o21g2000prn.googlegroups.com><0b12cdb1-45b4-41e4-9bdb-074ee669d76b@k14g2000pre.googlegroups.com> <048FB74272D440A0915ABC7D76AE262B@teddy> <5782E9AD8A8342D691EB3549E5E0ED7B@octavian> Message-ID: <43549D4396F34EA697C45AA40EA12BC8@octavian> From: "Robert Kern" > in? Robin Dunn is the wxPython project lead. Ok, in this case I understand why WxPython can't be included in stdlib. I think there was a communication problem because the oldest list members start with the idea that all the list members know who is who and they may be thinking that I don't want to accept the reality or that I have bad feelings about some list members or something like that. > There is a large difference between the being "promoted by Python" and > being "included in Python's standard library. The latter is the issue at > hand, not the former. wxPython is already "promoted" by Python's > documentation: If there is a bigger chance that a beginner start using Tkinter without knowing its issues, this means that Python promotes the wrong tool. As I said, the main issue is not that Python doesn't promote WxPython. I have even suggested that Python might not include any GUI if this would be prefered, but what's wrong is that Python promotes a GUI which is not accessible by including it as a default GUI. As we all know, Python doesn't care too much about maintaining a backward compatibility and there are much many other things which are not compatible between different Python versions, but some Python programmers consider this a virtue because they say that what was wrong was eliminated. If they are right, then why wouldn't be a good idea to also remove a wrong GUI lib? Just because the majority prefers it? Octavian From orasnita at gmail.com Thu Jan 27 02:12:18 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Thu, 27 Jan 2011 09:12:18 +0200 Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com><9MB%o.14110$%64.6074@unlimited.newshosting.com> <59F6E65E3D9A46AD8D7A3863F3C1DC84@teddy> <27f53f8c-7862-4366-9352-82ae9a2f3970@k3g2000yqc.googlegroups.com> <718D13777F254C839F9564BC4275DE0A@octavian> <4D402C42.1030407@tysdomain.com> <4D40447C.4010108@tysdomain.com><33C68A0874BE4C66AB478EDFB64C2C1D@teddy> <4D407321.3090705@web.de> Message-ID: From: "Alexander Kapps" > Please don't use the lower Linux user percentage as an argument here. If > you follow that path further, you would need to agree that it's only an > "insignificant" percent of people who need a screen reader, so why bother? I didn't say that the Linux users or Mac users are not important. MFC or standard Win32 GUI is better accessible than wxWIDGETS but I considered that wxWIDGETS should be prefered (and not only Win32 controls) because it is *portable*, exactly because it also work on other platforms than Windows. But this doesn't mean that giving the most used screen reader as an example for testing the inaccessibility of Tk is not something that should be done (especially that Tk-based GUIS are inaccessible for other screen readers also.) Octavian From orasnita at gmail.com Thu Jan 27 02:14:17 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Thu, 27 Jan 2011 09:14:17 +0200 Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com><9MB%o.14110$%64.6074@unlimited.newshosting.com> <59F6E65E3D9A46AD8D7A3863F3C1DC84@teddy> <27f53f8c-7862-4366-9352-82ae9a2f3970@k3g2000yqc.googlegroups.com> <718D13777F254C839F9564BC4275DE0A@octavian> <4D402C42.1030407@tysdomain.com> <4D40447C.4010108@tysdomain.com><33C68A0874BE4C66AB478EDFB64C2C1D@teddy> <4D407333.1070301@tysdomain.com> Message-ID: <82865E7A54C048C398B4F4160FC43B57@octavian> From: "Littlefield, Tyler" > It doesn't support a good voice synthesizer like Eloquence or IBM Via > voice, but only eSpeak which sounds horrible, it doesn't have a scripting > language > ready to use as JAWS and Window Eyes do, it doesn't offer the possibility > of reading with the mouse cursor as JAWS does with its so called JAWS > cursor, > it offers a poor accessibility in many applications and many other issues. > > > You are wrong, on all accounts. I have specificly asked about these things on the NVDA mailing list at the end of the last year, and I have also tried NVDA and all those things are very true. Which are those "wrong" things? Octavian From orasnita at gmail.com Thu Jan 27 02:23:28 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Thu, 27 Jan 2011 09:23:28 +0200 Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com><9MB%o.14110$%64.6074@unlimited.newshosting.com><4A48EDF6D7634F2E994661A457451E87@teddy><753A4C5A6658470085804B13C80340F2@octavian> Message-ID: <1415933D9839404492EBA93213DD5F05@octavian> From: "geremy condra" The bottom line is that, yes, you do still have to convince people that accessibility is important if you want them to do anything about it. I have to do almost exactly the same thing in my field- everybody knows that security is important, but every time I go to disclose a vulnerability I have to be very careful if I want to convince the vendor to fix the problem. During those discussions, an ounce of civility is worth more than ten tons of righteousness, not only because it helps convince people to do what you want but because they frequently walk away from it feeling good about the experience and eager to not make the same mistake again. Yes you might be right. It is just my way of communicating and it might be too direct and some people might not like it. I always consider the expressions like "How do you do" as having absolutely no value, because they are just nice expressions made for easing the communication, but yes, most people seem to like them and don't like to discuss directly about the sensible problems. As the other list members have started thinking that I know who is who and they thought that I should understand why WxPython can't be included, I have made the same mistake by thinking that the others are really aware about the importance of accessibility. But you are right, this may be a mistake from my part too and I am sorry if I offended somebody. Octavian From orasnita at gmail.com Thu Jan 27 02:28:15 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Thu, 27 Jan 2011 09:28:15 +0200 Subject: WxPython versus Tkinter. References: <4D4093AF.80806@etrix.com.au> Message-ID: From: "Brendan Simon (eTRIX)" > Since it seems the python motto is "Batteries included", then it would > seem to me that wxPython is the natural fit as it also has "Batteries > included" (e.g. accessibility, native look-n-feel, mature and evolving, > can produce simple or complex gui programs, etc, etc). Yes Brendan, you are perfectly right, but unfortunately WxPython developers don't want to have it included in the stdlib. Finally I understood that this is the main problem, because if they would want to do it in the conditions imposed by Python, it would have been much easier and many of other problems could have been solved. But WxPython is their work and they decision is their. Octavian From orasnita at gmail.com Thu Jan 27 03:13:02 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Thu, 27 Jan 2011 10:13:02 +0200 Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com><9MB%o.14110$%64.6074@unlimited.newshosting.com><4A48EDF6D7634F2E994661A457451E87@teddy><753A4C5A6658470085804B13C80340F2@octavian> Message-ID: From: "Grant Edwards" > And, based on your behavior, you apparently don't like convincing > others or advancing the cause of accessibility. It seems you prefer to > annoy and alienate others. >From what I said, what was annoying? >> I don't want to convince anyone, but I just want to inform the others >> and let them know if they are doing something not recommended. > > IOW, you don't really care about increasing accessibility, you just > want to hear the sound of your own voice as you shout into the wind. Where have you seen that I don't care about accessibility? I say that I don't need to convince because today everyone should be convinced about accessibility, because we are talking with programmers here, not with cow-boys. >> but is that atitude worst than of those who don't care about >> discriminatory practices? > > Yes, it is worse. People who don't care are neither helping nor > hurting your cause. However, you're actively hurting it. I was talking *only* to those who care and I just informed them that Tkinter is not accessible. Was that so bad or so impolitely as you said? Do you think that there are so many those who don't care (even on this list) and I hurt them? Do you think that I should care about the feeling of those who don't care about the accessibility? Do you think that they have bigger problems than those who are hurt by lack of care? > People will not separate your personality from the cause you espouse. Wow! that's really bad. I thought that I might find here people that might have something against my opinions, that is very normal, that's why we are discussing, but I didn't think that I will also find people that will have something against me, just because of my opinions. I know people with different political opinions, with different programming languages preferences, that like other kind of women, that prefer other kkind of food, with whom I have often philosophical debates often, but whith whom I can be a good friend and collaborator and co-worker for some projects. > You may not like it, but that's a fact. If you are in favor of XYZ, > and act rude and insulting while espousing XYZ, people will react > against not only you but _also_ XYZ. I know what you are reffering to. :-) And I was hoping that there won't be people that don't like me personally for what I think about some things that have nothing related to them personally. But I don't say that you are wrong. After some reactions on the list I can say that you might be really right. Octavian From orasnita at gmail.com Thu Jan 27 03:17:36 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Thu, 27 Jan 2011 10:17:36 +0200 Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com><9MB%o.14110$%64.6074@unlimited.newshosting.com><4A48EDF6D7634F2E994661A457451E87@teddy><753A4C5A6658470085804B13C80340F2@octavian> <4D40A97F.8090209@tysdomain.com> Message-ID: <00ABBA322416409EB749102EB1CC5E61@octavian> From: "Littlefield, Tyler" > >I don't want to convince anyone, but I just want to inform the others > and let >them know if they are doing something not recommended. > not recommended by -you-, which is different than by a community or the > subset of people you are attempting to represent. furthermore, your > attidude is that of "comply to my definition of what is needed, or you are > selfish, rude, mean, cruel, etc." Then when that fails, you try cramming > words in people's mouth to make them feel like they kick puppies, and to > bring everyone else to this same conclusion. We are talking about accessibility here. Are you saying that Tkinter can be recommended from the perspective of accessibility? Octavian From steve+comp.lang.python at pearwood.info Thu Jan 27 04:03:29 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 27 Jan 2011 09:03:29 GMT Subject: use class factory to set required class variables? References: Message-ID: <4d4134e1$0$29983$c3e8da3$5496439d@news.astraweb.com> On Wed, 26 Jan 2011 13:37:20 -0800, Alan wrote: > I have a class ``A`` that is intentionally incomplete: it has methods > that refer to class variables that do not exist. For the record, in Python it is usual to refer to "attributes" rather than "class variables" and "instance variables". In Python, classes are first-class objects (pun not intended) like ints, strings, floats etc., and so a "class variable" would be a variable holding a class, just as a string variable would be a variable holding a string, an int variable holds an int, etc. > The class ``A`` has > several complicated methods, a number of which reference the "missing" > class variables. Obviously, I do not directly use ``A``. This is called an abstract class -- you need to subclass it to use it. > I have a class factory ``f``` that subclasses ``A`` *only* in order to > define the class variables. > > The motivation/problem: > I did this because I need many versions of class ``A``, which differ > only in the class variables, which are not known until run time. > > Q: On the face of it, did I pick a reasonable solution to my problem? > If so is this a standard pattern? If not, can you mention a better > approach? You have a class factory which subclasses an abstract class. Seems perfectly reasonable to me. More than reasonable -- it sounds like a *good* way of dealing with the problem. -- Steven From alice at gothcandy.com Thu Jan 27 04:04:07 2011 From: alice at gothcandy.com (=?utf-8?Q?Alice_Bevan=E2=80=93McGregor?=) Date: Thu, 27 Jan 2011 01:04:07 -0800 Subject: how to read the last line of a huge file??? References: Message-ID: On 2011-01-26 02:59:26 -0800, Xavier Heruacles said: > I have do some log processing which is usually huge. The length of each > line is variable. How can I get the last line?? Don't tell me to use > readlines or something like linecache... This is not optimum or efficient, but it works! If you want to see what's going on, use 4 instead of 4096 and 8 instead of 8192 and add a print statement to the bottom of the while loop. :) import os with open('biglogfile.log', 'r') as fh: fh.seek(-4096, os.SEEK_END) buffer = fh.read(4096) # We are expecting a trailing newline. while "\n" not in buffer[:-1]: fh.seek(-8192, os.SEEK_CUR) buffer = fh.read(4096) + buffer # Eliminate empty lines, they aren't useful. lines = [line for line in buffer.split('\n') if line] print lines[-1] ? Alice. :) From list at qtrac.plus.com Thu Jan 27 05:06:53 2011 From: list at qtrac.plus.com (Mark Summerfield) Date: Thu, 27 Jan 2011 02:06:53 -0800 (PST) Subject: Decorator question References: <5c4ce9cb-c68d-457e-ad63-c320f3a46224@p7g2000prb.googlegroups.com> Message-ID: <0e8f26be-eb7b-414b-8fa3-e639c7943ba4@m20g2000prc.googlegroups.com> On Jan 27, 2:42?am, "Thomas L. Shinnick" wrote: > At 08:17 PM 1/26/2011, Chris wrote: > > >I have a class (A, for instance) that possesses a boolean (A.b, for > >instance) that is liable to change over an instance's lifetime. > > >Many of the methods of this class (A.foo, for instance) should not > >execute as long as this boolean is false, but should instead raise an > >exception. > > >Can I use a decorator to implement this functionality? ?More exactly, > >could I define a function called 'checker' that accomplishes this: > > Mark Summerfield's book "Programming in Python 3" has an example > something like this (p.357) called 'positive_result'. ? I hesitate to > quote the entire thing, so I'll quote only the inner 'half' of the decorator: > ? ? ? ? ?def wrapper(*args, **kwargs): > ? ? ? ? ? ? ?result = function(*args, **kwargs) > ? ? ? ? ? ? ?assert result >= 0, function.__name__ + "() result isn't >= 0" > ? ? ? ? ? ? ?return result > > I would guess you would have to count on the first item in the > methods' args to be self, and use that to test whether your attribute > is false/true? > > Mark? > > >def checker(f): > > ? ? ... > > >class A(): > > > ? ? b = True > > > ? ? @checker > > ? ? def foo(self,...): > > ? ? ? ? print 'in foo' > > >a = A() > >a.foo() > >a.b = False > >a.foo() > > >would result in: > > >'in foo' > >Exception: ... > > >This exact solution isn't necessary, just something that doesn't > >require me to have the clunky: > > >def foo(self,...): > > ? ? if self.b: > > ? ? ? ? ... > > ? ? else: raise Exception('b attribute must be true before executing > >this method') > > >in every method. > > >Thanks, > > >Chris Here's a simple example that I think does what you're after: ########################################## #!/usr/bin/env python3 import functools def execute_if_valid(function): @functools.wraps(function) def wrapper(*args, **kwargs): if not args[0].valid: raise Exception("invalid instance") return function(*args, **kwargs) return wrapper class A: valid = True def foo(self): print("called foo() on a valid or invalid instance") @execute_if_valid def bar(self): print("called bar() on a valid instance") a = A() a.foo() a.bar() a.valid = False a.foo() a.bar() ########################################## Here's its output: ########################################## called foo() on a valid or invalid instance called bar() on a valid instance called foo() on a valid or invalid instance Traceback (most recent call last): File "./test.py", line 32, in a.bar() File "./test.py", line 10, in wrapper raise Exception("invalid instance") Exception: invalid instance ########################################## From jeanmichel at sequans.com Thu Jan 27 05:15:37 2011 From: jeanmichel at sequans.com (Jean-Michel Pichavant) Date: Thu, 27 Jan 2011 11:15:37 +0100 Subject: use class factory to set required class variables? In-Reply-To: References: Message-ID: <4D4145C9.6060106@sequans.com> Alan wrote: > I have a class ``A`` that is intentionally incomplete: > it has methods that refer to class variables that do not exist. > The class ``A`` has several complicated methods, a number > of which reference the "missing" class variables. > Obviously, I do not directly use ``A``. > > I have a class factory ``f``` that subclasses ``A`` *only* in > order to define the class variables. > > The motivation/problem: > I did this because I need many versions of class ``A``, > which differ only in the class variables, which are not > known until run time. > > Q: On the face of it, did I pick a reasonable solution to > my problem? If so is this a standard pattern? If not, > can you mention a better approach? > > My solution is working for me, but the class ``A`` > is bugging me, because of the odd (to me) way in > which it is incomplete. Obviously, I'm not a > computer science type ... > > Thanks, > Alan Isaac > > Your design is perfectly fine. A is an abstract class, aka interface class. This is a very common pattern, that can solve many problems. However, and this is a personal advice, try to declare all the required attributes/methods in the abstract class, setting them to None or raising a NotImplementedError. That would help anyone, including you, to know what is required to define when subclassing A. class A: A_VALUE = None def aMethod(self): raise NotImplementedError() FYI, there is a python module that provide some feature to enhance your abstract classes: http://docs.python.org/library/abc.html. These are more advanced features, you may just ignore that module for now. JM From g.rodola at gmail.com Thu Jan 27 05:35:41 2011 From: g.rodola at gmail.com (=?ISO-8859-1?Q?Giampaolo_Rodol=E0?=) Date: Thu, 27 Jan 2011 11:35:41 +0100 Subject: WxPython versus Tkinter. In-Reply-To: <4D4093AF.80806@etrix.com.au> References: <4D4093AF.80806@etrix.com.au> Message-ID: wxPython is not suitable for inclusion for many reasons. One reason is that it is a *huge* library which requires a lot of constant work (bugfixing, documentation, lots of commits, etc...) which cannot weight on python development. Keeping the two worlds separated is better for both of them, especially for wxPython which doesn't have to follow the strict politics surrounding the python stdlib. For example, wxPython is free to break some API backward compatibility on every new major version if this is desired. Such a thing couldn't happen if it were in the stdlib for obvious reasons. --- Giampaolo http://code.google.com/p/pyftpdlib/ http://code.google.com/p/psutil/ 2011/1/26 Brendan Simon (eTRIX) : > Since it seems the python motto is "Batteries included", then it would seem > to me that wxPython is the natural fit as it also has "Batteries included" > (e.g. accessibility, native look-n-feel, mature and evolving, can produce > simple or complex gui programs, etc, etc). > > -- > Brendan Simon > www.etrix.com.au > > -- > http://mail.python.org/mailman/listinfo/python-list > From jeanmichel at sequans.com Thu Jan 27 05:44:03 2011 From: jeanmichel at sequans.com (Jean-Michel Pichavant) Date: Thu, 27 Jan 2011 11:44:03 +0100 Subject: Executing multiple subprocesses and waiting In-Reply-To: <106dca00-5ad8-4f10-af99-01525e72f9fb@z26g2000prf.googlegroups.com> References: <106dca00-5ad8-4f10-af99-01525e72f9fb@z26g2000prf.googlegroups.com> Message-ID: <4D414C73.9000503@sequans.com> JB wrote: > One of my python scripts that takes a bunch of inputs from a tKinter > gui, generates a set of command line stings, and then threads them off > to subprocess for calls to other programs like Nuke and our render > farm has recently started randomly crashing pythonw.exe. > > I'm taking a look at my threading setup and attempting to clean it up. > I was wondering what a smart way of doing what I describe is? Take a > list of strings containing command line calls to other programs, > process them one at a time (waiting for the previous one to complete > before starting the next) and then finishing elegantly. Currently, the > gui passes them all to a "workerThread" which loops through each > string, sending it to a "processThread" which makes a call to > subprocess to execute it. > > This has worked fine for over a year so the recent crashing is > mystifying me. I'm wondering if it's increased network stress (we've > grown) or something similar? > > Any thoughts and suggestions on waiting for threads to complete are > appreciated. > Google 'Python execnet'. The main purpose of this module is to execute jobs on a bunch of different machines. However by simply declaring your local as unique available gateway, execnet will take care of queueing the jobs on your local. Look for examples with 'Popen' type gateways. I love this module, (and any other that are doing the network stuff for you). JM From python at bdurham.com Thu Jan 27 06:33:27 2011 From: python at bdurham.com (python at bdurham.com) Date: Thu, 27 Jan 2011 06:33:27 -0500 Subject: WxPython versus Tkinter. In-Reply-To: References: <4D3E4377.3060807@tysdomain.com><9MB%o.14110$%64.6074@unlimited.newshosting.com> <59F6E65E3D9A46AD8D7A3863F3C1DC84@teddy> <27f53f8c-7862-4366-9352-82ae9a2f3970@k3g2000yqc.googlegroups.com> <718D13777F254C839F9564BC4275DE0A@octavian> <4D402C42.1030407@tysdomain.com> <4D40447C.4010108@tysdomain.com><33C68A0874BE4C66AB478EDFB64C2C1D@teddy><4D407321.3090705@web.de> Message-ID: <1296128007.17192.1417506961@webmail.messagingengine.com> Octavian, If I understand your message, you are frustrated with Tkinter because it doesn't support accessability. In several messages on this thread I pointed out that Tkinter can easily be made accessable under Linux and Mac OS X. Rather than throw out Tkinter entirely, why not work with the community to make Tkinter accessable under Windows. That sounds a lot easier than trying to fight for wxWidgets as a Tkinter replacement when so many good arguments have been made against this strategy. Malcolm From subscriptions at cagttraining.com Thu Jan 27 06:45:25 2011 From: subscriptions at cagttraining.com (Bill Felton) Date: Thu, 27 Jan 2011 06:45:25 -0500 Subject: use class factory to set required class variables? In-Reply-To: <4d4134e1$0$29983$c3e8da3$5496439d@news.astraweb.com> References: <4d4134e1$0$29983$c3e8da3$5496439d@news.astraweb.com> Message-ID: <5EFD8083-E2CE-4331-96CD-08C6A2C08CF7@cagttraining.com> On Jan 27, 2011, at 4:03 AM, Steven D'Aprano wrote: > On Wed, 26 Jan 2011 13:37:20 -0800, Alan wrote: > >> I have a class ``A`` that is intentionally incomplete: it has methods >> that refer to class variables that do not exist. > > For the record, in Python it is usual to refer to "attributes" rather > than "class variables" and "instance variables". In Python, classes are > first-class objects (pun not intended) like ints, strings, floats etc., > and so a "class variable" would be a variable holding a class, just as a > string variable would be a variable holding a string, an int variable > holds an int, etc. > Being nit-picky, this is a slightly flawed justification of the terminology. In Smalltalk, classes are first class objects (pun similarly not intended). Yet in Smalltalk we refer to class variables and instance variables. These are not necessarily variables that 'hold' classes. In fact, all classes are instances, and so all variables hold instances... So there's something not quite right about your 'first class objects ... so ... would be a ...'. This may well be a standard Python convention, and it is certainly not objectionable. But it isn't well-justified on the basis of the 'first-class-ness' of classes as objects... Best regards, Bill From ahsanbagwan at gmail.com Thu Jan 27 07:10:00 2011 From: ahsanbagwan at gmail.com (sl33k_) Date: Thu, 27 Jan 2011 04:10:00 -0800 (PST) Subject: Wrappers in python Message-ID: <2100032d-dd99-4b10-b445-76b5dd1efb91@r19g2000prm.googlegroups.com> What are wrappers? What entities do they wrap around? Struggling to understand the concept. From orasnita at gmail.com Thu Jan 27 07:21:06 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Thu, 27 Jan 2011 14:21:06 +0200 Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com><9MB%o.14110$%64.6074@unlimited.newshosting.com> <59F6E65E3D9A46AD8D7A3863F3C1DC84@teddy> <27f53f8c-7862-4366-9352-82ae9a2f3970@k3g2000yqc.googlegroups.com> <718D13777F254C839F9564BC4275DE0A@octavian> <4D402C42.1030407@tysdomain.com> <4D40447C.4010108@tysdomain.com><33C68A0874BE4C66AB478EDFB64C2C1D@teddy><4D407321.3090705@web.de> <1296128007.17192.1417506961@webmail.messagingengine.com> Message-ID: <1E1D9F437DC4497BAB23BFC5F4ED8DAF@octavian> From: > Octavian, > > If I understand your message, you are frustrated with Tkinter because it > doesn't support accessability. > > In several messages on this thread I pointed out that Tkinter can easily > be made accessable under Linux and Mac OS X. > > Rather than throw out Tkinter entirely, why not work with the community > to make Tkinter accessable under Windows. I am willing to help, but unfortunately I don't know neither TCL or C nor the technical details about the accessibility standards that need to be implemented. I am mainly a web/CLI programmer. I know Perl very well and I just started to also learn Python especially because Python is a little better than Perl for creating desktop apps for Windows. In these conditions, if I could be of any help, I am willing to contribute, but to be sincere I don't think that I would be a great help. If someone knows more about this field and thinks that I could be helpful however, I'd like to know. Octavian From jeanmichel at sequans.com Thu Jan 27 07:57:20 2011 From: jeanmichel at sequans.com (Jean-Michel Pichavant) Date: Thu, 27 Jan 2011 13:57:20 +0100 Subject: Wrappers in python In-Reply-To: <2100032d-dd99-4b10-b445-76b5dd1efb91@r19g2000prm.googlegroups.com> References: <2100032d-dd99-4b10-b445-76b5dd1efb91@r19g2000prm.googlegroups.com> Message-ID: <4D416BB0.4010405@sequans.com> sl33k_ wrote: > What are wrappers? > > What entities do they wrap around? > > Struggling to understand the concept. > We would need a little bit of a context to answer that question, you could be refering to differents things. I'll give it a try on one common usage for wrapper: A wrapper is a python module that interface between python and a 3rd party library offering a non python interface. Consider Google chart api. This is the native URL API: https://chart.googleapis.com/chart?cht=p3&chd=t:60,40&chs=250x100&chl=Hello|World pygooglechart is the python wrapper for that api, allowing you to get the same effect, using Python objects: from pygooglechart import PieChart3D # Create a chart object of 250x100 pixels chart = PieChart3D(250, 100) # Add some data chart.add_data([20, 10]) # Assign the labels to the pie data chart.set_pie_labels(['Hello', 'World']) # Print the chart URL print chart.get_url() Python wrapper allows users to write only python code, even when calling non python 3rd libraries. Another example of wrapper is pgdb. It allows you to interface with a postgreSQL database without knowing about the native interface, you can commit and fetch data from the database by writing python code only. Nice ! JM From roy at panix.com Thu Jan 27 08:55:21 2011 From: roy at panix.com (Roy Smith) Date: Thu, 27 Jan 2011 08:55:21 -0500 Subject: how to read the last line of a huge file??? References: Message-ID: In article , Alice Bevan???McGregor wrote: > On 2011-01-26 02:59:26 -0800, Xavier Heruacles said: > > > I have do some log processing which is usually huge. The length of each > > line is variable. How can I get the last line?? Don't tell me to use > > readlines or something like linecache... > > This is not optimum or efficient, but it works! If you want to see > what's going on, use 4 instead of 4096 and 8 instead of 8192 and add a > print statement to the bottom of the while loop. :) > > import os > > with open('biglogfile.log', 'r') as fh: > fh.seek(-4096, os.SEEK_END) > buffer = fh.read(4096) > > # We are expecting a trailing newline. > while "\n" not in buffer[:-1]: > fh.seek(-8192, os.SEEK_CUR) > buffer = fh.read(4096) + buffer > > # Eliminate empty lines, they aren't useful. > lines = [line for line in buffer.split('\n') if line] > print lines[-1] > > ??? Alice. :) Back in the old days, if you wanted to read a file backwards, you just used a tape drive that had read-reverse capability :-) From tyler at tysdomain.com Thu Jan 27 09:20:47 2011 From: tyler at tysdomain.com (Littlefield, Tyler) Date: Thu, 27 Jan 2011 07:20:47 -0700 Subject: WxPython versus Tkinter. Message-ID: <4D417F3F.8090101@tysdomain.com> >but what's wrong is that Python promotes a GUI which is not accessible by including it as a default GUI. You seem to have overlooked this multiple times and instead decided to shove words in my mouth and continue on your line of selfishness which is justified apparently now by the fact that you are ESL. I have mentioned many, many times that we work to make TKInter accessible; it is something I plan to start working on this weekend. But rather than that, you seem to still want to switch gui libraries in python, which I might add, will not happen over night, nor will the accessibilifying (my new word) TKInter. It's a process that will take time. So, I ask since you keep jumping around this point, what is wrong with fixing TKInter? -- Thanks, Ty From tyler at tysdomain.com Thu Jan 27 09:21:18 2011 From: tyler at tysdomain.com (Littlefield, Tyler) Date: Thu, 27 Jan 2011 07:21:18 -0700 Subject: WxPython versus Tkinter. Message-ID: <4D417F5E.9090203@tysdomain.com> Eloq is an add-on, but it does support it. >but only eSpeak which sounds horrible That's your personal preference. Plenty use and like ESpeak. >it doesn't have a scripting language ready to use as JAWS and Window Eyes do, Scripting is done in Python, (no, not some native scripting language), and are done as modules. You write your script in python, and off you go. Problem solved. >it doesn't offer the possibility of reading with the mouse cursor as JAWS does with its so called JAWS cursor, It's called flat review. Googling this term brings up a key reference at like the third or fourth result down. >it offers a poor accessibility in many applications Very very very wrong. It works better with some apps than Jaws does, and about as good in many others. NVDA (like all other readers, and any program for that matter) still does have problems, but none that you mentioned. >and many other issues. -other- says that there were issues to begin with; the only issue here is you promoting the most "widely used screen reader," because it's what you use, and you not being able to use google and do your homework before you start talking about products you know nothing of. -- Thanks, Ty From k.bx at ya.ru Thu Jan 27 09:25:03 2011 From: k.bx at ya.ru (kost BebiX) Date: Thu, 27 Jan 2011 16:25:03 +0200 Subject: how to read the last line of a huge file??? In-Reply-To: References: Message-ID: <125461296138303@web109.yandex.ru> 27.01.2011, 15:55, "Roy Smith" : > In article ;, > ?Alice Bevan?McGregor ; wrote: > >> ?On 2011-01-26 02:59:26 -0800, Xavier Heruacles said: >>> ?I have do some log processing which is usually huge. The length of each >>> ?line is variable. How can I get the last line?? Don't tell me to use >>> ?readlines or something like linecache... >> ?This is not optimum or efficient, but it works! ?If you want to see >> ?what's going on, use 4 instead of 4096 and 8 instead of 8192 and add a >> ?print statement to the bottom of the while loop. ?:) >> >> ?import os >> >> ?with open('biglogfile.log', 'r') as fh: >> ?????fh.seek(-4096, os.SEEK_END) >> ?????buffer = fh.read(4096) >> >> ?????# We are expecting a trailing newline. >> ?????while "\n" not in buffer[:-1]: >> ?????????fh.seek(-8192, os.SEEK_CUR) >> ?????????buffer = fh.read(4096) + buffer >> >> ?????# Eliminate empty lines, they aren't useful. >> ?????lines = [line for line in buffer.split('\n') if line] >> ?????print lines[-1] >> >> ?????????? Alice. ?:) > > Back in the old days, if you wanted to read a file backwards, you just > used a tape drive that had read-reverse capability :-) > > -- > http://mail.python.org/mailman/listinfo/python-list Yeah. And if you wanted to zoom image -- you just had to go couple steps closer to it) -- jabber: k.bx at ya.ru From tyler at tysdomain.com Thu Jan 27 09:25:24 2011 From: tyler at tysdomain.com (Littlefield, Tyler) Date: Thu, 27 Jan 2011 07:25:24 -0700 Subject: WxPython versus Tkinter. In-Reply-To: <00ABBA322416409EB749102EB1CC5E61@octavian> References: <4D3E4377.3060807@tysdomain.com><9MB%o.14110$%64.6074@unlimited.newshosting.com><4A48EDF6D7634F2E994661A457451E87@teddy><753A4C5A6658470085804B13C80340F2@octavian> <4D40A97F.8090209@tysdomain.com> <00ABBA322416409EB749102EB1CC5E61@octavian> Message-ID: <4D418054.8050002@tysdomain.com> >We are talking about accessibility here. Are you saying that Tkinter can be >recommended from the perspective of accessibility? See my comment about shoving words in people's mouths; I did not hint, nor did I come near saying that in that message. On 1/27/2011 1:17 AM, Octavian Rasnita wrote: > From: "Littlefield, Tyler" >> >I don't want to convince anyone, but I just want to inform the others >> and let >them know if they are doing something not recommended. >> not recommended by -you-, which is different than by a community or >> the subset of people you are attempting to represent. furthermore, >> your attidude is that of "comply to my definition of what is needed, >> or you are selfish, rude, mean, cruel, etc." Then when that fails, >> you try cramming words in people's mouth to make them feel like they >> kick puppies, and to bring everyone else to this same conclusion. > > > We are talking about accessibility here. Are you saying that Tkinter > can be recommended from the perspective of accessibility? > > Octavian > -- Thanks, Ty From philip at semanchuk.com Thu Jan 27 09:39:41 2011 From: philip at semanchuk.com (Philip Semanchuk) Date: Thu, 27 Jan 2011 09:39:41 -0500 Subject: help with multiprocessing pool In-Reply-To: References: Message-ID: <2A124DD5-95F2-4DE0-AB0F-5D3EA39A230B@semanchuk.com> On Jan 25, 2011, at 8:19 PM, Craig Yoshioka wrote: > Hi all, > > I could really use some help with a problem I'm having. Hiya Craig, I don't know if I can help, but it's really difficult to do without a full working example. Also, your code has several OS X-isms in it so I guess that's the platform you're on. But in case you're on Windows, note that that platform requires some extra care when using multiprocessing: http://docs.python.org/library/multiprocessing.html#windows Good luck Philip > I wrote a function that can take a pattern of actions and it apply it to the filesystem. > It takes a list of starting paths, and a pattern like this: > > pattern = { > InGlob('Test/**'):{ > MatchRemove('DS_Store'):[], > NoMatchAdd('(alhpaID_)|(DS_Store)','warnings'):[], > MatchAdd('alphaID_','alpha_found'):[], > InDir('alphaID_'):{ > NoMatchAdd('(betaID_)|(DS_Store)','warnings'):[], > InDir('betaID_'):{ > NoMatchAdd('(gammaID_)|(DS_Store)','warnings'):[], > MatchAdd('gammaID_','gamma_found'):[] }}}} > > so if you run evalFSPattern(['Volumes/**'],pattern) it'll return a dictionary where: > > dict['gamma_found'] = [list of paths that matched] (i.e. '/Volumes/HD1/Test/alphaID_3382/betaID_38824/gammaID_848384') > dict['warning'] = [list of paths that failed to match] (ie. '/Volumes/HD1/Test/alphaID_3382/gammaID_47383') > > Since some of these volumes are on network shares I also wanted to parallelize this so that it would not block on IO. I started the parallelization by using multiprocessing.Pool and got it to work if I ran the fsparser from the interpreter. It ran in *much* less time and produced correct output that matched the non-parallelized version. The problem begins if I then try to use the parallelized function from within the code. > > For example I wrote a class whose instances are created around valid FS paths, that are cached to reduce expensive FS lookups. > > class Experiment(object): > > SlidePaths = None > > @classmethod > def getSlidePaths(cls): > if cls.SlidePaths == None: > cls.SlidePaths = fsparser(['/Volumes/**'],pattern) > return cls.SlidePaths > > @classmethod > def lookupPathWithGammaID(cls,id): > paths = cls.getSlidePaths() > ... > return paths[selected] > > @classmethod > def fromGamaID(cls,id): > path = cls.lookupPathWithGammaID(id) > return cls(path) > > def __init__(self,path) > self.Path = path > ... > > ... > > If I do the following from the interpreter it works: > >>>> from experiment import Experiment >>>> expt = Experiment.fromGammaID(10102) > > but if I write a script called test.py: > > from experiment import Experiment > expt1 = Experiment.fromGammaID(10102) > expt2 = Experiment.fromGammaID(10103) > comparison = expt1.compareTo(expt2) > > it fails, if I try to import it or run it from bash prompt: > >>>> from test import comparison (hangs forever) > $ python test.py (hangs forever) > > I would really like some help trying to figure this out... I thought it should work easily since all the spawned processes don't share data or state (their results are merged in the main thread). The classes used in the pattern are also simple python objects (use python primitives). > > > These are the main functions: > > def mapAction(pool,paths,action): > merge = {'next':[]} > for result in pool.map(action,paths): > if result == None: > continue > merge = mergeDicts(merge,result) > return merge > > > def mergeDicts(d1,d2): > for key in d2: > if key not in d1: > d1[key] = d2[key] > else: > d1[key] += d2[key] > return d1 > > > def evalFSPattern(paths,pattern): > pool = Pool(10) > results = {} > for action in pattern: > tomerge1 = mapAction(pool,paths,action) > tomerge2 = evalFSPattern(tomerge1['next'],pattern[action]) > del tomerge1['next'] > results = mergeDicts(results,tomerge1) > results = mergeDicts(results,tomerge2) > return results > > the classes used in the pattern (InGlob,NoMatchAdd,etc.) are callable classes that take a single parameter (a path) and return a dict result or None which makes them trivial to adapt to Pool.map. > > Note if I change the mapAction function to: > > def mapAction(pool,paths,action): > merge = {'next':[]} > for path in paths: > result = action(path) > if result == None: > continue > merge = mergeDicts(merge,result) > return merge > > everything works just fine. > > > Thanks. > > > -- > http://mail.python.org/mailman/listinfo/python-list From emile at fenx.com Thu Jan 27 09:51:37 2011 From: emile at fenx.com (Emile van Sebille) Date: Thu, 27 Jan 2011 06:51:37 -0800 Subject: WxPython versus Tkinter. In-Reply-To: <43549D4396F34EA697C45AA40EA12BC8@octavian> References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <8q7sgiF5tpU1@mid.individual.net> <19891784-d6a3-41ac-a097-5902a6323bc0@o21g2000prn.googlegroups.com><0b12cdb1-45b4-41e4-9bdb-074ee669d76b@k14g2000pre.googlegroups.com> <048FB74272D440A0915ABC7D76AE262B@teddy> <5782E9AD8A8342D691EB3549E5E0ED7B@octavian> <43549D4396F34EA697C45AA40EA12BC8@octavian> Message-ID: On 1/26/2011 11:02 PM Octavian Rasnita said... > As we all know, Python doesn't care too much about maintaining a > backward compatibility Where'd you get this idea? Between v2 and v3 yes, that was the intent. But otherwise, I think there's another miscommunication behind this... See http://www.python.org/dev/peps/pep-0291/ Emile From bhell at spamfence.net Thu Jan 27 10:12:17 2011 From: bhell at spamfence.net (Benjamin Hell) Date: Thu, 27 Jan 2011 16:12:17 +0100 Subject: Which is the best book to learn python In-Reply-To: <53fd6f58-594e-48de-bc19-1408b4dcb580@29g2000prb.googlegroups.com> References: <188c0a9f-4e93-4fae-b3f9-e7c84f8030fd@v31g2000pri.googlegroups.com> <53fd6f58-594e-48de-bc19-1408b4dcb580@29g2000prb.googlegroups.com> Message-ID: <8qdgahFvmvU1@mid.individual.net> On 2011-01-26 01:43 , Luis M. Gonz?lez wrote: > On Jan 24, 2:09 pm, santosh hs wrote: >> i am beginner to python please tell me which is the best available >> reference for beginner to start from novice > > If you are a complete beginner to programming, I suggest start with a > tutorial such as "A Byte of Python" (google this). > I learned my first steps with Josh Cogliati's "Non-Programmers > Tutorial For Python" http://www.oopweb.com/Python/Documents/easytut/VolumeFrames.html Josh moved this tutorial to Wikibooks some years ago, where it has been improved since then. Today there are two versions, one for Python 2.x and one for Python 3: http://en.wikibooks.org/wiki/Non-Programmer's_Tutorial_for_Python_2.6 http://en.wikibooks.org/wiki/Non-Programmer's_Tutorial_for_Python_3 I have used it to introduce people to programming with very good results. If you want to get the maximum out of Lutz & Asher's "Learning Python", which is a very good book as well, you should have programmed in some way before. Ben From lukin.s.v at gmail.com Thu Jan 27 10:49:45 2011 From: lukin.s.v at gmail.com (Sergey Lukin) Date: Thu, 27 Jan 2011 16:49:45 +0100 Subject: Pickling/Unpickling python Exceptions Message-ID: Hi all, I'm migrating code from python 2.4 to python 2.6 and I've got into troubles with pickling/unpickling python Exceptions. The following code works fine in 2.4 but not in 2.6. See Exception1 example I have found on python mail list similar problem http://mail.python.org/pipermail/python-list/2009-December/1228773.html They recommend to use __reduce__. But this does not help as I'm getting different Exception class after pickle See Exception_with_reduce example I also have found possible solution to this problem here http://bugs.python.org/issue1692335 As a workaround they propose to pass Exception arguments into base class See Exception2 example But there is another problem. Constructor is called 2 times which is not acceptable to me. Could you please advice on the solution? ------------------------------------------ test program ------------------------------------------ import cPickle class Exception1(Exception): def __init__(self,arg1): print "constructor called" Exception.__init__(self) class Exception2(Exception): def __init__(self,arg1): print "constructor called" Exception.__init__(self,arg1) class Exception_with_reduce(Exception): def __reduce__(self): try: getnewargs = self.__getnewargs__ except AttributeError: newargs = (self.__class__,) else: newargs = (self.__class__,) + getnewargs() try: getstate = self.__getstate__ except AttributeError: state = self.__dict__ else: state = getstate() return (Exception, newargs, state) def __init__(self,arg1): print "constructor called" Exception.__init__(self,arg1) def test(E,args): try: print ">>",E.__name__ e = E(*args) print "- pickling" s = cPickle.dumps(e) print "- unpickling" e = cPickle.loads(s) if E != e.__class__: print "! failed: expected %s, got %s"%(E.__name__,e.__class__.__name__) except Exception, e: print "! failed:",e print "\ finished" print import os if os.path.isfile("/home/ast1/blabla"): try: s = open("/home/ast1/blabla","r").read() e = cPickle.loads(s) print e.__class__ except Exception, e: print "error:",e test(Exception1,[1]) test(Exception2,[1]) test(Exception_with_reduce,[1]) ------------------------------------------ ------------------------------------------ run results on python 2.6: ------------------------------------------ constructor called >> Exception1 constructor called - pickling - unpickling ! failed: ('__init__() takes exactly 2 arguments (1 given)', , ()) \ finished >> Exception2 constructor called - pickling - unpickling constructor called \ finished >> Exception_with_reduce constructor called - pickling - unpickling ! failed: expected Exception_with_reduce, got Exception \ finished ------------------------------------------ run results on python 2.4: ------------------------------------------ __main__.Exception2 >> Exception1 constructor called - pickling - unpickling \ finished >> Exception2 constructor called - pickling - unpickling \ finished >> Exception_with_reduce constructor called - pickling - unpickling \ finished -------------- next part -------------- An HTML attachment was scrubbed... URL: From orasnita at gmail.com Thu Jan 27 11:12:52 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Thu, 27 Jan 2011 18:12:52 +0200 Subject: WxPython versus Tkinter. References: <4D417F3F.8090101@tysdomain.com> Message-ID: From: "Littlefield, Tyler" > >but what's wrong is that Python promotes a GUI which is not accessible > by including it as a default GUI. > You seem to have overlooked this multiple times and instead decided to > shove words in my mouth and continue on your line of selfishness which > is justified apparently now by the fact that you are ESL. I have > mentioned many, many times that we work to make TKInter accessible; it > is something I plan to start working on this weekend. But rather than > that, you seem to still want to switch gui libraries in python, which I > might add, will not happen over night, nor will the accessibilifying (my > new word) TKInter. It's a process that will take time. So, I ask since > you keep jumping around this point, what is wrong with fixing TKInter? Hi Tyler, Nothing is wrong with adding accessibility to Tkinter. It is really great. What's wrong is that it is not available now and I believe only what I can see, because only what can be used now can be helpful. If Tkinter will be accessible in the future it will be very great, but it will be only in that moment. It is not now. Now we have just your promise that you will try to make Tk accessible but I think that you agree that for the moment this has no value for those who need accessibility. Octavian From me+list/python at ixokai.io Thu Jan 27 11:59:24 2011 From: me+list/python at ixokai.io (Stephen Hansen) Date: Thu, 27 Jan 2011 08:59:24 -0800 Subject: WxPython versus Tkinter. In-Reply-To: <43549D4396F34EA697C45AA40EA12BC8@octavian> References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <8q7sgiF5tpU1@mid.individual.net> <19891784-d6a3-41ac-a097-5902a6323bc0@o21g2000prn.googlegroups.com><0b12cdb1-45b4-41e4-9bdb-074ee669d76b@k14g2000pre.googlegroups.com> <048FB74272D440A0915ABC7D76AE262B@teddy> <5782E9AD8A8342D691EB3549E5E0ED7B@octavian> <43549D4396F34EA697C45AA40EA12BC8@octavian> Message-ID: <4D41A46C.8000308@ixokai.io> On 1/26/11 11:02 PM, Octavian Rasnita wrote: > As we all know, Python doesn't care too much about maintaining a > backward compatibility What? Nonsense. There are strict compatibility requirements. There was a one-time break with these; 2.x->3.x -- but that's it. It may never happen again. If another happens, its years down the road. If ever. -- Stephen Hansen ... Also: Ixokai ... Mail: me+list/python (AT) ixokai (DOT) io ... Blog: http://meh.ixokai.io/ -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 487 bytes Desc: OpenPGP digital signature URL: From ethan at stoneleaf.us Thu Jan 27 12:16:04 2011 From: ethan at stoneleaf.us (Ethan Furman) Date: Thu, 27 Jan 2011 09:16:04 -0800 Subject: WxPython versus Tkinter. In-Reply-To: <9a799be3-e4d9-4f64-9bf9-194eca79256f@r5g2000yql.googlegroups.com> References: <4D3E4377.3060807@tysdomain.com> <9MB%o.14110$%64.6074@unlimited.newshosting.com> <4A48EDF6D7634F2E994661A457451E87@teddy> <753A4C5A6658470085804B13C80340F2@octavian> <9a799be3-e4d9-4f64-9bf9-194eca79256f@r5g2000yql.googlegroups.com> Message-ID: <4D41A854.8090500@stoneleaf.us> On Jan 27, 3:35 am, rantingrick wrote: > A certain small subset of any group will always be emotionally driven. > However we should not concern ourselves with this sort of non- > objectivity. So, would this be like when rr disqualified himself by demanding posters have at least a 120 IQ? ;) ~Ethan~ From santosh.tronics at gmail.com Thu Jan 27 12:20:18 2011 From: santosh.tronics at gmail.com (santosh hs) Date: Thu, 27 Jan 2011 22:50:18 +0530 Subject: Which is the best book to learn python In-Reply-To: <4D3DB915.9060601@sequans.com> References: <188c0a9f-4e93-4fae-b3f9-e7c84f8030fd@v31g2000pri.googlegroups.com> <4D3DB915.9060601@sequans.com> Message-ID: I am very new to object oriented concept, so I need to learn everything frm basic, Will the above books fulfill My need On Monday, January 24, 2011, Jean-Michel Pichavant wrote: > santosh hs wrote: > > Hi All, > i am beginner to python please tell me which is the best available > reference for beginner to start from novice > > > > Hi, > > You could have searched the archive, this question was raised many times. > > http://wiki.python.org/moin/IntroductoryBooks > > I read "Learning Python" when I started. Since it's the only one I read I cannot tell you which one is the best (if there is). > Python is easy to learn, I'm not sure it's possible to write a bad book about it. > > JM > > From orasnita at gmail.com Thu Jan 27 12:22:55 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Thu, 27 Jan 2011 19:22:55 +0200 Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com><9MB%o.14110$%64.6074@unlimited.newshosting.com> <59F6E65E3D9A46AD8D7A3863F3C1DC84@teddy> <27f53f8c-7862-4366-9352-82ae9a2f3970@k3g2000yqc.googlegroups.com> <718D13777F254C839F9564BC4275DE0A@octavian> <4D402C42.1030407@tysdomain.com> <4D40447C.4010108@tysdomain.com><33C68A0874BE4C66AB478EDFB64C2C1D@teddy> <4D407333.1070301@tysdomain.com> <82865E7A54C048C398B4F4160FC43B57@octavian> <4D417EFC.70800@tysdomain.com> Message-ID: <57C3CFA0C7EE4578B0C6EAA267AAE678@teddy> From: "Littlefield, Tyler" > >It doesn't support a good voice synthesizer like Eloquence or IBM Via > voice > Eloq is an add-on, but it does support it. If you are saying this, it means that you haven't used it for a long time, or you just heard about it by searching on the web. Eloq is supported, but only as an unofficial hack because the NVDA developers pretend that it is illegally to offer support for Eloquence. They said that Nuance ask them to remove that support from NVDA, and as a consequence, the support for Eloquence was removed and it is harder to find the NVDA Eloquence driver from unofficial sources (and that unofficial support is not the same under all versions of NVDA...) > >but only eSpeak which sounds horrible > That's your personal preference. Plenty use and like ESpeak. That's my personal preference and the preference of all the blind people I know in my country with only one or two exceptions. (If you'd know Romanian, I could give you the address of a forum to ask there if you don't believe me.) And note that Eloquence doesn't support my native language, but eSpeak does it, however they still don't like eSpeak. Why do you think we don't like it? Because it is so good? > >it doesn't have a scripting language ready to use as JAWS and Window > Eyes do, > Scripting is done in Python, (no, not some native scripting language), > and are done as modules. You write your script in python, and off you > go. Problem solved. Have you done such a script for NVDA? I've created a sample script in Python that uses the COM interface and I have asked on the NVDA mailing list and on NVDA-dev mailing list if I can use it, but NVDA doesn't offer that feature yet. And I was saying that "NVDA doesn't have a scripting language ready to use". The scripting language can be Python, but it should accept a scripting code, easy to install with a copy/paste, not an NVDA patch. That means "ready to use". >it doesn't offer the possibility of reading with the mouse cursor as JAWS does with its so called JAWS cursor, It's called flat review. Googling this term brings up a key reference at like the third or fourth result down. Tyler, you are a Linux and Mac user and you search with Google and try to explain how many things you know about NVDA, but it is obviously that what JAWS can offer NVDA can't. That flat review can be used to read some things from the screen, and they say that it might also show the coordinates of the objects, however unlike JAWS, it can't show the coordinates of each character on the screen, and this is important by someone who is totally blind for checking the positions of different text elements on a web page, or in a desktop app. But NVDA can't be used for that. > the only issue here is you promoting the most "widely used screen reader," because it's what you use, and you not being able to use google and do your homework before you start talking about products you know nothing of. Tyler, the other list members sustain you because you are also against changing something in order to improve the accessibility and just promise that you will make Tk accessible, and I am sure they won't say anything about your atitude, but your atitude really sucks because it is obviously that you don't know many things about NVDA, and you haven't tried it, you even show that you don't care about the most used OS, you use Mac and Linux, but keep telling me that I don't know about it although I am an NVDA user for a long time. And all these useless phrases are just for answering to your useless hijack of the discussion, because we are not talking about NVDA here, but about the lack of accessibility in Tk-based applications, and Tk is as inaccessible in JAWS as in NVDA, Window Eyes or other screen readers, so it doesn't matter what screen reader we use for testing that inaccessibility. Octavian From mark at markroseman.com Thu Jan 27 12:31:08 2011 From: mark at markroseman.com (Mark Roseman) Date: Thu, 27 Jan 2011 10:31:08 -0700 Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> 0-47ef-a8b0-ca55d52ef683@1g20000qz.googlegroupssssss db3-4108-8a13-cc7d51f00b49@29g2200prb.googlegrooooooooo 5tpU1@mid.indivvvvvvvvvvv 784-d6a3-41ac-aa97-5902a6323bc00o21g2000prn.goooooooooooooooo <048FB74272D440A0915ABC7D76AE262B@teddy> <5782E9AD8A8342D691EB3549E5E0ED7B@octavian> Message-ID: Terry Reedy wrote: > Tk itself is purely a gui package -- abstract widgits, geometry placers > to make them visible, and an event system to make them active. But it > does have the baggage of needing tcl included. About a decade ago, some > people had the idea of removing the tcl dependency, but nothing seems to > have come of that. For some people, the tcl baggage is reason enough to > be rid of tk. Thanks for raising this point. While I don't want to exhaustively respond to this, I would like to raise a few important points. 1. The performance issues of having Tk use Tcl are negligible; the bulk of Tk (code-wise and time-wise) are spent in C. Tcl itself is also very fast nowadays, using all the usual techniques that modern dynamic languages use. 2. Some people do have moral/purity objections to including Tcl, and while I understand where the sentiment comes from, I think there are few solid engineering reasons for this. 3. Removing Tcl from Tk makes keeping up with changes in Tk very difficult. The Perl people found this out; Perl/Tk extracted Tcl, and as a result remained using a 10 year old version of Tk because upgrading would have been too painful. The newer Perl binding (Tkx) is in fact a ridiculously thin binding over the Tcl API, and makes keeping up to date with the newest Tk changes trivial, often requiring no code changes in the Perl binding. If anyone does have questions, comments or concerns about Python including a Tcl interpreter to use Tk, I'd be happy to try to explain or address them. Mark From invalid at invalid.invalid Thu Jan 27 12:47:14 2011 From: invalid at invalid.invalid (Grant Edwards) Date: Thu, 27 Jan 2011 17:47:14 +0000 (UTC) Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com> <9MB%o.14110$%64.6074@unlimited.newshosting.com> <4A48EDF6D7634F2E994661A457451E87@teddy> <753A4C5A6658470085804B13C80340F2@octavian> Message-ID: On 2011-01-27, Octavian Rasnita wrote: > Yes you might be right. It is just my way of communicating and it > might be too direct and some people might not like it. Too direct is putting it mildly. > I always consider the expressions like "How do you do" as having > absolutely no value, because they are just nice expressions made for > easing the communication, So you're saying that you don't see any value in easing communication, nor presumably in communication itself? > but yes, most people seem to like them and don't like to discuss > directly about the sensible problems. If you don't care about communicating with others, then being civil probably does have no value (except for keeping a job or being avoiding being beaten up on the playground). If you want to communicate (especially if you want somebody else to _do_ something), then being civil and following normal social rules (etiquette) is _very_ valuable. Without it the only thing you accomplish is to turn people against you and whatever you're saying. There is no inherent "value" in driving on the right side of the road vs. the left. However, there is a lot of value in driving on the side of road that others expect you to. I'd tell you to try driving on the other side of the road sometime to see how "easing communication" can be valuable, but I'm afraid you'd try it... -- Grant Edwards grant.b.edwards Yow! I'm RELIGIOUS!! at I love a man with gmail.com a HAIRPIECE!! Equip me with MISSILES!! From orasnita at gmail.com Thu Jan 27 12:54:15 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Thu, 27 Jan 2011 19:54:15 +0200 Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com><9MB%o.14110$%64.6074@unlimited.newshosting.com><4A48EDF6D7634F2E994661A457451E87@teddy><753A4C5A6658470085804B13C80340F2@octavian> <4D40A97F.8090209@tysdomain.com><00ABBA322416409EB749102EB1CC5E61@octavian> <4D418054.8050002@tysdomain.com> Message-ID: From: "Littlefield, Tyler" > >We are talking about accessibility here. Are you saying that Tkinter > can be >recommended from the perspective of accessibility? > See my comment about shoving words in people's mouths; I did not hint, > nor did I come near saying that in that message. But you asked who says that Tkinter is not recommended. Everything that's not accessible is not recommended. Tkinter should be at most accepted because there is no better solution, at least for Python 3, not because it is the recommended solution. Octavian From invalid at invalid.invalid Thu Jan 27 12:55:45 2011 From: invalid at invalid.invalid (Grant Edwards) Date: Thu, 27 Jan 2011 17:55:45 +0000 (UTC) Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com> <9MB%o.14110$%64.6074@unlimited.newshosting.com> <4A48EDF6D7634F2E994661A457451E87@teddy> <753A4C5A6658470085804B13C80340F2@octavian> Message-ID: On 2011-01-27, Octavian Rasnita wrote: > From: "Grant Edwards" >> And, based on your behavior, you apparently don't like convincing >> others or advancing the cause of accessibility. It seems you prefer to >> annoy and alienate others. > >>From what I said, what was annoying? > >>> I don't want to convince anyone, but I just want to inform the others >>> and let them know if they are doing something not recommended. >> >> IOW, you don't really care about increasing accessibility, you just >> want to hear the sound of your own voice as you shout into the wind. > > Where have you seen that I don't care about accessibility? You said that you don't care about convincing anybody either that accessibility is import or about convincing anybody to do anything about it. To me that means you don't care about accessiblity. >> People will not separate your personality from the cause you espouse. > > Wow! that's really bad. It's less than ideal, but it the way people are. Is that a surprise to you? > I thought that I might find here people that might have something > against my opinions, that is very normal, that's why we are > discussing, but I didn't think that I will also find people that will > have something against me, just because of my opinions. That's not what I said. I said that if you state your opininions in a rude, insulting, or disrepectful manner, that will turn people against your opinions regardless of the inherent value of the actual opinions themselves. This should not be a surprise to anybody over the age of three. > I know people with different political opinions, with different > programming languages preferences, that like other kind of women, > that prefer other kkind of food, with whom I have often philosophical > debates often, but whith whom I can be a good friend and collaborator > and co-worker for some projects. That's not what we're talking about. We're not talking about your opinions on some unrelated topic. We're talking about the manner in which you express your opinions on this topic. >> You may not like it, but that's a fact. If you are in favor of XYZ, >> and act rude and insulting while espousing XYZ, people will react >> against not only you but _also_ XYZ. > > I know what you are reffering to. :-) > > And I was hoping that there won't be people that don't like me > personally for what I think about some things that have nothing > related to them personally. Again, it's not your beliefs about other tops that are causing problems for you. What's causing problems is the manner in which you are expressing your beliefs about this topic. > But I don't say that you are wrong. After some reactions on the list > I can say that you might be really right. -- Grant Edwards grant.b.edwards Yow! I would like to at urinate in an OVULAR, gmail.com porcelain pool -- From invalid at invalid.invalid Thu Jan 27 12:57:50 2011 From: invalid at invalid.invalid (Grant Edwards) Date: Thu, 27 Jan 2011 17:57:50 +0000 (UTC) Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com> <9MB%o.14110$%64.6074@unlimited.newshosting.com> <59F6E65E3D9A46AD8D7A3863F3C1DC84@teddy> <27f53f8c-7862-4366-9352-82ae9a2f3970@k3g2000yqc.googlegroups.com> <718D13777F254C839F9564BC4275DE0A@octavian> <4D402C42.1030407@tysdomain.com> <4D40447C.4010108@tysdomain.com> <33C68A0874BE4C66AB478EDFB64C2C1D@teddy> <4D407321.3090705@web.de> <1296128007.17192.1417506961@webmail.messagingengine.com> Message-ID: On 2011-01-27, Octavian Rasnita wrote: > From: Octavian, > >> If I understand your message, you are frustrated with Tkinter because >> it doesn't support accessability. >> >> In several messages on this thread I pointed out that Tkinter can >> easily be made accessable under Linux and Mac OS X. >> >> Rather than throw out Tkinter entirely, why not work with the community >> to make Tkinter accessable under Windows. > > > I am willing to help, but unfortunately I don't know neither TCL or C > nor the technical details about the accessibility standards that need > to be implemented. I am mainly a web/CLI programmer. A very important way to help would be to test accessibility features and post accurate, detailed, bug-reports. -- Grant Edwards grant.b.edwards Yow! I'm not available at for comment.. gmail.com From invalid at invalid.invalid Thu Jan 27 13:04:09 2011 From: invalid at invalid.invalid (Grant Edwards) Date: Thu, 27 Jan 2011 18:04:09 +0000 (UTC) Subject: Need GUI pop-up to edit a (unicode ?) string References: <3tqr08-bj2.ln1@murmur.very.softly> <7691fe98-37af-4ddf-a8a8-eadeef0d4a6e@y2g2000prf.googlegroups.com> <541c02df-b1fc-4376-bf17-e0531fe5c4bf@r29g2000yqj.googlegroups.com> Message-ID: On 2011-01-27, Stephen Hansen wrote: > On 1/25/11 3:02 PM, rantingrick wrote: >> This is a major flaw in the design and i would be >> happy to fix the flaw. However our "friend" Fredrick decided to >> copyright the module to himself! What a jerk! Which is quite >> disgusting considering that Tkinter, and TclTk are completely open >> source! > > Uh. ... LOL. > > Copyright doesn't mean what you think it means. > > Tkinter is copyrighted. Python is copyrighted. Tcl/TK is copyrgithed. > > In fact: everything that is "open source" is copyrighted. By > definition[* see footnote]. One (domestic US) exception would be open-source software written by an employee of the US federal government. Works produced by the US Government are not copyrighted under US domestic copyright law. Such works are copyrighted under international law (which is probably what the Python maintainers care about). -- Grant Edwards grant.b.edwards Yow! Wow! Look!! A stray at meatball!! Let's interview gmail.com it! From orasnita at gmail.com Thu Jan 27 13:09:01 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Thu, 27 Jan 2011 20:09:01 +0200 Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <8q7sgiF5tpU1@mid.individual.net> <19891784-d6a3-41ac-a097-5902a6323bc0@o21g2000prn.googlegroups.com><0b12cdb1-45b4-41e4-9bdb-074ee669d76b@k14g2000pre.googlegroups.com> <048FB74272D440A0915ABC7D76AE262B@teddy> <5782E9AD8A8342D691EB3549E5E0ED7B@octavian> <43549D4396F34EA697C45AA40EA12BC8@octavian> Message-ID: <5858167B51BD4813A1D36C2D90D255F2@teddy> From: "Emile van Sebille" > On 1/26/2011 11:02 PM Octavian Rasnita said... > >> As we all know, Python doesn't care too much about maintaining a >> backward compatibility > > Where'd you get this idea? Between v2 and v3 yes, that was the intent. To be sincere I was thinking to the differences between Python 2 and 3. > But otherwise, I think there's another miscommunication behind this... It might be true, however I have seen some modules that say that are ment for Python 2.5, for 2.6 or for 2.7, so there seem to be differences between these versions also. py2exe offers the following installation kits, depending on the Python version. If you know, please tell me why there are different packages for different versions of Python? py2exe-0.6.9.win32-py2.5.exe py2exe-0.6.9.win32-py2.4.exe py2exe-0.6.9.win32-py2.3.exe py2exe-0.6.9.win32-py2.6.exe py2exe-0.6.9.win32-py2.7.exe Thanks. Octavian From rantingrick at gmail.com Thu Jan 27 13:11:55 2011 From: rantingrick at gmail.com (rantingrick) Date: Thu, 27 Jan 2011 10:11:55 -0800 (PST) Subject: WxPython versus Tkinter. References: <4D4093AF.80806@etrix.com.au> Message-ID: On Jan 27, 1:28?am, "Octavian Rasnita" wrote: > From: "Brendan Simon (eTRIX)" > > > Since it seems the python motto is "Batteries included", then it would > > seem to me that wxPython is the natural fit as it also has "Batteries > > included" (e.g. accessibility, native look-n-feel, mature and evolving, > > can produce simple or complex gui programs, etc, etc). > > Yes Brendan, you are perfectly right, but unfortunately WxPython developers > don't want to have it included in the stdlib. [...] > But WxPython is their work and they decision is their. Actually we don't want "Robins wxPython" in the stdlib "as is" anyway. What we DO want is an abstraction API for the short term that plugs into Robin's wx. Then over the long term we will either convince him to create a better API OR just create our own wxPython directly from WxWidgets and mold it into the stdlib. So hinging on the argument of what one *single* man thinks is a non-starter. We all respect Robin however python is greater then me, then you, and yes, EVEN Guido van Rossum! Python belongs to the world now. And what is best for Python's community AS A WHOLE is what we should be concerned about. From craigyk at me.com Thu Jan 27 13:12:37 2011 From: craigyk at me.com (Craig Yoshioka) Date: Thu, 27 Jan 2011 10:12:37 -0800 Subject: help with multiprocessing pool In-Reply-To: <2A124DD5-95F2-4DE0-AB0F-5D3EA39A230B@semanchuk.com> References: <2A124DD5-95F2-4DE0-AB0F-5D3EA39A230B@semanchuk.com> Message-ID: The code will be multi-platform. The OSXisms are there as an example, though I am developing on OS X machine. I've distilled my problem down to a simpler case, so hopefully that'll help troubleshoot. I have 2 files: test.py: -------------------------------------------------------------- from multiprocessing import Pool def square(x): return x*x def squares(numbers): pool = Pool(12) return pool.map(square,numbers) test2.py: -------------------------------------------------------------- from test import squares maxvalues = squares(range(3)) print maxvalues Now if I import squares into the interactive interpreter: from test import squares print squares(range(3)) I get the correct result, but if I try to import maxvalues from test2 the interactive interpreter python hangs. if I run the script from bash, though, it seems to run fine. I think it might have something to do with this note in the docs, though I am not sure how to use this information to fix my problem: Note: Functionality within this package requires that the __main__ method be importable by the children. This is covered inProgramming guidelines however it is worth pointing out here. This means that some examples, such as themultiprocessing.Pool examples will not work in the interactive interpreter. Thanks. On Jan 27, 2011, at 6:39 AM, Philip Semanchuk wrote: > > On Jan 25, 2011, at 8:19 PM, Craig Yoshioka wrote: > >> Hi all, >> >> I could really use some help with a problem I'm having. > > > Hiya Craig, > I don't know if I can help, but it's really difficult to do without a full working example. > > Also, your code has several OS X-isms in it so I guess that's the platform you're on. But in case you're on Windows, note that that platform requires some extra care when using multiprocessing: > http://docs.python.org/library/multiprocessing.html#windows > > > Good luck > Philip > > >> I wrote a function that can take a pattern of actions and it apply it to the filesystem. >> It takes a list of starting paths, and a pattern like this: >> >> pattern = { >> InGlob('Test/**'):{ >> MatchRemove('DS_Store'):[], >> NoMatchAdd('(alhpaID_)|(DS_Store)','warnings'):[], >> MatchAdd('alphaID_','alpha_found'):[], >> InDir('alphaID_'):{ >> NoMatchAdd('(betaID_)|(DS_Store)','warnings'):[], >> InDir('betaID_'):{ >> NoMatchAdd('(gammaID_)|(DS_Store)','warnings'):[], >> MatchAdd('gammaID_','gamma_found'):[] }}}} >> >> so if you run evalFSPattern(['Volumes/**'],pattern) it'll return a dictionary where: >> >> dict['gamma_found'] = [list of paths that matched] (i.e. '/Volumes/HD1/Test/alphaID_3382/betaID_38824/gammaID_848384') >> dict['warning'] = [list of paths that failed to match] (ie. '/Volumes/HD1/Test/alphaID_3382/gammaID_47383') >> >> Since some of these volumes are on network shares I also wanted to parallelize this so that it would not block on IO. I started the parallelization by using multiprocessing.Pool and got it to work if I ran the fsparser from the interpreter. It ran in *much* less time and produced correct output that matched the non-parallelized version. The problem begins if I then try to use the parallelized function from within the code. >> >> For example I wrote a class whose instances are created around valid FS paths, that are cached to reduce expensive FS lookups. >> >> class Experiment(object): >> >> SlidePaths = None >> >> @classmethod >> def getSlidePaths(cls): >> if cls.SlidePaths == None: >> cls.SlidePaths = fsparser(['/Volumes/**'],pattern) >> return cls.SlidePaths >> >> @classmethod >> def lookupPathWithGammaID(cls,id): >> paths = cls.getSlidePaths() >> ... >> return paths[selected] >> >> @classmethod >> def fromGamaID(cls,id): >> path = cls.lookupPathWithGammaID(id) >> return cls(path) >> >> def __init__(self,path) >> self.Path = path >> ... >> >> ... >> >> If I do the following from the interpreter it works: >> >>>>> from experiment import Experiment >>>>> expt = Experiment.fromGammaID(10102) >> >> but if I write a script called test.py: >> >> from experiment import Experiment >> expt1 = Experiment.fromGammaID(10102) >> expt2 = Experiment.fromGammaID(10103) >> comparison = expt1.compareTo(expt2) >> >> it fails, if I try to import it or run it from bash prompt: >> >>>>> from test import comparison (hangs forever) >> $ python test.py (hangs forever) >> >> I would really like some help trying to figure this out... I thought it should work easily since all the spawned processes don't share data or state (their results are merged in the main thread). The classes used in the pattern are also simple python objects (use python primitives). >> >> >> These are the main functions: >> >> def mapAction(pool,paths,action): >> merge = {'next':[]} >> for result in pool.map(action,paths): >> if result == None: >> continue >> merge = mergeDicts(merge,result) >> return merge >> >> >> def mergeDicts(d1,d2): >> for key in d2: >> if key not in d1: >> d1[key] = d2[key] >> else: >> d1[key] += d2[key] >> return d1 >> >> >> def evalFSPattern(paths,pattern): >> pool = Pool(10) >> results = {} >> for action in pattern: >> tomerge1 = mapAction(pool,paths,action) >> tomerge2 = evalFSPattern(tomerge1['next'],pattern[action]) >> del tomerge1['next'] >> results = mergeDicts(results,tomerge1) >> results = mergeDicts(results,tomerge2) >> return results >> >> the classes used in the pattern (InGlob,NoMatchAdd,etc.) are callable classes that take a single parameter (a path) and return a dict result or None which makes them trivial to adapt to Pool.map. >> >> Note if I change the mapAction function to: >> >> def mapAction(pool,paths,action): >> merge = {'next':[]} >> for path in paths: >> result = action(path) >> if result == None: >> continue >> merge = mergeDicts(merge,result) >> return merge >> >> everything works just fine. >> >> >> Thanks. >> >> >> -- >> http://mail.python.org/mailman/listinfo/python-list > > -- > http://mail.python.org/mailman/listinfo/python-list From me+list/python at ixokai.io Thu Jan 27 13:13:03 2011 From: me+list/python at ixokai.io (Stephen Hansen) Date: Thu, 27 Jan 2011 10:13:03 -0800 Subject: WxPython versus Tkinter. In-Reply-To: References: <4D3E4377.3060807@tysdomain.com> <9MB%o.14110$%64.6074@unlimited.newshosting.com> <4A48EDF6D7634F2E994661A457451E87@teddy> <753A4C5A6658470085804B13C80340F2@octavian> Message-ID: <4D41B5AF.8020200@ixokai.io> On 1/27/11 9:55 AM, Grant Edwards wrote: > On 2011-01-27, Octavian Rasnita wrote: >> From: "Grant Edwards" >>> People will not separate your personality from the cause you espouse. >> >> Wow! that's really bad. > > It's less than ideal, but it the way people are. > > Is that a surprise to you? Seriously. Octavian's attitude in this thread makes me want to go use Tkinter just to spite him. And I'm net-buds with Tyler, and I'm working on a project that I thought accessibility for the blind was very important for. But no more! Way to set the cause back, Octavian. :P You have -1 converts! -- Stephen Hansen ... Also: Ixokai ... Mail: me+list/python (AT) ixokai (DOT) io ... Blog: http://meh.ixokai.io/ * Disclaimer: You are stupid if you think this is true. But seriously, Octavian makes it REALLY hard to continue caring about something that I actually cared about before and thought was important. -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 487 bytes Desc: OpenPGP digital signature URL: From iwanttogetspammed at gmx.net Thu Jan 27 13:16:09 2011 From: iwanttogetspammed at gmx.net (hein) Date: Thu, 27 Jan 2011 10:16:09 -0800 (PST) Subject: lxml.etree, namespaces and element insertion Message-ID: The other day i was processing an xml tree using lxml.etree. That tree contained a namespace. During that processing i inserted an element. Later on i tried to find that element using xpath. And to my suprise that element was not found! Maybe my suprise is just the result of my marginal knowledge about xml namespaces. After some examination i found out that the reason for not finding the element was that i did not supply a namespace when inserting the element. This behavior can be reproduced be the folowing code: from lxml import etree import sys print "Python: ", sys.version_info print "lxml.etree:", etree.__version__ string_data = [ '', '', '' ] trees = map(etree.fromstring, string_data) print "\n Before insertion:" for t in trees: print etree.tostring(t, pretty_print=True) trees[1].insert(-1, etree.Element("sometag")) trees[2].insert(-1, etree.Element("{NameSpace.com}sometag", nsmap={None : "NameSpace.com"})) print "\n After insertion:" for t in trees: print etree.tostring(t, pretty_print=True) print "\n Using xpath:" for t in trees: elements = t.xpath("//ns:sometag", namespaces={'ns': 'NameSpace.com'}) print len(elements), if elements: print [e.tag for e in elements] else: print elements Its output is: Python: (2, 6, 6, 'final', 0) lxml.etree: 2.2.8 Before insertion: After insertion: Using xpath: 1 ['{NameSpace.com}sometag'] 0 [] 1 ['{NameSpace.com}sometag'] So my suprise was that in the second case the xpath result is an empty list. I have two questions on this: - Is what i am seeing expected behavior? - How am i supposed to detect a missing namespace, if there are no differences in the serialized representation? (That's what i initially used to debug the problem.) From tyler at tysdomain.com Thu Jan 27 13:17:27 2011 From: tyler at tysdomain.com (Littlefield, Tyler) Date: Thu, 27 Jan 2011 11:17:27 -0700 Subject: WxPython versus Tkinter. In-Reply-To: <57C3CFA0C7EE4578B0C6EAA267AAE678@teddy> References: <4D3E4377.3060807@tysdomain.com><9MB%o.14110$%64.6074@unlimited.newshosting.com> <59F6E65E3D9A46AD8D7A3863F3C1DC84@teddy> <27f53f8c-7862-4366-9352-82ae9a2f3970@k3g2000yqc.googlegroups.com> <718D13777F254C839F9564BC4275DE0A@octavian> <4D402C42.1030407@tysdomain.com> <4D40447C.4010108@tysdomain.com><33C68A0874BE4C66AB478EDFB64C2C1D@teddy> <4D407333.1070301@tysdomain.com> <82865E7A54C048C398B4F4160FC43B57@octavian> <4D417EFC.70800@tysdomain.com> <57C3CFA0C7EE4578B0C6EAA267AAE678@teddy> Message-ID: <4D41B6B7.7010609@tysdomain.com> >Tyler, you are a Linux and Mac user and you search with Google and try to >explain how many things you know about NVDA, but it is obviously that what >JAWS 1) Because you, your crew, and your group on a specific forum doesn't like ESpeak doesn't disqualify an entire reader. The eloquence fixes are illegal to be packaged with NVDA, so you -need- to get a separate patch, yes. That doesn't mean it can't be done. As to me being a Linux and Mac user, that doesn't disqualify what I'm telling you either, because unlike your limitations, I don't just decide to only use one reader. I use Linux, Mac, and windows (windows more than both, actually). Yes, I'm giving you what I got from googling, because that's my way of telling you to do your homework before you start ranting about a reader you clearly know nothing of. The fact that it appears on google says a lot. At least to me, maybe it's something you haven't been able to comprehend. On 1/27/2011 10:22 AM, Octavian Rasnita wrote: > From: "Littlefield, Tyler" >>> It doesn't support a good voice synthesizer like Eloquence or IBM Via >> voice >> Eloq is an add-on, but it does support it. > If you are saying this, it means that you haven't used it for a long time, or you just heard about it by searching on the web. Eloq is supported, but only as an unofficial hack because the NVDA developers pretend that it is illegally to offer support for Eloquence. They said that Nuance ask them to remove that support from NVDA, and as a consequence, the support for Eloquence was removed and it is harder to find the NVDA Eloquence driver from unofficial sources (and that unofficial support is not the same under all versions of NVDA...) > >>> but only eSpeak which sounds horrible >> That's your personal preference. Plenty use and like ESpeak. > That's my personal preference and the preference of all the blind people I know in my country with only one or two exceptions. (If you'd know Romanian, I could give you the address of a forum to ask there if you don't believe me.) > And note that Eloquence doesn't support my native language, but eSpeak does it, however they still don't like eSpeak. Why do you think we don't like it? Because it is so good? > >>> it doesn't have a scripting language ready to use as JAWS and Window >> Eyes do, >> Scripting is done in Python, (no, not some native scripting language), >> and are done as modules. You write your script in python, and off you >> go. Problem solved. > Have you done such a script for NVDA? > I've created a sample script in Python that uses the COM interface and I have asked on the NVDA mailing list and on NVDA-dev mailing list if I can use it, but NVDA doesn't offer that feature yet. And I was saying that "NVDA doesn't have a scripting language ready to use". The scripting language can be Python, but it should accept a scripting code, easy to install with a copy/paste, not an NVDA patch. That means "ready to use". > > >it doesn't offer the possibility of reading with the mouse cursor as > JAWS does with its so called JAWS cursor, > It's called flat review. Googling this term brings up a key reference at > like the third or fourth result down. > > Tyler, you are a Linux and Mac user and you search with Google and try to explain how many things you know about NVDA, but it is obviously that what JAWS can offer NVDA can't. That flat review can be used to read some things from the screen, and they say that it might also show the coordinates of the objects, however unlike JAWS, it can't show the coordinates of each character on the screen, and this is important by someone who is totally blind for checking the positions of different text elements on a web page, or in a desktop app. But NVDA can't be used for that. > >> the only issue here is you promoting the most "widely used screen reader," because it's what > you use, > and you not being able to use google and do your homework before you > start talking about products you know nothing of. > > Tyler, the other list members sustain you because you are also against changing something in order to improve the accessibility and just promise that you will make Tk accessible, and I am sure they won't say anything about your atitude, but your atitude really sucks because it is obviously that you don't know many things about NVDA, and you haven't tried it, you even show that you don't care about the most used OS, you use Mac and Linux, but keep telling me that I don't know about it although I am an NVDA user for a long time. > > And all these useless phrases are just for answering to your useless hijack of the discussion, because we are not talking about NVDA here, but about the lack of accessibility in Tk-based applications, and Tk is as inaccessible in JAWS as in NVDA, Window Eyes or other screen readers, so it doesn't matter what screen reader we use for testing that inaccessibility. > > Octavian > > -- Thanks, Ty From me+list/python at ixokai.io Thu Jan 27 13:18:58 2011 From: me+list/python at ixokai.io (Stephen Hansen) Date: Thu, 27 Jan 2011 10:18:58 -0800 Subject: Need GUI pop-up to edit a (unicode ?) string In-Reply-To: References: <3tqr08-bj2.ln1@murmur.very.softly> <7691fe98-37af-4ddf-a8a8-eadeef0d4a6e@y2g2000prf.googlegroups.com> <541c02df-b1fc-4376-bf17-e0531fe5c4bf@r29g2000yqj.googlegroups.com> Message-ID: <4D41B712.1020504@ixokai.io> On 1/27/11 10:04 AM, Grant Edwards wrote: > On 2011-01-27, Stephen Hansen wrote: >> On 1/25/11 3:02 PM, rantingrick wrote: >>> This is a major flaw in the design and i would be >>> happy to fix the flaw. However our "friend" Fredrick decided to >>> copyright the module to himself! What a jerk! Which is quite >>> disgusting considering that Tkinter, and TclTk are completely open >>> source! >> >> Uh. ... LOL. >> >> Copyright doesn't mean what you think it means. >> >> Tkinter is copyrighted. Python is copyrighted. Tcl/TK is copyrgithed. >> >> In fact: everything that is "open source" is copyrighted. By >> definition[* see footnote]. > > One (domestic US) exception would be open-source software written by > an employee of the US federal government. Works produced by the US > Government are not copyrighted under US domestic copyright law. Such > works are copyrighted under international law (which is probably what > the Python maintainers care about). I've actually wondered a bit about that: but the only open source software that I'm aware of that's been government-adjacent has ended up being written/owned by some University or joint venture funded by a government agency -- it didn't fall into the public domain category of content created directly by the federal government. Are you aware of any code out there that is? Just curious. I'm not arguing that the exception doesn't exist or anything. -- Stephen Hansen ... Also: Ixokai ... Mail: me+list/python (AT) ixokai (DOT) io ... Blog: http://meh.ixokai.io/ -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 487 bytes Desc: OpenPGP digital signature URL: From rantingrick at gmail.com Thu Jan 27 13:21:52 2011 From: rantingrick at gmail.com (rantingrick) Date: Thu, 27 Jan 2011 10:21:52 -0800 (PST) Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com><9MB%o.14110$%64.6074@unlimited.newshosting.com><4A48EDF6D7634F2E994661A457451E87@teddy><753A4C5A6658470085804B13C80340F2@octavian> Message-ID: <8a71f330-a634-4e48-bea2-ddde6e70a71a@m7g2000vbq.googlegroups.com> On Jan 27, 2:13?am, "Octavian Rasnita" wrote: > > You may not like it, but that's a fact. ?If you are in favor of XYZ, > > and act rude and insulting while espousing XYZ, people will react > > against not only you but _also_ XYZ. > > I know what you are reffering to. :-) > And I was hoping that there won't be people that don't like me personally > for what I think about some things that have nothing related to them > personally. > But I don't say that you are wrong. After some reactions on the list I can > say that you might be really right. Sadly many people lack the ability to make objective decisions. They let emotion get in the way of good choices. People should put aside petty differences and make judgments solely on facts. Yes, you can disagree with someone passionately on one subject and yet agree passionately on another. Case in point: If Guido and myself sit down for a political discussion we would probably poke each others eyes out in a very short time. However i still hold a great respect for Guido and that will never change. Now matter how much i may disagree with him on certain matters, he still forged the path and brought us Python. I will never think harsh of him just because we do not agree on everything. I believe in freedom of speech, freedom of expression, and freedom of ideas. Some of you out there need to take this advice yourselves. Stop hating those who may thing differently because one day you may find out your position was wrong. From rantingrick at gmail.com Thu Jan 27 13:24:55 2011 From: rantingrick at gmail.com (rantingrick) Date: Thu, 27 Jan 2011 10:24:55 -0800 (PST) Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com><9MB%o.14110$%64.6074@unlimited.newshosting.com><4A48EDF6D7634F2E994661A457451E87@teddy><753A4C5A6658470085804B13C80340F2@octavian> <4D40A97F.8090209@tysdomain.com> Message-ID: <3869f767-f8e9-4067-a32a-a2e12e6d4e1b@z31g2000vbs.googlegroups.com> On Jan 27, 2:17?am, "Octavian Rasnita" wrote: > From: "Littlefield, Tyler" [...] > > Then when that fails, you try cramming > > words in people's mouth to make them feel like they kick puppies, and to > > bring everyone else to this same conclusion. Tyler no one can *make* you *feel* like anything unless you let them. Actually i think what you are *feeling* now is guilt. The human conscience has a way of catching up with us when we exaggerate too much. From emile at fenx.com Thu Jan 27 13:30:59 2011 From: emile at fenx.com (Emile van Sebille) Date: Thu, 27 Jan 2011 10:30:59 -0800 Subject: WxPython versus Tkinter. In-Reply-To: <5858167B51BD4813A1D36C2D90D255F2@teddy> References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <8q7sgiF5tpU1@mid.individual.net> <19891784-d6a3-41ac-a097-5902a6323bc0@o21g2000prn.googlegroups.com><0b12cdb1-45b4-41e4-9bdb-074ee669d76b@k14g2000pre.googlegroups.com> <048FB74272D440A0915ABC7D76AE262B@teddy> <5782E9AD8A8342D691EB3549E5E0ED7B@octavian> <43549D4396F34EA697C45AA40EA12BC8@octavian> <5858167B51BD4813A1D36C2D90D255F2@teddy> Message-ID: On 1/27/2011 10:09 AM Octavian Rasnita said... > From: "Emile van Sebille" >> On 1/26/2011 11:02 PM Octavian Rasnita said... >> >>> As we all know, Python doesn't care too much about maintaining a >>> backward compatibility >> >> Where'd you get this idea? Between v2 and v3 yes, that was the intent. > > To be sincere I was thinking to the differences between Python 2 and 3. > >> But otherwise, I think there's another miscommunication behind this... > > It might be true, however I have seen some modules that say that are ment for Python 2.5, for 2.6 or for 2.7, so there seem to be differences between these versions also. Yes - but don't confuse forward compatibility (which means programs you write today in the current version will work on the prior versions) with backward compatibility (which means programs written for earlier versions will run under newer versions) I suspect that a lot of python 1.x code will work just fine under 2.x just as most 2.n will work under 2.m (where m>n). There are few exceptions, and those mostly in the standard library. I recall only getting stung once (something to do with passing in a tuple instead of two parameters in one or another imported module). Emile From rantingrick at gmail.com Thu Jan 27 13:33:59 2011 From: rantingrick at gmail.com (rantingrick) Date: Thu, 27 Jan 2011 10:33:59 -0800 (PST) Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com><9MB%o.14110$%64.6074@unlimited.newshosting.com> <59F6E65E3D9A46AD8D7A3863F3C1DC84@teddy> <27f53f8c-7862-4366-9352-82ae9a2f3970@k3g2000yqc.googlegroups.com> <718D13777F254C839F9564BC4275DE0A@octavian> <4D402C42.1030407@tysdomain.com> <4D40447C.4010108@tysdomain.com> <33C68A0874BE4C66AB478EDFB64C2C1D@teddy> Message-ID: On Jan 26, 1:16?pm, Alexander Kapps wrote: > Please don't use the lower Linux user percentage as an argument > here. If you follow that path further, you would need to agree that > it's only an "insignificant" percent of people who need a screen > reader, so why bother? Please don't use the lower accessibility percentage to prop up the low Linux percentage in an attempt to win your argument. Because healthy Linux users ARE NOT equal to handicapped people! And let's just get to the real point of this statement... This argument stems from me saying that Lunux users should stop complaining about downloading gtk to use wxPython because they use a non-hand- holding OS. And now you attempt to compare yourself to handicapped people in a veiled way so we feel sorry for you? Well it worked! I DO feel sorry for you. Congratulations! From g.rodola at gmail.com Thu Jan 27 13:35:46 2011 From: g.rodola at gmail.com (=?ISO-8859-1?Q?Giampaolo_Rodol=E0?=) Date: Thu, 27 Jan 2011 19:35:46 +0100 Subject: WxPython versus Tkinter. In-Reply-To: <5858167B51BD4813A1D36C2D90D255F2@teddy> References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <8q7sgiF5tpU1@mid.individual.net> <19891784-d6a3-41ac-a097-5902a6323bc0@o21g2000prn.googlegroups.com> <0b12cdb1-45b4-41e4-9bdb-074ee669d76b@k14g2000pre.googlegroups.com> <048FB74272D440A0915ABC7D76AE262B@teddy> <5782E9AD8A8342D691EB3549E5E0ED7B@octavian> <43549D4396F34EA697C45AA40EA12BC8@octavian> <5858167B51BD4813A1D36C2D90D255F2@teddy> Message-ID: > It might be true, however I have seen some modules that say that are ment for Python 2.5, for 2.6 or for 2.7, so there seem to be differences between these versions also. Python cares *a lot* about maintaining backward compatibiilty between all major versions. This is so true that I managed to use a unique code base for pyftpdlib which supports python from 2.3 to 2.7. Same for psutil which covers versions from 2.4 to 3.2 by using a unique code base! > It might be true, however I have seen some modules that say that are ment for Python 2.5, for 2.6 or for 2.7, so there seem to be differences between these versions also. Usually the differences between one version and another rely on *new features* only. One might decide to target a module only for a certain version of the 2.x serie because that certain version introduced a new functionnality which was not available before (silly example http://docs.python.org/library/os.html#os.initgroups ). All the other functionnalities are likely to remain the same and fully backward compatible. > py2exe offers the following installation kits, depending on the Python version. If you know, please tell me why there are different packages for different versions of Python? > > py2exe-0.6.9.win32-py2.5.exe > py2exe-0.6.9.win32-py2.4.exe > py2exe-0.6.9.win32-py2.3.exe > py2exe-0.6.9.win32-py2.6.exe > py2exe-0.6.9.win32-py2.7.exe That's a different story: those are pre-compiled binaries which are generated from a *unique* source code which support all those versions. If you have a compiler you can install pywin32 extension by using any Python version. --- Giampaolo http://code.google.com/p/pyftpdlib/ http://code.google.com/p/psutil/ 2011/1/27 Octavian Rasnita : > From: "Emile van Sebille" >> On 1/26/2011 11:02 PM Octavian Rasnita said... >> >>> As we all know, Python doesn't care too much about maintaining a >>> backward compatibility >> >> Where'd you get this idea? ?Between v2 and v3 yes, that was the intent. > > To be sincere I was thinking to the differences between Python 2 and 3. > >> ?But otherwise, I think there's another miscommunication behind this... > > It might be true, however I have seen some modules that say that are ment for Python 2.5, for 2.6 or for 2.7, so there seem to be differences between these versions also. > > py2exe offers the following installation kits, depending on the Python version. If you know, please tell me why there are different packages for different versions of Python? > > py2exe-0.6.9.win32-py2.5.exe > py2exe-0.6.9.win32-py2.4.exe > py2exe-0.6.9.win32-py2.3.exe > py2exe-0.6.9.win32-py2.6.exe > py2exe-0.6.9.win32-py2.7.exe > > Thanks. > > Octavian > > -- > http://mail.python.org/mailman/listinfo/python-list > From philip at semanchuk.com Thu Jan 27 13:38:00 2011 From: philip at semanchuk.com (Philip Semanchuk) Date: Thu, 27 Jan 2011 13:38:00 -0500 Subject: help with multiprocessing pool In-Reply-To: References: <2A124DD5-95F2-4DE0-AB0F-5D3EA39A230B@semanchuk.com> Message-ID: <016BC5FD-80F5-4578-9448-A592AD626C18@semanchuk.com> On Jan 27, 2011, at 1:12 PM, Craig Yoshioka wrote: > The code will be multi-platform. The OSXisms are there as an example, though I am developing on OS X machine. > > I've distilled my problem down to a simpler case, so hopefully that'll help troubleshoot. > > I have 2 files: > > test.py: > -------------------------------------------------------------- > from multiprocessing import Pool > > def square(x): > return x*x > > def squares(numbers): > pool = Pool(12) > return pool.map(square,numbers) > > > test2.py: > -------------------------------------------------------------- > from test import squares > > maxvalues = squares(range(3)) > print maxvalues > > > > Now if I import squares into the interactive interpreter: > > from test import squares > print squares(range(3)) > > I get the correct result, but if I try to import maxvalues from test2 the interactive interpreter python hangs. > if I run the script from bash, though, it seems to run fine. The short, complete example is much more useful, but it sounds like it demonstrates a different problem than you first described. Your first posting said that your code worked in the interpreter but failed when run from the command line. This code has the opposite problem. Correct? > I think it might have something to do with this note in the docs, though I am not sure how to use this information to fix my problem: > > Note: Functionality within this package requires that the __main__ method be importable by the children. This is covered inProgramming guidelines however it is worth pointing out here. This means that some examples, such as themultiprocessing.Pool examples will not work in the interactive interpreter. I suspect this is the problem with the demo above. Your original code ran fine in the interpreter, though, correct? bye Philip > > On Jan 27, 2011, at 6:39 AM, Philip Semanchuk wrote: > >> >> On Jan 25, 2011, at 8:19 PM, Craig Yoshioka wrote: >> >>> Hi all, >>> >>> I could really use some help with a problem I'm having. >> >> >> Hiya Craig, >> I don't know if I can help, but it's really difficult to do without a full working example. >> >> Also, your code has several OS X-isms in it so I guess that's the platform you're on. But in case you're on Windows, note that that platform requires some extra care when using multiprocessing: >> http://docs.python.org/library/multiprocessing.html#windows >> >> >> Good luck >> Philip >> >> >>> I wrote a function that can take a pattern of actions and it apply it to the filesystem. >>> It takes a list of starting paths, and a pattern like this: >>> >>> pattern = { >>> InGlob('Test/**'):{ >>> MatchRemove('DS_Store'):[], >>> NoMatchAdd('(alhpaID_)|(DS_Store)','warnings'):[], >>> MatchAdd('alphaID_','alpha_found'):[], >>> InDir('alphaID_'):{ >>> NoMatchAdd('(betaID_)|(DS_Store)','warnings'):[], >>> InDir('betaID_'):{ >>> NoMatchAdd('(gammaID_)|(DS_Store)','warnings'):[], >>> MatchAdd('gammaID_','gamma_found'):[] }}}} >>> >>> so if you run evalFSPattern(['Volumes/**'],pattern) it'll return a dictionary where: >>> >>> dict['gamma_found'] = [list of paths that matched] (i.e. '/Volumes/HD1/Test/alphaID_3382/betaID_38824/gammaID_848384') >>> dict['warning'] = [list of paths that failed to match] (ie. '/Volumes/HD1/Test/alphaID_3382/gammaID_47383') >>> >>> Since some of these volumes are on network shares I also wanted to parallelize this so that it would not block on IO. I started the parallelization by using multiprocessing.Pool and got it to work if I ran the fsparser from the interpreter. It ran in *much* less time and produced correct output that matched the non-parallelized version. The problem begins if I then try to use the parallelized function from within the code. >>> >>> For example I wrote a class whose instances are created around valid FS paths, that are cached to reduce expensive FS lookups. >>> >>> class Experiment(object): >>> >>> SlidePaths = None >>> >>> @classmethod >>> def getSlidePaths(cls): >>> if cls.SlidePaths == None: >>> cls.SlidePaths = fsparser(['/Volumes/**'],pattern) >>> return cls.SlidePaths >>> >>> @classmethod >>> def lookupPathWithGammaID(cls,id): >>> paths = cls.getSlidePaths() >>> ... >>> return paths[selected] >>> >>> @classmethod >>> def fromGamaID(cls,id): >>> path = cls.lookupPathWithGammaID(id) >>> return cls(path) >>> >>> def __init__(self,path) >>> self.Path = path >>> ... >>> >>> ... >>> >>> If I do the following from the interpreter it works: >>> >>>>>> from experiment import Experiment >>>>>> expt = Experiment.fromGammaID(10102) >>> >>> but if I write a script called test.py: >>> >>> from experiment import Experiment >>> expt1 = Experiment.fromGammaID(10102) >>> expt2 = Experiment.fromGammaID(10103) >>> comparison = expt1.compareTo(expt2) >>> >>> it fails, if I try to import it or run it from bash prompt: >>> >>>>>> from test import comparison (hangs forever) >>> $ python test.py (hangs forever) >>> >>> I would really like some help trying to figure this out... I thought it should work easily since all the spawned processes don't share data or state (their results are merged in the main thread). The classes used in the pattern are also simple python objects (use python primitives). >>> >>> >>> These are the main functions: >>> >>> def mapAction(pool,paths,action): >>> merge = {'next':[]} >>> for result in pool.map(action,paths): >>> if result == None: >>> continue >>> merge = mergeDicts(merge,result) >>> return merge >>> >>> >>> def mergeDicts(d1,d2): >>> for key in d2: >>> if key not in d1: >>> d1[key] = d2[key] >>> else: >>> d1[key] += d2[key] >>> return d1 >>> >>> >>> def evalFSPattern(paths,pattern): >>> pool = Pool(10) >>> results = {} >>> for action in pattern: >>> tomerge1 = mapAction(pool,paths,action) >>> tomerge2 = evalFSPattern(tomerge1['next'],pattern[action]) >>> del tomerge1['next'] >>> results = mergeDicts(results,tomerge1) >>> results = mergeDicts(results,tomerge2) >>> return results >>> >>> the classes used in the pattern (InGlob,NoMatchAdd,etc.) are callable classes that take a single parameter (a path) and return a dict result or None which makes them trivial to adapt to Pool.map. >>> >>> Note if I change the mapAction function to: >>> >>> def mapAction(pool,paths,action): >>> merge = {'next':[]} >>> for path in paths: >>> result = action(path) >>> if result == None: >>> continue >>> merge = mergeDicts(merge,result) >>> return merge >>> >>> everything works just fine. >>> >>> >>> Thanks. >>> >>> >>> -- >>> http://mail.python.org/mailman/listinfo/python-list >> >> -- >> http://mail.python.org/mailman/listinfo/python-list > From invalid at invalid.invalid Thu Jan 27 13:41:22 2011 From: invalid at invalid.invalid (Grant Edwards) Date: Thu, 27 Jan 2011 18:41:22 +0000 (UTC) Subject: Need GUI pop-up to edit a (unicode ?) string References: <3tqr08-bj2.ln1@murmur.very.softly> <7691fe98-37af-4ddf-a8a8-eadeef0d4a6e@y2g2000prf.googlegroups.com> <541c02df-b1fc-4376-bf17-e0531fe5c4bf@r29g2000yqj.googlegroups.com> Message-ID: On 2011-01-27, Stephen Hansen wrote: > On 1/27/11 10:04 AM, Grant Edwards wrote: >> On 2011-01-27, Stephen Hansen wrote: >> >>> In fact: everything that is "open source" is copyrighted. By >>> definition[* see footnote]. >> >> One (domestic US) exception would be open-source software written by >> an employee of the US federal government. Works produced by the US >> Government are not copyrighted under US domestic copyright law. Such >> works are copyrighted under international law (which is probably what >> the Python maintainers care about). > > I've actually wondered a bit about that: but the only open source > software that I'm aware of that's been government-adjacent has ended > up being written/owned by some University or joint venture funded by > a government agency -- it didn't fall into the public domain category > of content created directly by the federal government. That seems to be the usual case. > Are you aware of any code out there that is? Just curious. I'm not > arguing that the exception doesn't exist or anything. No, I can't point to anything significant or recent. I have vague memories of stuff from a long time ago (back when open-source software travelled hand-to-hand on DECUS tapes) written by people at NOAA or USGS that was copyright-free. -- Grant Edwards grant.b.edwards Yow! RELATIVES!! at gmail.com From tyler at tysdomain.com Thu Jan 27 13:43:14 2011 From: tyler at tysdomain.com (Littlefield, Tyler) Date: Thu, 27 Jan 2011 11:43:14 -0700 Subject: WxPython versus Tkinter. In-Reply-To: <4D41B5AF.8020200@ixokai.io> References: <4D3E4377.3060807@tysdomain.com> <9MB%o.14110$%64.6074@unlimited.newshosting.com> <4A48EDF6D7634F2E994661A457451E87@teddy> <753A4C5A6658470085804B13C80340F2@octavian> <4D41B5AF.8020200@ixokai.io> Message-ID: <4D41BCC2.2060906@tysdomain.com> >* Disclaimer: You are stupid if you think this is true. But seriously, >Octavian makes it REALLY hard to continue caring about something that I >actually cared about before and thought was important. People like Octavian do that. Sadly, it is one of the things holding the blind community back. I hope that with my arguments (for those that didn't just toss everything related to this thread), I have been able to get people to see a little differently and not consider Octavian as the voice for us all. I am by no means the guru with accessibility, but I can boast having worked with all three platforms (and now IOS) that were mentioned in this thread in terms of accessibility. If someone would like to make an app more accessible or anything the like, I would love to give comments and feedback. From jeanmichel at sequans.com Thu Jan 27 13:43:56 2011 From: jeanmichel at sequans.com (Jean-Michel Pichavant) Date: Thu, 27 Jan 2011 19:43:56 +0100 Subject: Which is the best book to learn python In-Reply-To: References: <188c0a9f-4e93-4fae-b3f9-e7c84f8030fd@v31g2000pri.googlegroups.com> <4D3DB915.9060601@sequans.com> Message-ID: <4D41BCEC.1040302@sequans.com> santosh hs wrote: > I am very new to object oriented concept, so I need to learn > everything frm basic, Will the above books fulfill > My need > > > read this http://www.freenetpages.co.uk/hp/alan.gauld/tutclass.htm and stop when they start to talk about VBscript :) JM From rantingrick at gmail.com Thu Jan 27 13:45:58 2011 From: rantingrick at gmail.com (rantingrick) Date: Thu, 27 Jan 2011 10:45:58 -0800 (PST) Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com> <9MB%o.14110$%64.6074@unlimited.newshosting.com> <4A48EDF6D7634F2E994661A457451E87@teddy> <753A4C5A6658470085804B13C80340F2@octavian> Message-ID: <84519d45-f584-4fab-b51c-cd53bde6c09a@p16g2000vbs.googlegroups.com> On Jan 27, 11:47?am, Grant Edwards wrote: > On 2011-01-27, Octavian Rasnita wrote: > If you don't care about communicating with others, then being civil > probably does have no value (except for keeping a job or being > avoiding being beaten up on the playground). ?If you want to > communicate (especially if you want somebody else to _do_ something), > then being civil and following normal social rules (etiquette) is > _very_ valuable. Without it the only thing you accomplish is to turn > people against you and whatever you're saying. When has Octavian been uncivil? This lecture of Octavian is ludicris! > There is no inherent "value" in driving on the right side of the road > vs. the left. ?However, there is a lot of value in driving on the side > of road that others expect you to. ?I'd tell you to try driving on the > other side of the road sometime to see how "easing communication" can > be valuable, but I'm afraid you'd try it... So i get it. When Ocatavian agrees with YOU he will be driving on the "right" side of the road. Until then, he is breaking the law and could cause a head on collision that could kill people. Wow good thing you were here to warn him of his "illegal" position and set him strait! You are such a friendly totalitarian, how do you keep a strait face -- Col. Hans Landa? From luismgz at gmail.com Thu Jan 27 13:53:50 2011 From: luismgz at gmail.com (=?ISO-8859-1?Q?Luis_M=2E_Gonz=E1lez?=) Date: Thu, 27 Jan 2011 10:53:50 -0800 (PST) Subject: Which is the best book to learn python References: <188c0a9f-4e93-4fae-b3f9-e7c84f8030fd@v31g2000pri.googlegroups.com> <4D3DB915.9060601@sequans.com> Message-ID: <4c677b91-a1e9-4700-ade8-35edaba550f5@l22g2000pre.googlegroups.com> On Jan 27, 3:43?pm, Jean-Michel Pichavant wrote: > santosh hs wrote: > > I am very new to object oriented concept, ?so I need to learn > > everything frm basic, Will the above books fulfill > > ?My need > > read thishttp://www.freenetpages.co.uk/hp/alan.gauld/tutclass.htm > > and stop when they start to talk about VBscript :) > > JM I strongly second this suggestion. Alan Gauld's example of a banking application was just what I needed to finally understand object oriented programming. This is how my head made the "click". Luis From mailing at franzoni.eu Thu Jan 27 14:03:18 2011 From: mailing at franzoni.eu (Alan Franzoni) Date: Thu, 27 Jan 2011 20:03:18 +0100 Subject: Behaviour-based interface/protocol implementation? In-Reply-To: References: Message-ID: On Wed, Jan 26, 2011 at 7:23 PM, Daniel Urban wrote: >> That's just what I'd like and I suppose can't be currently done with >> current ABC, PyProtocols or zope.interface implementations, right? > > It can. With __instancecheck__ you can override isinstance. It is > possible (for example) to write a subclass of abc.ABCMeta, which > extends __instancecheck__ to use an _instancehook classmethod > similarly to __subclasshook__. Then in your MyInterface class you can > implement _instancehook to check for methods/signatures/whatever you > want. Yes, __instancecheck__ could be used as an alternative hook with respect to maybe_implemented_by(), but there's no such logic for signature checking. That's a minor detail, I think. -- Alan Franzoni -- contact me at public@[mysurname].eu From me+list/python at ixokai.io Thu Jan 27 14:03:59 2011 From: me+list/python at ixokai.io (Stephen Hansen) Date: Thu, 27 Jan 2011 11:03:59 -0800 Subject: WxPython versus Tkinter. In-Reply-To: References: <4D4093AF.80806@etrix.com.au> Message-ID: <4D41C19F.4060306@ixokai.io> On 1/27/11 10:11 AM, rantingrick wrote: > On Jan 27, 1:28 am, "Octavian Rasnita" wrote: >> But WxPython is their work and they decision is their. > Actually we The word "we" does not mean what you think it means. -- Stephen Hansen ... Also: Ixokai ... Mail: me+list/python (AT) ixokai (DOT) io ... Blog: http://meh.ixokai.io/ -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 487 bytes Desc: OpenPGP digital signature URL: From mailing at franzoni.eu Thu Jan 27 14:05:19 2011 From: mailing at franzoni.eu (Alan Franzoni) Date: Thu, 27 Jan 2011 20:05:19 +0100 Subject: Behaviour-based interface/protocol implementation? In-Reply-To: References: Message-ID: On Thu, Jan 27, 2011 at 8:03 PM, Alan Franzoni wrote: > Yes, __instancecheck__ could be used as an alternative hook with > respect to maybe_implemented_by(), but there's no such logic for > signature checking. That's a minor detail, I think. On the contrary, now that I double checked, it can't be used that way; I don't want to modify the object I'm testing (it could be a third party object) nor I want to force it to be "registered" as a certain ABC; so __instancecheck__() is just useless here. -- Alan Franzoni -- contact me at public@[mysurname].eu From rustompmody at gmail.com Thu Jan 27 14:05:30 2011 From: rustompmody at gmail.com (rusi) Date: Thu, 27 Jan 2011 11:05:30 -0800 (PST) Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com> <9MB%o.14110$%64.6074@unlimited.newshosting.com> <4A48EDF6D7634F2E994661A457451E87@teddy> <753A4C5A6658470085804B13C80340F2@octavian> <84519d45-f584-4fab-b51c-cd53bde6c09a@p16g2000vbs.googlegroups.com> Message-ID: <793e3d37-f59c-4053-b38e-24bb48c44807@l22g2000pre.googlegroups.com> On Jan 27, 11:45?pm, rantingrick wrote: > > When has Octavian been uncivil? This lecture of Octavian is ludicris! > You are such a friendly totalitarian, how do you keep a strait face -- > Col. Hans Landa? And this mutual 'support' between Octavian and Ranter is ludicris(sic) Its quite clear to everyone here that -- RR has no interest in accessibility and is using it only for brownie points -- Octavian has no interest in a 21st century snazzy-looking toolkit which he cant see You guys would do yourselves a favor by forgetting about wx and getting your hands dirty with tkinter: - Octavian to (help) make it accessible - RR to make it look modern From stefan_ml at behnel.de Thu Jan 27 14:33:46 2011 From: stefan_ml at behnel.de (Stefan Behnel) Date: Thu, 27 Jan 2011 20:33:46 +0100 Subject: lxml.etree, namespaces and element insertion In-Reply-To: References: Message-ID: hein, 27.01.2011 19:16: > The other day i was processing an xml tree using lxml.etree. That tree > contained a namespace. During that processing i inserted an element. > Later on > i tried to find that element using xpath. And to my suprise that > element was > not found! Maybe my suprise is just the result of my marginal > knowledge about xml namespaces. > > After some examination i found out that the reason for not finding the > element > was that i did not supply a namespace when inserting the element. > [...] > I have two questions on this: > > - Is what i am seeing expected behavior? Yes. It's a common problem for new users, though. > - How am i supposed to detect a missing namespace, if there are no > differences > in the serialized representation? (That's what i initially used to > debug the problem.) This is a known problem of XML namespaces, which were only designed as an add-on to XML after the fact. The only advice I can give: be careful with the default namespace. Stefan From tjreedy at udel.edu Thu Jan 27 14:36:39 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Thu, 27 Jan 2011 14:36:39 -0500 Subject: WxPython versus Tkinter. In-Reply-To: References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> 0-47ef-a8b0-ca55d52ef683@1g20000qz.googlegroupssssss db3-4108-8a13-cc7d51f00b49@29g2200prb.googlegrooooooooo 5tpU1@mid.indivvvvvvvvvvv 784-d6a3-41ac-aa97-5902a6323bc00o21g2000prn.goooooooooooooooo <048FB74272D440A0915ABC7D76AE262B@teddy> <5782E9AD8A8342D691EB3549E5E0ED7B@octavian> Message-ID: On 1/27/2011 12:31 PM, Mark Roseman wrote: > Terry Reedy wrote: >> Tk itself is purely a gui package -- abstract widgits, geometry placers >> to make them visible, and an event system to make them active. But it >> does have the baggage of needing tcl included. About a decade ago, some >> people had the idea of removing the tcl dependency, but nothing seems to >> have come of that. For some people, the tcl baggage is reason enough to >> be rid of tk. > > > Thanks for raising this point. While I don't want to exhaustively > respond to this, I would like to raise a few important points. > > 1. The performance issues of having Tk use Tcl are negligible; the bulk > of Tk (code-wise and time-wise) are spent in C. Tcl itself is also very > fast nowadays, using all the usual techniques that modern dynamic > languages use. I have the impression that tcl is mostly used in initial setup and configuration, as opposed to repetitive drawing to the screen. But I do not really know. > > 2. Some people do have moral/purity objections to including Tcl, and > while I understand where the sentiment comes from, I think there are few > solid engineering reasons for this. There are two types of objections which have much less force now than a decade ago. One is the size issue. A tcl-less tk would presumably be smaller and thus add less to the Window distribution. The other is that tcl and Python were once seen as competing scripting languages, so why promote the competitor? Well, if there really was a contest, Python won. > 3. Removing Tcl from Tk makes keeping up with changes in Tk very > difficult. The Perl people found this out; Perl/Tk extracted Tcl, and > as a result remained using a 10 year old version of Tk because upgrading > would have been too painful. The newer Perl binding (Tkx) is in fact a > ridiculously thin binding over the Tcl API, and makes keeping up to date > with the newest Tk changes trivial, often requiring no code changes in > the Perl binding. Good point. Python should (continue to) just use the latest tk from its maintainers. If *they* were to decouple it from tcl (unlikely, it seems), fine. If not, so be it ;-). > If anyone does have questions, comments or concerns about Python > including a Tcl interpreter to use Tk, I'd be happy to try to explain or > address them. Thanks for the additional info. We need more of that. --- Terry Jan Reedy From alex.kapps at web.de Thu Jan 27 14:45:55 2011 From: alex.kapps at web.de (Alexander Kapps) Date: Thu, 27 Jan 2011 20:45:55 +0100 Subject: WxPython versus Tkinter. In-Reply-To: References: <4D3E4377.3060807@tysdomain.com><9MB%o.14110$%64.6074@unlimited.newshosting.com> <59F6E65E3D9A46AD8D7A3863F3C1DC84@teddy> <27f53f8c-7862-4366-9352-82ae9a2f3970@k3g2000yqc.googlegroups.com> <718D13777F254C839F9564BC4275DE0A@octavian> <4D402C42.1030407@tysdomain.com> <4D40447C.4010108@tysdomain.com> <33C68A0874BE4C66AB478EDFB64C2C1D@teddy> Message-ID: <4D41CB73.9090608@web.de> On 27.01.2011 19:33, rantingrick wrote: > Please don't use the lower accessibility percentage to prop up the low > Linux percentage in an attempt to win your argument. Because healthy > Linux users ARE NOT equal to handicapped people! Please don't put words into my mouth, idiot. And read my complete post. Nobody compares Linux users with handicapped people. I equalize handicapped Linux users with handicapped Windows users. And like it or not, the number of Linux users (handicapped or not) is raising. Again read my complete post. > And let's just get to the real point of this statement... This > argument stems from me saying that Lunux users should stop complaining > about downloading gtk to use wxPython because they use a non-hand- > holding OS. Another example of your limited understanding. Do you really believe the problem lies in downloading dependencies? Hasn't somebody already explained that it's about development dependencies? > And now you attempt to compare yourself to handicapped > people in a veiled way so we feel sorry for you? Well it worked! I DO > feel sorry for you. Congratulations! I'm entirely sure that you deliberately misunderstood me and now try to discredit me with putting this nonsense into my mouth. You are really a sad, disgusting asshole. Don't bother replying. I won't read. (How many more plonks will it take till you consider changing your behaviour?) From mark at markroseman.com Thu Jan 27 14:51:52 2011 From: mark at markroseman.com (Mark Roseman) Date: Thu, 27 Jan 2011 12:51:52 -0700 Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <048FB74272D440A0915ABC7D76AE262B@teddy> <5782E9AD8A8342D691EB3549E5E0ED7B@octavian> Message-ID: Terry Reedy wrote: > > 1. The performance issues of having Tk use Tcl are negligible; the bulk > > of Tk (code-wise and time-wise) are spent in C. Tcl itself is also very > > fast nowadays, using all the usual techniques that modern dynamic > > languages use. > > I have the impression that tcl is mostly used in initial setup and > configuration, as opposed to repetitive drawing to the screen. But I do > not really know. Tcl as a scripting language is used during some initialization things, used to invoke callbacks, and a few other non-performance critical areas. It sometimes helps to think of Tcl as a very powerful C library that happens to have a scripting language on top. :-) For example, there are C functions in the Tcl library that do things like string management, cross platform I/O, very efficient hash tables, dynamic lists, etc. that are used everywhere inside Tk. But none of those calls mean a trip through the Tcl interpreter per se. Every dynamic language would have similar internals of course, though with slight differences and different API's. Mark From ethan at stoneleaf.us Thu Jan 27 14:58:40 2011 From: ethan at stoneleaf.us (Ethan Furman) Date: Thu, 27 Jan 2011 11:58:40 -0800 Subject: Behaviour-based interface/protocol implementation? In-Reply-To: References: Message-ID: <4D41CE70.1090900@stoneleaf.us> Alan Franzoni wrote: > Hello, > I'd like to have a system which lets me do certain actions if the > duck-type of a certain objects matches what I expect, i.e. I'd like to > have a formalization of what it's sometimes done through getattr() > calls: > > if getattr(myobj, "somemethod", None) is not None: > myobj.somemethod(somevalue) [...] > > I'd like to do a kind of runtime-check for signatures. Of course there > couldn't be an absolute certainty of interface implementation, because > a runtime dynamic proxy method (accepting *args and **kwargs in its > signature, as an example) might just fool my signature check. When you signature check, do you mean counting the number of arguments, or actually checking argument types? ~Ethan~ From tjreedy at udel.edu Thu Jan 27 15:00:38 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Thu, 27 Jan 2011 15:00:38 -0500 Subject: WxPython versus Tkinter. In-Reply-To: References: <4D3E4377.3060807@tysdomain.com><9MB%o.14110$%64.6074@unlimited.newshosting.com><4A48EDF6D7634F2E994661A457451E87@teddy><753A4C5A6658470085804B13C80340F2@octavian> <4D40A97F.8090209@tysdomain.com><00ABBA322416409EB749102EB1CC5E61@octavian> <4D418054.8050002@tysdomain.com> Message-ID: On 1/27/2011 12:54 PM, Octavian Rasnita wrote: > Everything that's not accessible is not recommended. By you. We get that. >Tkinter should be at most accepted because there is no better solution, As I said at the beginning of this thread, tkinter is currently the only option. What would have happened if there had been a real competitor when 3.0 was being developed? What would happen in the future if one were developed? I do not think anyone really knows. > at least for Python 3, not because it is the recommended solution. AS far as I know, Guido has never recommended any particular gui and I believe he has avoided doing so when asked. He is happy that there are different choices. -- Terry Jan Reedy From tyler at tysdomain.com Thu Jan 27 15:22:38 2011 From: tyler at tysdomain.com (Littlefield, Tyler) Date: Thu, 27 Jan 2011 13:22:38 -0700 Subject: WxPython versus Tkinter. In-Reply-To: <4D41CB73.9090608@web.de> References: <4D3E4377.3060807@tysdomain.com><9MB%o.14110$%64.6074@unlimited.newshosting.com> <59F6E65E3D9A46AD8D7A3863F3C1DC84@teddy> <27f53f8c-7862-4366-9352-82ae9a2f3970@k3g2000yqc.googlegroups.com> <718D13777F254C839F9564BC4275DE0A@octavian> <4D402C42.1030407@tysdomain.com> <4D40447C.4010108@tysdomain.com> <33C68A0874BE4C66AB478EDFB64C2C1D@teddy> <4D41CB73.9090608@web.de> Message-ID: <4D41D40E.7060700@tysdomain.com> >Because healthy Linux users ARE NOT equal to handicapped people! O? I bet I could run circles around RR in the shell, any day. Why are you trying to promote accessibility for a group of people you consider not equal to a group of "healthy" people? From tjreedy at udel.edu Thu Jan 27 15:42:25 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Thu, 27 Jan 2011 15:42:25 -0500 Subject: WxPython versus Tkinter. In-Reply-To: References: <4D3E4377.3060807@tysdomain.com> <9MB%o.14110$%64.6074@unlimited.newshosting.com> <59F6E65E3D9A46AD8D7A3863F3C1DC84@teddy> <27f53f8c-7862-4366-9352-82ae9a2f3970@k3g2000yqc.googlegroups.com> <718D13777F254C839F9564BC4275DE0A@octavian> <4D402C42.1030407@tysdomain.com> <4D40447C.4010108@tysdomain.com> <33C68A0874BE4C66AB478EDFB64C2C1D@teddy> <4D407321.3090705@web.de> <1296128007.17192.1417506961@webmail.messagingengine.com> Message-ID: On 1/27/2011 12:57 PM, Grant Edwards wrote: > A very important way to help would be to test accessibility features > and post accurate, detailed, bug-reports. For example: pygui pretty much uses native widgets on Windows and OX and gtk (I believe) on *nix. How is the accessibility of those widget sets *as accessed through pygui*? Is it different from the 'native' accessibility of each of those set? -- Terry Jan Reedy From rantingrick at gmail.com Thu Jan 27 15:47:17 2011 From: rantingrick at gmail.com (rantingrick) Date: Thu, 27 Jan 2011 12:47:17 -0800 (PST) Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com><9MB%o.14110$%64.6074@unlimited.newshosting.com><4A48EDF6D7634F2E994661A457451E87@teddy><753A4C5A6658470085804B13C80340F2@octavian> <4D40A97F.8090209@tysdomain.com><00ABBA322416409EB749102EB1CC5E61@octavian> <4D418054.8050002@tysdomain.com> Message-ID: <171961f5-00da-444b-95fa-f3d95a685956@24g2000yqa.googlegroups.com> On Jan 27, 2:00?pm, Terry Reedy wrote: > AS far as I know, Guido has never recommended any particular gui and I > believe he has avoided doing so when asked. He is happy that there are > different choices. different choices OUTSIDE the stdlib. INSIDE the stdlib we have no choice. Just wanted to make that clear. From neilc at norwich.edu Thu Jan 27 16:06:49 2011 From: neilc at norwich.edu (Neil Cerutti) Date: 27 Jan 2011 21:06:49 GMT Subject: lxml.etree, namespaces and element insertion References: Message-ID: <8qe539FscdU1@mid.individual.net> On 2011-01-27, hein wrote: > - How am i supposed to detect a missing namespace, if there > are no differences in the serialized representation? (That's > what i initially used to debug the problem.) lxml's pretty printer is at fault, as it emits unprefixed names whenever possible while serializing. For debugging, try using .dump instead. Hopefully that makes the error obvious. -- Neil Cerutti From rantingrick at gmail.com Thu Jan 27 16:10:09 2011 From: rantingrick at gmail.com (rantingrick) Date: Thu, 27 Jan 2011 13:10:09 -0800 (PST) Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com><9MB%o.14110$%64.6074@unlimited.newshosting.com><4A48EDF6D7634F2E994661A457451E87@teddy><753A4C5A6658470085804B13C80340F2@octavian> <4D40A97F.8090209@tysdomain.com><00ABBA322416409EB749102EB1CC5E61@octavian> <4D418054.8050002@tysdomain.com> Message-ID: <1a37f3d8-b580-4d6d-a5a3-de8cc1e656dd@y26g2000yqd.googlegroups.com> On Jan 27, 2:00?pm, Terry Reedy wrote: > On 1/27/2011 12:54 PM, Octavian Rasnita wrote: > > > Everything that's not accessible is not recommended. > > By you. We get that. > > ?>Tkinter should be at most accepted because there is no better solution, > > As I said at the beginning of this thread, tkinter is currently the only > option. What would have happened if there had been a real competitor > when 3.0 was being developed? What would happen in the future if one > were developed? I do not think anyone really knows. > > > at least for Python 3, not because it is the recommended solution. > > AS far as I know, Guido has never recommended any particular gui and I > believe he has avoided doing so when asked. Yes but his silence speaks louder than words. He is saying " While i won't defend Tkinter publicly, i won't promote any others as well". This is a standard response you'd expect from a politician. These types of questions avoid dealing with the elephant in the room. We can't just assume that Tkinter is best for Python just because "Guido" does not want to "ruffle" some features. Actually if you look back over the very few post where Guido did offer an argument for Tkinter you'll the find the argument to be very weak. And to make matters worse no one has the balls to question or argue Guido. Now whilst i greatly respect Guido i will not hesitate for one second to call him on weak arguments. Case in point: Just recently i posted one of Guido's such arguments in another thread and responded to the argument. The original thread was from roughly eight years ago. Yes this is how long it has been since Guido offered argument for Tkinter. Does he honestly think that the world has not changed significantly in eight years as to render Tkinter into legacy? Does he also want us to believe that the world has not changed dramatically in the last twenty years since Tkinter was introduced? I have yet to get a response for his weak argument eight years ago and i can expect we will hear nothing now. My point is this: If you (Guido) are going to offer weak arguments then you must answer challenges to these weak arguments with facts. So I now challenge Guido to inject a solid argument for keeping Tkinter and i challenge him now. Before the entire world we will hash this out once and for all. Just be aware Guido, that i will NOT be afraid to question your facts and present good arguments based on fact. If you *do* inject your opinion on this very important subject matter --and do so here in a public forum-- then i believe the community will take you more seriously. And *i* will take you more seriously. All of your subordinates are unable to challenge me. Will you answer the challenge Guido van Rossum? Will you? The community at large needs to know what Guido van Rossum thinks. You owe us that much Guido. From mailing at franzoni.eu Thu Jan 27 16:12:45 2011 From: mailing at franzoni.eu (Alan Franzoni) Date: Thu, 27 Jan 2011 22:12:45 +0100 Subject: Behaviour-based interface/protocol implementation? In-Reply-To: <4D41CE70.1090900@stoneleaf.us> References: <4D41CE70.1090900@stoneleaf.us> Message-ID: On Thu, Jan 27, 2011 at 8:58 PM, Ethan Furman wrote: > When you signature check, do you mean counting the number of arguments, or > actually checking argument types? In order to check for argument types I should either assume type annotation (python 3 only, optional) or parse the docstring for the method, which might not be available or be out of sync. I just want to check for method name, number and/or names of the arguments. It might not be trivial in python because the very same argument can be passed either as a positional or a kw argument, so def method1(self, a, b): ... def method1(self, c, d): ... could satisfy or not the very same interface, depending whether the args are passed as postional or kw. -- Alan Franzoni -- contact me at public@[mysurname].eu From emile at fenx.com Thu Jan 27 16:19:42 2011 From: emile at fenx.com (Emile van Sebille) Date: Thu, 27 Jan 2011 13:19:42 -0800 Subject: WxPython versus Tkinter. In-Reply-To: <171961f5-00da-444b-95fa-f3d95a685956@24g2000yqa.googlegroups.com> References: <4D3E4377.3060807@tysdomain.com><9MB%o.14110$%64.6074@unlimited.newshosting.com><4A48EDF6D7634F2E994661A457451E87@teddy><753A4C5A6658470085804B13C80340F2@octavian> <4D40A97F.8090209@tysdomain.com><00ABBA322416409EB749102EB1CC5E61@octavian> <4D418054.8050002@tysdomain.com> <171961f5-00da-444b-95fa-f3d95a685956@24g2000yqa.googlegroups.com> Message-ID: On 1/27/2011 12:47 PM rantingrick said... > different choices OUTSIDE the stdlib. INSIDE the stdlib we have no > choice. Just wanted to make that clear. Only when you restrict yourself to the artificial restriction of 'no third party downloads allowed -- python must supply the right choice for my application no matter what' On that basis, os's ought to come with your browser and editor of choice as choice is the domain of the environment - not the user. If you think anyone capable of writing a gui application is incapable and needs to be babysat to that degree, then we're all stupid. T'ain't so. Emile From pavlovevidence at gmail.com Thu Jan 27 16:30:26 2011 From: pavlovevidence at gmail.com (Carl Banks) Date: Thu, 27 Jan 2011 13:30:26 -0800 (PST) Subject: Behaviour-based interface/protocol implementation? References: Message-ID: <999ee2b0-95b7-49be-a33d-f9c040ab21f5@32g2000yql.googlegroups.com> On Jan 24, 2:13?am, Alan Franzoni wrote: > Hello, > I'd like to have a system which lets me do certain actions if the > duck-type of a certain objects matches what I expect, i.e. I'd like to > have a formalization of what it's sometimes done through getattr() > calls: > > if getattr(myobj, "somemethod", None) is not None: > ? ? myobj.somemethod(somevalue) > > The above approach is sometimes too naive, because a) clutters code > with many getattr calls and ifs b) I might want to check for multiple > attributes and c) only checks for the method name and not for the > method's signature. Write some kind of signature proxy to do it. class SomeSignature(object): def __init__(self,target): self.target = target def somemethod(self,value): if hasattr(self.target,"somemethod"): self.target.somemethod(value) SomeSignature(myobj).somemethod(somevalue) Generalizing the proxy to easily accommodate all kinds of signatures to your heart's delight left as an exercise (and it's likley to involve metaclass programming). > After looking at PyProtocols, zope.interface and python's own abc > module, I'm left with a doubt: does any behaviour-based "interface > testing" system exist for Python? Based on this thread, you have quite specific requirements, so it's doubtful someone else has implemented exactly what you want. And because it hasn't been mentioned in this thread yet--surprisingly-- many people in Python prefer the EAFP strategy, "Easier to Ask Forgiveness than Permission", that is, to just do it and handle the resulting exception: try: myobj.somemethod(somevalue) except AttributeError: # doesn't fit signature, so do nothing pass Personally, I have my doubts about the method in general. It's definitely preferrable in many cases (like opening a file, where it avoids a race condition) but for something like this I don't see it working out too well. But I'm just throwing it out there. Carl Banks From rantingrick at gmail.com Thu Jan 27 16:38:52 2011 From: rantingrick at gmail.com (rantingrick) Date: Thu, 27 Jan 2011 13:38:52 -0800 (PST) Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com><9MB%o.14110$%64.6074@unlimited.newshosting.com><4A48EDF6D7634F2E994661A457451E87@teddy><753A4C5A6658470085804B13C80340F2@octavian> <4D40A97F.8090209@tysdomain.com><00ABBA322416409EB749102EB1CC5E61@octavian> <4D418054.8050002@tysdomain.com> <171961f5-00da-444b-95fa-f3d95a685956@24g2000yqa.googlegroups.com> Message-ID: On Jan 27, 3:19?pm, Emile van Sebille wrote: > On 1/27/2011 12:47 PM rantingrick said... > > > different choices OUTSIDE the stdlib. INSIDE the stdlib we have no > > choice. Just wanted to make that clear. > > Only when you restrict yourself to the artificial restriction of 'no > third party downloads allowed -- python must supply the right choice for > my application no matter what' Some people ARE in enviroments where they would like to add third party downloads but cannot. > On that basis, os's ought to come with your browser and editor of choice > as choice is the domain of the environment - not the user. Well then explain why Windows still ships with that god awful windows explorer? Tkinter IS Windows Explorer. Antiquated, legacy, bloatware. And it need to die! But this misses the entire point. We are not trying to please everyone because THAT would be impossible. What we are trying to do is keep Python relevant in the 21st century. Continuing to lug Tkinter around is killing Python's evolution. From kb1pkl at aim.com Thu Jan 27 16:48:42 2011 From: kb1pkl at aim.com (Corey Richardson) Date: Thu, 27 Jan 2011 16:48:42 -0500 Subject: WxPython versus Tkinter. In-Reply-To: <1a37f3d8-b580-4d6d-a5a3-de8cc1e656dd@y26g2000yqd.googlegroups.com> References: <4D3E4377.3060807@tysdomain.com><9MB%o.14110$%64.6074@unlimited.newshosting.com><4A48EDF6D7634F2E994661A457451E87@teddy><753A4C5A6658470085804B13C80340F2@octavian> <4D40A97F.8090209@tysdomain.com><00ABBA322416409EB749102EB1CC5E61@octavian> <4D418054.8050002@tysdomain.com> <1a37f3d8-b580-4d6d-a5a3-de8cc1e656dd@y26g2000yqd.googlegroups.com> Message-ID: <4D41E83A.3030209@aim.com> On 01/27/2011 04:10 PM, rantingrick wrote: > On Jan 27, 2:00 pm, Terry Reedy wrote: >> On 1/27/2011 12:54 PM, Octavian Rasnita wrote: >> >>> Everything that's not accessible is not recommended. >> >> By you. We get that. >> >> >Tkinter should be at most accepted because there is no better solution, >> >> As I said at the beginning of this thread, tkinter is currently the only >> option. What would have happened if there had been a real competitor >> when 3.0 was being developed? What would happen in the future if one >> were developed? I do not think anyone really knows. >> >>> at least for Python 3, not because it is the recommended solution. >> >> AS far as I know, Guido has never recommended any particular gui and I >> believe he has avoided doing so when asked. > > Yes but his silence speaks louder than words. He is saying " While i > won't defend Tkinter publicly, i won't promote any others as well". > This is a standard response you'd expect from a politician. These > types of questions avoid dealing with the elephant in the room. > > We can't just assume that Tkinter is best for Python just because > "Guido" does not want to "ruffle" some features. Actually if you look > back over the very few post where Guido did offer an argument for > Tkinter you'll the find the argument to be very weak. And to make > matters worse no one has the balls to question or argue Guido. Now > whilst i greatly respect Guido i will not hesitate for one second to > call him on weak arguments. > > Case in point: Just recently i posted one of Guido's such arguments in > another thread and responded to the argument. The original thread was > from roughly eight years ago. Yes this is how long it has been since > Guido offered argument for Tkinter. Does he honestly think that the > world has not changed significantly in eight years as to render > Tkinter into legacy? Does he also want us to believe that the world > has not changed dramatically in the last twenty years since Tkinter > was introduced? I have yet to get a response for his weak argument > eight years ago and i can expect we will hear nothing now. > wxPython is the best and most mature cross-platform GUI toolkit, given a number of constraints. The only reason wxPython isn't the standard Python GUI toolkit is that Tkinter was there first. -- Guido van Rossum (from http://www.wxpython.org/quotes.php) A weak argument - yes. But the thought is there, and it's the thought that counts, right? ;-) From tyler at tysdomain.com Thu Jan 27 16:49:21 2011 From: tyler at tysdomain.com (Littlefield, Tyler) Date: Thu, 27 Jan 2011 14:49:21 -0700 Subject: WxPython versus Tkinter. Message-ID: <4D41E861.9040604@tysdomain.com> >Yes but his silence speaks louder than words. He is saying " While i >won't defend Tkinter publicly, i won't promote any others as well". That's the best translation I've ever heard: taking silence and diverting it into your own meaning for what you want it to mean. From invalid at invalid.invalid Thu Jan 27 16:54:57 2011 From: invalid at invalid.invalid (Grant Edwards) Date: Thu, 27 Jan 2011 21:54:57 +0000 (UTC) Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com> <9MB%o.14110$%64.6074@unlimited.newshosting.com> <4A48EDF6D7634F2E994661A457451E87@teddy> <753A4C5A6658470085804B13C80340F2@octavian> <4D40A97F.8090209@tysdomain.com> <00ABBA322416409EB749102EB1CC5E61@octavian> <4D418054.8050002@tysdomain.com> <1a37f3d8-b580-4d6d-a5a3-de8cc1e656dd@y26g2000yqd.googlegroups.com> Message-ID: On 2011-01-27, rantingrick wrote: >> AS far as I know, Guido has never recommended any particular gui and I >> believe he has avoided doing so when asked. > > Yes but his silence speaks louder than words. He is saying " While i > won't defend Tkinter publicly, i won't promote any others as well". > This is a standard response you'd expect from a politician. These > types of questions avoid dealing with the elephant in the room. I think there are a lot of people who think that including a GUI in the standard library was a mistake and the best solution would be to get rid of Tkinter and replace it with nothing. If I were Guido and thought that, I'd probably keep mum about it as well. :) [I'm not claiming Guidoe does think that, but there are some pretty good arguments for not including a GUI at all.] > The community at large needs to know what Guido van Rossum thinks. You > owe us that much Guido. He doesn't "owe" you or me anything. -- Grant Edwards grant.b.edwards Yow! I'm not available at for comment.. gmail.com From emile at fenx.com Thu Jan 27 17:06:01 2011 From: emile at fenx.com (Emile van Sebille) Date: Thu, 27 Jan 2011 14:06:01 -0800 Subject: WxPython versus Tkinter. In-Reply-To: References: <4D3E4377.3060807@tysdomain.com><9MB%o.14110$%64.6074@unlimited.newshosting.com><4A48EDF6D7634F2E994661A457451E87@teddy><753A4C5A6658470085804B13C80340F2@octavian> <4D40A97F.8090209@tysdomain.com><00ABBA322416409EB749102EB1CC5E61@octavian> <4D418054.8050002@tysdomain.com> <171961f5-00da-444b-95fa-f3d95a685956@24g2000yqa.googlegroups.com> Message-ID: On 1/27/2011 1:38 PM rantingrick said... > Continuing to lug Tkinter around > is killing Python's evolution. Huh? Can you provide a reference where someone passed over python because of tkinter's inclusion in the standard library? You certainly can't mean that python's evolution over the past 10+ years from 1.5 days to 3.2rc1 was effectively killed. Why would anyone assume any different for the next ten? Emile From rantingrick at gmail.com Thu Jan 27 17:08:37 2011 From: rantingrick at gmail.com (rantingrick) Date: Thu, 27 Jan 2011 14:08:37 -0800 (PST) Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com><9MB%o.14110$%64.6074@unlimited.newshosting.com><4A48EDF6D7634F2E994661A457451E87@teddy><753A4C5A6658470085804B13C80340F2@octavian> <4D40A97F.8090209@tysdomain.com><00ABBA322416409EB749102EB1CC5E61@octavian> <4D418054.8050002@tysdomain.com> <1a37f3d8-b580-4d6d-a5a3-de8cc1e656dd@y26g2000yqd.googlegroups.com> Message-ID: On Jan 27, 3:48?pm, Corey Richardson wrote: > On 01/27/2011 04:10 PM, rantingrick wrote: > > > > > > > > > > > On Jan 27, 2:00 pm, Terry Reedy wrote: > >> On 1/27/2011 12:54 PM, Octavian Rasnita wrote: > > >>> Everything that's not accessible is not recommended. > > >> By you. We get that. > > >> ?>Tkinter should be at most accepted because there is no better solution, > > >> As I said at the beginning of this thread, tkinter is currently the only > >> option. What would have happened if there had been a real competitor > >> when 3.0 was being developed? What would happen in the future if one > >> were developed? I do not think anyone really knows. > > >>> at least for Python 3, not because it is the recommended solution. > > >> AS far as I know, Guido has never recommended any particular gui and I > >> believe he has avoided doing so when asked. > > > Yes but his silence speaks louder than words. He is saying " While i > > won't defend Tkinter publicly, i won't promote any others as well". > > This is a standard response you'd expect from a politician. These > > types of questions avoid dealing with the elephant in the room. > > > We can't just assume that Tkinter is best for Python just because > > "Guido" does not want to "ruffle" some features. Actually if you look > > back over the very few post where Guido did offer an argument for > > Tkinter you'll the find the argument to be very weak. And to make > > matters worse no one has the balls to question or argue Guido. Now > > whilst i greatly respect Guido i will not hesitate for one second to > > call him on weak arguments. > > > Case in point: Just recently i posted one of Guido's such arguments in > > another thread and responded to the argument. The original thread was > > from roughly eight years ago. Yes this is how long it has been since > > Guido offered argument for Tkinter. Does he honestly think that the > > world has not changed significantly in eight years as to render > > Tkinter into legacy? Does he also want us to believe that the world > > has not changed dramatically in the last twenty years since Tkinter > > was introduced? I have yet to get a response for his weak argument > > eight years ago and i can expect we will hear nothing now. > > wxPython is the best and most mature cross-platform GUI toolkit, given a > number of constraints. The only reason wxPython isn't the standard > Python GUI toolkit is that Tkinter was there first. > -- Guido van Rossum You forgot to put a date on that statement. Like of all of Guido's statements about Python they are from many, many years ago. And when i say many years i am talking 1990's. NEWSFLASH! The world has changed, GUI's have changed. All we have are these quotes from the 1990's to go on and i have had enough of this silence from Guido. Guid, SHOW YOURSELF! Come out from behind the safety and security of python-dev. Come out and show the peasants that you are in fact still a part of this community. Come out and walk among us. Come out and re- join the people in united celebration of 21st century evolution. But most of all, come out and defend those weak arguments you gave eight years ago. Even IF we "imagine" your arguments where enough to keep Tkinter then, how can you expect us to believe that now those arguments still hold merit in the year 2011? It is high time for you (Guido van Rossum) to weigh in on this discussion. The time of myths and legends is over, the time of community is NOW! Show yourself! From python at rcn.com Thu Jan 27 17:15:26 2011 From: python at rcn.com (Raymond Hettinger) Date: Thu, 27 Jan 2011 14:15:26 -0800 (PST) Subject: Wrappers in python References: <2100032d-dd99-4b10-b445-76b5dd1efb91@r19g2000prm.googlegroups.com> Message-ID: <8e225711-c412-4d3c-97f7-96d9ad17dabb@o7g2000prn.googlegroups.com> On Jan 27, 4:10?am, sl33k_ wrote: > What are wrappers? > > ?What entities do they wrap around? > > Struggling to understand the concept. http://www.castle-cadenza.demon.co.uk/wrapper.htm Raymond From mailing at franzoni.eu Thu Jan 27 17:23:56 2011 From: mailing at franzoni.eu (Alan Franzoni) Date: Thu, 27 Jan 2011 23:23:56 +0100 Subject: Behaviour-based interface/protocol implementation? In-Reply-To: <999ee2b0-95b7-49be-a33d-f9c040ab21f5@32g2000yql.googlegroups.com> References: <999ee2b0-95b7-49be-a33d-f9c040ab21f5@32g2000yql.googlegroups.com> Message-ID: On Thu, Jan 27, 2011 at 10:30 PM, Carl Banks wrote: > Write some kind of signature proxy to do it. I don't have a specific implementation idea yet, I see how that grows. > Based on this thread, you have quite specific requirements, so it's > doubtful someone else has implemented exactly what you want. Yes, but asking is better than blinding reimplementing :-) > And because it hasn't been mentioned in this thread yet--surprisingly-- > many people in Python prefer the EAFP strategy, "Easier to Ask > Forgiveness than Permission", that is, to just do it and handle the > resulting exception: > > try: > ? ?myobj.somemethod(somevalue) > except AttributeError: > ? ?# doesn't fit signature, so do nothing > ? ?pass Sure. That's an approach. But this has drawbacks. - it violates the CQS principle: http://en.wikipedia.org/wiki/Command-query_separation - Maybe my interface has not just a single method, and I might want to call multiple methods on my object. I need to check for all signatures before proceeding. - When calling the method, if an exception is raised - either AttributeError or TypeError most of the times - it could not be generated from my own call, but from a call deeper into the stack; It's easy to just think "that object doesn't support that interface" I could mistake an object for not supporting an interface, and I could silently swallow a true runtime exception instead. Maybe some stack analysis could be performed, but I'd prefer to check as much as I can *before* calling. - Sometimes I'd like to group objects depending on their *behaviour* (not their type), and then feed them somewhere else without actually calling their methods. If I can know their behaviour just after they've been called, it might be just too late. -- Alan Franzoni -- contact me at public@[mysurname].eu From rantingrick at gmail.com Thu Jan 27 17:24:12 2011 From: rantingrick at gmail.com (rantingrick) Date: Thu, 27 Jan 2011 14:24:12 -0800 (PST) Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com><9MB%o.14110$%64.6074@unlimited.newshosting.com><4A48EDF6D7634F2E994661A457451E87@teddy><753A4C5A6658470085804B13C80340F2@octavian> <4D40A97F.8090209@tysdomain.com><00ABBA322416409EB749102EB1CC5E61@octavian> <4D418054.8050002@tysdomain.com> <1a37f3d8-b580-4d6d-a5a3-de8cc1e656dd@y26g2000yqd.googlegroups.com> Message-ID: On Jan 27, 3:48?pm, Corey Richardson wrote: > A weak argument - yes. But the thought is there, and it's the thought > that counts, right? ;-) What thought? It screams lack of thought to me. We should just ignore a clearly better option because some other option was chosen first, THATS IT? Thats the best he can do? And it shows lack of resolve to move forward even in light of clearly better solutions. It boils down to lack of vision. They say as you grow older you start "setting your ways". Case in point <-- From rantingrick at gmail.com Thu Jan 27 17:28:39 2011 From: rantingrick at gmail.com (rantingrick) Date: Thu, 27 Jan 2011 14:28:39 -0800 (PST) Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com> <9MB%o.14110$%64.6074@unlimited.newshosting.com> <4A48EDF6D7634F2E994661A457451E87@teddy> <753A4C5A6658470085804B13C80340F2@octavian> <4D40A97F.8090209@tysdomain.com> <00ABBA322416409EB749102EB1CC5E61@octavian> <4D418054.8050002@tysdomain.com> <1a37f3d8-b580-4d6d-a5a3-de8cc1e656dd@y26g2000yqd.googlegroups.com> Message-ID: <1797b519-88f2-4b4f-832b-e8392619ac2e@q14g2000vbf.googlegroups.com> On Jan 27, 3:54?pm, Grant Edwards wrote: > On 2011-01-27, rantingrick wrote: > > >> AS far as I know, Guido has never recommended any particular gui and I > >> believe he has avoided doing so when asked. > > > Yes but his silence speaks louder than words. He is saying " While i > > won't defend Tkinter publicly, i won't promote any others as well". > > This is a standard response you'd expect from a politician. These > > types of questions avoid dealing with the elephant in the room. > > I think there are a lot of people who think that including a GUI in > the standard library was a mistake and the best solution would be to > get rid of Tkinter and replace it with nothing. ?If I were Guido and > thought that, I'd probably keep mum about it as well. :) Well i have considered that *maybe* he does feel this way. And by removing Tkinter not only would we take a huge burden from py-dev but we would also free Tkinter from the chains of stdlib. Could this help move Tkinter forward, i think so. > > The community at large needs to know what Guido van Rossum thinks. You > > owe us that much Guido. > > He doesn't "owe" you or me anything. Actually yes, he must give us good reason for this "holding on" to legacy technology. We deserve at least the respect of an explanation. That IS NOT too much to ask. I am tired of hearing Guido's thoughts second hand, i want to hear it strait from the horses mouth! From kb1pkl at aim.com Thu Jan 27 17:39:15 2011 From: kb1pkl at aim.com (Corey Richardson) Date: Thu, 27 Jan 2011 17:39:15 -0500 Subject: WxPython versus Tkinter. In-Reply-To: References: <4D3E4377.3060807@tysdomain.com><9MB%o.14110$%64.6074@unlimited.newshosting.com><4A48EDF6D7634F2E994661A457451E87@teddy><753A4C5A6658470085804B13C80340F2@octavian> <4D40A97F.8090209@tysdomain.com><00ABBA322416409EB749102EB1CC5E61@octavian> <4D418054.8050002@tysdomain.com> <1a37f3d8-b580-4d6d-a5a3-de8cc1e656dd@y26g2000yqd.googlegroups.com> Message-ID: <4D41F413.8000501@aim.com> On 01/27/2011 05:08 PM, rantingrick wrote: >> wxPython is the best and most mature cross-platform GUI toolkit, given a >> number of constraints. The only reason wxPython isn't the standard >> Python GUI toolkit is that Tkinter was there first. >> -- Guido van Rossum > > You forgot to put a date on that statement. I didn't forget - there was no date provided. From urban.dani at gmail.com Thu Jan 27 17:41:08 2011 From: urban.dani at gmail.com (Daniel Urban) Date: Thu, 27 Jan 2011 23:41:08 +0100 Subject: Behaviour-based interface/protocol implementation? In-Reply-To: References: Message-ID: On Thu, Jan 27, 2011 at 20:05, Alan Franzoni wrote: > On Thu, Jan 27, 2011 at 8:03 PM, Alan Franzoni wrote: >> Yes, __instancecheck__ could be used as an alternative hook with >> respect to maybe_implemented_by(), but there's no such logic for >> signature checking. That's a minor detail, I think. > > On the contrary, now that I double checked, it can't be used that way; > I don't want to modify the object I'm testing (it could be a third > party object) nor I want to force it to be "registered" as a certain > ABC; so __instancecheck__() is just useless here. Actually it can. You don't have to modify the object, just check for the desired methods/signature/whatever. See for example the implementation of collections.Hashable.__subclasshook__ in _abcoll.py and the abc.ABCMeta.__instancecheck__ method. Daniel From robert.kern at gmail.com Thu Jan 27 17:43:43 2011 From: robert.kern at gmail.com (Robert Kern) Date: Thu, 27 Jan 2011 16:43:43 -0600 Subject: Need GUI pop-up to edit a (unicode ?) string In-Reply-To: <4D41B712.1020504@ixokai.io> References: <3tqr08-bj2.ln1@murmur.very.softly> <7691fe98-37af-4ddf-a8a8-eadeef0d4a6e@y2g2000prf.googlegroups.com> <541c02df-b1fc-4376-bf17-e0531fe5c4bf@r29g2000yqj.googlegroups.com> <4D41B712.1020504@ixokai.io> Message-ID: On 2011-01-27 12:18 , Stephen Hansen wrote: > On 1/27/11 10:04 AM, Grant Edwards wrote: >> On 2011-01-27, Stephen Hansen wrote: >>> On 1/25/11 3:02 PM, rantingrick wrote: >>>> This is a major flaw in the design and i would be >>>> happy to fix the flaw. However our "friend" Fredrick decided to >>>> copyright the module to himself! What a jerk! Which is quite >>>> disgusting considering that Tkinter, and TclTk are completely open >>>> source! >>> >>> Uh. ... LOL. >>> >>> Copyright doesn't mean what you think it means. >>> >>> Tkinter is copyrighted. Python is copyrighted. Tcl/TK is copyrgithed. >>> >>> In fact: everything that is "open source" is copyrighted. By >>> definition[* see footnote]. >> >> One (domestic US) exception would be open-source software written by >> an employee of the US federal government. Works produced by the US >> Government are not copyrighted under US domestic copyright law. Such >> works are copyrighted under international law (which is probably what >> the Python maintainers care about). > > I've actually wondered a bit about that: but the only open source > software that I'm aware of that's been government-adjacent has ended up > being written/owned by some University or joint venture funded by a > government agency -- it didn't fall into the public domain category of > content created directly by the federal government. > > Are you aware of any code out there that is? Just curious. I'm not > arguing that the exception doesn't exist or anything. A lot of stuff from NIST is legitimately public domain. E.g. http://fingerprint.nist.gov/NFIS/ -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco From aahz at pythoncraft.com Thu Jan 27 17:47:54 2011 From: aahz at pythoncraft.com (Aahz) Date: 27 Jan 2011 14:47:54 -0800 Subject: Creating custom Python objects from C code References: Message-ID: In article , Eric Frederich wrote: > >I have read through all the documentation here: > > http://docs.python.org/extending/newtypes.html > >I have not seen any documentation anywhere else explaining how to >create custom defined objects from C. I have this need to create >custom objects from C and pass them as arguments to a function call. You should definitely investigate Cython, but if you really want to roll your own, look in the examples inside the Python source itself. -- Aahz (aahz at pythoncraft.com) <*> http://www.pythoncraft.com/ "All problems in computer science can be solved by another level of indirection." --Butler Lampson From ethan at stoneleaf.us Thu Jan 27 18:11:49 2011 From: ethan at stoneleaf.us (Ethan Furman) Date: Thu, 27 Jan 2011 15:11:49 -0800 Subject: Return Statement In-Reply-To: References: Message-ID: <4D41FBB5.3050509@stoneleaf.us> mpnordland wrote: > On 01/26/2011 03:26 PM, sl33k_ wrote: >> How does "return True" and "return False" affect the execution of the >> calling function? > > Basically it will affect it in whatever way you design it to for example: > def lie_test(statement): > if statement is True: > return False > else: > return False > Now, this is psuedo code somewhat. > "if statement is True:" would always equate to "True" unless statement > was an empty string, None, or 0. Um, no. Python 2.5.4 (r254:67916, Dec 23 2008, 15:10:54) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. --> if 'some stuff' is True: ... print 'True' ... else: ... print "it's a dang lie!" ... it's a dang lie! You need either < if bool(statement) is True: >, or < if bool(statement): >, or, simplest, < if statement: > > As to return False if statement equals > true, look at the function name. It is testing to see if it is a lie, > and if it is true, then it's not a lie. Your last statement, though, should be return True -- the way you have it now the function always returns False. ~Ethan~ From emile at fenx.com Thu Jan 27 18:28:59 2011 From: emile at fenx.com (Emile van Sebille) Date: Thu, 27 Jan 2011 15:28:59 -0800 Subject: WxPython versus Tkinter. In-Reply-To: <1797b519-88f2-4b4f-832b-e8392619ac2e@q14g2000vbf.googlegroups.com> References: <4D3E4377.3060807@tysdomain.com> <9MB%o.14110$%64.6074@unlimited.newshosting.com> <4A48EDF6D7634F2E994661A457451E87@teddy> <753A4C5A6658470085804B13C80340F2@octavian> <4D40A97F.8090209@tysdomain.com> <00ABBA322416409EB749102EB1CC5E61@octavian> <4D418054.8050002@tysdomain.com> <1a37f3d8-b580-4d6d-a5a3-de8cc1e656dd@y26g2000yqd.googlegroups.com> <1797b519-88f2-4b4f-832b-e8392619ac2e@q14g2000vbf.googlegroups.com> Message-ID: On 1/27/2011 2:28 PM rantingrick said... > And by > removing Tkinter not only would we take a huge burden from py-dev but > we would also free Tkinter from the chains of stdlib. Actually, IIRC, very little effort is put into maintaining tkinter by the py-dev crowd. I think I saw a post by Martin that he'll put some time in every couple years integrating submitted patches. So, no traction with that argument either. Emile From craigyk at me.com Thu Jan 27 18:44:31 2011 From: craigyk at me.com (Craig Yoshioka) Date: Thu, 27 Jan 2011 15:44:31 -0800 Subject: help with multiprocessing pool In-Reply-To: <016BC5FD-80F5-4578-9448-A592AD626C18@semanchuk.com> References: <2A124DD5-95F2-4DE0-AB0F-5D3EA39A230B@semanchuk.com> <016BC5FD-80F5-4578-9448-A592AD626C18@semanchuk.com> Message-ID: I did eventually get the original code to run from the command line but not the interpreter, so the new example does have a similar problem. Of course it's not as simple as saying I can't run an imported parallelized function from the interpreter because I can, as long as the parallelized function is being invoked directly. But if I caused the parallelized function to be invoked indirectly, for example, by importing a class that uses the parallelized function to set a class variable, it'll hang the interpreter. for now I added the following to any module that uses parallelized functions import __main__ if hasattr(__main__,'__file__'): __SHOULD_MULTITHREAD__ = True else: __SHOULD_MULTITHREAD__ = False and the parallelized functions check this flag to determine wether to run serially or not. This at least lets me import my classes into the interpreter so I can 'play' with them, although they initialize much slower. I'm not sure why Pool needs the __main__ module, except maybe someone sticks centralized process tracking information in there... sigh add it to the fuel of my love/hate with Python. On Jan 27, 2011, at 10:38 AM, Philip Semanchuk wrote: > > On Jan 27, 2011, at 1:12 PM, Craig Yoshioka wrote: > >> The code will be multi-platform. The OSXisms are there as an example, though I am developing on OS X machine. >> >> I've distilled my problem down to a simpler case, so hopefully that'll help troubleshoot. >> >> I have 2 files: >> >> test.py: >> -------------------------------------------------------------- >> from multiprocessing import Pool >> >> def square(x): >> return x*x >> >> def squares(numbers): >> pool = Pool(12) >> return pool.map(square,numbers) >> >> >> test2.py: >> -------------------------------------------------------------- >> from test import squares >> >> maxvalues = squares(range(3)) >> print maxvalues >> >> >> >> Now if I import squares into the interactive interpreter: >> >> from test import squares >> print squares(range(3)) >> >> I get the correct result, but if I try to import maxvalues from test2 the interactive interpreter python hangs. >> if I run the script from bash, though, it seems to run fine. > > The short, complete example is much more useful, but it sounds like it demonstrates a different problem than you first described. Your first posting said that your code worked in the interpreter but failed when run from the command line. This code has the opposite problem. Correct? > >> I think it might have something to do with this note in the docs, though I am not sure how to use this information to fix my problem: >> >> Note: Functionality within this package requires that the __main__ method be importable by the children. This is covered inProgramming guidelines however it is worth pointing out here. This means that some examples, such as themultiprocessing.Pool examples will not work in the interactive interpreter. > > I suspect this is the problem with the demo above. Your original code ran fine in the interpreter, though, correct? > > bye > Philip > > >> >> On Jan 27, 2011, at 6:39 AM, Philip Semanchuk wrote: >> >>> >>> On Jan 25, 2011, at 8:19 PM, Craig Yoshioka wrote: >>> >>>> Hi all, >>>> >>>> I could really use some help with a problem I'm having. >>> >>> >>> Hiya Craig, >>> I don't know if I can help, but it's really difficult to do without a full working example. >>> >>> Also, your code has several OS X-isms in it so I guess that's the platform you're on. But in case you're on Windows, note that that platform requires some extra care when using multiprocessing: >>> http://docs.python.org/library/multiprocessing.html#windows >>> >>> >>> Good luck >>> Philip >>> >>> >>>> I wrote a function that can take a pattern of actions and it apply it to the filesystem. >>>> It takes a list of starting paths, and a pattern like this: >>>> >>>> pattern = { >>>> InGlob('Test/**'):{ >>>> MatchRemove('DS_Store'):[], >>>> NoMatchAdd('(alhpaID_)|(DS_Store)','warnings'):[], >>>> MatchAdd('alphaID_','alpha_found'):[], >>>> InDir('alphaID_'):{ >>>> NoMatchAdd('(betaID_)|(DS_Store)','warnings'):[], >>>> InDir('betaID_'):{ >>>> NoMatchAdd('(gammaID_)|(DS_Store)','warnings'):[], >>>> MatchAdd('gammaID_','gamma_found'):[] }}}} >>>> >>>> so if you run evalFSPattern(['Volumes/**'],pattern) it'll return a dictionary where: >>>> >>>> dict['gamma_found'] = [list of paths that matched] (i.e. '/Volumes/HD1/Test/alphaID_3382/betaID_38824/gammaID_848384') >>>> dict['warning'] = [list of paths that failed to match] (ie. '/Volumes/HD1/Test/alphaID_3382/gammaID_47383') >>>> >>>> Since some of these volumes are on network shares I also wanted to parallelize this so that it would not block on IO. I started the parallelization by using multiprocessing.Pool and got it to work if I ran the fsparser from the interpreter. It ran in *much* less time and produced correct output that matched the non-parallelized version. The problem begins if I then try to use the parallelized function from within the code. >>>> >>>> For example I wrote a class whose instances are created around valid FS paths, that are cached to reduce expensive FS lookups. >>>> >>>> class Experiment(object): >>>> >>>> SlidePaths = None >>>> >>>> @classmethod >>>> def getSlidePaths(cls): >>>> if cls.SlidePaths == None: >>>> cls.SlidePaths = fsparser(['/Volumes/**'],pattern) >>>> return cls.SlidePaths >>>> >>>> @classmethod >>>> def lookupPathWithGammaID(cls,id): >>>> paths = cls.getSlidePaths() >>>> ... >>>> return paths[selected] >>>> >>>> @classmethod >>>> def fromGamaID(cls,id): >>>> path = cls.lookupPathWithGammaID(id) >>>> return cls(path) >>>> >>>> def __init__(self,path) >>>> self.Path = path >>>> ... >>>> >>>> ... >>>> >>>> If I do the following from the interpreter it works: >>>> >>>>>>> from experiment import Experiment >>>>>>> expt = Experiment.fromGammaID(10102) >>>> >>>> but if I write a script called test.py: >>>> >>>> from experiment import Experiment >>>> expt1 = Experiment.fromGammaID(10102) >>>> expt2 = Experiment.fromGammaID(10103) >>>> comparison = expt1.compareTo(expt2) >>>> >>>> it fails, if I try to import it or run it from bash prompt: >>>> >>>>>>> from test import comparison (hangs forever) >>>> $ python test.py (hangs forever) >>>> >>>> I would really like some help trying to figure this out... I thought it should work easily since all the spawned processes don't share data or state (their results are merged in the main thread). The classes used in the pattern are also simple python objects (use python primitives). >>>> >>>> >>>> These are the main functions: >>>> >>>> def mapAction(pool,paths,action): >>>> merge = {'next':[]} >>>> for result in pool.map(action,paths): >>>> if result == None: >>>> continue >>>> merge = mergeDicts(merge,result) >>>> return merge >>>> >>>> >>>> def mergeDicts(d1,d2): >>>> for key in d2: >>>> if key not in d1: >>>> d1[key] = d2[key] >>>> else: >>>> d1[key] += d2[key] >>>> return d1 >>>> >>>> >>>> def evalFSPattern(paths,pattern): >>>> pool = Pool(10) >>>> results = {} >>>> for action in pattern: >>>> tomerge1 = mapAction(pool,paths,action) >>>> tomerge2 = evalFSPattern(tomerge1['next'],pattern[action]) >>>> del tomerge1['next'] >>>> results = mergeDicts(results,tomerge1) >>>> results = mergeDicts(results,tomerge2) >>>> return results >>>> >>>> the classes used in the pattern (InGlob,NoMatchAdd,etc.) are callable classes that take a single parameter (a path) and return a dict result or None which makes them trivial to adapt to Pool.map. >>>> >>>> Note if I change the mapAction function to: >>>> >>>> def mapAction(pool,paths,action): >>>> merge = {'next':[]} >>>> for path in paths: >>>> result = action(path) >>>> if result == None: >>>> continue >>>> merge = mergeDicts(merge,result) >>>> return merge >>>> >>>> everything works just fine. >>>> >>>> >>>> Thanks. >>>> >>>> >>>> -- >>>> http://mail.python.org/mailman/listinfo/python-list >>> >>> -- >>> http://mail.python.org/mailman/listinfo/python-list >> > > -- > http://mail.python.org/mailman/listinfo/python-list From kw at codebykevin.com Thu Jan 27 18:50:44 2011 From: kw at codebykevin.com (Kevin Walzer) Date: Thu, 27 Jan 2011 18:50:44 -0500 Subject: WxPython versus Tkinter. In-Reply-To: References: <4D4093AF.80806@etrix.com.au> Message-ID: On 1/27/11 1:11 PM, rantingrick wrote: > Actually we don't want "Robins wxPython" in the stdlib "as is" anyway. > What we DO want is an abstraction API for the short term that plugs > into Robin's wx. Then over the long term we will either convince him > to create a better API OR just create our own wxPython directly from > WxWidgets and mold it into the stdlib. So hinging on the argument of > what one*single* man thinks is a non-starter. I saw this comment elsewhere in the thread, and I'm a bit confused. As I understand it, you want to layer a Tkinter-style abstraction API over wxPython? You had mentioned that you want to include something like Tkinter's grid/pack/place management API's, its event-handling mechanism, its use of tags, and a few other things? I'd like to suggest that these things are already in the stdlib, in the form of Tkinter itself. And at least some thing these things are tightly bound to Tkinter's inclusion of the Tcl interpreter. For instance, Tcl has a powerful and flexible event loop mechanism. Does wxWidgets have something similar? And are Tkinter's grid/pack/place geometry managers (which are defined at the C level) compatible with wx sizers, which are also defined at the lower C++ level? While this thread has taken many twists and turns, it nonetheless seems to me that the proposal being offered is to layer a Tkinter-style API over a Tkinter-scale subset of wxPython's widgets (listbox, button, menu, etc.). After all that work, what would really be gained? We'd have the same small core of widgets, with an arguably less stable base (since wxPython seems to have problems with segfaults on Linux). It is not persuasive to say that Tkinter is "legacy" while wxPython is "the future." Both Tk and wxWidgets date to the early 1990s. Tk did stagnate for a number of years, but its development in the past few years has been reinvigorated by the ttk themed widgets, in addition to various extension packages that use Tk's C API, and it is now a peer to wxWidgets in its GUI capabilties. I can't speak to Tkinter's performance relative to wxPython and the Tcl interpreter, but any performance gains that are achieved by wxPython's underlying C++ library may be obviated by lesser stability. After all the back-and-forth, I am simply not persuaded, especially since the proposal being offered is not to replace Tkinter with wxPython in the stdlib, but to instead replace Tkinter with a yet-to-be-designed wxTkinter amalgamation (a Tkinter body on a wxPython chassis). --Kevin -- Kevin Walzer Code by Kevin http://www.codebykevin.com From tjreedy at udel.edu Thu Jan 27 18:58:26 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Thu, 27 Jan 2011 18:58:26 -0500 Subject: WxPython versus Tkinter. In-Reply-To: <4D41E83A.3030209@aim.com> References: <4D3E4377.3060807@tysdomain.com><9MB%o.14110$%64.6074@unlimited.newshosting.com><4A48EDF6D7634F2E994661A457451E87@teddy><753A4C5A6658470085804B13C80340F2@octavian> <4D40A97F.8090209@tysdomain.com><00ABBA322416409EB749102EB1CC5E61@octavian> <4D418054.8050002@tysdomain.com> <1a37f3d8-b580-4d6d-a5a3-de8cc1e656dd@y26g2000yqd.googlegroups.com> <4D41E83A.3030209@aim.com> Message-ID: On 1/27/2011 4:48 PM, Corey Richardson wrote: > wxPython is the best and most mature cross-platform GUI toolkit, given a > number of constraints. The only reason wxPython isn't the standard > Python GUI toolkit is that Tkinter was there first. > -- Guido van Rossum > > (from http://www.wxpython.org/quotes.php) Of course, that is not the only reason now. Python has moved on to a 21st century version, while wxpython is still stuck on the 20century version. -- Terry Jan Reedy From mpnordland at gmail.com Thu Jan 27 19:16:58 2011 From: mpnordland at gmail.com (mpnordland) Date: Thu, 27 Jan 2011 19:16:58 -0500 Subject: Return Statement In-Reply-To: <4D41FBB5.3050509@stoneleaf.us> References: <4D41FBB5.3050509@stoneleaf.us> Message-ID: I stand corrected :) From rantingrick at gmail.com Thu Jan 27 19:54:34 2011 From: rantingrick at gmail.com (rantingrick) Date: Thu, 27 Jan 2011 16:54:34 -0800 (PST) Subject: WxPython versus Tkinter. References: <4D4093AF.80806@etrix.com.au> Message-ID: <0973f16e-ae4b-4adf-be99-6955be3d3cca@s28g2000prb.googlegroups.com> On Jan 27, 5:50?pm, Kevin Walzer wrote: > On 1/27/11 1:11 PM, rantingrick wrote: [...] Hello again Kevin and nice to have you back! Yes the minor details have been evolving over the course of this and another thread. We have been floating new ideas all along the way in an effort to get the best result. In the very beginning because we all know that wxPython IS HUGE i offered a divide and conquer approach... * Small "Tkinter-like" stdlib module. * Full featured third party download. By doing this we can keep the stdlib smaller and leave the bulk of wx in a 3rd party download. Then we floated around installing the entire wxPython library because after all hard drives are only getting bigger. However i think that neither are the best Option. In any event the ideas (like any ideas in a lively discussion) are very fluid in nature. Part of generating the best conclusion is by twisting and turning every idea until it fits neatly into some stated goals. And yes, we want to get the most bang for our community buck! I am now convinced that "Robins wxPython" is woefully inadequate due to the API. We can never consider putting such a blasphemy into the stdlib. Does that mean we should ignore the great benefits of wxWidgets? HELL NO, we would be fools if we did! Now i am thinking along the lines of an abstraction API that plugs into wxPython. We keep Tkinter until say "Python4000", but in the meantime we create a "pythonic wxPython" from the ground up (stealing as much as we can from Robin!). By doing this we can integrate wxPython at whatever rate the community can bear at the time. The only thing better would be to convince all GUI library creators to start thinking globally. To start setting a global standard for all GUI libraries. Then all we would have to do is create a Python API and just "plug" it in generically to WX, TK, GTK, QT, Etc, Etc. I know this sounds like a pipe dream, but this is what must happen at some point. And we should all be demanding this everyday. Always Remember: Selfishness = Multiplicity = Entropy = Shock = Stagnation = None > While this thread has taken many twists and turns, it nonetheless seems > to me that the proposal being offered is to layer a Tkinter-style API > over a Tkinter-scale subset of wxPython's widgets (listbox, button, > menu, etc.). After all that work, what would really be gained? We'd have > the same small core of widgets, with an arguably less stable base (since > wxPython seems to have problems with segfaults on Linux). Yes this discussion has taken many turns. Read my previous statement for insight. > It is not persuasive to say that Tkinter is "legacy" while wxPython is > "the future." Both Tk and wxWidgets date to the early 1990s. Tk did > stagnate for a number of years, but its development in the past few > years has been reinvigorated by the ttk themed widgets, in addition to > various extension packages that use Tk's C API, Yes Tk has just recently "come out of stagnation". But for how long? How long must we wait for them to "get it together"? Thats my point. We will all be dead and rotting by the time Tkinter is including a ListCtrl and accessibility. And i don't know about you Kevin, but i really don't want to wait that long! > and it is now a peer to > wxWidgets in its GUI capabilties. I can't speak to Tkinter's performance > relative to wxPython and the Tcl interpreter, but any performance gains > that are achieved by wxPython's underlying C++ library may be obviated > by lesser stability. wxPython IS NOT less stable than Tkinter: That is a FACT. However, WxPythons API was written in such a horribly unpythonic way (sorry Robin) that someone could find themselves in trouble IF they are not experienced enough to use the library. However, we can easily fix an API. What we can't fix is lack of vision and stagnation in an outside community. We must help ourselves because no one else is going to do it for us! > After all the back-and-forth, I am simply not persuaded, especially > since the proposal being offered is not to replace Tkinter with wxPython > in the stdlib, but to instead replace Tkinter with a yet-to-be-designed > wxTkinter amalgamation (a Tkinter body on a wxPython chassis). Not exactly Kevin. What i intend to do is take your Yugo (Tkinter) to my shop and rip out the antiquated engine, rusty transmission, and remove those "may-pop" tires. Then i plan to replace them with the best high performance parts that are available (wxWidgets) and probably even give her a nice paint job too (Tkinter API)! And when i am done, all your friends are going to be jealous and all the women are going to want a ride in your new hotrod. Kevin, i am going to make you the coolest cat in town! But nobody said it was going to an easy task! ;-) From mpnordland at gmail.com Thu Jan 27 19:58:22 2011 From: mpnordland at gmail.com (mpnordland) Date: Thu, 27 Jan 2011 19:58:22 -0500 Subject: replacing lines in a file In-Reply-To: <4D40B2EC.1070309@mrabarnett.plus.com> References: <4D40B2EC.1070309@mrabarnett.plus.com> Message-ID: thanks for explaining what I was doing wrong and how reading the file works. What would you suggest I do to remedy the situation? From misnomer at gmail.com Thu Jan 27 20:24:52 2011 From: misnomer at gmail.com (Nicholas Devenish) Date: Fri, 28 Jan 2011 01:24:52 +0000 Subject: WxPython versus Tkinter. In-Reply-To: <0973f16e-ae4b-4adf-be99-6955be3d3cca@s28g2000prb.googlegroups.com> References: <4D4093AF.80806@etrix.com.au> <0973f16e-ae4b-4adf-be99-6955be3d3cca@s28g2000prb.googlegroups.com> Message-ID: On 28/01/2011 00:54, rantingrick AKA "Brian" wrote: > Yes the minor details have been evolving over the course of this and > another thread. We have been floating new ideas all along the way in > an effort to get the best result. In the very beginning because we all > know that wxPython IS HUGE i offered a divide and conquer approach... In other, greater words: "He's making it up as he goes along." From python at mrabarnett.plus.com Thu Jan 27 21:38:44 2011 From: python at mrabarnett.plus.com (MRAB) Date: Fri, 28 Jan 2011 02:38:44 +0000 Subject: replacing lines in a file In-Reply-To: References: <4D40B2EC.1070309@mrabarnett.plus.com> Message-ID: <4D422C34.2010001@mrabarnett.plus.com> On 28/01/2011 00:58, mpnordland wrote: > thanks for explaining what I was doing wrong and how reading the file > works. What would you suggest I do to remedy the situation? > Write the new config out to a new file and then replace the old file with the new file. I'd use shutil.move(...) to do the replacement. This means that the existing config file will remain unchanged until you've successfully created the new config file (it's somewhat annoying if you're modifying a file and there's an exception part way through due to a bug, leaving 'invalid' contents!) From wuwei23 at gmail.com Thu Jan 27 21:53:03 2011 From: wuwei23 at gmail.com (alex23) Date: Thu, 27 Jan 2011 18:53:03 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com><63eea$4d3cd2fd$4275d90a$14984@FUSE.NET><69465430-08b3-4069-99c7-72f4d3034c66@s5g2000yqm.googlegroups.com><705ad$4d3ce0fc$4275d90a$29144@FUSE.NET> <2sm%o.8695$gM3.6118@viwinnwfe01.internal.bigpond.com> <0c3c61b0-d056-4757-b7e4-fecdf9a6e217@fm22g2000vbb.googlegroups.com> <94c48579-aed0-4987-aaa4-0f7b6209d9bb@8g2000prt.googlegroups.com> <704dd789-0eb2-4a33-9f2b-2363d3f5793f@s18g2000vbe.googlegroups.com> Message-ID: rantingrick wrote: > You'll need to read that snippet in context to understand what i was > talking about. Again, see my "tip of the day" in my last post to you. Pass. I'd have to see value in what you say inside of the endless masturbatory self-aggrandizement that you pass off as "visionary" posts. Instead it's all blah blah blah RUBY ASSHOLES blah blah INCOHERENT IDEA blah LAZY BASTARDS WHO DON'T APPRECIATE ME etc etc From kb1pkl at aim.com Thu Jan 27 22:00:25 2011 From: kb1pkl at aim.com (Corey Richardson) Date: Thu, 27 Jan 2011 22:00:25 -0500 Subject: WxPython versus Tkinter. In-Reply-To: References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com><63eea$4d3cd2fd$4275d90a$14984@FUSE.NET><69465430-08b3-4069-99c7-72f4d3034c66@s5g2000yqm.googlegroups.com><705ad$4d3ce0fc$4275d90a$29144@FUSE.NET> <2sm%o.8695$gM3.6118@viwinnwfe01.internal.bigpond.com> <0c3c61b0-d056-4757-b7e4-fecdf9a6e217@fm22g2000vbb.googlegroups.com> <94c48579-aed0-4987-aaa4-0f7b6209d9bb@8g2000prt.googlegroups.com> <704dd789-0eb2-4a33-9f2b-2363d3f5793f@s18g2000vbe.googlegroups.com> Message-ID: <4D423149.105@aim.com> On 01/27/2011 09:53 PM, alex23 wrote: > rantingrick wrote: >> You'll need to read that snippet in context to understand what i was >> talking about. Again, see my "tip of the day" in my last post to you. > > Pass. I'd have to see value in what you say inside of the endless > masturbatory self-aggrandizement that you pass off as "visionary" > posts. Instead it's all blah blah blah RUBY ASSHOLES blah blah > INCOHERENT IDEA blah LAZY BASTARDS WHO DON'T APPRECIATE ME etc etc Because insults and flaming totally get anyone anywhere. If you don't have anything civil to say, don't say it at all (Because sometimes un-nice things need to be said). From wuwei23 at gmail.com Thu Jan 27 22:00:45 2011 From: wuwei23 at gmail.com (alex23) Date: Thu, 27 Jan 2011 19:00:45 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <8q7sgiF5tpU1@mid.individual.net> <19891784-d6a3-41ac-a097-5902a6323bc0@o21g2000prn.googlegroups.com><0b12cdb1-45b4-41e4-9bdb-074ee669d76b@k14g2000pre.googlegroups.com> <048FB74272D440A0915ABC7D76AE262B@teddy> <5782E9AD8A8342D691EB3549E5E0ED7B@octavian> Message-ID: <409f37bb-6eb4-49ee-95cc-c4a9ea91b207@s29g2000pra.googlegroups.com> "Octavian Rasnita" wrote: > Ok, in this case I understand why WxPython can't be included in stdlib. > I think there was a communication problem because the oldest list members > start with the idea that all the list members know who is who and they may > be thinking that I don't want to accept the reality or that I have bad > feelings about some list members or something like that. The only expectation I as a list member have of you is that you maybe hit the web and do a bit of search & research before starting on an endless tirade. Implying that it was the responsibility of everyone here to explain every little aspect of an issue you're supposedly passionate about makes you seem either lazy or ignorant. From wuwei23 at gmail.com Thu Jan 27 22:07:20 2011 From: wuwei23 at gmail.com (alex23) Date: Thu, 27 Jan 2011 19:07:20 -0800 (PST) Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com><9MB%o.14110$%64.6074@unlimited.newshosting.com><4A48EDF6D7634F2E994661A457451E87@teddy><753A4C5A6658470085804B13C80340F2@octavian> <4D40A97F.8090209@tysdomain.com><00ABBA322416409EB749102EB1CC5E61@octavian> <4D418054.8050002@tysdomain.com> <171961f5-00da-444b-95fa-f3d95a685956@24g2000yqa.googlegroups.com> Message-ID: <3ec30430-9a40-4f0c-8d8f-cda09ac3c3ac@u11g2000prk.googlegroups.com> rantingrick wrote: > different choices OUTSIDE the stdlib. INSIDE the stdlib we have no > choice. Just wanted to make that clear. Because packaging a dependency with your application is an arcane art lost to modern times? From brian.curtin at gmail.com Thu Jan 27 23:18:41 2011 From: brian.curtin at gmail.com (Brian Curtin) Date: Thu, 27 Jan 2011 22:18:41 -0600 Subject: PSF Sprints - Call For Applications Message-ID: Hello Python Users! On behalf of the Python Software Foundation?s sponsored sprint group, I wanted to drop your group a quick note introducing us. If you?re already familiar with our sponsored sprints, you?ll be happy to know we made a few changes to help both sprint groups and Python even more. The PSF recently set aside funding to be distributed to groups who spend time contributing to the Python ecosystem, often in the form of development sprints. Our goal is to help you help Python, so whether it?s buying meals or renting meeting space for your all-day hackathon, we have a budget set aside to reimburse your expenses up to $300 USD (up from $250). If your goal is to make the Python world a better place, and you work on the problems facing Python today, we want to help you. We?re looking for groups of hackers that spend their time fixing and expanding the wide variety of Python interpreters, libraries, tools, and anything else affecting the community.We?re also looking for groups who want to help and get started but don?t have the resources to get together. Whether your group is separated by a train ride or lacking a shared space, we want to help you. On-boarding new contributors to open source Python projects is an especially important area that we?d like to work with.This means if you have a Python project and you want to sprint -- we want to help you.Some sprints we?ve sponsored include the porting of Genshi to Python 3, improvements to packaging (Distribute/distutils), and most recently, the PyPy winter sprint in Switzerland. If your group is interested in hosting a sprint, check out the full details of our call for applications at http://www.pythonsprints.com/cfa/ and contact us at sprints at python.org. Thanks for your time, and happy sprinting! Brian Curtin Jesse Noller http://www.pythonsprints.com/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From rantingrick at gmail.com Fri Jan 28 00:34:01 2011 From: rantingrick at gmail.com (rantingrick) Date: Thu, 27 Jan 2011 21:34:01 -0800 (PST) Subject: Bugs/issues in tkinter.simpledialog!! References: <412e4d83-f750-441d-bfc5-d96c0559e069@e9g2000prn.googlegroups.com> Message-ID: On Jan 26, 3:57?pm, Terry Reedy wrote: > On 1/26/2011 11:53 AM, rantingrick wrote: > > To answer your other post, one of the main people to touch tkinter in > the last 3 years was Guilherme Polo, who worked on it during and after a > Google Summer of Code project. He does not seen to be active currently. > > There are currently 63 open issues on the tracker listing tkinter as a > component. There are probably a few that could be closed. When I have > learned more, I should be able to review any patched sitting around. Well i tried searching for "Tkinter" issues on the tracker and just got annoyed quickly and left. It seems far to complicated to do searches with this software. Anyhoo, i did find the most current version of tksimpledialog.py and sure enough all the issues i have documented have been ported into this new version. From research at johnohagan.com Fri Jan 28 01:29:10 2011 From: research at johnohagan.com (John O'Hagan) Date: Fri, 28 Jan 2011 06:29:10 +0000 Subject: how to read the last line of a huge file??? In-Reply-To: References: Message-ID: <201101280629.11288.research@johnohagan.com> On Wed, 26 Jan 2011, Xavier Heruacles wrote: > I have do some log processing which is usually huge. The length of each > line is variable. How can I get the last line?? Don't tell me to use > readlines or something like linecache... file.seek takes an optional 'whence' argument which is 2 for the end, so you can just work back from there till you hit the first newline that has anything after it: def lastline(filename): offset = 0 line = '' with open(filename) as f: while True: offset -= 1 f.seek(offset, 2) nextline = f.next() if nextline == '\n' and line.strip(): return line else: line = nextline John From vaduvoiutibi at yahoo.com Fri Jan 28 02:34:57 2011 From: vaduvoiutibi at yahoo.com (Vaduvoiu Tiberiu) Date: Thu, 27 Jan 2011 23:34:57 -0800 (PST) Subject: dictionary error: list assignment index out of range Message-ID: <753474.31840.qm@web113802.mail.gq1.yahoo.com> Hy everyone, I'm trying to learng python for a week or two and there's a thing that is really disturbing me as I do not understand what the problem is. I'm trying to use a dictionary to remember when a user has visited a city. Code is really basic: in the class init method I added self.visited = [] and in the function where i check if city was visited: cityNumber = 1 #example if (not cityNumber in self.visited): #do some stuff self.visited[cityNumber] = "true" Apparently the last line causes the error: list assignment index out of range. I read that this is the simplest way to assign a value to a dictionary(dict[key]=value). So why is the error appearing?? Thanks a lot in advance -------------- next part -------------- An HTML attachment was scrubbed... URL: From vaduvoiutibi at yahoo.com Fri Jan 28 02:39:58 2011 From: vaduvoiutibi at yahoo.com (Vaduvoiu Tiberiu) Date: Thu, 27 Jan 2011 23:39:58 -0800 (PST) Subject: dictionary error: list assignment index out of range Message-ID: <588467.15109.qm@web113814.mail.gq1.yahoo.com> Well, to quote firefox: this is embarrassing. I've realized the dictionary initialization is wrong, as [] means its a tuple, I should use {}. That's why I don't like working nights..it's only in the morning when you start seeing things better. I apologize for the mail. Cheers ________________________________ From: Vaduvoiu Tiberiu To: python-list at python.org Sent: Fri, January 28, 2011 9:34:57 AM Subject: dictionary error: list assignment index out of range Hy everyone, I'm trying to learng python for a week or two and there's a thing that is really disturbing me as I do not understand what the problem is. I'm trying to use a dictionary to remember when a user has visited a city. Code is really basic: in the class init method I added self.visited = [] and in the function where i check if city was visited: cityNumber = 1 #example if (not cityNumber in self.visited): #do some stuff self.visited[cityNumber] = "true" Apparently the last line causes the error: list assignment index out of range. I read that this is the simplest way to assign a value to a dictionary(dict[key]=value). So why is the error appearing?? Thanks a lot in advance -------------- next part -------------- An HTML attachment was scrubbed... URL: From orasnita at gmail.com Fri Jan 28 03:33:31 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Fri, 28 Jan 2011 10:33:31 +0200 Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com><9MB%o.14110$%64.6074@unlimited.newshosting.com><4A48EDF6D7634F2E994661A457451E87@teddy><753A4C5A6658470085804B13C80340F2@octavian> Message-ID: <3482A10ED46D4A70B519125BE5D19DF9@octavian> From: "Grant Edwards" > So you're saying that you don't see any value in easing communication, > nor presumably in communication itself? No, I don't want to say that, but I want to say that if it is obviously that the others don't care about the main issue discussed, then the communication just for the sake of communication has no value. If the others do care, but they are just uninformed, then I guess they wouldn't be upset by a direct communication that just tell them what's wrong. > If you don't care about communicating with others, then being civil > probably does have no value (except for keeping a job or being > avoiding being beaten up on the playground). If you want to > communicate (especially if you want somebody else to _do_ something), > then being civil and following normal social rules (etiquette) is > _very_ valuable. Without it the only thing you accomplish is to turn > people against you and whatever you're saying. How can we talk about etiquette when exactly this etiquette is the one that needs to be changed? As you say, the etiquette is in favor of the preferences of the majority, but how should react someone, what he/she should say in order to make the others understand that that etiquette is bad because it discriminates some categories of people? And those minorities are not minorities because they want, or because they simply don't want to change their way, but because they can't do that. > There is no inherent "value" in driving on the right side of the road > vs. the left. However, there is a lot of value in driving on the side > of road that others expect you to. I'd tell you to try driving on the > other side of the road sometime to see how "easing communication" can > be valuable, but I'm afraid you'd try it... You are right in that case, but the comparison is not good because yes there is a value in creating accessible GUIS. Those who drive on the left, the minority, can adapt to drive on the right. If their cars have the wheels on the right, there are technical solutions for that problem... they ccan change their cars. But if an application uses Tk, those minorities that have problems don't have any technical solution to solve them, because there are not accessible versions for all the inaccessible apps. Try to imagine that it will appear an incurable disease for those who drive on the right. What do you think it will happen? Probably they all would start driving on the left. But what it would be happening if only a small minorities of those who drive on the right will get that disease, say those between 18 and 25? Probably it won't happen anything and those that are below 25 won't be able to drive a car, because they are too few and too unimportant, and they would have too small power to change things in favor of all. And that would mean discrimination. The people are free and as someone said, the man is a rational animal, so the power differences rank the world and not the truth and etiquette, because the etiquette is also imposed by the majority and about those who have the power. And I fully agree with you and others said regarding to this, but what I said is that all that majority should do what it wants, however it should always remember at least that it is not doing the right thing. Yes, I know that this opinion that those who create shortcomings should not feel good for what they do or even think, is something which is not helpful for me, and it might not be helpful for those who use a screen reader either in the present, exactly because of those bad and unfair sentiments, but I hope that this will change in the future. And here I agree, I am not talking only about the accessibility to computers, but about all the image that the blind people have in the healthy's people mind. Octavian From orasnita at gmail.com Fri Jan 28 03:33:38 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Fri, 28 Jan 2011 10:33:38 +0200 Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com><9MB%o.14110$%64.6074@unlimited.newshosting.com><4A48EDF6D7634F2E994661A457451E87@teddy><753A4C5A6658470085804B13C80340F2@octavian><84519d45-f584-4fab-b51c-cd53bde6c09a@p16g2000vbs.googlegroups.com> <793e3d37-f59c-4053-b38e-24bb48c44807@l22g2000pre.googlegroups.com> Message-ID: <20F7065AF3F24C72992FB20FBA68BAC2@octavian> From: "rusi" Its quite clear to everyone here that -- Octavian has no interest in a 21st century snazzy-looking toolkit Oh well I am interested, but with the condition that toolkit to be accessible, however Tkinter is not. Is it too much to expect from a "21st century snazzy-looking toolkit" to be accessable to screen readers? Octavian From orasnita at gmail.com Fri Jan 28 03:33:42 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Fri, 28 Jan 2011 10:33:42 +0200 Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com><9MB%o.14110$%64.6074@unlimited.newshosting.com><4A48EDF6D7634F2E994661A457451E87@teddy><753A4C5A6658470085804B13C80340F2@octavian> Message-ID: <8C94A3B3E1EC44D1B24E0A572DC2B087@octavian> From: "Grant Edwards" > You said that you don't care about convincing anybody either that > accessibility is import or about convincing anybody to do anything > about it. To me that means you don't care about accessiblity. And you are wrong. If you don't try to convince someone that Python is a good language, does that mean that you don't care about Python? You might be thinking that the people on the list *already know* that Python is a good language. And I also think that in the 21st century *every programmer* should know that the accessibility is important. >>> People will not separate your personality from the cause you espouse. >> >> Wow! that's really bad. > > It's less than ideal, but it the way people are. > Is that a surprise to you? No, but I am pretending that I don't know, because the those people are not thinking correctly and it should be a shame for someone to have bad opinions about a person just because that person has different opinions. And the world should be ideal. Of course, it will never be, but we should follow that direction at least and not consider it bad just because that way require big and uncomfortable changes. >> I thought that I might find here people that might have something >> against my opinions, that is very normal, that's why we are >> discussing, but I didn't think that I will also find people that will >> have something against me, just because of my opinions. > > That's not what I said. I said that if you state your opininions in a > rude, insulting, or disrepectful manner, that will turn people against > your opinions regardless of the inherent value of the actual opinions I have asked for a few times, but nobody answered. From what I said, what was rude, insulting and disrespectable? > That's not what we're talking about. We're not talking about your > opinions on some unrelated topic. We're talking about the manner in > which you express your opinions on this topic. And again, what's that "manner"? Do you really think that the opinions of the majority are always more valid than those of minorities, no matter the consequences? > Again, it's not your beliefs about other tops that are causing > problems for you. What's causing problems is the manner in which you > are expressing your beliefs about this topic. My beliefs are that the majority doesn't care about the minority of screen reader users, because if it would care, it would be promoting accessible tools. Don't you agree with this? Or you don't like the atitude of expressing it so clear and like to hide those sensible things? Octavian From orasnita at gmail.com Fri Jan 28 03:33:46 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Fri, 28 Jan 2011 10:33:46 +0200 Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com> <9MB%o.14110$%64.6074@unlimited.newshosting.com> <4A48EDF6D7634F2E994661A457451E87@teddy> <753A4C5A6658470085804B13C80340F2@octavian> <4D41B5AF.8020200@ixokai.io> Message-ID: From: "Stephen Hansen" > Seriously. Octavian's attitude in this thread makes me want to go use > Tkinter just to spite him. Oh yes? And this would probably mean that your atitude is a very good and normal one, right? Octavian From orasnita at gmail.com Fri Jan 28 03:33:50 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Fri, 28 Jan 2011 10:33:50 +0200 Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com> <9MB%o.14110$%64.6074@unlimited.newshosting.com> <4A48EDF6D7634F2E994661A457451E87@teddy> <753A4C5A6658470085804B13C80340F2@octavian> <4D41B5AF.8020200@ixokai.io> <4D41BCC2.2060906@tysdomain.com> Message-ID: From: "Littlefield, Tyler" > >* Disclaimer: You are stupid if you think this is true. But seriously, > >Octavian makes it REALLY hard to continue caring about something that I > >actually cared about before and thought was important. When I told about what the community of the blind from my country cares, or what I care, the others told me that that is not important. I am sure that won't say the same thing to your post in which you also say about what you care, just because you have the same opinions like them. > People like Octavian do that. Sadly, it is one of the things holding the > blind community back. I hope that with my arguments (for those that didn't > just toss everything related to this thread), I have been able to get > people to see a little differently and not consider Octavian as the voice > for us all. Who are those "us all"? Are you a representative voice for all the screen reader users? (Even though most of them use JAWS that you don't seem to like) Or do you agree with the associations of the blind in your country do when they fight with different companies because they make discrimination by not offering accessible products? Or you are more representative than those associations? Octavian From orasnita at gmail.com Fri Jan 28 03:33:53 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Fri, 28 Jan 2011 10:33:53 +0200 Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com><9MB%o.14110$%64.6074@unlimited.newshosting.com><59F6E65E3D9A46AD8D7A3863F3C1DC84@teddy><27f53f8c-7862-4366-9352-82ae9a2f3970@k3g2000yqc.googlegroups.com><718D13777F254C839F9564BC4275DE0A@octavian><4D402C42.1030407@tysdomain.com><4D40447C.4010108@tysdomain.com><33C68A0874BE4C66AB478EDFB64C2C1D@teddy><4D407321.3090705@web.de> <1296128007.17192.1417506961@webmail.messagingengine.com> Message-ID: From: "Grant Edwards" > A very important way to help would be to test accessibility features > and post accurate, detailed, bug-reports. > I am willing to do that. I have tested that program made with WxPython and I have posted here what I found, hoping that there will appear a Tkinter-based app to test. For the moment, the accessibility of Tkinter is something like: - The menus are accessible, at least those at the top of the window, I don't know about the context menus, because I don't know a Tk-based app that uses context menus. - The rest of the widgets are completely inaccessible. What can I say more? Octavian From orasnita at gmail.com Fri Jan 28 03:33:55 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Fri, 28 Jan 2011 10:33:55 +0200 Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com> <9MB%o.14110$%64.6074@unlimited.newshosting.com> <59F6E65E3D9A46AD8D7A3863F3C1DC84@teddy> <27f53f8c-7862-4366-9352-82ae9a2f3970@k3g2000yqc.googlegroups.com> <718D13777F254C839F9564BC4275DE0A@octavian> <4D402C42.1030407@tysdomain.com> <4D40447C.4010108@tysdomain.com> <33C68A0874BE4C66AB478EDFB64C2C1D@teddy> <4D407321.3090705@web.de> <1296128007.17192.1417506961@webmail.messagingengine.com> Message-ID: <8775C617C7B241759AC122A69955D42A@octavian> From: "Terry Reedy" > For example: pygui pretty much uses native widgets on Windows and OX and > gtk (I believe) on *nix. How is the accessibility of those widget sets *as > accessed through pygui*? Is it different from the 'native' accessibility > of each of those set? Thank you for telling about this GUI lib! I have tested the sample apps it offers and the standard dialogs are very accessible. I hope it is the same in case of the other common controls like list boxes, list views, check boxes, radio buttons, combo boxes, tree views... How complete is this GUI lib compared with others that can be used in Python apps? I am asking this, because I read: "Get the library and its documentation included in the core Python distribution, so that truly cross-platform GUI applications may be written that will run on any Python installation, anywhere." And this would be great! Octavian From orasnita at gmail.com Fri Jan 28 03:33:58 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Fri, 28 Jan 2011 10:33:58 +0200 Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com><8q7sgiF5tpU1@mid.individual.net><19891784-d6a3-41ac-a097-5902a6323bc0@o21g2000prn.googlegroups.com><0b12cdb1-45b4-41e4-9bdb-074ee669d76b@k14g2000pre.googlegroups.com><048FB74272D440A0915ABC7D76AE262B@teddy><5782E9AD8A8342D691EB3549E5E0ED7B@octavian><43549D4396F34EA697C45AA40EA12BC8@octavian><5858167B51BD4813A1D36C2D90D255F2@teddy> Message-ID: <1629FC367B75424EB32E4D9A7C355B8F@octavian> From: "Giampaolo Rodol?" ... > py2exe offers the following installation kits, depending on the Python > version. If you know, please tell me why there are different packages for > different versions of Python? > > py2exe-0.6.9.win32-py2.5.exe > py2exe-0.6.9.win32-py2.4.exe > py2exe-0.6.9.win32-py2.3.exe > py2exe-0.6.9.win32-py2.6.exe > py2exe-0.6.9.win32-py2.7.exe That's a different story: those are pre-compiled binaries which are generated from a *unique* source code which support all those versions. If you have a compiler you can install pywin32 extension by using any Python version. Thank you Giampaolo. Now I understand and it is a good thing. Octavian From orasnita at gmail.com Fri Jan 28 03:34:01 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Fri, 28 Jan 2011 10:34:01 +0200 Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com><9MB%o.14110$%64.6074@unlimited.newshosting.com> <59F6E65E3D9A46AD8D7A3863F3C1DC84@teddy> <27f53f8c-7862-4366-9352-82ae9a2f3970@k3g2000yqc.googlegroups.com> <718D13777F254C839F9564BC4275DE0A@octavian> <4D402C42.1030407@tysdomain.com> <4D40447C.4010108@tysdomain.com><33C68A0874BE4C66AB478EDFB64C2C1D@teddy> <4D407333.1070301@tysdomain.com><82865E7A54C048C398B4F4160FC43B57@octavian><4D417EFC.70800@tysdomain.com><57C3CFA0C7EE4578B0C6EAA267AAE678@teddy> <4D41B6B7.7010609@tysdomain.com> Message-ID: <409FABAAA3D74ADCB11E06C676282650@octavian> From: "Littlefield, Tyler" > what >JAWS Tyler, did I used bad words in my posts as you do now? I didn't, but the other list members told me that my atitude is not good, that I am not civilized, because I have a different opinion than them. I am sure *nobody* will tell you that thing even though they can also see your posts. > 1) Because you, your crew, and your group on a specific forum doesn't like > ESpeak doesn't disqualify an entire reader. The eloquence fixes are > illegal to be packaged with NVDA, so you -need- to get a separate patch, > yes. That doesn't mean it can't be done. Are you hearing yourself? You say that it is illegal, but that it can be done. Nice. And by the way, that group I told you about is not my group, but the group of most active young blind computer users in my country. > As to me being a Linux and Mac user, that doesn't disqualify what I'm > telling you either, because unlike your limitations, I don't just decide > to only use one reader. I use Linux, Mac, and windows (windows more than > both, actually). Yes, I'm giving you what I got from googling, because > that's my way of telling you to do your homework before you start ranting > about a reader you clearly know nothing of. The fact that it appears on > google says a lot. At least to me, maybe it's something you haven't been > able to comprehend. It also appears on Google an article in which the NVDA developers say why NVDA doesn't offer support for Eloquence anymore, and if you would have been such a great Google user you would have seen that NVDA doesn't offer those features I told you about. And I see that you continue this useless discussion about screen readers that you have started just because I gave only JAWS as an example of a screen reader that can be used to test the inaccessibility of Tkinter, while Tkinter is inaccessible for other screen readers also anyway. Octavian From orasnita at gmail.com Fri Jan 28 03:34:04 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Fri, 28 Jan 2011 10:34:04 +0200 Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com><9MB%o.14110$%64.6074@unlimited.newshosting.com> <59F6E65E3D9A46AD8D7A3863F3C1DC84@teddy> <27f53f8c-7862-4366-9352-82ae9a2f3970@k3g2000yqc.googlegroups.com> <718D13777F254C839F9564BC4275DE0A@octavian> <4D402C42.1030407@tysdomain.com> <4D40447C.4010108@tysdomain.com> <33C68A0874BE4C66AB478EDFB64C2C1D@teddy> <4D41CB73.9090608@web.de> <4D41D40E.7060700@tysdomain.com> Message-ID: <21659D90CEE24DAFBD4B8E81083504DF@octavian> From: "Littlefield, Tyler" > >Because healthy Linux users ARE NOT equal to handicapped people! > O? I bet I could run circles around RR in the shell, any day. Why are you > trying to promote accessibility for a group of people you consider not > equal to a group of "healthy" people? > What do you mean by equal? The accessibility features should make the world more equal, but neither the accessibility is not able to make everything perfect and make us all really equal. The word "handicap" implies that there is no an equality of possibilities and chances, and that's why the accessibility features are needed. I know that you want to appear as a genius guy that can't detect the light with his eyes, but that which is absolutely equal to the others without needing accessibility features, but this is an obvious exageration. Octavian From orasnita at gmail.com Fri Jan 28 03:34:07 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Fri, 28 Jan 2011 10:34:07 +0200 Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com><9MB%o.14110$%64.6074@unlimited.newshosting.com><4A48EDF6D7634F2E994661A457451E87@teddy><753A4C5A6658470085804B13C80340F2@octavian> <4D40A97F.8090209@tysdomain.com><00ABBA322416409EB749102EB1CC5E61@octavian> <4D418054.8050002@tysdomain.com> <1a37f3d8-b580-4d6d-a5a3-de8cc1e656dd@y26g2000yqd.googlegroups.com> <4D41E83A.3030209@aim.com> Message-ID: From: "Corey Richardson" > wxPython is the best and most mature cross-platform GUI toolkit, given a > number of constraints. The only reason wxPython isn't the standard > Python GUI toolkit is that Tkinter was there first. > -- Guido van Rossum Oh, how can Guido say this about that bad WxPython that gives those errors under Linux... :-) Now seriously, this is the kind of opinion that need to change. "First", at the beginning, there were no screen readers and no accessibility was possible. But now it is possible and if this possibility requires that kind of change, *I think* that it would be absolutely normal to be done. If we would say about everything that "it was first", then we should not change anything important because of that reason. Octavian From orasnita at gmail.com Fri Jan 28 03:34:10 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Fri, 28 Jan 2011 10:34:10 +0200 Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com><9MB%o.14110$%64.6074@unlimited.newshosting.com><4A48EDF6D7634F2E994661A457451E87@teddy><753A4C5A6658470085804B13C80340F2@octavian> <4D40A97F.8090209@tysdomain.com><00ABBA322416409EB749102EB1CC5E61@octavian> <4D418054.8050002@tysdomain.com> <1a37f3d8-b580-4d6d-a5a3-de8cc1e656dd@y26g2000yqd.googlegroups.com><4D41E83A.3030209@aim.com> Message-ID: <6CABCB34902E4A5FB9FB27934899701E@octavian> From: "Terry Reedy" >> wxPython is the best and most mature cross-platform GUI toolkit, given a >> number of constraints. The only reason wxPython isn't the standard >> Python GUI toolkit is that Tkinter was there first. >> -- Guido van Rossum >> >> (from http://www.wxpython.org/quotes.php) > > Of course, that is not the only reason now. Python has moved on to a 21st > century version, while wxpython is still stuck on the 20century version. > I don't say you are not right, but can you say that Tkinter is a 21st century lib if it doesn't offer even the accessibility features? Octavian From orasnita at gmail.com Fri Jan 28 03:34:14 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Fri, 28 Jan 2011 10:34:14 +0200 Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com><9MB%o.14110$%64.6074@unlimited.newshosting.com><4A48EDF6D7634F2E994661A457451E87@teddy><753A4C5A6658470085804B13C80340F2@octavian><4D40A97F.8090209@tysdomain.com><00ABBA322416409EB749102EB1CC5E61@octavian><4D418054.8050002@tysdomain.com><1a37f3d8-b580-4d6d-a5a3-de8cc1e656dd@y26g2000yqd.googlegroups.com> Message-ID: <367D4A6371234191887F0BA13FE6E9BA@octavian> From: "Grant Edwards" > I think there are a lot of people who think that including a GUI in > the standard library was a mistake and the best solution would be to > get rid of Tkinter and replace it with nothing. If I were Guido and > thought that, I'd probably keep mum about it as well. :) > > [I'm not claiming Guidoe does think that, but there are some pretty > good arguments for not including a GUI at all.] Fully agree. But you will hear reactions with "batteries" :-) Octavian From orasnita at gmail.com Fri Jan 28 03:34:18 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Fri, 28 Jan 2011 10:34:18 +0200 Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com><8q7sgiF5tpU1@mid.individual.net><19891784-d6a3-41ac-a097-5902a6323bc0@o21g2000prn.googlegroups.com><0b12cdb1-45b4-41e4-9bdb-074ee669d76b@k14g2000pre.googlegroups.com><048FB74272D440A0915ABC7D76AE262B@teddy><5782E9AD8A8342D691EB3549E5E0ED7B@octavian> <409f37bb-6eb4-49ee-95cc-c4a9ea91b207@s29g2000pra.googlegroups.com> Message-ID: <4664C576A1244B57A6163EC4A01DA92A@octavian> From: "alex23" > "Octavian Rasnita" wrote: >> Ok, in this case I understand why WxPython can't be included in stdlib. >> I think there was a communication problem because the oldest list members >> start with the idea that all the list members know who is who and they >> may >> be thinking that I don't want to accept the reality or that I have bad >> feelings about some list members or something like that. > > The only expectation I as a list member have of you is that you maybe > hit the web and do a bit of search & research before starting on an > endless tirade. Implying that it was the responsibility of everyone > here to explain every little aspect of an issue you're supposedly > passionate about makes you seem either lazy or ignorant. Hi Alex, You are right, I was lazy and didn't searched on the net to find who are all the list members that answered to my posts for understanding better their position, so it's my fault. Octavian From orasnita at gmail.com Fri Jan 28 03:43:27 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Fri, 28 Jan 2011 10:43:27 +0200 Subject: dictionary error: list assignment index out of range References: <588467.15109.qm@web113814.mail.gq1.yahoo.com> Message-ID: <910F48A9614D47E5AA1960DE94F78A27@octavian> From: Vaduvoiu Tiberiu > Well, to quote firefox: this is embarrassing. I've realized the dictionary initialization is wrong, as [] means its a tuple, I should use {}. That's why I > don't like working nights..it's only in the morning when you start seeing things better. I apologize for the mail. Cheers [] is for lists. () is for tuples. HTH. Octavian -------------- next part -------------- An HTML attachment was scrubbed... URL: From mailing at franzoni.eu Fri Jan 28 05:32:06 2011 From: mailing at franzoni.eu (Alan Franzoni) Date: Fri, 28 Jan 2011 11:32:06 +0100 Subject: Behaviour-based interface/protocol implementation? In-Reply-To: References: Message-ID: On Thu, Jan 27, 2011 at 11:41 PM, Daniel Urban wrote: > Actually it can. You don't have to modify the object, just check for > the desired methods/signature/whatever. See for example the > implementation of collections.Hashable.__subclasshook__ in _abcoll.py > and the abc.ABCMeta.__instancecheck__ method. Mmh, I don't get your examples (subclasshook checks for *classes*, not instances, and ABCMeta is a metaclass whose instance is an ABC), but after properly looking at the PEP (__instancecheck__ seems to be poorly documented in python standard docs) I've seen that yes, __instancecheck__ on an ABC can actually be used in place of maybe_implemented_by and hooking into isinstance(). Thanks! -- Alan Franzoni -- contact me at public@[mysurname].eu From research at johnohagan.com Fri Jan 28 05:36:00 2011 From: research at johnohagan.com (John O'Hagan) Date: Fri, 28 Jan 2011 10:36:00 +0000 Subject: Algorithm for generating pitch-class sets in prime form Message-ID: <201101281036.00656.research@johnohagan.com> I'm looking for some help coming up with an algorithm to produce lists which meet the following criterion (you don't need to know music to get this): In musical pitch-class set theory, "prime form" is defined as the most tightly- packed-to-the-left rotation of a set's interval structure. Prime forms are important in music because they provide the unique simplest form of any pitch structure. I'm writing a python program which uses this principle. For example: the sequence [2, 6, 9] (which happens to be a D major chord) would be put in prime form by: - Sorting and transposing it so it starts on zero: [0, 4, 7] - Expressing it as intervals: [4, 3, 5] (the last number is the distance to the octave) - Rotating the intervals such that the biggest interval is at the end; if there are more than one biggest intervals, we want the rotation with the smallest first interval, and if that is also tied, the one with the smallest second interval, and so on. In this example we are already there. An easy way of finding a prime form in Python is: def prime_form(seq): pcs = sorted(list(set(seq))) intervals = ([pcs[i + 1] - pcs[i] for i in range(len(pcs) - 1)] + [12 + min(pcs) - pcs[-1]]) rotations = [intervals[i:] + intervals[:i] for i in range(len(intervals))] prime_intervals = min([i for i in rotations if i[-1] == max(intervals)]) return [sum(prime_intervals[:i]) for i in range(len(prime_intervals))] But I'm looking for a way of generating sequences already in prime form without duplication or omission. One promising approach is using a function which generates all the (ordered) partitions of a number, and producing the multiset permutations of each partition, which gives us all the possible interval structures (but many of which are rotationally equivalent): def full(num): for part in partitions(num): for perm in multiset_permutations(part): yield perm (The actual functions I'm using for this are at the end of this message.) To start narrowing it down to prime forms, we can chop off the largest interval from the end, permute the rest, and replace it on the end of each permutation: def full(num): for part in partitions(num): if len(part) == 1: yield part else: for perm in multiset_permutations(part[:-1]): yield perm + part[-1] but this produces a lot of false positives in cases where there is more than one largest interval. I imagine a solution might work by removing the largest intervals from each partition, permuting the remaining intervals, and into each permutation inserting the large intervals, one at the end and the others in each possible place that satisfies the requirements. And that's where I'm getting lost. Any clues, suggestions or solutions? Regards, John The functions: def partitions(num): if num == 0: yield [] return for part in partitions(num-1): yield [1] + part if part and (len(part) < 2 or part[1] > part[0]): yield [part[0] + 1] + part[1:] def _reverse(seq, start, end): "A sub-function for multiset_permutations" #seq = seq[:start] + reversed(seq[start:end]) + seq[end:] end -= 1 if end <= start: return while True: seq[start], seq[end] = seq[end], seq[start] if start == end or start+1 == end: return start += 1 end -= 1 def multiset_permutations(seq): first = 0 last = len(seq) yield seq if last == 1: raise StopIteration while True: next = last - 1 while True: next1 = next next -= 1 if seq[next] < seq[next1]: mid = last - 1 while seq[next] >= seq[mid]: mid -= 1 seq[next], seq[mid] = seq[mid], seq[next] _reverse(seq, next1, last) yield seq break if next == first: raise StopIteration raise StopIteration From urban.dani at gmail.com Fri Jan 28 06:00:58 2011 From: urban.dani at gmail.com (Daniel Urban) Date: Fri, 28 Jan 2011 12:00:58 +0100 Subject: Behaviour-based interface/protocol implementation? In-Reply-To: References: Message-ID: On Fri, Jan 28, 2011 at 11:32, Alan Franzoni wrote: > On Thu, Jan 27, 2011 at 11:41 PM, Daniel Urban wrote: > >> Actually it can. You don't have to modify the object, just check for >> the desired methods/signature/whatever. See for example the >> implementation of collections.Hashable.__subclasshook__ in _abcoll.py >> and the abc.ABCMeta.__instancecheck__ method. > > Mmh, I don't get your examples (subclasshook checks for *classes*, not > instances, and ABCMeta is a metaclass whose instance is an ABC), but > after properly looking at the PEP (__instancecheck__ seems to be > poorly documented in python standard docs) I've seen that yes, > __instancecheck__ on an ABC can actually be used in place of > maybe_implemented_by and hooking into isinstance(). Exactly. I mentioned subclasshook because it is possible to define a similar "instancehook", which would check for instances. Daniel From ajaysachin44 at gmail.com Fri Jan 28 06:12:35 2011 From: ajaysachin44 at gmail.com (Vijay Varma) Date: Fri, 28 Jan 2011 03:12:35 -0800 (PST) Subject: Make Money Online Message-ID: <5d9285c5-4686-4c69-b286-266c4601f856@s9g2000vbh.googlegroups.com> Get New ideas for easy way of employment and buisness by just sitting at your home.Online jobs are one of the most liked jobs by youngsters and even by elders, after retirement or can do even as a part time job.Just Sing Up for Google Adsense,Adbrite,Bidvertiser etc adds company & earn up to 1254 $ per month Hurry Up ! offer limted for first 2000 persons only http://www.knowledge2know.com/incomesource.htm From orasnita at gmail.com Fri Jan 28 08:38:21 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Fri, 28 Jan 2011 15:38:21 +0200 Subject: WxPython versus Tkinter. References: <4D41E861.9040604@tysdomain.com> Message-ID: <180208786DB640C79FE59EF029E62717@octavian> From: "Littlefield, Tyler" > >Yes but his silence speaks louder than words. He is saying " While i > >won't defend Tkinter publicly, i won't promote any others as well". > That's the best translation I've ever heard: taking silence and diverting > it into your own meaning for what you want it to mean. And he is perfectly right. A library included in the stdlib is obviously promoted without beeing necessary to tell the world "use it". Octavian From rantingrick at gmail.com Fri Jan 28 09:09:07 2011 From: rantingrick at gmail.com (rantingrick) Date: Fri, 28 Jan 2011 06:09:07 -0800 (PST) Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com> <9MB%o.14110$%64.6074@unlimited.newshosting.com> <59F6E65E3D9A46AD8D7A3863F3C1DC84@teddy> <27f53f8c-7862-4366-9352-82ae9a2f3970@k3g2000yqc.googlegroups.com> <718D13777F254C839F9564BC4275DE0A@octavian> <4D402C42.1030407@tysdomain.com> <4D40447C.4010108@tysdomain.com> <33C68A0874BE4C66AB478EDFB64C2C1D@teddy> <4D407321.3090705@web.de> <1296128007.17192.1417506961@webmail.messagingengine.com> Message-ID: <8a9bdf33-4f0e-4a82-bc60-4ccafac468e3@k15g2000prk.googlegroups.com> On Jan 28, 2:33?am, "Octavian Rasnita" wrote: > From: "Terry Reedy" > > > For example: pygui pretty much uses native widgets on Windows and OX and > > gtk (I believe) on *nix. How is the accessibility of those widget sets *as > > accessed through pygui*? Is it different from the 'native' accessibility > > of each of those set? > > Thank you for telling about this GUI lib! > I have tested the sample apps it offers and the standard dialogs are very > accessible. I hope it is the same in case of the other common controls like > list boxes, list views, check boxes, radio buttons, combo boxes, tree > views... It is great to hear that pyGUI is accessible! You know, if we cannot have wxPython in the stdlib my next choice would be pyGUI. Heck, we should have started with pyGUI 20 years ago and we would better off today! From rantingrick at gmail.com Fri Jan 28 09:18:03 2011 From: rantingrick at gmail.com (rantingrick) Date: Fri, 28 Jan 2011 06:18:03 -0800 (PST) Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com> <9MB%o.14110$%64.6074@unlimited.newshosting.com> <4A48EDF6D7634F2E994661A457451E87@teddy> <753A4C5A6658470085804B13C80340F2@octavian> Message-ID: <90450b74-2d66-4a78-8a9f-0c3807607848@o14g2000prb.googlegroups.com> On Jan 27, 12:13?pm, Stephen Hansen wrote: > Seriously. Octavian's attitude in this thread makes me want to go use > Tkinter just to spite him. And I'm net-buds with Tyler, and I'm working > on a project that I thought accessibility for the blind was very > important for. But no more! Well Stephen that would mean you would have to actually *learn* to use Tkinter, and from your own admission (not very long ago!) you don't know anything about Tkinter. Remember our Tk-Wx geometry challenge? Nice try! ;-) Everyone on this list knows that Kevin and myself are the *only* people who know how to wield Tkinter past some simple utility GUI's. From rantingrick at gmail.com Fri Jan 28 09:21:19 2011 From: rantingrick at gmail.com (rantingrick) Date: Fri, 28 Jan 2011 06:21:19 -0800 (PST) Subject: WxPython versus Tkinter. References: Message-ID: <51e446d7-adb2-4507-93c1-37dc80baa4cb@o18g2000prh.googlegroups.com> On Jan 27, 3:49?pm, "Littlefield, Tyler" wrote: > ?>Yes but his silence speaks louder than words. He is saying " While i > ?>won't defend Tkinter publicly, i won't promote any others as well". > That's the best translation I've ever heard: taking silence and > diverting it into your own meaning for what you want it to mean. Oh Tyler, your just jealous that i beat you to the punch! :-) From malaclypse2 at gmail.com Fri Jan 28 09:36:53 2011 From: malaclypse2 at gmail.com (Jerry Hill) Date: Fri, 28 Jan 2011 09:36:53 -0500 Subject: Bugs/issues in tkinter.simpledialog!! In-Reply-To: References: <412e4d83-f750-441d-bfc5-d96c0559e069@e9g2000prn.googlegroups.com> Message-ID: On Fri, Jan 28, 2011 at 12:34 AM, rantingrick wrote: > Well i tried searching for "Tkinter" issues on the tracker and just > got annoyed quickly and left. It seems far to complicated to do > searches with this software. > You should apply some of the persistence that you show on the mailing list to the problem! Go to http://bugs.python.org On the left hand side, there's a link to the search page (listed just below "Issues"). Click that. Find the list box labeled "Components" and select "Tkinter" from the drop down. Click Search. Bob's your uncle! -- Jerry -------------- next part -------------- An HTML attachment was scrubbed... URL: From mail2bansi at gmail.com Fri Jan 28 09:46:04 2011 From: mail2bansi at gmail.com (bansi) Date: Fri, 28 Jan 2011 06:46:04 -0800 (PST) Subject: Is it possible to pass CSV Reader Object As Argument to another Python File ??? References: <2c35653e-3565-48c6-8939-b6b09b885e3f@d23g2000prj.googlegroups.com> <876b6c52-1a6d-4afa-83e9-fa987c9359a5@v31g2000pri.googlegroups.com> <87lj272vpo.fsf@benfinney.id.au> Message-ID: <430714cd-20b4-4a67-bd2d-54e8f0c44ad5@s18g2000vbe.googlegroups.com> On Jan 26, 8:31?pm, MRAB wrote: > On 27/01/2011 00:57, bansi wrote: > > > > > > > On Jan 26, 6:25 pm, Ethan Furman ?wrote: > >> bansi wrote: > > >> ? > ?First namelookupWrapper.py running under Python 2.6 accept arguments > >> ? > ?from stdin and uses csv reader object to read it i.e. > >> ? > ?r=csv.reader(sys.stdin) > > >> ? > ?And then it has to pass csv reader object to another python script > >> ? > ?namelookup.py running under Python 2.7 because it uses pyodbc to > >> ? > ?connect to database and iterates thru reader object > > >> Ben Finney wrote: > >>> bansi ?writes: > > >>>> Thanks Chris. Sorry for mis-communicating, the two python scripts are > >>>> dependant in a way that namelookupWrapper.py needs to pass csv record > >>>> object to another python script > > >>> Why have you structured them that way, though? What constraint is > >>> keeping you from doing the work in a single process, where the CSV > >>> reader object can be shared? > > >>>> If thats not possible then please let me know how to do the workaround > >>>> i didnt understood the import thing and not sure if it helps in my > >>>> case > > >>> The problem as you've described it so far is best solved by having a > >>> single process accessing the CSV reader object in memory. If that > >>> doesn't suit your use case, you'll need to explain why not. > > >> In other words, why can't you use Python 2.7 to accept input and > >> generate a csv.reader? > > >> ~Ethan~- Hide quoted text - > > >> - Show quoted text - > > > Ethan, > > The python script takes the input from Splunk (http://www.splunk.com/ > > base/Documentation/) which supports only Python 2.6 > > So the real constraint is Splunk supports only Python 2.6 . > > > As you know Python 2.6 doesnt support or doesnt have pyodbc install > > for Windows ?64 bit OS > > So i installed Python 2.7 and thereafter pyodbc install for Windows 64 > > bit OS for Python 2.7 > > Have you actually tried Splunk with Python 2.7? It might not work with > versions which are earlier than Python 2.6, but that doesn't > necessarily mean that it won't work with versions of Python 2 which are > later than Python 2.6 (unless the documentation says that it must be > Python 2.6).- Hide quoted text - > > - Show quoted text - Splunk's latest version 4.1.6 doesn't support Python 2.7 I tried the import trick but it didnt work because the real script which runs under Python 2.7 has import pyodbc so it results in following error c:\Splunk\etc\apps\search\bin>splunk cmd python namelookupWrapper.py memberId memberName < memberInput.csv Traceback (most recent call last): File "namelookupWrapper.py", line 3, in import namelookup File "c:\Splunk\etc\apps\search\bin\namelookup.py", line 7, in import pyodbc ImportError: DLL load failed: The specified module could not be found. Please let me know if i am missing something on import. If so please provide me with an example From g.rodola at gmail.com Fri Jan 28 09:52:55 2011 From: g.rodola at gmail.com (=?ISO-8859-1?Q?Giampaolo_Rodol=E0?=) Date: Fri, 28 Jan 2011 15:52:55 +0100 Subject: Bugs/issues in tkinter.simpledialog!! In-Reply-To: References: Message-ID: 2011/1/26 rantingrick : > > I just installed Python 3,0 on my machine. I cannot use 3.0 > exclusively yet however i was interested in just poking around and > acquiring a taste if you will. I was happy to find that the new > Tkinter module names now follow convention and are placed correctly... > example: "tkinter.simpledialog" > > However some things never change it seems and some improvements are > actually a step backwards. The same problems with the unit test in 2.x > got ported to 3.x. And the new SimpleDialog is just more lackluster > code like we've seen before. I was hoping to be amazed, i am > disappointed and disgusted. It is obvious that whoever is writing/ > maintaining the tkinter code base does NOT understand tkinter > completely and this is blinding apparent by reading the source code! > > ----------- > ?Issues > ----------- > > First lets start with the problems that migrated from 2.x... > (tkinter.simpledialog) > > #-- ISSUE 1 --# > In the test() function we still have code that uses the "quit" method > instead of "destroy". Calling the "quit" method only tells Tkinter to > stop processing events, IT DOES NOT DESTROY THE WIDGET!! And on > windows the the root will then become unresponsive -- you cannot close > the window, you cannot do anything. I have said time and time again. > DO NOT USE THE QUIT METHOD UNLESS YOU KNOW WHAT THE HECK YOU ARE > DOING! So the code needs to be this... > > OLD: > ? q = Button(root, text='Quit', command=t.quit) > > NEW: > ? q = Button(root, text='Quit', command=root.destroy) > > > #-- ISSUE 2: --# > The author used a very strange method by which to denote the default > button in the SimpleDialog class. He choose to set the relief to RIDGE > and the border "8". This not only looks horrible (and exposes the > authors ignorance of tkinter) but a much more elegant solution is > provided by the TclTk folks. All buttons have a "default" option that > will display the button with a nice border so the user can visually > see which button is active. So the code should be this.... > > OLD: > ? ? ? ? ? ?if num == default: > ? ? ? ? ? ? ? ?b.config(relief=RIDGE, borderwidth=8) > > NEW: > ? ? ? ? ? ?if num == default: > ? ? ? ? ? ? ? ?b.config(default=ACTIVE) > > > Last but not least i am puzzled as to why we choose the method name > "go" over "show". for "showing" the dialog. ?SimpleDialog uses no > inheritance so name clashes are mum. Why would anyone choose "go" over > "show" for a modal dialog? I would really like an explanation for > this. > > > Other minor issues exists. I may describe them later. At this time we > need to fix these grave abominations first. > -- > http://mail.python.org/mailman/listinfo/python-list Why don't you file a ticket on the bug tracker instead of wasting yours and other people's time here by making appear another rant against Tkinter as a bug report? It's been 3 days in a row you've been doing this. Aren't you tired? Seriously! This has come to not even being a rant anymore. It's just nonsense. --- Giampaolo http://code.google.com/p/pyftpdlib/ http://code.google.com/p/psutil/ From tyler at tysdomain.com Fri Jan 28 10:15:52 2011 From: tyler at tysdomain.com (Littlefield, Tyler) Date: Fri, 28 Jan 2011 08:15:52 -0700 Subject: WxPython versus Tkinter. In-Reply-To: References: <4D3E4377.3060807@tysdomain.com> <9MB%o.14110$%64.6074@unlimited.newshosting.com> <4A48EDF6D7634F2E994661A457451E87@teddy> <753A4C5A6658470085804B13C80340F2@octavian> <4D41B5AF.8020200@ixokai.io> <4D41BCC2.2060906@tysdomain.com> Message-ID: <4D42DDA8.4080100@tysdomain.com> >Are you a representative voice for all the screen reader users? (Even though >most of them use JAWS that you don't seem to like) Newsflash: I didn't say I didn't like Jaws, and I'm using Jaws -right now-. I don't like jaws and see a lot of future for NVDA as it is both free and open source. I like that a lot more than paying what, $1300 or so for a program that will allow me to use the computer? Plus the obligatory $260 for two updates so I can update once every four months, regardless of whether or not I want to update. If you want to rant and scream about accessibility, yell at the people charging an arm and a leg to make things accessible. On 1/28/2011 1:33 AM, Octavian Rasnita wrote: > From: "Littlefield, Tyler" >> >* Disclaimer: You are stupid if you think this is true. But seriously, >> >Octavian makes it REALLY hard to continue caring about something that I >> >actually cared about before and thought was important. > > When I told about what the community of the blind from my country > cares, or > what I care, the others told me that that is not important. I am sure > that > won't say the same thing to your post in which you also say about what > you > care, just because you have the same opinions like them. > >> People like Octavian do that. Sadly, it is one of the things holding the >> blind community back. I hope that with my arguments (for those that >> didn't >> just toss everything related to this thread), I have been able to get >> people to see a little differently and not consider Octavian as the >> voice >> for us all. > > > Who are those "us all"? > Are you a representative voice for all the screen reader users? (Even > though > most of them use JAWS that you don't seem to like) > Or do you agree with the associations of the blind in your country do > when > they fight with different companies because they make discrimination > by not > offering accessible products? > Or you are more representative than those associations? > > Octavian > -- Thanks, Ty From invalid at invalid.invalid Fri Jan 28 10:52:19 2011 From: invalid at invalid.invalid (Grant Edwards) Date: Fri, 28 Jan 2011 15:52:19 +0000 (UTC) Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com> <9MB%o.14110$%64.6074@unlimited.newshosting.com> <4A48EDF6D7634F2E994661A457451E87@teddy> <753A4C5A6658470085804B13C80340F2@octavian> Message-ID: On 2011-01-28, Octavian Rasnita wrote: > How can we talk about etiquette when exactly this etiquette is the one that > needs to be changed? Huh? > As you say, the etiquette is in favor of the preferences of the majority, > but how should react someone, what he/she should say in order to make the > others understand that that etiquette is bad because it discriminates some > categories of people? Please explain what etiquette you are talking about that is discriminatory. > You are right in that case, but the comparison is not good because yes there > is a value in creating accessible GUIS. I'm not arguing against creating accessible GUIs. I'm not saying that you shouldn't argue in favor of doing so. I'm just saying that the _way_ you are presenting your argument is counter-productive. > Those who drive on the left, the minority, can adapt to drive on the > right. If their cars have the wheels on the right, there are > technical solutions for that problem... they ccan change their cars. > But if an application uses Tk, those minorities that have problems > don't have any technical solution to solve them, because there are > not accessible versions for all the inaccessible apps. You've completely missed the analogy. I'm not saying that people who need/want accessible apps are "driving on the left". I'm saying that by the manner in which you espouse accessibility you are driving on the left. > Try to imagine that it will appear an incurable disease for those who drive > on the right. What do you think it will happen? Probably they all would > start driving on the left. I'm not saying accessibility isn't good or important. I'm saying you're _hurting_ the cause of accessiblity by the manner in which you lobby for it. But, you seem unable or unwilling to understand that. When somebody tells you you're being rude, insulting, or disrepectful, they're _not_ saying that accessibility is not important. They're just telling you that you're being rude, insulting , or disrepectful. [plonk] -- Grant Edwards grant.b.edwards Yow! There's enough money at here to buy 5000 cans of gmail.com Noodle-Roni! From bryan.oakley at gmail.com Fri Jan 28 10:52:22 2011 From: bryan.oakley at gmail.com (Bryan) Date: Fri, 28 Jan 2011 07:52:22 -0800 (PST) Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com> <9MB%o.14110$%64.6074@unlimited.newshosting.com> <4A48EDF6D7634F2E994661A457451E87@teddy> <753A4C5A6658470085804B13C80340F2@octavian> <90450b74-2d66-4a78-8a9f-0c3807607848@o14g2000prb.googlegroups.com> Message-ID: On Jan 28, 8:18?am, rantingrick wrote: > On Jan 27, 12:13?pm, Stephen Hansen wrote: > > > Seriously. Octavian's attitude in this thread makes me want to go use > > Tkinter just to spite him. And I'm net-buds with Tyler, and I'm working > > on a project that I thought accessibility for the blind was very > > important for. But no more! > > Well Stephen that would mean you would have to actually *learn* to use > Tkinter, and from your own admission (not very long ago!) you don't > know anything about Tkinter. Remember our Tk-Wx geometry challenge? > Nice try! ;-) Do you have a link to this challenge? I assume it's a different one than the challenge that started this thread since the one that started this thread had nothing to do with geometry. > > Everyone on this list knows that Kevin and myself are the *only* > people who know how to wield Tkinter past some simple utility GUI's. I beg your pardon. Neither statement is true. There are more experts than you realize, and "this list" knows there are more experts than you and Kevin. There's a possible third misconception in your statement that's not worth discussing at this point. From invalid at invalid.invalid Fri Jan 28 10:56:26 2011 From: invalid at invalid.invalid (Grant Edwards) Date: Fri, 28 Jan 2011 15:56:26 +0000 (UTC) Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com> <9MB%o.14110$%64.6074@unlimited.newshosting.com> <4A48EDF6D7634F2E994661A457451E87@teddy> <753A4C5A6658470085804B13C80340F2@octavian> <4D41B5AF.8020200@ixokai.io> Message-ID: On 2011-01-28, Octavian Rasnita wrote: > From: "Stephen Hansen" >> Seriously. Octavian's attitude in this thread makes me want to go use >> Tkinter just to spite him. > > Oh yes? And this would probably mean that your atitude is a very good > and normal one, right? Good? No. Normal? Yes. I'm beginning to think that Octavian has some fundamental problems when it comes to empathy and social interaction skills. I think he genuinly has no clue how others perceive his postings nor does he understand what we mean by etiquette. -- Grant Edwards grant.b.edwards Yow! HOORAY, Ronald!! at Now YOU can marry LINDA gmail.com RONSTADT too!! From invalid at invalid.invalid Fri Jan 28 10:57:54 2011 From: invalid at invalid.invalid (Grant Edwards) Date: Fri, 28 Jan 2011 15:57:54 +0000 (UTC) Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com> <9MB%o.14110$%64.6074@unlimited.newshosting.com> <59F6E65E3D9A46AD8D7A3863F3C1DC84@teddy> <27f53f8c-7862-4366-9352-82ae9a2f3970@k3g2000yqc.googlegroups.com> <718D13777F254C839F9564BC4275DE0A@octavian> <4D402C42.1030407@tysdomain.com> <4D40447C.4010108@tysdomain.com> <33C68A0874BE4C66AB478EDFB64C2C1D@teddy> <4D407321.3090705@web.de> <1296128007.17192.1417506961@webmail.messagingengine.com> Message-ID: On 2011-01-28, Octavian Rasnita wrote: > From: "Grant Edwards" >> A very important way to help would be to test accessibility features >> and post accurate, detailed, bug-reports. > I am willing to do that. I have tested that program made with > WxPython and I have posted here what I found, The wxPython mailing list and/or bug-tracker is the right place for that. > What can I say more? You don't need to say more. You need to say less and say it differently. -- Grant Edwards grant.b.edwards Yow! Do you guys know we at just passed thru a BLACK gmail.com HOLE in space? From deets at web.de Fri Jan 28 11:13:24 2011 From: deets at web.de (Diez B. Roggisch) Date: Fri, 28 Jan 2011 17:13:24 +0100 Subject: A http server References: Message-ID: Back9 writes: > Hi, > I'm trying to set up a http server to handle a single POST request. > That POST request is to upload a huge file and the server is supposed > to handle it with the just POST request. > With my python sample code, multiple post requests are working well, > but that is not my solution. > I need a single POST request handling in the http server side. > Does anyone have a good idea for this case or sample code? Why doesn't the single post not work with your sample code? Where is your sample code? It might be a good idea to use WSGI for this, to stream out the POST-body to a temporary file. Can you use mod_wsgi in conjuction with Apache? If not, some pure WSGI-server implementation such as Paster might be enough. Diez From kw at codebykevin.com Fri Jan 28 11:16:49 2011 From: kw at codebykevin.com (Kevin Walzer) Date: Fri, 28 Jan 2011 11:16:49 -0500 Subject: WxPython versus Tkinter. In-Reply-To: <90450b74-2d66-4a78-8a9f-0c3807607848@o14g2000prb.googlegroups.com> References: <4D3E4377.3060807@tysdomain.com> <9MB%o.14110$%64.6074@unlimited.newshosting.com> <4A48EDF6D7634F2E994661A457451E87@teddy> <753A4C5A6658470085804B13C80340F2@octavian> <90450b74-2d66-4a78-8a9f-0c3807607848@o14g2000prb.googlegroups.com> Message-ID: <18c47$4d42eba6$4275d90a$21758@FUSE.NET> On 1/28/11 9:18 AM, rantingrick wrote: > Everyone on this list knows that Kevin and myself are the *only* > people who know how to wield Tkinter past some simple utility GUI's. I strongly disagree with this statement. --Kevin -- Kevin Walzer Code by Kevin http://www.codebykevin.com From bryan.oakley at gmail.com Fri Jan 28 11:27:53 2011 From: bryan.oakley at gmail.com (Bryan) Date: Fri, 28 Jan 2011 08:27:53 -0800 (PST) Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com> <9MB%o.14110$%64.6074@unlimited.newshosting.com> <4A48EDF6D7634F2E994661A457451E87@teddy> <753A4C5A6658470085804B13C80340F2@octavian> <90450b74-2d66-4a78-8a9f-0c3807607848@o14g2000prb.googlegroups.com> <18c47$4d42eba6$4275d90a$21758@FUSE.NET> Message-ID: <9132f237-6101-4d28-a6b1-bfbfb4b0048a@p12g2000vbo.googlegroups.com> On Jan 28, 10:16?am, Kevin Walzer wrote: > On 1/28/11 9:18 AM, rantingrick wrote: > > > Everyone on this list knows that Kevin and myself are the *only* > > people who know how to wield Tkinter past some simple utility GUI's. > > I strongly disagree with this statement. > (BTW, Kevin, Congrats on getting a tk app accepted by the Mac app store. That's an impressive feat!) From me+list/python at ixokai.io Fri Jan 28 12:26:49 2011 From: me+list/python at ixokai.io (Stephen Hansen) Date: Fri, 28 Jan 2011 09:26:49 -0800 Subject: WxPython versus Tkinter. In-Reply-To: <90450b74-2d66-4a78-8a9f-0c3807607848@o14g2000prb.googlegroups.com> References: <4D3E4377.3060807@tysdomain.com> <9MB%o.14110$%64.6074@unlimited.newshosting.com> <4A48EDF6D7634F2E994661A457451E87@teddy> <753A4C5A6658470085804B13C80340F2@octavian> <90450b74-2d66-4a78-8a9f-0c3807607848@o14g2000prb.googlegroups.com> Message-ID: <4D42FC59.6000507@ixokai.io> On 1/28/11 6:18 AM, rantingrick wrote: > On Jan 27, 12:13 pm, Stephen Hansen wrote: > >> Seriously. Octavian's attitude in this thread makes me want to go use >> Tkinter just to spite him. And I'm net-buds with Tyler, and I'm working >> on a project that I thought accessibility for the blind was very >> important for. But no more! > > Well Stephen that would mean you would have to actually *learn* to use > Tkinter, and from your own admission (not very long ago!) you don't > know anything about Tkinter. Remember our Tk-Wx geometry challenge? > Nice try! ;-) And? Gee-whiz-golly, I might have to learn something new. OH NOES. Its friday again. > Everyone on this list knows that Kevin and myself are the *only* > people who know how to wield Tkinter past some simple utility GUI's. Hah. No. -- Stephen Hansen ... Also: Ixokai ... Mail: me+list/python (AT) ixokai (DOT) io ... Blog: http://meh.ixokai.io/ -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 487 bytes Desc: OpenPGP digital signature URL: From python at mrabarnett.plus.com Fri Jan 28 13:15:38 2011 From: python at mrabarnett.plus.com (MRAB) Date: Fri, 28 Jan 2011 18:15:38 +0000 Subject: WxPython versus Tkinter. In-Reply-To: <409FABAAA3D74ADCB11E06C676282650@octavian> References: <4D3E4377.3060807@tysdomain.com><9MB%o.14110$%64.6074@unlimited.newshosting.com> <59F6E65E3D9A46AD8D7A3863F3C1DC84@teddy> <27f53f8c-7862-4366-9352-82ae9a2f3970@k3g2000yqc.googlegroups.com> <718D13777F254C839F9564BC4275DE0A@octavian> <4D402C42.1030407@tysdomain.com> <4D40447C.4010108@tysdomain.com><33C68A0874BE4C66AB478EDFB64C2C1D@teddy> <4D407333.1070301@tysdomain.com><82865E7A54C048C398B4F4160FC43B57@octavian><4D417EFC.70800@tysdomain.com><57C3CFA0C7EE4578B0C6EAA267AAE678@teddy> <4D41B6B7.7010609@tysdomain.com> <409FABAAA3D74ADCB11E06C676282650@octavian> Message-ID: <4D4307CA.1070800@mrabarnett.plus.com> On 28/01/2011 08:34, Octavian Rasnita wrote: > From: "Littlefield, Tyler" >> what >JAWS > > Tyler, did I used bad words in my posts as you do now? > I didn't, but the other list members told me that my atitude is not good, > that I am not civilized, because I have a different opinion than them. > I am sure *nobody* will tell you that thing even though they can also see > your posts. > [snip] They are saying that your attitude is not good because your attitude is not good. They are not saying that your opinion is not good. It's not what you say but how you say it. From python at rcn.com Fri Jan 28 13:32:34 2011 From: python at rcn.com (Raymond Hettinger) Date: Fri, 28 Jan 2011 10:32:34 -0800 (PST) Subject: Use the Source Luke Message-ID: <094f6fc5-7242-46c7-b454-4cb29d0c6ef9@q40g2000prh.googlegroups.com> I hoping a new trend will start with dev's putting direct source code links in their documentation: http://rhettinger.wordpress.com/2011/01/28/open-your-source-more/ I'm looking for more examples of projects that routinely link their docs back into relavant sections of code. Have any of you all seen other examples besides the Go language docs and the Python docs? Raymond From mail2bansi at gmail.com Fri Jan 28 13:33:18 2011 From: mail2bansi at gmail.com (bansi) Date: Fri, 28 Jan 2011 10:33:18 -0800 (PST) Subject: Is it possible to pass CSV Reader Object As Argument to another Python File ??? References: <2c35653e-3565-48c6-8939-b6b09b885e3f@d23g2000prj.googlegroups.com> <876b6c52-1a6d-4afa-83e9-fa987c9359a5@v31g2000pri.googlegroups.com> <87lj272vpo.fsf@benfinney.id.au> <430714cd-20b4-4a67-bd2d-54e8f0c44ad5@s18g2000vbe.googlegroups.com> Message-ID: <2c9f82cd-756b-4460-940b-31e2a866f24e@n36g2000pre.googlegroups.com> On Jan 28, 9:46?am, bansi wrote: > On Jan 26, 8:31?pm, MRAB wrote: > > > > > > > On 27/01/2011 00:57, bansi wrote: > > > > On Jan 26, 6:25 pm, Ethan Furman ?wrote: > > >> bansi wrote: > > > >> ? > ?First namelookupWrapper.py running under Python 2.6 accept arguments > > >> ? > ?from stdin and uses csv reader object to read it i.e. > > >> ? > ?r=csv.reader(sys.stdin) > > > >> ? > ?And then it has to pass csv reader object to another python script > > >> ? > ?namelookup.py running under Python 2.7 because it uses pyodbc to > > >> ? > ?connect to database and iterates thru reader object > > > >> Ben Finney wrote: > > >>> bansi ?writes: > > > >>>> Thanks Chris. Sorry for mis-communicating, the two python scripts are > > >>>> dependant in a way that namelookupWrapper.py needs to pass csv record > > >>>> object to another python script > > > >>> Why have you structured them that way, though? What constraint is > > >>> keeping you from doing the work in a single process, where the CSV > > >>> reader object can be shared? > > > >>>> If thats not possible then please let me know how to do the workaround > > >>>> i didnt understood the import thing and not sure if it helps in my > > >>>> case > > > >>> The problem as you've described it so far is best solved by having a > > >>> single process accessing the CSV reader object in memory. If that > > >>> doesn't suit your use case, you'll need to explain why not. > > > >> In other words, why can't you use Python 2.7 to accept input and > > >> generate a csv.reader? > > > >> ~Ethan~- Hide quoted text - > > > >> - Show quoted text - > > > > Ethan, > > > The python script takes the input from Splunk (http://www.splunk.com/ > > > base/Documentation/) which supports only Python 2.6 > > > So the real constraint is Splunk supports only Python 2.6 . > > > > As you know Python 2.6 doesnt support or doesnt have pyodbc install > > > for Windows ?64 bit OS > > > So i installed Python 2.7 and thereafter pyodbc install for Windows 64 > > > bit OS for Python 2.7 > > > Have you actually tried Splunk with Python 2.7? It might not work with > > versions which are earlier than Python 2.6, but that doesn't > > necessarily mean that it won't work with versions of Python 2 which are > > later than Python 2.6 (unless the documentation says that it must be > > Python 2.6).- Hide quoted text - > > > - Show quoted text - > > Splunk's latest version 4.1.6 doesn't support Python 2.7 > I tried the import trick but it didnt work because the real script > which runs under Python 2.7 has import pyodbc so it results in > following error > > c:\Splunk\etc\apps\search\bin>splunk cmd python namelookupWrapper.py > memberId memberName < memberInput.csv > Traceback (most recent call last): > ? File "namelookupWrapper.py", line 3, in > ? ? import namelookup > ? File "c:\Splunk\etc\apps\search\bin\namelookup.py", line 7, in > > ? ? import pyodbc > ImportError: DLL load failed: The specified module could not be found. > > Please let me know if i am missing something on import. If so please > provide me with an example- Hide quoted text - > > - Show quoted text - Here are some more details from my earlier posting. Please click the below link http://answers.splunk.com/questions/11145/its-getting-mysterious-to-make-the-lookup-script-work From benjamin.kaplan at case.edu Fri Jan 28 13:52:15 2011 From: benjamin.kaplan at case.edu (Benjamin Kaplan) Date: Fri, 28 Jan 2011 13:52:15 -0500 Subject: Is it possible to pass CSV Reader Object As Argument to another Python File ??? In-Reply-To: <2c9f82cd-756b-4460-940b-31e2a866f24e@n36g2000pre.googlegroups.com> References: <2c35653e-3565-48c6-8939-b6b09b885e3f@d23g2000prj.googlegroups.com> <876b6c52-1a6d-4afa-83e9-fa987c9359a5@v31g2000pri.googlegroups.com> <87lj272vpo.fsf@benfinney.id.au> <430714cd-20b4-4a67-bd2d-54e8f0c44ad5@s18g2000vbe.googlegroups.com> <2c9f82cd-756b-4460-940b-31e2a866f24e@n36g2000pre.googlegroups.com> Message-ID: On Fri, Jan 28, 2011 at 1:33 PM, bansi wrote: > On Jan 28, 9:46?am, bansi wrote: >> On Jan 26, 8:31?pm, MRAB wrote: >> >> >> >> >> >> > On 27/01/2011 00:57, bansi wrote: >> >> > > On Jan 26, 6:25 pm, Ethan Furman ?wrote: >> > >> bansi wrote: >> >> > >> ? > ?First namelookupWrapper.py running under Python 2.6 accept arguments >> > >> ? > ?from stdin and uses csv reader object to read it i.e. >> > >> ? > ?r=csv.reader(sys.stdin) >> >> > >> ? > ?And then it has to pass csv reader object to another python script >> > >> ? > ?namelookup.py running under Python 2.7 because it uses pyodbc to >> > >> ? > ?connect to database and iterates thru reader object >> >> > >> Ben Finney wrote: >> > >>> bansi ?writes: >> >> > >>>> Thanks Chris. Sorry for mis-communicating, the two python scripts are >> > >>>> dependant in a way that namelookupWrapper.py needs to pass csv record >> > >>>> object to another python script >> >> > >>> Why have you structured them that way, though? What constraint is >> > >>> keeping you from doing the work in a single process, where the CSV >> > >>> reader object can be shared? >> >> > >>>> If thats not possible then please let me know how to do the workaround >> > >>>> i didnt understood the import thing and not sure if it helps in my >> > >>>> case >> >> > >>> The problem as you've described it so far is best solved by having a >> > >>> single process accessing the CSV reader object in memory. If that >> > >>> doesn't suit your use case, you'll need to explain why not. >> >> > >> In other words, why can't you use Python 2.7 to accept input and >> > >> generate a csv.reader? >> >> > >> ~Ethan~- Hide quoted text - >> >> > >> - Show quoted text - >> >> > > Ethan, >> > > The python script takes the input from Splunk (http://www.splunk.com/ >> > > base/Documentation/) which supports only Python 2.6 >> > > So the real constraint is Splunk supports only Python 2.6 . >> >> > > As you know Python 2.6 doesnt support or doesnt have pyodbc install >> > > for Windows ?64 bit OS >> > > So i installed Python 2.7 and thereafter pyodbc install for Windows 64 >> > > bit OS for Python 2.7 >> >> > Have you actually tried Splunk with Python 2.7? It might not work with >> > versions which are earlier than Python 2.6, but that doesn't >> > necessarily mean that it won't work with versions of Python 2 which are >> > later than Python 2.6 (unless the documentation says that it must be >> > Python 2.6).- Hide quoted text - >> >> > - Show quoted text - >> >> Splunk's latest version 4.1.6 doesn't support Python 2.7 >> I tried the import trick but it didnt work because the real script >> which runs under Python 2.7 has import pyodbc so it results in >> following error >> >> c:\Splunk\etc\apps\search\bin>splunk cmd python namelookupWrapper.py >> memberId memberName < memberInput.csv >> Traceback (most recent call last): >> ? File "namelookupWrapper.py", line 3, in >> ? ? import namelookup >> ? File "c:\Splunk\etc\apps\search\bin\namelookup.py", line 7, in >> >> ? ? import pyodbc >> ImportError: DLL load failed: The specified module could not be found. >> >> Please let me know if i am missing something on import. If so please >> provide me with an example- Hide quoted text - >> >> - Show quoted text - > > Here are some more details from my earlier posting. Please click the > below link > > http://answers.splunk.com/questions/11145/its-getting-mysterious-to-make-the-lookup-script-work > -- > http://mail.python.org/mailman/listinfo/python-list > Have you tried downloading the source for PyODBC and compiling it yourself? All you need to do is python setup.py install. My guess would be that it works just fine on 64-bit Python 2.6, they just never released a re-compiled version of it for that platform. From alan.isaac at gmail.com Fri Jan 28 14:02:49 2011 From: alan.isaac at gmail.com (Alan) Date: Fri, 28 Jan 2011 11:02:49 -0800 (PST) Subject: can't use multiprocessing with class factory? Message-ID: Can the below example be fixed to work? Thanks, Alan Isaac import multiprocessing as mp class Test(object): pass def class_factory(x): class ConcreteTest(Test): _x = x return ConcreteTest def f(cls): print cls._x if __name__ == '__main__': pool = mp.Pool(2) pool.map(f, [class_factory(i) for i in range(4)]) From robert.kern at gmail.com Fri Jan 28 14:23:35 2011 From: robert.kern at gmail.com (Robert Kern) Date: Fri, 28 Jan 2011 13:23:35 -0600 Subject: can't use multiprocessing with class factory? In-Reply-To: References: Message-ID: On 1/28/11 1:02 PM, Alan wrote: > Can the below example be fixed to work? > Thanks, > Alan Isaac > > import multiprocessing as mp > > class Test(object): > pass > > def class_factory(x): > class ConcreteTest(Test): > _x = x > return ConcreteTest > > def f(cls): > print cls._x > > if __name__ == '__main__': > pool = mp.Pool(2) > pool.map(f, [class_factory(i) for i in range(4)]) Send the (pickleable) factory and the arguments used to construct the instance, not the unpickleable instance itself. def g(factory, i): cls = factory(i) print cls._x if __name__ == '__main__': pool = mp.Pool(2) pool.map(g, zip([class_factory] * 4, range(4))) By the way, when asking for help like this, show us what your code did and describe what results you want. It can often be hard to figure out exactly what you mean by "work". -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco From urban.dani at gmail.com Fri Jan 28 14:25:08 2011 From: urban.dani at gmail.com (Daniel Urban) Date: Fri, 28 Jan 2011 20:25:08 +0100 Subject: can't use multiprocessing with class factory? In-Reply-To: References: Message-ID: On Fri, Jan 28, 2011 at 20:02, Alan wrote: > Can the below example be fixed to work? > Thanks, > Alan Isaac > > import multiprocessing as mp > > class Test(object): > ? ?pass > > def class_factory(x): > ? ?class ConcreteTest(Test): > ? ? ? ?_x = x > ? ?return ConcreteTest > > def f(cls): > ? ?print cls._x > > if __name__ == '__main__': > ? ?pool = mp.Pool(2) > ? ?pool.map(f, [class_factory(i) for i in range(4)]) Only classes defined on the top level of a module are picklable (see http://docs.python.org/dev/py3k/library/pickle#what-can-be-pickled-and-unpickled ). The collections.namedtuple class factory function works around this limitation by setting the __module__ attribute of the created class, but I'm not sure if this solution can be used in this case. Daniel From hidura at gmail.com Fri Jan 28 14:34:35 2011 From: hidura at gmail.com (Hidura) Date: Fri, 28 Jan 2011 15:34:35 -0400 Subject: can't use multiprocessing with class factory? In-Reply-To: References: Message-ID: What is the output? 2011/1/28, Alan : > Can the below example be fixed to work? > Thanks, > Alan Isaac > > import multiprocessing as mp > > class Test(object): > pass > > def class_factory(x): > class ConcreteTest(Test): > _x = x > return ConcreteTest > > def f(cls): > print cls._x > > if __name__ == '__main__': > pool = mp.Pool(2) > pool.map(f, [class_factory(i) for i in range(4)]) > > -- > http://mail.python.org/mailman/listinfo/python-list > -- Enviado desde mi dispositivo m?vil Diego I. Hidalgo D. From robert.kern at gmail.com Fri Jan 28 14:42:21 2011 From: robert.kern at gmail.com (Robert Kern) Date: Fri, 28 Jan 2011 13:42:21 -0600 Subject: can't use multiprocessing with class factory? In-Reply-To: References: Message-ID: On 1/28/11 1:25 PM, Daniel Urban wrote: > Only classes defined on the top level of a module are picklable (see > http://docs.python.org/dev/py3k/library/pickle#what-can-be-pickled-and-unpickled > ). The collections.namedtuple class factory function works around this > limitation by setting the __module__ attribute of the created class, > but I'm not sure if this solution can be used in this case. namedtuple's trick only works when you assign the created class to a name at the module level. E.g. MyFancyTuple = collections.namedtuple(...) The trick won't work for "anonymous" classes like the above use case. -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco From subhakolkata1234 at gmail.com Fri Jan 28 15:01:59 2011 From: subhakolkata1234 at gmail.com (joy99) Date: Fri, 28 Jan 2011 12:01:59 -0800 (PST) Subject: Question on Python Freelance Projects in NLP and Machine Learning Message-ID: <2c1cbfb6-9dc6-4ef3-82b4-46e16d246745@a28g2000prb.googlegroups.com> Dear Room, I am a Python programmer from India. I am looking for some freelance Python projects, preferably in Natural Language Processing and Machine Learning. If any one knows of it, please let me know. Best Regards, Subhabrata Banerjee. From rantingrick at gmail.com Fri Jan 28 15:24:55 2011 From: rantingrick at gmail.com (rantingrick) Date: Fri, 28 Jan 2011 12:24:55 -0800 (PST) Subject: Bugs/issues in tkinter.simpledialog!! References: Message-ID: On Jan 28, 8:52?am, Giampaolo Rodol? wrote: > Why don't you file a ticket on the bug tracker instead of wasting > yours and other people's time here by making appear another rant > against Tkinter as a bug report? Why don't you instead thank me for helping out instead of jumping to irate conclusions? It would *seem* that if YOU cared about the future of Python you would be more *accepting* of my help. > [...snip: shameless plugs...] Oh, i see why you dropped by; First to score some points on my behalf and then to plug your own software. Interesting. From alan.isaac at gmail.com Fri Jan 28 15:26:12 2011 From: alan.isaac at gmail.com (Alan) Date: Fri, 28 Jan 2011 12:26:12 -0800 (PST) Subject: can't use multiprocessing with class factory? References: Message-ID: <11c4bb6f-815b-4b64-ace2-2549b7cf8b5b@s28g2000prb.googlegroups.com> On Jan 28, 2:23 pm, Robert Kern wrote: > Send the (pickleable) factory and the arguments used to construct the instance, > not the unpickleable instance itself. > > def g(factory, i): > cls = factory(i) > print cls._x > > if __name__ == '__main__': > pool = mp.Pool(2) > pool.map(g, zip([class_factory] * 4, range(4))) If I change that to g((factory,i)) it does work. Thanks! Alan From rantingrick at gmail.com Fri Jan 28 15:30:20 2011 From: rantingrick at gmail.com (rantingrick) Date: Fri, 28 Jan 2011 12:30:20 -0800 (PST) Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com> <9MB%o.14110$%64.6074@unlimited.newshosting.com> <4A48EDF6D7634F2E994661A457451E87@teddy> <753A4C5A6658470085804B13C80340F2@octavian> Message-ID: <8ccd9099-0f9c-444a-bdfc-1fda779cb02b@i40g2000yqh.googlegroups.com> On Jan 28, 9:52?am, Grant Edwards wrote: > [plonk] Why is it necessarily for you guys to advertise when you plonk. Just plonk and shut up about it. Nobody cares what you do with your own incoming email. Really, are you that self centered as to think we actually care? [zing] From no.email at nospam.invalid Fri Jan 28 15:30:23 2011 From: no.email at nospam.invalid (Paul Rubin) Date: Fri, 28 Jan 2011 12:30:23 -0800 Subject: Use the Source Luke References: <094f6fc5-7242-46c7-b454-4cb29d0c6ef9@q40g2000prh.googlegroups.com> Message-ID: <7xvd18g49s.fsf@ruckus.brouhaha.com> Raymond Hettinger writes: > http://rhettinger.wordpress.com/2011/01/28/open-your-source-more/ > > I'm looking for more examples of projects that routinely > link their docs back into relavant sections of code. > Have any of you all seen other examples besides > the Go language docs and the Python docs? That is a very good post, and just about 2 days ago I happened to be looking at the source of heapq for something I was doing, and I think I got to it through the doc link that you added. So the link has already been useful. Haddock (Haskell's equivalent to Pydoc or Javadoc) can automatically generate source links in Haskell documentation. For example, here's the docs (including source links) for Haskell's standard library for dealing with lists: http://www.haskell.org/ghc/docs/7.0-latest/html/libraries/base-4.3.0.0/Data-List.html I've wanted for a long time for developer-oriented Linux distributions to include full source code of everything as an integral part of the distro rather than as a separate distribution. For example, you could examine any application and instantly see its source. All programs would be compiled with debugging enabled and a way to attach a debugger to the running process, so you could at any time interrupt the program and use gdb to see what it was doing, single step it, etc. From g.rodola at gmail.com Fri Jan 28 15:32:44 2011 From: g.rodola at gmail.com (=?ISO-8859-1?Q?Giampaolo_Rodol=E0?=) Date: Fri, 28 Jan 2011 21:32:44 +0100 Subject: Use the Source Luke In-Reply-To: <094f6fc5-7242-46c7-b454-4cb29d0c6ef9@q40g2000prh.googlegroups.com> References: <094f6fc5-7242-46c7-b454-4cb29d0c6ef9@q40g2000prh.googlegroups.com> Message-ID: 2011/1/28 Raymond Hettinger : > I hoping a new trend will start with dev's putting direct > source code links in their documentation: > > ?http://rhettinger.wordpress.com/2011/01/28/open-your-source-more/ > > I'm looking for more examples of projects that routinely > link their docs back into relavant sections of code. > Have any of you all seen other examples besides > the Go language docs and the Python docs? > > > Raymond > -- > http://mail.python.org/mailman/listinfo/python-list > Thanks, I think this is a great idea. I think this definitively should be done for 2.7 documentation as well. --- Giampaolo http://code.google.com/p/pyftpdlib/ http://code.google.com/p/psutil/ From benjamin.kaplan at case.edu Fri Jan 28 15:34:31 2011 From: benjamin.kaplan at case.edu (Benjamin Kaplan) Date: Fri, 28 Jan 2011 15:34:31 -0500 Subject: Bugs/issues in tkinter.simpledialog!! In-Reply-To: References: Message-ID: On Fri, Jan 28, 2011 at 3:24 PM, rantingrick wrote: > On Jan 28, 8:52?am, Giampaolo Rodol? wrote: > >> Why don't you file a ticket on the bug tracker instead of wasting >> yours and other people's time here by making appear another rant >> against Tkinter as a bug report? > > Why don't you instead thank me for helping out instead of jumping to > irate conclusions? It would *seem* that if YOU cared about the future > of Python you would be more *accepting* of my help. > It's not that people don't appreciate your help. It's that the mailing list is not the appropriate place for this type of discussion. Once it's been verified as a bug, you should create a ticket on the bug tracker, come back here and post a link, and then move the discussion over to the tracker. Even if you intend to fix it yourself, you should create a ticket and then attach the patch to the ticket when you fix it. From malaclypse2 at gmail.com Fri Jan 28 15:34:46 2011 From: malaclypse2 at gmail.com (Jerry Hill) Date: Fri, 28 Jan 2011 15:34:46 -0500 Subject: Bugs/issues in tkinter.simpledialog!! In-Reply-To: References: Message-ID: On Fri, Jan 28, 2011 at 3:24 PM, rantingrick wrote: > Why don't you instead thank me for helping out instead of jumping to > irate conclusions? It would *seem* that if YOU cared about the future > of Python you would be more *accepting* of my help. > But you have not, in fact, helped out. You've complained to a mailing list of python users that you've found some bugs. If you want to help out, you need to file issues on the bug tracker for bugs that you've found. If you want to be extra helpful, you'll also attach patches to those bug reports. It really isn't difficult, but you don't seem to be willing to do it. Until you do, all you're doing is ranting, not helping. -- Jerry -------------- next part -------------- An HTML attachment was scrubbed... URL: From rantingrick at gmail.com Fri Jan 28 15:35:18 2011 From: rantingrick at gmail.com (rantingrick) Date: Fri, 28 Jan 2011 12:35:18 -0800 (PST) Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com> <9MB%o.14110$%64.6074@unlimited.newshosting.com> <4A48EDF6D7634F2E994661A457451E87@teddy> <753A4C5A6658470085804B13C80340F2@octavian> <90450b74-2d66-4a78-8a9f-0c3807607848@o14g2000prb.googlegroups.com> <18c47$4d42eba6$4275d90a$21758@FUSE.NET> Message-ID: <6ee346d2-012b-45f7-8fc3-94b649048d18@n36g2000pre.googlegroups.com> On Jan 28, 10:16?am, Kevin Walzer wrote: > On 1/28/11 9:18 AM, rantingrick wrote: > > > Everyone on this list knows that Kevin and myself are the *only* > > people who know how to wield Tkinter past some simple utility GUI's. > > I strongly disagree with this statement. Whether you agree or disagree is irrelevant. The fact remains. And if there are others, why do we never hear from them? Why do they never help noobs when Tkinter questions come up? I guess they are the "silent majority" right? Man look at the state of Tkinter. Look at the bugs and mediocre code i exposed. Are you going to set there with a strait face and tell me many people are using Tkinter. Come on Kevin, be realistic! From tjreedy at udel.edu Fri Jan 28 15:37:25 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Fri, 28 Jan 2011 15:37:25 -0500 Subject: WxPython versus Tkinter. In-Reply-To: <8775C617C7B241759AC122A69955D42A@octavian> References: <4D3E4377.3060807@tysdomain.com> <9MB%o.14110$%64.6074@unlimited.newshosting.com> <59F6E65E3D9A46AD8D7A3863F3C1DC84@teddy> <27f53f8c-7862-4366-9352-82ae9a2f3970@k3g2000yqc.googlegroups.com> <718D13777F254C839F9564BC4275DE0A@octavian> <4D402C42.1030407@tysdomain.com> <4D40447C.4010108@tysdomain.com> <33C68A0874BE4C66AB478EDFB64C2C1D@teddy> <4D407321.3090705@web.de> <1296128007.17192.1417506961@webmail.messagingengine.com> <8775C617C7B241759AC122A69955D42A@octavian> Message-ID: On 1/28/2011 3:33 AM, Octavian Rasnita wrote: > From: "Terry Reedy" >> For example: pygui pretty much uses native widgets on Windows and OX and >> gtk (I believe) on *nix. How is the accessibility of those widget sets >> *as >> accessed through pygui*? Is it different from the 'native' accessibility >> of each of those set? > > > Thank you for telling about this GUI lib! > I have tested the sample apps it offers and the standard dialogs are very > accessible. I hope it is the same in case of the other common controls like > list boxes, list views, check boxes, radio buttons, combo boxes, tree > views... Which OS? The result might be different on each of Windows, OSX, and *nis as different widgets are used on each. > How complete is this GUI lib compared with others that can be used in > Python > apps? > I am asking this, because I read: > > "Get the library and its documentation included in the core Python > distribution, so that truly cross-platform GUI applications may be written > that will run on any Python installation, anywhere." I don't know if Grey still has that goal. It is 2.x only. -- Terry Jan Reedy From mail2bansi at gmail.com Fri Jan 28 15:42:34 2011 From: mail2bansi at gmail.com (bansi) Date: Fri, 28 Jan 2011 12:42:34 -0800 (PST) Subject: Is it possible to pass CSV Reader Object As Argument to another Python File ??? References: <2c35653e-3565-48c6-8939-b6b09b885e3f@d23g2000prj.googlegroups.com> <876b6c52-1a6d-4afa-83e9-fa987c9359a5@v31g2000pri.googlegroups.com> <87lj272vpo.fsf@benfinney.id.au> <430714cd-20b4-4a67-bd2d-54e8f0c44ad5@s18g2000vbe.googlegroups.com> <2c9f82cd-756b-4460-940b-31e2a866f24e@n36g2000pre.googlegroups.com> Message-ID: <933ce06c-7829-42b9-a96d-dc9582e8267b@u11g2000prk.googlegroups.com> On Jan 28, 1:52?pm, Benjamin Kaplan wrote: > On Fri, Jan 28, 2011 at 1:33 PM, bansi wrote: > > On Jan 28, 9:46?am, bansi wrote: > >> On Jan 26, 8:31?pm, MRAB wrote: > > >> > On 27/01/2011 00:57, bansi wrote: > > >> > > On Jan 26, 6:25 pm, Ethan Furman ?wrote: > >> > >> bansi wrote: > > >> > >> ? > ?First namelookupWrapper.py running under Python 2.6 accept arguments > >> > >> ? > ?from stdin and uses csv reader object to read it i.e. > >> > >> ? > ?r=csv.reader(sys.stdin) > > >> > >> ? > ?And then it has to pass csv reader object to another python script > >> > >> ? > ?namelookup.py running under Python 2.7 because it uses pyodbc to > >> > >> ? > ?connect to database and iterates thru reader object > > >> > >> Ben Finney wrote: > >> > >>> bansi ?writes: > > >> > >>>> Thanks Chris. Sorry for mis-communicating, the two python scripts are > >> > >>>> dependant in a way that namelookupWrapper.py needs to pass csv record > >> > >>>> object to another python script > > >> > >>> Why have you structured them that way, though? What constraint is > >> > >>> keeping you from doing the work in a single process, where the CSV > >> > >>> reader object can be shared? > > >> > >>>> If thats not possible then please let me know how to do the workaround > >> > >>>> i didnt understood the import thing and not sure if it helps in my > >> > >>>> case > > >> > >>> The problem as you've described it so far is best solved by having a > >> > >>> single process accessing the CSV reader object in memory. If that > >> > >>> doesn't suit your use case, you'll need to explain why not. > > >> > >> In other words, why can't you use Python 2.7 to accept input and > >> > >> generate a csv.reader? > > >> > >> ~Ethan~- Hide quoted text - > > >> > >> - Show quoted text - > > >> > > Ethan, > >> > > The python script takes the input from Splunk (http://www.splunk.com/ > >> > > base/Documentation/) which supports only Python 2.6 > >> > > So the real constraint is Splunk supports only Python 2.6 . > > >> > > As you know Python 2.6 doesnt support or doesnt have pyodbc install > >> > > for Windows ?64 bit OS > >> > > So i installed Python 2.7 and thereafter pyodbc install for Windows 64 > >> > > bit OS for Python 2.7 > > >> > Have you actually tried Splunk with Python 2.7? It might not work with > >> > versions which are earlier than Python 2.6, but that doesn't > >> > necessarily mean that it won't work with versions of Python 2 which are > >> > later than Python 2.6 (unless the documentation says that it must be > >> > Python 2.6).- Hide quoted text - > > >> > - Show quoted text - > > >> Splunk's latest version 4.1.6 doesn't support Python 2.7 > >> I tried the import trick but it didnt work because the real script > >> which runs under Python 2.7 has import pyodbc so it results in > >> following error > > >> c:\Splunk\etc\apps\search\bin>splunk cmd python namelookupWrapper.py > >> memberId memberName < memberInput.csv > >> Traceback (most recent call last): > >> ? File "namelookupWrapper.py", line 3, in > >> ? ? import namelookup > >> ? File "c:\Splunk\etc\apps\search\bin\namelookup.py", line 7, in > >> > >> ? ? import pyodbc > >> ImportError: DLL load failed: The specified module could not be found. > > >> Please let me know if i am missing something on import. If so please > >> provide me with an example- Hide quoted text - > > >> - Show quoted text - > > > Here are some more details from my earlier posting. Please click the > > below link > > >http://answers.splunk.com/questions/11145/its-getting-mysterious-to-m... > > -- > >http://mail.python.org/mailman/listinfo/python-list > > Have you tried downloading the source for PyODBC and compiling it > yourself? All you need to do is python setup.py install. My guess > would be that it works just fine on 64-bit Python 2.6, they just never > released a re-compiled version of it for that platform.- Hide quoted text - > > - Show quoted text - Thanks Benjamin. Please point me to the website from where i can download pyodbc for Windows 64 bit OS under Python 2.6 and installation instructions From rui.maciel at gmail.com Fri Jan 28 15:49:22 2011 From: rui.maciel at gmail.com (Rui Maciel) Date: Fri, 28 Jan 2011 20:49:22 +0000 Subject: Use the Source Luke References: <094f6fc5-7242-46c7-b454-4cb29d0c6ef9@q40g2000prh.googlegroups.com> Message-ID: <4d432bd0$0$19531$a729d347@news.telepac.pt> Raymond Hettinger wrote: > Have any of you all seen other examples besides > the Go language docs and the Python docs? Wasn't doxygen developed with that in mind? Rui Maciel From rantingrick at gmail.com Fri Jan 28 15:58:50 2011 From: rantingrick at gmail.com (rantingrick) Date: Fri, 28 Jan 2011 12:58:50 -0800 (PST) Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com> <59F6E65E3D9A46AD8D7A3863F3C1DC84@teddy> <27f53f8c-7862-4366-9352-82ae9a2f3970@k3g2000yqc.googlegroups.com> <718D13777F254C839F9564BC4275DE0A@octavian> <4D402C42.1030407@tysdomain.com> <4D40447C.4010108@tysdomain.com> <33C68A0874BE4C66AB478EDFB64C2C1D@teddy> <4D407321.3090705@web.de> <1296128007.17192.1417506961@webmail.messagingengine.com> <8775C617C7B241759AC122A69955D42A@octavian> Message-ID: <349dc47a-5a16-47e9-8dea-0de3aa814b52@d1g2000yqb.googlegroups.com> On Jan 28, 2:37?pm, Terry Reedy wrote: > On 1/28/2011 3:33 AM, Octavian Rasnita wrote: > > "Get the library and its documentation included in the core Python > > distribution, so that truly cross-platform GUI applications may be written > > that will run on any Python installation, anywhere." > > I don't know if Grey still has that goal. ?It is 2.x only. True, but *if* the community saw the potential that i see with pyGUI and wanted to seriously do some development to bring it into 3.0 compliance i'll bet Greg *would* be interested! pyGUI has lots of potential. To be honest, i would sacrifice all the functionality of wxWidgets if we could get pyGUI into the stdlib. Why? Well because pyGUI would be under OUR complete control. No more kissing TclTk butt, no more kissing WxWidgets+Robin Dunn butt. WE decide how fast to move and NOBODY will get in our way anymore! From tyler at tysdomain.com Fri Jan 28 16:09:27 2011 From: tyler at tysdomain.com (Littlefield, Tyler) Date: Fri, 28 Jan 2011 14:09:27 -0700 Subject: WxPython versus Tkinter. In-Reply-To: <6ee346d2-012b-45f7-8fc3-94b649048d18@n36g2000pre.googlegroups.com> References: <4D3E4377.3060807@tysdomain.com> <9MB%o.14110$%64.6074@unlimited.newshosting.com> <4A48EDF6D7634F2E994661A457451E87@teddy> <753A4C5A6658470085804B13C80340F2@octavian> <90450b74-2d66-4a78-8a9f-0c3807607848@o14g2000prb.googlegroups.com> <18c47$4d42eba6$4275d90a$21758@FUSE.NET> <6ee346d2-012b-45f7-8fc3-94b649048d18@n36g2000pre.googlegroups.com> Message-ID: <4D433087.70803@tysdomain.com> >Man look at the state of Tkinter. Look at the bugs and mediocre code i >exposed. Are you going to set there with a strait face and tell me >many people are using Tkinter. Come on Kevin, be realistic! You also uncovered bugs in WX (remember those segfaults, RR)? On 1/28/2011 1:35 PM, rantingrick wrote: > On Jan 28, 10:16 am, Kevin Walzer wrote: >> On 1/28/11 9:18 AM, rantingrick wrote: >> >>> Everyone on this list knows that Kevin and myself are the *only* >>> people who know how to wield Tkinter past some simple utility GUI's. >> I strongly disagree with this statement. > Whether you agree or disagree is irrelevant. The fact remains. And if > there are others, why do we never hear from them? Why do they never > help noobs when Tkinter questions come up? I guess they are the > "silent majority" right? > > Man look at the state of Tkinter. Look at the bugs and mediocre code i > exposed. Are you going to set there with a strait face and tell me > many people are using Tkinter. Come on Kevin, be realistic! -- Thanks, Ty From me+list/python at ixokai.io Fri Jan 28 16:09:39 2011 From: me+list/python at ixokai.io (Stephen Hansen) Date: Fri, 28 Jan 2011 13:09:39 -0800 Subject: WxPython versus Tkinter. In-Reply-To: <6ee346d2-012b-45f7-8fc3-94b649048d18@n36g2000pre.googlegroups.com> References: <4D3E4377.3060807@tysdomain.com> <9MB%o.14110$%64.6074@unlimited.newshosting.com> <4A48EDF6D7634F2E994661A457451E87@teddy> <753A4C5A6658470085804B13C80340F2@octavian> <90450b74-2d66-4a78-8a9f-0c3807607848@o14g2000prb.googlegroups.com> <18c47$4d42eba6$4275d90a$21758@FUSE.NET> <6ee346d2-012b-45f7-8fc3-94b649048d18@n36g2000pre.googlegroups.com> Message-ID: <4D433093.6040604@ixokai.io> On 1/28/11 12:35 PM, rantingrick wrote: > The fact remains. The word "fact" does not mean what you think it means. -- Stephen Hansen ... Also: Ixokai ... Mail: me+list/python (AT) ixokai (DOT) io ... Blog: http://meh.ixokai.io/ -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 487 bytes Desc: OpenPGP digital signature URL: From benjamin.kaplan at case.edu Fri Jan 28 16:22:49 2011 From: benjamin.kaplan at case.edu (Benjamin Kaplan) Date: Fri, 28 Jan 2011 16:22:49 -0500 Subject: Is it possible to pass CSV Reader Object As Argument to another Python File ??? In-Reply-To: <933ce06c-7829-42b9-a96d-dc9582e8267b@u11g2000prk.googlegroups.com> References: <2c35653e-3565-48c6-8939-b6b09b885e3f@d23g2000prj.googlegroups.com> <876b6c52-1a6d-4afa-83e9-fa987c9359a5@v31g2000pri.googlegroups.com> <87lj272vpo.fsf@benfinney.id.au> <430714cd-20b4-4a67-bd2d-54e8f0c44ad5@s18g2000vbe.googlegroups.com> <2c9f82cd-756b-4460-940b-31e2a866f24e@n36g2000pre.googlegroups.com> <933ce06c-7829-42b9-a96d-dc9582e8267b@u11g2000prk.googlegroups.com> Message-ID: On Fri, Jan 28, 2011 at 3:42 PM, bansi wrote: > On Jan 28, 1:52?pm, Benjamin Kaplan wrote: >> On Fri, Jan 28, 2011 at 1:33 PM, bansi wrote: >> > On Jan 28, 9:46?am, bansi wrote: >> >> On Jan 26, 8:31?pm, MRAB wrote: >> >> >> > On 27/01/2011 00:57, bansi wrote: >> >> >> > > On Jan 26, 6:25 pm, Ethan Furman ?wrote: >> >> > >> bansi wrote: >> >> >> > >> ? > ?First namelookupWrapper.py running under Python 2.6 accept arguments >> >> > >> ? > ?from stdin and uses csv reader object to read it i.e. >> >> > >> ? > ?r=csv.reader(sys.stdin) >> >> >> > >> ? > ?And then it has to pass csv reader object to another python script >> >> > >> ? > ?namelookup.py running under Python 2.7 because it uses pyodbc to >> >> > >> ? > ?connect to database and iterates thru reader object >> >> >> > >> Ben Finney wrote: >> >> > >>> bansi ?writes: >> >> >> > >>>> Thanks Chris. Sorry for mis-communicating, the two python scripts are >> >> > >>>> dependant in a way that namelookupWrapper.py needs to pass csv record >> >> > >>>> object to another python script >> >> >> > >>> Why have you structured them that way, though? What constraint is >> >> > >>> keeping you from doing the work in a single process, where the CSV >> >> > >>> reader object can be shared? >> >> >> > >>>> If thats not possible then please let me know how to do the workaround >> >> > >>>> i didnt understood the import thing and not sure if it helps in my >> >> > >>>> case >> >> >> > >>> The problem as you've described it so far is best solved by having a >> >> > >>> single process accessing the CSV reader object in memory. If that >> >> > >>> doesn't suit your use case, you'll need to explain why not. >> >> >> > >> In other words, why can't you use Python 2.7 to accept input and >> >> > >> generate a csv.reader? >> >> >> > >> ~Ethan~- Hide quoted text - >> >> >> > >> - Show quoted text - >> >> >> > > Ethan, >> >> > > The python script takes the input from Splunk (http://www.splunk.com/ >> >> > > base/Documentation/) which supports only Python 2.6 >> >> > > So the real constraint is Splunk supports only Python 2.6 . >> >> >> > > As you know Python 2.6 doesnt support or doesnt have pyodbc install >> >> > > for Windows ?64 bit OS >> >> > > So i installed Python 2.7 and thereafter pyodbc install for Windows 64 >> >> > > bit OS for Python 2.7 >> >> >> > Have you actually tried Splunk with Python 2.7? It might not work with >> >> > versions which are earlier than Python 2.6, but that doesn't >> >> > necessarily mean that it won't work with versions of Python 2 which are >> >> > later than Python 2.6 (unless the documentation says that it must be >> >> > Python 2.6).- Hide quoted text - >> >> >> > - Show quoted text - >> >> >> Splunk's latest version 4.1.6 doesn't support Python 2.7 >> >> I tried the import trick but it didnt work because the real script >> >> which runs under Python 2.7 has import pyodbc so it results in >> >> following error >> >> >> c:\Splunk\etc\apps\search\bin>splunk cmd python namelookupWrapper.py >> >> memberId memberName < memberInput.csv >> >> Traceback (most recent call last): >> >> ? File "namelookupWrapper.py", line 3, in >> >> ? ? import namelookup >> >> ? File "c:\Splunk\etc\apps\search\bin\namelookup.py", line 7, in >> >> >> >> ? ? import pyodbc >> >> ImportError: DLL load failed: The specified module could not be found. >> >> >> Please let me know if i am missing something on import. If so please >> >> provide me with an example- Hide quoted text - >> >> >> - Show quoted text - >> >> > Here are some more details from my earlier posting. Please click the >> > below link >> >> >http://answers.splunk.com/questions/11145/its-getting-mysterious-to-m... >> > -- >> >http://mail.python.org/mailman/listinfo/python-list >> >> Have you tried downloading the source for PyODBC and compiling it >> yourself? All you need to do is python setup.py install. My guess >> would be that it works just fine on 64-bit Python 2.6, they just never >> released a re-compiled version of it for that platform.- Hide quoted text - >> >> - Show quoted text - > > Thanks Benjamin. Please point me to the website from where i can > download pyodbc for Windows 64 bit OS under Python 2.6 and > installation instructions > -- You don't download it for 64-bit Windows with Python 2.6. You download the source code from the website and make the Python 2.6, 64-bit Windows version yourself. Download the source zip file and extract it. Then, open up the command prompt and use the "cd" command to change directories to that source folder. For instance, if the source code has been extracted to C:\pyodbc-2.1.8\, you type in "cd C:\pyodbc-2.1.8" and press enter. After that, you just run the build script which is already in there: C:\Python26\python26.exe setup.py install You'll need to have Visual C++ 2008 (not 2010) installed for this to work. You can get it for free from http://www.microsoft.com/express/Downloads/ if you don't already have it. > http://mail.python.org/mailman/listinfo/python-list > From rantingrick at gmail.com Fri Jan 28 16:26:11 2011 From: rantingrick at gmail.com (rantingrick) Date: Fri, 28 Jan 2011 13:26:11 -0800 (PST) Subject: Bugs/issues in tkinter.simpledialog!! References: Message-ID: On Jan 28, 2:34?pm, Benjamin Kaplan wrote: > It's not that people don't appreciate your help. First: Thanks for the reasonable response. > It's that the mailing > list is not the appropriate place for this type of discussion. Actually i see you point but there is a good reason behind me bringing this up here. I want to bring to the attention of everyone how little interest there is for Tkinter. Not many folks are using Tkinter, most hate Tkinter, and not many (if any) are capable of patching the Tkinter source code. It has been mentioned in this thread that the last person to do any real work on Tkinter is someone from two years ago. This is insanity! You know why i think nobody cares.. * Too much trouble to get patches submitted. * Nobody really cares at py-dev so the patches never get resolved. * There is resistance in the community to "outsiders". This mentality is setting us up for a bad bad future. Why are people so pedantic and emotional. Python does not belong to me, or you, or anybody. This is a team effort. And whist we need people doing work we also need to listen to the community. I have had nothing but an uphill battle dealing with a few "elites" on this list. Anybody can see that i am serious about helping out. Heck, i want Tkinter to be removed from the stdlib but yet i still offer help to noobies and still report bugs. > Once > it's been verified as a bug, you should create a ticket on the bug > tracker, come back here and post a link, and then move the discussion > over to the tracker. Agreed. However i would rather just write a patch, send it to some email and be done. Or just commit the changes myself. This bug tracker is just bureaucracy at it's worst. You are making this process too hard and people are not going to get involved when they have to jump through 20 hoops just to patch three lines of freaking code! There is too much red tape here. I COULD HAVE PATCHED HUNDREDS OF LINE OF CODE IN THE TIME I HAVE WASTED WITH THE BUG TRACKER PROCESS ALONE! I understand we need checks and balances but at some point the very safety net we rely on becomes a noose around our neck! Something needs to be done! From cmpython at gmail.com Fri Jan 28 16:47:42 2011 From: cmpython at gmail.com (CM) Date: Fri, 28 Jan 2011 13:47:42 -0800 (PST) Subject: A and B but not C in list References: <8cae2caf-d3df-4ed3-9afb-29de97772298@m13g2000yqb.googlegroups.com> Message-ID: <2add851e-4f5d-4cde-82e7-a96d43a3dc13@o1g2000yqb.googlegroups.com> Thanks, everyone, for your suggestions. -Che From tismer at stackless.com Fri Jan 28 16:53:29 2011 From: tismer at stackless.com (Christian Tismer) Date: Fri, 28 Jan 2011 22:53:29 +0100 Subject: WxPython versus Tkinter. In-Reply-To: <4d3e0563$0$29983$c3e8da3$5496439d@news.astraweb.com> References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <3a96fee1-995f-49f7-a967-f125cc3f1cdc@v26g2000yqf.googlegroups.com> <4d3e0563$0$29983$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4D433AD9.7030400@stackless.com> On 1/25/11 12:04 AM, Steven D'Aprano wrote: > On Mon, 24 Jan 2011 12:24:24 -0800, Robin Dunn wrote: > >> On Jan 24, 12:03 pm, rantingrick wrote: >>> On Jan 24, 1:57 pm, Robin Dunn wrote: >>>> BTW, on behalf of the wxPython community I'd like to apologize for >>>> the havoc caused by the flaming troll escaping from his cage. In >>>> general wxPython users are much less militant and zealotty and honor >>>> everyone's freedom to choose which ever UI tool kit works the best >>>> for their own needs. >>> Well we forgive Byran, but we will not forget! :) >> For the record, that is not who I was referring to. > I don't believe that anyone in their right mind could have imagined even > for a second that you were referring to Bryan. As we all experienced milleniums before: Self-criticism is the weakest, maybe totally missing virtue of a bozo. Which is great, because he won't recognize the irony ;-) -- Christian Tismer :^) tismerysoft GmbH : Have a break! Take a ride on Python's Johannes-Niemeyer-Weg 9A : *Starship* http://starship.python.net/ 14109 Berlin : PGP key -> http://wwwkeys.pgp.net/ work +49 30 802 86 56 mobile +49 173 24 18 776 fax +49 30 80 90 57 05 PGP 0x57F3BF04 9064 F4E1 D754 C2FF 1619 305B C09C 5A3B 57F3 BF04 whom do you want to sponsor today? http://www.stackless.com/ From rantingrick at gmail.com Fri Jan 28 16:56:18 2011 From: rantingrick at gmail.com (rantingrick) Date: Fri, 28 Jan 2011 13:56:18 -0800 (PST) Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com> <4A48EDF6D7634F2E994661A457451E87@teddy> <753A4C5A6658470085804B13C80340F2@octavian> <90450b74-2d66-4a78-8a9f-0c3807607848@o14g2000prb.googlegroups.com> <18c47$4d42eba6$4275d90a$21758@FUSE.NET> <6ee346d2-012b-45f7-8fc3-94b649048d18@n36g2000pre.googlegroups.com> Message-ID: <3ac99c65-96cc-46f6-9533-c57de9bb4155@a5g2000vbs.googlegroups.com> Rick: > Man look at the state of Tkinter. Look at the bugs and mediocre code i > exposed. Are you going to set there with a strait face and tell me > many people are using Tkinter. Come on Kevin, be realistic! Tyler: > You also uncovered bugs in WX (remember those segfaults, RR)? Yes i do, and i also remember Robin pointing out that those who were experiencing segfaults were experiencing them because they did not run wxPython correctly.But lets just ignore facts for a moment, you do this all the time. But just to make a point i will entertain you. Let's imagine that the segfaults are in fact only a wxPython problem. Now imagine you are buying a car and you have two choices. You can choose an old Yugo with 300,000 miles and a bad paint job or you can choose a fancy sports car fresh off the assembly line that contains the most modern technology. Both the new sports car and the old and dumpy Yugo have brand new tires. You're argument about segfauts would be akin to making the decision solely based on the tires. Completely moronic. From ben+python at benfinney.id.au Fri Jan 28 18:10:31 2011 From: ben+python at benfinney.id.au (Ben Finney) Date: Sat, 29 Jan 2011 10:10:31 +1100 Subject: Use the Source Luke References: <094f6fc5-7242-46c7-b454-4cb29d0c6ef9@q40g2000prh.googlegroups.com> Message-ID: <87tygs1v6g.fsf@benfinney.id.au> Raymond Hettinger writes: > I hoping a new trend will start with dev's putting direct > source code links in their documentation: > > http://rhettinger.wordpress.com/2011/01/28/open-your-source-more/ That's a good article overall. I have a quibble with the framing: > The rest of the blame lies with installers. They all treat > human-readable scripts like they were binaries and tuck the code away > in a dark corner. That?s hardly a ?blame? of installers. The modules are placed in such locations because they need to be accessible in a hierarchy at a location that is known to not conflict with anything else, and be predictable for the Python interpreter on the system. If you want to blame anything for this (though I think it?s inaccurate to frame it as a problem), the correct target of your accusation is the fact that a filesystem path is the identifier for these modules that will be used by programs to find them. As for reading the source and making it more available to programmers, yes, I agree wholeheartedly. Encouraging the routine reading of other projects?s source code is a good thing, and thank you for beating the drum. -- \ ?I distrust those people who know so well what God wants them | `\ to do to their fellows, because it always coincides with their | _o__) own desires.? ?Susan Brownell Anthony, 1896 | Ben Finney From python at bdurham.com Fri Jan 28 18:29:41 2011 From: python at bdurham.com (python at bdurham.com) Date: Fri, 28 Jan 2011 18:29:41 -0500 Subject: Determining calculation order for group of related calculations Message-ID: <1296257381.25947.1417811829@webmail.messagingengine.com> Wondering if there's a Python library or algorithm for determining the order in which a group of calculations should be performed when some calculations reference the result of other equations. I don't need anything as fancy as a spreadsheet engine, however I do need to detect recursive equations and treat these situations as errors. In terms of an example: What I would like to do is order the following equations such that all the dependent variables are calculated before they are referenced by later calculations. a + b + c = d a + b + d = e a + e = f d + e + f = g a + e = h Thank you, Malcolm -------------- next part -------------- An HTML attachment was scrubbed... URL: From ian.g.kelly at gmail.com Fri Jan 28 18:38:49 2011 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Fri, 28 Jan 2011 16:38:49 -0700 Subject: Determining calculation order for group of related calculations In-Reply-To: <1296257381.25947.1417811829@webmail.messagingengine.com> References: <1296257381.25947.1417811829@webmail.messagingengine.com> Message-ID: On Fri, Jan 28, 2011 at 4:29 PM, wrote: > Wondering if there's a Python library or algorithm for determining the order > in which a group of calculations should be performed when some calculations > reference the result of other equations. I don't need anything as fancy as a > spreadsheet engine, however I do need to detect recursive equations and > treat these situations as errors. A google search for "python topological sort" returns lots of results. From jackdied at gmail.com Fri Jan 28 19:02:25 2011 From: jackdied at gmail.com (Jack Diederich) Date: Fri, 28 Jan 2011 19:02:25 -0500 Subject: Use the Source Luke In-Reply-To: <094f6fc5-7242-46c7-b454-4cb29d0c6ef9@q40g2000prh.googlegroups.com> References: <094f6fc5-7242-46c7-b454-4cb29d0c6ef9@q40g2000prh.googlegroups.com> Message-ID: On Fri, Jan 28, 2011 at 1:32 PM, Raymond Hettinger wrote: > I hoping a new trend will start with dev's putting direct > source code links in their documentation: > > ?http://rhettinger.wordpress.com/2011/01/28/open-your-source-more/ > > I'm looking for more examples of projects that routinely > link their docs back into relavant sections of code. > Have any of you all seen other examples besides > the Go language docs and the Python docs? I think you overestimate how common it used to be to carry around the sourcecode for the software you use compared to now; In the past it wasn't even always possible - if the Sun cc compiler core dumps you have no recourse to code. Promoting the idea of doing it is good because it /is/ a novel idea to many people. Promoting the idea of making it extremely easy via documentation links is good because it is new as well. Modern tools are making this easier than it used to be so your call for making it easier still is well timed. Github/bitbucket/launchpad have combined the source with documentation; github especially because the README on github is the canonical documentation and the source is only one mouse click away. ack-grep has changed my life. Sure, I could always do the same thing in the past with find+grep but ack-grep makes it so easy (switches for language file types!) that I use it much more; I have "ag" aliased to "ack-grep --python" and I use it all the f'ing time because it costs me near zero to do so. Likewise I have an alias "cdp" that "cd"s me into the directory where any given python module lives. "cdp collections" puts me straight into "/usr/local/lib/python2.6" - again, it makes it so easy to look at sourcecode that I do it all the time. It is usually quicker to do cdp/python/import module_name/help(module_name) than to look up the docs. Worst case the docstrings suck and I just read the code. * Anecdote. I was in a room with Tim Peters and has some questions about the interface to code he wrote so I thought "Hey, I'll just ask Tim!" I asked him and he replied "I'm not sure what you're asking - do you want me to read the code aloud to you?" So I just went and read it. -Jack From python at bdurham.com Fri Jan 28 19:32:48 2011 From: python at bdurham.com (python at bdurham.com) Date: Fri, 28 Jan 2011 19:32:48 -0500 Subject: Determining calculation order for group of related calculations In-Reply-To: References: <1296257381.25947.1417811829@webmail.messagingengine.com> Message-ID: <1296261168.6565.1417819919@webmail.messagingengine.com> Ian, > A google search for "python topological sort" returns lots of results. Perfect!! That's exactly what I was looking for but couldn't manage to put a name to. Cheers, Malcolm From ben+python at benfinney.id.au Fri Jan 28 20:19:37 2011 From: ben+python at benfinney.id.au (Ben Finney) Date: Sat, 29 Jan 2011 12:19:37 +1100 Subject: Use the Source Luke References: <094f6fc5-7242-46c7-b454-4cb29d0c6ef9@q40g2000prh.googlegroups.com> Message-ID: <87lj241p7a.fsf@benfinney.id.au> Jack Diederich writes: > I think you overestimate how common it used to be to carry around the > sourcecode for the software you use compared to now; In the past it > wasn't even always possible - if the Sun cc compiler core dumps you > have no recourse to code. Note that Raymond is speaking specifically in the context of free software, where the license is by definition permitting free redistribution of the source code. So it doesn't cover the case of things like the Sun C compiler, either now or in the past. > Promoting the idea of doing it is good because it /is/ a novel idea to > many people. Promoting the idea of making it extremely easy via > documentation links is good because it is new as well. When one notes that the context is specifically free software projects, the promotion of reading the source code is even more a good idea. -- \ ?This [Bush] Administration is not sinking. This Administration | `\ is soaring. If anything they are rearranging the deck chairs on | _o__) the Hindenburg.? ?Steven Colbert, 2006-04-29 | Ben Finney From python at rcn.com Fri Jan 28 20:52:12 2011 From: python at rcn.com (Raymond Hettinger) Date: Fri, 28 Jan 2011 17:52:12 -0800 (PST) Subject: Use the Source Luke References: <094f6fc5-7242-46c7-b454-4cb29d0c6ef9@q40g2000prh.googlegroups.com> Message-ID: <9e25c9bf-4d8b-4484-b8fc-2bfaf6b5820c@n36g2000pre.googlegroups.com> [Jack Diedrich] > I think you overestimate how common it used to be to carry around the > sourcecode for the software you use compared to now; ?In the past it > wasn't even always possible - if the Sun cc compiler core dumps you > have no recourse to code. You're right of course. For the Python world though, there does seem to have been a change. A decade ago in this newsgroup, there were frequent references to standard library source. I don't see that much anymore. >?Promoting the idea of doing it is good > because it /is/ a novel idea to many people. ?Promoting the idea of > making it extremely easy via documentation links is good because it is > new as well. Judging from the comments so far, it looks like everyone here agrees. > Modern tools are making this easier than it used to be so your call > for making it easier still is well timed. ?Github/bitbucket/launchpad > have combined the source with documentation; Do they typically feature multiple links from documentation specifics to corresponding code specifics? Part of my thesis is that it is not enough to make docs and source available, they need to be linked in a way that helps people answer specific problems without having to invest a week in learning the gestalt of a foreign code base. >?Worst case the docstrings suck and I just read the code. That's a good habit to have. I find that my willingness to do it varies across projects -- I'm happy to look at the Mercurial source but could never being myself to look at the innards of Git or CouchDB. > * Anecdote. ?I was in a room with Tim Peters and has some questions > about the interface to code he wrote so I thought "Hey, I'll just ask > Tim!" ?I asked him and he replied "I'm not sure what you're asking - > do you want me to read the code aloud to you?" ?So I just went and > read it. Thanks for the anecdote. I love that story :-) Uncle Timmy's style is both clever and pointed. Raymond From data.2 at rediff.com Fri Jan 28 21:49:52 2011 From: data.2 at rediff.com (gaurav) Date: Fri, 28 Jan 2011 18:49:52 -0800 (PST) Subject: Employments Chance in Management work. Message-ID: <5208ea30-6106-4b0f-b81d-266acd379567@r19g2000prm.googlegroups.com> The Greatest site to Start your own Work from Home earn start earning. http://rojgars1.webs.com/gov.htm http://rojgars.webs.com/bankingjobs.htm Great earning in Management careers. Sales and Management work. http://managementjobs.webs.com/pm.htm & http://topcareer.webs.com/humanresourcemgmt.htm From rustompmody at gmail.com Sat Jan 29 00:34:09 2011 From: rustompmody at gmail.com (rusi) Date: Fri, 28 Jan 2011 21:34:09 -0800 (PST) Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com> <9MB%o.14110$%64.6074@unlimited.newshosting.com> <4A48EDF6D7634F2E994661A457451E87@teddy> <753A4C5A6658470085804B13C80340F2@octavian> Message-ID: On Jan 27, 10:47?pm, Grant Edwards wrote: > So you're saying that you don't see any value in easing communication, > nor presumably in communication itself? A Goedel-ian meta-recursion problem here Grant: You want to communicate the need for communication to one who does not see the need/value of communication From rustompmody at gmail.com Sat Jan 29 02:50:39 2011 From: rustompmody at gmail.com (rusi) Date: Fri, 28 Jan 2011 23:50:39 -0800 (PST) Subject: Use the Source Luke References: <094f6fc5-7242-46c7-b454-4cb29d0c6ef9@q40g2000prh.googlegroups.com> <87tygs1v6g.fsf@benfinney.id.au> Message-ID: <029f2ce4-e0fb-4cbc-a857-6cc7aa0a26f6@r4g2000vbq.googlegroups.com> On Jan 29, 4:10?am, Ben Finney wrote: > Note that Raymond is speaking specifically in the context of free > software, where the license is by definition permitting free > redistribution of the source code. It is an obvious necessary condition that for code to be opened it should be open (source). However the necessary condition is not sufficient. > > I have a quibble with the framing: > > > The rest of the blame lies with installers. They all treat > > human-readable scripts like they were binaries and tuck the code away > > in a dark corner. Consider this example: The emacs source if compiled from source will give you help for each lisp or even builtin (C) function out of the box from inside emacs. However if you get the emacs package from debian/ubuntu you will get neither unless you install el files -- which is fine -- just install the el package. About the C sources? I dont believe that one can get that linkage from within apt; one just hast to compile oneself. (I would be happy to be surprised on this). Isn't this an instance of the problem that Raymond is talking of? [Personal note: Ive been a python user and teacher for nearly 10 years and would eagerly welcome more easy code-open-ness] From homeinterwork at gmail.com Sat Jan 29 05:26:34 2011 From: homeinterwork at gmail.com (Ravi chandran) Date: Sat, 29 Jan 2011 02:26:34 -0800 (PST) Subject: Earn $2 Per Click For Free Join Make Money Message-ID: <1d737afa-386d-41f4-a0e8-d353ae79b433@t8g2000vbd.googlegroups.com> www.workfrominter.com From tobiasblass at gmx.net Sat Jan 29 06:10:27 2011 From: tobiasblass at gmx.net (Tobias Blass) Date: Sat, 29 Jan 2011 12:10:27 +0100 Subject: multiple values for keyword argument Message-ID: Hi all I'm just learning python and use it to write a GUI (with Tkinter) for a C program I already wrote. When trying to execute the program below I get the following error message. Traceback (most recent call last): File "./abirechner.py", line 64, in win =MainWin() File "./abirechner.py", line 43, in __init__ self.create_edit(row=i); TypeError: create_edit() got multiple values for keyword argument 'row' I don't really understand why create_edit gets multiple values, it gets one Integer after another (as I see it) Thanks for your help abirechner.py: # line 37 class MainWin(Frame): def __init__(self,master=None): Frame.__init__(self,master) self.grid() self.edits=() for i in range(10): self.create_edit(row=i); def create_edit(row,self): # LineEdit is defined, but I don't consider it important here self.edits+=LineEdit() self.edits[-1].grid(row=row,column=0) # ... #line 64 win = MainWin() win.mainLoop() From wingusr at gmail.com Sat Jan 29 06:22:48 2011 From: wingusr at gmail.com (TP) Date: Sat, 29 Jan 2011 03:22:48 -0800 Subject: Use the Source Luke In-Reply-To: <094f6fc5-7242-46c7-b454-4cb29d0c6ef9@q40g2000prh.googlegroups.com> References: <094f6fc5-7242-46c7-b454-4cb29d0c6ef9@q40g2000prh.googlegroups.com> Message-ID: On Fri, Jan 28, 2011 at 10:32 AM, Raymond Hettinger wrote: > I hoping a new trend will start with dev's putting direct > source code links in their documentation: > > ?http://rhettinger.wordpress.com/2011/01/28/open-your-source-more/ > > I'm looking for more examples of projects that routinely > link their docs back into relavant sections of code. > Have any of you all seen other examples besides > the Go language docs and the Python docs? > > > Raymond > -- > http://mail.python.org/mailman/listinfo/python-list > The Sphinx Python Documentation Generator (http://sphinx.pocoo.org/index.html), used for documenting lots of things other than Python, has an extension called "sphinx.ext.viewcode ? Add links to highlighted source code" (http://sphinx.pocoo.org/ext/viewcode.html). You can see my use of it here on a small PyQt project: http://tpgit.github.com/MDIImageViewer/imageviewer.html. You can even view the Sphinx documentation "code" by clicking the "Show Source" link on the left. -- TP From bieffe62 at gmail.com Sat Jan 29 06:24:06 2011 From: bieffe62 at gmail.com (Francesco Bochicchio) Date: Sat, 29 Jan 2011 03:24:06 -0800 (PST) Subject: multiple values for keyword argument References: Message-ID: <9f669337-6116-4442-9c7e-54b0051e33a2@8g2000prb.googlegroups.com> On 29 Gen, 12:10, Tobias Blass wrote: > Hi all > I'm just learning python and use it to write a GUI (with Tkinter) for a C > program I already wrote. When trying to execute the program below I get the > following error message. > > Traceback (most recent call last): > ? File "./abirechner.py", line 64, in > ? ? ? win =MainWin() > ? File "./abirechner.py", line 43, in __init__ > ? ? ? self.create_edit(row=i); > TypeError: create_edit() got multiple values for keyword argument 'row' > > I don't really understand why create_edit gets multiple values, it gets one > Integer after another (as I see it) > Thanks for your help > > abirechner.py: > > # line 37 > class MainWin(Frame): > ? ? ? ? def __init__(self,master=None): > ? ? ? ? ? ? ? ? Frame.__init__(self,master) > ? ? ? ? ? ? ? ? self.grid() > ? ? ? ? ? ? ? ? self.edits=() > ? ? ? ? ? ? ? ? for i in range(10): > ? ? ? ? ? ? ? ? ? ? ? ? self.create_edit(row=i); > ? ? ? ? def create_edit(row,self): > ? ? ? ? ? ? ? ? # LineEdit is defined, but I don't consider it important here > ? ? ? ? ? ? ? ? self.edits+=LineEdit() > ? ? ? ? ? ? ? ? self.edits[-1].grid(row=row,column=0) > # ... > #line 64 > win = MainWin() > win.mainLoop() Try this: > def create_edit(self, row): Ciao --- FB From tobiasblass at gmx.net Sat Jan 29 08:18:30 2011 From: tobiasblass at gmx.net (Tobias Blass) Date: Sat, 29 Jan 2011 14:18:30 +0100 Subject: multiple values for keyword argument In-Reply-To: <9f669337-6116-4442-9c7e-54b0051e33a2@8g2000prb.googlegroups.com> References: <9f669337-6116-4442-9c7e-54b0051e33a2@8g2000prb.googlegroups.com> Message-ID: On Sat, 29 Jan 2011, Francesco Bochicchio wrote: >On 29 Gen, 12:10, Tobias Blass wrote: >> Hi all >> I'm just learning python and use it to write a GUI (with Tkinter) for a C >> program I already wrote. When trying to execute the program below I get the >> following error message. >> >> Traceback (most recent call last): >> ? File "./abirechner.py", line 64, in >> ? ? ? win =MainWin() >> ? File "./abirechner.py", line 43, in __init__ >> ? ? ? self.create_edit(row=i); >> TypeError: create_edit() got multiple values for keyword argument 'row' >> >> I don't really understand why create_edit gets multiple values, it gets one >> Integer after another (as I see it) >> Thanks for your help >> >> abirechner.py: >> >> # line 37 >> class MainWin(Frame): >> ? ? ? ? def __init__(self,master=None): >> ? ? ? ? ? ? ? ? Frame.__init__(self,master) >> ? ? ? ? ? ? ? ? self.grid() >> ? ? ? ? ? ? ? ? self.edits=() >> ? ? ? ? ? ? ? ? for i in range(10): >> ? ? ? ? ? ? ? ? ? ? ? ? self.create_edit(row=i); >> ? ? ? ? def create_edit(row,self): >> ? ? ? ? ? ? ? ? # LineEdit is defined, but I don't consider it important here >> ? ? ? ? ? ? ? ? self.edits+=LineEdit() >> ? ? ? ? ? ? ? ? self.edits[-1].grid(row=row,column=0) >> # ... >> #line 64 >> win = MainWin() >> win.mainLoop() > >Try this: > >> def create_edit(self, row): > >Ciao >--- >FB > Ok it works now. So the problem was that python requires 'self' to be the first parameter? From saranyamsamy at gmail.com Sat Jan 29 08:30:35 2011 From: saranyamsamy at gmail.com (success all) Date: Sat, 29 Jan 2011 05:30:35 -0800 (PST) Subject: EARN 1000 DOLLARS PER DAY - WITHOUT INVESTMENT Message-ID: http://USAforextradingonline.blogspot.com http://USAforextradingonline.blogspot.com http://USAforextradingonline.blogspot.com http://USAforextradingonline.blogspot.com http://USAforextradingonline.blogspot.com From Frank.Dierkes at googlemail.com Sat Jan 29 08:43:44 2011 From: Frank.Dierkes at googlemail.com (Frank Dierkes) Date: 29 Jan 2011 13:43:44 GMT Subject: multiple values for keyword argument References: <9f669337-6116-4442-9c7e-54b0051e33a2@8g2000prb.googlegroups.com> Message-ID: <8qijsgFgu1U1@mid.dfncis.de> On Sat, 29 Jan 2011 14:18:30 +0100, Tobias Blass wrote: > On Sat, 29 Jan 2011, Francesco Bochicchio wrote: > >>> class MainWin(Frame): >>> ? ? ? ? def create_edit(row,self): >>> def create_edit(self, row): >> >> >> > Ok it works now. So the problem was that python requires 'self' to be > the first parameter? If you define an instance method, the first parameter is always the instance passed to the method - regardless of the parameters name. In your case the instance was passed to the row parameter. Then again you wanted to pass i to it. That's why the exception was raised. If you just had typed self.create_edit(i), then row would have been the instance (*self*.create_edit(...)) and self would have been i. Naming the first parameter self is only a convention. It could be any other name, too. From __peter__ at web.de Sat Jan 29 08:54:08 2011 From: __peter__ at web.de (Peter Otten) Date: Sat, 29 Jan 2011 14:54:08 +0100 Subject: multiple values for keyword argument References: <9f669337-6116-4442-9c7e-54b0051e33a2@8g2000prb.googlegroups.com> Message-ID: Tobias Blass wrote: > > > On Sat, 29 Jan 2011, Francesco Bochicchio wrote: > >>On 29 Gen, 12:10, Tobias Blass wrote: >>> Hi all >>> I'm just learning python and use it to write a GUI (with Tkinter) for a >>> C program I already wrote. When trying to execute the program below I >>> get the following error message. >>> >>> Traceback (most recent call last): >>> File "./abirechner.py", line 64, in >>> win =MainWin() >>> File "./abirechner.py", line 43, in __init__ >>> self.create_edit(row=i); >>> TypeError: create_edit() got multiple values for keyword argument 'row' >>> >>> I don't really understand why create_edit gets multiple values, it gets >>> one Integer after another (as I see it) >>> Thanks for your help >>> class MainWin(Frame): >>> def create_edit(row,self): >>Try this: >>> def create_edit(self, row): > Ok it works now. So the problem was that python requires 'self' to be the > first parameter? When you invoke a method Python implicitly passes the instance as the first positional parameter to it, regardless of the name: >>> class A: ... s = "yadda" ... def yadda(but_i_dont_want_to_call_it_self): ... print but_i_dont_want_to_call_it_self.s ... >>> A().yadda() yadda You can provoke the same error with a function: >>> def f(a, b): ... pass ... >>> f(1, b=2) >>> f(a=1, b=2) >>> f(2, a=1) Traceback (most recent call last): File "", line 1, in TypeError: f() got multiple values for keyword argument 'a' You can think of argument binding as a two-step process. At first positionals are bound to the formal parameters in the order of appearance from left to right; then named arguments are bound to parameters with the same name. If a name is already catered by a positional argument (or a name doesn't occur at all and doesn't have a default value) you get an Exception. From roy at panix.com Sat Jan 29 09:03:28 2011 From: roy at panix.com (Roy Smith) Date: Sat, 29 Jan 2011 09:03:28 -0500 Subject: multiple values for keyword argument References: <9f669337-6116-4442-9c7e-54b0051e33a2@8g2000prb.googlegroups.com> <8qijsgFgu1U1@mid.dfncis.de> Message-ID: In article <8qijsgFgu1U1 at mid.dfncis.de>, Frank Dierkes wrote: > Naming the first parameter self is only a convention. It could be any > other name, too. But it shouldn't. The use of "self" is so universal that using anything else will just make your code more difficult for other people to understand. From h.goebel at crazy-compilers.com Sat Jan 29 09:27:26 2011 From: h.goebel at crazy-compilers.com (Hartmut Goebel) Date: Sat, 29 Jan 2011 15:27:26 +0100 Subject: [ANN] python-ghostscript 0.4 Message-ID: Announcing: python-ghostscript 0.4 A Python-Interface to the Ghostscript C-API using ctypes :Copyright: GNU Public License v3 (GPLv3) :Author: Hartmut Goebel :Homepage: http://bitbucket.org/htgoebel/python-ghostscript :Download: http://pypi.python.org/pypi/ghostscript `Ghostscript`__, is a well known interpreter for the PostScript language and for PDF. This package implements a interface to the Ghostscript C-API using `ctypes`__. Both a low-level and a pythonic, high-level interface are provided. __ http://www.ghostscript.com/ __ http://docs.python.org/library/ctypes.html This package is currently tested only under GNU/Linux. Please report whether it works in your environment, too. Thanks. Latest Changes ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * Fixed bug: typo in function call name ctypes.util.find_library * (Unix) No longer try to load a specific version (version 8) of libgs.so * Added low-level interface for set_stdio() plus wrappers for file handles * (win32) Improved search for best Ghostscript installation: Consider Aladdin and GNU Ghostscript, too; Check for existence of DLL found in registry; take highest version available. * Added win32 example-batch file for testing and other improvements/fixes on examples an documentation. Example ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Here is an example for how to use the high-level interface of `python-ghostscript`. This implements a very basic ps2pdf-tool:: import sys import ghostscript args = [ "ps2pdf", # actual value doesn't matter "-dNOPAUSE", "-dBATCH", "-dSAFER", "-sDEVICE=pdfwrite", "-sOutputFile=" + sys.argv[1], "-c", ".setpdfwrite", "-f", sys.argv[2] ] ghostscript.Ghostscript(*args) -- Regards Hartmut Goebel | Hartmut Goebel | h.goebel at crazy-compilers.com | | www.crazy-compilers.com | compilers which you thought are impossible | From ethan at stoneleaf.us Sat Jan 29 10:45:53 2011 From: ethan at stoneleaf.us (Ethan Furman) Date: Sat, 29 Jan 2011 07:45:53 -0800 Subject: multiple values for keyword argument In-Reply-To: References: <9f669337-6116-4442-9c7e-54b0051e33a2@8g2000prb.googlegroups.com> <8qijsgFgu1U1@mid.dfncis.de> Message-ID: <4D443631.3000502@stoneleaf.us> Roy Smith wrote: > In article <8qijsgFgu1U1 at mid.dfncis.de>, > Frank Dierkes wrote: > >> Naming the first parameter self is only a convention. It could be any >> other name, too. > > But it shouldn't. The use of "self" is so universal that using anything > else will just make your code more difficult for other people to > understand. Nevertheless, if you have a good reason to, go ahead. I, myself, use the spanish word 'yo' instead (less keystrokes, I hate 'self', and it amuses me); if I'm working with my numerical experiments I'll use 'n' or 'x'... although, when posting sample code to c.l.py I do try to use 'self' to avoid possible confusion. :) ~Ethan~ From tobiasblass at gmx.net Sat Jan 29 11:11:43 2011 From: tobiasblass at gmx.net (Tobias Blass) Date: Sat, 29 Jan 2011 17:11:43 +0100 Subject: multiple values for keyword argument In-Reply-To: References: <9f669337-6116-4442-9c7e-54b0051e33a2@8g2000prb.googlegroups.com> Message-ID: On Sat, 29 Jan 2011, Peter Otten wrote: >Tobias Blass wrote: > >> >> >> On Sat, 29 Jan 2011, Francesco Bochicchio wrote: >> >>>On 29 Gen, 12:10, Tobias Blass wrote: >>>> Hi all >>>> I'm just learning python and use it to write a GUI (with Tkinter) for a >>>> C program I already wrote. When trying to execute the program below I >>>> get the following error message. >>>> >>>> Traceback (most recent call last): >>>> File "./abirechner.py", line 64, in >>>> win =MainWin() >>>> File "./abirechner.py", line 43, in __init__ >>>> self.create_edit(row=i); >>>> TypeError: create_edit() got multiple values for keyword argument 'row' >>>> >>>> I don't really understand why create_edit gets multiple values, it gets >>>> one Integer after another (as I see it) >>>> Thanks for your help > >>>> class MainWin(Frame): >>>> def create_edit(row,self): > >>>Try this: >>>> def create_edit(self, row): > >> Ok it works now. So the problem was that python requires 'self' to be the >> first parameter? > >When you invoke a method Python implicitly passes the instance as the first >positional parameter to it, regardless of the name: > >>>> class A: >... s = "yadda" >... def yadda(but_i_dont_want_to_call_it_self): >... print but_i_dont_want_to_call_it_self.s >... >>>> A().yadda() >yadda > >You can provoke the same error with a function: > >>>> def f(a, b): >... pass >... >>>> f(1, b=2) >>>> f(a=1, b=2) >>>> f(2, a=1) >Traceback (most recent call last): > File "", line 1, in >TypeError: f() got multiple values for keyword argument 'a' > >You can think of argument binding as a two-step process. >At first positionals are bound to the formal parameters in the order of >appearance from left to right; then named arguments are bound to parameters >with the same name. If a name is already catered by a positional argument >(or a name doesn't occur at all and doesn't have a default value) you get an >Exception. > > Thanks for your replies, as soon as I knew that python always passes the object reference as first parameter everything was clear (It's just like argc and argv in C, you could also call argc fish and argv chips) From miki.tebeka at gmail.com Sat Jan 29 12:06:40 2011 From: miki.tebeka at gmail.com (Miki) Date: Sat, 29 Jan 2011 09:06:40 -0800 (PST) Subject: Use the Source Luke In-Reply-To: <094f6fc5-7242-46c7-b454-4cb29d0c6ef9@q40g2000prh.googlegroups.com> Message-ID: Clojure a "source" that shows the source of a function (doh!). It's probably easy to implement in Python with the inspect module. Sadly this won't work for built-ins. Clojure's irc clojurebot will answer "source " with a link to github that points to the first line of definition. From peterwfh2000 at gmail.com Sat Jan 29 13:03:50 2011 From: peterwfh2000 at gmail.com (PETER WONG F H (+971 50 8320722)) Date: Sat, 29 Jan 2011 10:03:50 -0800 (PST) Subject: Distress sale/JBR/1 Bed /AED790sqft / 15th floor/050-8320722 Message-ID: <6cf7d895-93bf-45f4-b637-f66a34f87636@k38g2000vbn.googlegroups.com> Distress sale/JBR/1 Bed /AED790sqft / 15th floor/050-8320722 JBR Lower Price AED790per/sqft 15th floor 1,465.90sqft(AED1,160,000.00) +Transfer Fee 2 % + Broker Fee 2% JBR Apartments Located near to Dubai Marina and lying in a beach front location comprises the area of JBR or Jumeirah Beach Residences*Features:* - Swimming Pool - Community - Hot Property - 24hr Door Man - Built-in Wardrobes - Central A/C - Walking distance to Beaches - Balcony The Best Peter Wong F.H ??? Mob ?? : +971 50 83 20 722 E-mail ?? : peterwfh2000 at gmail.com Group : http://groups.google.com/group/dubai-property-club/boxsubscribe?p=FixAddr&email&_referer From patty at cruzio.com Sat Jan 29 13:39:49 2011 From: patty at cruzio.com (patty at cruzio.com) Date: Sat, 29 Jan 2011 10:39:49 -0800 (PST) Subject: multiple values for keyword argument In-Reply-To: <4D443631.3000502@stoneleaf.us> References: <9f669337-6116-4442-9c7e-54b0051e33a2@8g2000prb.googlegroups.com> <8qijsgFgu1U1@mid.dfncis.de> <4D443631.3000502@stoneleaf.us> Message-ID: <6f1dd6fbbc04d2788b2b191e3e407887.squirrel@cruziomail.cruzio.com> > Roy Smith wrote: >> In article <8qijsgFgu1U1 at mid.dfncis.de>, >> Frank Dierkes wrote: >> >>> Naming the first parameter self is only a convention. It could be any >>> other name, too. >> >> But it shouldn't. The use of "self" is so universal that using anything >> else will just make your code more difficult for other people to >> understand. > > Nevertheless, if you have a good reason to, go ahead. > > I, myself, use the spanish word 'yo' instead (less keystrokes, I hate > 'self', and it amuses me); if I'm working with my numerical experiments > I'll use 'n' or 'x'... although, when posting sample code to c.l.py I do > try to use 'self' to avoid possible confusion. :) > > ~Ethan~ > -- > http://mail.python.org/mailman/listinfo/python-list I am glad you said this. I have been avoiding understanding this 'self', just accepting it :} For the time being, since my programs I am creating are for my own use, I think I will make my own names up, that are descriptive to me as the programmer, it's all going to be interpreted anyway. And the other email equating to C's argv, etc. - now I get it. Regards, Patty > > From aahz at pythoncraft.com Sat Jan 29 13:51:59 2011 From: aahz at pythoncraft.com (Aahz) Date: 29 Jan 2011 10:51:59 -0800 Subject: how to read the last line of a huge file??? References: Message-ID: In article , John O'Hagan wrote: > >file.seek takes an optional 'whence' argument which is 2 for the end, so you >can just work back from there till you hit the first newline that has anything >after it: > > >def lastline(filename): > offset = 0 > line = '' > with open(filename) as f: > while True: > offset -= 1 > f.seek(offset, 2) > nextline = f.next() > if nextline == '\n' and line.strip(): > return line > else: > line = nextline It's a Bad Idea to mix direct file operations with the iterator API. Use f.read() instead of f.next(). -- Aahz (aahz at pythoncraft.com) <*> http://www.pythoncraft.com/ "All problems in computer science can be solved by another level of indirection." --Butler Lampson From python.list at tim.thechases.com Sat Jan 29 14:13:37 2011 From: python.list at tim.thechases.com (Tim Chase) Date: Sat, 29 Jan 2011 13:13:37 -0600 Subject: how to read the last line of a huge file??? In-Reply-To: References: Message-ID: <4D4466E1.5040406@tim.thechases.com> On 01/26/2011 04:59 AM, Xavier Heruacles wrote: > I have do some log processing which is usually huge. The > length of each line is variable. How can I get the last line?? > Don't tell me to use readlines or something like linecache... I wrote a modestly tested version (including missing terminal-EOL, files with no newlines, and empty files) at http://www.mail-archive.com/python-list at python.org/msg226537.html which minimizes the number of seeks (reading chunks rather than seeking for every character as you work backwards). You might find it useful. -tkc From python at rcn.com Sat Jan 29 15:23:17 2011 From: python at rcn.com (Raymond Hettinger) Date: Sat, 29 Jan 2011 12:23:17 -0800 (PST) Subject: Use the Source Luke References: <094f6fc5-7242-46c7-b454-4cb29d0c6ef9@q40g2000prh.googlegroups.com> Message-ID: On Jan 29, 3:22?am, TP wrote: > On Fri, Jan 28, 2011 at 10:32 AM, Raymond Hettinger wrote: > > I hoping a new trend will start with dev's putting direct > > source code links in their documentation: > > > ?http://rhettinger.wordpress.com/2011/01/28/open-your-source-more/ > > > I'm looking for more examples of projects that routinely > > link their docs back into relavant sections of code. > > Have any of you all seen other examples besides > > the Go language docs and the Python docs? > > > Raymond > > -- > >http://mail.python.org/mailman/listinfo/python-list > > The Sphinx Python Documentation Generator > (http://sphinx.pocoo.org/index.html), used for documenting lots of > things other than Python, has an extension called "sphinx.ext.viewcode > ? Add links to highlighted source code" > (http://sphinx.pocoo.org/ext/viewcode.html). Thanks, I didn't know about that extension. To support my effort to add source links to the Python docs, Georg Brandl added a new directive :source: so that we could write :source:`Lib/heapq.py` and the set the prefix somewhere else (i.e. pointing at the py3k branch on subversion or on mercurial). Raymond From subhakolkata1234 at gmail.com Sat Jan 29 16:19:57 2011 From: subhakolkata1234 at gmail.com (joy99) Date: Sat, 29 Jan 2011 13:19:57 -0800 (PST) Subject: Looking for Remote Python Project Message-ID: <4d1ff594-925b-457e-be62-7e4ca32ae136@33g2000pru.googlegroups.com> Dear Room, I am a Python Programmer from India(New Delhi Region), and I worked for quite a long time in Bangalore. I have been working in Python for the last 4 years or so. I have successfully built around 15 projects in Python. I am looking for some remote Python Projects, which can be done from home. If any one knows of anything, I may be helpful enough. Best Regards, Subhabrata. From ben+python at benfinney.id.au Sat Jan 29 16:22:19 2011 From: ben+python at benfinney.id.au (Ben Finney) Date: Sun, 30 Jan 2011 08:22:19 +1100 Subject: Use the Source Luke References: <094f6fc5-7242-46c7-b454-4cb29d0c6ef9@q40g2000prh.googlegroups.com> <87tygs1v6g.fsf@benfinney.id.au> <029f2ce4-e0fb-4cbc-a857-6cc7aa0a26f6@r4g2000vbq.googlegroups.com> Message-ID: <87hbcr1k38.fsf@benfinney.id.au> rusi writes: > On Jan 29, 4:10?am, Ben Finney wrote: > > I have a quibble with the framing: > > > > > The rest of the blame lies with installers. They all treat > > > human-readable scripts like they were binaries and tuck the code > > > away in a dark corner. > > Consider this example: > The emacs source if compiled from source will give you help for each > lisp or even builtin (C) function out of the box from inside emacs. > However if you get the emacs package from debian/ubuntu you will get > neither unless you install el files -- which is fine -- just install > the el package. [?] That's an example of the point I made in what followed in my message you quoted. The description can be interpreted as accurate, but it's framed poorly. > Isn't this an instance of the problem that Raymond is talking of? The ?problem?, which I don't consider to be a problem per se, is one of OS-wide policy, not ?installers?. The policy is a matter of tradeoffs across the system, and isn't ?tucking the code away in a dark corner?. > [Personal note: Ive been a python user and teacher for nearly 10 > years and would eagerly welcome more easy code-open-ness] Agreed. -- \ ?When people believe that they have absolute knowledge, with no | `\ test in reality, this [the Auschwitz crematorium] is how they | _o__) behave.? ?Jacob Bronowski, _The Ascent of Man_, 1973 | Ben Finney From ben+python at benfinney.id.au Sat Jan 29 16:24:45 2011 From: ben+python at benfinney.id.au (Ben Finney) Date: Sun, 30 Jan 2011 08:24:45 +1100 Subject: multiple values for keyword argument References: <9f669337-6116-4442-9c7e-54b0051e33a2@8g2000prb.googlegroups.com> Message-ID: <87d3nf1jz6.fsf@benfinney.id.au> Tobias Blass writes: > Ok it works now. So the problem was that python requires 'self' to be > the first parameter? More accurately, the instance is passed as the first parameter, and Python doesn't care what you name it. (Your fellow programmers do care, though, so please stick to the ?self? convention despite this freedom.) -- \ ?The lift is being fixed for the day. During that time we | `\ regret that you will be unbearable.? ?hotel, Bucharest | _o__) | Ben Finney From ben+python at benfinney.id.au Sat Jan 29 16:29:44 2011 From: ben+python at benfinney.id.au (Ben Finney) Date: Sun, 30 Jan 2011 08:29:44 +1100 Subject: multiple values for keyword argument References: <9f669337-6116-4442-9c7e-54b0051e33a2@8g2000prb.googlegroups.com> <8qijsgFgu1U1@mid.dfncis.de> <4D443631.3000502@stoneleaf.us> Message-ID: <877hdn1jqv.fsf@benfinney.id.au> patty at cruzio.com writes: > > I, myself, use the spanish word 'yo' instead (less keystrokes, I > > hate 'self', and it amuses me); if I'm working with my numerical > > experiments I'll use 'n' or 'x'... although, when posting sample > > code to c.l.py I do try to use 'self' to avoid possible confusion. > > :) > > I am glad you said this. I have been avoiding understanding this > 'self', just accepting it :} For the time being, since my programs I > am creating are for my own use, I think I will make my own names up, > that are descriptive to me as the programmer, it's all going to be > interpreted anyway. Please consider that your code is written primarily for humans to read, and only incidentally for the machine to execute. (If it were primarily for the machine to execute and communication with humans was not an issue, you would be writing in machine code.) Consider that code written ?only for my own use? frequently becomes more widespread; and it's impossible to know at the time of writing it whether that will be the case. It's prudent to write all such code as though it were for public consumption. -- \ ?Generally speaking, the errors in religion are dangerous; | `\ those in philosophy only ridiculous.? ?David Hume, _A Treatise | _o__) of Human Nature_, 1739 | Ben Finney From ben+python at benfinney.id.au Sat Jan 29 16:49:01 2011 From: ben+python at benfinney.id.au (Ben Finney) Date: Sun, 30 Jan 2011 08:49:01 +1100 Subject: Looking for Remote Python Project References: <4d1ff594-925b-457e-be62-7e4ca32ae136@33g2000pru.googlegroups.com> Message-ID: <8739ob1iuq.fsf@benfinney.id.au> joy99 writes: > I am looking for some remote Python Projects, which can be done from > home. > > If any one knows of anything, I may be helpful enough. One of the best ways to begin contributing is to fix bugs and provide patches. For Python itself, see the Python bug tracker ; for other projects, see the project's site and browse its bug tracker. -- \ ?Please to bathe inside the tub.? ?hotel room, Japan | `\ | _o__) | Ben Finney From aahz at pythoncraft.com Sat Jan 29 16:53:36 2011 From: aahz at pythoncraft.com (Aahz) Date: 29 Jan 2011 13:53:36 -0800 Subject: apscheduler error References: <9699865b-a8be-4284-a347-58d875b491f6@n2g2000pre.googlegroups.com> Message-ID: In article , =?utf-8?Q?Alice_Bevan=E2=80=93McGregor?= wrote: > >A package of mine, TurboMail, suffers from the same threading issue if >used improperly; you enqueue e-mail, it starts a thread, then you >immediately exit. TM tries to work around the issue, but in most cases >that workaround does not work properly. (You get strange uncatchable >exceptions printed on stderr though AFIK the e-mail does get sent >correctly, your application may hang waiting for the thread pool to >drain if you have a "minimum thread count" option set.) Why not write an exit handler that converts your thread to daemon? (Or something like that.) -- Aahz (aahz at pythoncraft.com) <*> http://www.pythoncraft.com/ "All problems in computer science can be solved by another level of indirection." --Butler Lampson From ben+python at benfinney.id.au Sat Jan 29 18:12:47 2011 From: ben+python at benfinney.id.au (Ben Finney) Date: Sun, 30 Jan 2011 10:12:47 +1100 Subject: apscheduler error References: <9699865b-a8be-4284-a347-58d875b491f6@n2g2000pre.googlegroups.com> Message-ID: <87y663z4ls.fsf@benfinney.id.au> aahz at pythoncraft.com (Aahz) writes: > In article , > =?utf-8?Q?Alice_Bevan=E2=80=93McGregor?= wrote: > >A package of mine, TurboMail, suffers from the same threading issue > >if used improperly; you enqueue e-mail, it starts a thread, then you > >immediately exit. > > Why not write an exit handler that converts your thread to daemon? (Or > something like that.) For that purpose, I'll ask that you try the ?python-daemon? library . It's designed specifically for making the current process into a well-behaved Unix daemon. -- \ ?I knew things were changing when my Fraternity Brothers threw | `\ a guy out of the house for mocking me because I'm gay.? | _o__) ?postsecret.com, 2010-01-19 | Ben Finney From steve+comp.lang.python at pearwood.info Sat Jan 29 18:45:02 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 29 Jan 2011 23:45:02 GMT Subject: multiple values for keyword argument References: <9f669337-6116-4442-9c7e-54b0051e33a2@8g2000prb.googlegroups.com> <8qijsgFgu1U1@mid.dfncis.de> Message-ID: <4d44a67e$0$29993$c3e8da3$5496439d@news.astraweb.com> On Sat, 29 Jan 2011 09:03:28 -0500, Roy Smith wrote: > In article <8qijsgFgu1U1 at mid.dfncis.de>, > Frank Dierkes wrote: > >> Naming the first parameter self is only a convention. It could be any >> other name, too. > > But it shouldn't. The use of "self" is so universal that using anything > else will just make your code more difficult for other people to > understand. It's a strong convention, true, but for Python to prohibit names other than self would be a serious mistake. It would add complication to the parser, for no real benefit. Remember, there's nothing special about methods. They're just ordinary functions which happen to be passed an extra argument at runtime. Making it compulsory to call the first argument "self" would seriously cripple Python's usefulness in at least three cases. (1) Class methods receive the class, not the instance, and the convention is to call that first argument "cls". It would be confusing and misleading to call it "self". Similarly, I sometimes use a similar descriptor which combines the functionality of class methods and ordinary methods. Since neither "self" nor "cls" would be appropriate, I use the name "this" for the first argument: http://code.activestate.com/recipes/577030-dualmethod-descriptor/ Descriptors are a general protocol, so there may be other such technologies being used by people. (2) Sometimes people use functions inside a class namespace as an ordinary function, perhaps as a factory function, called at class creation time. Here is a toy example that automates the building of properties: class K(object): def build(name): # called at class creation time def getter(self): return getattr(self, "_" + name) def setter(self, value): setattr(self, "_" + name, value) return property(getter, setter) spam = build("spam") ham = build("ham") (3) Because methods are just a wrapper around an ordinary function, you can inject almost any function into a class at runtime. You don't know what the first argument of that function is called: >>> class K(object): ... def __init__(self, value='spam'): ... self.attr = value ... >>> def get_attr(obj): ... return obj.attr ... >>> k = K() >>> get_attr(k) 'spam' >>> >>> K.method = get_attr >>> k.method() 'spam' -- Steven From rustompmody at gmail.com Sat Jan 29 22:59:33 2011 From: rustompmody at gmail.com (rusi) Date: Sat, 29 Jan 2011 19:59:33 -0800 (PST) Subject: Use the Source Luke References: <094f6fc5-7242-46c7-b454-4cb29d0c6ef9@q40g2000prh.googlegroups.com> <87tygs1v6g.fsf@benfinney.id.au> <029f2ce4-e0fb-4cbc-a857-6cc7aa0a26f6@r4g2000vbq.googlegroups.com> <87hbcr1k38.fsf@benfinney.id.au> Message-ID: On Jan 30, 2:22?am, Ben Finney wrote: > > The ?problem?, which I don't consider to be a problem per se, is one of > OS-wide policy, not ?installers?. The policy is a matter of tradeoffs > across the system, and isn't ?tucking the code away in a dark corner?. Earlier mail: > If you want to blame anything for this (though I think it?s inaccurate > to frame it as a problem), the correct target of your accusation is the > fact that a filesystem path is the identifier for these modules that > will be used by programs to find them. I think this is a fairly accurate description of (one aspect of) the problem. If you dont see it as a problem how do you explain that google can search the World Wide Web better than we can search our individual hard disks? From steve+comp.lang.python at pearwood.info Sat Jan 29 23:21:36 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 30 Jan 2011 04:21:36 GMT Subject: Use the Source Luke References: <094f6fc5-7242-46c7-b454-4cb29d0c6ef9@q40g2000prh.googlegroups.com> <87tygs1v6g.fsf@benfinney.id.au> <029f2ce4-e0fb-4cbc-a857-6cc7aa0a26f6@r4g2000vbq.googlegroups.com> <87hbcr1k38.fsf@benfinney.id.au> Message-ID: <4d44e750$0$29970$c3e8da3$5496439d@news.astraweb.com> On Sat, 29 Jan 2011 19:59:33 -0800, rusi wrote: > On Jan 30, 2:22?am, Ben Finney wrote: >> >> The ?problem?, which I don't consider to be a problem per se, is one of >> OS-wide policy, not ?installers?. The policy is a matter of tradeoffs >> across the system, and isn't ?tucking the code away in a dark corner?. > > Earlier mail: > >> If you want to blame anything for this (though I think it?s inaccurate >> to frame it as a problem), the correct target of your accusation is the >> fact that a filesystem path is the identifier for these modules that >> will be used by programs to find them. > > I think this is a fairly accurate description of (one aspect of) the > problem. > If you dont see it as a problem how do you explain that google can > search the World Wide Web better than we can search our individual hard > disks? I fail to see any connection between the location that operating systems store files, and the ability of Google to index publicly available websites. It sounds to me like the equivalent of "If you don't think Python programmers are a problem, how do you explain that it takes me 45 minutes to drive to work in the morning but nearly an hour to drive home in the evening?" Google has approximately one million servers indexing the web, and they're willing to use hundreds of terabytes of disk space to store the indexes. My desktop is *one* PC with little free space, and I'd rather trade off time for storage, so I don't keep any indexes of file content on my system. If I *wanted* to index my files, I could do so, although in fairness I'm not aware of any Linux tools which do this -- I know of `locate`, which indexes file *names* but not content, and `grep`, which searches file content but doesn't index what it finds. On Windows and Mac, though, I believe there are standard utilities which will index file content if you allow them. So... Google can search the web better than we can search our local hard drives because Google has invested tens or hundreds of millions into building a world-class search engine, and we haven't. -- Steven From rantingrick at gmail.com Sat Jan 29 23:25:30 2011 From: rantingrick at gmail.com (rantingrick) Date: Sat, 29 Jan 2011 20:25:30 -0800 (PST) Subject: [pygame-bug] Pygame.cdrom bug Message-ID: <4cb7b9c0-ebd1-44a1-bfb2-8ac9193faea6@p11g2000vbq.googlegroups.com> Hello folks, Pygame --the best little 2d game engine in Pythoina-- is great for little 2d one off games and such (or so i've heard). I really don't do much 2d graphics but pygame has some other helpful modules so i downloded it about a year or so ago although i had not used it until today. I just wanted to be ready just incase the 2d bug bit me. So recently I wanted to do some cdrom automation for one of my Tkinter scripts and thought... Hey, i finally found a good use for that old pygame module! So with much anticipation i moseyed on over to my site-packages folder and dusted off the old pygame module and docs and i was coding away just happy as a clam. I had my initialization working well, my ejections were a breeze, and i even had some boolean testing functionality all wrapped up nicely. Boy was i on cloud nine! And just as i was finishing up the interface class with a "close" method i realized in horror... YOU CAN OPEN THE CD TRAY WITH PYGAME HOWEVER FOR SOME CRUEL AND UNJUST REASON YOU CANNOT CLOSE IT! WTF? Yes at this point i realized that without a method to close the cd tray my little module was useless. Sure i could drop into my OS functionality and close the cdtray by first setting up a device handle and calling a few underlying Windows functions however i am convinced that this basic functionality should be a part of any cdrom interface. Why would someone create such an interface and leave out such an important method? Surely this functionality must be available through the SDL API? What gives pygame developers? What gives? From benjamin.kaplan at case.edu Sat Jan 29 23:40:51 2011 From: benjamin.kaplan at case.edu (Benjamin Kaplan) Date: Sat, 29 Jan 2011 23:40:51 -0500 Subject: [pygame-bug] Pygame.cdrom bug In-Reply-To: <4cb7b9c0-ebd1-44a1-bfb2-8ac9193faea6@p11g2000vbq.googlegroups.com> References: <4cb7b9c0-ebd1-44a1-bfb2-8ac9193faea6@p11g2000vbq.googlegroups.com> Message-ID: On Sat, Jan 29, 2011 at 11:25 PM, rantingrick wrote: > > Hello folks, > > Pygame ?--the best little 2d game engine in Pythoina-- is great for > little 2d one off games and such (or so i've heard). I really don't do > much 2d graphics but pygame has some other helpful modules so i > downloded it about a year or so ago although i had not used it until > today. I just wanted to be ready just incase the 2d bug bit me. So > recently I wanted to do some cdrom automation for one of my Tkinter > scripts and thought... Hey, i finally found a good use for that old > pygame module! > > So with much anticipation i moseyed on over to my site-packages folder > and dusted off the old pygame module and docs and i was coding away > just happy as a clam. I had my initialization working well, my > ejections were a breeze, and i even had some boolean testing > functionality all wrapped up nicely. Boy was i on cloud nine! And just > as i was finishing up the interface class with a "close" method i > realized in horror... YOU CAN OPEN THE CD TRAY WITH PYGAME HOWEVER FOR > SOME CRUEL AND UNJUST REASON YOU CANNOT CLOSE IT! ?WTF? > > Yes at this point i realized that without a method to close the cd > tray my little module was useless. Sure i could drop into my OS > functionality and close the cdtray by first setting up a device handle > and calling a few underlying Windows functions however i am convinced > that this basic functionality should be a part of any cdrom interface. > Why would someone create such an interface and leave out such an > important method? Surely this functionality must be available through > the SDL API? What gives pygame developers? What gives? > > -- 1) That's a feature request (something isn't there that should be there), not a bug (something that doesn't follow documented behaviors) 2) If you have a feature request or bug for a 3rd party package, moaning about it here won't do anything. Try asking nicely either on the project's mailing list or on the project's bug tracker. http://www.pygame.org/wiki/patchesandbugs From rustompmody at gmail.com Sat Jan 29 23:50:20 2011 From: rustompmody at gmail.com (rusi) Date: Sat, 29 Jan 2011 20:50:20 -0800 (PST) Subject: Use the Source Luke References: <094f6fc5-7242-46c7-b454-4cb29d0c6ef9@q40g2000prh.googlegroups.com> <87tygs1v6g.fsf@benfinney.id.au> <029f2ce4-e0fb-4cbc-a857-6cc7aa0a26f6@r4g2000vbq.googlegroups.com> <87hbcr1k38.fsf@benfinney.id.au> <4d44e750$0$29970$c3e8da3$5496439d@news.astraweb.com> Message-ID: <6c2ca5e4-6abe-49d5-b53f-a1d7c93ac328@r4g2000prm.googlegroups.com> On Jan 30, 9:21?am, Steven D'Aprano wrote: > > > I think this is a fairly accurate description of (one aspect of) the > > problem. > > If you dont see it as a problem how do you explain that google can > > search the World Wide Web better than we can search our individual hard > > disks? > > I fail to see any connection between the location that operating systems > store files, and the ability of Google to index publicly available > websites. http://en.wikipedia.org/wiki/Content-addressable_storage#Content-addressed_vs._Location-addressed From python at rcn.com Sun Jan 30 00:17:10 2011 From: python at rcn.com (Raymond Hettinger) Date: Sat, 29 Jan 2011 21:17:10 -0800 (PST) Subject: Use the Source Luke References: <094f6fc5-7242-46c7-b454-4cb29d0c6ef9@q40g2000prh.googlegroups.com> <87tygs1v6g.fsf@benfinney.id.au> Message-ID: On Jan 28, 3:10?pm, Ben Finney wrote: > Raymond Hettinger writes: > > The rest of the blame lies with installers. They all treat > > human-readable scripts like they were binaries and tuck the code away > > in a dark corner. > > That?s hardly a ?blame? of installers. The modules are placed in such > locations because they need to be accessible in a hierarchy at a > location that is known to not conflict with anything else, and be > predictable for the Python interpreter on the system. Sure. Installers are just installing where they're supposed to. And good people have given a lot of thought to the preferred target directories. I'm just observing that the source files are often ending-up out-of-sight and out-of-mind so that fewer users ever see the source. It's not deep a problem -- it would only take a symlink to provide quick access. My thesis is that we can do even better than that by adding direct links from the docs to the relevant code with nice syntax highlighting. Raymond P.S. Making it easy to get to relevant source is only half of the solution. The remaining problem is cultural. Perhaps every project should have a recommended reading list. As a start, I think the following are instructive and make for a good read: http://svn.python.org/view/python/branches/py3k/Lib/ftplib.py?view=markup http://svn.python.org/view/python/branches/py3k/Lib/heapq.py?view=markup http://svn.python.org/view/python/branches/py3k/Lib/collections.py?view=markup http://svn.python.org/view/python/branches/py3k/Lib/queue.py?view=markup http://svn.python.org/view/python/branches/py3k/Lib/functools.py?view=markup From rantingrick at gmail.com Sun Jan 30 00:23:02 2011 From: rantingrick at gmail.com (rantingrick) Date: Sat, 29 Jan 2011 21:23:02 -0800 (PST) Subject: Python critique References: <21868b6d-ab01-402d-a9b3-ee1be39771b8@o4g2000yqd.googlegroups.com> <4d028748$0$1621$742ec2ed@news.sonic.net> <4d02b47b$0$30000$c3e8da3$5496439d@news.astraweb.com> Message-ID: <385c6758-56ba-4323-9e93-16c9bc9eb350@m7g2000vbq.googlegroups.com> On Dec 10 2010, 5:15?pm, Steven D'Aprano wrote: > n = 1 > [print(n) for n in (2,)] > print n Oh *thats* why we have print as a function! I always wanted to put print in a list cmp. :-) From rantingrick at gmail.com Sun Jan 30 00:24:59 2011 From: rantingrick at gmail.com (rantingrick) Date: Sat, 29 Jan 2011 21:24:59 -0800 (PST) Subject: Python critique References: <21868b6d-ab01-402d-a9b3-ee1be39771b8@o4g2000yqd.googlegroups.com><4d028748$0$1621$742ec2ed@news.sonic.net> <4d02b47b$0$30000$c3e8da3$5496439d@news.astraweb.com> <52430F724D9B40DFB856FCDD172C28C8@teddy> Message-ID: <0a9ea419-3838-4603-a92d-0e117dfe49ff@r4g2000vbq.googlegroups.com> On Dec 13 2010, 4:40?am, Jean-Michel Pichavant wrote: > It's more a demonstration that you can do it with python. > The reason is that Python developpers will not put themself in the > situation where they need to use a variable 'orange' line 32 and use the > same variable 'orange' line 33 to refer to something else. Yes and when a programmer does something like this he does not demonstrate *scope-y* problems, he demonstrates *dope-y* problems. :-) From ethan at stoneleaf.us Sun Jan 30 00:35:31 2011 From: ethan at stoneleaf.us (Ethan Furman) Date: Sat, 29 Jan 2011 21:35:31 -0800 Subject: multiple values for keyword argument In-Reply-To: <6f1dd6fbbc04d2788b2b191e3e407887.squirrel@cruziomail.cruzio.com> References: <9f669337-6116-4442-9c7e-54b0051e33a2@8g2000prb.googlegroups.com> <8qijsgFgu1U1@mid.dfncis.de> <4D443631.3000502@stoneleaf.us> <6f1dd6fbbc04d2788b2b191e3e407887.squirrel@cruziomail.cruzio.com> Message-ID: <4D44F8A3.6050207@stoneleaf.us> patty at cruzio.com wrote: >> I, myself, use the spanish word 'yo' instead (less keystrokes, I hate >> 'self', and it amuses me); if I'm working with my numerical experiments >> I'll use 'n' or 'x'... although, when posting sample code to c.l.py I do >> try to use 'self' to avoid possible confusion. :) > > I am glad you said this. I have been avoiding understanding this 'self', > just accepting it :} For the time being, since my programs I am creating > are for my own use, I think I will make my own names up, that are > descriptive to me as the programmer, it's all going to be interpreted > anyway. And the other email equating to C's argv, etc. - now I get it. Careful about the names you make-up -- to aid yourself and others you don't want to have dozen's of different names that all basically mean 'this instance that I'm currently working on'. ~Ethan~ From research at johnohagan.com Sun Jan 30 00:37:54 2011 From: research at johnohagan.com (John O'Hagan) Date: Sun, 30 Jan 2011 05:37:54 +0000 Subject: how to read the last line of a huge file??? In-Reply-To: References: Message-ID: <201101300537.55343.research@johnohagan.com> On Sat, 29 Jan 2011, Aahz wrote: > In article , > > John O'Hagan wrote: [...] > > > >def lastline(filename): > > offset = 0 > > line = '' > > with open(filename) as f: > > while True: > > offset -= 1 > > f.seek(offset, 2) > > nextline = f.next() > > if nextline == '\n' and line.strip(): > > return line > > else: > > line = nextline > > It's a Bad Idea to mix direct file operations with the iterator API. I didn't know that; from the docs on file objects: "As a consequence of using a read-ahead buffer, combining next() with other file methods (like readline()) does not work right. However, using seek() to reposition the file to an absolute position will flush the read-ahead buffer." You are right in general, but the second sentence is why I got away with it in this case. > Use f.read() instead of f.next(). Which actually ends up improving the code as well: def lastline(filename): offset = 0 with open(filename) as f: while 1: f.seek(offset, 2) if f.tell() == 0: return f.read().strip() line = f.read() if line.strip() and line[0] == '\n': return line.strip() offset -= 1 although Tim Chase's solution covers files with very long lines. John From subhakolkata1234 at gmail.com Sun Jan 30 01:30:21 2011 From: subhakolkata1234 at gmail.com (joy99) Date: Sat, 29 Jan 2011 22:30:21 -0800 (PST) Subject: Looking for Remote Python Project References: <4d1ff594-925b-457e-be62-7e4ca32ae136@33g2000pru.googlegroups.com> <8739ob1iuq.fsf@benfinney.id.au> Message-ID: On Jan 30, 2:49?am, Ben Finney wrote: > joy99 writes: > > I am looking for some remote Python Projects, which can be done from > > home. > > > If any one knows of anything, I may be helpful enough. > > One of the best ways to begin contributing is to fix bugs and provide > patches. For Python itself, see the Python bug tracker > ; for other projects, see the project's > site and browse its bug tracker. > > -- > ?\ ? ? ? ? ? ? ? ??Please to bathe inside the tub.? ?hotel room, Japan | > ? `\ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? | > _o__) ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?| > Ben Finney Thanks Ben for a nice reply and suggestion. This experience will surely be rewarding one. But do you know whether it would be a paying one, I am looking to be a freelancer. >From this room of expert Python programmers, developers I am trying to get nice suggestions. Wishing You a Happy Day Ahead, Best Regards, Subhabrata. From ben+python at benfinney.id.au Sun Jan 30 03:07:52 2011 From: ben+python at benfinney.id.au (Ben Finney) Date: Sun, 30 Jan 2011 19:07:52 +1100 Subject: Looking for Remote Python Project References: <4d1ff594-925b-457e-be62-7e4ca32ae136@33g2000pru.googlegroups.com> <8739ob1iuq.fsf@benfinney.id.au> Message-ID: <87sjwazuef.fsf@benfinney.id.au> joy99 writes: > But do you know whether it would be a paying one, I am looking to be a > freelancer. You might find the Python Job Board useful . -- \ ?Choose mnemonic identifiers. If you can't remember what | `\ mnemonic means, you've got a problem.? ?Larry Wall | _o__) | Ben Finney From steve+comp.lang.python at pearwood.info Sun Jan 30 03:53:06 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 30 Jan 2011 08:53:06 GMT Subject: Use the Source Luke References: <094f6fc5-7242-46c7-b454-4cb29d0c6ef9@q40g2000prh.googlegroups.com> <87tygs1v6g.fsf@benfinney.id.au> <029f2ce4-e0fb-4cbc-a857-6cc7aa0a26f6@r4g2000vbq.googlegroups.com> <87hbcr1k38.fsf@benfinney.id.au> <4d44e750$0$29970$c3e8da3$5496439d@news.astraweb.com> <6c2ca5e4-6abe-49d5-b53f-a1d7c93ac328@r4g2000prm.googlegroups.com> Message-ID: <4d4526f2$0$29965$c3e8da3$5496439d@news.astraweb.com> On Sat, 29 Jan 2011 20:50:20 -0800, rusi wrote: > On Jan 30, 9:21?am, Steven D'Aprano +comp.lang.pyt... at pearwood.info> wrote: >> >> > I think this is a fairly accurate description of (one aspect of) the >> > problem. >> > If you dont see it as a problem how do you explain that google can >> > search the World Wide Web better than we can search our individual >> > hard disks? >> >> I fail to see any connection between the location that operating >> systems store files, and the ability of Google to index publicly >> available websites. > > http://en.wikipedia.org/wiki/Content-addressable_storage#Content- addressed_vs._Location-addressed Nope, sorry, doesn't help. Both local files on your hard drive, and most remote websites on the Internet, are location addressed. Google indexes the content, but they don't provide content-addresses. Indeed, they *can't* do so (except, possibly, for content they control such as Google Books), since they can't prevent content owners from modifying either the location address or the content. And as I've mentioned, there are desktop utilities that index content for Windows and Macintosh. In fact, Google themselves offer a desktop app that does just that: http://desktop.google.com/features.html -- Steven From steve+comp.lang.python at pearwood.info Sun Jan 30 04:36:39 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 30 Jan 2011 09:36:39 GMT Subject: multiple values for keyword argument References: <9f669337-6116-4442-9c7e-54b0051e33a2@8g2000prb.googlegroups.com> <8qijsgFgu1U1@mid.dfncis.de> <4D443631.3000502@stoneleaf.us> Message-ID: <4d453127$0$29965$c3e8da3$5496439d@news.astraweb.com> On Sat, 29 Jan 2011 10:39:49 -0800, patty wrote: > I am glad you said this. I have been avoiding understanding this > 'self', just accepting it :} For the time being, since my programs I am > creating are for my own use, I think I will make my own names up, that > are descriptive to me as the programmer, it's all going to be > interpreted anyway. And the other email equating to C's argv, etc. - > now I get it. That's a shame, because `self` is actually very simple once you understand the basic principles of object-oriented programming. What names would you choose? Unless you're writing descriptors, or using class methods, both of which should be considered advanced usage (highly advanced for descriptors, moderately so for class methods), it's not like every method needs a different descriptive first argument. In English, "self", "this", "me" or "instance" would be good names. What else would you use? The idea of method syntax is that you start with an instance of some class: mystring = "hello world" # an instance of the str class In procedural languages like C or Pascal, you would call a function and give the string as an argument. Python supports this programming model, and uses it for built-ins like len: len(mystring) => returns 11 Object oriented programming uses a different syntax. Instead of function(instance) as above, we take the instance argument outside the brackets. For example: mystring.upper() # instead of upper(mystring) => returns "HELLO WORLD" If there are any extra arguments needed, they go inside the brackets as normal. So far, this is just a change of syntax. It's like saying "The cat of my brother's" vs. "my brother's cat" -- the meaning is the same, but the syntax differs. The real advantages of object oriented programming and methods come elsewhere (e.g. encapsulation and inheritance). [Aside: when I was learning this, the hardest part I found was remembering which things were functions, and which were methods. I kept writing (wrongly!) things like: "hello world".len() upper("hello world") Unfortunately there is no easy way to recognise what will be a function like len, and which are methods like upper. That will come with experience. Back to function/procedural syntax versus object oriented syntax... One difference, though, is when you write a method definition. Because the method you write starts off life as an ordinary function, you need to write it *as if* it were a function you call like len() above. Here's how you might write a method in a class: class MyClass: def method(self, extra): pass When you then call the method: instance = MyClass() instance.method("something extra") Python automatically changes the syntax for you, and passes two arguments to the function as if you did this: # pseudo-code set self = instance set extra = "something extra extract "method" from MyClass call method(self, extra) We call the first argument something like "self" because it will ALWAYS be the instance itself. Unlike a regular function, which can have anything passed as the first argument, and therefore you should give it a descriptive name, the method's first argument is provided automatically for you and will always be the instance you started with. I hope this helps. -- Steven From david at boddie.org.uk Sun Jan 30 08:19:35 2011 From: david at boddie.org.uk (David Boddie) Date: Sun, 30 Jan 2011 14:19:35 +0100 Subject: Use the Source Luke References: <094f6fc5-7242-46c7-b454-4cb29d0c6ef9@q40g2000prh.googlegroups.com> <87tygs1v6g.fsf@benfinney.id.au> <029f2ce4-e0fb-4cbc-a857-6cc7aa0a26f6@r4g2000vbq.googlegroups.com> <87hbcr1k38.fsf@benfinney.id.au> <4d44e750$0$29970$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Sunday 30 January 2011 05:21, Steven D'Aprano wrote: > If I *wanted* to index my files, I could do so, although in > fairness I'm not aware of any Linux tools which do this -- I know of > `locate`, which indexes file *names* but not content, and `grep`, which > searches file content but doesn't index what it finds. You might find this page useful: http://www.wikinfo.org/index.php/Comparison_of_desktop_search_software David From mail2bansi at gmail.com Sun Jan 30 08:31:26 2011 From: mail2bansi at gmail.com (bansi) Date: Sun, 30 Jan 2011 05:31:26 -0800 (PST) Subject: Is it possible to pass CSV Reader Object As Argument to another Python File ??? References: <2c35653e-3565-48c6-8939-b6b09b885e3f@d23g2000prj.googlegroups.com> <876b6c52-1a6d-4afa-83e9-fa987c9359a5@v31g2000pri.googlegroups.com> <87lj272vpo.fsf@benfinney.id.au> <430714cd-20b4-4a67-bd2d-54e8f0c44ad5@s18g2000vbe.googlegroups.com> <2c9f82cd-756b-4460-940b-31e2a866f24e@n36g2000pre.googlegroups.com> <933ce06c-7829-42b9-a96d-dc9582e8267b@u11g2000prk.googlegroups.com> Message-ID: <558dc540-a09d-4034-b29d-c77103a341eb@m27g2000prj.googlegroups.com> On Jan 28, 4:22?pm, Benjamin Kaplan wrote: > On Fri, Jan 28, 2011 at 3:42 PM, bansi wrote: > > On Jan 28, 1:52?pm, Benjamin Kaplan wrote: > >> On Fri, Jan 28, 2011 at 1:33 PM, bansi wrote: > >> > On Jan 28, 9:46?am, bansi wrote: > >> >> On Jan 26, 8:31?pm, MRAB wrote: > > >> >> > On 27/01/2011 00:57, bansi wrote: > > >> >> > > On Jan 26, 6:25 pm, Ethan Furman ?wrote: > >> >> > >> bansi wrote: > > >> >> > >> ? > ?First namelookupWrapper.py running under Python 2.6 accept arguments > >> >> > >> ? > ?from stdin and uses csv reader object to read it i.e. > >> >> > >> ? > ?r=csv.reader(sys.stdin) > > >> >> > >> ? > ?And then it has to pass csv reader object to another python script > >> >> > >> ? > ?namelookup.py running under Python 2.7 because it uses pyodbc to > >> >> > >> ? > ?connect to database and iterates thru reader object > > >> >> > >> Ben Finney wrote: > >> >> > >>> bansi ?writes: > > >> >> > >>>> Thanks Chris. Sorry for mis-communicating, the two python scripts are > >> >> > >>>> dependant in a way that namelookupWrapper.py needs to pass csv record > >> >> > >>>> object to another python script > > >> >> > >>> Why have you structured them that way, though? What constraint is > >> >> > >>> keeping you from doing the work in a single process, where the CSV > >> >> > >>> reader object can be shared? > > >> >> > >>>> If thats not possible then please let me know how to do the workaround > >> >> > >>>> i didnt understood the import thing and not sure if it helps in my > >> >> > >>>> case > > >> >> > >>> The problem as you've described it so far is best solved by having a > >> >> > >>> single process accessing the CSV reader object in memory. If that > >> >> > >>> doesn't suit your use case, you'll need to explain why not. > > >> >> > >> In other words, why can't you use Python 2.7 to accept input and > >> >> > >> generate a csv.reader? > > >> >> > >> ~Ethan~- Hide quoted text - > > >> >> > >> - Show quoted text - > > >> >> > > Ethan, > >> >> > > The python script takes the input from Splunk (http://www.splunk.com/ > >> >> > > base/Documentation/) which supports only Python 2.6 > >> >> > > So the real constraint is Splunk supports only Python 2.6 . > > >> >> > > As you know Python 2.6 doesnt support or doesnt have pyodbc install > >> >> > > for Windows ?64 bit OS > >> >> > > So i installed Python 2.7 and thereafter pyodbc install for Windows 64 > >> >> > > bit OS for Python 2.7 > > >> >> > Have you actually tried Splunk with Python 2.7? It might not work with > >> >> > versions which are earlier than Python 2.6, but that doesn't > >> >> > necessarily mean that it won't work with versions of Python 2 which are > >> >> > later than Python 2.6 (unless the documentation says that it must be > >> >> > Python 2.6).- Hide quoted text - > > >> >> > - Show quoted text - > > >> >> Splunk's latest version 4.1.6 doesn't support Python 2.7 > >> >> I tried the import trick but it didnt work because the real script > >> >> which runs under Python 2.7 has import pyodbc so it results in > >> >> following error > > >> >> c:\Splunk\etc\apps\search\bin>splunk cmd python namelookupWrapper.py > >> >> memberId memberName < memberInput.csv > >> >> Traceback (most recent call last): > >> >> ? File "namelookupWrapper.py", line 3, in > >> >> ? ? import namelookup > >> >> ? File "c:\Splunk\etc\apps\search\bin\namelookup.py", line 7, in > >> >> > >> >> ? ? import pyodbc > >> >> ImportError: DLL load failed: The specified module could not be found. > > >> >> Please let me know if i am missing something on import. If so please > >> >> provide me with an example- Hide quoted text - > > >> >> - Show quoted text - > > >> > Here are some more details from my earlier posting. Please click the > >> > below link > > >> >http://answers.splunk.com/questions/11145/its-getting-mysterious-to-m... > >> > -- > >> >http://mail.python.org/mailman/listinfo/python-list > > >> Have you tried downloading the source for PyODBC and compiling it > >> yourself? All you need to do is python setup.py install. My guess > >> would be that it works just fine on 64-bit Python 2.6, they just never > >> released a re-compiled version of it for that platform.- Hide quoted text - > > >> - Show quoted text - > > > Thanks Benjamin. Please point me to the website from where i can > > download pyodbc for Windows 64 bit OS under Python 2.6 and > > installation instructions > > -- > > You don't download it for 64-bit Windows with Python 2.6. You download > the source code from the website and make the Python 2.6, 64-bit > Windows version yourself. > > Download the source zip file and extract it. Then, open up the command > prompt and use the "cd" command to change directories to that source > folder. For instance, if the source code has been extracted to > C:\pyodbc-2.1.8\, you type in "cd C:\pyodbc-2.1.8" and press enter. > > After that, you just run the build script which is already in there: > > C:\Python26\python26.exe setup.py install > > You'll need to have Visual C++ 2008 (not 2010) installed for this to > work. You can get it for free fromhttp://www.microsoft.com/express/Downloads/if you don't already have > it. > > > > >http://mail.python.org/mailman/listinfo/python-list- Hide quoted text - > > - Show quoted text -- Hide quoted text - > > - Show quoted text - Thanks Benjamin. Wondering why i need to Visual C++ 2008 . What it has to do with Python? Isn't it possible to implement your suggestion without installing Visual C++ 2008 . From tim.wintle at teamrubber.com Sun Jan 30 09:47:50 2011 From: tim.wintle at teamrubber.com (Tim Wintle) Date: Sun, 30 Jan 2011 14:47:50 +0000 Subject: Use the Source Luke In-Reply-To: References: <094f6fc5-7242-46c7-b454-4cb29d0c6ef9@q40g2000prh.googlegroups.com> <87tygs1v6g.fsf@benfinney.id.au> Message-ID: <1296398870.6379.5.camel@tim-laptop> On Sat, 2011-01-29 at 21:17 -0800, Raymond Hettinger wrote: > My thesis is that we can do even better than that by adding > direct links from the docs to the relevant code with nice > syntax highlighting. +1 - I think the source links are very useful (and thanks for pushing them). However I think the biggest changes that have probably happened with python itself are: (1) More users for whom this is their first language. (2) CS courses / training not teaching C (or pointer-based languages). (2) is especially important IMO - under half of the python developers I have regularly worked with would feel comfortable reading C - so for the other half reading C source code probably isn't going to help them understand exactly what's going on (although in the long run it might help them a lot) Tim Wintle From rantingrick at gmail.com Sun Jan 30 11:42:46 2011 From: rantingrick at gmail.com (rantingrick) Date: Sun, 30 Jan 2011 08:42:46 -0800 (PST) Subject: Use the Source Luke References: <094f6fc5-7242-46c7-b454-4cb29d0c6ef9@q40g2000prh.googlegroups.com> <87tygs1v6g.fsf@benfinney.id.au> <029f2ce4-e0fb-4cbc-a857-6cc7aa0a26f6@r4g2000vbq.googlegroups.com> <87hbcr1k38.fsf@benfinney.id.au> <4d44e750$0$29970$c3e8da3$5496439d@news.astraweb.com> <6c2ca5e4-6abe-49d5-b53f-a1d7c93ac328@r4g2000prm.googlegroups.com> <4d4526f2$0$29965$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Jan 30, 2:53?am, Steven D'Aprano wrote: > In fact, Google > themselves offer a desktop app that does just that: > > http://desktop.google.com/features.html Yes, but at the expense of your privacy! How much private information is being sent back to Google plex an used to flash more click ads at you? Well i guess we could say, google does spam us, but at least we are more likely to be *slightly* interested in the spam. From rustompmody at gmail.com Sun Jan 30 11:50:45 2011 From: rustompmody at gmail.com (rusi) Date: Sun, 30 Jan 2011 08:50:45 -0800 (PST) Subject: Use the Source Luke References: <094f6fc5-7242-46c7-b454-4cb29d0c6ef9@q40g2000prh.googlegroups.com> <87tygs1v6g.fsf@benfinney.id.au> <029f2ce4-e0fb-4cbc-a857-6cc7aa0a26f6@r4g2000vbq.googlegroups.com> <87hbcr1k38.fsf@benfinney.id.au> <4d44e750$0$29970$c3e8da3$5496439d@news.astraweb.com> Message-ID: <3a0492dc-7bbf-4458-b0a5-217d4bb87f5a@d23g2000prj.googlegroups.com> On Jan 30, 6:19?pm, David Boddie wrote: > You might find this page useful: > > http://www.wikinfo.org/index.php/Comparison_of_desktop_search_software > > David Thanks for that link David I note particularly the disclaimer that it was removed from wikipedia [Like when censors stuff you know it deserves a second look ;-) ] From rustompmody at gmail.com Sun Jan 30 12:35:33 2011 From: rustompmody at gmail.com (rusi) Date: Sun, 30 Jan 2011 09:35:33 -0800 (PST) Subject: Is it possible to pass CSV Reader Object As Argument to another Python File ??? References: <2c35653e-3565-48c6-8939-b6b09b885e3f@d23g2000prj.googlegroups.com> <876b6c52-1a6d-4afa-83e9-fa987c9359a5@v31g2000pri.googlegroups.com> <87lj272vpo.fsf@benfinney.id.au> <430714cd-20b4-4a67-bd2d-54e8f0c44ad5@s18g2000vbe.googlegroups.com> <2c9f82cd-756b-4460-940b-31e2a866f24e@n36g2000pre.googlegroups.com> <933ce06c-7829-42b9-a96d-dc9582e8267b@u11g2000prk.googlegroups.com> <558dc540-a09d-4034-b29d-c77103a341eb@m27g2000prj.googlegroups.com> Message-ID: <9584e7d1-aa0f-4ec9-988a-5c3e803bdb48@m27g2000prj.googlegroups.com> On Jan 30, 6:31?pm, bansi wrote: > On Jan 28, 4:22?pm, Benjamin Kaplan wrote: > > > You'll need to have Visual C++ 2008 (not 2010) installed for this to > > work. You can get it for free fromhttp://www.microsoft.com/express/Downloads/if > > you don't already have it. > > > Thanks Benjamin. Wondering why i need to Visual C++ 2008 . What it has > to do with Python? > Isn't it possible to implement your suggestion without installing > Visual C++ 2008 . http://code.google.com/p/pyodbc/wiki/Building#Windows From rajendra4linux at gmail.com Sun Jan 30 12:45:34 2011 From: rajendra4linux at gmail.com (Rajendra prasad Gottipati) Date: Sun, 30 Jan 2011 09:45:34 -0800 Subject: how to modify axis tick values exponential value location in matplotlib Message-ID: Hi, I am plotting the graph for long values like(267838484) so that its printing the tick lables on axes as 2.6 , 2.8 and at the top its having a text like e07 something like this, I want to move the display location of this exponent (e07) as i am having trouble in having multiple y-axis as they are getting mixed in text. like (e07 is written on top of e08 of other axis) Can any one help me in getting this done? also i am having issue in getting tick lables of x-axis while plotting with pylab.plot_date. Regards Raja -------------- next part -------------- An HTML attachment was scrubbed... URL: From gerald.britton at gmail.com Sun Jan 30 12:51:20 2011 From: gerald.britton at gmail.com (Gerald Britton) Date: Sun, 30 Jan 2011 12:51:20 -0500 Subject: Style question: Nicknames for deeply nested objects Message-ID: Hi all, Today I was thinking about a problem I often encounter. ?Say that I have (seems I often do!) a deeply nested object, by which I mean object within object with object, etc. For example: ? ?x = some.deeply.nested.object.method(some.other.deeply.nested.object.value) Well, that's extreme but I've worked with code approaching that level of nested-ness. ?Now, consider two scenarios: 1. You need to call this thing many times with different arguments, so you wind up with: ? ?x = some.deeply.nested.object.method(some.other.deeply.nested.object.value1) ? ?y = some.deeply.nested.object.method(some.other.deeply.nested.object.value2) ? ?z = some.deeply.nested.object.method(some.other.deeply.nested.object.value3) 2. You call it inside a loop: ? ?for item in some_iterable: ? ? ? ?x = some.deeply.nested.object.method(some.other.deeply.nested.object.value) For one thing, I find the long lines unattractive at best and error-prone at worst, especially if I also have ? ?some.other.deeply.nested.object.method that I might confuse with the first. ?To make it look better I might do this: ? ?_o = some.deeply.nested.object ? ?_o.method(_o.value) which is fine, I suppose. Then, putting on my company hat, I remembered that, from VBA, you could do this: ? ?with some.deeply.nested.object ? ? ? ?.method(.value) ? ?end with I like the structure of this, since the subordinate block can be indented, which makes it stand out. ?Also, it avoids temporary variables. So, I was thinking of how to get close to this in Python. ?I came up with two approaches: 1. ? ?_o = some.deeply.nested.object ? ?if 1: ? ? ? ?_o.method(_o.value) The "if 1:" forces me to indent the subordinate code, which sets it apart from the surrounding code. Note that I cannot just indent because I feel like it since Python is persnickety about indentation. 2. for _o in [some.deeply.nested.object]: ? ? ? ?_o.method(_o.value) The "for..." sets up the iterator and forces me to indent the subordinate code. As an aside, approach 1 generates less byte-code since approach 2 sets up loop machinery which you don't really need in this case. I have a couple of questions: 1. If you had to choose between approaches 1 and 2, which one would you go for, and why? 2. What other techniques have you used in such a situation? -- Gerald Britton From rajendra4linux at gmail.com Sun Jan 30 12:55:14 2011 From: rajendra4linux at gmail.com (Rajendra prasad Gottipati) Date: Sun, 30 Jan 2011 09:55:14 -0800 Subject: how to modify axis tick values exponential value location in matplotlib In-Reply-To: References: Message-ID: it seems relevant to my issue. http://stackoverflow.com/questions/3677368/matplotlib-format-axis-offset-values-to-whole-numbers-or-specific-number On Sun, Jan 30, 2011 at 9:45 AM, Rajendra prasad Gottipati < rajendra4linux at gmail.com> wrote: > Hi, > > I am plotting the graph for long values like(267838484) so that its > printing the tick lables on axes as 2.6 , 2.8 and at the top its having a > text like e07 something like this, I want to move the display location of > this exponent (e07) as i am having trouble in having multiple y-axis as they > are getting mixed in text. like (e07 is written on top of e08 of other axis) > > Can any one help me in getting this done? also i am having issue in getting > tick lables of x-axis while plotting with pylab.plot_date. > > > Regards > Raja > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rantingrick at gmail.com Sun Jan 30 13:09:33 2011 From: rantingrick at gmail.com (rantingrick) Date: Sun, 30 Jan 2011 10:09:33 -0800 (PST) Subject: Style question: Nicknames for deeply nested objects References: Message-ID: On Jan 30, 11:51?am, Gerald Britton wrote: [...] > that I might confuse with the first. ?To make it look better I might do this: > > ? ?_o = some.deeply.nested.object > ? ?_o.method(_o.value) > > which is fine, I suppose. It is very fine. And you "supposed" correctly! > Then, putting on my company hat, I remembered that, from VBA, you could do this: > > ? ?with some.deeply.nested.object > ? ? ? ?.method(.value) > ? ?end with > > I like the structure of this, since the subordinate block can be > indented, which makes it stand out. ?Also, it avoids temporary > variables. Yes it is a good idea! Well forgetting the horrendous VBA syntax this is. I brought this up many moons back as a feature request: Local Blocks. Here is how a pythonic local block would look with this as localvar: localvar.do_something() > So, I was thinking of how to get close to this in Python. ?I came up > with two approaches: > > 1. > > ? ?_o = some.deeply.nested.object > ? ?if 1: > ? ? ? ?_o.method(_o.value) bad idea! > 2. > > ? ? for _o in [some.deeply.nested.object]: > ? ? ? ?_o.method(_o.value) even worse idea! > I have a couple of questions: > > 1. If you had to choose between approaches 1 and 2, which one would > you go for, and why? neither! Stick with the original. From roy at panix.com Sun Jan 30 13:15:05 2011 From: roy at panix.com (Roy Smith) Date: Sun, 30 Jan 2011 13:15:05 -0500 Subject: Style question: Nicknames for deeply nested objects References: Message-ID: In article , Gerald Britton wrote: > 1. You need to call this thing many times with different arguments, so > you wind up with: > > ? ?x = some.deeply.nested.object.method(some.other.deeply.nested.object.value1) > ? ?y = some.deeply.nested.object.method(some.other.deeply.nested.object.value2) > ? ?z = some.deeply.nested.object.method(some.other.deeply.nested.object.value3) I would probably turn that into: object = some.deeply.nested.object object.method(object.value1) object.method(object.value2) object.method(object.value3) i.e. make the temporary variable have the exact same name as the last component of the deeply nested thing you're trying to refactor. If the scope of use is small and the meaning is obvious from context, sometimes I'll shorten the name, i.e. obj = some.deeply.nested.object or even o = some.deeply.nested.object but I tend to avoid doing that. I'd rather be a little more verbose in preference to being a little more cryptic. From me+list/python at ixokai.io Sun Jan 30 13:23:08 2011 From: me+list/python at ixokai.io (Stephen Hansen) Date: Sun, 30 Jan 2011 10:23:08 -0800 Subject: Style question: Nicknames for deeply nested objects In-Reply-To: References: Message-ID: <4D45AC8C.7090309@ixokai.io> On 1/30/11 9:51 AM, Gerald Britton wrote: > 1. If you had to choose between approaches 1 and 2, which one would > you go for, and why? Neither. Ideally, I'd tweak the API around so the deeply nested structure isn't something I need to access regularly. But! If you can't do that, I'd do something like: --- start from contextlib import contextmanager class Item(object): pass deeply = Item() deeply.nested = Item() deeply.nested.thing = Item() @contextmanager def my(thing): yield thing with my(deeply.nested.thing) as o: o.hello = 1 print deeply.nested.thing.hello --- end That's a dummy context-manager which basically does nothing: it just "abuses" the context manager protocol to basically make a local variable and indent its usage. Its really just a run-around and slightly less efficient to do: > _o = some.deeply.nested.object > _o.method(_o.value) But with the whitespace added on. Personally, I'd usually just make a local variable and skip any tricks. -- Stephen Hansen ... Also: Ixokai ... Mail: me+list/python (AT) ixokai (DOT) io ... Blog: http://meh.ixokai.io/ -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 487 bytes Desc: OpenPGP digital signature URL: From rantingrick at gmail.com Sun Jan 30 13:35:37 2011 From: rantingrick at gmail.com (rantingrick) Date: Sun, 30 Jan 2011 10:35:37 -0800 (PST) Subject: Style question: Nicknames for deeply nested objects References: Message-ID: On Jan 30, 12:23?pm, Stephen Hansen wrote: > --- start > from contextlib import contextmanager > > class Item(object): pass > > deeply = Item() > deeply.nested = Item() > deeply.nested.thing = Item() > > @contextmanager > def my(thing): > ? ? yield thing > > with my(deeply.nested.thing) as o: > ? ? o.hello = 1 > > print deeply.nested.thing.hello > --- end Well congratulations Stephen, you win the obfuscation prize of the year! From me+list/python at ixokai.io Sun Jan 30 13:53:02 2011 From: me+list/python at ixokai.io (Stephen Hansen) Date: Sun, 30 Jan 2011 10:53:02 -0800 Subject: Style question: Nicknames for deeply nested objects In-Reply-To: References: Message-ID: <4D45B38E.4030305@ixokai.io> On 1/30/11 10:35 AM, rantingrick wrote: > Well congratulations Stephen, you win the obfuscation prize of the > year! Yes, On 1/30/11 10:09 AM, rantingrick wrote: > Here is how a pythonic local block would look > > with this as localvar: > localvar.do_something() verses with my(this) as localvar: localvar.do_something() Is dreadfully more, er, obfuscated. I mean someone would have to know what the 'my' function does to understand what's going on! OH MY GOD. How can someone be expected to understand what a function does! Be serious! You can't expect that of them. -- Stephen Hansen ... Also: Ixokai ... Mail: me+list/python (AT) ixokai (DOT) io ... Blog: http://meh.ixokai.io/ -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 487 bytes Desc: OpenPGP digital signature URL: From ahsanbagwan at gmail.com Sun Jan 30 14:26:00 2011 From: ahsanbagwan at gmail.com (sl33k_) Date: Sun, 30 Jan 2011 11:26:00 -0800 (PST) Subject: Understanding def foo(*args) Message-ID: <17945aea-21b6-45b5-9c09-e602143f755e@k4g2000pre.googlegroups.com> Hi, I am struggling to grasp this concept about def foo(*args). Also, what is def bar(*args, *kwargs)? Isnt it like self must be the first parameter to the method/function? If not what are the exceptions? Also, can the terms method and function be used interchangeably? TIA From ahsanbagwan at gmail.com Sun Jan 30 14:35:34 2011 From: ahsanbagwan at gmail.com (sl33k_) Date: Sun, 30 Jan 2011 11:35:34 -0800 (PST) Subject: Understanding def foo(*args) References: <17945aea-21b6-45b5-9c09-e602143f755e@k4g2000pre.googlegroups.com> Message-ID: Sorry that parameter is **kwargs. From rantingrick at gmail.com Sun Jan 30 14:35:42 2011 From: rantingrick at gmail.com (rantingrick) Date: Sun, 30 Jan 2011 11:35:42 -0800 (PST) Subject: Understanding def foo(*args) References: <17945aea-21b6-45b5-9c09-e602143f755e@k4g2000pre.googlegroups.com> Message-ID: <27289cb5-b624-47d5-9692-06e23a034e03@b8g2000vbi.googlegroups.com> On Jan 30, 1:26?pm, sl33k_ wrote: > Hi, > > I am struggling to grasp this concept about def foo(*args). Also, what > is def bar(*args, *kwargs)? FYI: the python intepretor is your friend! py> def foo(*args): print args py> foo(1) (1,) py> foo(1,2,3) (1, 2, 3) py> foo(1,[1,23], {'hat':'cat'}) (1, [1, 23], {'hat': 'cat'}) py> def bar(*args, **kw): print 'Args:', args print 'Kwds:', kw py> bar(1,2,3, hat='cat', spam='eggs') Args: (1, 2, 3) Kwds: {'hat': 'cat', 'spam': 'eggs'} > Isnt it like self must be the first parameter to the method/function? > If not what are the exceptions? Only *must* with methods! > Also, can the terms method and function be used interchangeably? Can the terms cars and truck be used interchangeably? From mwilson at the-wire.com Sun Jan 30 14:40:29 2011 From: mwilson at the-wire.com (Mel) Date: Sun, 30 Jan 2011 14:40:29 -0500 Subject: Understanding def foo(*args) References: <17945aea-21b6-45b5-9c09-e602143f755e@k4g2000pre.googlegroups.com> Message-ID: sl33k_ wrote: > Hi, > > I am struggling to grasp this concept about def foo(*args). Also, what > is def bar(*args, *kwargs)? > > Isnt it like self must be the first parameter to the method/function? > If not what are the exceptions? > > Also, can the terms method and function be used interchangeably? > > TIA Try def foo (*args): print 'foo args:', repr (args) foo (1, 2, 3, 4) def bar (*args, **kwargs): print 'bar args:', args print 'bar kwargs:', kwargs bar (1, 2, 3, 4) bar (1, 2, 3, baz=6, boz=None) Mel. From clp2 at rebertia.com Sun Jan 30 14:54:38 2011 From: clp2 at rebertia.com (Chris Rebert) Date: Sun, 30 Jan 2011 11:54:38 -0800 Subject: Understanding def foo(*args) In-Reply-To: <17945aea-21b6-45b5-9c09-e602143f755e@k4g2000pre.googlegroups.com> References: <17945aea-21b6-45b5-9c09-e602143f755e@k4g2000pre.googlegroups.com> Message-ID: On Sun, Jan 30, 2011 at 11:26 AM, sl33k_ wrote: > Hi, > > I am struggling to grasp this concept about def foo(*args). The interactive interpreter is your friend! Try experimenting with it next time! http://docs.python.org/tutorial/controlflow.html#arbitrary-argument-lists That `def` defines a variadic function; i.e. a function which takes an arbitrary number of positional arguments. `args` will be a tuple of all the positional arguments passed to the function: >>> def foo(*args): ... print args ... >>> foo(1) (1,) >>> foo(1,2) (1, 2) >>> foo(1,2,3) (1, 2, 3) If positional parameters precede the *-parameter, then they are required and the *-parameter will receive any additional arguments: >>> def qux(a, b, *args): ... print 'a is', a ... print 'b is', b ... print 'args is', args ... >>> qux(1) Traceback (most recent call last): File "", line 1, in TypeError: qux() takes at least 2 arguments (1 given) >>> qux(1, 2) a is 1 b is 2 args is () >>> qux(1, 2, 3) a is 1 b is 2 args is (3,) >>> qux(1, 2, 3, 4) a is 1 b is 2 args is (3, 4) > Also, what is def bar(*args, *kwargs)? You meant: def bar(*args, **kwargs) See http://docs.python.org/tutorial/controlflow.html#keyword-arguments Basically, the **-parameter is like the *-parameter, except for keyword arguments instead of positional arguments. > Also, can the terms method and function be used interchangeably? No. A method is function that is associated with an object (normally via a class) and takes this object as its first argument (typically named "self"). A function does not have any of these requirements. Thus, all method are functions, but the reverse is not true. (I'm ignoring complexities like classmethods and staticmethods for simplicity.) Cheers, Chris -- http://blog.rebertia.com From doomster at knuut.de Sun Jan 30 15:21:28 2011 From: doomster at knuut.de (Ulrich Eckhardt) Date: Sun, 30 Jan 2011 21:21:28 +0100 Subject: Understanding def foo(*args) References: <17945aea-21b6-45b5-9c09-e602143f755e@k4g2000pre.googlegroups.com> Message-ID: <8qlvibFhetU1@mid.uni-berlin.de> sl33k_ wrote: > Isnt it like self must be the first parameter to the method/function? "self" is just customary as first parameter to memberfunctions, the language itself doesn't impose this convention, as e.g. C++ does with its "this". > Also, can the terms method and function be used interchangeably? This distinction doesn't exist in Python. You can put a reference to a "free" function as attribute in an object. You can store a reference to a "bound" memberfunction outside the object and call it. Objects and classes here are much more flexible than in C++ or Java. Uli From hobson42 at gmail.com Sun Jan 30 15:44:10 2011 From: hobson42 at gmail.com (Ian) Date: Sun, 30 Jan 2011 20:44:10 +0000 Subject: Style question: Nicknames for deeply nested objects In-Reply-To: References: Message-ID: <4D45CD9A.10108@gmail.com> On 30/01/2011 17:51, Gerald Britton wrote: > Hi all, > > Today I was thinking about a problem I often encounter. Say that I > have (seems I often do!) a deeply nested object, by which I mean > object within object with object, etc. > > For example: > > x = some.deeply.nested.object.method(some.other.deeply.nested.object.value) > > Well, that's extreme but I've worked with code approaching that level > of nested-ness. Now, consider two scenarios: > > 1. You need to call this thing many times with different arguments, so > you wind up with: > > x = some.deeply.nested.object.method(some.other.deeply.nested.object.value1) > y = some.deeply.nested.object.method(some.other.deeply.nested.object.value2) > z = some.deeply.nested.object.method(some.other.deeply.nested.object.value3) > Neither. You should tell. Don't ask if you can avoid it. Compare... queen.getButter() and queen.dairymaid.alderney.getButter() see http://www.timelessteacherstuff.com/readerstheater/KingsBreakfast.pdf king doesn't care where or how the butter is brought. Neither should your code! What are you doing with value1, value2 and value3 when you have them anyway? Stuffing them 3 levels deep into something else? Stop writing procedural code, and write object oriented code instead! If you you make some tell deeply.nested.object about other.deeply.nested.object it can fetch its own values, but it might be better to have some tell other.deeply.nested.object about deeply.nested.object to it can issue the correct commands. Then you tell some to do Somthing by writing some.takeMeaningfullAction() and it all happens "under the covers". Regards Ian From hayesjdno3 at yahoo.com Sun Jan 30 15:44:44 2011 From: hayesjdno3 at yahoo.com (ecu_jon) Date: Sun, 30 Jan 2011 12:44:44 -0800 (PST) Subject: homedir, file copy Message-ID: hello, i am trying to work with windows homedirectory as a starting point for some kind of file copy command. i'm testing this on a win7 box so my home is c:\Users\jon\ here is the code snippet i am working on: import os homedir = os.path.expanduser('~') try: from win32com.shell import shellcon, shell homedir = shell.SHGetFolderPath(0, shellcon.CSIDL_APPDATA, 0, 0) except ImportError: homedir = os.path.expanduser("~") print homedir print os.listdir(homedir+"\\backup\\") homedir.replace("\\\\" , "\\") print homedir shutil.copy (homedir+"\\backup\\", homedir+"\\backup2\\") output looks like: C:\Users\jon ['test1.txt', 'test2.txt'] C:\Users\jon Traceback (most recent call last): File "D:\spring 11\capstone-project\date.py", line 43, in shutil.copy (homedir+"\\backup\\", homedir+"\\backup2\\") File "C:\Python27\lib\shutil.py", line 116, in copy copyfile(src, dst) File "C:\Python27\lib\shutil.py", line 81, in copyfile with open(src, 'rb') as fsrc: IOError: [Errno 2] No such file or directory: 'C:\\Users\\jon\\backup\ \' why is there still two \\ in the pathfor the copy command? From rt8396 at gmail.com Sun Jan 30 15:55:01 2011 From: rt8396 at gmail.com (r) Date: Sun, 30 Jan 2011 12:55:01 -0800 (PST) Subject: homedir, file copy References: Message-ID: <6a5e3d0b-4aff-4008-9400-6a8a78629eb1@o18g2000prh.googlegroups.com> On Jan 30, 2:44?pm, ecu_jon wrote: > shutil.copy (homedir+"\\backup\\", homedir+"\\backup2\\") TIP: Use os.path.join(x,y, z*) > why is there still two \\ in the pathfor the copy command? I always convert my paths to use a single '/' instead of '\\'. Just makes life that much easier! From clp2 at rebertia.com Sun Jan 30 15:59:04 2011 From: clp2 at rebertia.com (Chris Rebert) Date: Sun, 30 Jan 2011 12:59:04 -0800 Subject: homedir, file copy In-Reply-To: References: Message-ID: On Sun, Jan 30, 2011 at 12:44 PM, ecu_jon wrote: > hello, > i am trying to work with windows homedirectory as a starting point for > some kind of file copy command. i'm testing this on a win7 box so my > home is c:\Users\jon\ > here is the code snippet i am working on: > > import os > > homedir = os.path.expanduser('~') > try: > ? ?from win32com.shell import shellcon, shell > ? ?homedir = shell.SHGetFolderPath(0, shellcon.CSIDL_APPDATA, 0, 0) > > except ImportError: > ? ?homedir = os.path.expanduser("~") > print homedir > print os.listdir(homedir+"\\backup\\") > homedir.replace("\\\\" , "\\") > print homedir > shutil.copy (homedir+"\\backup\\", homedir+"\\backup2\\") > > > output looks like: > C:\Users\jon > ['test1.txt', 'test2.txt'] > C:\Users\jon > > Traceback (most recent call last): > ?File "D:\spring 11\capstone-project\date.py", line 43, in > ? ?shutil.copy (homedir+"\\backup\\", homedir+"\\backup2\\") > ?File "C:\Python27\lib\shutil.py", line 116, in copy > ? ?copyfile(src, dst) > ?File "C:\Python27\lib\shutil.py", line 81, in copyfile > ? ?with open(src, 'rb') as fsrc: > IOError: [Errno 2] No such file or directory: 'C:\\Users\\jon\\backup\ > \' > > > why is there still two \\ in the pathfor the copy command? There aren't. The error message is just showing the repr() of the string, which involves escaping any literal backslashes in it; note the quotes around the path in the error message. Details on repr(): http://docs.python.org/library/functions.html#repr By way of example: >>> x = raw_input() C:\foo\bar >>> print x C:\foo\bar >>> print repr(x) 'C:\\foo\\bar' >>> print('C:\\foo\\bar') C:\foo\bar Note that you can use forward slashes instead of backslashes in Windows paths in Python, thus avoiding this confusion altogether. Cheers, Chris -- http://blog.rebertia.com From rantingrick at gmail.com Sun Jan 30 16:13:20 2011 From: rantingrick at gmail.com (rantingrick) Date: Sun, 30 Jan 2011 13:13:20 -0800 (PST) Subject: Style question: Nicknames for deeply nested objects References: Message-ID: On Jan 30, 12:53?pm, Stephen Hansen wrote: > On 1/30/11 10:35 AM, rantingrick wrote: > > > Well congratulations Stephen, you win the obfuscation prize of the > > year! > > Yes, > > On 1/30/11 10:09 AM, rantingrick wrote: > > > Here is how a pythonic local block would look > > > with this as localvar: > > ? ? localvar.do_something() > > verses > > with my(this) as localvar: > ? ? localvar.do_something() > > Is dreadfully more, er, obfuscated. Absolutely! > I mean someone would have to know what the 'my' function does to > understand what's going on! Yes, and also how decorators word and generators work, and ... > OH MY GOD. How can someone be expected to understand what a function does! Yes, and also how decorators word and generators work, and ... > Be serious! You can't expect that of them. I don't. I don't expect anyone to write 10 lines of obfuscation code when just two will suffice. Maybe you should join the perl group as they would proud! From malaclypse2 at gmail.com Sun Jan 30 16:46:03 2011 From: malaclypse2 at gmail.com (Jerry Hill) Date: Sun, 30 Jan 2011 16:46:03 -0500 Subject: Style question: Nicknames for deeply nested objects In-Reply-To: References: Message-ID: > > I don't. I don't expect anyone to write 10 lines of obfuscation code > when just two will suffice. Maybe you should join the perl group as > they would proud! But Stephen's 10 lines of somewhat obscure code actually works, and your two lines of code doesn't. I know which one I would prefer. -- Jerry -------------- next part -------------- An HTML attachment was scrubbed... URL: From steve+comp.lang.python at pearwood.info Sun Jan 30 17:02:03 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 30 Jan 2011 22:02:03 GMT Subject: Style question: Nicknames for deeply nested objects References: Message-ID: <4d45dfda$0$29967$c3e8da3$5496439d@news.astraweb.com> On Sun, 30 Jan 2011 12:51:20 -0500, Gerald Britton wrote: > Hi all, > > Today I was thinking about a problem I often encounter. ?Say that I have > (seems I often do!) a deeply nested object, by which I mean object > within object with object, etc. > > For example: > > ? ?x = > ? ?some.deeply.nested.object.method (some.other.deeply.nested.object.value) > > Well, that's extreme but I've worked with code approaching that level of > nested-ness. Then you're probably living in a state of sin, programming-wise, and you should stop doing that! You are violating the Law of Demeter. One dot, good. Two, acceptable. Three is a code smell. Four is a code reek. The Law of Demeter (more of a guideline than a law, really) says: If you want to get your dog to walk, call the dog. Don't talk to its legs, it confuses the dog and doesn't get it anywhere. http://en.wikipedia.org/wiki/Law_of_Demeter Another analogy: if you have to pay the paperboy for delivering the newspaper, you don't let him reach into your pocket, take out your wallet, open the wallet, take out whatever money he feels like, and put the wallet back. http://www.ccs.neu.edu/research/demeter/demeter-method/LawOfDemeter/paper- boy/demeter.pdf Despite my comment above, the Law of Demeter is not *really* a dot- counting exercise, although that's a handy short-cut for detecting potential problems. It can also apply to other data structures. If you've every seen C or Pascal code where you have a pointer to a pointer to a pointer to a pointer to a pointer to a pointer to some data, you've seen a violation. Consider your example: some.other.deeply.nested.object.value This is very tightly coupled code: the caller, who knows about the object `some`, needs to know the internal details of not just `some` but also `other`, `deeply`, `nested`, and `object`. As a basic principle, this is poor design! Which would you rather deal with? car.start() car.ignition.turn(key).connect(car.starter(battery), car.spark_plug) In particular, using temporary variables merely disguises the problem: temp = some.other temp = temp.deeply.nested x = temp.object.value Even though you never use more than two dots, you still have tight coupling. The point of Demeter is not to save dots (they're a renewable resource) but to reduce tight coupling. -- Steven From ben+python at benfinney.id.au Sun Jan 30 17:08:23 2011 From: ben+python at benfinney.id.au (Ben Finney) Date: Mon, 31 Jan 2011 09:08:23 +1100 Subject: Understanding def foo(*args) References: <17945aea-21b6-45b5-9c09-e602143f755e@k4g2000pre.googlegroups.com> Message-ID: <87oc6yyrhk.fsf@benfinney.id.au> sl33k_ writes: > I am struggling to grasp this concept about def foo(*args). Also, what > is def bar(*args, *kwargs)? Please work through the Python Tutorial from start to finish , performing each exercise and experimenting with it until you understand. You will then have a good grounding in basics of the language like this. -- \ Lucifer: ?Just sign the Contract, sir, and the Piano is yours.? | `\ Ray: ?Sheesh! This is long! Mind if I sign it now and read it | _o__) later?? ?http://www.achewood.com/ | Ben Finney From hayesjdno3 at yahoo.com Sun Jan 30 18:13:01 2011 From: hayesjdno3 at yahoo.com (ecu_jon) Date: Sun, 30 Jan 2011 15:13:01 -0800 (PST) Subject: homedir, file copy References: <6a5e3d0b-4aff-4008-9400-6a8a78629eb1@o18g2000prh.googlegroups.com> Message-ID: On Jan 30, 3:55?pm, r wrote: > On Jan 30, 2:44?pm, ecu_jon wrote: > > > shutil.copy (homedir+"\\backup\\", homedir+"\\backup2\\") > > TIP: Use os.path.join(x,y, z*) > > > why is there still two \\ in the pathfor the copy command? > > I always convert my paths to use a single '/' instead of '\\'. Just > makes life that much easier! what does this mean? Use os.path.join(x,y, z*) what is the x,y,z? From clp2 at rebertia.com Sun Jan 30 18:23:28 2011 From: clp2 at rebertia.com (Chris Rebert) Date: Sun, 30 Jan 2011 15:23:28 -0800 Subject: homedir, file copy In-Reply-To: References: <6a5e3d0b-4aff-4008-9400-6a8a78629eb1@o18g2000prh.googlegroups.com> Message-ID: On Sun, Jan 30, 2011 at 3:13 PM, ecu_jon wrote: > On Jan 30, 3:55?pm, r wrote: >> On Jan 30, 2:44?pm, ecu_jon wrote: >> >> > shutil.copy (homedir+"\\backup\\", homedir+"\\backup2\\") >> >> TIP: Use os.path.join(x,y, z*) >> >> > why is there still two \\ in the pathfor the copy command? >> >> I always convert my paths to use a single '/' instead of '\\'. Just >> makes life that much easier! > > what does this mean? ?Use os.path.join(x,y, z*) > what is the x,y,z? See http://docs.python.org/library/os.path.html#os.path.join e.g. in your case: backupdir = os.path.join(homedir, "backup") Cheers, Chris From rantingrick at gmail.com Sun Jan 30 18:36:13 2011 From: rantingrick at gmail.com (rantingrick) Date: Sun, 30 Jan 2011 15:36:13 -0800 (PST) Subject: homedir, file copy References: <6a5e3d0b-4aff-4008-9400-6a8a78629eb1@o18g2000prh.googlegroups.com> Message-ID: <421cfc90-c1dc-4f3c-82ac-74b43212a128@k14g2000pre.googlegroups.com> On Jan 30, 5:13?pm, ecu_jon wrote: > what does this mean? ?Use os.path.join(x,y, z*) > what is the x,y,z? x,y, and z in this case are just generic variables. Consider x+y=10. x and y could both equal 5 or any number of combinations of two numbers who sum equals ten. Anyway see the link chris posted to the docs or fire up your python shell and try this... >>> import sys >>> sys.version_info (2, 6, 5, 'final', 0) # yours may be different! >>> folder = 'C:/some\\\\path/to/folder' >>> filename = 'somefile.txt' >>> import os >>> help(os.path.join) Help on function join in module ntpath: join(a, *p) Join two or more pathname components, inserting "\" as needed. If any component is an absolute path, all previous path components will be discarded. >>> os.path.join(folder, filename) 'C:/some\\\\path/to/folder\\somefile.txt' >>> help(os.path.normpath) Help on function normpath in module ntpath: normpath(path) Normalize path, eliminating double slashes, etc. >>> os.path.normpath(os.path.join(folder, filename)) 'C:\\some\\path\\to\\folder\\somefile.txt' psst: i know what you're thinking... and yes, python is very cool! From hayesjdno3 at yahoo.com Sun Jan 30 18:43:47 2011 From: hayesjdno3 at yahoo.com (ecu_jon) Date: Sun, 30 Jan 2011 15:43:47 -0800 (PST) Subject: homedir, file copy References: <6a5e3d0b-4aff-4008-9400-6a8a78629eb1@o18g2000prh.googlegroups.com> Message-ID: <46bc3145-5df4-4146-b861-a9ac98722a99@q7g2000vbd.googlegroups.com> ok now i get permission denied.... import os homedir = os.path.expanduser('~') try: from win32com.shell import shellcon, shell homedir = shell.SHGetFolderPath(0, shellcon.CSIDL_APPDATA, 0, 0) except ImportError: homedir = os.path.expanduser("~") print homedir print os.listdir(homedir+"\\backup\\") #homedir.replace("\\\\" , "\\") #print homedir backupdir1 = os.path.join(homedir, "backup") backupdir2 = os.path.join(homedir, "backup2") shutil.copy (backupdir1, backupdir2) From rantingrick at gmail.com Sun Jan 30 18:50:09 2011 From: rantingrick at gmail.com (rantingrick) Date: Sun, 30 Jan 2011 15:50:09 -0800 (PST) Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com> <9MB%o.14110$%64.6074@unlimited.newshosting.com> <4A48EDF6D7634F2E994661A457451E87@teddy> <753A4C5A6658470085804B13C80340F2@octavian> <4D41B5AF.8020200@ixokai.io> <4D41BCC2.2060906@tysdomain.com> Message-ID: <5229651a-f240-4d43-87c4-63e49b23e6e5@y3g2000vbh.googlegroups.com> On Jan 28, 9:15?am, "Littlefield, Tyler" wrote: > > If you want to rant and scream about accessibility, yell at the > people charging an arm and a leg to make things accessible. > You make a good point as we could always use more opensource, free, and reasonably priced software. However unless the GUI library in question supports accessibility, it really won't matter how much the tool costs if you cannot use it! Consider if automobiles were free however gasoline was obsolete. -- rr: spreading common sense like an incurable virus. From python at mrabarnett.plus.com Sun Jan 30 19:09:10 2011 From: python at mrabarnett.plus.com (MRAB) Date: Mon, 31 Jan 2011 00:09:10 +0000 Subject: homedir, file copy In-Reply-To: <46bc3145-5df4-4146-b861-a9ac98722a99@q7g2000vbd.googlegroups.com> References: <6a5e3d0b-4aff-4008-9400-6a8a78629eb1@o18g2000prh.googlegroups.com> <46bc3145-5df4-4146-b861-a9ac98722a99@q7g2000vbd.googlegroups.com> Message-ID: <4D45FDA6.2060401@mrabarnett.plus.com> On 30/01/2011 23:43, ecu_jon wrote: > ok now i get permission denied.... > > import os > homedir = os.path.expanduser('~') > try: > from win32com.shell import shellcon, shell > homedir = shell.SHGetFolderPath(0, shellcon.CSIDL_APPDATA, 0, 0) > > except ImportError: > homedir = os.path.expanduser("~") > print homedir > print os.listdir(homedir+"\\backup\\") > #homedir.replace("\\\\" , "\\") > #print homedir > backupdir1 = os.path.join(homedir, "backup") > backupdir2 = os.path.join(homedir, "backup2") > shutil.copy (backupdir1, backupdir2) > shutil.copy(...) copies files, not directories. You should use shutil.copytree(...) instead. From hayesjdno3 at yahoo.com Sun Jan 30 19:18:52 2011 From: hayesjdno3 at yahoo.com (ecu_jon) Date: Sun, 30 Jan 2011 16:18:52 -0800 (PST) Subject: homedir, file copy References: <6a5e3d0b-4aff-4008-9400-6a8a78629eb1@o18g2000prh.googlegroups.com> <46bc3145-5df4-4146-b861-a9ac98722a99@q7g2000vbd.googlegroups.com> Message-ID: <400ab1ce-8f15-4708-b3de-408bc0765940@i40g2000yqh.googlegroups.com> On Jan 30, 7:09?pm, MRAB wrote: > On 30/01/2011 23:43, ecu_jon wrote: > > > ok now i get permission denied.... > > > import os > > homedir = os.path.expanduser('~') > > try: > > ? ? ?from win32com.shell import shellcon, shell > > ? ? ?homedir = shell.SHGetFolderPath(0, shellcon.CSIDL_APPDATA, 0, 0) > > > except ImportError: > > ? ? ?homedir = os.path.expanduser("~") > > print homedir > > print os.listdir(homedir+"\\backup\\") > > #homedir.replace("\\\\" , "\\") > > #print homedir > > backupdir1 = os.path.join(homedir, "backup") > > backupdir2 = os.path.join(homedir, "backup2") > > shutil.copy (backupdir1, backupdir2) > > shutil.copy(...) copies files, not directories. You should use > shutil.copytree(...) instead. i will, closer towards the end. just wanted to get past the naming stuff, the problem above. right now i just want to see it move files from 1 place to another. i had copytree in before, and will go back to that for final version. im working on a backup program, and copytree looks yummy. still no idea why getting permission denied. From davea at ieee.org Sun Jan 30 19:19:51 2011 From: davea at ieee.org (Dave Angel) Date: Sun, 30 Jan 2011 19:19:51 -0500 Subject: homedir, file copy In-Reply-To: <46bc3145-5df4-4146-b861-a9ac98722a99@q7g2000vbd.googlegroups.com> References: <6a5e3d0b-4aff-4008-9400-6a8a78629eb1@o18g2000prh.googlegroups.com> <46bc3145-5df4-4146-b861-a9ac98722a99@q7g2000vbd.googlegroups.com> Message-ID: <4D460027.1030208@ieee.org> On 01/-10/-28163 02:59 PM, ecu_jon wrote: > ok now i get permission denied.... > > import os > homedir = os.path.expanduser('~') > try: > from win32com.shell import shellcon, shell > homedir = shell.SHGetFolderPath(0, shellcon.CSIDL_APPDATA, 0, 0) > > except ImportError: > homedir = os.path.expanduser("~") > print homedir > print os.listdir(homedir+"\\backup\\") > #homedir.replace("\\\\" , "\\") > #print homedir > backupdir1 = os.path.join(homedir, "backup") > backupdir2 = os.path.join(homedir, "backup2") > shutil.copy (backupdir1, backupdir2) > You forgot to include the error traceback. So, is homedir/backup a file, or is it a directory? If you're trying to copy whole directories, you might want to look at copytree instead. If you're not sure, you could use os.isfile() to check. If that's false, then shutil.copy() can't work. Similarly, if the destination is a readonly file, you'd get some error. DaveA From hayesjdno3 at yahoo.com Sun Jan 30 19:27:42 2011 From: hayesjdno3 at yahoo.com (ecu_jon) Date: Sun, 30 Jan 2011 16:27:42 -0800 (PST) Subject: homedir, file copy References: <6a5e3d0b-4aff-4008-9400-6a8a78629eb1@o18g2000prh.googlegroups.com> <46bc3145-5df4-4146-b861-a9ac98722a99@q7g2000vbd.googlegroups.com> Message-ID: <6aa5e10b-6fa8-45ec-89d5-d9bece804bde@c10g2000vbv.googlegroups.com> On Jan 30, 7:19?pm, Dave Angel wrote: > On 01/-10/-28163 02:59 PM, ecu_jon wrote: > > > ok now i get permission denied.... > > > import os > > homedir = os.path.expanduser('~') > > try: > > ? ? ?from win32com.shell import shellcon, shell > > ? ? ?homedir = shell.SHGetFolderPath(0, shellcon.CSIDL_APPDATA, 0, 0) > > > except ImportError: > > ? ? ?homedir = os.path.expanduser("~") > > print homedir > > print os.listdir(homedir+"\\backup\\") > > #homedir.replace("\\\\" , "\\") > > #print homedir > > backupdir1 = os.path.join(homedir, "backup") > > backupdir2 = os.path.join(homedir, "backup2") > > shutil.copy (backupdir1, backupdir2) > > You forgot to include the error traceback. > > So, is homedir/backup a file, or is it a directory? ?If you're trying to > copy whole directories, you might want to look at copytree instead. > > If you're not sure, you could use > ? ? ?os.isfile() > > to check. ?If that's false, then shutil.copy() can't work. ?Similarly, > if the destination is a readonly file, you'd get some error. > > DaveA today's date is : 30 week chosen is : 4 C:\Users\jon ['test1.txt', 'test2.txt'] Traceback (most recent call last): File "D:\spring 11\capstone-project\date.py", line 45, in shutil.copy (backupdir1, backupdir2) File "C:\Python27\lib\shutil.py", line 116, in copy copyfile(src, dst) File "C:\Python27\lib\shutil.py", line 81, in copyfile with open(src, 'rb') as fsrc: IOError: [Errno 13] Permission denied: 'C:\\Users\\jon\\backup' From nambo4jb at gmail.com Sun Jan 30 19:28:40 2011 From: nambo4jb at gmail.com (Cathy James) Date: Sun, 30 Jan 2011 18:28:40 -0600 Subject: MS Access table values as input into a formula in another table-need help!! Message-ID: Dear Python Community, Table1: Prop_codeR_Value GC 0.8 CI 0.6 LDR 0.4 HDR 0.6 TR 0.65 CR 0.35 Table 2: O_ID PROP_CODE AI TArea R_Value Pre_R_Value IR MER02006 LDR 38.19235 132.3178 0.4 0.115456 0.555143 MER02006 TR 20.78983 132.3178 0.65 0.102128 0.555143 MER02006 UO 1.850129 132.3178 0.25 0.003496 0.555143 MER03001 GC 16.565 137.592 0.8 0.096314 0.45027 Initially, I manually entered R_Value from table 1 into table 2 in order to later compute subsequent fields using Python. Now I?d like to make the process a bit more automatic. I would like to get R_Values for each Prop_Code from table 1 into table 2 so that I can use them in a Table2 computation later on. I was thinking maybe a putting table 1 into a dict then use those values in table 2, but I need help getting started. Just learning Python and dicts are still tricky for me. Please help me modify the code below so that i don't have to repeat the lines of code below for all values of Prop_Code: import arcpy,sys arcpy.env.workspace = "C:\\test\\DRAINAGE.mdb" Table1= "basins" Table2="CV_Table" cur = arcpy.UpdateCursor(table2, "[PROP_CODE] = 'LDR'") row = cur.next() # Perform the update and move to the next row as long as there are # rows left while row: row.R_Value = 0 #initialize field from nulls to zero values row.R_Value = 0.4 #INstead, I need to get this from Table 2 cur.updateRow(row) row = cur.next() # Delete the cursors to remove any data locks del row, cur THANKS!! -------------- next part -------------- An HTML attachment was scrubbed... URL: From rantingrick at gmail.com Sun Jan 30 19:34:20 2011 From: rantingrick at gmail.com (rantingrick) Date: Sun, 30 Jan 2011 16:34:20 -0800 (PST) Subject: homedir, file copy References: <6a5e3d0b-4aff-4008-9400-6a8a78629eb1@o18g2000prh.googlegroups.com> <46bc3145-5df4-4146-b861-a9ac98722a99@q7g2000vbd.googlegroups.com> Message-ID: <9f3075db-d984-4097-ba49-d4c82a689255@k18g2000vbq.googlegroups.com> On Jan 30, 5:43?pm, ecu_jon wrote: > ok now i get permission denied.... [...] > shutil.copy (backupdir1, backupdir2) I must stress the importance of proper testing before ever running code that manipulates files! So many things can go wrong. Of course you are just copying files here and not deleting them however you must always be in the habit of treating files like explosives. And frankly you're being quite nonchalant with this very naive approach to coding and complete lack of testing. When handling files always test, test, test. Never actually move, copy, or delete until you are *absolutely* sure no failures will occur. I will always do test runs that print out the action but DO NOT actually DO the action, like... Copying files: -- from: C:\\somefile1 to: C:\\blah\\somefile1 -- from: C:\\somefile2 to: C:\\blah\\somefile2 -- from: C:\\somefile3 to: C:\\blah\\somefile3 -- etc... Once my test runs are bug free i can try to move or delete *one* file from some test set. Once that is bug free then i will try the code on many files of a test set, and ONLY THEN on the real thing. I guarantee if you keep manipulating files in such a haphazard way you will live to regret it! From hayesjdno3 at yahoo.com Sun Jan 30 19:43:10 2011 From: hayesjdno3 at yahoo.com (ecu_jon) Date: Sun, 30 Jan 2011 16:43:10 -0800 (PST) Subject: homedir, file copy References: <6a5e3d0b-4aff-4008-9400-6a8a78629eb1@o18g2000prh.googlegroups.com> <46bc3145-5df4-4146-b861-a9ac98722a99@q7g2000vbd.googlegroups.com> <9f3075db-d984-4097-ba49-d4c82a689255@k18g2000vbq.googlegroups.com> Message-ID: On Jan 30, 7:34?pm, rantingrick wrote: > On Jan 30, 5:43?pm, ecu_jon wrote: > > > ok now i get permission denied.... > > [...] > > > shutil.copy (backupdir1, backupdir2) > > I must stress the importance of proper testing before ever running > code that manipulates files! So many things can go wrong. Of course > you are just copying files here and not deleting them however you must > always be in the habit of treating files like explosives. And frankly > you're being quite nonchalant with this very naive approach to coding > and complete lack of testing. > > When handling files always test, test, test. Never actually move, > copy, or delete until you are *absolutely* sure no failures will > occur. I will always do test runs that print out the action but DO NOT > actually DO the action, like... > > Copying files: > ?-- from: C:\\somefile1 > ? ? ? to: C:\\blah\\somefile1 > ?-- from: C:\\somefile2 > ? ? ? to: C:\\blah\\somefile2 > ?-- from: C:\\somefile3 > ? ? ? to: C:\\blah\\somefile3 > ?-- etc... > > Once my test runs are bug free i can try to move or delete *one* file > from some test set. Once that is bug free then i will try the code on > many files of a test set, and ONLY THEN on the real thing. I guarantee > if you keep manipulating files in such a haphazard way you will live > to regret it! not nonchalant. i know i will ned to do testing and whatnot. just personally, i like to build stuff one concept at a time. for example, i had a problem with the homedir and peopel here helped me with that. now i have permissions problem, and an swer will likely meeerge. once i know how to copy a file, ill work on testing. like isfile and permissions. i know that has to be done. i guess its that you want tests before moves , and thats fine. since i have only ever had 1 python class, and basically learning this whole thing from scratch, i need to do things 1 step at a time. so now any thoughts on why i cannot write to my own homedir? From anikom15 at gmail.com Sun Jan 30 19:51:16 2011 From: anikom15 at gmail.com (Westley =?ISO-8859-1?Q?Mart=EDnez?=) Date: Sun, 30 Jan 2011 16:51:16 -0800 Subject: homedir, file copy In-Reply-To: References: <6a5e3d0b-4aff-4008-9400-6a8a78629eb1@o18g2000prh.googlegroups.com> <46bc3145-5df4-4146-b861-a9ac98722a99@q7g2000vbd.googlegroups.com> <9f3075db-d984-4097-ba49-d4c82a689255@k18g2000vbq.googlegroups.com> Message-ID: <1296435076.6394.6.camel@localhost.localdomain> It seems like you are trying to copy directories with shutil.copy. Use shutil.copytree instead. On Sun, 2011-01-30 at 16:43 -0800, ecu_jon wrote: > On Jan 30, 7:34 pm, rantingrick wrote: > > On Jan 30, 5:43 pm, ecu_jon wrote: > > > > > ok now i get permission denied.... > > > > [...] > > > > > shutil.copy (backupdir1, backupdir2) > > > > I must stress the importance of proper testing before ever running > > code that manipulates files! So many things can go wrong. Of course > > you are just copying files here and not deleting them however you must > > always be in the habit of treating files like explosives. And frankly > > you're being quite nonchalant with this very naive approach to coding > > and complete lack of testing. > > > > When handling files always test, test, test. Never actually move, > > copy, or delete until you are *absolutely* sure no failures will > > occur. I will always do test runs that print out the action but DO NOT > > actually DO the action, like... > > > > Copying files: > > -- from: C:\\somefile1 > > to: C:\\blah\\somefile1 > > -- from: C:\\somefile2 > > to: C:\\blah\\somefile2 > > -- from: C:\\somefile3 > > to: C:\\blah\\somefile3 > > -- etc... > > > > Once my test runs are bug free i can try to move or delete *one* file > > from some test set. Once that is bug free then i will try the code on > > many files of a test set, and ONLY THEN on the real thing. I guarantee > > if you keep manipulating files in such a haphazard way you will live > > to regret it! > > not nonchalant. > i know i will ned to do testing and whatnot. > just personally, i like to build stuff one concept at a time. > for example, i had a problem with the homedir and peopel here helped > me with that. > now i have permissions problem, and an swer will likely meeerge. > once i know how to copy a file, ill work on testing. like isfile and > permissions. > i know that has to be done. i guess its that you want tests before > moves , and thats fine. > since i have only ever had 1 python class, and basically learning this > whole thing from scratch, i need to do things 1 step at a time. > so now any thoughts on why i cannot write to my own homedir? -------------- next part -------------- An HTML attachment was scrubbed... URL: From python at mrabarnett.plus.com Sun Jan 30 20:25:43 2011 From: python at mrabarnett.plus.com (MRAB) Date: Mon, 31 Jan 2011 01:25:43 +0000 Subject: homedir, file copy In-Reply-To: <400ab1ce-8f15-4708-b3de-408bc0765940@i40g2000yqh.googlegroups.com> References: <6a5e3d0b-4aff-4008-9400-6a8a78629eb1@o18g2000prh.googlegroups.com> <46bc3145-5df4-4146-b861-a9ac98722a99@q7g2000vbd.googlegroups.com> <400ab1ce-8f15-4708-b3de-408bc0765940@i40g2000yqh.googlegroups.com> Message-ID: <4D460F97.60306@mrabarnett.plus.com> On 31/01/2011 00:18, ecu_jon wrote: > On Jan 30, 7:09 pm, MRAB wrote: >> On 30/01/2011 23:43, ecu_jon wrote: >> >>> ok now i get permission denied.... >> >>> import os >>> homedir = os.path.expanduser('~') >>> try: >>> from win32com.shell import shellcon, shell >>> homedir = shell.SHGetFolderPath(0, shellcon.CSIDL_APPDATA, 0, 0) >> >>> except ImportError: >>> homedir = os.path.expanduser("~") >>> print homedir >>> print os.listdir(homedir+"\\backup\\") >>> #homedir.replace("\\\\" , "\\") >>> #print homedir >>> backupdir1 = os.path.join(homedir, "backup") >>> backupdir2 = os.path.join(homedir, "backup2") >>> shutil.copy (backupdir1, backupdir2) >> >> shutil.copy(...) copies files, not directories. You should use >> shutil.copytree(...) instead. > > i will, closer towards the end. > just wanted to get past the naming stuff, the problem above. > right now i just want to see it move files from 1 place to another. > i had copytree in before, and will go back to that for final version. > im working on a backup program, and copytree looks yummy. > > still no idea why getting permission denied. The path given by backupdir1 is a directory, so you're trying to use shutil.copy(...) to copy a directory. The reason that it's complaining about permissions is that shutil.copy is trying to open the source file (look at the traceback) so that it can copy the file's contents, but it's not a file, it's a directory. CPython is written in C, so it's probably the underlying C library which is reporting it as a permissions problem instead of a "that's not a file!" problem. :-) From rustompmody at gmail.com Sun Jan 30 21:20:49 2011 From: rustompmody at gmail.com (rusi) Date: Sun, 30 Jan 2011 18:20:49 -0800 (PST) Subject: Is it possible to pass CSV Reader Object As Argument to another Python File ??? References: <2c35653e-3565-48c6-8939-b6b09b885e3f@d23g2000prj.googlegroups.com> <876b6c52-1a6d-4afa-83e9-fa987c9359a5@v31g2000pri.googlegroups.com> <87lj272vpo.fsf@benfinney.id.au> <430714cd-20b4-4a67-bd2d-54e8f0c44ad5@s18g2000vbe.googlegroups.com> <2c9f82cd-756b-4460-940b-31e2a866f24e@n36g2000pre.googlegroups.com> <933ce06c-7829-42b9-a96d-dc9582e8267b@u11g2000prk.googlegroups.com> <558dc540-a09d-4034-b29d-c77103a341eb@m27g2000prj.googlegroups.com> <9584e7d1-aa0f-4ec9-988a-5c3e803bdb48@m27g2000prj.googlegroups.com> Message-ID: On Jan 30, 10:35?pm, rusi wrote: > On Jan 30, 6:31?pm, bansi wrote: > > Isn't it possible to implement your suggestion without installing > > Visual C++ 2008 . > > http://code.google.com/p/pyodbc/wiki/Building#Windows Well... This is what the official site says... On second thoughts I wonder: Would it not be possible to compile python +pyodbc from source and use gcc/ming for that? Someone who knows more of the windows build process may say something about the issues involved. From hayesjdno3 at yahoo.com Sun Jan 30 21:41:54 2011 From: hayesjdno3 at yahoo.com (ecu_jon) Date: Sun, 30 Jan 2011 18:41:54 -0800 (PST) Subject: homedir, file copy References: <6a5e3d0b-4aff-4008-9400-6a8a78629eb1@o18g2000prh.googlegroups.com> <46bc3145-5df4-4146-b861-a9ac98722a99@q7g2000vbd.googlegroups.com> <400ab1ce-8f15-4708-b3de-408bc0765940@i40g2000yqh.googlegroups.com> Message-ID: <8b2ac4c3-e787-4e69-bc93-5793c4e85008@m13g2000yqb.googlegroups.com> On Jan 30, 8:25?pm, MRAB wrote: > On 31/01/2011 00:18, ecu_jon wrote: > > > > > On Jan 30, 7:09 pm, MRAB ?wrote: > >> On 30/01/2011 23:43, ecu_jon wrote: > > >>> ok now i get permission denied.... > > >>> import os > >>> homedir = os.path.expanduser('~') > >>> try: > >>> ? ? ? from win32com.shell import shellcon, shell > >>> ? ? ? homedir = shell.SHGetFolderPath(0, shellcon.CSIDL_APPDATA, 0, 0) > > >>> except ImportError: > >>> ? ? ? homedir = os.path.expanduser("~") > >>> print homedir > >>> print os.listdir(homedir+"\\backup\\") > >>> #homedir.replace("\\\\" , "\\") > >>> #print homedir > >>> backupdir1 = os.path.join(homedir, "backup") > >>> backupdir2 = os.path.join(homedir, "backup2") > >>> shutil.copy (backupdir1, backupdir2) > > >> shutil.copy(...) copies files, not directories. You should use > >> shutil.copytree(...) instead. > > > i will, closer towards the end. > > just wanted to get past the naming stuff, the problem above. > > right now i just want to see it move files from 1 place to another. > > i had copytree in before, and will go back to that for final version. > > im working on a backup program, and copytree looks yummy. > > > still no idea why getting permission denied. > > The path given by backupdir1 is a directory, so you're trying to use > shutil.copy(...) to copy a directory. > > The reason that it's complaining about permissions is that shutil.copy > is trying to open the source file (look at the traceback) so that it > can copy the file's contents, but it's not a file, it's a directory. > > CPython is written in C, so it's probably the underlying C library > which is reporting it as a permissions problem instead of a "that's not > a file!" problem. :-) as for testing i was planning on using something like this http://docs.python.org/library/shutil.html scroll down to 10.10.1.1 From s.sanadhya at gmail.com Sun Jan 30 21:43:29 2011 From: s.sanadhya at gmail.com (Shruti Sanadhya) Date: Sun, 30 Jan 2011 21:43:29 -0500 Subject: Limit on entries in dictionary data structure Message-ID: Hi, I am running a script that uses dictionaries on Python 2.6.4 on Ubuntu 9.10. I notice that my script crashes with a MemoryError when my dictionary reaches 44739243th entry. My system has 3GB RAM (32-bit). I noticed that changing the key or value types also did not help my code. For simplicity I tried running this: #BEGIN:python code import sys f={} lsize=0 try: for k in range(0,4*44739243): f[k]=k if sys.getsizeof(f) > lsize: lsize = sys.getsizeof(f) print k, lsize except: print k, lsize raise #END:python code The code terminates with: "Traceback (most recent call last): File "pydict-limit.py", line 6, in f[k]=k MemoryError" I have also tried running this on Ubuntu 9.10 with Python 2.6.6 with 3.5GB RAM(32-bit) and a 64-bit LINUX cluster machine with 62GB RAM and Python 2.4. On both these machines it crashed at entry 44739243. The size of the data structure grows to 1.5GB. On another 64-bit cluster machine with 32GB RAM and Python 2.6.6 it crashed at entry 178956970. In this case the size of the data structure grew to 6GB. Has anybody encountered this before? Can somebody suggest any fix for this? I am trying to read some 10GB network traces into a hash table(hence dictionary) and need constant time lookup. Clearly increasing the machine RAM does not work. Any suggestions would be greatly appreciated. Thanks, Shruti -------------- next part -------------- An HTML attachment was scrubbed... URL: From me+list/python at ixokai.io Sun Jan 30 21:53:03 2011 From: me+list/python at ixokai.io (Stephen Hansen) Date: Sun, 30 Jan 2011 18:53:03 -0800 Subject: Style question: Nicknames for deeply nested objects In-Reply-To: References: Message-ID: <4D46240F.20705@ixokai.io> On 1/30/11 1:13 PM, rantingrick wrote: > On Jan 30, 12:53 pm, Stephen Hansen wrote: >> OH MY GOD. How can someone be expected to understand what a function does! > > Yes, and also how decorators word and generators work, and ... > >> Be serious! You can't expect that of them. > > I don't. I don't expect anyone to write 10 lines of obfuscation code > when just two will suffice. Maybe you should join the perl group as > they would proud! Riiight. "suffice" doesn't mean what you think it means. Generally, if something suffices -- it actually, you know, ... works. My four lines of setup can get put into a library and treated as a recipe if they don't want to get into understanding generators or decorators: then its two lines to use, and those two lines are exactly like your two lines except for two little details: 1. They add a function call to the syntax. 2. They actually work. The OP doesn't have to understand decorators or generators if he doesn't want to: though I encourage him to do so, as they are beautiful and elegant tools that can very clearly and concisely help solve a lot of problems. Now, me? I wouldn't use the recipe, as I originally said in my response. I'd just use a local variable. But the OP didn't like that, and he wanted some indenting and whitespace to clearly demarcate where he intended to use the local. So I gave him a way to do that. You gave him... uh, what was it again? Oh, right. Nothing. As usual. -- Stephen Hansen ... Also: Ixokai ... Mail: me+list/python (AT) ixokai (DOT) io ... Blog: http://meh.ixokai.io/ -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 487 bytes Desc: OpenPGP digital signature URL: From davea at ieee.org Sun Jan 30 21:55:19 2011 From: davea at ieee.org (Dave Angel) Date: Sun, 30 Jan 2011 21:55:19 -0500 Subject: homedir, file copy In-Reply-To: <6aa5e10b-6fa8-45ec-89d5-d9bece804bde@c10g2000vbv.googlegroups.com> References: <6a5e3d0b-4aff-4008-9400-6a8a78629eb1@o18g2000prh.googlegroups.com> <46bc3145-5df4-4146-b861-a9ac98722a99@q7g2000vbd.googlegroups.com> <6aa5e10b-6fa8-45ec-89d5-d9bece804bde@c10g2000vbv.googlegroups.com> Message-ID: <4D462497.5020008@ieee.org> On 01/-10/-28163 02:59 PM, ecu_jon wrote: > On Jan 30, 7:19 pm, Dave Angel wrote: >> On 01/-10/-28163 02:59 PM, ecu_jon wrote: >> >>> ok now i get permission denied.... >> >>> import os >>> homedir =s.path.expanduser('~') >>> try: >>> from win32com.shell import shellcon, shell >>> homedir =hell.SHGetFolderPath(0, shellcon.CSIDL_APPDATA, 0, 0) >> >>> except ImportError: >>> homedir =s.path.expanduser("~") >>> print homedir >>> print os.listdir(homedir+"\\backup\\") >>> #homedir.replace("\\\\" , "\\") >>> #print homedir >>> backupdir1 =s.path.join(homedir, "backup") >>> backupdir2 =s.path.join(homedir, "backup2") >>> shutil.copy (backupdir1, backupdir2) >> >> You forgot to include the error traceback. >> >> So, is homedir/backup a file, or is it a directory? If you're trying to >> copy whole directories, you might want to look at copytree instead. >> >> If you're not sure, you could use >> os.isfile() >> >> to check. If that's false, then shutil.copy() can't work. Similarly, >> if the destination is a readonly file, you'd get some error. >> >> DaveA > > today's date is : 30 > week chosen is : 4 > C:\Users\jon > ['test1.txt', 'test2.txt'] > > Traceback (most recent call last): > File "D:\spring 11\capstone-project\date.py", line 45, in > shutil.copy (backupdir1, backupdir2) > File "C:\Python27\lib\shutil.py", line 116, in copy > copyfile(src, dst) > File "C:\Python27\lib\shutil.py", line 81, in copyfile > with open(src, 'rb') as fsrc: > IOError: [Errno 13] Permission denied: 'C:\\Users\\jon\\backup' > Good job, reading the first part of my message. Now, why are you saying in other messages that it can't write to your home directory? The error doesn't refer to your home directory, it refers to a file C:\Users\jon\backup which it can't read. But as your program demonstrates, that's a directory not a file. It's fine to use shutil.copy, but then you have to give it a source file to copy. For example, C:\Users\jon\backup\test1.txt DaveA From patty at cruzio.com Sun Jan 30 21:57:20 2011 From: patty at cruzio.com (Patty) Date: Sun, 30 Jan 2011 18:57:20 -0800 Subject: multiple values for keyword argument Message-ID: <91095C6A226E4A80A4721FD62828CD79@mycomputer> Well - this is all timely email. I just spent the day configuring my HP mini netbook running Windows 7 with all the right software based on recomendations from folks on this list, from the Python Tutor list and an email group of former colleagues where I spelled out exactly all the programming languages and stuff I ideally wanted. It has been very enlightening and actually not so difficult! Asking pays off! And I made a few realizations - I had some misperceptions about some software packages and -- I had been thinking about this 'self' business since yesterday. And you and Ethan and Ben Finney from yesterday (the last email msg I read last night, might know) are right -- I was being stubborn and wanting to do things *my* way and I was telling myself that when it comes time to do this for a future employer, well I will just change my code in the appropriate places to 'self' and will start using 'self' when I start working for them. And a little thought in the back of my head ... I wonder if the employer would be a little annoyed by that :) OK - I need my hand slapped sometimes and I see that you all are trying to prevent me from developing a bad habit. A few comments below: "Steven D'Aprano" wrote in message news:4d453127$0$29965$c3e8da3$5496439d at news.astraweb.com... > On Sat, 29 Jan 2011 10:39:49 -0800, patty wrote: > >> I am glad you said this. I have been avoiding understanding this >> 'self', just accepting it :} For the time being, since my programs I am >> creating are for my own use, I think I will make my own names up, that >> are descriptive to me as the programmer, it's all going to be >> interpreted anyway. And the other email equating to C's argv, etc. - >> now I get it. > > > That's a shame, because `self` is actually very simple once you > understand the basic principles of object-oriented programming. > > What names would you choose? Unless you're writing descriptors, or using > class methods, both of which should be considered advanced usage (highly > advanced for descriptors, moderately so for class methods), it's not like > every method needs a different descriptive first argument. In English, > "self", "this", "me" or "instance" would be good names. What else would > you use? That is the thing, I can get quite creative. I envisioned myself giving it a name something like 'instancecalledfrommain' probably scrunched up to 'instfrmmain' Weird descriptive names like that. I keep thinking of it as a variable, so I keep thinking of what it is used for underlying its name. Back to the I-can-do-anything-I-want mindset. I have saved the messages in this thread and other ones from the last month or so about 'self' so I think I will gather them together and read them more carefully including your very good explanations below. > > > The idea of method syntax is that you start with an instance of some > class: > > mystring = "hello world" # an instance of the str class > > In procedural languages like C or Pascal, you would call a function and > give the string as an argument. Python supports this programming model, > and uses it for built-ins like len: > > len(mystring) > => returns 11 > > And I am more comfortable in the C and Pascal worlds as a base so I see why I go this direction. > Object oriented programming uses a different syntax. Instead of > > function(instance) > > as above, we take the instance argument outside the brackets. For example: > > mystring.upper() # instead of upper(mystring) > => returns "HELLO WORLD" > > If there are any extra arguments needed, they go inside the brackets as > normal. > > So far, this is just a change of syntax. It's like saying "The cat of my > brother's" vs. "my brother's cat" -- the meaning is the same, but the > syntax differs. And I am a linguist so now you are Really talking ;) The real advantages of object oriented programming and > methods come elsewhere (e.g. encapsulation and inheritance). > > [Aside: when I was learning this, the hardest part I found was > remembering which things were functions, and which were methods. > I kept writing (wrongly!) things like: > > "hello world".len() > upper("hello world") > > Unfortunately there is no easy way to recognise what will be a > function like len, and which are methods like upper. That will > come with experience. Oh! I do this! I seem to use this syntax interchangably. I really need to memorize this carefully. > > Back to function/procedural syntax versus object oriented syntax... > > One difference, though, is when you write a method definition. Because > the method you write starts off life as an ordinary function, you need to > write it *as if* it were a function you call like len() above. Here's how > you might write a method in a class: > > class MyClass: > def method(self, extra): > pass > > When you then call the method: > > instance = MyClass() > instance.method("something extra") > > Python automatically changes the syntax for you, and passes two arguments > to the function as if you did this: > > # pseudo-code > set self = instance > set extra = "something extra > extract "method" from MyClass > call method(self, extra) > > We call the first argument something like "self" because it will ALWAYS > be the instance itself. Unlike a regular function, which can have > anything passed as the first argument, and therefore you should give it a > descriptive name, the method's first argument is provided automatically > for you and will always be the instance you started with. > > > > I hope this helps. Immensely > > > > > -- > Steven > -- > http://mail.python.org/mailman/listinfo/python-list > > Wow! Thanks so much! Patty -------------- next part -------------- An HTML attachment was scrubbed... URL: From rustompmody at gmail.com Sun Jan 30 22:07:47 2011 From: rustompmody at gmail.com (rusi) Date: Sun, 30 Jan 2011 19:07:47 -0800 (PST) Subject: Understanding def foo(*args) References: <17945aea-21b6-45b5-9c09-e602143f755e@k4g2000pre.googlegroups.com> <27289cb5-b624-47d5-9692-06e23a034e03@b8g2000vbi.googlegroups.com> Message-ID: On Jan 31, 12:35?am, rantingrick wrote: > > Also, can the terms method and function be used interchangeably? > > Can the terms cars and truck be used interchangeably? Oooff! A load of meaning in that one line -- I wonder though if the OP will understand... From stackslip at gmail.com Sun Jan 30 22:50:33 2011 From: stackslip at gmail.com (Garland Fulton) Date: Sun, 30 Jan 2011 18:50:33 -0900 Subject: Useing the processor clock, or get time in Femptoseconds Message-ID: Does anyone have any suggestions? -------------- next part -------------- An HTML attachment was scrubbed... URL: From python at mrabarnett.plus.com Sun Jan 30 22:52:12 2011 From: python at mrabarnett.plus.com (MRAB) Date: Mon, 31 Jan 2011 03:52:12 +0000 Subject: Limit on entries in dictionary data structure In-Reply-To: References: Message-ID: <4D4631EC.40905@mrabarnett.plus.com> On 31/01/2011 02:43, Shruti Sanadhya wrote: > Hi, > > I am running a script that uses dictionaries on Python 2.6.4 on Ubuntu > 9.10. I notice that my script crashes with a MemoryError when my > dictionary reaches 44739243th entry. My system has 3GB RAM (32-bit). I > noticed that changing the key or value types also did not help my code. > For simplicity I tried running this: > > #BEGIN:python code > import sys > f={} > lsize=0 > try: > for k in range(0,4*44739243): > f[k]=k > if sys.getsizeof(f) > lsize: > lsize = sys.getsizeof(f) > print k, lsize > except: > print k, lsize > raise > #END:python code > > The code terminates with: > "Traceback (most recent call last): > File "pydict-limit.py", line 6, in > f[k]=k > MemoryError" > > I have also tried running this on Ubuntu 9.10 with Python 2.6.6 with > 3.5GB RAM(32-bit) and a 64-bit LINUX cluster machine with 62GB RAM and > Python 2.4. On both these machines it crashed at entry 44739243. The > size of the data structure grows to 1.5GB. On another 64-bit cluster > machine with 32GB RAM and Python 2.6.6 it crashed at entry 178956970. In > this case the size of the data structure grew to 6GB. > > Has anybody encountered this before? Can somebody suggest any fix for > this? I am trying to read some 10GB network traces into a hash > table(hence dictionary) and need constant time lookup. Clearly > increasing the machine RAM does not work. Any suggestions would be > greatly appreciated. > sys.getsizeof(...) returns the size of an object itself, not the size of an object plus any others which that object references. The dict in your example code occupied 1.5GB, but that didn't include the size of the int keys and values, only the references to them. As for the 64-bit Linux cluster machine, did you run a 32-bit or a 64-bit build of Python? A 32-bit build can't use more than 4GB (2**32). From tyler at tysdomain.com Sun Jan 30 23:14:11 2011 From: tyler at tysdomain.com (Littlefield, Tyler) Date: Sun, 30 Jan 2011 21:14:11 -0700 Subject: Useing the processor clock, or get time in Femptoseconds In-Reply-To: References: Message-ID: <4D463713.8030805@tysdomain.com> If you are on windows, you can use high-resolution timers. What you are trying is physically impossible though: lets say you have a processor that runs at 2.5 GHz. that's 2.5 billion cycles per second, give or take a few. So, the lowest you can go is nanoseconds. You're trying to time like 10x the processor's actual speed, and you're not going to get timing that good. so, lower your bar a bit; the highest you will get is nanoseconds with high-res timers. (I'm not sure what the equivalent of this is on *nix, or whether or not python supports it on either platform. I think you'll end up making a DLL call, though I could be wrong). From wuwei23 at gmail.com Sun Jan 30 23:36:13 2011 From: wuwei23 at gmail.com (alex23) Date: Sun, 30 Jan 2011 20:36:13 -0800 (PST) Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com> <59F6E65E3D9A46AD8D7A3863F3C1DC84@teddy> <27f53f8c-7862-4366-9352-82ae9a2f3970@k3g2000yqc.googlegroups.com> <718D13777F254C839F9564BC4275DE0A@octavian> <4D402C42.1030407@tysdomain.com> <4D40447C.4010108@tysdomain.com> <33C68A0874BE4C66AB478EDFB64C2C1D@teddy> <4D407321.3090705@web.de> <1296128007.17192.1417506961@webmail.messagingengine.com> <8775C617C7B241759AC122A69955D42A@octavian> <349dc47a-5a16-47e9-8dea-0de3aa814b52@d1g2000yqb.googlegroups.com> Message-ID: <948029f2-962e-4389-9327-4ebbfdbef66b@z3g2000prz.googlegroups.com> rantingrick wrote: > To be honest, i would sacrifice all the functionality of > wxWidgets if we could get pyGUI into the stdlib. Why? Well because > pyGUI would be under OUR complete control. "You" would need to contribute something other than bullshit and vitriol in order to be able to use the word "our" in the way you do here. > *if* the community saw the potential that i see with pyGUI > and wanted to seriously do some development to bring it into 3.0 > compliance i'll bet Greg *would* be interested You can't even generate your _own_ code for this idea and yet you somehow mystically know how other people will respond? Have you _ever_ been even _close_ to being able to do this? You seem genuinely angry and shocked at times that we haven't embraced you as some kind of messianic firebrand, which doesn't really say a lot for your ability to gauge the responses & desires of others. Maybe Greg's not a complete egotist like yourself, needing the attention and constant fluffing you seem to demand before you'll even begin to consider coding. Maybe pyGUI as is scratches his itch, because rather than spending YEARS trying to offload work onto the community he just coded up what he needed to actually get something _done_, something other than masturbating over a library for its own sake. Maybe he has no interest in 3.x but has no concern with community submitted patches. A patch - I should probably explain for your sake, rick - is a diff of changes to a body of code allowing the project maintainer to integrate user submitted bug fixes and feature additions. Pretty much most project maintainers will accept them sans manifesto too. This isn't about getting your ego stroked. This isn't about which language's dick is the longest because it has its own GUI. This is about people with lives of their own making small contributions born of necessity culminating in the further growth & evolution of a useful piece of code. From drsalists at gmail.com Mon Jan 31 00:12:49 2011 From: drsalists at gmail.com (Dan Stromberg) Date: Sun, 30 Jan 2011 21:12:49 -0800 Subject: Limit on entries in dictionary data structure In-Reply-To: References: Message-ID: On Sun, Jan 30, 2011 at 6:43 PM, Shruti Sanadhya wrote: > Hi, > I am running a script that uses dictionaries on Python 2.6.4 on Ubuntu 9.10. > I notice that my script crashes with a MemoryError when my dictionary > reaches 44739243th entry. My system has 3GB RAM (32-bit). I noticed that > changing the key or value types also did not help my code. For simplicity I > tried running this: > #BEGIN:python code > import sys > f={} > lsize=0 > try: > ?? ?for k in range(0,4*44739243): > ?? ? ? ?f[k]=k > ?? ? ? ?if sys.getsizeof(f) > lsize: > ?? ? ? ? ? ?lsize = sys.getsizeof(f) > ?? ? ? ? ? ?print k, lsize > except: > ?? ?print k, lsize > ?? ?raise > #END:python code > The code terminates with: > "Traceback (most recent call last): > ??File "pydict-limit.py", line 6, in > ?? ?f[k]=k > MemoryError" > I have also tried running this on Ubuntu 9.10 with Python 2.6.6 with 3.5GB > RAM(32-bit) and a 64-bit LINUX cluster machine with 62GB RAM and Python 2.4. > On both these machines it crashed at entry 44739243. The size of the data > structure grows to 1.5GB. On another 64-bit cluster machine with 32GB RAM > and Python 2.6.6 it crashed at entry?178956970. In this case the size of the > data structure grew to 6GB. > Has anybody encountered this before? Can somebody suggest any fix for this? > I am trying to read some 10GB network traces into a hash table(hence > dictionary) and need constant time lookup. Clearly increasing the machine > RAM does not work. Any suggestions would be greatly appreciated. > Thanks, > Shruti If you need strict controls over how much memory is used, you might be better off with C or something. Or Cython would give you a Pythonic syntax with C's datastructures (as well as Python-style datastructures, but that gets back into memory unpredictability). On an Ubuntu system, you can probably "man hcreate" to get some info on a hash table accessible from C. If you need a huge "dictionary", then using something like gdbm or bsddb might be good, though I doubt these are constant time - they're more like single-table databases, where the keys and values must all be strings or serialized non-strings. However, they should be fine with huge dictionaries. They have the advantage of providing a pretty dictionary-like interface. This almost certainly would not bump into any memory limits, as they are disk-based. If you really do need to keep things in RAM (VM), you might try this module: http://stromberg.dnsalias.org/~strombrg/treap/ on one of your 64 bit systems, preferably with a recent cpython like 2.6 or 2.7 built with a 64 bit compiler. It too is not constant time, but it is O(c*log(n)) with a small c, at the expense of a higher standard deviation in write times compared to something like a red/black tree (better average performance though). This provides a very dictionary-like interface. It would implicitly store things sorted by key, incidentally, though that may be unimportant in your application. This may or may not have the same memory issues as the dictionary - and I'd be very interested in hearing whether they do or not. You might also be able to read everything into a big list, then sort it. Then use the bisect module to do log(n) time lookups. This does not give a dictionary-like interface or constant time, but it doesn't require anything outside of CPython's standard library. It may or may not have the same memory issues you were seeing with dictionaries. Here's something based on your code above, that works with the mentioned treap module. I found that it required about 1 gig for each 10% of the numbers the code was trying to save - on a 32 bit, Ubuntu 10.10 system. However, I have only 3 gig of RAM, so I terminated it before it got to a memory error: #!/usr/bin/python import sys import treap f = treap.treap() top = 4*44739243 try: for k in xrange(0, top): sys.stdout.write('%d %f%%\r' % (k, k * 100.0 / top)) f[k]=k print except: print raise From nagle at animats.com Mon Jan 31 00:13:14 2011 From: nagle at animats.com (John Nagle) Date: Sun, 30 Jan 2011 21:13:14 -0800 Subject: Useing the processor clock, or get time in Femptoseconds In-Reply-To: References: Message-ID: <4d4644f4$0$10557$742ec2ed@news.sonic.net> On 1/30/2011 8:14 PM, Littlefield, Tyler wrote: > If you are on windows, you can use high-resolution timers. What you are > trying is physically impossible though: lets say you have a processor > that runs at 2.5 GHz. that's 2.5 billion cycles per second, give or take > a few. So, the lowest you can go is nanoseconds. You're trying to time > like 10x the processor's actual speed, and you're not going to get > timing that good. so, lower your bar a bit; the highest you will get is > nanoseconds with high-res timers. (I'm not sure what the equivalent of > this is on *nix, or whether or not python supports it on either > platform. I think you'll end up making a DLL call, though I could be > wrong). On x86 CPUs since the Pentium, you can read the CPU's cycle counter, which is incrementing once for each clock cycle, maybe every 300ps or so on a current generation CPU. See "http://en.wikipedia.org/wiki/Time_Stamp_Counter" You do not want to do this. First, you're in Python, which is interpreted; picosecond level timing resolution is orders of magnitude finer than is meaningful at the Python source level. Second, on multiprocessors, each CPU has its own cycle clock, and they're not synchronized. Third, on superscalar CPUs, reading of the clock may occur out of order and be meaningless. In Python, just call "time.time()", which gets you a floating point number with about 1ms resolution. John Nagle From wuwei23 at gmail.com Mon Jan 31 00:39:50 2011 From: wuwei23 at gmail.com (alex23) Date: Sun, 30 Jan 2011 21:39:50 -0800 (PST) Subject: Bugs/issues in tkinter.simpledialog!! References: Message-ID: <2ae102e4-427f-4bbe-8c2e-4967c2cfb14d@i39g2000prd.googlegroups.com> rantingrick wrote: > Actually i see you point but there is a good reason behind me bringing > this up here. I want to bring to the attention of everyone how little > interest there is for Tkinter. Right. You have no interest in resolving this issue and instead want to use it as more ammunition in your ongoing crusade. You even have the gall to act _offended_ at Giampaolo's suggestion that you log the bug, dumping your usual bullshit and vitriol on someone WHO HAS ACTUALLY DONE THE SORT OF WORK YOU CONSTANTLY CLAIM YOU'RE GOING TO, even though your every intention was to parade this issue around as if it somehow validates your personal blend of crazy. You're a class act, that's for sure. > Agreed. However i would rather just write a patch, send it to some > email and be done. Or just commit the changes myself. This bug > tracker is just bureaucracy at it's worst. You are making this process > too hard and people are not going to get involved when they have to > jump through 20 hoops just to patch three lines of freaking code! Because complex distributed coding projects should be treated like Wikipedia? It must suck being such a genius and yet be unable to grapple with a simple bug tracker... From data.2 at rediff.com Mon Jan 31 04:33:29 2011 From: data.2 at rediff.com (gaurav) Date: Mon, 31 Jan 2011 01:33:29 -0800 (PST) Subject: Option in Management careers. Message-ID: <347de674-910f-4200-a5e3-5470910c000e@y31g2000prd.googlegroups.com> Rush for career in computer and government jobs potential revenue. http://rojgars1.webs.com/gov.htm http://rojgars.webs.com/bankingjobs.htm Huge chance in Management careers. Management careers for you. http://managementjobs.webs.com/pm.htm http://topcareer.webs.com/humanresourcemgmt.htm From simon at brunningonline.net Mon Jan 31 04:45:50 2011 From: simon at brunningonline.net (Simon Brunning) Date: Mon, 31 Jan 2011 09:45:50 +0000 Subject: multiple values for keyword argument In-Reply-To: <6f1dd6fbbc04d2788b2b191e3e407887.squirrel@cruziomail.cruzio.com> References: <9f669337-6116-4442-9c7e-54b0051e33a2@8g2000prb.googlegroups.com> <8qijsgFgu1U1@mid.dfncis.de> <4D443631.3000502@stoneleaf.us> <6f1dd6fbbc04d2788b2b191e3e407887.squirrel@cruziomail.cruzio.com> Message-ID: On 29 January 2011 18:39, wrote: >> I, myself, use the spanish word 'yo' instead (less keystrokes, I hate >> 'self', and it amuses me); if I'm working with my numerical experiments >> I'll use 'n' or 'x'... although, when posting sample code to c.l.py I do >> try to use 'self' to avoid possible confusion. ?:) > > I am glad you said this. ?I have been avoiding understanding this 'self', > just accepting it :} ?For the time being, since my programs I am creating > are for my own use, I think I will make my own names up, that are > descriptive to me as the programmer, it's all going to be interpreted > anyway. ?And the other email equating to C's argv, etc. - now I get it. It's perfectly legal to use a name other than self. It's alo perfectly legal never to wash - and you won't make any friends that way either. -- Cheers, Simon B. From georg at python.org Mon Jan 31 05:32:02 2011 From: georg at python.org (Georg Brandl) Date: Mon, 31 Jan 2011 11:32:02 +0100 Subject: [RELEASED] Python 3.2 rc 2 Message-ID: <4D468FA2.4040704@python.org> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On behalf of the Python development team, I'm quite happy to announce the second release candidate of Python 3.2. Python 3.2 is a continuation of the efforts to improve and stabilize the Python 3.x line. Since the final release of Python 2.7, the 2.x line will only receive bugfixes, and new features are developed for 3.x only. Since PEP 3003, the Moratorium on Language Changes, is in effect, there are no changes in Python's syntax and built-in types in Python 3.2. Development efforts concentrated on the standard library and support for porting code to Python 3. Highlights are: * numerous improvements to the unittest module * PEP 3147, support for .pyc repository directories * PEP 3149, support for version tagged dynamic libraries * PEP 3148, a new futures library for concurrent programming * PEP 384, a stable ABI for extension modules * PEP 391, dictionary-based logging configuration * an overhauled GIL implementation that reduces contention * an extended email package that handles bytes messages * a much improved ssl module with support for SSL contexts and certificate hostname matching * a sysconfig module to access configuration information * additions to the shutil module, among them archive file support * many enhancements to configparser, among them mapping protocol support * improvements to pdb, the Python debugger * countless fixes regarding bytes/string issues; among them full support for a bytes environment (filenames, environment variables) * many consistency and behavior fixes for numeric operations For a more extensive list of changes in 3.2, see http://docs.python.org/3.2/whatsnew/3.2.html To download Python 3.2 visit: http://www.python.org/download/releases/3.2/ Please consider trying Python 3.2 with your code and reporting any bugs you may notice to: http://bugs.python.org/ Enjoy! - -- Georg Brandl, Release Manager georg at python.org (on behalf of the entire python-dev team and 3.2's contributors) -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (GNU/Linux) iEYEARECAAYFAk1Gj6IACgkQN9GcIYhpnLC53wCfcZhc6bxbc+fsmi+PAJxM6npr Hh4An3QRdeyKHm+L3CqVk+EX02PxNx2r =sTu6 -----END PGP SIGNATURE----- From jeanmichel at sequans.com Mon Jan 31 06:15:13 2011 From: jeanmichel at sequans.com (Jean-Michel Pichavant) Date: Mon, 31 Jan 2011 12:15:13 +0100 Subject: Style question: Nicknames for deeply nested objects In-Reply-To: References: Message-ID: <4D4699C1.7090206@sequans.com> Gerald Britton wrote: > Hi all, > > Today I was thinking about a problem I often encounter. > [snip] > > 1. You need to call this thing many times with different arguments, so > you wind up with: > > x = some.deeply.nested.object.method(some.other.deeply.nested.object.value1) > y = some.deeply.nested.object.method(some.other.deeply.nested.object.value2) > z = some.deeply.nested.object.method(some.other.deeply.nested.object.value3) > [snip] > -- > Gerald Britton > This is not solved by style but by design. You simply don't use too much nested objects. That's a sign of something wrong in your overall object model. Since I do not encounter this problem as often as you are, I guess it is a matter of habbits. however, considering what "import a.module.that.is.quite.nested as myModule" is doing, I guess using a local variable to store your nested method is just fine. JM From jeanmichel at sequans.com Mon Jan 31 06:17:22 2011 From: jeanmichel at sequans.com (Jean-Michel Pichavant) Date: Mon, 31 Jan 2011 12:17:22 +0100 Subject: Understanding def foo(*args) In-Reply-To: <17945aea-21b6-45b5-9c09-e602143f755e@k4g2000pre.googlegroups.com> References: <17945aea-21b6-45b5-9c09-e602143f755e@k4g2000pre.googlegroups.com> Message-ID: <4D469A42.4090401@sequans.com> sl33k_ wrote: > Hi, > > I am struggling to grasp this concept about def foo(*args). Also, what > is def bar(*args, *kwargs)? > > Isnt it like self must be the first parameter to the method/function? > If not what are the exceptions? > > Also, can the terms method and function be used interchangeably? > > TIA > "python *args **kwargs" in google. 1st hit. JM From lukin.s.v at gmail.com Mon Jan 31 07:39:07 2011 From: lukin.s.v at gmail.com (Sergey Lukin) Date: Mon, 31 Jan 2011 13:39:07 +0100 Subject: Pickling/Unpickling python Exceptions In-Reply-To: References: Message-ID: Is anybody there to help me out ? On Thu, Jan 27, 2011 at 4:49 PM, Sergey Lukin wrote: > Hi all, > > I'm migrating code from python 2.4 to python 2.6 and I've got into troubles > with pickling/unpickling python Exceptions. > The following code works fine in 2.4 but not in 2.6. > See Exception1 example > > I have found on python mail list similar problem > http://mail.python.org/pipermail/python-list/2009-December/1228773.html > They recommend to use __reduce__. But this does not help as I'm getting > different Exception class after pickle > See Exception_with_reduce example > > I also have found possible solution to this problem here > http://bugs.python.org/issue1692335 > As a workaround they propose to pass Exception arguments into base class > See Exception2 example > But there is another problem. Constructor is called 2 times which is not > acceptable to me. > > Could you please advice on the solution? > > ------------------------------------------ > test program > ------------------------------------------ > import cPickle > > class Exception1(Exception): > def __init__(self,arg1): > print "constructor called" > Exception.__init__(self) > > class Exception2(Exception): > def __init__(self,arg1): > print "constructor called" > Exception.__init__(self,arg1) > > class Exception_with_reduce(Exception): > def __reduce__(self): > try: > getnewargs = self.__getnewargs__ > except AttributeError: > newargs = (self.__class__,) > else: > newargs = (self.__class__,) + getnewargs() > > try: > getstate = self.__getstate__ > except AttributeError: > state = self.__dict__ > else: > state = getstate() > return (Exception, newargs, state) > > def __init__(self,arg1): > print "constructor called" > Exception.__init__(self,arg1) > > def test(E,args): > try: > print ">>",E.__name__ > e = E(*args) > print "- pickling" > s = cPickle.dumps(e) > print "- unpickling" > e = cPickle.loads(s) > > if E != e.__class__: > print "! failed: expected %s, got > %s"%(E.__name__,e.__class__.__name__) > except Exception, e: > print "! failed:",e > > print "\ finished" > print > > > import os > if os.path.isfile("/home/ast1/blabla"): > try: > s = open("/home/ast1/blabla","r").read() > e = cPickle.loads(s) > print e.__class__ > except Exception, e: > print "error:",e > > test(Exception1,[1]) > test(Exception2,[1]) > test(Exception_with_reduce,[1]) > ------------------------------------------ > > > ------------------------------------------ > run results on python 2.6: > ------------------------------------------ > > constructor called > > >> Exception1 > constructor called > - pickling > - unpickling > ! failed: ('__init__() takes exactly 2 arguments (1 given)', '__main__.Exception1'>, ()) > \ finished > > >> Exception2 > constructor called > - pickling > - unpickling > constructor called > \ finished > > >> Exception_with_reduce > constructor called > - pickling > - unpickling > ! failed: expected Exception_with_reduce, got Exception > \ finished > > ------------------------------------------ > run results on python 2.4: > ------------------------------------------ > > __main__.Exception2 > >> Exception1 > constructor called > - pickling > - unpickling > \ finished > > >> Exception2 > constructor called > - pickling > - unpickling > \ finished > > >> Exception_with_reduce > constructor called > - pickling > - unpickling > \ finished > > > > > -- Media Center for TomTom - a unique video player from MobilNova.com Be the first to watch ! http://www.MobilNova.com/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From daniel at danielstender.com Mon Jan 31 07:45:59 2011 From: daniel at danielstender.com (Daniel Stender) Date: Mon, 31 Jan 2011 13:45:59 +0100 Subject: XML to dict(d) Message-ID: <4D46AF07.6000108@danielstender.com> Hi guys, we are trying to convert a Sanskrit dictionary which is in a "homegrown" XML format into dict(d), the input file goes like this:

200akAlikam2a-kAlikam ind. immediately MBh. 000173 2,2 266

110akAlya2a-kAlya mfn. unseasonable. 000174 2,2 267

110akAsAra1a-kAsAra m. N._of_a_teacher BhP. 000175 2,2 268

110akiYcana1a-kiYcana mfn. without_anything_,_utterly_destitute 2,2 269

100akiYcana1a-kiYcana mfn. disinterested 2,2 270 110akiYcana1a-kiYcana n. that_which_is_worth_nothing. 000176 2,2 271

110akiYcanatA3a-kiYcana--tA f. voluntary_poverty_

as_practised_by_JainajEna_ascetics

.
000177 2,2 272

I've found that there is the library python-dictdlib for concatenating dict dictionaries, what would be the best way to "de-XML" the source file? Thanks for any pointers in advance! Daniel Stender From neilc at norwich.edu Mon Jan 31 08:03:13 2011 From: neilc at norwich.edu (Neil Cerutti) Date: 31 Jan 2011 13:03:13 GMT Subject: XML to dict(d) References: Message-ID: <8qnq8hFtb5U5@mid.individual.net> On 2011-01-31, Daniel Stender wrote: > Hi guys, > > we are trying to convert a Sanskrit dictionary which is in a > "homegrown" XML format into dict(d), the input file goes like > this: xml.etree.ElementTree will parse your file and return it as a hierarchy of dict-like Element objects. -- Neil Cerutti From stefan_ml at behnel.de Mon Jan 31 08:08:02 2011 From: stefan_ml at behnel.de (Stefan Behnel) Date: Mon, 31 Jan 2011 14:08:02 +0100 Subject: XML to dict(d) In-Reply-To: <4D46AF07.6000108@danielstender.com> References: <4D46AF07.6000108@danielstender.com> Message-ID: Daniel Stender, 31.01.2011 13:45: > we are trying to convert a Sanskrit dictionary which is in a "homegrown" XML format into dict(d), > the input file goes like this: > > >

200akAlikam2a-kAlikam > ind. immediately MBh. 000173 2,2 > 266

>

110akAlya2a-kAlya mfn. > unseasonable. 000174 2,2 267

>

110akAsAra1a-kAsAra m. > N._of_a_teacher BhP. 000175 2,2 > 268

>

110akiYcana1a-kiYcana > mfn. without_anything_,_utterly_destitute 2,2 > 269

> 100akiYcana1a-kiYcana type="inh">mfn. disinterested 2,2 270 > 110akiYcana1a-kiYcana > n. that_which_is_worth_nothing. 000176 2,2 > 271 >

110akiYcanatA3a-kiYcana--tA > f. > voluntary_poverty_

as_practised_by_JainajEna_ascetics

.
> 000177 2,2 272

>
> > I've found that there is the library python-dictdlib for concatenating dict dictionaries, what would > be the best way to "de-XML" the source file? How do you want to the dict to look like? Stefan From Rob.Richardson at rad-con.com Mon Jan 31 08:57:55 2011 From: Rob.Richardson at rad-con.com (Rob Richardson) Date: Mon, 31 Jan 2011 08:57:55 -0500 Subject: Understanding def foo(*args) In-Reply-To: <4D469A42.4090401@sequans.com> Message-ID: <04A6DB42D2BA534FAC77B90562A6A03D0170185B@server.rad-con.local> My thanks both to the original poster and to JM for an excellent answer. I saw this syntax for the first time recently, and I've been curious about it too. RobR From daniel at danielstender.com Mon Jan 31 09:14:06 2011 From: daniel at danielstender.com (Daniel Stender) Date: Mon, 31 Jan 2011 15:14:06 +0100 Subject: XML to dict(d) In-Reply-To: References: <4D46AF07.6000108@danielstender.com> Message-ID: <4D46C3AE.7080604@danielstender.com> >> I've found that there is the library python-dictdlib for concatenating >> dict dictionaries, what would >> be the best way to "de-XML" the source file? > > How do you want to the dict to look like? > > Stefan What's in should be the "search word", the rest altogether belonging to that in a single line (with some minor modifications). Greetings, DS From stefan_ml at behnel.de Mon Jan 31 09:37:59 2011 From: stefan_ml at behnel.de (Stefan Behnel) Date: Mon, 31 Jan 2011 15:37:59 +0100 Subject: XML to dict(d) In-Reply-To: <4D46C3AE.7080604@danielstender.com> References: <4D46AF07.6000108@danielstender.com> <4D46C3AE.7080604@danielstender.com> Message-ID: Daniel Stender, 31.01.2011 15:14: >>> I've found that there is the library python-dictdlib for concatenating >>> dict dictionaries, what would >>> be the best way to "de-XML" the source file? >> >> How do you want to the dict to look like? > > What's in should be the "search word", the rest altogether belonging to that in a single line > (with some minor modifications). "the rest" isn't very precise, but here's an example of what you could do. from xml.etree.cElementTree import iterparse words = {} h_tags = ('H1', 'H2', 'H3') for _, element in iterparse('thefile.xml'): if element.tag in h_tags: words[element.findtext('h/key1')] = element Since you didn't provide enough information, I have no idea what you want to make of the "h", "body" and "tail" tags. But I'm sure you'll figure it out. Stefan From sturlamolden at yahoo.no Mon Jan 31 11:45:40 2011 From: sturlamolden at yahoo.no (sturlamolden) Date: Mon, 31 Jan 2011 08:45:40 -0800 (PST) Subject: Python critique References: <21868b6d-ab01-402d-a9b3-ee1be39771b8@o4g2000yqd.googlegroups.com> <4d028748$0$1621$742ec2ed@news.sonic.net> Message-ID: On 10 Des 2010, 21:02, John Nagle wrote: > ? ? Probably the biggest practical problem with CPython is > that C modules have to be closely matched to the version of > CPython. ?There's no well-defined API that doesn't change. ctypes and DLLs in plain C do not change, and do not depend on CPython version. Sturla From sturlamolden at yahoo.no Mon Jan 31 11:48:47 2011 From: sturlamolden at yahoo.no (sturlamolden) Date: Mon, 31 Jan 2011 08:48:47 -0800 (PST) Subject: Python critique References: <21868b6d-ab01-402d-a9b3-ee1be39771b8@o4g2000yqd.googlegroups.com> <4d028748$0$1621$742ec2ed@news.sonic.net> Message-ID: On 11 Des 2010, 00:09, Antoine Pitrou wrote: > > ? ? Probably the biggest practical problem with CPython is > > that C modules have to be closely matched to the version of > > CPython. ?There's no well-defined API that doesn't change. > > Please stop spreading FUD:http://docs.python.org/c-api/index.html Even if the API does not change, there is still static linkage with version dependency. That is avoided with ctypes. Sturla From ramon at conexus.net Mon Jan 31 11:49:53 2011 From: ramon at conexus.net (Ramon F Herrera) Date: Mon, 31 Jan 2011 08:49:53 -0800 (PST) Subject: Would like to add an "upload" facility to my web site Message-ID: (newbie alert) This is what I have so far: http://patriot.net/~ramon/upload_facility.html The code is shown below. It seems I need that actual script that performs the file transfer. I would prefer it in Python. TIA, -Ramon ---------------------------------------


From ramon at conexus.net Mon Jan 31 11:50:53 2011 From: ramon at conexus.net (Ramon F Herrera) Date: Mon, 31 Jan 2011 08:50:53 -0800 (PST) Subject: Would like to add an "upload" facility to my web site References: Message-ID: On Jan 31, 10:49?am, Ramon F Herrera wrote: > (newbie alert) > > This is what I have so far: > > http://patriot.net/~ramon/upload_facility.html > > The code is shown below. It seems I need that actual script that > performs the file transfer. I would prefer it in Python. > > TIA, > > -Ramon > > --------------------------------------- > > > >
>
> ? ? > ? ? > ? ?
> ? ?
> ? ? >
> > IMPORTANT Bonus question: Where should I post this type of question about writing stuff for the web???? -Ramon From miki.tebeka at gmail.com Mon Jan 31 12:16:11 2011 From: miki.tebeka at gmail.com (Miki) Date: Mon, 31 Jan 2011 09:16:11 -0800 (PST) Subject: Would like to add an "upload" facility to my web site In-Reply-To: Message-ID: <62829324-3191-4122-b0d7-2ec008644334@glegroupsg2000goo.googlegroups.com> One way is http://pythonwise.blogspot.com/2007/03/pushing-data-easy-way.html :) This list a good place to ask, you can try StackOverflow as well. From randrange at gmail.com Mon Jan 31 12:35:30 2011 From: randrange at gmail.com (Andrew Evans) Date: Mon, 31 Jan 2011 09:35:30 -0800 Subject: Cast to a method pointer in ctypes Message-ID: How can I cast to a method pointer in ctypes. for example this in C int (*func)(); func = (int (*)()) expl; (int)(*func)(); How can I do this in ctypes using Python? I couldn't find the info I needed to be able to do this *cheers -------------- next part -------------- An HTML attachment was scrubbed... URL: From luismgz at gmail.com Mon Jan 31 12:36:54 2011 From: luismgz at gmail.com (=?ISO-8859-1?Q?Luis_M=2E_Gonz=E1lez?=) Date: Mon, 31 Jan 2011 09:36:54 -0800 (PST) Subject: Would like to add an "upload" facility to my web site References: Message-ID: <231c1967-3447-4628-9bc2-1245dda06027@i40g2000yqh.googlegroups.com> On Jan 31, 1:50?pm, Ramon F Herrera wrote: > On Jan 31, 10:49?am, Ramon F Herrera wrote: > > > > > > > > > > > (newbie alert) > > > This is what I have so far: > > >http://patriot.net/~ramon/upload_facility.html > > > The code is shown below. It seems I need that actual script that > > performs the file transfer. I would prefer it in Python. > > > TIA, > > > -Ramon > > > --------------------------------------- > > > > > > >
> >
> > ? ? > > ? ? > > ? ?
> > ? ?
> > ? ? > >
> > > > > > IMPORTANT Bonus question: > > Where should I post this type of question about writing stuff for the > web???? > > -Ramon I guess this question is framework specific. Are you using any framework (django, pylons, etc...)? From rantingrick at gmail.com Mon Jan 31 12:39:58 2011 From: rantingrick at gmail.com (rantingrick) Date: Mon, 31 Jan 2011 09:39:58 -0800 (PST) Subject: IDLE: A cornicopia of mediocrity and obfuscation. Message-ID: IDLE: A cornicopia of mediocrity and obfuscation. -- by Rick Johnson IDLE --which is the Python Integrated Development and Learning Environment-- was once the apple of Guido's eye but has since degenerated into madness many years ago and remains now as the shining jewel "show piece" on the proverbial python wall of shame. A once mighty dream of "programming for everyone" that is now nothing more than an example of "how NOT to program". IDLE contains some of the worst code this community has created. Bad design patterns, tacked on functionality, blasphemous styling, and piss poor packaging. There seems to be no guiding goals or game-plan. And year after year if IDLE *does* get any attention it's just more haphazard code thrown into the mix by someone who has gone blind from reading the source. However we cannot blame the current maintainer (if any such even exists!) because NOBODY can maintains such a spaghetti mess that this package has become! If we would have had a proper game plan from day one i believe we could have avoided this catastrophe. Follows is an outline of the wrongs with some suggestions to right them... * First of all the main two modules "PyShell" and "EditorWindow" are laid out in such a non sequential way that it is virtually impossible to follow along. We should have had a proper app instance from which all widgets where combined. The main app should have followed a "common sense" sequential mentality of... * subclassing the tk.Toplevel * initializing instance variables * creating the main menu * creating the sub widgets * declaring internal methods * declaring event handlers * then interface/generic methods. This is the recipe for order AND NOT CHAOS! What we have now is utter chaos! When we have order we can read source code in a sequential fashion. When we have order we can comprehend what we read. And when we have order we can maintain a library/package with ease. However sadly we DO NOT have order, we have CHAOS, CHAOS, and more CHAOS! * The underlying sub widgets should have started with their own proper order of "declared" initialization. And all events should be handled in the widget at hand NOT outsourced to some other class! * One of the biggest design flaws is the fact that outside modules manipulate the main editor/pyshells events. This is a terrible way to code. For example the AutoCompleteWindow takes over the tab event.... #-- Puesdo Code --# # in editor window __init__ self.autocomplete = AutoComplete(blah) # in editor window onKeyPress(blah) if key == 'Tab' and blah: self.autocomplete.show_tip(blah) elif key == 'Escape' and acw.is_visibe(): self.autocomplete.hide() This is a bad design! The main editor window should handle all its own events AND THEN call outside class methods when needed. We don't want "Mommy" classes telling the kids what to do, when to eat, when to sleep, and when to excrete! We should create our objects with the virtue of self reliance and responsibility!. The Colorizer, ParenMatch, textView, TreeWidget, CallTips, and many other modules are guilty of "event stealing" also. Event functionality must be handled in the widget itself, NOT stolen and handled in an outside class. When we split up sequential code we get CHAOS! * Another bad choice was creating custom reusable widgets (Tabbedpages, FindDialog, ReplaceDialog, etc...) and leaving them in idlelib. These should have been moved into the lib-tk module where they would be more visible to python programmers AND we could reduce the cruft in the idlelib! Remember, when we create more files, folders, and objects we create CHAOS. And nobody can learn from CHAOS! * Another blasphemy is the fact that every module should include some sort of test to display its usage. If the module is a GUI widget then you MUST show how to use the widget in a window. Sadly like all everything else, idlelib is devoid of examples and testing. And the very few tests that DO exists just blow chunks! * Last but not least idlelib does not follow PEP8 or ANY convention. So much so that it seems the developers snubbed their nose at such conventions! We are missing doc strings and comments. We have built- ins being re-bound! Just code horror after code horror. These are just the top of the list. The peak of a huge iceberg that threatens to sink the community in the arms of chaos never to return. I am beginning to believe that this community is either made of amateurs due to this lackluster code in the stdlib. However it could be that the folks are really professional and refuse to work on such a horrible code base (which i understand). I am going with the latter. When are we going to demand that these abominations be rectified? How much longer must we wait? A year? Ten years?... i don't think Python will survive another ten years with this attitude of obfuscation, and mentality of mediocrity. -- rr: disappointed and annoyed! From goposter at jonjay.com Mon Jan 31 12:43:14 2011 From: goposter at jonjay.com (Google Poster) Date: Mon, 31 Jan 2011 09:43:14 -0800 (PST) Subject: Would like to add an "upload" facility to my web site References: <231c1967-3447-4628-9bc2-1245dda06027@i40g2000yqh.googlegroups.com> Message-ID: <36c9ff54-c860-47f9-a4a2-8d469d6c0609@m13g2000yqb.googlegroups.com> On Jan 31, 11:36?am, Luis M. Gonz?lez wrote: > On Jan 31, 1:50?pm, Ramon F Herrera wrote: > > > > > On Jan 31, 10:49?am, Ramon F Herrera wrote: > > > > (newbie alert) > > > > This is what I have so far: > > > >http://patriot.net/~ramon/upload_facility.html > > > > The code is shown below. It seems I need that actual script that > > > performs the file transfer. I would prefer it in Python. > > > > TIA, > > > > -Ramon > > > > --------------------------------------- > > > > > > > > > >
> > >
> > > ? ? > > > ? ? > > > ? ?
> > > ? ?
> > > ? ? > > >
> > > > > > > > > IMPORTANT Bonus question: > > > Where should I post this type of question about writing stuff for the > > web???? > > > -Ramon > > I guess this question is framework specific. No. > Are you using any framework (django, pylons, etc...)? Luis: I have a commercial shell account. I can only edit the directory ~ramon/public_html. I published one file already, I need the other. Gracias! -Ramon From goposter at jonjay.com Mon Jan 31 12:46:59 2011 From: goposter at jonjay.com (Google Poster) Date: Mon, 31 Jan 2011 09:46:59 -0800 (PST) Subject: Would like to add an "upload" facility to my web site References: <231c1967-3447-4628-9bc2-1245dda06027@i40g2000yqh.googlegroups.com> Message-ID: <573f8e92-c9f3-43c8-be33-7653bfba4501@f2g2000yqf.googlegroups.com> On Jan 31, 11:36?am, Luis M. Gonz?lez wrote: > On Jan 31, 1:50?pm, Ramon F Herrera wrote: > > > > > On Jan 31, 10:49?am, Ramon F Herrera wrote: > > > > (newbie alert) > > > > This is what I have so far: > > > >http://patriot.net/~ramon/upload_facility.html > > > > The code is shown below. It seems I need that actual script that > > > performs the file transfer. I would prefer it in Python. > > > > TIA, > > > > -Ramon > > > > --------------------------------------- > > > > > > > > > >
> > >
> > > ? ? > > > ? ? > > > ? ?
> > > ? ?
> > > ? ? > > >
> > > > > > > > > IMPORTANT Bonus question: > > > Where should I post this type of question about writing stuff for the > > web???? > > > -Ramon > > I guess this question is framework specific. > Are you using any framework (django, pylons, etc...)? Luis, Allow me to make this more clear. I have my own servers, all of them running Linux. I have been Linux sysadmin for more time than I care to remember. However, I (on purpose) provided an example hosted at my commercial shell provider. That was a deliberate decision, because I am looking for the simplest possible solution. I guess the question now is: Do I need root access to uploads files?? Gracias, -Ramon From rantingrick at gmail.com Mon Jan 31 12:49:49 2011 From: rantingrick at gmail.com (rantingrick) Date: Mon, 31 Jan 2011 09:49:49 -0800 (PST) Subject: IDLE: A cornicopia of mediocrity and obfuscation. References: Message-ID: On Jan 31, 11:39?am, rantingrick wrote: In my original post i showed this code.... #-- Puesdo Code --# # in editor window __init__ self.autocomplete = AutoComplete(blah) # in editor window onKeyPress(blah) if key == 'Tab' and blah: self.autocomplete.show_tip(blah) elif key == 'Escape' and acw.is_visibe(): self.autocomplete.hide() ...is a suggested FIX of the current code NOT a generalization of the current code. However it may easily be miss-interpreted due to improper placement in the paragraph. From sturlamolden at yahoo.no Mon Jan 31 12:51:12 2011 From: sturlamolden at yahoo.no (sturlamolden) Date: Mon, 31 Jan 2011 09:51:12 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> Message-ID: On 23 Jan, 01:07, rantingrick wrote: > It is time to prove once and for all how dated and worthless Tkinter > is compared to wxPython. Yes, WxPython is not as advanced as i would > like it to be for a 21st century GUI library. So use PyQt instead. > However compared to > Tkinter, Wx is light years ahead! Wx is our best hope to move Python > into the 21st century. I vaguely someone saying that about Borland VCL and C++. Now people harly remember there was a RAD product called Borland C++ Builder, with a sane GUI API compared to Microsoft's MFC. I for one do not like to handcode GUIs. That is why I use wxFormBuilder, and the availability of a good GUI builder dictates my choise of API (currently wxPython due to the previously mentioned product). Sturla From patty at cruzio.com Mon Jan 31 13:00:00 2011 From: patty at cruzio.com (patty at cruzio.com) Date: Mon, 31 Jan 2011 10:00:00 -0800 (PST) Subject: multiple values for keyword argument In-Reply-To: References: <9f669337-6116-4442-9c7e-54b0051e33a2@8g2000prb.googlegroups.com> <8qijsgFgu1U1@mid.dfncis.de> <4D443631.3000502@stoneleaf.us> <6f1dd6fbbc04d2788b2b191e3e407887.squirrel@cruziomail.cruzio.com> Message-ID: > On 29 January 2011 18:39, wrote: >>> I, myself, use the spanish word 'yo' instead (less keystrokes, I hate >>> 'self', and it amuses me); if I'm working with my numerical experiments >>> I'll use 'n' or 'x'... although, when posting sample code to c.l.py I >>> do >>> try to use 'self' to avoid possible confusion. ??:) >> >> I am glad you said this. ??I have been avoiding understanding this >> 'self', >> just accepting it :} ??For the time being, since my programs I am >> creating >> are for my own use, I think I will make my own names up, that are >> descriptive to me as the programmer, it's all going to be interpreted >> anyway. ??And the other email equating to C's argv, etc. - now I get it. > > It's perfectly legal to use a name other than self. It's alo perfectly > legal never to wash - and you won't make any friends that way either. > > -- > Cheers, > Simon B. > > Cute. Believe me, I am learning to change my evil ways. This is what happens when you come from a *long* line of self-employed, entrepreneurial people. Independently Yours, Patty From nitinpawar432 at gmail.com Mon Jan 31 13:06:01 2011 From: nitinpawar432 at gmail.com (Nitin Pawar) Date: Mon, 31 Jan 2011 23:36:01 +0530 Subject: Would like to add an "upload" facility to my web site In-Reply-To: <573f8e92-c9f3-43c8-be33-7653bfba4501@f2g2000yqf.googlegroups.com> References: <231c1967-3447-4628-9bc2-1245dda06027@i40g2000yqh.googlegroups.com> <573f8e92-c9f3-43c8-be33-7653bfba4501@f2g2000yqf.googlegroups.com> Message-ID: On Mon, Jan 31, 2011 at 11:16 PM, Google Poster wrote: > On Jan 31, 11:36 am, Luis M. Gonz?lez wrote: > > On Jan 31, 1:50 pm, Ramon F Herrera wrote: > > > > > > > > > On Jan 31, 10:49 am, Ramon F Herrera wrote: > > > > > > (newbie alert) > > > > > > This is what I have so far: > > > > > >http://patriot.net/~ramon/upload_facility.html > > > > > > The code is shown below. It seems I need that actual script that > > > > performs the file transfer. I would prefer it in Python. > > > > > > TIA, > > > > > > -Ramon > > > > > > --------------------------------------- > > > > > > > > > > > > > >
> > > >
> > > > > > > > > > > >
> > > >
> > > > > > > >
> > > > > > > > > > > > > IMPORTANT Bonus question: > > > > > Where should I post this type of question about writing stuff for the > > > web???? > > > > > -Ramon > > > > I guess this question is framework specific. > > Are you using any framework (django, pylons, etc...)? > > > Luis, > > Allow me to make this more clear. I have my own servers, all of them > running Linux. I have been Linux sysadmin for more time than I care to > remember. However, I (on purpose) provided an example hosted at my > commercial shell provider. That was a deliberate decision, because I > am looking for the simplest possible solution. > > I guess the question now is: Do I need root access to uploads files?? > > Gracias, > > -Ramon > > -- > You don't need a root access to upload files. You will just need to create a directory where you want to save the uploaded files and grant permission to the username by which the web server is running. In case the file uploads are small the simple upload feature works fine but for larger files you may need to write a chunk read/write api > http://mail.python.org/mailman/listinfo/python-list > -- Nitin Pawar -------------- next part -------------- An HTML attachment was scrubbed... URL: From rantingrick at gmail.com Mon Jan 31 13:12:49 2011 From: rantingrick at gmail.com (rantingrick) Date: Mon, 31 Jan 2011 10:12:49 -0800 (PST) Subject: IDLE: A cornicopia of mediocrity and obfuscation. References: Message-ID: PLEASE KINDLY IGNORE MY FIRST TWO POSTS: Due to some errors i need to repost. Thank you. IDLE: A cornicopia of mediocrity and obfuscation. -- by Rick Johnson IDLE --which is the Python Integrated Development and Learning Environment-- was once the apple of Guido's eye but has since degenerated into madness many years ago and remains now as the shining jewel "show piece" on the proverbial python wall of shame. A once mighty dream of "programming for everyone" that is now nothing more than an example of "how NOT to program". IDLE contains some of the worst code this community has created. Bad design patterns, tacked on functionality, blasphemous styling, and piss poor packaging. There seems to be no guiding goals or game-plan. And year after year if IDLE *does* get any attention it's just more haphazard code thrown into the mix by someone who has gone blind from reading the source. However we cannot blame the current maintainer -- if any such even exists-- because NOBODY can maintains such a spaghetti mess that this package has become! If we would have had a proper game plan from day one i believe we could have avoided this catastrophe. Follows is an outline of the wrongs with some suggestions to right them... * First of all the main two modules "PyShell" and "EditorWindow" are laid out in such a non sequential way that it is virtually impossible to follow along. We should have had a proper app instance from which all widgets where combined. The main app should have followed a "common sense" sequential mentality of... * subclassing the tk.Toplevel * initializing instance variables * creating the main menu * creating the sub widgets * declaring internal methods * declaring event handlers * interface/generic methods. ... This is the recipe for order AND NOT CHAOS! What we have now is utter chaos! When we have order we can read source code in a sequential fashion. When we have order we can comprehend what we read. And when we have order we can maintain a library/package with ease. However sadly we DO NOT have order, we have CHAOS, CHAOS, and more CHAOS! * The underlying sub widgets should have started with their own proper order of "declared" initialization. And all events should be handled in the widget at hand NOT outsourced to some other class! * One of the biggest design flaws is the fact that outside modules manipulate the main editor/pyshells events. This is a terrible way to code. For example the AutoCompleteWindow takes over the tab event. This is a bad design! The main editor window should handle all its own events AND THEN call outside class methods when needed... #-- Puesdo Code --# # in editor window __init__ self.autocomplete = AutoComplete(blah) # in editor window onKeyPress(blah) if key == 'Tab' and blah: self.autocomplete.show_tip(blah) elif key == 'Escape' and acw.is_visibe(): self.autocomplete.hide() ...We don't want "Mommy" classes telling the kids what to do, when to eat, when to sleep, and when to excrete! We should create our objects with the virtue of self reliance and responsibility!. The Colorizer, ParenMatch, CallTips, and many other modules are guilty of "event stealing" also. Event functionality must be handled in the widget itself, NOT stolen and handled in an outside class. When we split up sequential code we get CHAOS! * Another bad choice was creating custom reusable widgets (Tabbedpages, FindDialog, ReplaceDialog, textView, TreeWidget, etc...) and leaving them in idlelib. These should have been moved into the lib- tk folder where they would be more visible to python programmers AND we could reduce the cruft in the idlelib! Remember, when we create more files, folders, and objects we create CHAOS. And nobody can learn from CHAOS! * Another blasphemy is the fact that every module should include some sort of test/demo to display its usage. If the module is a GUI widget then you MUST show how to use the widget in a window. Sadly like all everything else, idlelib is devoid of examples and testing. And the very few tests that DO exists just blow chunks! * Last but not least idlelib does not follow PEP8 or ANY convention. So much so that it seems the developers snubbed their nose at such conventions! We are missing doc strings and comments. We have built- ins being rebound! Just code horror after code horror. These are just the top of the list. The peak of a huge iceberg that threatens to sink the community in the arms of chaos never to return. I am beginning to believe that this community is made of amateurs due to this lackluster code in the stdlib. However it could be that the folks are really professional and refuse to work on such a horrible code base (which i understand). I am going with the latter. When are we going to demand that these abominations be rectified? How much longer must we wait? A year? Ten years?... i don't think Python will survive another ten years with this attitude of obfuscation, and mentality of mediocrity. -- rr: disappointed and annoyed! From tyler at tysdomain.com Mon Jan 31 13:13:29 2011 From: tyler at tysdomain.com (Littlefield, Tyler) Date: Mon, 31 Jan 2011 11:13:29 -0700 Subject: IDLE: A cornicopia of mediocrity and obfuscation. In-Reply-To: References: Message-ID: <4D46FBC9.1010500@tysdomain.com> >However we cannot blame the current maintainer... You seem to still not know who -we- is. rewrite your message using I in place of we, and you'll be on the right track. From g.rodola at gmail.com Mon Jan 31 14:32:12 2011 From: g.rodola at gmail.com (=?ISO-8859-1?Q?Giampaolo_Rodol=E0?=) Date: Mon, 31 Jan 2011 20:32:12 +0100 Subject: IDLE: A cornicopia of mediocrity and obfuscation. In-Reply-To: References: Message-ID: So what you're actually telling is that Python won't survive another 10 years because: - IDLE is it's default editor - idlelib directory is the first place you should look every time you need an inspiration on how code should be written - code in idlelib directory sucks That's an interesting point and I thank you for pointing that out. Personally I've never looked into idlelib directory for 7 years in a row at all. I was probably doing some other things, I don't know, but now I'm definitively gonna start looking for a new language because it's clear that any language having a directory called "idlelib" within such a horrible source code is not gonna last for long. Thanks again, --- Giampaolo http://code.google.com/p/pyftpdlib/ http://code.google.com/p/psutil/ 2011/1/31 rantingrick : > PLEASE KINDLY IGNORE MY FIRST TWO POSTS: > ?Due to some errors i need to repost. > Thank you. > > > > IDLE: A cornicopia of mediocrity and obfuscation. > -- by Rick Johnson > > > IDLE --which is the Python Integrated Development and Learning > Environment-- was once the apple of Guido's eye but has since > degenerated into madness many years ago and remains now as the shining > jewel "show piece" on the proverbial python wall of shame. A once > mighty dream of "programming for everyone" that is now nothing more > than an example of "how NOT to program". > > IDLE contains some of the worst code this community has created. Bad > design patterns, tacked on functionality, blasphemous styling, and > piss poor packaging. There seems to be no guiding goals or game-plan. > And year after year if IDLE *does* get any attention it's just more > haphazard code thrown into the mix by someone who has gone blind from > reading the source. However we cannot blame the current maintainer -- > if any such even exists-- because NOBODY can maintains such a > spaghetti mess that this package has become! > > If we would have had a proper game plan from day one i believe we > could have avoided this catastrophe. Follows is an outline of the > wrongs with some suggestions to right them... > > ?* First of all the main two modules "PyShell" and "EditorWindow" are > laid out in such a non sequential way that it is virtually impossible > to follow along. We should have had a proper app instance from which > all widgets where combined. The main app should have followed a > "common sense" sequential mentality of... > > ?* subclassing the tk.Toplevel > ?* initializing instance variables > ?* creating the main menu > ?* creating the sub widgets > ?* declaring internal methods > ?* declaring event handlers > ?* interface/generic methods. > > ... This is the recipe for order AND NOT CHAOS! What we have now is > utter chaos! When we have order we can read source code in a > sequential fashion. When we have order we can comprehend what we read. > And when we have order we can maintain a library/package with ease. > However sadly we DO NOT have order, we have CHAOS, CHAOS, and more > CHAOS! > > * The underlying sub widgets should have started with their own proper > order of "declared" initialization. And all events should be handled > in the widget at hand NOT outsourced to some other class! > > ?* One of the biggest design flaws is the fact that outside modules > manipulate the main editor/pyshells events. This is a terrible way to > code. For example the AutoCompleteWindow takes over the tab event. > This is a bad design! The main editor window should handle all its own > events AND THEN call outside class methods when needed... > > ?#-- Puesdo Code --# > ?# in editor window __init__ > ?self.autocomplete = AutoComplete(blah) > ?# in editor window onKeyPress(blah) > ?if key == 'Tab' and blah: > ? ? ?self.autocomplete.show_tip(blah) > ?elif key == 'Escape' and acw.is_visibe(): > ? ? ?self.autocomplete.hide() > > ...We don't want "Mommy" classes telling the kids what to do, when to > eat, when to sleep, and when to excrete! We should create our objects > with the virtue of self reliance and responsibility!. The Colorizer, > ParenMatch, CallTips, and many other modules are guilty of "event > stealing" also. Event functionality must be handled in the widget > itself, NOT stolen and handled in an outside class. When we split up > sequential code we get CHAOS! > > ?* Another bad choice was creating custom reusable widgets > (Tabbedpages, FindDialog, ReplaceDialog, textView, TreeWidget, etc...) > and leaving them in idlelib. These should have been moved into the lib- > tk folder where they would be more visible to python programmers AND > we could reduce the cruft in the idlelib! Remember, when we create > more files, folders, and objects we create CHAOS. And nobody can learn > from CHAOS! > > ?* Another blasphemy is the fact that every module should include some > sort of test/demo to display its usage. If the module is a GUI widget > then you MUST show how to use the widget in a window. Sadly like all > everything else, idlelib is devoid of examples and testing. And the > very few tests that DO exists just blow chunks! > > ?* Last but not least idlelib does not follow PEP8 or ANY convention. > So much so that it seems the developers snubbed their nose at such > conventions! We are missing doc strings and comments. We have built- > ins being rebound! Just code horror after code horror. > > These are just the top of the list. The peak of a huge iceberg that > threatens to sink the community in the arms of chaos never to return. > I am beginning to believe that this community is made of amateurs due > to this lackluster code in the stdlib. However it could be that the > folks are really professional and refuse to work on such a horrible > code base (which i understand). I am going with the latter. > > When are we going to demand that these abominations be rectified? How > much longer must we wait? A year? Ten years?... i don't think Python > will survive another ten years with this attitude of obfuscation, and > mentality of mediocrity. > > -- rr: disappointed and annoyed! > -- > http://mail.python.org/mailman/listinfo/python-list > From jeanmichel at sequans.com Mon Jan 31 14:35:52 2011 From: jeanmichel at sequans.com (Jean-Michel Pichavant) Date: Mon, 31 Jan 2011 20:35:52 +0100 Subject: multiple values for keyword argument In-Reply-To: <6f1dd6fbbc04d2788b2b191e3e407887.squirrel@cruziomail.cruzio.com> References: <9f669337-6116-4442-9c7e-54b0051e33a2@8g2000prb.googlegroups.com> <8qijsgFgu1U1@mid.dfncis.de> <4D443631.3000502@stoneleaf.us> <6f1dd6fbbc04d2788b2b191e3e407887.squirrel@cruziomail.cruzio.com> Message-ID: <4D470F18.9000103@sequans.com> patty at cruzio.com wrote: > I have been avoiding understanding this 'self', > [snip] > Regards, > > Patty > What is to be understood ?? self references the instance. Did I miss something ? JM From gandalf at shopzeus.com Mon Jan 31 15:04:07 2011 From: gandalf at shopzeus.com (Laszlo Nagy) Date: Mon, 31 Jan 2011 21:04:07 +0100 Subject: Python metaclass and UML Message-ID: <4D4715B7.2020803@shopzeus.com> How should I represent a Python metaclass on an UML class diagram? I know how to represent composition, aggregation and inheritance. But not sure about metaclasses. What kind of arrow or line should I use between a class and its metaclass? Is there a standard for this? Thanks, Laszlo From rantingrick at gmail.com Mon Jan 31 15:19:44 2011 From: rantingrick at gmail.com (rantingrick) Date: Mon, 31 Jan 2011 12:19:44 -0800 (PST) Subject: IDLE: A cornicopia of mediocrity and obfuscation. References: Message-ID: <48d40a1b-9bfc-47aa-b06c-9889273d835d@o32g2000prb.googlegroups.com> On Jan 31, 1:32?pm, Giampaolo Rodol? wrote: > So what you're actually telling is that Python won't survive another > 10 years because: > > - IDLE is it's default editor Well not solely because IDLE is the default editor. IDLE is very useful to newcommers and could be made even more useful however the code base is rotten! > - idlelib directory is the first place you should look every time you > need an inspiration on how code should be written In an ideal world it should be the first place you look when wanting to learn how to build medium sized GUI projects with the built-in Tkinter module. However the reality is ANYTHING but ideal. The code is rotten to the core, full of inconsistencies and just very unpythonic. Not something i would suggest any aspiring Tkinter n00b look at unless they want to learn what NOT to do. > - code in idlelib directory sucks plainly and simply... YES. > That's an interesting point and I thank you for pointing that out. > Personally I've never looked into idlelib directory for 7 years in a row at all. And i am glad, because had you followed the example of IDLE you would be spreading mediocrity and obfuscation. Both of which are not virtues to be admired. > I was probably doing some other things, I don't know, but now I'm > definitively gonna start looking for a new language because it's clear > that any language having a directory called "idlelib" within such a > horrible source code is not gonna last for long. Well not unless we do something about it. It is high time to stop patching, bolting on, and future extending the suffering of this horrendous code base. It is time to pull the plug, let it die, and start fresh. Start from a real python perspective. We can learn from past mistakes and build something much better. But will we? Do we have the community spirit to take on this challenge? Do we as a community have any fire left or have we collectively waxed cold? From python at rcn.com Mon Jan 31 15:35:12 2011 From: python at rcn.com (Raymond Hettinger) Date: Mon, 31 Jan 2011 12:35:12 -0800 (PST) Subject: Use the Source Luke References: <094f6fc5-7242-46c7-b454-4cb29d0c6ef9@q40g2000prh.googlegroups.com> <87tygs1v6g.fsf@benfinney.id.au> Message-ID: On Jan 30, 6:47?am, Tim Wintle wrote: > +1 - I think the source links are very useful (and thanks for pushing > them). Happy to do it. > However I think the biggest changes that have probably happened with > python itself are: > > ?(1) More users for whom this is their first language. > ?(2) CS courses / training not teaching C (or pointer-based languages). > > (2) is especially important IMO - under half of the python developers I > have regularly worked with would feel comfortable reading C - so for the > other half reading C source code probably isn't going to help them > understand exactly what's going on (although in the long run it might > help them a lot) That would explain why fewer people look at the C source code. However, even the parts of the standard library written in pure Python don't seem to be getting read anymore, so I'm still inclined to attribute the issue to 1) inconvenient placement of source code, 2) a largish code base, and 3) possibly a cultural shift. I'm thinking that all of those can be addressed by efforts to lower to intellectual investment required to find the relevant source code. Raymond From rantingrick at gmail.com Mon Jan 31 15:45:05 2011 From: rantingrick at gmail.com (rantingrick) Date: Mon, 31 Jan 2011 12:45:05 -0800 (PST) Subject: Use the Source Luke References: <094f6fc5-7242-46c7-b454-4cb29d0c6ef9@q40g2000prh.googlegroups.com> <87tygs1v6g.fsf@benfinney.id.au> <029f2ce4-e0fb-4cbc-a857-6cc7aa0a26f6@r4g2000vbq.googlegroups.com> <87hbcr1k38.fsf@benfinney.id.au> <4d44e750$0$29970$c3e8da3$5496439d@news.astraweb.com> <3a0492dc-7bbf-4458-b0a5-217d4bb87f5a@d23g2000prj.googlegroups.com> Message-ID: On Jan 30, 10:50?am, rusi wrote: > I note particularly the disclaimer that it was removed from wikipedia > [Like when censors stuff you know it > deserves a second look ;-) ] Oh you mean that channel that *claims* to provide a specific type of "programming" however they really provide *anything* but that specific type of programming! Yes, thank god for you tube. From prologic at shortcircuit.net.au Mon Jan 31 16:10:01 2011 From: prologic at shortcircuit.net.au (James Mills) Date: Tue, 1 Feb 2011 07:10:01 +1000 Subject: Python metaclass and UML In-Reply-To: <4D4715B7.2020803@shopzeus.com> References: <4D4715B7.2020803@shopzeus.com> Message-ID: On Tue, Feb 1, 2011 at 6:04 AM, Laszlo Nagy wrote: > How should I represent a Python metaclass on an UML class diagram? I know > how to represent composition, aggregation and inheritance. But not sure > about metaclasses. What kind of arrow or line should I use between a class > and its metaclass? Is there a standard for this? IHMO (but others may have other opinions) the same way you'd represent a decorated function. Metaclasses IHMO have the same effect as a decorated function - modifying another classes's behavior. cheers Jaes -- -- James Mills -- -- "Problems are solved by method" From ian.g.kelly at gmail.com Mon Jan 31 16:11:11 2011 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Mon, 31 Jan 2011 14:11:11 -0700 Subject: Python metaclass and UML In-Reply-To: <4D4715B7.2020803@shopzeus.com> References: <4D4715B7.2020803@shopzeus.com> Message-ID: On Mon, Jan 31, 2011 at 1:04 PM, Laszlo Nagy wrote: > How should I represent a Python metaclass on an UML class diagram? I know > how to represent composition, aggregation and inheritance. But not sure > about metaclasses. What kind of arrow or line should I use between a class > and its metaclass? Is there a standard for this? http://stackoverflow.com/questions/1483273/how-to-draw-a-classs-metaclass-in-uml From patty at cruzio.com Mon Jan 31 16:20:43 2011 From: patty at cruzio.com (Patty) Date: Mon, 31 Jan 2011 13:20:43 -0800 Subject: multiple values for keyword argument References: <9f669337-6116-4442-9c7e-54b0051e33a2@8g2000prb.googlegroups.com> <8qijsgFgu1U1@mid.dfncis.de> <4D443631.3000502@stoneleaf.us> <6f1dd6fbbc04d2788b2b191e3e407887.squirrel@cruziomail.cruzio.com> <4D470F18.9000103@sequans.com> Message-ID: <929BEBF809CC4B2AA4D08104B266423D@mycomputer> ----- Original Message ----- From: "Jean-Michel Pichavant" To: Cc: Sent: Monday, January 31, 2011 11:35 AM Subject: Re: multiple values for keyword argument > patty at cruzio.com wrote: >> I have been avoiding understanding this 'self', >> [snip] >> Regards, >> >> Patty >> > What is to be understood ?? self references the instance. Did I miss > something ? > > JM > > > Yes, there was more. And it's been fully explained at this point. Patty From ben+python at benfinney.id.au Mon Jan 31 16:22:08 2011 From: ben+python at benfinney.id.au (Ben Finney) Date: Tue, 01 Feb 2011 08:22:08 +1100 Subject: Understanding def foo(*args) References: Message-ID: <87fws8zs3j.fsf@benfinney.id.au> "Rob Richardson" writes: > My thanks both to the original poster and to JM for an excellent answer. > I saw this syntax for the first time recently, and I've been curious > about it too. Would it be correct of me to assume that you have not worked through the entire Python tutorial to get a thorough grounding in Python basics like this? -- \ ?I wish there was a knob on the TV to turn up the intelligence. | `\ There's a knob called ?brightness? but it doesn't work.? | _o__) ?Eugene P. Gallagher | Ben Finney From emile at fenx.com Mon Jan 31 17:07:17 2011 From: emile at fenx.com (Emile van Sebille) Date: Mon, 31 Jan 2011 14:07:17 -0800 Subject: Use the Source Luke In-Reply-To: References: <094f6fc5-7242-46c7-b454-4cb29d0c6ef9@q40g2000prh.googlegroups.com> <87tygs1v6g.fsf@benfinney.id.au> Message-ID: On 1/31/2011 12:35 PM Raymond Hettinger said... > That would explain why fewer people look at the C source code. > > However, even the parts of the standard library written in pure Python > don't seem to be getting read anymore, so I'm still inclined to > attribute the issue to 1) inconvenient placement of source code, > 2) a largish code base, and 3) possibly a cultural shift. > ISTM that around the time the list forked off py-dev fewer people remained that were singing 'use the source'. . . Emile From sigzero at gmail.com Mon Jan 31 17:11:29 2011 From: sigzero at gmail.com (Robert) Date: Mon, 31 Jan 2011 17:11:29 -0500 Subject: IDLE: A cornicopia of mediocrity and obfuscation. References: <48d40a1b-9bfc-47aa-b06c-9889273d835d@o32g2000prb.googlegroups.com> Message-ID: On 2011-01-31 15:19:44 -0500, rantingrick said: > On Jan 31, 1:32?pm, Giampaolo Rodol? wrote: >> So what you're actually telling is that Python won't survive another >> 10 years because: >> >> - IDLE is it's default editor > > Well not solely because IDLE is the default editor. IDLE is very > useful to newcommers and could be made even more useful however the > code base is rotten! Then DO something about it and no excuses. Fork it, make it better, submit it as a replacement. -- Robert From samzielkeryner at gmail.com Mon Jan 31 17:16:12 2011 From: samzielkeryner at gmail.com (Sascha) Date: Mon, 31 Jan 2011 14:16:12 -0800 (PST) Subject: Determine from a HTTP request if the user is on a Smart Phone, IE, Firefox Message-ID: Hello I am returning specialised website html according to what platform the user is on. Is there a way to determine if the user is on a Smart Phone or on IE or on Firefox? Using python &/or examining HTTP packets? From kw at codebykevin.com Mon Jan 31 17:17:06 2011 From: kw at codebykevin.com (Kevin Walzer) Date: Mon, 31 Jan 2011 17:17:06 -0500 Subject: IDLE: A cornicopia of mediocrity and obfuscation. In-Reply-To: References: Message-ID: <4871f$4d4734d6$4275d90a$28417@FUSE.NET> Rick, I've spent a fair amount of time in the IDLE source tree, putting together patches for various Mac-specific bugs and submitting them to the Python tracker, and I agree the code is crufty and disorganized. It is certainly not an example of current best practices in Tkinter development. The code base has accrued over the years, has been touched by many, many different hands, and I think its current messy state reflects that legacy. But, as I understand it, the purpose of IDLE is not to provide a pedagogical example of Tkinter programming practices, but instead to provide a lightweight development environment for those learning Python, to interactively explore different aspects of Python. For this it serves its purpose well. I use IDLE a good deal for my Python development work, and the cruftiness of the code under the hood is not an impediment to me getting my work done (unless the work is patching IDLE itself). Given this, I don't see any huge need to bulldoze IDLE to the ground and replace it with something else, or even do massive rewrites of the code, unless such a project also significantly improved the user-facing portions of IDLE as well. However, there are certainly no impediments for you undertaking such a project yourself: similar efforts have been undertaken in the past and, as I understand it, have led to some significant improvements in IDLE's performance. Here's the one I'm thinking of: http://idlefork.sourceforge.net/ According to this project's details, IDLE was forked, numerous changes were made to its code base, the new version of IDLE gained a user base, and eventually the changes were merged back in to Python's main line of development. It certainly would be interesting to see a fresh approach to IDLE, and I think the scope of such a project would be much easier for a single person to manage than would replacing Tkinter in the stdlib with another GUI toolkit, such as wxPython, or pyGUI, or something else. I'd encourage you to set up a project page somewhere, begin cutting some code, and then invite feedback from other users and/or developers. I think that approach has a much better chance of getting off the ground and making progress than long threads on c.l.py. Good luck! --Kevin -- Kevin Walzer Code by Kevin http://www.codebykevin.com From pappuyadav5555 at gmail.com Mon Jan 31 17:27:32 2011 From: pappuyadav5555 at gmail.com (sneha) Date: Mon, 31 Jan 2011 14:27:32 -0800 (PST) Subject: Earn $500 every day... Message-ID: <44653797-08ca-4e40-ba6d-2d8c2510ea6a@g1g2000prb.googlegroups.com> Way to Make Money Online for FREE! - Looking for the best, fast, easy and free way to make money online? Do you need Quick. Earn $500 every day... http://www.knowledge2know.com/earnmilliondollar.htm From gelonida at gmail.com Mon Jan 31 17:28:09 2011 From: gelonida at gmail.com (Gelonida) Date: Mon, 31 Jan 2011 23:28:09 +0100 Subject: simplest way to create simple standalone wsgi server without import wsgi_lib.server Message-ID: Hi, Normally I use following code snippet to quickly test a wsgi module without a web server. import wsgi_lib.server wsgi_lib.server.run(application, port=port) However Now I'd like to test a small wsgi module on a rather old host ( Python 2.4.3 ) where I don't have means to update python. Is there any quick and easy code snippet / module, performing the same task as my above mentioned lines? Thanks in advance for any hints From sigzero at gmail.com Mon Jan 31 17:38:32 2011 From: sigzero at gmail.com (Robert) Date: Mon, 31 Jan 2011 17:38:32 -0500 Subject: IDLE: A cornicopia of mediocrity and obfuscation. References: <4871f$4d4734d6$4275d90a$28417@FUSE.NET> Message-ID: On 2011-01-31 17:17:06 -0500, Kevin Walzer said: > > > It certainly would be interesting to see a fresh approach to IDLE, and I > think the scope of such a project would be much easier for a single > person to manage than would replacing Tkinter in the stdlib with another > GUI toolkit, such as wxPython, or pyGUI, or something else. I'd > encourage you to set up a project page somewhere, begin cutting some > code, and then invite feedback from other users and/or developers. I > think that approach has a much better chance of getting off the ground > and making progress than long threads on c.l.py. > > Good luck! > > --Kevin I think it would be interesting as well. Hmmmm, I am about to do the O'Reilly series that Steve Holden did for Python. Maybe I will take that up as a project when I get through it (or...*nudge* *nudge* *wink* *wink* to Rick, help out if someone else does a fork). -- Robert From steve+comp.lang.python at pearwood.info Mon Jan 31 17:39:40 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 31 Jan 2011 22:39:40 GMT Subject: Use the Source Luke References: <094f6fc5-7242-46c7-b454-4cb29d0c6ef9@q40g2000prh.googlegroups.com> <87tygs1v6g.fsf@benfinney.id.au> Message-ID: <4d473a2c$0$29970$c3e8da3$5496439d@news.astraweb.com> On Mon, 31 Jan 2011 12:35:12 -0800, Raymond Hettinger wrote: > However, even the parts of the standard library written in pure Python > don't seem to be getting read anymore, so I'm still inclined to > attribute the issue to 1) inconvenient placement of source code, 2) a > largish code base, and 3) possibly a cultural shift. I'd be inclined to say that #3 is by far the most important. When I started programming, the internet wasn't even a distant object on radar. (That is to say, it existed, but hardly anyone outside of a few gurus at universities had even heard of it.) If you wanted to learn a language, you bought a book and read it, if one existed and you could afford it, and you read the sample code that came with the software. Often the book you bought told you to read the sample code. You couldn't email a mailing list to ask for help, or post to a forum, or google the answer. If you were lucky, you could go to a Users Group once a month or so. And so "old timers" learned to read the source, because that's almost all there was. Today's newbies take the internet, web forums, mailing lists, usenet and google for granted. This is a *big* cultural shift. As for #1, in truth I don't believe it is actually a problem. Okay, it might be a bit inconvenient to find the Python source code the first few times you go looking (I can never remember whether to look in /usr/lib/python or /usr/local/lib/python), but once you've found it, it isn't difficult to create a shortcut for it. And as for #2, yes, there may be a lot of code in the standard library, but it's all cut up into small, easily swallowed chunks called "modules" :) In my experience, the biggest obstacles for people to read the Python code in the standard library are: (1) thinking to do so in the first place; and (2) the chicken-and-egg problem that as a newbie they often don't understand what they're reading. Your idea of including links to source in the documentation will hopefully help with the first. -- Steven From prologic at shortcircuit.net.au Mon Jan 31 17:46:55 2011 From: prologic at shortcircuit.net.au (James Mills) Date: Tue, 1 Feb 2011 08:46:55 +1000 Subject: Determine from a HTTP request if the user is on a Smart Phone, IE, Firefox In-Reply-To: References: Message-ID: On Tue, Feb 1, 2011 at 8:16 AM, Sascha wrote: > I am returning specialised website html according to what platform the > user is on. Is there a way to determine if the user is on a Smart > Phone or on IE or on Firefox? I have an iPad and just wrote a simple demo app to test this: http://prologic.no-ip.org:8000/ Source: http://codepad.org/zdZJgm1j Basically if you check for the string "iPad" in the User-Agent header. Obviously this only works for iPads running IOS and the built-in Safari Web Browser - but I'm sure other tablet/mobile devices provide similar unique User-Agent strings. cheers James -- -- James Mills -- -- "Problems are solved by method" From anikom15 at gmail.com Mon Jan 31 18:27:05 2011 From: anikom15 at gmail.com (Westley =?ISO-8859-1?Q?Mart=EDnez?=) Date: Mon, 31 Jan 2011 15:27:05 -0800 Subject: multiple values for keyword argument In-Reply-To: <929BEBF809CC4B2AA4D08104B266423D@mycomputer> References: <9f669337-6116-4442-9c7e-54b0051e33a2@8g2000prb.googlegroups.com> <8qijsgFgu1U1@mid.dfncis.de> <4D443631.3000502@stoneleaf.us> <6f1dd6fbbc04d2788b2b191e3e407887.squirrel@cruziomail.cruzio.com> <4D470F18.9000103@sequans.com> <929BEBF809CC4B2AA4D08104B266423D@mycomputer> Message-ID: <1296516425.23266.1.camel@localhost.localdomain> http://en.wikipedia.org/wiki/Self_(computer_science) On Mon, 2011-01-31 at 13:20 -0800, Patty wrote: > ----- Original Message ----- > From: "Jean-Michel Pichavant" > To: > Cc: > Sent: Monday, January 31, 2011 11:35 AM > Subject: Re: multiple values for keyword argument > > > > patty at cruzio.com wrote: > >> I have been avoiding understanding this 'self', > >> [snip] > >> Regards, > >> > >> Patty > >> > > What is to be understood ?? self references the instance. Did I miss > > something ? > > > > JM > > > > > > > > Yes, there was more. And it's been fully explained at this point. > > Patty -------------- next part -------------- An HTML attachment was scrubbed... URL: From clp2 at rebertia.com Mon Jan 31 18:34:30 2011 From: clp2 at rebertia.com (Chris Rebert) Date: Mon, 31 Jan 2011 15:34:30 -0800 Subject: Determine from a HTTP request if the user is on a Smart Phone, IE, Firefox In-Reply-To: References: Message-ID: On Mon, Jan 31, 2011 at 2:16 PM, Sascha wrote: > Hello > > I am returning specialised website html according to what platform the > user is on. Is there a way to determine if the user is on a Smart > Phone or on IE or on Firefox? Yes, the "User-Agent" HTTP header: http://en.wikipedia.org/wiki/User_agent Cheers, Chris From anikom15 at gmail.com Mon Jan 31 18:35:25 2011 From: anikom15 at gmail.com (Westley =?ISO-8859-1?Q?Mart=EDnez?=) Date: Mon, 31 Jan 2011 15:35:25 -0800 Subject: IDLE: A cornicopia of mediocrity and obfuscation. In-Reply-To: References: Message-ID: <1296516925.23266.3.camel@localhost.localdomain> alias idle='vim' : D On Mon, 2011-01-31 at 09:39 -0800, rantingrick wrote: > IDLE: A cornicopia of mediocrity and obfuscation. > -- by Rick Johnson > > > IDLE --which is the Python Integrated Development and Learning > Environment-- was once the apple of Guido's eye but has since > degenerated into madness many years ago and remains now as the shining > jewel "show piece" on the proverbial python wall of shame. A once > mighty dream of "programming for everyone" that is now nothing more > than an example of "how NOT to program". > > IDLE contains some of the worst code this community has created. Bad > design patterns, tacked on functionality, blasphemous styling, and > piss poor packaging. There seems to be no guiding goals or game-plan. > And year after year if IDLE *does* get any attention it's just more > haphazard code thrown into the mix by someone who has gone blind from > reading the source. However we cannot blame the current maintainer (if > any such even exists!) because NOBODY can maintains such a spaghetti > mess that this package has become! > > If we would have had a proper game plan from day one i believe we > could have avoided this catastrophe. Follows is an outline of the > wrongs with some suggestions to right them... > > * First of all the main two modules "PyShell" and "EditorWindow" are > laid out in such a non sequential way that it is virtually impossible > to follow along. We should have had a proper app instance from which > all widgets where combined. The main app should have followed a > "common sense" sequential mentality of... > > * subclassing the tk.Toplevel > * initializing instance variables > * creating the main menu > * creating the sub widgets > * declaring internal methods > * declaring event handlers > * then interface/generic methods. > > This is the recipe for order AND NOT CHAOS! What we have now is utter > chaos! When we have order we can read source code in a sequential > fashion. When we have order we can comprehend what we read. And when > we have order we can maintain a library/package with ease. However > sadly we DO NOT have order, we have CHAOS, CHAOS, and more CHAOS! > > * The underlying sub widgets should have started with their own proper > order of "declared" initialization. And all events should be handled > in the widget at hand NOT outsourced to some other class! > > * One of the biggest design flaws is the fact that outside modules > manipulate the main editor/pyshells events. This is a terrible way to > code. For example the AutoCompleteWindow takes over the tab event.... > > #-- Puesdo Code --# > # in editor window __init__ > self.autocomplete = AutoComplete(blah) > # in editor window onKeyPress(blah) > if key == 'Tab' and blah: > self.autocomplete.show_tip(blah) > elif key == 'Escape' and acw.is_visibe(): > self.autocomplete.hide() > > This is a bad design! The main editor window should handle all its > own events AND THEN call outside class methods when needed. We don't > want "Mommy" classes telling the kids what to do, when to eat, when to > sleep, and when to excrete! We should create our objects with the > virtue of self reliance and responsibility!. The Colorizer, > ParenMatch, textView, TreeWidget, CallTips, and many other modules are > guilty of "event stealing" also. Event functionality must be handled > in the widget itself, NOT stolen and handled in an outside class. When > we split up sequential code we get CHAOS! > > * Another bad choice was creating custom reusable widgets > (Tabbedpages, FindDialog, ReplaceDialog, etc...) and leaving them in > idlelib. These should have been moved into the lib-tk module where > they would be more visible to python programmers AND we could reduce > the cruft in the idlelib! Remember, when we create more files, > folders, and objects we create CHAOS. And nobody can learn from CHAOS! > > * Another blasphemy is the fact that every module should include some > sort of test to display its usage. If the module is a GUI widget then > you MUST show how to use the widget in a window. Sadly like all > everything else, idlelib is devoid of examples and testing. And the > very few tests that DO exists just blow chunks! > > * Last but not least idlelib does not follow PEP8 or ANY convention. > So much so that it seems the developers snubbed their nose at such > conventions! We are missing doc strings and comments. We have built- > ins being re-bound! Just code horror after code horror. > > These are just the top of the list. The peak of a huge iceberg that > threatens to sink the community in the arms of chaos never to return. > I am beginning to believe that this community is either made of > amateurs due to this lackluster code in the stdlib. However it could > be that the folks are really professional and refuse to work on such a > horrible code base (which i understand). I am going with the latter. > > When are we going to demand that these abominations be rectified? How > much longer must we wait? A year? Ten years?... i don't think Python > will survive another ten years with this attitude of obfuscation, and > mentality of mediocrity. > > -- rr: disappointed and annoyed! > > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From me+list/python at ixokai.io Mon Jan 31 19:14:12 2011 From: me+list/python at ixokai.io (Stephen Hansen) Date: Mon, 31 Jan 2011 16:14:12 -0800 Subject: IDLE: A cornicopia of mediocrity and obfuscation. In-Reply-To: References: Message-ID: <4D475054.5010903@ixokai.io> On 1/31/11 10:12 AM, rantingrick wrote: > -- rr: disappointed and annoyed! tl;dr You did this one before, I swear. You're running out of material. -- Stephen Hansen ... Also: Ixokai ... Mail: me+list/python (AT) ixokai (DOT) io ... Blog: http://meh.ixokai.io/ -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 487 bytes Desc: OpenPGP digital signature URL: From vivshrivastava at gmail.com Mon Jan 31 19:51:18 2011 From: vivshrivastava at gmail.com (Vivek Shrivastava) Date: Mon, 31 Jan 2011 16:51:18 -0800 Subject: Determine from a HTTP request if the user is on a Smart Phone, IE, Firefox In-Reply-To: References: Message-ID: > > its userAgent or UserAgent String. Though its easy to send request with > any( fake) userAgent but its industry standard to get browser information > from userAgent only. > > http://www.useragentstring.com/pages/useragentstring.php > > > > On Mon, Jan 31, 2011 at 2:46 PM, James Mills > wrote: > >> On Tue, Feb 1, 2011 at 8:16 AM, Sascha wrote: >> > I am returning specialised website html according to what platform the >> > user is on. Is there a way to determine if the user is on a Smart >> > Phone or on IE or on Firefox? >> >> I have an iPad and just wrote a simple demo app to test this: >> >> http://prologic.no-ip.org:8000/ >> >> Source: http://codepad.org/zdZJgm1j >> >> Basically if you check for the string "iPad" in >> the User-Agent header. Obviously this only >> works for iPads running IOS and the built-in >> Safari Web Browser - but I'm sure other tablet/mobile >> devices provide similar unique User-Agent strings. >> >> cheers >> James >> >> -- >> -- James Mills >> -- >> -- "Problems are solved by method" >> -- >> http://mail.python.org/mailman/listinfo/python-list >> > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ben+python at benfinney.id.au Mon Jan 31 20:53:35 2011 From: ben+python at benfinney.id.au (Ben Finney) Date: Tue, 01 Feb 2011 12:53:35 +1100 Subject: Determine from a HTTP request if the user is on a Smart Phone, IE, Firefox References: Message-ID: <878vy0zfj4.fsf@benfinney.id.au> Sascha writes: > I am returning specialised website html according to what platform the > user is on. Is there a way to determine if the user is on a Smart > Phone or on IE or on Firefox? The HTTP standard defines the ?User-Agent? field, to be sent as part of the request header . Note that this information is often abused by web server operators, and the response of many users is to mangle or fabricate this field before it is sent to the server. (My browser, for example, instructs the reader to stop obsessing about User-Agent and to code for web standards instead .) -- \ ?If you do not trust the source do not use this program.? | `\ ?Microsoft Vista security dialogue | _o__) | Ben Finney From calderone.jeanpaul at gmail.com Mon Jan 31 21:07:45 2011 From: calderone.jeanpaul at gmail.com (Jean-Paul Calderone) Date: Mon, 31 Jan 2011 18:07:45 -0800 (PST) Subject: simplest way to create simple standalone wsgi server without import wsgi_lib.server References: Message-ID: <685d5386-d5bc-44aa-bb8c-2a395a458cde@i39g2000prd.googlegroups.com> On Jan 31, 5:28?pm, Gelonida wrote: > Hi, > > Normally I use following code snippet to quickly test a wsgi module > without a web server. > > import wsgi_lib.server > wsgi_lib.server.run(application, port=port) > > However Now I'd like to test a small wsgi module on a rather old host > ( Python 2.4.3 ) where I don't have means to update python. > > Is there any quick and easy code snippet / module, performing the same > task as my above mentioned lines? > > Thanks in advance for any hints You didn't mention why you can't update Python, or if that means you can't install new libraries either. However, if you have Twisted 8.2 or newer, you can replace your snippet with this shell command: twistd -n web --port --wsgi is the fully-qualified Python name of your application object. So, for example if you have a module named "foo" that defines an "application" name, you would pass "foo.application". Jean-Paul From patty at cruzio.com Mon Jan 31 21:18:48 2011 From: patty at cruzio.com (Patty) Date: Mon, 31 Jan 2011 18:18:48 -0800 Subject: multiple values for keyword argument References: <9f669337-6116-4442-9c7e-54b0051e33a2@8g2000prb.googlegroups.com> <8qijsgFgu1U1@mid.dfncis.de> <4D443631.3000502@stoneleaf.us><6f1dd6fbbc04d2788b2b191e3e407887.squirrel@cruziomail.cruzio.com><4D470F18.9000103@sequans.com><929BEBF809CC4B2AA4D08104B266423D@mycomputer> <1296516425.23266.1.camel@localhost.localdomain> Message-ID: <9CEC7810060C403B8CF46D9D98C00BAB@mycomputer> >----- Original Message ----- >From: Westley Mart?nez >To: python-list at python.org >Sent: Monday, January 31, 2011 3:27 PM >Subject: Re: multiple values for keyword argument >http://en.wikipedia.org/wiki/Self_(computer_science) Hello Westley: Thank you for the reference. I saw something in it that I think is what tripped me up in my understanding of 'self'. I printed out the page to absorb more later. It helps me to learn when the concept is introduced to me in terms of comparison to other languages so I like this page. Here are the two lines from the wiki page, I was probably going to try and 'assign to self' and expecting that I was modifying the original object like it says. In turn, that is what was leading me to want to name 'self' anything I want, to jog my memory as to 'where it came from' because '*I* am assigning it'. [I know I should be documenting my code clearly and my memory shouldn't need to be jogged :} ]. "Some languages, such as Objective-C, allow assignment to this, although it is deprecated. Doing so can be very misleading to maintenance programmers, because the assignment does not modify the original object, only changing which object that the rest of the code in the method refers to, and can end with undefined behavior" Regards - Patty On Mon, 2011-01-31 at 13:20 -0800, Patty wrote: ----- Original Message ----- From: "Jean-Michel Pichavant" To: Cc: Sent: Monday, January 31, 2011 11:35 AM Subject: Re: multiple values for keyword argument > patty at cruzio.com wrote: >> I have been avoiding understanding this 'self', >> [snip] >> Regards, >> >> Patty >> > What is to be understood ?? self references the instance. Did I miss > something ? > > JM > > > Yes, there was more. And it's been fully explained at this point. Patty ------------------------------------------------------------------------------ -- http://mail.python.org/mailman/listinfo/python-list -------------- next part -------------- An HTML attachment was scrubbed... URL: From anikom15 at gmail.com Mon Jan 31 21:36:12 2011 From: anikom15 at gmail.com (Westley =?ISO-8859-1?Q?Mart=EDnez?=) Date: Mon, 31 Jan 2011 18:36:12 -0800 Subject: multiple values for keyword argument In-Reply-To: <9CEC7810060C403B8CF46D9D98C00BAB@mycomputer> References: <9f669337-6116-4442-9c7e-54b0051e33a2@8g2000prb.googlegroups.com> <8qijsgFgu1U1@mid.dfncis.de> <4D443631.3000502@stoneleaf.us> <6f1dd6fbbc04d2788b2b191e3e407887.squirrel@cruziomail.cruzio.com> <4D470F18.9000103@sequans.com><929BEBF809CC4B2AA4D08104B266423D@mycomputer> <1296516425.23266.1.camel@localhost.localdomain> <9CEC7810060C403B8CF46D9D98C00BAB@mycomputer> Message-ID: <1296527772.23266.8.camel@localhost.localdomain> In Python, self is simply the standard name used. You can use any name. Consider this: >>> class Spam: ... def __init__(self): ... print(self) ... self = 'eggs' ... print(self) ... >>> spam = Spam() <__main__.Spam object at 0xb7224b4c> eggs When we have an instance method, here __init__, we always pass the instance as the first argument. This is assigned as regular old variable. It doesn't have any special restrictions. So when we refer self to a string, self simply stops pointing to the object and points to the string instead, but remember that each self is only contained in its method, so all the other selfs in the class will still point to the object. On Mon, 2011-01-31 at 18:18 -0800, Patty wrote: > ? > > >----- Original Message ----- > >From: Westley Mart?nez > >To: python-list at python.org > >Sent: Monday, January 31, 2011 3:27 PM > >Subject: Re: multiple values for keyword argument > > > >http://en.wikipedia.org/wiki/Self_(computer_science) > > Hello Westley: > > Thank you for the reference. I saw something in it that I > think is what tripped me up in my understanding of 'self'. I > printed out the page to absorb more later. It helps me to > learn when the concept is introduced to me in terms of > comparison to other languages so I like this page. Here are > the two lines from the wiki page, I was probably going to try > and 'assign to self' and expecting that I was modifying the > original object like it says. In turn, that is what was > leading me to want to name 'self' anything I want, to jog my > memory as to 'where it came from' because '*I* am assigning > it'. [I know I should be documenting my code clearly and my > memory shouldn't need to be jogged :} ]. > "Some languages, such as Objective-C, allow assignment to > this, although it is deprecated. Doing so can be very > misleading to maintenance programmers, because the assignment > does not modify the original object, only changing which > object that the rest of the code in the method refers to, and > can end with undefined behavior" > > Regards - > > Patty > > > On Mon, 2011-01-31 at 13:20 -0800, Patty wrote: > > > > ----- Original Message ----- > > From: "Jean-Michel Pichavant" > > To: > > Cc: > > Sent: Monday, January 31, 2011 11:35 AM > > Subject: Re: multiple values for keyword argument > > > > > > > patty at cruzio.com wrote: > > >> I have been avoiding understanding this 'self', > > >> [snip] > > >> Regards, > > >> > > >> Patty > > >> > > > What is to be understood ?? self references the instance. Did I miss > > > something ? > > > > > > JM > > > > > > > > > > > > > Yes, there was more. And it's been fully explained at this point. > > > > Patty > > > > > > ______________________________________________________________ > > -- > http://mail.python.org/mailman/listinfo/python-list -------------- next part -------------- An HTML attachment was scrubbed... URL: From mandersonrandersonanderson at gmail.com Mon Jan 31 21:43:25 2011 From: mandersonrandersonanderson at gmail.com (Nanderson) Date: Mon, 31 Jan 2011 18:43:25 -0800 (PST) Subject: Running python scripts from the command line. Message-ID: <2e8ce9be-fa71-42ff-a9bf-446bb9ec86dc@l22g2000pre.googlegroups.com> I've recently started to program. Python is my first language, so I'm a complete beginner. I've been trying to call python scripts from the command line by entering this command into it: >>>python test.py But it gives me this error message: >>>python test.py File "", line 1 python test.py ^ SyntaxError: invalid syntax I know that test.py exists, and the script is correct (here is is anyways): a = 1 if a: print 'Value of a is', a I am using python 2.7.1 installed on Windows 7. This seems like something that should be easy, so I'm sure I'm just missing a very small problem. Any help is greatly appreciated. Thanks, Anderson From benjamin.kaplan at case.edu Mon Jan 31 21:54:28 2011 From: benjamin.kaplan at case.edu (Benjamin Kaplan) Date: Mon, 31 Jan 2011 21:54:28 -0500 Subject: Running python scripts from the command line. In-Reply-To: <2e8ce9be-fa71-42ff-a9bf-446bb9ec86dc@l22g2000pre.googlegroups.com> References: <2e8ce9be-fa71-42ff-a9bf-446bb9ec86dc@l22g2000pre.googlegroups.com> Message-ID: On Mon, Jan 31, 2011 at 9:43 PM, Nanderson wrote: > I've recently started to program. Python is my first language, so I'm > a complete beginner. I've been trying to call python scripts from the > command line by entering this command into it: > >>>>python test.py > > But it gives me this error message: > >>>>python test.py > ?File "", line 1 > ? ?python test.py > ? ? ? ? ? ? ? ? ? ^ > SyntaxError: invalid syntax > > I know that test.py exists, and the script is correct (here is is > anyways): > > a = 1 > if a: > ? ?print 'Value of a is', a > > I am using python 2.7.1 installed on Windows 7. This seems like > something that should be easy, so I'm sure I'm just missing a very > small problem. Any help is greatly appreciated. > > Thanks, > Anderson You're already in Python when you type that. If you want to run a script, you need to call Python from your normal shell, not from inside the Python interpreter. $ python Python 2.6.6 (r266:84292, Jan 10 2011, 20:14:15) [GCC 4.2.1 (Apple Inc. build 5659)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> python Traceback (most recent call last): File "", line 1, in NameError: name 'python' is not defined >>> exit() $ python test.py Value of a is 1 > -- > http://mail.python.org/mailman/listinfo/python-list > From mandersonrandersonanderson at gmail.com Mon Jan 31 22:08:29 2011 From: mandersonrandersonanderson at gmail.com (Nanderson) Date: Mon, 31 Jan 2011 19:08:29 -0800 (PST) Subject: Running python scripts from the command line. References: <2e8ce9be-fa71-42ff-a9bf-446bb9ec86dc@l22g2000pre.googlegroups.com> Message-ID: <736780ab-c840-4f5e-bb4b-5b063771ff4f@w7g2000pre.googlegroups.com> On Jan 31, 6:54?pm, Benjamin Kaplan wrote: > On Mon, Jan 31, 2011 at 9:43 PM, Nanderson > > > > > > > > > > wrote: > > I've recently started to program. Python is my first language, so I'm > > a complete beginner. I've been trying to call python scripts from the > > command line by entering this command into it: > > >>>>python test.py > > > But it gives me this error message: > > >>>>python test.py > > ?File "", line 1 > > ? ?python test.py > > ? ? ? ? ? ? ? ? ? ^ > > SyntaxError: invalid syntax > > > I know that test.py exists, and the script is correct (here is is > > anyways): > > > a = 1 > > if a: > > ? ?print 'Value of a is', a > > > I am using python 2.7.1 installed on Windows 7. This seems like > > something that should be easy, so I'm sure I'm just missing a very > > small problem. Any help is greatly appreciated. > > > Thanks, > > Anderson > > You're already in Python when you type that. If you want to run a > script, you need to call Python from your normal shell, not from > inside the Python interpreter. > > $ python > Python 2.6.6 (r266:84292, Jan 10 2011, 20:14:15) > [GCC 4.2.1 (Apple Inc. build 5659)] on darwin > Type "help", "copyright", "credits" or "license" for more information.>>> python > > Traceback (most recent call last): > ? File "", line 1, in > NameError: name 'python' is not defined>>> exit() > > $ ?python test.py > Value of a is 1 > > > > > > > > > -- > >http://mail.python.org/mailman/listinfo/python-list Wow, thank you very much for your help. This worked absolutely great. I feel like a huge n00b after that though; it was just so obvious! Anyways, like I said before, thank you very much for your help. Anderson From g.rodola at gmail.com Mon Jan 31 22:24:59 2011 From: g.rodola at gmail.com (=?ISO-8859-1?Q?Giampaolo_Rodol=E0?=) Date: Tue, 1 Feb 2011 04:24:59 +0100 Subject: IDLE: A cornicopia of mediocrity and obfuscation. In-Reply-To: <48d40a1b-9bfc-47aa-b06c-9889273d835d@o32g2000prb.googlegroups.com> References: <48d40a1b-9bfc-47aa-b06c-9889273d835d@o32g2000prb.googlegroups.com> Message-ID: 2011/1/31 rantingrick : > In an ideal world it should be the first place you look when wanting > to learn how to build medium sized GUI projects with the built-in > Tkinter module. I wouldn't do that, and thankfully in the *real* world what is considered more important usually gets more attention. If instead of ranting nonsense all day long you would spend a little bit of your time by taking a look at how crowded the python bug tracker already is, you would discover an interesting thing which goes under the name of "priority". High priority bugs get fixed first. IDLE source code is clearly not a high priority issue, hence it doesn't get fixed: end of story. Actually I don't even understand how can IDLE source code quality have anything to do with python success or future adoption, as you implied in your statements. And why do you care so much anyway? You have spent the past 5 days blabbing about how bad Tkinter is, how ugly and useless it is nowadays, and now you suddenly care about IDLE source code quality? Do you have any idea how ridiculous this looks from the outside? > However the reality is ANYTHING but ideal. The code is > rotten to the core, full of inconsistencies and just very unpythonic. 99% of the times the right answer to this statement is "go file a bug and possibly provide a patch" but not in your case since it's clear that you have absolutely no interest in resolving *anything*, let alone actually write some code, assuming you're able to do so in the first place. >> Personally I've never looked into idlelib directory for 7 years in a row at all. >> I was probably doing some other things, I don't know, but now I'm >> definitively gonna start looking for a new language because it's clear >> that any language having a directory called "idlelib" within such a >> horrible source code is not gonna last for long. > > Well not unless we do something about it. It is high time to stop > patching, bolting on, and future extending the suffering of this > horrendous code base. It is time to pull the plug, let it die, and > start fresh. Start from a real python perspective. We can learn from > past mistakes and build something much better. But will we? Do we have > the community spirit to take on this challenge? Do we as a community > have any fire left or have we collectively waxed cold? How can you possibly not understand that I was being sarcastic? --- Giampaolo http://code.google.com/p/pyftpdlib/ http://code.google.com/p/psutil/ From ameyer2 at yahoo.com Mon Jan 31 22:42:46 2011 From: ameyer2 at yahoo.com (Alan Meyer) Date: Mon, 31 Jan 2011 22:42:46 -0500 Subject: how to read the last line of a huge file??? In-Reply-To: References: Message-ID: On 01/26/2011 04:22 PM, MRAB wrote: > On 26/01/2011 10:59, Xavier Heruacles wrote: >> I have do some log processing which is usually huge. The length of each >> line is variable. How can I get the last line?? Don't tell me to use >> readlines or something like linecache... >> > Seek to somewhere near the end and then read use readlines(). If you > get fewer than 2 lines then you can't be sure that you have the entire > last line, so seek a little farther from the end and try again. I think this has got to be the most efficient solution. You might get the source code for the open source UNIX utility "tail" and see how they do it. It seems to work with equal speed no matter how large the file is and I suspect it uses MRAB's solution, but because it's written in C, it probably examines each character directly rather than calling a library routine like readlines. Alan From ameyer2 at yahoo.com Mon Jan 31 22:45:23 2011 From: ameyer2 at yahoo.com (Alan Meyer) Date: Mon, 31 Jan 2011 22:45:23 -0500 Subject: Looking for Remote Python Project In-Reply-To: <4d1ff594-925b-457e-be62-7e4ca32ae136@33g2000pru.googlegroups.com> References: <4d1ff594-925b-457e-be62-7e4ca32ae136@33g2000pru.googlegroups.com> Message-ID: On 01/29/2011 04:19 PM, joy99 wrote: > Dear Room, > > I am a Python Programmer from India(New Delhi Region), and I worked > for quite a long time in Bangalore. I have been working in Python for > the last 4 years or so. I have successfully built around 15 projects > in Python. I am looking for some remote Python Projects, which can be > done from home. > > If any one knows of anything, I may be helpful enough. > > Best Regards, > Subhabrata. Subharata, Would you be willing to tell us what a programmer with your level of experience typically charges per hour for his services? I'm not in a position to hire anyone, I'm just a programmer myself. But I'm curious about rates in India vs. the U.S., where I live and work. Thanks and good luck with your efforts to get work. Alan From smersh009x at gmail.com Mon Jan 31 23:23:34 2011 From: smersh009x at gmail.com (SMERSH009) Date: Mon, 31 Jan 2011 20:23:34 -0800 (PST) Subject: Converting getCSS Count Code from java to python Message-ID: <1667474c-7080-44f8-81a3-c0fb31f41e22@d23g2000prj.googlegroups.com> Hi, I'd love some help converting this code to the python equivalent: private int getCSSCount(String aCSSLocator){ String jsScript = "var cssMatches = eval_css(\"%s\", window.document);cssMatches.length;"; return Integer.parseInt(selenium.getEval(String.format(jsScript, aCSSLocator))); } http://www.eviltester.com/index.php/2010/03/13/a-simple-getcsscount-helper-method-for-use-with-selenium-rc/ Thanks for the help From kushal.kumaran+python at gmail.com Mon Jan 31 23:58:05 2011 From: kushal.kumaran+python at gmail.com (Kushal Kumaran) Date: Tue, 1 Feb 2011 10:28:05 +0530 Subject: how to read the last line of a huge file??? In-Reply-To: References: Message-ID: On Tue, Feb 1, 2011 at 9:12 AM, Alan Meyer wrote: > On 01/26/2011 04:22 PM, MRAB wrote: >> >> On 26/01/2011 10:59, Xavier Heruacles wrote: >>> >>> I have do some log processing which is usually huge. The length of each >>> line is variable. How can I get the last line?? Don't tell me to use >>> readlines or something like linecache... >>> >> Seek to somewhere near the end and then read use readlines(). If you >> get fewer than 2 lines then you can't be sure that you have the entire >> last line, so seek a little farther from the end and try again. > > I think this has got to be the most efficient solution. > > You might get the source code for the open source UNIX utility "tail" and > see how they do it. ?It seems to work with equal speed no matter how large > the file is and I suspect it uses MRAB's solution, but because it's written > in C, it probably examines each character directly rather than calling a > library routine like readlines. > How about mmapping the file and using rfind? def mapper(filename): with open(filename) as f: mapping = mmap.mmap(f.fileno(), 0, prot=mmap.PROT_READ) endIdx = mapping.rfind('\n') startIdx = mapping.rfind('\n', 0, endIdx) return mapping[startIdx + 1:endIdx] def seeker(filename): offset = -10 with open(filename, 'rb') as f: while True: f.seek(offset, os.SEEK_END) lines = f.readlines() if len(lines) >= 2: return lines[-1][:-1] offset *= 2 In [1]: import timeit In [2]: timeit.timeit('finders.seeker("the-file")', 'import finders') Out[2]: 32.216405868530273 In [3]: timeit.timeit('finders.mapper("the-file")', 'import finders') Out[3]: 16.805877208709717 the-file is a 120M file with ~500k lines. Both functions assume the last line has a trailing newline. It's easy to correct if that's not the case. I think mmap works similarly on Windows, but I've never tried there. -- regards, kushal From devplayer at gmail.com Sat Jan 1 01:43:46 2011 From: devplayer at gmail.com (DevPlayer) Date: Fri, 31 Dec 2010 22:43:46 -0800 (PST) Subject: default argument in method References: <4d0955ae$0$29997$c3e8da3$5496439d@news.astraweb.com> <9f77af4a-83b0-47b6-9e38-5ac5d2214c66@29g2000yqq.googlegroups.com> <4d1ce5ab$0$29968$c3e8da3$5496439d@news.astraweb.com> Message-ID: I agree with you Steven that the OP should avoid __getattribute__ and the like for many a thing. I also agree with your last statement. I try to answer the OP's question without much "You shouldn't do this's and don't do that's". I trust them to make thier own decisions. I'd say "A much better solution..." is the way I like to say it. The last solution you offered I find I use more often now as I like to set my function with default values for which I call set-and-forget function parms/args where using None is what allows my functions to know what is changing (or not). # for example def logger(parm1, parm2=None): if not hasattr(myfunc.parm2_default): if parm2: myfunc.parm2_default = parm2 else: myfunc.parm2_default = CONSOLE if not parm2: parmTwo = myfunc.parm2_default else: parmTwo = parm2 # do something print(parmTwo) log = logger(gui_frame, GUI) # an inaccurate example From michele.simionato at gmail.com Sat Jan 1 03:30:27 2011 From: michele.simionato at gmail.com (Michele Simionato) Date: Sat, 1 Jan 2011 00:30:27 -0800 (PST) Subject: decorator 3.3 is out Message-ID: <30cca189-8d5f-438f-ac7e-a2424196ec61@g26g2000vbi.googlegroups.com> Thanks to the holiday period I found the time to add to the decorator module a long-awaited feature, the ability to understand and to preserve Python 3 function annotations. I have just released version 3.3 which implements such feature. It should be considered at an experimental stage. If you use Python 3 and function annotations you may want to try out the new decorator module (easy_install decorator) and give me feedback. See http://pypi.python.org/pypi/decorator for more. Thanks for your time and Happy New Year to all fellows Pythonistas! Michele Simionato P.S. today I have also released a new bug-fixed version of plac (see http://pypi.python.org/pypi/plac) From baptiste.lepilleur at gmail.com Sat Jan 1 04:01:20 2011 From: baptiste.lepilleur at gmail.com (Baptiste Lepilleur) Date: Sat, 1 Jan 2011 10:01:20 +0100 Subject: How to port bytes formatting to Python 3.x ? Message-ID: Hi, I'm trying to port a small library to Python 3.x, and I'm wondering what is the best way to port statements such as the one belows that are frequently found in network protocol implementation: headerparts = ("%s:%s\n" % (key, value) for key, value in headers.iteritems()) framebytes = "%s\n%s\n%s\x00" % (command, "".join(headerparts), body) Where all manipulated string are actually bytes, though value in headers dict may be any objects. Baptiste. -------------- next part -------------- An HTML attachment was scrubbed... URL: From baptiste.lepilleur at gmail.com Sat Jan 1 04:08:50 2011 From: baptiste.lepilleur at gmail.com (Baptiste Lepilleur) Date: Sat, 1 Jan 2011 10:08:50 +0100 Subject: How to define a bytes literal in Python 2.x for porting to Python 3.x using 2to3? Message-ID: Hi, I'm trying to port some network protocol library to Python 3.x, and it defines many bytes literals as plain string. How do you define bytes literals so that the library can be ported to Python 3.x using only 2to3? For example: In python 2.x, I need: self.buffer = '\n' In python 3.x, I need: self.buffer = b'\n' Is there a way to mark string literals so that 2to3 automatically prefixes them with 'b'? Is there a simpler trick? Baptiste. -------------- next part -------------- An HTML attachment was scrubbed... URL: From flebber.crue at gmail.com Sat Jan 1 04:21:20 2011 From: flebber.crue at gmail.com (flebber) Date: Sat, 1 Jan 2011 01:21:20 -0800 (PST) Subject: User input masks - Access Style References: <385bcaf1-81a5-405a-b7f0-28d7994a2e95@a28g2000prb.googlegroups.com> <7a7e3beb-380a-4d09-8bf6-71a3ecac17e8@p7g2000prb.googlegroups.com> Message-ID: On Jan 1, 11:13?am, Tim Harig wrote: > On 2010-12-31, flebber wrote: > > > On Dec 28 2010, 12:21 am, Adam Tauno Williams > > wrote: > >> On Sun, 2010-12-26 at 20:37 -0800, flebber wrote: > >> > Is there anyay to use input masks in python? Similar to the function > >> > found in access where a users input is limited to a type, length and > >> > format. > > >> > > >> Typically this is handled by a callback on a keypress event. > > > Regarding 137 of the re module, relating to the code above. > > 137? I am not sure what you are referencing? > > > EDIT: I just needed to use raw_input rather than input to stop this > > input error. > > Sorry, I used input() because that is what you had used in your example > and it worked for my system. ?Normally, I would have used window.getstr() > from the curses module, or whatever the platform equivilant is, for > getting line buffered input. 137 is the line number in the re module which refernces the match string. In this example the timeinput. From tjreedy at udel.edu Sat Jan 1 05:08:56 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Sat, 01 Jan 2011 05:08:56 -0500 Subject: How to define a bytes literal in Python 2.x for porting to Python 3.x using 2to3? In-Reply-To: References: Message-ID: On 1/1/2011 4:08 AM, Baptiste Lepilleur wrote: > Is there a way to mark string literals so that 2to3 automatically > prefixes them with 'b'? Is there a simpler trick? Python 2.7.1 (r271:86832, Nov 27 2010, 18:30:46) [MSC v.1500 32 bit (Intel)] on win32 Type "copyright", "credits" or "license()" for more information. >>> b=b'abc' >>> b 'abc' The b prefix does nothing in 2.7. It was specifically added for this type of porting problem. -- Terry Jan Reedy From stefan_ml at behnel.de Sat Jan 1 05:57:08 2011 From: stefan_ml at behnel.de (Stefan Behnel) Date: Sat, 01 Jan 2011 11:57:08 +0100 Subject: How to define a bytes literal in Python 2.x for porting to Python 3.x using 2to3? In-Reply-To: References: Message-ID: Terry Reedy, 01.01.2011 11:08: > On 1/1/2011 4:08 AM, Baptiste Lepilleur wrote: > >> Is there a way to mark string literals so that 2to3 automatically >> prefixes them with 'b'? Is there a simpler trick? > > Python 2.7.1 (r271:86832, Nov 27 2010, 18:30:46) [MSC v.1500 32 bit > (Intel)] on win32 > Type "copyright", "credits" or "license()" for more information. > >>> b=b'abc' > >>> b > 'abc' > > The b prefix does nothing in 2.7. It was specifically added for this type > of porting problem. More precisely, it was added in Python 2.6, so older Python versions will consider it a syntax error. To support older Python versions, you need to write your own wrapper functions for bytes literals that do nothing in Python 2 and convert the literal back to a bytes literal in Python 3. That's ugly, but there's no other way to do it. Stefan From stefan_ml at behnel.de Sat Jan 1 05:58:48 2011 From: stefan_ml at behnel.de (Stefan Behnel) Date: Sat, 01 Jan 2011 11:58:48 +0100 Subject: How to port bytes formatting to Python 3.x ? In-Reply-To: References: Message-ID: Baptiste Lepilleur, 01.01.2011 10:01: > Hi, > I'm trying to port a small library to Python 3.x, and I'm wondering what is > the best way to port statements such as the one belows that are frequently > found in network protocol implementation: > > headerparts = ("%s:%s\n" % (key, value) for key, value in > headers.iteritems()) > framebytes = "%s\n%s\n%s\x00" % (command, "".join(headerparts), > body) > > Where all manipulated string are actually bytes, though value in headers > dict may be any objects. See my answer in the other thread you started on this topic. You need to wrap the literal in a function call that converts it to a bytes literal when running in Python 3. Stefan From baptiste.lepilleur at gmail.com Sat Jan 1 06:34:37 2011 From: baptiste.lepilleur at gmail.com (Baptiste Lepilleur) Date: Sat, 1 Jan 2011 12:34:37 +0100 Subject: How to define a bytes literal in Python 2.x for porting to Python 3.x using 2to3? In-Reply-To: References: Message-ID: 2011/1/1 Stefan Behnel > Terry Reedy, 01.01.2011 11:08: > > On 1/1/2011 4:08 AM, Baptiste Lepilleur wrote: >> >> Is there a way to mark string literals so that 2to3 automatically >>> prefixes them with 'b'? Is there a simpler trick? >>> >> >> Python 2.7.1 (r271:86832, Nov 27 2010, 18:30:46) [MSC v.1500 32 bit >> (Intel)] on win32 >> Type "copyright", "credits" or "license()" for more information. >> >>> b=b'abc' >> >>> b >> 'abc' >> >> The b prefix does nothing in 2.7. It was specifically added for this type >> of porting problem. >> > > More precisely, it was added in Python 2.6, so older Python versions will > consider it a syntax error. > > To support older Python versions, you need to write your own wrapper > functions for bytes literals that do nothing in Python 2 and convert the > literal back to a bytes literal in Python 3. That's ugly, but there's no > other way to do it. > Thanks, I'll go that way. I guess it is an area where 3to2 would be better... -------------- next part -------------- An HTML attachment was scrubbed... URL: From subhakolkata1234 at gmail.com Sat Jan 1 06:52:55 2011 From: subhakolkata1234 at gmail.com (joy99) Date: Sat, 1 Jan 2011 03:52:55 -0800 (PST) Subject: Interesting bug Message-ID: <45562e32-6fd2-4d40-be64-bb88335ad274@z17g2000prz.googlegroups.com> Dear Group, Hope all of you are fine and spending nice new year evenings. I get a bug in Python over the last 4 years or so, since I am using it. The language is superb, no doubt about it. It helped me finish many a projects, with extraordinary accuracy. But long since, I was getting an interesting bug. In the initial days, I thought it may be my learning error or usability error. It comes every now and then. The bug is suppose I am calling a library or using some logical operator, it works fine initially but if I want to copy the code to some other modules, same line of codes do not run at all. The remedy I do is, (a) I take the code from file and test it in GUI, more astonishingly in 99% of the cases I found the code llines, are correct. Then I apply a brute force technique I rewrite the whole code again. For small codes this technique is okay, but if I write mammoth code, and all on a sudden some interesting behavior came out, well it really feels bad. I keep now a days some time out that I have to do this, but is there any definite solution? I believe there is some, as I do not know them, as it happens, unnecessarily get upset. I use Python on WinXP service pack2, I started to use Python2.5.1, and now I am using Python2.6.5, IDLE as GUI. Best Regards, Subhabrata From baptiste.lepilleur at gmail.com Sat Jan 1 06:53:52 2011 From: baptiste.lepilleur at gmail.com (Baptiste Lepilleur) Date: Sat, 1 Jan 2011 12:53:52 +0100 Subject: How to port bytes formatting to Python 3.x ? In-Reply-To: References: Message-ID: 2011/1/1 Stefan Behnel > Baptiste Lepilleur, 01.01.2011 10:01: > > Hi, >> I'm trying to port a small library to Python 3.x, and I'm wondering what >> is >> the best way to port statements such as the one belows that are >> frequently >> found in network protocol implementation: >> ... >> > See my answer in the other thread you started on this topic. You need to > wrap the literal in a function call that converts it to a bytes literal when > running in Python 3. > Is there a robust implementation of the format operator % for bytes that can substitute %s? I've stumbled on a bug on Mysql python 3 connector due to a "buggy" attempt to replace it (see https://bugs.launchpad.net/myconnpy/+bug/691836). Baptiste. -------------- next part -------------- An HTML attachment was scrubbed... URL: From stefan_ml at behnel.de Sat Jan 1 07:08:48 2011 From: stefan_ml at behnel.de (Stefan Behnel) Date: Sat, 01 Jan 2011 13:08:48 +0100 Subject: How to port bytes formatting to Python 3.x ? In-Reply-To: References: Message-ID: Baptiste Lepilleur, 01.01.2011 12:53: > 2011/1/1 Stefan Behnel >> Baptiste Lepilleur, 01.01.2011 10:01: >>> I'm trying to port a small library to Python 3.x, and I'm wondering what >>> is the best way to port statements such as the one belows that are >>> frequently found in network protocol implementation: >>> ... >>> >> See my answer in the other thread you started on this topic. You need to >> wrap the literal in a function call that converts it to a bytes literal when >> running in Python 3. > > Is there a robust implementation of the format operator % for bytes that can > substitute %s? Concatenation is portable and seems to suite your examples (which you stripped above). For more involved cases (as are also likely to occur in network protocol code), have a look at the struct module. http://docs.python.org/py3k/library/struct.html Stefan From fetchinson at googlemail.com Sat Jan 1 08:22:48 2011 From: fetchinson at googlemail.com (Daniel Fetchinson) Date: Sat, 1 Jan 2011 14:22:48 +0100 Subject: Interesting bug In-Reply-To: <45562e32-6fd2-4d40-be64-bb88335ad274@z17g2000prz.googlegroups.com> References: <45562e32-6fd2-4d40-be64-bb88335ad274@z17g2000prz.googlegroups.com> Message-ID: > Dear Group, > > Hope all of you are fine and spending nice new year evenings. > > I get a bug in Python over the last 4 years or so, since I am using > it. The language is superb, no doubt about it. It helped me finish > many a projects, with extraordinary accuracy. But long since, I was > getting an interesting bug. In the initial days, I thought it may be > my learning error or usability error. It comes every now and then. The > bug is suppose I am calling a library or using some logical operator, > it works fine initially but if I want to copy the code to some other > modules, same line of codes do not run at all. > > The remedy I do is, > (a) I take the code from file and test it in GUI, more astonishingly > in 99% of the cases I found the code llines, are correct. > Then I apply a brute force technique I rewrite the whole code again. > For small codes this technique is okay, but if I write mammoth code, > and all on a sudden some interesting behavior came out, well it really > feels bad. I keep now a days some time out that I have to do this, but > is there any definite solution? I believe there is some, as I do not > know them, as it happens, unnecessarily get upset. > > I use Python on WinXP service pack2, I started to use Python2.5.1, and > now I am using Python2.6.5, IDLE as GUI. > > Best Regards, > Subhabrata An AI bot is playing a trick on us. Focus and don't let your guards down! Cheers, Daniel -- Psss, psss, put it down! - http://www.cafepress.com/putitdown From ugnews at onlinehome.de Sat Jan 1 08:34:42 2011 From: ugnews at onlinehome.de (Uwe Grauer) Date: Sat, 01 Jan 2011 14:34:42 +0100 Subject: kinterbasdb error connection In-Reply-To: References: Message-ID: On 12/31/2010 04:41 PM, Ale Ghelfi wrote: > On 09/12/2010 15:17, Uwe Grauer wrote: >> On 12/07/2010 04:35 PM, Ale Ghelfi wrote: >>> (i'm under Ubuntu 10.10 amd64 and python 2.6 and kinterbasdb 3.2 ) >>> I try to connect my database of firebird 2.5 by kinterbasdb. >>> But python return this error : >> >> >> You are not using the current kinterbasdb version. >> See: >> http://firebirdsql.org/index.php?op=devel&sub=python >> >> Uwe >> > kinterbasdb 3.2.3 is the Really current version for Ubuntu 10.10 AMD64. > Kinterbasdb 3.3.0 exists only for ubuntu 10.10 i386 > I've check in the repository. > > AFAIK 3.2.3 doesn't work for FB 2.5. If you don't get 3.3.0 from the ubuntu repositories you could do a manual install for 3.3.0 Uwe From gurudatta97 at gmail.com Sat Jan 1 08:35:50 2011 From: gurudatta97 at gmail.com (guru datta) Date: Sat, 1 Jan 2011 05:35:50 -0800 (PST) Subject: HOT FOR TENAGE GUYS Message-ID: BOLLYWOOD HOT PHOTOS&VIDEOS http://www.photoscup.com/2010/12/keerthi-chawla.html SOUTH ACTRESS HOT PHOTOS http://www.photoscup.com/2010/12/madhu-shalini.html HOT ACTRESS NAVNEET KAUR http://www.photoscup.com/2010/12/navneet-kaur.html HOT SEXY POONAM KAUR PICS http://www.photoscup.com/2010/12/poonam-kaur.html HOLLYWOOD HOT PHOTOS http://www.photoscup.com/2010/12/christina-aguilera.html CHRISTINA HENDRICKS HOT PHOTOS http://www.photoscup.com/2010/12/christina-hendricks.html UDITI GOSWAMI HOT BOOBS SHOW http://www.photoscup.com/2010/12/uditi-goswami.html NEHA DHUPIA HOT ROMANTIC STILLS http://www.photoscup.com/2010/12/neha-dhupia.html SHRADDA DAS SEXY WALLPAPERS http://www.photoscup.com/2010/12/shraddha-das.html FREIDA PINTO HOLLYWOOD HOT http://www.photoscup.com/2010/12/freida-pinto.html From subhakolkata1234 at gmail.com Sat Jan 1 08:58:04 2011 From: subhakolkata1234 at gmail.com (joy99) Date: Sat, 1 Jan 2011 05:58:04 -0800 (PST) Subject: Interesting bug References: <45562e32-6fd2-4d40-be64-bb88335ad274@z17g2000prz.googlegroups.com> Message-ID: On Jan 1, 6:22?pm, Daniel Fetchinson wrote: > > Dear Group, > > > Hope all of you are fine and spending nice new year evenings. > > > I get a bug in Python over the last 4 years or so, since I am using > > it. The language is superb, no doubt about it. It helped me finish > > many a projects, with extraordinary accuracy. But long since, I was > > getting an interesting bug. In the initial days, I thought it may be > > my learning error or usability error. It comes every now and then. The > > bug is suppose I am calling a library or using some logical operator, > > it works fine initially but if I want to copy the code to some other > > modules, same line of codes do not run at all. > > > The remedy I do is, > > (a) I take the code from file and test it in GUI, more astonishingly > > in 99% of the cases I found the code llines, are correct. > > Then I apply a brute force technique I rewrite the whole code again. > > For small codes this technique is okay, but if I write mammoth code, > > and all on a sudden some interesting behavior came out, well it really > > feels bad. I keep now a days some time out that I have to do this, but > > is there any definite solution? I believe there is some, as I do not > > know them, as it happens, unnecessarily get upset. > > > I use Python on WinXP service pack2, I started to use Python2.5.1, and > > now I am using Python2.6.5, IDLE as GUI. > > > Best Regards, > > Subhabrata > > An AI bot is playing a trick on us. > Focus and don't let your guards down! > > Cheers, > Daniel > > -- > Psss, psss, put it down! -http://www.cafepress.com/putitdown Thanks for the suggestion. I'll keep it checked. Some useless fellows forget their own business and poke nose into others business. Best Regards, Subhabrata. From sigzero at gmail.com Sat Jan 1 10:00:06 2011 From: sigzero at gmail.com (Robert) Date: Sat, 1 Jan 2011 10:00:06 -0500 Subject: Nagios References: <3f7e76bf-3d62-4314-987f-62b9fda71f91@glegroupsg2000goo.googlegroups.com> Message-ID: On 2010-12-31 23:57:24 -0500, Adam Skutt said: > On Friday, December 31, 2010 9:56:02 PM UTC-5, Robert H wrote: >> It was forked to be written in Python, yes. The whole point (and it >> wasn't a Nagios port to Tcl) was that the Tcl community (and I like the >> Tcl community a lot) has a strange fixation with not reinventing the >> wheel, even when the wheel would be in Tcl and it might give Tcl more >> exposure. It is what it is though. >> >> -- > > Perhaps because they'd rather do something useful with the tool they've > created instead of trying to win some sort of nonexistent popularity > contest? What value would there be in that? > > Not trying to reinvent the wheel whenever feasible is both good > programming and good engineering most of the time. Unfortunately, the > fact you see this as irksome only paints you in a negative light. > > Adam Right, just because you say it paints me in a negative light. Look at every language out there and look within the groups. Everyone is trying to revinvent the wheel to (in their view) make it better. Your argument is sad to me. -- Robert From perica.zivkovic at gmail.com Sat Jan 1 10:14:02 2011 From: perica.zivkovic at gmail.com (Perica Zivkovic) Date: Sat, 1 Jan 2011 07:14:02 -0800 (PST) Subject: Portable Python challenge - round 1 Message-ID: All, Portable Python challenge - round 1 has started ! Answer one simple question and you can win 4GB USB fingerprint drive. http://www.egistec.com/en/sensors/fingerprintUSB.aspx This round of Portable Python challenge is sponsored by EgisTec Inc. In the future challenges we will test your knowledge of Python programming, Python language concepts and history of the language itself. Follow us and discover more: http://www.PortablePython.com Winner will be announced on the Portable Python project portal by the end of this month. Keep pythoning ! Perica Zivkovic http://www.PortablePython.com From askutt at gmail.com Sat Jan 1 10:34:46 2011 From: askutt at gmail.com (Adam Skutt) Date: Sat, 1 Jan 2011 07:34:46 -0800 (PST) Subject: Nagios In-Reply-To: Message-ID: On Saturday, January 1, 2011 10:00:06 AM UTC-5, Robert H wrote: > > Right, just because you say it paints me in a negative light. Look at > every language out there and look within the groups. Everyone is trying > to revinvent the wheel to (in their view) make it better. "Everyone" is doing nothing of the sort, hence why Tcl "irks" you. Or are you so forgetful that you can't even remember what you said a few days ago? > Your argument is sad to me. At least I've made an argument, whereas you've done nothing of the sort. Just because you take wheel reinvention == good as a tautology doesn't mean everyone else does. Again, what point is there in attempting to win a non-existent popularity contest? Adam From askutt at gmail.com Sat Jan 1 10:34:46 2011 From: askutt at gmail.com (Adam Skutt) Date: Sat, 1 Jan 2011 07:34:46 -0800 (PST) Subject: Nagios In-Reply-To: Message-ID: On Saturday, January 1, 2011 10:00:06 AM UTC-5, Robert H wrote: > > Right, just because you say it paints me in a negative light. Look at > every language out there and look within the groups. Everyone is trying > to revinvent the wheel to (in their view) make it better. "Everyone" is doing nothing of the sort, hence why Tcl "irks" you. Or are you so forgetful that you can't even remember what you said a few days ago? > Your argument is sad to me. At least I've made an argument, whereas you've done nothing of the sort. Just because you take wheel reinvention == good as a tautology doesn't mean everyone else does. Again, what point is there in attempting to win a non-existent popularity contest? Adam From krishna1344 at gmail.com Sat Jan 1 13:33:13 2011 From: krishna1344 at gmail.com (krishna kumar) Date: Sat, 1 Jan 2011 13:33:13 -0500 Subject: python etl tool Message-ID: can u please list out the etl tool which has been devloped in python and it is being used in market now? or just list me the etl tools developed in python? Thanks.... Krishnakumar.A -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjreedy at udel.edu Sat Jan 1 15:10:44 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Sat, 01 Jan 2011 15:10:44 -0500 Subject: How to define a bytes literal in Python 2.x for porting to Python 3.x using 2to3? In-Reply-To: References: Message-ID: On 1/1/2011 5:57 AM, Stefan Behnel wrote: > Terry Reedy, 01.01.2011 11:08: >> On 1/1/2011 4:08 AM, Baptiste Lepilleur wrote: >> >>> Is there a way to mark string literals so that 2to3 automatically >>> prefixes them with 'b'? Is there a simpler trick? >> >> Python 2.7.1 (r271:86832, Nov 27 2010, 18:30:46) [MSC v.1500 32 bit >> (Intel)] on win32 >> Type "copyright", "credits" or "license()" for more information. >> >>> b=b'abc' >> >>> b >> 'abc' >> >> The b prefix does nothing in 2.7. It was specifically added for this type >> of porting problem. > > More precisely, it was added in Python 2.6, so older Python versions > will consider it a syntax error. 'so' here means 'as a consequence' rather than 'with the intention' ;-). > To support older Python versions, you need to write your own wrapper > functions for bytes literals that do nothing in Python 2 and convert the > literal back to a bytes literal in Python 3. That's ugly, but there's no > other way to do it. I think the developers expected that most maintained and updated 2.x code, especially code targeted at 3.x also, would be migrated to 2.6+. -- Terry Jan Reedy From tjreedy at udel.edu Sat Jan 1 15:22:44 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Sat, 01 Jan 2011 15:22:44 -0500 Subject: Portable Python challenge - round 1 In-Reply-To: References: Message-ID: On 1/1/2011 10:14 AM, Perica Zivkovic wrote: > All, > > Portable Python challenge - round 1 has started ! > > Answer one simple question and you can win 4GB USB fingerprint > drive. In exchange for name and email... The question: "What is the exact date (day month and year) of the first Portable Python release ?" > Winner will be announced on the Portable Python project portal by the > end of this month. The idea of Python on a thumbstick is good. However, Distributing quickly superseded Python 3.0, with its known problems, instead of much improved 3.1 is, in my opinion, a disservice to the community. And why 2.6.1 instead of 2.6.6 with perhaps a couple of hundred bugfixes? -- Terry Jan Reedy From perica.zivkovic at gmail.com Sat Jan 1 15:59:49 2011 From: perica.zivkovic at gmail.com (Perica Zivkovic) Date: Sat, 1 Jan 2011 12:59:49 -0800 (PST) Subject: Portable Python challenge - round 1 In-Reply-To: Message-ID: <00dfff75-7469-40fb-a4dc-054cb07548dd@glegroupsg2000goo.googlegroups.com> Hi Terry, when those versions of Portable Python were published, they were the latest available versions of Python. Unfortunately I did not had time to update them since the last release. regards, Perica From perica.zivkovic at gmail.com Sat Jan 1 15:59:49 2011 From: perica.zivkovic at gmail.com (Perica Zivkovic) Date: Sat, 1 Jan 2011 12:59:49 -0800 (PST) Subject: Portable Python challenge - round 1 In-Reply-To: Message-ID: <00dfff75-7469-40fb-a4dc-054cb07548dd@glegroupsg2000goo.googlegroups.com> Hi Terry, when those versions of Portable Python were published, they were the latest available versions of Python. Unfortunately I did not had time to update them since the last release. regards, Perica From rantingrick at gmail.com Sat Jan 1 17:03:11 2011 From: rantingrick at gmail.com (rantingrick) Date: Sat, 1 Jan 2011 14:03:11 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <56d4ecc8-03fb-432a-b728-bebc53f11dec@e16g2000pri.googlegroups.com> <4d1ce2d4$0$29968$c3e8da3$5496439d@news.astraweb.com> <4c682692-dc0f-4055-9587-eb7cce169ef6@g26g2000vbz.googlegroups.com> <661858a7-2eaa-4ba5-a014-0805707f0a3f@p8g2000vbs.googlegroups.com> <6895332e-26dd-4306-ada9-d44533a3c7ab@l8g2000yqh.googlegroups.com> <7de8ad23-5613-46e4-8330-0eaa3d428935@j29g2000yqm.googlegroups.com> <23b1017b-2b14-457d-b4df-0219989940db@f30g2000yqa.googlegroups.com> Message-ID: On Dec 31 2010, 8:47?am, Adam Skutt wrote: Ok, at this point i am not going to respond to the last few posts that where directed at me. What i am going to do is to restate my intentions at the time i started this thread. First and foremost i want everyone to know that i have tons of GUI code that utilizes the Tkinter module and feel very confident crating GUI's with Tkinter. I am not some novice who tried to write up a hello world GUI, got aggravated, and then decided to vent about it. Quite to the contrary... I actually like Tkinter's simplistic API. I especially love Tkinter geometry management! However i realize that TclTk is lacking and because of that fact we will always be at the mercy of another community. This bothers me, and it should also bother you. Tk has a glass ceiling that cannot be broken by you, or me, or anyone in the Python community. If we are to have a GUI library it should be one that is up to date and feature rich. In the latter case there may still be a glass ceiling but it is so high they we will never notice anyway! However be aware that GUI's libraries are large beasts. You cannot cram everything into the stdlib. So what should go into the stdlib then? Well only a very limited subset of widgets. Some might say that you will be limited with a limited subset, well i must agree with argument :). Some might also say that a glass half full is also half empty, duh! Everyone needs to realize that the only reason for having ANY GUI in the Python stdlib is for ease of learning and also for "batteries included". We just want the basics of a GUI with an extension library available for download. There are two major advantages to this setup... 1. The basics never change. So the Python "stdlib GUI module" becomes a "set it and forget it" module. The Python "GUI extension library" can change all it wants and Python remain backwards compatible. 2. By relegating the bloat to an external download the stdlib is kept as small as possible. ... These two talking points are the main idea behind this whole damn discussion i initiated. We need to look beyond our own selfish needs and think about the community first. Anyone who truly cares about Python's stability and future will agree with these two points. I'll repeat... TclTk has had a whole decade to become a 21st century GUI library. I really don't think the motivation is there. Some will argue that ttk brings in the new widgets necessary to compete with a full featured GUI like wxPython -- and they could not be more wrong! There is no real Tk::Grid. Sure as someone suggested you can mimic a grid with another widget, it's just lipstick on a pig really. Go and check out the wx::Grid with all its wonderful capabilities and then you shall be enlightened! This is also no real support for a true Listview widget. Again go check out wx::ListView with all it's capabilities and ye shall be further enlightened. Wx is by far the best choice for Python. A small subset of wx widgets in the stdlib and ONE (and only one!) downloadable extension library. Yes the stdlib widgets are only going to cover the most minimal of GUIs -- for learning purposes, utilities, or just simply toys) If you plan to do professional GUI work than package the extension library. It's very simple really. Geesh! Now i know how the early scientist felt when trying to convince the lemmings that the earth is not flat! Flatearther said: """You heritic!. If the earth were round we would fall off the bottom!""" From martin at v.loewis.de Sat Jan 1 17:07:15 2011 From: martin at v.loewis.de (Martin v. Loewis) Date: Sat, 01 Jan 2011 23:07:15 +0100 Subject: How to define a bytes literal in Python 2.x for porting to Python 3.x using 2to3? In-Reply-To: References: Message-ID: <4D1FA593.7080503@v.loewis.de> >> To support older Python versions, you need to write your own wrapper >> functions for bytes literals that do nothing in Python 2 and convert the >> literal back to a bytes literal in Python 3. That's ugly, but there's no >> other way to do it. > > I think the developers expected that most maintained and updated 2.x > code, especially code targeted at 3.x also, would be migrated to 2.6+. Unfortunately, that assumption has hurt Python 3 migration significantly. It gave the impression that, as long as you need to support Python 2.5 and earlier, there is no way you could possibly support Python 3 as well, and that, therefore, starting to support Python 3 is pointless for many years to come. I personally never shared that assumption, and encourage people to ignore these gimmicks that had been added to 2.6 to ease porting. Instead, people should first determine what Python versions their users want to see supported, and then look for solutions that cover all these versions. In the case of byte literals, the solution is fairly straight-forward, and only moderately ugly. Regards, Martin From tjreedy at udel.edu Sat Jan 1 17:07:42 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Sat, 01 Jan 2011 17:07:42 -0500 Subject: Portable Python challenge - round 1 In-Reply-To: <00dfff75-7469-40fb-a4dc-054cb07548dd@glegroupsg2000goo.googlegroups.com> References: <00dfff75-7469-40fb-a4dc-054cb07548dd@glegroupsg2000goo.googlegroups.com> Message-ID: On 1/1/2011 3:59 PM, Perica Zivkovic wrote: > when those versions of Portable Python were published, they were the > latest available versions of Python. 2.6.1: December 2008; 3.0.1: February 2009 > Unfortunately I did not had time > to update them since the last release. If you have not done any updates in about 20 months, why are you paying people (with a sweepstakes ticket) for name and email? And why put your effort into this instead of producing a much better Python3 release? In spite of efforts otherwise, 3.0 (December 2008) had some typical .0 problems. It was quickly (in 2 months) patched a bit and them abandoned, with 3.1 release soon after (June 2009, without a 3.1.2, as would have been usual) with the recommendation that everyone replace 3.0 with 3.1. Hence my opinion that promoting 3.0(.1) 18 months later is a disservice. Anyone who tries it might get an incorrect bad impression and will certainly not get the benefit of subsequent improvements. -- Terry Jan Reedy From perica.zivkovic at gmail.com Sat Jan 1 17:32:33 2011 From: perica.zivkovic at gmail.com (Perica Zivkovic) Date: Sat, 1 Jan 2011 14:32:33 -0800 (PST) Subject: Portable Python challenge - round 1 In-Reply-To: Message-ID: <7c10baab-1f93-4f0c-b6d9-e07b9d09722f@glegroupsg2000goo.googlegroups.com> Well I'm not paying anybody anything. I'm giving USB sticks for free because I got them for free from our sponsor :) Name and email I need to be able to know where to send them, or you know some easier ways for that ? And thanks for your suggestion but I'm putting my free time where I want while I work on a new release of Portable Python in parallel :) regards, Perica From perica.zivkovic at gmail.com Sat Jan 1 17:32:33 2011 From: perica.zivkovic at gmail.com (Perica Zivkovic) Date: Sat, 1 Jan 2011 14:32:33 -0800 (PST) Subject: Portable Python challenge - round 1 In-Reply-To: Message-ID: <7c10baab-1f93-4f0c-b6d9-e07b9d09722f@glegroupsg2000goo.googlegroups.com> Well I'm not paying anybody anything. I'm giving USB sticks for free because I got them for free from our sponsor :) Name and email I need to be able to know where to send them, or you know some easier ways for that ? And thanks for your suggestion but I'm putting my free time where I want while I work on a new release of Portable Python in parallel :) regards, Perica From tjreedy at udel.edu Sat Jan 1 17:47:58 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Sat, 01 Jan 2011 17:47:58 -0500 Subject: How to define a bytes literal in Python 2.x for porting to Python 3.x using 2to3? In-Reply-To: <4D1FA593.7080503@v.loewis.de> References: <4D1FA593.7080503@v.loewis.de> Message-ID: On 1/1/2011 5:07 PM, Martin v. Loewis wrote: >> I think the developers expected that most maintained and updated 2.x >> code, especially code targeted at 3.x also, would be migrated to 2.6+. > > Unfortunately, that assumption has hurt Python 3 migration > significantly. It gave the impression that, as long as you need to > support Python 2.5 and earlier, there is no way you could possibly > support Python 3 as well, and that, therefore, starting to support > Python 3 is pointless for many years to come. > > I personally never shared that assumption, and encourage people to > ignore these gimmicks that had been added to 2.6 to ease porting. > Instead, people should first determine what Python versions their > users want to see supported, and then look for solutions that cover > all these versions. You have shown that it is easier than some people thought. I think two key ideas are these. 1. Code running in multiple versions has to be syntactically correct in every detail all versions in order to be compiled without error. However, version specific syntax *can* be used in modules that are conditionally imported and therefore conditionally compiled and executed. 2. The syntax of function calls has hardly changed and using the common subset is no limitation for the overwhelming majority of uses. Moreover, function names can be conditionally bound to version-specific function objects, whether builtin or imported. -- Terry Jan Reedy From martin at v.loewis.de Sat Jan 1 17:57:10 2011 From: martin at v.loewis.de (Martin v. Loewis) Date: Sat, 01 Jan 2011 23:57:10 +0100 Subject: How to define a bytes literal in Python 2.x for porting to Python 3.x using 2to3? In-Reply-To: References: <4D1FA593.7080503@v.loewis.de> Message-ID: > 1. Code running in multiple versions has to be syntactically correct in > every detail all versions in order to be compiled without error. > However, version specific syntax *can* be used in modules that are > conditionally imported and therefore conditionally compiled and executed. I also encourage people to use 2to3. Then this requirement (must be syntactically correct in all Python versions) goes away: it is ok to write source that doesn't compile on Python 3, and still *run* it on Python 3. OTOH, writing code that only supports newer 2.x versions isn't helped by 2to3, so compatibility within 2.x is more important to consider than compatibility between 2.x and 3.x. Regards, Martin From askutt at gmail.com Sat Jan 1 18:20:03 2011 From: askutt at gmail.com (Adam Skutt) Date: Sat, 1 Jan 2011 15:20:03 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <56d4ecc8-03fb-432a-b728-bebc53f11dec@e16g2000pri.googlegroups.com> <4d1ce2d4$0$29968$c3e8da3$5496439d@news.astraweb.com> <4c682692-dc0f-4055-9587-eb7cce169ef6@g26g2000vbz.googlegroups.com> <661858a7-2eaa-4ba5-a014-0805707f0a3f@p8g2000vbs.googlegroups.com> <6895332e-26dd-4306-ada9-d44533a3c7ab@l8g2000yqh.googlegroups.com> <7de8ad23-5613-46e4-8330-0eaa3d428935@j29g2000yqm.googlegroups.com> <23b1017b-2b14-457d-b4df-0219989940db@f30g2000yqa.googlegroups.com> Message-ID: On Jan 1, 5:03?pm, rantingrick wrote: > I actually like Tkinter's simplistic API. I especially love Tkinter > geometry management! However i realize that TclTk is lacking and > because of that fact we will always be at the mercy of another > community. This bothers me, and it should also bother you. It's true of any widget library out there. It's inescapable. Python bindings to the native widgets are still at the mercy of MS and Apple (and GTK+ or Qt, whomever you pick for UNIX ). We've seen how much Apple cares about 3rd-party developers, and while MS at least cares, you never know when or how they'll implement something. Look at the mess with the ribbon, for example. There's the Office version, an MFC/ Win32/COM version, and a WPF version. Not only do all three have slightly different APIs, they all behave slightly differently too w.r.t the end-user. Even a "pure python" GUI library cannot get rid of this problem entirely. Witness that Xlib is (slowly) being deprecated for XCB[1]. It's possible, though unlikely, that MS will eventually stop providing new functionality through Win32 and/or make radical changes. It's also possible, though unlikely, that Apple will eventually pull another stunt on the level of deprecating Carbon and rip apart Quartz. Any of those changes would require drastic implementation changes on the part of the python GUI library. It's inescapable, so it's generally best not to worry about it. > However be aware that GUI's libraries are large beasts. You cannot > cram everything into the stdlib. Who says? Java does. Android does. Microsoft does. Apple does. > So what should go into the stdlib then? > Well only a very limited subset of widgets. Some might say that > you will be limited with a limited subset, well i must agree with > argument :). Some might also say that a glass half full is also half > empty, duh! No, not 'duh'. You have to explain what the utility of doing such a thing is, as the utility is not apparent in the least. You also need to explain how this is actually accomplished. I don't see it as a trivial task, especially if the implementation path is to wrap something else. What we have now is about as minimal as things are going to get. > > Everyone needs to realize that the only reason for having ANY GUI in > the Python stdlib is for ease of learning and also for "batteries > included". We just want the basics of a GUI with an extension library > available for download. There are two major advantages to this > setup... > > 1. The basics never change. So the Python "stdlib GUI module" becomes > a "set it and forget it" module. The Python "GUI extension library" > can change all it wants and Python remain backwards compatible. > No, I don't see how this follows in the least, especially if the implementation path is, "wrap something else". But even in the pure Python case, most (nearly all) GUI applications will rely on the extension library, so it will not be able to change all it wants. > 2. By relegating the bloat to an external download the stdlib is kept > as small as possible. > It's not apparent why this is desirable to me. Even if we take it as a tautology, you need to show the value and means for splitting up a GUI library. Your cutting may result in their being more value by not including a GUI at all. Trivial proof: if everyone ends up needing to download the extension library anyway, you incur no cost for anyone and make the standard library smaller by not including any GUI functionality. So go on, show us a minimized, functional widget set and what we can do with it. We're all pretty eagerly awaiting such a thing. > There is no real Tk::Grid. Sure as someone suggested you can mimic a > grid with another widget, it's just lipstick on a pig really. Go and > check out the wx::Grid with all its wonderful capabilities and then > you shall be enlightened! > TkTable seems to do everything wx::Grid[sic] can do. I didn't check fully, as it's your claim, so your responsibility to show the inadequacies, especially since you don't even seem to be aware of TkTable's existence. The biggest missing feature seems to be DnD support, AFAICT. BFD to me, since I've never actually encounterd DnD support worth a damn ever and have always ended up doing it manually. > Wx is by far the best choice for Python. A small subset of wx widgets > in the stdlib and ONE (and only one!) downloadable extension library. > Yes the stdlib widgets are only going to cover the most minimal of > GUIs -- for learning purposes, utilities, or just simply toys) If you > plan to do professional GUI work than package the extension library. > It's very simple really. > Why split it, if you use wx[sic]? All that saves you is a few .py/.c files in the stdlib. You still need the full wxWidgets install to build even the "minimal set", which is pointless and stupid. The costly part with wxWidgets is depending on the native library, not the amount of code in the stdlib. Again, do you think the various Tk bindings fall along library lines just for fun, or that there just possibly might be a method to the madness? > Geesh! Now i know how the early scientist felt when trying to convince > the lemmings that the earth is not flat! > > Flatearther said: """You heritic!. If the earth were round we would > fall off the bottom!""" You can pretend you're being persecuted all you want, but it really only furthers the opinion that you're completely and fully disconnected from reality. The torches you see are entirely of your own imagination. Adam [1] In the case of X, you could write your own protocol library, but then when the protocol changes... From sigzero at gmail.com Sat Jan 1 18:21:59 2011 From: sigzero at gmail.com (Robert) Date: Sat, 1 Jan 2011 18:21:59 -0500 Subject: Nagios References: Message-ID: On 2011-01-01 10:34:46 -0500, Adam Skutt said: > On Saturday, January 1, 2011 10:00:06 AM UTC-5, Robert H wrote: >> >> Right, just because you say it paints me in a negative light. Look at >> every language out there and look within the groups. Everyone is trying >> to revinvent the wheel to (in their view) make it better. > > "Everyone" is doing nothing of the sort, hence why Tcl "irks" you. Or > are you so forgetful that you can't even remember what you said a few > days ago? Really? How many templating systems does Python have? More than one? Why is that? How many web frameworks does Perl have? More than one? Why is that? Why *was* Nagios forked and re-written in Python? There are too many examples to count. > >> Your argument is sad to me. > > At least I've made an argument, whereas you've done nothing of the > sort. Just because you take wheel reinvention == good as a tautology > doesn't mean everyone else does. Again, what point is there in > attempting to win a non-existent popularity contest? > > Adam Just gave you a bunch. You have totally missed the whole point of the original argument. Nice job. Done with you now. -- Robert From sigzero at gmail.com Sat Jan 1 18:26:31 2011 From: sigzero at gmail.com (Robert) Date: Sat, 1 Jan 2011 18:26:31 -0500 Subject: Nagios References: Message-ID: On 2011-01-01 10:34:46 -0500, Adam Skutt said: > On Saturday, January 1, 2011 10:00:06 AM UTC-5, Robert H wrote: >> >> Right, just because you say it paints me in a negative light. Look at >> every language out there and look within the groups. Everyone is trying >> to revinvent the wheel to (in their view) make it better. > > "Everyone" is doing nothing of the sort, hence why Tcl "irks" you. Or > are you so forgetful that you can't even remember what you said a few > days ago? > >> Your argument is sad to me. > > At least I've made an argument, whereas you've done nothing of the > sort. Just because you take wheel reinvention == good as a tautology > doesn't mean everyone else does. Again, what point is there in > attempting to win a non-existent popularity contest? > > Adam I want to apologize for my part. We just aren't going to see the same side of this. -- Robert From cmpython at gmail.com Sat Jan 1 18:39:41 2011 From: cmpython at gmail.com (CM) Date: Sat, 1 Jan 2011 15:39:41 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <56d4ecc8-03fb-432a-b728-bebc53f11dec@e16g2000pri.googlegroups.com> <4d1ce2d4$0$29968$c3e8da3$5496439d@news.astraweb.com> <4c682692-dc0f-4055-9587-eb7cce169ef6@g26g2000vbz.googlegroups.com> <661858a7-2eaa-4ba5-a014-0805707f0a3f@p8g2000vbs.googlegroups.com> <6895332e-26dd-4306-ada9-d44533a3c7ab@l8g2000yqh.googlegroups.com> <7de8ad23-5613-46e4-8330-0eaa3d428935@j29g2000yqm.googlegroups.com> <23b1017b-2b14-457d-b4df-0219989940db@f30g2000yqa.googlegroups.com> Message-ID: Rantingrick, Find a closet in your home, go inside, turn off the lights, and shout into a thermos; that will likely have a similar result as these posts on the state of GUI libraries in Python. There is something admirable about the FOSS philosophy of "You want it? You make it". And I don't see this as a problem anyway. I wanted to do GUI programming in Python, so I read a bit, chose wxPython, downloaded it, and started learning it. Done. From askutt at gmail.com Sat Jan 1 18:55:42 2011 From: askutt at gmail.com (Adam Skutt) Date: Sat, 1 Jan 2011 15:55:42 -0800 (PST) Subject: Nagios References: Message-ID: <22c9af69-a6aa-4a7c-b82c-43d677433949@30g2000yql.googlegroups.com> On Jan 1, 6:21?pm, Robert wrote: > > Really? How many templating systems does Python have? More than one? > Why is that? How many web frameworks does Perl have? More than one? Why > is that? > > Why *was* Nagios forked and re-written in Python? > > There are too many examples to count. > You're missing the point: you've yet to provide any sort of argument whatsoever. It's not automatically true that rewriting Nagios in Tcl would gain the Tcl community more exposure, nor is it automatically true that more exposure is a good or desirable thing. You first have to show how rewriting Nagios in Tcl would gain them more exposure. Then you have to show that the exposure would be a good thing. Until you've done both, you're arguing with very fundamental and conventional engineering wisdom; and you have not actually presented an argument just tautologies. Neither will be easy to prove, by and by large, most people don't give a shit what language their applications are written in and rightly so. > Just gave you a bunch. No, you've given me examples of wheel reinvention. Just because the people reinventing the wheel thought it was a good thing doesn't actually make it so. You personally have to present the case as to why it is a good thing. > I want to apologize for my part. We just aren't going to see the same > side of this. You can apologize, but I don't accept it. You want to actually apologize? Admit you were wrong and retract, or act like an adult and present an actual argument instead of wasting time. Adam From gert.cuykens at gmail.com Sat Jan 1 19:26:09 2011 From: gert.cuykens at gmail.com (gert) Date: Sat, 1 Jan 2011 16:26:09 -0800 (PST) Subject: wiki language Message-ID: I can't get the space betweeen \ " to work, what am I doing wrong? http://pypi.python.org/pypi/appwsgi | Install python3_ and launch the server_ | | All the examples are sending ajax packages, no html is being generated by the server. Pleas take a look at the source code and consider this technique in your future projects. | | client request | | \{"cmd":"order", | \ "sid":"bac0c1f9a9362f9e", | \ "input":"..."} | | server response | | \{"cmd":"order", | \ "sid":"bac0c1f9a9362f9e", | \ "uid":"gert", | \ "gid":"admin", | \ "output":"..."} .. _python3: http://python.org/download/ .. _server: http://appwsgi.googlecode.com/files/server.py From rantingrick at gmail.com Sat Jan 1 19:39:24 2011 From: rantingrick at gmail.com (rantingrick) Date: Sat, 1 Jan 2011 16:39:24 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <4d1ce2d4$0$29968$c3e8da3$5496439d@news.astraweb.com> <4c682692-dc0f-4055-9587-eb7cce169ef6@g26g2000vbz.googlegroups.com> <661858a7-2eaa-4ba5-a014-0805707f0a3f@p8g2000vbs.googlegroups.com> <6895332e-26dd-4306-ada9-d44533a3c7ab@l8g2000yqh.googlegroups.com> <7de8ad23-5613-46e4-8330-0eaa3d428935@j29g2000yqm.googlegroups.com> <23b1017b-2b14-457d-b4df-0219989940db@f30g2000yqa.googlegroups.com> Message-ID: On Jan 1, 5:39?pm, CM wrote: > And I don't see this as a problem anyway. ?I wanted to do GUI > programming in Python, so I read a bit, chose wxPython, downloaded it, > and started learning it. ?Done. I, I, I...Me,Me,Me. Seems you are only concerned about yourself CM. However this a community discussion. You must put your wants and needs in the backseat before you can see what is best for the Python community as a whole. From tyler at tysdomain.com Sat Jan 1 19:54:38 2011 From: tyler at tysdomain.com (Littlefield, Tyler) Date: Sat, 01 Jan 2011 17:54:38 -0700 Subject: nagios Message-ID: <4D1FCCCE.1030403@tysdomain.com> Adam, Frankly, I am getting really tired of listening to you. I've seen numerous good posts on this list, some post more good quality information and arguments than others, and so far I have yet to see any post of yours where you do not resort to insults and totally avoid the argument. I understand people have different views, but all you are doing is insulting anyone who dares not to agree with you, while making yourself look childish and pathetic in the attempt. So: Eeither 1) Shut up and quit wasting bandwidth, or 2) Grow up and recognize that your being rude is not going to get you anywhere. If you have different views, that's great, but your resorting to insults for lack of anything better is getting really old. While I do recognize that this isn't much better than what you are posting, I hope that you will read it or that something will be done about your responses, as they are contributing nothing at all useful to any discussions. On 1/1/2011 4:55 PM, Adam Skutt wrote: > On Jan 1, 6:21 pm, Robert wrote: >> Really? How many templating systems does Python have? More than one? >> Why is that? How many web frameworks does Perl have? More than one? Why >> is that? >> >> Why *was* Nagios forked and re-written in Python? >> >> There are too many examples to count. >> > You're missing the point: you've yet to provide any sort of argument > whatsoever. It's not automatically true that rewriting Nagios in Tcl > would gain the Tcl community more exposure, nor is it automatically > true that more exposure is a good or desirable thing. > > You first have to show how rewriting Nagios in Tcl would gain them > more exposure. Then you have to show that the exposure would be a > good thing. Until you've done both, you're arguing with very > fundamental and conventional engineering wisdom; and you have not > actually presented an argument just tautologies. > > Neither will be easy to prove, by and by large, most people don't give > a shit what language their applications are written in and rightly so. > >> Just gave you a bunch. > No, you've given me examples of wheel reinvention. Just because the > people reinventing the wheel thought it was a good thing doesn't > actually make it so. You personally have to present the case as to > why it is a good thing. > >> I want to apologize for my part. We just aren't going to see the same >> side of this. > You can apologize, but I don't accept it. You want to actually > apologize? Admit you were wrong and retract, or act like an adult and > present an actual argument instead of wasting time. > > Adam -- Thanks, Ty From fabiofz at gmail.com Sat Jan 1 20:37:06 2011 From: fabiofz at gmail.com (Fabio Zadrozny) Date: Sat, 1 Jan 2011 23:37:06 -0200 Subject: Pydev 1.6.4 Released Message-ID: Hi All, Pydev 1.6.4 has been released Details on Pydev: http://pydev.org Details on its development: http://pydev.blogspot.com Release Highlights: ------------------------------- * Improved Unittest integration: o Created a PyUnit view (with a red/green bar) which can be used to see the results of tests and relaunching them o The default test runner now allows parallel execution (distributing tests by module or individually) o The nose and py.test test runners are also supported now * Major Bug Fixed: existing interpreters could be corrupted when adding a new one * Fixed AttributeError on console startup in Python 3.0 * Added theming and automatic sash orientation to the pydev code coverage view * Patch by frigo7: When creating a new remote debugger target, the terminated ones are removed * Patch by frigo7: compare editor properly showing the revision information and fixed broken shortcuts (e.g.: ctrl+z) * Read-only files no longer editable in pydev actions * Fixed issue of remaining \r on python 3.0 on input() * The pydev parser is now properly dealing with bom (utf-8) * Assign to local: if method starts with '_', the leading '_' is not added to the local What is PyDev? --------------------------- PyDev is a plugin that enables users to use Eclipse for Python, Jython and IronPython development -- making Eclipse a first class Python IDE -- It comes with many goodies such as code completion, syntax highlighting, syntax analysis, refactor, debug and many others. Cheers, -- Fabio Zadrozny ------------------------------------------------------ Software Developer Aptana http://aptana.com/ Pydev - Python Development Environment for Eclipse http://pydev.org http://pydev.blogspot.com From rich at noir.com Sat Jan 1 20:55:10 2011 From: rich at noir.com (K. Richard Pixley) Date: Sat, 01 Jan 2011 17:55:10 -0800 Subject: @property; @classmethod; def f() Message-ID: <2WQTo.29689$Qi5.28495@newsfe01.iad> Can anyone explain to me why this doesn't work? class Foo(object): @property @classmethod def f(cls): return 4 I mean, I think it seems to be syntactically clear what I'm trying to accomplish. What am I missing? --rich From Joshua.R.English at gmail.com Sat Jan 1 20:59:33 2011 From: Joshua.R.English at gmail.com (Josh English) Date: Sat, 1 Jan 2011 17:59:33 -0800 (PST) Subject: Multiple instances and wrong parental links Message-ID: <1137ce0f-cc28-4aae-a3d1-2cda66ac389a@glegroupsg2000goo.googlegroups.com> I have hit yet another wall. I am dynamically creating a class and then creating instances of that class. The class relies on a second class to store a list of objects. (This is simplified from the the original by a factor of about 20. The real program is trying to create a Python object around an XML definition object.) Here's the code: ## OPTION ONE for class: ElementList ### Not really a list, but a wrapper that behaves like a list class ElementList(object): def __init__(self, parent, name): self._parent = parent self._name = name def MakeWrapper(checker, _addNameAsAttribute = False ): ## OPTION TWO for class: ElementList class Wrap(object): ## OPTION THREE for class: Elementlist def __init__(self, name): self._name = name setattr(Wrap, 'stuff', ElementList(self, 'test')) Wrap.__name__= checker.title() return Wrap if __name__ == '__main__': Dude = MakeWrapper('Dude') print Dude d1 = Dude('Josh') print d1, d1.stuff # creating the second instance changes the behavior of the subclass d2 = Dude('Ben') print d2, d2.stuff print d1.stuff._parent print d2.stuff._parent #creating a third instance changes the behavior of all the subclasses d3 = Dude('David') print d3, d3.stuff print d1.stuff._parent, d2.stuff._parent, d3.stuff._parent ## END CODE And here is the output: >>> <__main__.Dude object at 0x00DFB930> <__main__.ElementList object at 0x00DFB950> <__main__.Dude object at 0x00DFB730> <__main__.ElementList object at 0x00DFB770> <__main__.Dude object at 0x00DFB730> <__main__.Dude object at 0x00DFB730> <__main__.Dude object at 0x00DFB870> <__main__.ElementList object at 0x00DFB9B0> <__main__.Dude object at 0x00DFB870> <__main__.Dude object at 0x00DFB870> <__main__.Dude object at 0x00DFB870> The 'stuff' attribute is an ElementList object linked back to the parent instance, but every time I create an instance, every instance's 'stuff' links back to the last instance created. I'm not sure why this is happening, or how to prevent it. Any suggestions? From ian.g.kelly at gmail.com Sat Jan 1 21:42:09 2011 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Sat, 01 Jan 2011 19:42:09 -0700 Subject: @property; @classmethod; def f() In-Reply-To: <2WQTo.29689$Qi5.28495@newsfe01.iad> References: <2WQTo.29689$Qi5.28495@newsfe01.iad> Message-ID: On 1/1/2011 6:55 PM, K. Richard Pixley wrote: > Can anyone explain to me why this doesn't work? > > class Foo(object): > @property > @classmethod > def f(cls): > return 4 > > I mean, I think it seems to be syntactically clear what I'm trying to > accomplish. What am I missing? First, because classmethod returns a classmethod instance, not a function, so what gets passed to property is the classmethod descriptor, not an actual callable. Second, because a property descriptor just returns itself when accessed on the class. It only works on instances. To do what you want, I think you would need to write your own descriptor class. Something like this: class classproperty(object): def __init__(self, getter): self._getter = getter def __get__(self, instance, owner): return self._getter(owner) class Foo(object): @classproperty def f(cls): return 4 Modify as needed if you want to accomodate setters and deleters as well. Cheers, Ian From marc at marchankin.com Sat Jan 1 23:53:47 2011 From: marc at marchankin.com (marceepoo) Date: Sat, 1 Jan 2011 20:53:47 -0800 (PST) Subject: pyWin32 attempted installation; Error message: Skipping exchdapi: No library 'Ex2KSdk' Message-ID: <5b0d857d-3e1b-4426-9b86-7c558b774872@glegroupsg2000goo.googlegroups.com> I just downloaded pyWin32 (https://sourceforge.net/projects/pywin32/) and started to install it. I get these error msgs: Skipping exchange: No library 'Ex2KSdk' Skipping exchdapi: No library 'Ex2KSdk' Skipping directsound: The header 'dsound.h' can not be located Does anyone have any suggestions about how to address this? Thanks, Marceepoo From cbrown at cbrownsystems.com Sun Jan 2 00:57:15 2011 From: cbrown at cbrownsystems.com (ChasBrown) Date: Sat, 1 Jan 2011 21:57:15 -0800 (PST) Subject: Multiple instances and wrong parental links References: <1137ce0f-cc28-4aae-a3d1-2cda66ac389a@glegroupsg2000goo.googlegroups.com> Message-ID: On Jan 1, 5:59 pm, Josh English wrote: > I have hit yet another wall. I am dynamically creating a class and then creating instances of that class. The class relies on a second class to store a list of objects. (This is simplified from the the original by a factor of about 20. The real program is trying to create a Python object around an XML definition object.) > > Here's the code: > > ## OPTION ONE for class: ElementList > ### Not really a list, but a wrapper that behaves like a list > class ElementList(object): > def __init__(self, parent, name): > self._parent = parent > self._name = name > > def MakeWrapper(checker, _addNameAsAttribute = False ): > > ## OPTION TWO for class: ElementList > class Wrap(object): > > ## OPTION THREE for class: Elementlist > > def __init__(self, name): > self._name = name > setattr(Wrap, 'stuff', ElementList(self, 'test')) > > Wrap.__name__= checker.title() > > return Wrap > > if __name__ == '__main__': > > Dude = MakeWrapper('Dude') > print Dude > d1 = Dude('Josh') > print d1, d1.stuff > > # creating the second instance changes the behavior of the subclass > d2 = Dude('Ben') > print d2, d2.stuff > print d1.stuff._parent > print d2.stuff._parent > > #creating a third instance changes the behavior of all the subclasses > d3 = Dude('David') > print d3, d3.stuff > print d1.stuff._parent, d2.stuff._parent, d3.stuff._parent > > ## END CODE > > And here is the output: > > > > > <__main__.Dude object at 0x00DFB930> <__main__.ElementList object at 0x00DFB950> > <__main__.Dude object at 0x00DFB730> <__main__.ElementList object at 0x00DFB770> > <__main__.Dude object at 0x00DFB730> > <__main__.Dude object at 0x00DFB730> > <__main__.Dude object at 0x00DFB870> <__main__.ElementList object at 0x00DFB9B0> > <__main__.Dude object at 0x00DFB870> <__main__.Dude object at 0x00DFB870> <__main__.Dude object at 0x00DFB870> > > The 'stuff' attribute is an ElementList object linked back to the parent instance, but every time I create an instance, every instance's 'stuff' links back to the last instance created. > If every instance's is the same, one guesses that the has a class scope, rather than an instance scope. > I'm not sure why this is happening, or how to prevent it. > It's perfectly predictable; to understand what is happening, compare: >>> def foo(): class Bar(object): def __init__(self): setattr(Bar, 'stuff', {}) return Bar >>> Dude = foo() >>> a = Dude() >>> b = Dude() >>> a.stuff['foo'] = 2 >>> b.stuff {'foo': 2} >>> c = Dude() >>> a.stuff {} with the behavior (which I think you expected) of: >>> def foo(): class Bar(object): def __init__(self): setattr(self, 'stuff', {}) return Bar >>> Dude = foo() >>> a = Dude() >>> b = Dude() >>> a.stuff['foo'] = 2 >>> b.stuff {} >>> c = Dude() >>> a.stuff {'foo': 2} Cheers - Chas From steve+comp.lang.python at pearwood.info Sun Jan 2 02:18:48 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 02 Jan 2011 07:18:48 GMT Subject: @property; @classmethod; def f() References: <2WQTo.29689$Qi5.28495@newsfe01.iad> Message-ID: <4d2026d8$0$29968$c3e8da3$5496439d@news.astraweb.com> On Sat, 01 Jan 2011 17:55:10 -0800, K. Richard Pixley wrote: > Can anyone explain to me why this doesn't work? > > class Foo(object): > @property > @classmethod > def f(cls): > return 4 What does "doesn't work" mean? It works for me: >>> class Foo(object): ... @property ... @classmethod ... def f(cls): ... return 4 ... >>> There is no syntax error, the class is created, it works fine. What were you expecting to happen? If you instantiate the class and try accessing the property, you get the expected runtime error: >>> x = Foo() >>> x.f Traceback (most recent call last): File "", line 1, in TypeError: 'classmethod' object is not callable (Admittedly, *you* might not have expected it, but nevertheless...) property() expects a callable object, not a classmethod object, so naturally it fails. Admittedly, it's a little unexpected that classmethods aren't callable, but they're not: >>> classmethod(lambda x: 42)() Traceback (most recent call last): File "", line 1, in TypeError: 'classmethod' object is not callable Don't confuse the classmethod object with a class method (note the space!). Class methods are what you get once the descriptor mechanism kicks into action behind the scenes. classmethod objects are the descriptors that create class methods (note space) when required: >>> cm = classmethod(lambda x: 42).__get__(Spam) # descriptor protocol >>> cm of > >>> cm() 42 > I mean, I think it seems to be syntactically clear what I'm trying to > accomplish. What am I missing? An understanding of the dark and murky waters of descriptor black magic :) http://docs.python.org/howto/descriptor.html (It's not really that dark and murky. It's actually amazingly simple.) My recommendation is, forget the classmethod. A combination of property with class attributes and self.__class__ will get you what you want. Otherwise, just create your own descriptor object. The How To above shows pure-python versions of classmethod and staticmethod. -- Steven From nagle at animats.com Sun Jan 2 02:21:53 2011 From: nagle at animats.com (John Nagle) Date: Sat, 01 Jan 2011 23:21:53 -0800 Subject: Multiple instances and wrong parental links In-Reply-To: References: <1137ce0f-cc28-4aae-a3d1-2cda66ac389a@glegroupsg2000goo.googlegroups.com> Message-ID: <4d20278b$0$44015$742ec2ed@news.sonic.net> On 1/1/2011 9:57 PM, ChasBrown wrote: > setattr(Wrap, 'stuff', ElementList(self, 'test')) Right. As the previous poster wrote, that line is the basic problem. It's not entirely clear what you're trying to do, but it seems to be overly complex. You could have Wrap inherit from ElementList, if you want each Wrap class to be a subclsss of ElementList. Or simply have a line in the __init__ of Wrap like self.something = ElementList(self, whatever) John Nagle From alonmozilla at gmail.com Sun Jan 2 02:26:50 2011 From: alonmozilla at gmail.com (azakai) Date: Sat, 1 Jan 2011 23:26:50 -0800 (PST) Subject: CPython on the Web Message-ID: <19141efb-a288-43bc-be0d-44769bf5974b@j32g2000prh.googlegroups.com> Hello, I hope this will be interesting to people here: CPython running on the web, http://syntensity.com/static/python.html That isn't a new implementation of Python, but rather CPython 2.7.1, compiled from C to JavaScript using Emscripten and LLVM. For more details on the conversion process, see http://emscripten.org This is a work in progress, main issues right now are that the code isn't optimized (so don't expect good performance), and importing non- static modules doesn't work. Otherwise, though, it seems to run properly, in particular it runs all the examples in http://wiki.python.org/moin/SimplePrograms that don't rely on importing modules or receiving input from the user (with perhaps some minor formatting errors). The demo runs fine on recent versions of Firefox, Chrome and Safari, but has problems on IE9 and Opera (hopefully those will be resolved soon). The idea is that by compiling CPython itself, all the features of the language are immediately present, and at the latest version, unlike writing a new implementation which takes time and tends to lag behind. As to why run it on the web, there could be various uses, for example it could allow a simple learning environment for Python, which since it's on the web can be entered immediately without any download (and would run even in places where Python normally can't, like say an iPad). Feedback would be very welcome! - azakai From steve+comp.lang.python at pearwood.info Sun Jan 2 02:29:53 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 02 Jan 2011 07:29:53 GMT Subject: Multiple instances and wrong parental links References: <1137ce0f-cc28-4aae-a3d1-2cda66ac389a@glegroupsg2000goo.googlegroups.com> Message-ID: <4d202971$0$29968$c3e8da3$5496439d@news.astraweb.com> On Sat, 01 Jan 2011 17:59:33 -0800, Josh English wrote: > I have hit yet another wall. I am dynamically creating a class and then > creating instances of that class. The class relies on a second class to > store a list of objects. (This is simplified from the the original by a > factor of about 20. Sounds like it's about 40 times too complex then: aim for something about half the complexity of this "simplified" version. > The real program is trying to create a Python object > around an XML definition object.) > > Here's the code: > > ## OPTION ONE for class: ElementList > ### Not really a list, but a wrapper that behaves like a list class > ElementList(object): > def __init__(self, parent, name): > self._parent = parent > self._name = name Doesn't behave much like a list for me :) > def MakeWrapper(checker, _addNameAsAttribute = False ): > ## OPTION TWO for class: ElementList > class Wrap(object): > ## OPTION THREE for class: Elementlist > def __init__(self, name): > self._name = name > setattr(Wrap, 'stuff', ElementList(self, 'test')) > Wrap.__name__= checker.title() > return Wrap Your problem is that all the instances from a MakeWrapper class share the same "stuff" attribute, which is attached to the class Wrap. What you probably want is: setattr(self, 'stuff', ElementList(self, 'test')) instead. What you *need* is to rethink this complicated strategy for a simpler one. -- Steven From kevin.p.dwyer at gmail.com Sun Jan 2 05:27:36 2011 From: kevin.p.dwyer at gmail.com (Kev Dwyer) Date: Sun, 2 Jan 2011 10:27:36 +0000 (UTC) Subject: pyWin32 attempted installation; Error message: Skipping exchdapi: No library 'Ex2KSdk' References: <5b0d857d-3e1b-4426-9b86-7c558b774872@glegroupsg2000goo.googlegroups.com> Message-ID: On Sat, 01 Jan 2011 20:53:47 -0800, marceepoo wrote: > I just downloaded pyWin32 (https://sourceforge.net/projects/pywin32/) > and started to install it. > > I get these error msgs: > > Skipping exchange: No library 'Ex2KSdk' Skipping exchdapi: No library > 'Ex2KSdk' Skipping directsound: The header 'dsound.h' can not be located > > Does anyone have any suggestions about how to address this? > > Thanks, Marceepoo Are you using the binary installer or building from source? Cf http://stackoverflow.com/questions/4476764/pywin32-support-trouble-while-building-syntax-error Cheers, Kev From stefan_ml at behnel.de Sun Jan 2 07:11:56 2011 From: stefan_ml at behnel.de (Stefan Behnel) Date: Sun, 02 Jan 2011 13:11:56 +0100 Subject: How to define a bytes literal in Python 2.x for porting to Python 3.x using 2to3? In-Reply-To: References: <4D1FA593.7080503@v.loewis.de> Message-ID: Terry Reedy, 01.01.2011 23:47: > 1. Code running in multiple versions has to be syntactically correct in > every detail all versions in order to be compiled without error. However, > version specific syntax *can* be used in modules that are conditionally > imported and therefore conditionally compiled and executed. This is something that might also be a suitable solution for the OP's problem. The format strings can be by externalised into an importable module, which can then be duplicated to use the 'b' bytes prefix for Python 3. The obvious drawback is that this moves the strings out of the immediate sight of someone reading the sources, and that it requires the two string modules to be kept in sync. But at least for the synchronisation, a simplistic conversion tool run during installation could do the trick. Stefan From orasnita at gmail.com Sun Jan 2 08:18:02 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Sun, 2 Jan 2011 15:18:02 +0200 Subject: list 2 dict? Message-ID: <0DB6C288B2274DBBA5463E7771349EFB@teddy> Hi, If I want to create a dictionary from a list, is there a better way than the long line below? l = [1, 2, 3, 4, 5, 6, 7, 'a', 8, 'b'] d = dict(zip([l[x] for x in range(len(l)) if x %2 == 0], [l[x] for x in range(len(l)) if x %2 == 1])) print(d) {8: 'b', 1: 2, 3: 4, 5: 6, 7: 'a'} Thanks. Octavian From katie at coderstack.co.uk Sun Jan 2 08:29:03 2011 From: katie at coderstack.co.uk (Katie T) Date: Sun, 2 Jan 2011 13:29:03 +0000 Subject: CPython on the Web In-Reply-To: <19141efb-a288-43bc-be0d-44769bf5974b@j32g2000prh.googlegroups.com> References: <19141efb-a288-43bc-be0d-44769bf5974b@j32g2000prh.googlegroups.com> Message-ID: On Sun, Jan 2, 2011 at 7:26 AM, azakai wrote: > The idea is that by compiling CPython itself, all the features of the > language are immediately present, and at the latest version, unlike > writing a new implementation which takes time and tends to lag behind. > As to why run it on the web, there could be various uses, for example > it could allow a simple learning environment for Python, which since > it's on the web can be entered immediately without any download (and > would run even in places where Python normally can't, like say an > iPad). It looks pretty neat ! - most solutions I've seen involve running Python in a sandbox environment on the server as opposed to on the client desktop. Katie -- CoderStack http://www.coderstack.co.uk/perl-jobs The Software Developer Job Board From ian.g.kelly at gmail.com Sun Jan 2 08:37:59 2011 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Sun, 02 Jan 2011 06:37:59 -0700 Subject: list 2 dict? In-Reply-To: <0DB6C288B2274DBBA5463E7771349EFB@teddy> References: <0DB6C288B2274DBBA5463E7771349EFB@teddy> Message-ID: On 1/2/2011 6:18 AM, Octavian Rasnita wrote: > Hi, > > If I want to create a dictionary from a list, is there a better way than the long line below? > > l = [1, 2, 3, 4, 5, 6, 7, 'a', 8, 'b'] > > d = dict(zip([l[x] for x in range(len(l)) if x %2 == 0], [l[x] for x in range(len(l)) if x %2 == 1])) d = dict(zip(l[0::2], l[1::2])) Or, using the "grouper" function recipe from the itertools documentation: d = dict(grouper(2, l)) Cheers, Ian From stefan.sonnenberg at pythonmeister.com Sun Jan 2 08:40:53 2011 From: stefan.sonnenberg at pythonmeister.com (Stefan Sonnenberg-Carstens) Date: Sun, 02 Jan 2011 14:40:53 +0100 Subject: list 2 dict? In-Reply-To: <0DB6C288B2274DBBA5463E7771349EFB@teddy> References: <0DB6C288B2274DBBA5463E7771349EFB@teddy> Message-ID: <4D208065.1020106@pythonmeister.com> Am 02.01.2011 14:18, schrieb Octavian Rasnita: > l = [1, 2, 3, 4, 5, 6, 7, 'a', 8, 'b'] l = [1, 2, 3, 4, 5, 6, 7, 'a', 8, 'b'] dict(zip(l[0::2],l[1::2])) {8: 'b', 1: 2, 3: 4, 5: 6, 7: 'a'} From python at bdurham.com Sun Jan 2 08:42:08 2011 From: python at bdurham.com (python at bdurham.com) Date: Sun, 02 Jan 2011 08:42:08 -0500 Subject: CPython on the Web In-Reply-To: <19141efb-a288-43bc-be0d-44769bf5974b@j32g2000prh.googlegroups.com> References: <19141efb-a288-43bc-be0d-44769bf5974b@j32g2000prh.googlegroups.com> Message-ID: <1293975728.14009.1413126095@webmail.messagingengine.com> Azakai, WOW! That's incredible!! Thank you for sharing your work with the community. 1. Are there plans to support IE 7 or 8? 2. I'm not sure what you mean by non-static modules? Can we use modules such as json, pickle/cPickle, StringIO/cStringIO? 3. Is there a virtual file system we can take advantage of so calls to open() would work? Malcolm From orasnita at gmail.com Sun Jan 2 08:52:45 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Sun, 2 Jan 2011 15:52:45 +0200 Subject: CPython on the Web References: <19141efb-a288-43bc-be0d-44769bf5974b@j32g2000prh.googlegroups.com> Message-ID: From: "Katie T" Subject: Re: CPython on the Web > On Sun, Jan 2, 2011 at 7:26 AM, azakai wrote: >> The idea is that by compiling CPython itself, all the features of the >> language are immediately present, and at the latest version, unlike >> writing a new implementation which takes time and tends to lag behind. >> As to why run it on the web, there could be various uses, for example >> it could allow a simple learning environment for Python, which since >> it's on the web can be entered immediately without any download (and >> would run even in places where Python normally can't, like say an >> iPad). > > It looks pretty neat ! - most solutions I've seen involve running > Python in a sandbox environment on the server as opposed to on the > client desktop. > > Katie > -- I don't understand what can be this program used for. Can anyone explain please? Ok, I understand that it can be used for learning, which is pretty useless because I doubt that a Python newbie will start using Python and learning Python that way. Then, how can the Python programs run on the "desktop"? I suspect that the Python code is somehow translated to Javascript in order to run on the browser. Am I right? If yes, then how can run a Python code that access a database or one that create a web server, or a WxPython GUI run? If it can run just simple things that prints things in the browser, then why not writing that code directly in JS? As you can see, there are many things I don't understand. :-) Thank you. BTW. I have tried that page, and it appeared a JS error window telling that the JS scripts run too slow and it asked me if I want to continue. I have executed the default Python script, but nothing happend. Nothing was printed. I use Internet Explorer. Octavian From rtw at rtw.me.uk Sun Jan 2 08:56:06 2011 From: rtw at rtw.me.uk (Rob Williscroft) Date: Sun, 2 Jan 2011 13:56:06 +0000 (UTC) Subject: list 2 dict? References: <0DB6C288B2274DBBA5463E7771349EFB@teddy> Message-ID: Octavian Rasnita wrote in news:0DB6C288B2274DBBA5463E7771349EFB at teddy in gmane.comp.python.general: > Hi, > > If I want to create a dictionary from a list, is there a better way > than the long line below? > > l = [1, 2, 3, 4, 5, 6, 7, 'a', 8, 'b'] > > d = dict(zip([l[x] for x in range(len(l)) if x %2 == 0], [l[x] for x > in range(len(l)) if x %2 == 1])) > > print(d) > > {8: 'b', 1: 2, 3: 4, 5: 6, 7: 'a'} >>> dict( zip( l[ :: 2 ], l[ 1 :: 2 ] ) ) {8: 'b', 1: 2, 3: 4, 5: 6, 7: 'a'} If you don't know about slice notation, the synatax I'm using above is: list[ start : stop : step ] where I have ommited the "stop" item, which defaults to the length of the list. That will make 3 lists before it makes the dict thought, so if the list is large: >>> dict( ( l[ i ], l[ i + 1 ] ) for i in xrange( 0, len( l ), 2 ) ) may be better. Rob. From hniksic at xemacs.org Sun Jan 2 09:38:10 2011 From: hniksic at xemacs.org (Hrvoje Niksic) Date: Sun, 02 Jan 2011 15:38:10 +0100 Subject: list 2 dict? References: Message-ID: <87zkrjl6b1.fsf@xemacs.org> "Octavian Rasnita" writes: > If I want to create a dictionary from a list, is there a better way than the long line below? > > l = [1, 2, 3, 4, 5, 6, 7, 'a', 8, 'b'] > > d = dict(zip([l[x] for x in range(len(l)) if x %2 == 0], [l[x] for x in range(len(l)) if x %2 == 1])) > > print(d) > > {8: 'b', 1: 2, 3: 4, 5: 6, 7: 'a'} it = iter(l) d = dict(izip(it, it)) izip is the iterator equivalent of zip, import it from itertools. (Or, if your list is short, just use zip instead.) It can be written in a single short line, at the cost of additional obfuscation: d = dict(izip(*[iter(l)]*2)) From orasnita at gmail.com Sun Jan 2 10:09:38 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Sun, 2 Jan 2011 17:09:38 +0200 Subject: list 2 dict? References: <0DB6C288B2274DBBA5463E7771349EFB@teddy> Message-ID: From: "Rob Williscroft" > Octavian Rasnita wrote in news:0DB6C288B2274DBBA5463E7771349EFB at teddy in > gmane.comp.python.general: > >> Hi, >> >> If I want to create a dictionary from a list, is there a better way >> than the long line below? >> >> l = [1, 2, 3, 4, 5, 6, 7, 'a', 8, 'b'] >> >> d = dict(zip([l[x] for x in range(len(l)) if x %2 == 0], [l[x] for x >> in range(len(l)) if x %2 == 1])) >> >> print(d) >> >> {8: 'b', 1: 2, 3: 4, 5: 6, 7: 'a'} > >>>> dict( zip( l[ :: 2 ], l[ 1 :: 2 ] ) ) > {8: 'b', 1: 2, 3: 4, 5: 6, 7: 'a'} > > If you don't know about slice notation, the synatax I'm using above is: > > list[ start : stop : step ] > > where I have ommited the "stop" item, which defaults to the length of the > list. > > > list-tuple-bytearray-buffer-xrange> > > That will make 3 lists before it makes the dict thought, so if the > list is large: > > >>> dict( ( l[ i ], l[ i + 1 ] ) for i in xrange( 0, len( l ), 2 ) ) > > may be better. Thank you all. I have also discovered that I can zip 2 lists made with range(0, len(l), 2) and range(1, len(l), 2) but I remembered about that the slice notation accepts that third argument and as Stefan suggested, looks to be a shorter way. I have first thought to the solution you suggested, but I have forgotten to create a tuple from the pair of elements so it didn't work. I wasn't thinking to performance, but yes, it may be important for large lists. It seems that in some cases there are more ways to do it in Python than in Perl. :-) Octavian From stefan.sonnenberg at pythonmeister.com Sun Jan 2 10:15:41 2011 From: stefan.sonnenberg at pythonmeister.com (Stefan Sonnenberg-Carstens) Date: Sun, 02 Jan 2011 16:15:41 +0100 Subject: list 2 dict? In-Reply-To: <0DB6C288B2274DBBA5463E7771349EFB@teddy> References: <0DB6C288B2274DBBA5463E7771349EFB@teddy> Message-ID: <4D20969D.6040901@pythonmeister.com> Am 02.01.2011 14:18, schrieb Octavian Rasnita: > Hi, > > If I want to create a dictionary from a list, is there a better way than the long line below? > > l = [1, 2, 3, 4, 5, 6, 7, 'a', 8, 'b'] > > d = dict(zip([l[x] for x in range(len(l)) if x %2 == 0], [l[x] for x in range(len(l)) if x %2 == 1])) > > print(d) > > {8: 'b', 1: 2, 3: 4, 5: 6, 7: 'a'} > > Thanks. > > Octavian > Or so: dict(zip((y for x,y in enumerate(l) if x%2==0),(y for x,y in enumerate(l) if not x%2==0))) From orasnita at gmail.com Sun Jan 2 10:36:35 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Sun, 2 Jan 2011 17:36:35 +0200 Subject: list 2 dict? References: <0DB6C288B2274DBBA5463E7771349EFB@teddy> Message-ID: <3C5DC041709F47AA8F2D738D5AF93574@teddy> From: "Ian Kelly" > On 1/2/2011 6:18 AM, Octavian Rasnita wrote: >> Hi, >> >> If I want to create a dictionary from a list, is there a better way than the long line below? >> >> l = [1, 2, 3, 4, 5, 6, 7, 'a', 8, 'b'] >> >> d = dict(zip([l[x] for x in range(len(l)) if x %2 == 0], [l[x] for x in range(len(l)) if x %2 == 1])) > > d = dict(zip(l[0::2], l[1::2])) > > Or, using the "grouper" function recipe from the itertools documentation: > > d = dict(grouper(2, l)) > > Cheers, > Ian The grouper-way looks nice, but I tried it and it didn't work: from itertools import * ... d = dict(grouper(2, l)) NameError: name 'grouper' is not defined I use Python 2.7. Should it work with this version? Octavian From stefan.sonnenberg at pythonmeister.com Sun Jan 2 11:31:22 2011 From: stefan.sonnenberg at pythonmeister.com (Stefan Sonnenberg-Carstens) Date: Sun, 02 Jan 2011 17:31:22 +0100 Subject: list 2 dict? In-Reply-To: <3C5DC041709F47AA8F2D738D5AF93574@teddy> References: <0DB6C288B2274DBBA5463E7771349EFB@teddy> <3C5DC041709F47AA8F2D738D5AF93574@teddy> Message-ID: <4D20A85A.6080607@pythonmeister.com> Am 02.01.2011 16:36, schrieb Octavian Rasnita: > From: "Ian Kelly" > > >> On 1/2/2011 6:18 AM, Octavian Rasnita wrote: >>> Hi, >>> >>> If I want to create a dictionary from a list, is there a better way than the long line below? >>> >>> l = [1, 2, 3, 4, 5, 6, 7, 'a', 8, 'b'] >>> >>> d = dict(zip([l[x] for x in range(len(l)) if x %2 == 0], [l[x] for x in range(len(l)) if x %2 == 1])) >> d = dict(zip(l[0::2], l[1::2])) >> >> Or, using the "grouper" function recipe from the itertools documentation: >> >> d = dict(grouper(2, l)) >> >> Cheers, >> Ian > > The grouper-way looks nice, but I tried it and it didn't work: > > from itertools import * > ... > d = dict(grouper(2, l)) > > NameError: name 'grouper' is not defined > > I use Python 2.7. Should it work with this version? > Octavian > A last one: l = [1, 2, 3, 4, 5, 6, 7, 'a', 8, 'b'] dict((x[1],x[0]) for x in ((l.pop(),l.pop()) for x in xrange(len(l)/2))) From rockitout117 at yahoo.com Sun Jan 2 12:26:35 2011 From: rockitout117 at yahoo.com (Maurice Shih) Date: Sun, 2 Jan 2011 09:26:35 -0800 (PST) Subject: Python programming Message-ID: <854042.15917.qm@web59802.mail.ac4.yahoo.com> Dear python-list at python.org, I am making a program of the quadratic sieve on python 2.5.2. I am also using sympy to find linear dependencies in mod 2. For example matrix A is : 10110 01101 00011 10000 And using sympy I can type in a command to solve ax=0, which is: 10000=0 01002=0 0010-1=0 00011=0 To find the values of vector x is easy by hand if you assign one value as 1, but I was wondering if I could turn the numbers into letters ( variables) so I could run the solve command in sympy. Thank you for listening to by question and I hope that you can help me. Thank you again. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gervaz at gmail.com Sun Jan 2 12:43:38 2011 From: gervaz at gmail.com (gervaz) Date: Sun, 2 Jan 2011 09:43:38 -0800 (PST) Subject: String building using join References: Message-ID: On 31 Dic 2010, 16:43, Emile van Sebille wrote: > On 12/31/2010 7:22 AM gervaz said... > > > > > > > Hi all, I would like to ask you how I can use the more efficient join > > operation in a code like this: > > >>>> class Test: > > ... ? ? def __init__(self, v1, v2): > > ... ? ? ? ? self.v1 = v1 > > ... ? ? ? ? self.v2 = v2 > > ... > >>>> def prg(l): > > ... ? ? txt = "" > > ... ? ? for x in l: > > ... ? ? ? ? if x.v1 is not None: > > ... ? ? ? ? ? ? txt += x.v1 + "\n" > > ... ? ? ? ? if x.v2 is not None: > > ... ? ? ? ? ? ? txt += x.v2 + "\n" > > ... ? ? return txt > > ... > >>>> t1 = Test("hello", None) > >>>> t2 = Test(None, "ciao") > >>>> t3 = Test("salut", "hallo") > >>>> t = [t1, t2, t3] > > >>>> prg(t) > > 'hello\nciao\nsalut\nhallo\n' > > > The idea would be create a new list with the values not None and then > > use the join function... but I don't know if it is really worth it. > > Any hint? > > >>>> def prg2(l): > > ? ? ? ? ? ? ?return "\n".join([x for x in l if x]) > > Emile > > > > > ... ? ? e = [] > > ... ? ? for x in l: > > ... ? ? ? ? if x.v1 is not None: > > ... ? ? ? ? ? ? e.append(x.v1) > > ... ? ? ? ? if x.v2 is not None: > > ... ? ? ? ? ? ? e.append(x.v2) > > ... ? ? return "\n".join(e) > > ... > >>>> prg2(t) > > 'hello\nciao\nsalut\nhallo' > > > Thanks, Mattia- Nascondi testo citato > > - Mostra testo citato -- Nascondi testo citato > > - Mostra testo citato - Sorry, but it does not work >>> def prg3(l): ... return "\n".join([x for x in l if x]) ... >>> prg3(t) Traceback (most recent call last): File "", line 1, in File "", line 2, in prg3 TypeError: sequence item 0: expected str instance, Test found From gervaz at gmail.com Sun Jan 2 12:56:28 2011 From: gervaz at gmail.com (gervaz) Date: Sun, 2 Jan 2011 09:56:28 -0800 (PST) Subject: Interrput a thread References: <81c24eb1-41b6-442a-a971-8a44d2cd6c1b@p8g2000vbs.googlegroups.com> <4d1e20c5$0$43986$742ec2ed@news.sonic.net> Message-ID: On 31 Dic 2010, 23:25, Alice Bevan?McGregor wrote: > On 2010-12-31 10:28:26 -0800, John Nagle said: > > > Even worse, sending control-C to a multi-thread program > > is unreliable in CPython. ?See "http://blip.tv/file/2232410" > > for why. ?It's painful. > > AFIK, that has been resolved in Python 3.2 with the introduction of an > intelligent thread scheduler as part of the GIL release/acquire process. > > ? ? ? ? - Alice. Ok, but then suppose I have multiple long running threads that I want to delete/suspend because they are tooking too much time, which solution do you propose? Thanks, Mattia From alex at moreati.org.uk Sun Jan 2 13:07:44 2011 From: alex at moreati.org.uk (Alex Willmer) Date: Sun, 2 Jan 2011 10:07:44 -0800 (PST) Subject: list 2 dict? In-Reply-To: Message-ID: <69d86a8a-fef5-4da1-99d0-b6c73a73e748@glegroupsg2000goo.googlegroups.com> On Sunday, January 2, 2011 3:36:35 PM UTC, T wrote: > The grouper-way looks nice, but I tried it and it didn't work: > > from itertools import * > ... > d = dict(grouper(2, l)) > > NameError: name 'grouper' is not defined > > I use Python 2.7. Should it work with this version? No. As Ian said grouper() is a receipe in the itertools documentation. http://docs.python.org/library/itertools.html#recipes The module doesn't provide it directly From alex at moreati.org.uk Sun Jan 2 13:07:44 2011 From: alex at moreati.org.uk (Alex Willmer) Date: Sun, 2 Jan 2011 10:07:44 -0800 (PST) Subject: list 2 dict? In-Reply-To: Message-ID: <69d86a8a-fef5-4da1-99d0-b6c73a73e748@glegroupsg2000goo.googlegroups.com> On Sunday, January 2, 2011 3:36:35 PM UTC, T wrote: > The grouper-way looks nice, but I tried it and it didn't work: > > from itertools import * > ... > d = dict(grouper(2, l)) > > NameError: name 'grouper' is not defined > > I use Python 2.7. Should it work with this version? No. As Ian said grouper() is a receipe in the itertools documentation. http://docs.python.org/library/itertools.html#recipes The module doesn't provide it directly From alex at moreati.org.uk Sun Jan 2 13:11:50 2011 From: alex at moreati.org.uk (Alex Willmer) Date: Sun, 2 Jan 2011 10:11:50 -0800 (PST) Subject: String building using join In-Reply-To: Message-ID: On Sunday, January 2, 2011 5:43:38 PM UTC, gervaz wrote: > Sorry, but it does not work > > >>> def prg3(l): > ... return "\n".join([x for x in l if x]) > ... > >>> prg3(t) > Traceback (most recent call last): > File "", line 1, in > File "", line 2, in prg3 > TypeError: sequence item 0: expected str instance, Test found def prg3(l): return '\n'.join([str(x) for x in l if x]) That should do it From emile at fenx.com Sun Jan 2 13:14:12 2011 From: emile at fenx.com (Emile van Sebille) Date: Sun, 02 Jan 2011 10:14:12 -0800 Subject: String building using join In-Reply-To: References: Message-ID: On 1/2/2011 9:43 AM gervaz said... > On 31 Dic 2010, 16:43, Emile van Sebille wrote: >> On 12/31/2010 7:22 AM gervaz said... >> >> >> >> >> >>> Hi all, I would like to ask you how I can use the more efficient join >>> operation in a code like this: >> >>>>>> class Test: >>> ... def __init__(self, v1, v2): >>> ... self.v1 = v1 >>> ... self.v2 = v2 >>> ... >>>>>> def prg(l): >>> ... txt = "" >>> ... for x in l: >>> ... if x.v1 is not None: >>> ... txt += x.v1 + "\n" >>> ... if x.v2 is not None: >>> ... txt += x.v2 + "\n" >>> ... return txt >>> ... >>>>>> t1 = Test("hello", None) >>>>>> t2 = Test(None, "ciao") >>>>>> t3 = Test("salut", "hallo") >>>>>> t = [t1, t2, t3] >> >>>>>> prg(t) >>> 'hello\nciao\nsalut\nhallo\n' >> >>> The idea would be create a new list with the values not None and then >>> use the join function... but I don't know if it is really worth it. >>> Any hint? >> >>>>>> def prg2(l): >> >> return "\n".join([x for x in l if x]) >> >> Emile >> >> >> >>> ... e = [] >>> ... for x in l: >>> ... if x.v1 is not None: >>> ... e.append(x.v1) >>> ... if x.v2 is not None: >>> ... e.append(x.v2) >>> ... return "\n".join(e) >>> ... >>>>>> prg2(t) >>> 'hello\nciao\nsalut\nhallo' >> >>> Thanks, Mattia- Nascondi testo citato >> >> - Mostra testo citato -- Nascondi testo citato >> >> - Mostra testo citato - > > Sorry, but it does not work Oh -- you want a working solution, not a hint? OK. class Test: def __init__(self, v1, v2): self.v1 = v1 self.v2 = v2 t1 = Test("hello", None) t2 = Test(None, "ciao") t3 = Test("salut", "hallo") t = [t1, t2, t3] "\n".join([y for x in t for y in [x.v1,x.v2] if y]) Emile > >>>> def prg3(l): > ... return "\n".join([x for x in l if x]) > ... >>>> prg3(t) > Traceback (most recent call last): > File "", line 1, in > File "", line 2, in prg3 > TypeError: sequence item 0: expected str instance, Test found From emile at fenx.com Sun Jan 2 13:19:27 2011 From: emile at fenx.com (Emile van Sebille) Date: Sun, 02 Jan 2011 10:19:27 -0800 Subject: list 2 dict? In-Reply-To: <4D20A85A.6080607@pythonmeister.com> References: <0DB6C288B2274DBBA5463E7771349EFB@teddy> <3C5DC041709F47AA8F2D738D5AF93574@teddy> <4D20A85A.6080607@pythonmeister.com> Message-ID: On 1/2/2011 8:31 AM Stefan Sonnenberg-Carstens said... > A last one: > > l = [1, 2, 3, 4, 5, 6, 7, 'a', 8, 'b'] > dict((x[1],x[0]) for x in ((l.pop(),l.pop()) for x in xrange(len(l)/2))) This also works: l = [1, 2, 3, 4, 5, 6, 7, 'a', 8, 'b'] pop=l.pop dict([(pop(),pop()) for i in l]) From emile at fenx.com Sun Jan 2 13:22:02 2011 From: emile at fenx.com (Emile van Sebille) Date: Sun, 02 Jan 2011 10:22:02 -0800 Subject: list 2 dict? In-Reply-To: <4D20A85A.6080607@pythonmeister.com> References: <0DB6C288B2274DBBA5463E7771349EFB@teddy> <3C5DC041709F47AA8F2D738D5AF93574@teddy> <4D20A85A.6080607@pythonmeister.com> Message-ID: On 1/2/2011 8:31 AM Stefan Sonnenberg-Carstens said... Nevermind -- my bad. Emile From catalinfest at gmail.com Sun Jan 2 13:40:45 2011 From: catalinfest at gmail.com (catalinfest at gmail.com) Date: Sun, 2 Jan 2011 10:40:45 -0800 (PST) Subject: Where is win32service Message-ID: <3651f11b-f4cc-4c03-b51f-513a0a85b977@p38g2000vbn.googlegroups.com> I install Python 2.7 on Windows XP. I try use : import win32service import win32serviceutil But I got that error : ImportError: No module named win32service Where is this module ? From stefan.sonnenberg at pythonmeister.com Sun Jan 2 13:42:35 2011 From: stefan.sonnenberg at pythonmeister.com (Stefan Sonnenberg-Carstens) Date: Sun, 02 Jan 2011 19:42:35 +0100 Subject: list 2 dict? In-Reply-To: References: <0DB6C288B2274DBBA5463E7771349EFB@teddy> <3C5DC041709F47AA8F2D738D5AF93574@teddy> <4D20A85A.6080607@pythonmeister.com> Message-ID: <4D20C71B.5000302@pythonmeister.com> Am 02.01.2011 19:19, schrieb Emile van Sebille: > On 1/2/2011 8:31 AM Stefan Sonnenberg-Carstens said... > >> A last one: >> >> l = [1, 2, 3, 4, 5, 6, 7, 'a', 8, 'b'] >> dict((x[1],x[0]) for x in ((l.pop(),l.pop()) for x in xrange(len(l)/2))) > > This also works: > > > l = [1, 2, 3, 4, 5, 6, 7, 'a', 8, 'b'] > > pop=l.pop > > dict([(pop(),pop()) for i in l]) > No, it does not: >>> l = [1, 2, 3, 4, 5, 6, 7, 'a', 8, 'b'] >>> >>> pop=l.pop >>> >>> dict([(pop(),pop()) for i in l]) {'a': 7, 'b': 8, 4: 3, 6: 5} >>> From alex at moreati.org.uk Sun Jan 2 13:58:53 2011 From: alex at moreati.org.uk (Alex Willmer) Date: Sun, 2 Jan 2011 10:58:53 -0800 (PST) Subject: Where is win32service In-Reply-To: <3651f11b-f4cc-4c03-b51f-513a0a85b977@p38g2000vbn.googlegroups.com> Message-ID: <5106f086-85d2-40b3-bc11-ea8e25467947@glegroupsg2000goo.googlegroups.com> On Sunday, January 2, 2011 6:40:45 PM UTC, catalinfest at gmail.com wrote: > I install Python 2.7 on Windows XP. > I try use : > > import win32service > import win32serviceutil > > But I got that error : > > ImportError: No module named win32service > Where is this module ? It's part of the pywin32 (aka win32all) package http://sourceforge.net/projects/pywin32/ The latest download for your Python version is http://sourceforge.net/projects/pywin32/files/pywin32/Build%20214/pywin32-214.win32-py2.7.exe/download Regards, Alex From alonmozilla at gmail.com Sun Jan 2 14:19:56 2011 From: alonmozilla at gmail.com (azakai) Date: Sun, 2 Jan 2011 11:19:56 -0800 (PST) Subject: CPython on the Web References: <19141efb-a288-43bc-be0d-44769bf5974b@j32g2000prh.googlegroups.com> Message-ID: <2d76370f-4866-4428-8a3a-91b29197dc01@c17g2000prm.googlegroups.com> On Jan 2, 5:42?am, pyt... at bdurham.com wrote: > > 1. Are there plans to support IE 7 or 8? I think it might run slowly there, but otherwise sure, it should run - the code is intended to be valid JavaScript (if it isn't, that's a bug). Currently though a minor issue prevents it from running on IE, I have been told (I don't have a Windows machine to test on myself), http://code.google.com/p/emscripten/issues/detail?id=22 > > 2. I'm not sure what you mean by non-static modules? Can we use modules > such as json, pickle/cPickle, StringIO/cStringIO? > Sorry, I should have been more clear. There isn't support for dlopen(), which opens dynamically linked libraries. That means that you can import libraries like sys, which are already linked into python. But loading a module that exists as a separate file won't work yet (but hopefully soon). > 3. Is there a virtual file system we can take advantage of so calls to > open() would work? > No, not yet, the libc implementation used just has stubs for input/ output stuff so far. Work in progress ;) - azakai From alonmozilla at gmail.com Sun Jan 2 14:29:09 2011 From: alonmozilla at gmail.com (azakai) Date: Sun, 2 Jan 2011 11:29:09 -0800 (PST) Subject: CPython on the Web References: <19141efb-a288-43bc-be0d-44769bf5974b@j32g2000prh.googlegroups.com> Message-ID: On Jan 2, 5:52?am, "Octavian Rasnita" wrote: > > Then, how can the Python programs run on the "desktop"? > I suspect that the Python code is somehow translated to Javascript in order to run on the browser. Am I right? To clarify, in this demo, CPython itself - the C implementation of Python - was translated from C to JavaScript (or more specifically, C to LLVM, and LLVM to JavaScript). So your web browser is running the same CPython that you would run on your computer normally. That CPython executes Python by compiling it into bytecode, etc., and that is exactly the same with CPython normally and CPython on the web in this demo. So actual Python code is not translated into JavaScript (which is the approach pyjamas takes), instead the entire interpreter is. > > If yes, then how can run a Python code that access a database or one that create a web server, or a WxPython GUI run? By implementing whatever library functions and system calls CPython needs, in the browser. For example, if the CPython code calls printf() to print stuff, then we need to implement printf() in JavaScript, and so forth. Obviously there are limitations of the JS environment, so not everything can be done. > > BTW. I have tried that page, and it appeared a JS error window telling that the JS scripts run too slow and it asked me if I want to continue. > I have executed the default Python script, but nothing happend. Nothing was printed. I use Internet Explorer. > I've been told it doesn't run properly on IE, we have a bug open on that, sorry. It will work on Firefox, Chrome and Safari right now. - azakai From python.list at tim.thechases.com Sun Jan 2 14:49:36 2011 From: python.list at tim.thechases.com (Tim Chase) Date: Sun, 02 Jan 2011 13:49:36 -0600 Subject: Tkinter: The good, the bad, and the ugly! In-Reply-To: References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <4d1ce2d4$0$29968$c3e8da3$5496439d@news.astraweb.com> <4c682692-dc0f-4055-9587-eb7cce169ef6@g26g2000vbz.googlegroups.com> <661858a7-2eaa-4ba5-a014-0805707f0a3f@p8g2000vbs.googlegroups.com> <6895332e-26dd-4306-ada9-d44533a3c7ab@l8g2000yqh.googlegroups.com> <7de8ad23-5613-46e4-8330-0eaa3d428935@j29g2000yqm.googlegroups.com> <23b1017b-2b14-457d-b4df-0219989940db@f30g2000yqa.googlegroups.com> Message-ID: <4D20D6D0.7000603@tim.thechases.com> On 01/01/2011 06:39 PM, rantingrick wrote: > On Jan 1, 5:39 pm, CM wrote: > >> And I don't see this as a problem anyway. I wanted to do GUI >> programming in Python, so I read a bit, chose wxPython, downloaded it, >> and started learning it. Done. > > I, I, I...Me,Me,Me. > > Seems you are only concerned about yourself CM. However this a > community discussion. You must put your wants and needs in the > backseat before you can see what is best for the Python community as a > whole. Pot? Meet Kettle... Given that the community response has largely been an overwhelming "meh, show me some code" rather than an "I whole-heartedly agree with rantingrick", your use of "we" in your emails sounds more like a "royal we"[1] than a community-based concern. "best for the Python community" seems to be something that doesn't break backwards compat. with existing code-bases, works across a multitude of platforms, has a minimal install footprint, and a proven track-record of meeting those needs. Tkinter and wx both seem to satisfy most of those requirements, except that wx seems to have a larger footprint and not have been production-ready at the time a decision needed to be made for inclusion of a gui-library in Python. (I also don't know if there are licensing concerns with wx vs. tk and their interplay with the Python license). -tkc [1] http://en.wikipedia.org/wiki/Royal_we From cmpython at gmail.com Sun Jan 2 15:52:20 2011 From: cmpython at gmail.com (CM) Date: Sun, 2 Jan 2011 12:52:20 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <4c682692-dc0f-4055-9587-eb7cce169ef6@g26g2000vbz.googlegroups.com> <661858a7-2eaa-4ba5-a014-0805707f0a3f@p8g2000vbs.googlegroups.com> <6895332e-26dd-4306-ada9-d44533a3c7ab@l8g2000yqh.googlegroups.com> <7de8ad23-5613-46e4-8330-0eaa3d428935@j29g2000yqm.googlegroups.com> <23b1017b-2b14-457d-b4df-0219989940db@f30g2000yqa.googlegroups.com> Message-ID: <301e3cfd-68ed-4eac-a7a4-c6b8f9f20c56@g26g2000vbz.googlegroups.com> On Jan 1, 7:39?pm, rantingrick wrote: > On Jan 1, 5:39?pm, CM wrote: > > > And I don't see this as a problem anyway. ?I wanted to do GUI > > programming in Python, so I read a bit, chose wxPython, downloaded it, > > and started learning it. ?Done. > > I, I, I...Me,Me,Me. > > Seems you are only concerned about yourself CM. However this a > community discussion. You must put your wants and needs in the > backseat before you can see what is best for the Python community as a > whole. Must have been too many holiday baked goods that made me even try... From greno at verizon.net Sun Jan 2 16:01:53 2011 From: greno at verizon.net (Gerry Reno) Date: Sun, 02 Jan 2011 16:01:53 -0500 Subject: CPython on the Web In-Reply-To: <19141efb-a288-43bc-be0d-44769bf5974b@j32g2000prh.googlegroups.com> References: <19141efb-a288-43bc-be0d-44769bf5974b@j32g2000prh.googlegroups.com> Message-ID: <4D20E7C1.5070207@verizon.net> On 01/02/2011 02:26 AM, azakai wrote: > Hello, I hope this will be interesting to people here: CPython running > on the web, > > http://syntensity.com/static/python.html > > That isn't a new implementation of Python, but rather CPython 2.7.1, > compiled from C to JavaScript using Emscripten and LLVM. For more > details on the conversion process, see http://emscripten.org > > This is a work in progress, main issues right now are that the code > isn't optimized (so don't expect good performance), and importing non- > static modules doesn't work. Otherwise, though, it seems to run > properly, in particular it runs all the examples in > http://wiki.python.org/moin/SimplePrograms that don't rely on > importing modules or receiving input from the user (with perhaps some > minor formatting errors). The demo runs fine on recent versions of > Firefox, Chrome and Safari, but has problems on IE9 and Opera > (hopefully those will be resolved soon). > > The idea is that by compiling CPython itself, all the features of the > language are immediately present, and at the latest version, unlike > writing a new implementation which takes time and tends to lag behind. > As to why run it on the web, there could be various uses, for example > it could allow a simple learning environment for Python, which since > it's on the web can be entered immediately without any download (and > would run even in places where Python normally can't, like say an > iPad). > > Feedback would be very welcome! > > - azakai > Ok, visiting this page: http://syntensity.com/static/python.html I do not see anything happen when I click 'execute' button. I'm running Firefox 3.6.3. Here is what I see both before and after clicking 'execute': ===================================== This is CPython, the standard Python implementation, compiled from C to JavaScript using Emscripten , running in your browser (without any plugins). * Most core language stuff should work, except for importing non-static modules (in other words, |import sys| will work, but other modules won't). * Please report bugs if you find them! * Tested on Firefox 4 and Chrome 10. * The editor is Skywriter . ------------------------------------------------------------------------ *Enter some Python*: import sys print 'Hello world! This is Python {} on {}'.format(sys.version, sys.platform) print 'Here are some numbers:', [2*x for x in range(5)][:4] ===================================== So what is happening is that the whole Python interpreter has been converted to Javascript and is running the browser, is that correct? Ok, but the usual browser 'sandbox' constraints would still apply would they not? And what is the build toolchain that you need if you want to convert your modules to be importable with this "CPython on the Web"? Regards, Gerry From orasnita at gmail.com Sun Jan 2 16:04:10 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Sun, 2 Jan 2011 23:04:10 +0200 Subject: list 2 dict? References: <69d86a8a-fef5-4da1-99d0-b6c73a73e748@glegroupsg2000goo.googlegroups.com> Message-ID: <29BD0F6C46F249F7A82064C7BB7E2E45@teddy> Octavian ----- Original Message ----- From: "Alex Willmer" Newsgroups: comp.lang.python To: Cc: Sent: Sunday, January 02, 2011 8:07 PM Subject: Re: list 2 dict? > On Sunday, January 2, 2011 3:36:35 PM UTC, T wrote: >> The grouper-way looks nice, but I tried it and it didn't work: >> >> from itertools import * >> ... >> d = dict(grouper(2, l)) >> >> NameError: name 'grouper' is not defined >> >> I use Python 2.7. Should it work with this version? > > No. As Ian said grouper() is a receipe in the itertools documentation. > > http://docs.python.org/library/itertools.html#recipes I know that, that is why I used: from itertools import * Isn't enough? Octavian From simon at brunningonline.net Sun Jan 2 16:22:37 2011 From: simon at brunningonline.net (Simon Brunning) Date: Sun, 2 Jan 2011 21:22:37 +0000 Subject: list 2 dict? In-Reply-To: <29BD0F6C46F249F7A82064C7BB7E2E45@teddy> References: <69d86a8a-fef5-4da1-99d0-b6c73a73e748@glegroupsg2000goo.googlegroups.com> <29BD0F6C46F249F7A82064C7BB7E2E45@teddy> Message-ID: On 2 January 2011 21:04, Octavian Rasnita wrote: >> No. As Ian said grouper() is a receipe in the itertools documentation. >> >> http://docs.python.org/library/itertools.html#recipes > > I know that, that is why I used: > > from itertools import * > > Isn't enough? Did you follow the link? grouper() is a recipe, not part of the itertools module. -- Cheers, Simon B. From gervaz at gmail.com Sun Jan 2 16:37:50 2011 From: gervaz at gmail.com (gervaz) Date: Sun, 2 Jan 2011 13:37:50 -0800 (PST) Subject: String building using join References: Message-ID: <6ca085f6-7c03-44b2-a9f2-8d77db046c7e@s9g2000vby.googlegroups.com> On 2 Gen, 19:14, Emile van Sebille wrote: > On 1/2/2011 9:43 AM gervaz said... > > > > > > > On 31 Dic 2010, 16:43, Emile van Sebille ?wrote: > >> On 12/31/2010 7:22 AM gervaz said... > > >>> Hi all, I would like to ask you how I can use the more efficient join > >>> operation in a code like this: > > >>>>>> class Test: > >>> ... ? ? def __init__(self, v1, v2): > >>> ... ? ? ? ? self.v1 = v1 > >>> ... ? ? ? ? self.v2 = v2 > >>> ... > >>>>>> def prg(l): > >>> ... ? ? txt = "" > >>> ... ? ? for x in l: > >>> ... ? ? ? ? if x.v1 is not None: > >>> ... ? ? ? ? ? ? txt += x.v1 + "\n" > >>> ... ? ? ? ? if x.v2 is not None: > >>> ... ? ? ? ? ? ? txt += x.v2 + "\n" > >>> ... ? ? return txt > >>> ... > >>>>>> t1 = Test("hello", None) > >>>>>> t2 = Test(None, "ciao") > >>>>>> t3 = Test("salut", "hallo") > >>>>>> t = [t1, t2, t3] > > >>>>>> prg(t) > >>> 'hello\nciao\nsalut\nhallo\n' > > >>> The idea would be create a new list with the values not None and then > >>> use the join function... but I don't know if it is really worth it. > >>> Any hint? > > >>>>>> def prg2(l): > > >> ? ? ? ? ? ? ? return "\n".join([x for x in l if x]) > > >> Emile > > >>> ... ? ? e = [] > >>> ... ? ? for x in l: > >>> ... ? ? ? ? if x.v1 is not None: > >>> ... ? ? ? ? ? ? e.append(x.v1) > >>> ... ? ? ? ? if x.v2 is not None: > >>> ... ? ? ? ? ? ? e.append(x.v2) > >>> ... ? ? return "\n".join(e) > >>> ... > >>>>>> prg2(t) > >>> 'hello\nciao\nsalut\nhallo' > > >>> Thanks, Mattia- Nascondi testo citato > > >> - Mostra testo citato -- Nascondi testo citato > > >> - Mostra testo citato - > > > Sorry, but it does not work > > Oh -- you want a working solution, not a hint? ?OK. > > class Test: > ? ? ? def __init__(self, v1, v2): > ? ? ? ? ? self.v1 = v1 > ? ? ? ? ? self.v2 = v2 > > t1 = Test("hello", None) > t2 = Test(None, "ciao") > t3 = Test("salut", "hallo") > t = [t1, t2, t3] > > "\n".join([y for x in t for y in [x.v1,x.v2] if y]) > > Emile > > > > > > >>>> def prg3(l): > > ... ? ? return "\n".join([x for x in l if x]) > > ... > >>>> prg3(t) > > Traceback (most recent call last): > > ? ?File "", line 1, in > > ? ?File "", line 2, in prg3 > > TypeError: sequence item 0: expected str instance, Test found- Nascondi testo citato > > - Mostra testo citato -- Nascondi testo citato > > - Mostra testo citato - Thanks Emile, despite that now the solution runs in quadratic time I guess. I could also provide a __str__(self) representation, but in my real code I don't have access to the class. Also using str() on an empty object (i.e. None), the representation is 'None'. Ciao, Mattia From Joshua.R.English at gmail.com Sun Jan 2 16:42:02 2011 From: Joshua.R.English at gmail.com (Josh English) Date: Sun, 2 Jan 2011 13:42:02 -0800 (PST) Subject: Multiple instances and wrong parental links In-Reply-To: Message-ID: <16944036-3260-4e4a-9d94-7eebd247833c@glegroupsg2000goo.googlegroups.com> Chas, Thanks. The "self" in the setattr statement works sometimes, but what I'm adding most of the time is a property, and if I don't use the class when setting a property, nothing works. The property is returned instead of the value of the function the property returns. (yeah, it's complicated). This is the same project I asked about at https://groups.google.com/d/topic/comp.lang.python/K9PinAbuCJk/discussion. That's why this simple sample looks so incredibly complicated. I'm coding on the far edge of my learning curve. Josh From Joshua.R.English at gmail.com Sun Jan 2 16:51:29 2011 From: Joshua.R.English at gmail.com (Josh English) Date: Sun, 2 Jan 2011 13:51:29 -0800 (PST) Subject: Multiple instances and wrong parental links In-Reply-To: <4d202971$0$29968$c3e8da3$5496439d@news.astraweb.com> Message-ID: Steven, This was simplified. The complete story is, well, tedious: I have created a set of XML Validation and Normalization classes. With them I can define my data structures and make sure my data is good. These complications have come in wanting to take this tool and create a GUI (in wxPython) around these objects. Okay, really these complication come from me generalizing the problem, probably one step too far. I want a tool to take my structural definition and create the GUI. To use some of the "easy" tools like Validators that transfer data to the GUI and back, I need an interface. I tried creating validators that went straight to the element, but that got complicated. Then I created a map from a dictionary to an element (as defined by the XML validation tool) and back again. This also bogged down and fixing one problem undid all the other progress I had made. So this is my third attempt: create a Python object around the XML definition. I've looked at pyxb. It doesn't make any sense to me. I looked at pysxer, that made even less sense. Hence, I try it on my own. The Element List isn't a list, it has the same interface as a list, but always goes back to the original XML element (an elementree.Element object in this case.) Insanely complicated and just beyond my comprehension, I fear. I haven't found an easier way to wrap an object around these XML validators of mine. Josh From benjamin.kaplan at case.edu Sun Jan 2 16:56:15 2011 From: benjamin.kaplan at case.edu (Benjamin Kaplan) Date: Sun, 2 Jan 2011 16:56:15 -0500 Subject: list 2 dict? Message-ID: On Jan 2, 2011 4:15 PM, "Octavian Rasnita" wrote: > > > Octavian > > ----- Original Message ----- > From: "Alex Willmer" > Newsgroups: comp.lang.python > To: > Cc: > Sent: Sunday, January 02, 2011 8:07 PM > Subject: Re: list 2 dict? > > > > On Sunday, January 2, 2011 3:36:35 PM UTC, T wrote: > >> The grouper-way looks nice, but I tried it and it didn't work: > >> > >> from itertools import * > >> ... > >> d = dict(grouper(2, l)) > >> > >> NameError: name 'grouper' is not defined > >> > >> I use Python 2.7. Should it work with this version? > > > > No. As Ian said grouper() is a receipe in the itertools documentation. > > > > http://docs.python.org/library/itertools.html#recipes > > I know that, that is why I used: > > from itertools import * > > > Isn't enough? > > Octavian > It would be, if, the function was actually a part of the itertools module. It isn't. It's just a code example used in the documentation. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gervaz at gmail.com Sun Jan 2 17:00:49 2011 From: gervaz at gmail.com (gervaz) Date: Sun, 2 Jan 2011 14:00:49 -0800 (PST) Subject: String building using join References: <6ca085f6-7c03-44b2-a9f2-8d77db046c7e@s9g2000vby.googlegroups.com> Message-ID: <1d33bd0b-37c9-45db-8c35-c530f5ed15cf@l7g2000vbv.googlegroups.com> On 2 Gen, 22:37, gervaz wrote: > On 2 Gen, 19:14, Emile van Sebille wrote: > > > > > > > On 1/2/2011 9:43 AM gervaz said... > > > > On 31 Dic 2010, 16:43, Emile van Sebille ?wrote: > > >> On 12/31/2010 7:22 AM gervaz said... > > > >>> Hi all, I would like to ask you how I can use the more efficient join > > >>> operation in a code like this: > > > >>>>>> class Test: > > >>> ... ? ? def __init__(self, v1, v2): > > >>> ... ? ? ? ? self.v1 = v1 > > >>> ... ? ? ? ? self.v2 = v2 > > >>> ... > > >>>>>> def prg(l): > > >>> ... ? ? txt = "" > > >>> ... ? ? for x in l: > > >>> ... ? ? ? ? if x.v1 is not None: > > >>> ... ? ? ? ? ? ? txt += x.v1 + "\n" > > >>> ... ? ? ? ? if x.v2 is not None: > > >>> ... ? ? ? ? ? ? txt += x.v2 + "\n" > > >>> ... ? ? return txt > > >>> ... > > >>>>>> t1 = Test("hello", None) > > >>>>>> t2 = Test(None, "ciao") > > >>>>>> t3 = Test("salut", "hallo") > > >>>>>> t = [t1, t2, t3] > > > >>>>>> prg(t) > > >>> 'hello\nciao\nsalut\nhallo\n' > > > >>> The idea would be create a new list with the values not None and then > > >>> use the join function... but I don't know if it is really worth it. > > >>> Any hint? > > > >>>>>> def prg2(l): > > > >> ? ? ? ? ? ? ? return "\n".join([x for x in l if x]) > > > >> Emile > > > >>> ... ? ? e = [] > > >>> ... ? ? for x in l: > > >>> ... ? ? ? ? if x.v1 is not None: > > >>> ... ? ? ? ? ? ? e.append(x.v1) > > >>> ... ? ? ? ? if x.v2 is not None: > > >>> ... ? ? ? ? ? ? e.append(x.v2) > > >>> ... ? ? return "\n".join(e) > > >>> ... > > >>>>>> prg2(t) > > >>> 'hello\nciao\nsalut\nhallo' > > > >>> Thanks, Mattia- Nascondi testo citato > > > >> - Mostra testo citato -- Nascondi testo citato > > > >> - Mostra testo citato - > > > > Sorry, but it does not work > > > Oh -- you want a working solution, not a hint? ?OK. > > > class Test: > > ? ? ? def __init__(self, v1, v2): > > ? ? ? ? ? self.v1 = v1 > > ? ? ? ? ? self.v2 = v2 > > > t1 = Test("hello", None) > > t2 = Test(None, "ciao") > > t3 = Test("salut", "hallo") > > t = [t1, t2, t3] > > > "\n".join([y for x in t for y in [x.v1,x.v2] if y]) > > > Emile > > > >>>> def prg3(l): > > > ... ? ? return "\n".join([x for x in l if x]) > > > ... > > >>>> prg3(t) > > > Traceback (most recent call last): > > > ? ?File "", line 1, in > > > ? ?File "", line 2, in prg3 > > > TypeError: sequence item 0: expected str instance, Test found- Nascondi testo citato > > > - Mostra testo citato -- Nascondi testo citato > > > - Mostra testo citato - > > Thanks Emile, despite that now the solution runs in quadratic time I > guess. I could also provide a __str__(self) representation, but in my > real code I don't have access to the class. Also using str() on an > empty object (i.e. None), the representation is 'None'. > > Ciao, > > Mattia- Nascondi testo citato > > - Mostra testo citato - And this one is another working solution... >>> def prg4(l): ... s = [] ... for x in l: ... s.extend(set([x.v1, x.v2]) - set([None])) ... return "\n".join(s) ... >>> prg4(t) 'hello\nciao\nhallo\nsalut' My original question was just related to the fact that I read that the string concatenation in expensive and it sould be used the join() function but now probably it is better to stick with the first implementation, the simplest one. Ciao, Mattia From alonmozilla at gmail.com Sun Jan 2 17:53:47 2011 From: alonmozilla at gmail.com (azakai) Date: Sun, 2 Jan 2011 14:53:47 -0800 (PST) Subject: CPython on the Web References: <19141efb-a288-43bc-be0d-44769bf5974b@j32g2000prh.googlegroups.com> Message-ID: <5942c6f9-7af5-4cff-84d4-f23a8b3bbfa1@k14g2000pre.googlegroups.com> On Jan 2, 1:01?pm, Gerry Reno wrote: > > Ok, visiting this page: > > http://syntensity.com/static/python.html > > I do not see anything happen when I click 'execute' button. ?I'm running > Firefox 3.6.3. > I've only tested with Firefox 4. I'm surprised though that it wouldn't work on 3.6.3. Can you see what errors appear in the error console (control-shift-J)? If no errors appear, it might be a failure due to limited script stack space (which is fixed in FF4, and I guess is a problem in earlier versions). > > So what is happening is that the whole Python interpreter has been > converted to Javascript and is running the browser, is that correct? Yes. > > Ok, but the usual browser 'sandbox' constraints would still apply would > they not? Yes, the JavaScript is limited in the usual ways. So Python is running in a sandboxed manner. > > And what is the build toolchain that you need if you want to convert > your modules to be importable with this "CPython on the Web"? > Note that loading modules isn't implemented yet, but I'll work on it soon. The toolchain will be to use your normal makefiles and such, but replacing gcc with llvm-gcc or clang, so it generates LLVM bytecode instead of a normal binary. Then one would run the generated LLVM bytecode through Emscripten, which compiles it to JavaScript. So, the process should be fairly simple. - azakai From greno at verizon.net Sun Jan 2 18:14:39 2011 From: greno at verizon.net (Gerry Reno) Date: Sun, 02 Jan 2011 18:14:39 -0500 Subject: CPython on the Web In-Reply-To: <5942c6f9-7af5-4cff-84d4-f23a8b3bbfa1@k14g2000pre.googlegroups.com> References: <19141efb-a288-43bc-be0d-44769bf5974b@j32g2000prh.googlegroups.com> <5942c6f9-7af5-4cff-84d4-f23a8b3bbfa1@k14g2000pre.googlegroups.com> Message-ID: <4D2106DF.6080609@verizon.net> On 01/02/2011 05:53 PM, azakai wrote: > On Jan 2, 1:01 pm, Gerry Reno wrote: > >> Ok, visiting this page: >> >> http://syntensity.com/static/python.html >> >> I do not see anything happen when I click 'execute' button. I'm running >> Firefox 3.6.3. >> >> > I've only tested with Firefox 4. I'm surprised though that it wouldn't > work on 3.6.3. Can you see what errors appear in the error console > (control-shift-J)? > > Errors when using Firefox 3.6.3: script stack space quota is exhausted Module is not defined ... line 56 Regards, Gerry From stagi.andrea at gmail.com Sun Jan 2 19:09:06 2011 From: stagi.andrea at gmail.com (Andrea Stagi) Date: Sun, 2 Jan 2011 16:09:06 -0800 (PST) Subject: Tiny4py [important update] a little python wrapper to make shorten urls and QRCodes Message-ID: Hi, I would announce you my new version of this python wrapper to make shorten urls and QRCodes, using main used services: goo.gl, bit.ly and tinyurl. Please, visit http://code.google.com/p/tiny4py/ Bests From timr at probo.com Sun Jan 2 19:50:56 2011 From: timr at probo.com (Tim Roberts) Date: Sun, 02 Jan 2011 16:50:56 -0800 Subject: Interrput a thread References: <81c24eb1-41b6-442a-a971-8a44d2cd6c1b@p8g2000vbs.googlegroups.com> <4d1e20c5$0$43986$742ec2ed@news.sonic.net> Message-ID: <5972i6hdaru9g15hs14je5imggabq4l3b8@4ax.com> gervaz wrote: > >Ok, but then suppose I have multiple long running threads that I want >to delete/suspend because they are tooking too much time, which >solution do you propose? The right solution is to write your threads so they have an escape hatch -- to periodically check a "should I die?" flag, and then commit suicide. That is the ONLY clean way to handle this problem. There is simply no clean way to force another thread to die without its permission. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From python at bdurham.com Sun Jan 2 19:58:42 2011 From: python at bdurham.com (python at bdurham.com) Date: Sun, 02 Jan 2011 19:58:42 -0500 Subject: CPython on the Web In-Reply-To: <4D2106DF.6080609@verizon.net> References: <19141efb-a288-43bc-be0d-44769bf5974b@j32g2000prh.googlegroups.com><5942c6f9-7af5-4cff-84d4-f23a8b3bbfa1@k14g2000pre.googlegroups.com> <4D2106DF.6080609@verizon.net> Message-ID: <1294016322.6824.1413185103@webmail.messagingengine.com> Azakai/Gerry, > Errors when using Firefox 3.6.3: I'm running Firefox 3.6.1.3 and the interpreter is running fine. I'm on Windows 7 Pro 64-bit. Malcolm From alonmozilla at gmail.com Sun Jan 2 20:00:52 2011 From: alonmozilla at gmail.com (azakai) Date: Sun, 2 Jan 2011 17:00:52 -0800 (PST) Subject: CPython on the Web References: <19141efb-a288-43bc-be0d-44769bf5974b@j32g2000prh.googlegroups.com> <5942c6f9-7af5-4cff-84d4-f23a8b3bbfa1@k14g2000pre.googlegroups.com> Message-ID: <3e973cb5-4208-4f73-8bbf-15e1bc2f7595@35g2000prt.googlegroups.com> On Jan 2, 3:14?pm, Gerry Reno wrote: > On 01/02/2011 05:53 PM, azakai wrote: > > > On Jan 2, 1:01 pm, Gerry Reno wrote: > > >> Ok, visiting this page: > > >>http://syntensity.com/static/python.html > > >> I do not see anything happen when I click 'execute' button. ?I'm running > >> Firefox 3.6.3. > > > I've only tested with Firefox 4. I'm surprised though that it wouldn't > > work on 3.6.3. Can you see what errors appear in the error console > > (control-shift-J)? > > Errors when using Firefox 3.6.3: > > script stack space quota is exhausted Ah, then yeah, it's the script stack issue I was afraid of. Then there's not really a way to run the demo on Firefox 3.6.x. It will work on Firefox 4 though, or other recent browsers. - azakai From greno at verizon.net Sun Jan 2 20:55:48 2011 From: greno at verizon.net (Gerry Reno) Date: Sun, 02 Jan 2011 20:55:48 -0500 Subject: CPython on the Web In-Reply-To: <3e973cb5-4208-4f73-8bbf-15e1bc2f7595@35g2000prt.googlegroups.com> References: <19141efb-a288-43bc-be0d-44769bf5974b@j32g2000prh.googlegroups.com> <5942c6f9-7af5-4cff-84d4-f23a8b3bbfa1@k14g2000pre.googlegroups.com> <3e973cb5-4208-4f73-8bbf-15e1bc2f7595@35g2000prt.googlegroups.com> Message-ID: <4D212CA4.6010807@verizon.net> I tried printing sys.path and here is the output: ['', '/usr/local/lib/python27.zip', '/usr/local/lib/python2.7/', '/usr/local/lib/python2.7/plat-linux2', '/usr/local/lib/python2.7/lib-tk', '/usr/local/lib/python2.7/lib-old', '/usr/local/lib/lib-dynload'] Now, those paths must be on your machine because they are not on my client machine. But the interpreter is now running on MY machine. Well in a sandbox really. So how is that going to work? Regards, Gerry From alonmozilla at gmail.com Sun Jan 2 21:06:09 2011 From: alonmozilla at gmail.com (azakai) Date: Sun, 2 Jan 2011 18:06:09 -0800 (PST) Subject: CPython on the Web References: <19141efb-a288-43bc-be0d-44769bf5974b@j32g2000prh.googlegroups.com><5942c6f9-7af5-4cff-84d4-f23a8b3bbfa1@k14g2000pre.googlegroups.com> <4D2106DF.6080609@verizon.net> Message-ID: <5a62ec44-7dd0-456c-b14c-92f3b97b7f2a@c13g2000prc.googlegroups.com> On Jan 2, 4:58?pm, pyt... at bdurham.com wrote: > Azakai/Gerry, > > > Errors when using Firefox 3.6.3: > > I'm running Firefox 3.6.1.3 and the interpreter is running fine. > > I'm on Windows 7 Pro 64-bit. > > Malcolm Thanks for the info. To be honest I'm surprised it works there. I guess the error Gerry ran into depends on additional factors. - azakai From news3 at mystrobl.de Mon Jan 3 02:26:20 2011 From: news3 at mystrobl.de (Wolfgang Strobl) Date: Mon, 03 Jan 2011 08:26:20 +0100 Subject: CPython on the Web References: <19141efb-a288-43bc-be0d-44769bf5974b@j32g2000prh.googlegroups.com><5942c6f9-7af5-4cff-84d4-f23a8b3bbfa1@k14g2000pre.googlegroups.com> <4D2106DF.6080609@verizon.net> <5a62ec44-7dd0-456c-b14c-92f3b97b7f2a@c13g2000prc.googlegroups.com> Message-ID: azakai : >On Jan 2, 4:58?pm, pyt... at bdurham.com wrote: >> Azakai/Gerry, >> >> > Errors when using Firefox 3.6.3: >> >> I'm running Firefox 3.6.1.3 and the interpreter is running fine. I guess that meant FIrefox 3.6.13 (without the last dot), the current stable version. I'm using Firefox 3.6.13 (german) on Windowx XP (32bit, german) here, and the interpreter is running fine, too. Same for Chrome 8.0.552.224. -- Wir danken f?r die Beachtung aller Sicherheitsbestimmungen From yoavglazner at gmail.com Mon Jan 3 05:41:23 2011 From: yoavglazner at gmail.com (Glazner) Date: Mon, 3 Jan 2011 02:41:23 -0800 (PST) Subject: list 2 dict? References: Message-ID: <8e41b3be-9279-44f3-a9ab-a8d55fa7e72a@d8g2000yqf.googlegroups.com> On Jan 2, 3:18?pm, "Octavian Rasnita" wrote: > Hi, > > If I want to create a dictionary from a list, is there a better way than the long line below? > > l = [1, 2, 3, 4, 5, 6, 7, 'a', 8, 'b'] > > d = dict(zip([l[x] for x in range(len(l)) if x %2 == 0], [l[x] for x in range(len(l)) if x %2 == 1])) > > print(d) > > {8: 'b', 1: 2, 3: 4, 5: 6, 7: 'a'} > > Thanks. > > Octavian this is efficient l = [1,2,3,4,5,6] >>> dict(izip(islice(l,0,len(l),2),islice(l,1,len(l),2))) {1: 2, 3: 4, 5: 6} From maniearthg3 at gmail.com Mon Jan 3 06:10:34 2011 From: maniearthg3 at gmail.com (mani ma) Date: Mon, 3 Jan 2011 03:10:34 -0800 (PST) Subject: Arisingsoft provides the Norton antivirus all in one security suite. Message-ID: <68d35288-9ebe-425b-9639-f08d80fe1d94@22g2000prx.googlegroups.com> hai, Uses : The package includes a personal firewall, phishing protection and the ability to detect and remove malware. Norton 360 is compatible with 32-bit editions of Windows XP and 32-bit or 64-bit editions of Windows Vista.Windows 7 support has been added. Reviews cited Norton 360's low resource usage, relative to Norton Internet Security 2007, and phishing protection. http://www.arisingsoft.com/2010_11_14_archive.html http://www.arisingsoft.com/ From xrgtn at yandex.ru Mon Jan 3 06:56:12 2011 From: xrgtn at yandex.ru (Alexander Gattin) Date: Mon, 3 Jan 2011 13:56:12 +0200 Subject: String building using join In-Reply-To: References: Message-ID: <20110103115612.GA16693@xrgtn-q40> Hello, On Sun, Jan 02, 2011 at 10:11:50AM -0800, Alex Willmer wrote: > def prg3(l): > return '\n'.join([str(x) for x in l if x]) just one fix (one fix one fix one fix): return '\n'.join([str(x) for x in l if x is not None]) -- With best regards, xrgtn From deets at web.de Mon Jan 3 11:46:31 2011 From: deets at web.de (Diez B. Roggisch) Date: Mon, 03 Jan 2011 17:46:31 +0100 Subject: Is there anyway to run JavaScript in python? References: Message-ID: <878vz27x5k.fsf@web.de> crow writes: > Hi, I'm writing a test tool to simulate Web browser. Is there anyway > to run JavaScript in python? Thanks in advance. Not really. Yes, you can invoke spidermonkey. But the crucial point about running JS is not executing JS, it's about having the *DOM* of the browser available. Which spidermonkey obviously hasn't. So, I recommend using Selenium. Diez From deets at web.de Mon Jan 3 11:47:41 2011 From: deets at web.de (Diez B. Roggisch) Date: Mon, 03 Jan 2011 17:47:41 +0100 Subject: Interrput a thread References: <81c24eb1-41b6-442a-a971-8a44d2cd6c1b@p8g2000vbs.googlegroups.com> <4d1e20c5$0$43986$742ec2ed@news.sonic.net> Message-ID: <874o9q7x3m.fsf@web.de> gervaz writes: > On 31 Dic 2010, 23:25, Alice Bevan?McGregor > wrote: >> On 2010-12-31 10:28:26 -0800, John Nagle said: >> >> > Even worse, sending control-C to a multi-thread program >> > is unreliable in CPython. ?See "http://blip.tv/file/2232410" >> > for why. ?It's painful. >> >> AFIK, that has been resolved in Python 3.2 with the introduction of an >> intelligent thread scheduler as part of the GIL release/acquire process. >> >> ? ? ? ? - Alice. > > Ok, but then suppose I have multiple long running threads that I want > to delete/suspend because they are tooking too much time, which > solution do you propose? If possible, use multiple processes instead. Diez From cfp.vinorg at gmail.com Mon Jan 3 13:31:31 2011 From: cfp.vinorg at gmail.com (CFP - 1st International Conference on Virtual and Networked Organizations Emergent Technologies and Tools) Date: Mon, 3 Jan 2011 18:31:31 +0000 Subject: CFP - ViNOrg 11 - 1st International Conference on Virtual and Networked Organizations: Emergent Technologies and Tools Message-ID: <20110103185815.0FE70EE99F@mail.python.org> ViNOrg 11 1st International Conference on Virtual and Networked Organizations Emergent Technologies and Tools ---------- Paper submission deadline: April 17, 2011 ---------- http://www.2100projects.org/vinorg11 vinorg at 2100projects.org ---------- Dear Professor, It is our great pleasure to invite you to participate in the 1st International Conference on Virtual and Networked Organizations Emergent Technologies and Tools, ViNOrg ?11, to be held in Ofir, Portugal, from July 6-8, 2011. ViNOrg ?11 is promoted by the 2100 Projects Association ? Scientific Association for Promotion of Technology and Management for Organizational and Social Transformative Change. The overall objectives of the conference are to contribute to the development, implementation and promotion of advanced emergent IC technologies to be used in future Virtual and Networked Organizations, through the discussion and sharing of knowledge, as well as experiences and scientific and technical results. A shortlist of intended topics include: metaverse, virtual and augmented reality, ubiquitous computing and organizations, grid computing, cloud computing and architectures, human-computer interfaces, serious games, intelligence and soft computing, data mining, web services, cognitive systems, social networks and other emergent IT/IS approaches in various function domains, such as decision support systems, planning, design, control, negotiation, marketing, management and many other, in the context of virtual and networked enterprises and organizations. All accepted full papers will be published in the Conference Proceedings to be published by Springer-Verlag in a book of the CCIS series (Communications in Computer and Information Science), which is listed in the ISI proceedings index. Authors of selected papers will be invited to extend their papers for publication in some international scientific journals. For more information please consult the conference webpage at http://www.2100projects.org/vinorg11 Looking forward to meeting you in Ofir (Portugal) next July 2011, accept our best regards. The conference co-chairs, * Goran D. Putnik (putnikgd at dps.uminho.pt), University of Minho, Portugal * Maria Manuela Cruz-Cunha (mcunha at ipca.pt), Polytechnic Institute of Cavado and Ave, Portugal ---------- http://www.2100projects.org/vinorg11 vinorg at 2100projects.org ---------- You are receiving this email because of your research activities on the conference related topics. To unsubscribe please send an email to vinorg at 2100projects.org with the subject "Unsubscribe". (please excuse us if you received this call more than once). ---------- From alonmozilla at gmail.com Mon Jan 3 15:10:44 2011 From: alonmozilla at gmail.com (azakai) Date: Mon, 3 Jan 2011 12:10:44 -0800 (PST) Subject: CPython on the Web References: <19141efb-a288-43bc-be0d-44769bf5974b@j32g2000prh.googlegroups.com> <5942c6f9-7af5-4cff-84d4-f23a8b3bbfa1@k14g2000pre.googlegroups.com> <3e973cb5-4208-4f73-8bbf-15e1bc2f7595@35g2000prt.googlegroups.com> Message-ID: <11daa83d-d065-4816-b63b-a0144cc49943@n32g2000pre.googlegroups.com> On Jan 2, 5:55?pm, Gerry Reno wrote: > I tried printing sys.path and here is the output: > > ['', '/usr/local/lib/python27.zip', '/usr/local/lib/python2.7/', > '/usr/local/lib/python2.7/plat-linux2', > '/usr/local/lib/python2.7/lib-tk', '/usr/local/lib/python2.7/lib-old', > '/usr/local/lib/lib-dynload'] > > Now, those paths must be on your machine because they are not on my > client machine. ?But the interpreter is now running on MY machine. ?Well > in a sandbox really. ?So how is that going to work? > Yeah, those are the paths on the machine where the binary was compiled (so, they are the standard paths on ubuntu). Anyhow the filesystem can't (and shouldn't) be accessed from inside a browser page. I think we will implement a minimal virtual filesystem here, just enough for stuff to work. The actual implementation would use HTML5 features like local storage etc. - azakai From deets at web.de Mon Jan 3 15:13:29 2011 From: deets at web.de (Diez B. Roggisch) Date: Mon, 03 Jan 2011 21:13:29 +0100 Subject: CPython on the Web References: <19141efb-a288-43bc-be0d-44769bf5974b@j32g2000prh.googlegroups.com> Message-ID: azakai writes: > Hello, I hope this will be interesting to people here: CPython running > on the web, > > http://syntensity.com/static/python.html > > That isn't a new implementation of Python, but rather CPython 2.7.1, > compiled from C to JavaScript using Emscripten and LLVM. For more > details on the conversion process, see http://emscripten.org A fun hack. Have you bothered to compare it to the PyPy javascript backend - perfomance-wise, that is? Diez From gervaz at gmail.com Mon Jan 3 15:22:59 2011 From: gervaz at gmail.com (gervaz) Date: Mon, 3 Jan 2011 12:22:59 -0800 (PST) Subject: Interrput a thread References: <81c24eb1-41b6-442a-a971-8a44d2cd6c1b@p8g2000vbs.googlegroups.com> <4d1e20c5$0$43986$742ec2ed@news.sonic.net> <874o9q7x3m.fsf@web.de> Message-ID: <71631a5e-d3af-4c5d-9f1d-07eb8044d792@39g2000yqa.googlegroups.com> On 3 Gen, 17:47, de... at web.de (Diez B. Roggisch) wrote: > gervaz writes: > > On 31 Dic 2010, 23:25, Alice Bevan?McGregor > > wrote: > >> On 2010-12-31 10:28:26 -0800, John Nagle said: > > >> > Even worse, sending control-C to a multi-thread program > >> > is unreliable in CPython. ?See "http://blip.tv/file/2232410" > >> > for why. ?It's painful. > > >> AFIK, that has been resolved in Python 3.2 with the introduction of an > >> intelligent thread scheduler as part of the GIL release/acquire process. > > >> ? ? ? ? - Alice. > > > Ok, but then suppose I have multiple long running threads that I want > > to delete/suspend because they are tooking too much time, which > > solution do you propose? > > If possible, use multiple processes instead. > > Diez- Nascondi testo citato > > - Mostra testo citato - Multiple processes, ok, but then regarding processes' interruption there will be the same problems pointed out by using threads? Mattia From greno at verizon.net Mon Jan 3 15:23:51 2011 From: greno at verizon.net (Gerry Reno) Date: Mon, 03 Jan 2011 15:23:51 -0500 Subject: CPython on the Web In-Reply-To: <11daa83d-d065-4816-b63b-a0144cc49943@n32g2000pre.googlegroups.com> References: <19141efb-a288-43bc-be0d-44769bf5974b@j32g2000prh.googlegroups.com> <5942c6f9-7af5-4cff-84d4-f23a8b3bbfa1@k14g2000pre.googlegroups.com> <3e973cb5-4208-4f73-8bbf-15e1bc2f7595@35g2000prt.googlegroups.com> <11daa83d-d065-4816-b63b-a0144cc49943@n32g2000pre.googlegroups.com> Message-ID: <4D223057.1010301@verizon.net> On 01/03/2011 03:10 PM, azakai wrote: > On Jan 2, 5:55 pm, Gerry Reno wrote: > >> I tried printing sys.path and here is the output: >> >> ['', '/usr/local/lib/python27.zip', '/usr/local/lib/python2.7/', >> '/usr/local/lib/python2.7/plat-linux2', >> '/usr/local/lib/python2.7/lib-tk', '/usr/local/lib/python2.7/lib-old', >> '/usr/local/lib/lib-dynload'] >> >> Now, those paths must be on your machine because they are not on my >> client machine. But the interpreter is now running on MY machine. Well >> in a sandbox really. So how is that going to work? >> >> > Yeah, those are the paths on the machine where the binary was compiled > (so, they are the standard paths on ubuntu). > > Anyhow the filesystem can't (and shouldn't) be accessed from inside a > browser page. Well, the local filesystem could be accessible with the user's permission and this should be an option. Regards, Gerry From greno at verizon.net Mon Jan 3 15:35:01 2011 From: greno at verizon.net (Gerry Reno) Date: Mon, 03 Jan 2011 15:35:01 -0500 Subject: CPython on the Web In-Reply-To: References: <19141efb-a288-43bc-be0d-44769bf5974b@j32g2000prh.googlegroups.com> Message-ID: <4D2232F5.2010400@verizon.net> On 01/03/2011 03:13 PM, Diez B. Roggisch wrote: > > A fun hack. Have you bothered to compare it to the PyPy javascript > backend - perfomance-wise, that is? > > Diez > I don't think that exists anymore. Didn't that get removed from PyPy about 2 years ago? Regards, Gerry From calderone.jeanpaul at gmail.com Mon Jan 3 16:06:25 2011 From: calderone.jeanpaul at gmail.com (Jean-Paul Calderone) Date: Mon, 3 Jan 2011 13:06:25 -0800 (PST) Subject: Interrput a thread References: <81c24eb1-41b6-442a-a971-8a44d2cd6c1b@p8g2000vbs.googlegroups.com> <4d1e20c5$0$43986$742ec2ed@news.sonic.net> <874o9q7x3m.fsf@web.de> <71631a5e-d3af-4c5d-9f1d-07eb8044d792@39g2000yqa.googlegroups.com> Message-ID: On Jan 3, 3:22?pm, gervaz wrote: > On 3 Gen, 17:47, de... at web.de (Diez B. Roggisch) wrote: > > > > > gervaz writes: > > > On 31 Dic 2010, 23:25, Alice Bevan?McGregor > > > wrote: > > >> On 2010-12-31 10:28:26 -0800, John Nagle said: > > > >> > Even worse, sending control-C to a multi-thread program > > >> > is unreliable in CPython. ?See "http://blip.tv/file/2232410" > > >> > for why. ?It's painful. > > > >> AFIK, that has been resolved in Python 3.2 with the introduction of an > > >> intelligent thread scheduler as part of the GIL release/acquire process. > > > >> ? ? ? ? - Alice. > > > > Ok, but then suppose I have multiple long running threads that I want > > > to delete/suspend because they are tooking too much time, which > > > solution do you propose? > > > If possible, use multiple processes instead. > > > Diez- Nascondi testo citato > > > - Mostra testo citato - > > Multiple processes, ok, but then regarding processes' interruption > there will be the same problems pointed out by using threads? > No. Processes can be terminated easily on all major platforms. See `os.kill`. Jean-Paul From askutt at gmail.com Mon Jan 3 16:17:13 2011 From: askutt at gmail.com (Adam Skutt) Date: Mon, 3 Jan 2011 13:17:13 -0800 (PST) Subject: Interrput a thread References: <81c24eb1-41b6-442a-a971-8a44d2cd6c1b@p8g2000vbs.googlegroups.com> <4d1e20c5$0$43986$742ec2ed@news.sonic.net> <874o9q7x3m.fsf@web.de> <71631a5e-d3af-4c5d-9f1d-07eb8044d792@39g2000yqa.googlegroups.com> Message-ID: <4855b05f-1ea4-4287-9066-5aeb1b7cb720@k11g2000vbf.googlegroups.com> On Jan 3, 4:06?pm, Jean-Paul Calderone wrote: > > > Multiple processes, ok, but then regarding processes' interruption > > there will be the same problems pointed out by using threads? > > No. ?Processes can be terminated easily on all major platforms. ?See > `os.kill`. > Yes, but that's not the whole story, now is it? It's certainly much more reliable and easier to kill a process. It's not any easier to do it and retain defined behavior, depending on exactly what you're doing. For example, if you kill it while it's in the middle of updating shared memory, you can potentially incur undefined behavior on the part of any process that can also access shared memory. In short, taking a program that uses threads and shared state and simply replacing the threads with processes will likely not gain you a thing. It entirely depends on what those threads are doing and how they do it. Adam From sjmachin at lexicon.net Mon Jan 3 16:28:01 2011 From: sjmachin at lexicon.net (John Machin) Date: Mon, 3 Jan 2011 13:28:01 -0800 (PST) Subject: Interesting bug References: <45562e32-6fd2-4d40-be64-bb88335ad274@z17g2000prz.googlegroups.com> Message-ID: <8ff97e7b-9eab-4c48-9fe9-a3aec425af50@22g2000prx.googlegroups.com> On Jan 2, 12:22?am, Daniel Fetchinson wrote: > An AI bot is playing a trick on us. Yes, it appears that the mystery is solved: Mark V. Shaney is alive and well and living in Bangalore :-) From gervaz at gmail.com Mon Jan 3 17:05:46 2011 From: gervaz at gmail.com (gervaz) Date: Mon, 3 Jan 2011 14:05:46 -0800 (PST) Subject: Interrput a thread References: <81c24eb1-41b6-442a-a971-8a44d2cd6c1b@p8g2000vbs.googlegroups.com> <4d1e20c5$0$43986$742ec2ed@news.sonic.net> <874o9q7x3m.fsf@web.de> <71631a5e-d3af-4c5d-9f1d-07eb8044d792@39g2000yqa.googlegroups.com> <4855b05f-1ea4-4287-9066-5aeb1b7cb720@k11g2000vbf.googlegroups.com> Message-ID: On 3 Gen, 22:17, Adam Skutt wrote: > On Jan 3, 4:06?pm, Jean-Paul Calderone > wrote: > > > > > > Multiple processes, ok, but then regarding processes' interruption > > > there will be the same problems pointed out by using threads? > > > No. ?Processes can be terminated easily on all major platforms. ?See > > `os.kill`. > > Yes, but that's not the whole story, now is it? ?It's certainly much > more reliable and easier to kill a process. ?It's not any easier to do > it and retain defined behavior, depending on exactly what you're > doing. ?For example, if you kill it while it's in the middle of > updating shared memory, you can potentially incur undefined behavior > on the part of any process that can also access shared memory. > > In short, taking a program that uses threads and shared state and > simply replacing the threads with processes will likely not gain you a > thing. ?It entirely depends on what those threads are doing and how > they do it. > > Adam As per the py3.1 documentation, os.kill is only available in the Unix os. Regarding the case pointed out by Adam I think the best way to deal with it is to create a critical section so that the shared memory will be updated in an atomic fashion. Btw it would be useful to take a look at some actual code/documentation in order to understand how others dealt with the problem... Ciao, Mattia From calderone.jeanpaul at gmail.com Mon Jan 3 17:24:55 2011 From: calderone.jeanpaul at gmail.com (Jean-Paul Calderone) Date: Mon, 3 Jan 2011 14:24:55 -0800 (PST) Subject: Interrput a thread References: <81c24eb1-41b6-442a-a971-8a44d2cd6c1b@p8g2000vbs.googlegroups.com> <4d1e20c5$0$43986$742ec2ed@news.sonic.net> <874o9q7x3m.fsf@web.de> <71631a5e-d3af-4c5d-9f1d-07eb8044d792@39g2000yqa.googlegroups.com> <4855b05f-1ea4-4287-9066-5aeb1b7cb720@k11g2000vbf.googlegroups.com> Message-ID: <3856d645-86a5-449f-adca-fcbbc6371ba4@l17g2000yqe.googlegroups.com> On Jan 3, 4:17?pm, Adam Skutt wrote: > On Jan 3, 4:06?pm, Jean-Paul Calderone > wrote: > > > > > > Multiple processes, ok, but then regarding processes' interruption > > > there will be the same problems pointed out by using threads? > > > No. ?Processes can be terminated easily on all major platforms. ?See > > `os.kill`. > > Yes, but that's not the whole story, now is it? ?It's certainly much > more reliable and easier to kill a process. ?It's not any easier to do > it and retain defined behavior, depending on exactly what you're > doing. ?For example, if you kill it while it's in the middle of > updating shared memory, you can potentially incur undefined behavior > on the part of any process that can also access shared memory. Then don't use shared memory. > > In short, taking a program that uses threads and shared state and > simply replacing the threads with processes will likely not gain you a > thing. ?It entirely depends on what those threads are doing and how > they do it. > Of course. The whole point here is not about threads vs processes. It's about shared memory concurrency vs non-shared memory concurrency. You can implement both with threads and both with processes, but threads are geared towards shared memory and processes are geared towards non-shared memory. So what most people mean by "use processes" is "don't use shared memory". Jean-Paul From kentilton at gmail.com Mon Jan 3 17:37:12 2011 From: kentilton at gmail.com (kenny) Date: Mon, 3 Jan 2011 14:37:12 -0800 (PST) Subject: SUNLisp 2: Josh vs. Kenny Flamewars Galore!! Message-ID: All they agree on is Common Lisp! Come join the Yobbos of MCNA at the Frog & Toad for booze, vino, and great food and knock down drag out debates galore on everything from Cells to Lisp IDEs: When: Tomorrow Tuesday, at 7pm Where: http://www.thefrogandtoadpub.com/ HK From deets at web.de Mon Jan 3 17:55:41 2011 From: deets at web.de (Diez B. Roggisch) Date: Mon, 03 Jan 2011 23:55:41 +0100 Subject: CPython on the Web References: <19141efb-a288-43bc-be0d-44769bf5974b@j32g2000prh.googlegroups.com> Message-ID: Gerry Reno writes: > On 01/03/2011 03:13 PM, Diez B. Roggisch wrote: >> >> A fun hack. Have you bothered to compare it to the PyPy javascript >> backend - perfomance-wise, that is? >> >> Diez >> > > I don't think that exists anymore. Didn't that get removed from PyPy > about 2 years ago? Ah, didn't know that. I was under the impression pyjamas was done with it. Apparently, that's wrong: http://pyjs.org/ But then I re-phrase my question: how does this relate to pyjamas/pyjs? Diez From deets at web.de Mon Jan 3 17:57:17 2011 From: deets at web.de (Diez B. Roggisch) Date: Mon, 03 Jan 2011 23:57:17 +0100 Subject: Interrput a thread References: <81c24eb1-41b6-442a-a971-8a44d2cd6c1b@p8g2000vbs.googlegroups.com> <4d1e20c5$0$43986$742ec2ed@news.sonic.net> <874o9q7x3m.fsf@web.de> <71631a5e-d3af-4c5d-9f1d-07eb8044d792@39g2000yqa.googlegroups.com> <4855b05f-1ea4-4287-9066-5aeb1b7cb720@k11g2000vbf.googlegroups.com> Message-ID: gervaz writes: > On 3 Gen, 22:17, Adam Skutt wrote: >> On Jan 3, 4:06?pm, Jean-Paul Calderone >> wrote: >> >> >> >> > > Multiple processes, ok, but then regarding processes' interruption >> > > there will be the same problems pointed out by using threads? >> >> > No. ?Processes can be terminated easily on all major platforms. ?See >> > `os.kill`. >> >> Yes, but that's not the whole story, now is it? ?It's certainly much >> more reliable and easier to kill a process. ?It's not any easier to do >> it and retain defined behavior, depending on exactly what you're >> doing. ?For example, if you kill it while it's in the middle of >> updating shared memory, you can potentially incur undefined behavior >> on the part of any process that can also access shared memory. >> >> In short, taking a program that uses threads and shared state and >> simply replacing the threads with processes will likely not gain you a >> thing. ?It entirely depends on what those threads are doing and how >> they do it. >> >> Adam > > As per the py3.1 documentation, os.kill is only available in the Unix > os. Regarding the case pointed out by Adam I think the best way to > deal with it is to create a critical section so that the shared memory > will be updated in an atomic fashion. Btw it would be useful to take a > look at some actual code/documentation in order to understand how > others dealt with the problem... There is the multiprocessing module. It's a good start, and works cross-platform. Diez From askutt at gmail.com Mon Jan 3 18:10:10 2011 From: askutt at gmail.com (Adam Skutt) Date: Mon, 3 Jan 2011 15:10:10 -0800 (PST) Subject: Interrput a thread References: <81c24eb1-41b6-442a-a971-8a44d2cd6c1b@p8g2000vbs.googlegroups.com> <4d1e20c5$0$43986$742ec2ed@news.sonic.net> <874o9q7x3m.fsf@web.de> <71631a5e-d3af-4c5d-9f1d-07eb8044d792@39g2000yqa.googlegroups.com> <4855b05f-1ea4-4287-9066-5aeb1b7cb720@k11g2000vbf.googlegroups.com> Message-ID: <4d1da89f-7c74-47c7-a3c9-7f3a574308c0@s4g2000yql.googlegroups.com> On Jan 3, 5:05?pm, gervaz wrote: > Regarding the case pointed out by Adam I think the best way to > deal with it is to create a critical section so that the shared memory > will be updated in an atomic fashion. Ok, so if the OS kills the process between taking the lock and releasing it, what are you going to do? Handled naively, you can end up in a deadlock situation[1]. If a process has locked a semaphore and then terminates, the semaphore retains its current value: all other processes waiting on the semaphore will still be waiting, and any new processes that access the semaphore will wait as well. In short, if a process holding a semaphore dies, you have to manually unlock it. For signals that the process intends to handle, you can always disable them before taking the lock and reenable them after releasing it. Or, you can install signal handlers in each process that ensure everything is properly cleaned up when the signal is delivered. Which solution is right depends on what you're doing. For signals you don't intend to handle (SIGSEGV) or cannot handle (SIGKILL) there's not much you can do. It's potentially dangerous to continue on after a child has received such a signal, so the right solution may be to literally do nothing and let the deadlock occur. If you must do cleanup, it must be done carefully. The key thing to understand is that the problems with killing threads haven't gone away: delivering the "please die" message isn't the hard part; it's safely cleaning up the thread in such a way it doesn't break the rest of the application! This problem still exists if you replace threads with processes (assuming you're using shared memory). As such, the better thing to do, if possible, is to avoid shared memory and use constructs like pipes and sockets for I/O. They have much better defined failure semantics, and do allow you a modicum of fault isolation. At the very least, graceful shutdown is much easier. HTH, Adam [1] For SIGINT from the terminal, the "right thing" /might/ happen. Strong emphasis on the might. From askutt at gmail.com Mon Jan 3 18:17:13 2011 From: askutt at gmail.com (Adam Skutt) Date: Mon, 3 Jan 2011 15:17:13 -0800 (PST) Subject: Interrput a thread References: <81c24eb1-41b6-442a-a971-8a44d2cd6c1b@p8g2000vbs.googlegroups.com> <4d1e20c5$0$43986$742ec2ed@news.sonic.net> <874o9q7x3m.fsf@web.de> <71631a5e-d3af-4c5d-9f1d-07eb8044d792@39g2000yqa.googlegroups.com> <4855b05f-1ea4-4287-9066-5aeb1b7cb720@k11g2000vbf.googlegroups.com> <3856d645-86a5-449f-adca-fcbbc6371ba4@l17g2000yqe.googlegroups.com> Message-ID: <561e8842-bcca-45c4-baee-e5431e778f6a@n10g2000yqd.googlegroups.com> On Jan 3, 5:24?pm, Jean-Paul Calderone wrote: > Of course. ?The whole point here is not about threads vs processes. > It's about shared memory concurrency vs non-shared memory > concurrency. ?You can implement both with threads and both with > processes, but threads are geared towards shared memory and processes > are geared towards non-shared memory. ?So what most people mean by > "use processes" is "don't use shared memory". > This is entirely my presumption, but I think if the OP were keenly aware of the differences between thread and processes, it's pretty likely he wouldn't have asked his question in the first place. Also, I've written lots and lots of "use processes" code on multiple platforms, and much of it has used some sort of shared memory construct. It's actually pretty common, especially in code bases with a lot of history. Not all the world is Apache. Adam From greno at verizon.net Mon Jan 3 18:19:20 2011 From: greno at verizon.net (Gerry Reno) Date: Mon, 03 Jan 2011 18:19:20 -0500 Subject: CPython on the Web In-Reply-To: References: <19141efb-a288-43bc-be0d-44769bf5974b@j32g2000prh.googlegroups.com> Message-ID: <4D225978.6010202@verizon.net> On 01/03/2011 05:55 PM, Diez B. Roggisch wrote: > Gerry Reno writes: > > >> On 01/03/2011 03:13 PM, Diez B. Roggisch wrote: >> >>> A fun hack. Have you bothered to compare it to the PyPy javascript >>> backend - perfomance-wise, that is? >>> >>> Diez >>> >>> >> I don't think that exists anymore. Didn't that get removed from PyPy >> about 2 years ago? >> > Ah, didn't know that. I was under the impression pyjamas was done with > it. Apparently, that's wrong: > > http://pyjs.org/ > > But then I re-phrase my question: how does this relate to pyjamas/pyjs? > > Diez > >From what I've seen so far: Pyjamas is taking your python code and converting it into javascript so that your python code (converted to javascript) can run in a browser. CPotW is taking the whole python interpreter and converting the interpreter into javascript so that the python interpreter runs in the browser. Your python code remains as python code. Regards, Gerry From PointedEars at web.de Mon Jan 3 18:21:30 2011 From: PointedEars at web.de (Thomas 'PointedEars' Lahn) Date: Tue, 04 Jan 2011 00:21:30 +0100 Subject: SUNLisp 2: Josh vs. Kenny Flamewars Galore!! References: Message-ID: <1436090.LH7GnMWURc@PointedEars.de> kenny crossposted bullshit over 5 newsgroups again: > [?] JFTR: *PLONK* From astar at spamcop.net Mon Jan 3 19:00:59 2011 From: astar at spamcop.net (astar) Date: Mon, 3 Jan 2011 16:00:59 -0800 (PST) Subject: CPython on the Web References: <19141efb-a288-43bc-be0d-44769bf5974b@j32g2000prh.googlegroups.com><5942c6f9-7af5-4cff-84d4-f23a8b3bbfa1@k14g2000pre.googlegroups.com> <4D2106DF.6080609@verizon.net> Message-ID: On Jan 2, 4:58?pm, pyt... at bdurham.com wrote: > Azakai/Gerry, > > > Errors when using Firefox 3.6.3: > firefox 3.6.13 openbsd i386 4.8 -current error console has some errors: editor not defined module not define too much recursion nothing interested happened on the web page, but wonderful project anyway From alex at moreati.org.uk Mon Jan 3 19:17:00 2011 From: alex at moreati.org.uk (Alex Willmer) Date: Mon, 3 Jan 2011 16:17:00 -0800 (PST) Subject: Python comparison matrix Message-ID: <58cb13ff-2581-463b-9d0a-3c07ab39d3f7@glegroupsg2000goo.googlegroups.com> I've created a spreadsheet that compares the built ins, features and modules of the CPython releases so far. For instance it shows: - basestring was first introduced at version 2.3 then removed in version 3.0 - List comprehensions (PEP 202) were introduced at version 2.0. - apply() was a built in throughout the 1.x and 2.x series, but was deprecated in from 2.3 and removed in 3.0 - Generator functions were first introduced in 2.2 with __future__ import, from 2.3 they were fully supported https://spreadsheets.google.com/pub?key=0At5kubLl6ri7dHU2OEJFWkJ1SE16NUNvaGg2UFBxMUE The current version covers CPython 1.5 - 3.2 on these aspects: - Built in types and functions - Keywords - Modules - Interpreter switches and environment variables - Platforms, including shipped Python version(s) for major Linux distributions - Features/PEPs (incomplete) I gathered the data from the documentation at python.org. It's work in progress so there are plenty of rough edges and holes, but I'd like to get your opinions, feedback and suggestions. - Would you find such a document useful? - What format(s) would be most useful to you (e.g. spreadsheet, pdf, web page(s), database, wall chart, desktop background)? - Are there other aspects/pages that you'd like to see included? - Do you know of source(s) for which versions of CPython supported which operating systems (e.g. the first and last Python release that works on Windows 98 or Mac OS 9)? The best I've found so far is PEP 11 Regards and thanks, Alex From solipsis at pitrou.net Mon Jan 3 19:52:03 2011 From: solipsis at pitrou.net (Antoine Pitrou) Date: Tue, 4 Jan 2011 01:52:03 +0100 Subject: Python comparison matrix References: <58cb13ff-2581-463b-9d0a-3c07ab39d3f7@glegroupsg2000goo.googlegroups.com> Message-ID: <20110104015203.6be4477b@pitrou.net> On Mon, 3 Jan 2011 16:17:00 -0800 (PST) Alex Willmer wrote: > I've created a spreadsheet that compares the built ins, features and modules of the CPython releases so far. For instance it shows: A couple of errors: - BufferError is also in 3.x - IndentationError is also in 3.x - object is also in 3.x - NotImplemented is not an exception type, it's a built-in singleton like None - you forgot VMSError (only on VMS) :-) Regards Antoine. From python at bdurham.com Mon Jan 3 19:54:24 2011 From: python at bdurham.com (python at bdurham.com) Date: Mon, 03 Jan 2011 19:54:24 -0500 Subject: Python comparison matrix In-Reply-To: <58cb13ff-2581-463b-9d0a-3c07ab39d3f7@glegroupsg2000goo.googlegroups.com> References: <58cb13ff-2581-463b-9d0a-3c07ab39d3f7@glegroupsg2000goo.googlegroups.com> Message-ID: <1294102464.18692.1413347931@webmail.messagingengine.com> Alex, I think this type of documentation is incredibly useful! Is there some type of key which explains symbols like !, *, f, etc? Thanks for sharing this work with the community. Malcolm From alonmozilla at gmail.com Mon Jan 3 19:55:19 2011 From: alonmozilla at gmail.com (azakai) Date: Mon, 3 Jan 2011 16:55:19 -0800 (PST) Subject: CPython on the Web References: <19141efb-a288-43bc-be0d-44769bf5974b@j32g2000prh.googlegroups.com> Message-ID: On Jan 3, 12:13?pm, de... at web.de (Diez B. Roggisch) wrote: > A fun hack. Have you bothered to compare it to the PyPy javascript > backend - perfomance-wise, that is? > Gerry already gave a complete and accurate answer to the status of this project in comparison to PyPy and pyjamas. Regarding performance, this hack is not currently fast, primarily because the code is not optimized yet. But through a combination of optimizations on the side of Emscripten (getting all LLVM optimizations to work when compiling to JS) and on the side of the browsers (optimizing accesses on typed arrays in JS, etc.), then I hope the code will eventually run quite fast, even comparably to C. - azakai From alex at moreati.org.uk Mon Jan 3 20:01:17 2011 From: alex at moreati.org.uk (Alex Willmer) Date: Mon, 3 Jan 2011 17:01:17 -0800 (PST) Subject: Python comparison matrix In-Reply-To: Message-ID: <801098db-eaaf-4f06-927e-916c69ebdc82@glegroupsg2000goo.googlegroups.com> On Tuesday, January 4, 2011 12:54:24 AM UTC, Malcolm wrote: > Alex, > > I think this type of documentation is incredibly useful! Thank you. > Is there some type of key which explains symbols like !, *, f, etc? There is a key, it's the second tab from the end, '!' wasn't documented and I forgot why I marked bytes() thusly, so I've removed it. From alex at moreati.org.uk Mon Jan 3 20:01:17 2011 From: alex at moreati.org.uk (Alex Willmer) Date: Mon, 3 Jan 2011 17:01:17 -0800 (PST) Subject: Python comparison matrix In-Reply-To: Message-ID: <801098db-eaaf-4f06-927e-916c69ebdc82@glegroupsg2000goo.googlegroups.com> On Tuesday, January 4, 2011 12:54:24 AM UTC, Malcolm wrote: > Alex, > > I think this type of documentation is incredibly useful! Thank you. > Is there some type of key which explains symbols like !, *, f, etc? There is a key, it's the second tab from the end, '!' wasn't documented and I forgot why I marked bytes() thusly, so I've removed it. From alex at moreati.org.uk Mon Jan 3 20:10:52 2011 From: alex at moreati.org.uk (Alex Willmer) Date: Mon, 3 Jan 2011 17:10:52 -0800 (PST) Subject: Python comparison matrix In-Reply-To: Message-ID: <886aac2d-1db6-4c9f-98b9-e25ea7ff46c1@glegroupsg2000goo.googlegroups.com> Thank you Antoine, I've fixed those errors. Going by the docs, I have VMSError down as first introduced in Python 2.5. From alex at moreati.org.uk Mon Jan 3 20:10:52 2011 From: alex at moreati.org.uk (Alex Willmer) Date: Mon, 3 Jan 2011 17:10:52 -0800 (PST) Subject: Python comparison matrix In-Reply-To: Message-ID: <886aac2d-1db6-4c9f-98b9-e25ea7ff46c1@glegroupsg2000goo.googlegroups.com> Thank you Antoine, I've fixed those errors. Going by the docs, I have VMSError down as first introduced in Python 2.5. From alonmozilla at gmail.com Mon Jan 3 20:59:10 2011 From: alonmozilla at gmail.com (azakai) Date: Mon, 3 Jan 2011 17:59:10 -0800 (PST) Subject: CPython on the Web References: <19141efb-a288-43bc-be0d-44769bf5974b@j32g2000prh.googlegroups.com> <5942c6f9-7af5-4cff-84d4-f23a8b3bbfa1@k14g2000pre.googlegroups.com> <3e973cb5-4208-4f73-8bbf-15e1bc2f7595@35g2000prt.googlegroups.com> <11daa83d-d065-4816-b63b-a0144cc49943@n32g2000pre.googlegroups.com> Message-ID: On Jan 3, 12:23?pm, Gerry Reno wrote: > On 01/03/2011 03:10 PM, azakai wrote: > > > > > > > > > > > On Jan 2, 5:55 pm, Gerry Reno wrote: > > >> I tried printing sys.path and here is the output: > > >> ['', '/usr/local/lib/python27.zip', '/usr/local/lib/python2.7/', > >> '/usr/local/lib/python2.7/plat-linux2', > >> '/usr/local/lib/python2.7/lib-tk', '/usr/local/lib/python2.7/lib-old', > >> '/usr/local/lib/lib-dynload'] > > >> Now, those paths must be on your machine because they are not on my > >> client machine. ?But the interpreter is now running on MY machine. ?Well > >> in a sandbox really. ?So how is that going to work? > > > Yeah, those are the paths on the machine where the binary was compiled > > (so, they are the standard paths on ubuntu). > > > Anyhow the filesystem can't (and shouldn't) be accessed from inside a > > browser page. > > Well, the local filesystem could be accessible with the user's > permission and this should be an option. > Hmm, I think this might be possible with the HTML5 File API. Would definitely be useful here. - azakai From devplayer at gmail.com Mon Jan 3 22:28:08 2011 From: devplayer at gmail.com (DevPlayer) Date: Mon, 3 Jan 2011 19:28:08 -0800 (PST) Subject: Multiple instances and wrong parental links References: Message-ID: Mere are my ramblings of a novice (bad) Hobbyst programmer. You mentioned that your having a hard time coming up with a solution to your complex problem. Complex means you are doing lots of different things to different things all over the place where timing is an issue. First it seems you are trying to simplify your problem by creating a generic class you might call Element which is held in an ElementList class. Right? Or is it you would like you to create a new class for each unique element? If this is the case it would be because each unique element - behaves- differently. Is this the case? Or do all XML elements basically behave the same? If they behave the same you're confusing your design. A class represents a unique behavior. Remember instances can have unique attributes like "code" or "title". But I'm digressing. For example in your other discussion you posted at: https://groups.google.com/forum/#!topic/comp.lang.python/K9PinAbuCJk/discussion you say: So, an element like: Writers of the Future Or is the element structure?: "some value" Or is it like this? value Or like this? value value ... Or this, typical XML? value value ... value value ... And is nested or only one "sub" deep? Ask yourself why do you need to have a different class for each unique element type? Or in other words, why do you need a new class for each XML tag pair? If your elements are nested to some unknown depth, perhaps broaden your idea of your ElementList into an ElementTree. Take a look at the section "Basic Usage" midway down at url: http://effbot.org/zone/element-index.htm Or change you Market Class stucture(in your other discussion) to make it more dimensional by adding a tag attribute which would mark it as if it were a certain "class". class ElementNode(objec): def__init__(self, parent, elem) self.parent = parent # another elementNode object or None self.elem = elem # entire text block or just do offsets (i.e. file line numbers) self.tag = self.get_tag(elem) # market tag==class self.token = self.get_token(self) # "code" or whatever if variable self.sub_elems= self.get_subs(elem) # recursive ElementNodes; return a list or dict self.root = self.get_root(parent) # optional but handy # I like to use the root as the XML source; sometimes an XML file self.next = None # because I love double link lists # probably useful for that ObjectListView wxPython widget If in your case each Element does behave differently (ie has unique methods) then perhaps you should be looking at some other solution. Perhaps class factories or meta classes. I can't help you there. From rtomek at ceti.com.pl Mon Jan 3 22:48:21 2011 From: rtomek at ceti.com.pl (Tomasz Rola) Date: Tue, 4 Jan 2011 04:48:21 +0100 Subject: Python comparison matrix In-Reply-To: <58cb13ff-2581-463b-9d0a-3c07ab39d3f7@glegroupsg2000goo.googlegroups.com> References: <58cb13ff-2581-463b-9d0a-3c07ab39d3f7@glegroupsg2000goo.googlegroups.com> Message-ID: On Mon, 3 Jan 2011, Alex Willmer wrote: > I've created a spreadsheet that compares the built ins, features and > modules of the CPython releases so far. For instance it shows: [...] > I gathered the data from the documentation at python.org. It's work in > progress so there are plenty of rough edges and holes, but I'd like to > get your opinions, feedback and suggestions. > - Would you find such a document useful? Yes, definitely. Great idea, thanks for doing this. > - What format(s) would be most useful to you (e.g. spreadsheet, pdf, web > page(s), database, wall chart, desktop background)? I would vote for html/web pages with pdf as an option (i.e. a link), if you find it easy enough to make. This probably means you would like to have the source in a form that allows generation of both pages and pdf without much trouble. In this case, it seems there are more than few options to choose from. Perhaps in a form of Python code doing the job, with data in hashtables? That would be so Pythonish :-). > - Are there other aspects/pages that you'd like to see included? > - Do you know of source(s) for which versions of CPython supported which operating systems (e.g. the first and last Python release that works on Windows 98 or Mac OS 9)? The best I've found so far is PEP 11 Nothing comes to my head ATM. Regards, Tomasz Rola -- ** A C programmer asked whether computer had Buddha's nature. ** ** As the answer, master did "rm -rif" on the programmer's home ** ** directory. And then the C programmer became enlightened... ** ** ** ** Tomasz Rola mailto:tomasz_rola at bigfoot.com ** From kushal.kumaran+python at gmail.com Mon Jan 3 22:52:53 2011 From: kushal.kumaran+python at gmail.com (Kushal Kumaran) Date: Tue, 4 Jan 2011 09:22:53 +0530 Subject: String building using join In-Reply-To: <6ca085f6-7c03-44b2-a9f2-8d77db046c7e@s9g2000vby.googlegroups.com> References: <6ca085f6-7c03-44b2-a9f2-8d77db046c7e@s9g2000vby.googlegroups.com> Message-ID: On Mon, Jan 3, 2011 at 3:07 AM, gervaz wrote: > On 2 Gen, 19:14, Emile van Sebille wrote: >> >> >> class Test: >> ? ? ? def __init__(self, v1, v2): >> ? ? ? ? ? self.v1 = v1 >> ? ? ? ? ? self.v2 = v2 >> >> t1 = Test("hello", None) >> t2 = Test(None, "ciao") >> t3 = Test("salut", "hallo") >> t = [t1, t2, t3] >> >> "\n".join([y for x in t for y in [x.v1,x.v2] if y]) >> >> >> > > > Thanks Emile, despite that now the solution runs in quadratic time I > guess. I could also provide a __str__(self) representation, but in my > real code I don't have access to the class. Also using str() on an > empty object (i.e. None), the representation is 'None'. > Since no one else has mentioned it, I'll just point out that Emile's solution does not run in quadratic time. It has the same number of operations as the originally posted code. That str(None) results in "None" is not a problem because of the "if y" test in the list comprehension. -- regards, kushal From mrjean1 at gmail.com Mon Jan 3 23:28:30 2011 From: mrjean1 at gmail.com (MrJean1) Date: Mon, 3 Jan 2011 20:28:30 -0800 (PST) Subject: CPython on the Web References: <19141efb-a288-43bc-be0d-44769bf5974b@j32g2000prh.googlegroups.com><5942c6f9-7af5-4cff-84d4-f23a8b3bbfa1@k14g2000pre.googlegroups.com> <4D2106DF.6080609@verizon.net> <5a62ec44-7dd0-456c-b14c-92f3b97b7f2a@c13g2000prc.googlegroups.com> Message-ID: FireFox 3.6.13 on MacOS X Tiger (10.4.11) fails: Error: too much recursion Error: Modules is not defined Source File: http://synthensity.com/static/python.html /Jean On Jan 2, 11:26?pm, Wolfgang Strobl wrote: > azakai : > > >On Jan 2, 4:58 pm, pyt... at bdurham.com wrote: > >> Azakai/Gerry, > > >> > Errors when using Firefox 3.6.3: > > >> I'm running Firefox 3.6.1.3 and the interpreter is running fine. > > I guess that meant FIrefox 3.6.13 (without the last dot), the current > stable version. > > I'm using Firefox 3.6.13 (german) on Windowx XP (32bit, german) here, > and the interpreter is running fine, too. ?Same for Chrome 8.0.552.224. > > -- > Wir danken f r die Beachtung aller Sicherheitsbestimmungen From devplayer at gmail.com Mon Jan 3 23:34:18 2011 From: devplayer at gmail.com (DevPlayer) Date: Mon, 3 Jan 2011 20:34:18 -0800 (PST) Subject: list 2 dict? References: Message-ID: <69d248d7-cf62-49bf-9824-d8aec7de0a87@j25g2000yqa.googlegroups.com> An adaptation to Hrvoje Niksic's recipe Use a dictionary comprehention instead of a list comprehension or function call: lyst = [1, 2, 3, 4, 5, 6, 7, 'a', 8, 'b'] it = iter( lyst ) dyct = {i:it.next() for i in it} # I'm using {} and not [] for those with tiny fonts. #print dyct {8: 'b', 1: 2, 3: 4, 5: 6, 7: 'a'} Of course check for an "even" number of elements to the original list to avoid exceptions or dropping the last element on traps. From mrjean1 at gmail.com Mon Jan 3 23:34:33 2011 From: mrjean1 at gmail.com (MrJean1) Date: Mon, 3 Jan 2011 20:34:33 -0800 (PST) Subject: CPython on the Web References: <19141efb-a288-43bc-be0d-44769bf5974b@j32g2000prh.googlegroups.com> <5942c6f9-7af5-4cff-84d4-f23a8b3bbfa1@k14g2000pre.googlegroups.com> <3e973cb5-4208-4f73-8bbf-15e1bc2f7595@35g2000prt.googlegroups.com> <11daa83d-d065-4816-b63b-a0144cc49943@n32g2000pre.googlegroups.com> Message-ID: <96a8df4d-5cc2-4753-878b-68b1e044586b@z9g2000yqz.googlegroups.com> FYI, The example http://syntensity.com/static/python.html works fine in Safari 4.1.3 on MacOS X Tiger (10.4.11). /Jean On Jan 3, 5:59?pm, azakai wrote: > On Jan 3, 12:23?pm, Gerry Reno wrote: > > > > > > > On 01/03/2011 03:10 PM, azakai wrote: > > > > On Jan 2, 5:55 pm, Gerry Reno wrote: > > > >> I tried printing sys.path and here is the output: > > > >> ['', '/usr/local/lib/python27.zip', '/usr/local/lib/python2.7/', > > >> '/usr/local/lib/python2.7/plat-linux2', > > >> '/usr/local/lib/python2.7/lib-tk', '/usr/local/lib/python2.7/lib-old', > > >> '/usr/local/lib/lib-dynload'] > > > >> Now, those paths must be on your machine because they are not on my > > >> client machine. ?But the interpreter is now running on MY machine. ?Well > > >> in a sandbox really. ?So how is that going to work? > > > > Yeah, those are the paths on the machine where the binary was compiled > > > (so, they are the standard paths on ubuntu). > > > > Anyhow the filesystem can't (and shouldn't) be accessed from inside a > > > browser page. > > > Well, the local filesystem could be accessible with the user's > > permission and this should be an option. > > Hmm, I think this might be possible with the HTML5 File API. Would > definitely be useful here. > > - azakai From no.email at nospam.invalid Tue Jan 4 00:33:46 2011 From: no.email at nospam.invalid (Paul Rubin) Date: Mon, 03 Jan 2011 21:33:46 -0800 Subject: list 2 dict? References: Message-ID: <7xipy5b5c5.fsf@ruckus.brouhaha.com> "Octavian Rasnita" writes: > If I want to create a dictionary from a list... > l = [1, 2, 3, 4, 5, 6, 7, 'a', 8, 'b'] dict(l[i:i+2] for i in xrange(0,len(l),2)) seems simplest to me. From nagle at animats.com Tue Jan 4 01:11:20 2011 From: nagle at animats.com (John Nagle) Date: Mon, 03 Jan 2011 22:11:20 -0800 Subject: CPython on the Web In-Reply-To: <19141efb-a288-43bc-be0d-44769bf5974b@j32g2000prh.googlegroups.com> References: <19141efb-a288-43bc-be0d-44769bf5974b@j32g2000prh.googlegroups.com> Message-ID: <4d22ba06$0$44020$742ec2ed@news.sonic.net> On 1/1/2011 11:26 PM, azakai wrote: > Hello, I hope this will be interesting to people here: CPython running > on the web, > > http://syntensity.com/static/python.html > > That isn't a new implementation of Python, but rather CPython 2.7.1, > compiled from C to JavaScript using Emscripten and LLVM. For more > details on the conversion process, see http://emscripten.org It's a cute hack, but it's about 1000 times slower than CPython. Try def cnt(n) : j = 0 for i in xrange(n) : j = j + 1 return(j) print(cnt(1000000)) with this. It will take 30 seconds or so to count to a million. John Nagle From calderone.jeanpaul at gmail.com Tue Jan 4 01:13:54 2011 From: calderone.jeanpaul at gmail.com (Jean-Paul Calderone) Date: Mon, 3 Jan 2011 22:13:54 -0800 (PST) Subject: Interrput a thread References: <81c24eb1-41b6-442a-a971-8a44d2cd6c1b@p8g2000vbs.googlegroups.com> <4d1e20c5$0$43986$742ec2ed@news.sonic.net> <874o9q7x3m.fsf@web.de> <71631a5e-d3af-4c5d-9f1d-07eb8044d792@39g2000yqa.googlegroups.com> <4855b05f-1ea4-4287-9066-5aeb1b7cb720@k11g2000vbf.googlegroups.com> <3856d645-86a5-449f-adca-fcbbc6371ba4@l17g2000yqe.googlegroups.com> <561e8842-bcca-45c4-baee-e5431e778f6a@n10g2000yqd.googlegroups.com> Message-ID: <0e9cafd1-17ab-4a0f-b93f-a18929188b06@o4g2000yqd.googlegroups.com> On Jan 3, 6:17?pm, Adam Skutt wrote: > On Jan 3, 5:24?pm, Jean-Paul Calderone > wrote: > > > Of course. ?The whole point here is not about threads vs processes. > > It's about shared memory concurrency vs non-shared memory > > concurrency. ?You can implement both with threads and both with > > processes, but threads are geared towards shared memory and processes > > are geared towards non-shared memory. ?So what most people mean by > > "use processes" is "don't use shared memory". > > This is entirely my presumption, but I think if the OP were keenly > aware of the differences between thread and processes, it's pretty > likely he wouldn't have asked his question in the first place. > Fair enough. :) > Also, I've written lots and lots of "use processes" code on multiple > platforms, and much of it has used some sort of shared memory > construct. ?It's actually pretty common, especially in code bases with > a lot of history. ?Not all the world is Apache. > Hee hee, Apache. :) > Adam From alonmozilla at gmail.com Tue Jan 4 02:13:43 2011 From: alonmozilla at gmail.com (azakai) Date: Mon, 3 Jan 2011 23:13:43 -0800 (PST) Subject: CPython on the Web References: <19141efb-a288-43bc-be0d-44769bf5974b@j32g2000prh.googlegroups.com> <4d22ba06$0$44020$742ec2ed@news.sonic.net> Message-ID: On Jan 3, 10:11?pm, John Nagle wrote: > On 1/1/2011 11:26 PM, azakai wrote: > > > Hello, I hope this will be interesting to people here: CPython running > > on the web, > > >http://syntensity.com/static/python.html > > > That isn't a new implementation of Python, but rather CPython 2.7.1, > > compiled from C to JavaScript using Emscripten and LLVM. For more > > details on the conversion process, seehttp://emscripten.org > > ? ? It's a cute hack, but it's about 1000 times slower than CPython. > > Try > > def cnt(n) : > ? ? ?j = 0 > ? ? ?for i in xrange(n) : > ? ? ? ? ?j = j + 1 > ? ? ?return(j) > > print(cnt(1000000)) > > with this. ?It will take 30 seconds or so to count to a million. > > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? John Nagle Yes, as I said, "the code isn't optimized (so don't expect good performance)" :) It can get much faster with more work. - azakai From passionate_programmer at hotmail.com Tue Jan 4 03:00:49 2011 From: passionate_programmer at hotmail.com (RP Khare) Date: Tue, 4 Jan 2011 13:30:49 +0530 Subject: Qt with PyDev Message-ID: I installed Aptana PyDev plugin to Aptana Studio 3 Beta. I want to write my first GUI application using Python and I want to use Qt for it. How to integrate Qt into PyDev, or is there any other alternative IDE to work with Qt?elementFontfont-familyfont-sizefont-stylefont-variantfont-weightletter-spacingline-heighttext-decorationtext-aligntext-indenttext-transformwhite-spaceword-spacingcolorBackgroundbg-attachmentbg-colorbg-imagebg-positionbg-repeatBoxwidthheightborder-topborder-rightborder-bottomborder-leftmarginpaddingmax-heightmin-heightmax-widthmin-widthoutline-coloroutline-styleoutline-widthPositioningpositiontopbottomrightleftfloatdisplayclearz-indexListlist-style-imagelist-style-typelist-style-positionTablevertical-alignborder-collapseborder-spacingcaption-sideempty-cellstable-layoutEffectstext-shadow-webkit-box-shadowborder-radiusOtheroverflowcursorvisibility ...........Rohit -------------- next part -------------- An HTML attachment was scrubbed... URL: From nagle at animats.com Tue Jan 4 03:02:47 2011 From: nagle at animats.com (John Nagle) Date: Tue, 04 Jan 2011 00:02:47 -0800 Subject: CPython on the Web In-Reply-To: References: <19141efb-a288-43bc-be0d-44769bf5974b@j32g2000prh.googlegroups.com> <4d22ba06$0$44020$742ec2ed@news.sonic.net> Message-ID: <4d22d425$0$44041$742ec2ed@news.sonic.net> On 1/3/2011 11:13 PM, azakai wrote: > On Jan 3, 10:11 pm, John Nagle wrote: >> On 1/1/2011 11:26 PM, azakai wrote: >> >>> Hello, I hope this will be interesting to people here: CPython running >>> on the web, >> >>> http://syntensity.com/static/python.html >> >>> That isn't a new implementation of Python, but rather CPython 2.7.1, >>> compiled from C to JavaScript using Emscripten and LLVM. For more >>> details on the conversion process, seehttp://emscripten.org >> >> It's a cute hack, but it's about 1000 times slower than CPython. > > Yes, as I said, "the code isn't optimized (so > don't expect good performance)" :) > > It can get much faster with more work. Yea, right. You're three deep in interpreters. Performance is going to suck. John Nagle From devplayer at gmail.com Tue Jan 4 04:12:32 2011 From: devplayer at gmail.com (DevPlayer) Date: Tue, 4 Jan 2011 01:12:32 -0800 (PST) Subject: list 2 dict? References: <69d248d7-cf62-49bf-9824-d8aec7de0a87@j25g2000yqa.googlegroups.com> Message-ID: <11865218-b187-479e-8ef9-9a66d8b3b443@j25g2000yqa.googlegroups.com> or only convert the item when you need it leaving the lists as the source lyst = [1, 2, 3, 4, 5, 6, 7, 'a', 8, 'b'] func = lambda alist, index: dict([(lyst[index*2], lyst[(index*2)+1]),]) func(lyst, 0) {1: 2} func(lyst, 2) {5: 6} ##########------------ or as a function def func(lyst, index): return dict(((lyst[index], lyst[index+1]),)) From oknedz at gmail.com Tue Jan 4 04:40:02 2011 From: oknedz at gmail.com (Zdenko) Date: Tue, 04 Jan 2011 10:40:02 +0100 Subject: Matrix multiplication Message-ID: Please, can anybody write me a simple recursive matrix multiplication using multiple threads in Python, or at least show me some guidelines how to write it myself Thank You From wander.lairson at gmail.com Tue Jan 4 05:06:05 2011 From: wander.lairson at gmail.com (wander.lairson) Date: Tue, 4 Jan 2011 08:06:05 -0200 Subject: PyPi question Message-ID: Dear all, I am the PyUSB author and recently I was asked to update pyusb package in the PyPi. The point is that I am not the maintainer and don't know who is. Now I need to contact the current package maintainer but I could not find how to do so through PyPi (as maintainer's email does not show). Does anyone know how am I supposed to proceed (open a support request, maybe) ? Thanks in advance. -- Best Regards, Wander Lairson Costa LCoN - Laborat?rio de Computa??o Natural - Natural Computing Laboratory (http://www.mackenzie.com.br/lcon.html) Programa de P?s-Gradua??o em Engenharia El?trica (PPGEE) Faculdade de Computa??o e Inform?tica (FCI) Universidade Presbiteriana Mackenzie - SP - Brazil From ulrich.eckhardt at dominolaser.com Tue Jan 4 05:15:15 2011 From: ulrich.eckhardt at dominolaser.com (Ulrich Eckhardt) Date: Tue, 04 Jan 2011 11:15:15 +0100 Subject: Matrix multiplication References: Message-ID: <4h8bv7-p09.ln1@satorlaser.homedns.org> Zdenko wrote: > Please, can anybody write me a simple recursive matrix multiplication > using multiple threads in Python, or at least show me some guidelines > how to write it myself No problem, I just need your bank account data to withdraw the payment and the address of your teacher whom to send the results. ;^) Seriously, things don't work like this. If you show effort, you will get help, but you don't get working solutions without even a bit of effort on your own. Start with a recursive algorithm, then make it multithreaded. Be prepared to make some experiments on how to distribute tasks to threads and collect them again. Uli From spy974 at gmail.com Tue Jan 4 06:05:23 2011 From: spy974 at gmail.com (=?ISO-8859-1?Q?Gr=E9gory_Leocadie?=) Date: Tue, 4 Jan 2011 03:05:23 -0800 (PST) Subject: Matrix multiplication References: <4h8bv7-p09.ln1@satorlaser.homedns.org> Message-ID: On 4 jan, 11:15, Ulrich Eckhardt wrote: > Zdenko wrote: > > Please, can anybody write me a simple recursive matrix multiplication > > using multiple threads in Python, or at least show me some guidelines > > how to write it myself > > No problem, I just need your bank account data to withdraw the payment and > the address of your teacher whom to send the results. ;^) > > Seriously, things don't work like this. If you show effort, you will get > help, but you don't get working solutions without even a bit of effort on > your own. > > Start with a recursive algorithm, then make it multithreaded. Be prepared to > make some experiments on how to distribute tasks to threads and collect > them again. > > Uli Hi, just have a look here http://en.wikipedia.org/wiki/Matrix_multiplication and find out what parts can be parallelized ;) Gregory LEOCADIE From pavlovevidence at gmail.com Tue Jan 4 06:17:34 2011 From: pavlovevidence at gmail.com (Carl Banks) Date: Tue, 4 Jan 2011 03:17:34 -0800 (PST) Subject: CPython on the Web References: <19141efb-a288-43bc-be0d-44769bf5974b@j32g2000prh.googlegroups.com> Message-ID: <98f1b5df-c1af-450e-876b-365e00f33695@v17g2000prc.googlegroups.com> On Jan 3, 4:55?pm, azakai wrote: > But through a combination of optimizations on the side of Emscripten > (getting all LLVM optimizations to work when compiling to JS) and on > the side of the browsers (optimizing accesses on typed arrays in JS, > etc.), then I hope the code will eventually run quite fast, even > comparably to C. This is a very cool idea. It's quite fascinating to view the Javascript "machine code" for a complete CPython interpreter. I'm sure with a little work you'll be able to improve its performance, but I think "comparably to C" is going to be a tall order. If you can get this to work reasonably well, and manage to get it successfully deployed it somewhere, I'd recommend petitioning to have this be considered an official platform. Carl Banks From oknedz at gmail.com Tue Jan 4 07:22:33 2011 From: oknedz at gmail.com (Zdenko) Date: Tue, 04 Jan 2011 13:22:33 +0100 Subject: Matrix multiplication In-Reply-To: <4h8bv7-p09.ln1@satorlaser.homedns.org> References: <4h8bv7-p09.ln1@satorlaser.homedns.org> Message-ID: On 4.1.2011 11:15, Ulrich Eckhardt wrote: > Zdenko wrote: >> Please, can anybody write me a simple recursive matrix multiplication >> using multiple threads in Python, or at least show me some guidelines >> how to write it myself > > No problem, I just need your bank account data to withdraw the payment and > the address of your teacher whom to send the results. ;^) > > Seriously, things don't work like this. If you show effort, you will get > help, but you don't get working solutions without even a bit of effort on > your own. > > Start with a recursive algorithm, then make it multithreaded. Be prepared to > make some experiments on how to distribute tasks to threads and collect > them again. > > Uli > Ok, I expected something like this :) Lets try this way: I wrote these two codes for example: this one is naive way of matrix multiplication using one thread from random import * from time import clock import threading t0 = clock() A=[] B=[] C=[] m=300 #size of matrix m x m for i in range(m): A.append([]) B.append([]) C.append([]) for j in range(m): A[i].append(randint(1,9)) B[i].append(randint(1,9)) C[i].append(0) class MyThread ( threading.Thread ): def run ( self ): for i in range(m): for j in range(m): for k in range(m): C[i][j]+=A[i][k]*B[k][j] t=MyThread() t.start() t.join() print clock() - t0, "seconds" this one is using two threads, each one is multiplying half of matrix import time from threading import Thread from random import randint t0 = time.clock() class MyThread(Thread): def __init__(self, poc, kr): Thread.__init__(self) self.poc=poc self.kr=kr def run(self): for i in range(self.poc,self.kr): for j in range(m): for k in range(m): C[i][j]+=A[i][k]*B[k][j] A=[] B=[] C=[] m=300 #size of matrix m x m for i in range(m): A.append([]) B.append([]) C.append([]) for j in range(m): A[i].append(randint(1,9)) B[i].append(randint(1,9)) C[i].append(0) thr1=MyThread(0,m/2) thr2=MyThread(m/2,m) thr1.start() thr2.start() thr1.join() thr2.join() print time.clock() - t0, "seconds" why is second one more than twice slower than first when it should be faster. I suspect that problem is in simultaneous access to matrix C but i don't know how to solve this. I used this just for example to see how the threading works so i can work on recursive and Strassen algorithm. From devplayer at gmail.com Tue Jan 4 09:27:07 2011 From: devplayer at gmail.com (DevPlayer) Date: Tue, 4 Jan 2011 06:27:07 -0800 (PST) Subject: Python comparison matrix References: <58cb13ff-2581-463b-9d0a-3c07ab39d3f7@glegroupsg2000goo.googlegroups.com> Message-ID: <40120908-0951-46bb-91c6-2efdcb5be4cc@l7g2000vbv.googlegroups.com> Awesome, thanks so much for you efforts and sharing. Idea: It would be great if we put this table into a python program where I can run a script against this table and a Python source code module (file) so that it would spit out a list of strings showing what python versions work with said source code file. python.exe get_versions.py myPythonSourceFile.py -insertMetaInfo Would prepend a text line to myPythonSourceFile.py in some format like: # __requires_python__ = ["Python 2.5-2.7"] or # __requires_python__ = ["Python", "2.5.x", "2.6.x", "2.7.x"] or # __requires_python__ = {"1.0.x":False, ..., "2.5.x":True, "2.6.x":True, "2.7.x":True] where key format is comparable agains on of the following: sys.version, sys.version_info, sys.winver, sys.api_version, sys.subversion Idea: Perhaps add the table you made a list of which libraries/packages are included in the distro to the different releases. Comparable against sys.builtin_module_names Anyone ambisous enough to play with those idea, be my guest. From gervaz at gmail.com Tue Jan 4 10:05:41 2011 From: gervaz at gmail.com (gervaz) Date: Tue, 4 Jan 2011 07:05:41 -0800 (PST) Subject: Interrput a thread References: <81c24eb1-41b6-442a-a971-8a44d2cd6c1b@p8g2000vbs.googlegroups.com> <4d1e20c5$0$43986$742ec2ed@news.sonic.net> <874o9q7x3m.fsf@web.de> <71631a5e-d3af-4c5d-9f1d-07eb8044d792@39g2000yqa.googlegroups.com> <4855b05f-1ea4-4287-9066-5aeb1b7cb720@k11g2000vbf.googlegroups.com> <3856d645-86a5-449f-adca-fcbbc6371ba4@l17g2000yqe.googlegroups.com> <561e8842-bcca-45c4-baee-e5431e778f6a@n10g2000yqd.googlegroups.com> <0e9cafd1-17ab-4a0f-b93f-a18929188b06@o4g2000yqd.googlegroups.com> Message-ID: <0e803f65-3941-4c94-84b5-8a1100942742@j29g2000yqm.googlegroups.com> On 4 Gen, 07:13, Jean-Paul Calderone wrote: > On Jan 3, 6:17?pm, Adam Skutt wrote: > > > On Jan 3, 5:24?pm, Jean-Paul Calderone > > wrote: > > > > Of course. ?The whole point here is not about threads vs processes. > > > It's about shared memory concurrency vs non-shared memory > > > concurrency. ?You can implement both with threads and both with > > > processes, but threads are geared towards shared memory and processes > > > are geared towards non-shared memory. ?So what most people mean by > > > "use processes" is "don't use shared memory". > > > This is entirely my presumption, but I think if the OP were keenly > > aware of the differences between thread and processes, it's pretty > > likely he wouldn't have asked his question in the first place. > > Fair enough. :) > > > Also, I've written lots and lots of "use processes" code on multiple > > platforms, and much of it has used some sort of shared memory > > construct. ?It's actually pretty common, especially in code bases with > > a lot of history. ?Not all the world is Apache. > > Hee hee, Apache. :) > > > > > Adam- Nascondi testo citato > > - Mostra testo citato - BTW thanks for the suggestions. As in my original code snippet, the shared object that the threads are using is the Queue, that itself implement locking mechanism so I don't have to worry about concurrent access. Regarding my question, it was just to have a hint on how a thread termination can be handled as, per example, you have the consumer-producer pattern. Mattia From gherron at islandtraining.com Tue Jan 4 10:09:53 2011 From: gherron at islandtraining.com (Gary Herron) Date: Tue, 04 Jan 2011 07:09:53 -0800 Subject: Qt with PyDev In-Reply-To: References: Message-ID: <4D233841.9080909@islandtraining.com> On 01/04/2011 12:00 AM, RP Khare wrote: > I installed Aptana PyDev plugin to Aptana Studio 3 Beta. I want to > write my first GUI application using Python and I want to use Qt for > it. How to integrate Qt into PyDev, or is there any other alternative > IDE to work with Qt? > > > element > > Font > font-family > font-size > font-style > font-variant > font-weight > letter-spacing > line-height > text-decoration > text-align > text-indent > text-transform > white-space > word-spacing > color > Background > bg-attachment > bg-color > bg-image > bg-position > bg-repeat > Box > width > height > border-top > border-right > border-bottom > border-left > margin > padding > max-height > min-height > max-width > min-width > outline-color > outline-style > outline-width > Positioning > position > top > bottom > right > left > float > display > clear > z-index > List > list-style-image > list-style-type > list-style-position > Table > vertical-align > border-collapse > border-spacing > caption-side > empty-cells > table-layout > Effects > text-shadow > -webkit-box-shadow > border-radius > Other > overflow > cursor > visibility > > > ........... > Rohit See either of these packages: PyQt: http://qt.nokia.com/products/ PySide: http://www.pyside.org/ Either one should work with PyDev. Gary Herron -------------- next part -------------- An HTML attachment was scrubbed... URL: From fuzzyman at gmail.com Tue Jan 4 10:12:48 2011 From: fuzzyman at gmail.com (Fuzzyman) Date: Tue, 4 Jan 2011 07:12:48 -0800 (PST) Subject: Interrput a thread References: <81c24eb1-41b6-442a-a971-8a44d2cd6c1b@p8g2000vbs.googlegroups.com> Message-ID: <2ebc11a5-1b45-4faa-97b9-c84f0db015a4@k22g2000yqh.googlegroups.com> On Dec 29 2010, 11:31?pm, gervaz wrote: > Hi all, I need to stop a threaded (using CTR+C or kill) application if > it runs too much or if I decide to resume the work later. > I come up with the following test implementation but I wanted some > suggestion from you on how I can implement what I need in a better or > more pythonic way. Here the code: This is a case that .NET (C#) handles better than Python or Java. It is unsafe to terminate an os level thread at an arbitrary point because it may be executing code in a critical section. Both Java and .NET used to provide ways to terminate threads "safely" by raising an asynchronous exception in the thread. Releasing locks (etc) that the thread holds could then be done in a finally section protecting the code. Python doesn't allow you to abort threads. Unfortunately the thread abort exception could also be raised in the finally section - prematurely aborting the lock / resource cleanup. Java handled this by deprecating thread aborting. (Python has never had it I believe.) .NET handled it by changing the semantics of thread aborting - the thread abort exception will never be raised in a finally block. This makes thread aborting safe, although technically you can subvert it by putting all your code in a finally block (you can also catch and cancel the thread abort exception). The standard advice is to use a flag and do manual checking to abort threads. This only works for fine grained operations and *doesn't* work for very coarse grained operations or where there aren't convenient places to check the flag. It's another place where people sometimes have a genuine need/use case yet people will insist on telling them they don't *really* want it... Anyway, although there are ways based on ctypes to abort Python threads it's not really safe. If you google you should find them, hopefully with intelligible caveat emptor warnings... All the best, Michael Foord > > import os > import signal > import time > from threading import Thread, current_thread > from queue import LifoQueue, Empty > > COMMAND = {"STOP": 0, "NORMAL": 1} > THREAD_NUM = 5 > > lq = LifoQueue() > > print("{0}\n".format(os.getpid())) > > class InterceptInterrupt(Exception): > ? ? pass > > class Handler: > ? ? def __init__(self, queue): > ? ? ? ? self._queue = queue > ? ? def __del__(self): > ? ? ? ? print("Bye bye!") > ? ? def getHandler(self, signum, frame): > ? ? ? ? print("Interrupt raised!") > ? ? ? ? for _ in range(THREAD_NUM): > ? ? ? ? ? ? self._queue.put((COMMAND["STOP"], None)) > ? ? ? ? raise InterceptInterrupt > > h = Handler(lq) > > signal.signal(signal.SIGINT, h.getHandler) > > for i in range(25): > ? ? lq.put((COMMAND["NORMAL"], i)) > > def do_work(queue): > ? ? while True: > ? ? ? ? time.sleep(5) > ? ? ? ? try: > ? ? ? ? ? ? cmd, value = queue.get(block=False) > ? ? ? ? ? ? if cmd == COMMAND["STOP"]: > ? ? ? ? ? ? ? ? print("{0}: STOP command > received!".format(current_thread().name)) > ? ? ? ? ? ? ? ? break > ? ? ? ? ? ? elif cmd == COMMAND["NORMAL"]: > ? ? ? ? ? ? ? ? print(value) > ? ? ? ? except Empty: > ? ? ? ? ? ? break > > threads = [Thread(target=do_work, args=(lq,)) for _ in > range(THREAD_NUM)] > > for t in threads: > ? ? t.start() > > while not lq.empty(): > ? ? try: > ? ? ? ? time.sleep(1) > ? ? except (IOError, InterceptInterrupt): > ? ? ? ? break > > for t in threads: > ? ? t.join() > > if lq.empty(): > ? ? print("The queue is empty.") > else: > ? ? print("The queue is NOT empty. Some additional work has to be > done.") > > Thank you, > Mattia From fuzzyman at gmail.com Tue Jan 4 10:13:49 2011 From: fuzzyman at gmail.com (Fuzzyman) Date: Tue, 4 Jan 2011 07:13:49 -0800 (PST) Subject: Interrput a thread References: <81c24eb1-41b6-442a-a971-8a44d2cd6c1b@p8g2000vbs.googlegroups.com> <2ebc11a5-1b45-4faa-97b9-c84f0db015a4@k22g2000yqh.googlegroups.com> Message-ID: <8b7bcabb-a7f8-4967-8ddb-3fc8ae40559a@w17g2000yqh.googlegroups.com> On Jan 4, 3:12?pm, Fuzzyman wrote: > On Dec 29 2010, 11:31?pm, gervaz wrote: > > > Hi all, I need to stop a threaded (using CTR+C or kill) application if > > it runs too much or if I decide to resume the work later. > > I come up with the following test implementation but I wanted some > > suggestion from you on how I can implement what I need in a better or > > more pythonic way. Here the code: > > This is a case that .NET (C#) handles better than Python or Java. > Heh, so one possible option is to use IronPython.... :-) Michael Foord > It is unsafe to terminate an os level thread at an arbitrary point > because it may be executing code in a critical section. Both Java > and .NET used to provide ways to terminate threads "safely" by raising > an asynchronous exception in the thread. Releasing locks (etc) that > the thread holds could then be done in a finally section protecting > the code. Python doesn't allow you to abort threads. > > Unfortunately the thread abort exception could also be raised in the > finally section - prematurely aborting the lock / resource cleanup. > > Java handled this by deprecating thread aborting. (Python has never > had it I believe.) > > .NET handled it by changing the semantics of thread aborting - the > thread abort exception will never be raised in a finally block. This > makes thread aborting safe, although technically you can subvert it by > putting all your code in a finally block (you can also catch and > cancel the thread abort exception). > > The standard advice is to use a flag and do manual checking to abort > threads. This only works for fine grained operations and *doesn't* > work for very coarse grained operations or where there aren't > convenient places to check the flag. It's another place where people > sometimes have a genuine need/use case yet people will insist on > telling them they don't *really* want it... > > Anyway, although there are ways based on ctypes to abort Python > threads it's not really safe. If you google you should find them, > hopefully with intelligible caveat emptor warnings... > > All the best, > > Michael Foord > > > > > import os > > import signal > > import time > > from threading import Thread, current_thread > > from queue import LifoQueue, Empty > > > COMMAND = {"STOP": 0, "NORMAL": 1} > > THREAD_NUM = 5 > > > lq = LifoQueue() > > > print("{0}\n".format(os.getpid())) > > > class InterceptInterrupt(Exception): > > ? ? pass > > > class Handler: > > ? ? def __init__(self, queue): > > ? ? ? ? self._queue = queue > > ? ? def __del__(self): > > ? ? ? ? print("Bye bye!") > > ? ? def getHandler(self, signum, frame): > > ? ? ? ? print("Interrupt raised!") > > ? ? ? ? for _ in range(THREAD_NUM): > > ? ? ? ? ? ? self._queue.put((COMMAND["STOP"], None)) > > ? ? ? ? raise InterceptInterrupt > > > h = Handler(lq) > > > signal.signal(signal.SIGINT, h.getHandler) > > > for i in range(25): > > ? ? lq.put((COMMAND["NORMAL"], i)) > > > def do_work(queue): > > ? ? while True: > > ? ? ? ? time.sleep(5) > > ? ? ? ? try: > > ? ? ? ? ? ? cmd, value = queue.get(block=False) > > ? ? ? ? ? ? if cmd == COMMAND["STOP"]: > > ? ? ? ? ? ? ? ? print("{0}: STOP command > > received!".format(current_thread().name)) > > ? ? ? ? ? ? ? ? break > > ? ? ? ? ? ? elif cmd == COMMAND["NORMAL"]: > > ? ? ? ? ? ? ? ? print(value) > > ? ? ? ? except Empty: > > ? ? ? ? ? ? break > > > threads = [Thread(target=do_work, args=(lq,)) for _ in > > range(THREAD_NUM)] > > > for t in threads: > > ? ? t.start() > > > while not lq.empty(): > > ? ? try: > > ? ? ? ? time.sleep(1) > > ? ? except (IOError, InterceptInterrupt): > > ? ? ? ? break > > > for t in threads: > > ? ? t.join() > > > if lq.empty(): > > ? ? print("The queue is empty.") > > else: > > ? ? print("The queue is NOT empty. Some additional work has to be > > done.") > > > Thank you, > > Mattia From roy at panix.com Tue Jan 4 10:31:15 2011 From: roy at panix.com (Roy Smith) Date: Tue, 04 Jan 2011 10:31:15 -0500 Subject: Interrput a thread References: <81c24eb1-41b6-442a-a971-8a44d2cd6c1b@p8g2000vbs.googlegroups.com> <2ebc11a5-1b45-4faa-97b9-c84f0db015a4@k22g2000yqh.googlegroups.com> Message-ID: In article <2ebc11a5-1b45-4faa-97b9-c84f0db015a4 at k22g2000yqh.googlegroups.com>, Fuzzyman wrote: > It is unsafe to terminate an os level thread at an arbitrary point > because it may be executing code in a critical section. > [...] > The standard advice is to use a flag and do manual checking to abort > threads. This only works for fine grained operations and *doesn't* > work for very coarse grained operations or where there aren't > convenient places to check the flag. Another possibility is to not use threads! If you 1) Need asynchronous operation 2) Need iterruptability 3) Can't poll for an "please stop" signal You should look at running your "thread" as a separate process, which you can send a kill signal to when you want it to go away. You can then communicate with it via pipes, sockets, shared memory segments, whatever. Threads are a wonderful invention, but they are not a panacea for all possible parallelism tasks. Sometimes they're just the wrong tool. From devplayer at gmail.com Tue Jan 4 10:42:25 2011 From: devplayer at gmail.com (DevPlayer) Date: Tue, 4 Jan 2011 07:42:25 -0800 (PST) Subject: Matrix multiplication References: <4h8bv7-p09.ln1@satorlaser.homedns.org> Message-ID: <5909a2c0-b1ed-4dbd-852f-bb67c5dd5aa0@f9g2000vbq.googlegroups.com> I would be very suprised if you achieve faster results threading this problem. There's been much discussed on benefits or lack thereof to threading in Python (or in general). Threading is best used in situations where you are doing different kinds of tasks. For example if you want to do your matrix multiplication WHILE you were doing other things on your computer where matrix multiplication was a background process chugging away when you are not taxing the computer doing other stuff. Threading adds efficiency when you would have lots of "blocking" operations like reading in lots of big files from a comparable slow hard drive (compared to how fast a CPU processes data) or waiting on netword data (super slow compared to CPU processing). When you are doing mass numeric processing, you want to minimize the jumping from one function to another which uses overhead, recursion adds a small amount of uneccessary overhead, you want to minimize the need for the cpu to switch between threads or processes. If you still feel the need to use threads for some reason, for numeric processing I'd recommend using a "lighter" thread object, like a tiny thread or green thread or a threadlet or whatever they are calling them now. Another thing to note is it seems you might be expecting threads to run on different CPU cores expecting improvment. Be careful with this assumption. This is not always true. It is up to the CPU and OS to determine how threads are handled and perhaps the GIL to some extent. Beaware that Python has a GIL (some distributions). Google it if you don't know of it. To encourage better use of multi-core cpus you might consider the multiprocessing library included in Python 2.7 (I think) and above. I'm assuming that speed is an issue because you where timing your code. If you are doing actual serious number crunching there's lots of advice on this. The python Numpy package as well as Stackless Python (for microthreads or whatever thier called) comes to mind. Another thought. Ask yourself if you need a large in-memory or live set of processed numbers, in your case a fully and processed multiplied matrix. Usually a large set of in-memory numbers is something your going to use to simulate a model or to process and crunch further. Or is your actual usage going to be picking out a processed number here or there from the matrix. If this is true look at iterators or generators. Which would be a snapshot in time of your matrix multiplication. I like to think of Python generators like integral calculus (definition at: http://en.wikipedia.org/wiki/Integral_calculus) where the specific integral of a generator is often just 1. I'm loving generators a lot. For example there are generator accelorators which if you think it through means you can make generator deccelorators, useful for doing interpolation between elements of your matrix elements for example. I always forget if generators are thread safe though. Some indicators that generators could help: You're doing lots of for loops with range(). Also it's been measured that list comprehensions are slightly faster then while loops are a slightly faster then for loops. You can Google to confirm, enter something like "python fast iteration". Also if your numbers in your matix are actually not really numbers but objects with numbers, __slots__ is used to for large sets of objects (10s of millions at the very least) to minimize memory usage and perhaps with speed, if used properly. Just mentioning. I'd stay away from this though. Some of my informatation may be inaccurate (and even completely wrong; like I always get when a thread is best switched during a blocking verse a non-blocking operation) but there are some things to consider. From devplayer at gmail.com Tue Jan 4 10:49:29 2011 From: devplayer at gmail.com (DevPlayer) Date: Tue, 4 Jan 2011 07:49:29 -0800 (PST) Subject: Matrix multiplication References: <4h8bv7-p09.ln1@satorlaser.homedns.org> <5909a2c0-b1ed-4dbd-852f-bb67c5dd5aa0@f9g2000vbq.googlegroups.com> Message-ID: <961f9f53-5f51-4667-bac4-020dffeca3be@m7g2000vbn.googlegroups.com> BTW http://www.python.org/dev/peps/pep-0211/ From devplayer at gmail.com Tue Jan 4 11:10:02 2011 From: devplayer at gmail.com (DevPlayer) Date: Tue, 4 Jan 2011 08:10:02 -0800 (PST) Subject: Matrix multiplication References: <4h8bv7-p09.ln1@satorlaser.homedns.org> <5909a2c0-b1ed-4dbd-852f-bb67c5dd5aa0@f9g2000vbq.googlegroups.com> Message-ID: See section titled: "'array' or 'matrix'? Which should I use?" at http://www.scipy.org/NumPy_for_Matlab_Users BTW http://www.python.org/dev/peps/pep-0211/ From drsalists at gmail.com Tue Jan 4 12:08:32 2011 From: drsalists at gmail.com (Dan Stromberg) Date: Tue, 4 Jan 2011 09:08:32 -0800 Subject: Matrix multiplication In-Reply-To: References: <4h8bv7-p09.ln1@satorlaser.homedns.org> Message-ID: On Tue, Jan 4, 2011 at 4:22 AM, Zdenko wrote: > On 4.1.2011 11:15, Ulrich Eckhardt wrote: >> >> Zdenko wrote: >>> >>> Please, can anybody write me a simple recursive matrix multiplication >>> using multiple threads in Python, or at least show me some guidelines >>> how to write it myself >> >> No problem, I just need your bank account data to withdraw the payment and >> the address of your teacher whom to send the results. ;^) >> >> Seriously, things don't work like this. If you show effort, you will get >> help, but you don't get working solutions without even a bit of effort on >> your own. >> >> Start with a recursive algorithm, then make it multithreaded. Be prepared >> to >> make some experiments on how to distribute tasks to threads and collect >> them again. >> >> Uli >> > > Ok, I expected something like this :) > Lets try this way: > > I wrote these two codes for example: > > this one is naive way of matrix multiplication using one thread > > from random import * > from time import clock > import threading > > t0 = clock() > A=[] > B=[] > C=[] > m=300 ?#size of matrix m x m > > for i in range(m): > ? ?A.append([]) > ? ?B.append([]) > ? ?C.append([]) > ? ?for j in range(m): > ? ? ? ?A[i].append(randint(1,9)) > ? ? ? ?B[i].append(randint(1,9)) > ? ? ? ?C[i].append(0) > > class MyThread ( threading.Thread ): > > ? def run ( self ): > ? ? ? ? ? for i in range(m): > ? ? ? ? ? ? ? ?for j in range(m): > ? ? ? ? ? ? ? ? ? ?for k in range(m): > ? ? ? ? ? ? ? ? ? ? ? ?C[i][j]+=A[i][k]*B[k][j] > > t=MyThread() > t.start() > t.join() > print clock() - t0, "seconds" > > > > this one is using two threads, each one is multiplying half of matrix > > import time > from threading import Thread > from random import randint > > t0 = time.clock() > class MyThread(Thread): > ? ?def __init__(self, poc, kr): > ? ? ? ?Thread.__init__(self) > ? ? ? ?self.poc=poc > ? ? ? ?self.kr=kr > ? ?def run(self): > ? ? ? ? ? for i in range(self.poc,self.kr): > ? ? ? ? ? ? ? ?for j in range(m): > ? ? ? ? ? ? ? ? ? ?for k in range(m): > ? ? ? ? ? ? ? ? ? ? ? ?C[i][j]+=A[i][k]*B[k][j] > > A=[] > B=[] > C=[] > m=300 #size of matrix m x m > > for i in range(m): > ? ?A.append([]) > ? ?B.append([]) > ? ?C.append([]) > ? ?for j in range(m): > ? ? ? ?A[i].append(randint(1,9)) > ? ? ? ?B[i].append(randint(1,9)) > ? ? ? ?C[i].append(0) > thr1=MyThread(0,m/2) > thr2=MyThread(m/2,m) > thr1.start() > thr2.start() > thr1.join() > thr2.join() > print time.clock() - t0, "seconds" > > why is second one more than twice slower than first when it should be > faster. I suspect that problem is in simultaneous access to matrix C but i > don't know how to solve this. > > I used this just for example to see how the threading works so i can work on > recursive and Strassen algorithm. > -- > http://mail.python.org/mailman/listinfo/python-list > Threads in CPython are decent when you're doing I/O, not so good when you're doing CPU-bound tasks. When you're doing CPU-bound tasks, you may actually find that your application runs about 1/n times as fast, where n is the number of CPU's - that is, much slower. I don't mean that it just doesn't scale well, I mean that each additional CPU makes things slower for CPU-bound jobs. If you require java-like threading, you might be better off with Jython or Iron Python for now. pypy's likely to have good threading eventually, but last I heard it wasn't quite there yet. If you do require CPython, you might check out the greenlets module and/or PyCSP. Oh, and there's "stackless python", which amounts to a branch of CPython that's unlikely to be merged. It's supposed to be able to thread really well, and ISTR hearing that it's pretty similar to greenlets. The main force behind stackless is working on pypy now, I believe. Finally, with CPython, you can use the multiprocessing module to get pretty good parallelism via distinct processes. This way you tend to end up using queues for interprocess communication; these queues use shared memory. However, you might actually be able to put your matrix in shared memory - if it's large enough to justify that. I know you could put a linear array of homogeneous, scalar type in shared memory; I've not heard of a way of putting an aggregate type in shared memory. Naturally, you can fake an n dimensional array using a 1 dimensional array with a little multiplication and addition. As an example of using CPython with multiprocessing without having your matrix in shared memory, you could probably have one worker subprocess for each core on a system, divide up the cells of your result matrix by their coordinates (perhaps using an iterator and izip across the queues) and send a message (via a shared memory queue) with those coordinates to the appropriate subprocess. Then those subprocess send back the coordinates and the result at said coordinate via a different result queue. I suspect you'd want one queue for all the results, and one queue for each subprocess for initiating computation. Each subprocess would have its own COW copy of the input matrix. From jlconlin at gmail.com Tue Jan 4 12:11:26 2011 From: jlconlin at gmail.com (Jeremy) Date: Tue, 4 Jan 2011 09:11:26 -0800 (PST) Subject: Regular Expression for Finding and Deleting comments Message-ID: I am trying to write a regular expression that finds and deletes (replaces with nothing) comments in a string/file. Comments are defined by the first non-whitespace character is a 'c' or a dollar sign somewhere in the line. I want to replace these comments with nothing which isn't too hard. The trouble is, the comments are replaced with a new-line; or the new-line isn't captured in the regular expression. Below, I have copied a minimal example. Can someone help? Thanks, Jeremy import re text = """ c C - Second full line comment (first comment had no text) c Third full line comment F44:N 2 $ Inline comments start with dollar sign and go to end of line""" commentPattern = re.compile(""" (^\s*?c\s*?.*?| # Comment start with c or C \$.*?)$\n # Comment starting with $ """, re.VERBOSE|re.MULTILINE|re.IGNORECASE) found = commentPattern.finditer(text) print("\n\nCard:\n--------------\n%s\n------------------" %text) if found: print("\nI found the following:") for f in found: print(f.groups()) else: print("\nNot Found") print("\n\nComments replaced with ''") replaced = commentPattern.sub('', text) print("--------------\n%s\n------------------" %replaced) From fuzzyman at gmail.com Tue Jan 4 12:31:37 2011 From: fuzzyman at gmail.com (Fuzzyman) Date: Tue, 4 Jan 2011 09:31:37 -0800 (PST) Subject: Interrput a thread References: <81c24eb1-41b6-442a-a971-8a44d2cd6c1b@p8g2000vbs.googlegroups.com> <2ebc11a5-1b45-4faa-97b9-c84f0db015a4@k22g2000yqh.googlegroups.com> Message-ID: On Jan 4, 3:31?pm, Roy Smith wrote: > In article > <2ebc11a5-1b45-4faa-97b9-c84f0db01... at k22g2000yqh.googlegroups.com>, > > ?Fuzzyman wrote: > > It is unsafe to terminate an os level thread at an arbitrary point > > because it may be executing code in a critical section. > > [...] > > The standard advice is to use a flag and do manual checking to abort > > threads. This only works for fine grained operations and *doesn't* > > work for very coarse grained operations or where there aren't > > convenient places to check the flag. > > Another possibility is to not use threads! ?If you > > 1) Need asynchronous operation > > 2) Need iterruptability > > 3) Can't poll for an "please stop" signal > > You should look at running your "thread" as a separate process, which > you can send a kill signal to when you want it to go away. ?You can then > communicate with it via pipes, sockets, shared memory segments, whatever. > > Threads are a wonderful invention, but they are not a panacea for all > possible parallelism tasks. ?Sometimes they're just the wrong tool. However some tasks / algorithms are done much better with threads than processes. Asynchronous operations are good for IO bound concurrency but not for CPU bound concurrency. Michael Foord -- http://www.voidspace.org.uk/ From georgeryoung at gmail.com Tue Jan 4 12:38:58 2011 From: georgeryoung at gmail.com (gry) Date: Tue, 4 Jan 2011 09:38:58 -0800 (PST) Subject: CPython on the Web References: <19141efb-a288-43bc-be0d-44769bf5974b@j32g2000prh.googlegroups.com> <4d22ba06$0$44020$742ec2ed@news.sonic.net> Message-ID: On Jan 4, 1:11?am, John Nagle wrote: > On 1/1/2011 11:26 PM, azakai wrote: > > > Hello, I hope this will be interesting to people here: CPython running > > on the web, > > >http://syntensity.com/static/python.html > > > That isn't a new implementation of Python, but rather CPython 2.7.1, > > compiled from C to JavaScript using Emscripten and LLVM. For more > > details on the conversion process, seehttp://emscripten.org On loading, I "get script stack space quota is exhausted" under firefox 3.5.12, under linux. Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.12) Gecko/20100907 Fedora/3.5.12-1.fc12 Firefox/3.5.12 From greno at verizon.net Tue Jan 4 12:48:43 2011 From: greno at verizon.net (Gerry Reno) Date: Tue, 04 Jan 2011 12:48:43 -0500 Subject: CPython on the Web In-Reply-To: References: <19141efb-a288-43bc-be0d-44769bf5974b@j32g2000prh.googlegroups.com> <4d22ba06$0$44020$742ec2ed@news.sonic.net> Message-ID: <4D235D7B.30703@verizon.net> On 01/04/2011 12:38 PM, gry wrote: > On Jan 4, 1:11 am, John Nagle wrote: > >> On 1/1/2011 11:26 PM, azakai wrote: >> >> >>> Hello, I hope this will be interesting to people here: CPython running >>> on the web, >>> >> >>> http://syntensity.com/static/python.html >>> >> >>> That isn't a new implementation of Python, but rather CPython 2.7.1, >>> compiled from C to JavaScript using Emscripten and LLVM. For more >>> details on the conversion process, seehttp://emscripten.org >>> > On loading, I "get script stack space quota is exhausted" under > firefox 3.5.12, under linux. > Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.12) Gecko/20100907 > Fedora/3.5.12-1.fc12 Firefox/3.5.12 > It's a Firefox bug apparently fixed in Firefox 4.x. Some versions of Firefox 3.6.x do work but most do not. Regards, Gerry From nyc61 at fibertel.com.ar Tue Jan 4 12:56:18 2011 From: nyc61 at fibertel.com.ar (apustilnik) Date: Tue, 4 Jan 2011 09:56:18 -0800 (PST) Subject: Need your website? Message-ID: <17b28295-7048-48b1-a9a1-790dd12d48aa@c17g2000prm.googlegroups.com> Need a website for your enterprise or personal profile? Contact us now d212designs at hotmail.com http://www.d212.com.ar Yours sincerely. From nyc61 at fibertel.com.ar Tue Jan 4 12:56:20 2011 From: nyc61 at fibertel.com.ar (apustilnik) Date: Tue, 4 Jan 2011 09:56:20 -0800 (PST) Subject: Need your website? Message-ID: <69ed7a47-9bb0-4716-92f8-df16cce821b5@y19g2000prb.googlegroups.com> Need a website for your enterprise or personal profile? Contact us now d212designs at hotmail.com http://www.d212.com.ar Yours sincerely. From devplayer at gmail.com Tue Jan 4 13:07:48 2011 From: devplayer at gmail.com (DevPlayer) Date: Tue, 4 Jan 2011 10:07:48 -0800 (PST) Subject: list 2 dict? References: <69d248d7-cf62-49bf-9824-d8aec7de0a87@j25g2000yqa.googlegroups.com> <11865218-b187-479e-8ef9-9a66d8b3b443@j25g2000yqa.googlegroups.com> Message-ID: <40db65ac-aa85-44a5-aae4-021a1271da76@z19g2000yqb.googlegroups.com> Here is something totally the opposite of a nice one liner: A hackish module with a bloated generator. Feel free to comment, so I can learn the errors of my ways. Try not to be too mean though. Try to think of the attached file as a demonstration of ideas instead of good coding practices. Don't be afraid to mention the good points too. I tried to send an email with an attachment (to hide my shame) but I kept getting email rejections. # ======================================================= # list2dict.py # list item to dict item generator # I forget if generators are thread safe # DevPlayer at gmail.com # 2011-01 Jan-03 # def check_slice_bounds(list_len, start, stop, step): """Incomplete slice checker.""" # ----------------------------- # force step to be non-None if step is None: step = 1 # ----------------------------- # force step to be non-zero if step == 0: step = 1 # ----------------------------- # in iterating over list to be converted to dict # where list == [key, value, key, value] or in case swap==True # list = [value, key, value, key] # actual stepping is one for key, and plus one more for value step = step * 2 # ----------------------------- # force step to be smaller then size of list or -size of list if step > 0: if step > list_len: step = list_len else: if step < -list_len: step = -list_len # ----------------------------- # force step to be even for key, value iteration if step % 2 == 1: if step > 0: step = step - 1 else: step = step + 1 # ----------------------------- # set start to default; depending on step direction (+x vs -x) if start is None: if step > 0: start = 0 elif step == 0: start = 0 stop = start else: start = -1 # ----------------------------- # set stop to default; depending on step direction (+x vs -x) if stop is None: if step > 0: stop = list_len-1 elif step == 0: stop = start else: stop = -list_len # ----------------------------- # convert "start" to equivelent positive index if start < 0: if start < -list_len: raise IndexError("IndexError: list index out of range:", start) else: start = list_len + 1 + start # ----------------------------- # convert "stop" to equivelent positive index if stop < 0: if stop < -list_len: raise IndexError("IndexError: list index out of range:", stop) else: stop = list_len + 1 + stop return (start, stop, step) def gen(lyst, dyct=None, start=None, stop=None, step=None, swap=False): """ lyst == list to convert to dict dyct == external dict to be updated start == starting index stop step == amount to move index by; usually +1 or -1 (times 2) could be a float if clever enough. if step equals zero it is converted to 1 to prevent an infinite loop. step will be reset to be an index inbounds of a list len() swap 2nd item with the first item in the yield """ # ----------------------------- # Force into bool True or False from equivelent values if swap == True: swap = True else: swap = False # ----------------------------- # check and set lyst slice/index bounds of start, stop, step start, stop, step = check_slice_bounds(len(lyst), start, stop, step) # ----------------------------- index = start # ----------------------------- while 0 <= index < len(lyst): next = index + 1 if next == len(lyst): value = None else: value = lyst[next] key = lyst[index] # ----------------------------- # update external dict if given if dyct is not None: dyct[key] = value # ----------------------------- # effectively sway key with value == index, index+1 to index +1, index if swap: newindex = yield (value,key) else: newindex = yield (key,value) # ----------------------------- # process "newindex" variable if caller does a # gen.send(some_list_index) externally if newindex is None: index = index + (step) elif 0 <= newindex < len(lyst): # fix this to allow for negative index for negative stepping # but don't forget to convert it to its corrosponding # positive index index = newindex else: # fix this so it doesn't error on index 0 #raise IndexError("Index is out of range:", index) pass # ----------------------------- # Ungracefully coerce end of iteration if step > 0: if index > stop: # fix to raise StopIteration break else: if index < stop: # fix to raise StopIteration break # Example usage testlist = [1, 2, 3, 4, 5, 6, 7, 'a', 8, 'b'] # -------------------- d = {} e = {y[0]:y[1] for y in gen(testlist,d)} print d print d print 'next demo1' # -------------------- d = {} e = {y[1]:y[0] for y in gen(testlist,d)} f = {y[0]:y[1] for y in gen(testlist,d, swap=True)} print d print e print f print 'next demo2' # -------------------- d = {} for x in gen(testlist,d): print x print d print 'next demo3' # -------------------- d = {} e = [y for y in gen(testlist,d,swap=True)] print d print e print 'next demo4' # -------------------- d = {} e = gen(testlist,d) try: while e.next(): pass except: pass print d #print 'next demo' From devplayer at gmail.com Tue Jan 4 13:18:22 2011 From: devplayer at gmail.com (DevPlayer) Date: Tue, 4 Jan 2011 10:18:22 -0800 (PST) Subject: list 2 dict? References: <69d248d7-cf62-49bf-9824-d8aec7de0a87@j25g2000yqa.googlegroups.com> <11865218-b187-479e-8ef9-9a66d8b3b443@j25g2000yqa.googlegroups.com> <40db65ac-aa85-44a5-aae4-021a1271da76@z19g2000yqb.googlegroups.com> Message-ID: <0315b5bd-30e3-4508-b4af-9ebe16cdb5bd@15g2000vbz.googlegroups.com> The shorter version: This doesn't need any x = iter(list) line. perhaps more useful if you have a bunch of lists to be converted through out your code. def dictit(lyst): i = 0 while i < len(lyst): yield lyst[i], lyst[i+1] i = i + 2 l = [1, 2, 3, 4, 5, 6, 7, 'a', 8, 'b'] {d[0]:d[1] for d in dictit(l)} 3 again a dict comprehension func = lambda l: {k[0]:k[1] for k in dictit(l)} d = func(l) From xahlee at gmail.com Tue Jan 4 13:24:24 2011 From: xahlee at gmail.com (Xah Lee) Date: Tue, 4 Jan 2011 10:24:24 -0800 (PST) Subject: opinion: comp lang docs style Message-ID: <98e82f1b-cf59-4e64-8fd4-63671f96b04f@r19g2000prm.googlegroups.com> a opinion piece. ?The Idiocy of Computer Language Docs? http://xahlee.org/comp/idiocy_of_comp_lang.html -------------------------------------------------- The Idiocy of Computer Language Docs Xah Lee, 2011-01-03 Worked with Mathematica for a whole day yesterday, after about 10 years hiatus. Very nice. Mathematica lang and doc, is quite unique. Most other langs drivel with jargons, pettiness, comp-sci pretentiousness, while their content is mathematically garbage. (unixism mumble jumple (perl, unix), or ?proper?-engineering OOP fantasy (java), or impractical and ivory-tower adacemician idiocy as in Scheme & Haskell ( currying, tail recursion, closure, call-cc, lisp1 lisp2, and monad monad monad!)) (See: What are OOP's Jargons and Complexities ? Language, Purity, Cult, and Deception.) Mathematica, in its doc, is plain and simple. None of the jargon and pretention shit. Very easy to understand. Yet, some of its function's technical aspects are far more scholarly abstruse than any other lang (dealing with advanced math special functions that typically only a few thousand people in the world understand.). ------------------------------ A Gander into the Idiocies Here's a gander into the doc drivel in common langs. ------------------------------ unix In unix man pages, it starts with this type of garbage: SYNOPSIS gzip [ -acdfhlLnNrtvV19 ] [-S suffix] [ name ... ] gunzip [ -acfhlLnNrtvV ] [-S suffix] [ name ... ] zcat [ -fhLV ] [ name ... ] SYNOPSIS zip [-aABcdDeEfFghjklLmoqrRSTuvVwXyz!@$] [-- longoption ...] [-b path] [-n suf fixes] [-t date] [-tt date] [zipfile [file ...]] [-xi list] Here, the mindset of unix idiots, is that somehow this ?synopsis? form is technically precise and superior. They are thinking that it captures the full range of syntax in the most concise way. In practice, it's seldomly read. It's actually not accurate as one'd thought; no program can parse it and agree with the actual behavior. It's filled with errors, incomprehensible to human. Worse of all, the semantic of unix software's options are the worst rape to any possible science in computer science. See: The Nature of the Unix Philosophy ? Unix Pipe As Functional Language ? Unix zip Utility Path Problem. ------------------------------ Python In Python, you see this kinda garbage: 7.1. The if statement The if statement is used for conditional execution: if_stmt ::= "if" expression ":" suite ( "elif" expression ":" suite )* ["else" ":" suite] (Source docs.python.org) Here, the mindset of the python idiots is similar to the unix tech geekers. They think that using the BNF notation makes their doc more clear and precise. The fact is, there are so many variations of BNF each trying to fix other's problem. BNF is actually not used as a computer language for syntax description. It's mostly used to communicate syntax to humans. Like regex, there are so many variations. But worse than regex in the sense that there are actually not many actual implementations of BNF. Real word syntax description language are usually nothing close to BNF. See: Pattern Matching vs Lexical Grammar Specification. This incomprehensible BNF notation is the only thing you get if you want to know the basic syntax of ?if?, ?for?, ?while?, ?lambda?, or other basic constructs of python. ------------------------------ Perl In perl, you see this type of drivel: A Perl program consists of a sequence of declarations and statements which run from the top to the bottom. Loops, subroutines and other control structures allow you to jump around within the code. Perl is a free-form language, you can format and indent it however you like. Whitespace mostly serves to separate tokens, unlike languages like Python where it is an important part of the syntax. Many of Perl's syntactic elements are optional. Rather than requiring you to put parentheses around every function call and declare every variable, you can often leave such explicit elements off and Perl will figure out what you meant. This is known as Do What I Mean, abbreviated DWIM. It allows programmers to be lazy and to code in a style with which they are comfortable. Perl borrows syntax and concepts from many languages: awk, sed, C, Bourne Shell, Smalltalk, Lisp and even English. Other languages have borrowed syntax from Perl, particularly its regular expression extensions. So if you have programmed in another language you will see familiar pieces in Perl. They often work the same, but see perltrap for information about how they differ. (Source perldoc.perl.org) Notice they introduced you to their lingo ?DWIM?. Juvenile humor is a characteristics of perl's docs. It's a whole cult. They have ?perl republic?, ?state of the onion?, ?apocalypse?, ?perl monger?, ?perl golf?, etc.(See: Larry Wall and Cults.) Another trait is irrelevant rambling. For example, in the above you see: ?Perl borrows syntax and concepts from many languages: awk, sed, C, Bourne Shell, Smalltalk, Lisp and even English.?. However, perl doc overall is more practically usable than Python's. ------------------------------ Haskell Here's a example of ivory-tower idiocy, from Haskellers: Haskell uses a traditional Hindley-Milner polymorphic type system to provide a static type semantics [4, 6], but the type system has been extended with type classes (or just classes) that provide a structured way to introduce overloaded functions. A class declaration (Section 4.3.1) introduces a new type class and the overloaded operations that must be supported by any type that is an instance of that class. An instance declaration (Section 4.3.2) declares that a type is an instance of a class and includes the definitions of the overloaded operations?called class methods? instantiated on the named type. For example, suppose we wish to overload the operations (+) and negate on types Int and Float. We introduce a new type class called Num: class Num a where -- simplified class declaration for Num (+) :: a -> a -> a -- (Num is defined in the Prelude) negate :: a -> a This declaration may be read ?a type a is an instance of the class Num if there are class methods (+) and negate, of the given types, defined on it.? (Source www.haskell.org) Note the words ?Hindley-Milner?, ?polymorphic?, ?static type semantics?, ?overloaded operations?. The reason they wrote their doc like that is because they are academicians. You might think that their writing is really scholarly, mathematically meaningful, almost provably correct, full of dense mathematical rigor, and necessarily hard to understand because of the advanced math ideas. By the look of it it is really daunting. The irony is that the writing is often imprecise, most use of tech jargons and terms are absolutely uncessarily to the point of being irrelevant. And, the writing quality is pretty bad, far below the quality of standard math journal's articles. -------------------------------------------------- uhmm, happy 2011. Xah ? http://xahlee.org/ ? From python at mrabarnett.plus.com Tue Jan 4 13:26:48 2011 From: python at mrabarnett.plus.com (MRAB) Date: Tue, 04 Jan 2011 18:26:48 +0000 Subject: Regular Expression for Finding and Deleting comments In-Reply-To: References: Message-ID: <4D236668.6070200@mrabarnett.plus.com> On 04/01/2011 17:11, Jeremy wrote: > I am trying to write a regular expression that finds and deletes (replaces with nothing) comments in a string/file. Comments are defined by the first non-whitespace character is a 'c' or a dollar sign somewhere in the line. I want to replace these comments with nothing which isn't too hard. The trouble is, the comments are replaced with a new-line; or the new-line isn't captured in the regular expression. > > Below, I have copied a minimal example. Can someone help? > > Thanks, > Jeremy > > > import re > > text = """ c > C - Second full line comment (first comment had no text) > c Third full line comment > F44:N 2 $ Inline comments start with dollar sign and go to end of line""" > > commentPattern = re.compile(""" > (^\s*?c\s*?.*?| # Comment start with c or C > \$.*?)$\n # Comment starting with $ > """, re.VERBOSE|re.MULTILINE|re.IGNORECASE) > Part of the problem is that you're not using raw string literals or doubling the backslashes. Try soemthing like this: commentPattern = re.compile(r""" (^[ \t]*c.*\n| # Comment start with c or C [ \t]*\$.*) # Comment starting with $ """, re.VERBOSE|re.MULTILINE|re.IGNORECASE) > found = commentPattern.finditer(text) > > print("\n\nCard:\n--------------\n%s\n------------------" %text) > > if found: > print("\nI found the following:") > for f in found: print(f.groups()) > > else: > print("\nNot Found") > > print("\n\nComments replaced with ''") > replaced = commentPattern.sub('', text) > print("--------------\n%s\n------------------" %replaced) > From python at mrabarnett.plus.com Tue Jan 4 13:29:53 2011 From: python at mrabarnett.plus.com (MRAB) Date: Tue, 04 Jan 2011 18:29:53 +0000 Subject: list 2 dict? In-Reply-To: <7xipy5b5c5.fsf@ruckus.brouhaha.com> References: <7xipy5b5c5.fsf@ruckus.brouhaha.com> Message-ID: <4D236721.5010500@mrabarnett.plus.com> On 04/01/2011 05:33, Paul Rubin wrote: > "Octavian Rasnita" writes: >> If I want to create a dictionary from a list... >> l = [1, 2, 3, 4, 5, 6, 7, 'a', 8, 'b'] > > dict(l[i:i+2] for i in xrange(0,len(l),2)) > > seems simplest to me. Or: dict(zip(l[0 : : 2], l[1 : : 2])) From jlconlin at gmail.com Tue Jan 4 14:37:02 2011 From: jlconlin at gmail.com (Jeremy) Date: Tue, 4 Jan 2011 11:37:02 -0800 (PST) Subject: Regular Expression for Finding and Deleting comments In-Reply-To: Message-ID: On Tuesday, January 4, 2011 11:26:48 AM UTC-7, MRAB wrote: > On 04/01/2011 17:11, Jeremy wrote: > > I am trying to write a regular expression that finds and deletes (replaces with nothing) comments in a string/file. Comments are defined by the first non-whitespace character is a 'c' or a dollar sign somewhere in the line. I want to replace these comments with nothing which isn't too hard. The trouble is, the comments are replaced with a new-line; or the new-line isn't captured in the regular expression. > > > > Below, I have copied a minimal example. Can someone help? > > > > Thanks, > > Jeremy > > > > > > import re > > > > text = """ c > > C - Second full line comment (first comment had no text) > > c Third full line comment > > F44:N 2 $ Inline comments start with dollar sign and go to end of line""" > > > > commentPattern = re.compile(""" > > (^\s*?c\s*?.*?| # Comment start with c or C > > \$.*?)$\n # Comment starting with $ > > """, re.VERBOSE|re.MULTILINE|re.IGNORECASE) > > > Part of the problem is that you're not using raw string literals or > doubling the backslashes. > > Try soemthing like this: > > commentPattern = re.compile(r""" > (^[ \t]*c.*\n| # Comment start with c or C > [ \t]*\$.*) # Comment starting with $ > """, re.VERBOSE|re.MULTILINE|re.IGNORECASE) Using a raw string literal fixed the problem for me. Thanks for the suggestion. Why is that so important? Jeremy From jlconlin at gmail.com Tue Jan 4 14:37:02 2011 From: jlconlin at gmail.com (Jeremy) Date: Tue, 4 Jan 2011 11:37:02 -0800 (PST) Subject: Regular Expression for Finding and Deleting comments In-Reply-To: Message-ID: On Tuesday, January 4, 2011 11:26:48 AM UTC-7, MRAB wrote: > On 04/01/2011 17:11, Jeremy wrote: > > I am trying to write a regular expression that finds and deletes (replaces with nothing) comments in a string/file. Comments are defined by the first non-whitespace character is a 'c' or a dollar sign somewhere in the line. I want to replace these comments with nothing which isn't too hard. The trouble is, the comments are replaced with a new-line; or the new-line isn't captured in the regular expression. > > > > Below, I have copied a minimal example. Can someone help? > > > > Thanks, > > Jeremy > > > > > > import re > > > > text = """ c > > C - Second full line comment (first comment had no text) > > c Third full line comment > > F44:N 2 $ Inline comments start with dollar sign and go to end of line""" > > > > commentPattern = re.compile(""" > > (^\s*?c\s*?.*?| # Comment start with c or C > > \$.*?)$\n # Comment starting with $ > > """, re.VERBOSE|re.MULTILINE|re.IGNORECASE) > > > Part of the problem is that you're not using raw string literals or > doubling the backslashes. > > Try soemthing like this: > > commentPattern = re.compile(r""" > (^[ \t]*c.*\n| # Comment start with c or C > [ \t]*\$.*) # Comment starting with $ > """, re.VERBOSE|re.MULTILINE|re.IGNORECASE) Using a raw string literal fixed the problem for me. Thanks for the suggestion. Why is that so important? Jeremy From python at mrabarnett.plus.com Tue Jan 4 14:54:34 2011 From: python at mrabarnett.plus.com (MRAB) Date: Tue, 04 Jan 2011 19:54:34 +0000 Subject: Regular Expression for Finding and Deleting comments In-Reply-To: References: Message-ID: <4D237AFA.2030008@mrabarnett.plus.com> On 04/01/2011 19:37, Jeremy wrote: > On Tuesday, January 4, 2011 11:26:48 AM UTC-7, MRAB wrote: >> On 04/01/2011 17:11, Jeremy wrote: >>> I am trying to write a regular expression that finds and deletes (replaces with nothing) comments in a string/file. Comments are defined by the first non-whitespace character is a 'c' or a dollar sign somewhere in the line. I want to replace these comments with nothing which isn't too hard. The trouble is, the comments are replaced with a new-line; or the new-line isn't captured in the regular expression. >>> >>> Below, I have copied a minimal example. Can someone help? >>> >>> Thanks, >>> Jeremy >>> >>> >>> import re >>> >>> text = """ c >>> C - Second full line comment (first comment had no text) >>> c Third full line comment >>> F44:N 2 $ Inline comments start with dollar sign and go to end of line""" >>> >>> commentPattern = re.compile(""" >>> (^\s*?c\s*?.*?| # Comment start with c or C >>> \$.*?)$\n # Comment starting with $ >>> """, re.VERBOSE|re.MULTILINE|re.IGNORECASE) >>> >> Part of the problem is that you're not using raw string literals or >> doubling the backslashes. >> >> Try soemthing like this: >> >> commentPattern = re.compile(r""" >> (^[ \t]*c.*\n| # Comment start with c or C >> [ \t]*\$.*) # Comment starting with $ >> """, re.VERBOSE|re.MULTILINE|re.IGNORECASE) > > Using a raw string literal fixed the problem for me. Thanks for the suggestion. Why is that so important? > Regexes often use escape sequences, but so do string literals, and a sequence which is intended for the regex engine might not get passed along correctly. For example, in a normal string literal \b means 'backspace' and will be passed to the regex engine as that; in a regex it usually means 'word boundary': A regex for "the" as a word: \bthe\b As a raw string literal: r"\bthe\b" As a normal string literal: "\\bthe\\b" "\bthe\b" means: backspace + "the" + backspace From morfeokmg at gmail.com Tue Jan 4 14:57:59 2011 From: morfeokmg at gmail.com (Mauricio Martinez Garcia) Date: Tue, 04 Jan 2011 13:57:59 -0600 Subject: Error python + cx_Oracle :Oracle-Error-Message: ORA-01036: illegal variable name/number Message-ID: <4D237BC7.9010101@gmail.com> Hi, i need help with the next error: "ERR_PYTHON:Oracle-Error-Message: ORA-01036: illegal variable name/number", i used the cx_Oracle module, and the error not is only Oracle Error. The error its for that python don't translate the query, with the variables ":VARIABLE" when the VARIABLE is a number, this is th ecause of Oracle error. The template is: updateQUERYBSCS var. The code : ============================================================================================== class HilosPrepago(object): def __init__(self,numhilos,listadoSegmentos,archivoLOG,arregloSalida): global NHilos global LSegmnts global ALog global listadoSalida global path_sal global queue global loggingRegister global updateQUERYBSCS queue = Queue() listadoSalida = arregloSalida ALog = archivoLOG LSegmnts = listadoSegmentos NHilos = numhilos loggingRegister = log_register(ALog) updateQUERYBSCS = """UPDATE CONCIL_ICC SET CONTRATO_ICC = :CONTRATO_ICC, CONTRATO_ATS = :CONTRATO_BSCS, PLAN_ICC = :PLAN_ICC, PLAN_ATS = :PLAN_BSCS, IVA_ICC = :IVA_ICC, IVA_ATS = :IVA_BSCS, IVA_MAPEO = :IVA_MAPEO, PROFILE_ICC = :PROFILE_ICC, PROFILE_ATS = :PROFILE_BSCS, LEG_SOG_ICC = :LEG_SOG_ICC, LEG_SOG_ATS = :LEG_SOG_BSCS, LIC_SOG_ICC = :LIC_SOG_ICC, LIC_SOG_ATS = :LIC_SOG_BSCS, LEGLIG_SOG_ICC = :LEGLIC_SOG_ICC, LEGLIG_SOG_ATS = :LEGLIC_SOG_BSCS, LICN_SOG_ICC = :LICN_SOG_ICC, LICN_SOG_ATS = :LICN_SOG_BSCS, LDN_SOG_ICC = :LDN_SOG_ICC, LDN_SOG_ATS = :LDN_SOG_BSCS, REFILL_SOG_ICC = :REFILL_SOG_ICC, REFILL_SOG_ATS = :REFILL_SOG_BSCS, REFILL_PROM_ICC = :REFILL_PROM_ICC, REFILL_PROM_ATS = :REFILL_PROM_BSCS, DIA_RECARGA_ICC = :DIA_RECARGA_ICC, DIA_RECARGA_PROM_ICC = :DIA_RECARGA_PROM_ICC, DIA_RECARGA_ATS = :DIA_RECARGA_BSCS, CEL_IMSI_ICC = :CEL_IMSI_ICC, CEL_IMSI_ATS = :CEL_IMSI_BSCS, STATUS_ICC = :STATUS_ICC, STATUS_ATS = :STATUS_BSCS, ERROR_CONTRATO = to_number(:ERROR_CONTRATO), ERROR_PLAN = to_number(:ERROR_PLAN), ERROR_IVA_BSCS = to_number(:ERROR_IVA_BSCS), ERROR_IVA_ICC = to_number(:ERROR_IVA_ICC), ERROR_PROFILE = to_number(:ERROR_PROFILE), ERROR_LEGSOG = to_number(:ERROR_LEGSOG), ERROR_LICSOG = to_number(:ERROR_LICSOG), ERROR_LEGLICSOG = to_number(:ERROR_LEGLICSOG), ERROR_LICNSOG = to_number(:ERROR_LICNSOG), ERROR_LDNSOG = to_number(:ERROR_LDNSOG), ERROR_REFILLSOG = to_number(:ERROR_REFILLSOG), ERROR_REFILLPROMOCION = to_number(:ERROR_REFILLPROMOCION), ERROR_DIA_RECARGA = to_number(:ERROR_DIA_RECARGA), ERROR_DIA_RECARGAPROM = to_number(:ERROR_DIA_RECARGAPROM), ERROR_IMSI = to_number(:ERROR_IMSI), ERROR_STATUS = to_number(:ERROR_STATUS), ERROR_ENALTA = to_number(:ERROR_ENALTA), ERROR_ENELIMINACION = to_number(:ERROR_ENELIMINACION), PLANACTUALPROMO = :PLANACTUALPROMO, LLEVAPROMOCION = :LLEVAPROMOCION, DUPLICIDAD_DN = to_number(:DUPLICIDAD_DN), VALIDADO_PRODUCCION = :VALIDADO_PRODUCCION, CORREGIDO_EN_ALU = :CORREGIDO_EN_ALU, MENSAJE_CORRECCION = :MENSAJE_CORRECCION WHERE TELEFONO_ATS = :TELEFONO_BSCS """ #threading.Thread.__init__(self) def ejecutaHilo(self,lista,listaRegistrosOUT,archLog,hilo): from OracleConnections import OracleConnections print "Iniciando la ejecucion para el hilo... %s" % hilo listaUnica = lista.get() loggingRegister.registrarLog('Lista de datos...'+str(listaUnica)) FullNameLOG = str(archLog)+'_'+str(hilo)+'_' validador = conciliador(FullNameLOG) i = 1 j = 1 k = 1 ListadoDeregistros=[] conexiondeUpdateenReportes = OracleConnections(FullNameLOG) abreUpdateReportesIX = conexiondeUpdateenReportes.creaConexion('usuario','password','basededatos') try: for registro in listaUnica: pdb.set_trace() #registrosDelCampo = {} #registrosDelCampo = {'TELEFONO_ICC':'','TELEFONO_BSCS':'','CONTRATO_ICC':'','CONTRATO_BSCS':'','PLAN_ICC':'','PLAN_BSCS':'','IVA_ICC':'','IVA_BSCS':'','IVA_MAPEO':'','PROFILE_ICC':'','PROFILE_BSCS':'','LEG_SOG_ICC':'','LEG_SOG_BSCS':'','LIC_SOG_ICC':'','LIC_SOG_BSCS':'','LEGLIC_SOG_ICC':'','LEGLIC_SOG_BSCS':'','LICN_SOG_ICC':'','LICN_SOG_BSCS':'','LDN_SOG_ICC':'','LDN_SOG_BSCS':'','REFILL_SOG_ICC':'','REFILL_SOG_BSCS':'','REFILL_PROM_ICC':'','REFILL_PROM_BSCS':'','DIA_RECARGA_ICC':'','DIA_RECARGA_PROM_ICC':'','DIA_RECARGA_BSCS':'','CEL_IMSI_ICC':'','CEL_IMSI_BSCS':'','STATUS_ICC':'','STATUS_BSCS':'','ERROR_CONTRATO':0,'ERROR_PLAN':0,'ERROR_IVA_BSCS':0,'ERROR_IVA_ICC':0,'ERROR_PROFILE':0,'ERROR_LEGSOG':0,'ERROR_LICSOG':0,'ERROR_LEGLICSOG':0,'ERROR_LICNSOG':0,'ERROR_LDNSOG':0,'ERROR_REFILLSOG':0,'ERROR_REFILLPROMOCION':0,'ERROR_DIA_RECARGA':0,'ERROR_DIA_RECARGAPROM':0,'ERROR_IMSI':0,'ERROR_STATUS':0,'ERROR_ENALTA':0,'ERROR_ENELIMINACION':0,'PLANACTUALPROMO':0,'LLEVAPROMOCION':0,'DUPLICIDAD_DN':0,'VALIDADO_PRODUCCION':0,'CORREGIDO_EN_ALU':0,'MENSAJE_CORRECCION':0} ejecutor = validador.conciliacionGlobal(registro.telefono) registrosDelCampo = { 'TELEFONO_ICC':str(ejecutor.ALU_DN), 'TELEFONO_BSCS':str(ejecutor.BSCS_DN), 'CONTRATO_ICC':str(ejecutor.ALU_CO_ID), 'CONTRATO_BSCS':str(ejecutor.BSCS_CO_ID), 'PLAN_ICC':str(ejecutor.ALU_ICCCODE), 'PLAN_BSCS':str(ejecutor.BSCS_ICCCODE), 'IVA_ICC':str(ejecutor.ALU_IVA), #Para cambiar por solo el IVA 'IVA_BSCS':str(ejecutor.BSCS_IVA), 'IVA_MAPEO':str(ejecutor.BSCS_IVA_MAPEO), #Para cambiar solo por el IVA 'PROFILE_ICC':str(ejecutor.ALU_PROFILE), 'PROFILE_BSCS':str(ejecutor.BSCS_PROFILE), 'LEG_SOG_ICC':str(ejecutor.ALU_LEGSOG), 'LEG_SOG_BSCS':str(ejecutor.BSCS_LEGSOG), 'LIC_SOG_ICC':str(ejecutor.ALU_LICSOG), 'LIC_SOG_BSCS':str(ejecutor.BSCS_LICSOG), 'LEGLIC_SOG_ICC':str(ejecutor.ALU_LEGLICSOG), 'LEGLIC_SOG_BSCS':str(ejecutor.BSCS_LEGLICSOG), 'LICN_SOG_ICC':str(ejecutor.ALU_LICNSOG), 'LICN_SOG_BSCS':str(ejecutor.BSCS_LICNSOG), 'LDN_SOG_ICC':str(ejecutor.ALU_LDNSOG), 'LDN_SOG_BSCS':str(ejecutor.BSCS_LDNSOG), 'REFILL_SOG_ICC':str(ejecutor.ALU_REFILLSOG), 'REFILL_SOG_BSCS':str(ejecutor.BSCS_REFILLSOG), 'REFILL_PROM_ICC':str(ejecutor.ALU_REFILLPROMOCION), 'REFILL_PROM_BSCS':str(ejecutor.BSCS_REFILLPROMOCION), 'DIA_RECARGA_ICC':str(ejecutor.ALU_DIA_RECARGA), 'DIA_RECARGA_PROM_ICC':str(ejecutor.ALU_DIA_RECARGAPROM), 'DIA_RECARGA_BSCS':str(ejecutor.BSCS_DIA_RECARGA), 'CEL_IMSI_ICC':str(ejecutor.ALU_IMSI), 'CEL_IMSI_BSCS':str(ejecutor.BSCS_IMSI), 'STATUS_ICC':str(ejecutor.ALU_CH_STATUS), 'STATUS_BSCS':str(ejecutor.BSCS_CH_STATUS), 'ERROR_CONTRATO':str(ejecutor.error_coid), 'ERROR_PLAN':str(ejecutor.error_plan), 'ERROR_IVA_BSCS':str(ejecutor.error_iva_bscs), 'ERROR_IVA_ICC':str(ejecutor.error_iva_icc), 'ERROR_PROFILE':str(ejecutor.error_profile), 'ERROR_LEGSOG':str(ejecutor.error_legsog), 'ERROR_LICSOG':str(ejecutor.error_licsog), 'ERROR_LEGLICSOG':str(ejecutor.error_leglicsog), 'ERROR_LICNSOG':str(ejecutor.error_licnsog), 'ERROR_LDNSOG':str(ejecutor.error_ldnsog), 'ERROR_REFILLSOG':str(ejecutor.error_refillsog), 'ERROR_REFILLPROMOCION':str(ejecutor.error_refillpromocion), 'ERROR_DIA_RECARGA':str(ejecutor.error_diarecarga), 'ERROR_DIA_RECARGAPROM':str(ejecutor.error_diarecargaprom), 'ERROR_IMSI':str(ejecutor.error_imsi), 'ERROR_STATUS':str(ejecutor.error_status), 'ERROR_ENALTA':str(ejecutor.error_enAlta), 'ERROR_ENELIMINACION':str(ejecutor.error_enEliminacion), 'PLANACTUALPROMO':ejecutor.PLANACTUALPROMO, 'LLEVAPROMOCION':ejecutor.LLEVAPROMOCION, 'DUPLICIDAD_DN':'1', 'VALIDADO_PRODUCCION':'Si', 'CORREGIDO_EN_ALU':'No', 'MENSAJE_CORRECCION':'' } ListadoDeregistros.append(registrosDelCampo) #print registrosDelCampo #========================================================================================================= #Aqui se realizara una prevalidacion antes de mandar las correcciones #========================================================================================================= #========================================================================================================= #Terminan las correcciones #========================================================================================================= #pdb.set_trace() registroxLinea =str(ejecutor.BSCS_TMCODE)+','+str(ejecutor.BSCS_DN)+','+str(ejecutor.ALU_DN)+','+str(ejecutor.BSCS_CO_ID)+','+str(ejecutor.ALU_CO_ID)+','+str(ejecutor.BSCS_DIA_RECARGA)+','+str(ejecutor.ALU_DIA_RECARGA)+','+str(ejecutor.BSCS_CH_STATUS)+','+str(ejecutor.ALU_CH_STATUS)+','+str(ejecutor.BSCS_IMSI)+','+str(ejecutor.ALU_IMSI)+','+str(ejecutor.BSCS_DESCPLAN)+','+str(ejecutor.BSCS_SNCODELEG)+','+str(ejecutor.BSCS_SNCODELIC)+','+str(ejecutor.BSCS_SNCODELEGLIC)+','+str(ejecutor.BSCS_SNCODELICN)+','+str(ejecutor.BSCS_SNCODELDN)+','+str(ejecutor.BSCS_SNCODEREFILL)+','+str(ejecutor.BSCS_ICCCODE)+','+str(ejecutor.ALU_ICCCODE)+','+str(ejecutor.BSCS_PROFILE)+','+str(ejecutor.ALU_PROFILE)+','+str(ejecutor.BSCS_LEGSOG)+','+str(ejecutor.ALU_LEGSOG)+','+str(ejecutor.BSCS_LICSOG)+','+str(ejecutor.ALU_LICSOG)+','+str(ejecutor.BSCS_LEGLICSOG)+','+str(ejecutor.ALU_LEGLICSOG)+','+str(ejecutor.BSCS_LICNSOG)+','+str(ejecutor.ALU_LICNSOG)+','+str(ejecutor.BSCS_LDNSOG)+','+str(ejecutor.ALU_LDNSOG)+','+str(ejecutor.BSCS_REFILLSOG)+','+str(ejecutor.ALU_REFILLSOG)+','+str(ejecutor.error_coid)+','+str(ejecutor.error_diarecarga)+','+str(ejecutor.error_status)+','+str(ejecutor.error_imsi)+','+str(ejecutor.error_plan)+','+str(ejecutor.error_profile)+','+str(ejecutor.error_legsog)+','+str(ejecutor.error_licsog)+','+str(ejecutor.error_leglicsog)+','+str(ejecutor.error_licnsog)+','+str(ejecutor.error_ldnsog)+','+str(ejecutor.error_refillsog)+','+str(ejecutor.error_sncodesBSCS)+','+str(ejecutor.escenarioCorreccion)+'\n' loggingRegister.registrarLog('Linea de conciliacion...'+str(registroxLinea)+str(hilo)) #listaRegistrosOUT.append(ejecutor) print 'Registro %s, Telefono: %s, el registro validado corresponde al Hilo: %s ' %(str(k),registro.telefono,str(hilo)) k = k+1 i = i+1 if (i == 1000): loggingRegister.registrarLog('Abrimos conexion para ejecutar actualizacion en ReportesIX...'+str(hilo)) RS_UPDATE = conexiondeUpdateenReportes.ejecutaUpdate(updateQUERYBSCS, ListadoDeregistros, abreUpdateReportesIX) listadoSalida['Hilo_'+str(hilo)]=int(listadoSalida['Hilo_'+str(hilo)])+int(RS_UPDATE) ListadoDeregistros=[] i = 1 loggingRegister.registrarLog('Abrimos conexion para ejecutar actualizacion en ReportesIX final...'+str(hilo)) RS_UPDATE = conexiondeUpdateenReportes.ejecutaUpdate(updateQUERYBSCS, ListadoDeregistros, abreUpdateReportesIX) listadoSalida['Hilo_'+str(hilo)]=int(listadoSalida['Hilo_'+str(hilo)])+int(RS_UPDATE) conexiondeUpdateenReportes.cierraConexion(abreUpdateReportesIX) lista.task_done() except Exception, err: print "Error en la ejecucion: %s " % err lista.task_done() ============================================================================================== This is my debug output: ============================================================================================== ============================================================================================== -bash-3.2$ ./conciliaAltas_Cambios.py sliceDNUnique(telefono='522281926890') sliceDNUnique(telefono='523141209462') 2 Se genero tupla con los registros del 0 al 0. -- Se genero tupla con los registros del 0 al 0. -- Se genero tupla con los registros del 0 al 0. -- Se genero tupla con los registros del 0 al 0. -- Se genero tupla con los registros del 0 al 0. -- Se genero tupla con los registros del 0 al 0. -- Total de hilos a ejecutar: 1 Datos por hilo: ----- 2 ---- ================================================ Iniciando el proceso de ejecucion por hilos ================================================ Iniciando la ejecucion por hilos... Iniciando la ejecucion para el hilo... 0 > /data/NEW_ALUCLIENT_PRUEBAS/bin/prepagoThreads.py(116)ejecutaHilo() -> ejecutor = validador.conciliacionGlobal(registro.telefono) (Pdb) c ==================================================================================== Registro 1, Telefono: 522281926890, el registro validado corresponde al Hilo: 0 > /data/NEW_ALUCLIENT_PRUEBAS/bin/prepagoThreads.py(116)ejecutaHilo() -> ejecutor = validador.conciliacionGlobal(registro.telefono) (Pdb) c ==================================================================================== Registro 2, Telefono: 523141209462, el registro validado corresponde al Hilo: 0 > /data/NEW_ALUCLIENT_PRUEBAS/bin/OracleConnections.py(350)ejecutaUpdate() -> cursor = conn.cursor() (Pdb) n > /data/NEW_ALUCLIENT_PRUEBAS/bin/OracleConnections.py(353)ejecutaUpdate() -> cursor.arraysize = 100000 (Pdb) > /data/NEW_ALUCLIENT_PRUEBAS/bin/OracleConnections.py(356)ejecutaUpdate() -> try: (Pdb) > /data/NEW_ALUCLIENT_PRUEBAS/bin/OracleConnections.py(357)ejecutaUpdate() -> cursor.executemany(query,registros) (Pdb) DatabaseError: > /data/NEW_ALUCLIENT_PRUEBAS/bin/OracleConnections.py(357)ejecutaUpdate() -> cursor.executemany(query,registros) (Pdb) n > /data/NEW_ALUCLIENT_PRUEBAS/bin/OracleConnections.py(361)ejecutaUpdate() -> except cx_Oracle.DatabaseError, exc: (Pdb) > /data/NEW_ALUCLIENT_PRUEBAS/bin/OracleConnections.py(362)ejecutaUpdate() -> error, = exc.args (Pdb) > /data/NEW_ALUCLIENT_PRUEBAS/bin/OracleConnections.py(363)ejecutaUpdate() -> print >> sys.stderr, XP_ERROR+"Oracle-Error-Code:", error.code (Pdb) ERR_PYTHON:Oracle-Error-Code: 1036 > /data/NEW_ALUCLIENT_PRUEBAS/bin/OracleConnections.py(364)ejecutaUpdate() -> print >> sys.stderr, XP_ERROR+"Oracle-Error-Message:", error.message (Pdb) ERR_PYTHON:Oracle-Error-Message: ORA-01036: illegal variable name/number > /data/NEW_ALUCLIENT_PRUEBAS/bin/OracleConnections.py(365)ejecutaUpdate() -> print query (Pdb) n UPDATE CONCIL_ICC SET CONTRATO_ICC = :CONTRATO_ICC, CONTRATO_ATS = :CONTRATO_BSCS, PLAN_ICC = :PLAN_ICC, PLAN_ATS = :PLAN_BSCS, IVA_ICC = :IVA_ICC, IVA_ATS = :IVA_BSCS, IVA_MAPEO = :IVA_MAPEO, PROFILE_ICC = :PROFILE_ICC, PROFILE_ATS = :PROFILE_BSCS, LEG_SOG_ICC = :LEG_SOG_ICC, LEG_SOG_ATS = :LEG_SOG_BSCS, LIC_SOG_ICC = :LIC_SOG_ICC, LIC_SOG_ATS = :LIC_SOG_BSCS, LEGLIG_SOG_ICC = :LEGLIC_SOG_ICC, LEGLIG_SOG_ATS = :LEGLIC_SOG_BSCS, LICN_SOG_ICC = :LICN_SOG_ICC, LICN_SOG_ATS = :LICN_SOG_BSCS, LDN_SOG_ICC = :LDN_SOG_ICC, LDN_SOG_ATS = :LDN_SOG_BSCS, REFILL_SOG_ICC = :REFILL_SOG_ICC, REFILL_SOG_ATS = :REFILL_SOG_BSCS, REFILL_PROM_ICC = :REFILL_PROM_ICC, REFILL_PROM_ATS = :REFILL_PROM_BSCS, DIA_RECARGA_ICC = :DIA_RECARGA_ICC, DIA_RECARGA_PROM_ICC = :DIA_RECARGA_PROM_ICC, DIA_RECARGA_ATS = :DIA_RECARGA_BSCS, CEL_IMSI_ICC = :CEL_IMSI_ICC, CEL_IMSI_ATS = :CEL_IMSI_BSCS, STATUS_ICC = :STATUS_ICC, STATUS_ATS = :STATUS_BSCS, ERROR_CONTRATO = to_number(:ERROR_CONTRATO), ERROR_PLAN = to_number(:ERROR_PLAN), ERROR_IVA_BSCS = to_number(:ERROR_IVA_BSCS), ERROR_IVA_ICC = to_number(:ERROR_IVA_ICC), ERROR_PROFILE = to_number(:ERROR_PROFILE), ERROR_LEGSOG = to_number(:ERROR_LEGSOG), ERROR_LICSOG = to_number(:ERROR_LICSOG), ERROR_LEGLICSOG = to_number(:ERROR_LEGLICSOG), ERROR_LICNSOG = to_number(:ERROR_LICNSOG), ERROR_LDNSOG = to_number(:ERROR_LDNSOG), ERROR_REFILLSOG = to_number(:ERROR_REFILLSOG), ERROR_REFILLPROMOCION = to_number(:ERROR_REFILLPROMOCION), ERROR_DIA_RECARGA = to_number(:ERROR_DIA_RECARGA), ERROR_DIA_RECARGAPROM = to_number(:ERROR_DIA_RECARGAPROM), ERROR_IMSI = to_number(:ERROR_IMSI), ERROR_STATUS = to_number(:ERROR_STATUS), ERROR_ENALTA = to_number(:ERROR_ENALTA), ERROR_ENELIMINACION = to_number(:ERROR_ENELIMINACION), PLANACTUALPROMO = :PLANACTUALPROMO, LLEVAPROMOCION = :LLEVAPROMOCION, DUPLICIDAD_DN = to_number(:DUPLICIDAD_DN), VALIDADO_PRODUCCION = :VALIDADO_PRODUCCION, CORREGIDO_EN_ALU = :CORREGIDO_EN_ALU, MENSAJE_CORRECCION = :MENSAJE_CORRECCION WHERE TELEFONO_ATS = :TELEFONO_BSCS > /data/NEW_ALUCLIENT_PRUEBAS/bin/OracleConnections.py(366)ejecutaUpdate() -> sys.exit(1) (Pdb) q Error en la ejecucion: Finalizando el proceso .... ============================================================================================== ============================================================================================== From calderone.jeanpaul at gmail.com Tue Jan 4 15:01:52 2011 From: calderone.jeanpaul at gmail.com (Jean-Paul Calderone) Date: Tue, 4 Jan 2011 12:01:52 -0800 (PST) Subject: Interrput a thread References: <81c24eb1-41b6-442a-a971-8a44d2cd6c1b@p8g2000vbs.googlegroups.com> <2ebc11a5-1b45-4faa-97b9-c84f0db015a4@k22g2000yqh.googlegroups.com> Message-ID: <846091cf-db63-422d-adda-2b8a46a4f270@t35g2000yqj.googlegroups.com> On Jan 4, 12:31?pm, Fuzzyman wrote: > On Jan 4, 3:31?pm, Roy Smith wrote: > > > > > In article > > <2ebc11a5-1b45-4faa-97b9-c84f0db01... at k22g2000yqh.googlegroups.com>, > > > ?Fuzzyman wrote: > > > It is unsafe to terminate an os level thread at an arbitrary point > > > because it may be executing code in a critical section. > > > [...] > > > The standard advice is to use a flag and do manual checking to abort > > > threads. This only works for fine grained operations and *doesn't* > > > work for very coarse grained operations or where there aren't > > > convenient places to check the flag. > > > Another possibility is to not use threads! ?If you > > > 1) Need asynchronous operation > > > 2) Need iterruptability > > > 3) Can't poll for an "please stop" signal > > > You should look at running your "thread" as a separate process, which > > you can send a kill signal to when you want it to go away. ?You can then > > communicate with it via pipes, sockets, shared memory segments, whatever. > > > Threads are a wonderful invention, but they are not a panacea for all > > possible parallelism tasks. ?Sometimes they're just the wrong tool. > > However some tasks / algorithms are done much better with threads than > processes. > > Asynchronous operations are good for IO bound concurrency but not for > CPU bound concurrency. > > Asynchronous and threads aren't mutually exclusive. An asynchronous multithreading or multiprocessing library is perfectly well suited for CPU bound concurrency. > > Michael Foord > --http://www.voidspace.org.uk/ From goposter at jonjay.com Tue Jan 4 15:20:42 2011 From: goposter at jonjay.com (Google Poster) Date: Tue, 4 Jan 2011 12:20:42 -0800 (PST) Subject: Trying to decide between PHP and Python Message-ID: About once a year, I have to learn yet another programming language. Given all the recommendations (an outstanding accolade from Bruce Eckel, author of "Thinking in Java") I have set my aim to Python. Sounds kinda cool. The indentation-as-block is unique, but that is how I always indent, anyway. Can any of you nice folks post a snippet of how to perform a listing of the current directory and save it in a string? Something like this: $ setenv FILES = `ls` Bonus: Let's say that I want to convert the names of the files to lowercase? As 'tolower()' TIA, -Ramon From jearl at notengoamigos.org Tue Jan 4 15:24:35 2011 From: jearl at notengoamigos.org (Jason Earl) Date: Tue, 04 Jan 2011 13:24:35 -0700 Subject: opinion: comp lang docs style References: <98e82f1b-cf59-4e64-8fd4-63671f96b04f@r19g2000prm.googlegroups.com> Message-ID: <87vd24benw.fsf@notengoamigos.org> On Tue, Jan 04 2011, Xah Lee wrote: > a opinion piece. > > ?The Idiocy of Computer Language Docs? > http://xahlee.org/comp/idiocy_of_comp_lang.html > > -------------------------------------------------- > The Idiocy of Computer Language Docs > > Xah Lee, 2011-01-03 > > Worked with Mathematica for a whole day yesterday, after about 10 > years hiatus. Very nice. Mathematica lang and doc, is quite unique. > Most other langs drivel with jargons, pettiness, comp-sci > pretentiousness, while their content is mathematically garbage. > (unixism mumble jumple (perl, unix), or ?proper?-engineering OOP > fantasy (java), or impractical and ivory-tower adacemician idiocy as > in Scheme & Haskell ( currying, tail recursion, closure, call-cc, > lisp1 lisp2, and monad monad monad!)) (See: What are OOP's Jargons and > Complexities ? Language, Purity, Cult, and Deception.) > > Mathematica, in its doc, is plain and simple. None of the jargon and > pretention shit. Very easy to understand. Yet, some of its function's > technical aspects are far more scholarly abstruse than any other lang > (dealing with advanced math special functions that typically only a > few thousand people in the world understand.). > > ------------------------------ > A Gander into the Idiocies > > Here's a gander into the doc drivel in common langs. > > ------------------------------ > unix > > In unix man pages, it starts with this type of garbage: > > SYNOPSIS > gzip [ -acdfhlLnNrtvV19 ] [-S suffix] [ name ... ] > gunzip [ -acfhlLnNrtvV ] [-S suffix] [ name ... ] > zcat [ -fhLV ] [ name ... ] > > SYNOPSIS > zip [-aABcdDeEfFghjklLmoqrRSTuvVwXyz!@$] [-- > longoption ...] [-b path] [-n suf > fixes] [-t date] [-tt date] [zipfile [file ...]] [-xi > list] > > Here, the mindset of unix idiots, is that somehow this ?synopsis? form > is technically precise and superior. They are thinking that it > captures the full range of syntax in the most concise way. Actually, it *does* capture the full range of syntax in a concise way. If you know of man pages where the Synopsis does not match the syntax then you have found a documentation bug, which should be reported so that it can be fixed. In fact, if anything the real problem with the Synopsis is that it is too concise. Fortunately gzip is a bit of an extreme example. Most man pages look more like this: --8<---------------cut here---------------start------------->8--- NAME tar ? The GNU version of the tar archiving utility SYNOPSIS tar [-] A --catenate --concatenate | c --create | d --diff --compare | --delete | r --append | t --list | --test-label | u --update | x --extract --get [options] [pathname ...] --8<---------------cut here---------------end--------------->8--- That synopsis is pretty useful. If you have used tar before and just need a refresher chances are very good that the synopsis will do the trick. If you look at the man pages from the Linux Programmer's Manual the Synopsis makes even more sense. --8<---------------cut here---------------start------------->8--- NAME open, creat - open and possibly create a file or device SYNOPSIS #include #include #include int open(const char *pathname, int flags); int open(const char *pathname, int flags, mode_t mode); int creat(const char *pathname, mode_t mode); --8<---------------cut here---------------end--------------->8--- Heck, that's basically precisely what I want to know. > In practice, it's seldomly read. It's actually not accurate as one'd > thought; no program can parse it and agree with the actual behavior. > It's filled with errors, incomprehensible to human. I've been using UNIX man pages for quite some time, and I don't think that I have ever come across an error. I am sure that there are errors, but I am also sure that Mathematica's documentation has its share of errors as well. > Worse of all, the semantic of unix software's options are the worst > rape to any possible science in computer science. See: The Nature of > the Unix Philosophy ? Unix Pipe As Functional Language ? Unix zip > Utility Path Problem. It seems to me that the problem is not UNIX software in general, but rather that the zip function does not have an analogue of tar's -C option (which sets the current directory for the command). > ------------------------------ > Python > > In Python, you see this kinda garbage: > > 7.1. The if statement > > The if statement is used for conditional execution: > if_stmt ::= "if" expression ":" suite > ( "elif" expression ":" suite )* > ["else" ":" suite] > > (Source docs.python.org) > > Here, the mindset of the python idiots is similar to the unix tech > geekers. They think that using the BNF notation makes their doc more > clear and precise. The fact is, there are so many variations of BNF > each trying to fix other's problem. BNF is actually not used as a > computer language for syntax description. It's mostly used to > communicate syntax to humans. Like regex, there are so many > variations. But worse than regex in the sense that there are actually > not many actual implementations of BNF. Real word syntax description > language are usually nothing close to BNF. See: Pattern Matching vs > Lexical Grammar Specification. This example is taken from the Python Language Reference, which is really only useful if you are looking to re-implement Python (or create something that parses Python, I suppose). The particular flavor of BNF is explained in the Introduction. I am not sure what you expect from a Language Reference, but in the case of Python the Language Reference seems to have worked quite well. Very few languages have as many successful implementations as Python. The Language Reference is clearly a large part of that. > This incomprehensible BNF notation is the only thing you get if you > want to know the basic syntax of ?if?, ?for?, ?while?, ?lambda?, or > other basic constructs of python. If you want to *use* the language the Tutorial is probably what you want. Perhaps the most well-known statement type is the if statement. Here's what the Tutorial has to say about the if statement. --8<---------------cut here---------------start------------->8--- Perhaps the most well-known statement type is the if statement. For example: >>> x = int(raw_input("Please enter an integer: ")) Please enter an integer: 42 >>> if x < 0: ... x = 0 ... print 'Negative changed to zero' ... elif x == 0: ... print 'Zero' ... elif x == 1: ... print 'Single' ... else: ... print 'More' ... More There can be zero or more elif parts, and the else part is optional. The keyword ?elif? is short for ?else if?, and is useful to avoid excessive indentation. An if ... elif ... elif ... sequence is a substitute for the switch or case statements found in other languages. --8<---------------cut here---------------end--------------->8--- Once again, that looks pretty good to me. > ------------------------------ > Perl > > In perl, you see this type of drivel: > > A Perl program consists of a sequence of declarations and > statements which run from the top to the bottom. Loops, subroutines > and other control structures allow you to jump around within the code. > > Perl is a free-form language, you can format and indent it however > you like. Whitespace mostly serves to separate tokens, unlike > languages like Python where it is an important part of the syntax. > > Many of Perl's syntactic elements are optional. Rather than > requiring you to put parentheses around every function call and > declare every variable, you can often leave such explicit elements off > and Perl will figure out what you meant. This is known as Do What I > Mean, abbreviated DWIM. It allows programmers to be lazy and to code > in a style with which they are comfortable. > > Perl borrows syntax and concepts from many languages: awk, sed, C, > Bourne Shell, Smalltalk, Lisp and even English. Other languages have > borrowed syntax from Perl, particularly its regular expression > extensions. So if you have programmed in another language you will see > familiar pieces in Perl. They often work the same, but see perltrap > for information about how they differ. > > (Source perldoc.perl.org) > > Notice they introduced you to their lingo ?DWIM?. Juvenile humor is a > characteristics of perl's docs. It's a whole cult. They have ?perl > republic?, ?state of the onion?, ?apocalypse?, ?perl monger?, ?perl > golf?, etc.(See: Larry Wall and Cults.) Another trait is irrelevant > rambling. For example, in the above you see: ?Perl borrows syntax and > concepts from many languages: awk, sed, C, Bourne Shell, Smalltalk, > Lisp and even English.?. > > However, perl doc overall is more practically usable than Python's. You might not like Larry Wall's documentation style, but if that is the case then you are in the minority. IMHO Perl is an example of a language that prospered almost entirely on the strength of its documentation. The Camel book is one of the best selling computer language books of all time. Much of Perl's "culture" is just plain old marketing, but it is hard to argue that it has not been successful. > ------------------------------ > Haskell > > Here's a example of ivory-tower idiocy, from Haskellers: > > Haskell uses a traditional Hindley-Milner polymorphic type system > to provide a static type semantics [4, 6], but the type system has > been extended with type classes (or just classes) that provide a > structured way to introduce overloaded functions. > > A class declaration (Section 4.3.1) introduces a new type class > and the overloaded operations that must be supported by any type that > is an instance of that class. An instance declaration (Section 4.3.2) > declares that a type is an instance of a class and includes the > definitions of the overloaded operations?called class methods? > instantiated on the named type. > > For example, suppose we wish to overload the operations (+) and > negate on types Int and Float. We introduce a new type class called > Num: > > class Num a where -- simplified class declaration for > Num > (+) :: a -> a -> a -- (Num is defined in the Prelude) > negate :: a -> a > > This declaration may be read ?a type a is an instance of the class > Num if there are class methods (+) and negate, of the given types, > defined on it.? > > (Source www.haskell.org) > > Note the words ?Hindley-Milner?, ?polymorphic?, ?static type > semantics?, ?overloaded operations?. > > The reason they wrote their doc like that is because they are > academicians. You might think that their writing is really scholarly, > mathematically meaningful, almost provably correct, full of dense > mathematical rigor, and necessarily hard to understand because of the > advanced math ideas. By the look of it it is really daunting. The > irony is that the writing is often imprecise, most use of tech jargons > and terms are absolutely uncessarily to the point of being irrelevant. > And, the writing quality is pretty bad, far below the quality of > standard math journal's articles. I actually agree with you on this example. > uhmm, happy 2011. You too. Jason From goposter at jonjay.com Tue Jan 4 15:29:20 2011 From: goposter at jonjay.com (Google Poster) Date: Tue, 4 Jan 2011 12:29:20 -0800 (PST) Subject: opinion: comp lang docs style References: <98e82f1b-cf59-4e64-8fd4-63671f96b04f@r19g2000prm.googlegroups.com> Message-ID: <0edd77ae-2b3b-494b-8651-94b3f56a59e4@j32g2000prh.googlegroups.com> On Jan 4, 12:24?pm, Xah Lee wrote: > a opinion piece. > > ?The Idiocy of Computer Language Docs?http://xahlee.org/comp/idiocy_of_comp_lang.html > > -------------------------------------------------- > The Idiocy of Computer Language Docs > > Xah Lee, 2011-01-03 > > Worked with Mathematica for a whole day yesterday, after about 10 > years hiatus. Very nice. Mathematica lang and doc, is quite unique. > Most other langs drivel with jargons, pettiness, comp-sci > pretentiousness, while their content is mathematically garbage. > (unixism mumble jumple (perl, unix), or ?proper?-engineering OOP > fantasy (java), or impractical and ivory-tower adacemician idiocy as > in Scheme & Haskell ( currying, tail recursion, closure, call-cc, > lisp1 lisp2, and monad monad monad!)) (See: What are OOP's Jargons and > Complexities ? Language, Purity, Cult, and Deception.) > > Mathematica, in its doc, is plain and simple. None of the jargon and > pretention shit. Very easy to understand. Yet, some of its function's > technical aspects are far more scholarly abstruse than any other lang > (dealing with advanced math special functions that typically only a > few thousand people in the world understand.). > > ------------------------------ > A Gander into the Idiocies > > Here's a gander into the doc drivel in common langs. > > ------------------------------ > unix > > In unix man pages, it starts with this type of garbage: > > ? ? SYNOPSIS > ? ? ? ? ? ?gzip [ -acdfhlLnNrtvV19 ] [-S suffix] [ name ... ?] > ? ? ? ? ? ?gunzip [ -acfhlLnNrtvV ] [-S suffix] [ name ... ?] > ? ? ? ? ? ?zcat [ -fhLV ] [ name ... ?] > > ? ? SYNOPSIS > ? ? ? ? ? ?zip ?[-aABcdDeEfFghjklLmoqrRSTuvVwXyz!@$] ?[-- > longoption ?...] ? [-b path] [-n suf > ? ? ? ? ? ?fixes] [-t date] [-tt date] [zipfile [file ...]] ?[-xi > list] > > Here, the mindset of unix idiots, is that somehow this ?synopsis? form > is technically precise and superior. They are thinking that it > captures the full range of syntax in the most concise way. In > practice, it's seldomly read. It's actually not accurate as one'd > thought; no program can parse it and agree with the actual behavior. > It's filled with errors, incomprehensible to human. Worse of all, the > semantic of unix software's options are the worst rape to any possible > science in computer science. See: The Nature of the Unix Philosophy ? > Unix Pipe As Functional Language ? Unix zip Utility Path Problem. > > ------------------------------ > Python > > In Python, you see this kinda garbage: > > ? ? 7.1. The if statement > > ? ? The if statement is used for conditional execution: > ? ? if_stmt ::= ?"if" expression ":" suite > ? ? ? ? ? ? ? ? ?( "elif" expression ":" suite )* > ? ? ? ? ? ? ? ? ?["else" ":" suite] > > (Source docs.python.org) > > Here, the mindset of the python idiots is similar to the unix tech > geekers. They think that using the BNF notation makes their doc more > clear and precise. The fact is, there are so many variations of BNF > each trying to fix other's problem. BNF is actually not used as a > computer language for syntax description. It's mostly used to > communicate syntax to humans. Like regex, there are so many > variations. But worse than regex in the sense that there are actually > not many actual implementations of BNF. Real word syntax description > language are usually nothing close to BNF. See: Pattern Matching vs > Lexical Grammar Specification. > > This incomprehensible BNF notation is the only thing you get if you > want to know the basic syntax of ?if?, ?for?, ?while?, ?lambda?, or > other basic constructs of python. > > ------------------------------ > Perl > > In perl, you see this type of drivel: > > ? ? A Perl program consists of a sequence of declarations and > statements which run from the top to the bottom. Loops, subroutines > and other control structures allow you to jump around within the code. > > ? ? Perl is a free-form language, you can format and indent it however > you like. Whitespace mostly serves to separate tokens, unlike > languages like Python where it is an important part of the syntax. > > ? ? Many of Perl's syntactic elements are optional. Rather than > requiring you to put parentheses around every function call and > declare every variable, you can often leave such explicit elements off > and Perl will figure out what you meant. This is known as Do What I > Mean, abbreviated DWIM. It allows programmers to be lazy and to code > in a style with which they are comfortable. > > ? ? Perl borrows syntax and concepts from many languages: awk, sed, C, > Bourne Shell, Smalltalk, Lisp and even English. Other languages have > borrowed syntax from Perl, particularly its regular expression > extensions. So if you have programmed in another language you will see > familiar pieces in Perl. They often work the same, but see perltrap > for information about how they differ. > > (Source perldoc.perl.org) > > Notice they introduced you to their lingo ?DWIM?. Juvenile humor is a > characteristics of perl's docs. It's a whole cult. They have ?perl > republic?, ?state of the onion?, ?apocalypse?, ?perl monger?, ?perl > golf?, etc.(See: Larry Wall and Cults.) Another trait is irrelevant > rambling. For example, in the above you see: ?Perl borrows syntax and > concepts from many languages: awk, sed, C, Bourne Shell, Smalltalk, > Lisp and even English.?. > > However, perl doc overall is more practically usable than Python's. > > ------------------------------ > Haskell > > Here's a example of ivory-tower idiocy, from Haskellers: > > ? ? Haskell uses a traditional Hindley-Milner polymorphic type system > to provide a static type semantics [4, 6], but the type system has > been extended with type classes (or just classes) that provide a > structured way to introduce overloaded functions. > > ? ? A class declaration (Section 4.3.1) introduces a new type class > and the overloaded operations that must be supported by any type that > is an instance of that class. An instance declaration (Section 4.3.2) > declares that a type is an instance of a class and includes the > definitions of the overloaded operations?called class methods? > instantiated on the named type. > > ? ? For example, suppose we wish to overload the operations (+) and > negate on types Int and Float. We introduce a new type class called > Num: > > ? ? ? class Num a ?where ? ? ? ? ?-- simplified class declaration for > Num > ? ? ? ? (+) ? ?:: a -> a -> a ? ? -- (Num is defined in the Prelude) > ? ? ? ? negate :: a -> a > > ? ? This declaration may be read ?a type a is an instance of the class > Num if there are class methods (+) and negate, of the given types, > defined on it.? > > (Sourcewww.haskell.org) > > Note the words ?Hindley-Milner?, ?polymorphic?, ?static type > semantics?, ?overloaded operations?. > > The reason they wrote their doc like that is because they are > academicians. You might think that their writing is really scholarly, > mathematically meaningful, almost provably correct, full of dense > mathematical rigor, and necessarily hard to understand because of the > advanced math ideas. By the look of it it is really daunting. The > irony is that the writing is often imprecise, most use of tech jargons > and terms are absolutely uncessarily to the point of being irrelevant. > And, the writing quality is pretty bad, far below the quality of > standard math journal's articles. > > -------------------------------------------------- > > uhmm, happy 2011. > > ?Xah ?http://xahlee.org/? Fell free to rewrite the docs of those programming languages in iambic pentameter, adding harp octaves in the background. -Ramon From catdude at gmail.com Tue Jan 4 15:29:44 2011 From: catdude at gmail.com (Dan M) Date: Tue, 04 Jan 2011 14:29:44 -0600 Subject: Trying to decide between PHP and Python References: Message-ID: <_MmdnZ36uOSlHr7QnZ2dnUVZ5uGdnZ2d@giganews.com> On Tue, 04 Jan 2011 12:20:42 -0800, Google Poster wrote: > About once a year, I have to learn yet another programming language. > Given all the recommendations (an outstanding accolade from Bruce Eckel, > author of "Thinking in Java") I have set my aim to Python. Sounds kinda > cool. > > The indentation-as-block is unique, but that is how I always indent, > anyway. > > Can any of you nice folks post a snippet of how to perform a listing of > the current directory and save it in a string? > > Something like this: > > $ setenv FILES = `ls` > > Bonus: Let's say that I want to convert the names of the files to > lowercase? As 'tolower()' > > TIA, > > -Ramon 1) import os files = ' '.join(os.listdir('/home/dan')) 2) import os import string files = string.lower(' '.join(os.listdir('/home/dan'))) As to choice between Python and PHP, I would say learn anything but PHP. Even Perl has fewer tentacles than PHP. From goposter at jonjay.com Tue Jan 4 15:30:21 2011 From: goposter at jonjay.com (Google Poster) Date: Tue, 4 Jan 2011 12:30:21 -0800 (PST) Subject: Troll Alert (do not click) References: <1f0063d2-53fc-4167-921e-aab49ce9e09b@o11g2000prf.googlegroups.com> Message-ID: <21da0736-800c-4cfc-9106-ed9edab6059f@j32g2000prh.googlegroups.com> On Jan 4, 8:19?am, SHILPA wrote: > ? ? ? ? ? ?UNSEEN HOT SEXY PHOTOS > ?http://karomasti9.blogspot.com/2011/01/never.html > ? ? ? ? ? ? ? ? ? ? ? ? SEXY DIYA MIRZA > ? ?http://karomasti9.blogspot.com/2010/12/diya-mirza.html > ? ? ? ? ? ? ? ? ? ? ? ? HOT AISHWARIYA RAIhttp://karomasti9.blogspot.com/2010/12/aish.html > ? ? ? ? ? ? ? ? ? ? ?priyamani hot&sexy photoshttp://karomasti9.blogspot.com/2010/12/priyamani.html > ? ? ? ? ? ? ? ? ? ? ? KATRINA SEXY PHOTOShttp://karomasti9.blogspot.com/2010/12/katrina.html > ? ? ? ? ? ? ? ? ?ANUSHKA HOT PHOTOShttp://karomasti9.blogspot.com/2010/12/anuska.html > ? ? ? ? ? ? ? ? ? ? BEAUTIFUL AISHWARIYA RAIhttp://karomasti9.blogspot.com/2010/12/aiesh.html > ? ? ? ? ? ? ? ? ? ? TRISHA HOT PHOTOShttp://karomasti9.blogspot.com/2010/11/trisha-hot.html > ? ? ? ? ? ? ? AMISHAPATEL HOT VIDEOShttp://karomasti9.blogspot.com/search/label/amisha > ? ? ? ? ? ? ?HANSIKHA HOT SEXY PHOTOShttp://karomasti9.blogspot.com/search/label/HANSIKA > ? ? ? ? ? ? ?HOT SEXY COLLEGE GIRLShttp://karomasti9.blogspot.com/search/label/hot > ? ? ? ? ? ? ? BEAUTIFUL LARADATTAhttp://karomasti9.blogspot.com/search/label/laradatta > ? ? ? ? ? ? ? NIKISHA HOT BOOBShttp://karomasti9.blogspot.com/search/label/nikisha > ? ? ? ? ? ?PRIYANKA SPICY LATEST PICShttp://karomasti9.blogspot.com/search/label/priyanka > ? ? ? ? ? ? ? ONLY FOR YOUTHhttp://karomasti9.blogspot.com/search/label/spicy > ? ? ? ? ? ?SRILEKHA UNSEENED PHOTOShttp://karomasti9.blogspot.com/search/label/Srilekha > ? ? ? ? ? ? ?CHOPRA UNBELIVABLE PHOTOShttp://karomasti9.blogspot.com/search/label/chopra > ? ? ? ? ? ? ? HOT BIPASA BASU PHOTOShttp://karomasti9.blogspot.com/search/label/bipasa > ? ? ? ? ? ? ? TRISHA IN A SEXY FEELhttp://karomasti9.blogspot.com/search/label/thrisha > ? ? ? ? ? ?SRISHA HOT BOOBS SHOWhttp://karomasti9.blogspot.com/search/label/srisha > ? ? ? ? ? ?BEAUTIFUL POONAM PHOTOShttp://karomasti9.blogspot.com/search/label/poonam From goposter at jonjay.com Tue Jan 4 15:32:28 2011 From: goposter at jonjay.com (Google Poster) Date: Tue, 4 Jan 2011 12:32:28 -0800 (PST) Subject: Trying to decide between PHP and Python References: <_MmdnZ36uOSlHr7QnZ2dnUVZ5uGdnZ2d@giganews.com> Message-ID: On Jan 4, 2:29?pm, Dan M wrote: > On Tue, 04 Jan 2011 12:20:42 -0800, Google Poster wrote: > > About once a year, I have to learn yet another programming language. > > Given all the recommendations (an outstanding accolade from Bruce Eckel, > > author of "Thinking in Java") I have set my aim to Python. Sounds kinda > > cool. > > > The indentation-as-block is unique, but that is how I always indent, > > anyway. > > > Can any of you nice folks post a snippet of how to perform a listing of > > the current directory and save it in a string? > > > Something like this: > > > $ setenv FILES = `ls` > > > Bonus: Let's say that I want to convert the names of the files to > > lowercase? As 'tolower()' > > > TIA, > > > -Ramon > > 1) > import os > files = ' '.join(os.listdir('/home/dan')) > > 2) > import os > import string > files = string.lower(' '.join(os.listdir('/home/dan'))) > > As to choice between Python and PHP, I would say learn anything but PHP. > Even Perl has fewer tentacles than PHP. Not to mention that it took me 9 minutes to get a reply from you... Quite speedy community support. That is a very important parameter in my technology decisions these days. Thanks! -Ramon From catdude at gmail.com Tue Jan 4 15:34:17 2011 From: catdude at gmail.com (Dan M) Date: Tue, 04 Jan 2011 14:34:17 -0600 Subject: Trying to decide between PHP and Python References: <_MmdnZ36uOSlHr7QnZ2dnUVZ5uGdnZ2d@giganews.com> Message-ID: <_MmdnZz6uOTUGb7QnZ2dnUVZ5uGdnZ2d@giganews.com> On Tue, 04 Jan 2011 12:32:28 -0800, Google Poster wrote: > Not to mention that it took me 9 minutes to get a reply from you... > Quite speedy community support. > > That is a very important parameter in my technology decisions these > days. > > Thanks! > > -Ramon This Usenet group is a truly awesome resource. I'm a Python newbie myself, and the times I've posted here looking for direction I have been very pleased with the results. Dan From tjreedy at udel.edu Tue Jan 4 15:34:40 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Tue, 04 Jan 2011 15:34:40 -0500 Subject: opinion: comp lang docs style In-Reply-To: <98e82f1b-cf59-4e64-8fd4-63671f96b04f@r19g2000prm.googlegroups.com> References: <98e82f1b-cf59-4e64-8fd4-63671f96b04f@r19g2000prm.googlegroups.com> Message-ID: On 1/4/2011 1:24 PM, an Arrogant Ignoramus wrote: what he called > a opinion piece. I normally do not respond to trolls, but while expressing his opinions, AI made statements that are factually wrong at least as regards Python and its practitioners. 1. He correctly notes that the Python Language Reference includes snippets of BNF grammar with the intention of making the doc clear and precise. > The if statement is used for conditional execution: > if_stmt ::= "if" expression ":" suite > ( "elif" expression ":" suite )* > ["else" ":" suite] He incorrectly claims that the inclusion fails in its purpose. This is based on the irrelevant fact that 'BNF' has many versions (Python only uses one, explained in 1.2. Notation) and the false claim that "BNF is actually not used as a computer language for syntax description.". Actually, the above snippet is a quotation (with initial ':' expanded to '::=' and newlines added) from the file Grammar/Grammar: "if_stmt: 'if' test ':' suite ('elif' test ':' suite)* ['else' ':' suite]" The CPython program Parser/pgen takes Grammar/Grammar as input and produces the parser tables that CPython uses to parse Python code. In other words, CPython uses its well-defined version of extended BNF as a 'computer language for syntax description', contrary to AI's claim. I presume other implementations make either human or machine use of the same file. 2. AI also claims that this notation is 'incomprehensible'. Perhaps to him, but not to me or most the the subset of users who care about it. One way to expand the BNF into English is as follows: An if-statement starts with an if-clause consisting of the word 'if', an expression, a colon, and a suite. 'expression' and a 'suite' have already been defined elsewhere. The if clause can optionally be followed any count (including 0) of elif-clauses which are the same as if-clauses but with 'elif' substituted for 'if'. An if-statement can optionally be terminated with an else-clause consisting of 'else' and a suite. Even if such long-winded paraphrases were added to the doc (and I do not think they should be), in addition to the explanations currently given, the grammar snippet would still be needed to show the exact technical definition that CPython actually uses, for those who wan precisely that. (The people who care include those who want to change the grammar or those who think the behavior might might match the grammar.) 3. AI's complaint is deceptive and deficient in omitting any mention the part of the docs *intended* to teach beginners: the Tutorial. The main doc pages list the Tutorial first, as what one should start with. That is where I started and I cannot remember if I have ever read the formal if-statement grammar before, as I knew how to write such before I ever looked at the Language Reference. Guido and other developers do not and never have expected people to learn about if-statements from the grammar. The tutorial says: " 4.1. if Statements Perhaps the most well-known statement type is the if statement. For example: >>> x = int(input("Please enter an integer: ")) Please enter an integer: 42 >>> if x < 0: ... x = 0 ... print('Negative changed to zero') ... elif x == 0: ... print('Zero') ... elif x == 1: ... print('Single') ... else: ... print('More') There can be zero or more elif parts, and the else part is optional. The keyword ?elif? is short for ?else if?, and is useful to avoid excessive indentation. An if ... elif ... elif ... sequence is a substitute for the switch or case statements found in other languages. " I think this says by example and plain English just what a Python programmer needs to know. It is, of course, followed by many other examples in the remainder of the tutorial. If one wants to critique the 'Python Docs', especially as regards to usefulness to beginners, one must start with the Tutorial; and if one wants to use if statements as an example, one must start with the above. -- Terry Jan Reedy From arnodel at gmail.com Tue Jan 4 15:36:56 2011 From: arnodel at gmail.com (Arnaud Delobelle) Date: Tue, 04 Jan 2011 20:36:56 +0000 Subject: String building using join References: Message-ID: <87bp3wv21j.fsf@gmail.com> gervaz writes: > Hi all, I would like to ask you how I can use the more efficient join > operation in a code like this: > >>>> class Test: > ... def __init__(self, v1, v2): > ... self.v1 = v1 > ... self.v2 = v2 > ... >>>> def prg(l): > ... txt = "" > ... for x in l: > ... if x.v1 is not None: > ... txt += x.v1 + "\n" > ... if x.v2 is not None: > ... txt += x.v2 + "\n" > ... return txt > ... You can change the prg() function above slightly to make it a generator function: def genprg(l): for x in l: if x.v1 is not None: yield x.v1 if x.v2 is not None: yield x.v2 Then you can rewrite prg using join: def prg(l): return '\n'.join(genprg(l)) This way you save yourself from creating a list. I know this is not the one liner that others have suggested but it shows a general way of transforming a piece of code in order to make use of generator functions. -- Arnaud From goposter at jonjay.com Tue Jan 4 15:37:07 2011 From: goposter at jonjay.com (Google Poster) Date: Tue, 4 Jan 2011 12:37:07 -0800 (PST) Subject: Trying to decide between PHP and Python References: <_MmdnZ36uOSlHr7QnZ2dnUVZ5uGdnZ2d@giganews.com> <_MmdnZz6uOTUGb7QnZ2dnUVZ5uGdnZ2d@giganews.com> Message-ID: <2fdba007-53e0-470b-9663-1eb30183e76a@o11g2000prf.googlegroups.com> On Jan 4, 2:34?pm, Dan M wrote: > On Tue, 04 Jan 2011 12:32:28 -0800, Google Poster wrote: > > Not to mention that it took me 9 minutes to get a reply from you... > > Quite speedy community support. > > > That is a very important parameter in my technology decisions these > > days. > > > Thanks! > > > -Ramon > > This Usenet group is a truly awesome resource. My kinda place. :-) Now, I will embark on my learning journey the proper way: reading some Internet tutorials, instead of cheating like I just did. -Ramon From benjamin.kaplan at case.edu Tue Jan 4 15:45:12 2011 From: benjamin.kaplan at case.edu (Benjamin Kaplan) Date: Tue, 4 Jan 2011 15:45:12 -0500 Subject: Trying to decide between PHP and Python In-Reply-To: References: Message-ID: On Tue, Jan 4, 2011 at 3:20 PM, Google Poster wrote: > > About once a year, I have to learn yet another programming language. > Given all the recommendations (an outstanding accolade from Bruce > Eckel, author of "Thinking in Java") I have set my aim to Python. > Sounds kinda cool. > > The indentation-as-block is unique, but that is how I always indent, > anyway. > > Can any of you nice folks post a snippet of how to perform a listing > of the current directory and save it in a string? > > Something like this: > > $ setenv FILES = `ls` > import os FILES = os.listdir('.') will give you a list of all the files in the current directory. If you wanted that as a single string, just join all of the file names with whatever you want as a separator. files_str = '\n'.join(FILES) It's a bit different than what your original command does- it doesn't use the external "ls" command, it just gives you the list of files already parsed. > Bonus: Let's say that I want to convert the names of the files to > lowercase? As 'tolower()' > Strings in Python have a lower() method. files_str = files_str.lower() > TIA, > > -Ramon > -- > http://mail.python.org/mailman/listinfo/python-list > From bthate at gmail.com Tue Jan 4 15:46:39 2011 From: bthate at gmail.com (Bart Thate) Date: Tue, 4 Jan 2011 12:46:39 -0800 (PST) Subject: JSONBOT 0.6 RELEASED Message-ID: Hello world and the best wishes for 2011 for all of you ! i'm pleased to announce version 0.6 of JSONBOT, a release that saw it's complete codebase refactored. Things have moved into their own package, making it easier to distribute JSONBOT to the various OS around. I even renamed the name of the distribution to "jsb", so use the jsb-0.6.tar.gz or "easy_install jsb" to get this version of JSONBOT. So once again i need to ask existing users to upgrade their JSONBOT install, see http://jsonbot.appspot.com/docs/html/handbook/UPGRADE.html for instructions on how to do that. Functionality of the bot is the same as 0.5. For more information on JSONBOT, see http://jsonbot.googlecode.com or join us on #dunkbots Freenode. Bot documentation and demo is on http://jsonbot.appspot.com I hope you enjoy this release of JSONBOT, i'm glad i can start working on 0.7 ;] About JSONBOT: JSONBOT is a remote event-driven framework for building bots that talk JSON to each other over XMPP. This distribution provides bots built on this framework for console, IRC, XMPP for the shell and WWW and XMPP for the Google Application engine. JSONBOT is all of the following: * a shell console bot * a shell IRC bot * a shell XMPP bot * a Web bot running on Google Application Engine * a XMPP bot running on Google Application Engine * a Google Wave bot running op Google Application Engine * the XMPP bots are used to communicate between bots * plugin infrastructure to write your own functionality * event driven framework by the use of callbacks Bart From ameyer2 at yahoo.com Tue Jan 4 15:53:02 2011 From: ameyer2 at yahoo.com (Alan Meyer) Date: Tue, 04 Jan 2011 15:53:02 -0500 Subject: Trying to decide between PHP and Python In-Reply-To: References: Message-ID: <4D2388AE.6090103@yahoo.com> I confess that I haven't used php so someone correct me if I'm wrong. Looking at the history of the two languages, it is my impression that php originated as a language for web/CGI development which eventually added features enabling it to be used (sparingly) as a general purpose language. Python on the other hand is a general purpose language that has added features, in the form of library modules, that enable it to be used as a web/CGI development. Given these histories, one might ask, do you want to learn a new language for general purposes including web development, or do you want to learn a new language that is specifically focused on web/CGI? If the later, php will be an excellent choice, if the former, Python. If you only want to learn one language, or at least only want to learn one at this time, Python seems like a more useful choice - but only if you work (or also work) on some applications other than web/CGI. Alan From clp2 at rebertia.com Tue Jan 4 15:53:15 2011 From: clp2 at rebertia.com (Chris Rebert) Date: Tue, 4 Jan 2011 12:53:15 -0800 Subject: Trying to decide between PHP and Python In-Reply-To: <_MmdnZ36uOSlHr7QnZ2dnUVZ5uGdnZ2d@giganews.com> References: <_MmdnZ36uOSlHr7QnZ2dnUVZ5uGdnZ2d@giganews.com> Message-ID: On Tue, Jan 4, 2011 at 12:29 PM, Dan M wrote: > On Tue, 04 Jan 2011 12:20:42 -0800, Google Poster wrote: > >> About once a year, I have to learn yet another programming language. >> Given all the recommendations (an outstanding accolade from Bruce Eckel, >> author of "Thinking in Java") I have set my aim to Python. Sounds kinda >> cool. >> >> The indentation-as-block is unique, but that is how I always indent, >> anyway. >> >> Can any of you nice folks post a snippet of how to perform a listing of >> the current directory and save it in a string? >> >> Something like this: >> >> $ setenv FILES = `ls` >> >> Bonus: Let's say that I want to convert the names of the files to >> lowercase? As 'tolower()' > import os > import string > files = string.lower(' '.join(os.listdir('/home/dan'))) Most of the string module has been deprecated for quite a while now; use string methods instead: files = ' '.join(os.listdir('/home/dan')).lower() Cheers, Chris From alex at moreati.org.uk Tue Jan 4 16:09:13 2011 From: alex at moreati.org.uk (Alex Willmer) Date: Tue, 4 Jan 2011 13:09:13 -0800 (PST) Subject: Trying to decide between PHP and Python References: Message-ID: On Jan 4, 8:20?pm, Google Poster wrote: > Can any of you nice folks post a snippet of how to perform a listing > of the current directory and save it in a string? > > Something like this: > > $ setenv FILES = `ls` > > Bonus: Let's say that I want to convert the names of the files to > lowercase? As 'tolower()' I'd just like to mention one more python nicety: list comprehension. If you wanted the filenames as a list of strings, with each made lowercase then the following would serve well: import os filenames = os.listdir('.') filenames_lower = [fn.lower() for fn in filenames] You could also combine this into one line: import os filenames_lower = [fn.lower() for fn in os.listdir('.')] Regards, Alex From rtomek at ceti.com.pl Tue Jan 4 16:12:14 2011 From: rtomek at ceti.com.pl (Tomasz Rola) Date: Tue, 4 Jan 2011 22:12:14 +0100 Subject: Trying to decide between PHP and Python In-Reply-To: <_MmdnZ36uOSlHr7QnZ2dnUVZ5uGdnZ2d@giganews.com> References: <_MmdnZ36uOSlHr7QnZ2dnUVZ5uGdnZ2d@giganews.com> Message-ID: On Tue, 4 Jan 2011, Dan M wrote: > As to choice between Python and PHP, I would say learn anything but PHP. > Even Perl has fewer tentacles than PHP. However, the quality of code depends heavily on who writes it. My impression is that more folks of "I did it and it works so it is good, right?" attitude can be found among Perl/PHP crowd (compared to Python or Ruby or...). The reason is probably the "easyness" of those languages (mostly because of tons of readymade code on the net) which - wrongly - suggests they are already "there", no need to learn anymore. But I find, from time to time, nice code written in, say, PHP and from this I know it is possible to use it without screwing up. I guess it requires just some learning, some books (leaning towards theory rather than teaching dummies whatever in 2 and 1/10 days) and about five years (or maybe ten, or maybe only two) - after that, you can learn PHP and Perl if you really want to :-). I guess stackoverflow can give some pointers about it. Myself, I see neither of the two as promising for me, so I deflect them. Regards, Tomasz Rola -- ** A C programmer asked whether computer had Buddha's nature. ** ** As the answer, master did "rm -rif" on the programmer's home ** ** directory. And then the C programmer became enlightened... ** ** ** ** Tomasz Rola mailto:tomasz_rola at bigfoot.com ** From ian.g.kelly at gmail.com Tue Jan 4 16:14:17 2011 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Tue, 4 Jan 2011 14:14:17 -0700 Subject: Error python + cx_Oracle :Oracle-Error-Message: ORA-01036: illegal variable name/number In-Reply-To: <4D237BC7.9010101@gmail.com> References: <4D237BC7.9010101@gmail.com> Message-ID: On Tue, Jan 4, 2011 at 12:57 PM, Mauricio Martinez Garcia wrote: > > Hi, i need help with the next error: > > "ERR_PYTHON:Oracle-Error-Message: ORA-01036: illegal variable name/number", > i used the cx_Oracle module, and the error not is only Oracle Error. > > The error its for that python don't translate the query, with the variables > ":VARIABLE" when the VARIABLE is a number, this is th ecause of Oracle > error. You can only specify bind parameters that are used in the query. The dict you are passing in has 56 key/value pairs, but your query has only 55 variables. "TELEFONO_ICC" does not appear to be used anywhere in the query. Cheers, Ian From stef.mientki at gmail.com Tue Jan 4 16:15:33 2011 From: stef.mientki at gmail.com (Stef Mientki) Date: Tue, 04 Jan 2011 22:15:33 +0100 Subject: Trying to decide between PHP and Python In-Reply-To: <_MmdnZ36uOSlHr7QnZ2dnUVZ5uGdnZ2d@giganews.com> References: <_MmdnZ36uOSlHr7QnZ2dnUVZ5uGdnZ2d@giganews.com> Message-ID: <4D238DF5.4010305@gmail.com> > As to choice between Python and PHP, I would say learn anything but PHP. > Even Perl has fewer tentacles than PHP. type this in a form field 2.2250738585072011e-308 http://www.exploringbinary.com/php-hangs-on-numeric-value-2-2250738585072011e-308/ cheers, Stef From ben+python at benfinney.id.au Tue Jan 4 16:15:59 2011 From: ben+python at benfinney.id.au (Ben Finney) Date: Wed, 05 Jan 2011 08:15:59 +1100 Subject: Trying to decide between PHP and Python References: <_MmdnZ36uOSlHr7QnZ2dnUVZ5uGdnZ2d@giganews.com> <_MmdnZz6uOTUGb7QnZ2dnUVZ5uGdnZ2d@giganews.com> <2fdba007-53e0-470b-9663-1eb30183e76a@o11g2000prf.googlegroups.com> Message-ID: <87tyhofjzk.fsf@benfinney.id.au> Google Poster writes: > On Jan 4, 2:34?pm, Dan M wrote: > > This Usenet group is a truly awesome resource. > > My kinda place. :-) Can I ask, since you'll be joining us here, that you use your name (?Ramon? according to your signature, but preferably a full name) in your ?From? field to identify your messages better? -- \ ?I am too firm in my consciousness of the marvelous to be ever | `\ fascinated by the mere supernatural ?? ?Joseph Conrad, _The | _o__) Shadow-Line_ | Ben Finney From goposter at jonjay.com Tue Jan 4 16:22:41 2011 From: goposter at jonjay.com (Google Poster) Date: Tue, 4 Jan 2011 13:22:41 -0800 (PST) Subject: Trying to decide between PHP and Python References: Message-ID: On Jan 4, 3:09?pm, Alex Willmer wrote: > On Jan 4, 8:20?pm, Google Poster wrote: > > > Can any of you nice folks post a snippet of how to perform a listing > > of the current directory and save it in a string? > > > Something like this: > > > $ setenv FILES = `ls` > > > Bonus: Let's say that I want to convert the names of the files to > > lowercase? As 'tolower()' > > I'd just like to mention one more python nicety: list comprehension. > If you wanted the filenames as a list of strings, with each made > lowercase then the following would serve well: > > import os > filenames = os.listdir('.') > filenames_lower = [fn.lower() for fn in filenames] > > You could also combine this into one line: > > import os > filenames_lower = [fn.lower() for fn in os.listdir('.')] > > Regards, Alex The syntax reminds me of Lots of Interspersed Silly Parentheses (L.I.S.P.), but without the parentheses. :-) -Ramon From steve+comp.lang.python at pearwood.info Tue Jan 4 16:23:46 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 04 Jan 2011 21:23:46 GMT Subject: Troll Alert (do not click) References: <1f0063d2-53fc-4167-921e-aab49ce9e09b@o11g2000prf.googlegroups.com> <21da0736-800c-4cfc-9106-ed9edab6059f@j32g2000prh.googlegroups.com> Message-ID: <4d238fe1$0$29968$c3e8da3$5496439d@news.astraweb.com> On Tue, 04 Jan 2011 12:30:21 -0800, Google Poster wrote: [snip spam] Good lord, why the hell are you RE-POSTING spam??? Did you actually think it was HELPFUL to defeat everyone's anti-spam filters? Most people won't see the original spam, and then you "helpfully" resend it. Thanks a lot, if not for you we might not have seen it at all -- and if we did, we almost certainly wouldn't have clicked on it without the misleading subject line. I thought you were complaining about Xah Lee, which is always fun to read, not re-posting Indian porno spam. If I didn't know better, I'd seriously wonder whether you are, in fact, the spammer, just pretending to be replying to some other spammer. A false name (do your friends call you "Google Poster"?), a misleading subject line (it's not a troll post, it's spam), a trick to defeat filters and win the off-topic URLs many more links. Hmmm. Please don't try to "help" in this way again. -- Steven From steve+comp.lang.python at pearwood.info Tue Jan 4 16:31:56 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 04 Jan 2011 21:31:56 GMT Subject: Trying to decide between PHP and Python References: Message-ID: <4d2391cc$0$29968$c3e8da3$5496439d@news.astraweb.com> On Tue, 04 Jan 2011 13:09:13 -0800, Alex Willmer wrote: > You could also combine this into one line: > > import os > filenames_lower = [fn.lower() for fn in os.listdir('.')] That's two lines :) Here are a couple of nicely obfuscated one-liners: [name.lower() for name in __import__('os').listdir('.')] map(str.lower, __import__('os').listdir('.')) -- Steven From ameyer2 at yahoo.com Tue Jan 4 17:43:41 2011 From: ameyer2 at yahoo.com (Alan Meyer) Date: Tue, 04 Jan 2011 17:43:41 -0500 Subject: Trying to decide between PHP and Python In-Reply-To: References: Message-ID: <4D23A29D.7030104@yahoo.com> On 1/4/2011 4:22 PM, Google Poster wrote: > The syntax reminds me of Lots of Interspersed Silly Parentheses > (L.I.S.P.), but without the parentheses. I haven't heard that version before. The one I heard was: "Lots of Irritating Single Parentheses". Alan From steve+comp.lang.python at pearwood.info Tue Jan 4 17:48:24 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 04 Jan 2011 22:48:24 GMT Subject: Matrix multiplication References: <4h8bv7-p09.ln1@satorlaser.homedns.org> Message-ID: <4d23a3b8$0$29968$c3e8da3$5496439d@news.astraweb.com> On Tue, 04 Jan 2011 13:22:33 +0100, Zdenko wrote: > I wrote these two codes for example: > > this one is naive way of matrix multiplication using one thread [...] > this one is using two threads, each one is multiplying half of matrix [...] > why is second one more than twice slower than first when it should be > faster. I suspect that problem is in simultaneous access to matrix C but > i don't know how to solve this. Can I suggest that your timing code leaves something to be desired? * You time too much. You're interested in how long it takes to multiply two matrices, but you time how long it takes to do much more than just the multiplication: your timing code covers the time it takes to create the class object (which will be trivial), and build the matrix (non- trivial), as well as perform the multiplication. * Your perform the timing test once, which makes it subject to sampling errors. (Although if the process takes a long time, say, multiple seconds, the sampling error will *probably* be small relative to the measured time. But not always.) * You use time.clock, but without knowing which operating system you are running, it's impossible to tell whether you should be using time.time instead. Whether these issues will actually make a practical difference in this *specific* case, I don't know, but as a general rule, the most accurate way to perform these sorts of timing tests is with the timeit module. Something like this: A = ... # initialise matrix A B = ... # and B C = ... # and the result def mult1(A, B, C): # Multiply matrices A and B using 1 thread. t = MyThread() t.start() t.join() def mult2(A, B, C): # Multiply matrices A and B using 2 threads. t1 = MyThread() t2 = MyThread() t1.start() t2.start() t1.join() # Block until thread 1 is done. t2.join() # Now block until thread 2 is done. setup1 = "from __main__ import A, B, C, mult1" setup2 = "from __main__ import A, B, C, mult2" from timeit import Timer t1 = Timer("mult1(A, B, C)", setup1) t2 = Timer("mult2(A, B, C)", setup2) # Now perform the timing tests. best1 = min(t1.repeat()) best2 = min(t2.repeat()) By default, Timer.repeat will measure the time taken by one million iterations of the code snippet, and take three measurements. You almost always only care about the smallest measurement -- any larger times will represent sampling error. If it takes too long to time one million iterations, either make the matrices smaller, or pass keyword arguments number and/or repeat to the repeat method: # best of five measurements of one hundred iterations best1 = min(t1.repeat(number=100, repeat=5)) -- Steven From rurpy at yahoo.com Tue Jan 4 18:17:37 2011 From: rurpy at yahoo.com (rurpy at yahoo.com) Date: Tue, 4 Jan 2011 15:17:37 -0800 (PST) Subject: opinion: comp lang docs style References: <98e82f1b-cf59-4e64-8fd4-63671f96b04f@r19g2000prm.googlegroups.com> Message-ID: <4745479a-10c5-4281-9dcd-c9d7b013a1ec@k13g2000vbq.googlegroups.com> On 01/04/2011 01:34 PM, Terry Reedy wrote: > On 1/4/2011 1:24 PM, an Arrogant Ignoramus wrote: > > what he called >> a opinion piece. > > I normally do not respond to trolls, but while expressing his opinions, > AI made statements that are factually wrong at least as regards Python > and its practitioners. Given that most trolls include factually false statements, the above is inconsistent. And speaking of arrogant, it is just that to go around screaming "troll" about a posting relevant to the newsgroup it was posted in because you don't happen to agree with its content. In doing so you lower your own credibility. (Which is also not helped by your "Arrogant Ignoramus" name-calling.) > [...] > 2. AI also claims that this notation is 'incomprehensible'. Since incomprehensibility is clearly subjective your claim that it is a factual error is every bit as hyperbolic as his. > [...] > 3. AI's complaint is deceptive and deficient in omitting any mention the > part of the docs *intended* to teach beginners: the Tutorial. The main > doc pages list the Tutorial first, as what one should start with. That > [...] > If one wants to critique the 'Python Docs', especially as regards to > usefulness to beginners, one must start with the Tutorial; and if one > wants to use if statements as an example, one must start with the above. No. The language reference (LR) and standard library reference (SLR) must stand on their own merits. It is nice to have a good tutorial for those who like that style of learning. But it should be possible for a programmer with a basic understanding of computers and some other programming languages to understand how to program in python without referring to tutorials, explanatory websites, commercially published books, the source code, etc. The difficulty of doing that is a measure of the failure of the python docs to achive a level quality commensurate with the language itself. FWIW, I think the BNF in the LR is perfectly reasonable given the target audience I gave above. The failure of the LR has more to do with missing or excessively terse material -- it concentrates too exclusively on syntax and insufficiently on semantics. Much of the relevant semantics information is currently mislocated in the SLR. From roy at panix.com Tue Jan 4 19:31:01 2011 From: roy at panix.com (Roy Smith) Date: Tue, 04 Jan 2011 19:31:01 -0500 Subject: Trying to decide between PHP and Python References: <4D23A29D.7030104@yahoo.com> Message-ID: In article <4D23A29D.7030104 at yahoo.com>, Alan Meyer wrote: > On 1/4/2011 4:22 PM, Google Poster wrote: > > > The syntax reminds me of Lots of Interspersed Silly Parentheses > > (L.I.S.P.), but without the parentheses. > > I haven't heard that version before. The one I heard was: > > "Lots of Irritating Single Parentheses". > > Alan Long Involved Stupid Parentheses. From rtomek at ceti.com.pl Tue Jan 4 20:51:29 2011 From: rtomek at ceti.com.pl (Tomasz Rola) Date: Wed, 5 Jan 2011 02:51:29 +0100 Subject: Trying to decide between PHP and Python In-Reply-To: References: <4D23A29D.7030104@yahoo.com> Message-ID: On Tue, 4 Jan 2011, Roy Smith wrote: > In article <4D23A29D.7030104 at yahoo.com>, Alan Meyer > wrote: > > > On 1/4/2011 4:22 PM, Google Poster wrote: > > > > > The syntax reminds me of Lots of Interspersed Silly Parentheses > > > (L.I.S.P.), but without the parentheses. > > > > I haven't heard that version before. The one I heard was: > > > > "Lots of Irritating Single Parentheses". > > > > Alan > > Long Involved Stupid Parentheses. Heh. One day, guys, when you have nothing better to do, try writing a parser for Lisp-like language (Common Lisp, Scheme, whatever). After that, do the same with some other language of your preference (Python, Java, whatever). Compare time and code spent... Regards :-) Tomasz Rola -- ** A C programmer asked whether computer had Buddha's nature. ** ** As the answer, master did "rm -rif" on the programmer's home ** ** directory. And then the C programmer became enlightened... ** ** ** ** Tomasz Rola mailto:tomasz_rola at bigfoot.com ** From askutt at gmail.com Tue Jan 4 21:11:55 2011 From: askutt at gmail.com (Adam Skutt) Date: Tue, 4 Jan 2011 18:11:55 -0800 (PST) Subject: Interrput a thread References: <81c24eb1-41b6-442a-a971-8a44d2cd6c1b@p8g2000vbs.googlegroups.com> <2ebc11a5-1b45-4faa-97b9-c84f0db015a4@k22g2000yqh.googlegroups.com> Message-ID: <68004bac-5d4d-40fa-afb7-6de45f3ea87a@v17g2000yqv.googlegroups.com> On Jan 4, 10:12?am, Fuzzyman wrote: > > This is a case that .NET (C#) handles better than Python or Java. > Nope, read the documentation for Thread.Abort() carefully. Thread.Abort() can cause termination inside a static constructor, which is very bad. You sure your application can cope with that? Mine can't. Thread.Abort() is only safe for self-abortion, app domain termination and a few other very narrow and obscure scenarios. It is not a safe way to end arbitrary threads doing arbitrary processing. > It's another place where people > sometimes have a genuine need/use case yet people will insist on > telling them they don't *really* want it... > Because there's no safe way to do it. It's fundamentally a racy operation, with the typical horrible consequences when you lose. Removing the race requires support from the application, i.e., you have to write the code yourself. Frequently, it's simply not possible to remove the race. Adam From roy at panix.com Tue Jan 4 21:32:17 2011 From: roy at panix.com (Roy Smith) Date: Tue, 04 Jan 2011 21:32:17 -0500 Subject: Trying to decide between PHP and Python References: <4D23A29D.7030104@yahoo.com> Message-ID: In article , Tomasz Rola wrote: > Heh. One day, guys, when you have nothing better to do, try writing a > parser for Lisp-like language (Common Lisp, Scheme, whatever). After that, > do the same with some other language of your preference (Python, Java, > whatever). Compare time and code spent... There is no doubt that lisp is easy to parse. Even I can increment a counter every time I see '(' and decrement it every time I see ')'. But, computers are there to make life easy on people, not the other way around. There. Now that I've tossed some gasoline on the language wars fire, I'll duck and run in the other direction :-) From ben+python at benfinney.id.au Tue Jan 4 22:01:23 2011 From: ben+python at benfinney.id.au (Ben Finney) Date: Wed, 05 Jan 2011 14:01:23 +1100 Subject: Trying to decide between PHP and Python References: <4D23A29D.7030104@yahoo.com> Message-ID: <87bp3wf3zw.fsf@benfinney.id.au> Tomasz Rola writes: > Heh. One day, guys, when you have nothing better to do, try writing a > parser for Lisp-like language (Common Lisp, Scheme, whatever). After > that, do the same with some other language of your preference (Python, > Java, whatever). Compare time and code spent... Perhaps Lisp is a simpler language to parse than Python. Perhaps a machine with only one instruction is simpler to implement than one with a broader instruction set. So what? -- \ ?Shepherds ? look after their sheep so they can, first, fleece | `\ them and second, turn them into meat. That's much more like the | _o__) priesthood as I know it.? ?Christopher Hitchens, 2008-10-29 | Ben Finney From rtomek at ceti.com.pl Tue Jan 4 22:18:40 2011 From: rtomek at ceti.com.pl (Tomasz Rola) Date: Wed, 5 Jan 2011 04:18:40 +0100 Subject: Trying to decide between PHP and Python In-Reply-To: <87bp3wf3zw.fsf@benfinney.id.au> References: <4D23A29D.7030104@yahoo.com> <87bp3wf3zw.fsf@benfinney.id.au> Message-ID: On Wed, 5 Jan 2011, Ben Finney wrote: > > Tomasz Rola writes: > > Heh. One day, guys, when you have nothing better to do, try writing a > > parser for Lisp-like language (Common Lisp, Scheme, whatever). After > > that, do the same with some other language of your preference (Python, > > Java, whatever). Compare time and code spent... > Perhaps Lisp is a simpler language to parse than Python. > Perhaps a machine with only one instruction > is > simpler to implement than one with a broader instruction set. > So what? So... nothing at all. My intention was to point out that parentheses (or rather, simple syntax that is enabled when using them) can give a boost in some situations. BTW, my own experience tells me, they are not really as bad as some folk tales imply. Of course, there is also esthetic reason - some people don't like parentheses, period. I am ok with this. Me, OTOH, I have esthetic incompatibility with Perl and to some extent with PHP. No problem for me :-). Regards, Tomasz Rola -- ** A C programmer asked whether computer had Buddha's nature. ** ** As the answer, master did "rm -rif" on the programmer's home ** ** directory. And then the C programmer became enlightened... ** ** ** ** Tomasz Rola mailto:tomasz_rola at bigfoot.com ** From nagle at animats.com Tue Jan 4 22:46:10 2011 From: nagle at animats.com (John Nagle) Date: Tue, 04 Jan 2011 19:46:10 -0800 Subject: Matrix multiplication In-Reply-To: <4h8bv7-p09.ln1@satorlaser.homedns.org> References: <4h8bv7-p09.ln1@satorlaser.homedns.org> Message-ID: <4d23e980$0$44012$742ec2ed@news.sonic.net> On 1/4/2011 2:15 AM, Ulrich Eckhardt wrote: > Zdenko wrote: >> Please, can anybody write me a simple recursive matrix multiplication >> using multiple threads in Python, or at least show me some guidelines >> how to write it myself > > No problem, I just need your bank account data to withdraw the payment and > the address of your teacher whom to send the results. ;^) > > Seriously, things don't work like this. If you show effort, you will get > help, but you don't get working solutions without even a bit of effort on > your own. > > Start with a recursive algorithm, then make it multithreaded. Be prepared to > make some experiments on how to distribute tasks to threads and collect > them again. If you want to do matrix multiplication from Python, use NumPy. Anything you write in Python itself and run in CPython will be far, far slower. CPython without NumPy is about 60x slower than C on basic array math. Writing high-speed parallel number-crunching code that outperforms off the shelf libraries is typically non-trivial. If there's some easy way to make a simple operation like matrix multiply go faster, it's probably been done already. If you're really into this, look into the Unified Parallel C effort and its libraries. The supercomputer types spend their lives doing this sort of thing. John Nagle From nagle at animats.com Tue Jan 4 22:53:14 2011 From: nagle at animats.com (John Nagle) Date: Tue, 04 Jan 2011 19:53:14 -0800 Subject: Interrput a thread In-Reply-To: <68004bac-5d4d-40fa-afb7-6de45f3ea87a@v17g2000yqv.googlegroups.com> References: <81c24eb1-41b6-442a-a971-8a44d2cd6c1b@p8g2000vbs.googlegroups.com> <2ebc11a5-1b45-4faa-97b9-c84f0db015a4@k22g2000yqh.googlegroups.com> <68004bac-5d4d-40fa-afb7-6de45f3ea87a@v17g2000yqv.googlegroups.com> Message-ID: <4d23eb28$0$44049$742ec2ed@news.sonic.net> On 1/4/2011 6:11 PM, Adam Skutt wrote: > On Jan 4, 10:12 am, Fuzzyman wrote: >> >> This is a case that .NET (C#) handles better than Python or Java. >> > > Nope, read the documentation for Thread.Abort() carefully. > Thread.Abort() can cause termination inside a static constructor, > which is very bad. You sure your application can cope with that? > Mine can't. Thread.Abort() is only safe for self-abortion, app domain > termination and a few other very narrow and obscure scenarios. It is > not a safe way to end arbitrary threads doing arbitrary processing. > >> It's another place where people >> sometimes have a genuine need/use case yet people will insist on >> telling them they don't *really* want it... >> > > Because there's no safe way to do it. It's fundamentally a racy > operation, with the typical horrible consequences when you lose. > Removing the race requires support from the application, i.e., you > have to write the code yourself. Frequently, it's simply not possible > to remove the race. There are systems where there's support designed in for thread abort. LISP/Scheme systems tend to support it. QNX, the real-time OS, has well worked out thread-abort semantics at the C level. (QNX has really good features for "not getting stuck", like the ability to put a time limit on any system call.) But Python doesn't support things like that. What you'd really like in Python is the ability for one thread to be able to force an exception in another thread, plus a mechanism for locking out such exceptions for critical sections. It's not worth having, though, in a system where you can really only run one thread at a time. John Nagle From aahz at pythoncraft.com Tue Jan 4 23:40:15 2011 From: aahz at pythoncraft.com (Aahz) Date: 4 Jan 2011 20:40:15 -0800 Subject: Trying to decide between PHP and Python References: Message-ID: In article , Google Poster wrote: > >The syntax reminds me of Lots of Interspersed Silly Parentheses >(L.I.S.P.), but without the parentheses. You're not the first person to make that observation: http://norvig.com/python-lisp.html See also: http://norvig.com/python-iaq.html -- Aahz (aahz at pythoncraft.com) <*> http://www.pythoncraft.com/ "Think of it as evolution in action." --Tony Rand From aahz at pythoncraft.com Tue Jan 4 23:41:27 2011 From: aahz at pythoncraft.com (Aahz) Date: 4 Jan 2011 20:41:27 -0800 Subject: Trying to decide between PHP and Python References: <4D23A29D.7030104@yahoo.com> Message-ID: In article , Roy Smith wrote: >In article <4D23A29D.7030104 at yahoo.com>, Alan Meyer >wrote: >> On 1/4/2011 4:22 PM, Google Poster wrote: >>> >>> The syntax reminds me of Lots of Interspersed Silly Parentheses >>> (L.I.S.P.), but without the parentheses. >> >> I haven't heard that version before. The one I heard was: >> "Lots of Irritating Single Parentheses". > >Long Involved Stupid Parentheses. http://www.netfunny.com/rhf/jokes/90q2/lispcode.html -- Aahz (aahz at pythoncraft.com) <*> http://www.pythoncraft.com/ "Think of it as evolution in action." --Tony Rand From inyeol.lee at gmail.com Tue Jan 4 23:46:34 2011 From: inyeol.lee at gmail.com (Inyeol) Date: Tue, 4 Jan 2011 20:46:34 -0800 (PST) Subject: Which coding style is better? public API or private method inside class definition Message-ID: <0470dc9d-2a5f-40d4-afd4-97796059ba0a@q8g2000prm.googlegroups.com> For example: I'm writing simple class: class Numbers: def __init__(self, numbers): self._numbers = numbers def get_all(self): for number in self._numbers: yield number If I want to add another method for yielding even numbers only, I may use: def get_even(self): for numbers in self._numbers: if numbers % 2 == 0: yield number or, I can use public method 'get_all' instead of using private attribute '_numbers', like: def get_even(self): for numbers in self.get_all(): if numbers % 2 == 0: yield number Which coding style do you prefer? I'm more toward public API way, since it requires less code change if I refactor private data structure later. Plz give pros and cons of these. From inyeol.lee at gmail.com Tue Jan 4 23:52:00 2011 From: inyeol.lee at gmail.com (Inyeol) Date: Tue, 4 Jan 2011 20:52:00 -0800 (PST) Subject: Which coding style is better? public API or private method inside class definition References: <0470dc9d-2a5f-40d4-afd4-97796059ba0a@q8g2000prm.googlegroups.com> Message-ID: I found typo after posting: local name 'numbers' and 'number' are mixed. Plz don't report bug but focus on coding style only :-) From thaicares at gmail.com Wed Jan 5 00:22:58 2011 From: thaicares at gmail.com (Thai) Date: Tue, 4 Jan 2011 21:22:58 -0800 (PST) Subject: Just Starting in on programming Message-ID: <2c19b70f-917f-449c-9c6d-51f07cd769c5@glegroupsg2000goo.googlegroups.com> I was told this was good and some of the easier way to start programming. I'm just wondering if this statement is true and if so what is it I should do to really start getting in there and go ahead and start using some other languages. Thank you those who reply and help in advance Tyler Ryan Carroll From Joshua.R.English at gmail.com Wed Jan 5 00:31:52 2011 From: Joshua.R.English at gmail.com (Josh English) Date: Tue, 4 Jan 2011 21:31:52 -0800 (PST) Subject: Which coding style is better? public API or private method inside class definition In-Reply-To: <0470dc9d-2a5f-40d4-afd4-97796059ba0a@q8g2000prm.googlegroups.com> Message-ID: <801598ad-6bf9-4f62-a518-d5a469c0917d@glegroupsg2000goo.googlegroups.com> I think it depends on where you're willing to deal with changes. As it stands, if you make changes to get_all that will effect the way get_even works. If there's a logical chain that your code needs to follow and such changes would be acceptable, use them, because it's easier to change one thing once instead of one thing twice. In general, I try to code in a way that will reduce the number of places I'll have to change or refactor. Josh From ameyer2 at yahoo.com Wed Jan 5 00:57:37 2011 From: ameyer2 at yahoo.com (Alan Meyer) Date: Wed, 05 Jan 2011 00:57:37 -0500 Subject: Problem inserting an element where I want it using lxml Message-ID: <4D240851.4060802@yahoo.com> I'm having some trouble inserting elements where I want them using the lxml ElementTree (Python 2.6). I presume I'm making some wrong assumptions about how lxml works and I'm hoping someone can clue me in. I want to process an xml document as follows: For every occurrence of a particular element, no matter where it appears in the tree, I want to add a sibling to that element with the same name and a different value. Here's the smallest artificial example I've found so far demonstrates the problem: Add another bingo after this What I'd like to produce is this: Add another bingo after this Here's my program: -------- cut here ----- from lxml import etree as etree xml = """ Add another bingo after this """ tree = etree.fromstring(xml) # A list of all "bingo" element objects in the unmodified original xml # There's only one in this example elems = tree.xpath("//bingo") # For each one, insert a sibling after it bingoCounter = 0 for elem in elems: parent = elem.getparent() subIter = parent.iter() pos = 0 for subElem in subIter: # Is it one we want to create a sibling for? if subElem == elem: newElem = etree.Element("bingo") bingoCounter += 1 newElem.text = "New bingo %d" % bingoCounter newElem.tail = "\n" parent.insert(pos, newElem) break pos += 1 newXml = etree.tostring(tree) print("") print(newXml) -------- cut here ----- The output follows: -------- output ----- Add another bingo after this New bingo 1 -------- output ----- Setting aside the whitespace issues, the bug in the program shows up in the positioning of the insertion. I wanted and expected it to appear immediately after the original "bingo" element, and before the "bar" element, but it appeared after the "bar" instead of before it. Everything works if I take the "something" element out of the original input document. The new "bingo" appears before the "bar". But when I put it back in, the inserted bingo is out of order. Why should that be? What am I misunderstanding? Is there a more intelligent way to do what I'm trying to do? Thanks. Alan From kb1pkl at aim.com Wed Jan 5 01:07:01 2011 From: kb1pkl at aim.com (Corey Richardson) Date: Wed, 05 Jan 2011 01:07:01 -0500 Subject: Just Starting in on programming In-Reply-To: <2c19b70f-917f-449c-9c6d-51f07cd769c5@glegroupsg2000goo.googlegroups.com> References: <2c19b70f-917f-449c-9c6d-51f07cd769c5@glegroupsg2000goo.googlegroups.com> Message-ID: <4D240A85.5080702@aim.com> On 01/05/2011 12:22 AM, Thai wrote: > I was told this was good and some of the easier way to start >programming. I'm just wondering if this statement is true and if >so what is it I should do to really start getting in there and go >ahead and start using some other languages. > > Thank you those who reply and help in advance > Tyler Ryan Carrollhttp://docs.python.org/tutorial/ You were told what was good? Get started in where? If you're just learning to program, I found http://www.alan-g.me.uk/ was a very good resource, and I learned a lot. #python recommends http://www.greenteapress.com/thinkpython/html/index.html in the topic, and the Python tutorial at http://docs.python.org/tutorial/ is quality, you may learn quite a bit from it. If you have questions, I suggest you look into the tutor mailing list, tutor at python.org ~Corey Richardson From Joshua.R.English at gmail.com Wed Jan 5 01:16:14 2011 From: Joshua.R.English at gmail.com (Josh English) Date: Tue, 4 Jan 2011 22:16:14 -0800 (PST) Subject: Problem inserting an element where I want it using lxml In-Reply-To: <4D240851.4060802@yahoo.com> Message-ID: <106ef57e-6d86-4eef-959e-529453b8b026@glegroupsg2000goo.googlegroups.com> Here's a trimmed down version of how I did this (using ElementTree standalone, but the API should be the same) This is from a class definition and the _elem attribute is a link to an ElementTree.Element object. ... def _add_elem(self, tagName, text, attrib ={}): """_add_elem(tagName, text, attrib={}) Adds a child element in the appropriate place in the tree. Raises an IndexError if the checker does not allow an addition child of tagName. """ last_child = None for child in self._elem.findall('.//%s' % tagName): last_child = child if last_child is None: new_child = ET.SubElement(self._elem, tagName, attrib) else: new_child = ET.Element(tagName, attrib) self._elem.insert(self._elem._children.index(last_child)+1, new_child) new_child.text=str(text) return new_child I don't think you need to count the instances of the bingo node (unless you want to prevent too many from being added in). Josh From Joshua.R.English at gmail.com Wed Jan 5 01:17:42 2011 From: Joshua.R.English at gmail.com (Josh English) Date: Tue, 4 Jan 2011 22:17:42 -0800 (PST) Subject: Problem inserting an element where I want it using lxml In-Reply-To: <106ef57e-6d86-4eef-959e-529453b8b026@glegroupsg2000goo.googlegroups.com> Message-ID: <39b53121-1e38-4652-86ba-b53a631e3bc1@glegroupsg2000goo.googlegroups.com> Oh, and I usually use a separate function to indent my xml for readability when I need to actually look at the xml. It's easier than trying to change the element in situ and make it look nice. Josh From steve+comp.lang.python at pearwood.info Wed Jan 5 01:29:31 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 05 Jan 2011 06:29:31 GMT Subject: opinion: comp lang docs style References: <98e82f1b-cf59-4e64-8fd4-63671f96b04f@r19g2000prm.googlegroups.com> <4745479a-10c5-4281-9dcd-c9d7b013a1ec@k13g2000vbq.googlegroups.com> Message-ID: <4d240fca$0$29969$c3e8da3$5496439d@news.astraweb.com> On Tue, 04 Jan 2011 15:17:37 -0800, rurpy at yahoo.com wrote: >> If one wants to critique the 'Python Docs', especially as regards to >> usefulness to beginners, one must start with the Tutorial; and if one >> wants to use if statements as an example, one must start with the >> above. > > No. The language reference (LR) and standard library reference (SLR) > must stand on their own merits. It is nice to have a good tutorial for > those who like that style of learning. But it should be possible for a > programmer with a basic understanding of computers and some other > programming languages to understand how to program in python without > referring to tutorials, explanatory websites, commercially published > books, the source code, etc. No it shouldn't. That's what the tutorial is for. The language reference and standard library reference are there to be reference manuals, not to teach beginners Python. In any case, your assumption that any one documentation work should stand on its own merits is nonsense -- *nothing* stands alone. Everything builds on something else. Technical documentation is no different: it *must* assume some level of knowledge of its readers -- should it be aimed at Python experts, or average Python coders, or beginners, or beginners to programming, or at the very least is it allowed to assume that the reader already knows how to read? You can't satisfy all of these groups with one document, because their needs are different and in conflict. This is why you have different documentation -- tutorials and reference manuals and literate source code and help text are all aimed at different audiences. Expecting one document to be useful for all readers' needs is like expecting one data type to be useful for all programming tasks. Reasonable people might disagree on what a particular documentation work should target, and the best way to target it, but not on the need for different documentation for different targets. -- Steven From alice at gothcandy.com Wed Jan 5 02:23:31 2011 From: alice at gothcandy.com (=?utf-8?Q?Alice_Bevan=E2=80=93McGregor?=) Date: Tue, 4 Jan 2011 23:23:31 -0800 Subject: opinion: comp lang docs style References: <98e82f1b-cf59-4e64-8fd4-63671f96b04f@r19g2000prm.googlegroups.com> <4745479a-10c5-4281-9dcd-c9d7b013a1ec@k13g2000vbq.googlegroups.com> <4d240fca$0$29969$c3e8da3$5496439d@news.astraweb.com> Message-ID: On 2011-01-04 22:29:31 -0800, Steven D'Aprano said: > In any case, your assumption that any one documentation work should stand > on its own merits is nonsense -- *nothing* stands alone. +1 How many RFCs still in use today don't start with: > The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", > "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this > document are to be interpreted as described in RFC 2119 I posted a response on the article itself, rather than pollute a mailing list with replies to a troll. The name calling was a rather large hint as to the intention of the "opinion", either that or whoever translated the article (man or machine) was really angry at the time. ;) - Alice. From timr at probo.com Wed Jan 5 02:31:37 2011 From: timr at probo.com (Tim Roberts) Date: Tue, 04 Jan 2011 23:31:37 -0800 Subject: Matrix multiplication References: Message-ID: Zdenko wrote: > >Please, can anybody write me a simple recursive matrix multiplication >using multiple threads in Python, or at least show me some guidelines >how to write it myself Matrix multiplication is not generally done recursively. There's no conceptual gain. It makes more sense iteratively. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From stefan_ml at behnel.de Wed Jan 5 02:47:04 2011 From: stefan_ml at behnel.de (Stefan Behnel) Date: Wed, 05 Jan 2011 08:47:04 +0100 Subject: Problem inserting an element where I want it using lxml In-Reply-To: <4D240851.4060802@yahoo.com> References: <4D240851.4060802@yahoo.com> Message-ID: Alan Meyer, 05.01.2011 06:57: > I'm having some trouble inserting elements where I want them > using the lxml ElementTree (Python 2.6). I presume I'm making > some wrong assumptions about how lxml works and I'm hoping > someone can clue me in. > > I want to process an xml document as follows: > > For every occurrence of a particular element, no matter where it > appears in the tree, I want to add a sibling to that element with > the same name and a different value. > > Here's the smallest artificial example I've found so far > demonstrates the problem: > > > > > > Add another bingo after this > > > > What I'd like to produce is this: > > > > > > Add another bingo after this > > Looks trivial to me. ;) > Here's my program: > > -------- cut here ----- > from lxml import etree as etree > > xml = """ > > > > > Add another bingo after this > > > """ > > tree = etree.fromstring(xml) > > # A list of all "bingo" element objects in the unmodified original xml > # There's only one in this example > elems = tree.xpath("//bingo") > > # For each one, insert a sibling after it > bingoCounter = 0 > for elem in elems: > parent = elem.getparent() > subIter = parent.iter() ".iter()" gives you a recursive iterator that will also yield the "something" Element in your case, thus the incorrect counting. You only want the children, so you should iterate over the Element itself. > pos = 0 > for subElem in subIter: > # Is it one we want to create a sibling for? > if subElem == elem: There is an .index() method on Elements that does what you want to achieve here. However, the right way to do it is to use ".addnext()". http://codespeak.net/lxml/api/lxml.etree._Element-class.html Stefan From orasnita at gmail.com Wed Jan 5 02:48:40 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Wed, 5 Jan 2011 09:48:40 +0200 Subject: Trying to decide between PHP and Python References: <_MmdnZ36uOSlHr7QnZ2dnUVZ5uGdnZ2d@giganews.com> Message-ID: <00DCA6C991454D1A879B9F7BADDCEFCA@octavian> From: "Tomasz Rola" > On Tue, 4 Jan 2011, Dan M wrote: > >> As to choice between Python and PHP, I would say learn anything but PHP. >> Even Perl has fewer tentacles than PHP. > > However, the quality of code depends heavily on who writes it. My > impression is that more folks of "I did it and it works so it is good, > right?" attitude can be found among Perl/PHP crowd (compared to Python or > Ruby or...). The reason is probably the "easyness" of those languages > (mostly because of tons of readymade code on the net) which - wrongly - > suggests they are already "there", no need to learn anymore. Yes you are right. Perl is much flexible than all other languages and there was written a lot of bad code in the past that can now be found on the net, beeing very hard for a newbie to find only the good examples and tutorials. But Perl offers many helpful modules for testing the apps so for good programmers there is not true the idea of "it works so it's ok". Usually we compare the languages although we always think to all aditional modules and libraries we can use with them for creating apps. Thinking this way, Perl is better than Python for creating web apps, because Catalyst framework is more advanced than the frameworks for Python and it is more flexible even than Ruby on Rails, DBIx::Class ORM is a very advanced ORM and a very clean one and Perl web apps can use strong templating systems and form processors, unicode is a native code for Perl for a long time and so on. So how good is the language depends on what you need to use it for. (But I hope that this won't start a language war, because I have just done the same on a Perl mailing list telling about some Perl disadvantages towards Python :) Octavian From s.selvamsiva at gmail.com Wed Jan 5 04:28:31 2011 From: s.selvamsiva at gmail.com (Selvam) Date: Wed, 5 Jan 2011 14:58:31 +0530 Subject: Beautifulsoup html parsing - nested tags Message-ID: Hi all, I am trying to parse some html string with BeatifulSoup. The string is,

Tax

Base

Amount

rtables=soup.findAll(re.compile('table$')) The rtables is, [

Tax

Base

Amount

, ] The tr inside the blocktable are appearing inside the table, while blocktable contains nothing. Is there any way, I can get the tr in the right place (inside blocktable) ? -- Regards, S.Selvam SG E-ndicus Infotech Pvt Ltd. http://e-ndicus.com/ " I am because we are " -------------- next part -------------- An HTML attachment was scrubbed... URL: From s.selvamsiva at gmail.com Wed Jan 5 05:15:12 2011 From: s.selvamsiva at gmail.com (Selvam) Date: Wed, 5 Jan 2011 15:45:12 +0530 Subject: Beautifulsoup html parsing - nested tags In-Reply-To: References: Message-ID: On Wed, Jan 5, 2011 at 2:58 PM, Selvam wrote: > Hi all, > > I am trying to parse some html string with BeatifulSoup. > > The string is, > > > > > > > > > > > >
> >
>

Tax

>

Base

>

Amount

> > > rtables=soup.findAll(re.compile('table$')) > > The rtables is, > > [ > > > > > > >
> >
>

Tax

>

Base

>

Amount

, > ] > > > > The tr inside the blocktable are appearing inside the table, while > blocktable contains nothing. > > Is there any way, I can get the tr in the right place (inside blocktable) ? > > -- > Regards, > S.Selvam > SG E-ndicus Infotech Pvt Ltd. > http://e-ndicus.com/ > > " I am because we are " > Replying to myself, BeautifulSoup.BeautifulSoup.NESTABLE_TABLE_TAGS['tr'].append('blocktable') adding this, solved the issue. -- Regards, S.Selvam SG E-ndicus Infotech Pvt Ltd. http://e-ndicus.com/ " I am because we are " -------------- next part -------------- An HTML attachment was scrubbed... URL: From stackslip at gmail.com Wed Jan 5 05:19:59 2011 From: stackslip at gmail.com (Slie) Date: Wed, 5 Jan 2011 01:19:59 -0900 Subject: Graphing API, Message-ID: Is there a graphing API, someone suggests? From nitinpawar432 at gmail.com Wed Jan 5 05:22:31 2011 From: nitinpawar432 at gmail.com (Nitin Pawar) Date: Wed, 5 Jan 2011 15:52:31 +0530 Subject: Graphing API, In-Reply-To: References: Message-ID: you can check pywebgraph On Wed, Jan 5, 2011 at 3:49 PM, Slie wrote: > Is there a graphing API, someone suggests? > -- > http://mail.python.org/mailman/listinfo/python-list > -- Nitin Pawar -------------- next part -------------- An HTML attachment was scrubbed... URL: From flebber.crue at gmail.com Wed Jan 5 05:29:25 2011 From: flebber.crue at gmail.com (flebber) Date: Wed, 5 Jan 2011 02:29:25 -0800 (PST) Subject: Trying to decide between PHP and Python References: <_MmdnZ36uOSlHr7QnZ2dnUVZ5uGdnZ2d@giganews.com> Message-ID: On Jan 5, 6:48?pm, "Octavian Rasnita" wrote: > From: "Tomasz Rola" > > > On Tue, 4 Jan 2011, Dan M wrote: > > >> As to choice between Python and PHP, I would say learn anything but PHP. > >> Even Perl has fewer tentacles than PHP. > > > However, the quality of code depends heavily on who writes it. My > > impression is that more folks of "I did it and it works so it is good, > > right?" attitude can be found among Perl/PHP crowd (compared to Python or > > Ruby or...). The reason is probably the "easyness" of those languages > > (mostly because of tons of readymade code on the net) which - wrongly - > > suggests they are already "there", no need to learn anymore. > > Yes you are right. Perl is much flexible than all other languages and there > was written a lot of bad code in the past that can now be found on the net, > beeing very hard for a newbie to find only the good examples and tutorials. > > But Perl offers many helpful modules for testing the apps so for good > programmers there is not true the idea of "it works so it's ok". > > Usually we compare the languages although we always think to all aditional > modules and libraries we can use with them for creating apps. > Thinking this way, Perl is better than Python for creating web apps, because > Catalyst framework is more advanced than the frameworks for Python and it is > more flexible even than Ruby on Rails, DBIx::Class ORM is a very advanced > ORM and a very clean one and Perl web apps can use strong templating systems > and form processors, unicode is a native code for Perl for a long time and > so on. > > So how good is the language depends on what you need to use it for. > > (But I hope that this won't start a language war, because I have just done > the same on a Perl mailing list telling about some Perl disadvantages > towards Python :) > > Octavian My two cents, I am understanding python far better by learning scheme. Didn't intentionally set out to achieve that as a goal just a by product. An excelent resource http://htdp.org and using the racket scheme ide(as much of an ide as idle), simple thorough well explained concepts via worked examples and a very encouraging and enthusiastic mail group, much like this list. I would so love a book like that for python but after i complete htdp I may not need it. Regards Sayth From nobody at nowhere.com Wed Jan 5 05:44:19 2011 From: nobody at nowhere.com (Nobody) Date: Wed, 05 Jan 2011 10:44:19 +0000 Subject: Trying to decide between PHP and Python References: Message-ID: On Tue, 04 Jan 2011 12:20:42 -0800, Google Poster wrote: > The indentation-as-block is unique, Not at all. It's also used in occam, Miranda, Haskell and F#. From clp2 at rebertia.com Wed Jan 5 05:45:31 2011 From: clp2 at rebertia.com (Chris Rebert) Date: Wed, 5 Jan 2011 02:45:31 -0800 Subject: Graphing API, In-Reply-To: References: Message-ID: On Wed, Jan 5, 2011 at 2:19 AM, Slie wrote: > Is there a graphing API, someone suggests? matplotlib: http://matplotlib.sourceforge.net/ Cheers, Chris From ameyer2 at yahoo.com Wed Jan 5 06:20:22 2011 From: ameyer2 at yahoo.com (Alan Meyer) Date: Wed, 05 Jan 2011 06:20:22 -0500 Subject: Problem inserting an element where I want it using lxml In-Reply-To: References: <4D240851.4060802@yahoo.com> Message-ID: On 01/05/2011 02:47 AM, Stefan Behnel wrote: > ... > Looks trivial to me. ;) > ... > ".iter()" gives you a recursive iterator that will also yield the > "something" Element in your case, thus the incorrect counting. You only > want the children, so you should iterate over the Element itself. Thanks Stephan. I went home and went to sleep and woke up in the middle of the night and thought, wait a minute, iter() is giving me a depth first list of elements but insert() is indexing children of the parent. I think I must have been up too late. > There is an .index() method on Elements that does what you want to > achieve here. However, the right way to do it is to use ".addnext()". > > http://codespeak.net/lxml/api/lxml.etree._Element-class.html > > Stefan > Those are exactly the functions I wanted. I didn't see them (and still don't) in the Python ElementTree documentation and thought I had to use parent.insert(). Thanks again. From ameyer2 at yahoo.com Wed Jan 5 06:25:11 2011 From: ameyer2 at yahoo.com (Alan Meyer) Date: Wed, 05 Jan 2011 06:25:11 -0500 Subject: Problem inserting an element where I want it using lxml In-Reply-To: <106ef57e-6d86-4eef-959e-529453b8b026@glegroupsg2000goo.googlegroups.com> References: <106ef57e-6d86-4eef-959e-529453b8b026@glegroupsg2000goo.googlegroups.com> Message-ID: On 01/05/2011 01:16 AM, Josh English wrote: > Here's a trimmed down version of how I did this (using ElementTree standalone, but the API should be the same) > This is from a class definition and the _elem attribute is a link to an ElementTree.Element object. > > ... > def _add_elem(self, tagName, text, attrib ={}): > """_add_elem(tagName, text, attrib={}) > Adds a child element in the appropriate place in the tree. > Raises an IndexError if the checker does not allow an addition child of tagName. > """ > last_child = None > for child in self._elem.findall('.//%s' % tagName): > last_child = child > > if last_child is None: > new_child = ET.SubElement(self._elem, tagName, attrib) > else: > new_child = ET.Element(tagName, attrib) > self._elem.insert(self._elem._children.index(last_child)+1, new_child) > new_child.text=str(text) > > return new_child > > I don't think you need to count the instances of the bingo node (unless you want to prevent too many from being added in). > > Josh Thanks Josh. It looks like lxml adds some incredibly useful extensions to ElementTree that I will use. See Stephan's reply. Alan From alice at gothcandy.com Wed Jan 5 06:31:03 2011 From: alice at gothcandy.com (=?utf-8?Q?Alice_Bevan=E2=80=93McGregor?=) Date: Wed, 5 Jan 2011 03:31:03 -0800 Subject: Trying to decide between PHP and Python References: <4D2388AE.6090103@yahoo.com> Message-ID: On 2011-01-04 12:53:02 -0800, Alan Meyer said: > I confess that I haven't used PHP so someone correct me if I'm wrong. > [snip] +1 You're pretty much on the ball with your description. I might summarize it as: PHP (PHP: Hypertext Processor) is a templating language with a significant enough standard library for aspirations of general-purpose scripting. Python is a general-purpose scripting language with numerous templating languages, let alone the terrifyingly large standard library. ;) Yes, PHP has templating language syntaxes like Smarty, but you're running a template parser within another template parser... A fairly common sarcastic quote is: "You aren't a real Python programmer until you write your own [coroutine framework | web framework | templating language | ...]!" I've done all three, and this probably does not make me a good person. ;) The coroutine framework was a hack to see how they work through experimentation, but I'm quite proud of the web framework and templating system! :D - Alice. From pavlovevidence at gmail.com Wed Jan 5 06:37:46 2011 From: pavlovevidence at gmail.com (Carl Banks) Date: Wed, 5 Jan 2011 03:37:46 -0800 (PST) Subject: Which coding style is better? public API or private method inside class definition References: <0470dc9d-2a5f-40d4-afd4-97796059ba0a@q8g2000prm.googlegroups.com> Message-ID: On Jan 4, 8:46?pm, Inyeol wrote: > For example: I'm writing simple class: > > ? ? class Numbers: > ? ? ? ? def __init__(self, numbers): > ? ? ? ? ? ? self._numbers = numbers > ? ? ? ? def get_all(self): > ? ? ? ? ? ? for number in self._numbers: > ? ? ? ? ? ? ? ? yield number > > If I want to add another method for yielding even numbers only, I may > use: > > ? ? ? ? def get_even(self): > ? ? ? ? ? ? for numbers in self._numbers: > ? ? ? ? ? ? ? ? if numbers % 2 == 0: > ? ? ? ? ? ? ? ? ? ? yield number > > or, I can use public method 'get_all' instead of using private > attribute '_numbers', like: > > ? ? ? ? def get_even(self): > ? ? ? ? ? ? for numbers in self.get_all(): > ? ? ? ? ? ? ? ? if numbers % 2 == 0: > ? ? ? ? ? ? ? ? ? ? yield number > > Which coding style do you prefer? I'm more toward public API way, > since it requires less code change if I refactor private data > structure later. > Plz give pros and cons of these. Using Public API makes it easier to subclass, if you want to redefine the meaning of "all" somehow. The main reason to avoid Public API is to get performance benefits (most Python built-in classes access the internal structure directly for this reason). There are occasions where a function really needs to access the internals and not the "visible" value. Also, in Python it's reasonable to consider an instance variable to be part of the public interface of a class, because backwards- incompatible changes can be avoided using properties. Carl Banks From duncan.booth at invalid.invalid Wed Jan 5 07:43:09 2011 From: duncan.booth at invalid.invalid (Duncan Booth) Date: 5 Jan 2011 12:43:09 GMT Subject: Trying to decide between PHP and Python References: Message-ID: Nobody wrote: > On Tue, 04 Jan 2011 12:20:42 -0800, Google Poster wrote: > >> The indentation-as-block is unique, > > Not at all. It's also used in occam, Miranda, Haskell and F#. > Also Yaml. -- Duncan Booth http://kupuguy.blogspot.com From usernet at ilthio.net Wed Jan 5 08:32:45 2011 From: usernet at ilthio.net (Tim Harig) Date: Wed, 5 Jan 2011 13:32:45 +0000 (UTC) Subject: Graphing API, References: Message-ID: On 2011-01-05, Slie wrote: > Is there a graphing API, someone suggests? You should check the archives, variations of this question get asked a lot. I use GNUplot to do my graphing. I simply pipe it commands and data through the subprocess module; but, there are libraries available for interacting with it. Posts here also indicate that Google offers a web service based API for generating graphs. I have never actually used it; but, the documentation seems to be clear enough to get it working without too much trouble. From private at private.com Wed Jan 5 08:51:35 2011 From: private at private.com (ana sanchez) Date: Wed, 5 Jan 2011 13:51:35 +0000 (UTC) Subject: why generator assigned to slice? Message-ID: hi!!! i found this when i read the source of a program in python: self.__chunks[start:end] = (chunk for i in xrange(start, end)) and also this: self.__lines[line:line] = (None for i in xrange(count)) what utility has to assign a generator to a slice??? ?the *final result* isn't the same as this?: self.__chunks[start:end] = [chunk for i in xrange(start, end)] self.__chunks[line:line] = [None for i in xrange(count)] thanks!!! ana p.d. excuse my english From __peter__ at web.de Wed Jan 5 09:12:07 2011 From: __peter__ at web.de (Peter Otten) Date: Wed, 05 Jan 2011 15:12:07 +0100 Subject: why generator assigned to slice? References: Message-ID: ana sanchez wrote: > i found this when i read the source of a program in python: > > self.__chunks[start:end] = (chunk for i in xrange(start, end)) > what utility has to assign a generator to a slice??? ?the *final > result* isn't the same as this?: > > self.__chunks[start:end] = [chunk for i in xrange(start, end)] Whoever used the first variant probably was hoping that it was either faster or used less peak memory. I think the latter is wrong, and the former can easily be checked: $ python -m timeit -s'chunk = "yadda"; chunks = range(100); start = 20; end = 50' 'chunks[start:end] = (chunk for i in xrange(start, end))' 100000 loops, best of 3: 9.02 usec per loop $ python -m timeit -s'chunk = "yadda"; chunks = range(100); start = 20; end = 50' 'chunks[start:end] = [chunk for i in xrange(start, end)]' 100000 loops, best of 3: 4.16 usec per loop $ python -m timeit -s'chunk = "yadda"; chunks = range(100); start = 20; end = 50' 'chunks[start:end] = [chunk]*(end-start)' 1000000 loops, best of 3: 1.02 usec per loop From tinauser at libero.it Wed Jan 5 10:07:58 2011 From: tinauser at libero.it (tinauser) Date: Wed, 5 Jan 2011 07:07:58 -0800 (PST) Subject: dictionary as attribute of a class... Message-ID: Hallo list, here again I have a problem whose solution might be very obvious, but I really cannot see it: I have a class having as attribute a dictionary whose keys are names and values are instance of another class. This second class has in turn as an attribute a dictionary. I want a function of the first class that can change value of one of the second class instance's dictionary. however I cannot do it without modifying this attribute for ALL the instance of the second class contained in the first class' dictionary. What I'm doing wrong? the code: ############### ###can i change a dictionary attribute of an instantated object without affectin all the instances of that object? class mistClass(): def __init__(self,name,cDict={}): print 'mistClass ',name,' Init' self._name=name self._cDict=cDict def setName(self,n): self._name=n def getName(self): return self._name ## def setDict(self,one,two): ## self._cDict['one']=one ## self._cDict['two']=two def setDict(self,listK,listV): assert len(listK)==len(listV) for k,v in zip(listK,listV): self._cDict[k]=v def getDict(self): return self._cDict class mistClassContainer(): def __init__(self,name,dict_of_mistclass={}): print 'init mistClassContainer ',name self._name=name self._DOM=dict_of_mistclass def add_mistclass(self,mc): for el in mc: self._DOM[el]=mistClass(el) ## def mod_mistclasscDict(self,mc,one,two): ## self._DOM[mc].setDict(one,two) def mod_mistclasscDict(self,mc,lK,lV): self._DOM[mc].setDict(lK,lV) a=mistClassContainer('firsmistclasscontainer') a.add_mistclass(['mc1','mc2','mc3','mc4','mc5','mc6']) print 'before modification' for el in a._DOM.iterkeys(): print a._DOM[el].getDict() print a._DOM[el].getName() a.mod_mistclasscDict('mc1',['one','two'],['modone','modtwo']) print 'after modification' for el in a._DOM.iterkeys(): print a._DOM[el].getDict() print a._DOM[el].getName() b=mistClass('mc7') print b.getDict() print b.getName() b.setName('modified name') b.getName() for el in a._DOM.iterkeys(): print a._DOM[el].getName() From jeanmichel at sequans.com Wed Jan 5 10:18:22 2011 From: jeanmichel at sequans.com (Jean-Michel Pichavant) Date: Wed, 05 Jan 2011 16:18:22 +0100 Subject: Which coding style is better? public API or private method inside class definition In-Reply-To: <0470dc9d-2a5f-40d4-afd4-97796059ba0a@q8g2000prm.googlegroups.com> References: <0470dc9d-2a5f-40d4-afd4-97796059ba0a@q8g2000prm.googlegroups.com> Message-ID: <4D248BBE.6030102@sequans.com> Inyeol wrote: > For example: I'm writing simple class: > > class Numbers: > def __init__(self, numbers): > self._numbers = numbers > def get_all(self): > for number in self._numbers: > yield number > > If I want to add another method for yielding even numbers only, I may > use: > > def get_even(self): > for numbers in self._numbers: > if numbers % 2 == 0: > yield number > > or, I can use public method 'get_all' instead of using private > attribute '_numbers', like: > > def get_even(self): > for numbers in self.get_all(): > if numbers % 2 == 0: > yield number > > Which coding style do you prefer? I'm more toward public API way, > since it requires less code change if I refactor private data > structure later. > Plz give pros and cons of these. > - Unless you already know that you'll need to refactor the structure later, there's no need to anticipate => unnecessary optimization - Using public API deos not necessarily make refactoring easier. Let me explain, public APIs are meant to be called by external objects. These APIs may need to do some things that internal computing doesn't. For instance, let's say you add a logging statement in the get_all() method. Every call triggers a log entry. Does the get_even method want to log this call ? Maybe not. In that particular case, using the internal strucutre is preferable. - If you agree to the statement that readability > edition, then you should care more about writing clean and concise code, than refactorable ( :D ) code. Using self._numbers raises less questions to the reader. Though I admit that question raised by get_all are answered in 5 seconds (the question being 'If he used an method instead of _numbers, this method must do something special') - In fine, it doesn't really matter in the example you gave above. JM From rtomek at ceti.com.pl Wed Jan 5 10:21:05 2011 From: rtomek at ceti.com.pl (Tomasz Rola) Date: Wed, 5 Jan 2011 16:21:05 +0100 Subject: Trying to decide between PHP and Python In-Reply-To: References: <_MmdnZ36uOSlHr7QnZ2dnUVZ5uGdnZ2d@giganews.com> Message-ID: On Wed, 5 Jan 2011, flebber wrote: > My two cents, I am understanding python far better by learning scheme. > Didn't intentionally set out to achieve that as a goal just a by > product. An excelent resource http://htdp.org and using the racket > scheme ide(as much of an ide as idle), simple thorough well explained > concepts via worked examples and a very encouraging and enthusiastic > mail group, much like this list. > > I would so love a book like that for python but after i complete htdp > I may not need it. Agreed. I freezed my Racket usage while it was called DrScheme but I keep my eye on it ever since. It is really nice and well designed environment. It took me by a storm, which I cannot say about Idle ;-) . I also agree that every Python programmer could gain something valuable by at least trying it, as well as reading their docs and mailing list for a while. Or every programmer regardless of his/her current language. HTDP is interesting book, pity I couldn't read it when it might have made a bigger difference to my development. Regards, Tomasz Rola -- ** A C programmer asked whether computer had Buddha's nature. ** ** As the answer, master did "rm -rif" on the programmer's home ** ** directory. And then the C programmer became enlightened... ** ** ** ** Tomasz Rola mailto:tomasz_rola at bigfoot.com ** From invalid at invalid.invalid Wed Jan 5 10:30:23 2011 From: invalid at invalid.invalid (Grant Edwards) Date: Wed, 5 Jan 2011 15:30:23 +0000 (UTC) Subject: Trying to decide between PHP and Python References: <4D23A29D.7030104@yahoo.com> Message-ID: On 2011-01-05, Tomasz Rola wrote: > On Tue, 4 Jan 2011, Roy Smith wrote: >> Alan Meyer wrote: >>> On 1/4/2011 4:22 PM, Google Poster wrote: >>> >>>> The syntax reminds me of Lots of Interspersed Silly Parentheses >>>> (L.I.S.P.), but without the parentheses. >>> >>> I haven't heard that version before. The one I heard was: >>> >>> "Lots of Irritating Single Parentheses". >> >> Long Involved Stupid Parentheses. > > Heh. One day, guys, when you have nothing better to do, try writing a > parser for Lisp-like language (Common Lisp, Scheme, whatever). After that, > do the same with some other language of your preference (Python, Java, > whatever). Compare time and code spent... I've heard that justification many times, but I think it's 200% specious. 1) How often is a compiler for language X written? 2) How often is source code written in language X? 3) How often is that source code in language X read/modified? If you compare those numbers you'll realize that optimizing for case 1 at the expense of cases 2 & 3 is just plain stupid. Perhaps there is somebody on the planet who finds Lisp as easy to read/modify as Python, but I've never met him/her and never have you... Optimizing a language for the ease of the compiler writer is like saying, sure, that car is expensive to buy, expensive to run, doesn't work well, and tends to kill a lot of people, but it took less time to design! -- Grant Edwards grant.b.edwards Yow! I know things about at TROY DONAHUE that can't gmail.com even be PRINTED!! From benjamin.kaplan at case.edu Wed Jan 5 10:31:25 2011 From: benjamin.kaplan at case.edu (Benjamin Kaplan) Date: Wed, 5 Jan 2011 10:31:25 -0500 Subject: dictionary as attribute of a class... In-Reply-To: References: Message-ID: On Wed, Jan 5, 2011 at 10:07 AM, tinauser wrote: > Hallo list, > here again I have a problem whose solution might be very obvious, but > I really cannot see it: > I have a class having as attribute a dictionary whose keys are names > and values are instance of another class. > This second class has in turn as an attribute a dictionary. > I want a function of the first class that can change value of one of > the second class instance's dictionary. > however I cannot do it without modifying this attribute for ALL the > instance of the second class contained in the first class' dictionary. > What I'm doing wrong? > This is one of the biggest gotchas in Python. Default arguments are only evaluated *once*, when the function/method is declared. Not every time the function is called. Every instance of mistClass that didn't specify a separate cDict gets the same object as its cDict. The solution is to use a sentinel value (either None or a single object and use an "is" comparison) and create a new dict in the constructor if the default argument is still the sentinel. > class mistClass(): > ? ?def __init__(self,name,cDict={}): > ? ? ? ?print 'mistClass ',name,' Init' > ? ? ? ?self._name=name > ? ? ? ?self._cDict=cDict > should be changed to sentinel = object() class mistClass : def __init__(self, name, cDict=sentinel) : print 'mistClass ',name,' Init' self._name=name if cDict is not sentinel : self._cDict=cDict else : self._cDict = {} > class mistClassContainer(): > ? ?def __init__(self,name,dict_of_mistclass={}): > ? ? ? ?print 'init mistClassContainer ',name > ? ? ? ?self._name=name > ? ? ? ?self._DOM=dict_of_mistclass > and do the same thing with this one. From __peter__ at web.de Wed Jan 5 10:34:34 2011 From: __peter__ at web.de (Peter Otten) Date: Wed, 05 Jan 2011 16:34:34 +0100 Subject: dictionary as attribute of a class... References: Message-ID: tinauser wrote: > Hallo list, > here again I have a problem whose solution might be very obvious, but > I really cannot see it: > I have a class having as attribute a dictionary whose keys are names > and values are instance of another class. > This second class has in turn as an attribute a dictionary. > I want a function of the first class that can change value of one of > the second class instance's dictionary. > however I cannot do it without modifying this attribute for ALL the > instance of the second class contained in the first class' dictionary. > What I'm doing wrong? > > the code: > > ############### > ###can i change a dictionary attribute of an instantated object > without affectin all the instances of that object? > > class mistClass(): > def __init__(self,name,cDict={}): When you don't provide a cDict argument the default is used which is the same for every instance. Change the above to def __init__(self, name, cDict=None): if cDict is None: cDict = {} > class mistClassContainer(): > def __init__(self,name,dict_of_mistclass={}): Same here. > def setName(self,n): > self._name=n > > def getName(self): > return self._name Python has properties, so you don't need this just-in-case getter/setter nonsense. > for k,v in zip(listK,listV): > self._cDict[k]=v Make that self._cDict.update(zip(listK, listV)) By the way, not everyone loves Hungarian notation... From tinauser at libero.it Wed Jan 5 10:44:16 2011 From: tinauser at libero.it (tinauser) Date: Wed, 5 Jan 2011 07:44:16 -0800 (PST) Subject: dictionary as attribute of a class... References: Message-ID: On Jan 5, 4:34?pm, Peter Otten <__pete... at web.de> wrote: > tinauser wrote: > > Hallo list, > > here again I have a problem whose solution might be very obvious, but > > I really cannot see it: > > I have a class having as attribute a dictionary whose keys are names > > and values are instance of another class. > > This second class has in turn as an attribute a dictionary. > > I want a function of the first class that can change value of one of > > the second class instance's dictionary. > > however I cannot do it without modifying this attribute for ALL the > > instance of the second class contained in the first class' dictionary. > > What I'm doing wrong? > > > the code: > > > ############### > > ###can i change a dictionary attribute of an instantated object > > without affectin all the instances of that object? > > > class mistClass(): > > ? ? def __init__(self,name,cDict={}): > > When you don't provide a cDict argument the default is used which is the > same for every instance. Change the above to > > def __init__(self, name, cDict=None): > ? ? if cDict is None: > ? ? ? ? cDict = {} > > > class mistClassContainer(): > > ? ? def __init__(self,name,dict_of_mistclass={}): > > Same here. > > > ? ? def setName(self,n): > > ? ? ? ? self._name=n > > > ? ? def getName(self): > > ? ? ? ? return self._name > > Python has properties, so you don't need this just-in-case getter/setter > nonsense. > > > ? ? ? ? for k,v in zip(listK,listV): > > ? ? ? ? ? ? self._cDict[k]=v > > Make that > > self._cDict.update(zip(listK, listV)) > > By the way, not everyone loves Hungarian notation... Thanks both for the reply, I'll take some time to digest so to avoid further error in the future.Thanks again. From neilc at norwich.edu Wed Jan 5 11:15:15 2011 From: neilc at norwich.edu (Neil Cerutti) Date: 5 Jan 2011 16:15:15 GMT Subject: Trying to decide between PHP and Python References: <4D23A29D.7030104@yahoo.com> Message-ID: <8ojjojFdloU1@mid.individual.net> On 2011-01-05, Grant Edwards wrote: > Optimizing a language for the ease of the compiler writer is > like saying, sure, that car is expensive to buy, expensive to > run, doesn't work well, and tends to kill a lot of people, but > it took less time to design! A simple to parse syntax has non-trivial benefits. It makes a macro system feasible. -- Neil Cerutti From neilc at norwich.edu Wed Jan 5 11:26:14 2011 From: neilc at norwich.edu (Neil Cerutti) Date: 5 Jan 2011 16:26:14 GMT Subject: Which coding style is better? public API or private method inside class definition References: <0470dc9d-2a5f-40d4-afd4-97796059ba0a@q8g2000prm.googlegroups.com> Message-ID: <8ojkd6FdloU2@mid.individual.net> On 2011-01-05, Inyeol wrote: > For example: I'm writing simple class: > > class Numbers: > def __init__(self, numbers): > self._numbers = numbers > def get_all(self): > for number in self._numbers: > yield number > > If I want to add another method for yielding even numbers only, > I may use: > > def get_even(self): > for numbers in self._numbers: > if numbers % 2 == 0: > yield number > > or, I can use public method 'get_all' instead of using private > attribute '_numbers', like: > > def get_even(self): > for numbers in self.get_all(): > if numbers % 2 == 0: > yield number > > Which coding style do you prefer? I'm more toward public API > way, since it requires less code change if I refactor private > data structure later. Plz give pros and cons of these. Decoupling a member function from its own internal state would be of little benefit. However, decoupling an interface from its implementation can be a good idea. Python provides inheritance and the NotImplmented exception to help with that. Duck-typing is another popular approach. -- Neil Cerutti From eric.frederich at gmail.com Wed Jan 5 11:27:02 2011 From: eric.frederich at gmail.com (Eric Frederich) Date: Wed, 5 Jan 2011 11:27:02 -0500 Subject: Creating custom Python objects from C code Message-ID: I have read through all the documentation here: http://docs.python.org/extending/newtypes.html I have not seen any documentation anywhere else explaining how to create custom defined objects from C. I have this need to create custom objects from C and pass them as arguments to a function call. Question 1: how am I to create those objects from C code? The other thing I would like to know is how I can create helper functions in my extension so they can be created and manipulated easily. I am thinking along the lines of the built-in helper functions PyList_New and PyList_Append. Once I have an answer to question 1, the problem won't be creating the helper functions, but making them available from something built with distutils. To use the builtin python functions from C I need to link against python27.lib but when I create my own package using distutils it creates dll or pyd files. Question 2: How do I make C helper functions that are part of my extension available to other C projects in the same way that PyList_*, PyString_*, PyInt_* functions are available? Is it possible to have distutils make a .lib file for me? Thanks, ~Eric From rtomek at ceti.com.pl Wed Jan 5 11:36:29 2011 From: rtomek at ceti.com.pl (Tomasz Rola) Date: Wed, 5 Jan 2011 17:36:29 +0100 Subject: Trying to decide between PHP and Python In-Reply-To: References: <4D23A29D.7030104@yahoo.com> Message-ID: On Wed, 5 Jan 2011, Grant Edwards wrote: > On 2011-01-05, Tomasz Rola wrote: > > On Tue, 4 Jan 2011, Roy Smith wrote: > >> Alan Meyer wrote: > >>> On 1/4/2011 4:22 PM, Google Poster wrote: > >>> > >>>> The syntax reminds me of Lots of Interspersed Silly Parentheses > >>>> (L.I.S.P.), but without the parentheses. > >>> > >>> I haven't heard that version before. The one I heard was: > >>> > >>> "Lots of Irritating Single Parentheses". > >> > >> Long Involved Stupid Parentheses. > > > > Heh. One day, guys, when you have nothing better to do, try writing a > > parser for Lisp-like language (Common Lisp, Scheme, whatever). After that, > > do the same with some other language of your preference (Python, Java, > > whatever). Compare time and code spent... > > I've heard that justification many times, but I think it's 200% > specious. > > 1) How often is a compiler for language X written? > > 2) How often is source code written in language X? > > 3) How often is that source code in language X read/modified? > > If you compare those numbers you'll realize that optimizing for case 1 > at the expense of cases 2 & 3 is just plain stupid. You are right here. OTOH, a parser or even a compiler are just nice examples of non-trivial code. IMHO, the more non-trivial task one is trying to perform with a language, the more one appreciates language features that seem nonsense for less trivial programs. While in theory one can do the same job with a shovel and an excavator, in practice one should use the right tool depending on the job. Trying to get a car from a snowdrift with excavator requires a lot of attention and caution. It is easy (even if tiring) task for a man with a shovel. So one could extrapolate from this, that using excavator is ridiculous compared to using shovel. However, building dams or digging mile-long trenches with a shovel is not only ridicule but a sign of bad planning or desperation. And maybe even an incompetence. Now, how often they are building dams, trenches and other nontrivial constructions? I would hypothesise that in a society well developed, this happens quite often. Maybe even once every two days. The truth is, once you have an excavator, you don't shy away from using it and you more often than not are open for doing non-trivial assignments. > Perhaps there is > somebody on the planet who finds Lisp as easy to read/modify as > Python, but I've never met him/her and never have you... Here you are wrong. I meet the guy every day in a mirror. Now you have met him, too. I doubt, however, that I am so extraordinary as to be just one on the whole planet. > Optimizing a language for the ease of the compiler writer is like > saying, sure, that car is expensive to buy, expensive to run, doesn't > work well, and tends to kill a lot of people, but it took less time to > design! I guess every compiled language designed so far has been somewhat optimised for compilation by it's designers. If you say that some language, like Common Lisp, had been optimised for compiler at the expense of human programmer, I disagree. I find programing in CL to be nice experience, maybe even a refreshing one. From what I have read about Lisp history so far, your claims don't match the facts (at least facts as I know them). True, it requires some learning. AFAIK, nobody has to learn, so it is purely voluntary effort. Regards, Tomasz Rola -- ** A C programmer asked whether computer had Buddha's nature. ** ** As the answer, master did "rm -rif" on the programmer's home ** ** directory. And then the C programmer became enlightened... ** ** ** ** Tomasz Rola mailto:tomasz_rola at bigfoot.com ** From solipsis at pitrou.net Wed Jan 5 11:39:00 2011 From: solipsis at pitrou.net (Antoine Pitrou) Date: Wed, 5 Jan 2011 17:39:00 +0100 Subject: Creating custom Python objects from C code References: Message-ID: <20110105173900.4bad877b@pitrou.net> On Wed, 5 Jan 2011 11:27:02 -0500 Eric Frederich wrote: > I have read through all the documentation here: > > http://docs.python.org/extending/newtypes.html > > I have not seen any documentation anywhere else explaining how to > create custom defined objects from C. > I have this need to create custom objects from C and pass them as > arguments to a function call. What do you mean? Create instances of a type defined in Python code? The C API is not very different from Python-land. When you want to instantiate a type, just call that type (as a PyObject pointer) with the right arguments (using PyObject_Call() and friends). Whether that type has been defined in C or in Python does not make a difference. > Question 2: How do I make C helper functions that are part of my > extension available to other C projects in the same way that PyList_*, > PyString_*, PyInt_* functions are available? > Is it possible to have distutils make a .lib file for me? I don't know. I'd say "probably" :S Otherwise you can use the PyCapsule system, but that seems quite a bit more involved: http://docs.python.org/c-api/capsule.html Regards Antoine. From rtomek at ceti.com.pl Wed Jan 5 11:40:23 2011 From: rtomek at ceti.com.pl (Tomasz Rola) Date: Wed, 5 Jan 2011 17:40:23 +0100 Subject: Trying to decide between PHP and Python In-Reply-To: References: <4D23A29D.7030104@yahoo.com> Message-ID: On Tue, 4 Jan 2011, Roy Smith wrote: > There. Now that I've tossed some gasoline on the language wars fire, > I'll duck and run in the other direction :-) May I suggest a better strategy? Run first, duck next :-). Regards, Tomasz Rola -- ** A C programmer asked whether computer had Buddha's nature. ** ** As the answer, master did "rm -rif" on the programmer's home ** ** directory. And then the C programmer became enlightened... ** ** ** ** Tomasz Rola mailto:tomasz_rola at bigfoot.com ** From default at tlen.pl Wed Jan 5 11:59:06 2011 From: default at tlen.pl (Jacek Krysztofik) Date: Wed, 05 Jan 2011 17:59:06 +0100 Subject: Which coding style is better? public API or private method inside class definition In-Reply-To: <0470dc9d-2a5f-40d4-afd4-97796059ba0a@q8g2000prm.googlegroups.com> References: <0470dc9d-2a5f-40d4-afd4-97796059ba0a@q8g2000prm.googlegroups.com> Message-ID: -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 Sorry for OT, but this is actually a question of mine > if numbers % 2 == 0: wouldn't the following be faster? > if numbers & 1 == 0: JK -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iF4EAREIAAYFAk0ko1oACgkQfD3PECtxdkWzPAD+LD32NzjjDm8gb8qVFydIT693 ORuhRaYZOriaf+36/yMBAIREiarQAJ2ZYX8NPyHS2ns22PkEEEAkC98OYf1CkhwK =tg7G -----END PGP SIGNATURE----- From passionate_programmer at hotmail.com Wed Jan 5 12:11:17 2011 From: passionate_programmer at hotmail.com (Rohit Coder) Date: Wed, 5 Jan 2011 22:41:17 +0530 Subject: Qt with PyDev In-Reply-To: <4D233841.9080909@islandtraining.com> References: , <4D233841.9080909@islandtraining.com> Message-ID: Seen both, but do I need to install the binaries or add a link in Pydev to PySide source-code? Date: Tue, 4 Jan 2011 07:09:53 -0800 From: gherron at islandtraining.com To: python-list at python.org Subject: Re: Qt with PyDev On 01/04/2011 12:00 AM, RP Khare wrote: I installed Aptana PyDev plugin to Aptana Studio 3 Beta. I want to write my first GUI application using Python and I want to use Qt for it. How to integrate Qt into PyDev, or is there any other alternative IDE to work with Qt? element Font font-family font-size font-style font-variant font-weight letter-spacing line-height text-decoration text-align text-indent text-transform white-space word-spacing color Background bg-attachment bg-color bg-image bg-position bg-repeat Box width height border-top border-right border-bottom border-left margin padding max-height min-height max-width min-width outline-color outline-style outline-width Positioning position top bottom right left float display clear z-index List list-style-image list-style-type list-style-position Table vertical-align border-collapse border-spacing caption-side empty-cells table-layout Effects text-shadow -webkit-box-shadow border-radius Other overflow cursor visibility ........... Rohit See either of these packages: PyQt: http://qt.nokia.com/products/ PySide: http://www.pyside.org/ Either one should work with PyDev. Gary Herron -- http://mail.python.org/mailman/listinfo/python-list -------------- next part -------------- An HTML attachment was scrubbed... URL: From __peter__ at web.de Wed Jan 5 12:15:31 2011 From: __peter__ at web.de (Peter Otten) Date: Wed, 05 Jan 2011 18:15:31 +0100 Subject: Which coding style is better? public API or private method inside class definition References: <0470dc9d-2a5f-40d4-afd4-97796059ba0a@q8g2000prm.googlegroups.com> Message-ID: Jacek Krysztofik wrote: > Sorry for OT, but this is actually a question of mine >> if numbers % 2 == 0: > wouldn't the following be faster? >> if numbers & 1 == 0: You can answer that and similar questions yourself with the timeit module: $ python -m timeit -s'm, n = 1234, 1235' 'm % 2 == 0; n % 2 == 0' 1000000 loops, best of 3: 0.377 usec per loop $ python -m timeit -s'm, n = 1234, 1235' 'm & 1 == 0; n & 1 == 0' 1000000 loops, best of 3: 0.298 usec per loop So yes, a binary and seems to be faster. From python at mrabarnett.plus.com Wed Jan 5 12:26:05 2011 From: python at mrabarnett.plus.com (MRAB) Date: Wed, 05 Jan 2011 17:26:05 +0000 Subject: Trying to decide between PHP and Python In-Reply-To: References: Message-ID: <4D24A9AD.5030003@mrabarnett.plus.com> On 05/01/2011 10:44, Nobody wrote: > On Tue, 04 Jan 2011 12:20:42 -0800, Google Poster wrote: > >> The indentation-as-block is unique, > > Not at all. It's also used in occam, Miranda, Haskell and F#. > Don't forget about ABC. From benjamin.kaplan at case.edu Wed Jan 5 12:27:05 2011 From: benjamin.kaplan at case.edu (Benjamin Kaplan) Date: Wed, 5 Jan 2011 12:27:05 -0500 Subject: Qt with PyDev In-Reply-To: References: <4D233841.9080909@islandtraining.com> Message-ID: On Jan 5, 2011 12:15 PM, "Rohit Coder" wrote: > > Seen both, but do I need to install the binaries or add a link in Pydev to PySide source-code? > You need to install the binaries. Doing that will put the pyside libraries in a location where Python and Pydev can find them automatically. > ________________________________ > Date: Tue, 4 Jan 2011 07:09:53 -0800 > From: gherron at islandtraining.com > To: python-list at python.org > Subject: Re: Qt with PyDev > > > On 01/04/2011 12:00 AM, RP Khare wrote: >> >> I installed Aptana PyDev plugin to Aptana Studio 3 Beta. I want to write my first GUI application using Python and I want to use Qt for it. How to integrate Qt into PyDev, or is there any other alternative IDE to work with Qt? >> element >> Font >> font-family >> font-size >> font-style >> font-variant >> font-weight >> letter-spacing >> line-height >> text-decoration >> text-align >> text-indent >> text-transform >> white-space >> word-spacing >> color >> Background >> bg-attachment >> bg-color >> bg-image >> bg-position >> bg-repeat >> Box >> width >> height >> border-top >> border-right >> border-bottom >> border-left >> margin >> padding >> max-height >> min-height >> max-width >> min-width >> outline-color >> outline-style >> outline-width >> Positioning >> position >> top >> bottom >> right >> left >> float >> display >> clear >> z-index >> List >> list-style-image >> list-style-type >> list-style-position >> Table >> vertical-align >> border-collapse >> border-spacing >> caption-side >> empty-cells >> table-layout >> Effects >> text-shadow >> -webkit-box-shadow >> border-radius >> Other >> overflow >> cursor >> visibility >> >> ........... >> Rohit > > > See either of these packages: > PyQt: http://qt.nokia.com/products/ > PySide: http://www.pyside.org/ > > Either one should work with PyDev. > > Gary Herron > > > > -- http://mail.python.org/mailman/listinfo/python-list > > -- > http://mail.python.org/mailman/listinfo/python-list > -------------- next part -------------- An HTML attachment was scrubbed... URL: From no.email at nospam.invalid Wed Jan 5 12:44:40 2011 From: no.email at nospam.invalid (Paul Rubin) Date: Wed, 05 Jan 2011 09:44:40 -0800 Subject: Which coding style is better? public API or private method inside class definition References: <0470dc9d-2a5f-40d4-afd4-97796059ba0a@q8g2000prm.googlegroups.com> Message-ID: <7xy66zz1mf.fsf@ruckus.brouhaha.com> Inyeol writes: > def get_all(self): > for number in self._numbers: > yield number I think def get_all(self): return iter(self._numbers) is more direct. From nambo4jb at gmail.com Wed Jan 5 12:57:15 2011 From: nambo4jb at gmail.com (Cathy James) Date: Wed, 5 Jan 2011 11:57:15 -0600 Subject: Help with code-lists and strings Message-ID: Dear all, You folks will probably hear from me more often in the next few months. I hope some of you have time help me on occassion. Actually, a volunteer mentor would be greatly appreciated:) I am learning python and came across an excercise where i need to use lists to strip words from a sentence; starting with those containing one or more uppercase letters, followed by words with lower case letters. When I try, i get words in the order they were written:(* *I tried if statements, but unsuccessful. This has to be very easy to you experts, but I am clueless ( still rocket science to me) :( #Below is my shot at it: s=input("Write a sentence: ") list=s.strip().split() for word in list: list2 = (word.isupper() or word.istitle()) print (word) else print (word) -------------- next part -------------- An HTML attachment was scrubbed... URL: From miki.tebeka at gmail.com Wed Jan 5 13:15:05 2011 From: miki.tebeka at gmail.com (Miki) Date: Wed, 5 Jan 2011 10:15:05 -0800 (PST) Subject: Just Starting in on programming In-Reply-To: <2c19b70f-917f-449c-9c6d-51f07cd769c5@glegroupsg2000goo.googlegroups.com> Message-ID: <5bb4e2a8-2294-42bc-87ef-b2eb31908dc1@glegroupsg2000goo.googlegroups.com> http://www.openbookproject.net/thinkCSpy/ ? From Rob.Richardson at rad-con.com Wed Jan 5 13:20:39 2011 From: Rob.Richardson at rad-con.com (Rob Richardson) Date: Wed, 5 Jan 2011 13:20:39 -0500 Subject: Help with code-lists and strings In-Reply-To: Message-ID: <04A6DB42D2BA534FAC77B90562A6A03D01689A2B@server.rad-con.local> You take a sentence and break it up into words, storing it in a list named "list". Then, for each word in the list, you set list2 to a boolean value of true or false, depending on the result of isupper() and istitle(). Note that the variable "list2" does not refer to a list. It refers to whatever the result of the "or" operation is. Finally, you print out the word from the original, unordered list. You never do anything at all with list2. At least, that what I think is happening, but I am by no means a Python expert. Here's a suggestion: Try writing out what you want to do in plain English, but formatted sort of like a Python script would be. (This is generally called "pseudocode". It looks like a computer language, but it isn't.) Once you've got that, use it as a framework to write your Python code. Good luck! RobR ________________________________ From: python-list-bounces+rob.richardson=rad-con.com at python.org [mailto:python-list-bounces+rob.richardson=rad-con.com at python.org] On Behalf Of Cathy James Sent: Wednesday, January 05, 2011 12:57 PM To: python-list at python.org Subject: Help with code-lists and strings Dear all, You folks will probably hear from me more often in the next few months. I hope some of you have time help me on occassion. Actually, a volunteer mentor would be greatly appreciated:) I am learning python and came across an excercise where i need to use lists to strip words from a sentence; starting with those containing one or more uppercase letters, followed by words with lower case letters. When I try, i get words in the order they were written:( I tried if statements, but unsuccessful. This has to be very easy to you experts, but I am clueless ( still rocket science to me) :( #Below is my shot at it: s=input("Write a sentence: ") list=s.strip().split() for word in list: list2 = (word.isupper() or word.istitle()) print (word) else print (word) -------------- next part -------------- An HTML attachment was scrubbed... URL: From stefan_ml at behnel.de Wed Jan 5 13:42:06 2011 From: stefan_ml at behnel.de (Stefan Behnel) Date: Wed, 05 Jan 2011 19:42:06 +0100 Subject: Creating custom Python objects from C code In-Reply-To: References: Message-ID: Eric Frederich, 05.01.2011 17:27: > I have read through all the documentation here: > > http://docs.python.org/extending/newtypes.html > > I have not seen any documentation anywhere else explaining how to > create custom defined objects from C. At this point, it is best to take a look at Cython *before* continuing your struggle to solve problems that you wouldn't even have become aware of if you had used it right away. > I have this need to create custom objects from C and pass them as > arguments to a function call. > > Question 1: how am I to create those objects from C code? In Cython: obj = SomeType() or (in some truly performance critical cases): obj = SomeType.__new__(SomeType) > The other thing I would like to know is how I can create helper > functions in my extension so they can be created and manipulated > easily. Either functions or static methods would work here. It's up to you to make a suitable design choice. > I am thinking along the lines of the built-in helper functions > PyList_New and PyList_Append. > Once I have an answer to question 1, the problem won't be creating the > helper functions, but making them available from something built with > distutils. > To use the builtin python functions from C I need to link against > python27.lib but when I create my own package using distutils it > creates dll or pyd files. Cython has an embedding mode ("--embed" option) that generates a suitable main() function to embed the Python interpreter in your module. That might work for you as is, or it will at least show you the required C code that you can adapt as you see fit. > Question 2: How do I make C helper functions that are part of my > extension available to other C projects in the same way that PyList_*, > PyString_*, PyInt_* functions are available? Cython allows you to mark C functions and Python extension types with the "api" keyword and generates suitable header files and import/export code for them that you can use both from C and from other Cython generated modules. It automatically uses PyCObject in older Python versions and PyCapsule in Py2.7 and Py3.1+. Stefan From tjreedy at udel.edu Wed Jan 5 14:58:05 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Wed, 05 Jan 2011 14:58:05 -0500 Subject: Help with code-lists and strings In-Reply-To: References: Message-ID: On 1/5/2011 12:57 PM, Cathy James wrote: > I am learning python and came across an excercise where i need to use > lists to strip words from a sentence; starting with those containing one > or more uppercase letters, followed by words with lower case letters. When writing code, it is good to start with one or more input-output pairs that constitute a test. For example, what, exactly, do you want to result from "Some special words are ALLCAPS, TitleCase, and MIXed." It is also good to think about all relevant cases. Note the following: >>> 'MIXed'.isupper() or 'MIXed'.istitle() False Do you want punctuation stripped off words? You might skip that at first. -- Terry Jan Reedy From drsalists at gmail.com Wed Jan 5 15:02:13 2011 From: drsalists at gmail.com (Dan Stromberg) Date: Wed, 5 Jan 2011 12:02:13 -0800 Subject: Matrix multiplication In-Reply-To: References: Message-ID: On Tue, Jan 4, 2011 at 11:31 PM, Tim Roberts wrote: > Zdenko wrote: >> >>Please, can anybody write me a simple recursive matrix multiplication >>using multiple threads in Python, or at least show me some guidelines >>how to write it myself > > Matrix multiplication is not generally done recursively. ?There's no > conceptual gain. ?It makes more sense iteratively. It may not be that common, but there is at least one significant advantage: Cache obliviousness. http://www.catonmat.net/blog/mit-introduction-to-algorithms-part-fourteen From rurpy at yahoo.com Wed Jan 5 15:10:02 2011 From: rurpy at yahoo.com (rurpy at yahoo.com) Date: Wed, 5 Jan 2011 12:10:02 -0800 (PST) Subject: opinion: comp lang docs style References: <98e82f1b-cf59-4e64-8fd4-63671f96b04f@r19g2000prm.googlegroups.com> <4745479a-10c5-4281-9dcd-c9d7b013a1ec@k13g2000vbq.googlegroups.com> <4d240fca$0$29969$c3e8da3$5496439d@news.astraweb.com> Message-ID: <541fb01b-7c88-4bd9-814c-f921c591c2af@o14g2000yqe.googlegroups.com> On 01/04/2011 11:29 PM, Steven D'Aprano wrote: > On Tue, 04 Jan 2011 15:17:37 -0800, rurpy at yahoo.com wrote: > >>> If one wants to critique the 'Python Docs', especially as regards to >>> usefulness to beginners, one must start with the Tutorial; and if one >>> wants to use if statements as an example, one must start with the >>> above. >> >> No. The language reference (LR) and standard library reference (SLR) >> must stand on their own merits. It is nice to have a good tutorial for >> those who like that style of learning. But it should be possible for a >> programmer with a basic understanding of computers and some other >> programming languages to understand how to program in python without >> referring to tutorials, explanatory websites, commercially published >> books, the source code, etc. > > No it shouldn't. That's what the tutorial is for. The language reference > and standard library reference are there to be reference manuals, not to > teach beginners Python. Yes it should. That's not what the tutorial is for. The (any) tutorial is for people new to python, often new to programming, who have the time and a learning style suitable for sitting down and going through a slow step-by-step exposition, much as one would get in a classroom. That is a perfectly valid way for someone in that target audience to learn python. Your (and Terry's) mistake is to presume that it is appropriate for everyone, perhaps because it worked for you personally. There is a large class of potential python users for whom a tutorial is highly suboptimal -- people who have some significant programming experience, who don't have the time or patience required to go through it getting information serially bit by bit, or whos learning style is, "don't spoon feed me, just tell me concisely what python does", who fill in gaps on a need-to-know basis rather than linearly. I (and many others) don't need or want an explanation of how to use lists as a stack! A language reference manual should completely and accurately describe the language it documents. (That seems fairly obvious to me although there will be differing opinions of how precise one needs to be, etc.) Once it meets that minimum standard, it's quality is defined by how effectively it transfers that information to its target audience. A good reference manual meets the learning needs of the target audience above admirably. I learned Perl (reputedly more difficult to learn than Python) from the Perl manpages and used it for many many years before I ever bought a Perl book. I learned C mostly from Harbison and Steele's "C: A Reference". Despite several attempts at python using its reference docs, I never got a handle on it until I forked out money for Beazley's book. There is obviously nothing inherently "difficult" about python -- it's just that python's reference docs are written for people who already know python. Since limiting their scope that narrowly is not necessary, as other languages show, it is fair to say that python's reference docs are poorer. > In any case, your assumption that any one documentation work should stand > on its own merits is nonsense -- *nothing* stands alone. Everything > builds on something else. Technical documentation is no different: it > *must* assume some level of knowledge of its readers -- should it be > aimed at Python experts, or average Python coders, or beginners, or > beginners to programming, or at the very least is it allowed to assume > that the reader already knows how to read? > > You can't satisfy all of these groups with one document, because their > needs are different and in conflict. This is why you have different > documentation -- tutorials and reference manuals and literate source code > and help text are all aimed at different audiences. Expecting one > document to be useful for all readers' needs is like expecting one data > type to be useful for all programming tasks. I defined (roughly) the target audience I was talking about when I wrote "for a programmer with a basic understanding of computers and some other programming languages". Let's dispense with the 6th-grade arguments about people who don't know how to read, etc. > Reasonable people might disagree on what a particular documentation work > should target, and the best way to target it, but not on the need for > different documentation for different targets. As I hope I clarified above, that was exactly my point too. There is a significant, unsatisfied gap between the audience that a tutorial aims at, and the audience that the reference docs as currently written seem to be aimed at. Since other language manuals incorporate this gap audience more or less sucessfully in their reference manuals, python's failure to do so is justification for calling them poor. (Of course they are poor in lots of other ways too but my original response was prompted by the erroneous claim that good (in my sense above) reference manuals were unnecessary because a tutorial exists.) From rurpy at yahoo.com Wed Jan 5 15:15:28 2011 From: rurpy at yahoo.com (rurpy at yahoo.com) Date: Wed, 5 Jan 2011 12:15:28 -0800 (PST) Subject: opinion: comp lang docs style References: <98e82f1b-cf59-4e64-8fd4-63671f96b04f@r19g2000prm.googlegroups.com> <4745479a-10c5-4281-9dcd-c9d7b013a1ec@k13g2000vbq.googlegroups.com> <4d240fca$0$29969$c3e8da3$5496439d@news.astraweb.com> Message-ID: On 01/05/2011 12:23 AM, Alice Bevan?McGregor wrote: > > On 2011-01-04 22:29:31 -0800, Steven D'Aprano said: > > >> >> In any case, your assumption that any one documentation work should stand >> >> on its own merits is nonsense -- *nothing* stands alone. > > > > +1 I responded more fully in my response to Steven but you like he is taking "stand on it's own merits" out of context. The context I gave was someone who wants a complete and accurate description of python and who understands programming with other languages but not python. > > How many RFCs still in use today don't start with: > > >> >> The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", >> >> "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this >> >> document are to be interpreted as described in RFC 2119 RFC 2119 is incorporated in the others by reference. It is purely a matter of technical convenience that those definitions, which are common to hundreds of RFCs, are factored out to a single common location. RFC 2119 is not a tutorial. > > I posted a response on the article itself, rather than pollute a > > mailing list with replies to a troll. The name calling was a rather > > large hint as to the intention of the "opinion", either that or whoever > > translated the article (man or machine) was really angry at the time. > > ;) I can hint to my neighbor that his stereo is too loud by throwing a brick through his window. Neither that nor calling people arrogant ignoramus is acceptable in polite society. I am not naive, nor not shocked that c.l.p is not always polite, and normally would not have even commented on it except that 1) Terry Reedy is usually more polite and thoughtful, and 2) Xah Lee's post was not a troll -- it was a legitimate comment on free software documentation (including specifically python's) and while I don't agree with some of his particulars, the Python docs would be improved if some of his comments were considered rather than dismissed with mindless epithets like troll and arrogant ignoramus. From eric.frederich at gmail.com Wed Jan 5 15:46:44 2011 From: eric.frederich at gmail.com (Eric Frederich) Date: Wed, 5 Jan 2011 15:46:44 -0500 Subject: Creating custom Python objects from C code In-Reply-To: <20110105173900.4bad877b@pitrou.net> References: <20110105173900.4bad877b@pitrou.net> Message-ID: On Wed, Jan 5, 2011 at 11:39 AM, Antoine Pitrou wrote: > On Wed, 5 Jan 2011 11:27:02 -0500 > Eric Frederich wrote: >> I have read through all the documentation here: >> >> ? ? http://docs.python.org/extending/newtypes.html >> >> I have not seen any documentation anywhere else explaining how to >> create custom defined objects from C. >> I have this need to create custom objects from C and pass them as >> arguments to a function call. > > What do you mean? Create instances of a type defined in Python code? > > The C API is not very different from Python-land. When you want to > instantiate a type, just call that type (as a PyObject pointer) with the > right arguments (using PyObject_Call() and friends). Whether that type > has been defined in C or in Python does not make a difference. No, the custom types are defined in C. I need to create the objects in C. I need to pass those custom C objects created in C to a python function via PyObject_CallObject(pFunc, pArgs). From passionate_programmer at hotmail.com Wed Jan 5 16:21:18 2011 From: passionate_programmer at hotmail.com (Rohit Coder) Date: Thu, 6 Jan 2011 02:51:18 +0530 Subject: Attaching C++ libraries to Python app. Message-ID: Is it possible to use C++ libraries within a Python application? I am planning to write an encryption program and want to use GnuPG C++ libraries.elementFontfont-familyfont-sizefont-stylefont-variantfont-weightletter-spacingline-heighttext-decorationtext-aligntext-indenttext-transformwhite-spaceword-spacingcolorBackgroundbg-attachmentbg-colorbg-imagebg-positionbg-repeatBoxwidthheightborder-topborder-rightborder-bottomborder-leftmarginpaddingmax-heightmin-heightmax-widthmin-widthoutline-coloroutline-styleoutline-widthPositioningpositiontopbottomrightleftfloatdisplayclearz-indexListlist-style-imagelist-style-typelist-style-positionTablevertical-alignborder-collapseborder-spacingcaption-sideempty-cellstable-layoutEffectstext-shadow-webkit-box-shadowborder-radiusOtheroverflowcursorvisibility ...................................................Rohit. -------------- next part -------------- An HTML attachment was scrubbed... URL: From stackslip at gmail.com Wed Jan 5 16:30:51 2011 From: stackslip at gmail.com (Slie) Date: Wed, 5 Jan 2011 12:30:51 -0900 Subject: Graphing API, In-Reply-To: References: Message-ID: <184DF132-C405-4276-ABED-E518DE21AD88@gmail.com> Thank you, I will defiantly look into that. On Jan 5, 2011, at 4:32 AM, Tim Harig wrote: > On 2011-01-05, Slie wrote: >> Is there a graphing API, someone suggests? > > You should check the archives, variations of this question get asked > a lot. > > I use GNUplot to do my graphing. I simply pipe it commands and data > through the subprocess module; but, there are libraries available for > interacting with it. > > Posts here also indicate that Google offers a web service based API for > generating graphs. I have never actually used it; but, the documentation > seems to be clear enough to get it working without too much trouble. > -- > http://mail.python.org/mailman/listinfo/python-list From clp2 at rebertia.com Wed Jan 5 16:42:48 2011 From: clp2 at rebertia.com (Chris Rebert) Date: Wed, 5 Jan 2011 13:42:48 -0800 Subject: Trying to decide between PHP and Python In-Reply-To: <4D24A9AD.5030003@mrabarnett.plus.com> References: <4D24A9AD.5030003@mrabarnett.plus.com> Message-ID: On Wed, Jan 5, 2011 at 9:26 AM, MRAB wrote: > On 05/01/2011 10:44, Nobody wrote: >> >> On Tue, 04 Jan 2011 12:20:42 -0800, Google Poster wrote: >> >>> The indentation-as-block is unique, >> >> Not at all. It's also used in occam, Miranda, Haskell and F#. >> > Don't forget about ABC. Just to round out the list: ISWIM ("invented" the concept) Boo (via Python heritage) Cobra (via Python heritage) BuddyScript Curry Genie Nemerle (not by default) Pliant PROMAL Spin XL Source: http://en.wikipedia.org/wiki/Off-side_rule Cheers, Chris From stefan.sonnenberg at pythonmeister.com Wed Jan 5 16:44:15 2011 From: stefan.sonnenberg at pythonmeister.com (Stefan Sonnenberg-Carstens) Date: Wed, 5 Jan 2011 22:44:15 +0100 Subject: Attaching C++ libraries to Python app. In-Reply-To: References: Message-ID: You don't need to reinvent the wheel: http://www.dlitz.net/software/pycrypto/ Am Mi, 5.01.2011, 22:21 schrieb Rohit Coder: > > Is it possible to use C++ libraries within a Python application? I am > planning to write an encryption program and want to use GnuPG C++ > libraries.elementFontfont-familyfont-sizefont-stylefont-variantfont-weightletter-spacingline-heighttext-decorationtext-aligntext-indenttext-transformwhite-spaceword-spacingcolorBackgroundbg-attachmentbg-colorbg-imagebg-positionbg-repeatBoxwidthheightborder-topborder-rightborder-bottomborder-leftmarginpaddingmax-heightmin-heightmax-widthmin-widthoutline-coloroutline-styleoutline-widthPositioningpositiontopbottomrightleftfloatdisplayclearz-indexListlist-style-imagelist-style-typelist-style-positionTablevertical-alignborder-collapseborder-spacingcaption-sideempty-cellstable-layoutEffectstext-shadow-webkit-box-shadowborder-radiusOtheroverflowcursorvisibility > ...................................................Rohit. -- > http://mail.python.org/mailman/listinfo/python-list > -- MfG, Stefan Sonnenberg-Carstens IT Architect From emile at fenx.com Wed Jan 5 17:16:55 2011 From: emile at fenx.com (Emile van Sebille) Date: Wed, 05 Jan 2011 14:16:55 -0800 Subject: opinion: comp lang docs style In-Reply-To: <541fb01b-7c88-4bd9-814c-f921c591c2af@o14g2000yqe.googlegroups.com> References: <98e82f1b-cf59-4e64-8fd4-63671f96b04f@r19g2000prm.googlegroups.com> <4745479a-10c5-4281-9dcd-c9d7b013a1ec@k13g2000vbq.googlegroups.com> <4d240fca$0$29969$c3e8da3$5496439d@news.astraweb.com> <541fb01b-7c88-4bd9-814c-f921c591c2af@o14g2000yqe.googlegroups.com> Message-ID: On 1/5/2011 12:10 PM rurpy at yahoo.com said... > A language reference manual should completely and accurately > describe the language it documents. (That seems fairly obvious > to me although there will be differing opinions of how precise > one needs to be, etc.) Once it meets that minimum standard, > it's quality is defined by how effectively it transfers that > information to its target audience. A good reference manual > meets the learning needs of the target audience above admirably. > > I learned Perl (reputedly more difficult to learn than Python) > from the Perl manpages and used it for many many years before > I ever bought a Perl book. I learned C mostly from Harbison > and Steele's "C: A Reference". Despite several attempts at > python using its reference docs, I never got a handle on > it until I forked out money for Beazley's book. Hmm... I suspect most of us with prior programming experience simply worked the tutorial and immediately put python into play, digging deeper as necessary. Further, absolute beginners at programming are not likely to learn programming from a man page, nor should anyone expect the tutorial to be sufficient for their needs. I agree that as far as the specific details around the edges and corner cases go, it would be nice to have a single reference that provides those answers at the level you need (ala postscript's redbook imo), but I find this group serves well to fill the gaps when I can't easily find what I need. Emile From robert.kern at gmail.com Wed Jan 5 17:17:01 2011 From: robert.kern at gmail.com (Robert Kern) Date: Wed, 05 Jan 2011 16:17:01 -0600 Subject: Attaching C++ libraries to Python app. In-Reply-To: References: Message-ID: On 1/5/11 3:44 PM, Stefan Sonnenberg-Carstens wrote: > Am Mi, 5.01.2011, 22:21 schrieb Rohit Coder: >> >> Is it possible to use C++ libraries within a Python application? I am >> planning to write an encryption program and want to use GnuPG C++ > > You don't need to reinvent the wheel: > > http://www.dlitz.net/software/pycrypto/ Wrong wheel. http://pyme.sourceforge.net/ -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco From passionate_programmer at hotmail.com Wed Jan 5 17:44:44 2011 From: passionate_programmer at hotmail.com (Rohit Coder) Date: Thu, 6 Jan 2011 04:14:44 +0530 Subject: Attaching C++ libraries to Python app. In-Reply-To: References: , Message-ID: I am just asking. In future I may need to import any C++ library, not a Crypto, but some other. Is it possible? > Date: Wed, 5 Jan 2011 22:44:15 +0100 > Subject: Re: Attaching C++ libraries to Python app. > From: stefan.sonnenberg at pythonmeister.com > To: passionate_programmer at hotmail.com > CC: python-list at python.org > > You don't need to reinvent the wheel: > > http://www.dlitz.net/software/pycrypto/ > > Am Mi, 5.01.2011, 22:21 schrieb Rohit Coder: > > > > Is it possible to use C++ libraries within a Python application? I am > > planning to write an encryption program and want to use GnuPG C++ > > libraries.elementFontfont-familyfont-sizefont-stylefont-variantfont-weightletter-spacingline-heighttext-decorationtext-aligntext-indenttext-transformwhite-spaceword-spacingcolorBackgroundbg-attachmentbg-colorbg-imagebg-positionbg-repeatBoxwidthheightborder-topborder-rightborder-bottomborder-leftmarginpaddingmax-heightmin-heightmax-widthmin-widthoutline-coloroutline-styleoutline-widthPositioningpositiontopbottomrightleftfloatdisplayclearz-indexListlist-style-imagelist-style-typelist-style-positionTablevertical-alignborder-collapseborder-spacingcaption-sideempty-cellstable-layoutEffectstext-shadow-webkit-box-shadowborder-radiusOtheroverflowcursorvisibility > > ...................................................Rohit. -- > > http://mail.python.org/mailman/listinfo/python-list > > > > > -- > MfG, > > Stefan Sonnenberg-Carstens > > IT Architect elementFontfont-familyfont-sizefont-stylefont-variantfont-weightletter-spacingline-heighttext-decorationtext-aligntext-indenttext-transformwhite-spaceword-spacingcolorBackgroundbg-attachmentbg-colorbg-imagebg-positionbg-repeatBoxwidthheightborder-topborder-rightborder-bottomborder-leftmarginpaddingmax-heightmin-heightmax-widthmin-widthoutline-coloroutline-styleoutline-widthPositioningpositiontopbottomrightleftfloatdisplayclearz-indexListlist-style-imagelist-style-typelist-style-positionTablevertical-alignborder-collapseborder-spacingcaption-sideempty-cellstable-layoutEffectstext-shadow-webkit-box-shadowborder-radiusOtheroverflowcursorvisibility -------------- next part -------------- An HTML attachment was scrubbed... URL: From alice at gothcandy.com Wed Jan 5 17:56:15 2011 From: alice at gothcandy.com (=?utf-8?Q?Alice_Bevan=E2=80=93McGregor?=) Date: Wed, 5 Jan 2011 14:56:15 -0800 Subject: Streaming templating languages for use as WSGI body. Message-ID: Howdy! I'm trying to find a templating engine whose templates can be consumed directly as a WSGI response body iterable. So far I haven't been very successful with Google; the engines I've found universally generate a monolithic rendered string. Bonus points for templating engines that support flush() mechanics internally to allow developer-chosen 'break points' in the iterable. Bonus points++ if it can somehow calculate the response body length without generating the whole thing monolithically. ;) - Alice. From howe.steven at gmail.com Wed Jan 5 17:56:40 2011 From: howe.steven at gmail.com (GrayShark) Date: Wed, 05 Jan 2011 16:56:40 -0600 Subject: Help with code-lists and strings References: Message-ID: On Wed, 05 Jan 2011 14:58:05 -0500, Terry Reedy wrote: > On 1/5/2011 12:57 PM, Cathy James wrote: > >> I am learning python and came across an excercise where i need to use >> lists to strip words from a sentence; starting with those containing >> one or more uppercase letters, followed by words with lower case >> letters. > > When writing code, it is good to start with one or more input-output > pairs that constitute a test. For example, what, exactly, do you want to > result from > "Some special words are ALLCAPS, TitleCase, and MIXed." > > It is also good to think about all relevant cases. Note the following: > >>> 'MIXed'.isupper() or 'MIXed'.istitle() > False > > Do you want punctuation stripped off words? You might skip that at > first. In python it's best to build up you functional needs. So two steps. First a nand (negative 'and' operation). Then wrap that with a function to create two strings of your list element, you''re calling 'word'. By the way, list is reserved word, like string. Don't get in the bad habit of using it. def nand( a, b ): """nand has to vars. Both must be strings """ return( ( not eval( a ) ) and ( not eval( b ) ) ) Eval of 'Abcd'.isupper() returns False. Ditto 'Abcd'.islower(); negate both results, 'and' values, return. Now wrap 'nand' in packaging an you're cooking with grease. def mixed_case( str ): return nand( "'%s'.islower()" % str , "'%s'.isupper()" % str ) or if that's too advanced/compact, try ... def mixed_case( str ): # nand() needs strings a = "'%s'.isupper()" % str b = "'%s'.islower()" % str res = nand( a, b ) return res >>> mixed_case('Abcd' ) True >>> mixed_case('ABCD' ) False >>> mixed_case('abcd' ) False Good luck Steven Howe From kanthony at woh.rr.com Wed Jan 5 18:12:13 2011 From: kanthony at woh.rr.com (kanthony at woh.rr.com) Date: Wed, 05 Jan 2011 17:12:13 -0600 Subject: Help with a Python coding question Message-ID: <44CdnVDzP-NQZ7nQnZ2dnUVZ_h-dnZ2d@giganews.com> I want to use Python to find all "\n" terminated strings in a PDF file, ideally returning string starting addresses. Anyone willing to help? -- --------------------------------- --- -- - Posted with NewsLeecher v4.0 Final Web @ http://www.newsleecher.com/?usenet ------------------- ----- ---- -- - From emile at fenx.com Wed Jan 5 18:45:36 2011 From: emile at fenx.com (Emile van Sebille) Date: Wed, 05 Jan 2011 15:45:36 -0800 Subject: Help with a Python coding question In-Reply-To: <44CdnVDzP-NQZ7nQnZ2dnUVZ_h-dnZ2d@giganews.com> References: <44CdnVDzP-NQZ7nQnZ2dnUVZ_h-dnZ2d@giganews.com> Message-ID: On 1/5/2011 3:12 PM kanthony at woh.rr.com said... > I want to use Python to find all "\n" terminated > strings in a PDF file, ideally returning string > starting addresses. Anyone willing to help? pdflines = open(r'c:\shared\python_book_01.pdf').readlines() sps = [0] for ii in pdflines: sps.append(sps[-1]+len(ii)) Emile From jshgwave at yahoo.com Wed Jan 5 20:08:14 2011 From: jshgwave at yahoo.com (Jshgwave) Date: Wed, 5 Jan 2011 17:08:14 -0800 (PST) Subject: Importing modules from miscellaneous folders Message-ID: <614812.98013.qm@web84415.mail.ac2.yahoo.com> On a Windows PC, I would like to be able to store modules in topic-specific foldersinstead of in Python26/Lib/site-packages, and then import into an IPython session those modules and the functions in them. To test this, I have made a toy module: --- """ ?toy_module.py ? ?This is for testing the importing of modules from folders ?other than "Lib". ?The first statement below is from Langtangen, Primer, p.143. ?At allows running the module as a program, as well as ?importing it as a module. """ if __name__ == '__main__' : ? def double_it (a) : ??? b = 2.*a ??? print 'double_it in toy_module: a = ', a, ', b = ', b ??? return b ? def triple_it (a) : ??? b = 3.*a ??? print 'triple_it in toy_module: a = ', a, ', b = ', b ??? return b --- I have tried many ways of importing this module and its functions, but all of them have failed.? In the IPython session below, the failures have been flagged for easy identification by "<<<". --- Python 2.6.6 (r266:84297, Aug 24 2010, 18:46:32) [MSC v.1500 32 bit (Intel)] Type "copyright", "credits" or "license" for more information. IPython 0.10.1 -- An enhanced Interactive Python. ????????? -> Introduction and overview of IPython's features. %quickref -> Quick reference. help????? -> Python's own help system. object??? -> Details about 'object'. ?object also works, ?? prints more. In [1]: # Test importing from other than Lib. In [2]: # 2011-01-05 In [3]: function_dir = 'G:\\Python_2010-12\\JH_Python_Functions' In [4]: # That is for the PC at work. In [5]: import os In [6]: os.getcwd() Out[6]: 'C:\\Documents and Settings\\Hornstein' In [7]: os.chdir(function_dir) In [8]: os.getcwd() Out[8]: 'G:\\Python_2010-12\\JH_Python_Functions' In [9]: import toy_module In [10]: result1 = toy_module.double_it(3.) --------------------------------------------------------------------------- AttributeError??????????????????????????? Traceback (most recent call last) G:\Python_2010-12\JH_Python_Functions\ in () AttributeError: 'module' object has no attribute 'double_it'? <<< 1 In [11]: from toy_module import double_it as twox --------------------------------------------------------------------------- ImportError?????????????????????????????? Traceback (most recent call last) G:\Python_2010-12\JH_Python_Functions\ in () ImportError: cannot import name double_it???????????????????? <<< 2 In [12]: IsFileThere = os.isfile('toy_module.py') --------------------------------------------------------------------------- AttributeError??????????????????????????? Traceback (most recent call last) G:\Python_2010-12\JH_Python_Functions\ in () AttributeError: 'module' object has no attribute 'isfile' In [13]: IsFileThere = os.path.isfile('toy_module.py') In [14]: IsFileThere Out[14]: True In [15]: filelist = os.listdir(function_dir) In [16]: filelist Out[16]: ['arc_to_-pitopi.py', ?'arc_to_0to2pi.py', ?'ClustersOfGalaxiesUtils.py', ?'ClustersOfGalaxiesUtils.py.txt', ?'ClustersOfGalaxiesUtils.Test.2010-08-04.1.txt', ?'CosmolFns.py.txt', ?'CosmolGeom_SmoothedMatter_CL.py.txt', ?'Distances_z.py.txt', ?'extract_text_line.py', ?'JH.PythonExperimentsOnWindows.2011-01-03.txt', ?'LAMBDA_calc.py', ?'loop_to_sum.example.py', ?'number_theory.py', ?'omega_plasma_radHz.py', ?'README.txt', ?'Sampletxt.IPython.txt', ?'Sampletxt.txt', ?'script2_1.py', ?'synchRadn.py.txt', ?'toy_module.py', ?'toy_module.pyc', ?'uv2D.Feb14-06.py', ?'VariablesInFile.py', ?'VariablesInFile.pyc', ?'VLA_beamwidths.py', ?'z_cosmol.py'] In [17]: import glob In [18]: pyfilelist = glob.glob('*.py') In [19]: pyfilelist Out[19]: ['arc_to_-pitopi.py', ?'arc_to_0to2pi.py', ?'ClustersOfGalaxiesUtils.py', ?'extract_text_line.py', ?'LAMBDA_calc.py', ?'loop_to_sum.example.py', ?'number_theory.py', ?'omega_plasma_radHz.py', ?'script2_1.py', ?'toy_module.py', ?'uv2D.Feb14-06.py', ?'VariablesInFile.py', ?'VLA_beamwidths.py', ?'z_cosmol.py'] In [20]: # Try changing the Python search path. In [21]: import sys In [22]: sys.path Out[22]: ['', ?'C:\\Python26\\scripts', ?'C:\\WINDOWS\\system32\\python26.zip', ?'C:\\Python26\\DLLs', ?'C:\\Python26\\lib', ?'C:\\Python26\\lib\\plat-win', ?'C:\\Python26\\lib\\lib-tk', ?'C:\\Python26', ?'C:\\Python26\\lib\\site-packages', ?'C:\\Python26\\lib\\site-packages\\IPython/Extensions', ?u'C:\\Documents and Settings\\Hornstein\\_ipython'] In [23]: sys.path.append(function_dir) In [24]: sys.path Out[24]: ['', ?'C:\\Python26\\scripts', ?'C:\\WINDOWS\\system32\\python26.zip', ?'C:\\Python26\\DLLs', ?'C:\\Python26\\lib', ?'C:\\Python26\\lib\\plat-win', ?'C:\\Python26\\lib\\lib-tk', ?'C:\\Python26', ?'C:\\Python26\\lib\\site-packages', ?'C:\\Python26\\lib\\site-packages\\IPython/Extensions', ?u'C:\\Documents and Settings\\Hornstein\\_ipython', ?'G:\\Python_2010-12\\JH_Python_Functions'] In [25]: import toy_module In [26]: result1 = toy_module.double_it(3.) --------------------------------------------------------------------------- AttributeError??????????????????????????? Traceback (most recent call last) G:\Python_2010-12\JH_Python_Functions\ in () AttributeError: 'module' object has no attribute 'double_it'?? <<< 3 In [27]: exit() Do you really want to exit ([y]/n)? Any insight would be appreciated. Also, it is unfortunate that no warning is issued when an attempt at importing fails. John Hornstein (By the way, I am stuck with Python2.6 because the binary installer for NumPy on Windows still refuses to accept any later version of Python.) -------------- next part -------------- An HTML attachment was scrubbed... URL: From peelpy at gmail.com Wed Jan 5 20:14:28 2011 From: peelpy at gmail.com (Justin Peel) Date: Wed, 5 Jan 2011 18:14:28 -0700 Subject: Help with a Python coding question In-Reply-To: References: <44CdnVDzP-NQZ7nQnZ2dnUVZ_h-dnZ2d@giganews.com> Message-ID: On Wed, Jan 5, 2011 at 4:45 PM, Emile van Sebille wrote: > On 1/5/2011 3:12 PM kanthony at woh.rr.com said... > > I want to use Python to find all "\n" terminated >> strings in a PDF file, ideally returning string >> starting addresses. Anyone willing to help? >> > > pdflines = open(r'c:\shared\python_book_01.pdf').readlines() > sps = [0] > for ii in pdflines: sps.append(sps[-1]+len(ii)) > > Emile > > > -- > http://mail.python.org/mailman/listinfo/python-list > Bear in mind that pdf files often have compressed objects in them. If that is the case, then I would recommend opening the pdf in binary mode and figuring out how to deflate the correct objects before doing any searching. PyPDF is a package that might help with this though it could use some updating. -------------- next part -------------- An HTML attachment was scrubbed... URL: From askutt at gmail.com Wed Jan 5 20:25:49 2011 From: askutt at gmail.com (Adam Skutt) Date: Wed, 5 Jan 2011 17:25:49 -0800 (PST) Subject: Interrput a thread References: <81c24eb1-41b6-442a-a971-8a44d2cd6c1b@p8g2000vbs.googlegroups.com> <2ebc11a5-1b45-4faa-97b9-c84f0db015a4@k22g2000yqh.googlegroups.com> <68004bac-5d4d-40fa-afb7-6de45f3ea87a@v17g2000yqv.googlegroups.com> <4d23eb28$0$44049$742ec2ed@news.sonic.net> Message-ID: On Jan 4, 10:53?pm, John Nagle wrote: > ? ? ?There are systems where there's support designed in for thread > abort. ?LISP/Scheme systems tend to support it. ?QNX, the real-time > OS, has well worked out thread-abort semantics at the C level. > (QNX has really good features for "not getting stuck", like the > ability to put a time limit on any system call.) Yes, but "not getting stuck" and ending the thread execution is only one small part of the problem (and arguably the least significant). What we really want is a way to abort without harming other threads of execution, which is the hard part. QNX doesn't ipso facto make that easier. Functionality like time limits on system calls is more about latency guarantees and priority than "getting stuck" in a deadlock sense. > ? ? ?What you'd really like in Python is the ability for one thread > to be able to force an exception in another thread, plus a > mechanism for locking out such exceptions for critical sections. > It's not worth having, though, in a system where you can really only > run one thread at a time. Exceptions and critical sections are rather fundamentally incompatible, hence the absurd amount of gymnastics .NET goes through to attempt to make ThreadAbortException functional (and still fails rather miserably). If you had STM or 'antitry' blocks, then exceptions might be a semi-saneish way to abort a thread. Without either, I'm not entirely convinced of the utility. Only allowing the exception to be thrown from defined cancellation points is much better (ala POSIX threads), but diminishes the utility for things that are mostly grinding away in userspace. Adam From stackslip at gmail.com Wed Jan 5 20:31:13 2011 From: stackslip at gmail.com (Slie) Date: Wed, 5 Jan 2011 16:31:13 -0900 Subject: Searching Python-list Message-ID: <6113BAE4-29BB-416A-820F-CFCB0688DD37@gmail.com> I was wondering if anyone could tell me how to search through the Archives otter then manually looking through each month. From alice at gothcandy.com Wed Jan 5 20:36:31 2011 From: alice at gothcandy.com (=?utf-8?Q?Alice_Bevan=E2=80=93McGregor?=) Date: Wed, 5 Jan 2011 17:36:31 -0800 Subject: Streaming templating languages for use as WSGI body. References: Message-ID: Not sure if it's bad form to respond to your own posts, but here goes. ;) Coding up a quick hack of a templating engine, I've produced this: > http://pastie.textmate.org/private/ws5jbeh1xyeaqtrhahevqw (The implementation of the engine itself is a base class that overrides __call__ and __getitem__, with __unicode__ serializing in one block, the norm for templating engines, and .render(encoding='ascii') returning a generator using cStringIO for internal buffering.) I even have a light-weight widget system based on it, now. E.g. > class Input(Widget): > type_ = None > > @property > def template(self): > return tag.input ( > type_ = self.type_, > name = self.name, > id = self.name + '-field', > value = self.value, > **self.args > ) I'll polish it and package it up. :) - Alice. From nad at acm.org Wed Jan 5 20:39:42 2011 From: nad at acm.org (Ned Deily) Date: Wed, 05 Jan 2011 17:39:42 -0800 Subject: Searching Python-list References: <6113BAE4-29BB-416A-820F-CFCB0688DD37@gmail.com> Message-ID: In article <6113BAE4-29BB-416A-820F-CFCB0688DD37 at gmail.com>, Slie wrote: > I was wondering if anyone could tell me how to search through the Archives > otter then manually looking through each month. One way is to use the mirror of the mailing list at gmane.org: http://dir.gmane.org/gmane.comp.python.general -- Ned Deily, nad at acm.org From alice at gothcandy.com Wed Jan 5 20:39:49 2011 From: alice at gothcandy.com (=?utf-8?Q?Alice_Bevan=E2=80=93McGregor?=) Date: Wed, 5 Jan 2011 17:39:49 -0800 Subject: Searching Python-list References: <6113BAE4-29BB-416A-820F-CFCB0688DD37@gmail.com> Message-ID: On 2011-01-05 17:31:13 -0800, Slie said: > I was wondering if anyone could tell me how to search through the > Archives otter then manually looking through each month. Grab a Usenet news reader (such as Thunderbird or Unison), point it at: nntps://news.gmane.org/gmane.comp.python.general I can rather quickly search through articles using this interface (let alone keep my e-mail clear of mailing lists) and even post. :) - Alice. From BubbaCoder at gmail.com Wed Jan 5 20:55:45 2011 From: BubbaCoder at gmail.com (Bubba) Date: Wed, 05 Jan 2011 19:55:45 -0600 Subject: Help with a Python coding question References: Message-ID: <092dnYjfL7i8vLjQnZ2dnUVZ_u-dnZ2d@giganews.com> Does this work for binary files? (Like PDFs) -- --------------------------------- --- -- - Posted with NewsLeecher v4.0 Final Web @ http://www.newsleecher.com/?usenet ------------------- ----- ---- -- - From BubbaCoder at gmail.com Wed Jan 5 21:24:44 2011 From: BubbaCoder at gmail.com (Bubba) Date: Wed, 05 Jan 2011 20:24:44 -0600 Subject: Help with a Python coding question References: Message-ID: <58OdncbWoqVxurjQnZ2dnUVZ_hWdnZ2d@giganews.com> Your code only shows the first 488 bytes of the file? -- --------------------------------- --- -- - Posted with NewsLeecher v4.0 Final Web @ http://www.newsleecher.com/?usenet ------------------- ----- ---- -- - From stackslip at gmail.com Wed Jan 5 21:35:04 2011 From: stackslip at gmail.com (Garland) Date: Thu, 06 Jan 2011 02:35:04 +0000 Subject: Searching Python-list Message-ID: <90e6ba6e83d66145bd0499245919@google.com> Amazing you are a genius, I use google chrome and I chose Google Reader as my solution for the e-mail clutter and response. RSS from here. http://permalink.gmane.org/gmane.comp.python.general/681862 All i have to do is click on a response and i'm brought the the search thank you. Sent to you by Garland via Google Reader: Re: Searching Python-list via gmane.comp.python.general by Alice Bevan?McGregor on 1/6/11 On 2011-01-05 17:31:13 -0800, Slie said: Grab a Usenet news reader (such as Thunderbird or Unison), point it at: nntps://news.gmane.org/gmane.comp.python.general I can rather quickly search through articles using this interface (let alone keep my e-mail clear of mailing lists) and even post. :) - Alice. Things you can do from here: - Subscribe to gmane.comp.python.general using Google Reader - Get started using Google Reader to easily keep up with all your favorite sites -------------- next part -------------- An HTML attachment was scrubbed... URL: From nambo4jb at gmail.com Wed Jan 5 21:39:56 2011 From: nambo4jb at gmail.com (Cathy James) Date: Wed, 5 Jan 2011 20:39:56 -0600 Subject: Help with code-lists and strings Message-ID: Thank you all for your help. 1) I need to list words with uppercase first, then those with lower case; I used istitle() and isupper (don't know the method for mixed case yet) 2) Steve, it's a compliment that you though I'd undersand your code, but I only know conditional statements, started on lists, not functions yet. nand is still Greek to me right now. 3) If someone input "Thank you my FOLKS, i want the output to print words with upper case first: Thank FOLKS you my 3) Can someone help me make my code work in a very simple way. I am still learning, but watch this space colleagues; I may be helping you guys in a few months ;) Thanks to all who took their time to help. Future Python Expert, Cathy. My initial code: s=input("Write a sentence: ") list=s.strip().split() for word in list: list2 = (word.isupper() or word.istitle()) print (word) else print (word) On Wed, Jan 5, 2011 at 7:35 PM, wrote: > Send Python-list mailing list submissions to > python-list at python.org > > To subscribe or unsubscribe via the World Wide Web, visit > http://mail.python.org/mailman/listinfo/python-list > or, via email, send a message with subject or body 'help' to > python-list-request at python.org > > You can reach the person managing the list at > python-list-owner at python.org > > When replying, please edit your Subject line so it is more specific > than "Re: Contents of Python-list digest..." > > Today's Topics: > > 1. Re: Help with code-lists and strings (GrayShark) > 2. Help with a Python coding question (kanthony at woh.rr.com) > 3. Re: Help with a Python coding question (Emile van Sebille) > 4. Re: Help with a Python coding question (Justin Peel) > 5. Importing modules from miscellaneous folders (Jshgwave) > 6. Searching Python-list (Slie) > 7. Re: Interrput a thread (Adam Skutt) > > > ---------- Forwarded message ---------- > From: GrayShark > To: python-list at python.org > Date: Wed, 05 Jan 2011 16:56:40 -0600 > Subject: Re: Help with code-lists and strings > On Wed, 05 Jan 2011 14:58:05 -0500, Terry Reedy wrote: > > > On 1/5/2011 12:57 PM, Cathy James wrote: > > > >> I am learning python and came across an excercise where i need to use > >> lists to strip words from a sentence; starting with those containing > >> one or more uppercase letters, followed by words with lower case > >> letters. > > > > When writing code, it is good to start with one or more input-output > > pairs that constitute a test. For example, what, exactly, do you want to > > result from > > "Some special words are ALLCAPS, TitleCase, and MIXed." > > > > It is also good to think about all relevant cases. Note the following: > > >>> 'MIXed'.isupper() or 'MIXed'.istitle() > > False > > > > Do you want punctuation stripped off words? You might skip that at > > first. > > In python it's best to build up you functional needs. So two steps. First > a nand (negative 'and' operation). Then wrap that with a function to create > two strings of your list element, you''re calling 'word'. By the way, > list is reserved word, like string. Don't get in the bad habit of using it. > > def nand( a, b ): > """nand has to vars. Both must be strings """ > return( ( not eval( a ) ) and ( not eval( b ) ) ) > > Eval of 'Abcd'.isupper() returns False. Ditto 'Abcd'.islower(); negate both > results, 'and' values, return. > > Now wrap 'nand' in packaging an you're cooking with grease. > def mixed_case( str ): > return nand( "'%s'.islower()" % str , "'%s'.isupper()" % str ) > > or if that's too advanced/compact, try ... > def mixed_case( str ): > # nand() needs strings > a = "'%s'.isupper()" % str > b = "'%s'.islower()" % str > res = nand( a, b ) > return res > > >>> mixed_case('Abcd' ) > True > >>> mixed_case('ABCD' ) > False > >>> mixed_case('abcd' ) > False > > Good luck > Steven Howe > > > > ---------- Forwarded message ---------- > From: kanthony at woh.rr.com > To: python-list at python.org > Date: Wed, 05 Jan 2011 17:12:13 -0600 > Subject: Help with a Python coding question > I want to use Python to find all "\n" terminated > strings in a PDF file, ideally returning string > starting addresses. Anyone willing to help? > > > -- > --------------------------------- --- -- - > Posted with NewsLeecher v4.0 Final > Web @ http://www.newsleecher.com/?usenet > ------------------- ----- ---- -- - > > > > > ---------- Forwarded message ---------- > From: Emile van Sebille > To: python-list at python.org > Date: Wed, 05 Jan 2011 15:45:36 -0800 > Subject: Re: Help with a Python coding question > On 1/5/2011 3:12 PM kanthony at woh.rr.com said... > >> I want to use Python to find all "\n" terminated >> strings in a PDF file, ideally returning string >> starting addresses. Anyone willing to help? >> > > pdflines = open(r'c:\shared\python_book_01.pdf').readlines() > sps = [0] > for ii in pdflines: sps.append(sps[-1]+len(ii)) > > Emile > > > > > ---------- Forwarded message ---------- > From: Justin Peel > To: python-list at python.org > Date: Wed, 5 Jan 2011 18:14:28 -0700 > Subject: Re: Help with a Python coding question > > > On Wed, Jan 5, 2011 at 4:45 PM, Emile van Sebille wrote: > >> On 1/5/2011 3:12 PM kanthony at woh.rr.com said... >> >> I want to use Python to find all "\n" terminated >>> strings in a PDF file, ideally returning string >>> starting addresses. Anyone willing to help? >>> >> >> pdflines = open(r'c:\shared\python_book_01.pdf').readlines() >> sps = [0] >> for ii in pdflines: sps.append(sps[-1]+len(ii)) >> >> Emile >> >> >> -- >> http://mail.python.org/mailman/listinfo/python-list >> > Bear in mind that pdf files often have compressed objects in them. If that > is the case, then I would recommend opening the pdf in binary mode and > figuring out how to deflate the correct objects before doing any searching. > PyPDF is a package that might help with this though it could use some > updating. > > ---------- Forwarded message ---------- > From: Jshgwave > To: python-list at python.org > Date: Wed, 5 Jan 2011 17:08:14 -0800 (PST) > Subject: Importing modules from miscellaneous folders > On a Windows PC, I would like to be able to store modules in > topic-specific foldersinstead of in Python26/Lib/site-packages, > and then import into an IPython session those modules and the > functions in them. > > To test this, I have made a toy module: > > --- > > """ > toy_module.py > > This is for testing the importing of modules from folders > other than "Lib". > > The first statement below is from Langtangen, Primer, p.143. > At allows running the module as a program, as well as > importing it as a module. > """ > > > if __name__ == '__main__' : > > def double_it (a) : > b = 2.*a > print 'double_it in toy_module: a = ', a, ', b = ', b > return b > > > def triple_it (a) : > b = 3.*a > print 'triple_it in toy_module: a = ', a, ', b = ', b > return b > --- > > I have tried many ways of importing this module and its functions, but > all of them have failed. In the IPython session below, the failures > have been flagged for easy identification by "<<<". > > --- > > Python 2.6.6 (r266:84297, Aug 24 2010, 18:46:32) [MSC v.1500 32 bit > (Intel)] > Type "copyright", "credits" or "license" for more information. > > IPython 0.10.1 -- An enhanced Interactive Python. > ? -> Introduction and overview of IPython's features. > %quickref -> Quick reference. > help -> Python's own help system. > object? -> Details about 'object'. ?object also works, ?? prints more. > > In [1]: # Test importing from other than Lib. > > In [2]: # 2011-01-05 > > In [3]: function_dir = 'G:\\Python_2010-12\\JH_Python_Functions' > > In [4]: # That is for the PC at work. > > In [5]: import os > > In [6]: os.getcwd() > Out[6]: 'C:\\Documents and Settings\\Hornstein' > > In [7]: os.chdir(function_dir) > > In [8]: os.getcwd() > Out[8]: 'G:\\Python_2010-12\\JH_Python_Functions' > > In [9]: import toy_module > > In [10]: result1 = toy_module.double_it(3.) > --------------------------------------------------------------------------- > AttributeError Traceback (most recent call last) > > G:\Python_2010-12\JH_Python_Functions\ in () > > AttributeError: 'module' object has no attribute 'double_it' <<< 1 > > In [11]: from toy_module import double_it as twox > --------------------------------------------------------------------------- > ImportError Traceback (most recent call last) > > G:\Python_2010-12\JH_Python_Functions\ in () > > ImportError: cannot import name double_it <<< 2 > > In [12]: IsFileThere = os.isfile('toy_module.py') > --------------------------------------------------------------------------- > AttributeError Traceback (most recent call last) > > G:\Python_2010-12\JH_Python_Functions\ in () > > AttributeError: 'module' object has no attribute 'isfile' > > In [13]: IsFileThere = os.path.isfile('toy_module.py') > > In [14]: IsFileThere > Out[14]: True > > In [15]: filelist = os.listdir(function_dir) > > In [16]: filelist > Out[16]: > ['arc_to_-pitopi.py', > 'arc_to_0to2pi.py', > 'ClustersOfGalaxiesUtils.py', > 'ClustersOfGalaxiesUtils.py.txt', > 'ClustersOfGalaxiesUtils.Test.2010-08-04.1.txt', > 'CosmolFns.py.txt', > 'CosmolGeom_SmoothedMatter_CL.py.txt', > 'Distances_z.py.txt', > 'extract_text_line.py', > 'JH.PythonExperimentsOnWindows.2011-01-03.txt', > 'LAMBDA_calc.py', > 'loop_to_sum.example.py', > 'number_theory.py', > 'omega_plasma_radHz.py', > 'README.txt', > 'Sampletxt.IPython.txt', > 'Sampletxt.txt', > 'script2_1.py', > 'synchRadn.py.txt', > 'toy_module.py', > 'toy_module.pyc', > 'uv2D.Feb14-06.py ', > 'VariablesInFile.py', > 'VariablesInFile.pyc', > 'VLA_beamwidths.py', > 'z_cosmol.py'] > > In [17]: import glob > > In [18]: pyfilelist = glob.glob('*.py') > > In [19]: pyfilelist > Out[19]: > ['arc_to_-pitopi.py', > 'arc_to_0to2pi.py', > 'ClustersOfGalaxiesUtils.py', > 'extract_text_line.py', > 'LAMBDA_calc.py', > 'loop_to_sum.example.py', > 'number_theory.py', > 'omega_plasma_radHz.py', > 'script2_1.py', > 'toy_module.py', > 'uv2D.Feb14-06.py ', > 'VariablesInFile.py', > 'VLA_beamwidths.py', > 'z_cosmol.py'] > > In [20]: # Try changing the Python search path. > > In [21]: import sys > > In [22]: sys.path > Out[22]: > ['', > 'C:\\Python26\\scripts', > 'C:\\WINDOWS\\system32\\python26.zip', > 'C:\\Python26\\DLLs', > 'C:\\Python26\\lib', > 'C:\\Python26\\lib\\plat-win', > 'C:\\Python26\\lib\\lib-tk', > 'C:\\Python26', > 'C:\\Python26\\lib\\site-packages', > 'C:\\Python26\\lib\\site-packages\\IPython/Extensions', > u'C:\\Documents and Settings\\Hornstein\\_ipython'] > > In [23]: sys.path.append(function_dir) > > In [24]: sys.path > Out[24]: > ['', > 'C:\\Python26\\scripts', > 'C:\\WINDOWS\\system32\\python26.zip', > 'C:\\Python26\\DLLs', > 'C:\\Python26\\lib', > 'C:\\Python26\\lib\\plat-win', > 'C:\\Python26\\lib\\lib-tk', > 'C:\\Python26', > 'C:\\Python26\\lib\\site-packages', > 'C:\\Python26\\lib\\site-packages\\IPython/Extensions', > u'C:\\Documents and Settings\\Hornstein\\_ipython', > 'G:\\Python_2010-12\\JH_Python_Functions'] > > In [25]: import toy_module > > In [26]: result1 = toy_module.double_it(3.) > --------------------------------------------------------------------------- > AttributeError Traceback (most recent call last) > > G:\Python_2010-12\JH_Python_Functions\ in () > > AttributeError: 'module' object has no attribute 'double_it' <<< 3 > > In [27]: exit() > Do you really want to exit ([y]/n)? > > > Any insight would be appreciated. > > Also, it is unfortunate that no warning is issued when an attempt at > importing fails. > > John Hornstein > > > (By the way, I am stuck with Python2.6 because the binary installer for > NumPy on Windows still refuses to accept any later version of Python.) > > > > ---------- Forwarded message ---------- > From: Slie > To: python-list at python.org > Date: Wed, 5 Jan 2011 16:31:13 -0900 > Subject: Searching Python-list > I was wondering if anyone could tell me how to search through the Archives > otter then manually looking through each month. > > > > > ---------- Forwarded message ---------- > From: Adam Skutt > To: python-list at python.org > Date: Wed, 5 Jan 2011 17:25:49 -0800 (PST) > Subject: Re: Interrput a thread > On Jan 4, 10:53 pm, John Nagle wrote: > > There are systems where there's support designed in for thread > > abort. LISP/Scheme systems tend to support it. QNX, the real-time > > OS, has well worked out thread-abort semantics at the C level. > > (QNX has really good features for "not getting stuck", like the > > ability to put a time limit on any system call.) > > Yes, but "not getting stuck" and ending the thread execution is only > one small part of the problem (and arguably the least significant). > What we really want is a way to abort without harming other threads of > execution, which is the hard part. QNX doesn't ipso facto make that > easier. Functionality like time limits on system calls is more about > latency guarantees and priority than "getting stuck" in a deadlock > sense. > > > What you'd really like in Python is the ability for one thread > > to be able to force an exception in another thread, plus a > > mechanism for locking out such exceptions for critical sections. > > It's not worth having, though, in a system where you can really only > > run one thread at a time. > > Exceptions and critical sections are rather fundamentally > incompatible, hence the absurd amount of gymnastics .NET goes through > to attempt to make ThreadAbortException functional (and still fails > rather miserably). If you had STM or 'antitry' blocks, then > exceptions might be a semi-saneish way to abort a thread. Without > either, I'm not entirely convinced of the utility. > > Only allowing the exception to be thrown from defined cancellation > points is much better (ala POSIX threads), but diminishes the utility > for things that are mostly grinding away in userspace. > > Adam > > > -- > http://mail.python.org/mailman/listinfo/python-list > -------------- next part -------------- An HTML attachment was scrubbed... URL: From davea at ieee.org Wed Jan 5 22:17:29 2011 From: davea at ieee.org (Dave Angel) Date: Wed, 05 Jan 2011 22:17:29 -0500 Subject: Help with code-lists and strings In-Reply-To: References: Message-ID: <4D253449.90507@ieee.org> On 01/-10/-28163 02:59 PM, GrayShark wrote: > < > In python it's best to build up you functional needs. So two steps. First > a nand (negative 'and' operation). Then wrap that with a function to create > two strings of your list element, you''re calling 'word'. By the way, > list is reserved word, like string. Don't get in the bad habit of using it. > > def nand( a, b ): > """nand has to vars. Both must be strings """ > return( ( not eval( a ) ) and ( not eval( b ) ) ) > Two problems with that. One is that you've defined a NOR function, but called it nand(). The other is using eval. There's no need for it, and it's both slow and risky. DaveA From stackslip at gmail.com Wed Jan 5 22:36:55 2011 From: stackslip at gmail.com (Slie) Date: Wed, 5 Jan 2011 18:36:55 -0900 Subject: Google Chart API, HTTP POST request format. Message-ID: http://code.google.com/apis/chart/docs/post_requests.html Google will return a chart in your browser from a URL that you have built. If your URL is bigger then 2K characters it will allow you to submit POST requests. They gives examples of HTML, JavaScript, and PHP POST requests. Is there a way I can submit a request with Python? Or possibly submit the HTML, JavaScript or PHP using python?(That was a long shot thought). If I do that I would need to find out what to do with the .PNG it gives me. Am I headed in the right direction, is the above paragraph about submitting an HTML form from my program even logical? I have read several examples on python post requests but I'm not sure mine needs to be that complicated. Thank You, From benjamin.kaplan at case.edu Wed Jan 5 22:48:08 2011 From: benjamin.kaplan at case.edu (Benjamin Kaplan) Date: Wed, 5 Jan 2011 22:48:08 -0500 Subject: Importing modules from miscellaneous folders In-Reply-To: <614812.98013.qm@web84415.mail.ac2.yahoo.com> References: <614812.98013.qm@web84415.mail.ac2.yahoo.com> Message-ID: On Wed, Jan 5, 2011 at 8:08 PM, Jshgwave wrote: > > On a Windows PC, I would like to be able to store modules in > topic-specific foldersinstead of in Python26/Lib/site-packages, > and then import into an IPython session those modules and the > functions in them. > > To test this, I have made a toy module: > > --- > > """ > ?toy_module.py > > ?This is for testing the importing of modules from folders > ?other than "Lib". > > ?The first statement below is from Langtangen, Primer, p.143. > ?At allows running the module as a program, as well as > ?importing it as a module. > """ > > > if __name__ == '__main__' : > You've misunderstood what this statement does. Any python script can be executed as a program. In fact, all Python modules are scripts. Upon running or importing them, they are executed. Anything at the top level is run. If a module is imported, it's __name__ attribute will be the name of the script. If the module is run as a script, it's __name__ will be "__main__". By checking to see if the __name__ == "__main__", you can have certain code only run if the script is run as a program, as opposed to being imported as a module. The def statement in python is an executable statement, not a declaration. The function does not exist until after the def statement is executed. Because your functions are only created if __name__ == "__main__", they don't exist when __name__ == "toy_module", which is the case when you import it in the ipython shell. That's what's causing your error. From emile at fenx.com Wed Jan 5 22:54:25 2011 From: emile at fenx.com (Emile van Sebille) Date: Wed, 05 Jan 2011 19:54:25 -0800 Subject: Searching Python-list In-Reply-To: <6113BAE4-29BB-416A-820F-CFCB0688DD37@gmail.com> References: <6113BAE4-29BB-416A-820F-CFCB0688DD37@gmail.com> Message-ID: On 1/5/2011 5:31 PM Slie said... > I was wondering if anyone could tell me how to search through the Archives otter then manually looking through each month. > http://groups.google.com To limit the results to this group, prepend group:comp.lang.python to your search terms. Emile From emile at fenx.com Wed Jan 5 23:01:38 2011 From: emile at fenx.com (Emile van Sebille) Date: Wed, 05 Jan 2011 20:01:38 -0800 Subject: Help with a Python coding question In-Reply-To: <092dnYjfL7i8vLjQnZ2dnUVZ_u-dnZ2d@giganews.com> References: <092dnYjfL7i8vLjQnZ2dnUVZ_u-dnZ2d@giganews.com> Message-ID: On 1/5/2011 5:55 PM Bubba said... > Does this work for binary files? (Like PDFs) I don't know what you want -- pdf's are not line oriented so searching for \n's is sketchy from the get go. I figured this was homework to test something.... Emile From emile at fenx.com Wed Jan 5 23:02:28 2011 From: emile at fenx.com (Emile van Sebille) Date: Wed, 05 Jan 2011 20:02:28 -0800 Subject: Help with a Python coding question In-Reply-To: <58OdncbWoqVxurjQnZ2dnUVZ_hWdnZ2d@giganews.com> References: <58OdncbWoqVxurjQnZ2dnUVZ_hWdnZ2d@giganews.com> Message-ID: On 1/5/2011 6:24 PM Bubba said... > Your code only shows the first 488 bytes of the file? > > add 'rb' to the open statement... >>> pdflines = open(r'c:\shared\python_book_01.pdf','rb').readlines() >>> sps = [0] >>> for ii in pdflines: sps.append(sps[-1]+len(ii)) Emile From philip at semanchuk.com Wed Jan 5 23:11:44 2011 From: philip at semanchuk.com (Philip Semanchuk) Date: Wed, 5 Jan 2011 23:11:44 -0500 Subject: Searching Python-list In-Reply-To: <6113BAE4-29BB-416A-820F-CFCB0688DD37@gmail.com> References: <6113BAE4-29BB-416A-820F-CFCB0688DD37@gmail.com> Message-ID: <90E84BA3-297D-4DE0-866A-C99FD08FB420@semanchuk.com> On Jan 5, 2011, at 8:31 PM, Slie wrote: > I was wondering if anyone could tell me how to search through the Archives otter then manually looking through each month. Do a Google search and include this term: site:mail.python.org/pipermail/python-list/ e.g. to search for banana: http://www.google.com/search?q=site:mail.python.org%2Fpipermail%2Fpython-list%2F+banana HTH Philip From steve+comp.lang.python at pearwood.info Wed Jan 5 23:19:04 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 06 Jan 2011 04:19:04 GMT Subject: Help with code-lists and strings References: Message-ID: <4d2542b7$0$29996$c3e8da3$5496439d@news.astraweb.com> Apologies if this comes through twice, I'm having problems with my news client and/or provider. On Wed, 05 Jan 2011 16:56:40 -0600, GrayShark wrote: > In python it's best to build up you functional needs. So two steps. > First a nand (negative 'and' operation). Then wrap that with a function > to create two strings of your list element, you''re calling 'word'. By > the way, list is reserved word, like string. Don't get in the bad habit > of using it. Speaking of bad habits: > def nand( a, b ): > """nand has to vars. Both must be strings """ > return( ( not eval( a ) ) and ( not eval( b ) ) ) What is the purpose of the two calls to eval, other than potentially introducing serious security bugs, being slow, and raising exceptions? def nand(a, b): return not (a and b) is faster and safer, and less likely to cause annoyance if somebody manages to fool you into executing something similar to: nand("0", "__import__('os').system('# r m -rf /')") More safely, and works on both Linux and Windows: nand("0", "__import__('os').system('dir .')") > Eval of 'Abcd'.isupper() returns False. Ditto 'Abcd'.islower(); negate > both results, 'and' values, return. > > Now wrap 'nand' in packaging an you're cooking with grease. Eww. Greasy food. I think the idiom you are thinking of is "now you're cooking with gas", gas cooking being cleaner, faster and easier than cooking with wood. > def mixed_case( str ): > return nand( "'%s'.islower()" % str , "'%s'.isupper()" % str ) I'm afraid that's incorrect, because it returns True for strings that aren't mixed case: >>> mixed_case("123") True as well as strings that can't be mixed anything on account of being a single character: >>> mixed_case("!") True A better solution would be: def ismixed(s): seen_upper = seen_lower = False for c in s: if c.isupper(): seen_upper = True if c.islower(): seen_lower = True if seen_upper and seen_lower: return True return False which should return True if and only if the string contains both lowercase and uppercase characters. -- Steven From usernet at ilthio.net Wed Jan 5 23:26:42 2011 From: usernet at ilthio.net (Tim Harig) Date: Thu, 6 Jan 2011 04:26:42 +0000 (UTC) Subject: Google Chart API, HTTP POST request format. References: Message-ID: On 2011-01-06, Slie wrote: [reformated to <80 columns per RFC 1855 guidelines] > I have read several examples on python post requests but I'm not sure > mine needs to be that complicated. >From the HTML example on the page you posted:
you can retreive the same chart from Python: Python 3.1.2 (r312:79147, Oct 9 2010, 00:16:06) [GCC 4.4.4] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import urllib.request, urllib.parse >>> params = urllib.parse.urlencode({'cht':'lc', 'chtt':'This is | my >>> chart', ... 'chs':'600x200', 'chxt':'x,y', 'chd':'t:40,20,50,20,100'}) >>> chart = urllib.request.urlopen('https://chart.googleapis.com/chart', ... data = params).read() >>> chartFile = open("chart.png", 'wb') >>> chartFile.write(chart) 10782 >>> chartFile.close() From clp2 at rebertia.com Wed Jan 5 23:52:12 2011 From: clp2 at rebertia.com (Chris Rebert) Date: Wed, 5 Jan 2011 20:52:12 -0800 Subject: Google Chart API, HTTP POST request format. In-Reply-To: References: Message-ID: On Wed, Jan 5, 2011 at 7:36 PM, Slie wrote: > > http://code.google.com/apis/chart/docs/post_requests.html > > Google will return a chart in your browser from a URL that you have built. If your URL is bigger then 2K characters it will allow you to submit POST requests. > > They gives examples of HTML, JavaScript, and PHP POST requests. Is there a way I can submit a request with Python? Or possibly submit the HTML, JavaScript or PHP using python?(That was a long shot thought). If I do that I would need to find out what to do with the .PNG it gives me. > > Am I headed in the right direction, is the above paragraph about submitting an HTML form from my program even logical? You should probably first try one of the existing Python wrappers for Google's chart API and see if that meets your needs: http://code.google.com/p/google-chartwrapper/ http://pygooglechart.slowchop.com/ Cheers, Chris -- http://blog.rebertia.com From clp2 at rebertia.com Wed Jan 5 23:59:59 2011 From: clp2 at rebertia.com (Chris Rebert) Date: Wed, 5 Jan 2011 20:59:59 -0800 Subject: Help with code-lists and strings In-Reply-To: References: Message-ID: On Wed, Jan 5, 2011 at 6:39 PM, Cathy James wrote: > > Thank you all for your help. > 1) I need to list words with uppercase first, then those with lower case; I used istitle() and isupper (don't know the method for mixed case yet) > 2) Steve,?it's a compliment that you though I'd undersand your code, but I only know?conditional statements, started on lists, not functions yet. nand is still Greek to me right now. > 3) If someone input "Thank you my FOLKS, i want the output to print words with upper case first: > > Thank > FOLKS > you > my > > 3) Can someone help me make my code work in a very simple way. I am still learning, but watch this space colleagues;?I may be helping you guys in a few months ;) > > Thanks to all who took their time to help. > Future Python Expert, > Cathy. > > My initial code: > > s=input("Write a sentence: ") > list=s.strip().split() > for word in list: > ??? list2 = (word.isupper() or word.istitle()) > ??? print (word) > else print (word) > > On Wed, Jan 5, 2011 at 7:35 PM, wrote: >> >> Send Python-list mailing list submissions to >> ? ? ? ?python-list at python.org >> >> To subscribe or unsubscribe via the World Wide Web, visit >> ? ? ? ?http://mail.python.org/mailman/listinfo/python-list >> or, via email, send a message with subject or body 'help' to >> ? ? ? ?python-list-request at python.org >> >> You can reach the person managing the list at >> ? ? ? ?python-list-owner at python.org >> >> When replying, please edit your Subject line so it is more specific >> than "Re: Contents of Python-list digest..." >> >> Today's Topics: Note: Avoid replying to digests in the future, or at least trim off the irrelevant posts when doing so. You may want to switch to a non-digest subscription; this can be done at http://mail.python.org/mailman/listinfo/python-list (login and edit your subscription options). Cheers, Chris From stackslip at gmail.com Thu Jan 6 00:16:30 2011 From: stackslip at gmail.com (Garland Fulton) Date: Wed, 5 Jan 2011 20:16:30 -0900 Subject: Google Chart API, HTTP POST request format. In-Reply-To: References: Message-ID: I tried to use "pygooglechart.py" and I have been trying to get it set up all day actually along with several other graphing API's. I just found out that there is a problem with numpy and python 3.1 that is why I moved from the API's. Should I change version just for these library's? Should I be learning Python on 3.1? Awesome! On Wed, Jan 5, 2011 at 7:52 PM, Chris Rebert wrote: > On Wed, Jan 5, 2011 at 7:36 PM, Slie wrote: > > > > http://code.google.com/apis/chart/docs/post_requests.html > > > > Google will return a chart in your browser from a URL that you have > built. If your URL is bigger then 2K characters it will allow you to submit > POST requests. > > > > They gives examples of HTML, JavaScript, and PHP POST requests. Is there > a way I can submit a request with Python? Or possibly submit the HTML, > JavaScript or PHP using python?(That was a long shot thought). If I do that > I would need to find out what to do with the .PNG it gives me. > > > > Am I headed in the right direction, is the above paragraph about > submitting an HTML form from my program even logical? > > You should probably first try one of the existing Python wrappers for > Google's chart API and see if that meets your needs: > http://code.google.com/p/google-chartwrapper/ > http://pygooglechart.slowchop.com/ > > Cheers, > Chris > -- > http://blog.rebertia.com > -------------- next part -------------- An HTML attachment was scrubbed... URL: From stackslip at gmail.com Thu Jan 6 00:17:23 2011 From: stackslip at gmail.com (Garland Fulton) Date: Wed, 5 Jan 2011 20:17:23 -0900 Subject: Google Chart API, HTTP POST request format. In-Reply-To: References: Message-ID: Thank you for showing me the POST request, I will defiantly learn a lot from that. On Wed, Jan 5, 2011 at 7:26 PM, Tim Harig wrote: > On 2011-01-06, Slie wrote: > [reformated to <80 columns per RFC 1855 guidelines] > > I have read several examples on python post requests but I'm not sure > > mine needs to be that complicated. > > >From the HTML example on the page you posted: > >
> > > > > > >
> > you can retreive the same chart from Python: > > Python 3.1.2 (r312:79147, Oct 9 2010, 00:16:06) > [GCC 4.4.4] on linux2 > Type "help", "copyright", "credits" or "license" for more information. > >>> import urllib.request, urllib.parse > >>> params = urllib.parse.urlencode({'cht':'lc', 'chtt':'This is | my > >>> chart', > ... 'chs':'600x200', 'chxt':'x,y', 'chd':'t:40,20,50,20,100'}) > >>> chart = urllib.request.urlopen('https://chart.googleapis.com/chart > ', > ... data = params).read() > >>> chartFile = open("chart.png", 'wb') > >>> chartFile.write(chart) > 10782 > >>> chartFile.close() > -- > http://mail.python.org/mailman/listinfo/python-list > -------------- next part -------------- An HTML attachment was scrubbed... URL: From kb1pkl at aim.com Thu Jan 6 00:21:54 2011 From: kb1pkl at aim.com (Corey Richardson) Date: Thu, 06 Jan 2011 00:21:54 -0500 Subject: Google Chart API, HTTP POST request format. In-Reply-To: References: Message-ID: <4D255172.8020607@aim.com> On 01/06/2011 12:16 AM, Garland Fulton wrote: > I tried to use "pygooglechart.py" and I have been trying to get it set > up all day actually along with several other graphing API's. > > I just found out that there is a problem with numpy and python 3.1 that > is why I moved from the API's. Should I change version just for > these library's? > > Should I be learning Python on 3.1? > > Awesome! > > [snip] I swapped from 3 to 2.6 a while back, better support for modules, and not really losing much in the way of features. ~Corey Richardson From clp2 at rebertia.com Thu Jan 6 00:30:41 2011 From: clp2 at rebertia.com (Chris Rebert) Date: Wed, 5 Jan 2011 21:30:41 -0800 Subject: Google Chart API, HTTP POST request format. In-Reply-To: References: Message-ID: > On Wed, Jan 5, 2011 at 7:52 PM, Chris Rebert wrote: >> On Wed, Jan 5, 2011 at 7:36 PM, Slie wrote: >> > >> > http://code.google.com/apis/chart/docs/post_requests.html >> > >> > Google will return a chart in your browser from a URL that you have >> > built. If your URL is bigger then 2K characters it will allow you to submit >> > POST requests. >> > >> > They gives examples of HTML, JavaScript, and PHP POST requests. Is there >> > a way I can submit a request with Python? Or possibly submit the HTML, >> > JavaScript or PHP using python?(That was a long shot thought). If I do that >> > I would need to find out what to do with the .PNG it gives me. >> > >> > Am I headed in the right direction, is the above paragraph about >> > submitting an HTML form from my program even logical? >> >> You should probably first try one of the existing Python wrappers for >> Google's chart API and see if that meets your needs: >> http://code.google.com/p/google-chartwrapper/ >> http://pygooglechart.slowchop.com/ On Wed, Jan 5, 2011 at 9:16 PM, Garland Fulton wrote: > I tried to use "pygooglechart.py" and I have been trying to get it set up > all day actually along with several other graphing API's. > I just found out that there is a problem with numpy and python 3.1 that is > why I moved from the API's. Should I change version just for > these?library's? > Should I be learning Python on 3.1? Most third-party libraries have yet to be ported to Python 3.1 (with a few notable exceptions). If you actually want to write non-(toy/demo/trivial) programs, you should probably use Python 2.x. Python 3.1 is fine for learning the basics of the language; once you've done that, learning the Python 2.x differences and wart workarounds is not hard. (Also, in the future, please don't top-post.) Cheers, Chris -- http://blog.rebertia.com From stackslip at gmail.com Thu Jan 6 00:52:01 2011 From: stackslip at gmail.com (Garland Fulton) Date: Wed, 5 Jan 2011 20:52:01 -0900 Subject: Google Chart API, HTTP POST request format. In-Reply-To: References: Message-ID: On Wed, Jan 5, 2011 at 7:52 PM, Chris Rebert wrote: > On Wed, Jan 5, 2011 at 7:36 PM, Slie wrote: > > > > http://code.google.com/apis/chart/docs/post_requests.html > > > > Google will return a chart in your browser from a URL that you have > built. If your URL is bigger then 2K characters it will allow you to submit > POST requests. > > > > They gives examples of HTML, JavaScript, and PHP POST requests. Is there > a way I can submit a request with Python? Or possibly submit the HTML, > JavaScript or PHP using python?(That was a long shot thought). If I do that > I would need to find out what to do with the .PNG it gives me. > > > > Am I headed in the right direction, is the above paragraph about > submitting an HTML form from my program even logical? > > You should probably first try one of the existing Python wrappers for > Google's chart API and see if that meets your needs: > http://code.google.com/p/google-chartwrapper/ > http://pygooglechart.slowchop.com/ > > Cheers, > Chris > -- > http://blog.rebertia.com > Google Chart Wrapper is compatible with 3.1 and i have been looking all day for something like this. Thank you. -------------- next part -------------- An HTML attachment was scrubbed... URL: From stefan.sonnenberg at pythonmeister.com Thu Jan 6 01:08:14 2011 From: stefan.sonnenberg at pythonmeister.com (Stefan Sonnenberg-Carstens) Date: Thu, 06 Jan 2011 07:08:14 +0100 Subject: Attaching C++ libraries to Python app. In-Reply-To: References: , Message-ID: <4D255C4E.4060500@pythonmeister.com> Am 05.01.2011 23:44, schrieb Rohit Coder: > I am just asking. In future I may need to import any C++ library, not > a Crypto, but some other. Is it possible? Yes. There are at least five possible ways: - Handcode the interface and glue code (http://docs.python.org/extending) - use SWIG to autogenerate (mostly) the interface (http://www.swig.org) - using BOOST's python interface (http://www.boost.org/doc/libs/1_45_0/libs/python/doc/index.html) - using ctypes module for runtime interaction (like and use it a _lot_, very cool for rapid prototyping :-) http://docs.python.org/library/ctypes.html) - cython (different approach, implements a python subset, http://cython.org) I used SWIG and ctypes in the past, as it seems (for me) the easiest way. > > > Date: Wed, 5 Jan 2011 22:44:15 +0100 > > Subject: Re: Attaching C++ libraries to Python app. > > From: stefan.sonnenberg at pythonmeister.com > > To: passionate_programmer at hotmail.com > > CC: python-list at python.org > > > > You don't need to reinvent the wheel: > > > > http://www.dlitz.net/software/pycrypto/ > > > > Am Mi, 5.01.2011, 22:21 schrieb Rohit Coder: > > > > > > Is it possible to use C++ libraries within a Python application? I am > > > planning to write an encryption program and want to use GnuPG C++ > > > > libraries.elementFontfont-familyfont-sizefont-stylefont-variantfont-weightletter-spacingline-heighttext-decorationtext-aligntext-indenttext-transformwhite-spaceword-spacingcolorBackgroundbg-attachmentbg-colorbg-imagebg-positionbg-repeatBoxwidthheightborder-topborder-rightborder-bottomborder-leftmarginpaddingmax-heightmin-heightmax-widthmin-widthoutline-coloroutline-styleoutline-widthPositioningpositiontopbottomrightleftfloatdisplayclearz-indexListlist-style-imagelist-style-typelist-style-positionTablevertical-alignborder-collapseborder-spacingcaption-sideempty-cellstable-layoutEffectstext-shadow-webkit-box-shadowborder-radiusOtheroverflowcursorvisibility > > > ...................................................Rohit. -- > > > http://mail.python.org/mailman/listinfo/python-list > > > > > > > > > -- > > MfG, > > > > Stefan Sonnenberg-Carstens > > > > IT Architect > > > element > > Font > font-family > font-size > font-style > font-variant > font-weight > letter-spacing > line-height > text-decoration > text-align > text-indent > text-transform > white-space > word-spacing > color > Background > bg-attachment > bg-color > bg-image > bg-position > bg-repeat > Box > width > height > border-top > border-right > border-bottom > border-left > margin > padding > max-height > min-height > max-width > min-width > outline-color > outline-style > outline-width > Positioning > position > top > bottom > right > left > float > display > clear > z-index > List > list-style-image > list-style-type > list-style-position > Table > vertical-align > border-collapse > border-spacing > caption-side > empty-cells > table-layout > Effects > text-shadow > -webkit-box-shadow > border-radius > Other > overflow > cursor > visibility > -------------- next part -------------- An HTML attachment was scrubbed... URL: From stackslip at gmail.com Thu Jan 6 02:21:53 2011 From: stackslip at gmail.com (Garland Fulton) Date: Wed, 5 Jan 2011 22:21:53 -0900 Subject: Google Chart API, HTTP POST request format. In-Reply-To: References: Message-ID: On Wed, Jan 5, 2011 at 7:26 PM, Tim Harig wrote: > On 2011-01-06, Slie wrote: > [reformated to <80 columns per RFC 1855 guidelines] > > I have read several examples on python post requests but I'm not sure > > mine needs to be that complicated. > > >From the HTML example on the page you posted: > >
> > > > > > >
> > you can retreive the same chart from Python: > > Python 3.1.2 (r312:79147, Oct 9 2010, 00:16:06) > [GCC 4.4.4] on linux2 > Type "help", "copyright", "credits" or "license" for more information. > >>> import urllib.request, urllib.parse > >>> params = urllib.parse.urlencode({'cht':'lc', 'chtt':'This is | my > >>> chart', > ... 'chs':'600x200', 'chxt':'x,y', 'chd':'t:40,20,50,20,100'}) > >>> chart = urllib.request.urlopen('https://chart.googleapis.com/chart > ', > ... data = params).read() > >>> chartFile = open("chart.png", 'wb') > >>> chartFile.write(chart) > 10782 > >>> chartFile.close() > -- > http://mail.python.org/mailman/listinfo/python-list > Hope this isn't to stupid, For the chart = urllib.request.urlopen('https://chart.googleapis.com/chart', data = params).read() Where would I find information on why and what the ).read() part does. Thank you, -------------- next part -------------- An HTML attachment was scrubbed... URL: From passionate_programmer at hotmail.com Thu Jan 6 04:05:58 2011 From: passionate_programmer at hotmail.com (Rohit Coder) Date: Thu, 6 Jan 2011 14:35:58 +0530 Subject: How suitable is Python to write system utilities? Message-ID: Is Python suitable to write low-level system utilities like Defrag, Malware Removal Tools and Drivers? -------------- next part -------------- An HTML attachment was scrubbed... URL: From stefan_ml at behnel.de Thu Jan 6 04:57:08 2011 From: stefan_ml at behnel.de (Stefan Behnel) Date: Thu, 06 Jan 2011 10:57:08 +0100 Subject: Attaching C++ libraries to Python app. In-Reply-To: <4D255C4E.4060500@pythonmeister.com> References: , <4D255C4E.4060500@pythonmeister.com> Message-ID: Stefan Sonnenberg-Carstens, 06.01.2011 07:08: > Am 05.01.2011 23:44, schrieb Rohit Coder: >> I am just asking. In future I may need to import any C++ library, not a >> Crypto, but some other. Is it possible? > Yes. > There are at least five possible ways: > > - Handcode the interface and glue code (http://docs.python.org/extending) > - use SWIG to autogenerate (mostly) the interface (http://www.swig.org) > - using BOOST's python interface > (http://www.boost.org/doc/libs/1_45_0/libs/python/doc/index.html) None of these is worth recommending. Too much work, too hard to build a good interface with them and simply too slow for the invested effort. Their main drawback is that they distract you from designing wrappers and require you to think about lots of C/C++ problems. > - using ctypes module for runtime interaction (like and use it a _lot_, > very cool for rapid prototyping :-) > http://docs.python.org/library/ctypes.html) > - cython (different approach, implements a python subset, http://cython.org) IMHO, these are the two ways to do it nowadays. Cython wrappers are obviously much faster than anything you could ever write in ctypes, but both are similarly easy to use and allow users to focus on good wrapper design. Stefan From clp2 at rebertia.com Thu Jan 6 05:57:24 2011 From: clp2 at rebertia.com (Chris Rebert) Date: Thu, 6 Jan 2011 02:57:24 -0800 Subject: Google Chart API, HTTP POST request format. In-Reply-To: References: Message-ID: On Wed, Jan 5, 2011 at 11:21 PM, Garland Fulton wrote: > On Wed, Jan 5, 2011 at 7:26 PM, Tim Harig wrote: >> >> On 2011-01-06, Slie wrote: >> [reformated to <80 columns per RFC 1855 guidelines] >> > I have read several examples on python post requests but I'm not sure >> > mine needs to be that complicated. >> >> >From the HTML example on the page you posted: >> >> ? ?
>> ? ? ? ? >> ? ? ? ? >> ? ? ? ? >> ? ? ? ? >> ? ? ? ? >> ? ? ? ? >> ? ?
>> >> you can retreive the same chart from Python: >> >> ? ?Python 3.1.2 (r312:79147, Oct ?9 2010, 00:16:06) >> ? ?[GCC 4.4.4] on linux2 >> ? ?Type "help", "copyright", "credits" or "license" for more information. >> ? ?>>> import urllib.request, urllib.parse >> ? ?>>> params = urllib.parse.urlencode({'cht':'lc', 'chtt':'This is | my >> ? ?>>> chart', >> ? ?... ? ? ? ? 'chs':'600x200', 'chxt':'x,y', 'chd':'t:40,20,50,20,100'}) >> ? ?>>> chart = >> urllib.request.urlopen('https://chart.googleapis.com/chart', >> ? ?... ? ? ? ? data = params).read() >> ? ?>>> chartFile = open("chart.png", 'wb') >> ? ?>>> chartFile.write(chart) >> ? ?10782 >> ? ?>>> chartFile.close() >> -- >> http://mail.python.org/mailman/listinfo/python-list > > Hope this isn't to stupid, > For the > chart = urllib.request.urlopen('https://chart.googleapis.com/chart', data = > params).read() > Where would I find information on why and what the ).read() part does. http://docs.python.org/py3k/library/urllib.request.html#urllib.request.urlopen Specifically: "This function returns a file-like object" (representing the stream of data received). Thus, .read() on the file-like object returns the actual bytes obtained from the given URL. Cheers, Chris -- http://blog.rebertia.com From clp2 at rebertia.com Thu Jan 6 06:01:28 2011 From: clp2 at rebertia.com (Chris Rebert) Date: Thu, 6 Jan 2011 03:01:28 -0800 Subject: How suitable is Python to write system utilities? In-Reply-To: References: Message-ID: On Thu, Jan 6, 2011 at 1:05 AM, Rohit Coder wrote: > Is Python suitable to write low-level system utilities like Defrag, Malware > Removal Tools and Drivers? No; but I wouldn't classify a malware remover as a "low-level system utility". Writing such a tool in Python seems pretty feasible. Cheers, Chris -- http://blog.rebertia.com From alice at gothcandy.com Thu Jan 6 06:08:28 2011 From: alice at gothcandy.com (=?utf-8?Q?Alice_Bevan=E2=80=93McGregor?=) Date: Thu, 6 Jan 2011 03:08:28 -0800 Subject: How suitable is Python to write system utilities? References: Message-ID: On 2011-01-06 01:35:58 -0800, Rohit Coder said: > Is Python suitable to write low-level system utilities like Defrag, > Malware Removal Tools and Drivers? Yes and no. Python does include libraries (and has available third-party libraries) to interface with external low-level libraries of every kind, has Python-native third-party libraries to do things like examine ELF object files / executables, manipulate raw IP datagrams, etc, and it is possible to access glib (and other C libraries or even Windows DLLs) directly from within Python without creating wrapper interfaces. While you -can- do all of these things, the question becomes do you really -want to-? I've implemented server monitoring suites, FUSE filesystem drivers, and other strange low-level things in Python. This doesn't mean I'm getting the best "bang for the buck" when it comes to performance or overhead; I'm trading these things for the ease of prototyping, debugging, and the ability to utilize other high-level interfaces. My FUSE driver won't be as performant as it would have been had I written it in C. My server monitoring suite consumes more RAM than an equivalent solution in C. When it comes down to it, if you want it done efficiently, use C. ;) (As an aside, you -can- create hideous frankenstein monsters by using compiled CPython modules with glue code between the driver API, e.g. FUSE, and your CPython driver implementation; but in that case you're adding the overhead of Python for no gain whatsoever.) For anything system critical, Python might not be the best choice. Malware removal tools are themselves the target of malware (e.g. virii attempting to disable scanners and removal tools), and utilizing Python adds (IMHO) too many points of failure. Also, file fragmentation is a non-issue on all modern filesystems (ext3/4, reiser, ntfs, hfs+, etc.) as they perform live-system defragmentation to varying degrees. I have never seen a production server of mine (utilizing reiserfs) go above 11% fragmentation (non-contiguous extant allocations), and even that resolved itself within a few hours of active use. Note that non-contiguous extants are a distinct problem, reducing file read performance substantially, thus why filesystem drivers generally handle solving this problem by themselves. The other forms of fragmentation (free space fragmentation and file scattering / related-file fragmentation) substantially less so. Certain filesystems have features designed to avoid the latter (e.g. squashfs for ordering files on bootable CDs) and the former becomes more of an issue as you attempt to allocate extremely large contiguous files. (Becoming worse as free space is exhausted as more and more files of greater size need to be shuffled around the disk platter in order to free up a contiguous run of extants.) Hope this helps, - Alice. From passionate_programmer at hotmail.com Thu Jan 6 06:32:55 2011 From: passionate_programmer at hotmail.com (Rohit Coder) Date: Thu, 6 Jan 2011 17:02:55 +0530 Subject: Working with PyQt and Pydev Message-ID: I installed the PyDev plugin into Aptana Stdui 3 Beta. Someone suggested me to use PyQt for Python GUI app, and so I downloaded and installed PyQt. But when I open Aptana Studio, I could see a new menu added with the name "PyDev", but there is nothing for PyQt. In the Windows Start Meny item list, I could see a folder named PyQt and when I open it, there are few tools like Designer. When Designer is run, it opens Qt IDE for designing Forms like Visual Studio and the files have the extension .ui.I want to know how to integrate PyQt and PyDev. Do I need to use them separately by adding the .ui files to PyDev and then adding Python core code for functionality? ...............Rohit.elementFontfont-familyfont-sizefont-stylefont-variantfont-weightletter-spacingline-heighttext-decorationtext-aligntext-indenttext-transformwhite-spaceword-spacingcolorBackgroundbg-attachmentbg-colorbg-imagebg-positionbg-repeatBoxwidthheightborder-topborder-rightborder-bottomborder-leftmarginpaddingmax-heightmin-heightmax-widthmin-widthoutline-coloroutline-styleoutline-widthPositioningpositiontopbottomrightleftfloatdisplayclearz-indexListlist-style-imagelist-style-typelist-style-positionTablevertical-alignborder-collapseborder-spacingcaption-sideempty-cellstable-layoutEffectstext-shadow-webkit-box-shadowborder-radiusOtheroverflowcursorvisibility -------------- next part -------------- An HTML attachment was scrubbed... URL: From davea at ieee.org Thu Jan 6 06:38:01 2011 From: davea at ieee.org (Dave Angel) Date: Thu, 06 Jan 2011 06:38:01 -0500 Subject: Help with code-lists and strings In-Reply-To: <4D255309.5070109@gmail.com> References: <4D253449.90507@ieee.org> <4D255309.5070109@gmail.com> Message-ID: <4D25A999.6090508@ieee.org> On 01/06/2011 12:28 AM, Steven Howe wrote: > On 01/05/2011 07:17 PM, Dave Angel wrote: >> On 01/-10/-28163 02:59 PM, GrayShark wrote: >>> >> < >>> In python it's best to build up you functional needs. So two steps. >>> First >>> a nand (negative 'and' operation). Then wrap that with a function to >>> create >>> two strings of your list element, you''re calling 'word'. By the way, >>> list is reserved word, like string. Don't get in the bad habit of >>> using it. >>> >>> def nand( a, b ): >>> """nand has to vars. Both must be strings """ >>> return( ( not eval( a ) ) and ( not eval( b ) ) ) >>> >> >> Two problems with that. One is that you've defined a NOR function, but >> called it nand(). The other is using eval. There's no need for it, and >> it's both slow and risky. >> >> DaveA >> > Stupid. > All code is risky. > As to a nand operation, it not the same as a nor operation. > Stupid Well, if you're going to attack me, you could try to get your facts straight. Of course namd is different than nor. If it were not, I wouldn't have responded. NAND is defined as NOT (A and B) while NOR is defined as NOT (A or B) What you defined was the contrapositive of NOR, but you called it nand() If you need a refresher, check out http://en.wikipedia.org/wiki/Negated_AND_gate In particular, see the truth table, using ones and zeroes. DaveA From user at example.net Thu Jan 6 06:52:38 2011 From: user at example.net (J.O. Aho) Date: Thu, 06 Jan 2011 12:52:38 +0100 Subject: How suitable is Python to write system utilities? In-Reply-To: References: Message-ID: <8oloo6F566U1@mid.individual.net> Alice Bevan?McGregor wrote: > On 2011-01-06 01:35:58 -0800, Rohit Coder said: > >> Is Python suitable to write low-level system utilities like Defrag, >> Malware Removal Tools and Drivers? > > Yes and no. > > Also, file fragmentation is a non-issue on all modern filesystems > (ext3/4, reiser, ntfs, hfs+, etc.) as they perform live-system > defragmentation to varying degrees. According to microsoft documentation, the recommendation is to run defragmentation on ntfs on a regular bases. There seems to come some improvement on the mft fragmentation, but still it feels long behind the linux/unix file systems. Do you have any recent documentation on ntfs that shows it has the capability to defragmentate itself other than mft? -- //Aho From usernet at ilthio.net Thu Jan 6 08:19:17 2011 From: usernet at ilthio.net (Tim Harig) Date: Thu, 6 Jan 2011 13:19:17 +0000 (UTC) Subject: Google Chart API, HTTP POST request format. References: Message-ID: On 2011-01-06, Chris Rebert wrote: > On Wed, Jan 5, 2011 at 11:21 PM, Garland Fulton wrote: >> On Wed, Jan 5, 2011 at 7:26 PM, Tim Harig wrote: >>> ? ?Python 3.1.2 (r312:79147, Oct ?9 2010, 00:16:06) >>> ? ?[GCC 4.4.4] on linux2 >>> ? ?Type "help", "copyright", "credits" or "license" for more information. >>> ? ?>>> import urllib.request, urllib.parse >>> ? ?>>> params = urllib.parse.urlencode({'cht':'lc', 'chtt':'This is | my >>> ? ?>>> chart', Sorry I didn't notice this got accidently wrapped when I pasted it. >>> params = urllib.parse.urlencode({'cht':'lc', 'chtt':'This is | my chart', >>> ? ?... ? ? ? ? 'chs':'600x200', 'chxt':'x,y', 'chd':'t:40,20,50,20,100'}) >>> ? ?>>> chart = >>> urllib.request.urlopen('https://chart.googleapis.com/chart', >>> ? ?... ? ? ? ? data = params).read() >>> ? ?>>> chartFile = open("chart.png", 'wb') >>> ? ?>>> chartFile.write(chart) >>> ? ?10782 >>> ? ?>>> chartFile.close() >> >> Hope this isn't to stupid, >> For the >> chart = urllib.request.urlopen('https://chart.googleapis.com/chart', data = >> params).read() >> Where would I find information on why and what the ).read() part does. For some reason, posts from from this account don't seem to be making it through the gateway to usenet so I am only seeing what Mr. Rebert has replied to. If you have asked anything else, I very well may have missed it. > http://docs.python.org/py3k/library/urllib.request.html#urllib.request.urlopen > Specifically: "This function returns a file-like object" (representing > the stream of data received). Thus, .read() on the file-like object > returns the actual bytes obtained from the given URL. Mr. Rebert already answed your question; but, I will expand on that a little bit. One of the great things about the Python language is that it uses what is commonly known as "duck typing." That is anything object which provides the same attributes as another object can be used as though it is actually the second object. It is kind of like an implicit form of generics that doesn't require a template or an interface. The Python standard library makes extensive use of duck typing for file like objects. Any object that provides the proper method attributes can be given to functions that expect files even though the object is given might not be the traditional concept of a file on the filesystem. It might be a stringIO object, a socket file object, or something new that you have created that supports the required method attributes. The semantics and documentation for file like objects have changed a little for python2 vs. python3: python2: http://docs.python.org/library/stdtypes.html#file-objects python3: http://docs.python.org/py3k/library/io.html#io.IOBase but they still basically work the same way. Much of the Python 3 documentation still refers file objects. From roy at panix.com Thu Jan 6 08:21:38 2011 From: roy at panix.com (Roy Smith) Date: Thu, 06 Jan 2011 08:21:38 -0500 Subject: How suitable is Python to write system utilities? References: <8oloo6F566U1@mid.individual.net> Message-ID: In article <8oloo6F566U1 at mid.individual.net>, "J.O. Aho" wrote: > According to microsoft documentation, the recommendation is to run > defragmentation on ntfs on a regular bases. There seems to come some > improvement on the mft fragmentation, but still it feels long behind the > linux/unix file systems. > > Do you have any recent documentation on ntfs that shows it has the capability > to defragmentate itself other than mft? This is the best defragmenter for a windows file system is this: http://www.ubuntu.com/desktop/get-ubuntu/download From user at example.net Thu Jan 6 08:42:44 2011 From: user at example.net (J.O. Aho) Date: Thu, 06 Jan 2011 14:42:44 +0100 Subject: How suitable is Python to write system utilities? In-Reply-To: References: <8oloo6F566U1@mid.individual.net> Message-ID: <8olv6kFb8hU1@mid.individual.net> Roy Smith wrote: > In article <8oloo6F566U1 at mid.individual.net>, > "J.O. Aho" wrote: > >> According to microsoft documentation, the recommendation is to run >> defragmentation on ntfs on a regular bases. There seems to come some >> improvement on the mft fragmentation, but still it feels long behind the >> linux/unix file systems. >> >> Do you have any recent documentation on ntfs that shows it has the capability >> to defragmentate itself other than mft? > > This is the best defragmenter for a windows file system is this: > > http://www.ubuntu,com/desktop/get-ubuntu/download It depends on your taste, I favour to be able to customize quite a lot of my installation and those rather use a meta-distribution. As SourceMage ( www.sourcemage.org ) or Gentoo ( www.gentoo.org ). But your reply don't point at a ms-documentation about auto defragmentation of a file system. -- //Aho From private at private.com Thu Jan 6 08:44:08 2011 From: private at private.com (ana sanchez) Date: Thu, 6 Jan 2011 13:44:08 +0000 (UTC) Subject: why generator assigned to slice? References: Message-ID: In Peter Otten <__peter__ at web.de> writes: >ana sanchez wrote: >> i found this when i read the source of a program in python: >> >> self.__chunks[start:end] = (chunk for i in xrange(start, end)) >> what utility has to assign a generator to a slice??? ?the *final >> result* isn't the same as this?: >> >> self.__chunks[start:end] = [chunk for i in xrange(start, end)] >Whoever used the first variant probably was hoping that it was either faster >or used less peak memory. I think the latter is wrong, and the former can >easily be checked: >$ python -m timeit -s'chunk = "yadda"; chunks = range(100); start = 20; end >= 50' 'chunks[start:end] = (chunk for i in xrange(start, end))' >100000 loops, best of 3: 9.02 usec per loop >$ python -m timeit -s'chunk = "yadda"; chunks = range(100); start = 20; end >= 50' 'chunks[start:end] = [chunk for i in xrange(start, end)]' >100000 loops, best of 3: 4.16 usec per loop >$ python -m timeit -s'chunk = "yadda"; chunks = range(100); start = 20; end >= 50' 'chunks[start:end] = [chunk]*(end-start)' >1000000 loops, best of 3: 1.02 usec per loop peter thank you very much!!! (i like very much the timing "miniscripts") ana From Rob.Richardson at rad-con.com Thu Jan 6 08:50:51 2011 From: Rob.Richardson at rad-con.com (Rob Richardson) Date: Thu, 6 Jan 2011 08:50:51 -0500 Subject: Help with code-lists and strings In-Reply-To: Message-ID: <04A6DB42D2BA534FAC77B90562A6A03D01689A94@server.rad-con.local> Cathy, Please take another try at writing your program, using what advice you have received so far that you understand. I think this discussion is going rather far away from what you need, and seeing another step in the evolution of your program should help bring it back on track. I like your optimism! RobR From roy at panix.com Thu Jan 6 08:55:08 2011 From: roy at panix.com (Roy Smith) Date: Thu, 06 Jan 2011 08:55:08 -0500 Subject: How suitable is Python to write system utilities? References: <8oloo6F566U1@mid.individual.net> <8olv6kFb8hU1@mid.individual.net> Message-ID: In article <8olv6kFb8hU1 at mid.individual.net>, "J.O. Aho" wrote: > Roy Smith wrote: > > In article <8oloo6F566U1 at mid.individual.net>, > > "J.O. Aho" wrote: > > > >> According to microsoft documentation, the recommendation is to run > >> defragmentation on ntfs on a regular bases. There seems to come some > >> improvement on the mft fragmentation, but still it feels long behind the > >> linux/unix file systems. > >> > >> Do you have any recent documentation on ntfs that shows it has the > >> capability > >> to defragmentate itself other than mft? > > > > This is the best defragmenter for a windows file system is this: > > > > http://www.ubuntu,com/desktop/get-ubuntu/download > > It depends on your taste, I favour to be able to customize quite a lot of my > installation and those rather use a meta-distribution. > > As SourceMage ( www.sourcemage.org ) or Gentoo ( www.gentoo.org ). > > But your reply don't point at a ms-documentation about auto defragmentation > of > a file system. I think you missed the point :-) From david at boddie.org.uk Thu Jan 6 09:38:24 2011 From: david at boddie.org.uk (David Boddie) Date: Thu, 06 Jan 2011 15:38:24 +0100 Subject: How suitable is Python to write system utilities? References: Message-ID: On Thursday 06 January 2011 12:08, Alice Bevan?McGregor wrote: > Python does include libraries (and has available third-party libraries) > to interface with external low-level libraries of every kind, has > Python-native third-party libraries to do things like examine ELF > object files / executables, manipulate raw IP datagrams, etc, and it is > possible to access glib (and other C libraries or even Windows DLLs) > directly from within Python without creating wrapper interfaces. Just out of interest, which module/package are you using to examine ELF files? David From alice at gothcandy.com Thu Jan 6 10:06:17 2011 From: alice at gothcandy.com (=?utf-8?Q?Alice_Bevan=E2=80=93McGregor?=) Date: Thu, 6 Jan 2011 07:06:17 -0800 Subject: How suitable is Python to write system utilities? References: Message-ID: On 2011-01-06 06:38:24 -0800, David Boddie said: > Just out of interest, which module/package are you using to examine ELF files? http://pypi.python.org/pypi/elffile - Alice. From dmitrey.kroshko at scipy.org Thu Jan 6 10:28:49 2011 From: dmitrey.kroshko at scipy.org (dmitrey) Date: Thu, 6 Jan 2011 07:28:49 -0800 (PST) Subject: PEP: possibility of inline using of a symbol instead of "import" Message-ID: <0952cc24-097d-4685-a92d-75054406ddf3@f20g2000vbc.googlegroups.com> hi all, I have th PEP (I'm not sure something like that hadn't been proposed although): very often in a Python file header the following lines are present, like: from MyModule1 import myFunc1 import MyModule2 as mm2 from MyModule3 import myFunc3 as mf3 etc and after several pages of code they are using somewhere, maybe only one time, e.g. r1 = myFunc1(...) r2 = mm2.myFunc2(...) r3 = mf3(...) It makes programs less clear, you have to scroll several pages of code in IDE to understand what it refers to. I propose to add possibility of using a symbol instead (for simplicity I use @ here, that is already reserved for decorators, thus it should be other symbol, maybe from Unicode although for simplicity to type it I would prefer something ordinary like $ or ` or !). e.g. instead of import MyModule (...lots of code...) r = MyModule.myFunc(...) someone could just type in the single place r = @MyModule.myFunc(...) Also, "import MyModule2 as mm2" could be replaced to mere mm2 = @MyModule2 and "from MyModule3 import myFunc3 as mf3" could be replaced to mere "mf3 = @MyModule3.myFunc3". As for __import__(ModuleTextName), it could be replaced to something like @(ModuleTextName) or @{ModuleTextName} or @[ModuleTextName]. Regards, D. From shahmed at sfwmd.gov Thu Jan 6 10:51:42 2011 From: shahmed at sfwmd.gov (Ahmed, Shakir) Date: Thu, 6 Jan 2011 10:51:42 -0500 Subject: list from FTP server to a text file In-Reply-To: References: Message-ID: <77F33A87D54B2F47AB06A81DA7B5252736DBED@EXCHVS02.ad.sfwmd.gov> Hi, I am trying to create a list in a txt file from an ftp server. The following code is retrieving the list of the files but could not able to write in a text file. Any help is highly appreciated. Thanks **************************** import os import time from ftplib import FTP ftp = FTP("*.org","","") # connect to host, default port ftp.login() ftp.cwd("/pub/remotefolder/") ftp.retrlines('NLST') ****************************** From usernet at ilthio.net Thu Jan 6 10:57:46 2011 From: usernet at ilthio.net (Tim Harig) Date: Thu, 6 Jan 2011 15:57:46 +0000 (UTC) Subject: PEP: possibility of inline using of a symbol instead of "import" References: <0952cc24-097d-4685-a92d-75054406ddf3@f20g2000vbc.googlegroups.com> Message-ID: On 2011-01-06, dmitrey wrote: > and after several pages of code they are using somewhere, maybe only > one time, e.g. [SNIP] > It makes programs less clear, you have to scroll several pages of code > in IDE to understand what it refers to. Python doesn't require imports to be at the top of a file. They can be imported at any time. > import MyModule > (...lots of code...) > r = MyModule.myFunc(...) (...lots of code...) import MyModule r = MyModule.myFunc(...) From duncan.booth at invalid.invalid Thu Jan 6 11:02:40 2011 From: duncan.booth at invalid.invalid (Duncan Booth) Date: 6 Jan 2011 16:02:40 GMT Subject: PEP: possibility of inline using of a symbol instead of "import" References: <0952cc24-097d-4685-a92d-75054406ddf3@f20g2000vbc.googlegroups.com> Message-ID: dmitrey wrote: > e.g. instead of > > import MyModule > (...lots of code...) > r = MyModule.myFunc(...) > > someone could just type in the single place > > r = @MyModule.myFunc(...) > > Also, "import MyModule2 as mm2" could be replaced to mere > mm2 = @MyModule2 > and "from MyModule3 import myFunc3 as mf3" could be replaced to mere > "mf3 = @MyModule3.myFunc3". If you just import the modules at the top of the file then there's nothing to prevent you writing: mm2 = MyModule2 mf3 = MyModule3.myFunc3 without any punctuation to obscure the meaning. Your complaint seems to be that: r1 = myFunc1(...) is unclear when you don't know where myfunc1 originates, so why don't you write: r1 = MyModule1.myFunc1(...) -- Duncan Booth http://kupuguy.blogspot.com From dmitrey.kroshko at scipy.org Thu Jan 6 11:03:35 2011 From: dmitrey.kroshko at scipy.org (dmitrey) Date: Thu, 6 Jan 2011 08:03:35 -0800 (PST) Subject: PEP: possibility of inline using of a symbol instead of "import" References: <0952cc24-097d-4685-a92d-75054406ddf3@f20g2000vbc.googlegroups.com> Message-ID: <1201388b-16b8-4452-9a1f-c9aa00b126e7@p38g2000vbn.googlegroups.com> Yes, I know, still usually it is placed in file header On Jan 6, 5:57?pm, Tim Harig wrote: > Python doesn't require imports to be at the top of a file. ?They can be > imported at any time. > > > import MyModule > > (...lots of code...) > > r = MyModule.myFunc(...) > > (...lots of code...) > import MyModule > r = MyModule.myFunc(...) From catdude at gmail.com Thu Jan 6 11:06:12 2011 From: catdude at gmail.com (Dan M) Date: Thu, 06 Jan 2011 10:06:12 -0600 Subject: list from FTP server to a text file References: Message-ID: <4-ednbGsULvpdbjQnZ2dnUVZ5rudnZ2d@giganews.com> On Thu, 06 Jan 2011 10:51:42 -0500, Ahmed, Shakir wrote: > Hi, > > I am trying to create a list in a txt file from an ftp server. The > following code is retrieving the list of the files but could not able to > write in a text file. Any help is highly appreciated. > > Thanks > > > > **************************** > import os > import time > from ftplib import FTP > ftp = FTP("*.org","","") # connect to host, default port ftp.login() > ftp.cwd("/pub/remotefolder/") > ftp.retrlines('NLST') > ****************************** WARNING: I am a newbie! Expect more pythonic ways to do this in other replies from ftplib import FTP ftp = FTP("host", "user", "pass") ftp.cwd("/pub/myfolder") files = ftp.nlst(".") f = open('files.txt', 'w') for file in files: f.write('%s\n' % (file,)) f.close() From wanderer at dialup4less.com Thu Jan 6 11:11:34 2011 From: wanderer at dialup4less.com (Wanderer) Date: Thu, 6 Jan 2011 08:11:34 -0800 (PST) Subject: find in smartpdf files Message-ID: <4f69bdf1-2e68-4a6b-8110-09f0f5517387@k9g2000pre.googlegroups.com> We generate PCB assembly files in pdf format using SmartPDF. This allows us to search for a component in the assembly using the find feature. We would like to be able to generate a list of components sorted by part type and then use that list to cycle through a search by ref designator in the pdf file. Is there a way to use Python scripts to interface PDF files? Thanks From catdude at gmail.com Thu Jan 6 11:20:00 2011 From: catdude at gmail.com (Dan M) Date: Thu, 06 Jan 2011 10:20:00 -0600 Subject: find in smartpdf files References: <4f69bdf1-2e68-4a6b-8110-09f0f5517387@k9g2000pre.googlegroups.com> Message-ID: <4-ednbOsULstdrjQnZ2dnUVZ5rudnZ2d@giganews.com> On Thu, 06 Jan 2011 08:11:34 -0800, Wanderer wrote: > We generate PCB assembly files in pdf format using SmartPDF. This allows > us to search for a component in the assembly using the find feature. We > would like to be able to generate a list of components sorted by part > type and then use that list to cycle through a search by ref designator > in the pdf file. Is there a way to use Python scripts to interface PDF > files? > > Thanks Would PDFMiner help with your task? http://www.unixuser.org/~euske/python/pdfminer/index.html From dwdreisigmeyer at gmail.com Thu Jan 6 11:23:49 2011 From: dwdreisigmeyer at gmail.com (David) Date: Thu, 6 Jan 2011 08:23:49 -0800 (PST) Subject: Convert arbitrary function inputs to string Message-ID: Hi, I'd like to have a function that takes arbitrary inputs and returns them as a single string, with proper escapes for special characters I can define. For example: fun( ( + 1 2 ) ) => "( + 1 2)" or fun( (define (myhello str) (begin (print (string-append "Hello " str)) (newline) )) ) => "(define (myhello str) (begin (print (string-append \"Hello \" str)) (newline) ))" Thanks, -Dave From usernet at ilthio.net Thu Jan 6 11:32:31 2011 From: usernet at ilthio.net (Tim Harig) Date: Thu, 6 Jan 2011 16:32:31 +0000 (UTC) Subject: PEP: possibility of inline using of a symbol instead of "import" References: <0952cc24-097d-4685-a92d-75054406ddf3@f20g2000vbc.googlegroups.com> <1201388b-16b8-4452-9a1f-c9aa00b126e7@p38g2000vbn.googlegroups.com> Message-ID: On 2011-01-06, dmitrey wrote: [re-ordered] > On Jan 6, 5:57?pm, Tim Harig wrote: >> Python doesn't require imports to be at the top of a file. ?They can be >> imported at any time. >> >> > import MyModule >> > (...lots of code...) >> > r = MyModule.myFunc(...) >> >> (...lots of code...) >> import MyModule >> r = MyModule.myFunc(...) > > Yes, I know, still usually it is placed in file header 1. Don't top post. 2. Your so-called PEP probably clashes with Python's use of @ for decorators. 3. Do you really expect a language holding the mantra that there should be a single way of doing things to embrace a language bloating feature for what is effectively already possible with the language as it exists? From wanderer at dialup4less.com Thu Jan 6 11:33:14 2011 From: wanderer at dialup4less.com (Wanderer) Date: Thu, 6 Jan 2011 08:33:14 -0800 (PST) Subject: find in smartpdf files References: <4f69bdf1-2e68-4a6b-8110-09f0f5517387@k9g2000pre.googlegroups.com> <4-ednbOsULstdrjQnZ2dnUVZ5rudnZ2d@giganews.com> Message-ID: <4d74bf8f-38c0-4972-b1bc-06307c9a0668@k9g2000pre.googlegroups.com> On Jan 6, 11:20?am, Dan M wrote: > On Thu, 06 Jan 2011 08:11:34 -0800, Wanderer wrote: > > We generate PCB assembly files in pdf format using SmartPDF. This allows > > us to search for a component in the assembly using the find feature. We > > would like to be able to generate a list of components sorted by part > > type and then use that list to cycle through a search by ref designator > > in the pdf file. Is there a way to use Python scripts to interface PDF > > files? > > > Thanks > > Would PDFMiner help with your task?http://www.unixuser.org/~euske/python/pdfminer/index.html I'm not sure. I'll check it out. From jeanmichel at sequans.com Thu Jan 6 11:34:57 2011 From: jeanmichel at sequans.com (Jean-Michel Pichavant) Date: Thu, 06 Jan 2011 17:34:57 +0100 Subject: Convert arbitrary function inputs to string In-Reply-To: References: Message-ID: <4D25EF31.1050608@sequans.com> David wrote: > Hi, > > I'd like to have a function that takes arbitrary inputs and returns > them as a single string, with proper escapes for special characters I > can define. For example: > > fun( ( + 1 2 ) ) > => "( + 1 2)" > > or > > fun( (define (myhello str) (begin (print (string-append "Hello " > str)) (newline) )) ) > => "(define (myhello str) (begin (print (string-append \"Hello \" > str)) (newline) ))" > > Thanks, > > -Dave > Are you talking about python ?? fun( ( + 1 2 ) ) File "", line 1 fun( ( + 1 2 ) ) ^ SyntaxError: invalid syntax From mrmakent at cox.net Thu Jan 6 11:40:16 2011 From: mrmakent at cox.net (Mike Kent) Date: Thu, 6 Jan 2011 08:40:16 -0800 (PST) Subject: PEP: possibility of inline using of a symbol instead of "import" References: <0952cc24-097d-4685-a92d-75054406ddf3@f20g2000vbc.googlegroups.com> Message-ID: <6f5c2fd1-6e72-4b55-88a2-efcce0e9724b@z17g2000prz.googlegroups.com> On Jan 6, 11:02?am, Duncan Booth wrote: > Your complaint seems to be that: > > ? ?r1 = myFunc1(...) > > is unclear when you don't know where myfunc1 originates, so why don't > you write: > > ? ?r1 = MyModule1.myFunc1(...) > > -- > Duncan Boothhttp://kupuguy.blogspot.com My interpretation of his proposal is a bit different. I thought he meant that '@MyModule.myFunc' (yes, using '@' here is bad, but for conversation sake...) would cause MyModule to be imported if this was the first time '@MyModule' was encountered in the current module. Sort of an implied 'import MyModule', which would eliminate the need to actually use the explicit import. My reaction to his proposal is 'Meh.' Explicit is better than implicit. Python is not Perl. From eva_maia at sapo.pt Thu Jan 6 11:41:21 2011 From: eva_maia at sapo.pt (Eva Maia) Date: Thu, 06 Jan 2011 16:41:21 +0000 Subject: type of methods of builtin exceptions Message-ID: <4D25F0B1.5030905@sapo.pt> Hi, anyone has a list of the types of methods of builtin exceptions. For example, for the exception BaseException i need to know the type of arguments method __reduce__ and type of your return. Thanks, Eva Maia From ian.g.kelly at gmail.com Thu Jan 6 11:41:36 2011 From: ian.g.kelly at gmail.com (Ian) Date: Thu, 6 Jan 2011 08:41:36 -0800 (PST) Subject: Convert arbitrary function inputs to string References: Message-ID: <0f1768db-1636-4afd-8cec-f1724b55529a@c39g2000yqi.googlegroups.com> On Jan 6, 9:23?am, David wrote: > Hi, > > I'd like to have a function that takes arbitrary inputs and returns > them as a single string, with proper escapes for special characters I > can define. ?For example: What sorts of arbitrary inputs? Strings? Sequences of strings? Something else? It's not clear from your examples, which use invalid syntax. If you're looking for something like the "quote" form from Lisp, you can't really do that in Python. Just use a string. Cheers, Ian From dwdreisigmeyer at gmail.com Thu Jan 6 11:42:23 2011 From: dwdreisigmeyer at gmail.com (David Dreisigmeyer) Date: Thu, 6 Jan 2011 11:42:23 -0500 Subject: Convert arbitrary function inputs to string In-Reply-To: <4D25EF31.1050608@sequans.com> References: <4D25EF31.1050608@sequans.com> Message-ID: Yes, I'm calling Gambit-C from Python and would like to make this cleaner. Instead of having to do something like: gambit.eval ("(print \"Hello\n\")") I want to do this: gambit.eval (print "Hello\n") so that the expression following gambit.eval is a standard scheme expression. On Thu, Jan 6, 2011 at 11:34 AM, Jean-Michel Pichavant wrote: > David wrote: >> >> Hi, >> >> I'd like to have a function that takes arbitrary inputs and returns >> them as a single string, with proper escapes for special characters I >> can define. ?For example: >> >> fun( ( + 1 2 ) ) >> => "( + 1 2)" >> >> or >> >> fun( ?(define (myhello str) (begin (print (string-append "Hello " >> str)) (newline) )) ) >> => ?"(define (myhello str) (begin (print (string-append \"Hello \" >> str)) (newline) ))" >> >> Thanks, >> >> -Dave >> > > Are you talking about python ?? > > fun( ( + 1 2 ) ) > ?File "", line 1 > ? fun( ( + 1 2 ) ) > ? ? ? ? ? ? ?^ > SyntaxError: invalid syntax > > From shahmed at sfwmd.gov Thu Jan 6 11:48:16 2011 From: shahmed at sfwmd.gov (Ahmed, Shakir) Date: Thu, 6 Jan 2011 11:48:16 -0500 Subject: list from FTP server to a text file In-Reply-To: <4-ednbGsULvpdbjQnZ2dnUVZ5rudnZ2d@giganews.com> References: <4-ednbGsULvpdbjQnZ2dnUVZ5rudnZ2d@giganews.com> Message-ID: <77F33A87D54B2F47AB06A81DA7B5252736DBEE@EXCHVS02.ad.sfwmd.gov> -----Original Message----- From: python-list-bounces+shahmed=sfwmd.gov at python.org [mailto:python-list-bounces+shahmed=sfwmd.gov at python.org] On Behalf Of Dan M Sent: Thursday, January 06, 2011 11:06 AM To: python-list at python.org Subject: Re: list from FTP server to a text file On Thu, 06 Jan 2011 10:51:42 -0500, Ahmed, Shakir wrote: > Hi, > > I am trying to create a list in a txt file from an ftp server. The > following code is retrieving the list of the files but could not able to > write in a text file. Any help is highly appreciated. > > Thanks > > > > **************************** > import os > import time > from ftplib import FTP > ftp = FTP("*.org","","") # connect to host, default port ftp.login() > ftp.cwd("/pub/remotefolder/") > ftp.retrlines('NLST') > ****************************** WARNING: I am a newbie! Expect more pythonic ways to do this in other replies from ftplib import FTP ftp = FTP("host", "user", "pass") ftp.cwd("/pub/myfolder") files = ftp.nlst(".") f = open('files.txt', 'w') for file in files: f.write('%s\n' % (file,)) f.close() -- It worked Thanks, shk From ian.g.kelly at gmail.com Thu Jan 6 11:53:54 2011 From: ian.g.kelly at gmail.com (Ian) Date: Thu, 6 Jan 2011 08:53:54 -0800 (PST) Subject: Convert arbitrary function inputs to string References: <4D25EF31.1050608@sequans.com> Message-ID: On Jan 6, 9:42?am, David Dreisigmeyer wrote: > Yes, ?I'm calling Gambit-C from Python and would like to make this > cleaner. ?Instead of having to do something like: > > gambit.eval ("(print \"Hello\n\")") > > I want to do this: > > gambit.eval (print "Hello\n") > > so that the expression following gambit.eval is a standard scheme expression. That's much clearer. As I indicated in my previous email, there is no way to do this in Python. You might try using a raw multi-line string literal to reduce the amount of escaping you need to do. So this: "(print \"Hello\\n\")" becomes this: r"""(print "Hello\n")""" Cheers, Ian From ian.g.kelly at gmail.com Thu Jan 6 12:03:02 2011 From: ian.g.kelly at gmail.com (Ian) Date: Thu, 6 Jan 2011 09:03:02 -0800 (PST) Subject: PEP: possibility of inline using of a symbol instead of "import" References: <0952cc24-097d-4685-a92d-75054406ddf3@f20g2000vbc.googlegroups.com> <1201388b-16b8-4452-9a1f-c9aa00b126e7@p38g2000vbn.googlegroups.com> Message-ID: <7f726500-a9d1-45e2-8a7d-2236a9ef7845@p1g2000yqm.googlegroups.com> On Jan 6, 9:32?am, Tim Harig wrote: > 2. Your so-called PEP probably clashes with Python's use of @ for > ? ? ? ? decorators. > > 3. Do you really expect a language holding the mantra that there should be > ? ? ? ? a single way of doing things to embrace a language bloating feature > ? ? ? ? for what is effectively already possible with the language as it > ? ? ? ? exists? Isn't "Python's use of @ for decorators" a "language bloating feature for what [was] effectively already possible with the language as it [existed]?" ;-) Cheers, Ian From ian.g.kelly at gmail.com Thu Jan 6 12:09:34 2011 From: ian.g.kelly at gmail.com (Ian) Date: Thu, 6 Jan 2011 09:09:34 -0800 (PST) Subject: type of methods of builtin exceptions References: Message-ID: <7e4ef23e-8e31-4bce-8b8c-231cfdc6b92d@s5g2000yqm.googlegroups.com> On Jan 6, 9:41?am, Eva Maia wrote: > Hi, > > anyone has a list of the types of methods of builtin exceptions. For > example, for the exception BaseException i need to know the type of ? > arguments method __reduce__ and type of your return. http://docs.python.org/library/pickle.html?highlight=__reduce__#object.__reduce__ Another good place to start would be: http://docs.python.org/reference/datamodel.html#special-method-names Cheers, Ian From robert.kern at gmail.com Thu Jan 6 12:14:52 2011 From: robert.kern at gmail.com (Robert Kern) Date: Thu, 06 Jan 2011 11:14:52 -0600 Subject: Convert arbitrary function inputs to string In-Reply-To: References: <4D25EF31.1050608@sequans.com> Message-ID: On 1/6/11 10:42 AM, David Dreisigmeyer wrote: > Yes, I'm calling Gambit-C from Python and would like to make this > cleaner. Instead of having to do something like: > > gambit.eval ("(print \"Hello\n\")") > > I want to do this: > > gambit.eval (print "Hello\n") > > so that the expression following gambit.eval is a standard scheme expression. Sorry, Python's syntax is not extensible like this. -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco From robert.kern at gmail.com Thu Jan 6 12:17:04 2011 From: robert.kern at gmail.com (Robert Kern) Date: Thu, 06 Jan 2011 11:17:04 -0600 Subject: type of methods of builtin exceptions In-Reply-To: <4D25F0B1.5030905@sapo.pt> References: <4D25F0B1.5030905@sapo.pt> Message-ID: On 1/6/11 10:41 AM, Eva Maia wrote: > Hi, > > anyone has a list of the types of methods of builtin exceptions. For example, > for the exception BaseException i need to know the type of arguments method > __reduce__ and type of your return. http://docs.python.org/search.html?q=__reduce__&check_keywords=yes&area=default -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco From isaacrc82 at gmail.com Thu Jan 6 12:26:40 2011 From: isaacrc82 at gmail.com (Ariel) Date: Thu, 6 Jan 2011 12:26:40 -0500 Subject: I get an error when I used urllib2.urlopen() to open a remote file in a ftp server Message-ID: Hi everybody: I get an error when I used urllib2.urlopen() to open a remote file in a ftp server, My code is the following: >>> file = 'ftp:/192.168.250.14:2180/RTVE/VIDEOS/Thisisit.wmv' >>> mydata = urllib2.urlopen(file) Traceback (most recent call last): File "", line 1, in File "/usr/lib/python2.6/urllib2.py", line 126, in urlopen return _opener.open(url, data, timeout) File "/usr/lib/python2.6/urllib2.py", line 391, in open response = self._open(req, data) File "/usr/lib/python2.6/urllib2.py", line 409, in _open '_open', req) File "/usr/lib/python2.6/urllib2.py", line 369, in _call_chain result = func(*args) File "/usr/lib/python2.6/urllib2.py", line 1316, in ftp_open raise URLError('ftp error: no host given') URLError: But how you can see I get an error 'no host given'. Any idea how to solve this ? Could you help me please ? Regards Ariel -------------- next part -------------- An HTML attachment was scrubbed... URL: From python.list at tim.thechases.com Thu Jan 6 12:32:12 2011 From: python.list at tim.thechases.com (Tim Chase) Date: Thu, 06 Jan 2011 11:32:12 -0600 Subject: PEP: possibility of inline using of a symbol instead of "import" In-Reply-To: References: <0952cc24-097d-4685-a92d-75054406ddf3@f20g2000vbc.googlegroups.com> <1201388b-16b8-4452-9a1f-c9aa00b126e7@p38g2000vbn.googlegroups.com> Message-ID: <4D25FC9C.1010704@tim.thechases.com> On 01/06/2011 10:32 AM, Tim Harig wrote: > 2. Your so-called PEP probably clashes with Python's use of @ for > decorators. > > 3. Do you really expect a language holding the mantra that there should be > a single way of doing things to embrace a language bloating feature > for what is effectively already possible with the language as it > exists? Just as a side note, decorators (your #2, and an approved PEP) do exactly what you mention in #3, as @my_decorator def my_func(...): pass could just as well be written as def my_func(...): pass my_func = my_decorator(my_func) so you #3 point is counterargued by your #2 point :-/ So the powers-that-be have certainly deemed *some* level of syntactic sugar worthwhile. That said, I'm -1 (okay, -0.5) on the OP's suggestion, both in terms of the syntax clashing with decorators, and the need for syntactic sugar in this case. -tkc From ian.g.kelly at gmail.com Thu Jan 6 12:55:22 2011 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Thu, 6 Jan 2011 10:55:22 -0700 Subject: I get an error when I used urllib2.urlopen() to open a remote file in a ftp server In-Reply-To: References: Message-ID: On Thu, Jan 6, 2011 at 10:26 AM, Ariel wrote: > Hi everybody: > > I get an error when I used urllib2.urlopen() to open a remote file in a ftp > server, My code is the following: > >>>> file = 'ftp:/192.168.250.14:2180/RTVE/VIDEOS/Thisisit.wmv' Looks to me like you're missing a slash separating the protocol from the hostname. Try 'ftp://' instead of 'ftp:/'. From xahlee at gmail.com Thu Jan 6 12:55:49 2011 From: xahlee at gmail.com (Xah Lee) Date: Thu, 6 Jan 2011 09:55:49 -0800 (PST) Subject: opinion: comp lang docs style References: <98e82f1b-cf59-4e64-8fd4-63671f96b04f@r19g2000prm.googlegroups.com> <4745479a-10c5-4281-9dcd-c9d7b013a1ec@k13g2000vbq.googlegroups.com> Message-ID: <02827749-bed2-47d8-81cf-a2c3231b2940@u25g2000pra.googlegroups.com> On Jan 4, 3:17?pm, "ru... at yahoo.com" wrote: > On 01/04/2011 01:34 PM, Terry Reedy wrote: > > > On 1/4/2011 1:24 PM, an Arrogant Ignoramus wrote: > > > what he called > >> a opinion piece. > > > I normally do not respond to trolls, but while expressing his opinions, > > AI made statements that are factually wrong at least as regards Python > > and its practitioners. > > Given that most trolls include factually false statements, > the above is inconsistent. ?And speaking of arrogant, it > is just that to go around screaming "troll" about a posting > relevant to the newsgroup it was posted in because you don't > happen to agree with its content. ?In doing so you lower > your own credibility. ?(Which is also not helped by your > "Arrogant Ignoramus" name-calling.) yeah. i called them idiots, he calls me Artificial Intelligence ?. fair game. > No. ?The language reference (LR) and standard library reference > (SLR) must stand on their own merits. ?It is nice to have a good > tutorial for those who like that style of learning. ?But it should > be possible for a programmer with a basic understanding of computers > and some other programming languages to understand how to program > in python without referring to tutorials, explanatory websites, > commercially published books, the source code, etc. yes exactly. the best python reference to me is Richard Gruet's quick ref: http://rgruet.free.fr/PQR26/PQR2.6.html on the python doc, afaik people complains all the time, and i know at least 3 times in different years people have tried to bring up projects to fix it, all shot down with spit badly by python priests, of course. just 2 days ago, i was pissed due to python doc url disappearance too http://xahlee.org/perl-python/python_doc_url_disappearance.html Xah From awilliam at whitemice.org Thu Jan 6 13:00:39 2011 From: awilliam at whitemice.org (Adam Tauno Williams) Date: Thu, 06 Jan 2011 13:00:39 -0500 Subject: Streaming templating languages for use as WSGI body. In-Reply-To: References: Message-ID: <1294336839.10436.2.camel@linux-yu4c.site> On Wed, 2011-01-05 at 14:56 -0800, Alice Bevan?McGregor wrote: > Howdy! > I'm trying to find a templating engine whose templates can be consumed > directly as a WSGI response body iterable. So far I haven't been very > successful with Google; the engines I've found universally generate a > monolithic rendered string. With HTTP/1.0 [and WSGI is HTTP/1.0 only] you have to provide a Content-Length header - so you have to generate the entire response at once [however you want to muddy "at once"]. Streaming responses to the client requires Chunked-Encoding [HTTP/1.1] which is not possible via WSGI. It took me quite awhile to believe that, but there it is. I ditched WSGI; handling HTTP isn't that hard. From devent at deventm.org Thu Jan 6 13:43:29 2011 From: devent at deventm.org (Erwin Mueller) Date: Thu, 6 Jan 2011 19:43:29 +0100 Subject: PEP: possibility of inline using of a symbol instead of "import" In-Reply-To: <0952cc24-097d-4685-a92d-75054406ddf3@f20g2000vbc.googlegroups.com> References: <0952cc24-097d-4685-a92d-75054406ddf3@f20g2000vbc.googlegroups.com> Message-ID: <201101061943.30101.devent@deventm.org> On Thursday 06 January 2011 16:28:49 dmitrey wrote: > hi all, > I have th PEP (I'm not sure something like that hadn't been proposed > although): > very often in a Python file header the following lines are present, > like: > from MyModule1 import myFunc1 > import MyModule2 as mm2 > from MyModule3 import myFunc3 as mf3 > etc > > and after several pages of code they are using somewhere, maybe only > one time, e.g. > r1 = myFunc1(...) > r2 = mm2.myFunc2(...) > r3 = mf3(...) > It makes programs less clear, you have to scroll several pages of code > in IDE to understand what it refers to. > > Regards, D. Why you have several pages of code in the first place? Don't you know that you can split your code in files? Just a suggestion. -- Erwin Mueller, devent at deventm.org http://www.global-scaling-institute.de/ From isaacrc82 at gmail.com Thu Jan 6 13:59:24 2011 From: isaacrc82 at gmail.com (Ariel) Date: Thu, 6 Jan 2011 13:59:24 -0500 Subject: I get an error when I used urllib2.urlopen() to open a remote file in a ftp server In-Reply-To: References: Message-ID: You are right, Thanks. On Thu, Jan 6, 2011 at 12:55 PM, Ian Kelly wrote: > On Thu, Jan 6, 2011 at 10:26 AM, Ariel wrote: > > Hi everybody: > > > > I get an error when I used urllib2.urlopen() to open a remote file in a > ftp > > server, My code is the following: > > > >>>> file = 'ftp:/192.168.250.14:2180/RTVE/VIDEOS/Thisisit.wmv' > > Looks to me like you're missing a slash separating the protocol from > the hostname. Try 'ftp://' instead of 'ftp:/'. > -------------- next part -------------- An HTML attachment was scrubbed... URL: From alice at gothcandy.com Thu Jan 6 14:07:22 2011 From: alice at gothcandy.com (=?utf-8?Q?Alice_Bevan=E2=80=93McGregor?=) Date: Thu, 6 Jan 2011 11:07:22 -0800 Subject: Streaming templating languages for use as WSGI body. References: <1294336839.10436.2.camel@linux-yu4c.site> Message-ID: On 2011-01-06 10:00:39 -0800, Adam Tauno Williams said: > With HTTP/1.0 [and WSGI is HTTP/1.0 only] you have to provide a > Content-Length header - so you have to generate the entire response at > once [however you want to muddy "at once"]. Both of these statements are false. > Streaming responses to the client requires Chunked-Encoding [HTTP/1.1] > which is not possible via WSGI. This is also false. Oh for three, please try again. :) - Alice. From awilliam at whitemice.org Thu Jan 6 14:11:27 2011 From: awilliam at whitemice.org (Adam Tauno Williams) Date: Thu, 06 Jan 2011 14:11:27 -0500 Subject: Streaming templating languages for use as WSGI body. In-Reply-To: References: <1294336839.10436.2.camel@linux-yu4c.site> Message-ID: <1294341087.14042.3.camel@linux-yu4c.site> On Thu, 2011-01-06 at 11:07 -0800, Alice Bevan?McGregor wrote: > On 2011-01-06 10:00:39 -0800, Adam Tauno Williams said: > > > With HTTP/1.0 [and WSGI is HTTP/1.0 only] you have to provide a > > Content-Length header - so you have to generate the entire response at > > once [however you want to muddy "at once"]. > Both of these statements are false. Both these statements are true! I suggest you consult the HTTP spec. A valid Content-Length field value is required on all HTTP/1.0 request messages containing an entity body. > > Streaming responses to the client requires Chunked-Encoding [HTTP/1.1] > > which is not possible via WSGI. > This is also false. You claim of falsehood is false. > Oh for three, please try again. :) OK. From nagle at animats.com Thu Jan 6 14:11:47 2011 From: nagle at animats.com (John Nagle) Date: Thu, 06 Jan 2011 11:11:47 -0800 Subject: Trying to decide between PHP and Python In-Reply-To: References: Message-ID: <4d2613ef$0$44009$742ec2ed@news.sonic.net> On 1/4/2011 12:20 PM, Google Poster wrote: > > About once a year, I have to learn yet another programming language. > Given all the recommendations (an outstanding accolade from Bruce > Eckel, author of "Thinking in Java") I have set my aim to Python. > Sounds kinda cool. If you're just doing simple web-based services, PHP is the way of least resistance. It's supported by almost all hosting services. Trying to run Python on shared hosting is generally painful. Either you're stuck running in CGI, which means you take the cost of a Python load on every transaction, or you have to find someone who will let you run long-running processes so you can run FCGI/WSGI or some Python framework. Efforts to compile PHP to hard code have been more successful than the corresponding efforts for Python. Facebook developed and uses their HipHop compiler for their huge internal PHP code base. John Nagle From dmitrey.kroshko at scipy.org Thu Jan 6 14:42:16 2011 From: dmitrey.kroshko at scipy.org (dmitrey) Date: Thu, 6 Jan 2011 11:42:16 -0800 (PST) Subject: PEP: possibility of inline using of a symbol instead of "import" References: <0952cc24-097d-4685-a92d-75054406ddf3@f20g2000vbc.googlegroups.com> Message-ID: <5b21224a-edb7-49dd-8a41-2b16dbd4afcd@q18g2000vbk.googlegroups.com> On Jan 6, 8:43?pm, Erwin Mueller wrote: > > Why you have several pages of code in the first place? Don't you know that you > can split your code in files? Just a suggestion. > > -- > Erwin Mueller, dev... at deventm.orghttp://www.global-scaling-institute.de/ Erwin, take a look at Python language developers source code and see how many files have *tens* of pages. Or any other mature soft, e.g. numpy or scipy. Also, possibility of splitting *my* files doesn't matter I can split other files I deal with, e.g. written by other programmers. D. From subscriptions at cagttraining.com Thu Jan 6 14:44:13 2011 From: subscriptions at cagttraining.com (Bill Felton) Date: Thu, 6 Jan 2011 14:44:13 -0500 Subject: Can I have both Python 2.7 and Python 3.1 at the same time on the Mac? Message-ID: <775A9D45-25B5-4A16-9FE5-6217FD67F3AF@cagttraining.com> Hi All, I'm new to python, trying to learn it from a variety of resources, including references posted recently to this list. I'm going through /www.openbookproject.net/thinkCSpy/ and find it makes use of gasp, which apparently is not compatible with 3.1. I've also seen various resources indicate that one can install both Python 2.7 and Python 3.1 -- but when I did this, I get no end of problems in the 2.7 install. IDLE, in particular, fails rather spectacularly, even if I launch it directly from the Python 2.7 directory in which it resides. So, either I've been misled and should only try to have one or the other. OR I'm missing some (probably simple) step that's mucking me up. Help? Thanks, Bill From greno at verizon.net Thu Jan 6 14:51:10 2011 From: greno at verizon.net (Gerry Reno) Date: Thu, 06 Jan 2011 14:51:10 -0500 Subject: Can I have both Python 2.7 and Python 3.1 at the same time on the Mac? In-Reply-To: <775A9D45-25B5-4A16-9FE5-6217FD67F3AF@cagttraining.com> References: <775A9D45-25B5-4A16-9FE5-6217FD67F3AF@cagttraining.com> Message-ID: <4D261D2E.5070701@verizon.net> On 01/06/2011 02:44 PM, Bill Felton wrote: > Hi All, > I'm new to python, trying to learn it from a variety of resources, including references posted recently to this list. > I'm going through /www.openbookproject.net/thinkCSpy/ and find it makes use of gasp, which apparently is not compatible with 3.1. > I've also seen various resources indicate that one can install both Python 2.7 and Python 3.1 -- but when I did this, I get no end of problems in the 2.7 install. IDLE, in particular, fails rather spectacularly, even if I launch it directly from the Python 2.7 directory in which it resides. > So, either I've been misled and should only try to have one or the other. OR I'm missing some (probably simple) step that's mucking me up. > Help? > > Thanks, > Bill > > > You probably want to use 'virtualenv' for keeping things separated. From robert.kern at gmail.com Thu Jan 6 15:23:57 2011 From: robert.kern at gmail.com (Robert Kern) Date: Thu, 06 Jan 2011 14:23:57 -0600 Subject: PEP: possibility of inline using of a symbol instead of "import" In-Reply-To: <201101061943.30101.devent@deventm.org> References: <0952cc24-097d-4685-a92d-75054406ddf3@f20g2000vbc.googlegroups.com> <201101061943.30101.devent@deventm.org> Message-ID: On 1/6/11 12:43 PM, Erwin Mueller wrote: > On Thursday 06 January 2011 16:28:49 dmitrey wrote: >> hi all, >> I have th PEP (I'm not sure something like that hadn't been proposed >> although): >> very often in a Python file header the following lines are present, >> like: >> from MyModule1 import myFunc1 >> import MyModule2 as mm2 >> from MyModule3 import myFunc3 as mf3 >> etc >> >> and after several pages of code they are using somewhere, maybe only >> one time, e.g. >> r1 = myFunc1(...) >> r2 = mm2.myFunc2(...) >> r3 = mf3(...) >> It makes programs less clear, you have to scroll several pages of code >> in IDE to understand what it refers to. >> >> Regards, D. > > Why you have several pages of code in the first place? Don't you know that you > can split your code in files? Just a suggestion. Modules *should* have several pages of code. *Functions* should be limited to about a page of code at maximum. -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco From clp2 at rebertia.com Thu Jan 6 15:41:38 2011 From: clp2 at rebertia.com (Chris Rebert) Date: Thu, 6 Jan 2011 12:41:38 -0800 Subject: Trying to decide between PHP and Python In-Reply-To: <4d2613ef$0$44009$742ec2ed@news.sonic.net> References: <4d2613ef$0$44009$742ec2ed@news.sonic.net> Message-ID: On Thu, Jan 6, 2011 at 11:11 AM, John Nagle wrote: > On 1/4/2011 12:20 PM, Google Poster wrote: >> >> About once a year, I have to learn yet another programming language. >> Given all the recommendations (an outstanding accolade from Bruce >> Eckel, author of "Thinking in Java") I have set my aim to Python. >> Sounds kinda cool. > > ? ?If you're just doing simple web-based services, PHP is the > way of least resistance. ?It's supported by almost all hosting > services. ?Trying to run Python on shared hosting is generally > painful. ?Either you're stuck running in CGI, which means you > take the cost of a Python load on every transaction, or you > have to find someone who will let you run long-running > processes so you can run FCGI/WSGI or some Python framework. VPS hosting can be surprisingly cheap these days though (e.g. prgmr's super-cheapo plan is $4-5/month); you get root access, so setting up a Python web application is much easier. Cheers, Chris From nad at acm.org Thu Jan 6 15:46:12 2011 From: nad at acm.org (Ned Deily) Date: Thu, 06 Jan 2011 12:46:12 -0800 Subject: Can I have both Python 2.7 and Python 3.1 at the same time on the Mac? References: <775A9D45-25B5-4A16-9FE5-6217FD67F3AF@cagttraining.com> Message-ID: In article <775A9D45-25B5-4A16-9FE5-6217FD67F3AF at cagttraining.com>, Bill Felton wrote: > I'm new to python, trying to learn it from a variety of resources, including > references posted recently to this list. > I'm going through /www.openbookproject.net/thinkCSpy/ and find it makes use > of gasp, which apparently is not compatible with 3.1. > I've also seen various resources indicate that one can install both Python > 2.7 and Python 3.1 -- but when I did this, I get no end of problems in the > 2.7 install. IDLE, in particular, fails rather spectacularly, even if I > launch it directly from the Python 2.7 directory in which it resides. > So, either I've been misled and should only try to have one or the other. OR > I'm missing some (probably simple) step that's mucking me up. > Help? Yes, you can have multiple versions of Python installed on Mac OS X. In fact, Apple ships multiple versions of Python with OS X (2.6 and 2.6 with OS X 10.6, for example). Starting with Python 2.7, python.org offers two variants of OS X installers, one is 32-bit-only and works on all versions of OS X 10.3.9 through OS X 10.6, the other supports 64-bit execution and only works on 10.6 (as of 2.7.1). Unfortunately, there are some major interaction problems between Tkinter, Python's GUI toolkit which is used by IDLE, and the Tcl/Tk 8.5 supplied by Apple in OS X 10.6. I'm assuming you installed the 64-bit version. If so, until the problem is resolved in the next maintenance release of Python 2.7, I suggest you download and install the 32-bit-only version of Python 2.7.1 which does not have those problems. -- Ned Deily, nad at acm.org From nagle at animats.com Thu Jan 6 15:54:20 2011 From: nagle at animats.com (John Nagle) Date: Thu, 06 Jan 2011 12:54:20 -0800 Subject: Trying to decide between PHP and Python In-Reply-To: References: <4d2613ef$0$44009$742ec2ed@news.sonic.net> Message-ID: <4d262bf8$0$44066$742ec2ed@news.sonic.net> On 1/6/2011 12:41 PM, Chris Rebert wrote: > On Thu, Jan 6, 2011 at 11:11 AM, John Nagle wrote: >> On 1/4/2011 12:20 PM, Google Poster wrote: >>> >>> About once a year, I have to learn yet another programming language. >>> Given all the recommendations (an outstanding accolade from Bruce >>> Eckel, author of "Thinking in Java") I have set my aim to Python. >>> Sounds kinda cool. >> >> If you're just doing simple web-based services, PHP is the >> way of least resistance. It's supported by almost all hosting >> services. Trying to run Python on shared hosting is generally >> painful. Either you're stuck running in CGI, which means you >> take the cost of a Python load on every transaction, or you >> have to find someone who will let you run long-running >> processes so you can run FCGI/WSGI or some Python framework. > > VPS hosting can be surprisingly cheap these days though (e.g. prgmr's > super-cheapo plan is $4-5/month); you get root access, so setting up a > Python web application is much easier. That makes it possible, but not easier. If you're just running a typical web site with some "web 2.0" pages, forms, and a database, it's probably easier to use PHP. Administering a virtual machine instance puts you in the system administration business. With PHP, the hosting service will routinely handle that for you. You just create PHP pages, upload them, and the behind the scenes machinery is someone else's problem. If PHP breaks on shared hosting, enough users will be screaming that it gets fixed. John Nagle From ameyer2 at yahoo.com Thu Jan 6 15:57:25 2011 From: ameyer2 at yahoo.com (Alan Meyer) Date: Thu, 06 Jan 2011 15:57:25 -0500 Subject: PEP: possibility of inline using of a symbol instead of "import" In-Reply-To: <0952cc24-097d-4685-a92d-75054406ddf3@f20g2000vbc.googlegroups.com> References: <0952cc24-097d-4685-a92d-75054406ddf3@f20g2000vbc.googlegroups.com> Message-ID: <4D262CB5.90905@yahoo.com> On 1/6/2011 10:28 AM, dmitrey wrote: > hi all, > I have th PEP (I'm not sure something like that hadn't been proposed > although): > very often in a Python file header the following lines are present, > like: > from MyModule1 import myFunc1 > import MyModule2 as mm2 > from MyModule3 import myFunc3 as mf3 > etc ... Personally, I always do all of my imports at the top of every program I write and like it when others do the same. The reason is that, in a single glance, I can see all of the dependencies of the program. For similar reasons of explicit clarity I prefer this construct: import re pat = re.compile(...) To something like this one: from re import compile as cp pat = cp(...) The only benefit I can see from your proposal is that it cuts down slightly on the number of characters in a program, but I think it does so at the cost of reducing explicit clarity and increasing the learning burden for a programmer who will have to learn two techniques (if only so she can read other people's code) instead of one. Also, there are only 95 printable ASCII characters most of which are already dedicated to other uses (e.g., for use in variable names.) I would hate to reserve one to do something that can be done equally well without reserving a character. I applaud your interest in improving the language but I don't think the benefit justifies the cost in this case. Alan From nad at acm.org Thu Jan 6 16:15:25 2011 From: nad at acm.org (Ned Deily) Date: Thu, 06 Jan 2011 13:15:25 -0800 Subject: Can I have both Python 2.7 and Python 3.1 at the same time on the Mac? References: <775A9D45-25B5-4A16-9FE5-6217FD67F3AF@cagttraining.com> <4D261D2E.5070701@verizon.net> Message-ID: In article <4D261D2E.5070701 at verizon.net>, Gerry Reno wrote: > On 01/06/2011 02:44 PM, Bill Felton wrote: [...] > > I've also seen various resources indicate that one can install both Python > > 2.7 and Python 3.1 -- but when I did this, I get no end of problems in the > > 2.7 install. IDLE, in particular, fails rather spectacularly, even if I > > launch it directly from the Python 2.7 directory in which it resides. > > So, either I've been misled and should only try to have one or the other. > > OR I'm missing some (probably simple) step that's mucking me up. > > Help? > You probably want to use 'virtualenv' for keeping things separated. There are certainly good reasons to use virtualenv but simply to distinguish between Py2 and Py3 is not one of them. There is no ambiguity, using a "standard" distribution on OS X or any other platform that I'm aware of, between Python 2 and Python 3 installations. (Or, at least, any ambiguity that virtualenv would help resolve.) While you could get into an ambiguous situation if you install things yourself and are not careful about which targets are installed (and some additional versioning endcases are being addressed in the upcoming Python 3.2 release), all python3-related scripts and libraries are generally installed with different names (i.e. by adding a "3" somewhere) than their Python 2 counterparts. -- Ned Deily, nad at acm.org From carey.tilden at gmail.com Thu Jan 6 16:19:47 2011 From: carey.tilden at gmail.com (Carey Tilden) Date: Thu, 6 Jan 2011 13:19:47 -0800 Subject: Which coding style is better? public API or private method inside class definition In-Reply-To: References: <0470dc9d-2a5f-40d4-afd4-97796059ba0a@q8g2000prm.googlegroups.com> Message-ID: On Wed, Jan 5, 2011 at 9:15 AM, Peter Otten <__peter__ at web.de> wrote: > Jacek Krysztofik wrote: > > > Sorry for OT, but this is actually a question of mine > >> if numbers % 2 == 0: > > wouldn't the following be faster? > >> if numbers & 1 == 0: > > You can answer that and similar questions yourself with the timeit module: > > $ python -m timeit -s'm, n = 1234, 1235' 'm % 2 == 0; n % 2 == 0' > 1000000 loops, best of 3: 0.377 usec per loop > > $ python -m timeit -s'm, n = 1234, 1235' 'm & 1 == 0; n & 1 == 0' > 1000000 loops, best of 3: 0.298 usec per loop > > So yes, a binary and seems to be faster. > I would be curious to hear of a Python application where such a small speed difference mattered even a little bit. Looks to me like a pretty meaningless difference. Carey -------------- next part -------------- An HTML attachment was scrubbed... URL: From ameyer2 at yahoo.com Thu Jan 6 16:32:05 2011 From: ameyer2 at yahoo.com (Alan Meyer) Date: Thu, 06 Jan 2011 16:32:05 -0500 Subject: Trying to decide between PHP and Python In-Reply-To: References: <4D23A29D.7030104@yahoo.com> Message-ID: <4D2634D5.7040402@yahoo.com> On 1/5/2011 11:40 AM, Tomasz Rola wrote: > On Tue, 4 Jan 2011, Roy Smith wrote: > >> There. Now that I've tossed some gasoline on the language wars fire, >> I'll duck and run in the other direction :-) > > May I suggest a better strategy? Run first, duck next :-). Or more precisely: ((run) duck) Alan From ameyer2 at yahoo.com Thu Jan 6 16:42:19 2011 From: ameyer2 at yahoo.com (Alan Meyer) Date: Thu, 06 Jan 2011 16:42:19 -0500 Subject: Trying to decide between PHP and Python In-Reply-To: References: <4D23A29D.7030104@yahoo.com> Message-ID: <4D26373B.8070700@yahoo.com> On 1/5/2011 10:30 AM, Grant Edwards wrote: > 1) How often is a compiler for language X written? > > 2) How often is source code written in language X? > > 3) How often is that source code in language X read/modified? > > If you compare those numbers you'll realize that optimizing for case 1 > at the expense of cases 2& 3 is just plain stupid. Today? Sure. But let's remember the context. LISP was created in 1958 at a time when the only other high level language (if the Wikipedia is right) was Fortran. Writing a practical interpreter or compiler to run on a 16 or 32 K word memory machine, using punched cards and maybe mag tape, and probably starting in assembly language, was a pretty daunting task. It required gobs of intelligence and not a little fortitude. So instead of calling it "plain stupid" I'd be more comfortable saying that it is "no longer the best design choice for modern computers." Alan From kwmsmith at gmail.com Thu Jan 6 16:54:05 2011 From: kwmsmith at gmail.com (Kurt Smith) Date: Thu, 6 Jan 2011 15:54:05 -0600 Subject: Trying to decide between PHP and Python In-Reply-To: <4D2634D5.7040402@yahoo.com> References: <4D23A29D.7030104@yahoo.com> <4D2634D5.7040402@yahoo.com> Message-ID: On Thu, Jan 6, 2011 at 3:32 PM, Alan Meyer wrote: > On 1/5/2011 11:40 AM, Tomasz Rola wrote: >> >> On Tue, 4 Jan 2011, Roy Smith wrote: >> >>> There. ?Now that I've tossed some gasoline on the language wars fire, >>> I'll duck and run in the other direction :-) >> >> May I suggest a better strategy? Run first, duck next :-). > > Or more precisely: > > ? ((run) duck) If you're going to mock another language, you might as well get it right :-) If that's Lisp code, it should be: (funcall (run) duck) see: http://hornbeck.wordpress.com/2009/07/05/lisp-1-vs-lisp-2/ It'll work unchanged for Scheme, though. From kost-bebix at yandex.ua Thu Jan 6 17:07:09 2011 From: kost-bebix at yandex.ua (kost BebiX) Date: Fri, 07 Jan 2011 00:07:09 +0200 Subject: Rewriting __getattr__ Message-ID: <730351294351630@web139.yandex.ru> Hi everyone! I just saw a bug (?) in bson.dbref:DBRef.__getattr__ Here's they're code: ??? def __getattr__(self, key): ??????? return self.__kwargs[key] And when you do copy.deepcopy on that object it will raise you KeyError. So here's a small piece of code that reproduces the problem: >>> class A(object): .. def __init__(self): .. self.d = {} .. def __getattr__(self, key): .. self.d[key] .. a = A() .. copy.deepcopy(a) Traceback (most recent call last): File "", line 7, in copy.deepcopy(a) File "/usr/lib/python2.6/copy.py", line 171, in deepcopy copier = getattr(x, "__deepcopy__", None) File "", line 5, in __getattr__ self.d[key] KeyError: '__deepcopy__' So I thought the right thing right now will be to do just: class A(object): def __init__(self): self.d = {} def __getattr__(self, key): if key.startswith('__'): raise AttributeError self.d[key] and it works, but... isn't that wrong? I mean, shouldn't deepcopy somehow work in this situation, or, maybe, something else should differ? And why this code: class A(object): def __init__(self): self.d = {} def __getattr__(self, key): if key in dir(self.d): return self.d[key] raise AttributeError a = A() deepcopy(a) gets "maximum recursion depth exceeded"? Thank you. -- jabber: kost-bebix at ya.ru From alice at gothcandy.com Thu Jan 6 17:19:25 2011 From: alice at gothcandy.com (=?utf-8?Q?Alice_Bevan=E2=80=93McGregor?=) Date: Thu, 6 Jan 2011 14:19:25 -0800 Subject: Can I have both Python 2.7 and Python 3.1 at the same time on the Mac? References: <775A9D45-25B5-4A16-9FE5-6217FD67F3AF@cagttraining.com> Message-ID: On 2011-01-06 11:44:13 -0800, Bill Felton said: > I've also seen various resources indicate that one can install both > Python 2.7 and Python 3.1 -- but when I did this, I get no end of > problems in the 2.7 install. I have Apple's native Python installations (2.5 and 2.6, I believe), plus Python 2.7 and 3.1 from the Python.org site (.pkg installers) installed simultaneously without a problem, but I don't use Python GUI toolkits on my Mac. Still waiting on a .pkg installer for 3.2b2, though. :( - Alice. From subscriptions at cagttraining.com Thu Jan 6 17:25:51 2011 From: subscriptions at cagttraining.com (Bill Felton) Date: Thu, 6 Jan 2011 17:25:51 -0500 Subject: Can I have both Python 2.7 and Python 3.1 at the same time on the Mac? In-Reply-To: References: <775A9D45-25B5-4A16-9FE5-6217FD67F3AF@cagttraining.com> Message-ID: <51F66C79-5607-4943-B56C-2EF22F3AD407@cagttraining.com> On Jan 6, 2011, at 3:46 PM, Ned Deily wrote: > In article <775A9D45-25B5-4A16-9FE5-6217FD67F3AF at cagttraining.com>, > Bill Felton wrote: >> I'm new to python, trying to learn it from a variety of resources, including >> references posted recently to this list. >> I'm going through /www.openbookproject.net/thinkCSpy/ and find it makes use >> of gasp, which apparently is not compatible with 3.1. >> I've also seen various resources indicate that one can install both Python >> 2.7 and Python 3.1 -- but when I did this, I get no end of problems in the >> 2.7 install. IDLE, in particular, fails rather spectacularly, even if I >> launch it directly from the Python 2.7 directory in which it resides. >> So, either I've been misled and should only try to have one or the other. OR >> I'm missing some (probably simple) step that's mucking me up. >> Help? > > Yes, you can have multiple versions of Python installed on Mac OS X. In > fact, Apple ships multiple versions of Python with OS X (2.6 and 2.6 > with OS X 10.6, for example). Starting with Python 2.7, python.org > offers two variants of OS X installers, one is 32-bit-only and works on > all versions of OS X 10.3.9 through OS X 10.6, the other supports 64-bit > execution and only works on 10.6 (as of 2.7.1). Unfortunately, there > are some major interaction problems between Tkinter, Python's GUI > toolkit which is used by IDLE, and the Tcl/Tk 8.5 supplied by Apple in > OS X 10.6. I'm assuming you installed the 64-bit version. If so, until > the problem is resolved in the next maintenance release of Python 2.7, I > suggest you download and install the 32-bit-only version of Python 2.7.1 > which does not have those problems. > Thank you, Ned! Installing what appeared to be the 'old OS' version seems to fix my difficulty. IDLE now works fine without hanging, I can enter code, save, check syntax, and run from the 'new window'. And 3.1 still works as before. regards, Bill -------------- next part -------------- An HTML attachment was scrubbed... URL: From alice at gothcandy.com Thu Jan 6 17:33:29 2011 From: alice at gothcandy.com (=?utf-8?Q?Alice_Bevan=E2=80=93McGregor?=) Date: Thu, 6 Jan 2011 14:33:29 -0800 Subject: Streaming templating languages for use as WSGI body. References: <1294336839.10436.2.camel@linux-yu4c.site> <1294341087.14042.3.camel@linux-yu4c.site> Message-ID: On 2011-01-06 11:11:27 -0800, Adam Tauno Williams said: > On Thu, 2011-01-06 at 11:07 -0800, Alice Bevan?McGregor wrote: >> On 2011-01-06 10:00:39 -0800, Adam Tauno Williams said: >>> With HTTP/1.0 [and WSGI is HTTP/1.0 only] you have to provide a >>> Content-Length header - so you have to generate the entire response at >>> once [however you want to muddy "at once"]. >> >> Both of these statements are false. > > Both these statements are true! I suggest you consult the HTTP spec. It's generally polite to provide direct references, either sections or actual links when asking someone to RTFM. No matter, examining the HTTP/1.0 RFC (conveniently chopped up and HTML-ified by the w3) I find evidence to support your argument: http://www.w3.org/Protocols/HTTP/1.0/draft-ietf-http-spec.html#Entity-Body However, HTTP clients are smarter than the raw spec. ;) Run the code found at the following link and poke the wsgiref server that is run in a web browser, with curl, or any other HTTP tool, even telnet: http://pastie.textmate.org/1435415 You'll notice no content-length header (wsgiref adds one automatically for single-element iterables) and no difficulty in receiving the entire response body, even without a content-length. The de-facto standard behaviour combined with the following text from WSGI makes streaming content with non-deterministic lengths completely reasonable: > WSGI servers, gateways, and middleware must not delay the transmission > of any block; they must either fully transmit the block to the client, > or guarantee that they will continue transmission even while the > application is producing its next block. Point me to a HTTP client from the last 10 years that doesn't handle this particular condition and I'll believe your original statements. :) - Alice. From cerutti.francesco.to at gmail.com Thu Jan 6 17:49:22 2011 From: cerutti.francesco.to at gmail.com (francesco) Date: Thu, 6 Jan 2011 14:49:22 -0800 (PST) Subject: python only prints integers Message-ID: <5e52fbfb-c02e-4855-920e-8918cb12c90f@k11g2000vbf.googlegroups.com> I'm pretty new in Python language. I have a problem with numbers: it seems python doesn't know any more how to count! I get only the down rounded integer 20/8 = 2 8/3=2 I probably changed some option to round the numbers, but I don't remember how. Is there a way to reset the number of digits to default? Thanks in advance From debatem1 at gmail.com Thu Jan 6 17:58:28 2011 From: debatem1 at gmail.com (geremy condra) Date: Thu, 6 Jan 2011 14:58:28 -0800 Subject: python only prints integers In-Reply-To: <5e52fbfb-c02e-4855-920e-8918cb12c90f@k11g2000vbf.googlegroups.com> References: <5e52fbfb-c02e-4855-920e-8918cb12c90f@k11g2000vbf.googlegroups.com> Message-ID: On Thu, Jan 6, 2011 at 2:49 PM, francesco wrote: > I'm pretty new in Python language. I have a problem with numbers: it > seems python doesn't know any more how to count! > I get only the down rounded integer > 20/8 = 2 > 8/3=2 > I probably changed some option to round the numbers, but I don't > remember how. > Is there a way to reset the number of digits to default? > Thanks in advance Use floats instead of integers: Python 2.6.5 (r265:79063, Apr 16 2010, 13:57:41) [GCC 4.4.3] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> 20/8 2 >>> 20.0/8 2.5 or use Python3: Python 3.2a1 (r32a1:83318, Aug 13 2010, 22:32:03) [GCC 4.4.3] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> 20/8 2.5 >>> 20.0/8 2.5 From ian.g.kelly at gmail.com Thu Jan 6 17:59:00 2011 From: ian.g.kelly at gmail.com (Ian) Date: Thu, 6 Jan 2011 14:59:00 -0800 (PST) Subject: python only prints integers References: <5e52fbfb-c02e-4855-920e-8918cb12c90f@k11g2000vbf.googlegroups.com> Message-ID: On Jan 6, 3:49?pm, francesco wrote: > I'm pretty new in Python language. I have a problem with numbers: it > seems python doesn't know any more how to count! > I get only the down rounded integer > 20/8 = 2 > 8/3=2 > I probably changed some option to round the numbers, but I don't > remember how. > Is there a way to reset the number of digits to default? In Python 2, the '/' operator performs integer division by default when both its operands are integers. To change this, either place this at the top of the file: from __future__ import division or convert your numbers to floats: >>> 20.0 / 8.0 2.5 >>> float(20) / float(8) 2.5 In Python 3, the '/' operator always performs true division. From enalicho at gmail.com Thu Jan 6 18:02:59 2011 From: enalicho at gmail.com (Noah Hall) Date: Thu, 6 Jan 2011 23:02:59 +0000 Subject: python only prints integers In-Reply-To: <5e52fbfb-c02e-4855-920e-8918cb12c90f@k11g2000vbf.googlegroups.com> References: <5e52fbfb-c02e-4855-920e-8918cb12c90f@k11g2000vbf.googlegroups.com> Message-ID: On Thu, Jan 6, 2011 at 10:49 PM, francesco wrote: > I'm pretty new in Python language. I have a problem with numbers: it > seems python doesn't know any more how to count! > I get only the down rounded integer > 20/8 = 2 > 8/3=2 > I probably changed some option to round the numbers, but I don't > remember how. > Is there a way to reset the number of digits to default? > Thanks in advance > -- > http://mail.python.org/mailman/listinfo/python-list > Hi, the problem is that you've used two integers, which in turn return an integer. In order to get around your problem, try 20.0/8 - the 20.0 is a float, which will return a float. Have a read here - http://docs.python.org/library/stdtypes.html#numeric-types-int-float-long-complex Might I also suggest that you use the tutor at python.org mailing list for beginner questions - you'll get more help there. :) -------------- next part -------------- An HTML attachment was scrubbed... URL: From kost-bebix at yandex.ua Thu Jan 6 18:09:22 2011 From: kost-bebix at yandex.ua (kost BebiX) Date: Fri, 07 Jan 2011 01:09:22 +0200 Subject: python only prints integers In-Reply-To: <5e52fbfb-c02e-4855-920e-8918cb12c90f@k11g2000vbf.googlegroups.com> References: <5e52fbfb-c02e-4855-920e-8918cb12c90f@k11g2000vbf.googlegroups.com> Message-ID: <191741294355362@web95.yandex.ru> Well, that's because 20 is integer. To get float you can write 20.0 (or 20.). 20.0/8.0 = 2.5 8.0/3.0 = 2.6666666666666665 07.01.2011, 00:49, "francesco" : > I'm pretty new in Python language. I have a problem with numbers: it > seems python doesn't know any more how to count! > I get only the down rounded integer > 20/8 = 2 > 8/3=2 > I probably changed some option to round the numbers, but I don't > remember how. > Is there a way to reset the number of digits to default? > Thanks in advance > > -- > http://mail.python.org/mailman/listinfo/python-list -- jabber: kost-bebix at ya.ru From cerutti.francesco.to at gmail.com Thu Jan 6 18:12:19 2011 From: cerutti.francesco.to at gmail.com (francesco) Date: Thu, 6 Jan 2011 15:12:19 -0800 (PST) Subject: python only prints integers References: <5e52fbfb-c02e-4855-920e-8918cb12c90f@k11g2000vbf.googlegroups.com> Message-ID: <02f94678-853d-457e-a048-4711d7e9edc0@v17g2000vbo.googlegroups.com> On 6 Gen, 23:59, Ian wrote: > On Jan 6, 3:49?pm, francesco wrote: > > > I'm pretty new in Python language. I have a problem with numbers: it > > seems python doesn't know any more how to count! > > I get only the down rounded integer > > 20/8 = 2 > > 8/3=2 > > I probably changed some option to round the numbers, but I don't > > remember how. > > Is there a way to reset the number of digits to default? > > In Python 2, the '/' operator performs integer division by default > when both its operands are integers. ?To change this, either place > this at the top of the file: > > from __future__ import division > > or convert your numbers to floats: > > >>> 20.0 / 8.0 > 2.5 > >>> float(20) / float(8) > > 2.5 > > In Python 3, the '/' operator always performs true division. Thanks to all! Very quick answer! I fixed the problem by using floats. Thanks again From sol2ray at gmail.com Thu Jan 6 18:30:36 2011 From: sol2ray at gmail.com (Sol Toure) Date: Thu, 6 Jan 2011 18:30:36 -0500 Subject: Trying to decide between PHP and Python In-Reply-To: References: <4D23A29D.7030104@yahoo.com> <4D2634D5.7040402@yahoo.com> Message-ID: > > >> > >>> There. Now that I've tossed some gasoline on the language wars fire, > >>> I'll duck and run in the other direction :-) > >> > >> May I suggest a better strategy? Run first, duck next :-). > > > > Or more precisely: > > > > ((run) duck) > > If you're going to mock another language, you might as well get it right > :-) > > If that's Lisp code, it should be: > > (funcall (run) duck) > > Did you mean (progn #'run #'duck) -------------- next part -------------- An HTML attachment was scrubbed... URL: From steve+comp.lang.python at pearwood.info Thu Jan 6 18:37:29 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 06 Jan 2011 23:37:29 GMT Subject: PEP: possibility of inline using of a symbol instead of "import" References: <0952cc24-097d-4685-a92d-75054406ddf3@f20g2000vbc.googlegroups.com> <1201388b-16b8-4452-9a1f-c9aa00b126e7@p38g2000vbn.googlegroups.com> <7f726500-a9d1-45e2-8a7d-2236a9ef7845@p1g2000yqm.googlegroups.com> Message-ID: <4d265239$0$29968$c3e8da3$5496439d@news.astraweb.com> On Thu, 06 Jan 2011 09:03:02 -0800, Ian wrote: > On Jan 6, 9:32?am, Tim Harig wrote: >> 2. Your so-called PEP probably clashes with Python's use of @ for >> ? ? ? ? decorators. >> >> 3. Do you really expect a language holding the mantra that there should >> be >> ? ? ? ? a single way of doing things to embrace a language bloating >> ? ? ? ? feature for what is effectively already possible with the >> ? ? ? ? language as it exists? > > Isn't "Python's use of @ for decorators" a "language bloating feature > for what [was] effectively already possible with the language as it > [existed]?" ;-) Yes. The difference is that the invention of decorator syntax was a huge success, encouraging people to write code in a new way that added great power and expressiveness to their code. Guido's intuition as a language designer got decorator syntax right. Although function decorators of a sort have been possible since Python 1.5 or older (functions have always been first class objects), it needed good syntax that puts the wrapper function up near the function def to get people to see their potential. Decorator syntax isn't merely a time- saver, or to reduce the number of keystrokes needed from this: def spam(): pass spam = wrapper(spam) to this: @wrapper def spam(): pass While the two are functionally equivalent, the two are not mentally equivalent to the reader and writer. Decorators are significantly enhanced by the new syntax: it means you no longer have to use the function name three times, which is a code smell. More importantly, it puts the wrapper up with the function signature, where it belongs, instead of obscurely down the bottom past the definition. The end result has been to take a powerful design pattern that was always possible but hardly ever used, and make it friendly and far more common. This has been a huge win. So @ loses two points for being obscure and bringing nothing new to the language, while gaining ten thousand points for being one of the most successful examples of syntactic sugars since people realised they could use assembly language op codes instead of writing in hex. The use of syntax to turn: import module module.function() into something like: @module.function() is unlikely to give any such win. Its utility is fairly narrow: it doesn't encourage any new design patterns. It does save a few characters of typing, which may be a small win, but the use of this will be a code smell. Python doesn't require all imports to be at the beginning of your module, but it is recommended, and this inlining of imports encourages the anti-pattern of scattering imports all throughout your code base. Let me put it this way. The suggested syntactic sugar will encourage code that is functionally the equivalent of this: import math math.sin(1.2) # ... # much later import math math.cos(2.5) # ... # much later import math math.sqrt(24) Yes, the subsequent imports are relatively fast, but even so, we shouldn't *encourage* that sort of thing with special syntax for it. If you don't like this code pattern: import function from module # ... # much code goes here # ... function(x) then instead of creating new syntax, the conventional solution is the best: import module # ... # much code goes here # ... module.function(x) -- Steven From debatem1 at gmail.com Thu Jan 6 19:23:34 2011 From: debatem1 at gmail.com (geremy condra) Date: Thu, 6 Jan 2011 16:23:34 -0800 Subject: Trying to decide between PHP and Python In-Reply-To: <4d262bf8$0$44066$742ec2ed@news.sonic.net> References: <4d2613ef$0$44009$742ec2ed@news.sonic.net> <4d262bf8$0$44066$742ec2ed@news.sonic.net> Message-ID: On Thu, Jan 6, 2011 at 12:54 PM, John Nagle wrote: > On 1/6/2011 12:41 PM, Chris Rebert wrote: >> >> On Thu, Jan 6, 2011 at 11:11 AM, John Nagle ?wrote: >>> >>> On 1/4/2011 12:20 PM, Google Poster wrote: >>>> >>>> About once a year, I have to learn yet another programming language. >>>> Given all the recommendations (an outstanding accolade from Bruce >>>> Eckel, author of "Thinking in Java") I have set my aim to Python. >>>> Sounds kinda cool. >>> >>> ? ?If you're just doing simple web-based services, PHP is the >>> way of least resistance. ?It's supported by almost all hosting >>> services. ?Trying to run Python on shared hosting is generally >>> painful. ?Either you're stuck running in CGI, which means you >>> take the cost of a Python load on every transaction, or you >>> have to find someone who will let you run long-running >>> processes so you can run FCGI/WSGI or some Python framework. >> >> VPS hosting can be surprisingly cheap these days though (e.g. prgmr's >> super-cheapo plan is $4-5/month); you get root access, so setting up a >> Python web application is much easier. > > ? ?That makes it possible, but not easier. ?If you're just running a > typical web site with some "web 2.0" pages, forms, and a database, > it's probably easier to use PHP. ?Administering a virtual machine > instance puts you in the system administration business. ?With > PHP, the hosting service will routinely handle that for you. > You just create PHP pages, upload them, and the behind the scenes > machinery is someone else's problem. ?If PHP breaks on shared hosting, > enough users will be screaming that it gets fixed. > > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?John Nagle I'm not exactly a god unto sysadmins and I've had no problems with either bargain-basement Python managed hosting or VPS's. I'd encourage anybody looking at the differences between PHP and Python to try both and get some hosting that lets you use either. I'm pretty confident that in the long run Python will win out. Geremy Condra From bc at freeuk.com Thu Jan 6 19:31:52 2011 From: bc at freeuk.com (BartC) Date: Fri, 7 Jan 2011 00:31:52 -0000 Subject: Trying to decide between PHP and Python In-Reply-To: <87bp3wf3zw.fsf@benfinney.id.au> References: <4D23A29D.7030104@yahoo.com> <87bp3wf3zw.fsf@benfinney.id.au> Message-ID: "Ben Finney" wrote in message news:87bp3wf3zw.fsf at benfinney.id.au... > Tomasz Rola writes: > >> Heh. One day, guys, when you have nothing better to do, try writing a >> parser for Lisp-like language (Common Lisp, Scheme, whatever). After >> that, do the same with some other language of your preference (Python, >> Java, whatever). Compare time and code spent... > > Perhaps Lisp is a simpler language to parse than Python. > > Perhaps a machine with only one instruction > is > simpler to implement than one with a broader instruction set. One with zero instructions might be even simpler than that: http://en.wikipedia.org/wiki/Zero_instruction_set_computer -- Bartc From googler.1.webmaster at spamgourmet.com Thu Jan 6 21:24:13 2011 From: googler.1.webmaster at spamgourmet.com (moerchendiser2k3) Date: Thu, 6 Jan 2011 18:24:13 -0800 (PST) Subject: Resolve circular reference Message-ID: <1718ea91-fc4e-49f3-a15a-bdc683789126@k22g2000yqh.googlegroups.com> Hi, I have a small problem with circular references. I embedded Python into my app and I have two types which are flagged with Py_TPFLAGS_BASETYPE so I can inherit Python types from these types. Lets call my C types A and B. Here is the dependency: class Foo(A): e=Bar() class Bar(B): def __init__(self, p): self.p=p i=Foo() j=Bar(i) Everything works fine, the problem starts when I start to make a circular reference in Python. In my embedded app I have a reference to instance A. When I decref this reference its still alive because the instance j(Bar) makes this object still alive. Is there any chance to force this? Because without A the instance A shouldnt be alive anymore. Thanks for any hint!! Bye From python at mrabarnett.plus.com Thu Jan 6 21:59:26 2011 From: python at mrabarnett.plus.com (MRAB) Date: Fri, 07 Jan 2011 02:59:26 +0000 Subject: Resolve circular reference In-Reply-To: <1718ea91-fc4e-49f3-a15a-bdc683789126@k22g2000yqh.googlegroups.com> References: <1718ea91-fc4e-49f3-a15a-bdc683789126@k22g2000yqh.googlegroups.com> Message-ID: <4D26818E.5060604@mrabarnett.plus.com> On 07/01/2011 02:24, moerchendiser2k3 wrote: > Hi, > > I have a small problem with circular references. I embedded Python > into my app and I have two types which are flagged with > Py_TPFLAGS_BASETYPE so I can inherit Python types from these types. > Lets call my C types A and B. > > > Here is the dependency: > > class Foo(A): > e=Bar() > > class Bar(B): > def __init__(self, p): > self.p=p > i=Foo() > j=Bar(i) > > Everything works fine, the problem starts when I start to make a > circular reference in Python. In my embedded app I have a reference to > instance A. When I decref this reference its still alive because the > instance j(Bar) makes this object still alive. Is there any chance to > force this? Because without A the instance A shouldnt be alive > anymore. Thanks for any hint!! > Force what? j refers to i, i refers to Foo, Foo refers to A. Therefore A should be alive. From falk at rahul.net Thu Jan 6 22:32:54 2011 From: falk at rahul.net (Edward A. Falk) Date: Fri, 7 Jan 2011 03:32:54 +0000 (UTC) Subject: python only prints integers References: <5e52fbfb-c02e-4855-920e-8918cb12c90f@k11g2000vbf.googlegroups.com> Message-ID: In article , Ian wrote: > >In Python 3, the '/' operator always performs true division. How can I get integer division? -- -Ed Falk, falk at despams.r.us.com http://thespamdiaries.blogspot.com/ From enalicho at gmail.com Thu Jan 6 22:42:46 2011 From: enalicho at gmail.com (Noah Hall) Date: Fri, 7 Jan 2011 03:42:46 +0000 Subject: python only prints integers In-Reply-To: References: <5e52fbfb-c02e-4855-920e-8918cb12c90f@k11g2000vbf.googlegroups.com> Message-ID: On Fri, Jan 7, 2011 at 3:32 AM, Edward A. Falk wrote: > In article < > cd9d1c80-b1d2-4d20-9896-a6fd77bd7db2 at j25g2000yqa.googlegroups.com>, > Ian wrote: > > > >In Python 3, the '/' operator always performs true division. > > How can I get integer division? > > -- > -Ed Falk, falk at despams.r.us.com > http://thespamdiaries.blogspot.com/ > -- > http://mail.python.org/mailman/listinfo/python-list > Use // where you would / in order to preform integer division in Python 3. -------------- next part -------------- An HTML attachment was scrubbed... URL: From erwin.mueller at deventm.org Thu Jan 6 23:00:52 2011 From: erwin.mueller at deventm.org (Erwin Mueller) Date: Fri, 7 Jan 2011 05:00:52 +0100 Subject: PEP: possibility of inline using of a symbol instead of "import" In-Reply-To: References: <0952cc24-097d-4685-a92d-75054406ddf3@f20g2000vbc.googlegroups.com> <201101061943.30101.devent@deventm.org> Message-ID: <201101070500.52368.erwin.mueller@deventm.org> On Thursday 06 January 2011 21:23:57 Robert Kern wrote: > On 1/6/11 12:43 PM, Erwin Mueller wrote: > > On Thursday 06 January 2011 16:28:49 dmitrey wrote: > >> hi all, > >> I have th PEP (I'm not sure something like that hadn't been proposed > >> although): > >> very often in a Python file header the following lines are present, > >> like: > >> from MyModule1 import myFunc1 > >> import MyModule2 as mm2 > >> from MyModule3 import myFunc3 as mf3 > >> etc > >> > >> and after several pages of code they are using somewhere, maybe only > >> one time, e.g. > >> r1 = myFunc1(...) > >> r2 = mm2.myFunc2(...) > >> r3 = mf3(...) > >> It makes programs less clear, you have to scroll several pages of code > >> in IDE to understand what it refers to. > >> > >> Regards, D. > > > > Why you have several pages of code in the first place? Don't you know > > that you can split your code in files? Just a suggestion. > > Modules *should* have several pages of code. *Functions* should be limited > to about a page of code at maximum. I'm not quite familar with Python development, but why should modules be so big that the user is lost in the code? What is preventing you from splittin a module in several files, each file with a single responsibility? -- Erwin Mueller, erwin.mueller at deventm.org http://www.global-scaling-institute.de/ From devent at deventm.org Thu Jan 6 23:01:38 2011 From: devent at deventm.org (Erwin Mueller) Date: Fri, 7 Jan 2011 05:01:38 +0100 Subject: PEP: possibility of inline using of a symbol instead of "import" In-Reply-To: References: <0952cc24-097d-4685-a92d-75054406ddf3@f20g2000vbc.googlegroups.com> <201101061943.30101.devent@deventm.org> Message-ID: <201101070501.38410.devent@deventm.org> On Thursday 06 January 2011 21:23:57 Robert Kern wrote: > On 1/6/11 12:43 PM, Erwin Mueller wrote: > > On Thursday 06 January 2011 16:28:49 dmitrey wrote: > >> hi all, > >> I have th PEP (I'm not sure something like that hadn't been proposed > >> although): > >> very often in a Python file header the following lines are present, > >> like: > >> from MyModule1 import myFunc1 > >> import MyModule2 as mm2 > >> from MyModule3 import myFunc3 as mf3 > >> etc > >> > >> and after several pages of code they are using somewhere, maybe only > >> one time, e.g. > >> r1 = myFunc1(...) > >> r2 = mm2.myFunc2(...) > >> r3 = mf3(...) > >> It makes programs less clear, you have to scroll several pages of code > >> in IDE to understand what it refers to. > >> > >> Regards, D. > > > > Why you have several pages of code in the first place? Don't you know > > that you can split your code in files? Just a suggestion. > > Modules *should* have several pages of code. *Functions* should be limited > to about a page of code at maximum. I'm not quite familar with Python development, but why should modules be so big that the user is lost in the code? What is preventing you from splittin a module in several files, each file with a single responsibility? -- Erwin Mueller, devent at deventm.org http://www.global-scaling-institute.de/ From clp2 at rebertia.com Fri Jan 7 00:05:10 2011 From: clp2 at rebertia.com (Chris Rebert) Date: Thu, 6 Jan 2011 21:05:10 -0800 Subject: PEP: possibility of inline using of a symbol instead of "import" In-Reply-To: <201101070500.52368.erwin.mueller@deventm.org> References: <0952cc24-097d-4685-a92d-75054406ddf3@f20g2000vbc.googlegroups.com> <201101061943.30101.devent@deventm.org> <201101070500.52368.erwin.mueller@deventm.org> Message-ID: On Thu, Jan 6, 2011 at 8:00 PM, Erwin Mueller wrote: > On Thursday 06 January 2011 21:23:57 Robert Kern wrote: > > On 1/6/11 12:43 PM, Erwin Mueller wrote: > > > On Thursday 06 January 2011 16:28:49 dmitrey wrote: > > >> hi all, > > >> I have th PEP (I'm not sure something like that hadn't been proposed > > >> although): > > >> very often in a Python file header the following lines are present, > > >> like: > > >> from MyModule1 import myFunc1 > > >> import MyModule2 as mm2 > > >> from MyModule3 import myFunc3 as mf3 > > >> etc > > >> > > >> and after several pages of code they are using somewhere, maybe only > > >> one time, e.g. > > >> r1 = myFunc1(...) > > >> r2 = mm2.myFunc2(...) > > >> r3 = mf3(...) > > >> It makes programs less clear, you have to scroll several pages of code > > >> in IDE to understand what it refers to. > > >> > > >> Regards, D. > > > > > > Why you have several pages of code in the first place? Don't you know > > > that you can split your code in files? Just a suggestion. > > > > Modules *should* have several pages of code. *Functions* should be limited > > to about a page of code at maximum. > > ? ? ? ?I'm not quite familar with Python development, but why should modules > be so big that the user is lost in the code? They shouldn't, but due to Python's conciseness, the amount of code a module can hold before it becomes unwieldy is a good bit greater than some more verbose languages. Unlike say, Java, it is quite normal to have several classes, functions, and constants in a single Python module. "Several pages" is not an unreasonable upper bound for a Python module. > What is preventing you from > splittin a module in several files, each file with a single responsibility? Circular dependencies perhaps. Also, how a responsibility is defined and what level of module granularity is most useful is a design decision requiring skilled judgment; it's possible that just-one-module is appropriate for Dmitrey's situation. Cheers, Chris -- http://blog.rebertia.com From steve+comp.lang.python at pearwood.info Fri Jan 7 02:09:03 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 07 Jan 2011 07:09:03 GMT Subject: python only prints integers References: <5e52fbfb-c02e-4855-920e-8918cb12c90f@k11g2000vbf.googlegroups.com> Message-ID: <4d26bc0f$0$29976$c3e8da3$5496439d@news.astraweb.com> On Fri, 07 Jan 2011 03:32:54 +0000, Edward A. Falk wrote: > In article > , Ian > wrote: >> >>In Python 3, the '/' operator always performs true division. > > How can I get integer division? >>> 25//4 6 -- Steven From steve+comp.lang.python at pearwood.info Fri Jan 7 02:27:28 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 07 Jan 2011 07:27:28 GMT Subject: PEP: possibility of inline using of a symbol instead of "import" References: <0952cc24-097d-4685-a92d-75054406ddf3@f20g2000vbc.googlegroups.com> <201101061943.30101.devent@deventm.org> <201101070500.52368.erwin.mueller@deventm.org> Message-ID: <4d26c060$0$29976$c3e8da3$5496439d@news.astraweb.com> On Thu, 06 Jan 2011 21:05:10 -0800, Chris Rebert wrote: > On Thu, Jan 6, 2011 at 8:00 PM, Erwin Mueller > wrote: >> On Thursday 06 January 2011 21:23:57 Robert Kern wrote: >> > On 1/6/11 12:43 PM, Erwin Mueller wrote: >> > > On Thursday 06 January 2011 16:28:49 dmitrey wrote: >> > >> hi all, >> > >> I have th PEP (I'm not sure something like that hadn't been >> > >> proposed although): >> > >> very often in a Python file header the following lines are >> > >> present, like: >> > >> from MyModule1 import myFunc1 >> > >> import MyModule2 as mm2 >> > >> from MyModule3 import myFunc3 as mf3 >> > >> etc >> > >> >> > >> and after several pages of code they are using somewhere, maybe >> > >> only one time, e.g. >> > >> r1 = myFunc1(...) >> > >> r2 = mm2.myFunc2(...) >> > >> r3 = mf3(...) >> > >> It makes programs less clear, you have to scroll several pages of >> > >> code in IDE to understand what it refers to. >> > >> >> > >> Regards, D. >> > > >> > > Why you have several pages of code in the first place? Don't you >> > > know that you can split your code in files? Just a suggestion. >> > >> > Modules *should* have several pages of code. *Functions* should be >> > limited to about a page of code at maximum. >> >> ? ? ? ?I'm not quite familar with Python development, but why >> ? ? ? ?should modules >> be so big that the user is lost in the code? > > They shouldn't, but due to Python's conciseness, the amount of code a > module can hold before it becomes unwieldy is a good bit greater than > some more verbose languages. Unlike say, Java, it is quite normal to > have several classes, functions, and constants in a single Python > module. "Several pages" is not an unreasonable upper bound for a Python > module. Have a look at the decimal.py module in the standard library. That's nearly 5800 lines, including blanks, comments and docstrings, for 18 classes and 19 top-level functions, over 88 pages. I'd call that the maximum size I'm comfortable with a single module. "Several pages" is nothing to fear. I recently split a module I'm working on into a package of seven modules (plus about the same again for tests). My module was about 2500 lines, for about 50 classes and functions, and I expect it to grow by another dozen or so functions over the coming months. Splitting a single module into multiples doesn't happen for free. You have to worry about imports and dependencies that simply aren't an issue in a single module. But on the plus side, I was able to rename a bunch of similar-but-different functions from: module.function module.function1 to a much more sensible: module.function module.submodule.function -- Steven From googler.1.webmaster at spamgourmet.com Fri Jan 7 06:20:36 2011 From: googler.1.webmaster at spamgourmet.com (moerchendiser2k3) Date: Fri, 7 Jan 2011 03:20:36 -0800 (PST) Subject: Resolve circular reference References: <1718ea91-fc4e-49f3-a15a-bdc683789126@k22g2000yqh.googlegroups.com> Message-ID: > Force what? > > j refers to i, i refers to Foo, Foo refers to A. Therefore A should be > alive. Oh, sorry. Force the deletion of A. From googler.1.webmaster at spamgourmet.com Fri Jan 7 06:58:24 2011 From: googler.1.webmaster at spamgourmet.com (moerchendiser2k3) Date: Fri, 7 Jan 2011 03:58:24 -0800 (PST) Subject: Resolve circular reference References: <1718ea91-fc4e-49f3-a15a-bdc683789126@k22g2000yqh.googlegroups.com> Message-ID: <353ecd61-22f8-4770-be30-29cb76b0f6b0@t35g2000yqj.googlegroups.com> > Force what? > j refers to i, i refers to Foo, Foo refers to A. Therefore A should be > alive. Oh, sorry. Force the deletion of instance Foo(A) and Bar(B). From fabiofz at gmail.com Fri Jan 7 07:09:48 2011 From: fabiofz at gmail.com (Fabio Zadrozny) Date: Fri, 7 Jan 2011 10:09:48 -0200 Subject: [PyQt] Working with PyQt and Pydev In-Reply-To: References: Message-ID: On Thu, Jan 6, 2011 at 9:32 AM, Rohit Coder < passionate_programmer at hotmail.com> wrote: > I installed the PyDev plugin into Aptana Stdui 3 Beta. Someone suggested > me to use PyQt for Python GUI app, and so I downloaded and installed PyQt. > But when I open Aptana Studio, I could see a new menu added with the name > "PyDev", but there is nothing for PyQt. > > > In the Windows Start Meny item list, I could see a folder named PyQt and > when I open it, there are few tools like Designer. > > > When Designer is run, it opens Qt IDE for designing Forms like Visual > Studio and the files have the extension .ui. > > I want to know how to integrate PyQt and PyDev. Do I need to use them > separately by adding the .ui files to PyDev and then adding Python core code > for functionality? > > After you design your class in the Qt Designer, you need to run pyuic to convert the .ui file to a python file (which you'd probably subclass in another module to add your own code, as you don't want to mess the automatically generated file). If you want, you can add a builder (project > properties > builders) to run pyuic when a .ui file is changed, so you don't have to go to the console to ask pyuic to be rerun every time you change the file. Cheers, Fabio -------------- next part -------------- An HTML attachment was scrubbed... URL: From jeanmichel at sequans.com Fri Jan 7 08:45:56 2011 From: jeanmichel at sequans.com (Jean-Michel Pichavant) Date: Fri, 07 Jan 2011 14:45:56 +0100 Subject: Rewriting __getattr__ In-Reply-To: <730351294351630@web139.yandex.ru> References: <730351294351630@web139.yandex.ru> Message-ID: <4D271914.6090308@sequans.com> kost BebiX wrote: > Hi everyone! > I just saw a bug (?) in bson.dbref:DBRef.__getattr__ > > Here's they're code: > def __getattr__(self, key): > return self.__kwargs[key] > > And when you do copy.deepcopy on that object it will raise you KeyError. So here's a small piece of code that reproduces the problem: > > from http://docs.python.org/reference/datamodel.html About __getattr__ "This method should return the (computed) attribute value or raise an AttributeError exception." The code you provided raises a KeyError thus methods such as 'getattr' will fail as they expect an AttributeError exception. JM From kost-bebix at yandex.ua Fri Jan 7 08:54:37 2011 From: kost-bebix at yandex.ua (kost BebiX) Date: Fri, 07 Jan 2011 15:54:37 +0200 Subject: Rewriting __getattr__ In-Reply-To: <4D271914.6090308@sequans.com> References: <730351294351630@web139.yandex.ru> <4D271914.6090308@sequans.com> Message-ID: <191511294408478@web10.yandex.ru> You're absolutely right! Now try to do except Keyerror: raise AttributeError and it will also fail. But why? 07.01.2011, 15:45, "Jean-Michel Pichavant" : > kost BebiX wrote: > >> ?Hi everyone! >> ?I just saw a bug (?) in bson.dbref:DBRef.__getattr__ >> >> ?Here's they're code: >> ?????def __getattr__(self, key): >> ?????????return self.__kwargs[key] >> >> ?And when you do copy.deepcopy on that object it will raise you KeyError. So here's a small piece of code that reproduces the problem: > > from http://docs.python.org/reference/datamodel.html > > About __getattr__ > "This method should return the (computed) attribute value or raise an > AttributeError > > exception." > > The code you provided raises a KeyError thus methods such as 'getattr' > will fail as they expect an AttributeError exception. > > JM > > -- > http://mail.python.org/mailman/listinfo/python-list -- jabber: kost-bebix at ya.ru From tavares at fe.up.pt Fri Jan 7 09:16:04 2011 From: tavares at fe.up.pt (tavares at fe.up.pt) Date: Fri, 7 Jan 2011 06:16:04 -0800 (PST) Subject: =?windows-1252?Q?VipIMAGE_2011_=96_ECCOMAS_Thematic_Conference_=96_2n?= =?windows-1252?Q?d_ANNOUNCE_and_CALL?= Message-ID: <89e4a378-df07-49d9-87de-6a57b8bc8918@i41g2000vbn.googlegroups.com> ------------------------------------------------------------------------------------------------------------------------------------------ International ECCOMAS Thematic Conference VipIMAGE 2011 - III ECCOMAS THEMATIC CONFERENCE ON COMPUTATIONAL VISION AND MEDICAL IMAGE PROCESSING 12-14th October 2011, Olh?o, Algarve, Portugal www.fe.up.pt/~vipimage 2nd ANNOUNCE and CALL for PAPERS AND THEMATIC SESSIONS We would appreciate if you could distribute this information by your colleagues and co-workers. ------------------------------------------------------------------------------------------------------------------------------------------ Dear Colleague, We would like to call your attention to the International Conference VipIMAGE 2011 - III ECCOMAS THEMATIC CONFERENCE ON COMPUTATIONAL VISION AND MEDICAL IMAGE PROCESSING that will be held in Real Marina Hotel & Spa, Olh?o, Algarve, Portugal, on October 12-14, 2011. Possible Topics (not limited to) - Signal and Image Processing - Computational Vision - Medical Imaging - Physics of Medical Imaging - Tracking and Analysis of Movement - Simulation and Modeling - Image Acquisition - Shape Reconstruction - Objects Segmentation, Matching, Simulation - Data Interpolation, Registration, Acquisition and Compression - 3D Vision - Virtual Reality - Software Development for Image Processing and Analysis - Computer Aided Diagnosis, Surgery, Therapy, and Treatment - Computational Bioimaging and Visualization - Telemedicine Systems and their Applications Invited Lecturers - Armando J. Pinho - University of Aveiro, Portugal - Irene M. Gamba - The University of Texas at Austin, USA - Marc Pollefeys - ETH Zurich, Switzerland - Marc Thiriet - Universite Pierre et Marie Curie (Paris VI), France - Xavier Roca Marv? - Autonomous University of Barcelona, Spain - Stan Sclaroff - Boston University, USA Thematic Sessions Proposals to organize Thematic Session within VipIMAGE 2011 are mostly welcome. Proposals for Thematic Sessions should be submitted by email to the conference co-chairs (tavares at fe.up.pt, rnatal at fe.up.pt) Thematic Sessions Confirmed - Simultaneous MR-PET imaging - Satellite image analysis for environmental risk assessment Publications The proceedings book will be published by the Taylor & Francis Group and indexed by Thomson Reuters Conference Proceedings Citation Index, IET Inspect and Elsevier Scopus. A book with 20 invited works from the best ones presented in VipIMAGE2011 (extended versions) will be published by Springer. The organizers will encourage the submission of extended versions of the accepted papers to related International Journals; in particular, for special issues dedicated to the conference. Important dates - Deadline for Thematic Sessions proposals: 15th January 2011 - Deadline for Extended Abstracts: 15th March 2011 - Authors Notification: 15th April 2011 - Deadline for Full Papers: 15th June 2011 Awards "best paper award" and "best student paper award" are going to be given to the author(s) of two papers presented at the conference, selected by the Organizing Committee based on the best combined marks from the Scientific Committee and Session Chairs. We are looking forward to see you in Algarve next October. Kind regards, Jo?o Manuel R. S. Tavares Renato Natal Jorge (conference co-chairs) PS. For further details please see the conference website at: www.fe.up.pt/~vipimage From jeanmichel at sequans.com Fri Jan 7 09:22:40 2011 From: jeanmichel at sequans.com (Jean-Michel Pichavant) Date: Fri, 07 Jan 2011 15:22:40 +0100 Subject: Rewriting __getattr__ In-Reply-To: <191511294408478@web10.yandex.ru> References: <730351294351630@web139.yandex.ru> <4D271914.6090308@sequans.com> <191511294408478@web10.yandex.ru> Message-ID: <4D2721B0.7060601@sequans.com> kost BebiX wrote: > You're absolutely right! Now try to do except Keyerror: raise AttributeError and it will also fail. But why? > > 07.01.2011, 15:45, "Jean-Michel Pichavant" : > >> kost BebiX wrote: >> >> >>> Hi everyone! >>> I just saw a bug (?) in bson.dbref:DBRef.__getattr__ >>> >>> Here's they're code: >>> def __getattr__(self, key): >>> return self.__kwargs[key] >>> >>> And when you do copy.deepcopy on that object it will raise you KeyError. So here's a small piece of code that reproduces the problem: >>> >> from http://docs.python.org/reference/datamodel.html >> >> About __getattr__ >> "This method should return the (computed) attribute value or raise an >> AttributeError >> >> exception." >> >> The code you provided raises a KeyError thus methods such as 'getattr' >> will fail as they expect an AttributeError exception. >> >> JM >> >> -- >> http://mail.python.org/mailman/listinfo/python-list >> > > please don't top post :) It fails because you simply did not returned any value (with your class A example). class A(object): def __init__(self): self.d = {} def __getattr__(self, key): try: *return* self.d[key] except KeyError: raise AttributeError works fine with deepcopy JM From pavlovevidence at gmail.com Fri Jan 7 09:31:29 2011 From: pavlovevidence at gmail.com (Carl Banks) Date: Fri, 7 Jan 2011 06:31:29 -0800 (PST) Subject: PEP: possibility of inline using of a symbol instead of "import" References: <0952cc24-097d-4685-a92d-75054406ddf3@f20g2000vbc.googlegroups.com> Message-ID: <8fe5b19f-084a-4897-8d12-605344c6fa4d@y19g2000prb.googlegroups.com> On Jan 6, 7:28?am, dmitrey wrote: > hi all, > I have th PEP (I'm not sure something like that hadn't been proposed > although): > very often in a Python file header the following lines are present, > like: > from MyModule1 import myFunc1 > import MyModule2 as mm2 > from MyModule3 import myFunc3 as mf3 > etc > > and after several pages of code they are using somewhere, maybe only > one time, e.g. > r1 = myFunc1(...) > r2 = mm2.myFunc2(...) > r3 = mf3(...) > It makes programs less clear, you have to scroll several pages of code > in IDE to understand what it refers to. > > I propose to add possibility of using a symbol instead (for simplicity > I use @ here, that is already reserved for decorators, thus it should > be other symbol, maybe from Unicode although for simplicity to type it > I would prefer something ordinary like $ or ` or !). > > e.g. instead of > > import MyModule > (...lots of code...) > r = MyModule.myFunc(...) > > someone could just type in the single place > > r = @MyModule.myFunc(...) > > Also, "import MyModule2 as mm2" could be replaced to mere > mm2 = @MyModule2 > and "from MyModule3 import myFunc3 as mf3" could be replaced to mere > "mf3 = @MyModule3.myFunc3". > > As for __import__(ModuleTextName), it could be replaced to something > like @(ModuleTextName) or @{ModuleTextName} or @[ModuleTextName]. I actually wouldn't mind this; in fact Python's importing mechanism is bad enough that a complete overhaul might not be a bad thing. But, first of all, one can already do in-line imports in Python with the __import__ built-in function (and I used to do this frequently in throwaway scripts before list comprehensions were added). For instance, a one-liner to generate a password would be this: python -c 'for i in xrange(8): __import__("sys").stdout.write(__import__("random").choice(__import__("string").letters))' Today a better way to do it would be like this: python -c 'import random,string; print "".join(random.choice(string.letters) for i in xrange(8))' But that's a digression. The problem with in-line imports is that it can lead to deadlock in multithreaded programs, so for the most part it's a good idea to avoid importing within functions. Therefore, a syntax for it would really be needed to gain full benefit. This would allow the compiler to scan the file to collect a list of prerequisite modules. In my mind, the module itself wouldn't import the dependencies itself, it simply lists prerequisites and leaves it to the runtime to ensure that they've been imported. A side benefit to this is to keep module namespaces clean. Main drawback is that it makes accessing symbols in deepely nested packages unwieldy (since presumably you'd have to write out the fully- qualified name). Meh, I pretty much avoid deeply nested packages, and typically spell out the fully-qualified module names anyway. So not my problem. As for listing imports at the top of the program--I can't say I have much use for it. Sometimes it helps to see a list of prerqequisites in one place, but I can't say it's the most useful thing ever, and anyway it's misleading since the imports can become stale. I'd rather not have to stop and scroll up ten pages to add an import to the top of the module when I suddenly need to access time.sleep or itertools.count. So, pending a better syntax, I'll give it a +0; and the only reason I don't give it a +1 is it's such a drastic change. The syntax probably would deserve a lot of thought (being such a drastic change) but drawing from C++ a postfix operator would seem to fit. sys:: -> evaulates to the sys module sys::version -> evaluates to sys.version xml::etree::ElementTree:: -> as expected That has the unfortunate effect of making Python look like C++ though. Won't ever happen though. Carl Banks From pavlovevidence at gmail.com Fri Jan 7 09:34:38 2011 From: pavlovevidence at gmail.com (Carl Banks) Date: Fri, 7 Jan 2011 06:34:38 -0800 (PST) Subject: PEP: possibility of inline using of a symbol instead of "import" References: <0952cc24-097d-4685-a92d-75054406ddf3@f20g2000vbc.googlegroups.com> <1201388b-16b8-4452-9a1f-c9aa00b126e7@p38g2000vbn.googlegroups.com> Message-ID: <71bc0300-7bb1-4bc3-a72a-ef4dd3a413f6@21g2000prv.googlegroups.com> On Jan 6, 8:32?am, Tim Harig wrote: > 2. Your so-called PEP probably clashes with Python's use of @ for > ? ? ? ? decorators. He said it was just for simplicity's sake. Carl Banks From thibaud.roussillat at gmail.com Fri Jan 7 09:38:26 2011 From: thibaud.roussillat at gmail.com (Thibaud Roussillat) Date: Fri, 7 Jan 2011 15:38:26 +0100 Subject: Close stdout socket on CGI after fork with subprocess In-Reply-To: References: Message-ID: Hi, I work with Python 2.4 and CGI. I have a CGI which call a Python script in background process and return result before background task is finished. Actually, the browser displays response but it is waiting for end of background task because the socket is not closed. Internet told me that I must close the stdout file descriptor (sys.stdout.close()) to close the socket but it doesn't work. The background task is launched via subprocess.Popen and is attached to the root process on ps command. Any idea ? Thanks Thibaud -------------- next part -------------- An HTML attachment was scrubbed... URL: From kost-bebix at yandex.ua Fri Jan 7 09:47:55 2011 From: kost-bebix at yandex.ua (kost BebiX) Date: Fri, 07 Jan 2011 16:47:55 +0200 Subject: Rewriting __getattr__ In-Reply-To: <4D2721B0.7060601@sequans.com> References: <730351294351630@web139.yandex.ru> <4D271914.6090308@sequans.com> <191511294408478@web10.yandex.ru> <4D2721B0.7060601@sequans.com> Message-ID: <118251294411675@web154.yandex.ru> 07.01.2011, 16:22, "Jean-Michel Pichavant" : > kost BebiX wrote: > >> ?You're absolutely right! Now try to do except Keyerror: raise AttributeError and it will also fail. But why? >> >> ?07.01.2011, 15:45, "Jean-Michel Pichavant" ;: >>> ?kost BebiX wrote: >>>> ??Hi everyone! >>>> ??I just saw a bug (?) in bson.dbref:DBRef.__getattr__ >>>> >>>> ??Here's they're code: >>>> ??????def __getattr__(self, key): >>>> ??????????return self.__kwargs[key] >>>> >>>> ??And when you do copy.deepcopy on that object it will raise you KeyError. So here's a small piece of code that reproduces the problem: >>> ?from http://docs.python.org/reference/datamodel.html >>> >>> ?About __getattr__ >>> ?"This method should return the (computed) attribute value or raise an >>> ?AttributeError >>> ? >>> ?exception." >>> >>> ?The code you provided raises a KeyError thus methods such as 'getattr' >>> ?will fail as they expect an AttributeError exception. >>> >>> ?JM >>> >>> ?-- >>> ?http://mail.python.org/mailman/listinfo/python-list > > please don't top post :) > > It fails because you simply did not returned any value (with your class > A example). > > class A(object): > ????def __init__(self): > ????????self.d = {} > ????def __getattr__(self, key): > ????????try: > ????????????*return* self.d[key] > ????????except KeyError: > ????????????raise AttributeError > > works fine with deepcopy > > JM > > -- > http://mail.python.org/mailman/listinfo/python-list Sorry for top posting, didn't know about that) I'm quote new to posting to mailing lists. Well, actually the code you showed doesn't work) >>> class A(object): .. def __init__(self): .. self.d = {} .. def __getattr__(self, key): .. try: .. return self.d[key] .. except KeyError: .. raise AttributeError >>> from copy import deepcopy >>> a = A() >>> deepcopy(a) Exception RuntimeError: 'maximum recursion depth exceeded while calling a Python object' in ignored Exception RuntimeError: 'maximum recursion depth exceeded while calling a Python object' in ignored 0: <__main__.A object at 0xda0250> -- jabber: k.bx at ya.ru From jeanmichel at sequans.com Fri Jan 7 10:14:45 2011 From: jeanmichel at sequans.com (Jean-Michel Pichavant) Date: Fri, 07 Jan 2011 16:14:45 +0100 Subject: Rewriting __getattr__ In-Reply-To: <118251294411675@web154.yandex.ru> References: <730351294351630@web139.yandex.ru> <4D271914.6090308@sequans.com> <191511294408478@web10.yandex.ru> <4D2721B0.7060601@sequans.com> <118251294411675@web154.yandex.ru> Message-ID: <4D272DE5.9040604@sequans.com> kost BebiX wrote: > Sorry for top posting, didn't know about that) I'm quote new to posting to mailing lists. > > Well, actually the code you showed doesn't work) > > >>>> class A(object): >>>> > .. def __init__(self): > .. self.d = {} > .. def __getattr__(self, key): > .. try: > .. return self.d[key] > .. except KeyError: > .. raise AttributeError > >>>> from copy import deepcopy >>>> a = A() >>>> deepcopy(a) >>>> > Exception RuntimeError: 'maximum recursion depth exceeded while calling a Python object' in ignored > Exception RuntimeError: 'maximum recursion depth exceeded while calling a Python object' in ignored > 0: <__main__.A object at 0xda0250> > > > It does work as I pasted it with python2.5. recursion problems often occur when overriding __getattr__ or __getattribute__ *AND* accessing self attributes using self.attr form inside the method. try to change return self.d[key] into return object.__getattribute__(self, 'd')[key] Just speculating though, I cannot test since I don't reproduce the problem. JM From michael at stroeder.com Fri Jan 7 10:17:33 2011 From: michael at stroeder.com (=?UTF-8?B?TWljaGFlbCBTdHLDtmRlcg==?=) Date: Fri, 07 Jan 2011 16:17:33 +0100 Subject: Streaming templating languages for use as WSGI body. In-Reply-To: References: <1294336839.10436.2.camel@linux-yu4c.site> <1294341087.14042.3.camel@linux-yu4c.site> Message-ID: Alice Bevan?McGregor wrote: > On 2011-01-06 11:11:27 -0800, Adam Tauno Williams said: >> On Thu, 2011-01-06 at 11:07 -0800, Alice Bevan?McGregor wrote: >>> On 2011-01-06 10:00:39 -0800, Adam Tauno Williams said: >>>> With HTTP/1.0 [and WSGI is HTTP/1.0 only] you have to provide a >>>> Content-Length header - so you have to generate the entire response >>>> at once [however you want to muddy "at once"]. >>> >>> Both of these statements are false. >> >> Both these statements are true! I suggest you consult the HTTP spec. > > It's generally polite to provide direct references, either sections or > actual links when asking someone to RTFM. No matter, examining the > HTTP/1.0 RFC (conveniently chopped up and HTML-ified by the w3) I find > evidence to support your argument: > > http://www.w3.org/Protocols/HTTP/1.0/draft-ietf-http-spec.html#Entity-Body As I read section 7.2.2 (Length) the Content-length header is only required in HTTP *requests* if the body contains data. According to the text it's not required in HTTP *responses*. Ciao, Michael. From k.bx at ya.ru Fri Jan 7 10:18:43 2011 From: k.bx at ya.ru (kost BebiX) Date: Fri, 07 Jan 2011 17:18:43 +0200 Subject: Rewriting __getattr__ In-Reply-To: <4D272DE5.9040604@sequans.com> References: <730351294351630@web139.yandex.ru> <4D271914.6090308@sequans.com> <191511294408478@web10.yandex.ru> <4D2721B0.7060601@sequans.com> <118251294411675@web154.yandex.ru> <4D272DE5.9040604@sequans.com> Message-ID: <224691294413523@web18.yandex.ru> 07.01.2011, 17:14, "Jean-Michel Pichavant" : > kost BebiX wrote: > >> ?Sorry for top posting, didn't know about that) I'm quote new to posting to mailing lists. >> >> ?Well, actually the code you showed doesn't work) >>>>> ?class A(object): >> ?.. ????def __init__(self): >> ?.. ????????self.d = {} >> ?.. ????def __getattr__(self, key): >> ?.. ????????try: >> ?.. ????????????return self.d[key] >> ?.. ????????except KeyError: >> ?.. ????????????raise AttributeError >>>>> ?from copy import deepcopy >>>>> ?a = A() >>>>> ?deepcopy(a) >> ?Exception RuntimeError: 'maximum recursion depth exceeded while calling a Python object' in ignored >> ?Exception RuntimeError: 'maximum recursion depth exceeded while calling a Python object' in ignored >> ?0: <__main__.A object at 0xda0250> > > It does work as I pasted it with python2.5. > recursion problems often occur when overriding __getattr__ or > __getattribute__ *AND* accessing self attributes using self.attr form > inside the method. > > try to change > > ????return self.d[key] > > into > > ????return object.__getattribute__(self, 'd')[key] > > Just speculating though, I cannot test since I don't reproduce the problem. > > JM Yeap, that works. So, is it a python 2.6 bug? Because documentation says that __getattr__ is called only after property was not found (and __getattr__ was actually invented in a way that you can use self inside it). -- jabber: k.bx at ya.ru From steve+comp.lang.python at pearwood.info Fri Jan 7 10:41:59 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 07 Jan 2011 15:41:59 GMT Subject: Rewriting __getattr__ References: <730351294351630@web139.yandex.ru> <4D271914.6090308@sequans.com> <191511294408478@web10.yandex.ru> <4D2721B0.7060601@sequans.com> Message-ID: <4d273447$0$29976$c3e8da3$5496439d@news.astraweb.com> On Fri, 07 Jan 2011 16:47:55 +0200, kost BebiX wrote: > Well, actually the code you showed doesn't work) Actually, it does. It just prints a warning message as well. Look carefully: >>>> class A(object): > .. def __init__(self): > .. self.d = {} > .. def __getattr__(self, key): > .. try: > .. return self.d[key] > .. except KeyError: > .. raise AttributeError >>>> from copy import deepcopy >>>> a = A() >>>> deepcopy(a) > Exception RuntimeError: 'maximum recursion depth exceeded while calling > a Python object' in ignored > Exception RuntimeError: 'maximum recursion depth exceeded while calling > a Python object' in ignored > 0: <__main__.A object at 0xda0250> The last thing printed is the deepcopied object. I've tested the above code in Python versions 2.4 through 3.2 and the only one that prints that message is 2.6. -- Steven From pavlovevidence at gmail.com Fri Jan 7 10:56:26 2011 From: pavlovevidence at gmail.com (Carl Banks) Date: Fri, 7 Jan 2011 07:56:26 -0800 (PST) Subject: Resolve circular reference References: <1718ea91-fc4e-49f3-a15a-bdc683789126@k22g2000yqh.googlegroups.com> <353ecd61-22f8-4770-be30-29cb76b0f6b0@t35g2000yqj.googlegroups.com> Message-ID: <2349f7d4-2b85-456f-96b5-140f15548859@v17g2000prc.googlegroups.com> On Jan 7, 3:58?am, moerchendiser2k3 wrote: > > Force what? > > j refers to i, i refers to Foo, Foo refers to A. Therefore A should be > > alive. > > Oh, sorry. Force the deletion of instance Foo(A) and Bar(B). If you don't want j to keep i alive, you should look at weak referencing. (Look at the documentation for the weakref module. Also, this has nothing to do with A and B being C-defined types; this exact same behavior would happen even with Python types.) Carl Banks From jtim.arnold at gmail.com Fri Jan 7 11:24:01 2011 From: jtim.arnold at gmail.com (Tim) Date: Fri, 7 Jan 2011 08:24:01 -0800 (PST) Subject: os.system and loggers Message-ID: <70ac3463-cf3c-4435-909b-ac044bef7e41@z9g2000yqz.googlegroups.com> hi, I'm using a 3rd-party python program that uses the python logging facility and also makes calls to os.system. I'm trying to capture its output to a file. In my own code, I've taken control of the loggers that are setup in the other program by removing its StreamHandler and replacing with FileHander. But when it comes to the call to os.system I'm at a loss. I want to capture the stdout from that os.system call in my FileHandler. I thought this might work, before I call the other program's class/method: sys.stdout = getLogger('status').handlers[0].stream but no dice. Is there any clean way to get what I want? If not, I guess I'll override the other method with my own, but it will basically be a bunch of code copied with os.sytem replaced with subprocess, using getLogger('status').handlers[0].stream for stdout/ stderr. thanks, --Tim Arnold From alice at gothcandy.com Fri Jan 7 16:25:10 2011 From: alice at gothcandy.com (=?utf-8?Q?Alice_Bevan=E2=80=93McGregor?=) Date: Fri, 7 Jan 2011 13:25:10 -0800 Subject: Streaming templating languages for use as WSGI body. References: <1294336839.10436.2.camel@linux-yu4c.site> <1294341087.14042.3.camel@linux-yu4c.site> Message-ID: On 2011-01-07 07:17:33 -0800, Michael Str?der said: > As I read section 7.2.2 (Length) the Content-length header is only > required in HTTP *requests* if the body contains data. According to the > text it's not required in HTTP *responses*. You are correct; I mis-read that section in my haste. - Alice. From k.bx at ya.ru Fri Jan 7 16:51:53 2011 From: k.bx at ya.ru (kost BebiX) Date: Fri, 07 Jan 2011 23:51:53 +0200 Subject: Rewriting __getattr__ In-Reply-To: <2c5dfddb-abab-40ac-9936-ac4ee3778002@fm22g2000vbb.googlegroups.com> References: <730351294351630@web139.yandex.ru> <4D271914.6090308@sequans.com> <191511294408478@web10.yandex.ru> <4D2721B0.7060601@sequans.com> <118251294411675@web154.yandex.ru> <4D272DE5.9040604@sequans.com> <2c5dfddb-abab-40ac-9936-ac4ee3778002@fm22g2000vbb.googlegroups.com> Message-ID: <93751294437113@web122.yandex.ru> 07.01.2011, 23:48, "Fuzzyman" : > On Jan 7, 3:18?pm, kost BebiX ; wrote: > >> ?07.01.2011, 17:14, "Jean-Michel Pichavant" ;: >>> ?kost BebiX wrote: >>>> ??Sorry for top posting, didn't know about that) I'm quote new to posting to mailing lists. >>>> ??Well, actually the code you showed doesn't work) >>>>>>> ??class A(object): >>>> ??.. ????def __init__(self): >>>> ??.. ????????self.d = {} >>>> ??.. ????def __getattr__(self, key): >>>> ??.. ????????try: >>>> ??.. ????????????return self.d[key] >>>> ??.. ????????except KeyError: >>>> ??.. ????????????raise AttributeError >>>>>>> ??from copy import deepcopy >>>>>>> ??a = A() >>>>>>> ??deepcopy(a) >>>> ??Exception RuntimeError: 'maximum recursion depth exceeded while calling a Python object' in ignored >>>> ??Exception RuntimeError: 'maximum recursion depth exceeded while calling a Python object' in ignored >>>> ??0: <__main__.A object at 0xda0250> >>> ?It does work as I pasted it with python2.5. >>> ?recursion problems often occur when overriding __getattr__ or >>> ?__getattribute__ *AND* accessing self attributes using self.attr form >>> ?inside the method. >>> ?try to change >>> ?????return self.d[key] >>> ?into >>> ?????return object.__getattribute__(self, 'd')[key] >>> ?Just speculating though, I cannot test since I don't reproduce the problem. >>> ?JM >> ?Yeap, that works. So, is it a python 2.6 bug? Because documentation says that __getattr__ is called only after property was not found (and __getattr__ was actually invented in a way that you can use self inside it). > > That is true (that __getattr__ is called only if the attribute doesn't > exist), however deepcopy works by creating a new instance *without* > calling __init__. When it is copying the attributes self.d *doesn't* > exist initially. You should work around this case in your __getattr__ > if you want your object to be deep-copyable. > > Michael Foord > -- > http://www.voidspace.org.uk/ Yeah, but, I mean, shouldn't deepcopy copy the attributes before it gets to calling __getattr__? From k.bx at ya.ru Fri Jan 7 16:54:24 2011 From: k.bx at ya.ru (kost BebiX) Date: Fri, 07 Jan 2011 23:54:24 +0200 Subject: Rewriting __getattr__ In-Reply-To: <4d273447$0$29976$c3e8da3$5496439d@news.astraweb.com> References: <730351294351630@web139.yandex.ru> <4D271914.6090308@sequans.com> <191511294408478@web10.yandex.ru> <4D2721B0.7060601@sequans.com> <4d273447$0$29976$c3e8da3$5496439d@news.astraweb.com> Message-ID: <546511294437264@web13.yandex.ru> 07.01.2011, 17:47, "Steven D'Aprano" : > On Fri, 07 Jan 2011 16:47:55 +0200, kost BebiX wrote: > >> ?Well, actually the code you showed doesn't work) > > Actually, it does. It just prints a warning message as well. Look > carefully: > >>>>> ?class A(object): >> ?.. ????def __init__(self): >> ?.. ????????self.d = {} >> ?.. ????def __getattr__(self, key): >> ?.. ????????try: >> ?.. ????????????return self.d[key] >> ?.. ????????except KeyError: >> ?.. ????????????raise AttributeError >>>>> ?from copy import deepcopy >>>>> ?a = A() >>>>> ?deepcopy(a) >> ?Exception RuntimeError: 'maximum recursion depth exceeded while calling >> ?a Python object' in ignored >> ?Exception RuntimeError: 'maximum recursion depth exceeded while calling >> ?a Python object' in ignored >> ?0: <__main__.A object at 0xda0250> > > The last thing printed is the deepcopied object. > > I've tested the above code in Python versions 2.4 through 3.2 and the > only one that prints that message is 2.6. > > -- > Steven > -- > http://mail.python.org/mailman/listinfo/python-list So maybe it should be fixed in 2.6? When I'll have time I'll look at copy.py in different python's. Maybe there's the answer) Thanks anyway. From steve+comp.lang.python at pearwood.info Fri Jan 7 19:20:19 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 08 Jan 2011 00:20:19 GMT Subject: Rewriting __getattr__ References: <730351294351630@web139.yandex.ru> <4D271914.6090308@sequans.com> <191511294408478@web10.yandex.ru> <4D2721B0.7060601@sequans.com> <4d273447$0$29976$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4d27adc3$0$29976$c3e8da3$5496439d@news.astraweb.com> On Fri, 07 Jan 2011 23:54:24 +0200, kost BebiX wrote: > 07.01.2011, 17:47, "Steven D'Aprano" > : >> On Fri, 07 Jan 2011 16:47:55 +0200, kost BebiX wrote: >> >>> ?Well, actually the code you showed doesn't work) >> >> Actually, it does. It just prints a warning message as well. Look >> carefully: [...] >> I've tested the above code in Python versions 2.4 through 3.2 and the >> only one that prints that message is 2.6. > So maybe it should be fixed in 2.6? When I'll have time I'll look at > copy.py in different python's. Maybe there's the answer) Thanks anyway. Before you spend too much (i.e. any) time trying to fix this, I think that Python 2.6 is now only accepting security fixes. http://www.python.org/download/releases/2.6.6/ -- Steven From jason.swails at gmail.com Fri Jan 7 20:05:40 2011 From: jason.swails at gmail.com (Jason Swails) Date: Fri, 7 Jan 2011 20:05:40 -0500 Subject: Can I have both Python 2.7 and Python 3.1 at the same time on the Mac? In-Reply-To: <51F66C79-5607-4943-B56C-2EF22F3AD407@cagttraining.com> References: <775A9D45-25B5-4A16-9FE5-6217FD67F3AF@cagttraining.com> <51F66C79-5607-4943-B56C-2EF22F3AD407@cagttraining.com> Message-ID: MacPorts! They include a nifty little package called python_select that lets you switch default python versions on-the-fly and organizes everything for you perfectly. I have python 2.4, 2.5, 2.6, 2.7, 3.2, and the system default 2.6.1 all installed, and python_select python27 python_select python32 python_select python26-apple switches seamlessly between them. (I have so many versions to test script compatibility, not because I'm an avid collector). In any case, this seems to be an ideal solution. All the best, Jason On Thu, Jan 6, 2011 at 5:25 PM, Bill Felton wrote: > On Jan 6, 2011, at 3:46 PM, Ned Deily wrote: > > In article <775A9D45-25B5-4A16-9FE5-6217FD67F3AF at cagttraining.com>, > > Bill Felton wrote: > > I'm new to python, trying to learn it from a variety of resources, > including > > references posted recently to this list. > > I'm going through /www.openbookproject.net/thinkCSpy/ and find it makes > use > > of gasp, which apparently is not compatible with 3.1. > > I've also seen various resources indicate that one can install both Python > > 2.7 and Python 3.1 -- but when I did this, I get no end of problems in the > > 2.7 install. IDLE, in particular, fails rather spectacularly, even if I > > launch it directly from the Python 2.7 directory in which it resides. > > So, either I've been misled and should only try to have one or the other. > OR > > I'm missing some (probably simple) step that's mucking me up. > > Help? > > > Yes, you can have multiple versions of Python installed on Mac OS X. In > > fact, Apple ships multiple versions of Python with OS X (2.6 and 2.6 > > with OS X 10.6, for example). Starting with Python 2.7, python.org > > offers two variants of OS X installers, one is 32-bit-only and works on > > all versions of OS X 10.3.9 through OS X 10.6, the other supports 64-bit > > execution and only works on 10.6 (as of 2.7.1). Unfortunately, there > > are some major interaction problems between Tkinter, Python's GUI > > toolkit which is used by IDLE, and the Tcl/Tk 8.5 supplied by Apple in > > OS X 10.6. I'm assuming you installed the 64-bit version. If so, until > > the problem is resolved in the next maintenance release of Python 2.7, I > > suggest you download and install the 32-bit-only version of Python 2.7.1 > > which does not have those problems. > > > > Thank you, Ned! Installing what appeared to be the 'old OS' version seems > to fix my difficulty. > IDLE now works fine without hanging, I can enter code, save, check syntax, > and run from the 'new window'. > And 3.1 still works as before. > > regards, > Bill > > -- > http://mail.python.org/mailman/listinfo/python-list > > -- Jason M. Swails Quantum Theory Project, University of Florida Ph.D. Graduate Student 352-392-4032 -------------- next part -------------- An HTML attachment was scrubbed... URL: From linnaweb at gmail.com Fri Jan 7 20:08:28 2011 From: linnaweb at gmail.com (linna li) Date: Fri, 7 Jan 2011 17:08:28 -0800 (PST) Subject: apscheduler error Message-ID: <9699865b-a8be-4284-a347-58d875b491f6@n2g2000pre.googlegroups.com> I tried to use the apscheduler and used the sample code below from the tutorial, but got the error message: Exception in thread APScheduler (most likely raised during interpreter shutdown). What's going on here? I really appreciate any help! from apscheduler.scheduler import Scheduler sched = Scheduler() sched.start() def some_job(): print "Decorated job" sched.add_interval_job(some_job,minutes=1) From nad at acm.org Fri Jan 7 20:46:37 2011 From: nad at acm.org (Ned Deily) Date: Fri, 07 Jan 2011 17:46:37 -0800 Subject: Can I have both Python 2.7 and Python 3.1 at the same time on the Mac? References: <775A9D45-25B5-4A16-9FE5-6217FD67F3AF@cagttraining.com> <51F66C79-5607-4943-B56C-2EF22F3AD407@cagttraining.com> Message-ID: In article , Jason Swails wrote: > MacPorts! They include a nifty little package called python_select that > lets you switch default python versions on-the-fly and organizes everything > for you perfectly. I have python 2.4, 2.5, 2.6, 2.7, 3.2, and the system > default 2.6.1 all installed, and > > python_select python27 > python_select python32 > python_select python26-apple > > switches seamlessly between them. (I have so many versions to test script > compatibility, not because I'm an avid collector). In any case, this seems > to be an ideal solution. Unfortunately, that's not a complete solution. The biggest hole is that it does not automatically solve the problem of scripts installed into the particular version's framework bin directory, neither all of the current scripts included in the standard python distribution nor 3rd party version-dependent scripts, things like easy_install, pip, etc. The former is easily fixed, the latter is harder to automate. The python.org installers take the route of providing a shell script app for each version to modify your shell login profile to insert that version's bin directory at the head of the $PATH env variable. Modifying a shell profile is clearly not a particularly clean solution but it does actually work whereas python_select, in general, does not. -- Ned Deily, nad at acm.org From steve+comp.lang.python at pearwood.info Fri Jan 7 21:09:49 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 08 Jan 2011 02:09:49 GMT Subject: apscheduler error References: <9699865b-a8be-4284-a347-58d875b491f6@n2g2000pre.googlegroups.com> Message-ID: <4d27c76d$0$29976$c3e8da3$5496439d@news.astraweb.com> On Fri, 07 Jan 2011 17:08:28 -0800, linna li wrote: > I tried to use the apscheduler and used the sample code below from the > tutorial, but got the error message: Exception in thread APScheduler > (most likely raised during interpreter shutdown). What's going on here? > I really appreciate any help! I've tried your code in every version of Python from 2.4 through 3.2, and get an exception on the very first line every time: ImportError: No module named apscheduler.scheduler I think you will need to give some more detail... what version of Python are you running, and what is apschedular? Also, please copy and paste the exact error message, in full, including the traceback. Don't summarise it, retype it, or paraphrase it. -- Steven From clp2 at rebertia.com Fri Jan 7 21:13:26 2011 From: clp2 at rebertia.com (Chris Rebert) Date: Fri, 7 Jan 2011 18:13:26 -0800 Subject: apscheduler error In-Reply-To: <4d27c76d$0$29976$c3e8da3$5496439d@news.astraweb.com> References: <9699865b-a8be-4284-a347-58d875b491f6@n2g2000pre.googlegroups.com> <4d27c76d$0$29976$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Fri, Jan 7, 2011 at 6:09 PM, Steven D'Aprano wrote: > On Fri, 07 Jan 2011 17:08:28 -0800, linna li wrote: >> I tried to use the apscheduler and used the sample code below from the >> tutorial, but got the error message: Exception in thread APScheduler >> (most likely raised during interpreter shutdown). What's going on here? >> I really appreciate any help! > > > I've tried your code in every version of Python from 2.4 through 3.2, and > get an exception on the very first line every time: > > ImportError: No module named apscheduler.scheduler > > > I think you will need to give some more detail... what version of Python > are you running, and what is apschedular? A quick Google search suggests it's http://packages.python.org/APScheduler/ Cheers, Chris From k.bx at ya.ru Fri Jan 7 21:13:42 2011 From: k.bx at ya.ru (kost BebiX) Date: Sat, 08 Jan 2011 04:13:42 +0200 Subject: Rewriting __getattr__ In-Reply-To: <4d27adc3$0$29976$c3e8da3$5496439d@news.astraweb.com> References: <730351294351630@web139.yandex.ru> <4D271914.6090308@sequans.com> <191511294408478@web10.yandex.ru> <4D2721B0.7060601@sequans.com> <4d273447$0$29976$c3e8da3$5496439d@news.astraweb.com> <4d27adc3$0$29976$c3e8da3$5496439d@news.astraweb.com> Message-ID: <771791294452822@web75.yandex.ru> 08.01.2011, 02:20, "Steven D'Aprano" : > On Fri, 07 Jan 2011 23:54:24 +0200, kost BebiX wrote: > >> ?07.01.2011, 17:47, "Steven D'Aprano" >> ?;: >>> ?On Fri, 07 Jan 2011 16:47:55 +0200, kost BebiX wrote: >>>> ??Well, actually the code you showed doesn't work) >>> ?Actually, it does. It just prints a warning message as well. Look >>> ?carefully: > > [...] > >>> ?I've tested the above code in Python versions 2.4 through 3.2 and the >>> ?only one that prints that message is 2.6. >> ?So maybe it should be fixed in 2.6? When I'll have time I'll look at >> ?copy.py in different python's. Maybe there's the answer) Thanks anyway. > > Before you spend too much (i.e. any) time trying to fix this, I think > that Python 2.6 is now only accepting security fixes. > > http://www.python.org/download/releases/2.6.6/ > > -- > Steven Too bad (I mean, it's not too bad, because this thing can break other's 2.6 code that somehow depends on that). Now when I'll install 2.7 I'll have to remember about this bug when coding) From kushal.kumaran+python at gmail.com Fri Jan 7 21:19:18 2011 From: kushal.kumaran+python at gmail.com (Kushal Kumaran) Date: Sat, 8 Jan 2011 07:49:18 +0530 Subject: Close stdout socket on CGI after fork with subprocess In-Reply-To: References: Message-ID: On Fri, Jan 7, 2011 at 8:08 PM, Thibaud Roussillat wrote: > Hi, > > I work with Python 2.4 and CGI. > > I have a CGI which call a Python script in background process and return > result before background task is finished. > > Actually, the browser displays response but it is waiting for end of > background task because the socket is not closed. > > Internet told me that I must close the stdout file descriptor > (sys.stdout.close()) to close the socket but it doesn't work. > > The background task is launched via subprocess.Popen and is attached to the > root process on ps command. > This means that the parent process finished before the child. Call wait() on the Popen object to wait for the child to terminate. Depending on how you create the Popen object, the child process may inherit your own stdout. In that case, the child process may be keeping the socket open after the parent dies. -- regards, kushal From jlsphar at gmail.com Fri Jan 7 21:42:45 2011 From: jlsphar at gmail.com (John) Date: Fri, 7 Jan 2011 18:42:45 -0800 (PST) Subject: student question Message-ID: >>> q_file = open(questions_location) #opens the document successfully >>> for line in q_file: print line # prints document successfully >>> line # prints last line of document >>> for line in q_file: print line # prints nothing ...why does it print nothing? From kb1pkl at aim.com Fri Jan 7 21:47:05 2011 From: kb1pkl at aim.com (Corey Richardson) Date: Fri, 07 Jan 2011 21:47:05 -0500 Subject: student question In-Reply-To: References: Message-ID: <4D27D029.7050708@aim.com> On 01/07/2011 09:42 PM, John wrote: >>>> q_file = open(questions_location) #opens the document successfully >>>> for line in q_file: > print line > > # prints document successfully >>>> line > # prints last line of document >>>> for line in q_file: > print line # prints nothing > > ...why does it print nothing? IIRC, iterating through the lines in a file moves the cursor (is that the correct term?) to the end of the file. After the first one, use q_file.seek(0) to go back to the start. I think. ~Corey Richardson From jlsphar at gmail.com Fri Jan 7 21:54:29 2011 From: jlsphar at gmail.com (John) Date: Fri, 7 Jan 2011 18:54:29 -0800 (PST) Subject: student question References: Message-ID: On Jan 7, 6:47?pm, Corey Richardson wrote: > On 01/07/2011 09:42 PM, John wrote: > > >>>> q_file = open(questions_location) #opens the document successfully > >>>> for line in q_file: > > ? ? ? ? ? ?print line > > > # prints document successfully > >>>> line > > # prints last line of document > >>>> for line in q_file: > > ? ? ? ? ? ?print line # prints nothing > > > ...why does it print nothing? > > IIRC, iterating through the lines in a file moves the cursor (is that > the correct term?) to the end of the file. After the first one, use > q_file.seek(0) to go back to the start. I think. > > ~Corey Richardson fantastic. thanks, corey! From zuying at gmail.com Fri Jan 7 22:06:46 2011 From: zuying at gmail.com (Ying Zu) Date: 8 Jan 2011 03:06:46 GMT Subject: How to read ansic file into a pre-defined class? Message-ID: How to read ansic file into a pre-defined class? I have a series of files written in the following format, 2 # number of classes 100 # number of items for the first class object 0 foo 1 foo ... 99 foo 150 # number of items for the second class object 0 bar 1 bar ... 149 bar ultimately I want to read the file to two *structs* (sorry for my C jargon, just started playing with Python), with attributes number_of_items and data_array. I wrote a simply code to read and split each line into a list, then try to tell the meaning of each line by the number of elements of each line list and the its position in the file. But it is definitely not the way Python should be used. Any ideas on how to implement a more elegant yet efficient python version? Thanks. meaning of each line by counting the number of elements From zuying at gmail.com Fri Jan 7 22:24:01 2011 From: zuying at gmail.com (Ying Zu) Date: 8 Jan 2011 03:24:01 GMT Subject: How to read ansic file into a pre-defined class? Message-ID: How to read ansic file into a pre-defined class? I have a series of files written in the following format, 2 # number of classes 100 # number of items for the first class object 0 foo 1 foo ... 99 foo 150 # number of items for the second class object 0 bar 1 bar ... 149 bar ultimately I want to read the file to two *structs* (sorry for my C jargon, just started playing with Python), with attributes number_of_items and data_array. I wrote a simply code to read and split each line into a list, then try to tell the meaning of each line by the number of elements of each line list and the its position in the file. But it is definitely not the way Python should be used. Any ideas on how to implement a more elegant yet efficient python version? Thanks. -- ~ying From awilliam at whitemice.org Fri Jan 7 22:49:54 2011 From: awilliam at whitemice.org (Adam Tauno Williams) Date: Fri, 07 Jan 2011 22:49:54 -0500 Subject: apscheduler error In-Reply-To: <9699865b-a8be-4284-a347-58d875b491f6@n2g2000pre.googlegroups.com> References: <9699865b-a8be-4284-a347-58d875b491f6@n2g2000pre.googlegroups.com> Message-ID: <1294458594.11145.21.camel@linux-yu4c.site> On Fri, 2011-01-07 at 17:08 -0800, linna li wrote: > I tried to use the apscheduler and used the sample code below from the > tutorial, but got the error message: Exception in thread APScheduler > (most likely raised during interpreter shutdown). What's going on > here? I really appreciate any help! > > from apscheduler.scheduler import Scheduler > > sched = Scheduler() > sched.start() > > def some_job(): > print "Decorated job" > > sched.add_interval_job(some_job,minutes=1) I see this same error when I run this code (python-2.6.5-3.3.1.x86_64) I develop an application that uses APScheduler , the scheduler works very well. But I haven't used it in exactly this manner. If I add - import time time.sleep(300) - to the end of your script I don't get the error; and the job actually gets run [the scheduler thread won't stop the main thread, and thus the script, from exiting]. The author of APScheduler has an eponymously named channel on FreeNode, he can probably answer your question exactly. From kanthony at woh.rr.com Fri Jan 7 23:43:54 2011 From: kanthony at woh.rr.com (Keith Anthony) Date: Fri, 07 Jan 2011 22:43:54 -0600 Subject: More Help with python .find fucntion Message-ID: My previous question asked how to read a file into a strcuture a line at a time. Figured it out. Now I'm trying to use .find to separate out the PDF objects. (See code) PROBLEM/QUESTION: My call to lines[i].find does NOT find all instances of endobj. Any help available? Any insights? #!/usr/bin/python inputfile = file('sample.pdf','rb') # This is PDF with which we will work lines = inputfile.readlines() # read file one line at a time linestart = [] # Starting address for each line lineend = [] # Ending address for each line linetype = [] print len(lines) # print number of lines i = 0 # define an iterator, i addr = 0 # and address pointer while i < len(lines): # Go through each line linestart = linestart + [addr] length = len(lines[i]) lineend = lineend + [addr + (length-1)] addr = addr + length i = i + 1 i = 0 while i < len(lines): # Initialize line types as normal linetype = linetype + ['normal'] i = i + 1 i = 0 while i < len(lines): # if lines[i].find(' obj') > 0: linetype[i] = 'object' print "At address ",linestart[i],"object found at line ",i,": ", lines[i] if lines[i].find('endobj') > 0: linetype[i] = 'endobj' print "At address ",linestart[i],"endobj found at line ",i,": ", lines[i] i = i + 1 -- --------------------------------- --- -- - Posted with NewsLeecher v4.0 Final Web @ http://www.newsleecher.com/?usenet ------------------- ----- ---- -- - From clp2 at rebertia.com Sat Jan 8 00:06:55 2011 From: clp2 at rebertia.com (Chris Rebert) Date: Fri, 7 Jan 2011 21:06:55 -0800 Subject: More Help with python .find fucntion In-Reply-To: References: Message-ID: On Fri, Jan 7, 2011 at 8:43 PM, Keith Anthony wrote: > My previous question asked how to read a file into a strcuture > a line at a time. ?Figured it out. ?Now I'm trying to use .find > to separate out the PDF objects. ?(See code) ?PROBLEM/QUESTION: > My call to lines[i].find does NOT find all instances of endobj. > Any help available? ?Any insights? > > #!/usr/bin/python > > inputfile = ?file('sample.pdf','rb') ? ? ? ? ? ?# This is PDF with which we will work > lines = inputfile.readlines() ? ? ? ? ? ? ? ? ? # read file one line at a time > > linestart = [] ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?# Starting address for each line > lineend = [] ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?# Ending address for each line > linetype = [] > > print len(lines) ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?# print number of lines > > i = 0 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? # define an iterator, i > addr = 0 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?# and address pointer > > while i < len(lines): ? ? ? ? ? ? ? ? ? ? ? ? ? # Go through each line > ? ?linestart = linestart + [addr] > ? ?length = len(lines[i]) > ? ?lineend = lineend + [addr + (length-1)] > ? ?addr = addr + length > ? ?i = i + 1 > > i = 0 > while i < len(lines): ? ? ? ? ? ? ? ? ? ? ? ? ? # Initialize line types as normal > ? ?linetype = linetype + ['normal'] > ? ?i = i + 1 > > i = 0 > while i < len(lines): ? ? ? ? ? ? ? ? ? ? ? ? ? # > ? ?if lines[i].find(' obj') > 0: > ? ? ? ?linetype[i] = 'object' > ? ? ? ?print "At address ",linestart[i],"object found at line ",i,": ", lines[i] > ? ?if lines[i].find('endobj') > 0: > ? ? ? ?linetype[i] = 'endobj' > ? ? ? ?print "At address ",linestart[i],"endobj found at line ",i,": ", lines[i] > ? ?i = i + 1 Your code can be simplified significantly. In particular: - Don't add single-element lists. Use the list.append() method instead. - One seldom manually tracks counters like `i` in Python; use range() or enumerate() instead. - Lists have a multiply method which gives the concatenation of n copies of the list. Revised version (untested obviously): inputfile = file('sample.pdf','rb') # This is PDF with which we will work lines = inputfile.readlines() # read file one line at a time linestart = [] # Starting address for each line lineend = [] # Ending address for each line linetype = ['normal']*len(lines) print len(lines) # print number of lines addr = 0 # and address pointer for line in lines: # Go through each line linestart.append(addr) length = len(line) lineend.append(addr + (length-1)) addr += length for i, line in enumerate(lines): if line.find(' obj') > 0: linetype[i] = 'object' print "At address ",linestart[i],"object found at line ",i,": ", line if line.find('endobj') > 0: linetype[i] = 'endobj' print "At address ",linestart[i],"endobj found at line ",i,": ", line As to the bug: I think you want "!= -1" rather than "> 0" for your conditionals; remember that Python list/string indices are 0-based. Cheers, Chris -- http://blog.rebertia.com From stackslip at gmail.com Sat Jan 8 00:18:42 2011 From: stackslip at gmail.com (Garland Fulton) Date: Fri, 7 Jan 2011 20:18:42 -0900 Subject: Error invalid syntax while statement Message-ID: I don't understand what I'm doing wrong i've tried several different cases for what i am doing here. Will someone please point my error out. Thank you. 1 #!/bin/bash/python 2 import math 3 try: 4 x = int(input("Enter your number: ")) 5 if( 0 > x | x > 2147483647): 6 raise Exception() 7 else: 8 end = 0 9 count = 0 10 count1 = x 11 counter = 0 12 print("end: ", end) 13 print("count: ", count) 14 print("count1: ", count1) 15 print("counter: ", counter 16 17 while (end == 0): # <-------------------returns syntax error on this while statement 18 if(count < x): 19 20 sol = math.pow(count, 2) + math.pow(count1, 2) 21 count += 1 22 count1 -= 1 23 print("end: ", end) 24 print("count: ", count) 25 print("count1: ", count1) 26 print("counter: ", counter 27 if( sol == x): 28 counter += x 29 else: 30 end = 1 31 except Exception as ran: 32 print("Value not within range", ran) -------------- next part -------------- An HTML attachment was scrubbed... URL: From clp2 at rebertia.com Sat Jan 8 00:28:19 2011 From: clp2 at rebertia.com (Chris Rebert) Date: Fri, 7 Jan 2011 21:28:19 -0800 Subject: Error invalid syntax while statement In-Reply-To: References: Message-ID: On Fri, Jan 7, 2011 at 9:18 PM, Garland Fulton wrote: > I don't understand what I'm doing wrong i've tried several different cases > for what i am doing here. Will someone please point my error out. > Thank you. > > ??1 #!/bin/bash/python This shebang undoubtedly erroneous. > ??5 ? ? if( 0 > x | x > 2147483647): One normally writes that using boolean "or" rather than the bitwise operator. Also, the parentheses are completely unnecessary visual clutter. > ?15 ? ? ? ? print("counter: ", counter Where's the closing parenthesis? > ?17 ? ? ? ? ? ? ? while (end == 0): ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?# > <-------------------returns syntax error on this while statement Always include the exact error message + traceback in the future. Cheers, Chris -- http://blog.rebertia.com From nad at acm.org Sat Jan 8 00:28:40 2011 From: nad at acm.org (Ned Deily) Date: Fri, 07 Jan 2011 21:28:40 -0800 Subject: Error invalid syntax while statement References: Message-ID: In article , Garland Fulton wrote: > I don't understand what I'm doing wrong i've tried several different cases > for what i am doing here. Will someone please point my error out. > 15 print("counter: ", counter Missing ")" on line 15. -- Ned Deily, nad at acm.org From steve+comp.lang.python at pearwood.info Sat Jan 8 00:35:45 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 08 Jan 2011 05:35:45 GMT Subject: More Help with python .find fucntion References: Message-ID: <4d27f7b1$0$29976$c3e8da3$5496439d@news.astraweb.com> On Fri, 07 Jan 2011 22:43:54 -0600, Keith Anthony wrote: > My previous question asked how to read a file into a strcuture a line at > a time. Figured it out. Now I'm trying to use .find to separate out > the PDF objects. (See code) PROBLEM/QUESTION: My call to lines[i].find > does NOT find all instances of endobj. Any help available? Any > insights? > > #!/usr/bin/python > > inputfile = file('sample.pdf','rb') # This is PDF with which > we will work > lines = inputfile.readlines() # read file > one line at a time That's incorrect. readlines() reads the entire file in one go, and splits it into individual lines. > linestart = [] # Starting address for > each line > lineend = [] # Ending > address for each line > linetype = [] *raises eyebrow* How is an empty list a starting or ending address? The only thing worse than no comments where you need them is misleading comments. A variable called "linestart" implies that it should be a position, e.g. linestart = 0. Or possibly a flag. > print len(lines) # print number of lines > > i = 0 # define an iterator, i Again, 0 is not an iterator. 0 is a number. > addr = 0 # and address pointer > > while i < len(lines): # Go through each line > linestart = linestart + [addr] > length = len(lines[i]) > lineend = lineend + [addr + (length-1)] addr = addr + length > i = i + 1 Complicated and confusing and not the way to do it in Python. Something like this is much simpler: linetypes = [] # note plural inputfile = open('sample.pdf','rb') # Don't use file, use open. for line_number, line in enumerate(inputfile): # Process one line at a time. No need for that nonsense with manually # tracked line numbers, enumerate() does that for us. # No need to initialise linetypes. status = 'normal' i = line.find(' obj') if i >= 0: print "Object found at offset %d in line %d" % (i, line_number) status = 'object' i = line.find('endobj') if i >= 0: print "endobj found at offset %d in line %d" % (i, line_number) if status == 'normal': status = 'endobj' else: status = 'object & endobj' # both found on the one line linetypes.append(status) # What if obj or endobj exist more than once in a line? One last thing... if PDF files are a binary format, what makes you think that they can be processed line-by-line? They may not have lines, except by accident. -- Steven From stackslip at gmail.com Sat Jan 8 00:46:51 2011 From: stackslip at gmail.com (Garland Fulton) Date: Fri, 7 Jan 2011 20:46:51 -0900 Subject: Error invalid syntax while statement In-Reply-To: References: Message-ID: On Fri, Jan 7, 2011 at 8:28 PM, Ned Deily wrote: > In article > , > Garland Fulton wrote: > > I don't understand what I'm doing wrong i've tried several different > cases > > for what i am doing here. Will someone please point my error out. > > > 15 print("counter: ", counter > > Missing ")" on line 15. > > -- > Ned Deily, > nad at acm.org > > -- > http://mail.python.org/mailman/listinfo/python-list > 1 #!/bin/bash/python 2 import math 3 try: 4 x = int(input("Enter your number: ")) 5 if 0 > x > 2147483647: 6 raise Exception() 7 else: 8 end = 0 9 count = 0 10 count1 = x 11 counter = 0 12 print("end: ", end) 13 print("count: ", count) 14 print("count1: ", count1) 15 print("counter: ", counter) 16 17 while end == 0: # <-------------------returns syntax error on this while statement 18 if(count < x): 19 20 sol = math.pow(count, 2) + math.pow(count1, 2) 21 count += 1 22 count1 -= 1 23 print("end: ", end) 24 print("count: ", count) 25 print("count1: ", count1) 26 print("counter: ", counter) 27 if sol == x: 28 counter += x 29 else: 30 end = 1 31 except Exception as ran: 32 print("Value not within range", ran) File "blah.py", line 17 while (end == 0): # <-------------------returns syntax error on this while statement ^ IndentationError: unexpected indent Thank you and I'm sorry for the very blind question, it was because of the missing par-ends I have spent a while on this won't happen again. What is wrong with my shebang line? Thank you for the syntax tips! -------------- next part -------------- An HTML attachment was scrubbed... URL: From clp2 at rebertia.com Sat Jan 8 00:55:05 2011 From: clp2 at rebertia.com (Chris Rebert) Date: Fri, 7 Jan 2011 21:55:05 -0800 Subject: Error invalid syntax while statement In-Reply-To: References: Message-ID: On Fri, Jan 7, 2011 at 9:46 PM, Garland Fulton wrote: > ??1 #!/bin/bash/python > What is > wrong with my shebang line? Its path is invalid (unless you're using a *very* weird system). /bin/bash is the bash shell executable; bash is completely unrelated to Python. Further, /bin/bash is a file, not a directory. The shebang for Python is normally one of the following: #!/usr/bin/env python #!/usr/bin/python Cheers, Chris -- http://blog.rebertia.com From stackslip at gmail.com Sat Jan 8 00:57:25 2011 From: stackslip at gmail.com (Garland Fulton) Date: Fri, 7 Jan 2011 20:57:25 -0900 Subject: Error invalid syntax while statement In-Reply-To: References: Message-ID: On Fri, Jan 7, 2011 at 8:55 PM, Chris Rebert wrote: > On Fri, Jan 7, 2011 at 9:46 PM, Garland Fulton > wrote: > > > 1 #!/bin/bash/python > > > What is > > wrong with my shebang line? > > Its path is invalid (unless you're using a *very* weird system). > /bin/bash is the bash shell executable; bash is completely unrelated > to Python. Further, /bin/bash is a file, not a directory. > > The shebang for Python is normally one of the following: > #!/usr/bin/env python > #!/usr/bin/python > > Cheers, > Chris > -- > http://blog.rebertia.com > Great I have learned a ton and these questions will not arise again. -------------- next part -------------- An HTML attachment was scrubbed... URL: From alice at gothcandy.com Sat Jan 8 02:03:58 2011 From: alice at gothcandy.com (=?utf-8?Q?Alice_Bevan=E2=80=93McGregor?=) Date: Fri, 7 Jan 2011 23:03:58 -0800 Subject: apscheduler error References: <9699865b-a8be-4284-a347-58d875b491f6@n2g2000pre.googlegroups.com> Message-ID: Howdy! On 2011-01-07 17:08:28 -0800, linna li said: > I tried to use the apscheduler and used the sample code below from the > tutorial, but got the error message: Exception in thread APScheduler > (most likely raised during interpreter shutdown). What's going on here? > I really appreciate any help! After talking a bit with Alex Gr?nholm it seems this is an issue raised fairly often (not always in the context of this package) and is not really a problem with APScheduler. It has far more to do with attempting to start a thread, then immediately exiting the main thread. That's not how threading is supposed to be used, so don't do it. ;) APScheduler 2.0 adds some improved examples, according to Alex, that don't suffer the "problem" demonstrated by the short code snippit you provided. A package of mine, TurboMail, suffers from the same threading issue if used improperly; you enqueue e-mail, it starts a thread, then you immediately exit. TM tries to work around the issue, but in most cases that workaround does not work properly. (You get strange uncatchable exceptions printed on stderr though AFIK the e-mail does get sent correctly, your application may hang waiting for the thread pool to drain if you have a "minimum thread count" option set.) I hope this clears things up a bit, - Alice. From tjreedy at udel.edu Sat Jan 8 06:04:08 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Sat, 08 Jan 2011 06:04:08 -0500 Subject: Error invalid syntax while statement In-Reply-To: References: Message-ID: > 15 print("counter: ", counter > 16 > 17 while (end == 0): # > <-------------------returns syntax error on this while statement Among other responses, there is no indent after print. should be print() while x: #now indent -- Terry Jan Reedy From kanthony at woh.rr.com Sat Jan 8 08:44:19 2011 From: kanthony at woh.rr.com (Keith Anthony) Date: Sat, 08 Jan 2011 07:44:19 -0600 Subject: More Help with python .find fucntion References: <4d27f7b1$0$29976$c3e8da3$5496439d@news.astraweb.com> Message-ID: THanks ... I am new to Python ... Comparing the result of find with -1 fixes the bug ... some of the endobj start in the firt position ... You're right about the lines ending in \n by accident, EXCEPT in PDF files items are separated by obj <<\n and endobj\n -- --------------------------------- --- -- - Posted with NewsLeecher v4.0 Final Web @ http://www.newsleecher.com/?usenet ------------------- ----- ---- -- - From dmw at coder.cl Sat Jan 8 09:38:10 2011 From: dmw at coder.cl (Daniel Molina Wegener) Date: Sat, 08 Jan 2011 11:38:10 -0300 Subject: [ANN] pyxser-1.5.2r --- Python Object to XML serializer/deserializer Message-ID: Hello Python Community. I'm pleased to announce pyxser-1.5.2r, a python extension which contains functions to serialize and deserialize Python Objects into XML. This is a model based serializer. This release is supports Python 2.4 to Python 2.5. What can do this serializer? * Serialization of cross references. * Serialization of circular references. * Preserves object references on deserialization. * Custom serializations. * Custom deserializations. * Object attribute selection call-back. * Serialization depth limit. * Standards based serialization. * Standards based XML validation using pyxser XML Schema. * C14N based serialization, as optional kind of output. * Model based XML serialization, represented on XML Schema and XML DTD. The ChangeLog for this release is as follows: -----8<----------8<----------8<----------8<----- 1.5.2r (2011.01.08): Daniel Molina Wegener * Added support for Python 2.4 * Replaced the use of the commands package by the subprocess package on the setup script. * On the next release will be added support for Python 3.X ;) Thanks to pyxser users for their feedback. -----8<----------8<----------8<----------8<----- The project is hosted at: http://sourceforge.net/projects/pyxser/ Where you can report bugs and have other options, like forums mailing lists and access to the repository if you want to contribute. The web page for the project is located at: http://coder.cl/products/pyxser/ PyPi entry is: http://pypi.python.org/pypi/pyxser/1.5.2r Best regards, -- Daniel Molina Wegener System Programmer & Web Developer Phone: +56 (2) 979-0277 | Blog: http://coder.cl/ From wayne.dads.bell at gmail.com Sat Jan 8 09:44:05 2011 From: wayne.dads.bell at gmail.com (dads) Date: Sat, 8 Jan 2011 06:44:05 -0800 (PST) Subject: filecmp.dircmp performance Message-ID: I'm creating a one way sync program, it's to automate backing up data over the wan from our shops to a server at head office. It uses filecmp.dircmp() but the performance seems poor to me. for x in dc.diff_files: srcfp = os.path.join(src, x) self.fn777(srcfp) if os.path.isfile(srcfp): try: shutil.copy2(srcfp, dst) self.lg.add_diffiles(src, x) except Exception, e: self.lg.add_errors(e) I tested it at a store which is only around 50 miles away on a 10Mbps line, the directory has 59 files that are under 100KB. When it gets to dc.diff_files it takes 15mins to complete. Looking at the filecmp.py it's only using os.stat, it seems excessively long. code: http://pastebin.com/QskXGDQT From no.email at please.post Sat Jan 8 11:07:23 2011 From: no.email at please.post (kj) Date: Sat, 8 Jan 2011 16:07:23 +0000 (UTC) Subject: Python app dev tools for Gnome? Message-ID: There's a zillion utility apps that I've had kicking around in my head for years, but I've never implemented because I absolutely hate GUI programming. But I'm increasingly impressed by the quality, stability, and sheer number, of Gnome apps that I keep coming across that use Python under the hood. This gives me hope that maybe programming GUI Python apps for Gnome these days is no longer the traumatizing experience it used to be when I last tried it. Can someone recommend some good tools to speed up the development of Python apps[1] for Gnome? E.g. is there anything like Xcode for Gnome+Python? TIA! ~kj [1] Needless to say, when I write "apps" I mean full-blown GUI apps: windows, menus, events, threads, clickable icon, the whole ball of wax. As opposed to cli apps, panel widgets, etc. From __peter__ at web.de Sat Jan 8 11:28:56 2011 From: __peter__ at web.de (Peter Otten) Date: Sat, 08 Jan 2011 17:28:56 +0100 Subject: filecmp.dircmp performance References: Message-ID: dads wrote: > I'm creating a one way sync program, it's to automate backing up data > over the wan from our shops to a server at head office. It uses > filecmp.dircmp() but the performance seems poor to me. > > for x in dc.diff_files: > srcfp = os.path.join(src, x) > self.fn777(srcfp) > if os.path.isfile(srcfp): > try: > shutil.copy2(srcfp, dst) > self.lg.add_diffiles(src, x) > except Exception, e: > self.lg.add_errors(e) > > I tested it at a store which is only around 50 miles away on a 10Mbps > line, the directory has 59 files that are under 100KB. When it gets to > dc.diff_files it takes 15mins to complete. Looking at the filecmp.py > it's only using os.stat, it seems excessively long. As a baseline it would be interesting to see how long it takes to copy those 59 files using system tools. However, there are efficient tools out there that work hard to reduce the traffic over the net which is likely to be the bottleneck. I suggest that you have have a look at http://en.wikipedia.org/wiki/Rsync From awilliam at whitemice.org Sat Jan 8 11:35:17 2011 From: awilliam at whitemice.org (Adam Tauno Williams) Date: Sat, 08 Jan 2011 11:35:17 -0500 Subject: Python app dev tools for Gnome? In-Reply-To: References: Message-ID: <1294504517.17190.7.camel@linux-yu4c.site> On Sat, 2011-01-08 at 16:07 +0000, kj wrote: > There's a zillion utility apps that I've had kicking around in my > head for years, but I've never implemented because I absolutely > hate GUI programming. > But I'm increasingly impressed by the quality, stability, and sheer > number, of Gnome apps that I keep coming across that use Python > under the hood. > This gives me hope that maybe programming GUI Python apps for Gnome > these days is no longer the traumatizing experience it used to be > when I last tried it. > Can someone recommend some good tools to speed up the development > of Python apps[1] for Gnome? E.g. is there anything like Xcode > for Gnome+Python? I use Monodevelop for coding in Python, but I'm only writing server-side Python. While Monodevelop provides an excellent [possibly the best] Gtk UI designer I believe that component only works for C#. There are a variety of articles on the PyGTK site; Glade is the UI designer you probably want. I've also found which covers TreeViews which are the most tedious part of Gtk application development. Note that, technically, Glade is deprecated and replaced with GtkBuilder. But I believe the application is still called Glade. > [1] Needless to say, when I write "apps" I mean full-blown GUI > apps: windows, menus, events, threads, clickable icon, the whole > ball of wax. As opposed to cli apps, panel widgets, etc. Awesome; although I've avoided [to do Python's myriad deployment issues] Python for fat-client apps I'm becoming more and more tempted. From drsalists at gmail.com Sat Jan 8 13:25:47 2011 From: drsalists at gmail.com (Dan Stromberg) Date: Sat, 8 Jan 2011 10:25:47 -0800 Subject: Python app dev tools for Gnome? In-Reply-To: References: Message-ID: On Sat, Jan 8, 2011 at 8:07 AM, kj wrote: > There's a zillion utility apps that I've had kicking around in my > head for years, but I've never implemented because I absolutely > hate GUI programming. > > But I'm increasingly impressed by the quality, stability, and sheer > number, of Gnome apps that I keep coming across that use Python > under the hood. > > This gives me hope that maybe programming GUI Python apps for Gnome > these days is no longer the traumatizing experience it used to be > when I last tried it. > > Can someone recommend some good tools to speed up the development > of Python apps[1] for Gnome? ?E.g. is there anything like Xcode > for Gnome+Python? > > TIA! > > ~kj > > [1] Needless to say, when I write "apps" I mean full-blown GUI > apps: windows, menus, events, threads, clickable icon, the whole > ball of wax. ?As opposed to cli apps, panel widgets, etc. > -- > http://mail.python.org/mailman/listinfo/python-list > Check out Glade (the standard answer), Illumination (a new tool that has a very interesting design and goals), wxWindows (can run overtop of GTK+, but is pretty different from PyGTK to program, and like PyGTK, enables running on multiple desktop platforms), and pyjamas (produces GTK GUI's using its own widget set overtop of GTK, and web 2.0 apps, from the same code). Personally, I prefer to just code PyGTK GUI's manually, but I can't help but be curious about Ilumination and pyjamas. Illumination is at: http://radicalbreeze.com/ ...and it purportedly allows you to graphically build apps that run on PyGTK, Android, iPhone (not mature last I heard), Windows, Haiku - all automatically generated _from_a_single_description_, and I wouldn't be surprised if it does more platforms than that by now. It's been getting a lot of buzz in the Android community, but if it lives up to its design goals, it probably deserves buzz all over the place. From ppearson at nowhere.invalid Sat Jan 8 13:33:28 2011 From: ppearson at nowhere.invalid (Peter Pearson) Date: 8 Jan 2011 18:33:28 GMT Subject: student question References: Message-ID: <8orovoFe38U1@mid.individual.net> On Fri, 7 Jan 2011 18:42:45 -0800 (PST), John wrote: >>>> q_file = open(questions_location) #opens the document successfully >>>> for line in q_file: > print line > > # prints document successfully >>>> line > # prints last line of document >>>> for line in q_file: > print line # prints nothing > > ...why does it print nothing? open(filename) returns an iterator, not a list. Once you have exhausted the iterator, it stays exhausted. -- To email me, substitute nowhere->spamcop, invalid->net. From roy at panix.com Sat Jan 8 15:03:01 2011 From: roy at panix.com (Roy Smith) Date: Sat, 08 Jan 2011 15:03:01 -0500 Subject: Absolute imports? Message-ID: If I have an absolute path to a file (i.e. '/home/roy/foo.py'), is there a way to import that as a module WITHOUT modifying sys.path? I'm using Python 2.6. I've read PEP 328, and don't really understand how the absolute imports it's talking about are supposed to work. Should I be using imp.load_source()? From tjreedy at udel.edu Sat Jan 8 16:33:50 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Sat, 08 Jan 2011 16:33:50 -0500 Subject: Absolute imports? In-Reply-To: References: Message-ID: On 1/8/2011 3:03 PM, Roy Smith wrote: > If I have an absolute path to a file (i.e. '/home/roy/foo.py'), is there > a way to import that as a module WITHOUT modifying sys.path? I'm using > Python 2.6. Import from another file in /home/roy. (since '.' is part of sys.path). Or put module or package of modules in Lib/site-packages. But why the horror of modifying sys.path? It is normal proceedure. > I've read PEP 328, and don't really understand how the absolute imports > it's talking about are supposed to work. Those are the normal imports that start from a directory in sys.path. Relative imports (now) are ones that use '.'s to locate relative to the importing module. I have never done that. Purpose is to make a subpackage relocatable to another package without modification. > Should I be using imp.load_source()? No idea, never done that. Try it if you want. -- Terry Jan Reedy From ben+python at benfinney.id.au Sat Jan 8 16:53:18 2011 From: ben+python at benfinney.id.au (Ben Finney) Date: Sun, 09 Jan 2011 08:53:18 +1100 Subject: Absolute imports? References: Message-ID: <877heff4fl.fsf@benfinney.id.au> Roy Smith writes: > If I have an absolute path to a file (i.e. '/home/roy/foo.py'), is > there a way to import that as a module WITHOUT modifying sys.path? I'm > using Python 2.6. Importing a module with ?import? is done by using the module's name, which is only *incidentally* related to its filesystem path. What is the problem you're trying to solve? It is likely we can suggest a better solution. > I've read PEP 328, and don't really understand how the absolute > imports it's talking about are supposed to work. Should I be using > imp.load_source()? PEP 328 introduces a distinction between absolute imports and relative imports. Before the implementation of PEP 328, it was impossible to distinguish in the ?import? statement whether the import would be absolute (i.e., from the directories listed in ?sys.path?) or relative (i.e., from the directory housing the current module). I hope that clarifies. If you describe what you're trying to do and why you want a different import behaviour, the answers might be more directed to your actual situation. -- \ ?Spam will be a thing of the past in two years' time.? ?Bill | `\ Gates, 2004-01-24 | _o__) | Ben Finney From not0read0765 at yopmail.com Sat Jan 8 16:57:45 2011 From: not0read0765 at yopmail.com (Olive) Date: Sat, 8 Jan 2011 22:57:45 +0100 Subject: list displays Message-ID: <20110108225745.06b4f843@yopmail.com> I am a newbie to python. Python supports what I thinks it is called list display, for example: [i for i in range(10)] [i for i in range(10) if i<6] Does anyone know a good documentation for this. I have read the language reference but it is confusing. Olive From ddasilva at umd.edu Sat Jan 8 17:11:00 2011 From: ddasilva at umd.edu (Daniel da Silva) Date: Sat, 8 Jan 2011 17:11:00 -0500 Subject: list displays In-Reply-To: <20110108225745.06b4f843@yopmail.com> References: <20110108225745.06b4f843@yopmail.com> Message-ID: They're called "List Comprehensions" http://docs.python.org/tutorial/datastructures.html#list-comprehensions On Sat, Jan 8, 2011 at 4:57 PM, Olive wrote: > I am a newbie to python. Python supports what I thinks it is called > list display, for example: > > [i for i in range(10)] > [i for i in range(10) if i<6] > > Does anyone know a good documentation for this. I have read the > language reference but it is confusing. > > Olive > > -- > http://mail.python.org/mailman/listinfo/python-list > -------------- next part -------------- An HTML attachment was scrubbed... URL: From clp2 at rebertia.com Sat Jan 8 17:26:03 2011 From: clp2 at rebertia.com (Chris Rebert) Date: Sat, 8 Jan 2011 14:26:03 -0800 Subject: list displays In-Reply-To: <20110108225745.06b4f843@yopmail.com> References: <20110108225745.06b4f843@yopmail.com> Message-ID: On Sat, Jan 8, 2011 at 1:57 PM, Olive wrote: > I am a newbie to python. Python supports what I thinks it is called > list display, for example: > > [i for i in range(10)] > [i for i in range(10) if i<6] > > Does anyone know a good documentation for this. I have read the > language reference but it is confusing. You may find the translation to equivalent list-comprehension-free code in http://docs.python.org/howto/functional.html#generator-expressions-and-list-comprehensions helpful. Cheers, Chris From steve+comp.lang.python at pearwood.info Sat Jan 8 17:41:41 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 08 Jan 2011 22:41:41 GMT Subject: list displays References: <20110108225745.06b4f843@yopmail.com> Message-ID: <4d28e824$0$29976$c3e8da3$5496439d@news.astraweb.com> On Sat, 08 Jan 2011 22:57:45 +0100, Olive wrote: > I am a newbie to python. Python supports what I thinks it is called list > display, for example: > > [i for i in range(10)] > [i for i in range(10) if i<6] This is called a list comprehension, not list display. > Does anyone know a good documentation for this. I have read the language > reference but it is confusing. A list comprehension is syntactic sugar for a for loop. If you start with code looking like this: storage = [] for i in range(10): if i < 6: storage.append(i) you can re-write this as a list comprehension: storage = [i for i in range(10) if i < 6] The source doesn't have to be range, it can be any sequence or iterator: lengths = [len(obj) for obj in my_list_of_objects] # like map(len, my_list_of_objects) If you are mathematically inclined, you might also like this analogy: the syntax for a list comprehension is similar to that of sets in mathematics. [f(x) for x in D] is similar to: { f(x) ? x ? D } ("the set of f(x) for all x element of D") Don't waste your time with list comprehensions that just walk over the source, doing nothing. For example: [i for i in range(10)] Just use list(range(10)) instead. Where list comps get complicated is when you combine them. Nested list comps are not too bad, although they can get messy: [len(s) for s in [str(x) for x in [2**n for n in range(10)]]] That's the same as: powers_of_two = [2**n for n in range(10)] strings = [str(x) for x in powers_of_two] lengths = [len(s) for s in strings] But what do you make of this? [a*b for a in range(3) for b in range(4)] This is like a nested for-loop: results = [] for a in range(3): for b in range(4): results.append(a*b) Hope this helps. -- Steven From roy at panix.com Sat Jan 8 17:45:23 2011 From: roy at panix.com (Roy Smith) Date: Sat, 08 Jan 2011 17:45:23 -0500 Subject: Absolute imports? References: <877heff4fl.fsf@benfinney.id.au> Message-ID: In article <877heff4fl.fsf at benfinney.id.au>, Ben Finney wrote: > Roy Smith writes: > > > If I have an absolute path to a file (i.e. '/home/roy/foo.py'), is > > there a way to import that as a module WITHOUT modifying sys.path? I'm > > using Python 2.6. > > Importing a module with ???import??? is done by using the module's name, > which is only *incidentally* related to its filesystem path. > > What is the problem you're trying to solve? It is likely we can suggest > a better solution. Well, the problem I'm trying to solve is that I have an absolute pathname to a python source file that I want to import as a module :-) I'm working on a project where developers will typically have several sandboxes, with different versions of the code. There's a config file (which I have no control over) which defines a big multi-level dict containing configuration options: config = { 'memcache_servers' : ['localhost'], 'build_type' : 'development', 'thrift_configs' : { 'SearchService' : {'hosts' : ['localhost'], 'sendTimeout' : 300, 'port' : 9192, 'recvTimeout' : 3000 }, } } and so on. The file is auto-generated by some huge pile of perl scripts which also generates the same information in a forms ingestible by perl, PHP, Java, shell scripts, etc. Not how I would have designed it, but it is what it is. The best I can describe how to find the location of the config file is, "Work your way up the directory tree from where you are now, (i.e. following '..' links) until you get to the top level of the project, then from there, it's ./code/configs/autogen/config.py." It's reasonably straight-forward to figure out that absolute path, starting from sys.argv[0] and using the tools in os.path. Now I need to import the file, given that I know its absolute pathname. It looks like imp.load_source() does what I want, I'm just wondering if there's a cleaner way. From roy at panix.com Sat Jan 8 17:48:25 2011 From: roy at panix.com (Roy Smith) Date: Sat, 08 Jan 2011 17:48:25 -0500 Subject: Absolute imports? References: Message-ID: In article , Terry Reedy wrote: > > Import from another file in /home/roy. (since '.' is part of sys.path). > Or put module or package of modules in Lib/site-packages. > But why the horror of modifying sys.path? It is normal proceedure. Not quite horror, but since I already know the absolute path to the file, it seems silly to change the search path just so import can use it to search. Also, if I change the search path, I risk other things finding my module by mistake (if there's a module name collision). From jnoller at gmail.com Sat Jan 8 17:59:14 2011 From: jnoller at gmail.com (Jesse Noller) Date: Sat, 8 Jan 2011 17:59:14 -0500 Subject: PyCon 2011 - Full talk and tutorial list now available, registration open! Message-ID: I'm very pleased to announce, on behalf of the PyCon 2011 Program committee, and entire PyCon 2011 volunteer staff, that the full list of PyCon 2011 talks is now public, and available! This was an especially hard year for the PyCon program committee: we had over 200 proposals for only 95 total slots, so we ended up having to reject a lot of excellent proposals. We've spent the better part of the last few months in reviews, meetings and debates selecting which talks would be in the final PyCon program. It was not and easy task - all of the proposal authors really came through in their proposals - the number of high quality proposals we had to chose from was simply staggering. That said - the program committee completed it's work yesterday morning. Acceptance and rejection letters have been sent, and you can now view the full program on the site: http://us.pycon.org/2011/schedule/lists/talks/ This obviously complements the list of tutorials also available: http://us.pycon.org/2011/schedule/lists/tutorials/ Personally, this is my second year acting as the Program Committee chair (and hence, my last) - and between the talk list, and the list of tutorials, our current keynote speaker (http://us.pycon.org/2011/home/keynotes/) and the emerging line of up poster sessions - I'm extremely proud to have been part of the process, and extremely excited about the upcoming conference. It is going to be amazing One behalf of the entire PyCon 2011 staff, I want to again thank every single talk author for their submission(s), and I look forward to seeing all of you, and them at the conference. PyCon is an amazing conference only because of the quality talks, tutorials and community we have. I'm confident this one will knock it out of the park. As a reminder: Early Bird registration (http://us.pycon.org/2011/tickets/) closes January 17th - and we have an attendance cap of 1500 total attendees (speakers are counted against this number, and guaranteed a slot) so be sure to register today! Jesse Noller PyCon 2011 From tjreedy at udel.edu Sat Jan 8 19:32:12 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Sat, 08 Jan 2011 19:32:12 -0500 Subject: Absolute imports? In-Reply-To: References: Message-ID: On 1/8/2011 5:48 PM, Roy Smith wrote: > In article, > Terry Reedy wrote: > >> >> Import from another file in /home/roy. (since '.' is part of sys.path). >> Or put module or package of modules in Lib/site-packages. >> But why the horror of modifying sys.path? It is normal proceedure. > > Not quite horror, but since I already know the absolute path to the > file, it seems silly to change the search path just so import can use it > to search. Also, if I change the search path, I risk other things > finding my module by mistake (if there's a module name collision). Ben Finney asked you the right question. If config.py is the only .py file in .../autogen/, which I infer from your responses, you could .pop() .../autogen after the append and import. Or open config.py and use imp.load_module, being careful to get all the args correct. In either case, if I had a startup module or utility module that is imported right away, I would do the import with extra code there, just once. Then, either refer to util.config after importing util in other modules, or just do 'import config'. The latter should work because import first looks for already imported modules (in sys.modules). When the module is already there, 'import x' reduces to "x = sys.modules['x']". -- Terry Jan Reedy From passionate_programmer at hotmail.com Sat Jan 8 21:23:01 2011 From: passionate_programmer at hotmail.com (Rohit Coder) Date: Sun, 9 Jan 2011 07:53:01 +0530 Subject: Create a class to position a window on the screen. Message-ID: Hi,elementFontfont-familyfont-sizefont-stylefont-variantfont-weightletter-spacingline-heighttext-decorationtext-aligntext-indenttext-transformwhite-spaceword-spacingcolorBackgroundbg-attachmentbg-colorbg-imagebg-positionbg-repeatBoxwidthheightborder-topborder-rightborder-bottomborder-leftmarginpaddingmax-heightmin-heightmax-widthmin-widthoutline-coloroutline-styleoutline-widthPositioningpositiontopbottomrightleftfloatdisplayclearz-indexListlist-style-imagelist-style-typelist-style-positionTablevertical-alignborder-collapseborder-spacingcaption-sideempty-cellstable-layoutEffectstext-shadow-webkit-box-shadowborder-radiusOtheroverflowcursorvisibility I am new to Python and this is my fist Python class. I am using PyQt4 framework on Windows 7. I don't know whether the code below is correctly written or not. I want to modify it further as: 1. In the arguments, I want to pass the name of another opened Window (.py) on the screen. 2. I want to pass the x-coord., y-coord. and the name of the window to position on the screen. How to modify the code to fulfill these requirements? **Attempted Code** class PositionWindow: def __init__(self, xCoord, yCoord, windowName, parent = None): self.x = xCoord self.y = yCoord self.wName = windowName; def center(self): screen = QtGui.QDesktopWidget().screenGeometry() size = self.geometry() self.move((screen.width()-size.width())/2, (screen.height()-size.height())/2) ...................Rohit. -------------- next part -------------- An HTML attachment was scrubbed... URL: From aahz at pythoncraft.com Sat Jan 8 21:39:43 2011 From: aahz at pythoncraft.com (Aahz) Date: 8 Jan 2011 18:39:43 -0800 Subject: surprised by import in python 2.6 References: Message-ID: In article , Stefaan Himpe wrote: > >Recently someone asked me this question, to which I could not give an >answer. I'm hoping for some insight, or a manual page. What follows is >python 2.6. > >The problem is with the difference between > >from test import * > >and > >import test Just adding to this thread for Gooja: Don't use "import *" -- it makes debugging difficult because you can't tell where a name comes from. -- Aahz (aahz at pythoncraft.com) <*> http://www.pythoncraft.com/ "Think of it as evolution in action." --Tony Rand From timr at probo.com Sat Jan 8 21:51:38 2011 From: timr at probo.com (Tim Roberts) Date: Sat, 08 Jan 2011 18:51:38 -0800 Subject: How to read ansic file into a pre-defined class? References: Message-ID: Ying Zu wrote: > >How to read ansic file into a pre-defined class? This is not an "ansic" file. It's just a plain old data file. >I have a series of files written in the following format, > >2 # number of classes >100 # number of items for the first class object >0 foo >1 foo >... >99 foo >150 # number of items for the second class object >0 bar >1 bar >... >149 bar > >ultimately I want to read the file to two *structs* (sorry for my C >jargon, just started playing with Python), with attributes >number_of_items and data_array. > >I wrote a simply code to read and split each line into a list, then >try to tell the meaning of each line by the number of elements of >each line list and the its position in the file. But it is >definitely not the way Python should be used. You don't really need to count the number of elements. The file tells you how many of each to expect. This works: numclasses = int(f.next().strip()) classlist = [] for i in range(numclasses): numitems = int(f.next().strip()) classlist.append( [f.next().strip().split() for j in range(numitems)] ) Then len(classlist) tells you how many classes. len(classlist[0]) tells you how many items in the first class. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From rahul.nbg at gmail.com Sun Jan 9 01:10:38 2011 From: rahul.nbg at gmail.com (aregee) Date: Sat, 8 Jan 2011 22:10:38 -0800 (PST) Subject: compute the double square...... :( Message-ID: <654f1a64-b4c2-4a02-b4f8-86ee7e34d3cd@y19g2000prb.googlegroups.com> Double Squares A double-square number is an integer X which can be expressed as the sum of two perfect squares. For example, 10 is a double-square because 10 = 32 + 12. Your task in this problem is, given X, determine the number of ways in which it can be written as the sum of two squares. For example, 10 can only be written as 32 + 12 (we don't count 12 + 32 as being different). On the other hand, 25 can be written as 52 + 02 or as 42 + 32. Input You should first read an integer N, the number of test cases. The next N lines will contain N values of X. Constraints 0 ? X ? 2147483647 1 ? N ? 100 Output For each value of X, you should output the number of ways to write X as the sum of two square Is the code mention below solution to this question ???? what is the fault... Error : aregee at aregee-laptop:~/Desktop$ python pie.py enter a number::10 pie.py:3: Deprecation Warning: integer argument expected, got float for b in range(0,(x**0.5)/2): #Double square.... x = input("enter a number::") for b in range(0,(x**0.5)/2): a = (x-(b**2))**0.5 try: a = int(a) except: print("not an integer") exit(1) count = 0; count = count + 1; if (x == a**2 + b**2): print "double square" From kb1pkl at aim.com Sun Jan 9 01:23:27 2011 From: kb1pkl at aim.com (Corey Richardson) Date: Sun, 09 Jan 2011 01:23:27 -0500 Subject: compute the double square...... :( In-Reply-To: <654f1a64-b4c2-4a02-b4f8-86ee7e34d3cd@y19g2000prb.googlegroups.com> References: <654f1a64-b4c2-4a02-b4f8-86ee7e34d3cd@y19g2000prb.googlegroups.com> Message-ID: <4D29545F.3030601@aim.com> On 01/09/2011 01:10 AM, aregee wrote: > > Double Squares > A double-square number is an integer X which can be expressed as the > sum of two perfect squares. For example, 10 is a double-square because > 10 = 32 + 12. Your task in this problem is, given X, determine the > number of ways in which it can be written as the sum of two squares. > For example, 10 can only be written as 32 + 12 (we don't count 12 + 32 > as being different). On the other hand, 25 can be written as 52 + 02 > or as 42 + 32. > > Input > You should first read an integer N, the number of test cases. The next > N lines will contain N values of X. > Constraints > 0 ? X ? 2147483647 > 1 ? N ? 100 > Output > For each value of X, you should output the number of ways to write X > as the sum of two square > > Is the code mention below solution to this question ???? what is the > fault... > Error : > aregee at aregee-laptop:~/Desktop$ python pie.py > enter a number::10 > pie.py:3: Deprecation Warning: integer argument expected, got float > for b in range(0,(x**0.5)/2): That says it all. You can't use a float in range(), use int(x ** 0.5) if that's what you need, but the behavior won't be the same. My suggestion would be to try to find a different way to do it. > > #Double square.... > > x = input("enter a number::") > for b in range(0,(x**0.5)/2): > a = (x-(b**2))**0.5 > try: > a = int(a) > except: > print("not an integer") > exit(1) > Here it would be better to use: if type(a) != int print("Not an integer") exit(1) > count = 0; > count = count + 1; > if (x == a**2 + b**2): > > print "double square" ~Corey Richardson From gherron at islandtraining.com Sun Jan 9 02:14:28 2011 From: gherron at islandtraining.com (Gary Herron) Date: Sat, 08 Jan 2011 23:14:28 -0800 Subject: compute the double square...... :( In-Reply-To: <654f1a64-b4c2-4a02-b4f8-86ee7e34d3cd@y19g2000prb.googlegroups.com> References: <654f1a64-b4c2-4a02-b4f8-86ee7e34d3cd@y19g2000prb.googlegroups.com> Message-ID: <4D296054.9030208@islandtraining.com> On 01/08/2011 10:10 PM, aregee wrote: > Double Squares > A double-square number is an integer X which can be expressed as the > sum of two perfect squares. For example, 10 is a double-square because > 10 = 32 + 12. Your task in this problem is, given X, determine the > number of ways in which it can be written as the sum of two squares. > For example, 10 can only be written as 32 + 12 (we don't count 12 + 32 > as being different). On the other hand, 25 can be written as 52 + 02 > or as 42 + 32. Huh? In what number system does 10 = 32 + 12? And how do either 32 or 12 qualify as perfect squares? Gary Herron > Input > You should first read an integer N, the number of test cases. The next > N lines will contain N values of X. > Constraints > 0 ? X ? 2147483647 > 1 ? N ? 100 > Output > For each value of X, you should output the number of ways to write X > as the sum of two square > > Is the code mention below solution to this question ???? what is the > fault... > Error : > aregee at aregee-laptop:~/Desktop$ python pie.py > enter a number::10 > pie.py:3: Deprecation Warning: integer argument expected, got float > for b in range(0,(x**0.5)/2): > > #Double square.... > > x = input("enter a number::") > for b in range(0,(x**0.5)/2): > a = (x-(b**2))**0.5 > try: > a = int(a) > except: > print("not an integer") > exit(1) > > count = 0; > count = count + 1; > if (x == a**2 + b**2): > > print "double square" From xemoth at gmail.com Sun Jan 9 03:10:08 2011 From: xemoth at gmail.com (Owen) Date: Sun, 9 Jan 2011 00:10:08 -0800 (PST) Subject: compute the double square...... :( References: <654f1a64-b4c2-4a02-b4f8-86ee7e34d3cd@y19g2000prb.googlegroups.com> Message-ID: <0cc271af-35e9-47b9-8c31-324e484cd9a8@f21g2000prn.googlegroups.com> On Jan 9, 6:14?pm, Gary Herron wrote: > On 01/08/2011 10:10 PM, aregee wrote: > > > Double Squares > > A double-square number is an integer X which can be expressed as the > > sum of two perfect squares. For example, 10 is a double-square because > > 10 = 32 + 12. Your task in this problem is, given X, determine the > > number of ways in which it can be written as the sum of two squares. > > For example, 10 can only be written as 32 + 12 (we don't count 12 + 32 > > as being different). On the other hand, 25 can be written as 52 + 02 > > or as 42 + 32. > > Huh? ?In what number system does ?10 = 32 + 12? > And how do either 32 or 12 qualify as perfect squares? > > Gary Herron > > > > > > > > > Input > > You should first read an integer N, the number of test cases. The next > > N lines will contain N values of X. > > Constraints > > 0 ? X ? 2147483647 > > 1 ? N ? 100 > > Output > > For each value of X, you should output the number of ways to write X > > as the sum of two square > > > Is the code mention below solution to this question ???? what is the > > fault... > > Error : > > aregee at aregee-laptop:~/Desktop$ python pie.py > > enter a number::10 > > pie.py:3: Deprecation Warning: integer argument expected, got float > > ? ?for b in range(0,(x**0.5)/2): > > > #Double square.... > > > x = input("enter a number::") > > for b in range(0,(x**0.5)/2): > > ? ? ? ?a = (x-(b**2))**0.5 > > try: > > ? ? ? ?a = int(a) > > except: > > ? ? ? ?print("not an integer") > > ? ? ? ?exit(1) > > > ? ? ? ?count = 0; > > ? ? ? ?count = count + 1; > > if (x == a**2 + b**2): > > > ? ? ? ?print "double square" Well that he means 3(squared)+1(squared) [3 superscript 2 etc] Owen From ian.g.kelly at gmail.com Sun Jan 9 05:59:27 2011 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Sun, 09 Jan 2011 03:59:27 -0700 Subject: compute the double square...... :( In-Reply-To: <654f1a64-b4c2-4a02-b4f8-86ee7e34d3cd@y19g2000prb.googlegroups.com> References: <654f1a64-b4c2-4a02-b4f8-86ee7e34d3cd@y19g2000prb.googlegroups.com> Message-ID: On 1/8/2011 11:10 PM, aregee wrote: > pie.py:3: Deprecation Warning: integer argument expected, got float > for b in range(0,(x**0.5)/2): I expect you want range(0, int((x / 2) ** 0.5) + 1), no? > for b in range(0,(x**0.5)/2): > a = (x-(b**2))**0.5 > try: > a = int(a) > except: > print("not an integer") > exit(1) Your indentation is confusing. Is the try-except contained inside the for loop or not? And what are you actually trying to test for here? The assignment here of "a = int(a)" will never throw an exception as long as the loop runs. > > count = 0; > count = count + 1; Again, confusing indentation. Is this supposed to be part of the except block? And what is the purpose of incrementing count if you're going to set it to 0 immediately before? You might as well just write "count = 1" > if (x == a**2 + b**2): > > print "double square" This also appears to be outside of the loop. From cedric at schmeits.net Sun Jan 9 06:05:55 2011 From: cedric at schmeits.net (Cedric Schmeits) Date: Sun, 9 Jan 2011 03:05:55 -0800 (PST) Subject: compute the double square...... :( References: <654f1a64-b4c2-4a02-b4f8-86ee7e34d3cd@y19g2000prb.googlegroups.com> Message-ID: <5ba53a5b-c545-42e2-afab-5b21c832a2cc@32g2000yqz.googlegroups.com> On Jan 9, 7:10?am, aregee wrote: > Double Squares > A double-square number is an integer X which can be expressed as the > sum of two perfect squares. For example, 10 is a double-square because > 10 = 32 + 12. Your task in this problem is, given X, determine the > number of ways in which it can be written as the sum of two squares. > For example, 10 can only be written as 32 + 12 (we don't count 12 + 32 > as being different). On the other hand, 25 can be written as 52 + 02 > or as 42 + 32. > > Input > You should first read an integer N, the number of test cases. The next > N lines will contain N values of X. > Constraints > 0 ? X ? 2147483647 > 1 ? N ? 100 > Output > For each value of X, you should output the number of ways to write X > as the sum of two square > > Is the code mention below solution to this question ???? what is the > fault... > Error : > aregee at aregee-laptop:~/Desktop$ python pie.py > enter a number::10 > pie.py:3: Deprecation Warning: integer argument expected, got float > ? for b in range(0,(x**0.5)/2): > > #Double square.... > > x = input("enter a number::") > for b in range(0,(x**0.5)/2): > ? ? ? a = (x-(b**2))**0.5 > try: > ? ? ? a = int(a) > except: > ? ? ? print("not an integer") > ? ? ? exit(1) > > ? ? ? count = 0; > ? ? ? count = count + 1; > if (x == a**2 + b**2): > > ? ? ? print "double square" aregee, The problem you had was that you put a division by 2 in the range, if x would be 25 than x**0.5 = 5.0 than you would feed range with 2.5 and than you get the warning. Also I don't understand why you use de division by 2, because if for instance you would take 25 you get 5 and 0 but you mis 3 and 4 as match. I've put in a tried list to I would try the following: #Double square.... x = input("enter a number::") for b in range(0,int((x**0.5))): a = (x-(b**2))**0.5 try: a = int(a) except: print("not an integer") exit(1) if a < b: # when a is smaller than b we already have this match # and all the following matches we also have break if (x == a**2 + b**2): print "double square %s = %s**2 + %s**2" % (x, a, b) From rahul.nbg at gmail.com Sun Jan 9 06:26:22 2011 From: rahul.nbg at gmail.com (aregee) Date: Sun, 9 Jan 2011 03:26:22 -0800 (PST) Subject: compute the double square...... :( References: <654f1a64-b4c2-4a02-b4f8-86ee7e34d3cd@y19g2000prb.googlegroups.com> Message-ID: <1b8905da-0a84-424d-9ccf-9c4e7cba0e48@21g2000prv.googlegroups.com> hey all thanks for yr help,i got it right .....n sorry for confussions...i m very new to python...just started learning it couple of days ago... Ian Kelly wrote: > On 1/8/2011 11:10 PM, aregee wrote: > > pie.py:3: Deprecation Warning: integer argument expected, got float > > for b in range(0,(x**0.5)/2): > > I expect you want range(0, int((x / 2) ** 0.5) + 1), no? > > > for b in range(0,(x**0.5)/2): > > a = (x-(b**2))**0.5 > > try: > > a = int(a) > > except: > > print("not an integer") > > exit(1) > > Your indentation is confusing. Is the try-except contained inside the > for loop or not? > > And what are you actually trying to test for here? The assignment here > of "a = int(a)" will never throw an exception as long as the loop runs. > > > > > count = 0; > > count = count + 1; > > Again, confusing indentation. Is this supposed to be part of the except > block? And what is the purpose of incrementing count if you're going to > set it to 0 immediately before? You might as well just write "count = 1" > > > if (x == a**2 + b**2): > > > > print "double square" > > This also appears to be outside of the loop. From develsoftware at gmail.com Sun Jan 9 09:03:25 2011 From: develsoftware at gmail.com (=?UTF-8?B?0JXQstCz0LXQvdC40Lkg0J/QvtGH0LjRgtCw0LXQsg==?=) Date: Sun, 9 Jan 2011 06:03:25 -0800 (PST) Subject: Embedded Python static modules Message-ID: I build python from sources(static version): ./configure --disable-shared Next I build program with this static library. Program work fine on my linux, but when I tried run my program on another linux, I got next message: Could not find platform independent libraries Could not find platform dependent libraries Consider setting $PYTHONHOME to [:] ImportError: No module named site This message I receive when call Py_Initialize(). How I can build python static library with all required Python modules? Thanks. From acm at muc.de Sun Jan 9 09:54:53 2011 From: acm at muc.de (Alan Mackenzie) Date: Sun, 9 Jan 2011 14:54:53 +0000 (UTC) Subject: compute the double square...... :( References: <654f1a64-b4c2-4a02-b4f8-86ee7e34d3cd@y19g2000prb.googlegroups.com> Message-ID: aregee wrote: > Double Squares > A double-square number is an integer X which can be expressed as the > sum of two perfect squares. For example, 10 is a double-square because > 10 = 32 + 12. Your task in this problem is, given X, determine the > number of ways in which it can be written as the sum of two squares. > For example, 10 can only be written as 32 + 12 (we don't count 12 + 32 > as being different). On the other hand, 25 can be written as 52 + 02 > or as 42 + 32. There is interesting mathematics involved in "double squares". Such properties are intimately bound up with the factorisation of the number. It can be shown that: (i) a prime number of the form 4n + 1 is a double square in exactly one way. So is 2. E.g. 73 = 64 + 9, 2 = 1 + 1. (ii) a prime number of the form 4n + 3 is not a double square. (iii) The product of m distinct primes, each of the form 4n + 1, is a double square in 2^(m-1) ways. E.g. 5*13 = 65 = 64 + 1 = 49 + 16 (iv) If k = a^2 + b^2, l = c^2 + d^2, then: kl = (ac + bd)^2 + (ad - bc)^2 = (ac - bd)^2 + (ad + bc)^2. (v) if k is a prime of the form 4n + 1, then k^m is a double square in (m + 2) / 2 ways. E.g. 5^4 = 625 = 625 + 0 = 576 + 49 = 400 + 225. (vi) .... and so on. It's all in the factorisation! -- Alan Mackenzie (Nuremberg, Germany). From rohan.pai at live.com Sun Jan 9 10:41:41 2011 From: rohan.pai at live.com (Rohan Pai) Date: Sun, 9 Jan 2011 10:41:41 -0500 Subject: How can I find the remainder when dividing 2 integers Message-ID: Try using dividend % divisor, this will return the remainder Rohan Pai -------------- next part -------------- An HTML attachment was scrubbed... URL: From ian at ianhobson.co.uk Sun Jan 9 11:14:45 2011 From: ian at ianhobson.co.uk (Ian Hobson) Date: Sun, 09 Jan 2011 16:14:45 +0000 Subject: Help needed with unittest and global Message-ID: <4D29DEF5.2030702@ianhobson.co.uk> Hi all, I am trying to develop a PyQt application, and I want to unittest it. After three false starts, I am plainly unaware of something rather basic - can some kind person please help me out? This is a log to show what I have so far D:\work\ian>type testAll.py # coding=utf8 # testAll.py - run all tests. import unittest import sys from PyQt4.QtGui import * from testCubic import testCubic global app def main(): suite = unittest.TestLoader() suite.loadTestsFromTestCase(testCubic) unittest.TextTestRunner().run(suite) if __name__=="__main__": global app app = QApplication(sys.argv) # set gloabl app unittest.main() D:\work\ian>type testCubic.py # coding=utf8 # testCubic.py - tests the top level module import unittest global app class testCubic(unittest.TestCase): def test001_walkingSkeleton(self): global app # use global version app.processEvents() # fails D:\work\ian>python testAll.py E ====================================================================== ERROR: test001_walkingSkeleton (testCubic.testCubic) ---------------------------------------------------------------------- Traceback (most recent call last): File "D:\work\ian\testCubic.py", line 8, in test001_walkingSkeleton app.processEvents() # fails NameError: global name 'app' is not defined ---------------------------------------------------------------------- Ran 1 test in 0.001s FAILED (errors=1) D:\work\ian> Thanks Ian From twic at urchin.earth.li Sun Jan 9 11:49:35 2011 From: twic at urchin.earth.li (Tom Anderson) Date: Sun, 9 Jan 2011 16:49:35 +0000 Subject: Nothing to repeat Message-ID: Hello everyone, long time no see, This is probably not a Python problem, but rather a regular expressions problem. I want, for the sake of arguments, to match strings comprising any number of occurrences of 'spa', each interspersed by any number of occurrences of the 'm'. 'any number' includes zero, so the whole pattern should match the empty string. Here's the conversation Python and i had about it: Python 2.6.4 (r264:75706, Jun 4 2010, 18:20:16) [GCC 4.4.4 20100503 (Red Hat 4.4.4-2)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import re >>> re.compile("(spa|m*)*") Traceback (most recent call last): File "", line 1, in File "/usr/lib/python2.6/re.py", line 190, in compile return _compile(pattern, flags) File "/usr/lib/python2.6/re.py", line 245, in _compile raise error, v # invalid expression sre_constants.error: nothing to repeat What's going on here? Why is there nothing to repeat? Is the problem having one *'d term inside another? Now, i could actually rewrite this particular pattern as '(spa|m)*'. But what i neglected to mention above is that i'm actually generating patterns from structures of objects (representations of XML DTDs, as it happens), and as it stands, patterns like this are a possibility. Any thoughts on what i should do? Do i have to bite the bullet and apply some cleverness in my pattern generation to avoid situations like this? Thanks, tom -- If it ain't broke, open it up and see what makes it so bloody special. From aahz at pythoncraft.com Sun Jan 9 11:56:52 2011 From: aahz at pythoncraft.com (Aahz) Date: 9 Jan 2011 08:56:52 -0800 Subject: Integrating doctest with unittest References: <4d038b63$0$30000$c3e8da3$5496439d@news.astraweb.com> Message-ID: In article <4d038b63$0$30000$c3e8da3$5496439d at news.astraweb.com>, Steven D'Aprano wrote: > >Is there a way to have unittest.main() find and run doc_test_suite >together with the other test suites? You probably need to use nose or something. (That's what we're doing.) -- Aahz (aahz at pythoncraft.com) <*> http://www.pythoncraft.com/ "Think of it as evolution in action." --Tony Rand From hobson42 at gmail.com Sun Jan 9 12:49:10 2011 From: hobson42 at gmail.com (Ian) Date: Sun, 09 Jan 2011 17:49:10 +0000 Subject: Nothing to repeat In-Reply-To: References: Message-ID: <4D29F516.3030700@gmail.com> On 09/01/2011 16:49, Tom Anderson wrote: > Hello everyone, long time no see, > > This is probably not a Python problem, but rather a regular > expressions problem. > > I want, for the sake of arguments, to match strings comprising any > number of occurrences of 'spa', each interspersed by any number of > occurrences of the 'm'. 'any number' includes zero, so the whole > pattern should match the empty string. > > Here's the conversation Python and i had about it: > > Python 2.6.4 (r264:75706, Jun 4 2010, 18:20:16) > [GCC 4.4.4 20100503 (Red Hat 4.4.4-2)] on linux2 > Type "help", "copyright", "credits" or "license" for more information. >>>> import re >>>> re.compile("(spa|m*)*") > Traceback (most recent call last): > File "", line 1, in > File "/usr/lib/python2.6/re.py", line 190, in compile > return _compile(pattern, flags) > File "/usr/lib/python2.6/re.py", line 245, in _compile > raise error, v # invalid expression > sre_constants.error: nothing to repeat > > What's going on here? Why is there nothing to repeat? Is the problem > having one *'d term inside another? > > Now, i could actually rewrite this particular pattern as '(spa|m)*'. > But what i neglected to mention above is that i'm actually generating > patterns from structures of objects (representations of XML DTDs, as > it happens), and as it stands, patterns like this are a possibility. > > Any thoughts on what i should do? Do i have to bite the bullet and > apply some cleverness in my pattern generation to avoid situations > like this? > > Thanks, > tom > I think you want to anchor your list, or anything will match. Perhaps re.compile('/^(spa(m)+)*$/') is what you need. Regards Ian From martin at address-in-sig.invalid Sun Jan 9 13:05:46 2011 From: martin at address-in-sig.invalid (Martin Gregorie) Date: Sun, 9 Jan 2011 18:05:46 +0000 (UTC) Subject: Nothing to repeat References: Message-ID: On Sun, 09 Jan 2011 16:49:35 +0000, Tom Anderson wrote: > > Any thoughts on what i should do? Do i have to bite the bullet and apply > some cleverness in my pattern generation to avoid situations like this? > This sort of works: import re f = open("test.txt") p = re.compile("(spam*)*") for line in f: print "input line: %s" % (line.strip()) for m in p.findall(line): if m != "": print "==> %s" % (m) when I feed it =======================test.txt=========================== a line with no match spa should match spam should match so should all of spaspamspammspammm and so should all of spa spam spamm spammm no match again. =======================test.txt=========================== it produces: input line: a line with no match input line: spa should match ==> spa input line: spam should match ==> spam input line: so should all of spaspamspammspammm ==> spammm input line: and so should all of spa spam spamm spammm ==> spa ==> spam ==> spamm ==> spammm input line: no match again. so obviously there's a problem with greedy matching where there are no separators between adjacent matching strings. I tried non-greedy matching, e.g. r'(spam*?)*', but this was worse, so I'll be interested to see how the real regex mavens do it. -- martin@ | Martin Gregorie gregorie. | Essex, UK org | From hobson42 at gmail.com Sun Jan 9 13:09:44 2011 From: hobson42 at gmail.com (Ian) Date: Sun, 09 Jan 2011 18:09:44 +0000 Subject: Nothing to repeat In-Reply-To: <4D29F516.3030700@gmail.com> References: <4D29F516.3030700@gmail.com> Message-ID: <4D29F9E8.90902@gmail.com> On 09/01/2011 17:49, Ian wrote: > I think you want to anchor your list, or anything will match. Perhaps My bad - this is better re.compile('^((spa)*(m)*)+$') search finds match in 'spa', 'spaspaspa', 'spammmspa', '' and 'mmm' search fails on 'spats', 'mats' and others. From tjreedy at udel.edu Sun Jan 9 13:58:09 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Sun, 09 Jan 2011 13:58:09 -0500 Subject: Nothing to repeat In-Reply-To: References: Message-ID: On 1/9/2011 11:49 AM, Tom Anderson wrote: > Hello everyone, long time no see, > > This is probably not a Python problem, but rather a regular expressions > problem. > > I want, for the sake of arguments, to match strings comprising any > number of occurrences of 'spa', each interspersed by any number of > occurrences of the 'm'. 'any number' includes zero, so the whole pattern > should match the empty string. All you sure? A pattern that matches the empty string matches every string. > Here's the conversation Python and i had about it: > > Python 2.6.4 (r264:75706, Jun 4 2010, 18:20:16) > [GCC 4.4.4 20100503 (Red Hat 4.4.4-2)] on linux2 > Type "help", "copyright", "credits" or "license" for more information. >>>> import re >>>> re.compile("(spa|m*)*") I believe precedence rule of * tighter than | (not in the doc) makes this re is the same as "(spa|(m)*)*", which gives same error traceback. I believe that for this, re compiles first (spa)* and then ((m)*)* and the latter gives the same traceback. Either would seem to match strings of 'm's without and 'spa', which is not your spec. "((spa|m)*)*" does compile, so it is not the nesting itself. The doc does not give the formal grammar for Python re's, so it is hard to pinpoint which informal rule is violated, or if indeed the error is a bug. Someone else may do better. > Now, i could actually rewrite this particular pattern as '(spa|m)*'. That also does not match your spec. > Any thoughts on what i should do? Do i have to bite the bullet and apply > some cleverness in my pattern generation to avoid situations like this? Well, it has to generate legal re's according to the engine you are using (with whatever bugs and limitations it has). -- Terry Jan Reedy From davea at ieee.org Sun Jan 9 14:53:46 2011 From: davea at ieee.org (Dave Angel) Date: Sun, 09 Jan 2011 14:53:46 -0500 Subject: Help needed with unittest and global In-Reply-To: <4D29DEF5.2030702@ianhobson.co.uk> References: <4D29DEF5.2030702@ianhobson.co.uk> Message-ID: <4D2A124A.9000508@ieee.org> On 01/-10/-28163 02:59 PM, Ian Hobson wrote: > Hi all, > > I am trying to develop a PyQt application, and I want to unittest it. > > After three false starts, I am plainly unaware of something rather basic > - can some kind person please help me out? > > This is a log to show what I have so far > D:\work\ian>type testAll.py > # coding=utf8 > # testAll.py - run all tests. > import unittest > import sys > from PyQt4.QtGui import * > from testCubic import testCubic > global app > def main(): > suite = unittest.TestLoader() > suite.loadTestsFromTestCase(testCubic) > unittest.TextTestRunner().run(suite) > if __name__=="__main__": > global app > app = QApplication(sys.argv) # set gloabl app > unittest.main() > > D:\work\ian>type testCubic.py > # coding=utf8 > # testCubic.py - tests the top level module > import unittest > global app > class testCubic(unittest.TestCase): > def test001_walkingSkeleton(self): > global app # use global version > app.processEvents() # fails > D:\work\ian>python testAll.py > E > ====================================================================== > ERROR: test001_walkingSkeleton (testCubic.testCubic) > ---------------------------------------------------------------------- > Traceback (most recent call last): > File "D:\work\ian\testCubic.py", line 8, in test001_walkingSkeleton > app.processEvents() # fails > NameError: global name 'app' is not defined > You have two global variables called app, one is in the testCubic module and the other is in the testAll.py script. They do not automatically refer to the same thing. To use a global from another module, you can either do an import, or you can pass it as an argument. But beware of mutual imports. DaveA From hobson42 at gmail.com Sun Jan 9 15:13:07 2011 From: hobson42 at gmail.com (Ian) Date: Sun, 09 Jan 2011 20:13:07 +0000 Subject: Help needed with unittest and global In-Reply-To: <4D2A124A.9000508@ieee.org> References: <4D29DEF5.2030702@ianhobson.co.uk> <4D2A124A.9000508@ieee.org> Message-ID: <4D2A16D3.4070405@gmail.com> On 09/01/2011 19:53, Dave Angel wrote: > On 01/-10/-28163 02:59 PM, Ian Hobson wrote: >> Hi all, >> >> I am trying to develop a PyQt application, and I want to unittest it. >> snip >> D:\work\ian>python testAll.py >> E >> ====================================================================== >> ERROR: test001_walkingSkeleton (testCubic.testCubic) >> ---------------------------------------------------------------------- >> Traceback (most recent call last): >> File "D:\work\ian\testCubic.py", line 8, in test001_walkingSkeleton >> app.processEvents() # fails >> NameError: global name 'app' is not defined >> > > You have two global variables called app, one is in the testCubic > module and the other is in the testAll.py script. They do not > automatically refer to the same thing. > > To use a global from another module, you can either do an import, or > you can pass it as an argument. But beware of mutual imports. > > DaveA > Thanks David, I found http://mail.python.org/pipermail/tutor/2002-November/018353.html and created a shared module that both modules can import. Then I refer to shared.app, no use of global and it works as desired. I am on to the next step - actually running my code. Regards Ian From tshinnic at io.com Sun Jan 9 15:43:30 2011 From: tshinnic at io.com (Thomas L. Shinnick) Date: Sun, 09 Jan 2011 14:43:30 -0600 Subject: What INI config file module allows lists of duplicate same-named options? In-Reply-To: <4D2A16D3.4070405@gmail.com> References: <4D29DEF5.2030702@ianhobson.co.uk> <4D2A124A.9000508@ieee.org> <4D2A16D3.4070405@gmail.com> Message-ID: Having (possibly) surveyed all the available pypi config file modules, I still haven't seen one that allows an obvious and familiar extension of the strict Windows INI format. Each INI-style config module seems to enforce the strict rule: each option in a section must have a different name - no duplicates. Thus it is impossible to have a simple list, e.g. [pathset uk] pathpair: /bath/* to /london/* pathpair: /bath/upload/** to /london/* pathpair: /firth/* to /forth/* pathpair: /firth/upload/** to /forth/* Rather you must give each line a separate name, e.g. [pathset uk] pathpair001: /bath/* to /london/* pathpair002: /bath/upload/** to /london/* pathpair003: /firth/* to /forth/* pathpair004: /firth/upload/** to /forth/* | | | | | | pathpair068: /glasgow/* to /edinburgh/* pathpair069: /glasgow/upload/** to /edinburgh/* | | | | | | This is not ideal for a number of reasons. Do you know of a library module that has the (optional?) ability to handle duplicate-named options, returning them as a list? If instead someone can point me to a reasonable Apache-style config module, that might also serve. I've looked for such and the few found seemed to be either bare bones or clumsily stripped out of something much larger. -- I'm a pessimist about probabilities; I'm an optimist about possibilities. Lewis Mumford (1895-1990) -------------- next part -------------- An HTML attachment was scrubbed... URL: From kb1pkl at aim.com Sun Jan 9 15:47:06 2011 From: kb1pkl at aim.com (Corey Richardson) Date: Sun, 09 Jan 2011 15:47:06 -0500 Subject: What INI config file module allows lists of duplicate same-named options? In-Reply-To: References: <4D29DEF5.2030702@ianhobson.co.uk> <4D2A124A.9000508@ieee.org> <4D2A16D3.4070405@gmail.com> Message-ID: <4D2A1ECA.2090901@aim.com> On 01/09/2011 03:43 PM, Thomas L. Shinnick wrote: > Having (possibly) surveyed all the available pypi config file modules, I > still haven't seen one that allows an obvious and familiar extension of > the strict Windows INI format. > > Each INI-style config module seems to enforce the strict rule: each > option in a section must have a different name - no duplicates. Thus it > is impossible to have a simple list, e.g. > > [pathset uk] > pathpair: /bath/* to /london/* > pathpair: /bath/upload/** to /london/* > pathpair: /firth/* to /forth/* > pathpair: /firth/upload/** to /forth/* > > Rather you must give each line a separate name, e.g. > > [pathset uk] > pathpair001: /bath/* to /london/* > pathpair002: /bath/upload/** to /london/* > pathpair003: /firth/* to /forth/* > pathpair004: /firth/upload/** to /forth/* > | | | | | | > pathpair068: /glasgow/* to /edinburgh/* > pathpair069: /glasgow/upload/** to /edinburgh/* > | | | | | | > > This is not ideal for a number of reasons. Do you know of a library > module that has the (optional?) ability to handle duplicate-named > options, returning them as a list? > > If instead someone can point me to a reasonable Apache-style config > module, that might also serve. I've looked for such and the few found > seemed to be either bare bones or clumsily stripped out of something > much larger. > > > -- > I'm a pessimist about probabilities; I'm an optimist about possibilities. > Lewis Mumford (1895-1990) > Seems to me to be a standard enforced by Windows itself, not any an issue with the modules. What exactly are you doing? ~Corey Richardson From stefan.sonnenberg at pythonmeister.com Sun Jan 9 15:52:42 2011 From: stefan.sonnenberg at pythonmeister.com (Stefan Sonnenberg-Carstens) Date: Sun, 09 Jan 2011 21:52:42 +0100 Subject: What INI config file module allows lists of duplicate same-named options? In-Reply-To: References: <4D29DEF5.2030702@ianhobson.co.uk> <4D2A124A.9000508@ieee.org> <4D2A16D3.4070405@gmail.com> Message-ID: <4D2A201A.9040604@pythonmeister.com> Am 09.01.2011 21:43, schrieb Thomas L. Shinnick: > Having (possibly) surveyed all the available pypi config file modules, > I still haven't seen one that allows an obvious and familiar extension > of the strict Windows INI format. > > Each INI-style config module seems to enforce the strict rule: each > option in a section must have a different name - no duplicates. Thus > it is impossible to have a simple list, e.g. > > [pathset uk] > pathpair: /bath/* to /london/* > pathpair: /bath/upload/** to /london/* > pathpair: /firth/* to /forth/* > pathpair: /firth/upload/** to /forth/* > > Rather you must give each line a separate name, e.g. > > [pathset uk] > pathpair001: /bath/* to /london/* > pathpair002: /bath/upload/** to /london/* > pathpair003: /firth/* to /forth/* > pathpair004: /firth/upload/** to /forth/* > | | | | | | > pathpair068: /glasgow/* to /edinburgh/* > pathpair069: /glasgow/upload/** to /edinburgh/* > | | | | | | > > This is not ideal for a number of reasons. Do you know of a library > module that has the (optional?) ability to handle duplicate-named > options, returning them as a list? > > If instead someone can point me to a reasonable Apache-style config > module, that might also serve. I've looked for such and the few found > seemed to be either bare bones or clumsily stripped out of something > much larger. > > > -- > I'm a pessimist about probabilities; I'm an optimist about possibilities. > Lewis Mumford (1895-1990) > I've let ini style files alone some time ago. Whenever possible I use JSON based files. Your example could then look like this: { "pathpairs":{ "uk":[ ["/bath/*","/london/*"], ["/bath/upload/**","/london/*"], ["/firth/*,"/forth/*"], ["/firth/upload/**","/forth/*"] ] } } Since Python 2.7, json is in the standard library. -------------- next part -------------- An HTML attachment was scrubbed... URL: From tshinnic at io.com Sun Jan 9 16:04:07 2011 From: tshinnic at io.com (Thomas L. Shinnick) Date: Sun, 09 Jan 2011 15:04:07 -0600 Subject: What INI config file module allows lists of duplicate same-named options? In-Reply-To: <4D2A1ECA.2090901@aim.com> References: <4D29DEF5.2030702@ianhobson.co.uk> <4D2A124A.9000508@ieee.org> <4D2A16D3.4070405@gmail.com> <4D2A1ECA.2090901@aim.com> Message-ID: <6B.79.24070.8C22A2D4@hrndva-omtalb.mail.rr.com> At 02:47 PM 1/9/2011, Corey Richardson wrote: >On 01/09/2011 03:43 PM, Thomas L. Shinnick wrote: > > Having (possibly) surveyed all the available pypi config file modules, I > > still haven't seen one that allows an obvious and familiar extension of > > the strict Windows INI format. > > > > Each INI-style config module seems to enforce the strict rule: each > > option in a section must have a different name - no duplicates. Thus it > > is impossible to have a simple list, e.g. > > > > [pathset uk] > > pathpair: /bath/* to /london/* > > pathpair: /bath/upload/** to /london/* > > pathpair: /firth/* to /forth/* > > pathpair: /firth/upload/** to /forth/* > > > > Rather you must give each line a separate name, e.g. > > > > [pathset uk] > > pathpair001: /bath/* to /london/* > > pathpair002: /bath/upload/** to /london/* > > pathpair003: /firth/* to /forth/* > > pathpair004: /firth/upload/** to /forth/* > > | | | | | | > > pathpair068: /glasgow/* to /edinburgh/* > > pathpair069: /glasgow/upload/** to /edinburgh/* > > | | | | | | > > > > This is not ideal for a number of reasons. Do you know of a library > > module that has the (optional?) ability to handle duplicate-named > > options, returning them as a list? > > > > If instead someone can point me to a reasonable Apache-style config > > module, that might also serve. I've looked for such and the few found > > seemed to be either bare bones or clumsily stripped out of something > > much larger. > > > > > > -- > > I'm a pessimist about probabilities; I'm an optimist about possibilities. > > Lewis Mumford (1895-1990) > > > >Seems to me to be a standard enforced by Windows itself, not any an >issue with the modules. What exactly are you doing? Windows established the format, established the 'rules', then people adopted the format and rules, but often with 'adaptions' and extensions. I see many variations in the various modules found in pypi, such as variable interpolation, but none that violate the 'rule' "no duplicates". Here, I need to list multiple file/dir path pairs. A list of multiple items to be acted upon in a common way. It is a list. Simple. Except I can't find a library/pypi module with the obvious extension. Full disclosure: I'm familiar with $lang which has many such possible modules, which has me rather puzzled here. >~Corey Richardson From tshinnic at io.com Sun Jan 9 16:11:15 2011 From: tshinnic at io.com (Thomas L. Shinnick) Date: Sun, 09 Jan 2011 15:11:15 -0600 Subject: What INI config file module allows lists of duplicate same-named options? In-Reply-To: <4D2A201A.9040604@pythonmeister.com> References: <4D29DEF5.2030702@ianhobson.co.uk> <4D2A124A.9000508@ieee.org> <4D2A16D3.4070405@gmail.com> <4D2A201A.9040604@pythonmeister.com> Message-ID: <35.8D.14011.5742A2D4@hrndva-omtalb.mail.rr.com> At 02:52 PM 1/9/2011, Stefan Sonnenberg-Carstens wrote: >Am 09.01.2011 21:43, schrieb Thomas L. Shinnick: >>Having (possibly) surveyed all the available pypi config file >>modules, I still haven't seen one that allows an obvious and >>familiar extension of the strict Windows INI format. >> >>Each INI-style config module seems to enforce the strict rule: each >>option in a section must have a different name - no >>duplicates. Thus it is impossible to have a simple list, e.g. >> >> [pathset uk] >> pathpair: /bath/* to /london/* >> pathpair: /bath/upload/** to /london/* >> pathpair: /firth/* to /forth/* >> pathpair: /firth/upload/** to /forth/* >> >>Rather you must give each line a separate name, e.g. >> >> [pathset uk] >> pathpair001: /bath/* to /london/* >> pathpair002: /bath/upload/** to /london/* >> pathpair003: /firth/* to /forth/* >> pathpair004: /firth/upload/** to /forth/* >> | | | | | | >> pathpair068: /glasgow/* to /edinburgh/* >> pathpair069: /glasgow/upload/** to /edinburgh/* >> | | | | | | >> >>This is not ideal for a number of reasons. Do you know of a >>library module that has the (optional?) ability to handle >>duplicate-named options, returning them as a list? >> >>If instead someone can point me to a reasonable Apache-style config >>module, that might also serve. I've looked for such and the few >>found seemed to be either bare bones or clumsily stripped out of >>something much larger. >> >> >>-- >>I'm a pessimist about probabilities; I'm an optimist about possibilities. >> Lewis Mumford (1895-1990) >I've let ini style files alone some time ago. >Whenever possible I use JSON based files. > >Your example could then look like this: > >{ >"pathpairs":{ > "uk":[ > ["/bath/*","/london/*"], > ["/bath/upload/**","/london/*"], > ["/firth/*,"/forth/*"], > ["/firth/upload/**","/forth/*"] > ] >} >} > >Since Python 2.7, json is in the standard library. A reasonable response, if your only audience is computer folk. And used internally already. But in trying to be simple as can be for those installing and maintaining a package, INI-style configurations are a familiar format. As Apache-style configs would be. So, JSON is concise and flexible and easily handled by programs. But I was hoping for something easier for the poor soul coming back to a config after 2 months and wondering how to add something ... -------------- next part -------------- An HTML attachment was scrubbed... URL: From develsoftware at gmail.com Sun Jan 9 16:58:33 2011 From: develsoftware at gmail.com (=?UTF-8?B?0JXQstCz0LXQvdC40Lkg0J/QvtGH0LjRgtCw0LXQsg==?=) Date: Sun, 9 Jan 2011 13:58:33 -0800 (PST) Subject: Embedded Python static modules References: Message-ID: I made frozen modules and link this modules with my program. PyImport_FrozenModules = frozen_modules; Py_Initialize(); I got next message: Could not find platform independent libraries Could not find platform dependent libraries Consider setting $PYTHONHOME to [:] Traceback (most recent call last): File "site.py", line 553, in File "site.py", line 535, in main File "site.py", line 268, in addusersitepackages File "site.py", line 243, in getusersitepackages File "site.py", line 233, in getuserbase File "sysconfig.py", line 535, in get_config_var File "sysconfig.py", line 434, in get_config_vars File "sysconfig.py", line 287, in _init_posix IOError: invalid Python installation: unable to open /usr/local/lib/ python2.7/config/Makefile (No such file or directory) How I can fix this problem? From develsoftware at gmail.com Sun Jan 9 17:18:05 2011 From: develsoftware at gmail.com (=?UTF-8?B?0JXQstCz0LXQvdC40Lkg0J/QvtGH0LjRgtCw0LXQsg==?=) Date: Sun, 9 Jan 2011 14:18:05 -0800 (PST) Subject: Embedded Python static modules References: Message-ID: <6452fac5-88b4-4d71-81ec-26e6e6bb96cb@m11g2000vbs.googlegroups.com> I found solution: Py_NoSiteFlag = 1; Py_FrozenFlag = 1; Py_IgnoreEnvironmentFlag = 1; Py_SetPythonHome(""); Py_SetProgramName(""); From steve+comp.lang.python at pearwood.info Sun Jan 9 21:14:24 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 10 Jan 2011 02:14:24 GMT Subject: Integrating doctest with unittest References: <4d038b63$0$30000$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4d2a6b80$0$30004$c3e8da3$5496439d@news.astraweb.com> On Sun, 09 Jan 2011 08:56:52 -0800, Aahz wrote: > In article <4d038b63$0$30000$c3e8da3$5496439d at news.astraweb.com>, Steven > D'Aprano wrote: >> >>Is there a way to have unittest.main() find and run doc_test_suite >>together with the other test suites? > > You probably need to use nose or something. (That's what we're doing.) Thanks for the reply Aahz, even though it wasn't what I wanted to hear :( -- Steven From googler.1.webmaster at spamgourmet.com Mon Jan 10 03:21:31 2011 From: googler.1.webmaster at spamgourmet.com (moerchendiser2k3) Date: Mon, 10 Jan 2011 00:21:31 -0800 (PST) Subject: Resolve circular reference References: <1718ea91-fc4e-49f3-a15a-bdc683789126@k22g2000yqh.googlegroups.com> <353ecd61-22f8-4770-be30-29cb76b0f6b0@t35g2000yqj.googlegroups.com> <2349f7d4-2b85-456f-96b5-140f15548859@v17g2000prc.googlegroups.com> Message-ID: <1e7f6338-33ff-488e-9182-b31498babe0b@c39g2000yqi.googlegroups.com> so there is no chance without using weakrefs? any ideas, tips, workarounds how I might handle this? bye, moerchendiser2k3 From kushal.kumaran+python at gmail.com Mon Jan 10 03:26:51 2011 From: kushal.kumaran+python at gmail.com (Kushal Kumaran) Date: Mon, 10 Jan 2011 13:56:51 +0530 Subject: Close stdout socket on CGI after fork with subprocess In-Reply-To: References: Message-ID: On Mon, Jan 10, 2011 at 1:15 PM, Thibaud Roussillat wrote: > On Sat, Jan 8, 2011 at 3:19 AM, Kushal Kumaran > wrote: >> >> On Fri, Jan 7, 2011 at 8:08 PM, Thibaud Roussillat >> wrote: >> > Hi, >> > >> > I work with Python 2.4 and CGI. >> > >> > I have a CGI which call a Python script in background process and return >> > result before background task is finished. >> > >> > Actually, the browser displays response but it is waiting for end of >> > background task because the socket is not closed. >> > >> > Internet told me that I must close the stdout file descriptor >> > (sys.stdout.close()) to close the socket but it doesn't work. >> > >> > The background task is launched via subprocess.Popen and is attached to >> > the >> > root process on ps command. >> > >> >> This means that the parent process finished before the child. ?Call >> wait() on the Popen object to wait for the child to terminate. >> Depending on how you create the Popen object, the child process may >> inherit your own stdout. ?In that case, the child process may be >> keeping the socket open after the parent dies. >> > > > > In fact, the parent process finished before the child, it's why I want to > run the child in a forked process, and close the socket of the parent task. > > The goal is not to wait for the child process but to leave it lead one's own > life as a background task. The client don't have to wait for the end of the > child process. > > Is there a way to not inherit from the parent stdout on the child process ? > open os.devnull and pass that file object as stdin, stdout and stderr for the child process. Hopefully the program you are running has been designed not to expect to be able to use stdin/stdout/stderr. Please keep the discussion on the mailing list. Other people on the list are smarter than me. Also, the convention on this mailing list is to keep replies below the quoted content. -- regards, kushal From jeanmichel at sequans.com Mon Jan 10 05:13:38 2011 From: jeanmichel at sequans.com (Jean-Michel Pichavant) Date: Mon, 10 Jan 2011 11:13:38 +0100 Subject: Absolute imports? In-Reply-To: References: <877heff4fl.fsf@benfinney.id.au> Message-ID: <4D2ADBD2.3070604@sequans.com> Roy Smith wrote: > [snip] > It's reasonably straight-forward to figure out that absolute path, > starting from sys.argv[0] and using the tools in os.path. Now I need to > import the file, given that I know its absolute pathname. It looks like > imp.load_source() does what I want, I'm just wondering if there's a > cleaner way. > What about config = __import__(configPath.replace('.py', '')) JM From jldunn2000 at gmail.com Mon Jan 10 09:12:29 2011 From: jldunn2000 at gmail.com (loial) Date: Mon, 10 Jan 2011 06:12:29 -0800 (PST) Subject: PJL Message-ID: <19d28e76-6085-42b5-a98f-7bf40591910f@f35g2000vbl.googlegroups.com> Anyone got any experience of send PJL commands to a printer using Python on Unix? From thibaud.roussillat at gmail.com Mon Jan 10 09:53:18 2011 From: thibaud.roussillat at gmail.com (Thibaud Roussillat) Date: Mon, 10 Jan 2011 15:53:18 +0100 Subject: Close stdout socket on CGI after fork with subprocess In-Reply-To: References: Message-ID: On Mon, Jan 10, 2011 at 9:26 AM, Kushal Kumaran < kushal.kumaran+python at gmail.com > wrote: > On Mon, Jan 10, 2011 at 1:15 PM, Thibaud Roussillat > wrote: > > On Sat, Jan 8, 2011 at 3:19 AM, Kushal Kumaran > > > > wrote: > >> > >> On Fri, Jan 7, 2011 at 8:08 PM, Thibaud Roussillat > >> wrote: > >> > Hi, > >> > > >> > I work with Python 2.4 and CGI. > >> > > >> > I have a CGI which call a Python script in background process and > return > >> > result before background task is finished. > >> > > >> > Actually, the browser displays response but it is waiting for end of > >> > background task because the socket is not closed. > >> > > >> > Internet told me that I must close the stdout file descriptor > >> > (sys.stdout.close()) to close the socket but it doesn't work. > >> > > >> > The background task is launched via subprocess.Popen and is attached > to > >> > the > >> > root process on ps command. > >> > > >> > >> This means that the parent process finished before the child. Call > >> wait() on the Popen object to wait for the child to terminate. > >> Depending on how you create the Popen object, the child process may > >> inherit your own stdout. In that case, the child process may be > >> keeping the socket open after the parent dies. > >> > > > > > > > > In fact, the parent process finished before the child, it's why I want to > > run the child in a forked process, and close the socket of the parent > task. > > > > The goal is not to wait for the child process but to leave it lead one's > own > > life as a background task. The client don't have to wait for the end of > the > > child process. > > > > Is there a way to not inherit from the parent stdout on the child process > ? > > > > open os.devnull and pass that file object as stdin, stdout and stderr > for the child process. Hopefully the program you are running has been > designed not to expect to be able to use stdin/stdout/stderr. > > Please keep the discussion on the mailing list. Other people on the > list are smarter than me. Also, the convention on this mailing list > is to keep replies below the quoted content. > > -- > regards, > kushal > Thanks a lot, this works well with a file object opened on /dev/null (or os.devnull) and passed as stdin, stdout and stderr. Sorry for the reply, I just do "reply" on my webmail ;) Regards, Thib -------------- next part -------------- An HTML attachment was scrubbed... URL: From emile at fenx.com Mon Jan 10 10:00:23 2011 From: emile at fenx.com (Emile van Sebille) Date: Mon, 10 Jan 2011 07:00:23 -0800 Subject: PJL In-Reply-To: <19d28e76-6085-42b5-a98f-7bf40591910f@f35g2000vbl.googlegroups.com> References: <19d28e76-6085-42b5-a98f-7bf40591910f@f35g2000vbl.googlegroups.com> Message-ID: On 1/10/2011 6:12 AM loial said... > Anyone got any experience of send PJL commands to a printer using > Python on Unix? > Are you having trouble? PJL is sent like any other text... Emile From zac256 at gmail.com Mon Jan 10 10:00:47 2011 From: zac256 at gmail.com (Zac Burns) Date: Mon, 10 Jan 2011 23:00:47 +0800 Subject: Create a class to position a window on the screen. In-Reply-To: References: Message-ID: I'm not exactly sure what you are asking here, but one problem that is notable in your example is that the center function is indented inside the __init__ function. This would create a closure instead of a method on PositionWindow, which is probably not what you want. -Zac On Sun, Jan 9, 2011 at 10:23 AM, Rohit Coder < passionate_programmer at hotmail.com> wrote: > Hi, > elementFontfont-familyfont-sizefont-stylefont-variantfont-weight > letter-spacingline-heighttext-decorationtext-aligntext-indent > text-transformwhite-spaceword-spacingcolorBackgroundbg-attachmentbg-color > bg-imagebg-positionbg-repeatBoxwidthheightborder-topborder-right > border-bottomborder-leftmarginpaddingmax-heightmin-heightmax-width > min-widthoutline-coloroutline-styleoutline-widthPositioningpositiontop > bottomrightleftfloatdisplayclearz-indexListlist-style-imagelist-style-type > list-style-positionTablevertical-alignborder-collapseborder-spacing > caption-sideempty-cellstable-layoutEffectstext-shadow-webkit-box-shadow > border-radiusOtheroverflowcursorvisibility > > I am new to Python and this is my fist Python class. I am using PyQt4 > framework on Windows 7. > > I don't know whether the code below is correctly written or not. I want to > modify it further as: > > 1. In the arguments, I want to pass the name of another opened Window > (.py) on the screen. > 2. I want to pass the x-coord., y-coord. and the name of the window to > position on the screen. > > How to modify the code to fulfill these requirements? > > ***Attempted Code*** > > class PositionWindow: > def __init__(self, xCoord, yCoord, windowName, parent = None): > self.x = xCoord > self.y = yCoord > self.wName = windowName; > > def center(self): > screen = QtGui.QDesktopWidget().screenGeometry() > size = self.geometry() > self.move((screen.width()-size.width())/2, > (screen.height()-size.height())/2) > > ................... > Rohit. > > > -- > http://mail.python.org/mailman/listinfo/python-list > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From jldunn2000 at gmail.com Mon Jan 10 10:06:16 2011 From: jldunn2000 at gmail.com (loial) Date: Mon, 10 Jan 2011 07:06:16 -0800 (PST) Subject: PJL References: <19d28e76-6085-42b5-a98f-7bf40591910f@f35g2000vbl.googlegroups.com> Message-ID: <44a7123a-52e7-4c34-adba-d9cf19985899@u9g2000pra.googlegroups.com> Thanks for responding.. First question...how do I send it to the printer? Printer would be on the network. From pavlovevidence at gmail.com Mon Jan 10 10:20:06 2011 From: pavlovevidence at gmail.com (Carl Banks) Date: Mon, 10 Jan 2011 07:20:06 -0800 (PST) Subject: Resolve circular reference References: <1718ea91-fc4e-49f3-a15a-bdc683789126@k22g2000yqh.googlegroups.com> <353ecd61-22f8-4770-be30-29cb76b0f6b0@t35g2000yqj.googlegroups.com> <2349f7d4-2b85-456f-96b5-140f15548859@v17g2000prc.googlegroups.com> <1e7f6338-33ff-488e-9182-b31498babe0b@c39g2000yqi.googlegroups.com> Message-ID: <429e3e67-9732-4f82-9f97-99ed5aeb1f74@r8g2000prm.googlegroups.com> On Jan 10, 12:21?am, moerchendiser2k3 wrote: > so there is no chance without using weakrefs? > any ideas, tips, workarounds how I might handle this? No, sorry: as long as a reference to an object exists, the object is never deleted. There is no way to get around this. Python in general isn't designed to allow for exact control over the destruction of objects. Even in CPython, which uses reference counting, there are a bunch of situations where a reference might be stored to an object that keeps it alive. (Unexpected locations where a stray reference might exist: an unpickler object, the _ symbol in the interactive shell.) Other implementations, like Jython and IronPython, don't use reference counting and don't provide for any particular time at all for an object to be destroyed. The recommended way to ensure timely release of resources in Python is to provide a method (such as close or finalize) to explicity release the resource--the object then lives on in a zombie state. The with statement can be used in many cases to avoid the need to call this method explicitly. For example, if you were to run this code in Python: with open(filename) as f: g = f print g It would print . The object still exists because there is a reference to it, but the file has been closed. If you can tell us why it's so important that the object be destroyed at that given time, even while a reference to it exists, maybe we can give you better suggestions. Carl Banks From wolfgang at rohdewald.de Mon Jan 10 10:49:03 2011 From: wolfgang at rohdewald.de (Wolfgang Rohdewald) Date: Mon, 10 Jan 2011 16:49:03 +0100 Subject: PJL In-Reply-To: <44a7123a-52e7-4c34-adba-d9cf19985899@u9g2000pra.googlegroups.com> References: <19d28e76-6085-42b5-a98f-7bf40591910f@f35g2000vbl.googlegroups.com> <44a7123a-52e7-4c34-adba-d9cf19985899@u9g2000pra.googlegroups.com> Message-ID: <201101101649.03489.wolfgang@rohdewald.de> On Montag 10 Januar 2011, loial wrote: > First question...how do I send it to the printer? Printer > would be on the network. echo PJL | lp -oraw -dnetworkprinter if it works, translate it to python -- Wolfgang -------------- next part -------------- An HTML attachment was scrubbed... URL: From jtim.arnold at gmail.com Mon Jan 10 11:29:07 2011 From: jtim.arnold at gmail.com (Tim) Date: Mon, 10 Jan 2011 08:29:07 -0800 (PST) Subject: os.system and loggers References: <70ac3463-cf3c-4435-909b-ac044bef7e41@z9g2000yqz.googlegroups.com> Message-ID: <285801ef-7e26-4c40-a307-3c6eb5314b82@z17g2000prz.googlegroups.com> On Jan 7, 11:24?am, Tim wrote: > hi, I'm using a 3rd-party python program that uses the python logging > facility and also makes calls to os.system. I'm trying to capture its > output to a file. > > In my own code, I've taken control of the loggers that are setup in > the other program by removing its StreamHandler and replacing with > FileHander. But when it comes to the call to os.system I'm at a loss. > > I want to capture the stdout from that os.system call in my > FileHandler. I thought this might work, before I call the other > program's class/method: > sys.stdout = getLogger('status').handlers[0].stream > > but no dice. Is there any clean way to get what I want? If not, I > guess I'll override the other method with my own, but it will > basically be a bunch of code copied with os.sytem replaced with > subprocess, using getLogger('status').handlers[0].stream for stdout/ > stderr. > > thanks, > --Tim Arnold Replying to my own post.... I think I may have included too much fluff in my original question. The main thing I wonder is whether I can attach a log handler to stdout in such a way that os.system calls will write to that handler instead of the console. thanks, --Tim From emile at fenx.com Mon Jan 10 12:08:36 2011 From: emile at fenx.com (Emile van Sebille) Date: Mon, 10 Jan 2011 09:08:36 -0800 Subject: PJL In-Reply-To: <44a7123a-52e7-4c34-adba-d9cf19985899@u9g2000pra.googlegroups.com> References: <19d28e76-6085-42b5-a98f-7bf40591910f@f35g2000vbl.googlegroups.com> <44a7123a-52e7-4c34-adba-d9cf19985899@u9g2000pra.googlegroups.com> Message-ID: On 1/10/2011 7:06 AM loial said... > Thanks for responding.. > > First question...how do I send it to the printer? Printer would be > on the network. Start here: http://mail.python.org/pipermail/python-announce-list/2000-November/000567.html The middle article covers accessing the printer. Emile From torriem at gmail.com Mon Jan 10 12:37:33 2011 From: torriem at gmail.com (Michael Torrie) Date: Mon, 10 Jan 2011 10:37:33 -0700 Subject: Print to an IPP printer (pkipplib?) In-Reply-To: <1287247744.11414.0.camel@linux-yu4c.site> References: <1287247744.11414.0.camel@linux-yu4c.site> Message-ID: <4D2B43DD.4040101@gmail.com> On 10/16/2010 10:49 AM, Adam Tauno Williams wrote: > I've found the module pkipplib which seems to work well for things like > interrogating an IPP (CUPS) server. But is there a way to send a print > job to an IPP print queue? [and no, the local system knows nothing about > the print architecture so popen....lp is not an option]. I just want to > send the data from a file handle to a remote IPP queue as a print job. I wonder if you could post the print job directly to the IPP url. It's really just HTTP under the hood. From googler.1.webmaster at spamgourmet.com Mon Jan 10 12:55:54 2011 From: googler.1.webmaster at spamgourmet.com (moerchendiser2k3) Date: Mon, 10 Jan 2011 09:55:54 -0800 (PST) Subject: Resolve circular reference References: <1718ea91-fc4e-49f3-a15a-bdc683789126@k22g2000yqh.googlegroups.com> <353ecd61-22f8-4770-be30-29cb76b0f6b0@t35g2000yqj.googlegroups.com> <2349f7d4-2b85-456f-96b5-140f15548859@v17g2000prc.googlegroups.com> <1e7f6338-33ff-488e-9182-b31498babe0b@c39g2000yqi.googlegroups.com> <429e3e67-9732-4f82-9f97-99ed5aeb1f74@r8g2000prm.googlegroups.com> Message-ID: <451b9057-609a-4b1d-a064-62e738267084@e4g2000vbg.googlegroups.com> > If you can tell us why it's so important that the object be destroyed > at that given time, even while a reference to it exists, maybe we can > give you better suggestions. Thanks for your answer! In my case the types A and B (in my example above) are a dialog and a dialog widget. At a special time I have to close and destroy all dialogs but this does not happen because the widget keeps the dialog alive. I have the reference to the dialog but after I closed the dialogs I also would like to destroy them because they have to free some special ressources. Thanks a lot!! Bye, moerchendiser2k3 From pavlovevidence at gmail.com Mon Jan 10 13:01:06 2011 From: pavlovevidence at gmail.com (Carl Banks) Date: Mon, 10 Jan 2011 10:01:06 -0800 (PST) Subject: os.system and loggers References: <70ac3463-cf3c-4435-909b-ac044bef7e41@z9g2000yqz.googlegroups.com> <285801ef-7e26-4c40-a307-3c6eb5314b82@z17g2000prz.googlegroups.com> Message-ID: On Jan 10, 8:29?am, Tim wrote: > On Jan 7, 11:24?am, Tim wrote: > > > > > > > hi, I'm using a 3rd-party python program that uses the python logging > > facility and also makes calls to os.system. I'm trying to capture its > > output to a file. > > > In my own code, I've taken control of the loggers that are setup in > > the other program by removing its StreamHandler and replacing with > > FileHander. But when it comes to the call to os.system I'm at a loss. > > > I want to capture the stdout from that os.system call in my > > FileHandler. I thought this might work, before I call the other > > program's class/method: > > sys.stdout = getLogger('status').handlers[0].stream > > > but no dice. Is there any clean way to get what I want? If not, I > > guess I'll override the other method with my own, but it will > > basically be a bunch of code copied with os.sytem replaced with > > subprocess, using getLogger('status').handlers[0].stream for stdout/ > > stderr. > > > thanks, > > --Tim Arnold > > Replying to my own post.... > > I think I may have included too much fluff in my original question. > The main thing I wonder is whether I can attach a log handler to > stdout in such a way that os.system calls will write to that handler > instead of the console. No, but you could replace os.system with something that does work. (It would replace it globally for all uses, so you may need some logic to decide whether to leave the call alone, or to modify it, perhaps by inspecting the call stack.) The simplest thing to do is to append a shell redirection to the command (>/your/log/file), so something like this: _real_os_system = os.system def my_os_system(cmd): if test_log_condition: return _real_os_system(cmd + "2> /my/log/file") return _real_os_system(cmd) os.system = my_os_system That could backfire for any number of reasons so you probably should only do this if you know that it works with all the commands it issues. The better way might be to call the subprocess module instead, where you can dispatch the command with redirection to any stream. I doubt there's a foolproof way to do that given an arbitrary os.system command, but the subprocess way is probably safer. Carl Banks From pavlovevidence at gmail.com Mon Jan 10 13:03:57 2011 From: pavlovevidence at gmail.com (Carl Banks) Date: Mon, 10 Jan 2011 10:03:57 -0800 (PST) Subject: os.system and loggers References: <70ac3463-cf3c-4435-909b-ac044bef7e41@z9g2000yqz.googlegroups.com> <285801ef-7e26-4c40-a307-3c6eb5314b82@z17g2000prz.googlegroups.com> Message-ID: On Jan 10, 8:29?am, Tim wrote: > I think I may have included too much fluff in my original question. > The main thing I wonder is whether I can attach a log handler to > stdout in such a way that os.system calls will write to that handler > instead of the console. From stefan_ml at behnel.de Mon Jan 10 13:18:02 2011 From: stefan_ml at behnel.de (Stefan Behnel) Date: Mon, 10 Jan 2011 19:18:02 +0100 Subject: Resolve circular reference In-Reply-To: <451b9057-609a-4b1d-a064-62e738267084@e4g2000vbg.googlegroups.com> References: <1718ea91-fc4e-49f3-a15a-bdc683789126@k22g2000yqh.googlegroups.com> <353ecd61-22f8-4770-be30-29cb76b0f6b0@t35g2000yqj.googlegroups.com> <2349f7d4-2b85-456f-96b5-140f15548859@v17g2000prc.googlegroups.com> <1e7f6338-33ff-488e-9182-b31498babe0b@c39g2000yqi.googlegroups.com> <429e3e67-9732-4f82-9f97-99ed5aeb1f74@r8g2000prm.googlegroups.com> <451b9057-609a-4b1d-a064-62e738267084@e4g2000vbg.googlegroups.com> Message-ID: moerchendiser2k3, 10.01.2011 18:55: >> If you can tell us why it's so important that the object be destroyed >> at that given time, even while a reference to it exists, maybe we can >> give you better suggestions. > > Thanks for your answer! In my case the types A and B (in my example > above) > are a dialog and a dialog widget. At a special time I have to close > and > destroy all dialogs but this does not happen because the widget keeps > the dialog alive. I have the reference to the dialog > but after I closed the dialogs I also would like to destroy them > because they have to free some special ressources. Objects within a reference cycle will eventually get cleaned up, just not right away and not in a predictable order. If you need immediate cleanup, you should destroy the reference cycle yourself, e.g. by removing the widgets from the dialog when closing it. Stefan From awilliam at whitemice.org Mon Jan 10 13:40:54 2011 From: awilliam at whitemice.org (Adam Tauno Williams) Date: Mon, 10 Jan 2011 13:40:54 -0500 Subject: Print to an IPP printer (pkipplib?) In-Reply-To: <4D2B43DD.4040101@gmail.com> References: <1287247744.11414.0.camel@linux-yu4c.site> <4D2B43DD.4040101@gmail.com> Message-ID: <1294684854.16499.3.camel@linux-yu4c.site> On Mon, 2011-01-10 at 10:37 -0700, Michael Torrie wrote: > On 10/16/2010 10:49 AM, Adam Tauno Williams wrote: > > I've found the module pkipplib which seems to work well for things like > > interrogating an IPP (CUPS) server. But is there a way to send a print > > job to an IPP print queue? [and no, the local system knows nothing about > > the print architecture so popen....lp is not an option]. I just want to > > send the data from a file handle to a remote IPP queue as a print job. > I wonder if you could post the print job directly to the IPP url. It's > really just HTTP under the hood. Correct; I've been meaning to try that but haven't gotten back to it on my to-do list. First I have to make a text stream into a PDF, so I have something to send. Surprisingly I've been able to find no code to steal which does that; which means it will take longer. :( [clumsily thunking out to commands like "a2ps", etc... is strictly forbidden in this code-base; and that seems how a lot of people seem to hand it]. From emile at fenx.com Mon Jan 10 13:49:10 2011 From: emile at fenx.com (Emile van Sebille) Date: Mon, 10 Jan 2011 10:49:10 -0800 Subject: Print to an IPP printer (pkipplib?) In-Reply-To: <1294684854.16499.3.camel@linux-yu4c.site> References: <1287247744.11414.0.camel@linux-yu4c.site> <4D2B43DD.4040101@gmail.com> <1294684854.16499.3.camel@linux-yu4c.site> Message-ID: On 1/10/2011 10:40 AM Adam Tauno Williams said... > First I have to make a text stream into a PDF, so I have something to > send. Surprisingly I've been able to find no code to steal which does > that; which means it will take longer. :( reportlab? [clumsily thunking out to > commands like "a2ps", etc... is strictly forbidden in this code-base; > and that seems how a lot of people seem to hand it]. > From awilliam at whitemice.org Mon Jan 10 13:58:42 2011 From: awilliam at whitemice.org (Adam Tauno Williams) Date: Mon, 10 Jan 2011 13:58:42 -0500 Subject: Print to an IPP printer (pkipplib?) In-Reply-To: References: <1287247744.11414.0.camel@linux-yu4c.site> <4D2B43DD.4040101@gmail.com> <1294684854.16499.3.camel@linux-yu4c.site> Message-ID: <1294685922.16499.6.camel@linux-yu4c.site> On Mon, 2011-01-10 at 10:49 -0800, Emile van Sebille wrote: > On 1/10/2011 10:40 AM Adam Tauno Williams said... > > First I have to make a text stream into a PDF, so I have something to > > send. Surprisingly I've been able to find no code to steal which does > > that; which means it will take longer. :( > reportlab? Possibly, there is that an pyPdf. I've found recently, but haven't had time to take it apart yet [and the license looks OK, other code snippets I've found were explicitly GPL so I couldn't look at those]. > [clumsily thunking out to > > commands like "a2ps", etc... is strictly forbidden in this code-base; > > and that seems how a lot of people seem to hand it]. From stefan at bytereef.org Mon Jan 10 14:01:55 2011 From: stefan at bytereef.org (Stefan Krah) Date: Mon, 10 Jan 2011 20:01:55 +0100 Subject: [ANN] cdecimal-2.2 released Message-ID: <20110110190155.GA17474@yoda.bytereef.org> Hi, I'm pleased to announce the release of cdecimal-2.2. cdecimal is a fast drop-in replacement for the decimal module in Python's standard library. Blurb ===== cdecimal is a complete implementation of IBM's General Decimal Arithmetic Specification. With the appropriate context parameters, cdecimal will also conform to the IEEE 754-2008 Standard for Floating-Point Arithmetic. Typical performance gains over decimal.py are between 30x for I/O heavy benchmarks and 80x for numerical programs. In a PostgreSQL database benchmark, the speedup is 12x. +---------+-------------+--------------+-------------+ | | decimal | cdecimal | speedup | +=========+=============+==============+=============+ | pi | 42.75s | 0.58s | 74x | +---------+-------------+--------------+-------------+ | telco | 172.19s | 5.68s | 30x | +---------+-------------+--------------+-------------+ | psycopg | 3.57s | 0.29s | 12x | +---------+-------------+--------------+-------------+ In the pi benchmark, cdecimal often performs better than Java's BigDecimal running on Java HotSpot(TM) 64-Bit Server VM. Both cdecimal and the underlying library - libmpdec - have very large test suites. libmpdec has 100% code coverage, cdecimal 85%. The test suites have been running continuously for over a year without any major issues. Install ======= Since cdecimal is now listed on PyPI, it can be installed using pip: pip install cdecimal Windows installers are available at: http://www.bytereef.org/mpdecimal/download.html Links ===== http://www.bytereef.org/mpdecimal/index.html http://www.bytereef.org/mpdecimal/changelog.html http://www.bytereef.org/mpdecimal/download.html Checksums of the released packages ================================== sha256sum --------- 3d92429fab74ddb17d12feec9cd949cd8a0be4bc0ba9afc5ed9b3af884e5d406 mpdecimal-2.2.tar.gz e8f02731d4089d7c2b79513d01493c36ef41574423ea3e49b245b86640212bdc mpdecimal-2.2.zip 515625c5c5830b109c57af93d49ae2c57ec3f230d46a3e0583840ff73d7963be cdecimal-2.2.tar.gz sha1sum ------- 24695b2c9254e1b870eb663e3d966eb4f0abd5ab cdecimal-2.2.win32-py2.6.msi e74cb7e722f30265b408b322d2c50d9a18f78587 cdecimal-2.2.win32-py2.7.msi 7c39243b2fc8b1923ad6a6066536982844a7617f cdecimal-2.2.win32-py3.1.msi 5711fd69a8e1e2e7be0ad0e6b93ecc10aa584c68 cdecimal-2.2.win-amd64-py2.6.msi b1cd7b6a373c212bf2f6aa288cd767171bfefd41 cdecimal-2.2.win-amd64-py2.7.msi f08a803a1a42a2d8507da1dc49f3bf7eed37c332 cdecimal-2.2.win-amd64-py3.1.msi cb29fa8f67befaf2d1a05f4675f840d7cd35cf6c cdecimal-2.2-no-thread.win32-py2.6.msi 012a44488f2ce2912f903ae9faf995efc7c9324b cdecimal-2.2-no-thread.win32-py2.7.msi 1c08c73643fc45d7b0feb62c33bebd76537f9d02 cdecimal-2.2-no-thread.win32-py3.1.msi b6dbd92e86ced38506ea1a6ab46f2e41f1444eae cdecimal-2.2-no-thread.win-amd64-py2.6.msi b239b41e6958d9e71e91b122183dc0eaefa00fef cdecimal-2.2-no-thread.win-amd64-py2.7.msi 413724ff20ede7b648f57dd9a78a12e72e064583 cdecimal-2.2-no-thread.win-amd64-py3.1.msi Stefan Krah From opentracker124 at googlemail.com Mon Jan 10 15:25:35 2011 From: opentracker124 at googlemail.com (http://groups.google.com/group/de.comp.os.os2.apps/post) Date: Mon, 10 Jan 2011 12:25:35 -0800 (PST) Subject: arbeitsamt jobs ausland , stellenangebot in ausland , Berufskraftfahrer Berufskraftfahrerin , Maler Malerin , stellenanzeigen jobboerse , arbeitsvermittlung , Meteorologe Meteorologin , jobs und praktika im ausland 2007 , Innenarchitekt Innenarchi Message-ID: <9bc81066-8f36-4caf-ac88-df3eab511ad8@d7g2000vbv.googlegroups.com> arbeitsamt jobs ausland , stellenangebot in ausland , Berufskraftfahrer Berufskraftfahrerin , Maler Malerin , stellenanzeigen jobboerse , arbeitsvermittlung , Meteorologe Meteorologin , jobs und praktika im ausland 2007 , Innenarchitekt Innenarchitektin , + + + +++ TOPJOB AUSLAND +++ IM AUSLAND ARBEITEN +++ + + http://WWW.AUSLANDS-JOB.ORG http://WWW.AUSLANDS-JOB.ORG http://WWW.AUSLANDS-JOB.ORG http://WWW.AUSLANDS-JOB.ORG http://WWW.AUSLANDS-JOB.ORG http://WWW.AUSLANDS-JOB.ORG + + + + + + + + ehrenamtlich arbeiten im ausland Polizeivollzugsbeamte Polizeivollzugsbeamter Mediengestalter Bild und Ton www ausland jobs stellenangebote fuers ausland ausland jobs de jobboerse angebote stellenanzeigen ausland au?endienstmitarbeiter jobs im ausland australien jobboersen ausland berufe ausland Maurer Maurerin arbeiten im ausland steuern Tieraerztin Tierarzt auswandern jobs im ausland praktikum im ausland Event-Manager Event-Managerin Industriemechaniker Industriemechanikerin jobsuche jobboerse Restaurantfachfrau Restaurantfachmann Journalist Journalistin will im ausland arbeiten jobangebote ausland jobboerse arbeitgeber Personalreferent Personalreferentin jobboerse bayern Kauffrau audiovisuelle Medien www arbeiten im ausland Hebamme From drsalists at gmail.com Mon Jan 10 15:29:09 2011 From: drsalists at gmail.com (Dan Stromberg) Date: Mon, 10 Jan 2011 12:29:09 -0800 Subject: Python use growing fast Message-ID: I invite folks to check out Tiobe's Language Popularity Rankings: http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html The gist is: Python grew faster than any other programming language over the last year, according to this (slightly arbitrary, but better than no indicator) ranking. ...despite our wikipedia page whose first paragraph almost seems like it was written with the intention of scaring off new converts, with its "unusual" comment: http://en.wikipedia.org/wiki/Python_%28programming_language%29 (Like it or not, people do frequently confuse the descriptive for the normative) From python at mrabarnett.plus.com Mon Jan 10 16:02:09 2011 From: python at mrabarnett.plus.com (MRAB) Date: Mon, 10 Jan 2011 21:02:09 +0000 Subject: Python use growing fast In-Reply-To: References: Message-ID: <4D2B73D1.6060303@mrabarnett.plus.com> On 10/01/2011 20:29, Dan Stromberg wrote: > I invite folks to check out Tiobe's Language Popularity Rankings: > > http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html > > The gist is: Python grew faster than any other programming language > over the last year, according to this (slightly arbitrary, but better > than no indicator) ranking. > > ...despite our wikipedia page whose first paragraph almost seems like > it was written with the intention of scaring off new converts, with > its "unusual" comment: > > http://en.wikipedia.org/wiki/Python_%28programming_language%29 > > (Like it or not, people do frequently confuse the descriptive for the normative) It shows an example of Python code, which happens to have 2 syntax errors! From googler.1.webmaster at spamgourmet.com Mon Jan 10 16:19:25 2011 From: googler.1.webmaster at spamgourmet.com (moerchendiser2k3) Date: Mon, 10 Jan 2011 13:19:25 -0800 (PST) Subject: Resolve circular reference References: <1718ea91-fc4e-49f3-a15a-bdc683789126@k22g2000yqh.googlegroups.com> <353ecd61-22f8-4770-be30-29cb76b0f6b0@t35g2000yqj.googlegroups.com> <2349f7d4-2b85-456f-96b5-140f15548859@v17g2000prc.googlegroups.com> <1e7f6338-33ff-488e-9182-b31498babe0b@c39g2000yqi.googlegroups.com> <429e3e67-9732-4f82-9f97-99ed5aeb1f74@r8g2000prm.googlegroups.com> <451b9057-609a-4b1d-a064-62e738267084@e4g2000vbg.googlegroups.com> Message-ID: <55db55e9-539a-4f36-a84f-5199500cd909@k30g2000vbn.googlegroups.com> On Jan 10, 7:18?pm, Stefan Behnel wrote: > moerchendiser2k3, 10.01.2011 18:55: > > >> If you can tell us why it's so important that the object be destroyed > >> at that given time, even while a reference to it exists, maybe we can > >> give you better suggestions. > > > Thanks for your answer! In my case the types A and B (in my example > > above) > > are a dialog and a dialog widget. At a special time I have to close > > and > > destroy all dialogs but this does not happen because the widget keeps > > the dialog alive. I have the reference to the dialog > > but after I closed the dialogs I also would like to destroy them > > because they have to free some special ressources. > > Objects within a reference cycle will eventually get cleaned up, just not > right away and not in a predictable order. > > If you need immediate cleanup, you should destroy the reference cycle > yourself, e.g. by removing the widgets from the dialog when closing it. > > Stefan The PyWidget type does not own the widget, it just points to it. I have an idea, would this fix the problem? I destroy the internal dictionary of the dialog which points to other PyObjects? Then I would cut the dependency. From alice at gothcandy.com Mon Jan 10 16:43:23 2011 From: alice at gothcandy.com (=?utf-8?Q?Alice_Bevan=E2=80=93McGregor?=) Date: Mon, 10 Jan 2011 13:43:23 -0800 Subject: Python use growing fast References: <4D2B73D1.6060303@mrabarnett.plus.com> Message-ID: On 2011-01-10 13:02:09 -0800, MRAB said: > On 10/01/2011 20:29, Dan Stromberg wrote: >> ...despite our wikipedia page whose first paragraph almost seems like >> it was written with the intention of scaring off new converts, with its >> "unusual" comment... Indentation as a syntatitical structure is not actually unusual in any way as was recently discussed in another thread (having difficulty finding it). > It shows an example of Python code, which happens to have 2 syntax errors! Wikipedia is a Wiki; everyone is free to contribute and correct mistakes. - Alice. From krzysztof.t.bieniasz at gmail.com Mon Jan 10 16:56:13 2011 From: krzysztof.t.bieniasz at gmail.com (Krzysztof Bieniasz) Date: Mon, 10 Jan 2011 21:56:13 +0000 (UTC) Subject: Python use growing fast References: Message-ID: > I invite folks to check out Tiobe's Language Popularity Rankings: > > http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html > > The gist is: Python grew faster than any other programming language over > the last year, according to this (slightly arbitrary, but better than no > indicator) ranking. And look at the Hall of Fame. Python is the first language to win the popularity award twice. Although the statistical population isn't really extensive... From nagle at animats.com Mon Jan 10 17:29:32 2011 From: nagle at animats.com (John Nagle) Date: Mon, 10 Jan 2011 14:29:32 -0800 Subject: Python use growing fast In-Reply-To: References: Message-ID: <4d2b8844$0$43996$742ec2ed@news.sonic.net> On 1/10/2011 1:02 PM, MRAB wrote: > On 10/01/2011 20:29, Dan Stromberg wrote: >> I invite folks to check out Tiobe's Language Popularity Rankings: >> >> http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html That's somehow derived from web searches, not from any real data source. Look how far down JavaScript is. John Nagle From Philippe.vouters at laposte.net Mon Jan 10 17:33:01 2011 From: Philippe.vouters at laposte.net (A famous IT technical writer) Date: Mon, 10 Jan 2011 14:33:01 -0800 (PST) Subject: Compiling and Executing a Python byte coded program Message-ID: <446c01a1-b2c2-467a-a54b-853db80443b5@f2g2000vby.googlegroups.com> If interested with, have a look to http://vouters.dyndns.org/tima/All-OS-Python-Compiling_a_Python_Program_and_Executing_the_compiled_version.html Note you may boost your Python's startup time but not the execution speed of your program which depends on the generated byte code. From passionate_programmer at hotmail.com Mon Jan 10 17:37:35 2011 From: passionate_programmer at hotmail.com (Rohit Coder) Date: Tue, 11 Jan 2011 04:07:35 +0530 Subject: Centering a window Message-ID: I am using PyQt4 for GUI apps. I created a class that contains a function to center any window (Form) whose name is passed to this class. I have two questions: How to modify the below given code to center the window whose name we passed as an argument.How to pass window name to this class from another file that imports this class? ============= CODE BLOCK STARTS HERE ===========from PyQt4 import QtGui class PositionWindow: def __init__(self, xCoord, yCoord, windowName, parent = None): self.x = xCoord self.y = yCoord self.wName = windowName; def center(self): screen = QtGui.QDesktopWidget().screenGeometry() size = self.geometry() self.move((screen.width()-size.width())/2, (screen.height()-size.height())/2)============= CODE BLOCK ENDS HERE =========== ................Rohit K.elementFontfont-familyfont-sizefont-stylefont-variantfont-weightletter-spacingline-heighttext-decorationtext-aligntext-indenttext-transformwhite-spaceword-spacingcolorBackgroundbg-attachmentbg-colorbg-imagebg-positionbg-repeatBoxwidthheightborder-topborder-rightborder-bottomborder-leftmarginpaddingmax-heightmin-heightmax-widthmin-widthoutline-coloroutline-styleoutline-widthPositioningpositiontopbottomrightleftfloatdisplayclearz-indexListlist-style-imagelist-style-typelist-style-positionTablevertical-alignborder-collapseborder-spacingcaption-sideempty-cellstable-layoutEffectstext-shadow-webkit-box-shadowborder-radiusOtheroverflowcursorvisibility -------------- next part -------------- An HTML attachment was scrubbed... URL: From shankarphy at gmail.com Mon Jan 10 17:44:35 2011 From: shankarphy at gmail.com (SANKAR .) Date: Tue, 11 Jan 2011 09:44:35 +1100 Subject: String to char and decimal number conversion Message-ID: Hello There, I am from non IT field also new to python programming.Could you please help me to solve the following problem? I have a list T1 with following format: T1 = [ *' "*Field*" **' , ' "*12.5*" **', ' "*2.5*" ']* * * How do get the list elements without double quote in my output (T2). T2 =[ *' *Field* **' , ' *12.5 *', ' *2.5* ']* Thanks Sankar -------------- next part -------------- An HTML attachment was scrubbed... URL: From ben+python at benfinney.id.au Mon Jan 10 18:00:28 2011 From: ben+python at benfinney.id.au (Ben Finney) Date: Tue, 11 Jan 2011 10:00:28 +1100 Subject: Absolute imports? References: <877heff4fl.fsf@benfinney.id.au> Message-ID: <87y66se54j.fsf@benfinney.id.au> Roy Smith writes: > Ben Finney wrote: > > What is the problem you're trying to solve? It is likely we can > > suggest a better solution. > > Well, the problem I'm trying to solve is that I have an absolute > pathname to a python source file that I want to import as a module :-) And then have it available in the code under what name? It is important to realise that ?import? does many things. Among the many things it does (see the Python documentation for more) it executes the code within a namespace, and then binds that namespace to a name that is specified in the ?import? statement. The filesystem path (if any!) is derived from the name that the module will be bound to within the code. That'w why the indirection of ?sys.path? is necessary: it keeps the mapping between module names and filesystem paths. > The best I can describe how to find the location of the config file is, > "Work your way up the directory tree from where you are now, (i.e. > following '..' links) until you get to the top level of the project, > then from there, it's ./code/configs/autogen/config.py." One way to keep the import mechanism working with that situation would be to: * compute the path: ?config_dir_path = your_algorithm_above()? * add the path to the search list: ?sys.path.append(config_dir_path)? * import the config module: ?import config? The module is then available under the name ?config?. > It's reasonably straight-forward to figure out that absolute path, > starting from sys.argv[0] and using the tools in os.path. Now I need > to import the file, given that I know its absolute pathname. It looks > like imp.load_source() does what I want, I'm just wondering if there's > a cleaner way. I think ?imp.load_source? is not as clean as the steps I describe above, given the rest of the ?import? job that needs to be done. Given that modules in Python form a namespace hierarchy, it's unusual and discouraged to import files from arbitrary parts of the filesystem. -- \ ?I must say that I find television very educational. The minute | `\ somebody turns it on, I go to the library and read a book.? | _o__) ?Groucho Marx | Ben Finney From clp2 at rebertia.com Mon Jan 10 18:02:15 2011 From: clp2 at rebertia.com (Chris Rebert) Date: Mon, 10 Jan 2011 15:02:15 -0800 Subject: String to char and decimal number conversion In-Reply-To: References: Message-ID: On Mon, Jan 10, 2011 at 2:44 PM, SANKAR . wrote: > Hello There, > > ?????? I am from non IT field also new to python programming.Could you > please help me to solve the following problem? > > I have a list T1 with following format: > > T1 = [ ' "Field" ' , ' "12.5" ', ' "2.5" '] > > How do get the list elements without double quote in my output (T2). > > T2 =[ ' Field ' , ' 12.5 ', ' 2.5 '] How are you obtaining T1 in the first place? Cheers, Chris -- http://blog.rebertia.com From clp2 at rebertia.com Mon Jan 10 18:04:01 2011 From: clp2 at rebertia.com (Chris Rebert) Date: Mon, 10 Jan 2011 15:04:01 -0800 Subject: Python use growing fast In-Reply-To: <4d2b8844$0$43996$742ec2ed@news.sonic.net> References: <4d2b8844$0$43996$742ec2ed@news.sonic.net> Message-ID: On Mon, Jan 10, 2011 at 2:29 PM, John Nagle wrote: > On 1/10/2011 1:02 PM, MRAB wrote: >> >> On 10/01/2011 20:29, Dan Stromberg wrote: >>> >>> I invite folks to check out Tiobe's Language Popularity Rankings: >>> >>> http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html > > ? That's somehow derived from web searches, not from any real data > source. ?Look how far down JavaScript is. Also depends on how one defines "popularity" in the context of programming languages. Cheers, Chris From ben+python at benfinney.id.au Mon Jan 10 18:05:16 2011 From: ben+python at benfinney.id.au (Ben Finney) Date: Tue, 11 Jan 2011 10:05:16 +1100 Subject: What INI config file module allows lists of duplicate same-named options? References: <4D29DEF5.2030702@ianhobson.co.uk> <4D2A124A.9000508@ieee.org> <4D2A16D3.4070405@gmail.com> <4D2A1ECA.2090901@aim.com> Message-ID: <87tyhge4wj.fsf@benfinney.id.au> "Thomas L. Shinnick" writes: > Here, I need to list multiple file/dir path pairs. A list of multiple > items to be acted upon in a common way. It is a list. Simple. > Except I can't find a library/pypi module with the obvious extension. What you want is incompatible with calling the result ?an INI file?, because that entails the restrictions you described. You would be better advised to use a configuration format that can do what you want, such as YAML or JSON. Both of those have good Python support; JSON in particular has support in the standard library. -- \ ?Saying that Java is nice because it works on all OSes is like | `\ saying that anal sex is nice because it works on all genders? | _o__) ?http://bash.org/ | Ben Finney From philip at semanchuk.com Mon Jan 10 18:28:29 2011 From: philip at semanchuk.com (Philip Semanchuk) Date: Mon, 10 Jan 2011 18:28:29 -0500 Subject: What INI config file module allows lists of duplicate same-named options? In-Reply-To: <87tyhge4wj.fsf@benfinney.id.au> References: <4D29DEF5.2030702@ianhobson.co.uk> <4D2A124A.9000508@ieee.org> <4D2A16D3.4070405@gmail.com> <4D2A1ECA.2090901@aim.com> <87tyhge4wj.fsf@benfinney.id.au> Message-ID: On Jan 10, 2011, at 6:05 PM, Ben Finney wrote: > "Thomas L. Shinnick" writes: > >> Here, I need to list multiple file/dir path pairs. A list of multiple >> items to be acted upon in a common way. It is a list. Simple. >> Except I can't find a library/pypi module with the obvious extension. > > What you want is incompatible with calling the result ?an INI file?, > because that entails the restrictions you described. I dunno about that. The INI file format isn't standardized so there aren't restrictions on what one can expect to find in an INI file other than people's expectations. I'll grant you that most INI files don't have (or expect) duplicate keys in a section, but I've seen some that do. > You would be better advised to use a configuration format that can do > what you want, such as YAML or JSON. Both of those have good Python > support; JSON in particular has support in the standard library. I second that, and the point above (about there being no standard that governs INI files) is another reason to avoid them. Some INI file libraries expect a hash mark as a comment, some expect semicolon, some make no allowances for non-ASCII encodings, some expect UTF-8 or ISO-8859-1 or Win-1252, some only allow '=' as the key/value separator, some allow other characters. INI files are nice and simple but there's devils in those details. Cheers Philip From ben+python at benfinney.id.au Mon Jan 10 18:40:27 2011 From: ben+python at benfinney.id.au (Ben Finney) Date: Tue, 11 Jan 2011 10:40:27 +1100 Subject: Absolute imports? References: <877heff4fl.fsf@benfinney.id.au> <87y66se54j.fsf@benfinney.id.au> Message-ID: <87pqs4e39w.fsf@benfinney.id.au> Ben Finney writes: > The filesystem path (if any!) is derived from the name that the module > will be bound to within the code. That'w why the indirection of > ?sys.path? is necessary: it keeps the mapping between module names and > filesystem paths. That phrasing gives the wrong impression; ?sys.path? doesn't store that mapping. I meant only that the indirection of ?sys.path? is necessary to allow Python to maintain that mapping at import time. -- \ ?This world in arms is not spending money alone. It is spending | `\ the sweat of its laborers, the genius of its scientists, the | _o__) hopes of its children.? ?Dwight Eisenhower, 1953-04-16 | Ben Finney From shankarphy at gmail.com Mon Jan 10 19:00:10 2011 From: shankarphy at gmail.com (SANKAR .) Date: Tue, 11 Jan 2011 11:00:10 +1100 Subject: String to char and decimal number conversion In-Reply-To: References: Message-ID: Hi Chris , Thanks for your response. I am reading a Test.txt (see atatchment) file using following code to get the T2: F =open('C:\Test.txt','r') T1 = F.readlines() for i in range(len(T1)): T2 = T1[i].split(',') print(T2) Regards Sankar On Tue, Jan 11, 2011 at 10:02 AM, Chris Rebert wrote: > On Mon, Jan 10, 2011 at 2:44 PM, SANKAR . wrote: > > Hello There, > > > > I am from non IT field also new to python programming.Could you > > please help me to solve the following problem? > > > > I have a list T1 with following format: > > > > T1 = [ ' "Field" ' , ' "12.5" ', ' "2.5" '] > > > > How do get the list elements without double quote in my output (T2). > > > > T2 =[ ' Field ' , ' 12.5 ', ' 2.5 '] > > How are you obtaining T1 in the first place? > > Cheers, > Chris > -- > http://blog.rebertia.com > -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: Test.txt URL: From drsalists at gmail.com Mon Jan 10 19:51:17 2011 From: drsalists at gmail.com (Dan Stromberg) Date: Mon, 10 Jan 2011 16:51:17 -0800 Subject: Python use growing fast In-Reply-To: <4d2b8844$0$43996$742ec2ed@news.sonic.net> References: <4d2b8844$0$43996$742ec2ed@news.sonic.net> Message-ID: On Mon, Jan 10, 2011 at 2:29 PM, John Nagle wrote: > On 1/10/2011 1:02 PM, MRAB wrote: >> >> On 10/01/2011 20:29, Dan Stromberg wrote: >>> >>> I invite folks to check out Tiobe's Language Popularity Rankings: >>> >>> http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html > > ? That's somehow derived from web searches, not from any real data > source. ?Look how far down JavaScript is. Please define "real data source", and give examples... ^_^ From tjreedy at udel.edu Mon Jan 10 19:52:01 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Mon, 10 Jan 2011 19:52:01 -0500 Subject: Python use growing fast In-Reply-To: References: <4D2B73D1.6060303@mrabarnett.plus.com> Message-ID: On 1/10/2011 4:43 PM, Alice Bevan?McGregor wrote: > >> It shows an example of Python code, which happens to have 2 syntax >> errors! > > Wikipedia is a Wiki; everyone is free to contribute and correct mistakes. The errors, if there, are in .png and .svg images of a random, unrunnable snippet that will disappear in a week (at least the .png) due to lack of copyright release. A complete example that runs, pulled from the tutorial, would be good. I have no idea how to produce those types of images from code. -- Terry Jan Reedy From linnaweb at gmail.com Mon Jan 10 20:19:10 2011 From: linnaweb at gmail.com (linna li) Date: Mon, 10 Jan 2011 17:19:10 -0800 (PST) Subject: apscheduler error References: <9699865b-a8be-4284-a347-58d875b491f6@n2g2000pre.googlegroups.com> Message-ID: Thank you for all the replies here! I will try your suggestions. On Jan 7, 11:03?pm, Alice Bevan?McGregor wrote: > Howdy! > > On 2011-01-07 17:08:28 -0800, linna li said: > > > I tried to use the apscheduler and used the sample code below from the > > tutorial, but got the error message: Exception in thread APScheduler > > (most likely raised during interpreter shutdown). What's going on here? > > I really appreciate any help! > > After talking a bit with Alex Gr?nholm it seems this is an issue raised > fairly often (not always in the context of this package) and is not > really a problem with APScheduler. ?It has far more to do with > attempting to start a thread, then immediately exiting the main thread. > ?That's not how threading is supposed to be used, so don't do it. ?;) > > APScheduler 2.0 adds some improved examples, according to Alex, that > don't suffer the "problem" demonstrated by the short code snippit you > provided. > > A package of mine, TurboMail, suffers from the same threading issue if > used improperly; you enqueue e-mail, it starts a thread, then you > immediately exit. ?TM tries to work around the issue, but in most cases > that workaround does not work properly. ?(You get strange uncatchable > exceptions printed on stderr though AFIK the e-mail does get sent > correctly, your application may hang waiting for the thread pool to > drain if you have a "minimum thread count" option set.) > > I hope this clears things up a bit, > > ? ? ? ? - Alice. From krzysztof.t.bieniasz at gmail.com Mon Jan 10 20:22:54 2011 From: krzysztof.t.bieniasz at gmail.com (Krzysztof Bieniasz) Date: Tue, 11 Jan 2011 01:22:54 +0000 (UTC) Subject: Python use growing fast References: <4d2b8844$0$43996$742ec2ed@news.sonic.net> Message-ID: > Also depends on how one defines "popularity" in the context of > programming languages. Tiobe quite clearly states what they mean by the name "popularity". Namely the number of Google search results of expressions like "programming X" for X in languages. If no one in the Web writes about programming JavaScript then obviously it's not popular... sort of. From linnaweb at gmail.com Mon Jan 10 20:23:34 2011 From: linnaweb at gmail.com (linna li) Date: Mon, 10 Jan 2011 17:23:34 -0800 (PST) Subject: apscheduler error References: <9699865b-a8be-4284-a347-58d875b491f6@n2g2000pre.googlegroups.com> Message-ID: <8d45d736-8b89-41f0-96d7-66c3c077b670@22g2000prx.googlegroups.com> On Jan 7, 11:03?pm, Alice Bevan?McGregor wrote: > Howdy! > > On 2011-01-07 17:08:28 -0800, linna li said: > > > I tried to use the apscheduler and used the sample code below from the > > tutorial, but got the error message: Exception in thread APScheduler > > (most likely raised during interpreter shutdown). What's going on here? > > I really appreciate any help! > > After talking a bit with Alex Gr?nholm it seems this is an issue raised > fairly often (not always in the context of this package) and is not > really a problem with APScheduler. ?It has far more to do with > attempting to start a thread, then immediately exiting the main thread. > ?That's not how threading is supposed to be used, so don't do it. ?;) > > APScheduler 2.0 adds some improved examples, according to Alex, that > don't suffer the "problem" demonstrated by the short code snippit you > provided. > > A package of mine, TurboMail, suffers from the same threading issue if > used improperly; you enqueue e-mail, it starts a thread, then you > immediately exit. ?TM tries to work around the issue, but in most cases > that workaround does not work properly. ?(You get strange uncatchable > exceptions printed on stderr though AFIK the e-mail does get sent > correctly, your application may hang waiting for the thread pool to > drain if you have a "minimum thread count" option set.) > > I hope this clears things up a bit, > > ? ? ? ? - Alice. I see the latest version is APScheduler 1.3.1. Where can I get APScheduler 2.0? From katie at coderstack.co.uk Mon Jan 10 20:31:15 2011 From: katie at coderstack.co.uk (Katie T) Date: Tue, 11 Jan 2011 01:31:15 +0000 Subject: Python use growing fast In-Reply-To: <4d2b8844$0$43996$742ec2ed@news.sonic.net> References: <4d2b8844$0$43996$742ec2ed@news.sonic.net> Message-ID: On Mon, Jan 10, 2011 at 10:29 PM, John Nagle wrote: > On 1/10/2011 1:02 PM, MRAB wrote: >> >> On 10/01/2011 20:29, Dan Stromberg wrote: >>> >>> I invite folks to check out Tiobe's Language Popularity Rankings: >>> >>> http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html > > ? That's somehow derived from web searches, not from any real data > source. ?Look how far down JavaScript is. Any measure is arbitrary and subject to biases, what methodology would you prefer ? Katie -- CoderStack http://www.coderstack.co.uk/python-jobs The Software Developer Job Board From greno at verizon.net Mon Jan 10 20:37:23 2011 From: greno at verizon.net (Gerry Reno) Date: Mon, 10 Jan 2011 20:37:23 -0500 Subject: Python use growing fast In-Reply-To: References: <4d2b8844$0$43996$742ec2ed@news.sonic.net> Message-ID: <4D2BB453.8030304@verizon.net> On 01/10/2011 08:31 PM, Katie T wrote: > On Mon, Jan 10, 2011 at 10:29 PM, John Nagle wrote: > >> On 1/10/2011 1:02 PM, MRAB wrote: >> >>> On 10/01/2011 20:29, Dan Stromberg wrote: >>> >>>> I invite folks to check out Tiobe's Language Popularity Rankings: >>>> >>>> http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html >>>> >> That's somehow derived from web searches, not from any real data >> source. Look how far down JavaScript is. >> > Any measure is arbitrary and subject to biases, what methodology would > you prefer ? > > > Katie > Measuring the "Buzz" about a language is actually a pretty good way to gauge its popularity. . From drsalists at gmail.com Mon Jan 10 22:24:44 2011 From: drsalists at gmail.com (Dan Stromberg) Date: Mon, 10 Jan 2011 19:24:44 -0800 Subject: Python use growing fast In-Reply-To: References: <4d2b8844$0$43996$742ec2ed@news.sonic.net> Message-ID: On Mon, Jan 10, 2011 at 5:22 PM, Krzysztof Bieniasz wrote: >> Also depends on how one defines "popularity" in the context of >> programming languages. > > Tiobe quite clearly states what they mean by the name "popularity". > Namely the number of Google search results of expressions like > "programming X" for X in languages. If no one in the Web writes about > programming JavaScript then obviously it's not popular... sort of. > -- > http://mail.python.org/mailman/listinfo/python-list > About JavaScript's popularity: 1) I've been getting the impression that JavaScript is popular in a manner similar to how x86 machine language is popular: That is, it's used all over, but few people hand code it (though admittedly, there are probably more people hand coding JavaScript than people hand coding x86 assembler today) 2) JavaScript seems widely considered a bit of a mess, and yet, many tools make use of it because it's in almost all web browsers 3) It seems that when JavaScript does get used directly, it tends to be done in small snippets, like inline assembler in C or C++ 4) It appears that there is quite a few different tools (one of them, our own Pyjamas, and to a lesser extent, Django - and of course GWT though that's only tenuously related to Python through Pyjamas) that attempt to take the pain out of writing JavaScript IOW, I'm not convinced that Tiobe's ranking of JavaScript is inaccurate, or even weakly correlated with reality. From kb1pkl at aim.com Mon Jan 10 22:28:25 2011 From: kb1pkl at aim.com (Corey Richardson) Date: Mon, 10 Jan 2011 22:28:25 -0500 Subject: Python use growing fast In-Reply-To: References: <4d2b8844$0$43996$742ec2ed@news.sonic.net> Message-ID: <4D2BCE59.2040204@aim.com> On 01/10/2011 10:24 PM, Dan Stromberg wrote: > On Mon, Jan 10, 2011 at 5:22 PM, Krzysztof Bieniasz > wrote: >>> Also depends on how one defines "popularity" in the context of >>> programming languages. >> >> Tiobe quite clearly states what they mean by the name "popularity". >> Namely the number of Google search results of expressions like >> "programming X" for X in languages. If no one in the Web writes about >> programming JavaScript then obviously it's not popular... sort of. >> -- >> http://mail.python.org/mailman/listinfo/python-list >> > > About JavaScript's popularity: > 1) I've been getting the impression that JavaScript is popular in a > manner similar to how x86 machine language is popular: That is, it's > used all over, but few people hand code it (though admittedly, there > are probably more people hand coding JavaScript than people hand > coding x86 assembler today) > 2) JavaScript seems widely considered a bit of a mess, and yet, many > tools make use of it because it's in almost all web browsers > 3) It seems that when JavaScript does get used directly, it tends to > be done in small snippets, like inline assembler in C or C++ > 4) It appears that there is quite a few different tools (one of them, > our own Pyjamas, and to a lesser extent, Django - and of course GWT > though that's only tenuously related to Python through Pyjamas) that > attempt to take the pain out of writing JavaScript > > IOW, I'm not convinced that Tiobe's ranking of JavaScript is > inaccurate, or even weakly correlated with reality. The biggest use of JavaScript I've seen is browser-based games using them for some display magic, windows popping up etc. Their back-end is still VB.NET (or x framework), and none of the lifting is done by JavaScript. From alice at gothcandy.com Mon Jan 10 22:46:33 2011 From: alice at gothcandy.com (=?utf-8?Q?Alice_Bevan=E2=80=93McGregor?=) Date: Mon, 10 Jan 2011 19:46:33 -0800 Subject: apscheduler error References: <9699865b-a8be-4284-a347-58d875b491f6@n2g2000pre.googlegroups.com> <8d45d736-8b89-41f0-96d7-66c3c077b670@22g2000prx.googlegroups.com> Message-ID: On 2011-01-10 17:23:34 -0800, linna li said: > I see the latest version is APScheduler 1.3.1. Where can I get APScheduler 2.0? https://bitbucket.org/agronholm/apscheduler/ I don't think 2.0 has been released yet, but that is the version number in apscheduler/__init__.py on HG tip. The examples, BTW, just add time.sleep() calls. ;) - Alice. From roy at panix.com Mon Jan 10 22:49:47 2011 From: roy at panix.com (Roy Smith) Date: Mon, 10 Jan 2011 22:49:47 -0500 Subject: Python use growing fast References: <4d2b8844$0$43996$742ec2ed@news.sonic.net> Message-ID: In article , Dan Stromberg wrote: > About JavaScript's popularity: > 1) I've been getting the impression that JavaScript is popular in a > manner similar to how x86 machine language is popular: That is, it's > used all over, but few people hand code it (though admittedly, there > are probably more people hand coding JavaScript than people hand > coding x86 assembler today) One of the surprising (to me, anyway) uses of JavaScript is as the scripting language for MongoDB (http://www.mongodb.org/). From ameyer2 at yahoo.com Mon Jan 10 22:50:55 2011 From: ameyer2 at yahoo.com (Alan Meyer) Date: Mon, 10 Jan 2011 22:50:55 -0500 Subject: String to char and decimal number conversion In-Reply-To: References: Message-ID: <4D2BD39F.9080802@yahoo.com> On 1/10/2011 6:02 PM, Chris Rebert wrote: > On Mon, Jan 10, 2011 at 2:44 PM, SANKAR . wrote: >> Hello There, >> >> I am from non IT field also new to python programming.Could you >> please help me to solve the following problem? >> >> I have a list T1 with following format: >> >> T1 = [ ' "Field" ' , ' "12.5" ', ' "2.5" '] >> >> How do get the list elements without double quote in my output (T2). >> >> T2 =[ ' Field ' , ' 12.5 ', ' 2.5 '] This will do it: ------------------------------------------------ T1 = [ ' "Field" ' , ' "12.5" ', ' "2.5" '] T2 = [] for t in T1: T2.append(t.replace('"', '')) ------------------------------------------------ The "replace" function acts on each element in T1, replacing every double quote with nothing. We then append that to the new list T2. Alan From wx1234 at gmail.com Mon Jan 10 23:42:17 2011 From: wx1234 at gmail.com (dubux) Date: Mon, 10 Jan 2011 20:42:17 -0800 (PST) Subject: importing modules dynamicly Message-ID: <3c6f5e1e-2f0a-46a3-a99e-8b3eb4fcb063@30g2000yql.googlegroups.com> I am trying to import modules dynamicly from a directory (modules/) in which i have __init__.py with the __all__ variable set. Everything imports correctly and I have verified this however I am stuck on actually using my classes in the dynamicly imported modules. this bit is in my main.py (or base script) to import the modules in the modules/ directory: loaded_modules = [] for item in modules: if item == '__init__.py': pass else: if item.endswith('.py'): __import__('modules.' + item[0:len(item) - 3]) loaded_modules.append(item[0:len(item) - 3]) else: pass After loading all the modules, i try to do something like: instance = modules.modulename.class() And I get an AttributeError. What am I doing wrong here? Help please!! From data.2 at rediff.com Tue Jan 11 00:07:10 2011 From: data.2 at rediff.com (gaurav) Date: Mon, 10 Jan 2011 21:07:10 -0800 (PST) Subject: You can get careers in Management work. Message-ID: <9a905ba5-12cc-4847-847f-5a64851f927a@e20g2000vbn.googlegroups.com> Great careers in Management work. Management careers bases. http://topcareer.webs.com/executivemanager.htm http://rojgars1.webs.com/gov.htm From sohail at stupidcomputing.com Tue Jan 11 00:18:41 2011 From: sohail at stupidcomputing.com (Sohail) Date: Mon, 10 Jan 2011 21:18:41 -0800 (PST) Subject: Ideas for a module to process command line arguments Message-ID: Hey, every body has their own favorite method/ways to process command line arguments. I've worked on a little CPython extension to handle command line arguments may be you'll find it interesting and useful.... To download the source code.... http://www.stupidcomputing.com/page.php?id=argsv Thank you. From shankarphy at gmail.com Tue Jan 11 00:50:22 2011 From: shankarphy at gmail.com (SANKAR .) Date: Tue, 11 Jan 2011 16:50:22 +1100 Subject: String to char and decimal number conversion In-Reply-To: <4D2BD39F.9080802@yahoo.com> References: <4D2BD39F.9080802@yahoo.com> Message-ID: Thanks Alan! -Sankar On Tue, Jan 11, 2011 at 2:50 PM, Alan Meyer wrote: > On 1/10/2011 6:02 PM, Chris Rebert wrote: > >> On Mon, Jan 10, 2011 at 2:44 PM, SANKAR . wrote: >> >>> Hello There, >>> >>> >>> I am from non IT field also new to python programming.Could you >>> please help me to solve the following problem? >>> >>> I have a list T1 with following format: >>> >>> T1 = [ ' "Field" ' , ' "12.5" ', ' "2.5" '] >>> >>> How do get the list elements without double quote in my output (T2). >>> >>> T2 =[ ' Field ' , ' 12.5 ', ' 2.5 '] >>> >> > This will do it: > ------------------------------------------------ > > T1 = [ ' "Field" ' , ' "12.5" ', ' "2.5" '] > T2 = [] > for t in T1: > T2.append(t.replace('"', '')) > ------------------------------------------------ > > The "replace" function acts on each element in T1, replacing every double > quote with nothing. We then append that to the new list T2. > > Alan > -- > http://mail.python.org/mailman/listinfo/python-list > -------------- next part -------------- An HTML attachment was scrubbed... URL: From steve+comp.lang.python at pearwood.info Tue Jan 11 01:11:00 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 11 Jan 2011 06:11:00 GMT Subject: importing modules dynamicly References: <3c6f5e1e-2f0a-46a3-a99e-8b3eb4fcb063@30g2000yql.googlegroups.com> Message-ID: <4d2bf473$0$30004$c3e8da3$5496439d@news.astraweb.com> On Mon, 10 Jan 2011 20:42:17 -0800, dubux wrote: > After loading all the modules, i try to do something like: > > instance = modules.modulename.class() No you don't. class is a reserved word in Python, you would get a SyntaxError if you did that. Please post the error you get, including the complete traceback, showing the line of code that fails. Copy and paste the *actual* message in full, don't retype it from memory, paraphrase it, simplify it, translate it into Swahili, or otherwise change it in anyway. -- Steven From alice at gothcandy.com Tue Jan 11 02:25:55 2011 From: alice at gothcandy.com (=?utf-8?Q?Alice_Bevan=E2=80=93McGregor?=) Date: Mon, 10 Jan 2011 23:25:55 -0800 Subject: Ideas for a module to process command line arguments References: Message-ID: On 2011-01-10 21:18:41 -0800, Sohail said: > Hey, every body has their own favorite method/ways to process command > line arguments. I've worked on a little CPython extension to handle > command line arguments may be you'll find it interesting and useful.... Even I've implemented my own way to handle command-line scripts, marrow.script: https://github.com/pulp/marrow.script The idea with mine that you write a Python function... and that's it. The latest version has experimental support for class-based "subcommand" dispatch, but it needs work, needs to be updated to support sub-sub commands, and the help text generator needs to be overhauled to support classes properly. The argument list, typecasting, etc. is built from the argspec. Help text is pulled from the docstring. Decorators are provided to override short names, define explicit callbacks or typecasting functions, etc. I got tired of using PasteScript and OptParse. Mostly OptParse, actually. :/ - Alice. From orasnita at gmail.com Tue Jan 11 02:37:49 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Tue, 11 Jan 2011 09:37:49 +0200 Subject: Python use growing fast References: <4d2b8844$0$43996$742ec2ed@news.sonic.net> <4D2BB453.8030304@verizon.net> Message-ID: <08AA70425ADB4D99A8054A7F33141B76@octavian> From: "Gerry Reno" > On 01/10/2011 08:31 PM, Katie T wrote: >> On Mon, Jan 10, 2011 at 10:29 PM, John Nagle wrote: >> >>> On 1/10/2011 1:02 PM, MRAB wrote: >>> >>>> On 10/01/2011 20:29, Dan Stromberg wrote: >>>> >>>>> I invite folks to check out Tiobe's Language Popularity Rankings: >>>>> >>>>> http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html >>>>> >>> That's somehow derived from web searches, not from any real data >>> source. Look how far down JavaScript is. >>> >> Any measure is arbitrary and subject to biases, what methodology would >> you prefer ? >> >> >> Katie >> > > Measuring the "Buzz" about a language is actually a pretty good way to > gauge its popularity. Well, not exactly. C and C++ are older than many other languages and probably many of the web pages that contain "programming C" are very old and don't reflect their current popularity. On the other hand, newer languages are more attractive for book publishers because they can sell more books about Ruby than about C, because for C there are already very many books written so there is a bigger intrest to promote the newer languages, not just because they are better, but because there are interests involved. Talking about interests, Java and DotNet are more popular than many other languages, but we all know why, and we also know why PHP has such a big success although it is a bad language, as we all know why Window has a bigger success than other operating systems... so the popularity contest is good, but for something else than we want to prove. A programming language popularity contest is like a beauty contest for finding the most intelligent girl. Octavian From stefan_ml at behnel.de Tue Jan 11 02:47:26 2011 From: stefan_ml at behnel.de (Stefan Behnel) Date: Tue, 11 Jan 2011 08:47:26 +0100 Subject: Resolve circular reference In-Reply-To: <55db55e9-539a-4f36-a84f-5199500cd909@k30g2000vbn.googlegroups.com> References: <1718ea91-fc4e-49f3-a15a-bdc683789126@k22g2000yqh.googlegroups.com> <353ecd61-22f8-4770-be30-29cb76b0f6b0@t35g2000yqj.googlegroups.com> <2349f7d4-2b85-456f-96b5-140f15548859@v17g2000prc.googlegroups.com> <1e7f6338-33ff-488e-9182-b31498babe0b@c39g2000yqi.googlegroups.com> <429e3e67-9732-4f82-9f97-99ed5aeb1f74@r8g2000prm.googlegroups.com> <451b9057-609a-4b1d-a064-62e738267084@e4g2000vbg.googlegroups.com> <55db55e9-539a-4f36-a84f-5199500cd909@k30g2000vbn.googlegroups.com> Message-ID: moerchendiser2k3, 10.01.2011 22:19: > On Jan 10, 7:18 pm, Stefan Behnel wrote: >> moerchendiser2k3, 10.01.2011 18:55: >> >>>> If you can tell us why it's so important that the object be destroyed >>>> at that given time, even while a reference to it exists, maybe we can >>>> give you better suggestions. >> >>> Thanks for your answer! In my case the types A and B (in my example >>> above) >>> are a dialog and a dialog widget. At a special time I have to close >>> and >>> destroy all dialogs but this does not happen because the widget keeps >>> the dialog alive. I have the reference to the dialog >>> but after I closed the dialogs I also would like to destroy them >>> because they have to free some special ressources. >> >> Objects within a reference cycle will eventually get cleaned up, just not >> right away and not in a predictable order. >> >> If you need immediate cleanup, you should destroy the reference cycle >> yourself, e.g. by removing the widgets from the dialog when closing it. >> >> Stefan > > The PyWidget type does not own the widget, it just points to it. I > have an idea, would this fix the problem? > > I destroy the internal dictionary of the dialog which points to other > PyObjects? Then I would cut the dependency. Sure, that should work. Stefan From michele.simionato at gmail.com Tue Jan 11 03:32:32 2011 From: michele.simionato at gmail.com (Michele Simionato) Date: Tue, 11 Jan 2011 00:32:32 -0800 (PST) Subject: Ideas for a module to process command line arguments References: Message-ID: On Jan 11, 8:25?am, Alice Bevan?McGregor wrote: explicit callbacks or typecasting functions, etc. > > I got tired of using PasteScript and OptParse. ?Mostly OptParse, actually. ?:/ It's a pity that the argument parsing modules in the standard library are so verbose that everybody is reinventing the same thing :-( It looks like you have reinvented plac: http://pypi.python.org/pypi/plac From wander.lairson at gmail.com Tue Jan 11 04:42:28 2011 From: wander.lairson at gmail.com (wander.lairson) Date: Tue, 11 Jan 2011 07:42:28 -0200 Subject: ctypes and cygwin Message-ID: Hello, I was trying to use the libusb 1.0 with cygwin environments and noticed that this library uses stdcall calling convention, but ctypes does not have WinDLL object for cygwin. As far as I know, libusb builds with stdcall calling convention on cygwin by default. My question is if ctypes should have WinDLL in cygwin or cygwin, as a kind of emulation of Unix, considers everything to be cdecl and libusb guys should change their default build behavior in cygwin. Not sure if this is the right place to ask this question, but if ctypes guy(s) took out WinDLL from cygwin, I believe he (they) had a good reason to do so... -- Best Regards, Wander Lairson Costa LCoN - Laborat?rio de Computa??o Natural - Natural Computing Laboratory (http://www.mackenzie.com.br/lcon.html) Programa de P?s-Gradua??o em Engenharia El?trica (PPGEE) Faculdade de Computa??o e Inform?tica (FCI) Universidade Presbiteriana Mackenzie - SP - Brazil From ddasilva at umd.edu Tue Jan 11 04:43:52 2011 From: ddasilva at umd.edu (Daniel da Silva) Date: Tue, 11 Jan 2011 04:43:52 -0500 Subject: Parsing string for " " Message-ID: Hi, I have come across a task where I would like to scan a short 20-80 character line of text for instances of " ". Ideally could be of any tense. I know quite a bit of programming and computer science, but computational linguistics is relatively new to me. If anyone can point me in the right direction, I would be very thankful! Cheers, Daniel -------------- next part -------------- An HTML attachment was scrubbed... URL: From davishbhardwaj1986 at gmail.com Tue Jan 11 05:41:50 2011 From: davishbhardwaj1986 at gmail.com (Davish Bhardwaj) Date: Tue, 11 Jan 2011 02:41:50 -0800 (PST) Subject: String to char and decimal number conversion References: Message-ID: <5a568ba8-fca5-4d3e-bd05-ca3c865cfa31@fo10g2000vbb.googlegroups.com> On Jan 11, 4:02?am, Chris Rebert wrote: > On Mon, Jan 10, 2011 at 2:44 PM, SANKAR . wrote: > > Hello There, > > > ?????? I am from non IT field also new to python programming.Could you > > please help me to solve the following problem? > > > I have a list T1 with following format: > > > T1 = [ ' "Field" ' , ' "12.5" ', ' "2.5" '] > > > How do get the list elements without double quote in my output (T2). > > > T2 =[ ' Field ' , ' 12.5 ', ' 2.5 '] > > How are you obtaining T1 in the first place? > > Cheers, > Chris > --http://blog.rebertia.com You can also do it like : T1 = [ ' "Field" ' , ' "12.5" ', ' "2.5" '] T2 = [t.replace('"', '') for t in T1] This seems to me a more better and fast code ;) Davish From jeanmichel at sequans.com Tue Jan 11 06:14:18 2011 From: jeanmichel at sequans.com (Jean-Michel Pichavant) Date: Tue, 11 Jan 2011 12:14:18 +0100 Subject: importing modules dynamicly In-Reply-To: <3c6f5e1e-2f0a-46a3-a99e-8b3eb4fcb063@30g2000yql.googlegroups.com> References: <3c6f5e1e-2f0a-46a3-a99e-8b3eb4fcb063@30g2000yql.googlegroups.com> Message-ID: <4D2C3B8A.408@sequans.com> dubux wrote: > I am trying to import modules dynamicly from a directory (modules/) in > which i have __init__.py with the __all__ variable set. Everything > imports correctly and I have verified this however I am stuck on > actually using my classes in the dynamicly imported modules. > > this bit is in my main.py (or base script) to import the modules in > the modules/ directory: > > loaded_modules = [] > for item in modules: > if item == '__init__.py': pass > else: > if item.endswith('.py'): > __import__('modules.' + item[0:len(item) - 3]) > loaded_modules.append(item[0:len(item) - 3]) > else: pass > > After loading all the modules, i try to do something like: > > instance = modules.modulename.class() > > And I get an AttributeError. What am I doing wrong here? Help please!! > > Your code is rather strange, 'modules' looks to be a list or some iterable, and then you expect to have a 'modulename' attribute or something... My guess is that you pasted an approximative translation of your code which makes it impossible de debug. Here is a possible way of importing a bunch of python files: loaded_modules = {} fileNames = os.listdir('./modules') pyFiles = [os.path.basename(name).replace('.py', '') for name in fileNames if name.endswith('.py')] for pyFile in pyFiles: loaded_modules[pyFile] = __import__('modules.%s' % pyFile) # how to get a class named 'AClassName' defined in then modules for module in loaded_modules: myClass = getattr(loaded_modules[module], 'AClassName', None) print myClass if myClass: myInstance = myClass() JM From wiz1024 at gmail.com Tue Jan 11 06:18:27 2011 From: wiz1024 at gmail.com (wiz1024 wiz1024) Date: Tue, 11 Jan 2011 12:18:27 +0100 Subject: "socket operation on non socket" on Windows Message-ID: Hi I have a problem on Windows with the module urllib2 with python 2.5 when i use the "urlopen" function, i have some time the following error : error I don't understand why suddenly this error arrives The urlopen function is called from a thread Thanks in advance. -------------- next part -------------- An HTML attachment was scrubbed... URL: From jurko.gospodnetic at pke.hr Tue Jan 11 06:35:50 2011 From: jurko.gospodnetic at pke.hr (=?windows-1250?Q?Jurko_Gospodneti=E6?=) Date: Tue, 11 Jan 2011 12:35:50 +0100 Subject: os.path.realpath() and os.path.abspath() Message-ID: Hi all. os.path.realpath() documentation states that it returns a 'canonical' path. Does that infer that it returns an absolute path? I have not found seen any implementation that does not return an absolute path, but can this be counted on? Or should we use os.path.abspath(os.path.realpath(x)) when we want to convert x to its full/canonical name? Best regards, Jurko Gospodneti? From jldunn2000 at gmail.com Tue Jan 11 06:42:28 2011 From: jldunn2000 at gmail.com (loial) Date: Tue, 11 Jan 2011 03:42:28 -0800 (PST) Subject: PJL References: <19d28e76-6085-42b5-a98f-7bf40591910f@f35g2000vbl.googlegroups.com> <44a7123a-52e7-4c34-adba-d9cf19985899@u9g2000pra.googlegroups.com> Message-ID: Thank you. I was able to send the following PJL to the printer and it worked. @PJL STMSG DISPLAY = "Hello from John" Do you have any experience handling PJL responses from the printer?...What I really want to do is get PJL information back from the printer and read it in python(or some other Unix scripting tool) From ben+python at benfinney.id.au Tue Jan 11 07:21:20 2011 From: ben+python at benfinney.id.au (Ben Finney) Date: Tue, 11 Jan 2011 23:21:20 +1100 Subject: Asking for help with code? Post a minimal working example. (was: importing modules dynamicly) References: <3c6f5e1e-2f0a-46a3-a99e-8b3eb4fcb063@30g2000yql.googlegroups.com> Message-ID: <877hebeim7.fsf_-_@benfinney.id.au> Jean-Michel Pichavant writes: > Your code is rather strange, 'modules' looks to be a list or some > iterable, and then you expect to have a 'modulename' attribute or > something... > My guess is that you pasted an approximative translation of your code > which makes it impossible de debug. To the OP: It is often a good idea to simplify one's code when asking for help. That will make it easier to understand. But don't simplify to the point where the code doesn't actually run, or doesn't demonstrate the behaviour you're reporting! Instead, post a minimal working example of the thing you want explained. To discuss the code and present advice, people will want to run your code for themselves to see what you're seeing, or as close as they can get. Make that easier for them by ensuring your example actually does what you say it does. -- \ ?I prayed for twenty years but received no answer until I | `\ prayed with my legs.? ?Frederick Douglass, escaped slave | _o__) | Ben Finney From stefan_ml at behnel.de Tue Jan 11 08:08:07 2011 From: stefan_ml at behnel.de (Stefan Behnel) Date: Tue, 11 Jan 2011 14:08:07 +0100 Subject: String to char and decimal number conversion In-Reply-To: References: Message-ID: SANKAR ., 11.01.2011 01:00: > I am reading a Test.txt (see atatchment) file using following code to get > the T2: > > F =open('C:\Test.txt','r') > T1 = F.readlines() > for i in range(len(T1)): > T2 = T1[i].split(',') > print(T2) Take a look at the "csv" module in the standard library. Stefan From alice at gothcandy.com Tue Jan 11 09:37:28 2011 From: alice at gothcandy.com (=?utf-8?Q?Alice_Bevan=E2=80=93McGregor?=) Date: Tue, 11 Jan 2011 06:37:28 -0800 Subject: Ideas for a module to process command line arguments References: Message-ID: On 2011-01-11 00:32:32 -0800, Michele Simionato said: > On Jan 11, 8:25?am, Alice Bevan?McGregor wrote: >> I got tired of using PasteScript and OptParse. ?Mostly OptParse, actually. ?:/ > > It's a pity that the argument parsing modules in the standard library > are so verbose that everybody is reinventing the same thing :-( It > looks like you have reinvented plac: http://pypi.python.org/pypi/plac And a package called `commandline`. There are many command line parsing modules, many of which are unmaintained, few have reached 1.0. My criteria for 1.0? 100% unit test coverage, complete documentation, compatibility with 2.6+ and 3.1+ within a single package. marrow.script meets that criteria, do the others? :) - Alice. From alice at gothcandy.com Tue Jan 11 10:06:20 2011 From: alice at gothcandy.com (=?utf-8?Q?Alice_Bevan=E2=80=93McGregor?=) Date: Tue, 11 Jan 2011 07:06:20 -0800 Subject: Ideas for a module to process command line arguments References: Message-ID: On 2011-01-11 00:32:32 -0800, Michele Simionato said: > It's a pity that the argument parsing modules in the standard library > are so verbose that everybody is reinventing the same thing :-( It > looks like you have reinvented plac: http://pypi.python.org/pypi/plac After looking into it, Plac's default help display isn't very helpful; you need to massage your application a fair amount before generating nice, complete-looking argument lists and such. For example: def main(verbose: ('prints more info', 'flag', 'v'), dsn: 'connection string'): @annotate(dsn="connection string", verbose="prints more info") def main(dsn, verbose=False): The latter is marrow.script, and even without the annotation a more complete help text is generated. The -v and flag nature are assumed from the first unique character and default value. (Flags, when present on the command line, invert the default value.) Py3k annotations haven't been implemented yet, though. Also included is an easy way to simulte command-line execution (i.e. by reading arguments passed by hand and by returning the exit code, vs. reading sys.argv and calling sys.exit()) for unit testing purposes. Plac appears (from the documentation) to be written on top of argparse. :( - Alice. From michele.simionato at gmail.com Tue Jan 11 10:49:36 2011 From: michele.simionato at gmail.com (Michele Simionato) Date: Tue, 11 Jan 2011 07:49:36 -0800 (PST) Subject: Ideas for a module to process command line arguments References: Message-ID: <941cfb0b-e34b-4d07-8c51-293656878f6a@z19g2000yqb.googlegroups.com> On Jan 11, 4:06?pm, Alice Bevan?McGregor wrote: > Plac appears (from the documentation) to be written on top of argparse. > ?:( And the problem with that being what? From jeanmichel at sequans.com Tue Jan 11 11:22:10 2011 From: jeanmichel at sequans.com (Jean-Michel Pichavant) Date: Tue, 11 Jan 2011 17:22:10 +0100 Subject: Ideas for a module to process command line arguments In-Reply-To: <941cfb0b-e34b-4d07-8c51-293656878f6a@z19g2000yqb.googlegroups.com> References: <941cfb0b-e34b-4d07-8c51-293656878f6a@z19g2000yqb.googlegroups.com> Message-ID: <4D2C83B2.7030808@sequans.com> Michele Simionato wrote: > On Jan 11, 4:06 pm, Alice Bevan?McGregor wrote: > >> Plac appears (from the documentation) to be written on top of argparse. >> :( >> > > And the problem with that being what? > ... not available to python 2.5 / 2.6 users :) JM From michele.simionato at gmail.com Tue Jan 11 11:26:40 2011 From: michele.simionato at gmail.com (Michele Simionato) Date: Tue, 11 Jan 2011 08:26:40 -0800 (PST) Subject: Ideas for a module to process command line arguments References: <941cfb0b-e34b-4d07-8c51-293656878f6a@z19g2000yqb.googlegroups.com> Message-ID: <8dd04926-2ad2-4c01-b9e7-5843e801852f@39g2000yqa.googlegroups.com> On Jan 11, 5:22?pm, Jean-Michel Pichavant wrote: > Michele Simionato wrote: > > On Jan 11, 4:06 pm, Alice Bevan McGregor wrote: > > >> Plac appears (from the documentation) to be written on top of argparse. > >> ?:( > > > And the problem with that being what? > > ... not available to python 2.5 / 2.6 users :) > > JM In that case easy_install/pip/whatever will install the dependency automatically (who is installing dependencies by hand nowadays?). More seriously I thought being based on a solid module which is also part of the standard library (for Python 2.7+) was an asset of plac. From jtim.arnold at gmail.com Tue Jan 11 11:55:28 2011 From: jtim.arnold at gmail.com (Tim) Date: Tue, 11 Jan 2011 08:55:28 -0800 (PST) Subject: os.system and loggers References: <70ac3463-cf3c-4435-909b-ac044bef7e41@z9g2000yqz.googlegroups.com> <285801ef-7e26-4c40-a307-3c6eb5314b82@z17g2000prz.googlegroups.com> Message-ID: On Jan 10, 1:01?pm, Carl Banks wrote: > On Jan 10, 8:29?am, Tim wrote: > > > > > > > > > > > On Jan 7, 11:24?am, Tim wrote: > > > > hi, I'm using a 3rd-party python program that uses the python logging > > > facility and also makes calls to os.system. I'm trying to capture its > > > output to a file. > > > > In my own code, I've taken control of the loggers that are setup in > > > the other program by removing its StreamHandler and replacing with > > > FileHander. But when it comes to the call to os.system I'm at a loss. > > > > I want to capture the stdout from that os.system call in my > > > FileHandler. I thought this might work, before I call the other > > > program's class/method: > > > sys.stdout = getLogger('status').handlers[0].stream > > > > but no dice. Is there any clean way to get what I want? If not, I > > > guess I'll override the other method with my own, but it will > > > basically be a bunch of code copied with os.sytem replaced with > > > subprocess, using getLogger('status').handlers[0].stream for stdout/ > > > stderr. > > > > thanks, > > > --Tim Arnold > > > Replying to my own post.... > > > I think I may have included too much fluff in my original question. > > The main thing I wonder is whether I can attach a log handler to > > stdout in such a way that os.system calls will write to that handler > > instead of the console. > > No, but you could replace os.system with something that does work. > (It would replace it globally for all uses, so you may need some logic > to decide whether to leave the call alone, or to modify it, perhaps by > inspecting the call stack.) > > The simplest thing to do is to append a shell redirection to the > command (>/your/log/file), so something like this: > > _real_os_system = os.system > > def my_os_system(cmd): > ? ? if test_log_condition: > ? ? ? ? return _real_os_system(cmd + "2> /my/log/file") > ? ? return _real_os_system(cmd) > > os.system = my_os_system > > That could backfire for any number of reasons so you probably should > only do this if you know that it works with all the commands it > issues. > > The better way might be to call the subprocess module instead, where > you can dispatch the command with redirection to any stream. ?I doubt > there's a foolproof way to do that given an arbitrary os.system > command, but the subprocess way is probably safer. > > Carl Banks Thanks Carl. I will use subprocess. I made this little toy example to prove to myself that subprocess does handle a filehandler stream, so I include it here for completeness' sake: import subprocess,logging,shlex # create the logger, filehandler and get the stream log = logging.getLogger('mytest') fh = logging.FileHandler('mytest.log') log.addHandler(fh) log.setLevel(logging.INFO) mylog = logging.getLogger('mytest').handlers[0].stream # write a test line to the log log.info('my first line') # execute the subprocess using the stream as stdout cmd = 'ls -l' p = subprocess.Popen(shlex.split(cmd),stdout=mylog) # if you don't wait(), the output won't be necessarily in chronological order. r = p.wait() # write a last test line to the log log.info('done %s'% r) and it works as expected. thanks, --Tim Arnold From tjreedy at udel.edu Tue Jan 11 12:04:20 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Tue, 11 Jan 2011 12:04:20 -0500 Subject: "socket operation on non socket" on Windows In-Reply-To: References: Message-ID: On 1/11/2011 6:18 AM, wiz1024 wiz1024 wrote: > Hi > > I have a problem on Windows with the module urllib2 with python 2.5 > > when i use the "urlopen" function, i have some time the following error : > error > > I don't understand why suddenly this error arrives > The urlopen function is called from a thread Give us both the failing call and the complete copy-and-pasted traceback. -- Terry Jan Reedy From wiz1024 at gmail.com Tue Jan 11 12:16:31 2011 From: wiz1024 at gmail.com (wiz1024 wiz1024) Date: Tue, 11 Jan 2011 18:16:31 +0100 Subject: "socket operation on non socket" on Windows In-Reply-To: References: Message-ID: 2011/1/11 Terry Reedy > On 1/11/2011 6:18 AM, wiz1024 wiz1024 wrote: > >> Hi >> >> I have a problem on Windows with the module urllib2 with python 2.5 >> >> when i use the "urlopen" function, i have some time the following error : >> error >> >> I don't understand why suddenly this error arrives >> The urlopen function is called from a thread >> > > Give us both the failing call and the complete copy-and-pasted traceback. > > the failing call is urlopen I investigate a little and it seams that the problem is cause by the function connect of httplib I have the following traceback with log level debug connect: (10.42.1.116, 1111) connect fail: ('10.42.1.116', 1111) File "W:\david\OvdServer\ovd\SMRequestManager.py", line 145, in do_open h.request(req.get_method(), req.get_selector(), req.data, headers) File "C:\Python25\lib\httplib.py", line 866, in request self._send_request(method, url, body, headers) File "C:\Python25\lib\httplib.py", line 889, in _send_request self.endheaders() File "C:\Python25\lib\httplib.py", line 860, in endheaders self._send_output() File "C:\Python25\lib\httplib.py", line 732, in _send_output self.send(msg) File "C:\Python25\lib\httplib.py", line 699, in send self.connect() File "C:\Python25\lib\httplib.py", line 683, in connect raise socket.error, msg (10038, 'Socket operation on non-socket') best regard. David. > -- > Terry Jan Reedy > > -- > http://mail.python.org/mailman/listinfo/python-list > -------------- next part -------------- An HTML attachment was scrubbed... URL: From termim at gmail.com Tue Jan 11 12:57:32 2011 From: termim at gmail.com (Mike) Date: Tue, 11 Jan 2011 09:57:32 -0800 (PST) Subject: Ideas for a module to process command line arguments References: <941cfb0b-e34b-4d07-8c51-293656878f6a@z19g2000yqb.googlegroups.com> <8dd04926-2ad2-4c01-b9e7-5843e801852f@39g2000yqa.googlegroups.com> Message-ID: On Jan 11, 11:26?am, Michele Simionato wrote: > > In that case easy_install/pip/whatever will install the dependency > automatically (who is installing > dependencies by hand nowadays?). More seriously I thought being based I do. Is this bad? :} From jlconlin at gmail.com Tue Jan 11 15:53:02 2011 From: jlconlin at gmail.com (Jeremy) Date: Tue, 11 Jan 2011 12:53:02 -0800 (PST) Subject: Convert unicode escape sequences to unicode in a file Message-ID: I have a file that has unicode escape sequences, i.e., J\u00e9r\u00f4me and I want to replace all of them in a file and write the results to a new file. The simple script I've created is copied below. However, I am getting the following error: UnicodeEncodeError: 'ascii' codec can't encode character u'\xe9' in position 947: ordinal not in range(128) It appears that the data isn't being converted when writing to the file. Can someone please help? Thanks, Jeremy if __name__ == "__main__": f = codecs.open(filename, 'r', 'unicode-escape') lines = f.readlines() line = ''.join(lines) f.close() utFound = re.sub('STRINGDECODE\((.+?)\)', r'\1', line) print(utFound[:1000]) o = open('newDice.sql', 'w') o.write(utFound.decode('utf-8')) o.close() From SegundoBob at earthlink.net Tue Jan 11 17:30:40 2011 From: SegundoBob at earthlink.net (SegundoBob) Date: Tue, 11 Jan 2011 14:30:40 -0800 (PST) Subject: Integrating doctest with unittest References: <4d038b63$0$30000$c3e8da3$5496439d@news.astraweb.com> <4d2a6b80$0$30004$c3e8da3$5496439d@news.astraweb.com> Message-ID: <82d99929-40e8-4d69-8272-f156017f5bd0@u3g2000vbj.googlegroups.com> On Jan 9, 6:14?pm, Steven D'Aprano wrote: > >>Is there a way to have unittest.main() find and run doc_test_suite > >>together with the other test suites? I only recently began using unittest, so I only know a little about it. There are almost certainly more clever ways to what you want, but what I have done may satisfy you. allTests.py: import unittest import PalmDS.test.test_tree_node as test_tree_node import PalmDS.test.test_plugin_manager as test_plugin_manager import PalmDS.test.test_ds_utils as test_ds_utils import PalmDS.test.test_main as test_main import PalmDS.test.test_root as test_root all = unittest.TestSuite() for module in [test_tree_node, test_plugin_manager, test_ds_utils, test_root, ]: all.addTest(module.suite()) if __name__ == '__main__': unittest.main() Note: This requires me to put a suite() function in every unittest module, such as this one from my test_tree_node.py module: def suite(): return unittest.TestLoader().loadTestsFromTestCase(TstTreeNode) Note: I must change TstTreeNode appropriately when I copy suite() to a new module. Terminal contents after a run: bob at BobBuilt01:~/svnMyWork/PalmDS/test$ ./all_tests.py -v all testDs2tree01 (PalmDS.test.test_tree_node.TstTreeNode) ... ok testDs2tree02 (PalmDS.test.test_tree_node.TstTreeNode) ... ok testPlug01 (PalmDS.test.test_plugin_manager.TstPluginManager) ... ok testPlug02 (PalmDS.test.test_plugin_manager.TstPluginManager) ... ok testBitstringBytes (PalmDS.test.test_ds_utils.TstDsUtils) ... ok testComputeLoadDir (PalmDS.test.test_ds_utils.TstDsUtils) ... ok testDs2fmtStr (PalmDS.test.test_ds_utils.TstDsUtils) ... ok testPalmDateDecode (PalmDS.test.test_root.TstRoot) ... ok testPalmDateEncode (PalmDS.test.test_root.TstRoot) ... ok ---------------------------------------------------------------------- Ran 9 tests in 0.016s OK bob at BobBuilt01:~/svnMyWork/PalmDS/test$ My guess at an answer to your specific question: At the end of allTests.py add all.addTest(doctest.DocTestSuite(module=module_to_test))) Then I think your DocTest suite will be run with the unittest suites when you specify "all" on the command line. From alex at moreati.org.uk Tue Jan 11 17:36:26 2011 From: alex at moreati.org.uk (Alex Willmer) Date: Tue, 11 Jan 2011 14:36:26 -0800 (PST) Subject: Convert unicode escape sequences to unicode in a file References: Message-ID: On Jan 11, 8:53?pm, Jeremy wrote: > I have a file that has unicode escape sequences, i.e., > > J\u00e9r\u00f4me > > and I want to replace all of them in a file and write the results to a new file. ?The simple script I've created is copied below. ?However, I am getting the following error: > > UnicodeEncodeError: 'ascii' codec can't encode character u'\xe9' in position 947: ordinal not in range(128) > > It appears that the data isn't being converted when writing to the file. ?Can someone please help? Are you _sure_ that your file contains the characters '\', 'u', '0', '0', 'e' and '9'? I expect that actually your file contains a byte with value 0xe9 and you have inspected the file using Python, which has printed the byte using a Unicode escape sequence. Open the file using a text editor or hex editor and look at the value at offset 947 to be sure. If so, you need to replace 'unicode-escape' with the actual encoding of the file. > if __name__ == "__main__": > ? ? f = codecs.open(filename, 'r', 'unicode-escape') > ? ? lines = f.readlines() > ? ? line = ''.join(lines) > ? ? f.close() > > ? ? utFound = re.sub('STRINGDECODE\((.+?)\)', r'\1', line) > ? ? print(utFound[:1000]) > > ? ? o = open('newDice.sql', 'w') > ? ? o.write(utFound.decode('utf-8')) > ? ? o.close() From nitin1singhal at gmail.com Tue Jan 11 17:38:44 2011 From: nitin1singhal at gmail.com (nitin) Date: Tue, 11 Jan 2011 14:38:44 -0800 (PST) Subject: Req: Python Developer : Direct CLient Message-ID: <874604c5-62dc-445d-b645-e33d1b60adae@l8g2000yqh.googlegroups.com> Hi, Please send me your resume if you are interested in it. Python Developer Location: Sebastapol, CA Duration: 3 Months Python web application development. Systems integration. RESTful architectures and Web standards. Familiar with the following: JVM and java tools. Creating documentation. Workable knowledge of relational databases and NoSQL solutions Thanks Nitin Singhal | RJT Compuquest Inc. 23440 Hawthorne Blvd., Suite 210, Torrance, CA 90505 nsinghal at rjtcompuquest.com www.rjtcompuquest.com Direct: 310 961 5807 Voice: 866-978-0384 Ext- 46 Fax: 310-378-6867 From debacle at debian.org Tue Jan 11 17:40:01 2011 From: debacle at debian.org (W. Martin Borgert) Date: Tue, 11 Jan 2011 23:40:01 +0100 Subject: How to dump a Python 2.6 dictionary with UTF-8 strings? Message-ID: <20110111224001.GA1503@beron.tangosoft.com> Hi, naively, I thought the following code: #!/usr/bin/env python2.6 # -*- coding: utf-8 -*- import codecs d = { u'key': u'?????' } if __name__ == "__main__": with codecs.open("ilike.txt", "w", "utf-8") as f: print >>f, d would produce a file ilike.txt like this: {u'key': u'?????'} But unfortunately, it results in: {u'key': u'\u6211\u7231\u4e2d\u56fd\u4eba'} What's the right way to get the strings in UTF-8? Thanks in advance! From martin at v.loewis.de Tue Jan 11 18:27:02 2011 From: martin at v.loewis.de (Martin v. Loewis) Date: Wed, 12 Jan 2011 00:27:02 +0100 Subject: How to dump a Python 2.6 dictionary with UTF-8 strings? In-Reply-To: References: Message-ID: <4D2CE746.6090607@v.loewis.de> > What's the right way to get the strings in UTF-8? This will work. I doubt you can get it much simpler in 2.x; in 3.x, your code will work out of the box (with proper syntactical adjustments). import pprint, cStringIO class UniPrinter(pprint.PrettyPrinter): def format(self, obj, context, maxlevels, level): if not isinstance(obj, unicode): return pprint.PrettyPrinter.format(self, obj, context, maxlevels, level) out = cStringIO.StringIO() out.write('u"') for c in obj: if ord(c)<32 or c in u'"\\': out.write('\\x%.2x' % ord(c)) else: out.write(c.encode("utf-8")) out.write('"') # result, readable, recursive return out.getvalue(), True, False UniPrinter().pprint({ u'k"e\\y': u'?????' }) From ben+python at benfinney.id.au Tue Jan 11 18:31:20 2011 From: ben+python at benfinney.id.au (Ben Finney) Date: Wed, 12 Jan 2011 10:31:20 +1100 Subject: Please use the Python Job Board for recruitment (was: Req: Python Developer : Direct CLient) References: <874604c5-62dc-445d-b645-e33d1b60adae@l8g2000yqh.googlegroups.com> Message-ID: <8739ozdnlj.fsf@benfinney.id.au> nitin writes: > Please send me your resume if you are interested in it. Please don't use this forum for recruitment purposes. Instead, please use the Python Job Board . -- \ ?For every complex problem, there is a solution that is simple, | `\ neat, and wrong.? ?Henry L. Mencken | _o__) | Ben Finney From alex at moreati.org.uk Tue Jan 11 18:32:31 2011 From: alex at moreati.org.uk (Alex Willmer) Date: Tue, 11 Jan 2011 15:32:31 -0800 (PST) Subject: How to dump a Python 2.6 dictionary with UTF-8 strings? References: Message-ID: <69a51798-5ebd-471c-a30a-294b2e4e7b84@v12g2000vbx.googlegroups.com> On Jan 11, 10:40?pm, "W. Martin Borgert" wrote: > Hi, > > naively, I thought the following code: > > #!/usr/bin/env python2.6 > # -*- coding: utf-8 -*- > import codecs > d = { u'key': u'?????' } > if __name__ == "__main__": > ? ? with codecs.open("ilike.txt", "w", "utf-8") as f: > ? ? ? ? print >>f, d > > would produce a file ilike.txt like this: > > {u'key': u'?????'} > > But unfortunately, it results in: > > {u'key': u'\u6211\u7231\u4e2d\u56fd\u4eba'} > > What's the right way to get the strings in UTF-8? > > Thanks in advance! It has worked, you're just seeing how python presents unicode characters in the interactive interpreter: Python 2.7.1+ (r271:86832, Dec 24 2010, 10:04:43) [GCC 4.5.2] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> x = {u'key': u'\u6211\u7231\u4e2d\u56fd\u4eba'} >>> x {u'key': u'\u6211\u7231\u4e2d\u56fd\u4eba'} >>> print x {u'key': u'\u6211\u7231\u4e2d\u56fd\u4eba'} >>> print x['key'] ????? That last line only works if your terminal uses an suitable encoding (e.g. utf-8). Regards, Alex From jlconlin at gmail.com Tue Jan 11 18:39:15 2011 From: jlconlin at gmail.com (Jeremy) Date: Tue, 11 Jan 2011 15:39:15 -0800 (PST) Subject: Convert unicode escape sequences to unicode in a file In-Reply-To: Message-ID: <3565d3e8-0a5e-414d-b130-fb0bfecd83f0@glegroupsg2000goo.googlegroups.com> On Tuesday, January 11, 2011 3:36:26 PM UTC-7, Alex wrote: > > Are you _sure_ that your file contains the characters '\', 'u', '0', > '0', 'e' and '9'? I expect that actually your file contains a byte > with value 0xe9 and you have inspected the file using Python, which > has printed the byte using a Unicode escape sequence. Open the file > using a text editor or hex editor and look at the value at offset 947 > to be sure. > > If so, you need to replace 'unicode-escape' with the actual encoding > of the file. Yeah, I'm sure that's what the file contains. In fact, I solved my own problem while waiting for an answer. When writing to the file I need to *en*code instead of *de*code; i.e., o = open('newDice.sql', 'w') o.write(utFound.encode('utf-8')) o.close() That works! From Catherine.M.Moroney at jpl.nasa.gov Tue Jan 11 19:30:22 2011 From: Catherine.M.Moroney at jpl.nasa.gov (Catherine Moroney) Date: Tue, 11 Jan 2011 16:30:22 -0800 Subject: order of importing modules Message-ID: <4D2CF61E.7010500@jpl.nasa.gov> In what order does python import modules on a Linux system? I have a package that is both installed in /usr/lib64/python2.5/site-packages, and a newer version of the same module in a working directory. I want to import the version from the working directory, but when I print module.__file__ in the interpreter after importing the module, I get the version that's in site-packages. I've played with the PYTHONPATH environmental variable by setting it to just the path of the working directory, but when I import the module I still pick up the version in site-packages. /usr/lib64 is in my PATH variable, but doesn't appear anywhere else. I don't want to remove /usr/lib64 from my PATH because that will break a lot of stuff. Can I force python to import from my PYTHONPATH first, before looking in the system directory? Catherine From debacle at debian.org Tue Jan 11 20:05:25 2011 From: debacle at debian.org (W. Martin Borgert) Date: Wed, 12 Jan 2011 02:05:25 +0100 Subject: How to dump a Python 2.6 dictionary with UTF-8 strings? In-Reply-To: <4D2CE746.6090607@v.loewis.de> References: <4D2CE746.6090607@v.loewis.de> Message-ID: <20110112010525.GA2458@beron.tangosoft.com> On 2011-01-12 00:27, Martin v. Loewis wrote: > This will work. I doubt you can get it much simpler > in 2.x; in 3.x, your code will work out of the box > (with proper syntactical adjustments). Thanks, this works like a charm. I tried pprint before for this task and failed. Now I know why :~) From drsalists at gmail.com Tue Jan 11 20:20:18 2011 From: drsalists at gmail.com (Dan Stromberg) Date: Tue, 11 Jan 2011 17:20:18 -0800 Subject: order of importing modules In-Reply-To: <4D2CF61E.7010500@jpl.nasa.gov> References: <4D2CF61E.7010500@jpl.nasa.gov> Message-ID: On Tue, Jan 11, 2011 at 4:30 PM, Catherine Moroney wrote: > In what order does python import modules on a Linux system? ?I have a > package that is both installed in /usr/lib64/python2.5/site-packages, > and a newer version of the same module in a working directory. > > I want to import the version from the working directory, but when I > print module.__file__ in the interpreter after importing the module, > I get the version that's in site-packages. > > I've played with the PYTHONPATH environmental variable by setting it > to just the path of the working directory, but when I import the module > I still pick up the version in site-packages. > > /usr/lib64 is in my PATH variable, but doesn't appear anywhere else. ?I > don't want to remove /usr/lib64 from my PATH because that will break > a lot of stuff. > > Can I force python to import from my PYTHONPATH first, before looking > in the system directory? > > Catherine > -- > http://mail.python.org/mailman/listinfo/python-list Please import sys and inspect sys.path; this defines the search path for imports. By looking at sys.path, you can see where in the search order your $PYTHONPATH is going. It might actually be better to give your script a command line option that says "Throw the following directory at the beginning of sys.path". From ben+python at benfinney.id.au Tue Jan 11 20:26:04 2011 From: ben+python at benfinney.id.au (Ben Finney) Date: Wed, 12 Jan 2011 12:26:04 +1100 Subject: order of importing modules References: <4D2CF61E.7010500@jpl.nasa.gov> Message-ID: <87tyhediab.fsf@benfinney.id.au> Catherine Moroney writes: > In what order does python import modules on a Linux system? An import caused by a statement is done when that statement is executed. So the answer to that question is: in the order the statements occur in the execution flow. > I have a package that is both installed in > /usr/lib64/python2.5/site-packages, and a newer version of the same > module in a working directory. Ah, you're asking about the search path for importing modules. You would do well to work through the entire Python tutorial to cover the basics like that. Don't merely read it; actually *do* it, exploring each example and experimenting to understand before proceeding. The module import search path is part of that coverage . > I want to import the version from the working directory, but when I > print module.__file__ in the interpreter after importing the module, > I get the version that's in site-packages. You will be interested in the features enabled by PEP 328 , specifically the feature of relative imports. -- \ ?When I turned two I was really anxious, because I'd doubled my | `\ age in a year. I thought, if this keeps up, by the time I'm six | _o__) I'll be ninety.? ?Steven Wright | Ben Finney From ddasilva at umd.edu Tue Jan 11 20:50:46 2011 From: ddasilva at umd.edu (Daniel da Silva) Date: Tue, 11 Jan 2011 17:50:46 -0800 (PST) Subject: Parsing string for " " Message-ID: <0d7143ca-45cf-44c3-9e8d-acb867c52037@f30g2000yqa.googlegroups.com> Hi, I have come across a task where I would like to scan a short 20-80 character line of text for instances of " ". Ideally could be of any tense. I know quite a bit of programming and computer science, but computational linguistics is relatively new to me. If anyone can point me in the right direction, I would be very thankful! Cheers, Daniel From blume.erich at gmail.com Tue Jan 11 21:22:33 2011 From: blume.erich at gmail.com (eblume) Date: Tue, 11 Jan 2011 18:22:33 -0800 (PST) Subject: Syntactic structure for 'until :' loop Message-ID: <198391a1-7257-4422-a076-35b815ab99c6@l22g2000vbp.googlegroups.com> I'm still quite new to Python and I'm probably going about this entirely the wrong way, but it recently struck me that there might be the need for a control flow loop based on exception handling. First let me give the proposed syntax: until : do_something() This would be exactly equivalent to (but much more compact than): while True: try: do_something() except Exception: break Now, why would anyone want this structure? In my case, I'm using it (well, the latter form of it, obviously) to loop over an iterator object that was not created via the 'for obj in collection:' syntax. Here's the actual code snippet: headers = self.reader.next() ... intermediate code .... while True: try: line = self.reader.next() except StopIteration: return data data.append(line) I'm sure I'm doing this in a very backward and wrong way, and would appreciate tips on a better way to accomplish the same task. Obviously there is an existing syntax which handles the same situations, and I don't suspect that this will be an embraced proposal, I'm more hoping to spark some conversation. Thanks! From SSharma84 at slb.com Tue Jan 11 21:38:50 2011 From: SSharma84 at slb.com (Sachin Kumar Sharma) Date: Wed, 12 Jan 2011 02:38:50 +0000 Subject: Python use growing fast In-Reply-To: <08AA70425ADB4D99A8054A7F33141B76@octavian> References: <4d2b8844$0$43996$742ec2ed@news.sonic.net> <4D2BB453.8030304@verizon.net> <08AA70425ADB4D99A8054A7F33141B76@octavian> Message-ID: <75C2FED246299A478280FA1470EDA4430C907364@NL0230MBX06N1.DIR.slb.com> Since this discussion is going on about the popularity of a programming language. I would like to know views regarding the best language for scientific programming especially in terms of user friendliness, resources available, graphics and robustness to handle large numerical and simulation problems. Thanks & regards Sachin ************************************************************************ Sachin Kumar Sharma Senior Geomodeler -----Original Message----- From: python-list-bounces+ssharma84=slb.com at python.org [mailto:python-list-bounces+ssharma84=slb.com at python.org] On Behalf Of Octavian Rasnita Sent: Tuesday, January 11, 2011 3:38 PM To: python-list at python.org Subject: Re: Python use growing fast From: "Gerry Reno" > On 01/10/2011 08:31 PM, Katie T wrote: >> On Mon, Jan 10, 2011 at 10:29 PM, John Nagle wrote: >> >>> On 1/10/2011 1:02 PM, MRAB wrote: >>> >>>> On 10/01/2011 20:29, Dan Stromberg wrote: >>>> >>>>> I invite folks to check out Tiobe's Language Popularity Rankings: >>>>> >>>>> http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html >>>>> >>> That's somehow derived from web searches, not from any real data >>> source. Look how far down JavaScript is. >>> >> Any measure is arbitrary and subject to biases, what methodology would >> you prefer ? >> >> >> Katie >> > > Measuring the "Buzz" about a language is actually a pretty good way to > gauge its popularity. Well, not exactly. C and C++ are older than many other languages and probably many of the web pages that contain "programming C" are very old and don't reflect their current popularity. On the other hand, newer languages are more attractive for book publishers because they can sell more books about Ruby than about C, because for C there are already very many books written so there is a bigger intrest to promote the newer languages, not just because they are better, but because there are interests involved. Talking about interests, Java and DotNet are more popular than many other languages, but we all know why, and we also know why PHP has such a big success although it is a bad language, as we all know why Window has a bigger success than other operating systems... so the popularity contest is good, but for something else than we want to prove. A programming language popularity contest is like a beauty contest for finding the most intelligent girl. Octavian -- http://mail.python.org/mailman/listinfo/python-list From ian.g.kelly at gmail.com Tue Jan 11 21:53:19 2011 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Tue, 11 Jan 2011 19:53:19 -0700 Subject: Syntactic structure for 'until :' loop In-Reply-To: <198391a1-7257-4422-a076-35b815ab99c6@l22g2000vbp.googlegroups.com> References: <198391a1-7257-4422-a076-35b815ab99c6@l22g2000vbp.googlegroups.com> Message-ID: On 1/11/2011 7:22 PM, eblume wrote: > This would be exactly equivalent to (but much more compact than): > > while True: > try: > do_something() > except Exception: > break Or perhaps: try: while True: do_something() except Exception: pass > Now, why would anyone want this structure? In my case, I'm using it > (well, the latter form of it, obviously) to loop over an iterator > object that was not created via the 'for obj in collection:' syntax. > Here's the actual code snippet: > > headers = self.reader.next() > ... intermediate code .... > while True: > try: > line = self.reader.next() > except StopIteration: > return data > data.append(line) > > I'm sure I'm doing this in a very backward and wrong way, and would > appreciate tips on a better way to accomplish the same task. Obviously > there is an existing syntax which handles the same situations, and I > don't suspect that this will be an embraced proposal, I'm more hoping > to spark some conversation. reader_iter = iter(self.reader) headers = reader_iter.next() # intermediate code for line in reader_iter: data.append(line) return data Also note that recommended best practice is to wrap the "headers = reader_iter.next()" line in a try-except in case it raises a StopIteration. Otherwise it could get propagated silently up to some unrelated for loop higher in the stack, resulting in unexpected behavior. Cheers, Ian From python at mrabarnett.plus.com Tue Jan 11 22:23:11 2011 From: python at mrabarnett.plus.com (MRAB) Date: Wed, 12 Jan 2011 03:23:11 +0000 Subject: Parsing string for " " In-Reply-To: <0d7143ca-45cf-44c3-9e8d-acb867c52037@f30g2000yqa.googlegroups.com> References: <0d7143ca-45cf-44c3-9e8d-acb867c52037@f30g2000yqa.googlegroups.com> Message-ID: <4D2D1E9F.2020500@mrabarnett.plus.com> On 12/01/2011 01:50, Daniel da Silva wrote: > Hi, > > I have come across a task where I would like to scan a short 20-80 > character line of text for instances of " ". Ideally > could be of any tense. > > I know quite a bit of programming and computer science, but > computational linguistics is relatively new to me. If anyone can point > me in the right direction, I would be very thankful! > Have a look at the Natural Language Toolkit: http://www.nltk.org/ From askutt at gmail.com Tue Jan 11 22:30:43 2011 From: askutt at gmail.com (Adam Skutt) Date: Tue, 11 Jan 2011 19:30:43 -0800 (PST) Subject: os.path.realpath() and os.path.abspath() References: Message-ID: On Jan 11, 6:35?am, Jurko Gospodneti? wrote: > ? ?Hi all. > > ? ?os.path.realpath() documentation states that it returns a 'canonical' > path. Does that infer that it returns an absolute path? > A canonical path is supposed to be absolute and at least Python 2.7.1 ensures that is the case. Historically, some versions of the UNIX syscall (Solaris in particular) have not always returned absolute paths, but I believe this is no longer the case and was a very long standing bug (though I may be mistaken). Adam From sjbenner at gmail.com Tue Jan 11 22:50:15 2011 From: sjbenner at gmail.com (Josh Benner) Date: Tue, 11 Jan 2011 19:50:15 -0800 Subject: Python use growing fast In-Reply-To: <75C2FED246299A478280FA1470EDA4430C907364@NL0230MBX06N1.DIR.slb.com> References: <4d2b8844$0$43996$742ec2ed@news.sonic.net> <4D2BB453.8030304@verizon.net> <08AA70425ADB4D99A8054A7F33141B76@octavian> <75C2FED246299A478280FA1470EDA4430C907364@NL0230MBX06N1.DIR.slb.com> Message-ID: On Tue, Jan 11, 2011 at 6:38 PM, Sachin Kumar Sharma wrote: > Since this discussion is going on about the popularity of a programming > language. > > I would like to know views regarding the best language for scientific > programming especially in terms of user friendliness, resources available, > graphics and robustness to handle large numerical and simulation problems. > > Thanks & regards > > Sachin > > ************************************************************************ > Sachin Kumar Sharma > Senior Geomodeler > > According to this article ... http://neopythonic.blogspot.com/2009/11/python-in-scientific-world.html ... the answer is python. Josh Benner -------------- next part -------------- An HTML attachment was scrubbed... URL: From lanyjie at yahoo.com Tue Jan 11 23:08:12 2011 From: lanyjie at yahoo.com (Yingjie Lan) Date: Tue, 11 Jan 2011 20:08:12 -0800 (PST) Subject: the C header file when extending CPython Message-ID: <31414.45942.qm@web121506.mail.ne1.yahoo.com> Hi, I am wondering when extending Python (CPython), what should be put into the C header file? Any guidelines? Thanks, Yingjie From blume.erich at gmail.com Tue Jan 11 23:29:06 2011 From: blume.erich at gmail.com (eblume) Date: Tue, 11 Jan 2011 20:29:06 -0800 (PST) Subject: Syntactic structure for 'until :' loop References: <198391a1-7257-4422-a076-35b815ab99c6@l22g2000vbp.googlegroups.com> Message-ID: On Jan 11, 6:53?pm, Ian Kelly wrote: > On 1/11/2011 7:22 PM, eblume wrote: > > > > > reader_iter = iter(self.reader) > headers = reader_iter.next() > # intermediate code > for line in reader_iter: > ? ? ?data.append(line) > return data > > Also note that recommended best practice is to wrap the "headers = > reader_iter.next()" line in a try-except in case it raises a > StopIteration. ?Otherwise it could get propagated silently up to some > unrelated for loop higher in the stack, resulting in unexpected behavior. > > Cheers, > Ian That's brilliant, exactly the code I was looking for. Thanks very much Ian! Erich From michele.simionato at gmail.com Wed Jan 12 00:41:24 2011 From: michele.simionato at gmail.com (Michele Simionato) Date: Tue, 11 Jan 2011 21:41:24 -0800 (PST) Subject: Ideas for a module to process command line arguments References: Message-ID: <2ee89e8b-f7f6-48f2-9b7e-6b8592db0c13@k30g2000vbn.googlegroups.com> On Jan 11, 4:06?pm, Alice Bevan?McGregor wrote: > After looking into it, Plac's default help display isn't very helpful; > you need to massage your application a fair amount before generating > nice, complete-looking argument lists and such. ?For example: > > ? ? ? ? def main(verbose: ('prints more info', 'flag', 'v'), dsn: 'connection > string'): > > ? ? ? ? @annotate(dsn="connection string", verbose="prints more info") > ? ? ? ? def main(dsn, verbose=False): > > The latter is marrow.script, and even without the annotation a more > complete help text is generated. ?The -v and flag nature are assumed > from the first unique character and default value. ?(Flags, when > present on the command line, invert the default value.) Honestly I do not see any significant difference both in the level of verbosity for the annotations and in the quality of the help message provided in the absence of annotations. Originally plac too was able to recognize flags automatically by looking at the default value (if the default value is a boolean then the option is a flag); however I removed that functionality because I wanted to be able to differentiate between flag and (smart) options (see http://micheles.googlecode.com/hg/plac/doc/plac.html#scripts-with-options-and-smart-options). From michele.simionato at gmail.com Wed Jan 12 00:43:41 2011 From: michele.simionato at gmail.com (Michele Simionato) Date: Tue, 11 Jan 2011 21:43:41 -0800 (PST) Subject: Ideas for a module to process command line arguments References: <941cfb0b-e34b-4d07-8c51-293656878f6a@z19g2000yqb.googlegroups.com> <8dd04926-2ad2-4c01-b9e7-5843e801852f@39g2000yqa.googlegroups.com> Message-ID: <9745a845-7d39-4e84-91c8-b656681c9a6b@j1g2000vbl.googlegroups.com> On Jan 11, 6:57?pm, Mike wrote: > On Jan 11, 11:26?am, Michele Simionato > wrote: > > In that case easy_install/pip/whatever will install the dependency > > automatically (who is installing > > dependencies by hand nowadays?). > > I do. Is this bad? :} You are simply spending more time than needed, since there are already tools available to perform the task for you. From doomster at knuut.de Wed Jan 12 01:36:21 2011 From: doomster at knuut.de (Ulrich Eckhardt) Date: Wed, 12 Jan 2011 07:36:21 +0100 Subject: the C header file when extending CPython References: Message-ID: <8p50f6F4lpU1@mid.uni-berlin.de> Yingjie Lan wrote: > I am wondering when extending Python (CPython), what should be put into > the C header file? Any guidelines? You don't even need to write a header file at all. There are no Python- specific requirements to put anything into a header file, though you might want to do so for reasons internal to your project. Uli From __peter__ at web.de Wed Jan 12 03:39:37 2011 From: __peter__ at web.de (Peter Otten) Date: Wed, 12 Jan 2011 09:39:37 +0100 Subject: Syntactic structure for 'until :' loop References: <198391a1-7257-4422-a076-35b815ab99c6@l22g2000vbp.googlegroups.com> Message-ID: Ian Kelly wrote: > reader_iter = iter(self.reader) > headers = reader_iter.next() > # intermediate code > for line in reader_iter: > data.append(line) > return data If data is a list the for loop can be replaced with data.extend(reader_iter) or, if data is an empty list created within the function data = list(reader_iter) From prakash.stack at gmail.com Wed Jan 12 05:27:12 2011 From: prakash.stack at gmail.com (prakash jp) Date: Wed, 12 Jan 2011 15:57:12 +0530 Subject: read text color from image Message-ID: Hi All, During automation of a test case the web interface throws failure and sucess text in RED and GREEN colors respectively. Is there a method to read the color of the Success(green) and Failure(red) from the screenshots of the webinterfaces collect for Failure and Success say : import Image import ImageChops im2 = Image.open("Failure.JPG") im1 = Image.open("Sucess.JPG") #print list(im1.getdata()) diff = ImageChops.difference(im2, im1) #print diff.getbbox() #diff.show() #print im1.tostring() Thanks for all in advance Prakash -------------- next part -------------- An HTML attachment was scrubbed... URL: From cjwilliams43 at gmail.com Wed Jan 12 09:51:50 2011 From: cjwilliams43 at gmail.com (Colin J. Williams) Date: Wed, 12 Jan 2011 09:51:50 -0500 Subject: Python use growing fast In-Reply-To: References: Message-ID: On 10-Jan-11 16:02 PM, MRAB wrote: > On 10/01/2011 20:29, Dan Stromberg wrote: >> I invite folks to check out Tiobe's Language Popularity Rankings: >> >> http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html >> >> The gist is: Python grew faster than any other programming language >> over the last year, according to this (slightly arbitrary, but better >> than no indicator) ranking. >> >> ...despite our wikipedia page whose first paragraph almost seems like >> it was written with the intention of scaring off new converts, with >> its "unusual" comment: >> >> http://en.wikipedia.org/wiki/Python_%28programming_language%29 >> >> (Like it or not, people do frequently confuse the descriptive for the >> normative) > > It shows an example of Python code, which happens to have 2 syntax > errors! Why not correct the Wikipedia entry? Colin W. From aharrisreid at googlemail.com Wed Jan 12 11:37:16 2011 From: aharrisreid at googlemail.com (Alan Harris-Reid) Date: Wed, 12 Jan 2011 16:37:16 +0000 Subject: Career path - where next? Message-ID: <4D2DD8BC.1020907@googlemail.com> Hi there, I wonder if any Python folk out there can help me. For many years I was a contractor developing desktop and web applications using Visual Foxpro as my main language, with Foxpro, SQL-server and Oracle as back-end databases. Unfortunately Foxpro was killed-off by Microsoft, hence my work dried-up and my last 'big' contract ended about a year ago. Since then I have taken time off programming doing house-renovation, and in the last 6 months I have been updating my programming skills by learning Python (3) with SQLite, JavaScript, HTML and CSS to a level where I can create and deploy data-based web-sites. My situation now is that I am reasonably comfortable with the above languages and am now in a position where I wish to return to employment using my new and/or existing skills (contract/permanent, full/part-time or teleworking). However, I have yet to find any UK vacancy which will accept a relative 'beginner' - they all require at least 2-3 years Python in a commercial environment. It's a catch-22 situation - it's hard to get a job without experience, but you need a job to get experience in the 1st place! I would even consider doing small projects for nothing so that I can 'get my foot in the door' (although I hope to be wise-enough to know when I am being taken advantage of!). I am also mailing CVs to agencies I think may be interested. If anyone out has ideas as to how to proceed towards achieving my goal, I would be grateful for any advice. Regards, Alan Harris-Reid From tjreedy at udel.edu Wed Jan 12 11:56:53 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Wed, 12 Jan 2011 11:56:53 -0500 Subject: Career path - where next? In-Reply-To: <4D2DD8BC.1020907@googlemail.com> References: <4D2DD8BC.1020907@googlemail.com> Message-ID: On 1/12/2011 11:37 AM, Alan Harris-Reid wrote: ... > updating my programming skills by learning Python (3) with SQLite, > JavaScript, HTML and CSS to a level where I can create and deploy > data-based web-sites. ... > I would even consider doing small projects for nothing so that I can > 'get my foot in the door' (although I hope to be wise-enough to know I believe both Roundup/Python tracker and PyPI (Python package index) are based on sqlite and have small projects available/needed. I cannot help you otherwise. Good luck. -- Terry Jan Reedy From tjreedy at udel.edu Wed Jan 12 12:01:15 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Wed, 12 Jan 2011 12:01:15 -0500 Subject: Python use growing fast In-Reply-To: References: Message-ID: On 1/12/2011 9:51 AM, Colin J. Williams wrote: >> It shows an example of Python code, which happens to have 2 syntax >> errors! > > Why not correct the Wikipedia entry? As I reported early, the errors, if any, are in .png and .svg images of text, which would have to be replaced, not corrected. Would be good since the imaged snippet is a haphazard except from a much larger file and inane out of context. -- Terry Jan Reedy From alice at gothcandy.com Wed Jan 12 12:09:56 2011 From: alice at gothcandy.com (=?utf-8?Q?Alice_Bevan=E2=80=93McGregor?=) Date: Wed, 12 Jan 2011 09:09:56 -0800 Subject: Ideas for a module to process command line arguments References: <2ee89e8b-f7f6-48f2-9b7e-6b8592db0c13@k30g2000vbn.googlegroups.com> Message-ID: On 2011-01-11 21:41:24 -0800, Michele Simionato said: > Originally plac too was able to recognize flags automatically by > looking at the default value (if the default value is a boolean then > the option is a flag); however I removed that functionality because I > wanted to be able to differentiate between flag and (smart) options > (see > http://micheles.googlecode.com/hg/plac/doc/plac.html#scripts-with-options-and-smart-options). Not > entirely sure what you mean by 'smart' options. If your'e referring to using a single hyphen and a list of characters to represent a long option (which, to the rest of the world, use two leading hyphens) then that's pretty weird. ;) Consider most of the GNU tools: ls -lvh tar -xzvf file.tgz (goes so far as to make the leading hyphen optional!) less -ceF logfile bc -qw ps -aux (same as tar) And even third-party tools: mysql -fH pg_dump -abO ... One major system in the world that doesn't really differentiate between long and short options is... DOS, and by extension, Windows. But they also use / as a switch character. Anyway; I'm happy with what I have wrought (and am continuing to update with support for class-based sub-command dispatch) and will be utilizing it for all scripts in the Marrow suite. To each their own, but reinvention itself can be for motivations other than NIH. I wanted something pure-Python, portable across the 3k barrier without code modification (no 2to3), that didn't use optparse, getopt, or argparse and basically be a translation layer. It can be simpler than that, as marrow.script demonstrates. - Alice. From philip at semanchuk.com Wed Jan 12 13:28:23 2011 From: philip at semanchuk.com (Philip Semanchuk) Date: Wed, 12 Jan 2011 13:28:23 -0500 Subject: Career path - where next? In-Reply-To: <4D2DD8BC.1020907@googlemail.com> References: <4D2DD8BC.1020907@googlemail.com> Message-ID: On Jan 12, 2011, at 11:37 AM, Alan Harris-Reid wrote: > > Hi there, I wonder if any Python folk out there can help me. > > For many years I was a contractor developing desktop and web applications using Visual Foxpro as my main language, with Foxpro, SQL-server and Oracle as back-end databases. Unfortunately Foxpro was killed-off by Microsoft, hence my work dried-up and my last 'big' contract ended about a year ago. Since then I have taken time off programming doing house-renovation, and in the last 6 months I have been updating my programming skills by learning Python (3) with SQLite, JavaScript, HTML and CSS to a level where I can create and deploy data-based web-sites. > > My situation now is that I am reasonably comfortable with the above languages and am now in a position where I wish to return to employment using my new and/or existing skills (contract/permanent, full/part-time or teleworking). However, I have yet to find any UK vacancy which will accept a relative 'beginner' - they all require at least 2-3 years Python in a commercial environment. It's a catch-22 situation - it's hard to get a job without experience, but you need a job to get experience in the 1st place! > > I would even consider doing small projects for nothing so that I can 'get my foot in the door' (although I hope to be wise-enough to know when I am being taken advantage of!). I am also mailing CVs to agencies I think may be interested. > > If anyone out has ideas as to how to proceed towards achieving my goal, I would be grateful for any advice. Contributing to open source projects (your own or someone else's) will help to convince some employers that you're worth taking a look at. If nothing else it gives you a public example of the work that you can point them to. Good luck Philip From krzysztof.t.bieniasz at gmail.com Wed Jan 12 13:44:52 2011 From: krzysztof.t.bieniasz at gmail.com (Krzysztof Bieniasz) Date: Wed, 12 Jan 2011 18:44:52 +0000 (UTC) Subject: Python use growing fast References: Message-ID: > As I reported early, the errors, if any, are in .png and .svg images of > text, which would have to be replaced, not corrected. Would be good > since the imaged snippet is a haphazard except from a much larger file > and inane out of context. I don't think it really is a big deal. I mean, this is merely an illustration for the syntax-highlighted python code. So the message isn't: "Go ahead and try it with your Python". It's rather "Look, you can have colorful highlighting of python code, isn't that cool?!" It actually presents the specific indentation of Python code and therefore it is mostly useful to someone who never used Python. And actually I wouldn't expect any Python programmer to look for feedback on Wikipedia. It's not that I have anything against Wikipedia -- on the contrary, I use it all the time. But remember that it's an encyclopedia not a Python manual. From joncle at googlemail.com Wed Jan 12 13:47:41 2011 From: joncle at googlemail.com (Jon Clements) Date: Wed, 12 Jan 2011 10:47:41 -0800 (PST) Subject: Career path - where next? References: Message-ID: On Jan 12, 4:37?pm, Alan Harris-Reid wrote: > Hi there, I wonder if any Python folk out there can help me. > > For many years I was a contractor developing desktop and web > applications using Visual Foxpro as my main language, with Foxpro, > SQL-server and Oracle as back-end databases. ?Unfortunately Foxpro was > killed-off by Microsoft, hence my work dried-up and my last 'big' > contract ended about a year ago. ?Since then I have taken time off > programming doing house-renovation, and in the last 6 months I have been > updating my programming skills by learning Python (3) with SQLite, > JavaScript, HTML and CSS to a level where I can create and deploy > data-based web-sites. > > My situation now is that I am reasonably comfortable with the above > languages and am now in a position where I wish to return to employment > using my new and/or existing skills (contract/permanent, full/part-time > or teleworking). ? However, I have yet to find any UK vacancy which will > accept a relative 'beginner' - they all require at least 2-3 years > Python in a commercial environment. ?It's a catch-22 situation - it's > hard to get a job without experience, but you need a job to get > experience in the 1st place! > > I would even consider doing small projects for nothing so that I can > 'get my foot in the door' (although I hope to be wise-enough to know > when I am being taken advantage of!). ?I am also mailing CVs to agencies > I think may be interested. > > If anyone out has ideas as to how to proceed towards achieving my goal, > I would be grateful for any advice. > > Regards, > Alan Harris-Reid Hi Alan, Just some ideas (not in any order, just as they're thought of):- - Emphasise your experience with Oracle & SQL Server, and use Python as a "I also have". It may be someone will accept that as viable (saves them a DBA or something), and maybe you'll get into an experienced group and get on the job training. (I assume you have good SQL skills). - Look at cwjobs.co.uk / monster / etc..., and search for Python. Get a list of agencies there. Phone them *first*, explain what is it you've done, and what you can do. If the person seems to know what they're talking about send your CV - but chase often. - Look at web-frameworks. Django seems to be the most listed for "required"/"nice to have". Also check out javascript-frameworks - jquery & extjs are the biggest 2, so at least you can say you've had some experience. - Perhaps phone your local job centre, and ask for a contact for their local volunteer centre. They might have something like work for a small charity that just needs a couple of pages done. The idea being: 1) If it's a cause you believe in, it makes up for not getting paid; 2) You can use it as an example and reference; 3) You might be able to use it as networking - might get a free lunch from an event and meet someone with money, that's impressed with your good will and work, and just happens to have a job going spare... - Build a copy of your CV designed for the web. Make sure it looks good, is HTML/CSS compliant, and even add some nice interactive stuff to it, and include it as a link in your CV. [The other thing you can do, is only display the CV on entry of a short PIN (different for each one you send - '2431' or something'), then you can log who's bothered looking at it, and when, enabling timing of a follow-up better)]. - Look in local papers for local companies that offer not necessarily web design, but possibly just print design. See if you can't have a chat with them and get some work your way. Other options might be new- starts up, non-chain pubs, community/sports clubs, a local church for fund-raising, your local chinese/indian takeaway - wouldn't hurt to put their menu online with an online order form would it!? [What you might find about this, is that as they're not likely to be technical, you can take your own time, charge a reasonable amount, experiment a little and learn, and not have too tight deadlines or someone looking over your shoulder]. Brain (or somewhere else) dump finished. hth Jon. From msarro at gmail.com Wed Jan 12 13:59:05 2011 From: msarro at gmail.com (Matty Sarro) Date: Wed, 12 Jan 2011 13:59:05 -0500 Subject: Best way to automatically copy out attachments from an email Message-ID: As of now here is my situation: I am working on a system to aggregate IT data and logs. A number of important data are gathered by a third party system. The only immediate way I have to access the data is to have their system automatically email me updates in CSV format every hour. If I set up a mail client on the server, this shouldn't be a huge issue. However, is there a way to automatically open the emails, and copy the attachments to a directory based on the filename? Kind of a weird project, I know. Just looking for some ideas hence posting this on two lists. Thanks all, and happy hump day! -Matty From Catherine.M.Moroney at jpl.nasa.gov Wed Jan 12 14:07:24 2011 From: Catherine.M.Moroney at jpl.nasa.gov (Catherine Moroney) Date: Wed, 12 Jan 2011 11:07:24 -0800 Subject: order of importing modules In-Reply-To: References: <4D2CF61E.7010500@jpl.nasa.gov> Message-ID: <4D2DFBEC.1070605@jpl.nasa.gov> I've looked at my sys.path variable and I see that it has a whole bunch of site-package directories, followed by the contents of my $PYTHONPATH variable, followed by a list of misc site-package variables (see below). I've verified that if I manually reverse the order of sys.path I can then import the proper version of the module that I want. But this is not a permanent solution for me as this will mess up other people are who working with the same code. But, I'm curious as to where the first bunch of 'site-package' entries come from. The /usr/lib64/python2.5/site-packages/pyhdfeos-1.0_r57_58-py2.5-linux-x86_64.egg is not present in any of my environmental variables yet it shows up as one of the first entries in sys.path. A colleague of mine is running on the same system as I am, and he does not have the problem of the /usr/lib64/python2.5/site-packages/pyhdfeos-1.0_r57_58-py2.5-linux-x86_64.egg variable showing up as one of the first entries in sys.path. Thanks for the education, Catherine Dan Stromberg wrote: > On Tue, Jan 11, 2011 at 4:30 PM, Catherine Moroney > wrote: >> In what order does python import modules on a Linux system? I have a >> package that is both installed in /usr/lib64/python2.5/site-packages, >> and a newer version of the same module in a working directory. >> >> I want to import the version from the working directory, but when I >> print module.__file__ in the interpreter after importing the module, >> I get the version that's in site-packages. >> >> I've played with the PYTHONPATH environmental variable by setting it >> to just the path of the working directory, but when I import the module >> I still pick up the version in site-packages. >> >> /usr/lib64 is in my PATH variable, but doesn't appear anywhere else. I >> don't want to remove /usr/lib64 from my PATH because that will break >> a lot of stuff. >> >> Can I force python to import from my PYTHONPATH first, before looking >> in the system directory? >> >> Catherine >> -- >> http://mail.python.org/mailman/listinfo/python-list > > Please import sys and inspect sys.path; this defines the search path > for imports. > > By looking at sys.path, you can see where in the search order your > $PYTHONPATH is going. > > It might actually be better to give your script a command line option > that says "Throw the following directory at the beginning of > sys.path". From justpark78 at gmail.com Wed Jan 12 14:09:45 2011 From: justpark78 at gmail.com (justin) Date: Wed, 12 Jan 2011 11:09:45 -0800 (PST) Subject: How to populate all possible hierarchical clusterings from a set of elements? Message-ID: <3cb5ae7e-866d-40fb-ae3f-496193db91e4@t35g2000yqj.googlegroups.com> The title sounds too complex, but my question is actually simple. Suppose I have [1,2,3,4,5], then there are many ways of making clustering. Among them, I want to pair up terminals until there is only one left at the end. For example, ((((1,2),3),4),5), (1,(2,(3,(4,5)))), or (((1,2),(3,4)), 5) would be legitimate ones. How do you think can I, using the modules of Python such as itertools as much as possible, make all possible such clusterings? Thanks in advance, Justin. From physicsandpython at gmail.com Wed Jan 12 14:22:30 2011 From: physicsandpython at gmail.com (Physics Python) Date: Wed, 12 Jan 2011 11:22:30 -0800 (PST) Subject: Nested structures question Message-ID: Hello, I am teaching myself python using the book: Python Programming for Absolute Beginners, 2nd edition by Michael Dawson. I am using python 2.7.1. In chapter 3 we are learning to use structures (while, if, elif) to write a program that has the user guess a number between 1 and 100. Here is the code for the baseline program: ------------- start -------------- # Guess My Number # # The computer picks a random number between 1 and 100 # The player tries to guess it and the computer lets # the player know if the guess is too high, too low # or right on the money import random print "\tWelcome to 'Guess My Number'!" print "\nI'm thinking of a number between 1 and 100." print "Try to guess it in as few attempts as possible.\n" # set the initial values the_number = random.randrange(100) + 1 guess = int(raw_input("Take a guess: ")) tries = 1 # guessing loop while (guess != the_number): if (guess > the_number): print "Lower..." else: print "Higher..." guess = int(raw_input("Take a guess: ")) tries += 1 print "You guessed it! The number was", the_number print "And it only took you", tries, "tries!\n" raw_input("\n\nPress the enter key to exit.") ------------------- end --------------------- The book asks to write a version of this program that limits the number of guess the user can take. I have tried to write this program, and I am getting some run time errors. Can anybody take a look at my code and give me some advice or hints? Thanks! ---- start --- # Number Guessing Game Version 2 # # The computer picks a random number between 1 and 100 # The player tries to guess and the computer tells # the player if the guess is high or low or correct # The player has to guess the number in less than 7 tries. # # 1/12/2011 import random # welcome the player to the game print "\tWelcome to 'Guess My Number'!" print "\nI am thinking of a number between 1 and 100." print "Try and guess it in as few attempts as possible.\n" # Set the initial values the_number= random.randrange(100) + 1 guess = int(raw_input("Take a guess: ")) tries = 1 # Guessing loop while guess != the_number: while tries > 7: if guess > the_number: print "Lower..." else: print "Higher..." guess = int(raw_input("Take a guess: ")) tries += 1 print "You guessed it! The number was: ", the_number print "And it only took you", tries, "tries!\n" print "Wow, you suck at this, you should be able to solve this in 7 attempts or less" raw_input("Press Enter to exit the program.") ------- end ----- From Catherine.M.Moroney at jpl.nasa.gov Wed Jan 12 14:38:39 2011 From: Catherine.M.Moroney at jpl.nasa.gov (Catherine Moroney) Date: Wed, 12 Jan 2011 11:38:39 -0800 Subject: order of importing modules In-Reply-To: References: <4D2CF61E.7010500@jpl.nasa.gov> Message-ID: <4D2E033F.6030704@jpl.nasa.gov> I've looked at my sys.path variable and I see that it has a whole bunch of site-package directories, followed by the contents of my $PYTHONPATH variable, followed by a list of misc site-package variables (see below). I've verified that if I manually reverse the order of sys.path I can then import the proper version of the module that I want. But this is not a permanent solution for me as this will mess up other people are who working with the same code. But, I'm curious as to where the first bunch of 'site-package' entries come from. The /usr/lib64/python2.5/site-packages/pyhdfeos-1.0_r57_58-py2.5-linux-x86_64.egg is not present in any of my environmental variables yet it shows up as one of the first entries in sys.path. A colleague of mine is running on the same system as I am, and he does not have the problem of the /usr/lib64/python2.5/site-packages/pyhdfeos-1.0_r57_58-py2.5-linux-x86_64.egg variable showing up as one of the first entries in sys.path. Thanks for the education, Catherine Dan Stromberg wrote: > On Tue, Jan 11, 2011 at 4:30 PM, Catherine Moroney > wrote: >> In what order does python import modules on a Linux system? I have a >> package that is both installed in /usr/lib64/python2.5/site-packages, >> and a newer version of the same module in a working directory. >> >> I want to import the version from the working directory, but when I >> print module.__file__ in the interpreter after importing the module, >> I get the version that's in site-packages. >> >> I've played with the PYTHONPATH environmental variable by setting it >> to just the path of the working directory, but when I import the module >> I still pick up the version in site-packages. >> >> /usr/lib64 is in my PATH variable, but doesn't appear anywhere else. I >> don't want to remove /usr/lib64 from my PATH because that will break >> a lot of stuff. >> >> Can I force python to import from my PYTHONPATH first, before looking >> in the system directory? >> >> Catherine >> -- >> http://mail.python.org/mailman/listinfo/python-list > > Please import sys and inspect sys.path; this defines the search path > for imports. > > By looking at sys.path, you can see where in the search order your > $PYTHONPATH is going. > > It might actually be better to give your script a command line option > that says "Throw the following directory at the beginning of > sys.path". From usernet at ilthio.net Wed Jan 12 14:41:53 2011 From: usernet at ilthio.net (Tim Harig) Date: Wed, 12 Jan 2011 19:41:53 +0000 (UTC) Subject: Nested structures question References: Message-ID: On 2011-01-12, Physics Python wrote: > while guess != the_number: ================================================= > while tries > 7: > if guess > the_number: > print "Lower..." > else: > print "Higher..." > guess = int(raw_input("Take a guess: ")) > tries += 1 ================================================= Think about what happens when this nested loop exits because tries > 7? It returns to the outer loop whether or not the actual number was guessed correctly. There is no real need for this loop. > print "You guessed it! The number was: ", the_number > print "And it only took you", tries, "tries!\n" Note that the outer loop ends here without any test to see whether or not the number was actually guested and there is *nothing* that stops this outer loop, so it will spin forever. > print "Wow, you suck at this, you should be able to solve this in 7 attempts or less" > > raw_input("Press Enter to exit the program.") This is never reached. From invalid at invalid.invalid Wed Jan 12 14:51:00 2011 From: invalid at invalid.invalid (Grant Edwards) Date: Wed, 12 Jan 2011 19:51:00 +0000 (UTC) Subject: Python use growing fast References: Message-ID: On 2011-01-12, Terry Reedy wrote: > On 1/12/2011 9:51 AM, Colin J. Williams wrote: > >>> It shows an example of Python code, which happens to have 2 syntax >>> errors! >> >> Why not correct the Wikipedia entry? > > As I reported early, the errors, if any, are in .png and .svg images of > text, which would have to be replaced, not corrected. Would be good > since the imaged snippet is a haphazard except from a much larger file > and inane out of context. OK, but that answerws the question "what's wrong with it?", not "why not fix it?" -- Grant Edwards grant.b.edwards Yow! Thousands of days of at civilians ... have produced gmail.com a ... feeling for the aesthetic modules -- From physicsandpython at gmail.com Wed Jan 12 14:52:33 2011 From: physicsandpython at gmail.com (Physics Python) Date: Wed, 12 Jan 2011 11:52:33 -0800 (PST) Subject: Nested structures question In-Reply-To: Message-ID: <89b61e2d-cb26-4a44-9c86-57e7461a9eb8@glegroupsg2000goo.googlegroups.com> Thanks, Is this an indentation problem then? How do I update the sentinel within the secondary while loop. I am trying to avoid using breaks by the way, as I can program this example using breaks: --- start--- import random print "\tWelcome to 'Guess my number'!:" print "\nI'm thinking of a number between 1 and 100." print "Try to guess it in as few attempts as possible.\n" the_number = random.randrange(1,101) tries = 0 while True: guess = int(raw_input("Take a guess: ")) tries += 1 if guess > the_number: print "Lower..." elif guess < the_number: print "Higher..." else: print "You guessed it! The number was", the_number print "And it only took you", tries, "tries!\n" break if tries == 7: print "Wow you suck! It should only take at most 7 tries!" break raw_input ("\n\nPress the enter key to exit.") --- end --- But the book states that this can be done without needing to use breaks. Thanks! From jasons at adventureaquarium.com Wed Jan 12 15:04:36 2011 From: jasons at adventureaquarium.com (Jason Staudenmayer) Date: Wed, 12 Jan 2011 15:04:36 -0500 Subject: Nested structures question In-Reply-To: <89b61e2d-cb26-4a44-9c86-57e7461a9eb8@glegroupsg2000goo.googlegroups.com> Message-ID: Return False instead of break should work else: print "You guessed it! The number was", the_number print "And it only took you", tries, "tries!\n" return False Jason ..?><((((?> > -----Original Message----- > From: > python-list-bounces+jasons=adventureaquarium.com at python.org > [mailto:python-list-bounces+jasons=adventureaquarium.com at pytho > n.org] On Behalf Of Physics Python > Sent: Wednesday, January 12, 2011 2:53 PM > To: python-list at python.org > Subject: Re: Nested structures question > > > Thanks, > > Is this an indentation problem then? > How do I update the sentinel within the secondary while loop. > I am trying to avoid using breaks by the way, as I can > program this example using breaks: > > --- start--- > import random > print "\tWelcome to 'Guess my number'!:" > print "\nI'm thinking of a number between 1 and 100." > print "Try to guess it in as few attempts as possible.\n" > > the_number = random.randrange(1,101) > > tries = 0 > > while True: > guess = int(raw_input("Take a guess: ")) > tries += 1 > if guess > the_number: > print "Lower..." > elif guess < the_number: > print "Higher..." > else: > print "You guessed it! The number was", the_number > print "And it only took you", tries, "tries!\n" > break > if tries == 7: > print "Wow you suck! It should only take at most 7 tries!" > break > > raw_input ("\n\nPress the enter key to exit.") > > --- end --- > > But the book states that this can be done without needing to > use breaks. > > Thanks! > -- > http://mail.python.org/mailman/listinfo/python-list > From usernet at ilthio.net Wed Jan 12 15:12:11 2011 From: usernet at ilthio.net (Tim Harig) Date: Wed, 12 Jan 2011 20:12:11 +0000 (UTC) Subject: Nested structures question References: <89b61e2d-cb26-4a44-9c86-57e7461a9eb8@glegroupsg2000goo.googlegroups.com> Message-ID: [wrapped lines to <80 characters per RFC 1855] On 2011-01-12, Physics Python wrote: > Is this an indentation problem then? That depends how you look at it. I was not clear from your code exactly where you wanted to handle things. > How do I update the sentinel within the secondary while loop. I am > trying to avoid using breaks by the way, as I can program this example > using breaks: You don't need breaks. > import random > print "\tWelcome to 'Guess my number'!:" > print "\nI'm thinking of a number between 1 and 100." > print "Try to guess it in as few attempts as possible.\n" > > the_number = random.randrange(1,101) > > tries = 0 > > while True: while can be used to test for more then a single condition at a time using and/or chains. > else: > print "You guessed it! The number was", the_number > print "And it only took you", tries, "tries!\n" > break > if tries == 7: > print "Wow you suck! It should only take at most 7 tries!" > break Both of these tests can be performed as part of the loop itself. The end results can therefore be tested and handled outside of the loop without using breaks. From usernet at ilthio.net Wed Jan 12 15:22:24 2011 From: usernet at ilthio.net (Tim Harig) Date: Wed, 12 Jan 2011 20:22:24 +0000 (UTC) Subject: Nested structures question References: Message-ID: On 2011-01-12, Jason Staudenmayer wrote: > Return False instead of break should work > > else: > print "You guessed it! The number was", the_number > print "And it only took you", tries, "tries!\n" > return False Since he isn't in a function, that isn't any good. He would import sys and use sys.exit() but that rather defeats the purpose of having a single entry and exit point to the loop. From __peter__ at web.de Wed Jan 12 15:43:22 2011 From: __peter__ at web.de (Peter Otten) Date: Wed, 12 Jan 2011 21:43:22 +0100 Subject: How to populate all possible hierarchical clusterings from a set of elements? References: <3cb5ae7e-866d-40fb-ae3f-496193db91e4@t35g2000yqj.googlegroups.com> Message-ID: justin wrote: > The title sounds too complex, but my question is actually simple. > > Suppose I have [1,2,3,4,5], then there are many ways of making > clustering. > Among them, I want to pair up terminals until there is only one left > at the end. > For example, ((((1,2),3),4),5), (1,(2,(3,(4,5)))), or (((1,2),(3,4)), > 5) would be legitimate ones. > > How do you think can I, using the modules of Python such as itertools > as much as possible, make all possible such clusterings? Here's my first attempt: def cluster(items): if len(items) == 2: yield items return for i in range(len(items)-1): for c in cluster(items[:i] + (items[i:i+2],) + items[i+2:]): yield c def unique(items): seen = set() for item in items: if item not in seen: seen.add(item) yield item if __name__ == "__main__": for item in unique(cluster(tuple("abcd"))): print item Unfortunately I get a lot of duplicates :( You could define a kind of operator precedence using itertools.combinations(), but I think it suffers from the same problem as a 3 b 1 c 2 d and a 2 b 1 c 3 d would both result in ((a, b), (c, d)). From scott.mccarty at gmail.com Wed Jan 12 16:05:22 2011 From: scott.mccarty at gmail.com (Scott McCarty) Date: Wed, 12 Jan 2011 16:05:22 -0500 Subject: How to Buffer Serialized Objects to Disk Message-ID: Sorry to ask this question. I have search the list archives and googled, but I don't even know what words to find what I am looking for, I am just looking for a little kick in the right direction. I have a Python based log analysis program called petit ( http://crunchtools.com/petit). I am trying to modify it to manage the main object types to and from disk. Essentially, I have one object which is a list of a bunch of "Entry" objects. The Entry objects have date, time, date, etc fields which I use for analysis techniques. At the very beginning I build up the list of objects then would like to start pickling it while building to save memory. I want to be able to process more entries than I have memory. With a strait list it looks like I could build from xreadlines(), but once you turn it into a more complex object, I don't quick know where to go. I understand how to pickle the entire data structure, but I need something that will manage the memory/disk allocation? Any thoughts? Gracias Scott M -------------- next part -------------- An HTML attachment was scrubbed... URL: From alice at gothcandy.com Wed Jan 12 16:08:47 2011 From: alice at gothcandy.com (=?utf-8?Q?Alice_Bevan=E2=80=93McGregor?=) Date: Wed, 12 Jan 2011 13:08:47 -0800 Subject: Python use growing fast References: <4d2b8844$0$43996$742ec2ed@news.sonic.net> Message-ID: On 2011-01-10 19:49:47 -0800, Roy Smith said: > One of the surprising (to me, anyway) uses of JavaScript is as the > scripting language for MongoDB (http://www.mongodb.org/). I just wish they'd drop spidermonkey and go with V8 or another, faster and more modern engine. :( - Alice. From crebert at ucsd.edu Wed Jan 12 16:31:59 2011 From: crebert at ucsd.edu (Chris Rebert) Date: Wed, 12 Jan 2011 13:31:59 -0800 Subject: order of importing modules In-Reply-To: <4D2DFBEC.1070605@jpl.nasa.gov> References: <4D2CF61E.7010500@jpl.nasa.gov> <4D2DFBEC.1070605@jpl.nasa.gov> Message-ID: > Dan Stromberg wrote: >> On Tue, Jan 11, 2011 at 4:30 PM, Catherine Moroney >> wrote: >>> >>> In what order does python import modules on a Linux system? ?I have a >>> package that is both installed in /usr/lib64/python2.5/site-packages, >>> and a newer version of the same module in a working directory. >>> >>> I want to import the version from the working directory, but when I >>> print module.__file__ in the interpreter after importing the module, >>> I get the version that's in site-packages. >>> >>> I've played with the PYTHONPATH environmental variable by setting it >>> to just the path of the working directory, but when I import the module >>> I still pick up the version in site-packages. >>> >>> /usr/lib64 is in my PATH variable, but doesn't appear anywhere else. ?I >>> don't want to remove /usr/lib64 from my PATH because that will break >>> a lot of stuff. >>> >>> Can I force python to import from my PYTHONPATH first, before looking >>> in the system directory? >>> >> Please import sys and inspect sys.path; this defines the search path >> for imports. >> >> By looking at sys.path, you can see where in the search order your >> $PYTHONPATH is going. >> On Wed, Jan 12, 2011 at 11:07 AM, Catherine Moroney wrote: > I've looked at my sys.path variable and I see that it has > a whole bunch of site-package directories, followed by the > contents of my $PYTHONPATH variable, followed by a list of > misc site-package variables (see below). > But, I'm curious as to where the first bunch of 'site-package' > entries come from. ?The > /usr/lib64/python2.5/site-packages/pyhdfeos-1.0_r57_58-py2.5-linux-x86_64.egg > is not present in any of my environmental variables yet it shows up > as one of the first entries in sys.path. You probably have a .pth file somewhere that adds it (since it's an egg, probably site-packages/easy-install.pth). See http://docs.python.org/install/index.html#modifying-python-s-search-path Cheers, Chris -- http://blog.rebertia.com From python at mrabarnett.plus.com Wed Jan 12 16:32:49 2011 From: python at mrabarnett.plus.com (MRAB) Date: Wed, 12 Jan 2011 21:32:49 +0000 Subject: How to Buffer Serialized Objects to Disk In-Reply-To: References: Message-ID: <4D2E1E01.2070907@mrabarnett.plus.com> On 12/01/2011 21:05, Scott McCarty wrote: > Sorry to ask this question. I have search the list archives and googled, > but I don't even know what words to find what I am looking for, I am > just looking for a little kick in the right direction. > > I have a Python based log analysis program called petit > (http://crunchtools.com/petit). I am trying to modify it to manage the > main object types to and from disk. > > Essentially, I have one object which is a list of a bunch of "Entry" > objects. The Entry objects have date, time, date, etc fields which I use > for analysis techniques. At the very beginning I build up the list of > objects then would like to start pickling it while building to save > memory. I want to be able to process more entries than I have memory. > With a strait list it looks like I could build from xreadlines(), but > once you turn it into a more complex object, I don't quick know where to go. > > I understand how to pickle the entire data structure, but I need > something that will manage the memory/disk allocation? Any thoughts? > To me it sounds like you need to use a database. From clp2 at rebertia.com Wed Jan 12 16:41:32 2011 From: clp2 at rebertia.com (Chris Rebert) Date: Wed, 12 Jan 2011 13:41:32 -0800 Subject: How to Buffer Serialized Objects to Disk In-Reply-To: References: Message-ID: On Wed, Jan 12, 2011 at 1:05 PM, Scott McCarty wrote: > Sorry to ask this question. I have search the list archives and googled, but > I don't even know what words to find what I am looking for, I am just > looking for a little kick in the right direction. > I have a Python based log analysis program called petit > (http://crunchtools.com/petit). I am trying to modify it to manage the main > object types to and from disk. > Essentially, I have one object which is a list of a bunch of "Entry" > objects. The Entry objects have date, time, date, etc fields which I use for > analysis techniques. At the very beginning I build up the list of objects > then would like to start pickling it while building to save memory. I want > to be able to process more entries than I have memory. With a strait list it > looks like I could build from xreadlines(), but once you turn it into a more > complex object, I don't quick know where to go. > I understand how to pickle the entire data structure, but I need something > that will manage the memory/disk allocation? ?Any thoughts? You could subclass `list` and use sys.getsizeof() [http://docs.python.org/library/sys.html#sys.getsizeof ] to keep track of the size of the elements, and then start pickling them to disk once the total size reaches some preset limit. But like MRAB said, using a proper database, e.g. SQLite (http://docs.python.org/library/sqlite3.html ), wouldn't be a bad idea either. Cheers, Chris -- http://blog.rebertia.com From __peter__ at web.de Wed Jan 12 17:04:52 2011 From: __peter__ at web.de (Peter Otten) Date: Wed, 12 Jan 2011 23:04:52 +0100 Subject: How to Buffer Serialized Objects to Disk References: Message-ID: Scott McCarty wrote: > Sorry to ask this question. I have search the list archives and googled, > but I don't even know what words to find what I am looking for, I am just > looking for a little kick in the right direction. > > I have a Python based log analysis program called petit ( > http://crunchtools.com/petit). I am trying to modify it to manage the main > object types to and from disk. > > Essentially, I have one object which is a list of a bunch of "Entry" > objects. The Entry objects have date, time, date, etc fields which I use > for analysis techniques. At the very beginning I build up the list of > objects then would like to start pickling it while building to save > memory. I want to be able to process more entries than I have memory. With > a strait list it looks like I could build from xreadlines(), but once you > turn it into a more complex object, I don't quick know where to go. > > I understand how to pickle the entire data structure, but I need something > that will manage the memory/disk allocation? Any thoughts? You can write multiple pickled objects into a single file: import cPickle as pickle def dump(filename, items): with open(filename, "wb") as out: dump = pickle.Pickler(out).dump for item in items: dump(item) def load(filename): with open(filename, "rb") as instream: load = pickle.Unpickler(instream).load while True: try: item = load() except EOFError: break yield item if __name__ == "__main__": filename = "tmp.pickle" from collections import namedtuple T = namedtuple("T", "alpha beta") dump(filename, (T(a, b) for a, b in zip("abc", [1,2,3]))) for item in load(filename): print item To get random access you'd have to maintain a list containing the offsets of the entries in the file. However, a simple database like SQLite is probably sufficient for the kind of entries you have in mind, and it allows operations like aggregation, sorting and grouping out of the box. Peter From clp2 at rebertia.com Wed Jan 12 17:06:08 2011 From: clp2 at rebertia.com (Chris Rebert) Date: Wed, 12 Jan 2011 14:06:08 -0800 Subject: Best way to automatically copy out attachments from an email In-Reply-To: References: Message-ID: On Wed, Jan 12, 2011 at 10:59 AM, Matty Sarro wrote: > As of now here is my situation: > I am working on a system to aggregate IT data and logs. A number of > important data are gathered by a third party system. The only > immediate way I have to access the data is to have their system > automatically email me updates in CSV format every hour. If I set up a > mail client on the server, this shouldn't be a huge issue. > > However, is there a way to automatically open the emails, and copy the > attachments to a directory based on the filename? Kind of a weird > project, I know. Just looking for some ideas hence posting this on two > lists. Parsing out email attachments: http://docs.python.org/library/email.parser.html http://docs.python.org/library/email.message.html#module-email.message Parsing the extension from a filename: http://docs.python.org/library/os.path.html#os.path.splitext Retrieving email from a mail server: http://docs.python.org/library/poplib.html http://docs.python.org/library/imaplib.html You could poll for new messages via a cron job or the `sched` module (http://docs.python.org/library/sched.html ). Or if the messages are being delivered locally, you could use inotify bindings or similar to watch the appropriate directory for incoming mail. Integration with a mail server itself is also a possibility, but I don't know much about that. Cheers, Chris -- http://blog.rebertia.com From aahz at pythoncraft.com Wed Jan 12 17:07:28 2011 From: aahz at pythoncraft.com (Aahz) Date: 12 Jan 2011 14:07:28 -0800 Subject: Parsing string for " " References: <0d7143ca-45cf-44c3-9e8d-acb867c52037@f30g2000yqa.googlegroups.com> Message-ID: In article <0d7143ca-45cf-44c3-9e8d-acb867c52037 at f30g2000yqa.googlegroups.com>, Daniel da Silva wrote: > >I have come across a task where I would like to scan a short 20-80 >character line of text for instances of " ". Ideally > could be of any tense. In Soviet Russia, you! -- Aahz (aahz at pythoncraft.com) <*> http://www.pythoncraft.com/ "Think of it as evolution in action." --Tony Rand From usernet at ilthio.net Wed Jan 12 17:19:25 2011 From: usernet at ilthio.net (Tim Harig) Date: Wed, 12 Jan 2011 22:19:25 +0000 (UTC) Subject: Nested structures question References: <89b61e2d-cb26-4a44-9c86-57e7461a9eb8@glegroupsg2000goo.googlegroups.com> Message-ID: In case you still need help: - # Set the initial values - the_number= random.randrange(100) + 1 - tries = 0 - guess = None - - # Guessing loop - while guess != the_number and tries < 7: - guess = int(raw_input("Take a guess: ")) - if guess > the_number: - print "Lower..." - elif guess < the_number: - print "Higher..." - tries += 1 - - # did the user guess correctly to make too many guesses? - if guess == the_number: - print "You guessed it! The number was", the_number - print "And it only took you", tries, "tries!\n" - else: - print "Wow you suck! It should only take at most 7 tries!" - - raw_input("Press Enter to exit the program.") From scott.mccarty at gmail.com Wed Jan 12 17:29:19 2011 From: scott.mccarty at gmail.com (Scott McCarty) Date: Wed, 12 Jan 2011 17:29:19 -0500 Subject: How to Buffer Serialized Objects to Disk In-Reply-To: References: Message-ID: Been digging ever since I posted this. I suspected that the response might be use a database. I am worried I am trying to reinvent the wheel. The problem is I don't want any dependencies and I also don't need persistence program runs. I kind of wanted to keep the use of petit very similar to cat, head, awk, etc. But, that said, I have realized that if I provide the analysis features as an API, you very well, might want persistence between runs. What about using an array inside a shelve? Just got done messing with this in python shell: import shelve d = shelve.open(filename="/root/test.shelf", protocol=-1) d["log"] = () d["log"].append("test1") d["log"].append("test2") d["log"].append("test3") Then, always interacting with d["log"], for example: for i in d["log"]: print i Thoughts? I know this won't manage memory, but it will keep the footprint down right? On Wed, Jan 12, 2011 at 5:04 PM, Peter Otten <__peter__ at web.de> wrote: > Scott McCarty wrote: > > > Sorry to ask this question. I have search the list archives and googled, > > but I don't even know what words to find what I am looking for, I am just > > looking for a little kick in the right direction. > > > > I have a Python based log analysis program called petit ( > > http://crunchtools.com/petit). I am trying to modify it to manage the > main > > object types to and from disk. > > > > Essentially, I have one object which is a list of a bunch of "Entry" > > objects. The Entry objects have date, time, date, etc fields which I use > > for analysis techniques. At the very beginning I build up the list of > > objects then would like to start pickling it while building to save > > memory. I want to be able to process more entries than I have memory. > With > > a strait list it looks like I could build from xreadlines(), but once you > > turn it into a more complex object, I don't quick know where to go. > > > > I understand how to pickle the entire data structure, but I need > something > > that will manage the memory/disk allocation? Any thoughts? > > You can write multiple pickled objects into a single file: > > import cPickle as pickle > > def dump(filename, items): > with open(filename, "wb") as out: > dump = pickle.Pickler(out).dump > for item in items: > dump(item) > > def load(filename): > with open(filename, "rb") as instream: > load = pickle.Unpickler(instream).load > while True: > try: > item = load() > except EOFError: > break > yield item > > if __name__ == "__main__": > filename = "tmp.pickle" > from collections import namedtuple > T = namedtuple("T", "alpha beta") > dump(filename, (T(a, b) for a, b in zip("abc", [1,2,3]))) > for item in load(filename): > print item > > To get random access you'd have to maintain a list containing the offsets > of > the entries in the file. > However, a simple database like SQLite is probably sufficient for the kind > of entries you have in mind, and it allows operations like aggregation, > sorting and grouping out of the box. > > Peter > > -- > http://mail.python.org/mailman/listinfo/python-list > -------------- next part -------------- An HTML attachment was scrubbed... URL: From __peter__ at web.de Wed Jan 12 17:49:43 2011 From: __peter__ at web.de (Peter Otten) Date: Wed, 12 Jan 2011 23:49:43 +0100 Subject: How to Buffer Serialized Objects to Disk References: Message-ID: Scott McCarty wrote: > Been digging ever since I posted this. I suspected that the response might > be use a database. I am worried I am trying to reinvent the wheel. The > problem is I don't want any dependencies and I also don't need persistence > program runs. I don't think sqlite3 counts as a dependency these days. > I kind of wanted to keep the use of petit very similar to > cat, head, awk, etc. But, that said, I have realized that if I provide the > analysis features as an API, you very well, might want persistence between > runs. > > What about using an array inside a shelve? > > Just got done messing with this in python shell: > > import shelve > > d = shelve.open(filename="/root/test.shelf", protocol=-1) > > d["log"] = () > d["log"].append("test1") > d["log"].append("test2") > d["log"].append("test3") > > Then, always interacting with d["log"], for example: > > for i in d["log"]: > print i > > Thoughts? That won't save you any memory as the whole value (the complete list) is unpickled once you say d["log"]. From awilliam at whitemice.org Wed Jan 12 18:08:20 2011 From: awilliam at whitemice.org (Adam Tauno Williams) Date: Wed, 12 Jan 2011 18:08:20 -0500 Subject: How to Buffer Serialized Objects to Disk In-Reply-To: References: Message-ID: <1294873700.7831.3.camel@linux-yu4c.site> On Wed, 2011-01-12 at 17:29 -0500, Scott McCarty wrote: > Been digging ever since I posted this. I suspected that the response > might be use a database. I use shelve extensively; there are many use-cases where it makes sense. And there are many where a database makes sense. Basically, if I just want key based lookup and the data fits in memory I use a shelve. > The problem is I don't want any dependencies and I also don't need > persistence program runs. I kind of wanted to keep the use of petit > very similar to cat, head, awk, etc. But, that said, I have realized > that if I provide the analysis features as an API, you very well, > might want persistence between runs. > What about using an array inside a shelve? > Just got done messing with this in python shell: > import shelve > d = shelve.open(filename="/root/test.shelf", protocol=-1) > d["log"] = () > d["log"].append("test1") > d["log"].append("test2") > d["log"].append("test3") > Then, always interacting with d["log"], for example: > for i in d["log"]: > print i > Thoughts? That is fine so long as all your data fits comfortable in memory. > I know this won't manage memory, but it will keep the footprint down > right? No. All of "log" will always be in memory. From roy at panix.com Wed Jan 12 18:43:00 2011 From: roy at panix.com (Roy Smith) Date: Wed, 12 Jan 2011 18:43:00 -0500 Subject: Python use growing fast References: <4d2b8844$0$43996$742ec2ed@news.sonic.net> Message-ID: In article , Alice Bevan?McGregor wrote: > On 2011-01-10 19:49:47 -0800, Roy Smith said: > > > One of the surprising (to me, anyway) uses of JavaScript is as the > > scripting language for MongoDB (http://www.mongodb.org/). > > I just wish they'd drop spidermonkey and go with V8 or another, faster > and more modern engine. :( Could be. I've opened a few bugs against Mongo which were explained away as "it's really a bug in SM". From nambo4jb at gmail.com Wed Jan 12 19:35:46 2011 From: nambo4jb at gmail.com (Cathy James) Date: Wed, 12 Jan 2011 18:35:46 -0600 Subject: cipher encoding Message-ID: Dear all, I hope someone out there can help me. The output string of my code is close to what i need, but i need it 1)printed on one line and 2) reversed #mycode: s= input("Enter message: ") key=1 for letter in s: num=(chr(ord(letter)+1)) print(num) #or is there a better way to rewrite it with elementary level Python, which happens 2b my current ranking. #Your insight is always appreciated:) -------------- next part -------------- An HTML attachment was scrubbed... URL: From kb1pkl at aim.com Wed Jan 12 19:39:14 2011 From: kb1pkl at aim.com (Corey Richardson) Date: Wed, 12 Jan 2011 19:39:14 -0500 Subject: cipher encoding In-Reply-To: References: Message-ID: <4D2E49B2.9010602@aim.com> On 01/12/2011 07:35 PM, Cathy James wrote: > Dear all, > > I hope someone out there can help me. > > The output string of my code is close to what i need, but i need it > 1)printed on one line and > 2) reversed > > #mycode: > s= input("Enter message: ") > key=1 > for letter in s: > num=(chr(ord(letter)+1)) > print(num) > #or is there a better way to rewrite it with elementary level Python, > which happens 2b my current ranking. > #Your insight is always appreciated:) > s = input("Enter message: ") key = int(input("Enter offset: ")) # I think that's what you wanted for letter in s: print(chr(ord(letter) + key), end = "") From kb1pkl at aim.com Wed Jan 12 19:49:19 2011 From: kb1pkl at aim.com (Corey Richardson) Date: Wed, 12 Jan 2011 19:49:19 -0500 Subject: cipher encoding In-Reply-To: <4D2E49B2.9010602@aim.com> References: <4D2E49B2.9010602@aim.com> Message-ID: <4D2E4C0F.6030804@aim.com> On 01/12/2011 07:39 PM, Corey Richardson wrote: > On 01/12/2011 07:35 PM, Cathy James wrote: >> Dear all, >> >> I hope someone out there can help me. >> >> The output string of my code is close to what i need, but i need it >> 1)printed on one line and >> 2) reversed >> >> #mycode: >> s= input("Enter message: ") >> key=1 >> for letter in s: >> num=(chr(ord(letter)+1)) >> print(num) >> #or is there a better way to rewrite it with elementary level Python, >> which happens 2b my current ranking. >> #Your insight is always appreciated:) >> > > s = input("Enter message: ") > key = int(input("Enter offset: ")) # I think that's what you wanted > for letter in s: > print(chr(ord(letter) + key), end = "") > Oh, and you wanted it reversed. That's not hard. message = input("Enter message: ") key = int(input("Enter offset: ")) new_message = "" for char in message: new_message += chr(ord(letter) + key) print(new_message[::-1]) From nstinemates at gmail.com Wed Jan 12 19:50:15 2011 From: nstinemates at gmail.com (Nick Stinemates) Date: Wed, 12 Jan 2011 16:50:15 -0800 Subject: cipher encoding In-Reply-To: References: Message-ID: Try print s[::-1] Nick On Wednesday, January 12, 2011, Cathy James wrote: > Dear all, > > I hope someone out there can help me. > > ?The output string of my code is close to what i need, but i need it > 1)printed on one line and > > 2) reversed > > > #mycode: > s= input("Enter message: ") > key=1 > for letter in s: > ??? num=(chr(ord(letter)+1)) > ??? print(num) > #or is there a better way to rewrite it with elementary level Python, which happens 2b my current ranking. > #Your insight is always appreciated:) > From python at mrabarnett.plus.com Wed Jan 12 20:05:30 2011 From: python at mrabarnett.plus.com (MRAB) Date: Thu, 13 Jan 2011 01:05:30 +0000 Subject: cipher encoding In-Reply-To: <4D2E4C0F.6030804@aim.com> References: <4D2E49B2.9010602@aim.com> <4D2E4C0F.6030804@aim.com> Message-ID: <4D2E4FDA.4070704@mrabarnett.plus.com> On 13/01/2011 00:49, Corey Richardson wrote: > On 01/12/2011 07:39 PM, Corey Richardson wrote: >> On 01/12/2011 07:35 PM, Cathy James wrote: >>> Dear all, >>> >>> I hope someone out there can help me. >>> >>> The output string of my code is close to what i need, but i need it >>> 1)printed on one line and >>> 2) reversed >>> >>> #mycode: >>> s= input("Enter message: ") >>> key=1 >>> for letter in s: >>> num=(chr(ord(letter)+1)) >>> print(num) >>> #or is there a better way to rewrite it with elementary level Python, >>> which happens 2b my current ranking. >>> #Your insight is always appreciated:) >>> >> >> s = input("Enter message: ") >> key = int(input("Enter offset: ")) # I think that's what you wanted >> for letter in s: >> print(chr(ord(letter) + key), end = "") >> > Oh, and you wanted it reversed. That's not hard. > > message = input("Enter message: ") > key = int(input("Enter offset: ")) > new_message = "" > for char in message: > new_message += chr(ord(letter) + key) > print(new_message[::-1]) It's neater with: for char in reversed(message): then you don't need 'new_message'. From devplayer at gmail.com Wed Jan 12 20:15:20 2011 From: devplayer at gmail.com (DevPlayer) Date: Wed, 12 Jan 2011 17:15:20 -0800 (PST) Subject: Which coding style is better? public API or private method inside class definition References: <0470dc9d-2a5f-40d4-afd4-97796059ba0a@q8g2000prm.googlegroups.com> Message-ID: <6e9f2bdb-e08d-4864-9e0c-4d39ac6d11d1@b25g2000vbz.googlegroups.com> On Jan 4, 11:46?pm, Inyeol wrote: > Which coding style do you prefer? I'm more toward public API way, > since it requires less code change if I refactor private data > structure later. > Plz give pros and cons of these. Great question. It gets at the heart of Python style. It's a tricky question and can be answered so many ways. I'm not a pro- programmer anymore so here's my hobbyst's take on it. First, API is application programming interface. Follow me for a sec. It's the interface that your programmers use to use your "package". But WHICH programmers? For large apps like game developers or large all encompassing apps for companys there are many different types of programmers. That helps determine how heavy to lean towards private verse public interfaces. Funny thing is I end up using the private interfaces as much as the public interaces for certain things. For example when coding in wxPython I rarely use any private apis (ie. __dict__ or other "special or magic named" attributes). But when coding outside of wxPython I'm all over the place defining new classes with special named attributes like __new__ or __metaclass__, and lots and lots of other magic named methods and private attributes. So one way to decide whether to be coding towards more public verse private is where in your project you are. Building infrastructure and framework verse building "application" and end-user interfaces. Or similarly the interface TO the API interface is private (as far as Python considers things private that is). The interface to all others to use your "package" is public. And if your code is not a package for other coders, then what is the sense in having private anythings? One thing that mungles one's mind into thinking it matters is your IDE tools. When you run your scripts as an end user, who cares that there's tons of objects cluttering your namespace - I'm implying that using private API in that case is somewhat a waste. When in your IDE coding like PyCrust and you type in the interface something like wx. you'll get a popup of "attributes" and you think "ah, these attributes and methods I can use". But in use of that program, there's no sense in hidding stuff with underscored names. On the otherhand. I like to think my namespaces are simple, clean, uncluttered. There's less "What the heck is that thing" while looking at dir() and debugging. Personally I do not like the underscore. My hands don't like the keystroke pattern. And the underscore is butt ugly to me. Ugly does not equal "less readable". I find underscore easier to read then camel case/Hungarian Notation (wx and .NET has a lot of that). Although name mangling and camel case usage are different things, from a visual (of source code), to me they are the same. Also when there is name mangling, there is often an unmangled version of it in some usage somewhere in your code. Another thought. Although private interfaces are not intended to be SEEN, you code your private interfaces (i.e. attributes and methods, functions, etc) to denote themselves as private when you LOOK at them by using underscores. I'd rather have my source code just color private attributes differently. However editors are not at that level yet (meaning they'd have to interpret the code to know what's private). Lastly. Shouldn't it be better to use APIs based on the docs instead of analyzing the code for intended public interfaces verse private ones? Although not explicidly listing pros and cons to public verse private APIs I hope I spark some useful insight. From drsalists at gmail.com Wed Jan 12 21:27:51 2011 From: drsalists at gmail.com (Dan Stromberg) Date: Wed, 12 Jan 2011 18:27:51 -0800 Subject: order of importing modules In-Reply-To: <4D2DFBEC.1070605@jpl.nasa.gov> References: <4D2CF61E.7010500@jpl.nasa.gov> <4D2DFBEC.1070605@jpl.nasa.gov> Message-ID: I don't know where the site-packages directories are coming from - maybe a site.py or sitecustomize.py? Sometimes you can strace with a very large -s to see where something like this is coming from. -o is your friend for saving the output to a file in, EG, /tmp. What I usually do is to put specific versions of modules I need, that are different from what the OS is providing, in the same CWD as my script during testing. Then in my experience, CPython imports them instead. When it comes time for a production run, you can drop the special modules into the OS directories somewhere. However, another option is to add a --test command line argument to your script, and make the option just do something like: if '--test' in sys.argv: sys.path.insert(0, os.path.expanduser('~/magic-modules')) ...for example (and that in sys.argv test could probably be improved to fit your program's specifics). On Wed, Jan 12, 2011 at 11:07 AM, Catherine Moroney wrote: > I've looked at my sys.path variable and I see that it has > a whole bunch of site-package directories, followed by the > contents of my $PYTHONPATH variable, followed by a list of > misc site-package variables (see below). > > I've verified that if I manually reverse the order of sys.path > I can then import the proper version of the module that I want. > But this is not a permanent solution for me as this will mess up > other people are who working with the same code. > > But, I'm curious as to where the first bunch of 'site-package' > entries come from. ?The > /usr/lib64/python2.5/site-packages/pyhdfeos-1.0_r57_58-py2.5-linux-x86_64.egg > is not present in any of my environmental variables yet it shows up > as one of the first entries in sys.path. > > A colleague of mine is running on the same system as I am, and he > does not have the problem of the > /usr/lib64/python2.5/site-packages/pyhdfeos-1.0_r57_58-py2.5-linux-x86_64.egg > variable showing up as one of the first entries in sys.path. > > Thanks for the education, > > Catherine > > Dan Stromberg wrote: >> >> On Tue, Jan 11, 2011 at 4:30 PM, Catherine Moroney >> wrote: >>> >>> In what order does python import modules on a Linux system? ?I have a >>> package that is both installed in /usr/lib64/python2.5/site-packages, >>> and a newer version of the same module in a working directory. >>> >>> I want to import the version from the working directory, but when I >>> print module.__file__ in the interpreter after importing the module, >>> I get the version that's in site-packages. >>> >>> I've played with the PYTHONPATH environmental variable by setting it >>> to just the path of the working directory, but when I import the module >>> I still pick up the version in site-packages. >>> >>> /usr/lib64 is in my PATH variable, but doesn't appear anywhere else. ?I >>> don't want to remove /usr/lib64 from my PATH because that will break >>> a lot of stuff. >>> >>> Can I force python to import from my PYTHONPATH first, before looking >>> in the system directory? >>> >>> Catherine >>> -- >>> http://mail.python.org/mailman/listinfo/python-list >> >> Please import sys and inspect sys.path; this defines the search path >> for imports. >> >> By looking at sys.path, you can see where in the search order your >> $PYTHONPATH is going. >> >> It might actually be better to give your script a command line option >> that says "Throw the following directory at the beginning of >> sys.path". > > -- > http://mail.python.org/mailman/listinfo/python-list > From ben+python at benfinney.id.au Wed Jan 12 21:47:50 2011 From: ben+python at benfinney.id.au (Ben Finney) Date: Thu, 13 Jan 2011 13:47:50 +1100 Subject: order of importing modules References: <4D2CF61E.7010500@jpl.nasa.gov> <4D2DFBEC.1070605@jpl.nasa.gov> Message-ID: <87r5chbju1.fsf@benfinney.id.au> (Please don't top-post replies. Instead, reply in-line with the quoted material, removing irrelevant material. An example is this message.) Catherine Moroney writes: > I've looked at my sys.path variable and I see that it has a whole > bunch of site-package directories, followed by the contents of my > $PYTHONPATH variable, followed by a list of misc site-package > variables (see below). Can you show the full list here? What does ?sys.path? actually contain when your Python interpreter is running? > I've verified that if I manually reverse the order of sys.path I can > then import the proper version of the module that I want. I think the PEP 328 relative import feature is likely to be what you want: you can specify that a specific import should search for the file relative to the current module's file, instead of from ?sys.path?. As described earlier, by working through the Python tutorial you will learn about the different styles of import statement, including relative versus absolute . > But, I'm curious as to where the first bunch of 'site-package' entries > come from. The > /usr/lib64/python2.5/site-packages/pyhdfeos-1.0_r57_58-py2.5-linux-x86_64.egg > is not present in any of my environmental variables yet it shows up as > one of the first entries in sys.path. That's probably there because you have used the Setuptools system (or something related) to install a third-party package. That is achieved by meddling with the start-up module search path, to make the third-party package available for import. The result is often a messy search path. Python's system for installing third-party components is far from ideal; it has seen a lot of improvement recently, but on the other hand is carrying a lot of baggage from its earlier design. This is one of the symptoms. > Thanks for the education, I hope that helps! -- \ ?To me, boxing is like a ballet, except there's no music, no | `\ choreography, and the dancers hit each other.? ?Jack Handey | _o__) | Ben Finney From zvictoryz at gmail.com Wed Jan 12 23:20:14 2011 From: zvictoryz at gmail.com (shengli zhang) Date: Thu, 13 Jan 2011 12:20:14 +0800 Subject: The problem of 324 (net::ERR_EMPTY_RESPONSE) Message-ID: This is something I've been fighting for a couple of days. Let me try to describe it as I can. I use "python2.5 + django1.0 + mod_python + apache2" to develop a website. the website has run for two years. But the problem happend these days. when I log in my system, the first browser's sessin will be a error page: 324 (net::ERR_EMPTY_RESPONSE) in Chrom, empty page in Firefox, error in IE, and "exit signal Segmentation fault (11)" in apache error_log. However, when I close this error page and open a new page to log in the system, everything is ok. I have tried many ways to test or solve this problem, but I failed. following is my tries: 1 using "python manage.py runserver" to start project, everything is ok, so django is not a factor of the problem. 2 update the OS's expat to expat-2.0.0 which is accordant with pyexpat of python, the problem remains. 3 replace mod_python to mod_wsgi, the problem remains too. 4 modify apache's httpd.conf to remove some modules of apache, including mod_expires, mod_deflate and libphp5, but I failed again. Any idea about these? Has anyone experienced something similar? Or how shall I approach this further? Thanks a lot! -------------- next part -------------- An HTML attachment was scrubbed... URL: From ddasilva at umd.edu Thu Jan 13 01:21:04 2011 From: ddasilva at umd.edu (Daniel da Silva) Date: Thu, 13 Jan 2011 01:21:04 -0500 Subject: Parsing string for " " In-Reply-To: <4D2D1E9F.2020500@mrabarnett.plus.com> References: <0d7143ca-45cf-44c3-9e8d-acb867c52037@f30g2000yqa.googlegroups.com> <4D2D1E9F.2020500@mrabarnett.plus.com> Message-ID: MRAB, I will check it out. Thanks! Daniel On Tue, Jan 11, 2011 at 10:23 PM, MRAB wrote: > On 12/01/2011 01:50, Daniel da Silva wrote: > >> Hi, >> >> I have come across a task where I would like to scan a short 20-80 >> character line of text for instances of " ". Ideally >> could be of any tense. >> >> I know quite a bit of programming and computer science, but >> computational linguistics is relatively new to me. If anyone can point >> me in the right direction, I would be very thankful! >> >> Have a look at the Natural Language Toolkit: > > http://www.nltk.org/ > -- > http://mail.python.org/mailman/listinfo/python-list > -------------- next part -------------- An HTML attachment was scrubbed... URL: From devplayer at gmail.com Thu Jan 13 01:57:33 2011 From: devplayer at gmail.com (DevPlayer) Date: Wed, 12 Jan 2011 22:57:33 -0800 (PST) Subject: Nested structures question References: Message-ID: looping = True while looping: guess = int(raw_input("Take a guess: ")) tries += 1 if guess > the_number: print "Lower..." elif guess < the_number: print "Higher..." else: print "You guessed it! The number was", the_number print "And it only took you", tries, "tries!\n" break if tries >= 7: print "Wow you suck! It should only take at most 7 tries!" looping = False # Alternatively while learing while looping use the continue statement looping = True while looping: guess = int(raw_input("Take a guess: ")) tries += 1 if guess > the_number: print "Lower..." elif guess < the_number: print "Higher..." else: print "You guessed it! The number was", the_number print "And it only took you", tries, "tries!\n" break if tries < 7: continue print "Wow you suck! It should only take at most 7 tries!" looping = False # In a while loop I recommend to NOT end loops using the # conditional test of == but instead use >, <, >= or <= or !=. # In a complex while loop the exit condition may be skipped # by mistake and you'll loop forever. # In while loops I get less bugs by putting the incrementor as # the last statement in the while block; # this helps follow precedence like range(7) is - zero to 6 # as well as index 0 in a list is the first item. However # while index: where index == 0 will exit the loop before # it even starts as 0 == False (0 is not False but equals False) # Use the while loop for looping an undetermined number of # iterations or conditional iterations. # Use for loops for an explicid number of iterations. for tries in range(7): guess = int(raw_input("Take a guess: ")) if guess > the_number: print "Lower..." elif guess < the_number: print "Higher..." else: print "You guessed it! The number was", the_number print "And it only took you", tries, "tries!\n" break if tries >= 7: print "Wow you suck! It should only take at most 7 tries!" # I'm guessing the chapter's test is to see if you remember the for loop. # start using print() to get into a good habit for Python 3.0+ # I haven't seen the book but often one part of while that is # left off in tutorials is the "else" statement. while condition: "block" else: "block" # you can use else for when the condition never happens. From michele.simionato at gmail.com Thu Jan 13 03:32:03 2011 From: michele.simionato at gmail.com (Michele Simionato) Date: Thu, 13 Jan 2011 00:32:03 -0800 (PST) Subject: Ideas for a module to process command line arguments References: <2ee89e8b-f7f6-48f2-9b7e-6b8592db0c13@k30g2000vbn.googlegroups.com> Message-ID: On Jan 12, 6:09?pm, Alice Bevan?McGregor wrote: > entirely sure what you mean by 'smart' options. ?If your'e referring to > using a single hyphen and a list of characters to represent a long > option (which, to the rest of the world, use two leading hyphens) then > that's pretty weird. ?;) > > One major system in the world that doesn't really differentiate between > long and short options is... DOS, and by extension, Windows. ?But they > also use / as a switch character. Yes, and plac (it is argparse actually) can accomodate the Windows convention by setting the prefix_chars to "/". I wanted to be able to give that freedom even if personally am more used to the GNU double-dash convention. > Anyway; I'm happy with what I have wrought (and am continuing to update > with support for class-based sub-command dispatch) and will be > utilizing it for all scripts in the Marrow suite. ?To each their own, > but reinvention itself can be for motivations other than NIH. ?I wanted > something pure-Python, portable across the 3k barrier without code > modification (no 2to3), that didn't use optparse, getopt, or argparse > and basically be a translation layer. ?It can be simpler than that, as > marrow.script demonstrates. No arguing against that. BTW, I was not criticizing marrow.script, I was simply deploring the situation in the standard library. If the same approach for parsing command-line options is being reinvented by different people multiple times there must be something wrong with the current standard. From devplayer at gmail.com Thu Jan 13 04:23:02 2011 From: devplayer at gmail.com (DevPlayer) Date: Thu, 13 Jan 2011 01:23:02 -0800 (PST) Subject: How to populate all possible hierarchical clusterings from a set of elements? References: <3cb5ae7e-866d-40fb-ae3f-496193db91e4@t35g2000yqj.googlegroups.com> Message-ID: <4e88e8bc-4704-4b07-98dc-1e79b770acae@30g2000yql.googlegroups.com> lst = [1, 2, 3, 4, 5] def maketup(lst): cur_item = lst[-1] lst = lst[:-1] if len(lst): return maketup(lst), cur_item else: return cur_item print maketup(lst) ((((1, 2), 3), 4), 5) But I'm confused as to what you mean by : > Among them, I want to pair up terminals until there is only one left > at the end. One what? one pair?, one terminal meaning one number? From devplayer at gmail.com Thu Jan 13 04:51:02 2011 From: devplayer at gmail.com (DevPlayer) Date: Thu, 13 Jan 2011 01:51:02 -0800 (PST) Subject: How to populate all possible hierarchical clusterings from a set of elements? References: <3cb5ae7e-866d-40fb-ae3f-496193db91e4@t35g2000yqj.googlegroups.com> <4e88e8bc-4704-4b07-98dc-1e79b770acae@30g2000yql.googlegroups.com> Message-ID: def maketup(lst): if len(lst) == 1: return lst[0] elif len(lst) == 2: return (lst[0],lst[1]) elif len(lst) > 2: return ( (maketup(lst[:-2]), lst[-2]), lst[-1]) maketup(lst) ((((1, 2), 3), 4), 5) From alain at dpt-info.u-strasbg.fr Thu Jan 13 05:02:46 2011 From: alain at dpt-info.u-strasbg.fr (Alain Ketterlin) Date: Thu, 13 Jan 2011 11:02:46 +0100 Subject: How to populate all possible hierarchical clusterings from a set of elements? References: <3cb5ae7e-866d-40fb-ae3f-496193db91e4@t35g2000yqj.googlegroups.com> Message-ID: <87tyhdi0jd.fsf@dpt-info.u-strasbg.fr> justin writes: > Suppose I have [1,2,3,4,5], then there are many ways of making > clustering. > Among them, I want to pair up terminals until there is only one left > at the end. Are you trying "ascending hierarchical clustering" by any chance? In that case you're supposed to use some kind of distance to select the (unique) pair of elements to merge at each step. > For example, ((((1,2),3),4),5), (1,(2,(3,(4,5)))), or (((1,2),(3,4)), > 5) would be legitimate ones. > > How do you think can I, using the modules of Python such as itertools > as much as possible, make all possible such clusterings? I don't know about itertools, but the basic idea is: def clusterings(l): if len(l) == 1: print repr(l) else: n = len(l) for i in xrange(n): for j in xrange(i+1,n): clusterings(l[:i]+l[i+1:j]+l[j+1:]+[[l[i],l[j]]]) Test this with: import sys clusterings([i for i in xrange(int(sys.argv[1]))]) Do you realize there are *many* such clusterings? (the exact number should be (n!)*((n-1)!)/2^(n-1) given the code above, if I'm not mistaken.) -- Alain. From alain at dpt-info.u-strasbg.fr Thu Jan 13 05:27:20 2011 From: alain at dpt-info.u-strasbg.fr (Alain Ketterlin) Date: Thu, 13 Jan 2011 11:27:20 +0100 Subject: How to populate all possible hierarchical clusterings from a set of elements? References: <3cb5ae7e-866d-40fb-ae3f-496193db91e4@t35g2000yqj.googlegroups.com> <4e88e8bc-4704-4b07-98dc-1e79b770acae@30g2000yql.googlegroups.com> Message-ID: <87pqs1hzef.fsf@dpt-info.u-strasbg.fr> DevPlayer writes: > def maketup(lst): > > if len(lst) == 1: > return lst[0] > > elif len(lst) == 2: > return (lst[0],lst[1]) > > elif len(lst) > 2: > return ( (maketup(lst[:-2]), lst[-2]), lst[-1]) The OP wants all binary trees over the elements, not just one. -- Alain. From dzizes451 at gmail.com Thu Jan 13 05:28:12 2011 From: dzizes451 at gmail.com (dzizes451) Date: Thu, 13 Jan 2011 02:28:12 -0800 (PST) Subject: File "/usr/lib/python2.6/atexit.py", line 24, in _run_exitfuncs Message-ID: <9c1513be-2fb1-40ae-ad04-56a9574f1313@32g2000yqz.googlegroups.com> Hello! I wrote a python (2.6) deamon running on linux. Program (deamon, manager) collects lets say work-orders from db and creates sub- processes for each one. Sub-processes do their job with out problems, errors, exceptions. However, sometimes deamon throws: Traceback (most recent call last): File "/usr/lib/python2.6/atexit.py", line 24, in _run_exitfuncs func(*targs, **kargs) File "/usr/lib/python2.6/multiprocessing/util.py", line 281, in _exit_function p.join() File "/usr/lib/python2.6/multiprocessing/process.py", line 119, in join res = self._popen.wait(timeout) File "/usr/lib/python2.6/multiprocessing/forking.py", line 117, in wait return self.poll(0) File "/usr/lib/python2.6/multiprocessing/forking.py", line 106, in poll pid, sts = os.waitpid(self.pid, flag) OSError: [Errno 4] Interrupted system call the main deamon process crushes (after some time) and the sub- processes (childs) work fine until their work is finished. below sample code that is responsible for creating sub_processes : #!/usr/bin/python2.6 import pwd import os import sys import time import multiprocessing import signal import traceback from deamon import deamon from post import post class manager(deamon): def __run_subprocess(self, typ, work_order): def runrun(t, z): self.__info('creating object post for %s' %(z)) wns = post(z) self.__info('done creating object post for %s' %(z)) #slownik z choiceem opcji choice = {'typ1': wns.typ1, 'typ2': wns.typ2, 'typ3': wns.typ3} if typ in choice: self.__info('lounching %s for %s' %(t, z)) choice[typ]() else: self.__blad('nie znam %s typu operacji post, znam tylko %s' \ %(t, str(choice))) wns.endit() del(wns) self.__blad('problem with starting proces for =%s, typ= %s' %(z, t)) try: p = multiprocessing.Process(target=runrun, args=(typ,work_order)) self.__info('done preparing proces...') p.start() self.__info('done lounching process...doing join...') p.join() return p.pid except Exception, err: ex = sys.exc_info() sys.stderr.write(str(sys.exc_info())) msg = 'manager.__run_subprocess %s error in line %s' sys.stderr.write(msg %(str(err), ex[2].tb_lineno)) #traceback.print_last() return None def __liczba_wierszy(self, active_child): return int(self._deamon__liczba_proces - active_child) def run(self): try: while True: active_child = len(multiprocessing.active_children()) #czy liczba pod-procesow <= liczba mozliwych pod- procesow if active_child <= self._deamon__liczba_proces: lista_zlecen = self._deamon__baza.get_work( self.__liczba_wierszy(active_child)) if len(lista_zlecen) > 0: for work_order in lista_zlecen: self.__info('start %s' %(work_order)) pid = self.__run_subprocess('typ1',work_order) self.__info('end %s %s' %(work_order, str(pid))) time.sleep(self._deamon__sleep) elif active_child == self.__liczba_proces: msg = 'number of processes %i is equal to maximum %i, '\ 'going sleep for %i seconds' %( active_child, self.__liczba_proces, self._deamon__sleep) self.__info(msg) time.sleep(self._deamon__sleep) else: self.__info('nothing to do... going sleep for %i seconds' %(self._deamon__liczba_proces)) #self._deamon__baza.zamknij_polacznie() time.sleep(self._deamon__sleep) except Exception, err: ei = sys.exc_info() msg = 'manager.run %s\n' %(str(err)) sys.stderr.write('error in line %s\n' % (str(ei[2].tb_lineno))) sys.stderr.write(msg) def receive_sygnal(self, signum, stack): if signum == 10: #print 'otrzymalem sygnal', signum self.__zapisz_status() elif signum == 12: self.__info('cheking if there are any active sub- processes') while len(multiprocessing.active_children()) > 0: self.__info('liczba podprocesow > 0, ide spac na 10 sekund') time.sleep(10) else: print 'got unknown signal', signum From devplayer at gmail.com Thu Jan 13 05:29:32 2011 From: devplayer at gmail.com (DevPlayer) Date: Thu, 13 Jan 2011 02:29:32 -0800 (PST) Subject: How to populate all possible hierarchical clusterings from a set of elements? References: <3cb5ae7e-866d-40fb-ae3f-496193db91e4@t35g2000yqj.googlegroups.com> <4e88e8bc-4704-4b07-98dc-1e79b770acae@30g2000yql.googlegroups.com> Message-ID: <1b177afd-8023-4755-827f-1093fddb6f55@v17g2000yqv.googlegroups.com> tuple([ (tuple(lst[x-1:x+1]) if len(tuple(lst[x-1:x+1]))==2 else lst[x-1]) for x in lst[::2]]) ((1, 2), (3, 4), 5) # or x = ((tuple(lst[x-1:x+1]) if len(tuple(lst[x-1:x+1]))==2 else lst[x-1]) for x in lst[::2]) x.next() (1, 2) x.next() (3, 4) x.next() 5 From devplayer at gmail.com Thu Jan 13 05:31:25 2011 From: devplayer at gmail.com (DevPlayer) Date: Thu, 13 Jan 2011 02:31:25 -0800 (PST) Subject: How to populate all possible hierarchical clusterings from a set of elements? References: <3cb5ae7e-866d-40fb-ae3f-496193db91e4@t35g2000yqj.googlegroups.com> <4e88e8bc-4704-4b07-98dc-1e79b770acae@30g2000yql.googlegroups.com> <87pqs1hzef.fsf@dpt-info.u-strasbg.fr> Message-ID: <4e7d3e84-b48f-4207-b012-0b8b7594bbf9@j29g2000yqm.googlegroups.com> Ah. out of my depth. From krzysztof.t.bieniasz at gmail.com Thu Jan 13 05:54:01 2011 From: krzysztof.t.bieniasz at gmail.com (Krzysztof Bieniasz) Date: Thu, 13 Jan 2011 10:54:01 +0000 (UTC) Subject: cipher encoding References: Message-ID: > Dear all, > > I hope someone out there can help me. > > The output string of my code is close to what i need, but i need it > 1)printed on one line and > 2) reversed > > #mycode: > s= input("Enter message: ") > key=1 > for letter in s: > num=(chr(ord(letter)+1)) > print(num) > #or is there a better way to rewrite it with elementary level Python, > which happens 2b my current ranking. > #Your insight is always appreciated:) If you want it on one line the simplest thing would be to have it in one string: num='' for letter in s: num+=chr(ord(letter)+1) print num[::-1] But if you don't want it that way you can simply write print num, in your original code. The comma suppresses '\n' at the end of print. Only you have to feed letters to the loop in reverse order if you want it reversed. From jeanmichel at sequans.com Thu Jan 13 06:13:02 2011 From: jeanmichel at sequans.com (Jean-Michel Pichavant) Date: Thu, 13 Jan 2011 12:13:02 +0100 Subject: Nested structures question In-Reply-To: References: Message-ID: <4D2EDE3E.7050404@sequans.com> Physics Python wrote: > Hello, > > I am teaching myself python using the book: Python Programming for Absolute Beginners, 2nd edition by Michael Dawson. I am using python 2.7.1. > > In chapter 3 we are learning to use structures (while, if, elif) to write a program that has the user guess a number between 1 and 100. > > Here is the code for the baseline program: > > [snip] here is an example of code using a for loop, which is always better than a while loop, when applicable of course. It uses the for... else... statement which is rather strange at first glance but has some uses, it's always good to know it exists. http://paste.pocoo.org/show/319931/ JM From chardster at gmail.com Thu Jan 13 09:11:32 2011 From: chardster at gmail.com (Richard Thomas) Date: Thu, 13 Jan 2011 06:11:32 -0800 (PST) Subject: How to populate all possible hierarchical clusterings from a set of elements? References: <3cb5ae7e-866d-40fb-ae3f-496193db91e4@t35g2000yqj.googlegroups.com> <87tyhdi0jd.fsf@dpt-info.u-strasbg.fr> Message-ID: <562e7da2-fa99-458f-80cf-01f21d37b1b4@s9g2000vby.googlegroups.com> On Jan 13, 10:02?am, Alain Ketterlin wrote: > justin writes: > > Suppose I have [1,2,3,4,5], then there are many ways of making > > clustering. > > Among them, I want to pair up terminals until there is only one left > > at the end. > > Are you trying "ascending hierarchical clustering" by any chance? In > that case you're supposed to use some kind of distance to select the > (unique) pair of elements to merge at each step. > > > For example, ((((1,2),3),4),5), (1,(2,(3,(4,5)))), or (((1,2),(3,4)), > > 5) would be legitimate ones. > > > How do you think can I, using the modules of Python such as itertools > > as much as possible, make all possible such clusterings? > > I don't know about itertools, but the basic idea is: > > def clusterings(l): > ? ? if len(l) == 1: > ? ? ? ? print repr(l) > ? ? else: > ? ? ? ? n = len(l) > ? ? ? ? for i in xrange(n): > ? ? ? ? ? ? for j in xrange(i+1,n): > ? ? ? ? ? ? ? ? clusterings(l[:i]+l[i+1:j]+l[j+1:]+[[l[i],l[j]]]) > > Test this with: > > import sys > clusterings([i for i in xrange(int(sys.argv[1]))]) > > Do you realize there are *many* such clusterings? (the exact number > should be (n!)*((n-1)!)/2^(n-1) given the code above, if I'm not > mistaken.) > > -- Alain. Actually the number of such "clusterings" is the (n-1)th Catalan number. http://en.wikipedia.org/wiki/Catalan_numbers Chard. From hankfay at gmail.com Thu Jan 13 10:31:34 2011 From: hankfay at gmail.com (Hank Fay) Date: Thu, 13 Jan 2011 07:31:34 -0800 (PST) Subject: Career path - where next? In-Reply-To: Message-ID: <7de3dd11-d60e-4daf-9519-e186f309cb1a@glegroupsg2000goo.googlegroups.com> I would second the recommendation for Django: on LinkedIn, the python jobs postings (there is a Python group there) most often mention Django. I also would second the recommendation to participate in open source projects. I met a couple of days ago with a college sophomore who is a core contributor to the Cappuccino project(cappuccino.org -- warning: not Python ). My employer said, on my relating the pleasant and interesting conversation we had, "he doesn't need to finish college: anyone would hire him." >From a selfish (to you and to me ) perspective, may I suggest the pyjamas (pyjs.org) project and accompanying visual designer (http://pyjsglade.sourceforge.net), which brings the GWT widgets to Python, for desktop and web apps. Selfish to me because I'm porting our VFP framework to there over the next year or so. To you because, well, you've been spoiled by having the most productive data-oriented software development framework available, past or present, for maybe as many years as have I (21 at this point, started with FoxPro 1.0), and that's the end result at which I'm aiming. Hank From hankfay at gmail.com Thu Jan 13 10:31:34 2011 From: hankfay at gmail.com (Hank Fay) Date: Thu, 13 Jan 2011 07:31:34 -0800 (PST) Subject: Career path - where next? In-Reply-To: Message-ID: <7de3dd11-d60e-4daf-9519-e186f309cb1a@glegroupsg2000goo.googlegroups.com> I would second the recommendation for Django: on LinkedIn, the python jobs postings (there is a Python group there) most often mention Django. I also would second the recommendation to participate in open source projects. I met a couple of days ago with a college sophomore who is a core contributor to the Cappuccino project(cappuccino.org -- warning: not Python ). My employer said, on my relating the pleasant and interesting conversation we had, "he doesn't need to finish college: anyone would hire him." >From a selfish (to you and to me ) perspective, may I suggest the pyjamas (pyjs.org) project and accompanying visual designer (http://pyjsglade.sourceforge.net), which brings the GWT widgets to Python, for desktop and web apps. Selfish to me because I'm porting our VFP framework to there over the next year or so. To you because, well, you've been spoiled by having the most productive data-oriented software development framework available, past or present, for maybe as many years as have I (21 at this point, started with FoxPro 1.0), and that's the end result at which I'm aiming. Hank From alain at dpt-info.u-strasbg.fr Thu Jan 13 10:59:06 2011 From: alain at dpt-info.u-strasbg.fr (Alain Ketterlin) Date: Thu, 13 Jan 2011 16:59:06 +0100 Subject: How to populate all possible hierarchical clusterings from a set of elements? References: <3cb5ae7e-866d-40fb-ae3f-496193db91e4@t35g2000yqj.googlegroups.com> <87tyhdi0jd.fsf@dpt-info.u-strasbg.fr> <562e7da2-fa99-458f-80cf-01f21d37b1b4@s9g2000vby.googlegroups.com> Message-ID: <87hbdciylx.fsf@dpt-info.u-strasbg.fr> Richard Thomas writes: > On Jan 13, 10:02?am, Alain Ketterlin >> def clusterings(l): >> ? ? if len(l) == 1: >> ? ? ? ? print repr(l) >> ? ? else: >> ? ? ? ? n = len(l) >> ? ? ? ? for i in xrange(n): >> ? ? ? ? ? ? for j in xrange(i+1,n): >> ? ? ? ? ? ? ? ? clusterings(l[:i]+l[i+1:j]+l[j+1:]+[[l[i],l[j]]]) >> [...] there are *many* such clusterings? (the exact number should be >> (n!)*((n-1)!)/2^(n-1) given the code above, if I'm not mistaken.) > Actually the number of such "clusterings" is the (n-1)th Catalan > number. > > http://en.wikipedia.org/wiki/Catalan_numbers I don't think Catalan numbers exactly captures this number. As far as I remember (and wikipedia seems to confirm this), Cn is the number of ways you can repeatedly apply a binary operator to a sequence of objects, where sequence means that the objects are ordered, which is not the case here. To use wikipedia's example, C3 is 5 because you can do: ((ab)c)d (a(bc))d (ab)(cd) a((bc)d) a(b(cd)) If we list clusterings we can also have: ((ac)b)d ((ac)d)b (ac)(bd) ... Actually, for each of the 5 "catalan expressions" above, you have 4! valid permutations of the objects (leading to a complete count of n!*C(n-1)). But this leads to many "duplicates", because (ab)(cd) and (cd)(ab) are considered the same. I just realize that the code I've given above also produces duplicates (in particular, the example I've just used). At least, my counting was correct w.r.t. the code :-) The plot thickens... -- Alain. From tjreedy at udel.edu Thu Jan 13 11:46:18 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Thu, 13 Jan 2011 11:46:18 -0500 Subject: File "/usr/lib/python2.6/atexit.py", line 24, in _run_exitfuncs In-Reply-To: <9c1513be-2fb1-40ae-ad04-56a9574f1313@32g2000yqz.googlegroups.com> References: <9c1513be-2fb1-40ae-ad04-56a9574f1313@32g2000yqz.googlegroups.com> Message-ID: On 1/13/2011 5:28 AM, dzizes451 wrote: > Hello! > > I wrote a python (2.6) deamon running on linux. Program (deamon, > manager) collects lets say work-orders from db and creates sub- > processes for each one. Sub-processes do their job with out problems, > errors, exceptions. However, sometimes deamon throws: > > Traceback (most recent call last): > File "/usr/lib/python2.6/atexit.py", line 24, in _run_exitfuncs > func(*targs, **kargs) I would either just try 2.7 or at least examine What's New or even Misc/NEWS in the repository to see if there were changes that affect this. My impression is that there were. -- Terry Jan Reedy From chardster at gmail.com Thu Jan 13 11:58:42 2011 From: chardster at gmail.com (Richard Thomas) Date: Thu, 13 Jan 2011 08:58:42 -0800 (PST) Subject: How to populate all possible hierarchical clusterings from a set of elements? References: <3cb5ae7e-866d-40fb-ae3f-496193db91e4@t35g2000yqj.googlegroups.com> <87tyhdi0jd.fsf@dpt-info.u-strasbg.fr> <562e7da2-fa99-458f-80cf-01f21d37b1b4@s9g2000vby.googlegroups.com> <87hbdciylx.fsf@dpt-info.u-strasbg.fr> Message-ID: On Jan 13, 3:59?pm, Alain Ketterlin wrote: > Richard Thomas writes: > > On Jan 13, 10:02?am, Alain Ketterlin > >> def clusterings(l): > >> ? ? if len(l) == 1: > >> ? ? ? ? print repr(l) > >> ? ? else: > >> ? ? ? ? n = len(l) > >> ? ? ? ? for i in xrange(n): > >> ? ? ? ? ? ? for j in xrange(i+1,n): > >> ? ? ? ? ? ? ? ? clusterings(l[:i]+l[i+1:j]+l[j+1:]+[[l[i],l[j]]]) > >> [...] there are *many* such clusterings? (the exact number should be > >> (n!)*((n-1)!)/2^(n-1) given the code above, if I'm not mistaken.) > > Actually the number of such "clusterings" is the (n-1)th Catalan > > number. > > >http://en.wikipedia.org/wiki/Catalan_numbers > > I don't think Catalan numbers exactly captures this number. As far as I > remember (and wikipedia seems to confirm this), Cn is the number of ways > you can repeatedly apply a binary operator to a sequence of objects, > where sequence means that the objects are ordered, which is not the case > here. To use wikipedia's example, C3 is 5 because you can do: > > ((ab)c)d (a(bc))d (ab)(cd) a((bc)d) a(b(cd)) > > If we list clusterings we can also have: > > ((ac)b)d ((ac)d)b (ac)(bd) ... > > Actually, for each of the 5 "catalan expressions" above, you have 4! > valid permutations of the objects (leading to a complete count of > n!*C(n-1)). But this leads to many "duplicates", because (ab)(cd) and > (cd)(ab) are considered the same. > > I just realize that the code I've given above also produces duplicates > (in particular, the example I've just used). At least, my counting was > correct w.r.t. the code :-) The plot thickens... > > -- Alain. Okay, I misunderstood the problem, sorry about that. This makes it rather hard to define a nice recurrence relation for the number of such clusterings: C(1) = 1 C(2n+1) = Sigma(1; n; choose(2n+1, r) * C(r) * C(2n+1-r)) C(2n) = Sigma(1; n-1; choose(2n, r) * C(r) * C(2n-r)) + choose(2n, n) * C(n) * C(n) / 2 See, very ugly. I can't reduce it to anything workable so I just computed it. Clearly its more than exponential. Some values: In [1]: [cluster(n) for n in xrange(1, 21)] Out[1]: [1, 1, 3, 15, 105, 945, 10395, 135135, 2027025, 34459425, 654729075, 13749310575L, 316234143225L, 7905853580625L, 213458046676875L, 6190283353629375L, 191898783962510625L, 6332659870762850625L, 221643095476699771875L, 8200794532637891559375L] Anyway, I'm done counting things for now. Chard. From marcohornung at googlemail.com Thu Jan 13 12:07:47 2011 From: marcohornung at googlemail.com (Marco Hornung) Date: Thu, 13 Jan 2011 12:07:47 -0500 Subject: how to use priority queue with multiprocessing Message-ID: <0191111D-0C16-4CA3-A680-FDFB98FF7C07@gmail.com> Hey, ------------------------------------------------------------------------------------------ question ------------------------------------------------------------------------------------------ How can I use a priority queue to schedule jobs within the "multiprocessing pool" module? ------------------------------------------------------------------------------------------ my scenario ------------------------------------------------------------------------------------------ I want to run several jobs on a server. The jobs are being sent by users. However, all jobs have a different priority, and high-priority jobs should be processed before any low-priority job gets touched. Currently I just append all incoming jobs to the multiprocessing worker pool as follows: ### initialize worker pool pool = PriorityPool(processes=worker_count) process_handles = [] ### distribute function execution over several processes for job_parameter in job_parameter_list: handle = pool.apply_async(process_function, [job_parameter,]) process_handles.append(handle) This will only put the jobs in some kind of a list - and execute the jobs in the order they come in. Is it possible to use a priority queue for the process-pool? Kind Regards, Marco From lycka at carmen.se Thu Jan 13 13:12:49 2011 From: lycka at carmen.se (=?ISO-8859-1?Q?Magnus_Lyck=E5?=) Date: Thu, 13 Jan 2011 19:12:49 +0100 Subject: Resolve circular reference In-Reply-To: <1718ea91-fc4e-49f3-a15a-bdc683789126@k22g2000yqh.googlegroups.com> References: <1718ea91-fc4e-49f3-a15a-bdc683789126@k22g2000yqh.googlegroups.com> Message-ID: On 2011-01-07 03:24, moerchendiser2k3 wrote: > Everything works fine, the problem starts when I start to make a > circular reference in Python. I didn't quite grok your example, but concerning CPython GC & circular references... >>> import gc >>> class X: ... def __del__(self): ... print 'Deleted', self ... >>> a = X() >>> del a Deleted <__main__.X instance at 0x00CCCF80> >>> a=X() >>> b=X() >>> a.b=b >>> b.a=a >>> del a >>> gc.collect() 0 >>> del b >>> gc.collect() 4 >>> From lycka at carmen.se Thu Jan 13 13:23:22 2011 From: lycka at carmen.se (=?UTF-8?B?TWFnbnVzIEx5Y2vDpQ==?=) Date: Thu, 13 Jan 2011 19:23:22 +0100 Subject: How to read ansic file into a pre-defined class? In-Reply-To: References: Message-ID: On 2011-01-08 04:24, Ying Zu wrote: > How to read ansic file into a pre-defined class? > > I have a series of files written in the following format, ... You might like to take a look at the json module if you aren't locked to the exact format you suggested. http://json.org/ http://docs.python.org/library/json.html#module-json From ethan at stoneleaf.us Thu Jan 13 14:33:48 2011 From: ethan at stoneleaf.us (Ethan Furman) Date: Thu, 13 Jan 2011 11:33:48 -0800 Subject: Career path - where next? In-Reply-To: <7de3dd11-d60e-4daf-9519-e186f309cb1a@glegroupsg2000goo.googlegroups.com> References: <7de3dd11-d60e-4daf-9519-e186f309cb1a@glegroupsg2000goo.googlegroups.com> Message-ID: <4D2F539C.6070803@stoneleaf.us> Hank Fay wrote: > ... > > From a selfish (to you and to me ) perspective, may I suggest > the pyjamas (pyjs.org) project and accompanying visual designer > (http://pyjsglade.sourceforge.net), which brings the GWT widgets > to Python, for desktop and web apps. Selfish to me because I'm > porting our VFP framework to there over the next year or so. > To you because, well, you've been spoiled by having the most > productive data-oriented software development framework available, > past or present, for maybe as many years as have I (21 at this point, > started with FoxPro 1.0), and that's the end result at which I'm > aiming. Hank, I have a dbf* package which supports VFP dbf files up to 6, and I would like to implement support for compound index files. So far, I have been unable to locate the algorithms necessary to do so. If you have any information that would help me, I would be very grateful! ~Ethan~ *http://pypi.python.org/pypi/dbf/0.88.16 From heshamebrahimi at gmail.com Thu Jan 13 14:47:15 2011 From: heshamebrahimi at gmail.com (Hesham) Date: Thu, 13 Jan 2011 11:47:15 -0800 (PST) Subject: apscheduler error References: <9699865b-a8be-4284-a347-58d875b491f6@n2g2000pre.googlegroups.com> <8d45d736-8b89-41f0-96d7-66c3c077b670@22g2000prx.googlegroups.com> Message-ID: In cases like that instead of sleep() can use pause(). E.g., from apscheduler.scheduler import Scheduler import signal sched = Scheduler() sched.start() def some_job(): print "Decorated job" sched.add_interval_job(some_job,minutes=1) signal.pause() Mosalam From arnodel at gmail.com Thu Jan 13 14:54:03 2011 From: arnodel at gmail.com (Arnaud Delobelle) Date: Thu, 13 Jan 2011 19:54:03 +0000 Subject: How to populate all possible hierarchical clusterings from a set of elements? References: <3cb5ae7e-866d-40fb-ae3f-496193db91e4@t35g2000yqj.googlegroups.com> Message-ID: <87d3o0r350.fsf@gmail.com> Peter Otten <__peter__ at web.de> writes: > justin wrote: > >> The title sounds too complex, but my question is actually simple. >> >> Suppose I have [1,2,3,4,5], then there are many ways of making >> clustering. >> Among them, I want to pair up terminals until there is only one left >> at the end. >> For example, ((((1,2),3),4),5), (1,(2,(3,(4,5)))), or (((1,2),(3,4)), >> 5) would be legitimate ones. >> >> How do you think can I, using the modules of Python such as itertools >> as much as possible, make all possible such clusterings? > > Here's my first attempt: > > def cluster(items): > if len(items) == 2: > yield items > return > > for i in range(len(items)-1): > for c in cluster(items[:i] + (items[i:i+2],) + items[i+2:]): > yield c > > def unique(items): > seen = set() > for item in items: > if item not in seen: > seen.add(item) > yield item > > if __name__ == "__main__": > for item in unique(cluster(tuple("abcd"))): > print item more simply: def clusters(l): if len(l) == 1: yield l[0] return for i in range(1, len(l)): for left in clusters(l[:i]): for right in clusters(l[i:]): yield (left, right) That would give all solutions without duplicates. In fact, this is simply finding all full binary trees which order l. However, somewhere else in the thread someone claims that no ordering is implied on the initial list of items (which is not at all obvious from the OP). -- Arnaud From somewhere at hotmail.com Thu Jan 13 14:57:53 2011 From: somewhere at hotmail.com (Dave) Date: Thu, 13 Jan 2011 15:57:53 -0400 Subject: troubles compiling pythonwebkit Message-ID: <4d2f5543$0$5598$9a566e8b@news.aliant.net> Hello Python enthusiasts, I'm trying to install the "Python Webkit DOM Bindings" (http://www.gnu.org/software/pythonwebkit/) but am not successful. The trouble starts when trying to 'make' pywebkitgtk. I've tried the prepatched version and downloading and patching myself. In both case the 'make' fails but with different errors. Here are the steps I performed and the error output. Thanks for any insight in resolving this problem. :-) I'm running Ubuntu 10.04 32bit sudo apt-get remove python-webkit sudo apt-get install python-dev sudo apt-get install python-ply sudo apt-get install autoconf sudo apt-get install automake sudo apt-get install autotools-dev sudo apt-get install bison sudo apt-get install flex sudo apt-get install gperf sudo apt-get install glib-networking <---E: Couldn't find package glib-networking sudo apt-get install gtk-doc-tools sudo apt-get install libenchant-dev sudo apt-get install libgail-dev sudo apt-get install libgeoclue-dev sudo apt-get install libglib2.0-dev sudo apt-get install libgstreamer-plugins-base0.10-dev sudo apt-get install libgtk2.0-dev sudo apt-get install libicu-dev sudo apt-get install libjpeg62-dev sudo apt-get install libpango1.0-dev sudo apt-get install libpng12-dev sudo apt-get install libsoup2.4-dev sudo apt-get install libsqlite3-dev sudo apt-get install libtool sudo apt-get install libxslt-dev sudo apt-get install libxt-dev sudo apt-get install git-core git clone git://git.savannah.gnu.org/pythonwebkit.git cd pythonwebkit git checkout -b python_codegen sudo mkdir build cd build sudo ../autogen.sh sudo ../configure sudo make sudo make install cd ../.. sudo apt-get install libxslt1-dev sudo apt-get install python-gtk2-dev sudo apt-get install liblogthread-dev git clone git://github.com/lkcl/pywebkitgtk.git cd pywebkitgtk git checkout -b pythonwebkitgtk_1_1_8 sudo ./autogen.sh sudo ./configure sudo make results in the following: make all-am make[1]: Entering directory `/home/david/Downloads/pywebkitgtk' /bin/bash ./libtool --tag=CC --mode=compile gcc -DHAVE_CONFIG_H -I. -I/usr/include/python2.6 -pthread -I/usr/include/libxml2 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/pygtk-2.0 -pthread -D_REENTRANT -I/usr/local/include/webkit-1.0 -I/usr/local/include/libsoup-2.4 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/gio-unix-2.0/ -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/directfb -I/usr/include/libpng12 -I/usr/include/libxml2 -g -O2 -MT webkit/webkit_la-webkitmodule.lo -MD -MP -MF webkit/.deps/webkit_la-webkitmodule.Tpo -c -o webkit/webkit_la-webkitmodule.lo `test -f 'webkit/webkitmodule.c' || echo './'`webkit/webkitmodule.c libtool: compile: gcc -DHAVE_CONFIG_H -I. -I/usr/include/python2.6 -pthread -I/usr/include/libxml2 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/pygtk-2.0 -pthread -D_REENTRANT -I/usr/local/include/webkit-1.0 -I/usr/local/include/libsoup-2.4 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/gio-unix-2.0/ -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/directfb -I/usr/include/libpng12 -I/usr/include/libxml2 -g -O2 -MT webkit/webkit_la-webkitmodule.lo -MD -MP -MF webkit/.deps/webkit_la-webkitmodule.Tpo -c webkit/webkitmodule.c -fPIC -DPIC -o webkit/.libs/webkit_la-webkitmodule.o libtool: compile: gcc -DHAVE_CONFIG_H -I. -I/usr/include/python2.6 -pthread -I/usr/include/libxml2 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/pygtk-2.0 -pthread -D_REENTRANT -I/usr/local/include/webkit-1.0 -I/usr/local/include/libsoup-2.4 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/gio-unix-2.0/ -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/directfb -I/usr/include/libpng12 -I/usr/include/libxml2 -g -O2 -MT webkit/webkit_la-webkitmodule.lo -MD -MP -MF webkit/.deps/webkit_la-webkitmodule.Tpo -c webkit/webkitmodule.c -o webkit/webkit_la-webkitmodule.o >/dev/null 2>&1 mv -f webkit/.deps/webkit_la-webkitmodule.Tpo webkit/.deps/webkit_la-webkitmodule.Plo /bin/bash ./libtool --tag=CC --mode=compile gcc -DHAVE_CONFIG_H -I. -I/usr/include/python2.6 -pthread -I/usr/include/libxml2 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/pygtk-2.0 -pthread -D_REENTRANT -I/usr/local/include/webkit-1.0 -I/usr/local/include/libsoup-2.4 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/gio-unix-2.0/ -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/directfb -I/usr/include/libpng12 -I/usr/include/libxml2 -g -O2 -MT javascriptcore/webkit_la-javascriptcore_types.lo -MD -MP -MF javascriptcore/.deps/webkit_la-javascriptcore_types.Tpo -c -o javascriptcore/webkit_la-javascriptcore_types.lo `test -f 'javascriptcore/javascriptcore_types.c' || echo './'`javascriptcore/javascriptcore_types.c libtool: compile: gcc -DHAVE_CONFIG_H -I. -I/usr/include/python2.6 -pthread -I/usr/include/libxml2 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/pygtk-2.0 -pthread -D_REENTRANT -I/usr/local/include/webkit-1.0 -I/usr/local/include/libsoup-2.4 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/gio-unix-2.0/ -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/directfb -I/usr/include/libpng12 -I/usr/include/libxml2 -g -O2 -MT javascriptcore/webkit_la-javascriptcore_types.lo -MD -MP -MF javascriptcore/.deps/webkit_la-javascriptcore_types.Tpo -c javascriptcore/javascriptcore_types.c -fPIC -DPIC -o javascriptcore/.libs/webkit_la-javascriptcore_types.o libtool: compile: gcc -DHAVE_CONFIG_H -I. -I/usr/include/python2.6 -pthread -I/usr/include/libxml2 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/pygtk-2.0 -pthread -D_REENTRANT -I/usr/local/include/webkit-1.0 -I/usr/local/include/libsoup-2.4 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/gio-unix-2.0/ -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/directfb -I/usr/include/libpng12 -I/usr/include/libxml2 -g -O2 -MT javascriptcore/webkit_la-javascriptcore_types.lo -MD -MP -MF javascriptcore/.deps/webkit_la-javascriptcore_types.Tpo -c javascriptcore/javascriptcore_types.c -o javascriptcore/webkit_la-javascriptcore_types.o >/dev/null 2>&1 mv -f javascriptcore/.deps/webkit_la-javascriptcore_types.Tpo javascriptcore/.deps/webkit_la-javascriptcore_types.Plo /usr/bin/python /usr/share/pygobject/2.0/codegen/createdefs.py webkit/webkit.defs ./webkit/webkitdom.defs ./webkit/webkit-base-types.defs ./webkit/webkit-1.1-types.defs ./webkit/webkit-1.0.2.defs ./webkit/webkit-1.1.defs (/usr/bin/pygobject-codegen-2.0 \ --register /usr/share/pygtk/2.0/defs/gdk-types.defs \ --register /usr/share/pygtk/2.0/defs/gtk-types.defs \ --override ./webkit/webkit.override \ --prefix pywebkit webkit/webkit.defs) 2>&1 > webkit/gen-webkit.c | tee webkit/webkit.errors \ && cp webkit/gen-webkit.c webkit/webkit.c \ && rm -f webkit/gen-webkit.c Warning: Constructor for WebKitWebHistoryItem needs to be updated to new API See http://live.gnome.org/PyGTK_2fWhatsNew28#update-constructors ***INFO*** The coverage of global functions is 100.00% (5/5) ***INFO*** The coverage of methods is 100.00% (1434/1434) ***INFO*** There are no declared virtual proxies. ***INFO*** There are no declared virtual accessors. ***INFO*** There are no declared interface proxies. /bin/bash ./libtool --tag=CC --mode=compile gcc -DHAVE_CONFIG_H -I. -I/usr/include/python2.6 -pthread -I/usr/include/libxml2 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/pygtk-2.0 -pthread -D_REENTRANT -I/usr/local/include/webkit-1.0 -I/usr/local/include/libsoup-2.4 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/gio-unix-2.0/ -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/directfb -I/usr/include/libpng12 -I/usr/include/libxml2 -g -O2 -MT webkit/webkit_la-webkit.lo -MD -MP -MF webkit/.deps/webkit_la-webkit.Tpo -c -o webkit/webkit_la-webkit.lo `test -f 'webkit/webkit.c' || echo './'`webkit/webkit.c libtool: compile: gcc -DHAVE_CONFIG_H -I. -I/usr/include/python2.6 -pthread -I/usr/include/libxml2 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/pygtk-2.0 -pthread -D_REENTRANT -I/usr/local/include/webkit-1.0 -I/usr/local/include/libsoup-2.4 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/gio-unix-2.0/ -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/directfb -I/usr/include/libpng12 -I/usr/include/libxml2 -g -O2 -MT webkit/webkit_la-webkit.lo -MD -MP -MF webkit/.deps/webkit_la-webkit.Tpo -c webkit/webkit.c -fPIC -DPIC -o webkit/.libs/webkit_la-webkit.o webkit/webkit.c: In function ?_wrap_webkit_dom_navigator_get_geolocation?: webkit/webkit.c:3642: error: ?WebKitDOMGeolocation? undeclared (first use in this function) webkit/webkit.c:3642: error: (Each undeclared identifier is reported only once webkit/webkit.c:3642: error: for each function it appears in.) webkit/webkit.c:3642: error: ?ret? undeclared (first use in this function) webkit/webkit.c: In function ?pywebkit_register_classes?: webkit/webkit.c:32127: error: ?WEBKIT_TYPE_DOM_GEOLOCATION? undeclared (first use in this function) make[1]: *** [webkit/webkit_la-webkit.lo] Error 1 make[1]: Leaving directory `/home/david/Downloads/pywebkitgtk' make: *** [all] Error 2 Alternatively I download pywebkitgtk-1.1.8 and extract. I download pywebkitgtk-1.1.8.patch to dir just extracted. cd pywebkitgtk-1.1.8 patch -p 1 < pywebkitgtk-1.1.8.patch ./configure sudo make Results in the following: cd . && /bin/bash /home/david/Downloads/pywebkitgtk-1.1.8/missing --run automake-1.11 --foreign aclocal.m4:16: warning: this file was generated for autoconf 2.66. You have another version of autoconf. It may work, but is not guaranteed to. If you have problems, you may need to regenerate the build system entirely. To do so, use the procedure documented by the package, typically `autoreconf'. cd . && /bin/bash ./config.status Makefile depfiles config.status: creating Makefile config.status: executing depfiles commands make all-am make[1]: Entering directory `/home/david/Downloads/pywebkitgtk-1.1.8' /bin/bash ./libtool --tag=CC --mode=compile gcc -DHAVE_CONFIG_H -I. -I/usr/include/python2.6 -pthread -I/usr/include/libxml2 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/pygtk-2.0 -pthread -D_REENTRANT -I/usr/local/include/webkit-1.0 -I/usr/local/include/libsoup-2.4 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/gio-unix-2.0/ -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/directfb -I/usr/include/libpng12 -I/usr/include/libxml2 -g -O2 -MT webkit/webkit_la-webkitmodule.lo -MD -MP -MF webkit/.deps/webkit_la-webkitmodule.Tpo -c -o webkit/webkit_la-webkitmodule.lo `test -f 'webkit/webkitmodule.c' || echo './'`webkit/webkitmodule.c libtool: compile: gcc -DHAVE_CONFIG_H -I. -I/usr/include/python2.6 -pthread -I/usr/include/libxml2 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/pygtk-2.0 -pthread -D_REENTRANT -I/usr/local/include/webkit-1.0 -I/usr/local/include/libsoup-2.4 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/gio-unix-2.0/ -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/directfb -I/usr/include/libpng12 -I/usr/include/libxml2 -g -O2 -MT webkit/webkit_la-webkitmodule.lo -MD -MP -MF webkit/.deps/webkit_la-webkitmodule.Tpo -c webkit/webkitmodule.c -fPIC -DPIC -o webkit/.libs/webkit_la-webkitmodule.o webkit/webkitmodule.c:30:22: error: pywebkit.h: No such file or directory webkit/webkitmodule.c:37: warning: 'struct pyjoinapi' declared inside parameter list webkit/webkitmodule.c:37: warning: its scope is only this definition or declaration, which is probably not what you want webkit/webkitmodule.c: In function 'initwebkit': webkit/webkitmodule.c:59: warning: passing argument 2 of 'webkit_init_pywebkit' from incompatible pointer type webkit/webkitmodule.c:37: note: expected 'struct pyjoinapi *' but argument is of type 'struct pyjoinapi *' make[1]: *** [webkit/webkit_la-webkitmodule.lo] Error 1 make[1]: Leaving directory `/home/david/Downloads/pywebkitgtk-1.1.8' make: *** [all] Error 2 From pythonmarco at gmail.com Thu Jan 13 15:03:39 2011 From: pythonmarco at gmail.com (Marco Hornung) Date: Thu, 13 Jan 2011 15:03:39 -0500 Subject: how to use priority queue with multiprocessing Message-ID: <87E38041-C753-40C1-BD37-0334717C543D@gmail.com> Hey, ------------------------------------------------------------------------------------------ question ------------------------------------------------------------------------------------------ How can I use a priority queue to schedule jobs within the "multiprocessing pool" module? ------------------------------------------------------------------------------------------ my scenario ------------------------------------------------------------------------------------------ I want to run several jobs on a server. The jobs are being sent by users. However, all jobs have a different priority, and high-priority jobs should be processed before any low-priority job gets touched. Currently I just append all incoming jobs to the multiprocessing worker pool as follows: ### initialize worker pool pool = PriorityPool(processes=worker_count) process_handles = [] ### distribute function execution over several processes for job_parameter in job_parameter_list: handle = pool.apply_async(process_function, [job_parameter,]) process_handles.append(handle) This will only put the jobs in some kind of a list - and execute the jobs in the order they come in. Is it possible to use a priority queue for the process-pool? Kind Regards, Marco From leoboiko at gmail.com Thu Jan 13 15:45:31 2011 From: leoboiko at gmail.com (leoboiko) Date: Thu, 13 Jan 2011 12:45:31 -0800 (PST) Subject: python 3 and Unicode line breaking Message-ID: <32f75200-b4d8-4ec8-b07d-4740a79c28b6@g26g2000vba.googlegroups.com> Hi, Is there an equivalent to the textwrap module that knows about the Unicode line breaking algorithm (UAX #14, http://unicode.org/reports/tr14/ )? From gnuist006 at gmail.com Thu Jan 13 16:18:31 2011 From: gnuist006 at gmail.com (bolega) Date: Thu, 13 Jan 2011 13:18:31 -0800 (PST) Subject: GURU NEEDED : break a command into several lines and comment each line Message-ID: Basically, I have spent a few hours experimenting and searching on the comp.unix.shell how to break a command with several switches into more than one line AND to be able to put some comment on each line. #!/bin/bash -xv command \ # comment1 -sw1 \ # comment2 -sw2 \ # comment3 arguments One ought to be able to comment every single switch if desired for whatever reason. Bolega From bhoel at despammed.com Thu Jan 13 16:45:20 2011 From: bhoel at despammed.com (Berthold =?utf-8?Q?H=C3=B6llmann?=) Date: Thu, 13 Jan 2011 22:45:20 +0100 Subject: GURU NEEDED : break a command into several lines and comment each line References: Message-ID: <87wrm8scjz.fsf@pchoel.xn--hllmanns-n4a.de> bolega writes: > Basically, I have spent a few hours experimenting and searching on the > comp.unix.shell > > how to break a command with several switches into more than one line > AND to be able to put some comment on each line. > > #!/bin/bash -xv > > command \ # comment1 > -sw1 \ # comment2 > -sw2 \ # comment3 > arguments How about ----------- #!/bin/bash -xv COMMAND=command # comment1 COMMAND=$COMMAND -sw1 \ # comment2 COMMAND=$COMMAND -sw2 \ # comment3 COMMAND=$COMMAND arguments $COMMAND --------- ? Regards Berthold > One ought to be able to comment every single switch if desired for > whatever reason. > > Bolega > > -- A: Weil es die Lesbarkeit des Textes verschlechtert. F: Warum ist TOFU so schlimm? A: TOFU F: Was ist das gr??te ?rgernis im Usenet? -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 197 bytes Desc: not available URL: From clp2 at rebertia.com Thu Jan 13 16:49:06 2011 From: clp2 at rebertia.com (Chris Rebert) Date: Thu, 13 Jan 2011 13:49:06 -0800 Subject: GURU NEEDED : break a command into several lines and comment each line In-Reply-To: References: Message-ID: On Thu, Jan 13, 2011 at 1:18 PM, bolega wrote: > Basically, I have spent a few hours experimenting and searching on the > comp.unix.shell > > how to break a command with several switches into more than one line > AND to be able to put some comment on each line. > > #!/bin/bash -xv > > command ? ? ? \ # comment1 > ? ? ? ? -sw1 \ # comment2 > ? ? ? ? -sw2 \ # comment3 > ? ? ? ? arguments > > One ought to be able to comment every single switch if desired for > whatever reason. This doesn't seem to have anything whatsoever to do with Python... Regards, Chris From dwhodgins at nomail.afraid.org Thu Jan 13 17:08:46 2011 From: dwhodgins at nomail.afraid.org (David W. Hodgins) Date: Thu, 13 Jan 2011 17:08:46 -0500 Subject: GURU NEEDED : break a command into several lines and comment each line References: Message-ID: On Thu, 13 Jan 2011 16:18:31 -0500, bolega wrote: > how to break a command with several switches into more than one line > AND to be able to put some comment on each line. > command \ # comment1 > -sw1 \ # comment2 Not what you want to hear, but that will not work. With the above, the backslash is being used to escape the following space, rather then a newline, as is required to continue the line. Even if it were to work that way, would the next line be considered a continuation of the command, or of the comment? Your stuck with command \ -sw1 # comment1 # comment2 Regards, Dave Hodgins -- Change nomail.afraid.org to ody.ca to reply by email. (nomail.afraid.org has been set up specifically for use in usenet. Feel free to use it yourself.) From steve+comp.lang.python at pearwood.info Thu Jan 13 19:15:23 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 14 Jan 2011 00:15:23 GMT Subject: python 3 and Unicode line breaking References: <32f75200-b4d8-4ec8-b07d-4740a79c28b6@g26g2000vba.googlegroups.com> Message-ID: <4d2f959a$0$29984$c3e8da3$5496439d@news.astraweb.com> On Thu, 13 Jan 2011 12:45:31 -0800, leoboiko wrote: > Hi, > > Is there an equivalent to the textwrap module that knows about the > Unicode line breaking algorithm (UAX #14, > http://unicode.org/reports/tr14/ )? Is access to Google blocked where you are, or would you just like us to do your searches for you? If you have tried searching, please say so, otherwise most people will conclude you haven't bothered, and most likely will not bother to reply. -- Steven From martin.hellwig at dcuktec.org Thu Jan 13 19:27:40 2011 From: martin.hellwig at dcuktec.org (Martin P. Hellwig) Date: Fri, 14 Jan 2011 00:27:40 +0000 Subject: Multiple independently started python processes and sharing of a module Message-ID: Hi all, I have the following problem (which I already have a hacked around solution that works but I'd would like some more input on it): I have a situation where multiple python processes are started independently from each other but by the same user with the same environment (as happens with mod_wsgi, when not using daemon mode). All of these processes access a single module which needs synchronization for some of the commands, for example a db (MySQLdb) module where when a select is done, the fetchall must be done of that same process before another process can do anything else. How would I go and provide synchronization? Locking does not seem to work because there is no relationship between all the python processes except that they are started by the same user. Currently my solution is to wrap the module around a module that when used creates a directory and pipes to the process (multiprocessing.Connection) thus enforcing single access and within that I have wrapped the db function around again so that select statement as mentioned above is actually an execute followed by a fetchall. I still have the nagging feeling that I have reinvented a squared wheel or am totally missing the point. Any suggestions/comments are greatly appreciated, Thanks in advanced, Martin P. Hellwig From steve+comp.lang.python at pearwood.info Thu Jan 13 19:48:53 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 14 Jan 2011 00:48:53 GMT Subject: GURU NEEDED : break a command into several lines and comment each line References: Message-ID: <4d2f9d74$0$29984$c3e8da3$5496439d@news.astraweb.com> On Thu, 13 Jan 2011 13:49:06 -0800, Chris Rebert wrote: > On Thu, Jan 13, 2011 at 1:18 PM, bolega wrote: >> Basically, I have spent a few hours experimenting and searching on the >> comp.unix.shell [...] > This doesn't seem to have anything whatsoever to do with Python... Well, I launch Python scripts from the shell, so there's your connection. *wink* -- Steven From aahz at pythoncraft.com Thu Jan 13 21:22:08 2011 From: aahz at pythoncraft.com (Aahz) Date: 13 Jan 2011 18:22:08 -0800 Subject: Trying to parse a HUGE(1gb) xml file References: <5f734c26-a804-4370-9e0d-5f1e1bb31105@glegroupsg2000goo.googlegroups.com> <1292874586.11975.8.camel@linux-yu4c.site> Message-ID: In article , Stefan Behnel wrote: > >Try > > import xml.etree.cElementTree as etree > >instead. Note the leading "c", which hints at the C implementations of >ElementTree. It's much faster and much more memory friendly than the Python >implementation. Thanks! I updated our codebase this afternoon... -- Aahz (aahz at pythoncraft.com) <*> http://www.pythoncraft.com/ "The volume of a pizza of thickness 'a' and radius 'z' is given by pi*z*z*a" From kushal.kumaran at gmail.com Thu Jan 13 22:04:05 2011 From: kushal.kumaran at gmail.com (Kushal Kumaran) Date: Fri, 14 Jan 2011 08:34:05 +0530 Subject: Multiple independently started python processes and sharing of a module In-Reply-To: References: Message-ID: <1294974245.31975.2.camel@Nokia-N900> ----- Original message ----- > Hi all, > > I have the following problem (which I already have a hacked around > solution that works but I'd would like some more input on it): > > I have a situation where multiple python processes are started > independently from each other but by the same user with the same > environment (as happens with mod_wsgi, when not using daemon mode). > > All of these processes access a single module which needs > synchronization for some of the commands, for example a db (MySQLdb) > module where when a select is done, the fetchall must be done of that > same process before another process can do anything else. > If the processes are independent, they are not sharing the database connection, unless you've taken steps to make it so. MySQLdb imported in one process should not interfere with MySQLdb importerd in another process. > -- regards, kushal From monnier at iro.umontreal.ca Thu Jan 13 22:12:30 2011 From: monnier at iro.umontreal.ca (Stefan Monnier) Date: Thu, 13 Jan 2011 22:12:30 -0500 Subject: GURU NEEDED : break a command into several lines and comment each line References: Message-ID: > #!/bin/bash -xv > command \ # comment1 > -sw1 \ # comment2 > -sw2 \ # comment3 > arguments > One ought to be able to comment every single switch if desired for > whatever reason. Thanks for the riddle. Here's a solution: command $(: # comment1 ) -sw1 $(: # comment2 ) -sw2 $(: # comment3 ) arguments -- Stefan From zuying at gmail.com Fri Jan 14 02:04:31 2011 From: zuying at gmail.com (ZuYing) Date: Thu, 13 Jan 2011 23:04:31 -0800 (PST) Subject: overplot while keeping the axes fixed Message-ID: <6289eadb-05d0-40be-8303-19b5373cb197@p38g2000vbn.googlegroups.com> Hi folks, I was trying to split the frame into 2 panels using "subplot", fig = matplotlib.pyplot.figure() plt1 = fig.add_subplot(2,1,1 ) plt2 = fig.add_subplot(2,1,2 ) plt1.plot(x1, y1, 'g-') plt2.plot(x2, y2, 'g-') then I need to overplot other curves on each subplot panel using the same axes/ticksize settings, although the new data points extend a longer x-range plt1.plot(x3, y3, 'g-') will simply overplot the new x3/y3 by extending the x-axis, is there a simply option or way to hold the axes/ ticksize setting fixed while doing overplot? I am writing a pipeline to analyze thousands of sets of data points, so a tunning on the pyplot would be a lot more preferred than finding the xrange individually for each data sets. Thanks! From __peter__ at web.de Fri Jan 14 02:05:31 2011 From: __peter__ at web.de (Peter Otten) Date: Fri, 14 Jan 2011 08:05:31 +0100 Subject: How to populate all possible hierarchical clusterings from a set of elements? References: <3cb5ae7e-866d-40fb-ae3f-496193db91e4@t35g2000yqj.googlegroups.com> <87d3o0r350.fsf@gmail.com> Message-ID: Arnaud Delobelle wrote: > more simply: > > def clusters(l): > if len(l) == 1: > yield l[0] > return > for i in range(1, len(l)): > for left in clusters(l[:i]): > for right in clusters(l[i:]): > yield (left, right) > > That would give all solutions without duplicates. In fact, this is > simply finding all full binary trees which order l. Easy, now that I see it ;) From martin.hellwig at dcuktec.org Fri Jan 14 03:21:45 2011 From: martin.hellwig at dcuktec.org (Martin P. Hellwig) Date: Fri, 14 Jan 2011 08:21:45 +0000 Subject: Multiple independently started python processes and sharing of a module In-Reply-To: References: Message-ID: On 01/14/11 03:04, Kushal Kumaran wrote: > ----- Original message ----- >> Hi all, >> >> I have the following problem (which I already have a hacked around >> solution that works but I'd would like some more input on it): >> >> I have a situation where multiple python processes are started >> independently from each other but by the same user with the same >> environment (as happens with mod_wsgi, when not using daemon mode). >> >> All of these processes access a single module which needs >> synchronization for some of the commands, for example a db (MySQLdb) >> module where when a select is done, the fetchall must be done of that >> same process before another process can do anything else. >> > > If the processes are independent, they are not sharing the database connection, unless you've taken steps to make it so. MySQLdb imported in one process should not interfere with MySQLdb importerd in another process. > >> > It might be a misconfiguration but, under mod_wsgi with apache it does. Cheers, Martin From aotto1968 at users.berlios.de Fri Jan 14 04:23:21 2011 From: aotto1968 at users.berlios.de (Andreas Otto) Date: Fri, 14 Jan 2011 10:23:21 +0100 Subject: ANNOUNCE: NHI1-0.11, PLMK-2.0 und libmsgque-5.0 Message-ID: -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Dear User, ANNOUNCE: Major Feature Release ==================================== libmsgque: Application-Server-Toolkit for C, C++, JAVA, C#, Go, TCL, PERL, PHP, PYTHON, RUBY, VB.NET PLMK: Programming-Language-Microkernel NHI1: Non-Human-Intelligence #1 SUMMARY ======= Finish release 4 of wp2 with adding Factory support. The Factory add the ability to create NEW server-types on-the-fly and introduce the self-programming capability to NHI1. The "Factory" is an important part of the object management and has the following basic features: * create a new instance identified by an "Identifier" or using an already available instance as template * cleanup and delete an instance * provide an "Identifier" for factory lookup and as an unique application name * identify the server in the network The link between the "Factory-Identifier" and the "Factory-Interface" is important for the future development of "libmsgque". Message-Routing, Service-Location and Persistent-Transactions depend on this feature. The relationship between the "MqFactoryS" and the "MqS" is the same as the relationship between a "type" and an "instance" of the "type" in a regular programming language. The "MqFactoryS" define the "type" of the server and the "MqS" define a single instance of the server. Every kind of server has !!only one!! specific "MqFactoryS" object but every instance of a server has one "MqS" object used for object management. Decreasing the size and the complexity of a "MqS" object will improve the server performance. In future more fields, defined in the "MqSetupS" attribute of the the "MqS" object, will move into "MqFactoryS" object. LINKS ===== libmsgque including PHP documentation: > http://nhi1.berlios.de/theLink/index.htm NHI1: > http://nhi1.berlios.de/ DOWNLOAD: > http://developer.berlios.de/projects/nhi1/ mfg, Andreas Otto (aotto1968) -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.15 (GNU/Linux) Comment: Using GnuPG with SUSE - http://enigmail.mozdev.org/ iQEcBAEBAgAGBQJNMBYJAAoJEGTcPijNG3/AxGkH/1Nf7GBL7DWAUktwaFs7Bs69 7voAXXWgIug+X42MqmsjFY8TrVGSHJfB8au+gecP1z6RQnPlubT2Od9T3GbXJL5h ZeyK8r2cf7reqp0W63iw0Gh+mDV/bmcjqjA8RTvw95du8l8t0W+zSjcDmeMct/a6 o8eTvQTfCyr7+LcOqjzVEA19XVVgJBF55DA24+HACVFgXfRchpylZiXegmAC0iFy gWKDAyiC95wJzZuqK+a5hPAYOZ+nhAaEMDVY0olN81qnWnb7j6uubSWAbgdXPWaP zu1gXoGo2fugqQt8XB1Ux8gHZhXOXVQGxcX2LyMUwiI1iXxnLVXXL1K3p7+Wnng= =/7W5 -----END PGP SIGNATURE----- From kushal.kumaran+python at gmail.com Fri Jan 14 05:05:25 2011 From: kushal.kumaran+python at gmail.com (Kushal Kumaran) Date: Fri, 14 Jan 2011 15:35:25 +0530 Subject: Multiple independently started python processes and sharing of a module In-Reply-To: References: Message-ID: On Fri, Jan 14, 2011 at 1:51 PM, Martin P. Hellwig wrote: > On 01/14/11 03:04, Kushal Kumaran wrote: >> >> ----- Original message ----- >>> >>> Hi all, >>> >>> I have the following problem (which I already have a hacked around >>> solution that works but I'd would like some more input on it): >>> >>> I have a situation where multiple python processes are started >>> independently from each other but by the same user with the same >>> environment (as happens with mod_wsgi, when not using daemon mode). >>> >>> All of these processes access a single module which needs >>> synchronization for some of the commands, for example a db (MySQLdb) >>> module where when a select is done, the fetchall must be done of that >>> same process before another process can do anything else. >>> >> >> If the processes are independent, they are not sharing the database >> connection, unless you've taken steps to make it so. ?MySQLdb imported in >> one process should not interfere with MySQLdb importerd in another process. >> >>> >> > It might be a misconfiguration but, under mod_wsgi with apache it does. > Ah, I didn't notice the mod_wsgi reference. I'm out of my depth here. Hopefully someone with mod_wsgi experience will chime in. This might help though: https://code.google.com/p/modwsgi/wiki/ProcessesAndThreading It seems if you're not using 'daemon' mode, global data might be shared. You could create new connections for each request (and close them when done). There won't be interference between select/fetch across multiple database connections. Additionally, the documentation of MySQLdb says it is a bad idea to share database connections between threads. -- regards, kushal From martin.hellwig at dcuktec.org Fri Jan 14 05:51:01 2011 From: martin.hellwig at dcuktec.org (Martin P. Hellwig) Date: Fri, 14 Jan 2011 10:51:01 +0000 Subject: Multiple independently started python processes and sharing of a module In-Reply-To: References: Message-ID: On 01/14/11 10:05, Kushal Kumaran wrote: > This might help though: > https://code.google.com/p/modwsgi/wiki/ProcessesAndThreading > > It seems if you're not using 'daemon' mode, global data might be shared. > Yes I read that thoroughly before I started out implementing a solution. But in my case I wanted something that worked as expected and not be depending on specific configuration of underlying technology as I can not assure that these condition will be met. > You could create new connections for each request (and close them when > done). There won't be interference between select/fetch across > multiple database connections. Additionally, the documentation of > MySQLdb says it is a bad idea to share database connections between > threads. > That is a possible solution too, however the performance impact is in the range of 40% while doing forced synchronization and overhead of the singleton wrapper is around 20%. So the latter is what I have gone with. Thanks for bouncing off ideas though, much appreciated. -- mph From hniksic at xemacs.org Fri Jan 14 06:25:11 2011 From: hniksic at xemacs.org (Hrvoje Niksic) Date: Fri, 14 Jan 2011 12:25:11 +0100 Subject: Resolve circular reference References: <1718ea91-fc4e-49f3-a15a-bdc683789126@k22g2000yqh.googlegroups.com> Message-ID: <87sjwviv6w.fsf@xemacs.org> Magnus Lyck? writes: >>>> a = X() >>>> del a > Deleted <__main__.X instance at 0x00CCCF80> >>>> a=X() >>>> b=X() >>>> a.b=b >>>> b.a=a >>>> del a >>>> gc.collect() > 0 >>>> del b >>>> gc.collect() > 4 If your method has a __del__ at all, the automatic cyclic collector is disabled. It detects the cycle, but it only stores the objects in gc.garbage, to give you a chance to do something about them, such as break the cycle(s) yourself. For example: >>> class X(object): ... def __del__(self): ... print 'deleted', self ... >>> a, b = X(), X() >>> a.cycle = b >>> b.cycle = a >>> del a, b >>> import gc >>> gc.collect() 4 >>> gc.garbage [<__main__.X object at 0xb76d84cc>, <__main__.X object at 0xb76d980c>] >>> del gc.garbage[0].cycle >>> del gc.garbage[:] deleted <__main__.X object at 0xb76d980c> deleted <__main__.X object at 0xb76d84cc> From tkpmep at gmail.com Fri Jan 14 06:55:10 2011 From: tkpmep at gmail.com (Thomas Philips) Date: Fri, 14 Jan 2011 03:55:10 -0800 (PST) Subject: FTP problem Message-ID: I'm using ftplib for the first time, and am having trouble getting it to work. I type >>> from ftplib import FTP >>> ftp = FTP('ftp.indexftp.barcap.com', 'A Valid Username', ' A Valid Password') where I have suppressed the user name and password, and I get Traceback (most recent call last): File "", line 1, in ftp = FTP('ftp.indexftp.barcap.com') File "C:\Python26\lib\ftplib.py", line 116, in __init__ self.connect(host) File "C:\Python26\lib\ftplib.py", line 131, in connect self.sock = socket.create_connection((self.host, self.port), self.timeout) File "C:\Python26\lib\socket.py", line 498, in create_connection for res in getaddrinfo(host, port, 0, SOCK_STREAM): gaierror: [Errno 11001] getaddrinfo failed I have tried this on two different computers and on two different versions of Python (2.6 and 2.7). I get the same error both times, and have no understanding of what the problem might be. Any assistance would be greatly appreciated. Sincerely Thomas Philips From python at bdurham.com Fri Jan 14 07:05:05 2011 From: python at bdurham.com (python at bdurham.com) Date: Fri, 14 Jan 2011 07:05:05 -0500 Subject: FTP problem In-Reply-To: References: Message-ID: <1295006705.28988.1415283211@webmail.messagingengine.com> Thomas, > ftp = FTP('ftp.indexftp.barcap.com', 'A Valid Username', ' A Valid Password') Your FTP URI is bad. When I try to connect to your site from the Windows FTP client, I get the following response: Unknown host ftp.indexftp.barcap.com. Malcolm From sudheer.s at sudheer.net Fri Jan 14 07:07:11 2011 From: sudheer.s at sudheer.net (Sudheer Satyanarayana) Date: Fri, 14 Jan 2011 17:37:11 +0530 Subject: FTP problem In-Reply-To: References: Message-ID: <4D303C6F.9080809@sudheer.net> > gaierror: [Errno 11001] getaddrinfo failed That part of the error indicates, your computer is unable to resolve the IP address for the hostname ftp.indexftp.barcap.com Make sure the hostname is valid. -- With warm regards, Sudheer. S Personal home page - http://sudheer.net | Tech Chorus - http://techchorus.net Web and IT services - http://binaryvibes.co.in From alex.kyrish at gmail.com Fri Jan 14 07:15:10 2011 From: alex.kyrish at gmail.com (Alex Boyko) Date: Fri, 14 Jan 2011 14:15:10 +0200 Subject: unbalanced tree iteration issue Message-ID: Dear All! I have deal with large unbalanced trees and I have to implement post-order tree traversal. My first attempt is shown below ("Node" and "Tree" classes) and based on recursive generators approach. class Node(): def __init__(self,value): self.childs = [] self.value = value class Tree(): def __init__(self, root): self.root = root self.numberCells = 1 def add(self, node, child): node.childs.append(child) self.numberCells+=1 def __iter__(self): return self.postorder(self.root) def postorder(self, node): if node: for child in node.childs: for n in self.postorder(child): yield n yield node It works fine for small test trees. But, my tree has approximately 300000 nodes, and shown post order traversal with generators takes 80 sec against 1 sec with simple recursive routine: def recursiveFromTop(node): for child in node.childs: recursiveFromTop(child) ## here I can do some computations with current node's data So, I'd like to know how should I implement (if it's possible of course) __iter__ for my tree class based on recursion without generators? Please, can You show me the ways? because I'm very passionate in idea iterate through my tree with simple: for node in tree: do something with node Thanks in Advance! Best Regards! Alex -------------- next part -------------- An HTML attachment was scrubbed... URL: From alt.mcarter at gmail.com Fri Jan 14 07:28:37 2011 From: alt.mcarter at gmail.com (Mark Carter) Date: Fri, 14 Jan 2011 04:28:37 -0800 (PST) Subject: wx Just Print! Message-ID: <00354847-5ab0-4247-802c-15cd0f7d22c7@fo10g2000vbb.googlegroups.com> I'm using Python 2.6.5. I would like to be able to print an RTF file, with no prompts for printers or anything like that. Here's the code so far: import wx.richtext rtp = wx.richtext.RichTextPrinting() rtp.PrintFile('C:\\path\\to\\file.rtf') When I run it, it says: ... assert "(wxThePrintPaperDatabase*) NULL) failed ... What is the fix? From chris at simplistix.co.uk Fri Jan 14 07:38:26 2011 From: chris at simplistix.co.uk (Chris Withers) Date: Fri, 14 Jan 2011 12:38:26 +0000 Subject: TestFixtures 1.8.0 Released! Message-ID: <4D3043C2.6020305@simplistix.co.uk> Hi All, I'm very happy to announce the first fully-documented release of TestFixtures, my collection of testing fixtures and helpers that I've been collecting for the last couple of years. Along with my own take on a lot of the common fixtures and helpers, it has some bits that I haven't seen anywhere else and so would like to point out: - Comparison objects for comparing objects that don't natively support comparison: http://packages.python.org/testfixtures/comparing.html#comparison-objects - Helpful mock objects for when you want to test code that makes use of datetime.datetime.now, datetime.date.today or time.time: http://packages.python.org/testfixtures/datetime.html - Helpers for capturing and checking messages logged from your code using the python logging framework: http://packages.python.org/testfixtures/logging.html - Helpers for working with temporary directories in tests. In particular, quickly and easily creating temporary directories and files within them and making assertions about things written to them by the code under test: http://packages.python.org/testfixtures/files.html There's plenty more in there too! Please do let me know what you find useful, if you find any bugs or if there are any features you'd like to see added. The package is on PyPI and a full list of all the links to docs, issue trackers and the like can be found here: http://www.simplistix.co.uk/software/python/testfixtures cheers, Chris -- Simplistix - Content Management, Batch Processing & Python Consulting - http://www.simplistix.co.uk From leoboiko at gmail.com Fri Jan 14 08:06:15 2011 From: leoboiko at gmail.com (leoboiko) Date: Fri, 14 Jan 2011 05:06:15 -0800 (PST) Subject: python 3 and Unicode line breaking References: <32f75200-b4d8-4ec8-b07d-4740a79c28b6@g26g2000vba.googlegroups.com> <4d2f959a$0$29984$c3e8da3$5496439d@news.astraweb.com> Message-ID: <55c2f7dc-d4d8-4939-85de-41c19c336f23@k25g2000vbl.googlegroups.com> Of course I searched for one and couldn?t find; that goes without saying. Otherwise I wouldn?t even bother writing a message, isn?t it? I disagree people should cruft their messages with details about how they failed to find information, as that is unrelated to the question at hand and has no point other than polluting people?s mailboxes. I also see no reason to reply to a simple question with such discourtesy, and cannot understand why someone would be so aggressive to a stranger. From k.bx at ya.ru Fri Jan 14 08:26:59 2011 From: k.bx at ya.ru (kost BebiX) Date: Fri, 14 Jan 2011 15:26:59 +0200 Subject: unbalanced tree iteration issue In-Reply-To: References: Message-ID: <461431295011620@web65.yandex.ru> 14.01.2011, 14:15, "Alex Boyko" : > Dear All! > > I have deal with large unbalanced trees and I have to implement post-order tree traversal. My first attempt is shown below ("Node" and "Tree" classes) and based on recursive generators approach. > > class Node(): > ?? ?def __init__(self,value): > ?? ? ? ?self.childs = [] > ?? ? ? ?self.value = value > > class Tree(): > > ?? ?def __init__(self, root): > ?? ? ? ?self.root = root > ?? ? ? ?self.numberCells = 1 > > ?? ?def add(self, node, child): > ?? ? ? ?node.childs.append(child) > ?? ? ? ?self.numberCells+=1 > > ?? ?def __iter__(self): > ?? ? ? ?return self.postorder(self.root) > > ?? ?def postorder(self, node): > ?? ? ? ?if node: > ?? ? ? ? ? ?for child in node.childs: > ?? ? ? ? ? ? ? ?for n in self.postorder(child): > ?? ? ? ? ? ? ? ? ? ?yield n > ?? ? ? ? ? ?yield node > > It works fine for small test trees. But, my tree has approximately 300000 nodes, and shown post order traversal with generators takes 80 sec against 1 sec with simple recursive routine: > > def recursiveFromTop(node): > ?? ?for child in node.childs: > ?? ? ? ?recursiveFromTop(child) > ?? ? ? ?## here I can do some computations with current node's data > > So, I'd like to know how?should?I implement (if it's possible of course) __iter__ for my tree class based on recursion without generators? Please, can You show me the ways? > because I'm very passionate in idea iterate through my tree with simple: > > for node in tree: > ?? do something with node > > Thanks in Advance! > Best Regards! > Alex > > -- > http://mail.python.org/mailman/listinfo/python-list Well, I think it's actually because the difference is that you would not do yielding, you would just put everything in memory and then return it. ret_val = [x for x in self.postorder(child)] return ret_val + [self] or something like that (but beware of memory). But that's strange. This code works fast: #!/usr/bin/env python # -*- coding: utf-8 -*- import sys def w(s): sys.stdout.write("%s" % s) sys.stdout.flush() class Node(): __slots__ = ('childs', 'value',) def __init__(self, value): self.childs = [] self.value = value def post_order(self): for child in self.childs: yield child yield self def build_tree(): def append_1000_childs(node): for i in xrange(20): node.childs.append(Node(10)) def append_n_levels(node, levels=1): if levels >= 1: append_1000_childs(node) if levels > 1: for child in node.childs: append_n_levels(child, levels - 1) root = Node(10) append_n_levels(root, 5) return root if __name__ == '__main__': from datetime import datetime w("building tree...") _t = datetime.now() root = build_tree() w("done\n") w(datetime.now() - _t) w("\n") w("doing generator post_order...") _t = datetime.now() for item in root.post_order(): fake = item.value w("done\n") w(datetime.now() - _t) w("\n") def post_order(root): for child in root.childs: post_order(child) fake = item.value w("doing non-generator post_order...") _t = datetime.now() post_order(root) w("done\n") w(datetime.now() - _t) w("\n") $ python postorder.py building tree...done 0:01:34.422288 doing generator post_order...done 0:00:00.000018 doing non-generator post_order...done 0:00:01.232272 -- jabber: k.bx at ya.ru From k.bx at ya.ru Fri Jan 14 08:29:34 2011 From: k.bx at ya.ru (kost BebiX) Date: Fri, 14 Jan 2011 15:29:34 +0200 Subject: unbalanced tree iteration issue In-Reply-To: References: Message-ID: <77391295011774@web158.yandex.ru> 14.01.2011, 14:15, "Alex Boyko" : > Dear All! > > I have deal with large unbalanced trees and I have to implement post-order tree traversal. My first attempt is shown below ("Node" and "Tree" classes) and based on recursive generators approach. > > class Node(): > ?? ?def __init__(self,value): > ?? ? ? ?self.childs = [] > ?? ? ? ?self.value = value > > class Tree(): > > ?? ?def __init__(self, root): > ?? ? ? ?self.root = root > ?? ? ? ?self.numberCells = 1 > > ?? ?def add(self, node, child): > ?? ? ? ?node.childs.append(child) > ?? ? ? ?self.numberCells+=1 > > ?? ?def __iter__(self): > ?? ? ? ?return self.postorder(self.root) > > ?? ?def postorder(self, node): > ?? ? ? ?if node: > ?? ? ? ? ? ?for child in node.childs: > ?? ? ? ? ? ? ? ?for n in self.postorder(child): > ?? ? ? ? ? ? ? ? ? ?yield n > ?? ? ? ? ? ?yield node > > It works fine for small test trees. But, my tree has approximately 300000 nodes, and shown post order traversal with generators takes 80 sec against 1 sec with simple recursive routine: > > def recursiveFromTop(node): > ?? ?for child in node.childs: > ?? ? ? ?recursiveFromTop(child) > ?? ? ? ?## here I can do some computations with current node's data > > So, I'd like to know how?should?I implement (if it's possible of course) __iter__ for my tree class based on recursion without generators? Please, can You show me the ways? > because I'm very passionate in idea iterate through my tree with simple: > > for node in tree: > ?? do something with node > > Thanks in Advance! > Best Regards! > Alex > > -- > http://mail.python.org/mailman/listinfo/python-list Forgot to make new-style object) class Node(object): The results for new-style objects are: $ python postorder.py building tree...done 0:00:26.180799 doing generator post_order...done 0:00:00.000017 doing non-generator post_order...done 0:00:01.117986 -- jabber: k.bx at ya.ru From k.bx at ya.ru Fri Jan 14 08:33:34 2011 From: k.bx at ya.ru (kost BebiX) Date: Fri, 14 Jan 2011 15:33:34 +0200 Subject: unbalanced tree iteration issue In-Reply-To: References: Message-ID: <85071295012015@web146.yandex.ru> 14.01.2011, 14:17, "Alex Boyko" : > Dear All! > > I have deal with large unbalanced trees and I have to implement post-order tree traversal. My first attempt is shown below ("Node" and "Tree" classes) and based on recursive generators approach. > > class Node(): > ?? ?def __init__(self,value): > ?? ? ? ?self.childs = [] > ?? ? ? ?self.value = value > > class Tree(): > > ?? ?def __init__(self, root): > ?? ? ? ?self.root = root > ?? ? ? ?self.numberCells = 1 > > ?? ?def add(self, node, child): > ?? ? ? ?node.childs.append(child) > ?? ? ? ?self.numberCells+=1 > > ?? ?def __iter__(self): > ?? ? ? ?return self.postorder(self.root) > > ?? ?def postorder(self, node): > ?? ? ? ?if node: > ?? ? ? ? ? ?for child in node.childs: > ?? ? ? ? ? ? ? ?for n in self.postorder(child): > ?? ? ? ? ? ? ? ? ? ?yield n > ?? ? ? ? ? ?yield node > > It works fine for small test trees. But, my tree has approximately 300000 nodes, and shown post order traversal with generators takes 80 sec against 1 sec with simple recursive routine: > > def recursiveFromTop(node): > ?? ?for child in node.childs: > ?? ? ? ?recursiveFromTop(child) > ?? ? ? ?## here I can do some computations with current node's data > > So, I'd like to know how?should?I implement (if it's possible of course) __iter__ for my tree class based on recursion without generators? Please, can You show me the ways? > because I'm very passionate in idea iterate through my tree with simple: > > for node in tree: > ?? do something with node > > Thanks in Advance! > Best Regards! > Alex > > -- > http://mail.python.org/mailman/listinfo/python-list God damn pypy is fast)) $ ~/bin/pypy-1.4.1-linux64/bin/pypy ./postorder.py building tree...done 0:00:03.000854 doing generator post_order...done 0:00:00.000069 doing non-generator post_order...done 0:00:00.240168 -- jabber: k.bx at ya.ru From stefan_ml at behnel.de Fri Jan 14 08:39:01 2011 From: stefan_ml at behnel.de (Stefan Behnel) Date: Fri, 14 Jan 2011 14:39:01 +0100 Subject: python 3 and Unicode line breaking In-Reply-To: <55c2f7dc-d4d8-4939-85de-41c19c336f23@k25g2000vbl.googlegroups.com> References: <32f75200-b4d8-4ec8-b07d-4740a79c28b6@g26g2000vba.googlegroups.com> <4d2f959a$0$29984$c3e8da3$5496439d@news.astraweb.com> <55c2f7dc-d4d8-4939-85de-41c19c336f23@k25g2000vbl.googlegroups.com> Message-ID: leoboiko, 14.01.2011 14:06: > Of course I searched for one and couldn?t find; that goes without > saying. Otherwise I wouldn?t even bother writing a message, isn?t > it? I disagree people should cruft their messages with details about > how they failed to find information, as that is unrelated to the > question at hand and has no point other than polluting people?s > mailboxes. http://www.catb.org/~esr/faqs/smart-questions.html#beprecise http://www.catb.org/~esr/faqs/smart-questions.html#volume Stefan From stefan_ml at behnel.de Fri Jan 14 08:48:29 2011 From: stefan_ml at behnel.de (Stefan Behnel) Date: Fri, 14 Jan 2011 14:48:29 +0100 Subject: python 3 and Unicode line breaking In-Reply-To: <4d2f959a$0$29984$c3e8da3$5496439d@news.astraweb.com> References: <32f75200-b4d8-4ec8-b07d-4740a79c28b6@g26g2000vba.googlegroups.com> <4d2f959a$0$29984$c3e8da3$5496439d@news.astraweb.com> Message-ID: Steven D'Aprano, 14.01.2011 01:15: > On Thu, 13 Jan 2011 12:45:31 -0800, leoboiko wrote: >> Is there an equivalent to the textwrap module that knows about the >> Unicode line breaking algorithm (UAX #14, >> http://unicode.org/reports/tr14/ )? > > Is access to Google blocked where you are, or would you just like us to > do your searches for you? > > If you have tried searching, please say so, otherwise most people will > conclude you haven't bothered, and most likely will not bother to reply. I think the OP was asking for something like the "textwrap" module (which the OP apparently knows about), but based on a special line break algorithm which, as suggested by the way the OP asks, is not supported by textwrap. Sadly, the OP did not clearly state that the required feature is really not supported by "textwrap" and in what way textwrap behaves differently. That would have helped in answering. Stefan From phlip2005 at gmail.com Fri Jan 14 09:15:35 2011 From: phlip2005 at gmail.com (Phlip) Date: Fri, 14 Jan 2011 06:15:35 -0800 Subject: [TIP] TestFixtures 1.8.0 Released! In-Reply-To: <4D3043C2.6020305@simplistix.co.uk> References: <4D3043C2.6020305@simplistix.co.uk> Message-ID: [ please set the reply-to to testing-in-python@ !] > The package is on PyPI and a full list of all the links to docs, issue > trackers and the like can be found here: > > http://www.simplistix.co.uk/software/python/testfixtures The number one problem with all the test fixture systems I ever auditioned for Django models was unbelievable slowness. Thats' a major bummer for TDD, because you should integrate after every few edits, and a slow integration derails your flow. On a project with 500 tests the complete run could be 5 minutes. Some fixture systems use JSON to represent model values, and they pump the JSON directly into SQL insert statements. I was using farmdev's fixture system, and it was incredibly slow. It also did not use raw SQL. It fully resolved all records into model objects, and called save() on them. (The extra round trip thru a model's validations would be nice - if we were testing validations. That's what explicit tests are for!) I rewrote the fixture loader, going direct to SQL, and got a major speed boost. Then I rewrote it again, going directly from XML to our (very simple & stereotypical) model objects, and called save(). The speed boost remained. I have no idea what farmdev fixture was doing to slow things down. Anyway thanks for the library, but you can see I can't use its fixture loader; I'm just putting this out here. But does it do Django models, and are they performant? -- Phlip http://c2.com/cgi/wiki?ZeekLand From leoboiko at gmail.com Fri Jan 14 09:29:27 2011 From: leoboiko at gmail.com (leoboiko) Date: Fri, 14 Jan 2011 06:29:27 -0800 (PST) Subject: python 3 and Unicode line breaking References: <32f75200-b4d8-4ec8-b07d-4740a79c28b6@g26g2000vba.googlegroups.com> <4d2f959a$0$29984$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Jan 14, 11:48 am, Stefan Behnel wrote: > Sadly, the OP did not clearly state that the required feature > is really not supported by "textwrap" and in what way textwrap > behaves differently. That would have helped in answering. Oh, textwrap doesn?t work for arbitrary Unicode text at all. For example, it separates combining sequences: >>> s = "ti?ng Vi?t" # precomposed >>> len(s) 10 >>> s = "ti?ng Vi?t" # combining >>> len(s) # number of unicode characters; ? line length 14 >>> print(textwrap.fill(s, width=4)) # breaks sequences ti? ng Vi? t It also doesn?t know about double-width characters: >>> s1 = "???????" >>> s2 = "12345678901234" # both s1 and s2 use 14 columns >>> print(textwrap.fill(s1, width=7)) ??????? >>> print(textwrap.fill(s2, width=7)) 1234567 8901234 It doesn?t know about non-ascii punctuation: >>> print(textwrap.fill("abc-def", width=5)) # ASCII minus-hyphen abc- def >>> print(textwrap.fill("abc?def", width=5)) # true hyphen U+2010 abc?d ef It doesn?t know East Asian filling rules (though this is perhaps pushing it a bit beyond textwrap?s goals): >>> print(textwrap.fill("???????", width=3)) ??? ??? # should avoid linebreak before CJK punctuation ? And it generally doesn?t try to pick good places to break lines at all, just making the assumption that 1 character = 1 column and that breaking on ASCII whitespaces/hyphens is enough. We can?t really blame textwrap for that, it is a very simple module and Unicode line breaking gets complex fast (that?s why the consortium provides a ready-made algorithm). It?s just that, with python3?s emphasis on Unicode support, I was surprised not to be able to find an UAX #14 implementation. I thought someone would surely have written one and I simply couldn?t find, so I asked precisely that. From whatsjacksemail at gmail.com Fri Jan 14 09:39:05 2011 From: whatsjacksemail at gmail.com (Jack Keegan) Date: Fri, 14 Jan 2011 14:39:05 +0000 Subject: TestFixtures 1.8.0 Released! In-Reply-To: <4D3043C2.6020305@simplistix.co.uk> References: <4D3043C2.6020305@simplistix.co.uk> Message-ID: I'm new to python and have just been looking into a solution for Mocking objects. In particular, at the moment, testing some code that needs to access hardware IOs using DLLs. I do this using Ctypes. However, on my dev machine, I don't have the same hardware so calling the DLL functions will not work as expected. Therefore I'd like to mock out the ctypes dll calls. Can you give me an indication of how you would go about doing this with Simplistix? Just so you know, I use py.test for unit testing. Thanks, Jack On Fri, Jan 14, 2011 at 12:38 PM, Chris Withers wrote: > Hi All, > > I'm very happy to announce the first fully-documented release of > TestFixtures, my collection of testing fixtures and helpers that I've been > collecting for the last couple of years. > > Along with my own take on a lot of the common fixtures and helpers, it has > some bits that I haven't seen anywhere else and so would like to point out: > > - Comparison objects for comparing objects that don't natively support > comparison: > > http://packages.python.org/testfixtures/comparing.html#comparison-objects > > - Helpful mock objects for when you want to test code that makes use of > datetime.datetime.now, datetime.date.today or time.time: > > http://packages.python.org/testfixtures/datetime.html > > - Helpers for capturing and checking messages logged from your code > using the python logging framework: > > http://packages.python.org/testfixtures/logging.html > > - Helpers for working with temporary directories in tests. In > particular, quickly and easily creating temporary directories and > files within them and making assertions about things written to them > by the code under test: > > http://packages.python.org/testfixtures/files.html > > There's plenty more in there too! > > Please do let me know what you find useful, if you find any bugs or if > there are any features you'd like to see added. > > The package is on PyPI and a full list of all the links to docs, issue > trackers and the like can be found here: > > http://www.simplistix.co.uk/software/python/testfixtures > > cheers, > > Chris > > -- > Simplistix - Content Management, Batch Processing & Python Consulting > - http://www.simplistix.co.uk > -- > http://mail.python.org/mailman/listinfo/python-list > -- The earth is a very small stage in a vast cosmic arena. Think of the rivers of blood spilled by all those generals and emperors so that in glory and in triumph they could become the momentary masters of a fraction of a dot. - Carl Sagan [Pale Blue Dot] -------------- next part -------------- An HTML attachment was scrubbed... URL: From whatsjacksemail at gmail.com Fri Jan 14 09:40:52 2011 From: whatsjacksemail at gmail.com (Jack Keegan) Date: Fri, 14 Jan 2011 14:40:52 +0000 Subject: TestFixtures 1.8.0 Released! In-Reply-To: References: <4D3043C2.6020305@simplistix.co.uk> Message-ID: Appologies, please read the 2nd last line as: Can you give me an indication of how you would go about doing this with TestFixtures? :) Thanks Jack On Fri, Jan 14, 2011 at 2:39 PM, Jack Keegan wrote: > I'm new to python and have just been looking into a solution for Mocking > objects. In particular, at the moment, testing some code that needs to > access hardware IOs using DLLs. I do this using Ctypes. > However, on my dev machine, I don't have the same hardware so calling the > DLL functions will not work as expected. Therefore I'd like to mock out the > ctypes dll calls. Can you give me an indication of how you would go about > doing this with Simplistix? Just so you know, I use py.test for unit > testing. > > Thanks, > > Jack > > On Fri, Jan 14, 2011 at 12:38 PM, Chris Withers wrote: > >> Hi All, >> >> I'm very happy to announce the first fully-documented release of >> TestFixtures, my collection of testing fixtures and helpers that I've been >> collecting for the last couple of years. >> >> Along with my own take on a lot of the common fixtures and helpers, it has >> some bits that I haven't seen anywhere else and so would like to point out: >> >> - Comparison objects for comparing objects that don't natively support >> comparison: >> >> >> http://packages.python.org/testfixtures/comparing.html#comparison-objects >> >> - Helpful mock objects for when you want to test code that makes use of >> datetime.datetime.now, datetime.date.today or time.time: >> >> http://packages.python.org/testfixtures/datetime.html >> >> - Helpers for capturing and checking messages logged from your code >> using the python logging framework: >> >> http://packages.python.org/testfixtures/logging.html >> >> - Helpers for working with temporary directories in tests. In >> particular, quickly and easily creating temporary directories and >> files within them and making assertions about things written to them >> by the code under test: >> >> http://packages.python.org/testfixtures/files.html >> >> There's plenty more in there too! >> >> Please do let me know what you find useful, if you find any bugs or if >> there are any features you'd like to see added. >> >> The package is on PyPI and a full list of all the links to docs, issue >> trackers and the like can be found here: >> >> http://www.simplistix.co.uk/software/python/testfixtures >> >> cheers, >> >> Chris >> >> -- >> Simplistix - Content Management, Batch Processing & Python Consulting >> - http://www.simplistix.co.uk >> -- >> http://mail.python.org/mailman/listinfo/python-list >> > > > > -- > The earth is a very small stage in a vast cosmic arena. Think of the rivers > of blood spilled by all those generals and emperors so that in glory and in > triumph they could become the momentary masters of a fraction of a dot. > - Carl Sagan [Pale Blue Dot] > -- The earth is a very small stage in a vast cosmic arena. Think of the rivers of blood spilled by all those generals and emperors so that in glory and in triumph they could become the momentary masters of a fraction of a dot. - Carl Sagan [Pale Blue Dot] -------------- next part -------------- An HTML attachment was scrubbed... URL: From chris at simplistix.co.uk Fri Jan 14 09:49:16 2011 From: chris at simplistix.co.uk (Chris Withers) Date: Fri, 14 Jan 2011 14:49:16 +0000 Subject: TestFixtures 1.8.0 Released! In-Reply-To: References: <4D3043C2.6020305@simplistix.co.uk> Message-ID: <4D30626C.2@simplistix.co.uk> Hi Jack, On 14/01/2011 14:39, Jack Keegan wrote: > objects. In particular, at the moment, testing some code that needs to > access hardware IOs using DLLs. I do this using Ctypes. > However, on my dev machine, I don't have the same hardware so calling > the DLL functions will not work as expected. Therefore I'd like to mock > out the ctypes dll calls. Can you give me an indication of how you would > go about doing this with TestFixtures? Just so you know, I use py.test for > unit testing. I've not used ctypes myself so let me know if things don't work ;-) I'd suggest developing mock objects to work in place of your ctypes objects. You may well find that if you're just wanting to test that the right calls are made you can use an existing mock objects such as: http://pypi.python.org/pypi/mock/ ...and then compare the method_calls attribute of the mock with what you expect it to be. TestFixtures provides some handy tools for managing the insertion and removal of mock objects, read here: http://packages.python.org/testfixtures/mocking.html cheers, Chris -- Simplistix - Content Management, Batch Processing & Python Consulting - http://www.simplistix.co.uk From whatsjacksemail at gmail.com Fri Jan 14 09:53:38 2011 From: whatsjacksemail at gmail.com (Jack Keegan) Date: Fri, 14 Jan 2011 14:53:38 +0000 Subject: TestFixtures 1.8.0 Released! In-Reply-To: <4D30626C.2@simplistix.co.uk> References: <4D3043C2.6020305@simplistix.co.uk> <4D30626C.2@simplistix.co.uk> Message-ID: Hi Chris, Thanks for that. I'll give it a go. Cheers, Jack On Fri, Jan 14, 2011 at 2:49 PM, Chris Withers wrote: > Hi Jack, > > > On 14/01/2011 14:39, Jack Keegan wrote: > >> objects. In particular, at the moment, testing some code that needs to >> access hardware IOs using DLLs. I do this using Ctypes. >> However, on my dev machine, I don't have the same hardware so calling >> the DLL functions will not work as expected. Therefore I'd like to mock >> out the ctypes dll calls. Can you give me an indication of how you would >> go about doing this with TestFixtures? Just so you know, I use py.test for >> unit testing. >> > > I've not used ctypes myself so let me know if things don't work ;-) > > I'd suggest developing mock objects to work in place of your ctypes > objects. You may well find that if you're just wanting to test that the > right calls are made you can use an existing mock objects such as: > > http://pypi.python.org/pypi/mock/ > > ...and then compare the method_calls attribute of the mock with what you > expect it to be. > > TestFixtures provides some handy tools for managing the insertion and > removal of mock objects, read here: > > http://packages.python.org/testfixtures/mocking.html > > > cheers, > > Chris > > -- > Simplistix - Content Management, Batch Processing & Python Consulting > - http://www.simplistix.co.uk > -- The earth is a very small stage in a vast cosmic arena. Think of the rivers of blood spilled by all those generals and emperors so that in glory and in triumph they could become the momentary masters of a fraction of a dot. - Carl Sagan [Pale Blue Dot] -------------- next part -------------- An HTML attachment was scrubbed... URL: From anurag.chourasia at gmail.com Fri Jan 14 10:50:56 2011 From: anurag.chourasia at gmail.com (Anurag Chourasia) Date: Fri, 14 Jan 2011 21:20:56 +0530 Subject: FTP problem In-Reply-To: References: Message-ID: Please make the below change to get past this problem Change *ftp.*indexftp.barcap.com to indexftp.barcap.com Regards, Anurag On Fri, Jan 14, 2011 at 5:25 PM, Thomas Philips wrote: > I'm using ftplib for the first time, and am having trouble getting it > to work. I type > > >>> from ftplib import FTP > >>> ftp = FTP('ftp.indexftp.barcap.com', 'A Valid Username', ' A Valid > Password') > > where I have suppressed the user name and password, and I get > > Traceback (most recent call last): > File "", line 1, in > ftp = FTP('ftp.indexftp.barcap.com') > File "C:\Python26\lib\ftplib.py", line 116, in __init__ > self.connect(host) > File "C:\Python26\lib\ftplib.py", line 131, in connect > self.sock = socket.create_connection((self.host, self.port), > self.timeout) > File "C:\Python26\lib\socket.py", line 498, in create_connection > for res in getaddrinfo(host, port, 0, SOCK_STREAM): > gaierror: [Errno 11001] getaddrinfo failed > > I have tried this on two different computers and on two different > versions of Python (2.6 and 2.7). I get the same error both times, and > have no understanding of what the problem might be. Any assistance > would be greatly appreciated. > > Sincerely > > Thomas Philips > -- > http://mail.python.org/mailman/listinfo/python-list > -------------- next part -------------- An HTML attachment was scrubbed... URL: From apzc2529 at gmail.com Fri Jan 14 10:52:41 2011 From: apzc2529 at gmail.com (Cun Zhang) Date: Fri, 14 Jan 2011 23:52:41 +0800 Subject: Is it possible to let a virtual file created by cStringIO have a filename so that functions can read it by its filename? Message-ID: Hi,all I hope use cStringIO to create virtual file, but my customed function which is from a shared library imported by ctypes just accepts a filename(string type) as parameter. So I'm wondering whether there is any method that make the virtual file created by cStringIO like a normal file which have a filename, so it can be called by my functions. Thank you! Yours, Cun Zhang -------------- next part -------------- An HTML attachment was scrubbed... URL: From steve+comp.lang.python at pearwood.info Fri Jan 14 11:07:12 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 14 Jan 2011 16:07:12 GMT Subject: python 3 and Unicode line breaking References: <32f75200-b4d8-4ec8-b07d-4740a79c28b6@g26g2000vba.googlegroups.com> <4d2f959a$0$29984$c3e8da3$5496439d@news.astraweb.com> <55c2f7dc-d4d8-4939-85de-41c19c336f23@k25g2000vbl.googlegroups.com> Message-ID: <4d3074b0$0$29984$c3e8da3$5496439d@news.astraweb.com> On Fri, 14 Jan 2011 05:06:15 -0800, leoboiko wrote: > Of course I searched for one and couldn?t find; that goes without > saying. Otherwise I wouldn?t even bother writing a message, isn?t it? You wouldn't say that if you had the slightest idea about how many people write to newsgroups and web forums asking for help without making the tiniest effort to solve the problem themselves. So, no, it *doesn't* go without saying -- unless, of course, you want the answer to also go without saying. > I disagree people should cruft their messages with details about how > they failed to find information, as that is unrelated to the question at > hand and has no point other than polluting people?s mailboxes. This is total nonsense -- how on earth can you say that it is unrelated to the question you are asking? It tells others what they should not waste their time trying, because you've already tried it. You don't need to write detailed step-by-step instructions of everything you've tried, but you can point us in the directions you've already traveled. Think of it this way... if you were paying money for professional advice, would you be happy to receive a bill for time spent doing the exact same things you have already tried? I'm sure you wouldn't be. So why do you think it is okay to waste the time of unpaid volunteers? That's just thoughtless and selfish. If you think so little of other people's time that you won't even write a few words to save them from going down the same dead-ends that you've already tried, then don't be surprised if they think so little of your time that they don't bother replying even when they know the answer. > I also see no reason to reply to a simple question with such > discourtesy, and cannot understand why someone would be so aggressive to > a stranger. If you think my reply was aggressive and discourteous, you've got a lot to learn about public forums. -- Steven From alex.kyrish at gmail.com Fri Jan 14 11:57:17 2011 From: alex.kyrish at gmail.com (Alex Boyko) Date: Fri, 14 Jan 2011 18:57:17 +0200 Subject: unbalanced tree iteration issue In-Reply-To: <461431295011620@web65.yandex.ru> References: <461431295011620@web65.yandex.ru> Message-ID: Thank you for your reply, but I have question about your code. Your defined: def post_order(self): for child in self.childs: yield child yield self just for "Node" , not for "Tree", and do w("doing generator post_order...") _t = datetime.now() for item in root.post_order(): fake = item.value w("done\n") w(datetime.now() - _t) w("\n") what give us only iterating along root's children, not iterating along tree...Or I didn't catch your though? Best Regards Alex 2011/1/14 kost BebiX > 14.01.2011, 14:15, "Alex Boyko" : > > Dear All! > > > > I have deal with large unbalanced trees and I have to implement > post-order tree traversal. My first attempt is shown below ("Node" and > "Tree" classes) and based on recursive generators approach. > > > > class Node(): > > def __init__(self,value): > > self.childs = [] > > self.value = value > > > > class Tree(): > > > > def __init__(self, root): > > self.root = root > > self.numberCells = 1 > > > > def add(self, node, child): > > node.childs.append(child) > > self.numberCells+=1 > > > > def __iter__(self): > > return self.postorder(self.root) > > > > def postorder(self, node): > > if node: > > for child in node.childs: > > for n in self.postorder(child): > > yield n > > yield node > > > > It works fine for small test trees. But, my tree has approximately 300000 > nodes, and shown post order traversal with generators takes 80 sec against 1 > sec with simple recursive routine: > > > > def recursiveFromTop(node): > > for child in node.childs: > > recursiveFromTop(child) > > ## here I can do some computations with current node's data > > > > So, I'd like to know how should I implement (if it's possible of course) > __iter__ for my tree class based on recursion without generators? Please, > can You show me the ways? > > because I'm very passionate in idea iterate through my tree with simple: > > > > for node in tree: > > do something with node > > > > Thanks in Advance! > > Best Regards! > > Alex > > > > -- > > http://mail.python.org/mailman/listinfo/python-list > > Well, I think it's actually because the difference is that you would not do > yielding, you would just put everything in memory and then return it. > > ret_val = [x for x in self.postorder(child)] > return ret_val + [self] > > or something like that (but beware of memory). But that's strange. This > code works fast: > > #!/usr/bin/env python > # -*- coding: utf-8 -*- > > import sys > > def w(s): > sys.stdout.write("%s" % s) > sys.stdout.flush() > > class Node(): > __slots__ = ('childs', 'value',) > > def __init__(self, value): > self.childs = [] > self.value = value > > def post_order(self): > for child in self.childs: > yield child > yield self > > def build_tree(): > def append_1000_childs(node): > for i in xrange(20): > node.childs.append(Node(10)) > > def append_n_levels(node, levels=1): > if levels >= 1: > append_1000_childs(node) > if levels > 1: > for child in node.childs: > append_n_levels(child, levels - 1) > > root = Node(10) > append_n_levels(root, 5) > return root > > if __name__ == '__main__': > from datetime import datetime > > w("building tree...") > _t = datetime.now() > root = build_tree() > w("done\n") > w(datetime.now() - _t) > w("\n") > > w("doing generator post_order...") > _t = datetime.now() > for item in root.post_order(): > fake = item.value > w("done\n") > w(datetime.now() - _t) > w("\n") > > def post_order(root): > for child in root.childs: > post_order(child) > fake = item.value > > w("doing non-generator post_order...") > _t = datetime.now() > post_order(root) > w("done\n") > w(datetime.now() - _t) > w("\n") > > $ python postorder.py > building tree...done > 0:01:34.422288 > doing generator post_order...done > 0:00:00.000018 > doing non-generator post_order...done > 0:00:01.232272 > > -- > jabber: k.bx at ya.ru > -------------- next part -------------- An HTML attachment was scrubbed... URL: From alex.kyrish at gmail.com Fri Jan 14 12:32:24 2011 From: alex.kyrish at gmail.com (Alex Boyko) Date: Fri, 14 Jan 2011 19:32:24 +0200 Subject: unbalanced tree iteration issue In-Reply-To: References: <461431295011620@web65.yandex.ru> Message-ID: So I mean, your approach with generators showed good results in terms of time efficiency 'cos iteration was done for root and root's children. On 14 January 2011 18:57, Alex Boyko wrote: > Thank you for your reply, but I have question about your code. Your > defined: > > def post_order(self): > for child in self.childs: > yield child > yield self > > just for "Node" , not for "Tree", and do > > w("doing generator post_order...") > _t = datetime.now() > for item in root.post_order(): > fake = item.value > w("done\n") > w(datetime.now() - _t) > w("\n") > > what give us only iterating along root's children, not iterating along > tree...Or I didn't catch your though? > > Best Regards > Alex > > 2011/1/14 kost BebiX > > 14.01.2011, 14:15, "Alex Boyko" : >> > Dear All! >> > >> > I have deal with large unbalanced trees and I have to implement >> post-order tree traversal. My first attempt is shown below ("Node" and >> "Tree" classes) and based on recursive generators approach. >> > >> > class Node(): >> > def __init__(self,value): >> > self.childs = [] >> > self.value = value >> > >> > class Tree(): >> > >> > def __init__(self, root): >> > self.root = root >> > self.numberCells = 1 >> > >> > def add(self, node, child): >> > node.childs.append(child) >> > self.numberCells+=1 >> > >> > def __iter__(self): >> > return self.postorder(self.root) >> > >> > def postorder(self, node): >> > if node: >> > for child in node.childs: >> > for n in self.postorder(child): >> > yield n >> > yield node >> > >> > It works fine for small test trees. But, my tree has approximately >> 300000 nodes, and shown post order traversal with generators takes 80 sec >> against 1 sec with simple recursive routine: >> > >> > def recursiveFromTop(node): >> > for child in node.childs: >> > recursiveFromTop(child) >> > ## here I can do some computations with current node's data >> > >> > So, I'd like to know how should I implement (if it's possible of course) >> __iter__ for my tree class based on recursion without generators? Please, >> can You show me the ways? >> > because I'm very passionate in idea iterate through my tree with simple: >> > >> > for node in tree: >> > do something with node >> > >> > Thanks in Advance! >> > Best Regards! >> > Alex >> > >> > -- >> > http://mail.python.org/mailman/listinfo/python-list >> >> Well, I think it's actually because the difference is that you would not >> do yielding, you would just put everything in memory and then return it. >> >> ret_val = [x for x in self.postorder(child)] >> return ret_val + [self] >> >> or something like that (but beware of memory). But that's strange. This >> code works fast: >> >> #!/usr/bin/env python >> # -*- coding: utf-8 -*- >> >> import sys >> >> def w(s): >> sys.stdout.write("%s" % s) >> sys.stdout.flush() >> >> class Node(): >> __slots__ = ('childs', 'value',) >> >> def __init__(self, value): >> self.childs = [] >> self.value = value >> >> def post_order(self): >> for child in self.childs: >> yield child >> yield self >> >> def build_tree(): >> def append_1000_childs(node): >> for i in xrange(20): >> node.childs.append(Node(10)) >> >> def append_n_levels(node, levels=1): >> if levels >= 1: >> append_1000_childs(node) >> if levels > 1: >> for child in node.childs: >> append_n_levels(child, levels - 1) >> >> root = Node(10) >> append_n_levels(root, 5) >> return root >> >> if __name__ == '__main__': >> from datetime import datetime >> >> w("building tree...") >> _t = datetime.now() >> root = build_tree() >> w("done\n") >> w(datetime.now() - _t) >> w("\n") >> >> w("doing generator post_order...") >> _t = datetime.now() >> for item in root.post_order(): >> fake = item.value >> w("done\n") >> w(datetime.now() - _t) >> w("\n") >> >> def post_order(root): >> for child in root.childs: >> post_order(child) >> fake = item.value >> >> w("doing non-generator post_order...") >> _t = datetime.now() >> post_order(root) >> w("done\n") >> w(datetime.now() - _t) >> w("\n") >> >> $ python postorder.py >> building tree...done >> 0:01:34.422288 >> doing generator post_order...done >> 0:00:00.000018 >> doing non-generator post_order...done >> 0:00:01.232272 >> >> -- >> jabber: k.bx at ya.ru >> > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ian.g.kelly at gmail.com Fri Jan 14 13:07:32 2011 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Fri, 14 Jan 2011 11:07:32 -0700 Subject: unbalanced tree iteration issue In-Reply-To: References: Message-ID: On Fri, Jan 14, 2011 at 5:15 AM, Alex Boyko wrote: > So, I'd like to know how?should?I implement (if it's possible of course) > __iter__ for my tree class based on recursion without generators? You could try something like this (untested): from itertools import chain, imap ... def postorder(self, node): return chain(chain.from_iterable(imap(self.postorder, node.childs)), [node]) Or you could write the iterator the old-fashioned way, as an object with state (also untested): def __iter__(self): return PostOrderIter(self.root) class PostOrderIter(object): def __iter__(self, node): self.stack = [(node, 0)] def next(self): if not self.stack: raise StopIteration node, index = self.stack.pop() if index < len(node.childs): child = node.childs[index] self.stack.append((node, index+1)) self.stack.append((child, 0)) return self.next() else: return node From ian.g.kelly at gmail.com Fri Jan 14 13:08:36 2011 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Fri, 14 Jan 2011 11:08:36 -0700 Subject: unbalanced tree iteration issue In-Reply-To: References: Message-ID: On Fri, Jan 14, 2011 at 11:07 AM, Ian Kelly wrote: > class PostOrderIter(object): > > ? ?def __iter__(self, node): > ? ? ? ?self.stack = [(node, 0)] That __iter__ should actually be __init__, of course. From k.bx at ya.ru Fri Jan 14 13:08:42 2011 From: k.bx at ya.ru (kost BebiX) Date: Fri, 14 Jan 2011 20:08:42 +0200 Subject: unbalanced tree iteration issue In-Reply-To: References: <461431295011620@web65.yandex.ru> Message-ID: <189501295028530@web144.yandex.ru> 14.01.2011, 18:57, "Alex Boyko" : > 2011/1/14 kost BebiX >> 14.01.2011, 14:15, "Alex Boyko" : >> >>> Dear All! >>> >>> I have deal with large unbalanced trees and I have to implement post-order tree traversal. My first attempt is shown below ("Node" and "Tree" classes) and based on recursive generators approach. >>> >>> class Node(): >>> ?? ?def __init__(self,value): >>> ?? ? ? ?self.childs = [] >>> ?? ? ? ?self.value = value >>> >>> class Tree(): >>> >>> ?? ?def __init__(self, root): >>> ?? ? ? ?self.root = root >>> ?? ? ? ?self.numberCells = 1 >>> >>> ?? ?def add(self, node, child): >>> ?? ? ? ?node.childs.append(child) >>> ?? ? ? ?self.numberCells+=1 >>> >>> ?? ?def __iter__(self): >>> ?? ? ? ?return self.postorder(self.root) >>> >>> ?? ?def postorder(self, node): >>> ?? ? ? ?if node: >>> ?? ? ? ? ? ?for child in node.childs: >>> ?? ? ? ? ? ? ? ?for n in self.postorder(child): >>> ?? ? ? ? ? ? ? ? ? ?yield n >>> ?? ? ? ? ? ?yield node >>> >>> It works fine for small test trees. But, my tree has approximately 300000 nodes, and shown post order traversal with generators takes 80 sec against 1 sec with simple recursive routine: >>> >>> def recursiveFromTop(node): >>> ?? ?for child in node.childs: >>> ?? ? ? ?recursiveFromTop(child) >>> ?? ? ? ?## here I can do some computations with current node's data >>> >>> So, I'd like to know how?should?I implement (if it's possible of course) __iter__ for my tree class based on recursion without generators? Please, can You show me the ways? >>> because I'm very passionate in idea iterate through my tree with simple: >>> >>> for node in tree: >>> ?? do something with node >>> >>> Thanks in Advance! >>> Best Regards! >>> Alex >>> >> >>> -- >>> http://mail.python.org/mailman/listinfo/python-list >> >> Well, I think it's actually because the difference is that you would not do yielding, you would just put everything in memory and then return it. >> >> ret_val = [x for x in self.postorder(child)] >> return ret_val + [self] >> >> or something like that (but beware of memory). But that's strange. This code works fast: >> >> #!/usr/bin/env python >> # -*- coding: utf-8 -*- >> >> import sys >> >> def w(s): >> ? ?sys.stdout.write("%s" % s) >> ? ?sys.stdout.flush() >> >> class Node(): >> ? ?__slots__ = ('childs', 'value',) >> >> ? ?def __init__(self, value): >> ? ? ? ?self.childs = [] >> ? ? ? ?self.value = value >> >> ? ?def post_order(self): >> ? ? ? ?for child in self.childs: >> ? ? ? ? ? ?yield child >> ? ? ? ?yield self >> >> def build_tree(): >> ? ?def append_1000_childs(node): >> ? ? ? ?for i in xrange(20): >> ? ? ? ? ? ?node.childs.append(Node(10)) >> >> ? ?def append_n_levels(node, levels=1): >> ? ? ? ?if levels >= 1: >> ? ? ? ? ? ?append_1000_childs(node) >> ? ? ? ? ? ?if levels > 1: >> ? ? ? ? ? ? ? ?for child in node.childs: >> >> ? ? ? ? ? ? ? ? ? ?append_n_levels(child, levels - 1) >> >> ? ?root = Node(10) >> ? ?append_n_levels(root, 5) >> ? ?return root >> >> if __name__ == '__main__': >> ? ?from datetime import datetime >> >> ? ?w("building tree...") >> ? ?_t = datetime.now() >> ? ?root = build_tree() >> ? ?w("done\n") >> ? ?w(datetime.now() - _t) >> ? ?w("\n") >> >> ? ?w("doing generator post_order...") >> ? ?_t = datetime.now() >> ? ?for item in root.post_order(): >> ? ? ? ?fake = item.value >> ? ?w("done\n") >> ? ?w(datetime.now() - _t) >> ? ?w("\n") >> >> ? ?def post_order(root): >> ? ? ? ?for child in root.childs: >> ? ? ? ? ? ?post_order(child) >> ? ? ? ? ? ?fake = item.value >> >> ? ?w("doing non-generator post_order...") >> ? ?_t = datetime.now() >> ? ?post_order(root) >> ? ?w("done\n") >> ? ?w(datetime.now() - _t) >> ? ?w("\n") >> >> $ python postorder.py >> building tree...done >> 0:01:34.422288 >> doing generator post_order...done >> 0:00:00.000018 >> doing non-generator post_order...done >> 0:00:01.232272 >> >> -- >> jabber: k.bx at ya.ru > Thank you for your reply, but I have question about your code. Your defined: > > def post_order(self): > for child in self.childs: > yield child > yield self > > just for "Node" , not for "Tree", and do > > w("doing generator post_order...") > _t = datetime.now() > for item in root.post_order(): > fake = item.value > w("done\n") > w(datetime.now() - _t) > w("\n") > > what give us only iterating along root's children, not iterating along tree...Or I didn't catch your though? > > Best Regards > Alex > Well, isn't tree is a root node and it's children? Why do you need Tree class anyway? p.s.: please, do not top-post the messages, write your reply at bottom because it will then be easier to read for those who will google this page. -- jabber: k.bx at ya.ru From ian.g.kelly at gmail.com Fri Jan 14 13:19:01 2011 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Fri, 14 Jan 2011 11:19:01 -0700 Subject: unbalanced tree iteration issue In-Reply-To: <189501295028530@web144.yandex.ru> References: <461431295011620@web65.yandex.ru> <189501295028530@web144.yandex.ru> Message-ID: 2011/1/14 kost BebiX : > Well, isn't tree is a root node and it's children? And its grandchildren, great-grandchildren, etc. What Alex is saying is that the implementation you posted traverses the root and its immediate children, but does not recur any further than that. That is why it was so fast. From k.bx at ya.ru Fri Jan 14 13:41:31 2011 From: k.bx at ya.ru (kost BebiX) Date: Fri, 14 Jan 2011 20:41:31 +0200 Subject: unbalanced tree iteration issue In-Reply-To: References: <461431295011620@web65.yandex.ru> <189501295028530@web144.yandex.ru> Message-ID: <141461295030492@web155.yandex.ru> 14.01.2011, 20:19, "Ian Kelly" : > 2011/1/14 kost BebiX ;: > >> ?Well, isn't tree is a root node and it's children? > > And its grandchildren, great-grandchildren, etc. ?What Alex is saying > is that the implementation you posted traverses the root and its > immediate children, but does not recur any further than that. ?That is > why it was so fast. Oh, yeah, sorry, forgot the recursion. It should be (if I'm not wrong again): def post_order(self): for child in self.childs: for po in child.post_order(): yield po yield self if you give it more deepness: $ python postorder.py building tree...done 0:00:25.839462 doing generator post_order...done 0:00:02.776876 doing non-generator post_order...done 0:00:01.092648 still not bad, but if you'll give it more deepness $ python postorder.py building tree...done 0:00:16.078972 doing generator post_order...done 0:00:03.119023 doing non-generator post_order...done 0:00:00.841976 it will be worse -- jabber: k.bx at ya.ru From nagle at animats.com Fri Jan 14 13:57:59 2011 From: nagle at animats.com (John Nagle) Date: Fri, 14 Jan 2011 10:57:59 -0800 Subject: how to use priority queue with multiprocessing In-Reply-To: References: Message-ID: <4d309cc3$0$43988$742ec2ed@news.sonic.net> On 1/13/2011 9:07 AM, Marco Hornung wrote: > Hey, > > ------------------------------------------------------------------------------------------ > > question > ------------------------------------------------------------------------------------------ > > How can I use a priority queue to schedule jobs within the "multiprocessing pool" module? > > ------------------------------------------------------------------------------------------ > > my scenario > ------------------------------------------------------------------------------------------ > > I want to run several jobs on a server. The jobs are being sent by users. However, all jobs have a different priority, and high-priority jobs should be processed before any low-priority job gets touched. > Currently I just append all incoming jobs to the multiprocessing > worker pool as follows: ### initialize worker pool pool = > PriorityPool(processes=worker_count) process_handles = [] > > ### distribute function execution over several processes for > job_parameter in job_parameter_list: handle = > pool.apply_async(process_function, [job_parameter,]) > process_handles.append(handle) > > This will only put the jobs in some kind of a list - and execute the > jobs in the order they come in. Is it possible to use a priority > queue for the process-pool? > You''ll probably have to track the available processes yourself, starting a new job when there's a process available. One way to do this is to have a management thread for each process. Each management thread starts a subprocess, gets a work item from the priority queue (blocking if necessary), gives it to the subprocess, waits for the subprocess to return a result, and goes back to get another work item. This is straightforward, except for working out a way to cleanly shut the thing down. One way to do that is to have a "shutdown" flag visible to all the threads. That's checked before getting a new task. If it's set, the thread terminates its subprocess and returns. Set the terminate flag in a signal handler for control-C. (I have something that manages multiple processes using a priority queue, where the queue is implemented using MySQL. This allows me to put a whole cluster to work.) John Nagle From a.j.romanista at gmail.com Fri Jan 14 14:39:40 2011 From: a.j.romanista at gmail.com (Ata Jafari) Date: Fri, 14 Jan 2011 11:39:40 -0800 (PST) Subject: Developing a program to make a family tree. Message-ID: <317f6ed0-ebd9-4a58-9ad3-da57563193ad@w29g2000vba.googlegroups.com> Hi there. I'm trying to develop a program like family tree maker. I have all information, so there is no need to search on the net. This must be something like trees. Can someone help me? I'm at the beginning. Thanks. -- Ata J. Tabrizi atae.tabrizi at metu.edu.tr From solipsis at pitrou.net Fri Jan 14 14:47:35 2011 From: solipsis at pitrou.net (Antoine Pitrou) Date: Fri, 14 Jan 2011 20:47:35 +0100 Subject: python 3 and Unicode line breaking References: <32f75200-b4d8-4ec8-b07d-4740a79c28b6@g26g2000vba.googlegroups.com> <4d2f959a$0$29984$c3e8da3$5496439d@news.astraweb.com> <55c2f7dc-d4d8-4939-85de-41c19c336f23@k25g2000vbl.googlegroups.com> <4d3074b0$0$29984$c3e8da3$5496439d@news.astraweb.com> Message-ID: <20110114204735.094d1c8a@pitrou.net> Hey, On 14 Jan 2011 16:07:12 GMT Steven D'Aprano wrote: > > > I also see no reason to reply to a simple question with such > > discourtesy, and cannot understand why someone would be so aggressive to > > a stranger. > > If you think my reply was aggressive and discourteous, you've got a lot > to learn about public forums. Perhaps you've got to learn about politeness yourself! Just because some people are jerks on internet forums (or in real life) doesn't mean everyone should; this is quite a stupid and antisocial excuse actually. You would never have reacted this way if the same question had been phrased by a regular poster here (let alone on python-dev). Taking cheap shots at newcomers is certainly not the best way to welcome them. Thank you Antoine. From mukeshtiwari.iiitm at gmail.com Fri Jan 14 14:52:21 2011 From: mukeshtiwari.iiitm at gmail.com (mukesh tiwari) Date: Fri, 14 Jan 2011 11:52:21 -0800 (PST) Subject: Elliptic Curve Prime factorisation Message-ID: <2040fe29-f11d-4e64-acac-d49ae8bb5ca9@u32g2000yqe.googlegroups.com> Hello all , I have implemented Elliptic curve prime factorisation using wikipedia [ http://en.wikipedia.org/wiki/Lenstra_elliptic_curve_factorization]. I think that this code is not optimised and posting for further improvement. Feel free to comment and if you have any link regarding Elliptic curve prime factorisation , kindly post it. Thank you import math import random #y^2=x^3+ax+b mod n def extended_gcd(a,b): # taken from wikipedia x,y,lastx,lasty=0,1,1,0 while b!=0: q=a/b a,b=b,a%b x,lastx=(lastx-q*x,x) y,lasty=(lasty-q*y,y) if a<0: return (-a,-lastx,-lasty) else: return (a,lastx,lasty) def gcd(a,b): if a < 0: a = -a if b < 0: b = -b if a == 0: return b if b == 0: return a while b != 0: (a, b) = (b, a%b) return a def randomCurve(N): A,u,v=random.randrange(N),random.randrange(N),random.randrange(N) B=(v*v-u*u*u-A*u)%N return [(A,B,N),(u,v)] def addPoint(E,p_1,p_2): if p_1=="Identity": return [p_2,1] if p_2=="Identity": return [p_1,1] a,b,n=E (x_1,y_1)=p_1 (x_2,y_2)=p_2 x_1%=n y_1%=n x_2%=n y_2%=n if x_1 != x_2 : d,u,v=extended_gcd(x_1-x_2,n) s=((y_1-y_2)*u)%n x_3=(s*s-x_1-x_2)%n y_3=(-y_1-s*(x_3-x_1))%n else: if (y_1+y_2)%n==0:return ["Identity",1] else: d,u,v=extended_gcd(2*y_1,n) s=((3*x_1*x_1+a)*u)%n x_3=(s*s-2*x_1)%n y_3=(-y_1-s*(x_3-x_1))%n return [(x_3,y_3),d] def mulPoint(E,P,m): Ret="Identity" d=1 while m!=0: if m%2!=0: Ret,d=addPoint(E,Ret,P) if d!=1 : return [Ret,d] # as soon as i got anything otherthan 1 return P,d=addPoint(E,P,P) if d!=1 : return [Ret,d] m>>=1 return [Ret,d] def ellipticFactor(N,m,times=5): for i in xrange(times): E,P=randomCurve(N); Q,d=mulPoint(E,P,m) if d!=1 : return d return N if __name__=="__main__": n=input() m=int(math.factorial(1000)) while n!=1: k=ellipticFactor(n,m) n/=k print k From joncle at googlemail.com Fri Jan 14 14:57:52 2011 From: joncle at googlemail.com (Jon Clements) Date: Fri, 14 Jan 2011 11:57:52 -0800 (PST) Subject: Developing a program to make a family tree. References: <317f6ed0-ebd9-4a58-9ad3-da57563193ad@w29g2000vba.googlegroups.com> Message-ID: On Jan 14, 7:39?pm, Ata Jafari wrote: > Hi there. > I'm trying to develop a program like family tree maker. I have all > information, so there is no need to search on the net. This must be > something like trees. Can someone help me? I'm at the beginning. > Thanks. > > -- > Ata J. Tabrizi > atae.tabr... at metu.edu.tr If you're after mature and actively developed Genealogy software developed in Python, then check out http://gramps-project.org/ The developer list is very friendly. Otherwise, you're in for a struggle, as you need to choose a storage back-end, a GUI (wxWindows/GTK/Qt4 etc...), how to handle GEDCOM format (unless it's not going to be compatible with other software), does it need to produce web pages/reports (and in what formats). I strongly suggest looking at GRAMPS and see what you're setting yourself up for :) hth Jon From k.bx at ya.ru Fri Jan 14 15:01:52 2011 From: k.bx at ya.ru (kost BebiX) Date: Fri, 14 Jan 2011 22:01:52 +0200 Subject: Elliptic Curve Prime factorisation In-Reply-To: <2040fe29-f11d-4e64-acac-d49ae8bb5ca9@u32g2000yqe.googlegroups.com> References: <2040fe29-f11d-4e64-acac-d49ae8bb5ca9@u32g2000yqe.googlegroups.com> Message-ID: <792711295035313@web108.yandex.ru> 14.01.2011, 21:52, "mukesh tiwari" : > Hello all , I have implemented Elliptic curve prime factorisation > using wikipedia [ http://en.wikipedia.org/wiki/Lenstra_elliptic_curve_factorization]. > I think that this code is not optimised and posting for further > improvement. Feel free to comment and if you have any link regarding > Elliptic curve prime factorisation , kindly post it. > Thank you > > import math > import random > > #y^2=x^3+ax+b mod n > > def extended_gcd(a,b): ??# taken from wikipedia > ????????x,y,lastx,lasty=0,1,1,0 > ????????while b!=0: > ????????????????q=a/b > ????????????????a,b=b,a%b > ????????????????x,lastx=(lastx-q*x,x) > ????????????????y,lasty=(lasty-q*y,y) > ????????if a<0: > ????????????????return (-a,-lastx,-lasty) > ????????else: > ????????????????return (a,lastx,lasty) > def gcd(a,b): > ????????if a < 0: ?a = -a > ????????if b < 0: ?b = -b > ????????if a == 0: return b > ????????if b == 0: return a > ????????while b != 0: > ????????????????(a, b) = (b, a%b) > ????????return a > > def randomCurve(N): > ????????A,u,v=random.randrange(N),random.randrange(N),random.randrange(N) > ????????B=(v*v-u*u*u-A*u)%N > ????????return [(A,B,N),(u,v)] > > def addPoint(E,p_1,p_2): > ????????if p_1=="Identity": return [p_2,1] > ????????if p_2=="Identity": return [p_1,1] > ????????a,b,n=E > ????????(x_1,y_1)=p_1 > ????????(x_2,y_2)=p_2 > ????????x_1%=n > ????????y_1%=n > ????????x_2%=n > ????????y_2%=n > ????????if x_1 != x_2 : > ????????????????d,u,v=extended_gcd(x_1-x_2,n) > ????????????????s=((y_1-y_2)*u)%n > ????????????????x_3=(s*s-x_1-x_2)%n > ????????????????y_3=(-y_1-s*(x_3-x_1))%n > ????????else: > ????????????????if (y_1+y_2)%n==0:return ["Identity",1] > ????????????????else: > ????????????????????????d,u,v=extended_gcd(2*y_1,n) > ????????????????????????s=((3*x_1*x_1+a)*u)%n > ????????????????????????x_3=(s*s-2*x_1)%n > ????????????????????????y_3=(-y_1-s*(x_3-x_1))%n > > ????????return [(x_3,y_3),d] > > def mulPoint(E,P,m): > ????????Ret="Identity" > ????????d=1 > ????????while m!=0: > ????????????????if m%2!=0: Ret,d=addPoint(E,Ret,P) > ????????????????if d!=1 : return [Ret,d] ?# as soon as i got anything otherthan 1 > return > ????????????????P,d=addPoint(E,P,P) > ????????????????if d!=1 : return [Ret,d] > ????????????????m>>=1 > ????????return [Ret,d] > > def ellipticFactor(N,m,times=5): > ????????for i in xrange(times): > ????????????????E,P=randomCurve(N); > ????????????????Q,d=mulPoint(E,P,m) > ????????????????if d!=1 : return d > ????????return N > > if __name__=="__main__": > ????????n=input() > ????????m=int(math.factorial(1000)) > ????????while n!=1: > ????????????????k=ellipticFactor(n,m) > ????????????????n/=k > ????????????????print k > > -- > http://mail.python.org/mailman/listinfo/python-list Well, first of all you should read and follow this http://www.python.org/dev/peps/pep-0008/ :-) -- jabber: k.bx at ya.ru From awilliam at whitemice.org Fri Jan 14 15:16:48 2011 From: awilliam at whitemice.org (Adam Tauno Williams) Date: Fri, 14 Jan 2011 15:16:48 -0500 Subject: how to use priority queue with multiprocessing In-Reply-To: <4d309cc3$0$43988$742ec2ed@news.sonic.net> References: <4d309cc3$0$43988$742ec2ed@news.sonic.net> Message-ID: <1295036208.8883.7.camel@linux-yu4c.site> On Fri, 2011-01-14 at 10:57 -0800, John Nagle wrote: > On 1/13/2011 9:07 AM, Marco Hornung wrote: > I want to run several jobs on a server. The jobs are being sent by > users. However, all jobs have a different priority, and high-priority > jobs should be processed before any low-priority job gets touched. > > Currently I just append all incoming jobs to the multiprocessing > > worker pool as follows: ### initialize worker pool pool = > > PriorityPool(processes=worker_count) process_handles = [] > > ### distribute function execution over several processes for > > job_parameter in job_parameter_list: handle = > > pool.apply_async(process_function, [job_parameter,]) > > process_handles.append(handle) > > This will only put the jobs in some kind of a list - and execute the > > jobs in the order they come in. Is it possible to use a priority > > queue for the process-pool? > You''ll probably have to track the available processes yourself, > starting a new job when there's a process available. Which is exactly what we do in OpenGroupwre Coils' OIE. There is a process [job] list which is sorted by priority and the next available process is started when a worker is available. We use multiprocessing to create a *process*, rather than a thread, for each job. > One way to do this is to have a management thread for each > process. Each management thread starts a subprocess, gets > a work item from the priority queue (blocking if necessary), > gives it to the subprocess, waits for the subprocess to > return a result, and goes back to get another work item. We have a manager process and an executor process. These communicate via AMQ, but you could use any mechanism. The manager process controls the process [job] list. When a process needs to be started a message is send to the executor which creates a worker process if an opening is available. Otherwise it messages the manager process to place the process in a queued state. When a worker process completes it messages the executor which in turn messages the manager that a process slot may be available; then the manager looks up the next available process and messages the executor to start it - provided a worker slot is still available the executor will start the worker.... [otherwise the process will go back into a queued state]. > This is straightforward, except for working out a way > to cleanly shut the thing down. One way to do that is > to have a "shutdown" flag visible to all the threads. Using a message bus helps a lot, and with multiprocessing you just do a join/isalive to make sure a worker is still working. From clp2 at rebertia.com Fri Jan 14 15:51:11 2011 From: clp2 at rebertia.com (Chris Rebert) Date: Fri, 14 Jan 2011 12:51:11 -0800 Subject: Is it possible to let a virtual file created by cStringIO have a filename so that functions can read it by its filename? In-Reply-To: References: Message-ID: On Fri, Jan 14, 2011 at 7:52 AM, Cun Zhang wrote: > Hi,all > I hope use cStringIO to create virtual file, but my customed function which > is from a shared library imported by ctypes > just accepts a filename(string type) as parameter. > > So I'm wondering whether there is any method that make the virtual file > created by cStringIO like a normal file which have > a filename, so it can be called by my functions. That's not possible. (c)StringIO presents a file-like interface at the Python level, but under the covers, it's not implemented using anything like a normal file; thus, it doesn't have a presence on any filesystem. I would suggest using a temporary file (http://docs.python.org/library/tempfile.html ) for communicating with the C module, writing the contents of the StringIO object to the temporary file if necessary. (It's probably also possible to hack something together with FUSE, but it'd be a slow, platform-specific kludge.) Cheers, Chris -- http://blog.rebertia.com From cjwilliams43 at gmail.com Fri Jan 14 16:11:51 2011 From: cjwilliams43 at gmail.com (Colin J. Williams) Date: Fri, 14 Jan 2011 16:11:51 -0500 Subject: python 3 and Unicode line breaking In-Reply-To: References: <32f75200-b4d8-4ec8-b07d-4740a79c28b6@g26g2000vba.googlegroups.com> <4d2f959a$0$29984$c3e8da3$5496439d@news.astraweb.com> <55c2f7dc-d4d8-4939-85de-41c19c336f23@k25g2000vbl.googlegroups.com> <4d3074b0$0$29984$c3e8da3$5496439d@news.astraweb.com> Message-ID: On 14-Jan-11 14:47 PM, Antoine Pitrou wrote: > > Hey, > > On 14 Jan 2011 16:07:12 GMT > Steven D'Aprano wrote: >> >>> I also see no reason to reply to a simple question with such >>> discourtesy, and cannot understand why someone would be so aggressive to >>> a stranger. >> >> If you think my reply was aggressive and discourteous, you've got a lot >> to learn about public forums. > > Perhaps you've got to learn about politeness yourself! Just because > some people are jerks on internet forums (or in real life) doesn't mean > everyone should; this is quite a stupid and antisocial excuse actually. > > You would never have reacted this way if the same question had been > phrased by a regular poster here (let alone on python-dev). Taking > cheap shots at newcomers is certainly not the best way to welcome > them. > > Thank you > > Antoine. > > +1 From xahlee at gmail.com Fri Jan 14 16:20:28 2011 From: xahlee at gmail.com (Xah Lee) Date: Fri, 14 Jan 2011 13:20:28 -0800 (PST) Subject: do you know what's CGI? (web history personal story) Message-ID: some extempore thought. Do you know what is CGI? Worked with Mathematica for 5 hours yesterday. Fantastic! This old hand can still do something! lol. My plane curve packages soon to be out n am gonna be rich. ...gosh what godly hours i've spend on Mathematica in 1990s. Surprised to find that i even Unproctected builtin symbols to fix things. (get rid of asymptotes in ParametricPlot) (Draft notes as i go: Mathematica Version 3 to Version 7 Conversion Notes) ... i recall, i stopped doing Mathematica in 1998 because it's a career dead-end as a programing lang, and dived into the utterly idiotic Perl & unix & mysql world. (See: The Unix Pestilence ? Xah Lee's Computing Experience (Impression Of Lisp from Mathematica).) Well, dead-end just as Emacs Lisp i'm spending my nights with in the past 4 years. LOL. And on that note, same thing can be said with haskell, OCaml. Though, fringe langs are picking up these days. Remember Python, ruby, in year 2000? Who'd imagined they'd become mainstream. But it took 10+ years. (See: Language, Purity, Cult, and Deception.) Also got reminded my age recently. Someone on stackoverflow is asking about what are those ?A:? and ?B:? drives on Windows. (anyone heard of floppy drives?) In another incident, i was chatting to a friend, and the topic went to internet tech in 1990s, and i was telling him about how PHP (aka Pretty Home Page) came about, then naturally i discussed CGI. After a while, i realized, those who are around 20 years old today were under 10 in the 1990s. They wouldn't know what was CGI, and no amount of explanation can tell them exactly it was like, because it has become HISTORY ? if you didn't live it, you can't feel it. http://xahlee.blogspot.com/2011/01/do-you-know-what-is-cgi.html Xah ? http://xahlee.org/ From debatem1 at gmail.com Fri Jan 14 16:37:24 2011 From: debatem1 at gmail.com (geremy condra) Date: Fri, 14 Jan 2011 13:37:24 -0800 Subject: Tkinter: The good, the bad, and the ugly! In-Reply-To: References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <18c2f4d8-0cce-4cdf-a386-80831dc2f114@m37g2000vbn.googlegroups.com> Message-ID: On Wed, Dec 29, 2010 at 5:03 PM, rantingrick wrote: > On Dec 29, 6:41?pm, Gerry Reno wrote: >> Also, what do you think about frameworks such as pyjamas? ?It lets you >> write in python and compiles everything down to Javascript so it can be >> used across the Web as well as on the desktop. > > Hmm, this is like two double edged swords smashing one another in > battle. Seriously, get off of WoW and go write some code. If you'd spent the last year programming instead of doing your best Xah Lee impression you might have actually made some progress on this. Geremy Condra From ladasky at my-deja.com Fri Jan 14 16:41:56 2011 From: ladasky at my-deja.com (John Ladasky) Date: Fri, 14 Jan 2011 13:41:56 -0800 (PST) Subject: Python use growing fast References: <4D2B73D1.6060303@mrabarnett.plus.com> Message-ID: <48293735-9370-4037-b130-07f6735df886@m11g2000vbs.googlegroups.com> On Jan 10, 1:43?pm, Alice Bevan?McGregor wrote: > On 2011-01-10 13:02:09 -0800, MRAB said: > > Wikipedia is a Wiki; everyone is free to contribute and correct mistakes. > > ? ? ? ? - Alice. Except for some of us. I tried to make a correction to a chemistry Wikipedia entry several months back. I received a message saying that a series of IP addresses which happen to include the one that my ISP assigned me had been blocked, due to hacking problems. Wikipedia provided a link to contact a real human being to request that an address be unblocked. I submitted a request, and -- nothing happened. From miki.tebeka at gmail.com Fri Jan 14 17:05:54 2011 From: miki.tebeka at gmail.com (Miki) Date: Fri, 14 Jan 2011 14:05:54 -0800 (PST) Subject: wx Just Print! In-Reply-To: <00354847-5ab0-4247-802c-15cd0f7d22c7@fo10g2000vbb.googlegroups.com> Message-ID: <6c709190-4294-4b17-8ca4-b3e0c6ab8f57@glegroupsg2000goo.googlegroups.com> I think you need to create a wxApp first. Try adding app = wx.PySimpleApp() at the beginning. From steve+comp.lang.python at pearwood.info Fri Jan 14 17:10:02 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 14 Jan 2011 22:10:02 GMT Subject: python 3 and Unicode line breaking References: <32f75200-b4d8-4ec8-b07d-4740a79c28b6@g26g2000vba.googlegroups.com> <4d2f959a$0$29984$c3e8da3$5496439d@news.astraweb.com> <55c2f7dc-d4d8-4939-85de-41c19c336f23@k25g2000vbl.googlegroups.com> <4d3074b0$0$29984$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4d30c9ba$0$29984$c3e8da3$5496439d@news.astraweb.com> On Fri, 14 Jan 2011 20:47:35 +0100, Antoine Pitrou wrote: > You would never have reacted this way if the same question had been > phrased by a regular poster here (let alone on python-dev). Taking cheap > shots at newcomers is certainly not the best way to welcome them. You're absolutely correct. Regular posters have demonstrated their ability to perform the basics -- if you had asked the question, I could assume that you would have done a google search, because I know you're not a lazy n00b who expects others to do their work for them. But the Original Poster has not, as far as I can see, ever posted here before. He has no prior reputation and gives no detail in his post. You have focused on my first blunt remark, and ignored the second: "If you have tried searching, please say so, otherwise most people will conclude you haven't bothered, and most likely will not bother to reply." This is good, helpful advice, and far more useful to the OP than just ignoring his post. You have jumped to his defense (or rather, you have jumped to criticise me) but I see that you haven't replied to his question or given him any advice in how to solve his problem. Instead of encouraging him to ask smarter questions, you encourage the behaviour that hinders his ability to get help from others. The only other person I can see who has attempted to actually help the OP is Stefan Behnel, who tried to get more information about the problem being solved in order to better answer the question. The OP has, so far as I can see, not responded, although he has taken the time to write to me in private to argue further. -- Steven From albert at spenarnc.xs4all.nl Fri Jan 14 17:17:01 2011 From: albert at spenarnc.xs4all.nl (Albert van der Horst) Date: 14 Jan 2011 22:17:01 GMT Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> Message-ID: In article , Adam Skutt wrote: > >Replacing TkInter with some sort of minimized wxwidgets is a dumb idea >for some very obvious reasons, reasons that are obvious if you simply >look at a widget gallery and then the applications you run on your own >computer. Quite honestly, if you're not capable of that, there's >little reason to believe you'll ever be able to bring forth a >coherent, cogent proposal. I really don't follow that. You need a tremendous set to write gimp. Obviously you won't write gimp in Python. Now you want to jot together three cooperating screens to specify some properties for say bluetooth. The proposed set is ample for that, no? Such things make up a substantial part of the applications as far as numbers is concerned. They are probably written by people who don't want to dive very deeply into GUI. (Maybe they are more bluetooth experts than GUI-experts, what would you say?) > >Adam Groetjes Albert -- -- Albert van der Horst, UTRECHT,THE NETHERLANDS Economic growth -- being exponential -- ultimately falters. albert at spe&ar&c.xs4all.nl &=n http://home.hccnet.nl/a.w.m.van.der.horst From Zeissmann at gmail.com Fri Jan 14 17:22:57 2011 From: Zeissmann at gmail.com (Zeissmann) Date: Fri, 14 Jan 2011 22:22:57 +0000 (UTC) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <18c2f4d8-0cce-4cdf-a386-80831dc2f114@m37g2000vbn.googlegroups.com> Message-ID: > Seriously, get off of WoW and go write some code. If you'd spent the > last year programming instead of doing your best Xah Lee impression you > might have actually made some progress on this. I'm curious, is Xah Lee some sort of a Usenet meme? Cause this is not the first time I see his name in the context of a lightweight invective. From leoboiko at gmail.com Fri Jan 14 17:26:09 2011 From: leoboiko at gmail.com (leoboiko) Date: Fri, 14 Jan 2011 14:26:09 -0800 (PST) Subject: python 3 and Unicode line breaking References: <32f75200-b4d8-4ec8-b07d-4740a79c28b6@g26g2000vba.googlegroups.com> <4d2f959a$0$29984$c3e8da3$5496439d@news.astraweb.com> <55c2f7dc-d4d8-4939-85de-41c19c336f23@k25g2000vbl.googlegroups.com> <4d3074b0$0$29984$c3e8da3$5496439d@news.astraweb.com> <4d30c9ba$0$29984$c3e8da3$5496439d@news.astraweb.com> Message-ID: <9b84ec07-0679-4bc6-96ea-b37231d3fd83@b25g2000vbz.googlegroups.com> On Jan 14, 8:10?pm, Steven D'Aprano wrote: > The only other person I can see who has attempted to actually help the OP > is Stefan Behnel, who tried to get more information about the problem > being solved in order to better answer the question. The OP has, so far > as I can see, not responded, although he has taken the time to write to > me in private to argue further. I have written in private because I really feel this discussion is out- of-place here. This thread is already in the first page of google results for ?python unicode line breaking?, ?python uax #14? etc. I feel it would be good to use this place to discuss Unicode line breaking, not best practices on asking questions, or in how disappointly impolite the Internet has become. (Briefly: As a tech support professional myself, I prefer direct, concise questions than crufty ones; and I try to ask questions in the most direct manner precisely _because_ I don?t want to waste the time of kind volunteers with my problems.) As for taking the time to provide information, I wonder if there was any technical problem that prevented you from seeing my reply to Stefan, sent Jan 14, 12:29PM? He asked how exacly the stdlib module ?textwrap? differs from the Unicode algorithm, so I provided some commented examples. From howe.steven at gmail.com Fri Jan 14 17:32:59 2011 From: howe.steven at gmail.com (Steven Howe) Date: Fri, 14 Jan 2011 14:32:59 -0800 Subject: Is it possible to let a virtual file created by cStringIO have a filename so that functions can read it by its filename? In-Reply-To: References: Message-ID: <4D30CF1B.9030307@gmail.com> On 01/14/2011 12:51 PM, Chris Rebert wrote: > On Fri, Jan 14, 2011 at 7:52 AM, Cun Zhang wrote: >> Hi,all >> I hope use cStringIO to create virtual file, but my customed function which >> is from a shared library imported by ctypes >> just accepts a filename(string type) as parameter. >> >> So I'm wondering whether there is any method that make the virtual file >> created by cStringIO like a normal file which have >> a filename, so it can be called by my functions. > That's not possible. (c)StringIO presents a file-like interface at the > Python level, but under the covers, it's not implemented using > anything like a normal file; thus, it doesn't have a presence on any > filesystem. I would suggest using a temporary file > (http://docs.python.org/library/tempfile.html ) for communicating with > the C module, writing the contents of the StringIO object to the > temporary file if necessary. > (It's probably also possible to hack something together with FUSE, but > it'd be a slow, platform-specific kludge.) > > Cheers, > Chris > -- > http://blog.rebertia.com However, as the only reason to have the cstringIO object have a name is for you to open or close it. The rest of the functionality is the same, reading and writing too. ------------------ in a terminal ... import cStringIO ab = cStringIO.StringIO() # an output type, as it was call with nothing. cd = cStringIO.StringIO( 'a filled buffer') # an input type. type( ab ) == cStringIO.OutputType True type( cd ) == cStringIO.InputType True Working with these properties .... we get Let's assume you have class with read and write ability, which assumes opening a file or cStringIO object (could extend to StringIO object with out much changing ). class foo: def __init__( self ): """ Define some variables. House keeping. """ self.readState = False self.writeState = False self.readObj = None self.writeObj = None def fooOpenWrite( self, fileobj ): if type( fileobj ) === StringType: self.writeObj = open( fileobj, 'wb' ) elif type( fileobj ) == cStringIO.OutputType: self.writeObj = fileobj else: self.writeState = False return self.readState = True return True def fooOpenRead( self, fileobj ): if type( fileobj ) === StringType: self.readObj = open( fileobj, 'wb' ) elif type( fileobj ) == cStringIO.OutputType: self.readObj = fileobj else: self.readState = False return self.readState = True return def fooRead( self ): for x in self.readObj: print x def fooWrite( self, str ): self.readObj.write( str ) Steven From solipsis at pitrou.net Fri Jan 14 17:54:34 2011 From: solipsis at pitrou.net (Antoine Pitrou) Date: Fri, 14 Jan 2011 23:54:34 +0100 Subject: python 3 and Unicode line breaking References: <32f75200-b4d8-4ec8-b07d-4740a79c28b6@g26g2000vba.googlegroups.com> <4d2f959a$0$29984$c3e8da3$5496439d@news.astraweb.com> <55c2f7dc-d4d8-4939-85de-41c19c336f23@k25g2000vbl.googlegroups.com> <4d3074b0$0$29984$c3e8da3$5496439d@news.astraweb.com> <4d30c9ba$0$29984$c3e8da3$5496439d@news.astraweb.com> Message-ID: <20110114235434.1040bb5a@pitrou.net> On 14 Jan 2011 22:10:02 GMT Steven D'Aprano wrote: > > This is good, helpful advice, and far more useful to the OP than just > ignoring his post. You have jumped to his defense (or rather, you have > jumped to criticise me) but I see that you haven't replied to his > question or given him any advice in how to solve his problem. Simply because I have no elaborate answer to give, even in the light of his/her recent precisions on the topic (and, actually, neither do you). Asking for precisions is certainly fine; doing it in an agressive way is not, especially when the original message doesn't look like the usual blunt, impolite and typo-ridden "can you do my homework" message. Also, I would expect someone familiar with the textwrap module's (lack of) unicode capabilities would have been able to answer the first message without even asking for precisions. Regards Antoine. From solipsis at pitrou.net Fri Jan 14 18:23:55 2011 From: solipsis at pitrou.net (Antoine Pitrou) Date: Sat, 15 Jan 2011 00:23:55 +0100 Subject: python 3 and Unicode line breaking References: <32f75200-b4d8-4ec8-b07d-4740a79c28b6@g26g2000vba.googlegroups.com> <4d2f959a$0$29984$c3e8da3$5496439d@news.astraweb.com> Message-ID: <20110115002355.3b9a7b5d@pitrou.net> On Fri, 14 Jan 2011 06:29:27 -0800 (PST) leoboiko wrote: > > And it generally doesn?t try to pick good places to break lines > at all, just making the assumption that 1 character = 1 column > and that breaking on ASCII whitespaces/hyphens is enough. We > can?t really blame textwrap for that, it is a very simple module > and Unicode line breaking gets complex fast (that?s why the > consortium provides a ready-made algorithm). It?s just that, > with python3?s emphasis on Unicode support, I was surprised not > to be able to find an UAX #14 implementation. I thought someone > would surely have written one and I simply couldn?t find, so I > asked precisely that. If you're willing to help on that matter (or some aspects of them, textwrap-specific or not), you can open an issue on http://bugs.python.org and propose a patch. See also http://docs.python.org/devguide/#contributing if you need more info on how to contribute. Regards Antoine. From billy.earney at gmail.com Fri Jan 14 19:07:19 2011 From: billy.earney at gmail.com (Billy Earney) Date: Fri, 14 Jan 2011 18:07:19 -0600 Subject: Developing a program to make a family tree. In-Reply-To: <317f6ed0-ebd9-4a58-9ad3-da57563193ad@w29g2000vba.googlegroups.com> References: <317f6ed0-ebd9-4a58-9ad3-da57563193ad@w29g2000vba.googlegroups.com> Message-ID: try http://gramps-project.org/, which is created in python.. :) On Fri, Jan 14, 2011 at 1:39 PM, Ata Jafari wrote: > Hi there. > I'm trying to develop a program like family tree maker. I have all > information, so there is no need to search on the net. This must be > something like trees. Can someone help me? I'm at the beginning. > Thanks. > > -- > Ata J. Tabrizi > atae.tabrizi at metu.edu.tr > -- > http://mail.python.org/mailman/listinfo/python-list > -------------- next part -------------- An HTML attachment was scrubbed... URL: From kushal.kumaran at gmail.com Fri Jan 14 20:26:27 2011 From: kushal.kumaran at gmail.com (Kushal Kumaran) Date: Sat, 15 Jan 2011 06:56:27 +0530 Subject: Developing a program to make a family tree. In-Reply-To: <317f6ed0-ebd9-4a58-9ad3-da57563193ad@w29g2000vba.googlegroups.com> References: <317f6ed0-ebd9-4a58-9ad3-da57563193ad@w29g2000vba.googlegroups.com> Message-ID: <1295054787.6346.2.camel@Nokia-N900> ----- Original message ----- > Hi there. > I'm trying to develop a program like family tree maker. I have all > information, so there is no need to search on the net. This must be > something like trees. Can someone help me? I'm at the beginning. > Thanks. > Family trees are nothing like trees, actually. If you start with that assumption, your software will sadly not be usable by many people. -- regards, kushal From steve+comp.lang.python at pearwood.info Fri Jan 14 20:28:10 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 15 Jan 2011 01:28:10 GMT Subject: python 3 and Unicode line breaking References: <32f75200-b4d8-4ec8-b07d-4740a79c28b6@g26g2000vba.googlegroups.com> <4d2f959a$0$29984$c3e8da3$5496439d@news.astraweb.com> <55c2f7dc-d4d8-4939-85de-41c19c336f23@k25g2000vbl.googlegroups.com> <4d3074b0$0$29984$c3e8da3$5496439d@news.astraweb.com> <4d30c9ba$0$29984$c3e8da3$5496439d@news.astraweb.com> <9b84ec07-0679-4bc6-96ea-b37231d3fd83@b25g2000vbz.googlegroups.com> Message-ID: <4d30f82a$0$29984$c3e8da3$5496439d@news.astraweb.com> On Fri, 14 Jan 2011 14:26:09 -0800, leoboiko wrote: ... > As for taking the time to provide information, I wonder if there was any > technical problem that prevented you from seeing my reply to Stefan, > sent Jan 14, 12:29PM? Presumably, since I haven't got it in my news client. This is not the first time. > He asked how exacly the stdlib module ?textwrap? > differs from the Unicode algorithm, so I provided some commented > examples. Does this help? http://packages.python.org/kitchen/api-text-display.html kitchen.text.display.wrap(text, width=70, initial_indent=u'', subsequent_indent=u'', encoding='utf-8', errors='replace') Works like we want textwrap.wrap() to work [...] textwrap.wrap() from the python standard libray has two drawbacks that this attempts to fix: 1. It does not handle textual width. It only operates on bytes or characters which are both inadequate (due to multi-byte and double width characters). 2. It malforms lists and blocks. -- Steven From steve+comp.lang.python at pearwood.info Fri Jan 14 21:02:45 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 15 Jan 2011 02:02:45 GMT Subject: Elliptic Curve Prime factorisation References: <2040fe29-f11d-4e64-acac-d49ae8bb5ca9@u32g2000yqe.googlegroups.com> Message-ID: <4d310045$0$29984$c3e8da3$5496439d@news.astraweb.com> On Fri, 14 Jan 2011 11:52:21 -0800, mukesh tiwari wrote: > Hello all , I have implemented Elliptic curve prime factorisation using > wikipedia [ > http://en.wikipedia.org/wiki/Lenstra_elliptic_curve_factorization]. I > think that this code is not optimised and posting for further > improvement. Feel free to comment and if you have any link regarding > Elliptic curve prime factorisation , kindly post it. Thank you I don't think you can optimize it further in pure Python, although it is probably a good candidate for something like Cython, Pyrex or Shedskin. I think the code can be optimized for easier reading by putting single spaces around operators, following commas, etc. I find your style difficult to read. It could do with a docstring explaining what it does and how to use it, and some doctests. But other than that, it looks good. Have you considered putting it up on the ActiveState Python cookbook? -- Steven From usernet at ilthio.net Fri Jan 14 21:09:55 2011 From: usernet at ilthio.net (Tim Harig) Date: Sat, 15 Jan 2011 02:09:55 +0000 (UTC) Subject: Developing a program to make a family tree. References: <317f6ed0-ebd9-4a58-9ad3-da57563193ad@w29g2000vba.googlegroups.com> Message-ID: On 2011-01-14, Ata Jafari wrote: > I'm trying to develop a program like family tree maker. I have all > information, so there is no need to search on the net. This must be > something like trees. Can someone help me? I'm at the beginning. I don't know anything specific about family tree software and you don't really specify what you want your software to do. I can only assume that you are interested in taking the data in some format which contains the links between family members and creating a tree representation of that data? If I was going to attempt something like this, I would probably generate the representation as a set of postscript instructions. I would start with a basic template for a union which could be essentially pasted into different places in the output page. Then generating your tree is a simple matter of laying out the templates to match your data, filling in the template fields for each persion within their union, and drawing the connecting lines of the tree. Since I was already generating postscript anyway, I would probably implement much of the actual logic in postscript (the built in stacks provide an exellent way to process tree like structures in all of their nested levels). I would Python provide any user interface for manipulating the data and to dump the data into the postscript program. From drsalists at gmail.com Fri Jan 14 22:28:28 2011 From: drsalists at gmail.com (Dan Stromberg) Date: Fri, 14 Jan 2011 19:28:28 -0800 Subject: Elliptic Curve Prime factorisation In-Reply-To: <2040fe29-f11d-4e64-acac-d49ae8bb5ca9@u32g2000yqe.googlegroups.com> References: <2040fe29-f11d-4e64-acac-d49ae8bb5ca9@u32g2000yqe.googlegroups.com> Message-ID: On Fri, Jan 14, 2011 at 11:52 AM, mukesh tiwari wrote: > Hello all , I have implemented Elliptic curve prime factorisation > using wikipedia [ http://en.wikipedia.org/wiki/Lenstra_elliptic_curve_factorization]. > I think that this code is not optimised and posting for further > improvement. Feel free to comment and if you have any link regarding > Elliptic curve prime factorisation , kindly post it. > Thank you You can get a lot of good suggestions for your code quickly and easily by going over it with pylint. For performance, you could try the gmpy module - it's good at dealing with large numbers. For an example, you might examine http://stromberg.dnsalias.org/svn/huge-prime/trunk . BTW, huge-prime dates from just shortly before I started routinely going over my code with pylint. From mukeshtiwari.iiitm at gmail.com Fri Jan 14 23:34:49 2011 From: mukeshtiwari.iiitm at gmail.com (mukesh tiwari) Date: Fri, 14 Jan 2011 20:34:49 -0800 (PST) Subject: Elliptic Curve Prime factorisation References: <2040fe29-f11d-4e64-acac-d49ae8bb5ca9@u32g2000yqe.googlegroups.com> <4d310045$0$29984$c3e8da3$5496439d@news.astraweb.com> Message-ID: <1f251f3f-4446-4c29-bc41-b1a03ae372e2@s9g2000vby.googlegroups.com> On Jan 15, 7:02 am, Steven D'Aprano wrote: > On Fri, 14 Jan 2011 11:52:21 -0800, mukesh tiwari wrote: > > Hello all , I have implemented Elliptic curve prime factorisation using > > wikipedia [ > >http://en.wikipedia.org/wiki/Lenstra_elliptic_curve_factorization]. I > > think that this code is not optimised and posting for further > > improvement. Feel free to comment and if you have any link regarding > > Elliptic curve prime factorisation , kindly post it. Thank you > > I don't think you can optimize it further in pure Python, although it is > probably a good candidate for something like Cython, Pyrex or Shedskin. > > I think the code can be optimized for easier reading by putting single > spaces around operators, following commas, etc. I find your style > difficult to read. > > It could do with a docstring explaining what it does and how to use it, > and some doctests. But other than that, it looks good. Have you > considered putting it up on the ActiveState Python cookbook? > > -- > Steven Thank you for your suggestion. I posted it ActiveState with comments. #!/usr/local/bin/python # -*- coding: utf-8 -*- import math import random #y^2=x^3+ax+b mod n # ax+by=gcd(a,b). This function returns [gcd(a,b),x,y]. Source Wikipedia def extended_gcd(a,b): x,y,lastx,lasty=0,1,1,0 while b!=0: q=a/b a,b=b,a%b x,lastx=(lastx-q*x,x) y,lasty=(lasty-q*y,y) if a<0: return (-a,-lastx,-lasty) else: return (a,lastx,lasty) def gcd(a,b): if a < 0: a = -a if b < 0: b = -b if a == 0: return b if b == 0: return a while b != 0: (a, b) = (b, a%b) return a # pick first a point P=(u,v) with random non-zero coordinates u,v (mod N), then pick a random non-zero A (mod N), # then take B = u^2 - v^3 - Ax (mod N). # http://en.wikipedia.org/wiki/Lenstra_elliptic_curve_factorization def randomCurve(N): A,u,v=random.randrange(N),random.randrange(N),random.randrange(N) B=(v*v-u*u*u-A*u)%N return [(A,B,N),(u,v)] # Given the curve y^2 = x^3 + ax + b over the field K (whose characteristic we assume to be neither 2 nor 3), and points # P = (xP, yP) and Q = (xQ, yQ) on the curve, assume first that xP != xQ. Let the slope of the line s = (yP - yQ)/(xP - xQ); since K # is a field, s is well-defined. Then we can define R = P + Q = (xR, - yR) by # s=(xP-xQ)/(yP-yQ) Mod N # xR=s^2-xP-xQ Mod N # yR=yP+s(xR-xP) Mod N # If xP = xQ, then there are two options: if yP = -yQ, including the case where yP = yQ = 0, then the sum is defined as 0[Identity]. # thus, the inverse of each point on the curve is found by reflecting it across the x-axis. If yP = yQ != 0, then R = P + P = 2P = # (xR, -yR) is given by # s=3xP^2+a/(2yP) Mod N # xR=s^2-2xP Mod N # yR=yP+s(xR-xP) Mod N # http://en.wikipedia.org/wiki/Elliptic_curve#The_group_law''') def addPoint(E,p_1,p_2): if p_1=="Identity": return [p_2,1] if p_2=="Identity": return [p_1,1] a,b,n=E (x_1,y_1)=p_1 (x_2,y_2)=p_2 x_1%=n y_1%=n x_2%=n y_2%=n if x_1 != x_2 : d,u,v=extended_gcd(x_1-x_2,n) s=((y_1-y_2)*u)%n x_3=(s*s-x_1-x_2)%n y_3=(-y_1-s*(x_3-x_1))%n else: if (y_1+y_2)%n==0:return ["Identity",1] else: d,u,v=extended_gcd(2*y_1,n) s=((3*x_1*x_1+a)*u)%n x_3=(s*s-2*x_1)%n y_3=(-y_1-s*(x_3-x_1))%n return [(x_3,y_3),d] # http://en.wikipedia.org/wiki/Elliptic_curve_point_multiplication # Q=0 [Identity element] # while m: # if (m is odd) Q+=P # P+=P # m/=2 # return Q') def mulPoint(E,P,m): Ret="Identity" d=1 while m!=0: if m%2!=0: Ret,d=addPoint(E,Ret,P) if d!=1 : return [Ret,d] # as soon as i got anything otherthan 1 return P,d=addPoint(E,P,P) if d!=1 : return [Ret,d] m>>=1 return [Ret,d] def ellipticFactor(N,m,times=5): for i in xrange(times): E,P=randomCurve(N); Q,d=mulPoint(E,P,m) if d!=1 : return d return N if __name__=="__main__": n=input() m=int(math.factorial(1000)) while n!=1: k=ellipticFactor(n,m) n/=k print k From apzc2529 at gmail.com Sat Jan 15 00:42:39 2011 From: apzc2529 at gmail.com (Cun Zhang) Date: Sat, 15 Jan 2011 13:42:39 +0800 Subject: Is it possible to let a virtual file created by cStringIO have a filename so that functions can read it by its filename? In-Reply-To: References: Message-ID: hi Chris, Thank you for your advice. I will use tmpfs as a temperory file system to detail with it. Cheers, Cun Zhang On Sat, Jan 15, 2011 at 4:51 AM, Chris Rebert wrote: > On Fri, Jan 14, 2011 at 7:52 AM, Cun Zhang wrote: > > Hi,all > > I hope use cStringIO to create virtual file, but my customed function > which > > is from a shared library imported by ctypes > > just accepts a filename(string type) as parameter. > > > > So I'm wondering whether there is any method that make the virtual file > > created by cStringIO like a normal file which have > > a filename, so it can be called by my functions. > > That's not possible. (c)StringIO presents a file-like interface at the > Python level, but under the covers, it's not implemented using > anything like a normal file; thus, it doesn't have a presence on any > filesystem. I would suggest using a temporary file > (http://docs.python.org/library/tempfile.html ) for communicating with > the C module, writing the contents of the StringIO object to the > temporary file if necessary. > (It's probably also possible to hack something together with FUSE, but > it'd be a slow, platform-specific kludge.) > > Cheers, > Chris > -- > http://blog.rebertia.com > -- ======================================== Cun Zhang Ph.D. Candidate LNM,Institute of Mechanics Chinese Academy of Sciences Beijing, 100190, China Tel:86-10-82544204 http://www.edwardpku.com/cun ======================================== -------------- next part -------------- An HTML attachment was scrubbed... URL: From rantingrick at gmail.com Sat Jan 15 00:57:51 2011 From: rantingrick at gmail.com (rantingrick) Date: Fri, 14 Jan 2011 21:57:51 -0800 (PST) Subject: Python use growing fast References: <4d2b8844$0$43996$742ec2ed@news.sonic.net> Message-ID: <66961d22-be39-4dc1-a7bf-3bf406808137@z19g2000yqb.googlegroups.com> On Jan 10, 9:24?pm, Dan Stromberg wrote: > About JavaScript's popularity: > 1) I've been getting the impression that JavaScript is popular in a > manner similar to how x86 machine language is popular: That is, it's > used all over, but few people hand code it (though admittedly, there > are probably more people hand coding JavaScript than people hand > coding x86 assembler today) Exactly, another half baked language that has been shoved down our throats like artery clogging Big Macs and French Fries! Oh how many times i have lamented for Python's eloquent syntax whilst brain farting Javascript idiosyncrasies! >:( From justin.mailinglists at gmail.com Sat Jan 15 05:27:20 2011 From: justin.mailinglists at gmail.com (Justin Ezequiel) Date: Sat, 15 Jan 2011 02:27:20 -0800 (PST) Subject: FTP problem References: Message-ID: 'indexftp.barcap.com' only (sans the 'ftp.' prefix) allows me to connect to an FTP server >ftp indexftp.barcap.com Connected to usftp.barcap.com. 220-Connected to usftp.barcap.com. 220 FTP server ready. User (usftp.barcap.com:(none)): From udodenko at users.sourceforge.net Sat Jan 15 09:45:13 2011 From: udodenko at users.sourceforge.net (Captain Obvious) Date: Sat, 15 Jan 2011 16:45:13 +0200 Subject: do you know what's CGI? (web history personal story) References: Message-ID: <4d31b300$0$23758$14726298@news.sunsite.dk> XL> ... i recall, i stopped doing Mathematica in 1998 because it's a XL> career dead-end as a programing lang, and dived into the utterly XL> idiotic Perl & unix & mysql world. (See: The Unix Pestilence ? Xah XL> Lee's Computing Experience (Impression Of Lisp from Mathematica).) I guess you're calling "idiotic" everything you're too lazy to understand. XL> today were under 10 in the 1990s. They wouldn't know what was CGI, and XL> no amount of explanation can tell them exactly it was like, because it XL> has become HISTORY ? if you didn't live it, you can't feel it. CGI is still used in some places today, hello? If spawning a process for each request is what you want to do, it is a way to go. inetd is quite similar to CGI and, guess what, it is still used. From mwilson at the-wire.com Sat Jan 15 09:55:00 2011 From: mwilson at the-wire.com (Mel) Date: Sat, 15 Jan 2011 09:55 -0500 Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <18c2f4d8-0cce-4cdf-a386-80831dc2f114@m37g2000vbn.googlegroups.com> Message-ID: Zeissmann wrote: >> Seriously, get off of WoW and go write some code. If you'd spent the >> last year programming instead of doing your best Xah Lee impression you >> might have actually made some progress on this. > > I'm curious, is Xah Lee some sort of a Usenet meme? Cause this is not the > first time I see his name in the context of a lightweight invective. AFAIK he's just a guy who thinks Usenet is his blog, and kicks off big rambling threads, cross-posted to infinity that mathematically have probability 0.0 of being on topic in any of the groups they're in. Mel. From stefan.sonnenberg at pythonmeister.com Sat Jan 15 10:06:58 2011 From: stefan.sonnenberg at pythonmeister.com (Stefan Sonnenberg-Carstens) Date: Sat, 15 Jan 2011 16:06:58 +0100 Subject: BackupRead problem Message-ID: <4D31B812.2040105@pythonmeister.com> I'm trying to create a Backup/Restore app. I'm really struggeling for a long time. I can successfully read directories, but not files. Every time, I'll try I get "Access denied", Error 5. It's running with admin privs. Any ideas ? #!python import sys import os import os.path import getopt import time DELETE=0x00010000 READ_CONTROL=0x00020000 WRITE_DAC=0x00040000 WRITE_OWNER=0x00080000 SYNCHRONIZE=0x00100000 STANDARD_RIGHTS_REQUIRED=0x000F0000L STANDARD_RIGHTS_READ=READ_CONTROL STANDARD_RIGHTS_WRITE=READ_CONTROL STANDARD_RIGHTS_EXECUTE=READ_CONTROL STANDARD_RIGHTS_ALL=0x001F0000 SPECIFIC_RIGHTS_ALL=0x0000FFFF FILE_ATTRIBUTE_REPARSE_POINT=0x400 from ctypes import * if os.name == 'nt': import win32security import win32process import win32file try: import win32api except ImportError,e: print >>sys.stderr,'Could not load win32api module. Can not continue' os._exit(1) try: import wmi except ImportError,e: print >>sys.stderr,'Could not load wmi module. Can not continue' os._exit(1) try: import ctypes except ImportError,e: print >>sys.stderr,'Could not load ctypes module. Can not continue' os._exit(1) else: print >>sys.stderr,'Sorry, your platform %s is not supported' % os.name os._exit(1) if len(sys.argv) >= 1: try: opts,args = getopt.getopt(sys.argv[1:],'h',('help',)) except getopt.GetoptError,e: print str(e) if not ctypes.windll.shell32.IsUserAnAdmin(): win32api.ShellExecute(None,'runas',sys.executable,' '.join(sys.argv),r'C:\WINDOWS',0) else: print >>sys.stderr,'Running with administrative privileges' token = win32security.OpenProcessToken(win32process.GetCurrentProcess(),win32security.TOKEN_ADJUST_PRIVILEGES|win32security.TOKEN_QUERY) if token: for priv in (win32security.SE_BACKUP_NAME,win32security.SE_RESTORE_NAME): luid = win32security.LookupPrivilegeValue(None,priv) newState = [(luid,win32security.SE_PRIVILEGE_ENABLED)] try: win32security.AdjustTokenPrivileges(token,0,newState) except: print >>sys.stderr,'Could not get (some) required priviledge(s): ',win32api.FormatMessage(win32api.GetLastError()) os._exit(1) win32api.CloseHandle(token) else: print >>sys.stderr,'Could not get token for running process' os._exit(1) print >>sys.stderr,'Acquired backup/restore context (SeRestorePrivilege and SeBackupPrivilege enabled)' inf = win32file.CreateFile(r'C:\Windows\System32\drivers\etc\hosts',READ_CONTROL,0,None,win32file.OPEN_EXISTING,win32file.FILE_FLAG_BACKUP_SEMANTICS,None) buf = win32file.AllocateReadBuffer(4096) ctx = 0 (bytes_read,buf,ctx) = win32file.BackupRead(inf,4096,buf,False,True,ctx) From invalid at invalid.invalid Sat Jan 15 10:26:54 2011 From: invalid at invalid.invalid (Grant Edwards) Date: Sat, 15 Jan 2011 15:26:54 +0000 (UTC) Subject: Developing a program to make a family tree. References: <317f6ed0-ebd9-4a58-9ad3-da57563193ad@w29g2000vba.googlegroups.com> Message-ID: On 2011-01-14, Ata Jafari wrote: > I'm trying to develop a program like family tree maker. I have all > information, so there is no need to search on the net. This must be > something like trees. Not really. It's more like a combination of a directed graph and a relational database. > Can someone help me? I'm at the beginning. You do know there is already a "family-tree-maker" program written in Python, right? http://gramps-project.org/ Your time might be better spent working on Gramps... -- Grant From sherm.pendley at gmail.com Sat Jan 15 11:15:25 2011 From: sherm.pendley at gmail.com (Sherm Pendley) Date: Sat, 15 Jan 2011 11:15:25 -0500 Subject: do you know what's CGI? (web history personal story) References: <4d31b300$0$23758$14726298@news.sunsite.dk> Message-ID: "Captain Obvious" writes: > XL> ... i recall, i stopped doing Mathematica in 1998 because it's a > XL> career dead-end as a programing lang, and dived into the utterly > XL> idiotic Perl & unix & mysql world. (See: The Unix Pestilence ? Xah > XL> Lee's Computing Experience (Impression Of Lisp from Mathematica).) > > I guess you're calling "idiotic" everything you're too lazy to understand. That's Xah for you. > XL> today were under 10 in the 1990s. They wouldn't know what was CGI, and > XL> no amount of explanation can tell them exactly it was like, because it > XL> has become HISTORY ? if you didn't live it, you can't feel it. > > CGI is still used in some places today, hello? Yeah, James Cameron made a *ton* of money using it to make Avatar. What? Why is everyone looking at me that way? ;-) sherm-- -- Sherm Pendley Cocoa Developer From invalid at invalid.invalid Sat Jan 15 11:38:49 2011 From: invalid at invalid.invalid (Grant Edwards) Date: Sat, 15 Jan 2011 16:38:49 +0000 (UTC) Subject: do you know what's CGI? (web history personal story) References: <4d31b300$0$23758$14726298@news.sunsite.dk> Message-ID: On 2011-01-15, Sherm Pendley wrote: > "Captain Obvious" writes: > >> XL> ... i recall, i stopped doing Mathematica in 1998 because it's a >> XL> career dead-end as a programing lang, and dived into the utterly >> XL> idiotic Perl & unix & mysql world. (See: The Unix Pestilence ??? Xah >> XL> Lee's Computing Experience (Impression Of Lisp from Mathematica).) >> >> I guess you're calling "idiotic" everything you're too lazy to understand. > > That's Xah for you. > >> XL> today were under 10 in the 1990s. They wouldn't know what was CGI, and >> XL> no amount of explanation can tell them exactly it was like, because it >> XL> has become HISTORY ??? if you didn't live it, you can't feel it. >> >> CGI is still used in some places today, hello? > > Yeah, James Cameron made a *ton* of money using it to make Avatar. Too bad he couldn't have used it to make a better movie. Did we really need "Furngully" avec 3D sans funny? -- Grant From martin at v.loewis.de Sat Jan 15 11:41:43 2011 From: martin at v.loewis.de (Martin v. Loewis) Date: Sat, 15 Jan 2011 17:41:43 +0100 Subject: do you know what's CGI? (web history personal story) In-Reply-To: References: <4d31b300$0$23758$14726298@news.sunsite.dk> Message-ID: <4D31CE47.4050501@v.loewis.de> >> CGI is still used in some places today, hello? > > Yeah, James Cameron made a *ton* of money using it to make Avatar. He used compacted graphite iron in Avatar? I didn't know that. Regards, Martin From invalid at invalid.invalid Sat Jan 15 11:44:43 2011 From: invalid at invalid.invalid (Grant Edwards) Date: Sat, 15 Jan 2011 16:44:43 +0000 (UTC) Subject: do you know what's CGI? (web history personal story) References: <4d31b300$0$23758$14726298@news.sunsite.dk> <4D31CE47.4050501@v.loewis.de> Message-ID: On 2011-01-15, Martin v. Loewis wrote: >>> CGI is still used in some places today, hello? >> >> Yeah, James Cameron made a *ton* of money using it to make Avatar. > > He used compacted graphite iron in Avatar? I didn't know that. Is that what "unobtanium" is? Did anybody else thing Unobtainium was a blatant ripoff of Upsidasium from Rocky and Bullwinkle? http://en.wikipedia.org/wiki/Upsidaisium -- Grant From rantingrick at gmail.com Sat Jan 15 11:55:47 2011 From: rantingrick at gmail.com (rantingrick) Date: Sat, 15 Jan 2011 08:55:47 -0800 (PST) Subject: do you know what's CGI? (web history personal story) References: <4d31b300$0$23758$14726298@news.sunsite.dk> Message-ID: <9b74ebf2-f9d4-48b1-b614-94ad4abd1f46@k3g2000yqc.googlegroups.com> On Jan 15, 10:38?am, Grant Edwards wrote: > > Yeah, James Cameron made a *ton* of money using it to make Avatar. > > Too bad he couldn't have used it to make a better movie. I don't LOL very often but i must say that i was ROTF after this comment. Avatar was very disappointing (Both in graphics and story) but maybe i expect too much...? I found the look and feel of Beowulf to be more lifelike. Actually if you appreciate great rendering then you may want to check out "Despicable Me". The story was utterly atrocious (although slightly interesting at moments) but the render quality rivaled the best Dreamworks i have ever seem! From stefan.sonnenberg at pythonmeister.com Sat Jan 15 11:58:16 2011 From: stefan.sonnenberg at pythonmeister.com (Stefan Sonnenberg-Carstens) Date: Sat, 15 Jan 2011 17:58:16 +0100 Subject: BackupRead problem In-Reply-To: <4D31B812.2040105@pythonmeister.com> References: <4D31B812.2040105@pythonmeister.com> Message-ID: <4D31D228.7020101@pythonmeister.com> Am 15.01.2011 16:06, schrieb Stefan Sonnenberg-Carstens: > I'm trying to create a Backup/Restore app. > I'm really struggeling for a long time. > > I can successfully read directories, but not files. > Every time, I'll try I get "Access denied", Error 5. > > It's running with admin privs. > > Any ideas ? > > #!python > import sys > import os > import os.path > import getopt > import time > > > DELETE=0x00010000 > READ_CONTROL=0x00020000 > WRITE_DAC=0x00040000 > WRITE_OWNER=0x00080000 > SYNCHRONIZE=0x00100000 > STANDARD_RIGHTS_REQUIRED=0x000F0000L > STANDARD_RIGHTS_READ=READ_CONTROL > STANDARD_RIGHTS_WRITE=READ_CONTROL > STANDARD_RIGHTS_EXECUTE=READ_CONTROL > STANDARD_RIGHTS_ALL=0x001F0000 > SPECIFIC_RIGHTS_ALL=0x0000FFFF > > FILE_ATTRIBUTE_REPARSE_POINT=0x400 > > from ctypes import * > > if os.name == 'nt': > > import win32security > import win32process > import win32file > > try: > import win32api > except ImportError,e: > print >>sys.stderr,'Could not load win32api module. Can not > continue' > os._exit(1) > try: > import wmi > except ImportError,e: > print >>sys.stderr,'Could not load wmi module. Can not continue' > os._exit(1) > try: > import ctypes > except ImportError,e: > print >>sys.stderr,'Could not load ctypes module. Can not > continue' > os._exit(1) > else: > print >>sys.stderr,'Sorry, your platform %s is not supported' % > os.name > os._exit(1) > > if len(sys.argv) >= 1: > try: > opts,args = getopt.getopt(sys.argv[1:],'h',('help',)) > except getopt.GetoptError,e: > print str(e) > if not ctypes.windll.shell32.IsUserAnAdmin(): > win32api.ShellExecute(None,'runas',sys.executable,' > '.join(sys.argv),r'C:\WINDOWS',0) > else: > print >>sys.stderr,'Running with administrative privileges' > token = > win32security.OpenProcessToken(win32process.GetCurrentProcess(),win32security.TOKEN_ADJUST_PRIVILEGES|win32security.TOKEN_QUERY) > if token: > for priv in > (win32security.SE_BACKUP_NAME,win32security.SE_RESTORE_NAME): > luid = win32security.LookupPrivilegeValue(None,priv) > newState = [(luid,win32security.SE_PRIVILEGE_ENABLED)] > try: > win32security.AdjustTokenPrivileges(token,0,newState) > except: > print >>sys.stderr,'Could not get (some) required > priviledge(s): ',win32api.FormatMessage(win32api.GetLastError()) > os._exit(1) > win32api.CloseHandle(token) > else: > print >>sys.stderr,'Could not get token for running process' > os._exit(1) > print >>sys.stderr,'Acquired backup/restore context > (SeRestorePrivilege and SeBackupPrivilege enabled)' > inf = > win32file.CreateFile(r'C:\Windows\System32\drivers\etc\hosts',READ_CONTROL,0,None,win32file.OPEN_EXISTING,win32file.FILE_FLAG_BACKUP_SEMANTICS,None) > buf = win32file.AllocateReadBuffer(4096) > ctx = 0 > (bytes_read,buf,ctx) = > win32file.BackupRead(inf,4096,buf,False,True,ctx) MS's documenation sucks. Just found some code on the web regarding root-kits, but after changing win32file.CreateFile(r'C:\Windows\System32\drivers\etc\hosts',READ_CONTROL,0,None,win32file.OPEN_EXISTING,win32file.FILE_FLAG_BACKUP_SEMANTICS,None) to win32file.CreateFile(r'C:\Windows\System32\drivers\etc\hosts',win32file.GENERIC_READ,0,None,win32file.OPEN_EXISTING,win32file.FILE_FLAG_BACKUP_SEMANTICS,None) it works. From antonio.cardenes at gmail.com Sat Jan 15 12:47:19 2011 From: antonio.cardenes at gmail.com (Antonio Cardenes) Date: Sat, 15 Jan 2011 17:47:19 +0000 Subject: Fitness data program Message-ID: Hello folks, I'm trying to improve my Phyton skills with a project: A fitness program that can correlate measurements (weight and size of various body parts), date taken and it has to be able to print a nice graph showing improvements (a la Wii Fit) I was wondering if you could point me in the right path (modules and such), thanks. Antonio Cardenes -------------- next part -------------- An HTML attachment was scrubbed... URL: From emile at fenx.com Sat Jan 15 13:02:46 2011 From: emile at fenx.com (Emile van Sebille) Date: Sat, 15 Jan 2011 10:02:46 -0800 Subject: do you know what's CGI? (web history personal story) In-Reply-To: References: <4d31b300$0$23758$14726298@news.sunsite.dk> <4D31CE47.4050501@v.loewis.de> Message-ID: On 1/15/2011 8:44 AM Grant Edwards said... > On 2011-01-15, Martin v. Loewis wrote: >>>> CGI is still used in some places today, hello? >>> >>> Yeah, James Cameron made a *ton* of money using it to make Avatar. >> >> He used compacted graphite iron in Avatar? I didn't know that. > > Is that what "unobtanium" is? > > Did anybody else thing Unobtainium was a blatant ripoff of Upsidasium > from Rocky and Bullwinkle? http://en.wikipedia.org/wiki/Upsidaisium > No -- I figured he took it directly form the name of the material used to make the MotoGP bikes... Emile From nagle at animats.com Sat Jan 15 13:38:16 2011 From: nagle at animats.com (John Nagle) Date: Sat, 15 Jan 2011 10:38:16 -0800 Subject: do you know what's CGI? (web history personal story) In-Reply-To: References: Message-ID: <4d31e9a9$0$44039$742ec2ed@news.sonic.net> On 1/14/2011 1:20 PM, Xah Lee wrote: > some extempore thought. Who let the dogs in? John Nagle From alan at baselinedata.co.uk Sat Jan 15 14:39:25 2011 From: alan at baselinedata.co.uk (Alan Harris-Reid) Date: Sat, 15 Jan 2011 19:39:25 +0000 Subject: Career path - where next? In-Reply-To: References: <4D2DD8BC.1020907@googlemail.com> Message-ID: <4D31F7ED.4040307@baselinedata.co.uk> To all those who answered my original post so far (Jon Clements, Terry Jan Reedy, Philip Semanchuk) - many thanks. Your suggestions have given me a number of avenues to follow. I'll let you know how I get on. Regards, Alan From katie at coderstack.co.uk Sat Jan 15 14:45:49 2011 From: katie at coderstack.co.uk (Katie T) Date: Sat, 15 Jan 2011 19:45:49 +0000 Subject: Developing a program to make a family tree. In-Reply-To: References: <317f6ed0-ebd9-4a58-9ad3-da57563193ad@w29g2000vba.googlegroups.com> Message-ID: On Fri, Jan 14, 2011 at 7:57 PM, Jon Clements wrote: > Otherwise, you're in for a struggle, as you need to choose a storage > back-end, a GUI (wxWindows/GTK/Qt4 etc...), how to handle GEDCOM > format (unless it's not going to be compatible with other software), > does it need to produce web pages/reports (and in what formats). There are a couple of Python gedcom parsers around: http://ilab.cs.byu.edu/cs460/code/gedcom/gedcom.py https://github.com/dijxtra/simplepyged Katie -- CoderStack http://www.coderstack.co.uk/python-jobs The Software Developer Job Board From katie at coderstack.co.uk Sat Jan 15 14:48:40 2011 From: katie at coderstack.co.uk (Katie T) Date: Sat, 15 Jan 2011 19:48:40 +0000 Subject: Fitness data program In-Reply-To: References: Message-ID: On Sat, Jan 15, 2011 at 5:47 PM, Antonio Cardenes wrote: > Hello folks, I'm trying to improve my Phyton skills with a project: A > fitness program that can correlate measurements (weight and size of various > body parts), date taken and it has to be able to print a nice graph showing > improvements (a la Wii Fit) Scipy + Matplotlib should give you the tools to do correlation stats and graphing. Katie -- CoderStack http://www.coderstack.co.uk/python-jobs The Software Developer Job Board From howe.steven at gmail.com Sat Jan 15 16:13:25 2011 From: howe.steven at gmail.com (GrayShark) Date: Sat, 15 Jan 2011 15:13:25 -0600 Subject: Fitness data program References: Message-ID: On Sat, 15 Jan 2011 19:48:40 +0000, Katie T wrote: > On Sat, Jan 15, 2011 at 5:47 PM, Antonio Cardenes > wrote: >> Hello folks, I'm trying to improve my Phyton skills with a project: A >> fitness program that can correlate measurements (weight and size of >> various body parts), date taken and it has to be able to print a nice >> graph showing improvements (a la Wii Fit) > > Scipy + Matplotlib should give you the tools to do correlation stats and > graphing. > > Katie Likely you'll want a database, for usernames, dates, weights. Since it's so simple, using sqlite (which doesn't have a running database engine) is a wise choice. There's a python module to help interface. Also you might visit the django website. This sort of project could use a web frontend, since your likely want users to have access to their plots, so logins are required; Remote access (via web) sounds reasonable too. During those early days of shaping up, well, no one else need see my progress. Remember the old adage KISS (Keep It Simple, Stupid) steven From tahoemph at gmail.com Sat Jan 15 16:43:18 2011 From: tahoemph at gmail.com (Michael Hunter) Date: Sat, 15 Jan 2011 13:43:18 -0800 Subject: Developing a program to make a family tree. In-Reply-To: <317f6ed0-ebd9-4a58-9ad3-da57563193ad@w29g2000vba.googlegroups.com> References: <317f6ed0-ebd9-4a58-9ad3-da57563193ad@w29g2000vba.googlegroups.com> Message-ID: On Fri, Jan 14, 2011 at 11:39 AM, Ata Jafari wrote: > Hi there. > I'm trying to develop a program like family tree maker. I have all > information, so there is no need to search on the net. This must be > something like trees. Can someone help me? I'm at the beginning. > Thanks. I think you are probably coming at this from the wrong direction. Either you want to solve your family tree problem in the easiest way possible in which case there are already packages available or you want to develop this because you want to do the project to learn (more) python, etc. Assuming the later the fact you have to ask the question in the way you did means you are short on software design experience and don't know much about the problem domain (genealogy). Additionally you probably havn't written much code although you came here so you probably have a little experience. That is triple death. You need to hold a couple of those variables stable. I'd suggest finding a existing open source genealogy program and use bug fixing as a way to learn basics about the package and then try to add a feature as a way of learning something about software design. Michael From a.j.romanista at gmail.com Sat Jan 15 17:01:30 2011 From: a.j.romanista at gmail.com (Ata Jafari) Date: Sat, 15 Jan 2011 14:01:30 -0800 (PST) Subject: Developing a program to make a family tree. References: <317f6ed0-ebd9-4a58-9ad3-da57563193ad@w29g2000vba.googlegroups.com> Message-ID: People here guided me to GRAMPS, an open-source software project. Yes, I'm new, and Python is my first programming language. My software should not be only a "tree-like" one. There are 254 people in this family tree. I'm trying to find another method. But I think it is better to start with contributing to GRAMPS first. Thanks. Ata From alice at gothcandy.com Sat Jan 15 17:19:47 2011 From: alice at gothcandy.com (=?utf-8?Q?Alice_Bevan=E2=80=93McGregor?=) Date: Sat, 15 Jan 2011 14:19:47 -0800 Subject: do you know what's CGI? (web history personal story) References: <4d31b300$0$23758$14726298@news.sunsite.dk> Message-ID: On 2011-01-15 08:15:25 -0800, Sherm Pendley said: > "Captain Obvious" writes: > >> XL> ... i recall, i stopped doing Mathematica in 1998 because it's a >> XL> career dead-end as a programing lang, and dived into the utterly >> XL> idiotic Perl & unix & mysql world. (See: The Unix Pestilence ? Xah >> XL> Lee's Computing Experience (Impression Of Lisp from Mathematica).) >> >> I guess you're calling "idiotic" everything you're too lazy to understand. > > That's Xah for you. It's a bad sign when people use your name as a running joke in multiple mailing lists (outside the ones regularly posted in, specificaly I noticed this in one of the web framework lists) to mean "silly/stupid comments with no basis in reality". ? Alice. From alice at gothcandy.com Sat Jan 15 17:22:41 2011 From: alice at gothcandy.com (=?utf-8?Q?Alice_Bevan=E2=80=93McGregor?=) Date: Sat, 15 Jan 2011 14:22:41 -0800 Subject: do you know what's CGI? (web history personal story) References: <4d31b300$0$23758$14726298@news.sunsite.dk> <9b74ebf2-f9d4-48b1-b614-94ad4abd1f46@k3g2000yqc.googlegroups.com> Message-ID: On 2011-01-15 08:55:47 -0800, rantingrick said: > On Jan 15, 10:38?am, Grant Edwards wrote: > >>> Yeah, James Cameron made a *ton* of money using it to make Avatar. >> >> Too bad he couldn't have used it to make a better movie. I found the graphics impressive; the "blue people" was merely an effort to avoid a more clear representation of the Na'vi as North American indigenous people. > Avatar was very disappointing (Both in graphics and story) but maybe i > expect too much...? The story was clearly "Pocahontas? in Space!", which was very disappointing. > I found the look and feel of Beowulf to be more lifelike. That's just the naked Angelina Jolie in your brain talking. ;) ? Alice. From rantingrick at gmail.com Sat Jan 15 19:00:37 2011 From: rantingrick at gmail.com (rantingrick) Date: Sat, 15 Jan 2011 16:00:37 -0800 (PST) Subject: do you know what's CGI? (web history personal story) References: <4d31b300$0$23758$14726298@news.sunsite.dk> <9b74ebf2-f9d4-48b1-b614-94ad4abd1f46@k3g2000yqc.googlegroups.com> Message-ID: <43af9f08-e20d-4897-b9e4-65babe8679db@u32g2000yqe.googlegroups.com> On Jan 15, 4:22?pm, Alice Bevan?McGregor wrote: > That's just the naked Angelina Jolie in your brain talking. ?;) must...keep...hands...on...keyboard :-O . . . . . . . . OPPS! ;-) From jeanfrancois.leberre at gmail.com Sat Jan 15 20:48:28 2011 From: jeanfrancois.leberre at gmail.com (Jean-Francois) Date: Sat, 15 Jan 2011 17:48:28 -0800 (PST) Subject: Regex url Message-ID: Hi, I try to match the following url with one regex /hello /hello/ /hello/world /hello/world/ world is a variable, I can put toto instead Thanks ! From python at mrabarnett.plus.com Sat Jan 15 21:26:28 2011 From: python at mrabarnett.plus.com (MRAB) Date: Sun, 16 Jan 2011 02:26:28 +0000 Subject: Regex url In-Reply-To: References: Message-ID: <4D325754.4050602@mrabarnett.plus.com> On 16/01/2011 01:48, Jean-Francois wrote: > Hi, > > I try to match the following url with one regex > > /hello > /hello/ > /hello/world > /hello/world/ > > > world is a variable, I can put toto instead > The regex is: ^/hello(?:/(?:[a-z]+/?)?)$ Its meaning is: start of string characters "/hello" optional: character "/" optional: one or more: one of: "a" .. "z" optional: character "/" end of string If it's not what you want, you need to be more specific. From kb1pkl at aim.com Sat Jan 15 21:27:17 2011 From: kb1pkl at aim.com (Corey Richardson) Date: Sat, 15 Jan 2011 21:27:17 -0500 Subject: Regex url In-Reply-To: References: Message-ID: <4D325785.1020908@aim.com> On 01/15/2011 08:48 PM, Jean-Francois wrote: > Hi, > > I try to match the following url with one regex > > /hello > /hello/ > /hello/world > /hello/world/ > > > world is a variable, I can put toto instead > > Thanks ! What was the regex you tried, and where did it fail? I'm no re guru, but here's my go at it: "(/hello/?(%s)?/?)" % var Interpreter session: Python 2.6.6 (r266:84292, Sep 15 2010, 16:22:56) [GCC 4.4.5] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import re >>> var = "toto" >>> pat = re.compile("(/hello/?(%s)?/?)" % var) >>> pat.match("/hello/toto") <_sre.SRE_Match object at 0x7f53baf25938> >>> pat.match("/hello") <_sre.SRE_Match object at 0x7f53baf25c68> >>> pat.match("/hello/") <_sre.SRE_Match object at 0x7f53baf25938> >>> pat.match("/hello/toto/") <_sre.SRE_Match object at 0x7f53baf25c68> From andrei.avk at gmail.com Sat Jan 15 21:28:35 2011 From: andrei.avk at gmail.com (Rainy) Date: Sat, 15 Jan 2011 18:28:35 -0800 (PST) Subject: do you know what's CGI? (web history personal story) References: <4d31b300$0$23758$14726298@news.sunsite.dk> <9b74ebf2-f9d4-48b1-b614-94ad4abd1f46@k3g2000yqc.googlegroups.com> Message-ID: On Jan 15, 5:22?pm, Alice Bevan?McGregor wrote: > On 2011-01-15 08:55:47 -0800, rantingrick said: > > > On Jan 15, 10:38?am, Grant Edwards wrote: > > >>> Yeah, James Cameron made a *ton* of money using it to make Avatar. > > >> Too bad he couldn't have used it to make a better movie. > > I found the graphics impressive; the "blue people" was merely an effort > to avoid a more clear representation of the Na'vi as North American > indigenous people. > > > Avatar was very disappointing (Both in graphics and story) but maybe i > > expect too much...? > > The story was clearly "Pocahontas? in Space!", which was very disappointing. > I have to disagree.. without writing a dozen pages of my thoughts on Avatar, I think this comment from Metafilter sums it up best: http://www.metafilter.com/88197/Even-better-without-special-effects#2897157 link From rantingrick at gmail.com Sat Jan 15 23:17:45 2011 From: rantingrick at gmail.com (rantingrick) Date: Sat, 15 Jan 2011 20:17:45 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <18c2f4d8-0cce-4cdf-a386-80831dc2f114@m37g2000vbn.googlegroups.com> Message-ID: <39e4dbf5-f7ca-40fe-ae54-b9a7b6b5d1eb@g26g2000vba.googlegroups.com> On Jan 14, 3:37?pm, geremy condra wrote: > If you'd spent the > last year programming instead of doing your best Xah Lee impression > you might have actually made some progress on this. Well Geremy the very first step a wise developer employs is to get an idea of what the masses want and what they don't want. Nobody wants to waste a second (much less a whole year) developing a wxPython stdlib module when the powers that be won't even *entertain* the idea of a wxPython stdlib module. Most every Python programmer (noob to pro) understands that while Tkinter is a great starter GUI module eventually you hit the glass ceiling. However for some strange and quite ridiculous reason they insist on keeping Tkinter alive forever. I am at a loss here. Interviewer: So how do you feel about Tkinter? Python Community: Well Tkinter sucks what more can i say? Interviewer: Ok so maybe we should replace Tkinter with something better then? Python Community: What? Are you stupid? No it sucks but we will keep it! And that is that! I have spoken! Interviewer: So let me get this strait fella... You hate Tkinter, and most of your constituents won't even bother to use it because they hate it also *however* you just want to let it rot in the stdlib like some aging hero of boredom and booze? Python Community: Pretty much. Yea. Interviewer: Sounds like a Masochistic psychosis to me. Python Community: ad hominem!, ad hominem! From aman.6677 at gmail.com Sun Jan 16 00:30:00 2011 From: aman.6677 at gmail.com (Aman) Date: Sat, 15 Jan 2011 21:30:00 -0800 (PST) Subject: After C++, what with Python? Message-ID: <5adf432d-2629-4717-8fe6-6d073d6de860@glegroupsg2000goo.googlegroups.com> Hey all, I am a college student, and at college, we did most of the work in C/C++. I kind of stopped using C when I learned C++ (simply because C++ seemed a natural/elegant choice to me, and had backward compatibility with C). I've had a lot of experience with C++. Recently, I was on the path to learn a new programming language, and after suggestion of some of my friends and consulting the web, I chose to proceed with Python. I've finished with core Python and now I'm going through the various inbuilt packages that Python provides. I have an inquisitive mind, and while programming, I always want/tend to make something that is out of the box. It would be great if you people could guide me as to what to proceed with and how. From xahlee at gmail.com Sun Jan 16 00:45:59 2011 From: xahlee at gmail.com (Xah Lee) Date: Sat, 15 Jan 2011 21:45:59 -0800 (PST) Subject: do you know what's CGI? (web history personal story) References: <4d31b300$0$23758$14726298@news.sunsite.dk> <9b74ebf2-f9d4-48b1-b614-94ad4abd1f46@k3g2000yqc.googlegroups.com> Message-ID: <0b19f9e6-d1e3-4481-920d-d980073884c3@e4g2000vbg.googlegroups.com> > > > Avatar was very disappointing (Both in graphics and story) but maybe i > > > expect too much...? > > > The story was clearly "Pocahontas? in Space!", which was very disappointing. > > I have to disagree.. Loly. At this point, i must voice Xah's Point Of View. ?Avatar and District 9 Movie Review? http://xahlee.org/Periodic_dosage_dir/skina/avatar.html -------------------------------------------------- Avatar and District 9 Movie Review Xah Lee, 2010-01-07 ------------------------------ Avatar Went to watch the movie Avatar (2009 film) in theater today. Boo. On a scale of 1 to 10, i'd say this is no more than 7. This movie is totally predicable, stereotypical, intellectually shallow. The 3D effect isn't impressive at all, and about the only thing that is positive about this movie is the imaginative flora and fauna. This movies garnered raving reviews, both by critics as well as being a highly successful money maker. But it's so disappointing to me that i have to think about where to begin. ------------------------------ 3D Effect Ok, lets begin at some easy criticisms, the 3D tech. I recall, back in late 1970s or early 1980s when i was about 10 or so, my mom's mom took me to see one of the first 3D film, in Taiwan, a kung fu film. I vividly recall that i physically dodged when the weapons swung towards me from the screen. Yeah, a lot people did that. That, is the effect of good 3D on you. But now, after 30 years, one'd suppose that the 3D tech has improved vastly, which it has. However, watching Avatar, i hardly get ANY 3D sense at all. In fact, i absolutely don't feel any 3D sense, perhaps a little, if i force my self to feel it, thru its 3D glasses. (I did not watch it on iMax) What's wrong? I don't know. Perhaps the 3D tech is different. I don't remember which 3D films i've watched back 30 years ago, but am guessing that some 3D tech are designed to have a exaggerated perspectivity, and am guessing the 3D tech used in this movie is designed to be more mellow or wide angle. But over all, i say bah. ------------------------------ Predicable Ok, now i might disclose some of this movie's plot, and so here's your ?spoiler? warning, but, the movie is so formula driven and stereotypical that it doesn't matter much. The movie, in one sentence, is about Western powers with high tech wanting to take over gold from some primitive, indigenous people, for their riches in their land. Yeah, that's it. And, yes, there's a hero, who gradually realized that this isn't right, and fell in love with one of the beautiful chick from the indigenous people (you guessed right, the daughter of a chieftain!), and saved the tribe, with the help of local animals and magical nature. The movies runs 2.5 hours. I didn't particular cry ?move on already? at any point, but nor did the long movie had my attention wholly seized. There are no characters. All are shallow. The bad guys, in this case, the corporation head and the head of marines, are just what they are. The corporation head has eyes on gold, and that's his only concern. The marines head has bulky muscles, and is all about toughness. The hero, is just that, with good heart, and handsome to boot, courageous, always miraculously succeeds against all odds, and gets his girl. The heroin, in this case a alien race chick, is of course beautiful as much beauty we can put on a feline humanoid. And what's she like? Well, a beautiful woman, with concerns of loyalty of her man, love of her family, her people, a caring of nature. Actually had sex with the half-human half-alien hero. (inter-species porn anyone?) ------------------------------ Where is the Science in Sci-Fi? What about the story line? Well, the human animals want this million- dollar land inhabited by primitive tribes. The human animals created what's called a ?avatar?, which is a humanoid creature grown from bio- tubes that has mixed DNA from humans and the native feline-like humanoid aliens. The avatar is connected and controlled by a sleeping human. When one is awake, the other goes to sleep. Thru the avatars, it is thought that they can persuade the feline humanoids to move out. But the diplomatic cunning didn't work out, of course, and violence is resorted to. The hero fell in love with the heroin, and grew the sense of American Justice, and defended the primitive feline-humanoids with the help of miracle nature. The Sci-Fi aspect of the avatar concept is all interesting. How does the avatar work? How's it grown? How long does it take? How's the technology to control or connect it? What's the biology of the alien? What they eat? Well, this movie isn't concerned about these things, only that these settings qualify it as Sci-Fi flick. Another interesting aspect of sci-fi is that the plants and animals on this alien place have some sort bio-wire grown from their body, that allows direct animal-to-animal communication or animal-to-plant. For example, the feline-humanoid can connect her bio-wire grown from her head, with the bio-wire on a 6-legged horse or a flying-saurus, similar to how you connect 2 electric wires. Also, the plants form some kinda neural network by some bio-chemical means. (see Biocommunication (science)) Again, all this is used as plot-devices, you don't get to whiff them. ------------------------------ The Message? You can't help but think about American Indians when watching this movie, which the US American Disney proudly showed you in Pocahontas (1995 film). A history of genocide shown as one big, happy, tale. (See: Hollywood and Disney's Rape of Culture.) What can we say about that? Is it just a coincidence that this movie made you think of American Indians? The alien race is named ?Na'vi?. The tribe is called Omaticaya. They worship their tree deity. They mumble some prayer after killing in hunt, presumably to thank mother nature and bless the deceased prey. They tame wild alien beasts the likes of 6 legged horse and flying-saurus as a warrior's rite of passage. They do their face war-paints. They use bows and arrows... I'm not sure how much of all these is connected to real American Indian, or pop beliefs in Primitive Culture. What is Primitive culture anyway? Wikipedia doesn't help much except saying it's controversial. One thing for sure, is that the movie isn't shy of perpetuating the primitive people concept. So is there a message in this movie? Maybe i think too much. Maybe it is simply a visual treat of special effects and explosions. But you can't help thinking how shallow it is, how it reinforces a simplistic picture of Colonization and backwater savages trying to defend it. It is a insult to anthropology educators. ------------------------------ Enjoyable Parts I give this movie 6 out of 10. So, it's a bit above average. What i liked is watching the weird-looking, feline-like humanoid alien race. Of course, especially the female heroin. (Yeah, i'd totally do her.) The exotic flora and fauna, based on exotic rain forest things, are enjoyable to look at. The imagined bipedal mech, the vertical take off chopper, are all well done. The final battle, i wouldn't say spectacular, but still, enjoyable. Conclusion If you love sci-fi and is a movie-goer, yeah sure by all means go watch it. If you watch movies just 4 times a year, then i'm not sure. Wikipedia says with references, that the director acknowledged and some critics thought this movie carries anti-imperialism message. But i think, if anything, it is another black vs white, good vs evil, US- American-justice driven, brainlessness, that is likely to do more harm than good, as far as human animal's moral progress is concerned. Suppose, after watching this movie, viewer came out persuaded by the film and filled with the brainless zeal of JUSTICE. That IS American, and is where the problem is. Avatar movie trailer. ------------------------------ District 9 2010-02-07 Watched movie District 9. Fantastic. Much better than Avatar. Both movies are science fiction. Both involve aliens. Both have mechs. Both involves human animals as a group needing to deal and interact with alien animal. Both are successful, either by movie critics as well by profit. However, the Avatar is the most stereotypical Hollywood brainlessness. No intelligence, no content, no creativity, but plenty of big expensive computer graphics and explosions. The District 9, is just the opposite in every way. The aliens there are quite novel, and i really loved them. They have distinct, idiosyncratic, character. The mecha is also quite interesting, far more so than the one in Avatar. The alien mecha, somehow is integrated biologically with the aliens, and would puke, and when it being shot, hurts the alien inside too. The computer graphics is so well done. The overall movie content, unlike Avatar, doesn't contain some anti-this message or pro-that message, but makes you think, about deep ugly human nature, african history, history of race treatment. The only negative part about District 9, i would say, is that the beginning 30 min is quite boring. I'd give this movie a 9. District 9 Official Trailer 2 Xah ? http://xahlee.org/ From nagle at animats.com Sun Jan 16 01:03:25 2011 From: nagle at animats.com (John Nagle) Date: Sat, 15 Jan 2011 22:03:25 -0800 Subject: After C++, what with Python? In-Reply-To: <5adf432d-2629-4717-8fe6-6d073d6de860@glegroupsg2000goo.googlegroups.com> References: <5adf432d-2629-4717-8fe6-6d073d6de860@glegroupsg2000goo.googlegroups.com> Message-ID: <4d328a3d$0$44058$742ec2ed@news.sonic.net> On 1/15/2011 9:30 PM, Aman wrote: > Hey all, I am a college student, and at college, we did most of the > work in C/C++. I kind of stopped using C when I learned C++ (simply > because C++ seemed a natural/elegant choice to me, and had backward > compatibility with C). I've had a lot of experience with C++. > Recently, I was on the path to learn a new programming language, and > after suggestion of some of my friends and consulting the web, I > chose to proceed with Python. I've finished with core Python and now > I'm going through the various inbuilt packages that Python provides. > I have an inquisitive mind, and while programming, I always want/tend > to make something that is out of the box. It would be great if you > people could guide me as to what to proceed with and how. If you know C++ well, and have a computer science background. Python is trivial. Here's what you need to know: It's a safe dynamically typed imperative object oriented language, with explicit classes. The language is declaration-free and block structure is defined by indentation. Threading is supported but thread concurrency is marginal. The most common implementation is a naive interpreter with reference counting backed up by a mark and sweep garbage collector. Performance is about 1/60 of optimized C code. That's Python. John Nagle From aman.6677 at gmail.com Sun Jan 16 01:48:12 2011 From: aman.6677 at gmail.com (Aman) Date: Sat, 15 Jan 2011 22:48:12 -0800 (PST) Subject: After C++, what with Python? In-Reply-To: <4d328a3d$0$44058$742ec2ed@news.sonic.net> Message-ID: <86a904f8-05b0-435f-81d6-7450650f1679@glegroupsg2000goo.googlegroups.com> @nagle Means you are suggesting me not to proceed with Python because I've had experience with C++? From nagle at animats.com Sun Jan 16 02:04:40 2011 From: nagle at animats.com (John Nagle) Date: Sat, 15 Jan 2011 23:04:40 -0800 Subject: After C++, what with Python? In-Reply-To: <86a904f8-05b0-435f-81d6-7450650f1679@glegroupsg2000goo.googlegroups.com> References: <86a904f8-05b0-435f-81d6-7450650f1679@glegroupsg2000goo.googlegroups.com> Message-ID: <4d329899$0$43988$742ec2ed@news.sonic.net> On 1/15/2011 10:48 PM, Aman wrote: > @nagle Means you are suggesting me not to proceed with Python because I've had experience with C++? No, Python is quite useful, but on the slow side. If you're I/O bound, not time critical, or otherwise not performance constrained, it's quite useful. The language is really quite good, but there's some excessive dynamism which has caused every attempt at an optimizing implementation to fail. John Nagle From tjreedy at udel.edu Sun Jan 16 02:20:59 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Sun, 16 Jan 2011 02:20:59 -0500 Subject: Tkinter: The good, the bad, and the ugly! In-Reply-To: <39e4dbf5-f7ca-40fe-ae54-b9a7b6b5d1eb@g26g2000vba.googlegroups.com> References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <18c2f4d8-0cce-4cdf-a386-80831dc2f114@m37g2000vbn.googlegroups.com> <39e4dbf5-f7ca-40fe-ae54-b9a7b6b5d1eb@g26g2000vba.googlegroups.com> Message-ID: On 1/15/2011 11:17 PM, rantingrick wrote: > Well Geremy the very first step a wise developer employs is to get an > idea of what the masses want and what they don't want. 'The masses' have so far been divided on what alternative they might want. In any case, open source developers are typically scratching their own itches, which may are may not be influenced by 'the masses'. > Nobody wants to waste a second (much less a whole year) > developing a wxPython stdlib > module when the powers that be won't even *entertain* the idea of a > wxPython stdlib module. As far as I know, no one has ever seriously proposed any replacement for tkinter in at least the last ten years. There has been nothing to entertain, review, or discuss, let alone approve or reject. (And if you propose to the PSF that developer X contribute his code, the answer will be to talk to developer X instead.) 'gui' does not appear in any PEP title (except as part of 'guide' or 'guideline'. -- Terry Jan Reedy From georg at python.org Sun Jan 16 02:33:41 2011 From: georg at python.org (Georg Brandl) Date: Sun, 16 Jan 2011 08:33:41 +0100 Subject: [RELEASED] Python 3.2 rc 1 Message-ID: <4D329F55.9040903@python.org> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On behalf of the Python development team, I'm very happy to announce the first release candidate of Python 3.2. Python 3.2 is a continuation of the efforts to improve and stabilize the Python 3.x line. Since the final release of Python 2.7, the 2.x line will only receive bugfixes, and new features are developed for 3.x only. Since PEP 3003, the Moratorium on Language Changes, is in effect, there are no changes in Python's syntax and built-in types in Python 3.2. Development efforts concentrated on the standard library and support for porting code to Python 3. Highlights are: * numerous improvements to the unittest module * PEP 3147, support for .pyc repository directories * PEP 3149, support for version tagged dynamic libraries * PEP 3148, a new futures library for concurrent programming * PEP 384, a stable ABI for extension modules * PEP 391, dictionary-based logging configuration * an overhauled GIL implementation that reduces contention * an extended email package that handles bytes messages * a much improved ssl module with support for SSL contexts and certificate hostname matching * a sysconfig module to access configuration information * additions to the shutil module, among them archive file support * many enhancements to configparser, among them mapping protocol support * improvements to pdb, the Python debugger * countless fixes regarding bytes/string issues; among them full support for a bytes environment (filenames, environment variables) * many consistency and behavior fixes for numeric operations For a more extensive list of changes in 3.2, see http://docs.python.org/3.2/whatsnew/3.2.html To download Python 3.2 visit: http://www.python.org/download/releases/3.2/ Please consider trying Python 3.2 with your code and reporting any bugs you may notice to: http://bugs.python.org/ Enjoy! - -- Georg Brandl, Release Manager georg at python.org (on behalf of the entire python-dev team and 3.2's contributors) -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.16 (GNU/Linux) iEYEARECAAYFAk0yn1QACgkQN9GcIYhpnLDTdACgqQYW5ZmTLlxmppBZItprSj7I TmAAn13lgnu9TdVy0Jln7VwOt5JW9CwL =VZ3p -----END PGP SIGNATURE----- From debatem1 at gmail.com Sun Jan 16 02:35:54 2011 From: debatem1 at gmail.com (geremy condra) Date: Sat, 15 Jan 2011 23:35:54 -0800 Subject: After C++, what with Python? In-Reply-To: <5adf432d-2629-4717-8fe6-6d073d6de860@glegroupsg2000goo.googlegroups.com> References: <5adf432d-2629-4717-8fe6-6d073d6de860@glegroupsg2000goo.googlegroups.com> Message-ID: On Sat, Jan 15, 2011 at 9:30 PM, Aman wrote: > Hey all, I am a college student, and at college, we did most of the work in C/C++. I kind of stopped using C when I learned C++ (simply because C++ seemed a natural/elegant choice to me, and had backward compatibility with C). I've had a lot of experience with C++. > Recently, I was on the path to learn a new programming language, and after suggestion of some of my friends and consulting the web, I chose to proceed with Python. I've finished with core Python and now I'm going through the various inbuilt packages that Python provides. I have an inquisitive mind, and while programming, I always want/tend to make something that is out of the box. It would be great if you people could guide me as to what to proceed with and how. Here's what I would do: 1. Start off slow; reimplement things you've written in other languages until you're sure that you understand how Python constructs differ from superficially similar things in C/C++. 2. Once you've done that, pick a few small tasks (things you would expect to take about one or two weeks to finish), write all the high-level architectural code, and then put together a test harness for them using either unittest[0] or doctest[1]. Pick the one you're most confident you can write the code for and keep at it until you pass all your tests. Using the lessons learned from that, refactor the code of the others and iterate until you feel comfortable thinking about Python at a high level. As a bonus, you also now have a set of medium-scale projects with good test harnesses to show off. 3. After you've convinced yourself you know how to write Python, learn to read other peoples' Python code. Look for small projects (1-5 KLOC) with 'easy' bugs, get familiar with them, and fix those bugs. It isn't a race- make sure your work is high-quality, well-tested, and well documented before you send it to the maintainers. As yet another bonus, if those patches get accepted you'll be able to tell that to potential employers. At this point you'll probably have a much better idea of what you'd like to do moving forward- you'll probably have found out what kinds of problems you find interesting, which ones you have an aptitude for, and what kinds of environments you like. In other words, you'll be much better off than the vast majority of your peers ;) Geremy Condra [0]: http://docs.python.org/library/unittest.html [1]: http://docs.python.org/library/doctest.html From usernet at ilthio.net Sun Jan 16 03:25:13 2011 From: usernet at ilthio.net (Tim Harig) Date: Sun, 16 Jan 2011 08:25:13 +0000 (UTC) Subject: After C++, what with Python? References: <86a904f8-05b0-435f-81d6-7450650f1679@glegroupsg2000goo.googlegroups.com> <4d329899$0$43988$742ec2ed@news.sonic.net> Message-ID: On 2011-01-16, John Nagle wrote: > On 1/15/2011 10:48 PM, Aman wrote: >> @nagle Means you are suggesting me not to proceed with Python because I've had experience with C++? > > No, Python is quite useful, but on the slow side. If you're I/O > bound, not time critical, or otherwise not performance constrained, > it's quite useful. The language is really quite good, but there's > some excessive dynamism which has caused every attempt at an optimizing > implementation to fail. Those who are concerned about performance should check out Go. Garbage collection, duck typing, and compiles to a native binary. It creates a great middle ground between C++ and Python. Any C and/or Python programmer will feel right at home with the language. It is still a young language; but, I have been using it for some useful things. http://golang.org From no.email at nospam.invalid Sun Jan 16 03:53:20 2011 From: no.email at nospam.invalid (Paul Rubin) Date: Sun, 16 Jan 2011 00:53:20 -0800 Subject: After C++, what with Python? References: <86a904f8-05b0-435f-81d6-7450650f1679@glegroupsg2000goo.googlegroups.com> <4d329899$0$43988$742ec2ed@news.sonic.net> Message-ID: <7x8vylfcvz.fsf@ruckus.brouhaha.com> Tim Harig writes: > Those who are concerned about performance should check out Go. > Garbage collection, duck typing, and compiles to a native binary. > It creates a great middle ground between C++ and Python. Any C and/or > Python programmer will feel right at home with the language. It is > still a young language; but, I have been using it for some useful things. Go has some nice aspects but it is much lower level than Python. If you want a statically typed, compiled language closer to Python's level, I know of some projects that have switched from Python to Ocaml. If you want dynamic types, I guess there's Dylan, Lisp, or possibly Erlang. There is also Haskell, but I think using it takes a much different mind-set than Python usually brings out. From list at qtrac.plus.com Sun Jan 16 04:10:56 2011 From: list at qtrac.plus.com (Mark Summerfield) Date: Sun, 16 Jan 2011 09:10:56 +0000 Subject: [python-committers] [RELEASED] Python 3.2 rc 1 In-Reply-To: <4D329F55.9040903@python.org> References: <4D329F55.9040903@python.org> Message-ID: <20110116091056.7d78cca8@dino> On Sun, 16 Jan 2011 08:33:41 +0100 Georg Brandl wrote: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > On behalf of the Python development team, I'm very happy to announce > the first release candidate of Python 3.2. [snip] Regarding http://docs.python.org/dev/whatsnew/3.2.html - in the first argparse example the comment says "one of four allowed values", but the choices list has only three items so I wonder if this is correct? - in the coverage of PEP 3333 code points are written as u0000 and u00FF which is non-standard; one standard way to write them is U+0000 and U+00FF I love the clickable table of built-in functions in functions.html. On debian testing 64-bit make test resulted in: ... [349/349] test_zlib 328 tests OK. 21 tests skipped: test_codecmaps_cn test_codecmaps_hk test_codecmaps_jp test_codecmaps_kr test_codecmaps_tw test_curses test_gdb test_kqueue test_ossaudiodev test_smtpnet test_socketserver test_startfile test_timeout test_tk test_ttk_guionly test_urllib2net test_urllibnet test_winreg test_winsound test_xmlrpc_net test_zipfile64 Those skips are all expected on linux2. sys:1: ResourceWarning: unclosed file <_io.TextIOWrapper name='/dev/null' mode='a' encoding='UTF-8'> which looks pretty good:-) However, I hit a problem with relative imports not working (compared with 3.1). I have to go now but will try to produce a small example if I can. -- Mark Summerfield, Qtrac Ltd, www.qtrac.eu C++, Python, Qt, PyQt - training and consultancy "Programming in Python 3" - ISBN 0321680561 http://www.qtrac.eu/py3book.html From wxjmfauth at gmail.com Sun Jan 16 04:22:00 2011 From: wxjmfauth at gmail.com (jmfauth) Date: Sun, 16 Jan 2011 01:22:00 -0800 (PST) Subject: Issue 1602, cp65001, powershell and python3 crash Message-ID: <04f85ff6-7ece-4397-b0f8-e8b4127a3641@s9g2000vby.googlegroups.com> After having read the discussion about the issue 1602, http://bugs.python.org/issue1602, I came to the idea to test Python with the PowerShell. I thought, it could help and manage "unicode" better than the std "dosbox" does My experience with PowerShell is closed to zero, so take the following as a flat raw information. 1) Setup the coding in PowerShell (font: Consolas) PS D:\jm> $OutputEncoding IsSingleByte : True BodyName : us-ascii EncodingName : US-ASCII HeaderName : us-ascii WebName : us-ascii WindowsCodePage : 1252 IsBrowserDisplay : False IsBrowserSave : False IsMailNewsDisplay : True IsMailNewsSave : True EncoderFallback : System.Text.EncoderReplacementFallback DecoderFallback : System.Text.DecoderReplacementFallback IsReadOnly : True CodePage : 20127 PS D:\jm> chcp 65001 Page de codes active?: 65001 PS D:\jm> $OutputEncoding = [Console]::OutputEncoding PS D:\jm> $OutputEncoding BodyName : utf-8 EncodingName : Unicode (UTF-8) HeaderName : utf-8 WebName : utf-8 WindowsCodePage : 1200 IsBrowserDisplay : True IsBrowserSave : True IsMailNewsDisplay : True IsMailNewsSave : True IsSingleByte : False EncoderFallback : System.Text.EncoderReplacementFallback DecoderFallback : System.Text.DecoderReplacementFallback IsReadOnly : True CodePage : 65001 So far, so good. It seems I can enter and display "unicode characters" (as opposed to cp850). PS D:\jm> echo 'abc?????' abc????? PS D:\jm> chcp Page de codes active?: 65001 PS D:\jm> 2) Python test PS D:\jm> c:\python31\python.exe Fatal Python error: Py_Initialize: can't initialize sys standard streams LookupError: unknown encoding: cp65001 This application has requested the Runtime to terminate it in an unusual way. Please contact the application's support team for more information. PS D:\jm> Obviously and expectedly Python does not recognize cp65001. That's not the problem. The main concern is, Python crashes with the usual msgbox, "python.exe has stopped working ..." . win7 pro (32 bits), Swiss French setup, cp850/cp1252, Python 3.1.2 . Take this a raw information and do not ask me what's happen behind the scene. Last minute info: Python 3.2.rc1: same behaviour. jmf From stefan_ml at behnel.de Sun Jan 16 04:31:36 2011 From: stefan_ml at behnel.de (Stefan Behnel) Date: Sun, 16 Jan 2011 10:31:36 +0100 Subject: After C++, what with Python? In-Reply-To: <4d328a3d$0$44058$742ec2ed@news.sonic.net> References: <5adf432d-2629-4717-8fe6-6d073d6de860@glegroupsg2000goo.googlegroups.com> <4d328a3d$0$44058$742ec2ed@news.sonic.net> Message-ID: John Nagle, 16.01.2011 07:03: > Threading is supported > but thread concurrency is marginal. The most common implementation is > a naive interpreter with reference counting backed up by a mark > and sweep garbage collector. Performance is about 1/60 of > optimized C code. > > That's Python. Since the OP is new to Python (and thus also to this group), it's worth noting that the above is what John Nagle commonly claims to be important about Python. It doesn't match everybody's POV. For most other people, the essence is that Python is actually fun to work with. And if you come from a C++ background, you will happily appreciate how simple programming can be. You will also appreciate learning about Cython, which is the straight forward way for you to write Python code that interfaces with C++ natively. Stefan From usernet at ilthio.net Sun Jan 16 04:47:35 2011 From: usernet at ilthio.net (Tim Harig) Date: Sun, 16 Jan 2011 09:47:35 +0000 (UTC) Subject: [OT] Python like lanugages [was Re: After C++, what with Python?] References: <86a904f8-05b0-435f-81d6-7450650f1679@glegroupsg2000goo.googlegroups.com> <4d329899$0$43988$742ec2ed@news.sonic.net> <7x8vylfcvz.fsf@ruckus.brouhaha.com> Message-ID: On 2011-01-16, Paul Rubin wrote: > Tim Harig writes: >> Those who are concerned about performance should check out Go. >> Garbage collection, duck typing, and compiles to a native binary. >> It creates a great middle ground between C++ and Python. Any C and/or >> Python programmer will feel right at home with the language. It is >> still a young language; but, I have been using it for some useful things. > > Go has some nice aspects but it is much lower level than Python. If you It is a little lower; but, I wouldn't say much lower. My Go code is much more similar in concept, feel, and size to my Python code then it is to my C code. > want a statically typed, compiled language closer to Python's level, I > know of some projects that have switched from Python to Ocaml. If you I have head good things about Ocaml; but, I have never taken the time to learn the language myself. It never reached a critical mass of interest from me to consider adopting it. One of the things that gives me hope for Go is that it is backed by Google so I expect that it may gain some rather rapid adoption. It has made enough of a wake to grab one of Eweek's 18 top languages for 2011. http://www.eweek.com/c/a/Application-Development/Java-C-C-Top-18-Programming-Languages-for-2011-480790/ > want dynamic types, I guess there's Dylan, Lisp, or possibly Erlang. I am a big fan of Erlang and it's ability to create fault tolerant systems; but, it isn't really a general purpose programming language. It also runs inside of a VM which means that it doesn't produce native binary. From steve+comp.lang.python at pearwood.info Sun Jan 16 05:26:23 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 16 Jan 2011 10:26:23 GMT Subject: [OT] Python like lanugages [was Re: After C++, what with Python?] References: <86a904f8-05b0-435f-81d6-7450650f1679@glegroupsg2000goo.googlegroups.com> <4d329899$0$43988$742ec2ed@news.sonic.net> <7x8vylfcvz.fsf@ruckus.brouhaha.com> Message-ID: <4d32c7cf$0$29983$c3e8da3$5496439d@news.astraweb.com> On Sun, 16 Jan 2011 09:47:35 +0000, Tim Harig wrote: > One of the things that gives me hope > for Go is that it is backed by Google so I expect that it may gain some > rather rapid adoption. It has made enough of a wake to grab one of > Eweek's 18 top languages for 2011. If the author thinks that Go is a "tried and true" (his words, not mine) language "where programmers can go to look for work", I think he's fooling himself. When I design my new language, I will make sure I choose a name such that any attempt to search for it on job sites will produce oodles and oodles and oodles of false positives, all the better to ensure that simple- minded "top language of ..." surveys will give a massively inflated job count. I think I'll call it "Salary". -- Steven From wxjmfauth at gmail.com Sun Jan 16 05:55:58 2011 From: wxjmfauth at gmail.com (jmfauth) Date: Sun, 16 Jan 2011 02:55:58 -0800 (PST) Subject: Does Python 3.1 accept \r\n in compile()? References: <5c7ae38a-4302-427b-98f0-2900eaf2a974@l24g2000vby.googlegroups.com> <19d5330a-1237-4e7a-b9aa-47ce312ce8f9@d7g2000vbv.googlegroups.com> Message-ID: <91286f34-037e-47b9-baf4-9427766f2d05@g26g2000vbz.googlegroups.com> Just an info, addendum. >>> sys.version '3.2rc1 (r32rc1:88035, Jan 15 2011, 21:05:51) [MSC v.1500 32 bit (Intel)]' >>> compile('if True:\r\n print(999)\r\n', '', 'exec') at 0x023CA610, file "", line 2> >>> exec(compile('if True:\r\n print(999)\r\n', '', 'exec')) 999 >>> From usernet at ilthio.net Sun Jan 16 06:03:48 2011 From: usernet at ilthio.net (Tim Harig) Date: Sun, 16 Jan 2011 11:03:48 +0000 (UTC) Subject: [OT] Python like lanugages [was Re: After C++, what with Python?] References: <86a904f8-05b0-435f-81d6-7450650f1679@glegroupsg2000goo.googlegroups.com> <4d329899$0$43988$742ec2ed@news.sonic.net> <7x8vylfcvz.fsf@ruckus.brouhaha.com> <4d32c7cf$0$29983$c3e8da3$5496439d@news.astraweb.com> Message-ID: On 2011-01-16, Steven D'Aprano wrote: > On Sun, 16 Jan 2011 09:47:35 +0000, Tim Harig wrote: > >> One of the things that gives me hope >> for Go is that it is backed by Google so I expect that it may gain some >> rather rapid adoption. It has made enough of a wake to grab one of >> Eweek's 18 top languages for 2011. > > If the author thinks that Go is a "tried and true" (his words, not mine) > language "where programmers can go to look for work", I think he's > fooling himself. No I wouldn't say that it has reached market penetration yet; but, it has more momentum then any language I am familiar with. I wouldn't be at all surprised to see it becoming quite common in the next five years. How long has it taken Python to reach its present level of market penetration? And, I still don't see a huge amount of professional Python use outside of web developement. Go has only been public for less then a year. Personally, I think the time is ripe for a language that bridges the gap between ease of use dynamic languages with the performance and distribution capabilities of a full systems level language. This is after all the promise the VM based languages made but never really fulfilled. It is also high time for a fully concurrent language fully capable of taking advantage of multicore processors without having to deal with the inherent dangers of threading. There are several good choices available for both a even a few that fit both bills; but, few of them have the support of a company like Google that is capable of the push required to move the language into the mainstream. > When I design my new language, I will make sure I choose a name such that > any attempt to search for it on job sites will produce oodles and oodles > and oodles of false positives, all the better to ensure that simple- > minded "top language of ..." surveys will give a massively inflated job > count. I would agree that Go wasn't the best idea for a language name from the search perspective. One would have though a company like Google would have been cognizant of those limitations... From nambo4jb at gmail.com Sun Jan 16 09:49:18 2011 From: nambo4jb at gmail.com (Cathy James) Date: Sun, 16 Jan 2011 08:49:18 -0600 Subject: Functions Not Fun (yet)-please help! Message-ID: Dear all, I can't thank you enough for taking time from your busy schedules to assist me (and others) in my baby steps with Python. Learning about functions now and wondering about some things commented in my code below. Maybe someone can break it down for me and show me why i cant print the function i created. I am using IDLE, saved it as .py def my_func(a, b="b is a default" ,c="c is another default"): print (a) print (b) print (c) #printing the function itself: #1. assign value to a only, b and c as default: a= "testing" print (my_func(a,b,c)) #why does program say c is not defined, tho default in function above? #2. assign a and b only, c is default print my_func(a="testing a", b="testing b") -------------- next part -------------- An HTML attachment was scrubbed... URL: From askutt at gmail.com Sun Jan 16 10:18:16 2011 From: askutt at gmail.com (Adam Skutt) Date: Sun, 16 Jan 2011 07:18:16 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> Message-ID: On Jan 14, 5:17?pm, Albert van der Horst wrote: > > I really don't follow that. You need a tremendous set to write gimp. > Obviously you won't write gimp in Python. > You need a tremendous set to write /the majority of the applications on your computer/. On my desktop right now, I have running: * Google Chrome * TweetDeck * PuTTY * Pidgin * Game for Windows Launcher * Free Download Manager * Steam Client * A Windows Control Panel Window None of those applications could be written with his proposed widget set, he's literally 0/7 on running applications. If the situation isn't the same on your computer then your application usage is highly unusual or you don't understand what widgets are used to construct your applications. You've just told me that Python would no longer be suitable for constructing the majority of GUI applications on the planet. > Now you want to jot together three cooperating screens to specify > some properties for say bluetooth. The proposed set is ample for > that, no? Yes, but why would I ever do such a thing? Such things are provided for me by the operating system already, pretty much regardless of platform. His widget set is quite truly only good for OS utilities, but I already have those. I generally don't need nor want more of them. Neither do Python users, because the majority of us aren't writing OS utilities. That leaves the logical equivalent of traditional terrible, awful Visual Basic applications left, and even Microsoft gives them a full widget set (and "real" programming language) now in VB.NET. The effort involved in segmentation doesn't make things any easier and doesn't save them, the library authors, much of anything. > Such things make up a substantial part of the applications > as far as numbers is concerned. They are probably written by > people who don't want to dive very deeply into GUI. > (Maybe they are more bluetooth experts than GUI-experts, what > would you say?) > I could list every application on the my computer and make a table of which ones would be workable given the list above, but I can already tell you that the answer is, "Not very many, and most of the ones that can were written by MS". And I'm entirely ignoring issues like theming as well. Adding a few additional layout controls would expand the list a moderate deal, but that's going to be true pretty much regardless of which 3 or 4 additional widgets you pick. And this ignores the obvious, "You'd still need a full WxWidgets install in order to build the minimized set, so all you've saved is a few .py files" part of the argument, which is just as compelling, if not more so. Really, if you believe the case to be otherwise, I truly believe you aren't paying attention to your own computer(s), or don't understand how the applications you use are constructed. What's out there isn't interesting, it's what people use that's interesting, and people tend to use GUIs that are moderately to highly complicated. Adam From emile at fenx.com Sun Jan 16 10:24:14 2011 From: emile at fenx.com (Emile van Sebille) Date: Sun, 16 Jan 2011 07:24:14 -0800 Subject: Functions Not Fun (yet)-please help! In-Reply-To: References: Message-ID: On 1/16/2011 6:49 AM Cathy James said... > Dear all, > > I can't thank you enough for taking time from your busy schedules to assist > me (and others) in my baby steps with Python. Learning about functions now > and wondering about some things commented in my code below. Maybe someone > can break it down for me and show me why i cant print the function i > created. I am using IDLE, saved it as .py > > def my_func(a, b="b is a default" ,c="c is another default"): > print (a) > print (b) > print (c) > > > #printing the function itself: > > #1. assign value to a only, b and c as default: > a= "testing" > print (my_func(a,b,c)) #why does program say c is not defined, tho default > in function above? Because c is not defined in the scope outside the function where you are passing the variables into my_func. To see the effect of the defaults, call with only 'a', as otherwise any variables you pass in must have been previously defined. >>> print (my_func(a)) testing b is a default c is another default None >>> Emile > #2. assign a and b only, c is default > print my_func(a="testing a", b="testing b") > > From david at boddie.org.uk Sun Jan 16 10:30:45 2011 From: david at boddie.org.uk (David Boddie) Date: Sun, 16 Jan 2011 16:30:45 +0100 Subject: After C++, what with Python? References: <5adf432d-2629-4717-8fe6-6d073d6de860@glegroupsg2000goo.googlegroups.com> Message-ID: On Sunday 16 January 2011 08:35, geremy condra wrote: > On Sat, Jan 15, 2011 at 9:30 PM, Aman wrote: >> It would be great if you people could guide me as to what to proceed with >> and how. > > Here's what I would do: [Snip advice] Maybe it would be good to expand the Getting Started material in the Python Wiki with your advice, Geremy. It would save you the trouble of having to type it all over again the next time a similar question is asked. David From jamuah at gmail.com Sun Jan 16 10:34:15 2011 From: jamuah at gmail.com (Moses) Date: Sun, 16 Jan 2011 17:34:15 +0200 Subject: [PYTHON] threading: Parallel processing Message-ID: Hi All, Is there is a way to print or use the value of new in the main function of the script below? from thread import start_new_thread, allocate_lock num_threads = 0 thread_started = False lock = allocate_lock() def heron(a): global num_threads, thread_started lock.acquire() num_threads += 1 thread_started = True lock.release() """Calculates the square root of a""" eps = 0.0000001 old = 1 new = 1 while True: old,new = new, (new + a/new) / 2.0 print old, new if abs(new - old) < eps: break lock.acquire() num_threads -= 1 lock.release() return new start_new_thread(heron,(81,)) start_new_thread(heron,(999,)) start_new_thread(heron,(1733,)) while not thread_started: pass while num_threads > 0: pass Thanks, Moses. -------------- next part -------------- An HTML attachment was scrubbed... URL: From rantingrick at gmail.com Sun Jan 16 11:30:06 2011 From: rantingrick at gmail.com (rantingrick) Date: Sun, 16 Jan 2011 08:30:06 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> Message-ID: On Jan 16, 9:18?am, Adam Skutt wrote: > You need a tremendous set to write /the majority of the applications > on your computer/. [...snip incessant rambling...] Adam your post is so incoherent that i cannot decide if you are FOR or AGAINST changing the current Tkinter GUI module into a wxPython GUI module. And this widget set that you keep referring to is a bit vague also. So i will quote myself because i *think* this may be what "it" referres to... ####################### # Start Quote by Rick # ####################### Exactly! All we need to do is replace the existing Tkinter with a small sub-set of wxPython widgets that mirrors exactly what we have now... Toplevel Label Entry Button Radiobutton Checkbutton Canvas Textbox Listbox Menu Scale Scrollbar ...thats all you need in the std library "widget wise". ##################### # End Quote by Rick # ##################### If you cannot relize that this is exactly what we have now in Tkinter then you need to go and read the source for Tkinter. Oh hell, i'd better do it for you. Watch this... >>> f = open('C:\\Python26\\Lib\\lib-tk\\Tkinter.py') >>> s = f.read() >>> f.close() >>> import re >>> re.findall(r'class (\w+)\(', s) ['StringVar', 'IntVar', 'DoubleVar', 'BooleanVar', 'Tk', 'BaseWidget', 'Widget', 'Toplevel', 'Button', 'Canvas', 'Checkbutton', 'Entry', 'Frame', 'Label', 'Listbox', 'Menu', 'Menubutton', 'Message', 'Radiobutton', 'Scale', 'Scrollbar', 'Text', 'OptionMenu', 'PhotoImage', 'BitmapImage', 'Spinbox', 'LabelFrame', 'PanedWindow', 'Studbutton', 'Tributton'] Now what seems to be missing from my proposed widget set that hampers you from re-creating every GUI app on your computer? And just in case you did not notice "my proposed wxPython module" includes the exact same widget set. Ok, Ok, i let out image support but in my mind PIL should handle all of that. The IntVar, StringVar, and BooleanVar classes are non-applicable in a wx GUI. So just for your sake i shall "lower the bar of comprehension"... >>> tkclasses = re.findall(r'class (\w+)\(', s) >>> omit = ['StringVar', 'IntVar', 'DoubleVar', 'BooleanVar', 'Tk', 'BaseWidget', 'Widget', 'Frame', 'Message', 'OptionMenu', 'LabelFrame', 'PanedWindow', 'Studbutton', 'Tributton'] >>> [x for x in tkclasses if x not in omit] ['Toplevel', 'Button', 'Canvas', 'Checkbutton', 'Entry', 'Label', 'Listbox', 'Menu', 'Menubutton', 'Radiobutton', 'Scale', 'Scrollbar', 'Text', 'PhotoImage', 'BitmapImage', 'Spinbox'] There you have it. The same exact widget set we have now. Sure you cannot re-create every GUI app on your stinking computer however if you download the 3rd party wxPython extension module not only will you be able to re-create every GUI app on your stinking computer it will wipe your backside too! (psst: "it" refers to wxPython) i hope you learned something from this exercise Adam. From rantingrick at gmail.com Sun Jan 16 12:08:08 2011 From: rantingrick at gmail.com (rantingrick) Date: Sun, 16 Jan 2011 09:08:08 -0800 (PST) Subject: Developing a program to make a family tree. References: <317f6ed0-ebd9-4a58-9ad3-da57563193ad@w29g2000vba.googlegroups.com> Message-ID: <8d37c88b-5695-49a5-a3d1-ce5ad60ac724@w2g2000yqb.googlegroups.com> On Jan 15, 3:43?pm, Michael Hunter wrote: > I think you are probably coming at this from the wrong direction. > Either you want to solve your family tree problem in the easiest way > possible in which case there are already packages available or you > want to develop this because you want to do the project to learn > (more) python, etc. ?Assuming the later the fact you have to ask the > question in the way you did means you are short on software design > experience and don't know much about the problem domain (genealogy). > Additionally you probably havn't written much code although you came > here so you probably have a little experience. ?That is triple death. > You need to hold a couple of those variables stable. ?I'd suggest > finding a existing open source genealogy program and use bug fixing as > a way to learn basics about the package and then try to add a feature > as a way of learning something about software design. While i mostly agree with this statement i must also whole-heart-ly disagree. I have many projects that i am currently "developing" that are far beyond my skill set at this time. However this "lack of experience" within the problem domain does not scare me away. Actually i want to learn how many things work "under the hood". So what i do is develop and design until i hit a wall. Then i move over to another project and develop and design until i hit another wall. Sometimes i have to go back and re-write the hole thing, but hey, its part of the learning curve. And in the process something interesting always happens... I find that solving one problem lends knowledge and insight into another completely different problem. This technique may not be for the weak of heart but it works well for me. I like a challenge. I also like to learn. So this drives me to keep going. I can tell you that i have written code i previously thought was impossible for me to create. Nothing is impossible if you want it bad enough or if you can manage to live long enough! :). Sadly even if your thirst for knowledge is unquenchable, your life will be quenched in due time :(. But i do not want to image a world where we all live forever, what a nightmare! From kw at codebykevin.com Sun Jan 16 12:39:41 2011 From: kw at codebykevin.com (Kevin Walzer) Date: Sun, 16 Jan 2011 12:39:41 -0500 Subject: Tkinter: The good, the bad, and the ugly! In-Reply-To: References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> Message-ID: <79a8a$4d332d1a$4275d90a$3986@FUSE.NET> On 1/16/11 11:30 AM, rantingrick wrote: > > ####################### > # Start Quote by Rick # > ####################### > Exactly! All we need to do is replace the existing Tkinter with a > small sub-set of wxPython widgets that mirrors exactly what we have > now... > Toplevel > Label > Entry > Button > Radiobutton > Checkbutton > Canvas > Textbox > Listbox > Menu > Scale > Scrollbar > ...thats all you need in the std library "widget wise". Rick, So, after all this discussion, your idea (it's not quite a proposal since you haven't initiated the PEP process for it) boils down to replacing Tkinter in the stdlib with a very stripped-down subset of wxPython? I'm not quite clear on what this accomplishes. Some of these widgets in Tkinter are ugly, but they have themed (ttk) equivalents (such as label, entry, button) that wrap native widgets in a manner similar to wxPython. So there's no real advantage to wx here. Your suggestion that developers who want a larger widget set can download the entire wxPython package is, again, answered by the observation that numerous Tk extensions, with Tkinter wrappers, exist to expand the standard Tk widget set. And there are pure-Python extension packages that are not dependent on binary Tk extensions, cf. Python Megawidgets. Again, no real advantage to wxPython. Your initial criticism that Python's standard GUI toolkit should not dependent on the priorities and development schedule of an outside project (Tcl/Tk) seems to have gone by the wayside here, because wxPython is an outside project (led by Robin Dunn) that is in turn dependent on the timeline of yet another outside project--wxWidgets, the underlying C++ library. Finally, there are licensing issues to consider. Tcl/Tk's license is very liberal, BSD-style, and it is quite similar to Python's. wxWidget's library is basically LGPL with a couple of exceptions to make it friendlier to proprietary software. Could code under such a license be gracefully included in the stlib? --Kevin -- Kevin Walzer Code by Kevin http://www.codebykevin.com From tjreedy at udel.edu Sun Jan 16 12:58:49 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Sun, 16 Jan 2011 12:58:49 -0500 Subject: [python-committers] [RELEASED] Python 3.2 rc 1 In-Reply-To: <20110116091056.7d78cca8@dino> References: <4D329F55.9040903@python.org> <20110116091056.7d78cca8@dino> Message-ID: On 1/16/2011 4:10 AM, Mark Summerfield wrote: > Regarding http://docs.python.org/dev/whatsnew/3.2.html > > - in the first argparse example the comment says "one of four allowed > values", but the choices list has only three items so I wonder if this > is correct? > > - in the coverage of PEP 3333 code points are written as u0000 and u00FF > which is non-standard; one standard way to write them is U+0000 and > U+00FF Both fixed. > I love the clickable table of built-in functions in functions.html. I do too. > On debian testing 64-bit make test resulted in: > ... > However, I hit a problem with relative imports not working (compared > with 3.1). I have to go now but will try to produce a small example if I > can. -- Terry Jan Reedy From tjreedy at udel.edu Sun Jan 16 13:17:35 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Sun, 16 Jan 2011 13:17:35 -0500 Subject: Issue 1602, cp65001, powershell and python3 crash In-Reply-To: <04f85ff6-7ece-4397-b0f8-e8b4127a3641@s9g2000vby.googlegroups.com> References: <04f85ff6-7ece-4397-b0f8-e8b4127a3641@s9g2000vby.googlegroups.com> Message-ID: On 1/16/2011 4:22 AM, jmfauth wrote: > After having read the discussion about the issue 1602, > http://bugs.python.org/issue1602, I came to the idea > to test Python with the PowerShell. I thought, it > could help and manage "unicode" better than the > std "dosbox" does > > My experience with PowerShell is closed to zero, so > take the following as a flat raw information. > > 1) Setup the coding in PowerShell (font: Consolas) > > PS D:\jm> $OutputEncoding > > > IsSingleByte : True > BodyName : us-ascii > EncodingName : US-ASCII > HeaderName : us-ascii > WebName : us-ascii > WindowsCodePage : 1252 > IsBrowserDisplay : False > IsBrowserSave : False > IsMailNewsDisplay : True > IsMailNewsSave : True > EncoderFallback : System.Text.EncoderReplacementFallback > DecoderFallback : System.Text.DecoderReplacementFallback > IsReadOnly : True > CodePage : 20127 > > PS D:\jm> chcp 65001 > Page de codes active : 65001 > > PS D:\jm> $OutputEncoding = [Console]::OutputEncoding > PS D:\jm> $OutputEncoding > > > BodyName : utf-8 > EncodingName : Unicode (UTF-8) > HeaderName : utf-8 > WebName : utf-8 > WindowsCodePage : 1200 > IsBrowserDisplay : True > IsBrowserSave : True > IsMailNewsDisplay : True > IsMailNewsSave : True > IsSingleByte : False > EncoderFallback : System.Text.EncoderReplacementFallback > DecoderFallback : System.Text.DecoderReplacementFallback > IsReadOnly : True > CodePage : 65001 > > > So far, so good. It seems I can enter and display "unicode > characters" (as opposed to cp850). > > PS D:\jm> echo 'abc?????' > abc????? > PS D:\jm> chcp > Page de codes active : 65001 > PS D:\jm> > > 2) Python test > > PS D:\jm> c:\python31\python.exe > Fatal Python error: Py_Initialize: can't initialize sys standard > streams > LookupError: unknown encoding: cp65001 > > This application has requested the Runtime to terminate it in an > unusual way. > Please contact the application's support team for more information. > PS D:\jm> > > Obviously and expectedly Python does not recognize cp65001. > That's not the problem. > > The main concern is, Python crashes with the usual msgbox, > "python.exe has stopped working ..." . > > win7 pro (32 bits), Swiss French setup, cp850/cp1252, Python 3.1.2 . > > Take this a raw information and do not ask me what's happen > behind the scene. > > Last minute info: > Python 3.2.rc1: same behaviour. Could you add this report, slightly condensed, to the issue? -- Terry Jan Reedy From rantingrick at gmail.com Sun Jan 16 13:27:01 2011 From: rantingrick at gmail.com (rantingrick) Date: Sun, 16 Jan 2011 10:27:01 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <79a8a$4d332d1a$4275d90a$3986@FUSE.NET> Message-ID: On Jan 16, 11:39?am, Kevin Walzer wrote: First of all welcome back to the discussion Kevin. You and i both appreciate and use Tkinter extensively and your input is most welcome here. You are a smart and level headed fella which makes for good discussion. Thanks for that! Ok, let the battle begin! :-) > So, after all this discussion, your idea (it's not quite a proposal > since you haven't initiated the PEP process for it) ?boils down to > replacing Tkinter in the stdlib with a very stripped-down subset of > wxPython? Exactly (almost). However I need to stress that nothing will be lost to the user when this change happens! On the contrary, much will be gained. You're going to have the same basic capabilities as you have now in the stdlib with Tkinter HOWEVER, you can download all the feature rich goodies that only wx can offer. > I'm not quite clear on what this accomplishes. Some of these widgets in > Tkinter are ugly, but they have themed (ttk) equivalents (such as label, > entry, button) that wrap native widgets in a manner similar to wxPython. > So there's no real advantage to wx here. This statement is uninformed Kevin. Wx needs no themed widgets because the default widgets where created equal from day one. TclTk has always been behind in look and feel. Yes we do now FINALLY have themed widgets however this does not make TclTk equal to wxPython in any shape or form. Kevin i ask that you and everyone else who may be interested in this community to download the wxPython demo. This demo (which is a work of art in it's own right!) will be all you need to understand the vast differences between TclTk and wxPython. You can get it here... http://www.wxpython.org/download.php#stable If for some reason you cannot download this beautiful demo, then at least look at the awesome screen shots here... http://www.wxpython.org/screenshots.php > Your suggestion that developers who want a larger widget set can > download the entire wxPython package is, again, answered by the > observation that numerous Tk extensions, with Tkinter wrappers, exist to > expand the standard Tk widget set. And there are pure-Python extension > packages that are not dependent on binary Tk extensions, cf. Python > Megawidgets. Again, no real advantage to wxPython. Wrong. Even with the hodgepodge of third party downloads and extension packages Tkinter cannot hold a candle to the professional quality of wxPython. Again i urge you to at least download the demo and see for yourself. WxPython is a massive library of almost any widget you can imagine using in the 21st century. All of the hard work has been done for you, no need to create your own custom widgets again and again. Do yourself a favor and download the demo. Here it is again... http://www.wxpython.org/download.php#stable > Your initial criticism that Python's standard GUI toolkit should not > dependent on the priorities and development schedule of an outside > project (Tcl/Tk) seems to have gone by the wayside here, because > wxPython is an outside project (led by Robin Dunn) that is in turn > dependent on the timeline of yet another outside project--wxWidgets, the > underlying C++ library. Yes, we will always be at the mercy of another development community unless we build a real Python GUI. Well newsflash, that dream is not going to happen because we would need to re-invent the wheel many times over and not to mention the long bug fix time-line. However let's get back to reality and compare wxPython to TclTk+Tkinter. First of all wxPython IS a part of the Python community. They DO care about Python and Python only. Yes WxWidgets IS NOT part of our community, however the widget set is so mature that we don't need to worry about version releases. We could live off the current widget set unchanged for many years to come!! Compare that to TclTk who only cares about TclTk and the fact that TclTk is not ANYWHERE near the maturity of wxPython. With Tkinter we WILL need to update as new widgets and functionality come into being. Oh did i forget to give you a link to the beautiful wxDemo, ok here it is... http://www.wxpython.org/download.php#stable > Finally, there are licensing issues to consider. Tcl/Tk's license is > very liberal, BSD-style, and it is quite similar to Python's. wxWidget's > library is basically LGPL with a couple of exceptions to make it > friendlier to proprietary software. Could code under such a license be > gracefully included in the stlib? Well we need the license lawyers to weigh in on that aspect. If wxPythons license is weighed and found wanting then we must consider something else. However, i will tell you that nothing else exists that can match the maturity, cross-platform, and feature rich-ness of wx. If someone knows of any such package by all means speak up! In any event, the time to start looking for something more appropriate to this community in the 21st century has long passed. We have allowed Tkinter to rot and grow pungent for the sake of people's "feelings". Yes, big changes alike this are going to piss off a few folks because it is human nature to fear change. However i must stress that as Python 3000 was a difficult --but very necessary change-- so too will the ushering of a new GUI kit be. But in the the end, we will be a better community and language for it. But we must start the transformation now, because transformations take such a looong time! We have dragged our collective feet long enough! From tjreedy at udel.edu Sun Jan 16 13:49:24 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Sun, 16 Jan 2011 13:49:24 -0500 Subject: Tkinter: The good, the bad, and the ugly! In-Reply-To: References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> Message-ID: On 1/16/2011 11:30 AM, rantingrick wrote: > Toplevel > Label > Entry > Button > Radiobutton > Checkbutton > Canvas > Textbox > Listbox > Menu > Scale > Scrollbar > ...thats all you need in the std library "widget wise". Once IDLE is revised to use some of the widgets in ttk that are not in tk (such as Notebook) the set would need expansion. But the details of any such set are irrelevant to the main problems of replacement. -- Terry Jan Reedy From kw at codebykevin.com Sun Jan 16 13:59:19 2011 From: kw at codebykevin.com (Kevin Walzer) Date: Sun, 16 Jan 2011 13:59:19 -0500 Subject: Tkinter: The good, the bad, and the ugly! In-Reply-To: References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <79a8a$4d332d1a$4275d90a$3986@FUSE.NET> Message-ID: <552a7$4d334005$4275d90a$11458@FUSE.NET> On 1/16/11 1:27 PM, rantingrick wrote: > On Jan 16, 11:39 am, Kevin Walzer wrote: > > First of all welcome back to the discussion Kevin. You and i both > appreciate and use Tkinter extensively and your input is most welcome > here. You are a smart and level headed fella which makes for good > discussion. Thanks for that! Ok, let the battle begin! :-) Glad to be back. > > Wrong. Even with the hodgepodge of third party downloads and extension > packages Tkinter cannot hold a candle to the professional quality of > wxPython. Again i urge you to at least download the demo and see for > yourself. WxPython is a massive library of almost any widget you can > imagine using in the 21st century. All of the hard work has been done > for you, no need to create your own custom widgets again and again. Do > yourself a favor and download the demo. Here it is again... I'm quite familiar with the wxPython demo. I've got the latest incarnation, from 2.9.x, installed on my machine. The latest version is quite nice, especially with the AUI widgets, and the underlying wxWidgets libraries are finally up-to-date on my Mac as they access the Cocoa frameworks, rather than the deprecated Carbon frameworks. However, wxPython does lack some things on my Mac, which I have been able to implement in Tk. Specifically: 1. My Tkinter apps can access the Mac's Services menu, which provides a form of inter-application communication that allows one application to send data to another and have the target application perform some manipulation of that data. wxPython does not support this feature of the Mac. 2. Any wxPython application that attempts to display the filesystem on the Mac looks out-of-place because wx has no support for displaying native icons on the Mac, though it can display them in Windows. Tk on the Mac has a few different ways of displaying icons natively. 3. wxPython applications do not make use of common window flags on the Mac, such as sheets and drawers. Tk provides native support for some of this, and extension packages provide further support. So: while wxPython is quite capable of creating handsome applications, even on the Mac, there are subtle things about wxPython applications that make them feel not quite native, regardless of how rich the overall widget set is. Part of my preference for Tkinter is that, under the hood, Tk is much, much easier to extend than wxWidgets. I have written several libraries in Objective-C, using Tk's C API, that hook into various aspects of native Mac functionality, such as the Services menu. Once this functionality is accessible from Tk, it's trivial to write a Python wrapper for it; it's often as easy as 'root.tk.call', 'nativetclcode here'. As I understand it, extending wxWidgets requires coding in C++, and then you'd need to run your code through SWIG in some fashion to be able to access it from wxPython. In short, there are several more steps, and it's likely more complicated at each step. For various reasons, the things I think are missing from wxWidgets (native icons, sheets/drawers, etc.) are not considered important by the core wxWidget developers, or implementing them is a low priority. > Well we need the license lawyers to weigh in on that aspect. If > wxPythons license is weighed and found wanting then we must consider > something else. However, i will tell you that nothing else exists that > can match the maturity, cross-platform, and feature rich-ness of wx. > If someone knows of any such package by all means speak up! Well, PyQt comes to mind. Qt is better at native Mac implementation than wx in many respects (window flags, accessing native Mac icons), and overall it is a richer framework (its support for WebKit is amazing), but PyQt remains licensed under the GPL, which makes it off-limits for the stdlib. Plus, there are other Python-Qt implementations out there (PySide) that may claim some of PyQt's mindshare in the future. --Kevin -- Kevin Walzer Code by Kevin http://www.codebykevin.com From tomf.sessile at gmail.com Sun Jan 16 14:05:37 2011 From: tomf.sessile at gmail.com (TomF) Date: Sun, 16 Jan 2011 11:05:37 -0800 Subject: examples of realistic multiprocessing usage? Message-ID: <2011011611053732597-tomfsessile@gmailcom> I'm trying to multiprocess my python code to take advantage of multiple cores. I've read the module docs for threading and multiprocessing, and I've done some web searches. All the examples I've found are too simple: the processes take simple inputs and compute a simple value. My problem involves lots of processes, complex data structures, and potentially lots of results. It doesn't map cleanly into a Queue, Pool, Manager or Listener/Client example from the python docs. Instead of explaining my problem and asking for design suggestions, I'll ask: is there a compendium of realistic Python multiprocessing examples somewhere? Or an open source project to look at? Thanks, -Tom From rantingrick at gmail.com Sun Jan 16 14:17:02 2011 From: rantingrick at gmail.com (rantingrick) Date: Sun, 16 Jan 2011 11:17:02 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> Message-ID: <00a62b5b-c1f8-4c54-b416-7f86c0b0ed24@m13g2000yqb.googlegroups.com> On Jan 16, 12:49?pm, Terry Reedy wrote: > Once IDLE is revised to use some of the widgets in ttk that are not in > tk (such as Notebook) the set would need expansion. The IDLE library has had a NoteBook widget for ages. They just choose to call it TabPages instead. And what is a NoteBook exactly? Well a Notebook is a compound widget consisting of a "main frame that holds two sub frames -- which are a "tab" frame and "pages" frame. When any "tab" is clicked the page it is linked to is either *raised-to-the-top- of-the-stack* OR *made-visible* depending on the design. Each "tab" within the "tab frame" is a Radiobutton. Technically you could even consider a RadioButton as a compound widget consisting of a button and a label widget. And one could even dissect further the components of any such widget however we must stop at some point. The widgets i outlined are the highest of the lowest you'd want to consider. I believe compound widgets have no business in the stdlib. When Guido included Tkinter in the stdlib it was mainly for ease of introductory GUI programming to the uninitiaed and for batteries included. However since we do have a "batteries included" mantra we will need to hash out which compound widgets should be included in the stdlib -- at a later time! At this time the discussion needs to focus on defending OR replacing Tkinter with something better. And my position is that we cannot keep lugging around this ancient TclTk library. > But the details of > any such set are irrelevant to the main problems of replacement. Not exactly. Once a library has been chosen we will need to consider a small subset for inclusion in the stdlib and ONE large extension library. So these problems are very relevant -- albeit out of chronological order. From awilliam at whitemice.org Sun Jan 16 14:25:18 2011 From: awilliam at whitemice.org (Adam Tauno Williams) Date: Sun, 16 Jan 2011 14:25:18 -0500 Subject: examples of realistic multiprocessing usage? In-Reply-To: <2011011611053732597-tomfsessile@gmailcom> References: <2011011611053732597-tomfsessile@gmailcom> Message-ID: <1295205918.10561.7.camel@linux-yu4c.site> > Instead of explaining my problem and asking for design suggestions, > I'll ask: is there a compendium of realistic Python multiprocessing > examples somewhere? Not that I've ever seen. > Or an open source project to look at? OpenGroupware Coils uses multiprocessing [in conjunction with AMQ]. From rantingrick at gmail.com Sun Jan 16 14:44:25 2011 From: rantingrick at gmail.com (rantingrick) Date: Sun, 16 Jan 2011 11:44:25 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <79a8a$4d332d1a$4275d90a$3986@FUSE.NET> <552a7$4d334005$4275d90a$11458@FUSE.NET> Message-ID: On Jan 16, 12:59?pm, Kevin Walzer wrote: > I'm quite familiar with the wxPython demo. I've got the latest > incarnation, from 2.9.x, installed on my machine. The latest version is > quite nice, especially with the AUI widgets, and the underlying > wxWidgets libraries are finally up-to-date on my Mac as they access the > Cocoa frameworks, rather than the deprecated Carbon frameworks. Glad to hear that! :) > However, wxPython does lack some things on my Mac, which I have been > able to implement in Tk. Specifically: > > 1. My Tkinter apps can access the Mac's Services menu, which provides a > form of inter-application communication that allows one application to > send data to another and have the target application perform some > manipulation of that data. wxPython does not support this feature of the > Mac. Ok so you're complaining about a "Mac specific" missing functionality? > 2. Any wxPython application that attempts to display the filesystem on > the Mac looks out-of-place because wx has no support for displaying > native icons on the Mac, though it can display them in Windows. ?Tk on > the Mac has a few different ways of displaying icons natively. Ok, even if it looks "out of place" this is another "Mac Specific" problem. > 3. wxPython applications do not make use of common window flags on the > Mac, such as sheets and drawers. Tk provides native support for some of > this, and extension packages provide further support. "Mac Specific" > So: while wxPython is quite capable of creating handsome applications, > even on the Mac, there are subtle things about wxPython applications > that make them feel not quite native, regardless of how rich the overall > widget set is. I think the moral of this story is simple. Mac decided to implement an OS that is completely different from the others. Also as you well know Macs are at the bottom of the stack in terms of popularity. Windows, Unix, Linix, Mac, in that order. Sure you "may" have the most pretentious OS on the planet. However you must accept that with a small user community also comes an equally small developer community. And even if i give these "minor complaints" 100% merit you still only have 0.25% of the market you are representing, so you lose the argument in a big way. Your complaints are but a drop in the proverbial bucket. But don't fret my friend with wxPython in the stdlib i'll bet you could persuade or even help to bring Mac support for these "small" annoyances. > As I understand it, extending wxWidgets requires coding in C++, and then > you'd need to run your code through SWIG in some fashion to be able to > access it from wxPython. In short, there are several more steps, and > it's likely more complicated at each step. ?For various reasons, the > things I think are missing from wxWidgets (native icons, sheets/drawers, > etc.) are not considered important by the core wxWidget developers, or > implementing them is a low priority. Well this is something that you need to attack at the source Kevin. Specifically i mean for you to join the WxWidgets group and start a grassroots movement for better mac support. Barking about a few small "annoyances" with an OS that has a "last ranked" standing is a bit bombastic to say the least. Yes? > Well, PyQt comes to mind. Qt is better at native Mac implementation than > wx in many respects (window flags, accessing native Mac icons), and > overall it is a richer framework (its support for WebKit is amazing), > but PyQt remains licensed under the GPL, which makes it off-limits for > the stdlib. Plus, there are other Python-Qt implementations out there > (PySide) that may claim some of PyQt's mindshare in the future. I am willing to support any GUI library that will move us forward and TclTk is dead weight. I like the feature rich nature of wx however i will consider others if a "compelling" argument is put forward. From joe at goldthwaites.com Sun Jan 16 14:51:04 2011 From: joe at goldthwaites.com (Joe Goldthwaite) Date: Sun, 16 Jan 2011 12:51:04 -0700 Subject: Functions Not Fun (yet)-please help! In-Reply-To: References: Message-ID: <67EB215872114010A58F81DEF27776EB@NewMBP> Hi Kathy, The defaults only get assigned when you leave them out of the list. This will work the way you want by setting b & c to the defaults. print my_func(a) When you try this; a = "testing" b = "defaults" print my_func(a, b, c) You get an undefined error on c. This is because at this point, c has been created but hasn't had anything assigned to it. In other words, you're actually passing the undefined c variable from here into my_func. _____ From: python-list-bounces+joe=goldthwaites.com at python.org [mailto:python-list-bounces+joe=goldthwaites.com at python.org] On Behalf Of Cathy James Sent: Sunday, January 16, 2011 7:49 AM To: python-list at python.org Subject: Functions Not Fun (yet)-please help! Dear all, I can't thank you enough for taking time from your busy schedules to assist me (and others) in my baby steps with Python. Learning about functions now and wondering about some things commented in my code below. Maybe someone can break it down for me and show me why i cant print the function i created. I am using IDLE, saved it as .py def my_func(a, b="b is a default" ,c="c is another default"): print (a) print (b) print (c) #printing the function itself: #1. assign value to a only, b and c as default: a= "testing" print (my_func(a,b,c)) #why does program say c is not defined, tho default in function above? #2. assign a and b only, c is default print my_func(a="testing a", b="testing b") -------------- next part -------------- An HTML attachment was scrubbed... URL: From azeynel1 at gmail.com Sun Jan 16 14:59:11 2011 From: azeynel1 at gmail.com (Zeynel) Date: Sun, 16 Jan 2011 11:59:11 -0800 (PST) Subject: Not clear about the dot notation Message-ID: <2d3e986b-6e6a-477f-a4ba-fe091ff72b8f@i41g2000vbn.googlegroups.com> What does vote.vote refer to in this snippet? def txn(): quote = Quote.get_by_id(quote_id) vote = Vote.get_by_key_name(key_names = user.email(), parent = quote) if vote is None: vote = Vote(key_name = user.email(), parent = quote) if vote.vote == newvote: return quote.votesum = quote.votesum - vote.vote + newvote vote.vote = newvote from here: http://code.google.com/appengine/articles/overheard.html From tomf.sessile at gmail.com Sun Jan 16 15:24:40 2011 From: tomf.sessile at gmail.com (TomF) Date: Sun, 16 Jan 2011 12:24:40 -0800 Subject: Not clear about the dot notation References: <2d3e986b-6e6a-477f-a4ba-fe091ff72b8f@i41g2000vbn.googlegroups.com> Message-ID: <2011011612244047855-tomfsessile@gmailcom> On 2011-01-16 11:59:11 -0800, Zeynel said: > What does vote.vote refer to in this snippet? > > def txn(): > quote = Quote.get_by_id(quote_id) > vote = Vote.get_by_key_name(key_names = user.email(), parent = > quote) > if vote is None: > vote = Vote(key_name = user.email(), parent = quote) > if vote.vote == newvote: > return > quote.votesum = quote.votesum - vote.vote + newvote > vote.vote = newvote > > from here: http://code.google.com/appengine/articles/overheard.html vote refers to the Vote instance. vote.vote refers to the instance variable in that instance: ? ? ? vote: The value of 1 for like, -1 for dislike. Confusing choice of names, in my opinion. -Tom From ian.g.kelly at gmail.com Sun Jan 16 15:26:02 2011 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Sun, 16 Jan 2011 13:26:02 -0700 Subject: Not clear about the dot notation In-Reply-To: <2d3e986b-6e6a-477f-a4ba-fe091ff72b8f@i41g2000vbn.googlegroups.com> References: <2d3e986b-6e6a-477f-a4ba-fe091ff72b8f@i41g2000vbn.googlegroups.com> Message-ID: On 1/16/2011 12:59 PM, Zeynel wrote: > What does vote.vote refer to in this snippet? "vote" is an instance of the Vote class, and "vote.vote" is the value of the "vote" attribute on that instance. In this case, that will be an int. More precisely, "vote.vote" is a value managed by the "vote" descriptor on the "Vote" class, a Google App Engine IntegerProperty. Cheers, Ian From azeynel1 at gmail.com Sun Jan 16 15:44:35 2011 From: azeynel1 at gmail.com (Zeynel) Date: Sun, 16 Jan 2011 12:44:35 -0800 (PST) Subject: Not clear about the dot notation References: <2d3e986b-6e6a-477f-a4ba-fe091ff72b8f@i41g2000vbn.googlegroups.com> <2011011612244047855-tomfsessile@gmailcom> Message-ID: On Jan 16, 3:24?pm, TomF wrote: > vote refers to the Vote instance. So he must have instatiated previously like vote = Vote() is this correct? So I have a model class Item(db.Model): title = db.StringProperty() url = db.StringProperty() date = db.DateTimeProperty(auto_now_add=True) author = db.UserProperty() and to write to the database I do item = Item() item.title = self.request.get("title") item.url = self.request.get("url") item.author = users.get_current_user() item.put() self.redirect("/newest") so his vote.vote is like my item.url ? From philip at semanchuk.com Sun Jan 16 16:22:12 2011 From: philip at semanchuk.com (Philip Semanchuk) Date: Sun, 16 Jan 2011 16:22:12 -0500 Subject: examples of realistic multiprocessing usage? In-Reply-To: <2011011611053732597-tomfsessile@gmailcom> References: <2011011611053732597-tomfsessile@gmailcom> Message-ID: <590FF1A8-55C7-4058-A8C9-AB9CC8B3DFAB@semanchuk.com> On Jan 16, 2011, at 2:05 PM, TomF wrote: > I'm trying to multiprocess my python code to take advantage of multiple cores. I've read the module docs for threading and multiprocessing, and I've done some web searches. All the examples I've found are too simple: the processes take simple inputs and compute a simple value. My problem involves lots of processes, complex data structures, and potentially lots of results. It doesn't map cleanly into a Queue, Pool, Manager or Listener/Client example from the python docs. > > Instead of explaining my problem and asking for design suggestions, I'll ask: is there a compendium of realistic Python multiprocessing examples somewhere? Or an open source project to look at? A colleague pointed me to this project the other day. http://gluino.com/ I grepped through the code to see that it's using multiprocessing.Listener. I didn't go any further than that because our project is BSD licensed and the license for Gluino is unclear. Until I find out whether or not its under an equally permissive license, I can't borrow ideas and/or code from it. Hope it's of some help to you, though. Cheers Philip From tomf.sessile at gmail.com Sun Jan 16 16:34:57 2011 From: tomf.sessile at gmail.com (TomF) Date: Sun, 16 Jan 2011 13:34:57 -0800 Subject: Not clear about the dot notation References: <2d3e986b-6e6a-477f-a4ba-fe091ff72b8f@i41g2000vbn.googlegroups.com> <2011011612244047855-tomfsessile@gmailcom> Message-ID: <2011011613345783108-tomfsessile@gmailcom> On 2011-01-16 12:44:35 -0800, Zeynel said: > On Jan 16, 3:24?pm, TomF wrote: > >> vote refers to the Vote instance. > > So he must have instatiated previously like > > vote = Vote() > > is this correct? Yes. > > So I have a model > > class Item(db.Model): > title = db.StringProperty() > url = db.StringProperty() > date = db.DateTimeProperty(auto_now_add=True) > author = db.UserProperty() > > and to write to the database I do > > item = Item() > item.title = self.request.get("title") > item.url = self.request.get("url") > item.author = users.get_current_user() > item.put() > self.redirect("/newest") > > so his vote.vote is like my item.url ? I believe so. Though you're now talking about an extension to db.Model which looks like it's doing a lot more behind the scenes than a simple variable access. -Tom From rantingrick at gmail.com Sun Jan 16 17:57:36 2011 From: rantingrick at gmail.com (rantingrick) Date: Sun, 16 Jan 2011 14:57:36 -0800 (PST) Subject: Python like lanugages [was Re: After C++, what with Python?] References: <86a904f8-05b0-435f-81d6-7450650f1679@glegroupsg2000goo.googlegroups.com> <4d329899$0$43988$742ec2ed@news.sonic.net> <7x8vylfcvz.fsf@ruckus.brouhaha.com> <4d32c7cf$0$29983$c3e8da3$5496439d@news.astraweb.com> Message-ID: <14ad108e-93d7-41fc-bb42-065f12a062f2@s5g2000yqm.googlegroups.com> On Jan 16, 5:03?am, Tim Harig wrote: > Personally, I think the time is ripe for a language that bridges the > gap between ease of use dynamic languages with the performance and > distribution capabilities of a full systems level language. ? Bravo! > This is after > all the promise the VM based languages made but never really fulfilled. > It is also high time for a fully concurrent language fully capable of > taking advantage of multicore processors without having to deal with the > inherent dangers of threading. Bravissimo!!!!!! > There are several good choices available > for both a even a few that fit both bills; but, few of them have the > support of a company like Google that is capable of the push required > to move the language into the mainstream. Maybe. I have skimmed over Go and while it looks "somewhat" promising i always miss the batteries included and elegant syntax of Python. Of course the language is still young so i hope they plan to invest into it. From steve+comp.lang.python at pearwood.info Sun Jan 16 18:04:35 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 16 Jan 2011 23:04:35 GMT Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> Message-ID: <4d337983$0$29983$c3e8da3$5496439d@news.astraweb.com> On Sun, 16 Jan 2011 07:18:16 -0800, Adam Skutt wrote: [...] I'm afraid I found most of your post hard to interpret, because you didn't give sufficient context for me to understand it. You refer to "his proposed widget set", but with no clue as to who he is, or what the widget set is, or what essential widgets you continue missing. I can guess "he" is rantingrick, but am not sure -- there's only so much of his time-wasting I can read before reaching for the killfile. Rantingrick believes he is doing us a service by haranguing us incessantly into scratching *his* poorly thought-out itches, regardless of practicality or actual need. But putting that aside, I'd like to comment on a few points: [...] > If the situation isn't > the same on your computer then your application usage is highly unusual > or you don't understand what widgets are used to construct your > applications. You've just told me that Python would no longer be > suitable for constructing the majority of GUI applications on the > planet. No, that does not follow. Unless "he" (I'll assume it is rantingrick) has proposed hunting down and destroying all third-party GUI tool sets, what you've been told is that *one specific* tool set is unsuitable for constructing the majority of GUI apps. [...] > Really, if you believe the case to be otherwise, I truly believe you > aren't paying attention to your own computer(s), or don't understand how > the applications you use are constructed. What's out there isn't > interesting, it's what people use that's interesting, and people tend to > use GUIs that are moderately to highly complicated. Well, true, but people tend to *use* the parts of the GUIs that are simple and basic. Not only do the big complicated apps get all the press even when they are actually a niche product (everyone knows about Photoshop, but more people use MS Paint) but it's a truism that most people use something like 20% of the functionality of big, complicated GUI apps. Most people use Microsoft Word or OpenOffice for little more than text editing with formatting. It's easy for power users to overestimate how much of their complicated GUIs are actually used by the average user. Or even the *above* average user. I suspect that a variation of Zipf's Law probably holds for GUI complexity -- if you rank the widgets in order of most to least commonly used, I expect that you'll see actual use drop away rapidly and at an accelerated rate. E.g. the widget in second place might be used roughly half as often as the widget in first place place, the widget in third place one third as often, the widget in fourth place one quarter as often, and so forth. -- Steven From tjreedy at udel.edu Sun Jan 16 18:14:44 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Sun, 16 Jan 2011 18:14:44 -0500 Subject: Tkinter: The good, the bad, and the ugly! In-Reply-To: References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <79a8a$4d332d1a$4275d90a$3986@FUSE.NET> Message-ID: On 1/16/2011 1:27 PM, rantingrick wrote: > least look at the awesome screen shots here... > > http://www.wxpython.org/screenshots.php I did. Well, they say, "Beauty is in the eye of the beholder!". To me, these are mostly awesomely ugly, ugly, ugly. Shot 1: Ugly gray field followed by shot2: ugly black on gray. These first two examples look like Windows 95/8 -- ie, 20th century look, not 21st. Based on this page, wxwidgets would be a regression from tk. Current tkinter on Windows looks like it use native Windows windows. IDLE on WinXP looks like a WinXP app; on Windows 7 it looks like a Windows 7 app. If wxwidgets/wxpython does the same, this page hides it very well. And this is apparently an update from 'the old Screen shots' page. The above is based on presented looks. I have no idea whether, to what extent, and how easily one could duplicate the layout and performance of the examples with tk. There are, however, other problems with wx that I have and will point out in other posts. -- Terry Jan Reedy From askutt at gmail.com Sun Jan 16 18:16:51 2011 From: askutt at gmail.com (Adam Skutt) Date: Sun, 16 Jan 2011 15:16:51 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> Message-ID: On Jan 16, 11:30?am, rantingrick wrote: > Adam your post is so incoherent that i cannot decide if you are FOR or > AGAINST changing the current Tkinter GUI module into a wxPython GUI > module. And this widget set that you keep referring to is a bit vague > also. If you found my post incoherent then you shouldn't be attempting to respond, you should ask me to fucking clarify! Funny how when I ask you technical questions you refuse to respond, but when you find my post incoherent you find plenty of time to attempt to twist my words to support your own mental masturbation. > If you cannot relize that this is exactly what we have now in Tkinter > then you need to go and read the source for Tkinter. Oh hell, i'd > better do it for you. Watch this... As I already told you, if you think that what's contained only in TkInter is relevant or interesting, then you're hopelessly lost. In fact, you're outright trolling. Python's standard library don't only include TkInter so only talking about TkInter is entirely disingenuous. > Now what seems to be missing from my proposed widget set that hampers > you from re-creating every GUI app on your computer? Go download the applications and run them yourself! If you can't figure it out from a visual examination, you lack the competence to bring forward your proposal. Being able to identify what widgets are used to create an application is a fundamental, rudimentary skill. If you lack that skill, you're tacitly calling all of your credibility (not that you haven't already done a fine job of demolishing any assumed credibility on your part) into question. > Ok, Ok, i let out image support but in my mind PIL > should handle all of that. It fundamentally cannot. That's not how image rendering in native widgets works. > There you have it. The same exact widget set we have now. Sure you > cannot re-create every GUI app on your stinking computer however if > you download the 3rd party wxPython extension module not only will you > be able to re-create every GUI app on your stinking computer it will > wipe your backside too! (psst: "it" refers to wxPython) > Again, I've already responded to this in detail, in other postings, posted serious and detailed technical questions, and asked for your clarifications. So instead of posting the same tired, idiotic tripe, why don't you go find those postings, read them, and respond to them? Your refusal and/or inability to do so harms your position immensely. > i hope you learned something from this exercise Adam. I'm not the one who needs to learn anything. Adam From debatem1 at gmail.com Sun Jan 16 18:38:47 2011 From: debatem1 at gmail.com (geremy condra) Date: Sun, 16 Jan 2011 15:38:47 -0800 Subject: [OT] Python like lanugages [was Re: After C++, what with Python?] In-Reply-To: References: <86a904f8-05b0-435f-81d6-7450650f1679@glegroupsg2000goo.googlegroups.com> <4d329899$0$43988$742ec2ed@news.sonic.net> <7x8vylfcvz.fsf@ruckus.brouhaha.com> <4d32c7cf$0$29983$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Sun, Jan 16, 2011 at 3:03 AM, Tim Harig wrote: > On 2011-01-16, Steven D'Aprano wrote: >> If the author thinks that Go is a "tried and true" (his words, not mine) >> language "where programmers can go to look for work", I think he's >> fooling himself. > > No I wouldn't say that it has reached market penetration yet; but, it > has more momentum then any language I am familiar with. ?I wouldn't be > at all surprised to see it becoming quite common in the next five years. I would be very surprised if this were the case. As you point out, languages typically have very long incubation times before they reach any kind of serious market penetration. This seems doubly true for a relatively narrowly targeted language that is in many ways on the wrong side of history. > How long has it taken Python to reach its present level of market > penetration? ?And, I still don't see a huge amount of professional Python > use outside of web developement. ?Go has only been public for less then > a year. Python's very widely used for scripting and related tasks, and has a pretty big user base in academia and the sciences. > Personally, I think the time is ripe for a language that bridges the > gap between ease of use dynamic languages with the performance and > distribution capabilities of a full systems level language. I agree. That does not make Go that language, and many of the choices made during Go's development indicate that they don't think it's that language either. I'm speaking specifically of its non-object model, lack of exceptions, etc. >This is after all the promise the VM based languages made but never > really fulfilled. It is also high time for a fully concurrent language fully > capable of taking advantage of multicore processors without having to > deal with the inherent dangers of threading. ?There are several good > choices available for both a even a few that fit both bills; but, few of > them have the support of a company like Google that is capable of the > push required to move the language into the mainstream. You might be right, but I doubt we'll know one way or the other in the next 5 years. Personally, I'm hoping that functional language use continues to grow. Geremy Condra From kw at codebykevin.com Sun Jan 16 18:41:17 2011 From: kw at codebykevin.com (Kevin Walzer) Date: Sun, 16 Jan 2011 18:41:17 -0500 Subject: Tkinter: The good, the bad, and the ugly! In-Reply-To: References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <79a8a$4d332d1a$4275d90a$3986@FUSE.NET> <552a7$4d334005$4275d90a$11458@FUSE.NET> Message-ID: <7b37f$4d33821c$4275d90a$11538@FUSE.NET> On 1/16/11 2:44 PM, rantingrick wrote: > > Ok so you're complaining about a "Mac specific" missing functionality? Um, yes. > > Ok, even if it looks "out of place" this is another "Mac Specific" > problem. Yes, it sure does. "Mac-specific"=="important." > >> 3. wxPython applications do not make use of common window flags on the >> Mac, such as sheets and drawers. Tk provides native support for some of >> this, and extension packages provide further support. > > "Mac Specific" Ditto. > > > I think the moral of this story is simple. Mac decided to implement an > OS that is completely different from the others. Also as you well know > Macs are at the bottom of the stack in terms of popularity. Windows, > Unix, Linix, Mac, in that order. Sure you "may" have the most > pretentious OS on the planet. However you must accept that with a > small user community also comes an equally small developer community. > And even if i give these "minor complaints" 100% merit you still only > have 0.25% of the market you are representing, so you lose the > argument in a big way. Your complaints are but a drop in the > proverbial bucket. But don't fret my friend with wxPython in the > stdlib i'll bet you could persuade or even help to bring Mac support > for these "small" annoyances. Rick, your statements here are entirely untroubled by facts.:-) First of all, Mac OS X *is* Unix, at least according to The Open Group, which controls the UNIX trademark and is actually in charge of certifying an OS as valid UNIX. Next, in terms of market share, Apple's machines exceeded 10% of the U.S. market (placing them third in shipments behind HP and Dell), and run about 4-5% of the market globally. (See http://bit.ly/cqxl6L.) In any event, it's a bit more than 0.25%. (Actually, according to http://bit.ly/c4PBlm, Linux comes in at around 0.77%, while Mac OS X comes int around 5%.) > > Well this is something that you need to attack at the source Kevin. > Specifically i mean for you to join the WxWidgets group and start a > grassroots movement for better mac support. Barking about a few small > "annoyances" with an OS that has a "last ranked" standing is a bit > bombastic to say the least. Yes? I have commit rights to the Tk core, so it's much easier for me to submit bug fixes and patches there. It's not worth my while to do the same for wxWidgets. --Kevin -- Kevin Walzer Code by Kevin http://www.codebykevin.com From askutt at gmail.com Sun Jan 16 18:41:41 2011 From: askutt at gmail.com (Adam Skutt) Date: Sun, 16 Jan 2011 15:41:41 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <4d337983$0$29983$c3e8da3$5496439d@news.astraweb.com> Message-ID: <044a5101-948d-4458-9c94-57dbb3e25f67@m35g2000vbn.googlegroups.com> On Jan 16, 6:04?pm, Steven D'Aprano wrote: > > If the situation isn't > > the same on your computer then your application usage is highly unusual > > or you don't understand what widgets are used to construct your > > applications. ?You've just told me that Python would no longer be > > suitable for constructing the majority of GUI applications on the > > planet. > > No, that does not follow. Unless "he" (I'll assume it is rantingrick) has > proposed hunting down and destroying all third-party GUI tool sets, what > you've been told is that *one specific* tool set is unsuitable for > constructing the majority of GUI apps. > If you're going to expect me to be that pedantic, then pay me the courtesy of taking the time to find the necessary context. Nevertheless, it's not the least bit unreasonable to address deficiencies in the standard library as deficiencies in the language, like it or not; and since rick's proposal involves regressing the standard library.. > > Really, if you believe the case to be otherwise, I truly believe you > > aren't paying attention to your own computer(s), or don't understand how > > the applications you use are constructed. ?What's out there isn't > > interesting, it's what people use that's interesting, and people tend to > > use GUIs that are moderately to highly complicated. > > Well, true, but people tend to *use* the parts of the GUIs that are > simple and basic. Not only do the big complicated apps get all the press > even when they are actually a niche product (everyone knows about > Photoshop, but more people use MS Paint) but it's a truism that most > people use something like 20% of the functionality of big, complicated > GUI apps. Most people use Microsoft Word or OpenOffice for little more > than text editing with formatting. First, you can't even build MS Paint from Rick's set / the TkInter set alone, so you're already way off mark (even ignoring the ribbon in the latest versions). Second, relevance? If I cannot ship the application with only 20% of the functionality, then your point is meaningless. Plus, look at my list more closely: TweetDeck is really little more than a bunch of listboxes stuck side by side, but we cannot even construct that without replicating what would be considered standard widgets (mostlu layout widgets, but still, that's the hardest stuff to get right and therefore the most important stuff to include). It is not, from a GUI L&F perspective, "complicated". Yet, I still need quite a few widgets in order to assemble it and make it work. And many of those widgets need fairly rich functionality: buttons must support text and images, listboxes must support embedding more than text, text controls must support hyperlinks, the various layout panes must support scrollbars, sizing, and dynamic updates. > I suspect that a variation of Zipf's Law probably holds for GUI > complexity -- if you rank the widgets in order of most to least commonly > used, I expect that you'll see actual use drop away rapidly and at an > accelerated rate. E.g. the widget in second place might be used roughly > half as often as the widget in first place place, the widget in third > place one third as often, the widget in fourth place one quarter as > often, and so forth. Perhaps, but the drop off isn't relevant till we approach well over 30 widgets, at least, quite arguably more (since GUI toolkits include both things that are common, and things that absolutely suck to program, even if they're not used often). Adam From askutt at gmail.com Sun Jan 16 18:54:14 2011 From: askutt at gmail.com (Adam Skutt) Date: Sun, 16 Jan 2011 15:54:14 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <00a62b5b-c1f8-4c54-b416-7f86c0b0ed24@m13g2000yqb.googlegroups.com> Message-ID: On Jan 16, 2:17?pm, rantingrick wrote: > The IDLE library has had a NoteBook widget for ages. They just choose > to call it TabPages instead. And what is a NoteBook exactly? Well a > Notebook is a compound widget consisting of a "main frame that holds > two sub frames -- which are a "tab" frame and "pages" frame. When any > "tab" is clicked the page it is linked to is either *raised-to-the-top- > of-the-stack* OR *made-visible* depending on the design. Each "tab" > within the "tab frame" is a Radiobutton. You need an eye exam if you actually believe what you just wrote. TabLayouts are not just two frames and radiobuttons inside a bigger frame. To even say that is disingenuous and insulting to every human who's ever used one. > I believe compound widgets have no business in the stdlib. All widgets are compound widgets, ergo you believe no widgets should be in the stdlib. Adam From rantingrick at gmail.com Sun Jan 16 18:58:43 2011 From: rantingrick at gmail.com (rantingrick) Date: Sun, 16 Jan 2011 15:58:43 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <79a8a$4d332d1a$4275d90a$3986@FUSE.NET> Message-ID: <64976187-88ad-47c9-9bc6-c0712a657264@j32g2000yqc.googlegroups.com> On Jan 16, 5:14?pm, Terry Reedy wrote: > On 1/16/2011 1:27 PM, rantingrick wrote: > > > least look at the awesome screen shots here... > > > ? ? ?http://www.wxpython.org/screenshots.php > > I did. Well, they say, "Beauty is in the eye of the beholder!". To me, > these are mostly awesomely ugly, ugly, ugly. Shot 1: Ugly gray field > followed by shot2: ugly black on gray. These first two examples look > like Windows 95/8 -- ie, 20th century look, not 21st. Now hold on Terry because you are overreacting just a bit here. If you remember i had requested that everyone download the beautiful demo and only look at the screen shots as a last resort. It seems you went to the screenshots page and went home in a huff. However let's investigate the screen shots with a little more clarity shall we? ######### # Shot1 # ######### This shot shows the most minimal wx GUI, that is, a simple Toplevel window and nothing more. And if you took the time to read the captions above that said... "Here is a screen shot of the "minimal" wxPython application:"... and the screenshot below that said... "Okay, so it is very minimal, but it is small enough that the source should be understandable without somebody holding your hand... Take a peek."... you probably would not have jumped to such bombastic conclusions. ########## # Shot 2 # ########## This shot merely builds on shot one. Nothing fancy. They were not trying to woo you with the most fancy GUI coding available from shot one (psst: THAT IS WHAT THE DEMO IS FOR!). You must remember that screen shots are for inquisitive and possible future users. If you continue to follow along with the shots you'll see the complexity increase with each shot. It seems to me that "easy intoduction" was the focus of the screenshots not "selfish vanity" (psst: THAT IS WHAT THE DEMO IS FOR!) > Based on this page, wxwidgets would be a regression from tk. Yes one might come to that conclusion if they are as shallow as you seem to be behaving Terry. However i urge you to download the wxPython demo and then give me an honest opinion. but only AFTER you have spent at least one hour familiarizing yourself with all the feature richness of this great GUI library. Heck each widget has an overview page, a source code page, and a demo page all wrapped up into a nice GUI. No GUI in the world is this user friendly! Geesh! > Current > tkinter on Windows looks like it use native Windows windows. IDLE on > WinXP looks like a WinXP app; on Windows 7 it looks like a Windows 7 > app. If wxwidgets/wxpython does the same, this page hides it very well. > And this is apparently an update from 'the old Screen shots' page. I'll agree this screenshots page needs an update. However (like me) the wxPython folks probably put more time into the demo and thought that most people would at least download it before jumping to conclusions about the screenshots without sufficient data. Oh, did i give you the demo link. No? Well here it is again... http://www.wxpython.org/download.php#stable > The above is based on presented looks. I have no idea whether, to what > extent, and how easily one could duplicate the layout and performance of > the examples with tk. Tkinter and all of TclTk cannot hold a matchstick to WxPython in feature richness. Anyone who says otherwise is ill-informed! > There are, however, other problems with wx that I > have and will point out in other posts. Please elaborate, these are free and open forums as far as know...? From rantingrick at gmail.com Sun Jan 16 19:12:34 2011 From: rantingrick at gmail.com (rantingrick) Date: Sun, 16 Jan 2011 16:12:34 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> Message-ID: <2778bd04-c2c0-423a-9254-64c547b02fc8@m13g2000yqb.googlegroups.com> On Jan 16, 5:16?pm, Adam Skutt wrote: [...snip: emotionally nonsensical hyperbole...] Adam. Arguing with you is like masturbating with a cheese-grater... slightly amusing, but mostly painful. I don't have the energy to chase my tail like you do. From debatem1 at gmail.com Sun Jan 16 19:59:19 2011 From: debatem1 at gmail.com (geremy condra) Date: Sun, 16 Jan 2011 16:59:19 -0800 Subject: Tkinter: The good, the bad, and the ugly! In-Reply-To: <2778bd04-c2c0-423a-9254-64c547b02fc8@m13g2000yqb.googlegroups.com> References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <2778bd04-c2c0-423a-9254-64c547b02fc8@m13g2000yqb.googlegroups.com> Message-ID: On Sun, Jan 16, 2011 at 4:12 PM, rantingrick wrote: > > I don't have the energy to chase my tail like you do. Hahahahahahahaha. Troll. Geremy Condra From rantingrick at gmail.com Sun Jan 16 20:50:39 2011 From: rantingrick at gmail.com (rantingrick) Date: Sun, 16 Jan 2011 17:50:39 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <2778bd04-c2c0-423a-9254-64c547b02fc8@m13g2000yqb.googlegroups.com> Message-ID: <17eb1e05-d8b9-423c-bcc0-49a5651c4812@f35g2000vbl.googlegroups.com> On Jan 16, 6:59?pm, geremy condra wrote: > Hahahahahahahaha. Troll. Coming from someone who actually gives advice on how to troll more efficiently... now that is ironic! ################################################### # Geremy Condra From: I strongly dislike Python 3 # ################################################### Eh, 3 troll points out of 10. Bonus awarded for the gratuitous sexual reference, but the deductions for lack of finesse more than overcame it. Some suggestions for next time: * use proper punctuation- it lends your posts an air of seriousness. * use the weakest arguments presented- it infuriates those who support the position you're trolling from as well. * overly dramatic statements are a dead giveaway. Hmm. So i take it you are some sort of *expert* on the matter of trolling then? From askutt at gmail.com Sun Jan 16 20:57:17 2011 From: askutt at gmail.com (Adam Skutt) Date: Sun, 16 Jan 2011 17:57:17 -0800 (PST) Subject: examples of realistic multiprocessing usage? References: <2011011611053732597-tomfsessile@gmailcom> Message-ID: <70bc330a-63d7-4162-b21f-4b38257d6c5b@g26g2000vbz.googlegroups.com> On Jan 16, 2:05?pm, TomF wrote: > Instead of explaining my problem and asking for design suggestions, > I'll ask: is there a compendium of realistic Python multiprocessing > examples somewhere? ?Or an open source project to look at? There are tons, but without even a knowledge domain, it's difficult to recommend much of anything. Multiprocessing for I/O (e.g., web serving) tends to look different and be structured differently from multiprocessing for CPU-intensive tasking (e.g., digital signal processing), and both look different from things with specific requirements w.r.t latency (e.g., video game server, hard-real time applications) or other requirements. Even the level at which you parallel process can change things dramatically. Consider the simple case of matrix multiplication. I can make the multiplication itself parallel; or assuming I have multiple sets of matricies I want to multiply (common), I can make execute each multiplication in parallel. Both solutions look different, and a solution that uses both levels of parallelism frequently will look different still. Adam From debatem1 at gmail.com Sun Jan 16 20:59:17 2011 From: debatem1 at gmail.com (geremy condra) Date: Sun, 16 Jan 2011 17:59:17 -0800 Subject: Tkinter: The good, the bad, and the ugly! In-Reply-To: <17eb1e05-d8b9-423c-bcc0-49a5651c4812@f35g2000vbl.googlegroups.com> References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <2778bd04-c2c0-423a-9254-64c547b02fc8@m13g2000yqb.googlegroups.com> <17eb1e05-d8b9-423c-bcc0-49a5651c4812@f35g2000vbl.googlegroups.com> Message-ID: On Sun, Jan 16, 2011 at 5:50 PM, rantingrick wrote: > On Jan 16, 6:59?pm, geremy condra wrote: >> Hahahahahahahaha. Troll. > > > Coming from someone who actually gives advice on how to troll more > efficiently... now that is ironic! > > ################################################### > # Geremy Condra From: I strongly dislike Python 3 # > ################################################### > Eh, 3 troll points out of 10. Bonus awarded for the gratuitous sexual > reference, but the deductions for lack of finesse more than overcame > it. Some suggestions for next time: > ?* use proper punctuation- it lends your posts an air of > seriousness. > ?* use the weakest arguments presented- it infuriates those who > ? ?support the position you're trolling from as well. > ?* overly dramatic statements are a dead giveaway. > > Hmm. So i take it you are some sort of *expert* on the matter of > trolling then? I've read most of your threads, yes. Geremy Condra From drsalists at gmail.com Sun Jan 16 22:16:15 2011 From: drsalists at gmail.com (Dan Stromberg) Date: Sun, 16 Jan 2011 19:16:15 -0800 Subject: examples of realistic multiprocessing usage? In-Reply-To: <2011011611053732597-tomfsessile@gmailcom> References: <2011011611053732597-tomfsessile@gmailcom> Message-ID: On Sun, Jan 16, 2011 at 11:05 AM, TomF wrote: > I'm trying to multiprocess my python code to take advantage of multiple > cores. ?I've read the module docs for threading and multiprocessing, and > I've done some web searches. ?All the examples I've found are too simple: > the processes take simple inputs and compute a simple value. ?My problem > involves lots of processes, complex data structures, and potentially lots of > results. ?It doesn't map cleanly into a Queue, Pool, Manager or > Listener/Client example from the python docs. > > Instead of explaining my problem and asking for design suggestions, I'll > ask: is there a compendium of realistic Python multiprocessing examples > somewhere? ?Or an open source project to look at? I'm unaware of a big archive of projects that use multiprocessing, but maybe one of the free code search engines could help with that. It sounds like you're planning to use mutable shared state, which is generally best avoided if at all possible, in concurrent programming - because mutable shared state tends to slow down things quite a bit. But if you must have mutable shared state that's more complex than a basic scalar or homogeneous array, I believe the multiprocessing module would have you use a "server process manager". From tjreedy at udel.edu Sun Jan 16 22:45:42 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Sun, 16 Jan 2011 22:45:42 -0500 Subject: Tkinter: The good, the bad, and the ugly! In-Reply-To: <64976187-88ad-47c9-9bc6-c0712a657264@j32g2000yqc.googlegroups.com> References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <79a8a$4d332d1a$4275d90a$3986@FUSE.NET> <64976187-88ad-47c9-9bc6-c0712a657264@j32g2000yqc.googlegroups.com> Message-ID: On 1/16/2011 6:58 PM, rantingrick wrote: > On Jan 16, 5:14 pm, Terry Reedy wrote: >> On 1/16/2011 1:27 PM, rantingrick wrote: >> >>> least look at the awesome screen shots here... >> >>> http://www.wxpython.org/screenshots.php >> >> I did. Well, they say, "Beauty is in the eye of the beholder!". To me, >> these are mostly awesomely ugly, ugly, ugly. Shot 1: Ugly gray field >> followed by shot2: ugly black on gray. These first two examples look >> like Windows 95/8 -- ie, 20th century look, not 21st. > > remember i had requested that everyone download the beautiful demo and > only look at the screen shots as a last resort. You called them 'awesome'. I did not expect 'awesomely ugly'. Screenshots are the first thing for someone to look at, to see WHAT THE APP LOOKS LIKE, and to decide whether one wants to bother to download, switch to admin, install, run, and uninstall (and hope that that really disinstalls everything). I looked and decided that what I saw (except for the Mac example), was too ugly to bother with, at least for now. One of the criticisms against tk has been that it is 'ugly' compared to other other guis. Comparing current tk against the screenshots, I saw the reverse. If the screenshots are awesomely unfair to wx, because they are actually 12 years old and RD and the wxpython community cannot be bothered to update them at least to merely 7 years old, that is their fault, not mine for taking them at their presentation. > ######### > # Shot1 # > ######### > This shot shows the most minimal wx GUI, that is, a simple Toplevel > window and nothing more. And to me it is ugly compared to a minimal tk GUI. > ########## > # Shot 2 # > ########## > This shot merely builds on shot one. Nothing fancy. And it is ugly compared to the equivalent tk example. > However i urge you to download the wxPython > demo and then give me an honest opinion. If you think the site is bad, send me a ONE better screenshot, or link thereto, of wx on WinXP/Vista/7. I promise to look at it. Then urge Robin to update the page. But until wx is either a serious contender for the stdlib, or I have personal need of a modern gui system, or I become curious enough about wx, compared to other things I have already downloaded and not looked at, I have little reason to spend more time with it. I already know that some people like wx and swear by it and have even had the vague idea that it somehow should replace tk. > I'll agree this screenshots page needs an update. However (like me) > the wxPython folks probably put more time into the demo and thought If Python developers gave that excuse to not update decade-old examples in the doc, you would probably rant about it for a week;-). Instead, we are updating text and examples as problems are discovered and we can get to them. I improved some years-old text and examples just last week. 3.2 will have hundreds of other improvements. >> There are, however, other problems with wx that I >> have and will point out in other posts. > Please elaborate, these are free and open forums as far as know...? There are two issues: some interface to wxwidgets, and wxpython as that interface or the base therefore. As to wxpython: for starters, it is written in Python2, not Python3. It is owned by Roben Dunn and he has shown no interest that I know of in having it in the stdlib. Given what that would mean in terms of loss of control of interface, code style, docs, release schedule, repository, and so on, I would not either if I had done what he has done. A wxinter written for the stdlib in Python3, possibly based on ctypes rather than swig or the equivalent, might be a stdlib candidate, somewhat independently of the fate of tkinter. But no one has volunteered and you yourself suggested that such are unlikely. -- Terry Jan Reedy From rantingrick at gmail.com Sun Jan 16 23:20:02 2011 From: rantingrick at gmail.com (rantingrick) Date: Sun, 16 Jan 2011 20:20:02 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <79a8a$4d332d1a$4275d90a$3986@FUSE.NET> <64976187-88ad-47c9-9bc6-c0712a657264@j32g2000yqc.googlegroups.com> Message-ID: <3af4fd5e-8cc9-4cec-aad2-cbf82ad3bab3@l24g2000vby.googlegroups.com> On Jan 16, 9:45?pm, Terry Reedy wrote: > You called them 'awesome'. I did not expect 'awesomely ugly'. > Screenshots are the first thing for someone to look at, to see WHAT THE > APP LOOKS LIKE, and to decide whether one wants to bother to download, > switch to admin, install, run, and uninstall (and hope that that really > disinstalls everything). I looked and decided that what I saw (except > for the Mac example), was too ugly to bother with, at least for now. Ok, Ok, i concede. The screenshots are horrendous, atrocious, and utterly reprehensible. I should never had posted a link to such a horrible example of wx. Trust me wx is much more beautiful than that! > One of the criticisms against tk has been that it is 'ugly' compared to > other other guis. Comparing current tk against the screenshots, I saw > the reverse. Ok, but read on because i may be able to convince you with some new screenshots... > If you think the site is bad, send me a ONE better screenshot, or link > thereto, of wx on WinXP/Vista/7. I promise to look at it. Then urge > Robin to update the page. Ok, try this... http://juicereceiver.sourceforge.net/screenshots/index.php and this... http://www.sensi.org/~ak/pyslsk/pyslsk6.png and this (wxWidgets)... http://www.wxwidgets.org/about/screensh.htm > If Python developers gave that excuse to not update decade-old examples > in the doc, you would probably rant about it for a week ;-). Agreed. These horrible screenshots need to be updated yesterday! Or just redirect to the wxwidgets screenshots if they are too lazy. > There are two issues: some interface to wxwidgets, and wxpython as that > interface or the base therefore. > > As to wxpython: for starters, it is written in Python2, not Python3. It > is owned by Roben Dunn and he has shown no interest that I know of in > having it in the stdlib. Given what that would mean in terms of loss of > control of interface, code style, docs, release schedule, repository, > and so on, I would not either if I had done what he has done. Agreed. However we NEED Roben Dunn to keep doing what he is doing now. And we need the people who are investing (maybe wasting) energy on Tkinter to focus on a small subset of wx for stdlib inclusion. Roben can keep his BDFL title, and Python can be updated. From tomf.sessile at gmail.com Sun Jan 16 23:39:51 2011 From: tomf.sessile at gmail.com (TomF) Date: Sun, 16 Jan 2011 20:39:51 -0800 Subject: examples of realistic multiprocessing usage? References: <2011011611053732597-tomfsessile@gmailcom> Message-ID: <2011011620395149614-tomfsessile@gmailcom> On 2011-01-16 19:16:15 -0800, Dan Stromberg said: > On Sun, Jan 16, 2011 at 11:05 AM, TomF wrote: >> I'm trying to multiprocess my python code to take advantage of multiple >> cores. ?I've read the module docs for threading and multiprocessing, and >> I've done some web searches. ?All the examples I've found are too simple: >> the processes take simple inputs and compute a simple value. ?My problem >> involves lots of processes, complex data structures, and potentially lots of >> results. ?It doesn't map cleanly into a Queue, Pool, Manager or >> Listener/Client example from the python docs. >> >> Instead of explaining my problem and asking for design suggestions, I'll >> ask: is there a compendium of realistic Python multiprocessing examples >> somewhere? ?Or an open source project to look at? > > I'm unaware of a big archive of projects that use multiprocessing, but > maybe one of the free code search engines could help with that. > > It sounds like you're planning to use mutable shared state, which is > generally best avoided if at all possible, in concurrent programming - > because mutable shared state tends to slow down things quite a bit. > I'm trying to avoid mutable shared state since I've read the cautions against it. I think it's possible for each worker to compute changes and return them back to the parent (and have the parent coordinate all changes) without too much overhead. So far It looks like multiprocessing.Pool.apply_async is the best match to what I want. One difficulty is that there is a queue of work to be done and a queue of results to be incorporated back into the parent; there is no one-to-one correspondence between the two. It's not obvious to me how to coordinate the queues in a natural way to avoid deadlock or starvation. > > But if you must have mutable shared state that's more complex than a > basic scalar or homogeneous array, I believe the multiprocessing > module would have you use a "server process manager". I've looked into Manager but I don't really understand the trade-offs. -Tom From askutt at gmail.com Sun Jan 16 23:57:41 2011 From: askutt at gmail.com (Adam Skutt) Date: Sun, 16 Jan 2011 20:57:41 -0800 (PST) Subject: examples of realistic multiprocessing usage? References: <2011011611053732597-tomfsessile@gmailcom> <2011011620395149614-tomfsessile@gmailcom> Message-ID: <0ab368a7-0cff-4de5-9527-4f14a70edb3b@v12g2000vbx.googlegroups.com> On Jan 16, 11:39?pm, TomF wrote: > One difficulty is that there is a queue of work to be done and a queue > of results to be incorporated back into the parent; there is no > one-to-one correspondence between the two. ?It's not obvious to me how > to coordinate the queues in a natural way to avoid deadlock or > starvation. > Depends on what you are doing. If you can enqueue all the jobs before waiting for your results, then two queues are adequate. The first queue is jobs to be accomplished, the second queue is the results. The items you put on the result queue have both the result and some sort of id so the results can be ordered after the fact. Your parent thread of execution (thread hereafter) then: 1. Adds jobs to the queue 2. Blocks until all the results are returned. Given that you suggested that there isn't a 1:1 correspondence between jobs and results, have the queue support a message saying, 'Job X is done'. You're finished when all jobs send such a message. 3. Sorts the results into the desired ordered. 4. Acts on them. If you cannot enqueue all the jobs before waiting for the results, I suggest turning the problem into a pipeline, such that the thread submitting the jobs and the thread acting on the results are different: submitter -> job processor -> results processor. Again though, the devil is in the details and without more details, it's hard to suggest an explicit approach. The simplest way to avoid contention between two queues is to just remove it entirely (by converting the processing to a single pipeline like I suggested). If that is not possible, then I suggest moving to pipes (or some other form of I/O based IPC) and asynchronous I/O. But I'd only do that if I really couldn't write a pipeline. Adam From timr at probo.com Mon Jan 17 00:14:59 2011 From: timr at probo.com (Tim Roberts) Date: Sun, 16 Jan 2011 21:14:59 -0800 Subject: Not clear about the dot notation References: <2d3e986b-6e6a-477f-a4ba-fe091ff72b8f@i41g2000vbn.googlegroups.com> <2011011612244047855-tomfsessile@gmailcom> Message-ID: <80k7j6t9jbqvd8t1t9hlueeo05dlfvvvqd@4ax.com> Zeynel wrote: >On Jan 16, 3:24?pm, TomF wrote: > >> vote refers to the Vote instance. > >So he must have instatiated previously like > >vote = Vote() No, it's the line immediately above the one you asked about: if vote is None: vote = Vote(key_name = user.email(), parent = quote) if vote.vote == newvote: return If "vote" is empty, it creates a Vote object and assigns it to "vote". It then checks the "vote" member of that object. >class Item(db.Model): > title = db.StringProperty() > url = db.StringProperty() > date = db.DateTimeProperty(auto_now_add=True) > author = db.UserProperty() > >and to write to the database I do > > item = Item() > item.title = self.request.get("title") > item.url = self.request.get("url") > item.author = users.get_current_user() > item.put() > self.redirect("/newest") > >so his vote.vote is like my item.url ? Exactly. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From hjtoi-better-remove-before-reply at comcast.net Mon Jan 17 00:44:02 2011 From: hjtoi-better-remove-before-reply at comcast.net (Heikki Toivonen) Date: Sun, 16 Jan 2011 21:44:02 -0800 Subject: ANN: M2Crypto 0.21.1 Message-ID: Announcing M2Crypto 0.21.1 Changes: 0.21.1 - 2011-01-15 ------------------- - Distribution fix 0.21 - 2011-01-12 ----------------- - Support OpenSSL 1.0. Thanks to Miloslav Trmac for figuring out how to fix test_smime.py - Rename m2.engine_init to engine_init_error so that ENGINE_init and ENGINE_finish can be exposed, thanks to Erlo - 0.20 started releasing Python locks even around some operations that interacted with the Python runtime, potentially causing crashes and other weirdness, fix by Miloslav Trmac - Make httpslib.ProxyHTTPSConnection work with Python 2.3 M2Crypto is the most complete Python wrapper for OpenSSL featuring RSA, DSA, DH, EC, HMACs, message digests, symmetric ciphers (including AES); SSL functionality to implement clients and servers; HTTPS extensions to Python's httplib, urllib, and xmlrpclib; unforgeable HMAC'ing AuthCookies for web session management; FTP/TLS client and server; S/MIME; ZServerSSL: A HTTPS server for Zope and ZSmime: An S/MIME messenger for Zope. M2Crypto can also be used to provide SSL for Twisted. Smartcards supported through the Engine interface. -- Heikki Toivonen - http://heikkitoivonen.net From tomf.sessile at gmail.com Mon Jan 17 00:44:22 2011 From: tomf.sessile at gmail.com (TomF) Date: Sun, 16 Jan 2011 21:44:22 -0800 Subject: examples of realistic multiprocessing usage? References: <2011011611053732597-tomfsessile@gmailcom> <2011011620395149614-tomfsessile@gmailcom> <0ab368a7-0cff-4de5-9527-4f14a70edb3b@v12g2000vbx.googlegroups.com> Message-ID: <2011011621442275350-tomfsessile@gmailcom> On 2011-01-16 20:57:41 -0800, Adam Skutt said: > On Jan 16, 11:39?pm, TomF wrote: >> One difficulty is that there is a queue of work to be done and a queue >> of results to be incorporated back into the parent; there is no >> one-to-one correspondence between the two. ?It's not obvious to me how >> to coordinate the queues in a natural way to avoid deadlock or >> starvation. >> > > Depends on what you are doing. If you can enqueue all the jobs before > waiting for your results, then two queues are adequate. The first > queue is jobs to be accomplished, the second queue is the results. > The items you put on the result queue have both the result and some > sort of id so the results can be ordered after the fact. Your parent > thread of execution (thread hereafter) then: > > 1. Adds jobs to the queue > 2. Blocks until all the results are returned. Given that you > suggested that there isn't a 1:1 correspondence between jobs and > results, have the queue support a message saying, 'Job X is done'. > You're finished when all jobs send such a message. > 3. Sorts the results into the desired ordered. > 4. Acts on them. > > If you cannot enqueue all the jobs before waiting for the results, I > suggest turning the problem into a pipeline, such that the thread > submitting the jobs and the thread acting on the results are > different: submitter -> job processor -> results processor. > Adam Thanks for your reply. I can enqueue all the jobs before waiting for the results, it's just that I want the parent to process the results as they come back. I don't want the parent to block until all results are returned. I was hoping the Pool module had a test for whether all processes were done, but I guess it isn't hard to keep track of that myself. -Tom From orasnita at gmail.com Mon Jan 17 01:46:58 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Mon, 17 Jan 2011 08:46:58 +0200 Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <4d337983$0$29983$c3e8da3$5496439d@news.astraweb.com> Message-ID: From: "Steven D'Aprano" Sent: Monday, January 17, 2011 1:04 AM Subject: Re: Tkinter: The good, the bad, and the ugly! .... > Well, true, but people tend to *use* the parts of the GUIs that are > simple and basic. Not only do the big complicated apps get all the press > even when they are actually a niche product (everyone knows about > Photoshop, but more people use MS Paint) but it's a truism that most > people use something like 20% of the functionality of big, complicated > GUI apps. Most people use Microsoft Word or OpenOffice for little more > than text editing with formatting. True, but the most important thing is that those apps need to work and these days the portability of programs is also important for making them available to as many people as possible. wxWIDGETS are portable and also pretty accessible for those who need to use screen readers which is not the case of purely native widgets as the Win32 GUI standard controls or the libraries like Tk, GTK or QT. Octavian From no.email at nospam.invalid Mon Jan 17 02:21:49 2011 From: no.email at nospam.invalid (Paul Rubin) Date: Sun, 16 Jan 2011 23:21:49 -0800 Subject: [OT] Python like lanugages References: <86a904f8-05b0-435f-81d6-7450650f1679@glegroupsg2000goo.googlegroups.com> <4d329899$0$43988$742ec2ed@news.sonic.net> <7x8vylfcvz.fsf@ruckus.brouhaha.com> <4d32c7cf$0$29983$c3e8da3$5496439d@news.astraweb.com> Message-ID: <7xipxo9er6.fsf@ruckus.brouhaha.com> geremy condra writes: > I agree. That does not make Go that language, and many of the choices > made during Go's development indicate that they don't think it's that > language either. I'm speaking specifically of its non-object model, > lack of exceptions, etc .... > You might be right, but I doubt we'll know one way or the other in the > next 5 years. Personally, I'm hoping that functional language use > continues to grow. You know, the functional programming community seems to think of OOP as a 1990's thing that didn't work out. Most things that can be done with OOP, can be done with higher-order functions and bounded polymorphism like in Haskell. I'm not sure, but I don't think Erlang has exceptions in the sense we're used to. Someone mentioned Erlang uses a VM, but I think there is a native compiler called HIPE. Of course there is still a fairly substantial runtime system, but that's true of any language with a garbage collector and so forth. Scala seems like an interesting language that is maybe a bit more "practical" than Haskell. I want to try writing something in it. Yes it's JVM-bound but maybe the Java aspects can be decoupled somehow. From howe.steven at gmail.com Mon Jan 17 03:30:28 2011 From: howe.steven at gmail.com (Steven Howe) Date: Mon, 17 Jan 2011 00:30:28 -0800 Subject: Tkinter: Joking? In-Reply-To: References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <4d337983$0$29983$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4D33FE24.3050109@gmail.com> On 01/16/2011 10:46 PM, Octavian Rasnita wrote: > From: "Steven D'Aprano" > Sent: Monday, January 17, 2011 1:04 AM > Subject: Re: Tkinter: The good, the bad, and the ugly! > .... >> Well, true, but people tend to *use* the parts of the GUIs that are >> simple and basic. Not only do the big complicated apps get all the press >> even when they are actually a niche product (everyone knows about >> Photoshop, but more people use MS Paint) but it's a truism that most >> people use something like 20% of the functionality of big, complicated >> GUI apps. Most people use Microsoft Word or OpenOffice for little more >> than text editing with formatting. > > > > True, but the most important thing is that those apps need to work and > these days the portability of programs is also important for making > them available to as many people as possible. > > wxWIDGETS are portable and also pretty accessible for those who need > to use screen readers which is not the case of purely native widgets > as the Win32 GUI standard controls or the libraries like Tk, GTK or QT. > > Octavian > If you are making a product, you want it to be unique and inaccessible to other companies/products. Hence 'propriety'. It's part of that 'capture the market' mindset that engineers and programmers have a problem with. Fight or flight, you have to deal with it. So ... Target your market. Design your software in the Model-View-Controller format. It becomes easy to configure you frontend, your GUI, your web page, if your code is written to separate the work from the glitz. Car companies know this. There is the body design crew, and the engineers that make it work. So software products too. Artists always come first; with good reason, their work catches the eye; remember what Dr. Lecter said "Don't your eyes seek out what you want Clares?". Fighting that fact, for 'efficiency' is just tilting at windmills (or Pontiac Aztec). Instead, think 'optimal' i.e. maximum usage per market. MVC makes that approach reasonable in the first market. Easy in the second (Apple), third (Linux) and fourth (BSD). In the mean time, quit bad mouthing works like Tk/Tcl that have come before the current crop. Their successors too shall pass. Oh, and if your interested, I'm in the third market, been here since 1992. Time and Tide Microsoft, Apple. Time and tide. Steven From list at qtrac.plus.com Mon Jan 17 03:33:42 2011 From: list at qtrac.plus.com (Mark Summerfield) Date: Mon, 17 Jan 2011 08:33:42 +0000 Subject: [python-committers] [RELEASED] Python 3.2 rc 1 In-Reply-To: <4D329F55.9040903@python.org> References: <4D329F55.9040903@python.org> Message-ID: <20110117083342.719d9ab5@dino> Hi Georg, I can't be sure it is a bug, but there is a definite difference of behavior between 3.0/3.1 and 3.2rc1. Given this directory layout: $ ls -R Graphics/ Graphics/: __init__.py Vector Xpm.py Graphics/Vector: __init__.py Svg.py And these files: $ cat Graphics/__init__.py __all__ = ["Xpm"] $ cat Graphics/Xpm.py #!/usr/bin/env python3 XPM = 0 $ cat Graphics/Vector/__init__.py __all__ = ["Svg"] $ cat Graphics/Vector/Svg.py #!/usr/bin/env python3 from ..Graphics import Xpm SVG = 1 I can do the relative import with Python 3.0 and 3.1 but not with 3.2rc1: $ python30 Python 3.0.1 (r301:69556, Jul 15 2010, 10:31:51) [GCC 4.4.4] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> from Graphics.Vector import * >>> Svg.SVG 1 $ python31 Python 3.1.2 (r312:79147, Jul 15 2010, 10:56:05) [GCC 4.4.4] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> from Graphics.Vector import * >>> Svg.SVG 1 $ ~/opt/python32rc1/bin/python3 Python 3.2rc1 (r32rc1:88035, Jan 16 2011, 08:32:59) [GCC 4.4.5] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> from Graphics.Vector import * Traceback (most recent call last): File "", line 1, in File "Graphics/Vector/Svg.py", line 2, in from ..Graphics import Xpm ImportError: No module named Graphics Should I report it as a bug or is this a planned change of behavior (or was the original behavior wrong?). -- Mark Summerfield, Qtrac Ltd, www.qtrac.eu C++, Python, Qt, PyQt - training and consultancy "Advanced Qt Programming" - ISBN 0321635906 http://www.qtrac.eu/aqpbook.html From usernet at ilthio.net Mon Jan 17 04:12:04 2011 From: usernet at ilthio.net (Tim Harig) Date: Mon, 17 Jan 2011 09:12:04 +0000 (UTC) Subject: [OT] Python like lanugages [was Re: After C++, what with Python?] References: <86a904f8-05b0-435f-81d6-7450650f1679@glegroupsg2000goo.googlegroups.com> <4d329899$0$43988$742ec2ed@news.sonic.net> <7x8vylfcvz.fsf@ruckus.brouhaha.com> <4d32c7cf$0$29983$c3e8da3$5496439d@news.astraweb.com> Message-ID: On 2011-01-16, geremy condra wrote: > On Sun, Jan 16, 2011 at 3:03 AM, Tim Harig wrote: >> On 2011-01-16, Steven D'Aprano wrote: >>> If the author thinks that Go is a "tried and true" (his words, not mine) >>> language "where programmers can go to look for work", I think he's >>> fooling himself. >> >> No I wouldn't say that it has reached market penetration yet; but, it >> has more momentum then any language I am familiar with. ?I wouldn't be >> at all surprised to see it becoming quite common in the next five years. > > I would be very surprised if this were the case. As you point out, > languages typically have very long incubation times before they reach > any kind of serious market penetration. This seems doubly true for a > relatively narrowly targeted language that is in many ways on the > wrong side of history. I wouldn't say Go is narrowly targeted. It's a systems language that can compete in the same domain with scripting languages. It is true that most languages have long incubation periods; but, corporate support can change that quite a bit. C#, being backed by Microsoft, managed to go mainstream pretty quickly. >> How long has it taken Python to reach its present level of market >> penetration? ?And, I still don't see a huge amount of professional Python >> use outside of web developement. ?Go has only been public for less then >> a year. > > Python's very widely used for scripting and related tasks, and has a > pretty big user base in academia and the sciences. Python has been widely used by people like us that happen to like the language and found ways to use it in our workplaces; but, most of the time it is an unofficial use that the company. You still don't see many companies doing large scale internal development using Python and you definately don't see any doing external developement using a language that gives the customers full access to the source code. >> Personally, I think the time is ripe for a language that bridges the >> gap between ease of use dynamic languages with the performance and >> distribution capabilities of a full systems level language. > > I agree. That does not make Go that language, and many of the choices > made during Go's development indicate that they don't think it's that > language either. I'm speaking specifically of its non-object model, > lack of exceptions, etc. 1. Go has an object model. What it lacks is an object hierarchy where all object are decended from a single root "object" since it does not support object inheritance as it is used in most languages. In Go we simply adapt an object to meet the needs of the newer object by adding whatever new functionality is needed. 2. Go has a similar mechanism to exceptions, defer/panic/recover. It does downplay >>This is after all the promise the VM based languages made but never >> really fulfilled. It is also high time for a fully concurrent language fully >> capable of taking advantage of multicore processors without having to >> deal with the inherent dangers of threading. ?There are several good >> choices available for both a even a few that fit both bills; but, few of >> them have the support of a company like Google that is capable of the >> push required to move the language into the mainstream. > > You might be right, but I doubt we'll know one way or the other in the > next 5 years. Personally, I'm hoping that functional language use > continues to grow. I personally doubt that purely functional languages will ever make it mainstream. Functional programming has been around for a long time and never really ever managed to break out of academic research. The current interest in functional programming stems merely because some announced that it would be *the* way to utilize multicore computers. Having looked into the space somewhat, there is more hype then substantiation for purely functional concepts. What the hype did do was return attention to SCP style concurrency using actors and MPI and I think that will be the direction taken for concurrent programming into the future. I believe functional programming will make an impact in the mainstream in the form of functionally enabled multiparadigm but not purely functional languages. I think you will see code that uses more functional concepts as guidelines to better code. From usernet at ilthio.net Mon Jan 17 04:34:58 2011 From: usernet at ilthio.net (Tim Harig) Date: Mon, 17 Jan 2011 09:34:58 +0000 (UTC) Subject: [OT] Python like lanugages References: <86a904f8-05b0-435f-81d6-7450650f1679@glegroupsg2000goo.googlegroups.com> <4d329899$0$43988$742ec2ed@news.sonic.net> <7x8vylfcvz.fsf@ruckus.brouhaha.com> <4d32c7cf$0$29983$c3e8da3$5496439d@news.astraweb.com> <7xipxo9er6.fsf@ruckus.brouhaha.com> Message-ID: On 2011-01-17, Paul Rubin wrote: > geremy condra writes: >> I agree. That does not make Go that language, and many of the choices >> made during Go's development indicate that they don't think it's that >> language either. I'm speaking specifically of its non-object model, >> lack of exceptions, etc .... >> You might be right, but I doubt we'll know one way or the other in the >> next 5 years. Personally, I'm hoping that functional language use >> continues to grow. > > You know, the functional programming community seems to think of OOP as > a 1990's thing that didn't work out. Most things that can be done with > OOP, can be done with higher-order functions and bounded polymorphism > like in Haskell. Which is rather interesting because the OOP community had traditionally though of functional programming as a 1960's thing that didn't work out. Functional programming has been around a long time; but, it only regained conciousness outside of academia because of its hyped abilities to make threading easier. Unfortunately for functional programming, much of that ability actually traces back to MPI and the actor model. Using the actor model, it is possible to reap the benefits of easier multiprocessing without using any functional programming concepts. That isn't to say that the injection of functional programming into the mainstream will not have some good affects overall. I expect to see functional programming concepts being incorporated into guidelines for imperative language use. > I'm not sure, but I don't think Erlang has exceptions in the sense we're > used to. Someone mentioned Erlang uses a VM, but I think there is a Erlang has exceptions that look very much like Python exceptions. > native compiler called HIPE. Of course there is still a fairly > substantial runtime system, but that's true of any language with a > garbage collector and so forth. Which is why I say Erlang doesn't compile to a native binary. HIPE has been available through the standard OTP for some time now. HIPE generates native machine OP codes where possible; but, the generated product must still run on the BEAM runtime system. The end result is much faster then Python and often faster then Java with a JIT; but, still doesn't rival C code. It is possible to optimize things quite a bit by integrating with C code; but, then you loose much of the safety provided by Erlang and BEAM. This isn't such a tragedy Erlang as it is for other managed VMs because Erlang/BEAM makes powerful usage of its VM for fault tolerance mechanisms. I don't know of any other VM that allows software upgrades on a running system. From frankcui24 at gmail.com Mon Jan 17 05:01:22 2011 From: frankcui24 at gmail.com (frank cui) Date: Mon, 17 Jan 2011 18:01:22 +0800 Subject: Question on the Module Import Message-ID: Hi all, I'm quite a novice in doing python,and i wish to ask you guys a question on the module import. Say we have a source file called module1.py. What's the difference between the " import module1 " and " from module1 import * " I know that conventionally by coding style, we dont use the second form,but does the first one also reach the same effect ? (importing all the classes and functions and pollute the namespace?) thanks in advance for your answer. Regards, Frank -------------- next part -------------- An HTML attachment was scrubbed... URL: From arndt.roger at addcom.de Mon Jan 17 05:03:22 2011 From: arndt.roger at addcom.de (Arndt Roger Schneider) Date: Mon, 17 Jan 2011 11:03:22 +0100 Subject: [OT] Python like lanugages References: <86a904f8-05b0-435f-81d6-7450650f1679@glegroupsg2000goo.googlegroups.com> <4d329899$0$43988$742ec2ed@news.sonic.net> <7x8vylfcvz.fsf@ruckus.brouhaha.com> <4d32c7cf$0$29983$c3e8da3$5496439d@news.astraweb.com> <7xipxo9er6.fsf@ruckus.brouhaha.com> Message-ID: Tim Harig schrieb: [snip] > > This isn't such a tragedy Erlang as it is for other managed VMs because > Erlang/BEAM makes powerful usage of its VM for fault tolerance mechanisms. I > don't know of any other VM that allows software upgrades on a running system. styx, the distributed operating system inferno, language: limbo. From clp2 at rebertia.com Mon Jan 17 05:25:43 2011 From: clp2 at rebertia.com (Chris Rebert) Date: Mon, 17 Jan 2011 02:25:43 -0800 Subject: Question on the Module Import In-Reply-To: References: Message-ID: On Mon, Jan 17, 2011 at 2:01 AM, frank cui wrote: > Hi all, > > I'm quite a novice in doing python,and i wish to ask you guys a question on > the module import. > > Say we have a source file called module1.py. > > What's the difference between the " import module1 " and " from module1 > import * " > > I know that conventionally by coding style, we dont use the second form,but > does the first one also reach the same effect ? (importing all the classes > and functions and pollute the namespace?) No, not at all. Only the second form pollutes the namespace. The first form *only* imports the name "module1" into your namespace. To access stuff in module1, you then *must* write "module1.foo" etc., explicitly going thru the "module1" name every single time.? The latter form dumps *all* the stuff in module1 into your namespace,? with the name "module1" itself left unbound. To access stuff from module1, you then merely write "foo" etc., and are unable to refer to the module namespace as a whole. By way of example: $ python Python 2.6.6 (r266:84292, Jan 12 2011, 13:35:00) >>> import pickle >>> dir(pickle) # output severely trimmed for convenience/relevance [..., 'dump', 'dumps', 'encode_long', 'format_version', 'load', 'loads', ...] >>> dump Traceback (most recent call last): File "", line 1, in NameError: name 'dump' is not defined >>> pickle.dump >>> pickle Contrast with: $ python Python 2.6.6 (r266:84292, Jan 12 2011, 13:35:00) >>> from pickle import * >>> dump >>> pickle.dump Traceback (most recent call last): File "", line 1, in NameError: name 'pickle' is not defined >>> pickle Traceback (most recent call last): File "", line 1, in NameError: name 'pickle' is not defined ?: Unless you manually alias something to a local name of course, but that's not pedagogically relevant here. ?: Excepting names starting with an underscore. Cheers, Chris -- http://blog.rebertia.com From orsenthil at gmail.com Mon Jan 17 05:31:42 2011 From: orsenthil at gmail.com (Senthil Kumaran) Date: Mon, 17 Jan 2011 16:01:42 +0530 Subject: [Python-Dev] [python-committers] [RELEASED] Python 3.2 rc 1 In-Reply-To: <20110117083342.719d9ab5@dino> References: <4D329F55.9040903@python.org> <20110117083342.719d9ab5@dino> Message-ID: On Mon, Jan 17, 2011 at 2:03 PM, Mark Summerfield wrote: > Hi Georg, > > I can't be sure it is a bug, but there is a definite difference of > behavior between 3.0/3.1 and 3.2rc1. > > I can do the relative import with Python 3.0 and 3.1 but not with > 3.2rc1: Are you sure that the package that you are trying to import is the PYTHONPATH of your system's Python 3.0 and Python 3.1 and Not in RC1? Looks to me a PYTHONPATH problem than a problem with rc1. - I tried to recreate the directory structure that you mentioned and tried from Graphics.Vector import * It failed with ImportError on python3, 3.1 and rc. - Just to test the relative imports, I created a directory structure as mentioned here: http://www.python.org/dev/peps/pep-0328/ and tried to test the relative import for usecase :- from ..moduleA import foo and works fine in rc1. - I also find that your use case (from ..Graphics import XPM in Graphics/Vector/Svg.py) is not one of the listed ones in PEP-0328. -- Senthil From steve+comp.lang.python at pearwood.info Mon Jan 17 06:20:30 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 17 Jan 2011 11:20:30 GMT Subject: [OT] Python like lanugages [was Re: After C++, what with Python?] References: <86a904f8-05b0-435f-81d6-7450650f1679@glegroupsg2000goo.googlegroups.com> <4d329899$0$43988$742ec2ed@news.sonic.net> <7x8vylfcvz.fsf@ruckus.brouhaha.com> <4d32c7cf$0$29983$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4d3425fe$0$29983$c3e8da3$5496439d@news.astraweb.com> On Mon, 17 Jan 2011 09:12:04 +0000, Tim Harig wrote: > Python has been widely used by people like us that happen to like the > language and found ways to use it in our workplaces; but, most of the > time it is an unofficial use that the company. You still don't see many > companies doing large scale internal development using Python and you > definately don't see any doing external developement using a language > that gives the customers full access to the source code. Careful with the FUD there *wink* http://www.python.org/about/quotes/ Sometimes giving access to the source code is a feature, not a bug. Just ask Red Hat. And for those who think otherwise, you can always ship the .pyc files alone. Or turn your software into a web-app. In any case, most companies, and individuals, follow the crowd. They do what everybody else does. There are good reasons for this, as well as bad reasons, but the end result is that most companies' software development is, quite frankly, crap, using the wrong language and the wrong methodology for the wrong reasons. If you doubt this, then perhaps you would like to explain why most software projects fail and those that don't rarely come in on time or on budget? It would probably be crap regardless of what language they used (Sturgeon's Law), but there are degrees of crap. Being optimized for rapid development, at least with Python the average company will develop their crap software five times as quickly and at a third the cost than if they had chosen C++ or Java. You should also consider Paul Graham's essay: http://www.paulgraham.com/avg.html He's hot for Lisp, which is fine, but the lessons hold for Python too. -- Steven From clp2 at rebertia.com Mon Jan 17 06:45:08 2011 From: clp2 at rebertia.com (Chris Rebert) Date: Mon, 17 Jan 2011 03:45:08 -0800 Subject: [OT] Python like lanugages [was Re: After C++, what with Python?] In-Reply-To: References: <86a904f8-05b0-435f-81d6-7450650f1679@glegroupsg2000goo.googlegroups.com> <4d329899$0$43988$742ec2ed@news.sonic.net> <7x8vylfcvz.fsf@ruckus.brouhaha.com> <4d32c7cf$0$29983$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Mon, Jan 17, 2011 at 1:12 AM, Tim Harig wrote: > On 2011-01-16, geremy condra wrote: >> On Sun, Jan 16, 2011 at 3:03 AM, Tim Harig wrote: >>> Personally, I think the time is ripe for a language that bridges the >>> gap between ease of use dynamic languages with the performance and >>> distribution capabilities of a full systems level language. >> >> I agree. That does not make Go that language, and many of the choices >> made during Go's development indicate that they don't think it's that >> language either. I'm speaking specifically of its non-object model, >> lack of exceptions, etc. > > 2. Go has a similar mechanism to exceptions, defer/panic/recover. ?It does > ? ? ? ?downplay > Downplay what exactly? Seems your paragraph got truncated. Cheers, Chris From askutt at gmail.com Mon Jan 17 07:05:36 2011 From: askutt at gmail.com (Adam Skutt) Date: Mon, 17 Jan 2011 04:05:36 -0800 (PST) Subject: examples of realistic multiprocessing usage? References: <2011011611053732597-tomfsessile@gmailcom> <2011011620395149614-tomfsessile@gmailcom> <0ab368a7-0cff-4de5-9527-4f14a70edb3b@v12g2000vbx.googlegroups.com> <2011011621442275350-tomfsessile@gmailcom> Message-ID: On Jan 17, 12:44?am, TomF wrote: > Thanks for your reply. ?I can enqueue all the jobs before waiting for > the results, it's just that I want the parent to process the results as > they come back. ?I don't want the parent to block until all results are > returned. ?I was hoping the Pool module had a test for whether all > processes were done, but I guess it isn't hard to keep track of that > myself. > Regardless of whether it does or doesn't, you don't really want to be blocking in two places anyway, so the "FINISHED" event in the queue is the superior solution. It's certainly possible to build a work pool w/ a queue such that you block on both for entries added to the queue and job completion, but I'm pretty sure it's something you'd have to write yourself. Adam From askutt at gmail.com Mon Jan 17 07:22:12 2011 From: askutt at gmail.com (Adam Skutt) Date: Mon, 17 Jan 2011 04:22:12 -0800 (PST) Subject: Tkinter: Joking? References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <4d337983$0$29983$c3e8da3$5496439d@news.astraweb.com> Message-ID: <8be36c74-d10a-4848-ba69-3b208bb98243@k30g2000vbn.googlegroups.com> On Jan 17, 3:30?am, Steven Howe wrote: > Target your market. Design your software in the Model-View-Controller > format. It becomes easy to configure you frontend, your GUI, your web > page, if your code is written to separate the work from the glitz. > If there were some evidence MVC actually worked, perhaps. Unfortunately, there isn't, so there's little reason to do this. Nevermind that most MVC frameworks get the definitions entirely wrong, despite the plethora of examples from the original paper (e.g., Swing does). > Car companies know this. There is the body design crew, and the > engineers that make it work. No, there really isn't anymore. Integrated teams are the mandatory order of the day, because getting the necessary fuel economy requires paying close attention to body design. Vehicles where the designer runs rampant over the look are getting rarer, and will continue to do so as long as governments continue to tighten fuel economy standards (and to a lesser degree, safety standards). Adam From usernet at ilthio.net Mon Jan 17 07:25:57 2011 From: usernet at ilthio.net (Tim Harig) Date: Mon, 17 Jan 2011 12:25:57 +0000 (UTC) Subject: [OT] Python like lanugages [was Re: After C++, what with Python?] References: <86a904f8-05b0-435f-81d6-7450650f1679@glegroupsg2000goo.googlegroups.com> <4d329899$0$43988$742ec2ed@news.sonic.net> <7x8vylfcvz.fsf@ruckus.brouhaha.com> <4d32c7cf$0$29983$c3e8da3$5496439d@news.astraweb.com> <4d3425fe$0$29983$c3e8da3$5496439d@news.astraweb.com> Message-ID: On 2011-01-17, Steven D'Aprano wrote: > On Mon, 17 Jan 2011 09:12:04 +0000, Tim Harig wrote: > >> Python has been widely used by people like us that happen to like the >> language and found ways to use it in our workplaces; but, most of the >> time it is an unofficial use that the company. You still don't see many >> companies doing large scale internal development using Python and you >> definately don't see any doing external developement using a language >> that gives the customers full access to the source code. > > Careful with the FUD there *wink* This isn't FUD, I am as enthusiastic about Python as anybody here; but, I also have to be realistic about its actual impact in the industry. > http://www.python.org/about/quotes/ There are always success stories; although, many of those are web based companies which, if you will look up the thread, I already excuded from the conversation. However from my experience, a small percentage of people make their primary income from writing non-web based Python software. It certainly hasn't displaced, or even encroached on the primary langauge leaders. > Sometimes giving access to the source code is a feature, not a bug. Just > ask Red Hat. And for those who think otherwise, you can always ship > the .pyc files alone. Or turn your software into a web-app. Red Hat is the big example; but, few other companies actually make substantial profits from FOSS. I am not interested in an idealogy debate about whether exposing your source is good or bad; the fact is that those who fund software developement have a strong preference to choosing closed source. Any software that doesn't provide good methods for closed sourced software is going to suffer. 1. Distributing .pyc files still requires the user to have a Python interpreter. 2. My understanding is that Python bytecode is not guaranteed to be compatible between releases? 3. I have already excluded web apps where Python has a large market penetration (were most of the dynamic languages have found their niche). My point pertains to those areas where Python cannot, or doesn't, compete well with systems level languages and that even for its web niche, it didn't arrive here overnight. There was a long period where it was less likely the Perl to be used for server side web scripting. You can see the recent thread about a web based IDE for what I think about many web applications. > In any case, most companies, and individuals, follow the crowd. They do > what everybody else does. There are good reasons for this, as well as bad > reasons, but the end result is that most companies' software development > is, quite frankly, crap, using the wrong language and the wrong > methodology for the wrong reasons. If you doubt this, then perhaps you People funding software developement really don't care about the quality of the software. They care how much money it will make them. If you really think quality matters, then look at Microsoft's meteoric rise to dominance. Early Microsoft was not known for its superior quality. Only in the last ten years, since they have had to contend with a really poor reputation and competition from their own products have they started to be conserned with writing better software. > methodology for the wrong reasons. If you doubt this, then perhaps you > would like to explain why most software projects fail and those that > don't rarely come in on time or on budget? Yes, lots of projects fail; but, the choice of language is seldom the primary, or even a major contributing reason, for the failure. Python holds the distinction of having had a book written about one such failed project. > It would probably be crap regardless of what language they used > (Sturgeon's Law), but there are degrees of crap. Being optimized for > rapid development, at least with Python the average company will develop > their crap software five times as quickly and at a third the cost than if > they had chosen C++ or Java. If I didn't think Python was a good language, I wouldn't be here. Nevertheless, it isn't a good fit for many pieces of software where a systems language is better suited. Reasons include ease of distribution without an interpeter, non-necessity of distributing source with the product, ability to leverage multiple CPU and multicore systems, and simple sequential performance. Given that Python does't work well in many areas, we could just give up and accept having to write C++ for our day jobs or we can look for a language which bridges the gap between those tasks that require C++'s level of control and those which work well for dynamic languages. Java attempted to do that, and has the market share to show that the concept works, but I think that it missed the mark for many needs. It is still much lower level then Python for purposes of rapid developement and too slow to be competative for non-long-lived tasks. From usernet at ilthio.net Mon Jan 17 07:28:21 2011 From: usernet at ilthio.net (Tim Harig) Date: Mon, 17 Jan 2011 12:28:21 +0000 (UTC) Subject: [OT] Python like lanugages [was Re: After C++, what with Python?] References: <86a904f8-05b0-435f-81d6-7450650f1679@glegroupsg2000goo.googlegroups.com> <4d329899$0$43988$742ec2ed@news.sonic.net> <7x8vylfcvz.fsf@ruckus.brouhaha.com> <4d32c7cf$0$29983$c3e8da3$5496439d@news.astraweb.com> Message-ID: On 2011-01-17, Chris Rebert wrote: > On Mon, Jan 17, 2011 at 1:12 AM, Tim Harig wrote: >> On 2011-01-16, geremy condra wrote: >>> On Sun, Jan 16, 2011 at 3:03 AM, Tim Harig wrote: > >>>> Personally, I think the time is ripe for a language that bridges the >>>> gap between ease of use dynamic languages with the performance and >>>> distribution capabilities of a full systems level language. >>> >>> I agree. That does not make Go that language, and many of the choices >>> made during Go's development indicate that they don't think it's that >>> language either. I'm speaking specifically of its non-object model, >>> lack of exceptions, etc. > >> >> 2. Go has a similar mechanism to exceptions, defer/panic/recover. ?It does >> ? ? ? ?downplay there use for less exceptional conditions in favor of function return values; however, there is nothing preventing you from using them as you see fit to do so. > Downplay what exactly? Seems your paragraph got truncated. Sorry. From askutt at gmail.com Mon Jan 17 08:17:39 2011 From: askutt at gmail.com (Adam Skutt) Date: Mon, 17 Jan 2011 05:17:39 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> Message-ID: <0139798e-dd80-4fc3-a820-f328124b27c1@a10g2000vby.googlegroups.com> On Jan 17, 8:30?am, Albert van der Horst wrote: > We are not talking about running applications, but about writing > applications. Someone has to write the applications I run... > I count 4000+ .py files in my /usr/share alone on Ubuntu. > Your set is totally unrepresentative for those scripts. Yeah, go back and count how many of those actually use a GUI and were not written by Canonical for the purpose of OS configuration (though it'd be especially odd to find them in /usr/_share_). Such a response is entirely and completely disingenuous and borderline insulting. You and rick both need eye exams, apparently. Adam From awilliam at whitemice.org Mon Jan 17 08:27:58 2011 From: awilliam at whitemice.org (Adam Tauno Williams) Date: Mon, 17 Jan 2011 08:27:58 -0500 Subject: examples of realistic multiprocessing usage? In-Reply-To: References: <2011011611053732597-tomfsessile@gmailcom> Message-ID: <1295270878.4082.12.camel@linux-yu4c.site> On Mon, 2011-01-17 at 13:55 +0000, Albert van der Horst wrote: > In article , > Philip Semanchuk wrote: > > >I grepped through the code to see that it's using = > >multiprocessing.Listener. I didn't go any further than that because our = > >project is BSD licensed and the license for Gluino is unclear. Until I = > >find out whether or not its under an equally permissive license, I can't = > >borrow ideas and/or code from it. > You have been brain washed by the Intellectual Properties congsy. > Of course you can read through code to borrow idea's from it. I wouldn't; and there is no brain-washing. It is very unwise to look at GPL'd code if you are working on a non-GPL project; the GPL is specifically and intentionally viral. The distinction between reading-through-code-and-borrowing-ideas and copying-code is thin and best left to lawyers. Aside: Comments to the contrary often stand-on-their-head to make such cases. For example: "You do have a choice under the GPL license: you can stop using the stolen code and write your own, or you can decide you'd rather release under the GPL. But the choice is yours. If you say, I choose neither, then the court can impose an injunction to stop you from further distribution, but it won't order your code released under the GPL. ... Of course, you could avoid all such troubles in the first place by not stealing GPL code to begin with" Seriously? What that basically means is you can't use GPL'd code in a non-GPL'd product/project. Saying if you do it is OK, but you'll be required to replace the code or change your license is standing-on-ones-head. Risking a forced reimplementation of a core component of an existing application is 'just nuts'. From albert at spenarnc.xs4all.nl Mon Jan 17 08:30:18 2011 From: albert at spenarnc.xs4all.nl (Albert van der Horst) Date: 17 Jan 2011 13:30:18 GMT Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> Message-ID: In article , Adam Skutt wrote: >On Jan 14, 5:17=A0pm, Albert van der Horst >wrote: >> >> I really don't follow that. You need a tremendous set to write gimp. >> Obviously you won't write gimp in Python. >> > >You need a tremendous set to write /the majority of the applications >on your computer/. > >On my desktop right now, I have running: >* Google Chrome >* TweetDeck >* PuTTY >* Pidgin >* Game for Windows Launcher >* Free Download Manager >* Steam Client >* A Windows Control Panel Window > >None of those applications could be written with his proposed widget >set, he's literally 0/7 on running applications. If the situation >isn't the same on your computer then your application usage is highly >unusual or you don't understand what widgets are used to construct >your applications. You've just told me that Python would no longer be >suitable for constructing the majority of GUI applications on the >planet. We are not talking about running applications, but about writing applications. I count 4000+ .py files in my /usr/share alone on Ubuntu. Your set is totally unrepresentative for those scripts. >Adam Groetjes Albert -- -- Albert van der Horst, UTRECHT,THE NETHERLANDS Economic growth -- being exponential -- ultimately falters. albert at spe&ar&c.xs4all.nl &=n http://home.hccnet.nl/a.w.m.van.der.horst From albert at spenarnc.xs4all.nl Mon Jan 17 08:37:10 2011 From: albert at spenarnc.xs4all.nl (Albert van der Horst) Date: 17 Jan 2011 13:37:10 GMT Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <4d337983$0$29983$c3e8da3$5496439d@news.astraweb.com> Message-ID: In article <4d337983$0$29983$c3e8da3$5496439d at news.astraweb.com>, Steven D'Aprano wrote: >On Sun, 16 Jan 2011 07:18:16 -0800, Adam Skutt wrote: > >[...] > >I'm afraid I found most of your post hard to interpret, because you >didn't give sufficient context for me to understand it. You refer to "his >proposed widget set", but with no clue as to who he is, or what the >widget set is, or what essential widgets you continue missing. I can >guess "he" is rantingrick, but am not sure -- there's only so much of his >time-wasting I can read before reaching for the killfile. Rantingrick >believes he is doing us a service by haranguing us incessantly into >scratching *his* poorly thought-out itches, regardless of practicality or >actual need. > >But putting that aside, I'd like to comment on a few points: > >[...] >> If the situation isn't >> the same on your computer then your application usage is highly unusual >> or you don't understand what widgets are used to construct your >> applications. You've just told me that Python would no longer be >> suitable for constructing the majority of GUI applications on the >> planet. > >No, that does not follow. Unless "he" (I'll assume it is rantingrick) has >proposed hunting down and destroying all third-party GUI tool sets, what >you've been told is that *one specific* tool set is unsuitable for >constructing the majority of GUI apps. Actually it was me. Those guys don't even know how to attribute or quote. >[...] >> Really, if you believe the case to be otherwise, I truly believe you >> aren't paying attention to your own computer(s), or don't understand how >> the applications you use are constructed. What's out there isn't >> interesting, it's what people use that's interesting, and people tend to >> use GUIs that are moderately to highly complicated. > >Well, true, but people tend to *use* the parts of the GUIs that are >simple and basic. Not only do the big complicated apps get all the press >even when they are actually a niche product (everyone knows about >Photoshop, but more people use MS Paint) but it's a truism that most >people use something like 20% of the functionality of big, complicated >GUI apps. Most people use Microsoft Word or OpenOffice for little more >than text editing with formatting. > >It's easy for power users to overestimate how much of their complicated >GUIs are actually used by the average user. Or even the *above* average >user. Or even for the support of other packages, I gave the bluetooth example. I think the use of Python for e.g. configuration of packages is quite common. > >I suspect that a variation of Zipf's Law probably holds for GUI >complexity -- if you rank the widgets in order of most to least commonly >used, I expect that you'll see actual use drop away rapidly and at an >accelerated rate. E.g. the widget in second place might be used roughly >half as often as the widget in first place place, the widget in third >place one third as often, the widget in fourth place one quarter as >often, and so forth. That is the point I wanted to make. >-- >Steven Groetjes Albert -- -- Albert van der Horst, UTRECHT,THE NETHERLANDS Economic growth -- being exponential -- ultimately falters. albert at spe&ar&c.xs4all.nl &=n http://home.hccnet.nl/a.w.m.van.der.horst From albert at spenarnc.xs4all.nl Mon Jan 17 08:55:35 2011 From: albert at spenarnc.xs4all.nl (Albert van der Horst) Date: 17 Jan 2011 13:55:35 GMT Subject: examples of realistic multiprocessing usage? References: <2011011611053732597-tomfsessile@gmailcom> Message-ID: In article , Philip Semanchuk wrote: >I grepped through the code to see that it's using = >multiprocessing.Listener. I didn't go any further than that because our = >project is BSD licensed and the license for Gluino is unclear. Until I = >find out whether or not its under an equally permissive license, I can't = >borrow ideas and/or code from it. You have been brain washed by the Intellectual Properties congsy. Of course you can read through code to borrow idea's from it. >Hope it's of some help to you, though. > >Cheers >Philip= -- -- Albert van der Horst, UTRECHT,THE NETHERLANDS Economic growth -- being exponential -- ultimately falters. albert at spe&ar&c.xs4all.nl &=n http://home.hccnet.nl/a.w.m.van.der.horst From rdmurray at bitdance.com Mon Jan 17 09:23:39 2011 From: rdmurray at bitdance.com (R. David Murray) Date: Mon, 17 Jan 2011 09:23:39 -0500 Subject: [Python-Dev] [python-committers] [RELEASED] Python 3.2 rc 1 In-Reply-To: <20110117083342.719d9ab5@dino> References: <4D329F55.9040903@python.org> <20110117083342.719d9ab5@dino> Message-ID: <20110117142339.E3D2D24108C@kimball.webabinitio.net> On Mon, 17 Jan 2011 08:33:42 +0000, Mark Summerfield wrote: > from ..Graphics import Xpm > SVG = 1 > > I can do the relative import with Python 3.0 and 3.1 but not with > 3.2rc1: What about 3.1.3? I wonder if it is related to this issue: http://bugs.python.org/issue7902 -- R. David Murray www.bitdance.com From wxjmfauth at gmail.com Mon Jan 17 09:31:00 2011 From: wxjmfauth at gmail.com (jmfauth) Date: Mon, 17 Jan 2011 06:31:00 -0800 (PST) Subject: __pycache__, one more good reason to stck with Python 2? Message-ID: <23e02e0d-b2f1-4b52-85ea-d1feba99dd37@22g2000prx.googlegroups.com> As a scientist using computer tools, and not as a computer scientist, I discovered Python long time ago (it was in its 1.5.6 version) and I remain an happy user up to now date. Yesterday, I was happy to download and test Python 3.2rc1. Python is still this powerful and pleasant language, but... I fall on this cached pyc's directory, __pycache__. Without to many explanations (I think they will be obvious for an end user), one word: a nithtmare. From list at qtrac.plus.com Mon Jan 17 09:33:21 2011 From: list at qtrac.plus.com (Mark Summerfield) Date: Mon, 17 Jan 2011 14:33:21 +0000 Subject: [Python-Dev] [python-committers] [RELEASED] Python 3.2 rc 1 In-Reply-To: <20110117142339.E3D2D24108C@kimball.webabinitio.net> References: <4D329F55.9040903@python.org> <20110117083342.719d9ab5@dino> <20110117142339.E3D2D24108C@kimball.webabinitio.net> Message-ID: <20110117143321.627793c9@dino> On Mon, 17 Jan 2011 09:23:39 -0500 "R. David Murray" wrote: > On Mon, 17 Jan 2011 08:33:42 +0000, Mark Summerfield > wrote: > > from ..Graphics import Xpm > > SVG = 1 > > > > I can do the relative import with Python 3.0 and 3.1 but not with > > 3.2rc1: > > What about 3.1.3? I wonder if it is related to this issue: > > http://bugs.python.org/issue7902 > > -- > R. David Murray www.bitdance.com I'm not sure. Anyway, I have reported it a Georg's suggestion: http://bugs.python.org/issue10926 And mentioned issue7902. -- Mark Summerfield, Qtrac Ltd, www.qtrac.eu C++, Python, Qt, PyQt - training and consultancy "Programming in Python 3" - ISBN 0321680561 http://www.qtrac.eu/py3book.html From brian.curtin at gmail.com Mon Jan 17 09:40:41 2011 From: brian.curtin at gmail.com (Brian Curtin) Date: Mon, 17 Jan 2011 08:40:41 -0600 Subject: __pycache__, one more good reason to stck with Python 2? In-Reply-To: <23e02e0d-b2f1-4b52-85ea-d1feba99dd37@22g2000prx.googlegroups.com> References: <23e02e0d-b2f1-4b52-85ea-d1feba99dd37@22g2000prx.googlegroups.com> Message-ID: On Mon, Jan 17, 2011 at 08:31, jmfauth wrote: > As a scientist using computer tools, and not as a computer > scientist, I discovered Python long time ago (it was in its > 1.5.6 version) and I remain an happy user up to now date. > Yesterday, I was happy to download and test Python 3.2rc1. > Python is still this powerful and pleasant language, but... > > I fall on this cached pyc's directory, __pycache__. Without > to many explanations (I think they will be obvious for an > end user), one word: a nithtmare. What are the specific problems you've seen with __pycache__? Have you read PEP 3147 [0], at least through the rationale section? [0] http://www.python.org/dev/peps/pep-3147/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From leoboiko at gmail.com Mon Jan 17 09:46:22 2011 From: leoboiko at gmail.com (leoboiko) Date: Mon, 17 Jan 2011 06:46:22 -0800 (PST) Subject: python 3 and Unicode line breaking References: <32f75200-b4d8-4ec8-b07d-4740a79c28b6@g26g2000vba.googlegroups.com> <4d2f959a$0$29984$c3e8da3$5496439d@news.astraweb.com> <55c2f7dc-d4d8-4939-85de-41c19c336f23@k25g2000vbl.googlegroups.com> <4d3074b0$0$29984$c3e8da3$5496439d@news.astraweb.com> <4d30c9ba$0$29984$c3e8da3$5496439d@news.astraweb.com> <9b84ec07-0679-4bc6-96ea-b37231d3fd83@b25g2000vbz.googlegroups.com> <4d30f82a$0$29984$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Jan 14, 11:28?pm, Steven D'Aprano wrote: > Does this help? > > http://packages.python.org/kitchen/api-text-display.html Ooh, it doesn?t appear to be a full line-breaking implementation but it certainly helps for what I want to do in my project! Thanks much! (There?s also the alternative of using something like PyICU to access a C library, something I had forgotten about entirely.) Antoine wrote: > If you're willing to help on that matter (or some aspects of them, > textwrap-specific or not), you can open an issue on > http://bugs.python.org and propose a patch. I?m not sure my poor coding is good enough to contribute but I?ll keep this is mind if I find myself implementing the algorithm or wanting to patch textwrap. Thanks. From sherm.pendley at gmail.com Mon Jan 17 10:47:44 2011 From: sherm.pendley at gmail.com (Sherm Pendley) Date: Mon, 17 Jan 2011 10:47:44 -0500 Subject: [OT] Python like lanugages References: <86a904f8-05b0-435f-81d6-7450650f1679@glegroupsg2000goo.googlegroups.com> <4d329899$0$43988$742ec2ed@news.sonic.net> <7x8vylfcvz.fsf@ruckus.brouhaha.com> <4d32c7cf$0$29983$c3e8da3$5496439d@news.astraweb.com> <7xipxo9er6.fsf@ruckus.brouhaha.com> Message-ID: Tim Harig writes: > Functional programming has been around a long time; but, it only regained > conciousness outside of academia because of its hyped abilities to > make threading easier. I believe the widespread use of some functional techniques in JavaScript had a lot to do with that as well. sherm-- -- Sherm Pendley Cocoa Developer From steve+comp.lang.python at pearwood.info Mon Jan 17 10:57:07 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 17 Jan 2011 15:57:07 GMT Subject: __pycache__, one more good reason to stck with Python 2? References: <23e02e0d-b2f1-4b52-85ea-d1feba99dd37@22g2000prx.googlegroups.com> Message-ID: <4d3466d3$0$29983$c3e8da3$5496439d@news.astraweb.com> On Mon, 17 Jan 2011 06:31:00 -0800, jmfauth wrote: > As a scientist using computer tools, and not as a computer scientist, I > discovered Python long time ago (it was in its 1.5.6 version) and I > remain an happy user up to now date. Yesterday, I was happy to download > and test Python 3.2rc1. Python is still this powerful and pleasant > language, but... > > I fall on this cached pyc's directory, __pycache__. Without to many > explanations (I think they will be obvious for an end user), one word: a > nithtmare. No, I'm sorry, they're not obvious at all. I too have been using Python since version 1.5 (although I don't remember the minor point release), and I've also been testing Python 3.2, but I'm afraid I have no idea why you think that __pycache__ is a nightmare. -- Steven From steve+comp.lang.python at pearwood.info Mon Jan 17 11:01:04 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 17 Jan 2011 16:01:04 GMT Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <4d337983$0$29983$c3e8da3$5496439d@news.astraweb.com> <044a5101-948d-4458-9c94-57dbb3e25f67@m35g2000vbn.googlegroups.com> Message-ID: <4d3467bf$0$29983$c3e8da3$5496439d@news.astraweb.com> On Sun, 16 Jan 2011 15:41:41 -0800, Adam Skutt wrote: > If you're going to expect me to be that pedantic, then pay me the > courtesy of taking the time to find the necessary context. Nevertheless, > it's not the least bit unreasonable to address deficiencies in the > standard library as deficiencies in the language, like it or not; I'm afraid that's precisely what I'm arguing you *can't* do -- there's nothing reasonable about equating the standard library with the language. Some languages don't even have a standard library, or for that matter a standard implementation. Would you argue that Python is unsuitable for parsing real-world (i.e. broken) HTML because Beautiful Soup is not in the standard library? That Python is unsuitable for scientific and mathematical processing because Scipy and Numpy aren't in the standard library? That you can't do natural language processing with Python because NLTK is not in the standard library? That you can't do image processing with Python because PIL is a third-party library? There's no doubt that having a good standard library with a rich toolset is a beneficial feature of Python. Python's philosophy of "batteries included" has been one of it's strengths. But it would be absurd to claim that if a tool isn't in the standard library, the language can't do it. > and since rick's proposal involves regressing the standard library.. If you think I'm supporting Rick's incoherent proposal, you've misunderstood me. In any case, I'm not disputing that if you wish to write modern looking, and feeling, GUI apps, you need a powerful widget set, or spend all your time reinventing the wheel. Nevertheless, you can do good, useful work with only a minimal widget set. Back when dinosaurs walked the earth, I wrote GUI apps using an *extremely* limited widget set, equivalent to window, button, text field, and simple bit-mapped graphics -- no menus, no scroll bars, no list boxes, no styled text, and certainly no layout widgets. By today's standards, that's even more primitive than the average web UI, and yet some of the apps written in it were useful and even elegant. (I don't claim credit for the elegant ones, but the ones I wrote were at least useful to me.) You can get surprisingly far with only simple widgets and a bit of ingenuity. Or at least by lowering your expectations. *wink* -- Steven From stefan_ml at behnel.de Mon Jan 17 11:02:00 2011 From: stefan_ml at behnel.de (Stefan Behnel) Date: Mon, 17 Jan 2011 17:02:00 +0100 Subject: [OT] Python like lanugages In-Reply-To: References: <86a904f8-05b0-435f-81d6-7450650f1679@glegroupsg2000goo.googlegroups.com> <4d329899$0$43988$742ec2ed@news.sonic.net> <7x8vylfcvz.fsf@ruckus.brouhaha.com> <4d32c7cf$0$29983$c3e8da3$5496439d@news.astraweb.com> <7xipxo9er6.fsf@ruckus.brouhaha.com> Message-ID: Sherm Pendley, 17.01.2011 16:47: > I believe the widespread use of some functional techniques in JavaScript > had a lot to do with that as well. I doubt that there's really "widespread use" of functional techniques in JavaScript. Such code may be widely deployed, but that doesn't tell anything about the skill level of 'the average' JavaScript developer wrt. functional techniques. Stefan From rantingrick at gmail.com Mon Jan 17 11:02:36 2011 From: rantingrick at gmail.com (rantingrick) Date: Mon, 17 Jan 2011 08:02:36 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <79a8a$4d332d1a$4275d90a$3986@FUSE.NET> <64976187-88ad-47c9-9bc6-c0712a657264@j32g2000yqc.googlegroups.com> <3af4fd5e-8cc9-4cec-aad2-cbf82ad3bab3@l24g2000vby.googlegroups.com> Message-ID: Everyone needs to jump off the troll wagon and come back to reality. We need to get back on topic and compare Tkinter and wxPython by nuts and bolts. We need to make a decision based on facts NOT misconceptions, based on merit NOT prejudice, and finally based on sanity NOT lunacy! ------------------- Tkinter Pros: ------------------- * Very simple to use! * Geometry managers are a delight! ------------------ Tkinter Cons: ------------------ * very limited widget set! * some of the widgets have a asinine API! * very poor packaging of widgets (extensions) * the events where given horrendous names: ButtonRelease-1 -> ButtonOneRelease B1-Motion -> ButtonOneMotion etc * slow execution speed due to calling ANOTHER interpretor! * not extensible within our community! * no real Grid Widget. * no real Listveiw Widget. * not real OpenGL Widget (togl sucks). * the Canvas is lacking manipulators, rotation, etc. ------------------- WxPython Pros: ------------------- * A truly 21st century widget set! * More feature rich than one could ever dream! * Fully instructional, professional, and exhaustive Free Demo! * Up to date OpenGL support ------------------- WxPython Cons ------------------- * Screenshots are outdated * Large library (however we can split it!) * Some people are (w)xenophobic From stefan_ml at behnel.de Mon Jan 17 11:29:10 2011 From: stefan_ml at behnel.de (Stefan Behnel) Date: Mon, 17 Jan 2011 17:29:10 +0100 Subject: [OT] Python like lanugages [was Re: After C++, what with Python?] In-Reply-To: References: <86a904f8-05b0-435f-81d6-7450650f1679@glegroupsg2000goo.googlegroups.com> <4d329899$0$43988$742ec2ed@news.sonic.net> <7x8vylfcvz.fsf@ruckus.brouhaha.com> <4d32c7cf$0$29983$c3e8da3$5496439d@news.astraweb.com> <4d3425fe$0$29983$c3e8da3$5496439d@news.astraweb.com> Message-ID: Tim Harig, 17.01.2011 13:25: > If I didn't think Python was a good language, I wouldn't be here. > Nevertheless, it isn't a good fit for many pieces of software where a > systems language is better suited. Reasons include ease of distribution > without an interpeter, non-necessity of distributing source with the > product, ability to leverage multiple CPU and multicore systems, and > simple sequential performance. > > Given that Python does't work well in many areas, we could just give up > and accept having to write C++ for our day jobs or we can look for a > language which bridges the gap between those tasks that require C++'s > level of control and those which work well for dynamic languages. > Java attempted to do that, and has the market share to show that the > concept works, but I think that it missed the mark for many needs. It is > still much lower level then Python for purposes of rapid developement > and too slow to be competative for non-long-lived tasks. So seriously need to take a look at Cython. http://cython.org Stefan From robin at reportlab.com Mon Jan 17 11:52:23 2011 From: robin at reportlab.com (Robin Becker) Date: Mon, 17 Jan 2011 16:52:23 +0000 Subject: [OT] Python like lanugages In-Reply-To: References: <86a904f8-05b0-435f-81d6-7450650f1679@glegroupsg2000goo.googlegroups.com> <4d329899$0$43988$742ec2ed@news.sonic.net> <7x8vylfcvz.fsf@ruckus.brouhaha.com> <4d32c7cf$0$29983$c3e8da3$5496439d@news.astraweb.com> <7xipxo9er6.fsf@ruckus.brouhaha.com> Message-ID: <4D3473C7.80506@chamonix.reportlab.co.uk> On 17/01/2011 16:02, Stefan Behnel wrote: > Sherm Pendley, 17.01.2011 16:47: >> I believe the widespread use of some functional techniques in JavaScript >> had a lot to do with that as well. > > I doubt that there's really "widespread use" of functional techniques in > JavaScript. Such code may be widely deployed, but that doesn't tell anything > about the skill level of 'the average' JavaScript developer wrt. functional > techniques. > > Stefan > I'm not sure whether this counts as functional, but it certainly not traditional imperative style http://www.vpri.org/pdf/tr2008003_experimenting.pdf it was mentioned in some recent clp thread. -- Robin Becker From robin at reportlab.com Mon Jan 17 11:52:23 2011 From: robin at reportlab.com (Robin Becker) Date: Mon, 17 Jan 2011 16:52:23 +0000 Subject: [OT] Python like lanugages In-Reply-To: References: <86a904f8-05b0-435f-81d6-7450650f1679@glegroupsg2000goo.googlegroups.com> <4d329899$0$43988$742ec2ed@news.sonic.net> <7x8vylfcvz.fsf@ruckus.brouhaha.com> <4d32c7cf$0$29983$c3e8da3$5496439d@news.astraweb.com> <7xipxo9er6.fsf@ruckus.brouhaha.com> Message-ID: <4D3473C7.80506@chamonix.reportlab.co.uk> On 17/01/2011 16:02, Stefan Behnel wrote: > Sherm Pendley, 17.01.2011 16:47: >> I believe the widespread use of some functional techniques in JavaScript >> had a lot to do with that as well. > > I doubt that there's really "widespread use" of functional techniques in > JavaScript. Such code may be widely deployed, but that doesn't tell anything > about the skill level of 'the average' JavaScript developer wrt. functional > techniques. > > Stefan > I'm not sure whether this counts as functional, but it certainly not traditional imperative style http://www.vpri.org/pdf/tr2008003_experimenting.pdf it was mentioned in some recent clp thread. -- Robin Becker From alan at baselinedata.co.uk Mon Jan 17 12:10:15 2011 From: alan at baselinedata.co.uk (Alan Harris-Reid) Date: Mon, 17 Jan 2011 17:10:15 +0000 Subject: Career path - where next? In-Reply-To: References: <4D2DD8BC.1020907@googlemail.com> <4D31F7ED.4040307@baselinedata.co.uk> Message-ID: <4D3477F7.6010309@baselinedata.co.uk> Hi Fred, thanks for the reply. I have already contacted old clients (those that are still in business), but unfortunately they have either gone the 'off the shelf' route (ie. don't use bespoke software any more), or moved-over to .NET, which is a route which I don't want to follow. Still, at least I've let them know what I am doing now and you never know where word-of-mouth may lead. I tried C# for a while, but after Foxpro it appeared to me to be such a horrible, clunky language. Then I discovered Python about a year ago and have loved it ever since. Regards, Alan ------------------------------------------------------------------------ On 17/01/2011 16:13, Sells, Fred wrote: > Since you were burned by Microsoft dropping foxpro, I suspect many > others were also. I would contact all my old clients and see how they > are coping and tell them you've been converting FoxPro to *xyz* and can > help them (assuming of course that you have done some of this). If they > don't have anything, ask them for leads contacts. > > Trying to get a job "cold" is much more difficult than if you have a > referral. -------------- next part -------------- An HTML attachment was scrubbed... URL: From venu.allipuram at gmail.com Mon Jan 17 12:35:30 2011 From: venu.allipuram at gmail.com (Venu) Date: Mon, 17 Jan 2011 09:35:30 -0800 (PST) Subject: Need the list of XML parsers Message-ID: <9f75fdb8-78e3-4675-a48a-64147e0a0095@w29g2000vba.googlegroups.com> Hi, I am getting into serious Python programming for Electronic CAD tools, I am trying to find the best XML parser modules available. I need good searching capability for attributes, nodes and block of XML. I am looking for either a recommendation or previous forum links. Thanks Venu From sudheer.s at sudheer.net Mon Jan 17 12:48:36 2011 From: sudheer.s at sudheer.net (Sudheer Satyanarayana) Date: Mon, 17 Jan 2011 23:18:36 +0530 Subject: Need the list of XML parsers In-Reply-To: <9f75fdb8-78e3-4675-a48a-64147e0a0095@w29g2000vba.googlegroups.com> References: <9f75fdb8-78e3-4675-a48a-64147e0a0095@w29g2000vba.googlegroups.com> Message-ID: <4D3480F4.6070606@sudheer.net> On Monday 17 January 2011 11:05 PM, Venu wrote: > Hi, > > I am getting into serious Python programming for Electronic CAD tools, > I am trying to find the best XML parser modules available. I need good > searching capability for attributes, nodes and block of XML. I am > looking for either a recommendation or previous forum links. > > Thanks > Venu lxml is a good XML parser. It supports xpath and IIRC, xquery. I wrote a blog post about it a while ago - http://techchorus.net/web-scraping-lxml -- With warm regards, Sudheer. S Personal home page - http://sudheer.net | Tech Chorus - http://techchorus.net Web and IT services - http://binaryvibes.co.in From hackingkk at gmail.com Mon Jan 17 12:49:12 2011 From: hackingkk at gmail.com (hackingKK) Date: Mon, 17 Jan 2011 23:19:12 +0530 Subject: Need the list of XML parsers In-Reply-To: <9f75fdb8-78e3-4675-a48a-64147e0a0095@w29g2000vba.googlegroups.com> References: <9f75fdb8-78e3-4675-a48a-64147e0a0095@w29g2000vba.googlegroups.com> Message-ID: <4D348118.9090801@gmail.com> Hi Venu, Use element tree module. This comes with Python itself and does all that you need with presision. I have already used it and it does a very very good job. Happy hacking. Krishnakant. On 17/01/11 23:05, Venu wrote: > Hi, > > I am getting into serious Python programming for Electronic CAD tools, > I am trying to find the best XML parser modules available. I need good > searching capability for attributes, nodes and block of XML. I am > looking for either a recommendation or previous forum links. > > Thanks > Venu > From stefan_ml at behnel.de Mon Jan 17 12:57:13 2011 From: stefan_ml at behnel.de (Stefan Behnel) Date: Mon, 17 Jan 2011 18:57:13 +0100 Subject: Need the list of XML parsers In-Reply-To: <9f75fdb8-78e3-4675-a48a-64147e0a0095@w29g2000vba.googlegroups.com> References: <9f75fdb8-78e3-4675-a48a-64147e0a0095@w29g2000vba.googlegroups.com> Message-ID: Venu, 17.01.2011 18:35: > I am getting into serious Python programming for Electronic CAD tools, > I am trying to find the best XML parser modules available. I need good > searching capability for attributes, nodes and block of XML. I am > looking for either a recommendation or previous forum links. Canonical answers: cElementTree and lxml. The first, if you want to use stdlib tools, the second, if you can afford external dependencies. Both are mostly compatible, very fast and memory friendly. lxml has lots of features in addition. Stefan From wxjmfauth at gmail.com Mon Jan 17 13:17:08 2011 From: wxjmfauth at gmail.com (jmfauth) Date: Mon, 17 Jan 2011 10:17:08 -0800 (PST) Subject: __pycache__, one more good reason to stck with Python 2? References: <23e02e0d-b2f1-4b52-85ea-d1feba99dd37@22g2000prx.googlegroups.com> <4d3466d3$0$29983$c3e8da3$5496439d@news.astraweb.com> Message-ID: <0c62aacd-e6d2-4778-81d6-e06924192add@j1g2000vbl.googlegroups.com> > No, I'm sorry, they're not obvious at all. These reasons become obious as soon as you start working. Let's take a practical point view. It did not take a long time to understand, that it is much simpler to delete the __pycache__ directory everytime I compile my scripts than to visit it just because I deleted or renamed a .py file in my working directory. How long will it take to find on the web tools to parse and delete ophan .pyc files on a hd? If I get (stupidly, I agree) a .pyc file and want to test it. Should I create manually a cache alongside my test.py script? If I wish to delete the numerous auxiliary files a TeX document produces, I just del /rm .* to keep a clean working dir. With Python now? Impossible! The files are spread in two dirs (at least). ... That's life, unfortunately. From orasnita at gmail.com Mon Jan 17 13:27:38 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Mon, 17 Jan 2011 20:27:38 +0200 Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com><4d337983$0$29983$c3e8da3$5496439d@news.astraweb.com><044a5101-948d-4458-9c94-57dbb3e25f67@m35g2000vbn.googlegroups.com> <4d3467bf$0$29983$c3e8da3$5496439d@news.astraweb.com> Message-ID: From: "Steven D'Aprano" Subject: Re: Tkinter: The good, the bad, and the ugly! > On Sun, 16 Jan 2011 15:41:41 -0800, Adam Skutt wrote: > >> If you're going to expect me to be that pedantic, then pay me the >> courtesy of taking the time to find the necessary context. Nevertheless, >> it's not the least bit unreasonable to address deficiencies in the >> standard library as deficiencies in the language, like it or not; > > I'm afraid that's precisely what I'm arguing you *can't* do -- there's > nothing reasonable about equating the standard library with the language. > Some languages don't even have a standard library, or for that matter a > standard implementation. > > Would you argue that Python is unsuitable for parsing real-world (i.e. > broken) HTML because Beautiful Soup is not in the standard library? That > Python is unsuitable for scientific and mathematical processing because > Scipy and Numpy aren't in the standard library? That you can't do natural > language processing with Python because NLTK is not in the standard > library? That you can't do image processing with Python because PIL is a > third-party library? > > There's no doubt that having a good standard library with a rich toolset > is a beneficial feature of Python. Python's philosophy of "batteries > included" has been one of it's strengths. But it would be absurd to claim > that if a tool isn't in the standard library, the language can't do it. Well, you are right, but it is not the same thing. If Tkinter is included by default in Python package, much more programmers would be tempted to use Tkinter instead of WxPython, so they will create bad programs. The best idea would be to include WxPython in Python and eliminate Tkinter. If this is not possible, because of those reasons that were discussed here, then the second-best idea would be to just eliminate Tkinter from Python, because as you said, if it is not included, it doesn't mean that a module can't be used, but in that case the programmers won't be tempted to use it. And Python should also not include any editor because for some programmers it is absolutely useless anyway. The editor can be installed separately very easy and the programmers can choose the editor they like. The problem is not that WxPython is not encouraged, but that Tkinter is encouraged because it is promoted. Octavian From jsmithfield at hotmail.co.uk Mon Jan 17 13:34:13 2011 From: jsmithfield at hotmail.co.uk (J Smithfield) Date: Mon, 17 Jan 2011 18:34:13 +0000 Subject: FW: Entry of Non-European (Unicode or UTF-8) characters In-Reply-To: References: Message-ID: From: jsmithfield at hotmail.co.uk To: wiki at python.org Subject: Entry of Non-European (Unicode or UTF-8) characters Date: Mon, 17 Jan 2011 18:26:36 +0000 Hi there. I have difficulty entering directly non-European Unicode characters into Python 3.2's interpreter. When I do enter them, I get "????"; pastinf is OK though, but who wants to paste all the time? I use Python 3 on Windows XP and Vista. The same problem was experienced on other developement systems, but most have since corrected the problem: Python should not be the last to do so! J -------------- next part -------------- An HTML attachment was scrubbed... URL: From rantingrick at gmail.com Mon Jan 17 13:53:17 2011 From: rantingrick at gmail.com (rantingrick) Date: Mon, 17 Jan 2011 10:53:17 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com><4d337983$0$29983$c3e8da3$5496439d@news.astraweb.com><044a5101-948d-4458-9c94-57dbb3e25f67@m35g2000vbn.googlegroups.com> <4d3467bf$0$29983$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Jan 17, 12:27?pm, "Octavian Rasnita" wrote: > And Python should also not include any editor because for > some programmers it is absolutely useless anyway. The > editor can be installed separately very easy and the > programmers can choose the editor they like. The problem > is not that WxPython is not encouraged, but that Tkinter > is encouraged because it is promoted. These are very true statements Octavian! I had always believed that Python should include a GUI AND and IDE even though Tkinter and IDLE are severely dated. Now i am thinking that maybe we should judt dump both and leave it that way. Why did i previously think this way? Well my concern was to keep the goals of GvR alive. That is that programming should be for everyone and having a simplistic IDE and GUI in the stdlib help foster these goals. However that was circa 1980's and we now find our selfs a decade past the 21st century. We now have a huge amount of 3rd party GUI's and IDE's. Do we even need to include them any more? Sure one could always argue batteries included however with the plethera of 3rd party downloads, the batteries may not be included, but they are located witin reach at the reqister check out Q. Do we need ANY GUI or ANY IDE in the stdlib anymore? I say probably not considering the availability of 3rd party downloads. What say you, Python community? From alexlbasso at gmail.com Mon Jan 17 14:08:52 2011 From: alexlbasso at gmail.com (AlexLBasso) Date: Mon, 17 Jan 2011 11:08:52 -0800 (PST) Subject: 9 Month Python contract in Austin, TX Message-ID: I am recruiting for a 9 month contract (with contract extension potential) for a company in North Austin. I am seeking an Applications Developer very familiar with the JavaScript toolkit. The position requires specific experience with Python, Dojo, and JQuery. In this role, you would be developing front-end applications for the management and configuration of IPS systems. If you (or someone you know) is interested in this opportunity, please contact me at 512.257.7903 or abasso at aerotek.com From rantingrick at gmail.com Mon Jan 17 14:15:12 2011 From: rantingrick at gmail.com (rantingrick) Date: Mon, 17 Jan 2011 11:15:12 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com><4d337983$0$29983$c3e8da3$5496439d@news.astraweb.com><044a5101-948d-4458-9c94-57dbb3e25f67@m35g2000vbn.googlegroups.com> <4d3467bf$0$29983$c3e8da3$5496439d@news.astraweb.com> Message-ID: More post thoughts on removing all GUI's from stdlib... This change would not only affect Python in a positive way (lighting the proverbial load) it would also serve to speed the advancement of Tkinter because now Tkinter could advance at its own pace untethered by the release cycles of Python! You guys need to start thinking about this from a purley community perspective. From askutt at gmail.com Mon Jan 17 14:26:15 2011 From: askutt at gmail.com (Adam Skutt) Date: Mon, 17 Jan 2011 11:26:15 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <4d337983$0$29983$c3e8da3$5496439d@news.astraweb.com> <044a5101-948d-4458-9c94-57dbb3e25f67@m35g2000vbn.googlegroups.com> <4d3467bf$0$29983$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Jan 17, 11:01?am, Steven D'Aprano wrote: > > I'm afraid that's precisely what I'm arguing you *can't* do -- there's > nothing reasonable about equating the standard library with the language. > Some languages don't even have a standard library, or for that matter a > standard implementation. And we're not discussing those languages, we're discussing Python, which has an explicit policy of "batteries included". As such, criticism of the standard library is perfectly acceptable under the name "Python", whether you like it or not. Besides, it's inevitable anyway. > Would you argue that Python is unsuitable for parsing real-world (i.e. > broken) HTML because Beautiful Soup is not in the standard library? That > Python is unsuitable for scientific and mathematical processing because > Scipy and Numpy aren't in the standard library? That you can't do natural > language processing with Python because NLTK is not in the standard > library? That you can't do image processing with Python because PIL is a > third-party library? > Out of the box? Absolutely. Again, expecting me to explicitly state that is worthless pedantry, especially when the discussion at hand proposes modifications to the standard library. There's no question, in context, about what my words meant. > There's no doubt that having a good standard library with a rich toolset > is a beneficial feature of Python. Python's philosophy of "batteries > included" has been one of it's strengths. But it would be absurd to claim > that if a tool isn't in the standard library, the language can't do it. > Too bad that isn't what I claimed, nor can what I said be interpreted as such in any way whatsoever, unless you're a pedantic twit. > > and since rick's proposal involves regressing the standard library.. > > If you think I'm supporting Rick's incoherent proposal, you've > misunderstood me. > If you think what I said somehow even implies you support his proposal, then you need to take a few English courses. > Nevertheless, you can do good, useful work > with only a minimal widget set. Back when dinosaurs walked the earth, I > wrote GUI apps using an *extremely* limited widget set, equivalent to > window, button, text field, and simple bit-mapped graphics -- no menus, > no scroll bars, no list boxes, no styled text, and certainly no layout > widgets. By today's standards, that's even more primitive than the > average web UI, and yet some of the apps written in it were useful and > even elegant. (I don't claim credit for the elegant ones, but the ones I > wrote were at least useful to me.) You can get surprisingly far with only > simple widgets and a bit of ingenuity. Or at least by lowering your > expectations. *wink* And when a time machine warps all back to the 1980s, that argument might have some merit. Since you're not Dr. Emmett Brown, I suggest you refrain from making arguments that predicate themselves on time travel. Adam From debatem1 at gmail.com Mon Jan 17 14:35:39 2011 From: debatem1 at gmail.com (geremy condra) Date: Mon, 17 Jan 2011 11:35:39 -0800 Subject: [OT] Python like lanugages [was Re: After C++, what with Python?] In-Reply-To: References: <86a904f8-05b0-435f-81d6-7450650f1679@glegroupsg2000goo.googlegroups.com> <4d329899$0$43988$742ec2ed@news.sonic.net> <7x8vylfcvz.fsf@ruckus.brouhaha.com> <4d32c7cf$0$29983$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Mon, Jan 17, 2011 at 1:12 AM, Tim Harig wrote: > On 2011-01-16, geremy condra wrote: >> On Sun, Jan 16, 2011 at 3:03 AM, Tim Harig wrote: >>> On 2011-01-16, Steven D'Aprano wrote: >>>> If the author thinks that Go is a "tried and true" (his words, not mine) >>>> language "where programmers can go to look for work", I think he's >>>> fooling himself. >>> >>> No I wouldn't say that it has reached market penetration yet; but, it >>> has more momentum then any language I am familiar with. ?I wouldn't be >>> at all surprised to see it becoming quite common in the next five years. >> >> I would be very surprised if this were the case. As you point out, >> languages typically have very long incubation times before they reach >> any kind of serious market penetration. This seems doubly true for a >> relatively narrowly targeted language that is in many ways on the >> wrong side of history. > > I wouldn't say Go is narrowly targeted. ?It's a systems language that can > compete in the same domain with scripting languages. ?It is true that most > languages have long incubation periods; but, corporate support can change > that quite a bit. ?C#, being backed by Microsoft, managed to go mainstream > pretty quickly. This seems... shall we say, overly optimistic. I've seen no evidence at all that Go is even trying to compete with scripting languages, and I don't know of anyone who would actually use it where a shell script might do. AFAICS, it is an unabashedly concurrency-centric systems language for people who are willing to sacrifice some speed and control for legible code. That's not an impossibly narrow niche (and it certainly has deep pockets) but it *is* narrow compared to a general purpose language like Java or Python. I'd also note that the .NET languages received much, much more in the way of support than Go seems to be. >>> How long has it taken Python to reach its present level of market >>> penetration? ?And, I still don't see a huge amount of professional Python >>> use outside of web developement. ?Go has only been public for less then >>> a year. >> >> Python's very widely used for scripting and related tasks, and has a >> pretty big user base in academia and the sciences. > > Python has been widely used by people like us that happen to like the > language and found ways to use it in our workplaces; but, most of the > time it is an unofficial use that the company. ?You still don't see many > companies doing large scale internal development using Python and you > definately don't see any doing external developement using a language > that gives the customers full access to the source code. Right, I mean, it's not like the company that wrote Go would *ever* stoop to using Python ;) Seriously, I see a lot of Python in use in the sciences, HPC, etc. It's also a major part of nearly every linux distro, is widely used by defense and intelligence contractors for what they consider to be critical infrastructure, etc etc etc. Even if none of that were true though, the fact is that you can be a successful language and only deal with the web, and even you admit that Python is widely used in that context. >>> Personally, I think the time is ripe for a language that bridges the >>> gap between ease of use dynamic languages with the performance and >>> distribution capabilities of a full systems level language. >> >> I agree. That does not make Go that language, and many of the choices >> made during Go's development indicate that they don't think it's that >> language either. I'm speaking specifically of its non-object model, >> lack of exceptions, etc. > > 1. Go has an object model. ?What it lacks is an object hierarchy where all > ? ? ? ?object are decended from a single root "object" since it does > ? ? ? ?not support object inheritance as it is used in most languages. > ? ? ? ?In Go we simply adapt an object to meet the needs of the newer > ? ? ? ?object by adding whatever new functionality is needed. Go has structs. Its structs are not objects, principally because they can't do real inheritance. You can do similar things ('structural inheritance') to C structs, and nobody argues that C is OO. > 2. Go has a similar mechanism to exceptions, defer/panic/recover. ?It does > ? ? ? ?downplay Defer, panic, and recover only allow you to build a recovery stack. That's like saying that try/except isn't needed anymore because you have the with statement. Do you think you could get through a rewrite of Django without ripping out some hair over that? >>>This is after all the promise the VM based languages made but never >>> really fulfilled. It is also high time for a fully concurrent language fully >>> capable of taking advantage of multicore processors without having to >>> deal with the inherent dangers of threading. ?There are several good >>> choices available for both a even a few that fit both bills; but, few of >>> them have the support of a company like Google that is capable of the >>> push required to move the language into the mainstream. >> >> You might be right, but I doubt we'll know one way or the other in the >> next 5 years. Personally, I'm hoping that functional language use >> continues to grow. > > I personally doubt that purely functional languages will ever make it > mainstream. ?Functional programming has been around for a long time and > never really ever managed to break out of academic research. I doubt it as well. Doesn't mean I can't hope for it- I would really like to see something a little more readable out of that community, a kind of hybrid between haskell's writability and python's readability. > The current > interest in functional programming stems merely because some announced > that it would be *the* way to utilize multicore computers. ?Having looked > into the space somewhat, there is more hype then substantiation for > purely functional concepts. ?What the hype did do was return attention > to SCP style concurrency using actors and MPI and I think that will be > the direction taken for concurrent programming into the future. I'm not an expert in concurrency and can't evaluate the claims many are making in that space. I know that I still find writing highly parallel programs easier in C and Python than I do in Haskell, but I seldom wind up thinking that concurrency was the hard part of the problem I was solving. > I believe functional programming will make an impact in the mainstream in > the form of functionally enabled multiparadigm but not purely functional > languages. ?I think you will see code that uses more functional concepts > as guidelines to better code. Ditto. Geremy Condra From rantingrick at gmail.com Mon Jan 17 14:39:11 2011 From: rantingrick at gmail.com (rantingrick) Date: Mon, 17 Jan 2011 11:39:11 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com><4d337983$0$29983$c3e8da3$5496439d@news.astraweb.com><044a5101-948d-4458-9c94-57dbb3e25f67@m35g2000vbn.googlegroups.com> <4d3467bf$0$29983$c3e8da3$5496439d@news.astraweb.com> Message-ID: <0947517d-a2c4-44af-83cb-8ed4299b143a@k25g2000vbl.googlegroups.com> Even more post thoughts on removing all GUI's from stlib... Q: If you could replace Tkinter with any module/library (THAT IS NOT A GUI OR IDE!!) what would you like to see fill its place? PS: And please make this decision from a *community* perspective and not pure selfishness. From usernet at ilthio.net Mon Jan 17 14:41:54 2011 From: usernet at ilthio.net (Tim Harig) Date: Mon, 17 Jan 2011 19:41:54 +0000 (UTC) Subject: [OT] Python like lanugages [was Re: After C++, what with Python?] References: <86a904f8-05b0-435f-81d6-7450650f1679@glegroupsg2000goo.googlegroups.com> <4d329899$0$43988$742ec2ed@news.sonic.net> <7x8vylfcvz.fsf@ruckus.brouhaha.com> <4d32c7cf$0$29983$c3e8da3$5496439d@news.astraweb.com> <4d3425fe$0$29983$c3e8da3$5496439d@news.astraweb.com> Message-ID: In comp.lang.python, you wrote: > Tim Harig, 17.01.2011 13:25: >> If I didn't think Python was a good language, I wouldn't be here. >> Nevertheless, it isn't a good fit for many pieces of software where a >> systems language is better suited. Reasons include ease of distribution >> without an interpeter, non-necessity of distributing source with the >> product, ability to leverage multiple CPU and multicore systems, and >> simple sequential performance. >> >> Given that Python does't work well in many areas, we could just give up >> and accept having to write C++ for our day jobs or we can look for a >> language which bridges the gap between those tasks that require C++'s >> level of control and those which work well for dynamic languages. >> Java attempted to do that, and has the market share to show that the >> concept works, but I think that it missed the mark for many needs. It is >> still much lower level then Python for purposes of rapid developement >> and too slow to be competative for non-long-lived tasks. > > So seriously need to take a look at Cython. > > http://cython.org One of the arguments for Python has always made is that you can optimize it by writing the most important parts in C. Perhaps that is a crutch that has held the communty back from seeking higher performance solutions in the language itself. I prefer a single language as opposed to a creolization of two. Go gives me more less complete independence from C. I can write pretty much anything I would like using almost pure Go and because it generates a native binary with similar performance to C, I don't need to resort to using another language. I certainly don't need to require anybody who wants to use a program I have compiled to install an interpreter. From vishal2295 at gmail.com Mon Jan 17 14:43:56 2011 From: vishal2295 at gmail.com (vishal kumar rai) Date: Mon, 17 Jan 2011 11:43:56 -0800 (PST) Subject: CodeFest - Online Coding Festival by Computer Engineering Society, IT-BHU Message-ID: Hello, We are delighted to inform you that CodeFest, the annual International online coding festival of Computer Engineering Society, IT-BHU, has been unveiled. CodeFest is a unique fest wherein concepts of mathematics, logic, artificial intelligence, algorithms, language syntax, etc. are required to be deployed in programming; these concepts manifest themselves in solving problems effectively and efficiently! CodeFest was started last year. CodeFest'10 was a phenomenal success with participation from all over the globe. CodeFest'11 is geared up with some new and pepped up events, while maintaining the integrity of its standards. Here is a brief description of the constituent online events: * Mathmania: A mathematical puzzle contest that puts mathematical and computational skills to test. * Manthan: An algorithm intensive programming contest that would require coders to tailor existing standard algorithms to solve real life computation problems. * Virtual Combat: An educational game wherein teams of programmed robotic tanks will fight the battles for glory. Codes Do Fight! Watch this out. * Perplexed: A programming contest, aimed to test the knowledge of C, wherein codes will be rewarded against syntactic constraints. * Ratespiel: A technical quiz covering different areas of Computer Science. This year CodeFest, in association with Technex'11, brings onsite events: * Eniac: An open software exhibition where you get an opportunity to demonstrate your software from any domain. * Code Warrior: A multiple round contest to award the title of 'ultimate computer geek'. Visit our website to get more details. Few exciting statistics about CodeFest'10: * 2354 registrations (including 128 professionals) from 680 different institutions, across 59 countries. * Some participants were among the winners of Google Code Jam, Top Coder SRMs and ACM ICPC. * Total prize money was a whopping amount of 260,000 INR! * CodeFest '10 was the largest online coding festival of the Indian subcontinent in 2010 in terms of prize money! * CodeFest'10 was the second largest online coding festival of the Indian subcontinent in 2010, next to Bitwise. * Gained recognition from several international organizations including Codechef, Adobe, British Telecom, TCS and IEEE. The CodeFest'11 team has set out to unleash a coding extravaganza. You can't afford to miss the chance to be a part of this fest! Still have any questions? Feel free to contact us at codefest at itbhu.ac.in or reach us personally at: * Mohit Bansal mohit.bansal.cse06 at itbhu.ac.in * Saket Saurabh +91-9452-825-690 saket.saurabh.cse07 at itbhu.ac.in We wish you all the best for CodeFest and for your future endeavors. Be free and Happy Coding! Team CodeFest IT-BHU From rantingrick at gmail.com Mon Jan 17 14:44:53 2011 From: rantingrick at gmail.com (rantingrick) Date: Mon, 17 Jan 2011 11:44:53 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <4d337983$0$29983$c3e8da3$5496439d@news.astraweb.com> <044a5101-948d-4458-9c94-57dbb3e25f67@m35g2000vbn.googlegroups.com> <4d3467bf$0$29983$c3e8da3$5496439d@news.astraweb.com> Message-ID: <00d83365-8bb0-435e-929f-d20f456faf2b@f20g2000vbc.googlegroups.com> On Jan 17, 1:26?pm, Adam Skutt wrote: > On Jan 17, 11:01?am, Steven D'Aprano > Nevertheless, you can do good, useful work > > with only a minimal widget set. Back when dinosaurs walked the earth, [...snip...] > And when a time machine warps all back to the 1980s, that argument > might have some merit. ?Since you're not Dr. Emmett Brown, I suggest > you refrain from making arguments that predicate themselves on time > travel. You know Adam some people could use that very same sarcastic argument against you for claiming that Tkinter is "just as good" or *giggles* "better" than wxPython. From venu.allipuram at gmail.com Mon Jan 17 15:01:03 2011 From: venu.allipuram at gmail.com (Venu Allipuram) Date: Mon, 17 Jan 2011 14:01:03 -0600 Subject: Need the list of XML parsers In-Reply-To: <4D3480F4.6070606@sudheer.net> References: <9f75fdb8-78e3-4675-a48a-64147e0a0095@w29g2000vba.googlegroups.com> <4D3480F4.6070606@sudheer.net> Message-ID: lxml is a great one, but it is not simple to install libxml and libxslt on Linux using user permissions. Also it is hard to package the scripts after the complete development for release. Did anybody try this, if so please let me know your thoughts on this. Thanks venu On Mon, Jan 17, 2011 at 11:48 AM, Sudheer Satyanarayana < sudheer.s at sudheer.net> wrote: > On Monday 17 January 2011 11:05 PM, Venu wrote: > >> Hi, >> >> I am getting into serious Python programming for Electronic CAD tools, >> I am trying to find the best XML parser modules available. I need good >> searching capability for attributes, nodes and block of XML. I am >> looking for either a recommendation or previous forum links. >> >> Thanks >> Venu >> > lxml is a good XML parser. It supports xpath and IIRC, xquery. > > I wrote a blog post about it a while ago - > http://techchorus.net/web-scraping-lxml > > > -- > With warm regards, > Sudheer. S > Personal home page - http://sudheer.net | Tech Chorus - > http://techchorus.net > Web and IT services - http://binaryvibes.co.in > -- ************************ Venu Allipuram 479-445-3502 -------------- next part -------------- An HTML attachment was scrubbed... URL: From solipsis at pitrou.net Mon Jan 17 15:02:47 2011 From: solipsis at pitrou.net (Antoine Pitrou) Date: Mon, 17 Jan 2011 21:02:47 +0100 Subject: 9 Month Python contract in Austin, TX References: Message-ID: <20110117210247.7418f6a9@pitrou.net> On Mon, 17 Jan 2011 11:08:52 -0800 (PST) AlexLBasso wrote: > I am recruiting for a 9 month contract (with contract extension > potential) for a company in North Austin. Please post on the job board instead: http://python.org/community/jobs/ Thank you Antoine. From orasnita at gmail.com Mon Jan 17 15:04:57 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Mon, 17 Jan 2011 22:04:57 +0200 Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com><4d337983$0$29983$c3e8da3$5496439d@news.astraweb.com><044a5101-948d-4458-9c94-57dbb3e25f67@m35g2000vbn.googlegroups.com><4d3467bf$0$29983$c3e8da3$5496439d@news.astraweb.com> Message-ID: From: "rantingrick" Sent: Monday, January 17, 2011 8:53 PM Subject: Re: Tkinter: The good, the bad, and the ugly! On Jan 17, 12:27 pm, "Octavian Rasnita" wrote: > And Python should also not include any editor because for > some programmers it is absolutely useless anyway. The > editor can be installed separately very easy and the > programmers can choose the editor they like. The problem > is not that WxPython is not encouraged, but that Tkinter > is encouraged because it is promoted. These are very true statements Octavian! I had always believed that Python should include a GUI AND and IDE even though Tkinter and IDLE are severely dated. Now i am thinking that maybe we should judt dump both and leave it that way. Why did i previously think this way? Well my concern was to keep the goals of GvR alive. That is that programming should be for everyone and having a simplistic IDE and GUI in the stdlib help foster these goals. However that was circa 1980's and we now find our selfs a decade past the 21st century. We now have a huge amount of 3rd party GUI's and IDE's. Do we even need to include them any more? Sure one could always argue batteries included however with the plethera of 3rd party downloads, the batteries may not be included, but they are located witin reach at the reqister check out Q. Do we need ANY GUI or ANY IDE in the stdlib anymore? I say probably not considering the availability of 3rd party downloads. What say you, Python community? And one more thing. Not all the Python programmers create desktop apps so a GUI lib is useless. Some of them use Python only for web programming or only for system administration. Octavian From orasnita at gmail.com Mon Jan 17 15:08:56 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Mon, 17 Jan 2011 22:08:56 +0200 Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com><4d337983$0$29983$c3e8da3$5496439d@news.astraweb.com><044a5101-948d-4458-9c94-57dbb3e25f67@m35g2000vbn.googlegroups.com><4d3467bf$0$29983$c3e8da3$5496439d@news.astraweb.com> Message-ID: <2BA870E82295475CA5568A2E57E1DE6E@teddy> From: "Adam Skutt" Subject: Re: Tkinter: The good, the bad, and the ugly! On Jan 17, 11:01 am, Steven D'Aprano wrote: > > I'm afraid that's precisely what I'm arguing you *can't* do -- there's > nothing reasonable about equating the standard library with the language. > Some languages don't even have a standard library, or for that matter a > standard implementation. And we're not discussing those languages, we're discussing Python, which has an explicit policy of "batteries included". As such, criticism of the standard library is perfectly acceptable under the name "Python", whether you like it or not. Besides, it's inevitable anyway. "Batteries included"? Python doesn't follow this policy at all. We can say that maybe PHP follows it, but not Python. And if this is the wanted policy, why should it be "cheap batteries included" and not "strong batteries included"? Octavian From martin.hellwig at dcuktec.org Mon Jan 17 15:09:44 2011 From: martin.hellwig at dcuktec.org (Martin P. Hellwig) Date: Mon, 17 Jan 2011 20:09:44 +0000 Subject: Should there be a 'core' python install? (was Re: Tkinter: The good, the bad, and the ugly!) In-Reply-To: <0947517d-a2c4-44af-83cb-8ed4299b143a@k25g2000vbl.googlegroups.com> References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com><4d337983$0$29983$c3e8da3$5496439d@news.astraweb.com><044a5101-948d-4458-9c94-57dbb3e25f67@m35g2000vbn.googlegroups.com> <4d3467bf$0$29983$c3e8da3$5496439d@news.astraweb.com> <0947517d-a2c4-44af-83cb-8ed4299b143a@k25g2000vbl.googlegroups.com> Message-ID: On 01/17/11 19:39, rantingrick wrote: Q: If you could replace Tkinter with any module/library (THAT IS NOT A > GUI OR IDE!!) what would you like to see fill its place? Some systems, like FreeBSD have Tkinter and IDLE as a separate package which is not installed by default. Purely because those systems don't assume that the user has X installed. Though since this is a windows world, that argument is rather mood. But then again the win32 extension modules aren't installed by default, rather inconsistent in that perspective. You could argue that there is some advantage especially for starters, having at least something to start on (IDLE), but on the other hand there are already a couple of special 'distribution packages' that aim to include anything remotely python related. I think that the ones that should make these decisions (if any) are those how spend _their_ time integrating the dependencies and making the builds for public download. Perhaps for pythons 3 lifetime there should still be a 'python' maintained tkinter integration. But I don't see any reason why this should be continued for 4, fortunately it is not my call and I actually quite like Tkinter. -- mph From venu.allipuram at gmail.com Mon Jan 17 15:34:06 2011 From: venu.allipuram at gmail.com (Venu) Date: Mon, 17 Jan 2011 12:34:06 -0800 (PST) Subject: Need the list of XML parsers In-Reply-To: Message-ID: <625910e2-22c2-4365-bc34-d0f9d5af8c65@glegroupsg2000goo.googlegroups.com> Hi Stefan Using cElementTree, would you be willing show to me how to find the nodes with certain attribute, ie search using attributes and attibute values. I did not see any example code from the cElementTree official website. Regards, Venu From venu.allipuram at gmail.com Mon Jan 17 15:34:06 2011 From: venu.allipuram at gmail.com (Venu) Date: Mon, 17 Jan 2011 12:34:06 -0800 (PST) Subject: Need the list of XML parsers In-Reply-To: Message-ID: <625910e2-22c2-4365-bc34-d0f9d5af8c65@glegroupsg2000goo.googlegroups.com> Hi Stefan Using cElementTree, would you be willing show to me how to find the nodes with certain attribute, ie search using attributes and attibute values. I did not see any example code from the cElementTree official website. Regards, Venu From nagle at animats.com Mon Jan 17 15:40:26 2011 From: nagle at animats.com (John Nagle) Date: Mon, 17 Jan 2011 12:40:26 -0800 Subject: [OT] Python like lanugages In-Reply-To: References: <86a904f8-05b0-435f-81d6-7450650f1679@glegroupsg2000goo.googlegroups.com> <4d329899$0$43988$742ec2ed@news.sonic.net> <7x8vylfcvz.fsf@ruckus.brouhaha.com> <4d32c7cf$0$29983$c3e8da3$5496439d@news.astraweb.com> <7xipxo9er6.fsf@ruckus.brouhaha.com> Message-ID: <4d34a939$0$44014$742ec2ed@news.sonic.net> On 1/17/2011 1:34 AM, Tim Harig wrote: > On 2011-01-17, Paul Rubin wrote: >> geremy condra writes: > > Which is rather interesting because the OOP community had > traditionally though of functional programming as a 1960's thing that > didn't work out. Right. The big problem with functional programming is that each function has only one output. It's interesting that this is purely a syntactical problem. Functional programs look like trees. They have "fan in", gathering many inputs into one, but no "fan out", spreading outputs out to multiple destinations. Conceptually, you could have a programming language which allows you to write programs where functions had multiple outputs which could be directed to different places, but which weren't stored as state. Such programs would be directed acyclic graphs, rather than trees. That's been done once or twice. There's what are called "single assignment languages". Each variable can only be assigned once. The result looks like an imperative language but works like a functional language. Look up "SISAL" for an example. This approach is good for concurrency and optimization, but it never caught on. Note that from a concurrency standpoint, immutability is very useful. It's a lot like single assignment. You can pass around immutable objects to concurrent threads without race conditions, provided that memory management can handle concurrency. This works in Python, although, because of the GIL problem, it doesn't help performance. A form of Python for highly concurrent work is possible. More things would have to be immutable, at least once the program went multi-thread. If modules, classes, and functions were immutable in multi-thread code, global locking wouldn't be necessary, and you could put tens or hundreds of CPUs to work on one program. But Guido would never allow that, so concurrency in Python is doomed to suck. John Nagle From askutt at gmail.com Mon Jan 17 15:54:05 2011 From: askutt at gmail.com (Adam Skutt) Date: Mon, 17 Jan 2011 12:54:05 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com><4d337983$0$29983$c3e8da3$5496439d@news.astraweb.com><044a5101-948d-4458-9c94-57dbb3e25f67@m35g2000vbn.googlegroups.com><4d3467bf$0$29983$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Jan 17, 3:08?pm, "Octavian Rasnita" wrote: >> From: "Adam Skutt" >> And we're not discussing those languages, we're discussing Python, >> which has an explicit policy of "batteries included". ?As such, >> criticism of the standard library is perfectly acceptable under the >> name "Python", whether you like it or not. ?Besides, it's inevitable >> anyway. > > "Batteries included"? > > Python doesn't follow this policy at all. We can say that maybe PHP follows it, but not Python. > http://lmgtfy.com/?q=python+%22batteries+included%22&l=1 > And if this is the wanted policy, why should it be "cheap batteries included" and not "strong batteries included"? You'd have this same argument regardless of GUI toolkit you end up picking, or even if you choose to not include one at all. This would be because none of them are universal solutions, all of them have deficiencies (actual or perceived) that make them unsuitable for certain applications. Adam From usernet at ilthio.net Mon Jan 17 16:07:42 2011 From: usernet at ilthio.net (Tim Harig) Date: Mon, 17 Jan 2011 21:07:42 +0000 (UTC) Subject: [OT] Python like lanugages [was Re: After C++, what with Python?] References: <86a904f8-05b0-435f-81d6-7450650f1679@glegroupsg2000goo.googlegroups.com> <4d329899$0$43988$742ec2ed@news.sonic.net> <7x8vylfcvz.fsf@ruckus.brouhaha.com> <4d32c7cf$0$29983$c3e8da3$5496439d@news.astraweb.com> Message-ID: On 2011-01-17, geremy condra wrote: > On Mon, Jan 17, 2011 at 1:12 AM, Tim Harig wrote: >> On 2011-01-16, geremy condra wrote: >> I wouldn't say Go is narrowly targeted. ?It's a systems language that can >> compete in the same domain with scripting languages. ?It is true that most >> languages have long incubation periods; but, corporate support can change >> that quite a bit. ?C#, being backed by Microsoft, managed to go mainstream >> pretty quickly. > > This seems... shall we say, overly optimistic. I've seen no evidence > at all that Go is even trying to compete with scripting languages, and > I don't know of anyone who would actually use it where a shell script > might do. AFAICS, it is an unabashedly concurrency-centric systems I don't write Python where shell scripts will do either. I have rewritten several simple Python scripts in Go. I will not be leaving Python completely; but, Go will likely replace Python for most of my large scale programming needs. > might do. AFAICS, it is an unabashedly concurrency-centric systems > language for people who are willing to sacrifice some speed and > control for legible code. That's not an impossibly narrow niche (and > it certainly has deep pockets) but it *is* narrow compared to a > general purpose language like Java or Python. You are writing Go into far too narrow of a niche then it actually is. In fact, whatever language you are commenting on doesn't sound like Go at all. Go is every bit of a general purpose programming language. It is useful for the same basic applications that you would otherwise write in Java. It can do pretty much anything that you can do in C, with the probable exception of writing operating systems. I have been using C/C++ for most of my programming career; but, everything that I have done can be done with Go. I am not really sure where you are seeing such narrowing limitations. Support for concurrency is really icing on the cake. I find it rather supprising that so many modern languages do not already support full concurrency constructs. >>> Python's very widely used for scripting and related tasks, and has a >>> pretty big user base in academia and the sciences. >> >> Python has been widely used by people like us that happen to like the >> language and found ways to use it in our workplaces; but, most of the >> time it is an unofficial use that the company. ?You still don't see many >> companies doing large scale internal development using Python and you >> definately don't see any doing external developement using a language >> that gives the customers full access to the source code. > > Right, I mean, it's not like the company that wrote Go would *ever* > stoop to using Python ;) I have never said that there are not companies doing developement in Python and certainly not for web programming; but, a handful of companies that have adopted Python doesn't make it mainstream. Good luck finding many Python jobs in my area. Java, C#, Visual Basic, PHP, *COBOL*, RPG-IV, and, to a lesser extent, C++ jobs are available in abundance. The few Python jobs that are available are for web based programming. >> 1. Go has an object model. ?What it lacks is an object hierarchy where all >> ? ? ? ?object are decended from a single root "object" since it does >> ? ? ? ?not support object inheritance as it is used in most languages. >> ? ? ? ?In Go we simply adapt an object to meet the needs of the newer >> ? ? ? ?object by adding whatever new functionality is needed. > > Go has structs. Its structs are not objects, principally because they > can't do real inheritance. You can do similar things ('structural > inheritance') to C structs, and nobody argues that C is OO. http://www.infoq.com/interviews/johnson-armstrong-oop Listen to the third point. Object orientation is quite possible even without inheritance. Not all programming languages support the same set of OOP features. Not all classless OOP programming languages support inheritance. The basic definition of object oriented programming is programing with self contained objects which contain their own data and the procedures necessary to manipulate that data. >> 2. Go has a similar mechanism to exceptions, defer/panic/recover. ?It does >> ? ? ? ?downplay > > Defer, panic, and recover only allow you to build a recovery stack. > That's like saying that try/except isn't needed anymore because you > have the with statement. Do you think you could get through a rewrite > of Django without ripping out some hair over that? I don't know what you are referencing about Django as I don't work on or with the project; but, if one wanted exceptions with similar sematics to Python's, it could easily be built around Go's defer/panic/recover. There are actually packages availble that recreate exceptions as they are used in Ruby and other languages. The only think defer/panic/recover lacks is an exception class containing more more detailed information about what actually went wrong. >> The current >> interest in functional programming stems merely because some announced >> that it would be *the* way to utilize multicore computers. ?Having looked >> into the space somewhat, there is more hype then substantiation for >> purely functional concepts. ?What the hype did do was return attention >> to SCP style concurrency using actors and MPI and I think that will be >> the direction taken for concurrent programming into the future. > > I'm not an expert in concurrency and can't evaluate the claims many > are making in that space. I know that I still find writing highly > parallel programs easier in C and Python than I do in Haskell, but I > seldom wind up thinking that concurrency was the hard part of the > problem I was solving. I don't know much about Haskells concurrent programming constructs. If you have found concurrent programming easy, then your problems probably don't involve many shared resources. From alex.kapps at web.de Mon Jan 17 16:10:38 2011 From: alex.kapps at web.de (Alexander Kapps) Date: Mon, 17 Jan 2011 22:10:38 +0100 Subject: Tkinter: The good, the bad, and the ugly! In-Reply-To: References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com><4d337983$0$29983$c3e8da3$5496439d@news.astraweb.com><044a5101-948d-4458-9c94-57dbb3e25f67@m35g2000vbn.googlegroups.com><4d3467bf$0$29983$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4D34B04E.8050309@web.de> On 17.01.2011 21:04, Octavian Rasnita wrote: > I say probably not considering the availability of 3rd party > downloads. What say you, Python community? Available as 3rd party downloads: XML,HTML,... HTTP,FTP,SMTP,POP,IMAP/... MD5,SHA,... zip,bzip,... and so on and so on and so on. Remove them all just because they are available as 3rd party downloads? The "Batteries included" of Python is just *great* and I vote for *more* not less batteries! > And one more thing. Not all the Python programmers create desktop apps so a GUI lib is useless. Some of them use Python only for web programming or only for system administration. Not all Python programmers do web programming, so please remove the useless HTML junk too. Almost every beginner wants to do GUIs or at least some graphic stuff. Removing the GUI module from the stdlib would be plain wrong IMHO. But I don't understand the whole issue anyway. It isn't that you need to fire up your torrent client and wait 48 hours for the Python download to complete. Why remove useful (to many, not most) stuff from the lib? From usernet at ilthio.net Mon Jan 17 16:59:56 2011 From: usernet at ilthio.net (Tim Harig) Date: Mon, 17 Jan 2011 21:59:56 +0000 (UTC) Subject: [OT] Python like lanugages References: <86a904f8-05b0-435f-81d6-7450650f1679@glegroupsg2000goo.googlegroups.com> <4d329899$0$43988$742ec2ed@news.sonic.net> <7x8vylfcvz.fsf@ruckus.brouhaha.com> <4d32c7cf$0$29983$c3e8da3$5496439d@news.astraweb.com> <7xipxo9er6.fsf@ruckus.brouhaha.com> <4d34a939$0$44014$742ec2ed@news.sonic.net> Message-ID: On 2011-01-17, John Nagle wrote: > That's been done once or twice. There's what are called "single > assignment languages". Each variable can only be assigned once. > The result looks like an imperative language but works like a functional > language. Look up "SISAL" for an example. This approach is good > for concurrency and optimization, but it never caught on. That is rather interesting; especially since most of the current hype is about immutability and the lack of side affects of functional languages rather then functional decomposition using lamda calculus constructs. > Note that from a concurrency standpoint, immutability is very > useful. It's a lot like single assignment. You can pass around > immutable objects to concurrent threads without race conditions, > provided that memory management can handle concurrency. This works I wonder if even that is fully necessary. In, Ada procedure arguments specify whether or not they can be changed within the procedure effectively creating a gateway whereby side affects can be specified. If you take that a step further and require: 1. The function of a scope is completely closed. It cannot access anything from the scope above it except what is passed to it as arguments. 2. Arguments that can be changed must be copied on write so that they don't directly affect the memory of the outer scope. Then you can be sure that the functions have no side affects outside of the values that they return. Internally, the function can use imperative semantics that require mutability such as iteration instead recursion without affecting anything above it. From rantingrick at gmail.com Mon Jan 17 17:00:47 2011 From: rantingrick at gmail.com (rantingrick) Date: Mon, 17 Jan 2011 14:00:47 -0800 (PST) Subject: Should there be a 'core' python install? (was Re: Tkinter: The good, the bad, and the ugly!) References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com><4d337983$0$29983$c3e8da3$5496439d@news.astraweb.com><044a5101-948d-4458-9c94-57dbb3e25f67@m35g2000vbn.googlegroups.com> <4d3467bf$0$29983$c3e8da3$5496439d@news.astraweb.com> <0947517d-a2c4-44af-83cb-8ed4299b143a@k25g2000vbl.googlegroups.com> Message-ID: <3ac4634f-1c6f-4552-9e7f-a2d912a77dc2@f35g2000vbl.googlegroups.com> On Jan 17, 2:09?pm, "Martin P. Hellwig" wrote: > fortunately it is not my call and I actually > quite like Tkinter. Are you sure about that Martin? :))) > From: "Martin P. Hellwig" > Newsgroups: comp.lang.python > Subject: Re: GUIs - A Modest Proposal > Date: Fri, 11 Jun 2010 07:10:35 +0100 [...snip...] > Though I don't like tkinter either, but I don't seem to hate it as > much as others do. hmm? From sysengp2p at gmail.com Mon Jan 17 17:19:13 2011 From: sysengp2p at gmail.com (carlo) Date: Mon, 17 Jan 2011 14:19:13 -0800 (PST) Subject: UTF-8 question from Dive into Python 3 Message-ID: Hi, recently I had to study *seriously* Unicode and encodings for one project in Python but I left with a couple of doubts arised after reading the unicode chapter of Dive into Python 3 book by Mark Pilgrim. 1- Mark says: "Also (and you?ll have to trust me on this, because I?m not going to show you the math), due to the exact nature of the bit twiddling, there are no byte-ordering issues. A document encoded in UTF-8 uses the exact same stream of bytes on any computer." Is it true UTF-8 does not have any "big-endian/little-endian" issue because of its encoding method? And if it is true, why Mark (and everyone does) writes about UTF-8 with and without BOM some chapters later? What would be the BOM purpose then? 2- If that were true, can you point me to some documentation about the math that, as Mark says, demonstrates this? thank you Carlo From jake.biesinger at gmail.com Mon Jan 17 17:20:59 2011 From: jake.biesinger at gmail.com (Jake Biesinger) Date: Mon, 17 Jan 2011 14:20:59 -0800 (PST) Subject: Efficient python 2-d arrays? Message-ID: Hi all, Using numpy, I can create large 2-dimensional arrays quite easily. >>> import numpy >>> mylist = numpy.zeros((100000000,2), dtype=numpy.int32) Unfortunately, my target audience may not have numpy so I'd prefer not to use it. Similarly, a list-of-tuples using standard python syntax. >>> mylist = [(0,0) for i in xrange(100000000) but this method uses way too much memory (>4GB for 100 million items, compared to 1.5GB for numpy method). Since I want to keep the two elements together during a sort, I *can't* use array.array. >>> mylist = [array.array('i',xrange(100000000)), array.array('i',xrange(100000000))] If I knew the size in advance, I could use ctypes arrays. >>> from ctypes import * >>> class myStruct(Structure): >>> _fields_ = [('x',c_int),('y',c_int)] >>> mylist_type = myStruct * 100000000 >>> mylist = mylist_type() but I don't know that size (and it can vary between 1 million-200 million), so preallocating doesn't seem to be an option. Is there a python standard library way of creating *efficient* 2-dimensional lists/arrays, still allowing me to sort and append? Thanks! From debatem1 at gmail.com Mon Jan 17 17:21:17 2011 From: debatem1 at gmail.com (geremy condra) Date: Mon, 17 Jan 2011 14:21:17 -0800 Subject: [OT] Python like lanugages [was Re: After C++, what with Python?] In-Reply-To: References: <86a904f8-05b0-435f-81d6-7450650f1679@glegroupsg2000goo.googlegroups.com> <4d329899$0$43988$742ec2ed@news.sonic.net> <7x8vylfcvz.fsf@ruckus.brouhaha.com> <4d32c7cf$0$29983$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Mon, Jan 17, 2011 at 1:07 PM, Tim Harig wrote: > On 2011-01-17, geremy condra wrote: >> On Mon, Jan 17, 2011 at 1:12 AM, Tim Harig wrote: >>> On 2011-01-16, geremy condra wrote: >>> I wouldn't say Go is narrowly targeted. ?It's a systems language that can >>> compete in the same domain with scripting languages. ?It is true that most >>> languages have long incubation periods; but, corporate support can change >>> that quite a bit. ?C#, being backed by Microsoft, managed to go mainstream >>> pretty quickly. >> >> This seems... shall we say, overly optimistic. I've seen no evidence >> at all that Go is even trying to compete with scripting languages, and >> I don't know of anyone who would actually use it where a shell script >> might do. AFAICS, it is an unabashedly concurrency-centric systems > > I don't write Python where shell scripts will do either. ?I have rewritten > several simple Python scripts in Go. ?I will not be leaving Python > completely; but, Go will likely replace Python for most of my large scale > programming needs. I'm happy that you've found a language you like. I don't happen to share your enthusiasm for it, and I think my arguments are better grounded. I suspect you feel the same about yours, and I'm happy to leave it at that. >> might do. AFAICS, it is an unabashedly concurrency-centric systems >> language for people who are willing to sacrifice some speed and >> control for legible code. That's not an impossibly narrow niche (and >> it certainly has deep pockets) but it *is* narrow compared to a >> general purpose language like Java or Python. > > You are writing Go into far too narrow of a niche then it actually is. ?In > fact, whatever language you are commenting on doesn't sound like Go at all. > > Go is every bit of a general purpose programming language. ?It is useful > for the same basic applications that you would otherwise write in Java. ?It > can do pretty much anything that you can do in C, with the probable > exception of writing operating systems. ?I have been using C/C++ for most > of my programming career; but, everything that I have done can be done with > Go. ?I am not really sure where you are seeing such narrowing limitations. I'm a C, Python, and Haskell developer. Everything I've done could be done in C. I would probably not be happy if I had to, though. Some people get very attached to one language and use it for everything. I'd rather use the right tool for the job. Go is not an ideal language for high-performance code. Despite the occasional claims of others, Go is consistently outperformed by C, C++, and Java on a wide variety of benchmarks. Some claim that Ada and Haskell do as well, and my benchmarks (CPU bound, focused on speed of cryptographic primitives) *seem* to confirm that for Haskell. I say 'seem' because I'm clearly much more familiar with Haskell than with Go, and would be inclined to question my conclusions if they weren't in line with the work of others. You can argue that it's good enough- it is, for most cases- but taking a 20% performance hit rules it out of a lot of systems work, and the C-Go gap in many cases is much larger than that. Go is also not an ideal language for enterprise development. It provides no compatibility or support guarantees; in fact, the website describes it as 'an experiment' and recommends it for 'adventurous users'. There are no independent experts in case something goes wrong, and if it goes belly up a year from now you will have a one year old piece of legacy infrastructure on your hands. Maybe you don't think that this will be the case; in any event, I would not want to try convincing a CFO of that. As you point out, Go is also not a good language for operating systems work. The lack of a widely accepted GUI toolkit weakens your argument about application development. The lack of third party tools and dependence on foreign language bindings weakens your single-language argument. Etc, etc, etc. Taking these things out you are left with very little that Go is compellingly good at. I certainly don't see it displacing Java or C, which you claim is equivalent. > Support for concurrency is really icing on the cake. ?I find it rather > supprising that so many modern languages do not already support full > concurrency constructs. Go's most-lauded feature is its goroutines. I suspect that if this isn't a big deal for you, you aren't its primary use case. >>>> Python's very widely used for scripting and related tasks, and has a >>>> pretty big user base in academia and the sciences. >>> >>> Python has been widely used by people like us that happen to like the >>> language and found ways to use it in our workplaces; but, most of the >>> time it is an unofficial use that the company. ?You still don't see many >>> companies doing large scale internal development using Python and you >>> definately don't see any doing external developement using a language >>> that gives the customers full access to the source code. >> >> Right, I mean, it's not like the company that wrote Go would *ever* >> stoop to using Python ;) > > I have never said that there are not companies doing developement in > Python and certainly not for web programming; but, a handful of companies > that have adopted Python doesn't make it mainstream. ?Good luck finding > many Python jobs in my area. ?Java, C#, Visual Basic, PHP, *COBOL*, > RPG-IV, and, to a lesser extent, C++ jobs are available in abundance. > The few Python jobs that are available are for web based programming. Let me know when you get a job writing Go. >>> 1. Go has an object model. ?What it lacks is an object hierarchy where all >>> ? ? ? ?object are decended from a single root "object" since it does >>> ? ? ? ?not support object inheritance as it is used in most languages. >>> ? ? ? ?In Go we simply adapt an object to meet the needs of the newer >>> ? ? ? ?object by adding whatever new functionality is needed. >> >> Go has structs. Its structs are not objects, principally because they >> can't do real inheritance. You can do similar things ('structural >> inheritance') to C structs, and nobody argues that C is OO. > > http://www.infoq.com/interviews/johnson-armstrong-oop > > Listen to the third point. ?Object orientation is quite possible even > without inheritance. ?Not all programming languages support the same set > of OOP features. ?Not all classless OOP programming languages support > inheritance. ?The basic definition of object oriented programming is > programing with self contained objects which contain their own data and > the procedures necessary to manipulate that data. So C is OOP. Let's agree to disagree on that. >>> 2. Go has a similar mechanism to exceptions, defer/panic/recover. ?It does >>> ? ? ? ?downplay >> >> Defer, panic, and recover only allow you to build a recovery stack. >> That's like saying that try/except isn't needed anymore because you >> have the with statement. Do you think you could get through a rewrite >> of Django without ripping out some hair over that? > > I don't know what you are referencing about Django as I don't work on or > with the project; but, if one wanted exceptions with similar sematics to > Python's, it could easily be built around Go's defer/panic/recover. ?There > are actually packages availble that recreate exceptions as they are used in > Ruby and other languages. ?The only think defer/panic/recover lacks is an > exception class containing more more detailed information about what > actually went wrong. You could also build it in C, yet C is exceptionless and is commonly faulted for that fact. >>> The current >>> interest in functional programming stems merely because some announced >>> that it would be *the* way to utilize multicore computers. ?Having looked >>> into the space somewhat, there is more hype then substantiation for >>> purely functional concepts. ?What the hype did do was return attention >>> to SCP style concurrency using actors and MPI and I think that will be >>> the direction taken for concurrent programming into the future. >> >> I'm not an expert in concurrency and can't evaluate the claims many >> are making in that space. I know that I still find writing highly >> parallel programs easier in C and Python than I do in Haskell, but I >> seldom wind up thinking that concurrency was the hard part of the >> problem I was solving. > > I don't know much about Haskells concurrent programming constructs. ?If you > have found concurrent programming easy, then your problems probably don't > involve many shared resources. Not an enormous number, no. Geremy Condra From martin.hellwig at dcuktec.org Mon Jan 17 17:23:59 2011 From: martin.hellwig at dcuktec.org (Martin P. Hellwig) Date: Mon, 17 Jan 2011 22:23:59 +0000 Subject: Should there be a 'core' python install? (was Re: Tkinter: The good, the bad, and the ugly!) In-Reply-To: <3ac4634f-1c6f-4552-9e7f-a2d912a77dc2@f35g2000vbl.googlegroups.com> References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com><4d337983$0$29983$c3e8da3$5496439d@news.astraweb.com><044a5101-948d-4458-9c94-57dbb3e25f67@m35g2000vbn.googlegroups.com> <4d3467bf$0$29983$c3e8da3$5496439d@news.astraweb.com> <0947517d-a2c4-44af-83cb-8ed4299b143a@k25g2000vbl.googlegroups.com> <3ac4634f-1c6f-4552-9e7f-a2d912a77dc2@f35g2000vbl.googlegroups.com> Message-ID: On 01/17/11 22:00, rantingrick wrote: > On Jan 17, 2:09 pm, "Martin P. Hellwig" > wrote: > >> fortunately it is not my call and I actually >> quite like Tkinter. > > > Are you sure about that Martin? :))) > >> From: "Martin P. Hellwig" >> Newsgroups: comp.lang.python >> Subject: Re: GUIs - A Modest Proposal >> Date: Fri, 11 Jun 2010 07:10:35 +0100 > [...snip...] >> Though I don't like tkinter either, but I don't seem to hate it as >> much as others do. > > hmm? Yep when I started looking much more at other toolkits, I started to like Tkinter more and more. Maybe it its simplicity, or that not every thing starts with a bloody g or that it is actually cross platform usable without jumping through hoops charted in a map where lat/long references have been omitted because in the future a map of mars will not cause confusion, even though it is totally irrelevant now. Actually my favourite GUI toolkit at the moment is pyjamas. -- mph From tr03 at jm.rinkleff.com Mon Jan 17 17:30:10 2011 From: tr03 at jm.rinkleff.com (plovet) Date: Mon, 17 Jan 2011 14:30:10 -0800 (PST) Subject: New to Jpype - TypeError .... class is not callable Message-ID: <30676235.post@talk.nabble.com> Hello, I am trying to use jpype, but after several hours/days, I still cannot get it to work. I get a TypeError --- Package is not Callable error. (See below) I already have done a good workable chunk of code I wrote in Java that implements steam table calculations. After a few weeks of playing with Python, I see that as much more promising for me, and want to switch. But rewriting all of this java code a second time is not going to happen. If I can get jpype to make this ONE link to my existing Java code for me, I can move forward. I would appreciate any help as I can not find the answer in my internet searches. -------------------------------------------------------------------------- I get the following error (IDLE): Traceback (most recent call last): File "C:\Python26\testPype.py", line 16, in myClass = steamPackage.SteamPoint() File "C:\Python26\lib\site-packages\jpype\_jpackage.py", line 53, in __call__ raise TypeError, "Package "+self.__name+" is not Callable" TypeError: Package de.engineering.steam.SteamPoint is not Callable ---------------------------------------------------------------- Here is my Python Code: import jpype jvmPath = "C:\\Program Files\\Java\\jdk1.5.0_13\\jre\\bin\\client\\jvm.dll" options = "-ea" jarPath = "-DJava.class.path=C:\\javaNetBeans\\Projects\\de.engineering.steam\\dist\\de.engineering.steam.jar" jpype.startJVM(jvmPath,options, jarPath) packageName="de.engineering.steam" steamPackage = jpype.JPackage(packageName) myClass = steamPackage.SteamPoint() FYI, I have tried various variations that I could think of, but still no luck myClass = steamPackage.SteamPoint #produces no error, but I can do nothing with this myClass = steamPacakge.NonExistentClass #also produces no error, and just as useless! myClass = steamPackage.SteamPoint(1,40,400) # TypeError as above myClass = steamPackage.SteamPoint.SteamPoint() # TypeError as above --------------------------------------------------------------------- Here is a summary of the Java code for the class. This is stored in a .jar file (see python code). As stated, this single Java class is the gateway to all of my Java code stored in that jar file ... so all I need is to access the functionality in this one class. package de.engineering.steam; import de.engineering.steam.IAPWSF97.*; public class SteamPoint { private double p, t, h, s, v, x; ///etc. etc. //blank constructor - not important public SteamPoint() {} //the *real* constructer public SteamPoint(int switchCode, double d1, double d2) {...} //the methods I need to access after a sucessful construction creation /**Returns the pressure (bara)*/ public double p() {return p;} //etc.... etc... etc.. } THANK YOU for any help! Timothy (plovet) -- View this message in context: http://old.nabble.com/New-to-Jpype---TypeError-....-class-is-not-callable-tp30676235p30676235.html Sent from the Python - python-list mailing list archive at Nabble.com. From alex.kapps at web.de Mon Jan 17 17:30:59 2011 From: alex.kapps at web.de (Alexander Kapps) Date: Mon, 17 Jan 2011 23:30:59 +0100 Subject: UTF-8 question from Dive into Python 3 In-Reply-To: References: Message-ID: <4D34C323.4030909@web.de> On 17.01.2011 23:19, carlo wrote: > Is it true UTF-8 does not have any "big-endian/little-endian" issue > because of its encoding method? And if it is true, why Mark (and > everyone does) writes about UTF-8 with and without BOM some chapters > later? What would be the BOM purpose then? Can't answer your other questions, but the UTF-8 BOM is simply a marker saying "This is a UTF-8 text file, not an ASCII text file" If I'm not wrong, this was a Microsoft invention and surely one of their brightest ideas. I really wish, that this had been done for ANSI some decades ago. Determining the encoding for text files is hard to impossible because such a mark was never introduced. From usernet at ilthio.net Mon Jan 17 17:34:32 2011 From: usernet at ilthio.net (Tim Harig) Date: Mon, 17 Jan 2011 22:34:32 +0000 (UTC) Subject: UTF-8 question from Dive into Python 3 References: Message-ID: On 2011-01-17, carlo wrote: > Is it true UTF-8 does not have any "big-endian/little-endian" issue > because of its encoding method? And if it is true, why Mark (and > everyone does) writes about UTF-8 with and without BOM some chapters > later? What would be the BOM purpose then? Yes, it is true. The BOM simply identifies that the encoding as a UTF-8.: http://unicode.org/faq/utf_bom.html#bom5 > 2- If that were true, can you point me to some documentation about the > math that, as Mark says, demonstrates this? It is true because UTF-8 is essentially an 8 bit encoding that resorts to the next bit once it exhausts the addressible space of the current byte it moves to the next one. Since the bytes are accessed and assessed sequentially, they must be in big-endian order. From solipsis at pitrou.net Mon Jan 17 17:34:57 2011 From: solipsis at pitrou.net (Antoine Pitrou) Date: Mon, 17 Jan 2011 23:34:57 +0100 Subject: UTF-8 question from Dive into Python 3 References: Message-ID: <20110117233457.17f716ea@pitrou.net> On Mon, 17 Jan 2011 14:19:13 -0800 (PST) carlo wrote: > Is it true UTF-8 does not have any "big-endian/little-endian" issue > because of its encoding method? Yes. > And if it is true, why Mark (and > everyone does) writes about UTF-8 with and without BOM some chapters > later? What would be the BOM purpose then? "BOM" in this case is a misnomer. For UTF-8, it is only used as a marker (a magic number, if you like) to signal than a given text file is UTF-8. The UTF-8 "BOM" does not say anything about byte order; and, actually, it does not change with endianness. (note that it is not required to put an UTF-8 "BOM" at the beginning of text files; it is just a hint that some tools use when generating/reading UTF-8) > 2- If that were true, can you point me to some documentation about the > math that, as Mark says, demonstrates this? Math? UTF-8 is simply a byte-oriented (rather than word-oriented) encoding. There is no math involved, it just works by construction. Regards Antoine. From tjreedy at udel.edu Mon Jan 17 17:47:28 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Mon, 17 Jan 2011 17:47:28 -0500 Subject: Tkinter: The good, the bad, and the ugly! In-Reply-To: <3af4fd5e-8cc9-4cec-aad2-cbf82ad3bab3@l24g2000vby.googlegroups.com> References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <79a8a$4d332d1a$4275d90a$3986@FUSE.NET> <64976187-88ad-47c9-9bc6-c0712a657264@j32g2000yqc.googlegroups.com> <3af4fd5e-8cc9-4cec-aad2-cbf82ad3bab3@l24g2000vby.googlegroups.com> Message-ID: On 1/16/2011 11:20 PM, rantingrick wrote: > Ok, try this... > > http://juicereceiver.sourceforge.net/screenshots/index.php > http://www.sensi.org/~ak/pyslsk/pyslsk6.png > http://www.wxwidgets.org/about/screensh.htm Ok, wxwidgets can look at least as good as tk. Agreed that wxpython might instead link to the excellent wxwidgets page. -- Terry Jan Reedy From sysengp2p at gmail.com Mon Jan 17 17:51:21 2011 From: sysengp2p at gmail.com (carlo) Date: Mon, 17 Jan 2011 14:51:21 -0800 (PST) Subject: UTF-8 question from Dive into Python 3 References: Message-ID: On 17 Gen, 23:34, Antoine Pitrou wrote: > On Mon, 17 Jan 2011 14:19:13 -0800 (PST) > > carlo wrote: > > Is it true UTF-8 does not have any "big-endian/little-endian" issue > > because of its encoding method? > > Yes. > > > And if it is true, why Mark (and > > everyone does) writes about UTF-8 with and without BOM some chapters > > later? What would be the BOM purpose then? > > "BOM" in this case is a misnomer. For UTF-8, it is only used as a > marker (a magic number, if you like) to signal than a given text file > is UTF-8. The UTF-8 "BOM" does not say anything about byte order; and, > actually, it does not change with endianness. > > (note that it is not required to put an UTF-8 "BOM" at the beginning of > text files; it is just a hint that some tools use when > generating/reading UTF-8) > > > 2- If that were true, can you point me to some documentation about the > > math that, as Mark says, demonstrates this? > > Math? UTF-8 is simply a byte-oriented (rather than word-oriented) > encoding. There is no math involved, it just works by construction. > > Regards > > Antoine. thank you all, eventually found http://www.unicode.org/versions/Unicode5.2.0/ch03.pdf#G7404 which clears up. No math in fact, as Tim and Antoine pointed out. From drsalists at gmail.com Mon Jan 17 17:54:20 2011 From: drsalists at gmail.com (Dan Stromberg) Date: Mon, 17 Jan 2011 14:54:20 -0800 Subject: Efficient python 2-d arrays? In-Reply-To: References: Message-ID: On Mon, Jan 17, 2011 at 2:20 PM, Jake Biesinger wrote: > Hi all, > > Using numpy, I can create large 2-dimensional arrays quite easily. >>>> import numpy >>>> mylist = numpy.zeros((100000000,2), dtype=numpy.int32) > > Unfortunately, my target audience may not have numpy so I'd prefer not to use it. > > Similarly, a list-of-tuples using standard python syntax. >>>> mylist = [(0,0) for i in xrange(100000000) > > but this method uses way too much memory (>4GB for 100 million items, compared to 1.5GB for numpy method). > > Since I want to keep the two elements together during a sort, I *can't* use array.array. >>>> mylist = [array.array('i',xrange(100000000)), array.array('i',xrange(100000000))] > > If I knew the size in advance, I could use ctypes arrays. >>>> from ctypes import * >>>> class myStruct(Structure): >>>> ? ? _fields_ = [('x',c_int),('y',c_int)] >>>> mylist_type = myStruct * 100000000 >>>> mylist = mylist_type() > > but I don't know that size (and it can vary between 1 million-200 million), so preallocating doesn't seem to be an option. > > Is there a python standard library way of creating *efficient* 2-dimensional lists/arrays, still allowing me to sort and append? > > Thanks! > -- > http://mail.python.org/mailman/listinfo/python-list > I recently had need of a two dimensional array also, but I only needed small ones, so I just used a dictionary indexed by tuples. If you need to sort a row as an aggregate type, it seems that you probably either want to: 1) Use a list of lists, where the outer list is the easier one to sort by - this is analogous to the array of pointers in C - sorting by the outer would want to compare "elements" by looking at the 0th inner, then 1st inner, etc. So if you can organize things this way, things might be pretty easy. 2) Use a list of instances, where the instances (rows) might just include a list 3) Use array.array with a custom sort so that you can move multiple things when a more common sort would move "one" (possibly an aggregate). If you want some sorting code to start from for #3, I have a variety of sorts written in Python (pure python or cython, your option, each automatically derived from the same m4 file for a given sort) at http://stromberg.dnsalias.org/svn/sorts/compare/trunk/ - however, even the cython timsort provided there doesn't perform quite as well as the standard library's timsort. HTH From rantingrick at gmail.com Mon Jan 17 18:13:39 2011 From: rantingrick at gmail.com (rantingrick) Date: Mon, 17 Jan 2011 15:13:39 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <79a8a$4d332d1a$4275d90a$3986@FUSE.NET> <64976187-88ad-47c9-9bc6-c0712a657264@j32g2000yqc.googlegroups.com> <3af4fd5e-8cc9-4cec-aad2-cbf82ad3bab3@l24g2000vby.googlegroups.com> Message-ID: <7c1928e5-ba2c-4034-9a5d-3f20cfe756ab@1g2000yqz.googlegroups.com> On Jan 17, 4:47?pm, Terry Reedy wrote: > On 1/16/2011 11:20 PM, rantingrick wrote: > > > Ok, try this... > > > ? ? ?http://juicereceiver.sourceforge.net/screenshots/index.php > > ? ? ?http://www.sensi.org/~ak/pyslsk/pyslsk6.png > > ? ? ?http://www.wxwidgets.org/about/screensh.htm > > Ok, wxwidgets can look at least as good as tk. Agreed that wxpython > might instead link to the excellent wxwidgets page. > > -- > Terry Jan Reedy Thanks for being honest. We need more people acting in this manner and just think of the progress we could make, it would wonderful! You know we Python programmers are professional debaters. This has been my take on the Python community. However without the virtues of compromise and community spirit all we are going to do is fight like cats and dogs forever to the very detriment of the very community we wish to muster We need to look at these problems from a community perspective and tone down the rhetoric. The layer of thick sarcasm that exists is so viscous and putrid that any semblance of civility is completely impervious to it's gelatinous all encompassing mass. We need to get more folks involved in the decision process. We need more community discussion and less community corruption. Currently we have a small subset of the community making a large proportion of the decisions. We did have a monarchy ruled by our beloved dictator however it has degenerated into a banana republic! We need democracy and we need it now! From tjreedy at udel.edu Mon Jan 17 18:18:36 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Mon, 17 Jan 2011 18:18:36 -0500 Subject: __pycache__, one more good reason to stck with Python 2? In-Reply-To: <0c62aacd-e6d2-4778-81d6-e06924192add@j1g2000vbl.googlegroups.com> References: <23e02e0d-b2f1-4b52-85ea-d1feba99dd37@22g2000prx.googlegroups.com> <4d3466d3$0$29983$c3e8da3$5496439d@news.astraweb.com> <0c62aacd-e6d2-4778-81d6-e06924192add@j1g2000vbl.googlegroups.com> Message-ID: No. The benefit of, for instance, not adding 200 .pyc files to a directory with 200 .py files is immediately obvious to most people. On 1/17/2011 1:17 PM, jmfauth wrote: >> No, I'm sorry, they're not obvious at all. > These reasons become obious as soon as you start working. > > Let's take a practical point view. It did not take a long time > to understand, that it is much simpler to delete the __pycache__ > directory everytime I compile my scripts than to visit it just > because I deleted or renamed a .py file in my working directory. Deleting the subdirectory is as least as easy as searching through the directory to find one or more files. In any case, the obsolete misnamed .pyc files hurt very little. Delete once a year or so if the space is an issue. In 13 years, I have hardly ever worried about deleting .pyc files. > How long will it take to find on the web tools to parse and > delete ophan .pyc files on a hd? > > If I get (stupidly, I agree) a .pyc file and want to test > it. Should I create manually a cache alongside my test.py > script? Since this is stupid (your word), it should be rare ;-). Since it can be dangerous, it should be more difficult. If you get a zip or tar file from a trusted source, get the .__cache__ dir with the file. > If I wish to delete the numerous auxiliary files a TeX > document produces, I just del /rm .* to keep a clean working > dir. With Python now? Impossible! The files are spread in two > dirs (at least). I do not know what TeX has to do with Python. -- Terry Jan Reedy From usernet at ilthio.net Mon Jan 17 19:02:38 2011 From: usernet at ilthio.net (Tim Harig) Date: Tue, 18 Jan 2011 00:02:38 +0000 (UTC) Subject: [OT] Python like lanugages [was Re: After C++, what with Python?] References: <86a904f8-05b0-435f-81d6-7450650f1679@glegroupsg2000goo.googlegroups.com> <4d329899$0$43988$742ec2ed@news.sonic.net> <7x8vylfcvz.fsf@ruckus.brouhaha.com> <4d32c7cf$0$29983$c3e8da3$5496439d@news.astraweb.com> Message-ID: On 2011-01-17, geremy condra wrote: > On Mon, Jan 17, 2011 at 1:07 PM, Tim Harig wrote: >> On 2011-01-17, geremy condra wrote: >>> On Mon, Jan 17, 2011 at 1:12 AM, Tim Harig wrote: >>>> On 2011-01-16, geremy condra wrote: >> Go is every bit of a general purpose programming language. ?It is useful >> for the same basic applications that you would otherwise write in Java. ?It >> can do pretty much anything that you can do in C, with the probable >> exception of writing operating systems. ?I have been using C/C++ for most >> of my programming career; but, everything that I have done can be done with >> Go. ?I am not really sure where you are seeing such narrowing limitations. > > Some people get very attached to one language and use it for > everything. I'd rather use the right tool for the job. I much agree. You don't see me dropping python, shell, awk, etc. I do expect Go will enter some of the programming that I am doing in Python and it will almost certainly replace much of the programming that I am doing in C/C++. > Go is not an ideal language for high-performance code. Despite the > occasional claims of others, Go is consistently outperformed by C, > C++, and Java on a wide variety of benchmarks. Some claim that Ada and > Haskell do as well, and my benchmarks (CPU bound, focused on speed of I much agree that Go doesn't beat C or C++. I really doubt that it could with the runtime necessary to do garbage collction. Nevertheless, I find that Go can be optimized to perform within tolerable limits of C given the boost it gives in development. I really question that you get Java anywhere even close to C performance. Google reports they get within the same order of magnitude as C for their long-lived server processes where the JIT has had time to optimize its results. For shorter term processes such as desktop applications, Java performance stinks -- even after you discount the JVM starup time. Ada is capable of C++ like performance *if* you compile it to remove *all* of runtime checking. Depending what checks you enable, it can run much slower. > cryptographic primitives) *seem* to confirm that for Haskell. I say > 'seem' because I'm clearly much more familiar with Haskell than with > Go, and would be inclined to question my conclusions if they weren't I have not worked with Haskell, so I don't really have any idea's about its performance. I understand that leveraging lazy evaluation and result caching can provide some *huge* opportunities for optimizations. > in line with the work of others. You can argue that it's good enough- > it is, for most cases- but taking a 20% performance hit rules it out > of a lot of systems work, and the C-Go gap in many cases is much > larger than that. I don't work anything that involves and absolute need for performance. I could probably accept penalty several times that of C for higher level functionality; but, sometimes the penalty for Python is just too much. Many of my programs are very quick lived such that even loading an interpeter or VM can eclipse the actual runtime. Given less developmental effort required, I also find that I have more time to look for ways to optimize Go. There are many things (such as using alternate data structures rather then the build in slices and immutable strings) that can be used to accelerate Go when time permits and I suspect many more will be found as the language matures. > Go is also not an ideal language for enterprise development. It > provides no compatibility or support guarantees; in fact, the website > describes it as 'an experiment' and recommends it for 'adventurous There is no doubt that it is a young project and there are a number of things that will need to be improved to be effective for some branches of programming; but, that isn't a language restriction. Frankly, I am rather impressed by the sheer number of third party packages that have already become available. No go isn't going to replace some of the other top mainstream langauges today; but, I can easily see it starting to see some market penetration 5 years from now. > users'. There are no independent experts in case something goes wrong, > and if it goes belly up a year from now you will have a one year old > piece of legacy infrastructure on your hands. Maybe you don't think > that this will be the case; in any event, I would not want to try > convincing a CFO of that. If I was trying to convince a CFO, I would ask if he really thought Google was likely to simply drop the time and effort that Google has already placed into the infrastructure. Furthermore, few dying languages already have not one, but two, open source compilers available for use. > As you point out, Go is also not a good language for operating systems > work. The lack of a widely accepted GUI toolkit weakens your argument > about application development. The lack of third party tools and > dependence on foreign language bindings weakens your single-language > argument. Etc, etc, etc. I don't really do GUI programming so you are probably right about the need for GUI toolkits. I do know that there is a GTK binding available as well as direct X11 support. Database bindings are another weak link outside of the more common open source databases. In both cases, Go readily capable of C library functions as a stop-gap until a native wrapper is available. Yes it will be nice once community has filled in the gaps; but, I am rather impressed at what is already available in less then a years time. There are a few libraries you may have missed here: http://go-lang.cat-v.org/pure-go-libs http://go-lang.cat-v.org/library-bindings Every language I know of has some binds that are simply wrappers to C libraries. There isn't much gain in reinventing the wheel to create a 100% non-C implementation for every library available and there are strong disadvantages such as trail time from the C release until it is reimplented natively. What are the advantages of recreating the termcap parser just to be able to position a few characters on the screen? I will point out that Go's libraries are miles ahead of the standard C library and other minimalistic standard libraries. Many things are possible with even the most basic functionalities. I don't use Python bindings when using GNUplot simply because its easier to access GNUplot directly. Finally, and most importantly, nothing about any third party tools and libraries has any bearing on the generality language itself. >> Support for concurrency is really icing on the cake. ?I find it rather >> supprising that so many modern languages do not already support full >> concurrency constructs. > > Go's most-lauded feature is its goroutines. I suspect that if this > isn't a big deal for you, you aren't its primary use case. Actually, I would consider Go's implicit interfaces to be a far more important innovation. The goroutines are nice but not ground breaking. They are quite recognizable to other SCP concurrancy derivatives. >> http://www.infoq.com/interviews/johnson-armstrong-oop >> >> Listen to the third point. ?Object orientation is quite possible even >> without inheritance. ?Not all programming languages support the same set >> of OOP features. ?Not all classless OOP programming languages support >> inheritance. ?The basic definition of object oriented programming is >> programing with self contained objects which contain their own data and ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >> the procedures necessary to manipulate that data. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ > So C is OOP. Let's agree to disagree on that. C fails to be an object oriented language because it fails to provide the syntactic sugar necessary to bind functions to the data that they manipulate and because it doesn't provide the isolation necessary for encapsilation of objects. >>>> 2. Go has a similar mechanism to exceptions, defer/panic/recover. ?It does >>>> ? ? ? ?downplay >>> >>> Defer, panic, and recover only allow you to build a recovery stack. >>> That's like saying that try/except isn't needed anymore because you >>> have the with statement. Do you think you could get through a rewrite >>> of Django without ripping out some hair over that? >> >> I don't know what you are referencing about Django as I don't work on or >> with the project; but, if one wanted exceptions with similar sematics to >> Python's, it could easily be built around Go's defer/panic/recover. ?There >> are actually packages availble that recreate exceptions as they are used in >> Ruby and other languages. ?The only think defer/panic/recover lacks is an >> exception class containing more more detailed information about what >> actually went wrong. > > You could also build it in C, yet C is exceptionless and is commonly > faulted for that fact. defer/panic/recover is conceptually a world closer to exceptions then is setjmp/longjmp. It really isn't any further different then the variantions in exceptions between different languages. From programming at toomuchcookies.net Mon Jan 17 19:12:51 2011 From: programming at toomuchcookies.net (OAN) Date: Tue, 18 Jan 2011 01:12:51 +0100 Subject: Efficient python 2-d arrays? In-Reply-To: References: Message-ID: <4D34DB03.9010009@toomuchcookies.net> Hi, what about pytables? It's built for big data collections and it doesn't clog up the memory. Am 17.01.2011 23:54, schrieb Dan Stromberg: > On Mon, Jan 17, 2011 at 2:20 PM, Jake Biesinger > wrote: >> Hi all, >> >> Using numpy, I can create large 2-dimensional arrays quite easily. >>>>> import numpy >>>>> mylist = numpy.zeros((100000000,2), dtype=numpy.int32) >> Unfortunately, my target audience may not have numpy so I'd prefer not to use it. >> >> Similarly, a list-of-tuples using standard python syntax. >>>>> mylist = [(0,0) for i in xrange(100000000) >> but this method uses way too much memory (>4GB for 100 million items, compared to 1.5GB for numpy method). >> >> Since I want to keep the two elements together during a sort, I *can't* use array.array. >>>>> mylist = [array.array('i',xrange(100000000)), array.array('i',xrange(100000000))] >> If I knew the size in advance, I could use ctypes arrays. >>>>> from ctypes import * >>>>> class myStruct(Structure): >>>>> _fields_ = [('x',c_int),('y',c_int)] >>>>> mylist_type = myStruct * 100000000 >>>>> mylist = mylist_type() >> but I don't know that size (and it can vary between 1 million-200 million), so preallocating doesn't seem to be an option. >> >> Is there a python standard library way of creating *efficient* 2-dimensional lists/arrays, still allowing me to sort and append? >> >> Thanks! >> -- >> http://mail.python.org/mailman/listinfo/python-list >> > I recently had need of a two dimensional array also, but I only needed > small ones, so I just used a dictionary indexed by tuples. > > If you need to sort a row as an aggregate type, it seems that you > probably either want to: > 1) Use a list of lists, where the outer list is the easier one to sort > by - this is analogous to the array of pointers in C - sorting by the > outer would want to compare "elements" by looking at the 0th inner, > then 1st inner, etc. So if you can organize things this way, things > might be pretty easy. > 2) Use a list of instances, where the instances (rows) might just include a list > 3) Use array.array with a custom sort so that you can move multiple > things when a more common sort would move "one" (possibly an > aggregate). > > If you want some sorting code to start from for #3, I have a variety > of sorts written in Python (pure python or cython, your option, each > automatically derived from the same m4 file for a given sort) at > http://stromberg.dnsalias.org/svn/sorts/compare/trunk/ - however, even > the cython timsort provided there doesn't perform quite as well as the > standard library's timsort. > > HTH From martin at v.loewis.de Mon Jan 17 20:11:16 2011 From: martin at v.loewis.de (Martin v. Loewis) Date: Tue, 18 Jan 2011 02:11:16 +0100 Subject: Efficient python 2-d arrays? In-Reply-To: References: Message-ID: > Using numpy, I can create large 2-dimensional arrays quite easily. IIUC (please confirm), you don't need a generic two-dimensional array, but rather an Nx2 array, where N may be large (but the other dimension will always have a magnitude of 2). > Since I want to keep the two elements together during a sort I assume (please confirm) that you want to sort by one of the numbers, and keep the other one together with the sort key. I suggest that you implement your own sorting algorithm, or reuse heapsort (actually, any of the sorting algorithms would do). You then use array.array, and take the elements at indices 2k and 2k+1 together. Sorting would then only look at even indices, but any swapping you do during the sorting would always swap two numbers with two other numbers. Regards, Martin From jake.biesinger at gmail.com Mon Jan 17 20:30:55 2011 From: jake.biesinger at gmail.com (Jake Biesinger) Date: Mon, 17 Jan 2011 17:30:55 -0800 (PST) Subject: Efficient python 2-d arrays? In-Reply-To: Message-ID: > IIUC (please confirm), you don't need a generic two-dimensional > array, but rather an Nx2 array, where N may be large (but the other > dimension will always have a magnitude of 2). Yes, that's right, Nx2 not NxM. > > Since I want to keep the two elements together during a sort > > I assume (please confirm) that you want to sort by one of the numbers, > and keep the other one together with the sort key. Again, yes. > I suggest that you implement your own sorting algorithm, or reuse > heapsort (actually, any of the sorting algorithms would do). > > You then use array.array, and take the elements at indices 2k and 2k+1 > together. Sorting would then only look at even indices, but any swapping > you do during the sorting would always swap two numbers with two other > numbers. Yes, this is an option. Writing a custom sort function just didn't sound very appealing and I was hoping for a more generic solution. Thanks! From jake.biesinger at gmail.com Mon Jan 17 20:32:34 2011 From: jake.biesinger at gmail.com (Jake Biesinger) Date: Mon, 17 Jan 2011 17:32:34 -0800 (PST) Subject: Efficient python 2-d arrays? In-Reply-To: Message-ID: <28a234f1-c4d7-41a4-a1c5-74ee48a1e9f0@glegroupsg2000goo.googlegroups.com> On Monday, January 17, 2011 4:12:51 PM UTC-8, OAN wrote: > Hi, > > what about pytables? It's built for big data collections and it doesn't > clog up the memory. I thought PyTables depends on NumPy? Otherwise I would indeed use their carray module. Thanks! From jake.biesinger at gmail.com Mon Jan 17 20:32:34 2011 From: jake.biesinger at gmail.com (Jake Biesinger) Date: Mon, 17 Jan 2011 17:32:34 -0800 (PST) Subject: Efficient python 2-d arrays? In-Reply-To: Message-ID: <28a234f1-c4d7-41a4-a1c5-74ee48a1e9f0@glegroupsg2000goo.googlegroups.com> On Monday, January 17, 2011 4:12:51 PM UTC-8, OAN wrote: > Hi, > > what about pytables? It's built for big data collections and it doesn't > clog up the memory. I thought PyTables depends on NumPy? Otherwise I would indeed use their carray module. Thanks! From flisboa.costa at gmail.com Mon Jan 17 20:59:15 2011 From: flisboa.costa at gmail.com (=?UTF-8?B?RmzDoXZpbyBMaXNiw7Rh?=) Date: Mon, 17 Jan 2011 22:59:15 -0300 Subject: __pycache__, one more good reason to stck with Python 2? In-Reply-To: <0c62aacd-e6d2-4778-81d6-e06924192add@j1g2000vbl.googlegroups.com> References: <23e02e0d-b2f1-4b52-85ea-d1feba99dd37@22g2000prx.googlegroups.com> <4d3466d3$0$29983$c3e8da3$5496439d@news.astraweb.com> <0c62aacd-e6d2-4778-81d6-e06924192add@j1g2000vbl.googlegroups.com> Message-ID: That's why i disagree (and hate) the automatic compilation of code, my project directory becomes full of object files, and then i need to either delete everything manually or create a script to do the work (not in python, because it'll dirt things even more :). Sometimes i notice python doesn't recompile the .pyc in response to changes in .py (because i share my project folders between computers using Dropbox). Unless this is just a rant, maybe you could use the PYTHONDONTWRITEBYTECODE environment flag or set the -B flag when executing the python interpreter. This flag deactivates auto-compilation, and may also deactivate __pycache__ effects, but i'm not sure, i can't test it now. See http://docs.python.org/using/cmdline.html#envvar-PYTHONDONTWRITEBYTECODE . The implications of deactivating this behaviour are somewhat obvious, and i wonder what impacts it'd cause on your system (but i hardly expect it to be anything serious). After reading some articles about it, I've come to think python depends a lot on bytecode writing on the filesystem. I wonder if it's good or bad. I find it so invasive, and that it should not be the default behaviour. But that's me, i'm sure most of python users don't mind at all. -------------- next part -------------- An HTML attachment was scrubbed... URL: From pavlovevidence at gmail.com Mon Jan 17 21:26:14 2011 From: pavlovevidence at gmail.com (Carl Banks) Date: Mon, 17 Jan 2011 18:26:14 -0800 (PST) Subject: Efficient python 2-d arrays? References: Message-ID: <3ab5326f-bf39-4dfa-9875-a1bfd5ccab68@w29g2000vba.googlegroups.com> On Jan 17, 2:20?pm, Jake Biesinger wrote: > Is there a python standard library way of creating *efficient* 2-dimensional lists/arrays, still allowing me to sort and append? Without using third party libraries, no not really. numpy has it covered so there's not really a lot of demand for it. If your users are loading 1.5 GB arrays into memory, it's probably not unreasonable to expect them to have numpy installed. Other than that you're probably stuck emulating 2D with the array module. Carl Banks From alice at gothcandy.com Mon Jan 17 21:29:50 2011 From: alice at gothcandy.com (=?utf-8?Q?Alice_Bevan=E2=80=93McGregor?=) Date: Mon, 17 Jan 2011 18:29:50 -0800 Subject: __pycache__, one more good reason to stck with Python 2? References: <23e02e0d-b2f1-4b52-85ea-d1feba99dd37@22g2000prx.googlegroups.com> <4d3466d3$0$29983$c3e8da3$5496439d@news.astraweb.com> <0c62aacd-e6d2-4778-81d6-e06924192add@j1g2000vbl.googlegroups.com> Message-ID: find . -name \*.pyc -exec rm -f {} \; vs. rm -rf __pycache__ I do not see how this is more difficult, but I may be missing something. ? Alice. From pruebauno at latinmail.com Mon Jan 17 21:51:01 2011 From: pruebauno at latinmail.com (nn) Date: Mon, 17 Jan 2011 18:51:01 -0800 (PST) Subject: move to end, in Python 3.2 Really? Message-ID: <58c17709-d68e-4448-b618-b6f594d0e8c5@t35g2000yqj.googlegroups.com> I somehow missed this before. I like most of the additions from Raymond Hettinger. But the api on this baffles me a bit: >>> d = OrderedDict.fromkeys('abcde') >>> d.move_to_end('b', last=False) >>> ''.join(d.keys) 'bacde' I understand that "end" could potentially mean either end, but would "move_to_end" and "move_to_beginning" not have been clearer? From rantingrick at gmail.com Mon Jan 17 21:58:57 2011 From: rantingrick at gmail.com (rantingrick) Date: Mon, 17 Jan 2011 18:58:57 -0800 (PST) Subject: move to end, in Python 3.2 Really? References: <58c17709-d68e-4448-b618-b6f594d0e8c5@t35g2000yqj.googlegroups.com> Message-ID: <8a0329a1-e84e-43f0-a89e-a2c66dab41e6@30g2000yql.googlegroups.com> On Jan 17, 8:51?pm, nn wrote: > I somehow missed this before. I like most of the additions from > Raymond Hettinger. But the api on this baffles me a bit: If we are not careful with all these "additions" we could end up with a language like ruby which has wasteful methods to clean your backside, and take out your trash -- clogging up your dir requests >:( Multiplicity is a slippery slope my friend! From tjreedy at udel.edu Mon Jan 17 22:39:33 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Mon, 17 Jan 2011 22:39:33 -0500 Subject: __pycache__, one more good reason to stck with Python 2? In-Reply-To: References: <23e02e0d-b2f1-4b52-85ea-d1feba99dd37@22g2000prx.googlegroups.com> <4d3466d3$0$29983$c3e8da3$5496439d@news.astraweb.com> <0c62aacd-e6d2-4778-81d6-e06924192add@j1g2000vbl.googlegroups.com> Message-ID: On 1/17/2011 8:59 PM, Fl?vio Lisb?a wrote: > That's why i disagree (and hate) the automatic compilation of code, my > project directory becomes full of object files That is one point of stashing them all in a .__pycache__ directory. > After reading some articles about it, I've come to think python depends > a lot on bytecode writing on the filesystem. A purely interpreted Python would be much slower. Saving module code to the filesystem speeds startup, which most find slow as it is. > I wonder if it's good or > bad. I find it so invasive, and that it should not be the default > behaviour. But that's me, i'm sure most of python users don't mind at all. Seems so. Complaints are rare. -- Terry Jan Reedy From ben+python at benfinney.id.au Mon Jan 17 22:57:13 2011 From: ben+python at benfinney.id.au (Ben Finney) Date: Tue, 18 Jan 2011 14:57:13 +1100 Subject: __pycache__, one more good reason to stck with Python 2? References: <23e02e0d-b2f1-4b52-85ea-d1feba99dd37@22g2000prx.googlegroups.com> <4d3466d3$0$29983$c3e8da3$5496439d@news.astraweb.com> <0c62aacd-e6d2-4778-81d6-e06924192add@j1g2000vbl.googlegroups.com> Message-ID: <87vd1m6ezq.fsf@benfinney.id.au> Terry Reedy writes: > On 1/17/2011 8:59 PM, Fl?vio Lisb?a wrote: > > But that's me, i'm sure most of python users don't mind at all. > > Seems so. Complaints are rare. That conclusion isn't valid; the behaviour is (AIUI) only in Python 3.2 and later. You can't presume that a lack of complaints means anything about ?most Python users? until those users are on a Python that shows this behaviour. -- \ ?If nature has made any one thing less susceptible than all | `\ others of exclusive property, it is the action of the thinking | _o__) power called an idea? ?Thomas Jefferson | Ben Finney From rustompmody at gmail.com Mon Jan 17 23:24:30 2011 From: rustompmody at gmail.com (rusi) Date: Mon, 17 Jan 2011 20:24:30 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <79a8a$4d332d1a$4275d90a$3986@FUSE.NET> <64976187-88ad-47c9-9bc6-c0712a657264@j32g2000yqc.googlegroups.com> <3af4fd5e-8cc9-4cec-aad2-cbf82ad3bab3@l24g2000vby.googlegroups.com> <7c1928e5-ba2c-4034-9a5d-3f20cfe756ab@1g2000yqz.googlegroups.com> Message-ID: <44dfe215-4e9d-4621-8999-1f46536df878@d1g2000pra.googlegroups.com> On Jan 18, 4:13?am, rantingrick wrote: > On Jan 17, 4:47?pm, Terry Reedy wrote: > > > On 1/16/2011 11:20 PM, rantingrick wrote: > > > > Ok, try this... > > > > ? ? ?http://juicereceiver.sourceforge.net/screenshots/index.php > > > ? ? ?http://www.sensi.org/~ak/pyslsk/pyslsk6.png > > > ? ? ?http://www.wxwidgets.org/about/screensh.htm > > > Ok, wxwidgets can look at least as good as tk. Agreed that wxpython > > might instead link to the excellent wxwidgets page. > > > -- > > Terry Jan Reedy > > Thanks for being honest. We need more people acting in this manner and > just think of the progress we could make, it would wonderful! > > You know we Python programmers are professional debaters. This has > been my take on the Python community. However without the virtues of > compromise and community spirit all we are going to do is fight like > cats and dogs forever to the very detriment of the very community we > wish to muster > > ?We need to look at these problems from a community perspective and > tone down the rhetoric. The layer of thick sarcasm that exists is so > viscous and putrid that any semblance of civility is completely > impervious to it's gelatinous all encompassing mass. We need to get > more folks involved in the decision process. We need more community > discussion and less community corruption. Currently we have a small > subset of the community making a large proportion of the decisions. We > did have a monarchy ruled by our beloved dictator however it has > degenerated into a banana republic! We need democracy and we need it > now! Lehman Beladys entropy law http://en.wikipedia.org/wiki/Lehman%27s_laws_of_software_evolution says The quality of ... systems will decline unless they are rigorously maintained and adapted to operational environment changes. Just look at emacs --once upon a time the best editor for alpha geeks, today unable to get rid of 40 years of cruft. Guido's 'benevolent dictatorship' has so far kept python the exception because - he give powerful batteries to start with - does not introduce junk - is not afraid of backward incompatibility for the sake of clarity and cleanliness (python3) Gui (and web) frameworks are two of his more visible failures From pavlovevidence at gmail.com Mon Jan 17 23:40:23 2011 From: pavlovevidence at gmail.com (Carl Banks) Date: Mon, 17 Jan 2011 20:40:23 -0800 (PST) Subject: __pycache__, one more good reason to stck with Python 2? References: <23e02e0d-b2f1-4b52-85ea-d1feba99dd37@22g2000prx.googlegroups.com> <4d3466d3$0$29983$c3e8da3$5496439d@news.astraweb.com> <0c62aacd-e6d2-4778-81d6-e06924192add@j1g2000vbl.googlegroups.com> Message-ID: <77ef8068-7f07-404f-8b0e-c039d1122659@e16g2000pri.googlegroups.com> On Jan 17, 6:29?pm, Alice Bevan?McGregor wrote: > ? ? ? ? find . -name \*.pyc -exec rm -f {} \; > > vs. > > ? ? ? ? rm -rf __pycache__ > > I do not see how this is more difficult, but I may be missing something. Well the former deletes all the pyc files in the directory tree whereas the latter only deletes the top level __pycache__, not the __pycache__ for subpackages. To delete all the __pycache__s you'd have to do something like this: file . -name __pycache__ -prune -exec rm -rf {} \; or, better, file . -name __pycache__ -prune | xargs rm -rf Still not anything really difficult. (I don't think a lot of people know about -prune; it tells find don't recursively descend.) Carl Banks From pavlovevidence at gmail.com Mon Jan 17 23:51:13 2011 From: pavlovevidence at gmail.com (Carl Banks) Date: Mon, 17 Jan 2011 20:51:13 -0800 (PST) Subject: __pycache__, one more good reason to stck with Python 2? References: <23e02e0d-b2f1-4b52-85ea-d1feba99dd37@22g2000prx.googlegroups.com> <4d3466d3$0$29983$c3e8da3$5496439d@news.astraweb.com> <0c62aacd-e6d2-4778-81d6-e06924192add@j1g2000vbl.googlegroups.com> Message-ID: <58b2111d-f0d5-499b-8339-6b27bb4743ca@z17g2000prz.googlegroups.com> On Jan 17, 10:17?am, jmfauth wrote: > > No, I'm sorry, they're not obvious at all. > > These reasons become obious as soon as you start working. > > Let's take a practical point view. It did not take a long time > to understand, that it is much simpler to delete the __pycache__ > directory everytime I compile my scripts than to visit it just > because I deleted or renamed a .py file in my working directory. According to PEP 3147, stale *.pyc files in the __pycache__ directories are ignored. So it's no longer necessary to delete the *.pyc files when renaming a *.py file. This is a big improvement, and easily justifies __pycache__ IMO, even without the distro considerations. > How long will it take to find on the web tools to parse and > delete ophan .pyc files on a hd? Probably under a month. (Updating old tools to work with new scheme will take a bit longer.) > If I get (stupidly, I agree) a .pyc file and want to test > it. Should I create manually a cache alongside my test.py > script? Nope: according to PEP 3147 a standalone *.pyc should not be put in same directory where the source file would have been, not in the __pycache__ directory (it'll be considered stale otherwise). It says this is for backwards compatibility, but I think there are valid reasons you don't want to deliver source so it's good that we can still do that. > If I wish to delete the numerous auxiliary files a TeX > document produces, I just del /rm .* to keep a clean working > dir. With Python now? Impossible! The files are spread in two > dirs (at least). > > ... > > That's life, unfortunately. Give yourself a little time. The one little non-temporary drawback I see for __pycache__ is if you have a directory with lots of stuff and one or two python files in the mix; and then you add that directory to sys.path and import the files. It creates the __pycache__ in that directory. It's a bit of a shock compared to the *.pyc files because it's at a very different place in the listings, and is a directory and not a file. But that's a minor thing. Carl Banks From tjreedy at udel.edu Tue Jan 18 00:07:05 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Tue, 18 Jan 2011 00:07:05 -0500 Subject: __pycache__, one more good reason to stck with Python 2? In-Reply-To: <87vd1m6ezq.fsf@benfinney.id.au> References: <23e02e0d-b2f1-4b52-85ea-d1feba99dd37@22g2000prx.googlegroups.com> <4d3466d3$0$29983$c3e8da3$5496439d@news.astraweb.com> <0c62aacd-e6d2-4778-81d6-e06924192add@j1g2000vbl.googlegroups.com> <87vd1m6ezq.fsf@benfinney.id.au> Message-ID: On 1/17/2011 10:57 PM, Ben Finney wrote: > Terry Reedy writes: > >> On 1/17/2011 8:59 PM, Fl?vio Lisb?a wrote: >>> But that's me, i'm sure most of python users don't mind at all. >> >> Seems so. Complaints are rare. > > That conclusion isn't valid; the behaviour is (AIUI) only in Python 3.2 > and later. You can't presume that a lack of complaints means anything > about ?most Python users? until those users are on a Python that shows > this behaviour. The person I was responding to was complaining, I believe, about .pyc files in the project directory, which I take to be the same directory as .py files. This is the 21-year-old behavior now changed. -- Terry Jan Reedy From pavlovevidence at gmail.com Tue Jan 18 00:09:42 2011 From: pavlovevidence at gmail.com (Carl Banks) Date: Mon, 17 Jan 2011 21:09:42 -0800 (PST) Subject: __pycache__, one more good reason to stck with Python 2? References: <23e02e0d-b2f1-4b52-85ea-d1feba99dd37@22g2000prx.googlegroups.com> <4d3466d3$0$29983$c3e8da3$5496439d@news.astraweb.com> <0c62aacd-e6d2-4778-81d6-e06924192add@j1g2000vbl.googlegroups.com> Message-ID: <4956ce5a-11f7-43c1-9936-fd6957af2023@u13g2000prd.googlegroups.com> On Jan 17, 10:17?am, jmfauth wrote: > That's life, unfortunately. Also, an earlier version of the proposal was to create a *.pyr directory for each *.py file. That was a real mess; be thankful they worked on it and came up with a much cleaner method. Carl Banks From rantingrick at gmail.com Tue Jan 18 00:18:16 2011 From: rantingrick at gmail.com (rantingrick) Date: Mon, 17 Jan 2011 21:18:16 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <79a8a$4d332d1a$4275d90a$3986@FUSE.NET> <64976187-88ad-47c9-9bc6-c0712a657264@j32g2000yqc.googlegroups.com> <3af4fd5e-8cc9-4cec-aad2-cbf82ad3bab3@l24g2000vby.googlegroups.com> <7c1928e5-ba2c-4034-9a5d-3f20cfe756ab@1g2000yqz.googlegroups.com> <44dfe215-4e9d-4621-8999-1f46536df878@d1g2000pra.googlegroups.com> Message-ID: <37d23248-b47a-4af5-8a98-f3002fa259d0@e20g2000vbn.googlegroups.com> On Jan 17, 10:24?pm, rusi wrote: > The quality of ... systems will ?decline unless they are rigorously > maintained and adapted to operational environment changes. This is both eloquent and frightening at the same time when applied to the current state of Python's stdlib. We have come so far and forged a path of langauge innovation. However we have now entered a state of limbo, we have solidified -- This collective static state has manifested both in the tangible (stdlib) and more frighteningly the intangible (community). Are we going to allow this slow decay to wither away all the work that has been done because we cannot come to a consensus on anything as a community? Heck i'll bet we could not even agree on what punch to serve at the next Pycon much less makes some real decisions that concern this community. When does the slightly overweight spare tire become the morbidly obese? When does losing a few hairs become que ball histeria , and when does the slow creeping of time catch up to the blissful ignorants and mortality slap you in the face *slap*. Sadly and most often-ly when the missed opportunities are now but wishful fantasies and stories of glory days unrealized! Are we in those days as a community? Maybe? > Just look at emacs --once upon a time the best editor for alpha geeks, > today unable to get rid of 40 years of cruft. Today emacs, tomorrow Python. > Guido's 'benevolent dictatorship' has so far kept python the exception > because > - he give powerful batteries to start with > - does not introduce junk > - is not afraid of backward incompatibility for the sake of clarity > and cleanliness (python3) Agreed > Gui (and web) frameworks are two of his more visible failures His initial intention were pure. However TclTk may turn out to be GvR's Achilles heel. It seems Tkinter has metamorphosis into some ill legitimate red-headed step child that the community both hates and loves at the same time. Or is something more sinister at work here? Could a high ranking TclTk "Guru" be within the "inner circle" of Python dev? Or maybe even Guido's close friend? Could emotions and back door politics be standing in the way of Tkinters graceful exit? Is hurting one or two peoples feelings really that bad in face of what is best for a community? In any event we definitely need a mid life crisis to wake ourselves from this slow decay of narcissism, sarcasm, pretentiousness, apathy, and just outright laziness that is destroying everything we hold dear. Because the bell that tolls, may just be our own (as a community). From steve+comp.lang.python at pearwood.info Tue Jan 18 00:19:01 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 18 Jan 2011 05:19:01 GMT Subject: [OT] Python like lanugages [was Re: After C++, what with Python?] References: <86a904f8-05b0-435f-81d6-7450650f1679@glegroupsg2000goo.googlegroups.com> <4d329899$0$43988$742ec2ed@news.sonic.net> <7x8vylfcvz.fsf@ruckus.brouhaha.com> <4d32c7cf$0$29983$c3e8da3$5496439d@news.astraweb.com> <4d3425fe$0$29983$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4d3522c5$0$29990$c3e8da3$5496439d@news.astraweb.com> On Mon, 17 Jan 2011 19:41:54 +0000, Tim Harig wrote: > One of the arguments for Python has always made is that you can optimize > it by writing the most important parts in C. Perhaps that is a crutch > that has held the communty back from seeking higher performance > solutions in the language itself. Are you aware of PyPy? PyPy is now about double the speed of CPython for most things, and they have set themselves the ambitious target of being faster than C. http://codespeak.net/pypy/dist/pypy/doc/faq.html -- Steven From pavlovevidence at gmail.com Tue Jan 18 00:20:19 2011 From: pavlovevidence at gmail.com (Carl Banks) Date: Mon, 17 Jan 2011 21:20:19 -0800 (PST) Subject: move to end, in Python 3.2 Really? References: <58c17709-d68e-4448-b618-b6f594d0e8c5@t35g2000yqj.googlegroups.com> Message-ID: On Jan 17, 6:51?pm, nn wrote: > I somehow missed this before. I like most of the additions from > Raymond Hettinger. But the api on this baffles me a bit: > > >>> d = OrderedDict.fromkeys('abcde') > >>> d.move_to_end('b', last=False) > >>> ''.join(d.keys) > > 'bacde' > > I understand that "end" could potentially mean either end, but would > "move_to_end" and "move_to_beginning" not have been clearer? It's a minor issue, but I'd tend to lean that way. Most other times when something can happen on one end of a sequence or another, it uses different function calls. E.g.: startswith vs endswith, lstrip vs rstrip, and even pop vs popleft. Oddly, Hettinger seems to be a big advocate of not overloading functions. Carl Banks From python at rcn.com Tue Jan 18 00:20:48 2011 From: python at rcn.com (Raymond Hettinger) Date: Mon, 17 Jan 2011 21:20:48 -0800 (PST) Subject: move to end, in Python 3.2 Really? References: <58c17709-d68e-4448-b618-b6f594d0e8c5@t35g2000yqj.googlegroups.com> Message-ID: <125db7fe-036e-47c9-be89-50f05106936f@n2g2000pre.googlegroups.com> On Jan 17, 6:51?pm, nn wrote: > ...But the api on this baffles me a bit: > > >>> d = OrderedDict.fromkeys('abcde') > >>> d.move_to_end('b', last=False) > >>> ''.join(d.keys) > > 'bacde' > > I understand that "end" could potentially mean either end, but would > "move_to_end" and "move_to_beginning" not have been clearer? The default (and normal usage) is to move an item to the last position. So, od.move_to_end(k) becomes a fast equivalent to v=d.pop(k) followed by d[k]=v. The less common usage of moving to the beginning is done with last=False. This parallels the existing API for od.popitem(): >>> od = OrderedDict.fromkeys('abcdefghi') >>> od.move_to_end('c') # default case: move to last >>> od.popitem() # default case: pop from last ('c', None) >>> od.move_to_end('d', last=False) # other case: move to first >>> od.popitem(last=False) # other case: pop from first ('d', None) The existing list.pop() API is similar (though it takes an index value instead of a boolean): >>> mylist.pop() # default case: pop from last >>> mylist.pop(0) # other case: pop from first Those were the design considerations. Sorry you didn't like the result. Raymond From rantingrick at gmail.com Tue Jan 18 00:28:43 2011 From: rantingrick at gmail.com (rantingrick) Date: Mon, 17 Jan 2011 21:28:43 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <79a8a$4d332d1a$4275d90a$3986@FUSE.NET> <64976187-88ad-47c9-9bc6-c0712a657264@j32g2000yqc.googlegroups.com> <3af4fd5e-8cc9-4cec-aad2-cbf82ad3bab3@l24g2000vby.googlegroups.com> <7c1928e5-ba2c-4034-9a5d-3f20cfe756ab@1g2000yqz.googlegroups.com> <44dfe215-4e9d-4621-8999-1f46536df878@d1g2000pra.googlegroups.com> <37d23248-b47a-4af5-8a98-f3002fa259d0@e20g2000vbn.googlegroups.com> Message-ID: I have proposed this before and i shall propose it again. Most of the naysayers parrot off about how many people use Tkinter. Maybe they are right, and maybe they are wrong. Nobody, and i repeat NOBODY even GvR himself can offer reliable evidence as to how important moduleX *is* or *is not* to this community... However i can! I propose a truly democratic method by which we can gather REAL data about what is important, and what is not important to the average Python programmer. I am not suggesting that this data be an official vote. I am only suggesting that those who walk the halls of "privilege" should listen carefully to the peasants when making decisions that affect the peasants. To make a long story short my proposal is to send out a warning in the next official release of Python. The warning will be as follows... """ ------------------------------- ModuleRemovalWarning: Tkinter ------------------------------- The GUI module "Tkinter" is being considered for removal from the Python stdlib FOREVER. If you use Tkinter and wish for it to stay in the stdlib you need to visit "www.savetkinter.com" and cast your vote now. The voting will end on dd/mm/yyyy so make sure to cast your vote or don't be complaining about it later. Note: Simon Cowell WILL NOT be making a celebrity appearance! """ If i need to create a PEP i will. From stefan_ml at behnel.de Tue Jan 18 02:06:42 2011 From: stefan_ml at behnel.de (Stefan Behnel) Date: Tue, 18 Jan 2011 08:06:42 +0100 Subject: Need the list of XML parsers In-Reply-To: <625910e2-22c2-4365-bc34-d0f9d5af8c65@glegroupsg2000goo.googlegroups.com> References: <625910e2-22c2-4365-bc34-d0f9d5af8c65@glegroupsg2000goo.googlegroups.com> Message-ID: Venu, 17.01.2011 21:34: > Using cElementTree, would you be willing show to me how to find the nodes with certain attribute, ie search using attributes and attibute values. > I did not see any example code from the cElementTree official website. Check out the documentation of ElementTree and lxml.etree. That should get you going. Stefan From stefan_ml at behnel.de Tue Jan 18 02:08:50 2011 From: stefan_ml at behnel.de (Stefan Behnel) Date: Tue, 18 Jan 2011 08:08:50 +0100 Subject: Need the list of XML parsers In-Reply-To: References: <9f75fdb8-78e3-4675-a48a-64147e0a0095@w29g2000vba.googlegroups.com> <4D3480F4.6070606@sudheer.net> Message-ID: Venu Allipuram, 17.01.2011 21:01: > lxml is a great one, but it is not simple to install libxml and libxslt on > Linux using user permissions. Well, you have to build it, obviously. Just pass "--static-deps" to the build script and it will build and link libxml2 and libxslt automatically for you. Stefan From stefan_ml at behnel.de Tue Jan 18 02:31:26 2011 From: stefan_ml at behnel.de (Stefan Behnel) Date: Tue, 18 Jan 2011 08:31:26 +0100 Subject: [OT] Python like lanugages [was Re: After C++, what with Python?] In-Reply-To: References: <86a904f8-05b0-435f-81d6-7450650f1679@glegroupsg2000goo.googlegroups.com> <4d329899$0$43988$742ec2ed@news.sonic.net> <7x8vylfcvz.fsf@ruckus.brouhaha.com> <4d32c7cf$0$29983$c3e8da3$5496439d@news.astraweb.com> <4d3425fe$0$29983$c3e8da3$5496439d@news.astraweb.com> Message-ID: Tim Harig, 17.01.2011 20:41: > In comp.lang.python, I wrote: >> Tim Harig, 17.01.2011 13:25: >>> If I didn't think Python was a good language, I wouldn't be here. >>> Nevertheless, it isn't a good fit for many pieces of software where a >>> systems language is better suited. Reasons include ease of distribution >>> without an interpeter, non-necessity of distributing source with the >>> product, ability to leverage multiple CPU and multicore systems, and >>> simple sequential performance. >>> >>> Given that Python does't work well in many areas, we could just give up >>> and accept having to write C++ for our day jobs or we can look for a >>> language which bridges the gap between those tasks that require C++'s >>> level of control and those which work well for dynamic languages. >>> Java attempted to do that, and has the market share to show that the >>> concept works, but I think that it missed the mark for many needs. It is >>> still much lower level then Python for purposes of rapid developement >>> and too slow to be competative for non-long-lived tasks. >> >> So seriously need to take a look at Cython. >> >> http://cython.org > > One of the arguments for Python has always made is that you can optimize > it by writing the most important parts in C. Perhaps that is a crutch > that has held the communty back from seeking higher performance solutions > in the language itself. The good news with Cython is that you no longer need to "write the most important parts in C". Instead, you type them statically and compile them. You don't even need to sacrifice Python source compatibility for that. So you get the best of Python at the speed of C (or 'c', as some would say ;). > I prefer a single language as opposed to a creolization of two. With the possible exception of Lisp, I find it hard to think of a language that's still alive and not the creolisation of (at least) two other languages. They all inherited from each other, sometimes right from the start ("lessons learned") and always during their subsequent life time. > I certainly don't need to require anybody who > wants to use a program I have compiled to install an interpreter. You will be happy to hear that you can link Cython programs against libpython (even statically) to build an executable that embeds the interpreter for you. Besides, on most operating systems, installing a dependency is done automatically, and Go code doesn't run natively on Windows either, without first installing and running the compiler over it. Stefan From healthyweightloss2burnfat at gmail.com Tue Jan 18 03:30:31 2011 From: healthyweightloss2burnfat at gmail.com (something healthy) Date: Tue, 18 Jan 2011 00:30:31 -0800 (PST) Subject: How to lose calories before your wedding Message-ID: <11ffdf1a-41b7-421c-820c-5f775666e90b@l24g2000vby.googlegroups.com> How to lose calories before your wedding http://healthyweightlossways.blogspot.com/2011/01/how-to-lose-calories-before-your.html From orasnita at gmail.com Tue Jan 18 03:49:42 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Tue, 18 Jan 2011 10:49:42 +0200 Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com><4d337983$0$29983$c3e8da3$5496439d@news.astraweb.com><044a5101-948d-4458-9c94-57dbb3e25f67@m35g2000vbn.googlegroups.com><4d3467bf$0$29983$c3e8da3$5496439d@news.astraweb.com> Message-ID: From: "Adam Skutt" Subject: Re: Tkinter: The good, the bad, and the ugly! On Jan 17, 3:08 pm, "Octavian Rasnita" wrote: >> From: "Adam Skutt" >> And we're not discussing those languages, we're discussing Python, >> which has an explicit policy of "batteries included". As such, >> criticism of the standard library is perfectly acceptable under the >> name "Python", whether you like it or not. Besides, it's inevitable >> anyway. > > "Batteries included"? > > Python doesn't follow this policy at all. We can say that maybe PHP > follows it, but not Python. > http://lmgtfy.com/?q=python+%22batteries+included%22&l=1 Well, this doesn't mean anything because Perl can also say that includes batteries, and PHP can say it also. > And if this is the wanted policy, why should it be "cheap batteries > included" and not "strong batteries included"? You'd have this same argument regardless of GUI toolkit you end up picking, or even if you choose to not include one at all. This would be because none of them are universal solutions, all of them have deficiencies (actual or perceived) that make them unsuitable for certain applications. Adam You are perfectly right. Then why favor Tkinter and not WxPython. Why not strip the Python package and offer WxPython and Tkinter separately? Octavian From orasnita at gmail.com Tue Jan 18 03:58:01 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Tue, 18 Jan 2011 10:58:01 +0200 Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com><4d337983$0$29983$c3e8da3$5496439d@news.astraweb.com><044a5101-948d-4458-9c94-57dbb3e25f67@m35g2000vbn.googlegroups.com><4d3467bf$0$29983$c3e8da3$5496439d@news.astraweb.com> <4D34B04E.8050309@web.de> Message-ID: <4266E8D7BA204BFEA5BF66C635CE1716@octavian> From: "Alexander Kapps" > On 17.01.2011 21:04, Octavian Rasnita wrote: >> I say probably not considering the availability of 3rd party >> downloads. What say you, Python community? > > Available as 3rd party downloads: > > XML,HTML,... > HTTP,FTP,SMTP,POP,IMAP/... > MD5,SHA,... > zip,bzip,... > > and so on and so on and so on. > > Remove them all just because they are available as 3rd party downloads? No, they should not be removed because they don't cause any damage, very bad damage as Tkinter does. > The "Batteries included" of Python is just *great* and I vote for *more* > not less batteries! Well, in that case, why don't you agree to also include WxPython in the Python package? >> And one more thing. Not all the Python programmers create desktop apps so >> a GUI lib is useless. Some of them use Python only for web programming or >> only for system administration. > > Not all Python programmers do web programming, so please remove the > useless HTML junk too. Why do you call it "html junk"? > Almost every beginner wants to do GUIs or at least some graphic stuff. > Removing the GUI module from the stdlib would be plain wrong IMHO. But I > don't understand the whole issue anyway. It isn't that you need to fire up > your torrent client and wait 48 hours for the Python download to complete. > Why remove useful (to many, not most) stuff from the lib? Yes it can be useful for some people, but why promote it instead of promoting a better library for beginners? Octavian From wxjmfauth at gmail.com Tue Jan 18 03:58:14 2011 From: wxjmfauth at gmail.com (jmfauth) Date: Tue, 18 Jan 2011 00:58:14 -0800 (PST) Subject: __pycache__, one more good reason to stck with Python 2? References: <23e02e0d-b2f1-4b52-85ea-d1feba99dd37@22g2000prx.googlegroups.com> <4d3466d3$0$29983$c3e8da3$5496439d@news.astraweb.com> <0c62aacd-e6d2-4778-81d6-e06924192add@j1g2000vbl.googlegroups.com> <87vd1m6ezq.fsf@benfinney.id.au> Message-ID: <992b11a0-d35d-4b08-98ab-d08c90a86ec7@j1g2000vbl.googlegroups.com> On Jan 18, 6:07?am, Terry Reedy wrote: > ... > This is the 21-year-old behavior now changed. > ... Yes, you summarized the situation very well. The way of working has changed and probably more deeply that one may think. It is now practically impossible to launch a Python application via a .pyc file. (For the fun, try to add the "parent directory" of a cached file to the sys.path). About the caches, I'am just fearing, they will become finally garbage collectors of orphan .pyc files, Python has seed/seeded(?). The .pyc files may not be very pleasant, but at least you can use them and you have that "feeling" of their existence. I my "computer experience", once you start to cache/hide something for simplicity, the problems start. May be it a good move for Python, I do not feel very comfortable with all this stuff. From orasnita at gmail.com Tue Jan 18 04:03:16 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Tue, 18 Jan 2011 11:03:16 +0200 Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com><79a8a$4d332d1a$4275d90a$3986@FUSE.NET><64976187-88ad-47c9-9bc6-c0712a657264@j32g2000yqc.googlegroups.com><3af4fd5e-8cc9-4cec-aad2-cbf82ad3bab3@l24g2000vby.googlegroups.com> <7c1928e5-ba2c-4034-9a5d-3f20cfe756ab@1g2000yqz.googlegroups.com> Message-ID: <6D0E5A2E17824D63B1E8D171F35D74A3@octavian> From: "rantingrick" You know we Python programmers are professional debaters. This has been my take on the Python community. However without the virtues of compromise and community spirit all we are going to do is fight like cats and dogs forever to the very detriment of the very community we wish to muster We need to look at these problems from a community perspective and tone down the rhetoric. The layer of thick sarcasm that exists is so viscous and putrid that any semblance of civility is completely impervious to it's gelatinous all encompassing mass. We need to get more folks involved in the decision process. We need more community discussion and less community corruption. Currently we have a small subset of the community making a large proportion of the decisions. We did have a monarchy ruled by our beloved dictator however it has degenerated into a banana republic! We need democracy and we need it now! Well, those who work have the latest word and they will decide what they will want to do. We can just show our opinions and hope that they will care and take the best decision. The problem is that some people don't care and want to demonstrate that this is very normal and that they are right, which is not good at all. Octavian From __peter__ at web.de Tue Jan 18 04:04:24 2011 From: __peter__ at web.de (Peter Otten) Date: Tue, 18 Jan 2011 10:04:24 +0100 Subject: __pycache__, one more good reason to stck with Python 2? References: <23e02e0d-b2f1-4b52-85ea-d1feba99dd37@22g2000prx.googlegroups.com> <4d3466d3$0$29983$c3e8da3$5496439d@news.astraweb.com> <0c62aacd-e6d2-4778-81d6-e06924192add@j1g2000vbl.googlegroups.com> <77ef8068-7f07-404f-8b0e-c039d1122659@e16g2000pri.googlegroups.com> Message-ID: Carl Banks wrote: > On Jan 17, 6:29 pm, Alice Bevan?McGregor wrote: >> find . -name \*.pyc -exec rm -f {} \; >> >> vs. >> >> rm -rf __pycache__ >> >> I do not see how this is more difficult, but I may be missing something. > > > Well the former deletes all the pyc files in the directory tree > whereas the latter only deletes the top level __pycache__, not the > __pycache__ for subpackages. To delete all the __pycache__s you'd > have to do something like this: > > file . -name __pycache__ -prune -exec rm -rf {} \; > > or, better, > > file . -name __pycache__ -prune | xargs rm -rf > > Still not anything really difficult. (I don't think a lot of people > know about -prune; it tells find don't recursively descend.) What's the advantage of 'find ... | xargs ...' over 'find ... -exec ...'? From orasnita at gmail.com Tue Jan 18 04:13:06 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Tue, 18 Jan 2011 11:13:06 +0200 Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com><79a8a$4d332d1a$4275d90a$3986@FUSE.NET><64976187-88ad-47c9-9bc6-c0712a657264@j32g2000yqc.googlegroups.com><3af4fd5e-8cc9-4cec-aad2-cbf82ad3bab3@l24g2000vby.googlegroups.com><7c1928e5-ba2c-4034-9a5d-3f20cfe756ab@1g2000yqz.googlegroups.com> <44dfe215-4e9d-4621-8999-1f46536df878@d1g2000pra.googlegroups.com> Message-ID: <26D977282CC948E99F7BA4AACCEE9A64@octavian> From: "rusi" Lehman Beladys entropy law http://en.wikipedia.org/wiki/Lehman%27s_laws_of_software_evolution says The quality of ... systems will decline unless they are rigorously maintained and adapted to operational environment changes. Yes. Pretty right. Tkinter -> WxPython change would be a very good one. Guido's 'benevolent dictatorship' has so far kept python the exception because - he give powerful batteries to start with With the exception of Tkinter. :-)) - does not introduce junk - is not afraid of backward incompatibility for the sake of clarity and cleanliness (python3) Well, on the long term this could be a very big disadvantage also. Of course, the beginners won't care, but the old users and the companies that would need to adapt the old code that might not work with newer versions of Python won't like this incompatibility. Gui (and web) frameworks are two of his more visible failures Well, Python has good GUI libs , at least WxPython, however it is not one of its included batteries. :-) Yes, for web programming Python is not as great as Perl, but I don't think this has something to do with the core Python. Octavian From stefan_ml at behnel.de Tue Jan 18 04:23:27 2011 From: stefan_ml at behnel.de (Stefan Behnel) Date: Tue, 18 Jan 2011 10:23:27 +0100 Subject: __pycache__, one more good reason to stck with Python 2? In-Reply-To: References: <23e02e0d-b2f1-4b52-85ea-d1feba99dd37@22g2000prx.googlegroups.com> <4d3466d3$0$29983$c3e8da3$5496439d@news.astraweb.com> <0c62aacd-e6d2-4778-81d6-e06924192add@j1g2000vbl.googlegroups.com> Message-ID: Terry Reedy, 18.01.2011 04:39: > Saving module code to the > filesystem speeds startup, which most find slow as it is. I've been using Jython recently, which, in addition to the huge JVM startup time, must also fire up the Jython runtime before actually doing anything useful. I must say that I never found CPython's startup time to be slow, quite the contrary. Stefan From stefan_ml at behnel.de Tue Jan 18 04:27:54 2011 From: stefan_ml at behnel.de (Stefan Behnel) Date: Tue, 18 Jan 2011 10:27:54 +0100 Subject: __pycache__, one more good reason to stck with Python 2? In-Reply-To: <992b11a0-d35d-4b08-98ab-d08c90a86ec7@j1g2000vbl.googlegroups.com> References: <23e02e0d-b2f1-4b52-85ea-d1feba99dd37@22g2000prx.googlegroups.com> <4d3466d3$0$29983$c3e8da3$5496439d@news.astraweb.com> <0c62aacd-e6d2-4778-81d6-e06924192add@j1g2000vbl.googlegroups.com> <87vd1m6ezq.fsf@benfinney.id.au> <992b11a0-d35d-4b08-98ab-d08c90a86ec7@j1g2000vbl.googlegroups.com> Message-ID: jmfauth, 18.01.2011 09:58: > About the caches, I'am just fearing, they will > become finally garbage collectors of orphan .pyc files, > Python has seeded I can't see how that is supposed to be any different than before. If you rename a file without deleting the .pyc file, you will end up with an orphaned .pyc file, right now and as it was for the last 21 years. The same applies to the new cache directory. Stefan From stefan_ml at behnel.de Tue Jan 18 04:29:04 2011 From: stefan_ml at behnel.de (Stefan Behnel) Date: Tue, 18 Jan 2011 10:29:04 +0100 Subject: __pycache__, one more good reason to stck with Python 2? In-Reply-To: References: <23e02e0d-b2f1-4b52-85ea-d1feba99dd37@22g2000prx.googlegroups.com> <4d3466d3$0$29983$c3e8da3$5496439d@news.astraweb.com> <0c62aacd-e6d2-4778-81d6-e06924192add@j1g2000vbl.googlegroups.com> <77ef8068-7f07-404f-8b0e-c039d1122659@e16g2000pri.googlegroups.com> Message-ID: Peter Otten, 18.01.2011 10:04: > What's the advantage of 'find ... | xargs ...' over 'find ... -exec ...'? The former runs in parallel, the latter runs sequentially. Stefan From tartley at tartley.com Tue Jan 18 04:54:26 2011 From: tartley at tartley.com (Jonathan Hartley) Date: Tue, 18 Jan 2011 01:54:26 -0800 (PST) Subject: Efficient python 2-d arrays? References: Message-ID: <6b865cda-5df4-4053-b5e4-f7deba45360e@l7g2000vbv.googlegroups.com> On Jan 17, 10:20?pm, Jake Biesinger wrote: > Hi all, > > Using numpy, I can create large 2-dimensional arrays quite easily. > > >>> import numpy > >>> mylist = numpy.zeros((100000000,2), dtype=numpy.int32) > > Unfortunately, my target audience may not have numpy so I'd prefer not to use it. > > Similarly, a list-of-tuples using standard python syntax. > > >>> mylist = [(0,0) for i in xrange(100000000) > > but this method uses way too much memory (>4GB for 100 million items, compared to 1.5GB for numpy method). > > Since I want to keep the two elements together during a sort, I *can't* use array.array. > > >>> mylist = [array.array('i',xrange(100000000)), array.array('i',xrange(100000000))] > > If I knew the size in advance, I could use ctypes arrays. > > >>> from ctypes import * > >>> class myStruct(Structure): > >>> ? ? _fields_ = [('x',c_int),('y',c_int)] > >>> mylist_type = myStruct * 100000000 > >>> mylist = mylist_type() > > but I don't know that size (and it can vary between 1 million-200 million), so preallocating doesn't seem to be an option. > > Is there a python standard library way of creating *efficient* 2-dimensional lists/arrays, still allowing me to sort and append? > > Thanks! Since you can't depend on your users installing the dependencies, is it vital that your users run from source? You could bundle up your application along with numpy and other dependencies using py2Exe or similar. This also means you wouldn't have to require users to have the right (or any) version of Python installed. From nambo4jb at gmail.com Tue Jan 18 05:01:57 2011 From: nambo4jb at gmail.com (Cathy James) Date: Tue, 18 Jan 2011 04:01:57 -0600 Subject: newby qn about functions Message-ID: #This has to be very simple, but I don't get it-please help def *lower_case*(s): #return s print(s) #return s.lower() print(s.lower()) s=*"Testing Functions-lower case: " * lower_case(s) *"""how can i use a return statement to write a function that returns the string "Testing Functions-lower case: "and the lowercase representation of its string parameter""" If I uncomment the above, nothing outputs to console:(* ** *Much appreciation as always.* -------------- next part -------------- An HTML attachment was scrubbed... URL: From sliwinski at red-sky.pl Tue Jan 18 05:22:45 2011 From: sliwinski at red-sky.pl (=?ISO-8859-2?Q?Grzegorz_=A6liwi=F1ski?=) Date: Tue, 18 Jan 2011 02:22:45 -0800 (PST) Subject: Python unicode utf-8 characters and MySQL unicode utf-8 characters Message-ID: <1914ba89-7ecc-43d5-8fbc-9a45f27ae8c8@z5g2000yqb.googlegroups.com> Hello, Recently I tried to insert some unicode object in utf-8 encoding into MySQL using MySQLdb, and got MySQL warnings on characters like: ???? i found somewhere in my data. I can't even read them. MySQL seems to cut the whole string after that characters off, so I get incomplete data. After a little bit of digging I found out, that MySQL usually supports utf-8 data but encoded into maximum three bytes. That's why I think it would help I f I was able to replace all larger unicode characters with replacement characters. Is there any way, I could adjust python unicode utf-8 encoded strings to be accepted by mysql utf-8 columns? From enalicho at gmail.com Tue Jan 18 05:42:08 2011 From: enalicho at gmail.com (Noah Hall) Date: Tue, 18 Jan 2011 10:42:08 +0000 Subject: newby qn about functions In-Reply-To: References: Message-ID: > """how can i use a return statement? to write a function that returns the > string "Testing?Functions-lower case: "and the lowercase representation of > its string parameter""" If I uncomment the above, nothing outputs to > console:( def lower_case(s): return "Testing Functions-lower case: %s" % (s.lower()) >>> print(lower_case("HeLLo")) Testing Functions-lower case: hello >>> d = lower_case("HeLLo") >>> print(d) Testing Functions-lower case: hello If a function returns something and you want it printed, you need to then tell Python to print the return. Please note that "return" and "print" aren't the same things, return returns a given variable or constant, and print simply prints a given variable or constant. From usernet at ilthio.net Tue Jan 18 05:52:06 2011 From: usernet at ilthio.net (Tim Harig) Date: Tue, 18 Jan 2011 10:52:06 +0000 (UTC) Subject: [OT] Python like lanugages [was Re: After C++, what with Python?] References: <86a904f8-05b0-435f-81d6-7450650f1679@glegroupsg2000goo.googlegroups.com> <4d329899$0$43988$742ec2ed@news.sonic.net> <7x8vylfcvz.fsf@ruckus.brouhaha.com> <4d32c7cf$0$29983$c3e8da3$5496439d@news.astraweb.com> <4d3425fe$0$29983$c3e8da3$5496439d@news.astraweb.com> <4d3522c5$0$29990$c3e8da3$5496439d@news.astraweb.com> Message-ID: On 2011-01-18, Steven D'Aprano wrote: > On Mon, 17 Jan 2011 19:41:54 +0000, Tim Harig wrote: > >> One of the arguments for Python has always made is that you can optimize >> it by writing the most important parts in C. Perhaps that is a crutch >> that has held the communty back from seeking higher performance >> solutions in the language itself. > > Are you aware of PyPy? Yes I have heard of PyPy, RPython, and Cython. If they were sufficient I probably wouldn't have to look around. These alternate Python projects have made some small gains; but, they still have a long way to go. > PyPy is now about double the speed of CPython for most things, and they > have set themselves the ambitious target of being faster than C. Let me know when they reach that target. When Java started there was hype that the JIT would be able to run faster then native C because the JIT could optimize at runtime based on the actual data that it encountered. That never really panned out either. From askutt at gmail.com Tue Jan 18 05:53:09 2011 From: askutt at gmail.com (Adam Skutt) Date: Tue, 18 Jan 2011 02:53:09 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com><4d337983$0$29983$c3e8da3$5496439d@news.astraweb.com><044a5101-948d-4458-9c94-57dbb3e25f67@m35g2000vbn.googlegroups.com><4d3467bf$0$29983$c3e8da3$5496439d@news.astraweb.com> Message-ID: <732431c3-b056-4a81-8ff8-c88a2181ef7c@fu15g2000vbb.googlegroups.com> On Jan 18, 3:49?am, "Octavian Rasnita" wrote: > From: "Adam Skutt" > Subject: Re: Tkinter: The good, the bad, and the ugly! > > On Jan 17, 3:08 pm, "Octavian Rasnita" wrote: > > "Batteries included"? > > > Python doesn't follow this policy at all. We can say that maybe PHP > > follows it, but not Python. > > http://lmgtfy.com/?q=python+%22batteries+included%22&l=1 > > Well, this doesn't mean anything because Perl can also say that includes > batteries, and PHP can say it also. It means that Python intentionally endeavorer to include some sort of rich and useful standard library as part of the language, ergo criticisms of the language may include criticisms of its library, like it or not. I'm not sure what makes you believe Perl or PHP are relevant here. > You are perfectly right. Then why favor Tkinter and not WxPython. Why not > strip the Python package and offer WxPython and Tkinter separately? As of now? There's no reason to remove what's there already as long as carrying it as a dependency isn't creating problems for building and distributing Python. But I already mentioned an important reason earlier: the dependencies of Tk are much, much smaller than the dependencies of WxWidgets (though eventually this may change with the X11 port getting complete). Another is that the scope and scale of WxWidgets is problematic: since it's a cross-platform C++ solution it provides a lot of things that it needs, but that Pyhton doesn't especially need or want. It creates incompatibility issues because you end up with a bunch of libraries that become useless when writing a GUI. This problem is minimized with Tk when compared to WxWidgets, and most other toolkits (certainly all the ones I've ever used). Adam From usernet at ilthio.net Tue Jan 18 06:37:34 2011 From: usernet at ilthio.net (Tim Harig) Date: Tue, 18 Jan 2011 11:37:34 +0000 (UTC) Subject: [OT] Python like lanugages [was Re: After C++, what with Python?] References: <86a904f8-05b0-435f-81d6-7450650f1679@glegroupsg2000goo.googlegroups.com> <4d329899$0$43988$742ec2ed@news.sonic.net> <7x8vylfcvz.fsf@ruckus.brouhaha.com> <4d32c7cf$0$29983$c3e8da3$5496439d@news.astraweb.com> <4d3425fe$0$29983$c3e8da3$5496439d@news.astraweb.com> Message-ID: On 2011-01-18, Stefan Behnel wrote: > Tim Harig, 17.01.2011 20:41: >> One of the arguments for Python has always made is that you can optimize >> it by writing the most important parts in C. Perhaps that is a crutch >> that has held the communty back from seeking higher performance solutions >> in the language itself. > > The good news with Cython is that you no longer need to "write the most > important parts in C". Instead, you type them statically and compile them. > You don't even need to sacrifice Python source compatibility for that. So > you get the best of Python at the speed of C (or 'c', as some would say ;). Well not quite. The fact that you still need a Python interpeter should tell you that the end result is not really just C. Effectively, you get the same thing that you might get from writing C modules for your performance sensitive loops. Cython just makes it a little easier to generate the C modules; but, there is still a lot of Python operating under the hood. >> I prefer a single language as opposed to a creolization of two. > > With the possible exception of Lisp, I find it hard to think of a language > that's still alive and not the creolisation of (at least) two other > languages. They all inherited from each other, sometimes right from the > start ("lessons learned") and always during their subsequent life time. I am not talking about language influences. Cython effectively requires two separate languages that interoperate. The end result is a mix of two code written in two separate langauges. That is not a single language solution. >> I certainly don't need to require anybody who >> wants to use a program I have compiled to install an interpreter. > > You will be happy to hear that you can link Cython programs against > libpython (even statically) to build an executable that embeds the > interpreter for you. Besides, on most operating systems, installing a Which means that you effectively end up with a py2exe style frozen binary. While that is a nice hack for solving some problems, it is hardly an elegant solution. It still effectively means that I have to package a redundant Python installation with every binary that I distribute. I just don't have to write installation routines that check for, and potentially install, a compatable version of Python. > interpreter for you. Besides, on most operating systems, installing a > dependency is done automatically, and Go code doesn't run natively on > Windows either, without first installing and running the compiler over it. Go works like C. If I compile my code on Windows, then I can give the binary to another Windows user and they can execute it without having to install any additional software (gcgo currently compiles everything using static binaries. Since the linker only includes the fuctions you actually use, you don't end up with the bloat of embedding entire libraries. I am not sure about gccgo.). The same holds true for Linux, BSD, OS X, and any other supported OS. Every go program includes a runtime componet that provides the garbage collection; but, all of that is included as 100% processor native code. That is quite a bit different from having to include an interpreter to run non-native code. From jeeva235 at hotmail.com Tue Jan 18 06:53:11 2011 From: jeeva235 at hotmail.com (superman) Date: Tue, 18 Jan 2011 03:53:11 -0800 (PST) Subject: THE TRUTH TO MAKING $13,693.94 IN 48 HOURS Message-ID: <6c2fe4f4-3251-4ca9-adef-01db764c7cdb@n32g2000pre.googlegroups.com> THE TRUTH TO MAKING $13,693.94 IN 48 HOURS You need to go and check this out right now! =>> https://secure.aischeckout.com/t/qraiI/nyPHA/subaffiliate It's an underground method to start making CRAZY cash by this time tomorrow! This method is responsible for making $112,075.22 just last month and has the guru's running scared! It even made $13,693.94 in just 48 hours! Forget everything you've been taught in the past and listen up. Go to this page NOW and learn how you can steal this exact $4.1 million business for yourself: =>> https://secure.aischeckout.com/t/qraiI/nyPHA/subaffiliate From marrina0012 at gmail.com Tue Jan 18 07:40:25 2011 From: marrina0012 at gmail.com (Marrina anderson tina) Date: Tue, 18 Jan 2011 04:40:25 -0800 (PST) Subject: Feel free to post your ads in our site. Message-ID: Frieds want to give personal ads as all other essential products which is now available in our site In www.webadlist.com. This is now fastest and growing site where already more than thousand of people uploaded and sold their products. Just now u can also registered and post your ads. Just visit at: http://www.webadlist.com/ From solipsis at pitrou.net Tue Jan 18 07:46:22 2011 From: solipsis at pitrou.net (Antoine Pitrou) Date: Tue, 18 Jan 2011 13:46:22 +0100 Subject: move to end, in Python 3.2 Really? References: <58c17709-d68e-4448-b618-b6f594d0e8c5@t35g2000yqj.googlegroups.com> <125db7fe-036e-47c9-be89-50f05106936f@n2g2000pre.googlegroups.com> Message-ID: <20110118134622.0c181cc4@pitrou.net> On Mon, 17 Jan 2011 21:20:48 -0800 (PST) Raymond Hettinger wrote: > On Jan 17, 6:51?pm, nn wrote: > > ...But the api on this baffles me a bit: > > > > >>> d = OrderedDict.fromkeys('abcde') > > >>> d.move_to_end('b', last=False) > > >>> ''.join(d.keys) > > > > 'bacde' > > > > I understand that "end" could potentially mean either end, but would > > "move_to_end" and "move_to_beginning" not have been clearer? > > The default (and normal usage) is to move an item to the last > position. > So, od.move_to_end(k) becomes a fast equivalent to v=d.pop(k) > followed by d[k]=v. > > The less common usage of moving to the beginning is done with > last=False. This parallels the existing API for od.popitem(): Well I have to agree that moving to the beginning using move_to_end() with a "last" argument looks completely bizarre and unexpected. "Parallels popitem()" is not really convincing since popitem() doesn't have "end" its name. > Those were the design considerations. Sorry you didn't like the > result. Design considerations? Where were they discussed? Regards Antoine. From arndt.roger at addcom.de Tue Jan 18 08:09:10 2011 From: arndt.roger at addcom.de (Arndt Roger Schneider) Date: Tue, 18 Jan 2011 14:09:10 +0100 Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <79a8a$4d332d1a$4275d90a$3986@FUSE.NET> <64976187-88ad-47c9-9bc6-c0712a657264@j32g2000yqc.googlegroups.com> <3af4fd5e-8cc9-4cec-aad2-cbf82ad3bab3@l24g2000vby.googlegroups.com> Message-ID: Terry Reedy schrieb: > On 1/16/2011 11:20 PM, rantingrick wrote: > >> Ok, try this... >> >> http://juicereceiver.sourceforge.net/screenshots/index.php >> http://www.sensi.org/~ak/pyslsk/pyslsk6.png >> http://www.wxwidgets.org/about/screensh.htm > > > Ok, wxwidgets can look at least as good as tk. Agreed that wxpython > might instead link to the excellent wxwidgets page. > Well, tosssing screenshots around doesn't prove wether a framwork/toolkit is good or not; It only displays the developers commitment to create a work of art. Lets examine one of your examples: http://juicereceiver.sourceforge.net/screenshots/index.php#mac Overall impression: The software was designed for windows; more or less following the windows hci-guidelines, The windows version is resonable good. About the Aqua screenshots: 1. Negative actions are located on the falling diagonale. 2-3. The select background and foreground inside the multi-column listbox have the wrong color--the used color originates from text fields. 4. The multi-column listbox should have vertical gridlines. 5-6. Too much top and bottom padding inside the column header. 7. The column texture is wrong --there is a visible line in the bottom. 8. There are white boxess around the input fields. 9. Header column label and lisstbox content are not aligned. 10. There is separator line between the status bar and the brusshed dialog. 11. Last picture: there is a single page inside the tabet control. 12. Last picture: The text "Select radio ..." is trucated, the dialog isn't large enough. 13. The Scheduler activation should come before customizing the scheduler. 14. The dialog uses sunken group boxes for some sections, these group should be 2% darker than their surrounding container. 15. The spacing rules from the aqua hci guidlines are violated. The inner tabset should have 20px distance from both sides, 20px from the bottom, 14px from top. 16. Second last picture: The button lables are truncated. 17. Tree: Uses the wrong folder symbols--from windows--, select background and foreground are wrong, too. - The Aqua hci-guidlines discourage group boxes, the same with the windows guidlines, too. Get rid off group boxes. - second last picture: There should be more top padding for the checkbutton inside the white rectangle; best the same as left-padding. - There no focus frames visilbe inside these screenshots, it would be interessting to see how those are realised. - The icon buttons should be brushed, likewise shoud the column header have brushed background. - Aqua hci guidelines: All dialogs should have a centered appearance. Back to rantingrick 21st century toolkit/framwork: Let's have a look at the numbers: Worlwide pc market are 300 Million pcs per year, this number includes desktops(2/3) and servers(1/3). Your gui app is not relevant on servers. Quite a good deal of the remaining pc's are sold in countries with rampant ilict software copies; Since there are no software cost for these copies the people tend to install the big, bloated software pieces from named computer companies --you wont sell linux there, because it is more expensive than an ilict windows+office++. ~ 100 Million potential new desktop users for you. Apple's projection for the ipad in 2011 are 65 Million pieces, iphone and ipod touch will be roughly the same. 130 Million ios pieces. ~ 130 Million new ios users for you. The android market is still unclear, but I do suppose it will rival ios, lets say 100 Million in 2011. ~ 100 Million new android users for you. Microsoft mobile and blueberry are wildcards; no serious forecast is possible for these devices. Lets assume: ~ 50 Million blueberry, windows mobile. Total is: 380 Million potential new user for your application. wxWidgets: 36000000 LOC, python: 1400000 LOC --these are very old numbers, but from the same time period. wxWidgets on desktop, present for windows, Aqua and X11. wxWidgets on ios, possible but unlikely, the thing is way to big for any ios device. wxWidgets on android not realistic. wxWidgets on blueberry not possible. wxWidgets on windows mobile; development is silverlight with .net, so wxWidgets would have to be ported to .net; not realistic. python on desktop, present. python on ios, possible --if not yet present. python on android, present. python on blueberry, possible. python on windows mobile, present--but .net support deprecated by ms. The smartphone and table market has only started, yet. In 2011 the mobile market is already larger than the desktop pc, almost 3 times largerv. The desktop pc market is in decline; there is however a shift toward pc-servers, instead. It is anybodies guess how far the pc-desktop decline will go. Every 21st century toolkit or framework must run on mobile platforms! wxWidgets was written ~1992, it is a copy of mfc, which in turn is a copy of MacApp. MacApp is also OSS, maintained through an industrie consortium. Why do you not use the original framework? Looking into wxWidgets: The treeview: Trees do not work well with touchscreens. Mutli-column-listbox: Doesn't work at all with touchscreens, instead use simple lists with multi-line entries. Interactivity: keyboard focus, shortcuts, function keys, active foreground, active background are obsolete. hovering tooltips obsolete, status bar to large, obsolete. scrolled dialogs, obsolete. OK, Cancel, Retry, Abort buttons, obsolete, file dialogs obsolete, old style printing obsolete, drag-and-drop obsolete... Screen resolution: The time of 72ppi CRT monitors is over. A GUI framework/toolkit must be resolution independent, including all icons and indicators; it should use decluttering (newspeak:ZUI). Summary wxWidgets: wxWidgets is large scale C++ library from the 20th century, solemnly dedicated toward desktop computers. wxWidgets originates from a time before templates were used in C++ and thus duplicates many of today's C++ features. wxWidgets is not suitable for a modern type GUI ad thus clearly not the toolkit/framework of the 21st century. -roger From orasnita at gmail.com Tue Jan 18 08:49:56 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Tue, 18 Jan 2011 15:49:56 +0200 Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <79a8a$4d332d1a$4275d90a$3986@FUSE.NET> <64976187-88ad-47c9-9bc6-c0712a657264@j32g2000yqc.googlegroups.com> <3af4fd5e-8cc9-4cec-aad2-cbf82ad3bab3@l24g2000vby.googlegroups.com> Message-ID: <2DC5227DF1F24BCB9AA9A7BA069719FE@octavian> From: "Arndt Roger Schneider" > > Overall impression: > The software was designed for windows; more or less > following the windows hci-guidelines, > The windows version is resonable good. This is the most important thing, because most users use Windows. Those who have other preferences are not forced to choose Windows, so it's their choice, and if the interface doesn't look so nice, that's it. > Back to rantingrick 21st century toolkit/framwork: > Let's have a look at the numbers: > Worlwide pc market are 300 Million pcs per year, > this number includes desktops(2/3) and servers(1/3). > Your gui app is not relevant on servers. > Quite a good deal of the remaining pc's are sold in > countries with rampant ilict software copies; > Since there are no software cost for these copies Python is an open source software and the programmers that use Python might also prefer to offer open source software for free so this is not important. And "not legal" is not a very correct term, because somebody from Iran or North Corea must respect the laws from his/her country and in her/his country some things might not be forbidden by law, so it may be perfectly legal. > ~ 100 Million potential new desktop users for you. > > Apple's projection for the ipad in 2011 are 65 Million pieces, > iphone and ipod touch will be roughly the same. > 130 Million ios pieces. > The android market is still unclear, but I do suppose > it will rival ios, lets say 100 Million in 2011. > > ~ 100 Million new android users for you. > > > Microsoft mobile and blueberry are wildcards; > no serious forecast is possible for these devices. > Lets assume: > > ~ 50 Million blueberry, windows mobile. > > Total is: 380 Million potential new user for your application. > > > wxWidgets: 36000000 LOC, python: 1400000 LOC > --these are very old numbers, but from the same time period. This is a bad comparison because the programs targetted to the mobile phones are in most cases very different than the programs that need to be used on the desktop. Do you want to say that WxPython is not good just because it doesn't work well on mobile phones? Those numbers show that only the mobile phones are important, because there are more mobile phones than computers. Well, Python needs a better GUI lib for using them on desktop computers, not on mobile phones. > The desktop pc market is in decline; there is > however a shift toward pc-servers, instead. What do you mean by declining? Are there fewer desktop PCs today than a year ago? > Looking into wxWidgets: > Interactivity: keyboard focus, shortcuts, function keys, > active foreground, active background are obsolete. > hovering tooltips obsolete, status bar to large, obsolete. > scrolled dialogs, obsolete. OK, Cancel, Retry, Abort > buttons, obsolete, file dialogs obsolete, old style printing > obsolete, drag-and-drop obsolete... Who says that they are obsolete? A good GUI interface should offer keyboard accessibility. Otherwise it is broken. > Summary wxWidgets: > wxWidgets is large scale C++ library from the 20th century, > solemnly dedicated toward desktop computers. Yes, Python should promote a good GUI lib for desktop computers, and not a poor GUI lib for desktop computers that might also work on other platforms. > wxWidgets is not suitable for a modern type > GUI ad thus clearly not the toolkit/framework > of the 21st century. Why do you think that everything what's modern is better? Octavian From ethan at stoneleaf.us Tue Jan 18 09:09:11 2011 From: ethan at stoneleaf.us (Ethan Furman) Date: Tue, 18 Jan 2011 06:09:11 -0800 Subject: __pycache__, one more good reason to stck with Python 2? In-Reply-To: <58b2111d-f0d5-499b-8339-6b27bb4743ca@z17g2000prz.googlegroups.com> References: <23e02e0d-b2f1-4b52-85ea-d1feba99dd37@22g2000prx.googlegroups.com> <4d3466d3$0$29983$c3e8da3$5496439d@news.astraweb.com> <0c62aacd-e6d2-4778-81d6-e06924192add@j1g2000vbl.googlegroups.com> <58b2111d-f0d5-499b-8339-6b27bb4743ca@z17g2000prz.googlegroups.com> Message-ID: <4D359F07.1020504@stoneleaf.us> Carl Banks wrote: > On Jan 17, 10:17 am, jmfauth wrote: >> ... >> If I get (stupidly, I agree) a .pyc file and want to test >> it. Should I create manually a cache alongside my test.py >> script? > > Nope: according to PEP 3147 a standalone *.pyc should not be put in > same directory where the source file would have been, not in the > __pycache__ directory (it'll be considered stale otherwise). Typo? According to PEP 3147 a standalone *.pyc *should* (not should not) be put in the same directory where the source file would have been. ~Ethan~ From rui.maciel at gmail.com Tue Jan 18 09:44:57 2011 From: rui.maciel at gmail.com (Rui Maciel) Date: Tue, 18 Jan 2011 14:44:57 +0000 Subject: [OT] Python like lanugages [was Re: After C++, what with Python?] References: <86a904f8-05b0-435f-81d6-7450650f1679@glegroupsg2000goo.googlegroups.com> <4d329899$0$43988$742ec2ed@news.sonic.net> <7x8vylfcvz.fsf@ruckus.brouhaha.com> <4d32c7cf$0$29983$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4d35a769$0$2258$a729d347@news.telepac.pt> Tim Harig wrote: > You still don't see many > companies doing large scale internal development using Python and you > definately don't see any doing external developement using a language > that gives the customers full access to the source code. What you refered as "full access to the source code" only goes as far as the license which was imposed by the copyright holders lets it to go. If you distribute the source code along with the binaries but you only license your code if the licencees accept that they may look at the source code but they can't touch it then distributing the source code is essentially meaningless. There is a good reason why "open source software" is not the same thing as "free software". Rui Maciel From sherm.pendley at gmail.com Tue Jan 18 09:45:33 2011 From: sherm.pendley at gmail.com (Sherm Pendley) Date: Tue, 18 Jan 2011 09:45:33 -0500 Subject: __pycache__, one more good reason to stck with Python 2? References: <23e02e0d-b2f1-4b52-85ea-d1feba99dd37@22g2000prx.googlegroups.com> <4d3466d3$0$29983$c3e8da3$5496439d@news.astraweb.com> <0c62aacd-e6d2-4778-81d6-e06924192add@j1g2000vbl.googlegroups.com> <77ef8068-7f07-404f-8b0e-c039d1122659@e16g2000pri.googlegroups.com> Message-ID: Peter Otten <__peter__ at web.de> writes: > Carl Banks wrote: > >> Well the former deletes all the pyc files in the directory tree >> whereas the latter only deletes the top level __pycache__, not the >> __pycache__ for subpackages. To delete all the __pycache__s you'd >> have to do something like this: >> >> file . -name __pycache__ -prune -exec rm -rf {} \; >> >> or, better, >> >> file . -name __pycache__ -prune | xargs rm -rf >> >> Still not anything really difficult. (I don't think a lot of people >> know about -prune; it tells find don't recursively descend.) > > What's the advantage of 'find ... | xargs ...' over 'find ... -exec ...'? Exec launches a new instance of 'rm' for each found file, while xargs launches a single instance, and passes the list of found files as arg- uments. Probably not a big deal in this case, but if you're passing a long list of files to a script that has a long startup time, it can make a big difference. sherm-- -- Sherm Pendley Cocoa Developer From usernet at ilthio.net Tue Jan 18 10:30:23 2011 From: usernet at ilthio.net (Tim Harig) Date: Tue, 18 Jan 2011 15:30:23 +0000 (UTC) Subject: [OT] Python like lanugages [was Re: After C++, what with Python?] References: <86a904f8-05b0-435f-81d6-7450650f1679@glegroupsg2000goo.googlegroups.com> <4d329899$0$43988$742ec2ed@news.sonic.net> <7x8vylfcvz.fsf@ruckus.brouhaha.com> <4d32c7cf$0$29983$c3e8da3$5496439d@news.astraweb.com> <4d35a769$0$2258$a729d347@news.telepac.pt> Message-ID: On 2011-01-18, Rui Maciel wrote: > Tim Harig wrote: > >> You still don't see many >> companies doing large scale internal development using Python and you >> definately don't see any doing external developement using a language >> that gives the customers full access to the source code. > > What you refered as "full access to the source code" only goes as far as > the license which was imposed by the copyright holders lets it to go. If > you distribute the source code along with the binaries but you only > license your code if the licencees accept that they may look at the source > code but they can't touch it then distributing the source code is > essentially meaningless. There is a good reason why "open source > software" is not the same thing as "free software". That argument is not going to fly with where commericial interests are concerned. The simple fact is that there is legality and then there is reality. People follow licenses like they follow the speed limit: only when they think they might get caught and punished. When people break the licenses, the only recourse is litigation; which is expensive. Even finding and proving license violations is difficult where source is availible. It is therefore in the corporate interest to make breaking licenses as difficult, uneconomical, and tracible as possible; and that is exactly what companies do. Even companies that don't really have any trade secrets to protect are protective about their source keeping it locked out of public view. Access to the source generally means signing an NDA so that if the source is somehow leaked, they know the most likely candidates for the origin [so as not to pun with "source"] of the leak. Whether or not you actually agree with that economic reality is irrelevant. Those who fund commerical projects do; and, any developement tool which violates the security of the source is going to find itself climbing an uphill battle in trying to gain market penetration with commericial software producers. From arndt.roger at addcom.de Tue Jan 18 11:10:25 2011 From: arndt.roger at addcom.de (Arndt Roger Schneider) Date: Tue, 18 Jan 2011 17:10:25 +0100 Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <79a8a$4d332d1a$4275d90a$3986@FUSE.NET> <64976187-88ad-47c9-9bc6-c0712a657264@j32g2000yqc.googlegroups.com> <3af4fd5e-8cc9-4cec-aad2-cbf82ad3bab3@l24g2000vby.googlegroups.com> Message-ID: Octavian Rasnita schrieb: > From: "Arndt Roger Schneider" > At least keep the disclaimer: >> Well, tosssing screenshots around doesn't prove wether >> a framwork/toolkit is good or not; >> It only displays the developers commitment to create >> a work of art. >> >> Overall impression: >> The software was designed for windows; more or less >> following the windows hci-guidelines, >> The windows version is resonable good. > > > > This is the most important thing, because most users use Windows. Those > who have other preferences are not forced to choose Windows, so it's > their choice, and if the interface doesn't look so nice, that's it. > See disclaimer. Since you mentioned "nice": I do not use such words to charcterize a gui. I think the developers of said software tried hard to make it "nice" and "beauty", hence the brushed background and group-boxes --BTW: the windows Guidelines also discourage using group-boxes for usability reasons (see Theo. Mandel object oriented user interfaces). >> Back to rantingrick 21st century toolkit/framwork: >> Let's have a look at the numbers: >> Worlwide pc market are 300 Million pcs per year, >> this number includes desktops(2/3) and servers(1/3). >> Your gui app is not relevant on servers. >> Quite a good deal of the remaining pc's are sold in >> countries with rampant ilict software copies; >> Since there are no software cost for these copies > > > Python is an open source software and the programmers that use Python > might also prefer to offer open source software for free so this is not > important. And "not legal" is not a very correct term, because somebody > from Iran or North Corea must respect the laws from his/her country and > in her/his country some things might not be forbidden by law, so it may > be perfectly legal. > Nice cropping, >>the people tend to install the big, bloated software >pieces from named computer companies >>--you wont sell linux there, because it is more >> expensive than an ilict windows+office++. Illict as in unlicensed. Law has nothing to do with it. And yes these unlicensed sofware has an negative impact on the distribution of free open source software. I wonder, what license do you use in your own work, and what do you think about people which violate your license? >> ~ 100 Million potential new desktop users for you. >> >> Apple's projection for the ipad in 2011 are 65 Million pieces, >> iphone and ipod touch will be roughly the same. >> 130 Million ios pieces. >> The android market is still unclear, but I do suppose >> it will rival ios, lets say 100 Million in 2011. >> >> ~ 100 Million new android users for you. >> >> >> Microsoft mobile and blueberry are wildcards; >> no serious forecast is possible for these devices. >> Lets assume: >> >> ~ 50 Million blueberry, windows mobile. >> >> Total is: 380 Million potential new user for your application. >> >> >> wxWidgets: 36000000 LOC, python: 1400000 LOC >> --these are very old numbers, but from the same time period. > > > This is a bad comparison because the programs targetted to the mobile > phones are in most cases very different than the programs that need to > be used on the desktop. This is the marketplace for all gui applications, and not a comparision. > Do you want to say that WxPython is not good just because it doesn't > work well on mobile phones? I do not comment on the quality of either wxWidgets nor wxPython. Both exist for certain reasons. The desktop pc was the sole target for all the big C++ gui class liraries in 1992. Over time a large code base evolved which makes it very difficult to get these class libraries into new markets--such as today with mobile devices. > Those numbers show that only the mobile phones are important, because > there are more mobile phones than computers. > No, it doesn't. There are billions of mobile phones with graphical user interfaces, still these phones weren't relevant for gui applications. > Well, Python needs a better GUI lib for using them on desktop computers, > not on mobile phones. > wxWidgets is suiteable for the desktop. >> The desktop pc market is in decline; there is >> however a shift toward pc-servers, instead. > > > What do you mean by declining? Are there fewer desktop PCs today than a > year ago? I am writing about graphical applications not computers. > >> Looking into wxWidgets: >> Interactivity: keyboard focus, shortcuts, function keys, >> active foreground, active background are obsolete. >> hovering tooltips obsolete, status bar to large, obsolete. >> scrolled dialogs, obsolete. OK, Cancel, Retry, Abort >> buttons, obsolete, file dialogs obsolete, old style printing >> obsolete, drag-and-drop obsolete... > > > Who says that they are obsolete? > A good GUI interface should offer keyboard accessibility. Otherwise it > is broken. OK, I take keyboard focus back. > >> Summary wxWidgets: >> wxWidgets is large scale C++ library from the 20th century, >> solemnly dedicated toward desktop computers. > > > > Yes, Python should promote a good GUI lib for desktop computers, and not > a poor GUI lib for desktop computers that might also work on other > platforms. > >> wxWidgets is not suitable for a modern type >> GUI ad thus clearly not the toolkit/framework >> of the 21st century. > > > Why do you think that everything what's modern is better? "I belive in the horse", Kaiser Wilhelm II -roger From robert.kern at gmail.com Tue Jan 18 11:25:15 2011 From: robert.kern at gmail.com (Robert Kern) Date: Tue, 18 Jan 2011 10:25:15 -0600 Subject: Efficient python 2-d arrays? In-Reply-To: <28a234f1-c4d7-41a4-a1c5-74ee48a1e9f0@glegroupsg2000goo.googlegroups.com> References: <28a234f1-c4d7-41a4-a1c5-74ee48a1e9f0@glegroupsg2000goo.googlegroups.com> Message-ID: On 1/17/11 7:32 PM, Jake Biesinger wrote: > On Monday, January 17, 2011 4:12:51 PM UTC-8, OAN wrote: >> Hi, >> >> what about pytables? It's built for big data collections and it doesn't >> clog up the memory. > > I thought PyTables depends on NumPy? It does. -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco From __peter__ at web.de Tue Jan 18 11:27:10 2011 From: __peter__ at web.de (Peter Otten) Date: Tue, 18 Jan 2011 17:27:10 +0100 Subject: __pycache__, one more good reason to stck with Python 2? References: <23e02e0d-b2f1-4b52-85ea-d1feba99dd37@22g2000prx.googlegroups.com> <4d3466d3$0$29983$c3e8da3$5496439d@news.astraweb.com> <0c62aacd-e6d2-4778-81d6-e06924192add@j1g2000vbl.googlegroups.com> <77ef8068-7f07-404f-8b0e-c039d1122659@e16g2000pri.googlegroups.com> Message-ID: Stefan Behnel wrote: > Peter Otten, 18.01.2011 10:04: >> What's the advantage of 'find ... | xargs ...' over 'find ... -exec ...'? > > The former runs in parallel, the latter runs sequentially. This may sometimes be relevant, but I doubt that it matters in this particular case. Peter From rantingrick at gmail.com Tue Jan 18 11:27:27 2011 From: rantingrick at gmail.com (rantingrick) Date: Tue, 18 Jan 2011 08:27:27 -0800 (PST) Subject: move to end, in Python 3.2 Really? References: <58c17709-d68e-4448-b618-b6f594d0e8c5@t35g2000yqj.googlegroups.com> <125db7fe-036e-47c9-be89-50f05106936f@n2g2000pre.googlegroups.com> Message-ID: On Jan 18, 6:46?am, Antoine Pitrou wrote: > Design considerations? Where were they discussed? They were never discussed with the bulk of this community and that is part of what i want to change. We have a very small group of folks making all the decisions and that is fine. However this small group of "privileged" folks needs to gather input from the rest of us (peasants) on the value of such changes before making rash decisions. Currently we have a closed set of intellectual inbreeding that is rotting the community gene pool. We need more diversity in this "milkshake" to bring about and foster healthy ideas. No wonder we get these "brain childs" (farts) with inherited diseases from birth. From __peter__ at web.de Tue Jan 18 11:28:34 2011 From: __peter__ at web.de (Peter Otten) Date: Tue, 18 Jan 2011 17:28:34 +0100 Subject: __pycache__, one more good reason to stck with Python 2? References: <23e02e0d-b2f1-4b52-85ea-d1feba99dd37@22g2000prx.googlegroups.com> <4d3466d3$0$29983$c3e8da3$5496439d@news.astraweb.com> <0c62aacd-e6d2-4778-81d6-e06924192add@j1g2000vbl.googlegroups.com> <77ef8068-7f07-404f-8b0e-c039d1122659@e16g2000pri.googlegroups.com> Message-ID: Sherm Pendley wrote: > Peter Otten <__peter__ at web.de> writes: > >> Carl Banks wrote: >> >>> Well the former deletes all the pyc files in the directory tree >>> whereas the latter only deletes the top level __pycache__, not the >>> __pycache__ for subpackages. To delete all the __pycache__s you'd >>> have to do something like this: >>> >>> file . -name __pycache__ -prune -exec rm -rf {} \; >>> >>> or, better, >>> >>> file . -name __pycache__ -prune | xargs rm -rf >>> >>> Still not anything really difficult. (I don't think a lot of people >>> know about -prune; it tells find don't recursively descend.) >> >> What's the advantage of 'find ... | xargs ...' over 'find ... -exec ...'? > > Exec launches a new instance of 'rm' for each found file, while xargs > launches a single instance, and passes the list of found files as arg- > uments. > > Probably not a big deal in this case, but if you're passing a long list > of files to a script that has a long startup time, it can make a big > difference. You can avoid that: $ touch {1..10}.txt $ find . -exec python -c'import sys; print sys.argv' {} \; ['-c', '.'] ['-c', './10.txt'] ['-c', './1.txt'] ['-c', './7.txt'] ['-c', './8.txt'] ['-c', './4.txt'] ['-c', './6.txt'] ['-c', './3.txt'] ['-c', './5.txt'] ['-c', './9.txt'] ['-c', './2.txt'] $ find . -exec python -c'import sys; print sys.argv' {} \+ ['-c', '.', './10.txt', './1.txt', './7.txt', './8.txt', './4.txt', './6.txt', './3.txt', './5.txt', './9.txt', './2.txt'] Peter From rantingrick at gmail.com Tue Jan 18 11:53:12 2011 From: rantingrick at gmail.com (rantingrick) Date: Tue, 18 Jan 2011 08:53:12 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <79a8a$4d332d1a$4275d90a$3986@FUSE.NET> <64976187-88ad-47c9-9bc6-c0712a657264@j32g2000yqc.googlegroups.com> <3af4fd5e-8cc9-4cec-aad2-cbf82ad3bab3@l24g2000vby.googlegroups.com> Message-ID: On Jan 18, 7:09?am, Arndt Roger Schneider wrote: > Summary wxWidgets: > wxWidgets is large scale C++ library from the 20th century, > solemnly dedicated toward desktop computers. > wxWidgets originates from a time before templates > were used in C++ and thus duplicates many of > today's C++ features. > wxWidgets is not suitable for a modern type > GUI ad thus clearly not the toolkit/framework > of the 21st century. Alight i'll except that Rodger. Wx may be unusable for the mobile market. And since the mobile market is exploding --and will continue to explode-- then we need to consider this. However, does any GUI library exist that can handle desktop, mobile, and accessibility and do it all in a 21st century way? You slaughtered wx but failed to provide any alternative, however i am listing to your advice contently because it is very good advice. Read on... We DO need to consider the mobile market in this decision. Maybe it is time for us to actually get on the cutting edge of GUI's. Maybe we should head an effort to create a REAL 21st century GUI that can handle desktop, mobile, and accessibility, and do it all whilst looking very sharp! Sure we rob from peter to pay paul. We will use Tkinters awesome API and geometry managers, wxPythons feature richness, and any other code we can steal to make this work! Then we can "advertise" python as the best GUI language available. I have nothing against seeing Python on more devices and this would no doubt bring that dream into fruition. There is a huge hole in the market at this very moment and we need to pounce on it like a hungry tiger on wildebeest. Just think how wonderful it would be to switch from mobile to desktop and still write beatiful Python code. From python at mrabarnett.plus.com Tue Jan 18 11:54:42 2011 From: python at mrabarnett.plus.com (MRAB) Date: Tue, 18 Jan 2011 16:54:42 +0000 Subject: move to end, in Python 3.2 Really? In-Reply-To: References: <58c17709-d68e-4448-b618-b6f594d0e8c5@t35g2000yqj.googlegroups.com> <125db7fe-036e-47c9-be89-50f05106936f@n2g2000pre.googlegroups.com> Message-ID: <4D35C5D2.7060606@mrabarnett.plus.com> On 18/01/2011 16:27, rantingrick wrote: > On Jan 18, 6:46 am, Antoine Pitrou wrote: > >> Design considerations? Where were they discussed? > > > They were never discussed with the bulk of this community and that is > part of what i want to change. We have a very small group of folks > making all the decisions and that is fine. However this small group of > "privileged" folks needs to gather input from the rest of us > (peasants) on the value of such changes before making rash decisions. > > Currently we have a closed set of intellectual inbreeding that is > rotting the community gene pool. We need more diversity in this > "milkshake" to bring about and foster healthy ideas. No wonder we get > these "brain childs" (farts) with inherited diseases from birth. Decisions are made after open discussion (although we're not sure about "move to end" :-)). You shouldn't complain about not being consulted if you don't take the time to join in... From rantingrick at gmail.com Tue Jan 18 12:10:48 2011 From: rantingrick at gmail.com (rantingrick) Date: Tue, 18 Jan 2011 09:10:48 -0800 (PST) Subject: move to end, in Python 3.2 Really? References: <58c17709-d68e-4448-b618-b6f594d0e8c5@t35g2000yqj.googlegroups.com> <125db7fe-036e-47c9-be89-50f05106936f@n2g2000pre.googlegroups.com> Message-ID: <99e7061d-20d5-434b-9404-bdafd6a013ac@i17g2000vbq.googlegroups.com> On Jan 18, 10:54?am, MRAB wrote: > Decisions are made after open discussion (although we're not sure about > "move to end" :-)). You shouldn't complain about not being consulted if > you don't take the time to join in... Well don't get wrong i want to join in --not that i have all the solutions-- however python-dev is a dangerous place for the uninitiated. And we can't have thousands and thousands of posts clogging up the main pool because that would only serve to slow the process to a grinding hault. However, we need some way that the average Python programmer can speak up and be heard when any subject that he/she is passionate about comes before the "council". These folks probably don't want to participate in the highly competitive environment of Python dev. However they may have very good ideas. I think we are doing this community a dis service by not giving these voices an outlet. We need either some way to vote outside of Python dev. i think it would be much easier to just have a site where all proposals can be viewed by anyone and they can offer input without clogging up Python dev with noob questions or bad ideas. Then the "council" can review these suggestions and make a more informed decision. Some might say "well that is what blogs and c.l.py is for" and i say wrong. I believe more folks would get involved if they felt that the medium was real. c.l.py is not that place (although it could be with some changes) and python.dev is not that place. I am open to any ideas you may have. From kushal.kumaran+python at gmail.com Tue Jan 18 12:15:00 2011 From: kushal.kumaran+python at gmail.com (Kushal Kumaran) Date: Tue, 18 Jan 2011 22:45:00 +0530 Subject: Python unicode utf-8 characters and MySQL unicode utf-8 characters In-Reply-To: <1914ba89-7ecc-43d5-8fbc-9a45f27ae8c8@z5g2000yqb.googlegroups.com> References: <1914ba89-7ecc-43d5-8fbc-9a45f27ae8c8@z5g2000yqb.googlegroups.com> Message-ID: 2011/1/18 Grzegorz ?liwi?ski : > Hello, > Recently I tried to insert some unicode object in utf-8 encoding into > MySQL using MySQLdb, and got MySQL warnings on characters like: > ???? i found somewhere in my data. I can't even read them. MySQL > seems to cut the whole string after that characters off, so I get > incomplete data. > After a little bit of digging I found out, that MySQL usually supports > utf-8 data but encoded into maximum three bytes. That's why I think it > would help I f I was able to replace all larger unicode characters > with replacement characters. > > Is there any way, I could adjust python unicode utf-8 encoded strings > to be accepted by mysql utf-8 columns? Did you pass the charset argument when creating your MySQLdb connection? -- regards, kushal From solipsis at pitrou.net Tue Jan 18 12:56:34 2011 From: solipsis at pitrou.net (Antoine Pitrou) Date: Tue, 18 Jan 2011 18:56:34 +0100 Subject: move to end, in Python 3.2 Really? References: <58c17709-d68e-4448-b618-b6f594d0e8c5@t35g2000yqj.googlegroups.com> <125db7fe-036e-47c9-be89-50f05106936f@n2g2000pre.googlegroups.com> <99e7061d-20d5-434b-9404-bdafd6a013ac@i17g2000vbq.googlegroups.com> Message-ID: <20110118185634.541cd9e1@pitrou.net> On Tue, 18 Jan 2011 09:10:48 -0800 (PST) rantingrick wrote: > > Well don't get wrong i want to join in --not that i have all the > solutions-- Take a look at http://docs.python.org/devguide/#contributing From debatem1 at gmail.com Tue Jan 18 12:57:03 2011 From: debatem1 at gmail.com (geremy condra) Date: Tue, 18 Jan 2011 09:57:03 -0800 Subject: [OT] Python like lanugages [was Re: After C++, what with Python?] In-Reply-To: References: <86a904f8-05b0-435f-81d6-7450650f1679@glegroupsg2000goo.googlegroups.com> <4d329899$0$43988$742ec2ed@news.sonic.net> <7x8vylfcvz.fsf@ruckus.brouhaha.com> <4d32c7cf$0$29983$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Mon, Jan 17, 2011 at 4:02 PM, Tim Harig wrote: >> Go is not an ideal language for high-performance code. Despite the >> occasional claims of others, Go is consistently outperformed by C, >> C++, and Java on a wide variety of benchmarks. Some claim that Ada and >> Haskell do as well, and my benchmarks (CPU bound, focused on speed of > > I much agree that Go doesn't beat C or C++. ?I really doubt that it could > with the runtime necessary to do garbage collction. ?Nevertheless, I find > that Go can be optimized to perform within tolerable limits of C given the > boost it gives in development. The question isn't whether you will use it; right or wrong, it seems certain that you will. The question is whether it will see significant uptake, and this is a big barrier for many. > I really question that you get Java anywhere even close to C performance. > Google reports they get within the same order of magnitude as C for > their long-lived server processes where the JIT has had time to optimize > its results. ?For shorter term processes such as desktop applications, > Java performance stinks -- even after you discount the JVM starup time. I'm sorry, but you're wrong on this. Java's performance can be excellent, particularly when it comes to mathematical functions. I recall reading a pretty smug paper a few years ago describing how they managed to beat C on a number of numerical benchmarks. > Ada is capable of C++ like performance *if* you compile it to remove *all* > of runtime checking. ?Depending what checks you enable, it can run much > slower. No idea, never used it. >> in line with the work of others. You can argue that it's good enough- >> it is, for most cases- but taking a 20% performance hit rules it out >> of a lot of systems work, and the C-Go gap in many cases is much >> larger than that. > > I don't work anything that involves and absolute need for performance. Then don't argue about performance, it makes you look like a hack just eager to shill for your language. > I could probably accept penalty several times that of C for higher > level functionality; but, sometimes the penalty for Python is just > too much. ?Many of my programs are very quick lived such that even > loading an interpeter or VM can eclipse the actual runtime. ?Given less > developmental effort required, I also find that I have more time to look > for ways to optimize Go. ?There are many things (such as using alternate > data structures rather then the build in slices and immutable strings) > that can be used to accelerate Go when time permits and I suspect many > more will be found as the language matures. This is inconsistent with your argument about PyPy. See my earlier comment. >> Go is also not an ideal language for enterprise development. It >> provides no compatibility or support guarantees; in fact, the website >> describes it as 'an experiment' and recommends it for 'adventurous > > There is no doubt that it is a young project and there are a number of > things that will need to be improved to be effective for some branches > of programming; but, that isn't a language restriction. It will nevertheless preclude its use in most enterprise software development. That's most systems software. > ?Frankly, I am > rather impressed by the sheer number of third party packages that have > already become available. ?No go isn't going to replace some of the other > top mainstream langauges today; but, I can easily see it starting to see > some market penetration 5 years from now. I suppose that for some small value of market penetration ('mom uses it!') you're right. I don't see any evidence of major movement at this moment though. >> users'. There are no independent experts in case something goes wrong, >> and if it goes belly up a year from now you will have a one year old >> piece of legacy infrastructure on your hands. Maybe you don't think >> that this will be the case; in any event, I would not want to try >> convincing a CFO of that. > > If I was trying to convince a CFO, I would ask if he really thought Google > was likely to simply drop the time and effort that Google has already > placed into the infrastructure. Hahahaha. You mean like wave? >?Furthermore, few dying languages already > have not one, but two, open source compilers available for use. Two compilers by the same people. Not two active projects. Big difference. > Database bindings are another weak link outside of the more common > open source databases. ?In both cases, Go readily capable of C library > functions as a stop-gap until a native wrapper is available. ?Yes it will > be nice once community has filled in the gaps; but, I am rather impressed > at what is already available in less then a years time. ?There are a few > libraries you may have missed here: Sounds like a two-language solution, ie, the thing you criticized Python for. > I will point out that Go's libraries are miles ahead of the standard C > library and other minimalistic standard libraries. ?Many things are > possible with even the most basic functionalities. ?I don't use Python > bindings when using GNUplot simply because its easier to access GNUplot > directly. And miles behind Python and other large standard libraries. > Finally, and most importantly, nothing about any third party tools and > libraries has any bearing on the generality language itself. Except for its uptake. >>> Support for concurrency is really icing on the cake. ?I find it rather >>> supprising that so many modern languages do not already support full >>> concurrency constructs. >> >> Go's most-lauded feature is its goroutines. I suspect that if this >> isn't a big deal for you, you aren't its primary use case. > > Actually, I would consider Go's implicit interfaces to be a far more > important innovation. ?The goroutines are nice but not ground breaking. > They are quite recognizable to other SCP concurrancy derivatives. I think if we did a poll of people who had heard of Go, they would generally say that concurrency was its big selling point. I suspect that its (ugly, IMHO) interface mechanism would not appear on the list. > C fails to be an object oriented language because it fails to provide > the syntactic sugar necessary to bind functions to the data that they > manipulate and because it doesn't provide the isolation necessary for > encapsilation of objects. No, it doesn't. I can add functions to structures using function pointers, and languages like Python only provide encapsulation by convention. There's no reason why that couldn't be true for C as well. Ergo, if Go is OO, then C is OO. > defer/panic/recover is conceptually a world closer to exceptions then is > setjmp/longjmp. ?It really isn't any further different then the variantions > in exceptions between different languages. We can agree to disagree here. As I say, I find it much closer to things like the with statement than true exceptions, and general internet rabble seems to agree. As a question, given how hot you are for this language I have to wonder how much of it you've actually written. Could you provide a link? Google code search turned up nada. Geremy Condra From joe at goldthwaites.com Tue Jan 18 13:01:19 2011 From: joe at goldthwaites.com (Joe Goldthwaite) Date: Tue, 18 Jan 2011 11:01:19 -0700 Subject: newby qn about functions In-Reply-To: References: Message-ID: <00710D8B61E1450BB05F97C22E27D6D9@NewMBP> I'm not sure I understand the question completely but maybe the function below does what you want. def lower_case(s): return ?Testing Functions-lower case: ? + s.lower() print lower_case(?AbCdEfG?) ________________________________________ From: python-list-bounces+joe=goldthwaites.com at python.org [mailto:python-list-bounces+joe=goldthwaites.com at python.org] On Behalf Of Cathy James Sent: Tuesday, January 18, 2011 3:02 AM To: python-list at python.org Subject: newby qn about functions #This has to be very simple, but I don't get it-please help ? def lower_case(s): ??? #return s ??? print(s) ??? #return s.lower() ??? print(s.lower()) s= "Testing?Functions-lower case: " lower_case(s) """how can i use a return statement? to write a function that returns the string "Testing?Functions-lower case: "and the lowercase representation of its string parameter""" If I uncomment the above, nothing outputs to console:( ? Much appreciation as always. From python at rcn.com Tue Jan 18 13:14:49 2011 From: python at rcn.com (Raymond Hettinger) Date: Tue, 18 Jan 2011 10:14:49 -0800 (PST) Subject: UTF-8 question from Dive into Python 3 References: Message-ID: <748ae354-c735-4bd6-95c7-8353ee5fb005@q8g2000prm.googlegroups.com> On Jan 17, 2:19?pm, carlo wrote: > Hi, > recently I had to study *seriously* Unicode and encodings for one > project in Python but I left with a couple of doubts arised after > reading the unicode chapter of Dive into Python 3 book by Mark > Pilgrim. > > 1- Mark says: > "Also (and you?ll have to trust me on this, because I?m not going to > show you the math), due to the exact nature of the bit twiddling, > there are no byte-ordering issues. A document encoded in UTF-8 uses > the exact same stream of bytes on any computer." . . . > 2- If that were true, can you point me to some documentation about the > math that, as Mark says, demonstrates this? I believe Mark was referring to the bit-twiddling described in the Design section at http://en.wikipedia.org/wiki/UTF-8 . Raymond From arndt.roger at addcom.de Tue Jan 18 13:25:44 2011 From: arndt.roger at addcom.de (Arndt Roger Schneider) Date: Tue, 18 Jan 2011 19:25:44 +0100 Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <79a8a$4d332d1a$4275d90a$3986@FUSE.NET> <64976187-88ad-47c9-9bc6-c0712a657264@j32g2000yqc.googlegroups.com> <3af4fd5e-8cc9-4cec-aad2-cbf82ad3bab3@l24g2000vby.googlegroups.com> Message-ID: rantingrick schrieb: > On Jan 18, 7:09 am, Arndt Roger Schneider > wrote: > > >>Summary wxWidgets: >>wxWidgets is large scale C++ library from the 20th century, >>solemnly dedicated toward desktop computers. >>wxWidgets originates from a time before templates >>were used in C++ and thus duplicates many of >>today's C++ features. >>wxWidgets is not suitable for a modern type >>GUI ad thus clearly not the toolkit/framework >>of the 21st century. > > > > Alight i'll except that Rodger. Wx may be unusable for the mobile > market. And since the mobile market is exploding --and will continue > to explode-- then we need to consider this. However, does any GUI > library exist that can handle desktop, mobile, and accessibility and > do it all in a 21st century way? You slaughtered wx but failed to > provide any alternative, however i am listing to your advice contently > because it is very good advice. Read on... Thanks! Again this is not about the quality of wxWidgets, wxWidgets grew large because there was vested interest in it. Its success is its undoing. > > We DO need to consider the mobile market in this decision. Maybe it is > time for us to actually get on the cutting edge of GUI's. Maybe we > should head an effort to create a REAL 21st century GUI that can > handle desktop, mobile, and accessibility, and do it all whilst > looking very sharp! Sure we rob from peter to pay paul. We will use > Tkinters awesome API and geometry managers, wxPythons feature > richness, and any other code we can steal to make this work! I am not sure whether this sarcasms or for real..., so I'll take for genuine. Tk is also doomed, and Tkinter isn't Tk. You are right about keeping the separate geometry managers, though. For starters: http://kenai.com/projects/swank Swank publishes java/swing classes as tk in jtcl, which is similar to what tkinter does for python and tk. It should be feasible to use swank with the tkinter interface for jpython--without jtcl. However, this doesn't make tkinter mobile, neither is swing available on android. When you look into the android developer documents concerning the gui, then you can see that the gui model is quite similar to tk. So I suppose android can be reached by jpython in a two stage process. The other devices are more difficult to reach, though. There is webkit on some, but not all. Webkit is available for the desktop, ios and android--today without svg. There are two ways to gain graphical independence: First a basic implementation for each platform and second through abstraction. With abstraction I mean to base the gui on a common graphical model present on all platforms and hence to implement the "toolkit" on-top of it in python (not C, C++, java,javascript), python! The single common graphical model is SVG. > > Then we can "advertise" python as the best GUI language available. I > have nothing against seeing Python on more devices and this would no > doubt bring that dream into fruition. There is a huge hole in the > market at this very moment and we need to pounce on it like a hungry > tiger on wildebeest. Just think how wonderful it would be to switch > from mobile to desktop and still write beatiful Python code. > So be it. -roger From tjreedy at udel.edu Tue Jan 18 13:26:07 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Tue, 18 Jan 2011 13:26:07 -0500 Subject: [OT] Python like lanugages [was Re: After C++, what with Python?] In-Reply-To: References: <86a904f8-05b0-435f-81d6-7450650f1679@glegroupsg2000goo.googlegroups.com> <4d329899$0$43988$742ec2ed@news.sonic.net> <7x8vylfcvz.fsf@ruckus.brouhaha.com> <4d32c7cf$0$29983$c3e8da3$5496439d@news.astraweb.com> <4d35a769$0$2258$a729d347@news.telepac.pt> Message-ID: On 1/18/2011 10:30 AM, Tim Harig wrote: > Whether or not you actually agree with that economic reality is > irrelevant. Those who fund commerical projects do; and, any developement > tool which violates the security of the source is going to find itself > climbing an uphill battle in trying to gain market penetration with > commericial software producers. Of course. When I submit or commit patches, I am doing it mostly for hobby, educational, and scientific users, and maybe website makers (who make site I can visit). If commercial users piggyback on top, ok. I do not know how many developers, if any, are after such market penetration. Shedskin compiles a slowly growing subset of Python to native code. But I do not know that it has gotten any commercial support. Maybe Mark should sell it instead of giving it away for commercial use (if he does now). -- Terry Jan Reedy From askutt at gmail.com Tue Jan 18 13:29:22 2011 From: askutt at gmail.com (Adam Skutt) Date: Tue, 18 Jan 2011 10:29:22 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <79a8a$4d332d1a$4275d90a$3986@FUSE.NET> <64976187-88ad-47c9-9bc6-c0712a657264@j32g2000yqc.googlegroups.com> <3af4fd5e-8cc9-4cec-aad2-cbf82ad3bab3@l24g2000vby.googlegroups.com> Message-ID: On Jan 18, 8:09?am, Arndt Roger Schneider wrote: > Back to rantingrick 21st century toolkit/framwork: > Let's have a look at the numbers: > Worlwide pc market are 300 Million pcs per year, > this number includes desktops(2/3) and servers(1/3). > Your gui app is not relevant on servers. You should tell this "fact" to just about every major enterprise software manufacturer out there. They all ship GUI tools intended to be used on the server. Some of them ship only GUI tools or CLI tools that are worthless, making you use the GUI tools. > The desktop pc market is in decline; there is > however a shift toward pc-servers, instead. > It is anybodies guess how far the pc-desktop decline will go. > Every 21st century toolkit or framework must run on > mobile platforms! Until we have pixel-perfect touch sensors, toolkits for devices with pointer interfaces (e.g., PCs) and toolkits for devices with touch interfaces (e.g., phones and tablets) will necessarily be different. You note this yourself: the UI paradigms that work well when you have a pixel-perfect pointer do not work at all when you have a touch screen, especially on a limited size and resolution display. Even if you're provided a "single" toolkit, you still end up with two, maybe three, different applications, each using different widgets targeted for the device they run on. And no one provides a "single" toolkit: while Silverlight can run on the desktop, the web, and now on Windows Phone, you can't use the same widgets everywhere; ditto with Cocoa for OS X and Cocoa Touch for iTouch devices. While some further unification is obviously possible, it's rather doubtful we'll ever have unified widgets that are truly workable on the web, on the "desktop", and on a portable touch screen device. > > wxWidgets was written ~1992, it is a copy of > mfc, which in turn is a copy of MacApp. MacApp > is also OSS, maintained through an industrie consortium. > Why do you not use the original framework? > Because it's not cross-platform, I'd imagine. The entire point of wxWidgets was to provide a cross-platform "OOP" UI toolkit. It closely copies MFC since MFC and XView were the two "backends" it supported. > Screen resolution: > ? ?The time of 72ppi CRT monitors is over. A GUI > ? ?framework/toolkit must be resolution independent, > ? ?including all icons and indicators; > ? ?it should use decluttering (newspeak:ZUI). > WPF is the only functional resolution-independent UI toolkit in existence. While I don't disagree with you in principal, practice is pretty heavily divorced from principal here. Principal doesn't help me write GUI applications today. > wxWidgets is not suitable for a modern type > GUI ad thus clearly not the toolkit/framework > of the 21st century. None of the toolkits accessible from CPython are suitable for a 21st century guy by your standard. If we talk about IronPython, Silverlight becomes the closest, but it isn't a panacea by any stretch of the imagination. Adam From rantingrick at gmail.com Tue Jan 18 13:33:45 2011 From: rantingrick at gmail.com (rantingrick) Date: Tue, 18 Jan 2011 10:33:45 -0800 (PST) Subject: move to end, in Python 3.2 Really? References: <58c17709-d68e-4448-b618-b6f594d0e8c5@t35g2000yqj.googlegroups.com> <125db7fe-036e-47c9-be89-50f05106936f@n2g2000pre.googlegroups.com> <99e7061d-20d5-434b-9404-bdafd6a013ac@i17g2000vbq.googlegroups.com> Message-ID: <665f862b-0d8f-476a-ae51-d8fdc9767f0a@g26g2000vbi.googlegroups.com> On Jan 18, 11:56?am, Antoine Pitrou wrote: > On Tue, 18 Jan 2011 09:10:48 -0800 (PST) > > rantingrick wrote: > > > Well don't get wrong i want to join in --not that i have all the > > solutions-- > > Take a look athttp://docs.python.org/devguide/#contributing Thanks for this link Antoine however i think you missed the point of my post. What i would like to see is an forum where the "noob" to "average" python programmer can voice his/her opinion about the current state or future state of Pythons syntax, stdlib, goals and dreams, etc, al the while not fearing attack from all sides. Currently such a place is non-existent. I believe many folks would get involved if this "place" existed however it does not exist. I also believe that these same folks have no interest in "debating" in the highly competitive environmental of python-dev, python-ideas. Heck, even c.l.py is far too competitive! They just basically want a forum were they can come in and give their two cents and leave. comp.lang.py would be a good place for this to happen since "after all" Usenet was created for like-minded people to collaborate in lively discussion. However c.l.py has a problem with criminals. We need to bring these "predators", "bullies", and "brow beaters" under control. I have seen many new voices come in and then get crucified by these scoundrels causing them to quickly "tuck tail" and run for cover --never to return again-- and nobody says a word!!!! And anyone who dares to speak out is threatened with the kill-file. This group has been handed over to the criminals who's only concern is chaos and anarchy all the while making sure that they control the speech and content herein. Now don't get me wrong we have a lot of good people here but they are too fearful to speak up. Sadly these folks don't realize that by staying quiet they only embolden the criminals to do more dastardly deeds. These criminals are cowards by nature, and when presented with a united front they will themselves "tuck tail" and run for the hills never to return. I am not saying we cannot have lively discussion, or even use the occasional sarcastic quip. No, what i am saying is that we need hear all sides of the argument. Remember this is a community of many different people wanting many different things. We must be willing to first listen, and then compromise on all sides -- if we want to move forward. Ask not... What is best for me? Instead ask yourself... What is best for the entire community? So the moral is... either we need to take back c.l.py (by force if needed!) or we need to abandon c.l.py and open a more friendly environment for Python discussions. Either way if this "forum" is not taken seriously by the "elite" then it will be yet another catastrophic failure! From alex.kapps at web.de Tue Jan 18 13:34:47 2011 From: alex.kapps at web.de (Alexander Kapps) Date: Tue, 18 Jan 2011 19:34:47 +0100 Subject: Tkinter: The good, the bad, and the ugly! In-Reply-To: <4D35DCE8.5030002@web.de> References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com><4d337983$0$29983$c3e8da3$5496439d@news.astraweb.com><044a5101-948d-4458-9c94-57dbb3e25f67@m35g2000vbn.googlegroups.com><4d3467bf$0$29983$c3e8da3$5496439d@news.astraweb.com> <4D34B04E.8050309@web.de> <4266E8D7BA204BFEA5BF66C635CE1716@octavian> <4D35DCE8.5030002@web.de> Message-ID: <4D35DD47.1070304@web.de> On 18.01.2011 09:58, Octavian Rasnita wrote: > From: "Alexander Kapps" >> On 17.01.2011 21:04, Octavian Rasnita wrote: >>> I say probably not considering the availability of 3rd party >>> downloads. What say you, Python community? >> >> Available as 3rd party downloads: >> >> XML,HTML,... >> HTTP,FTP,SMTP,POP,IMAP/... >> MD5,SHA,... >> zip,bzip,... >> >> and so on and so on and so on. >> >> Remove them all just because they are available as 3rd party >> downloads? > > No, they should not be removed because they don't cause any damage, > very bad damage as Tkinter does. Tkinter causes damage? Very bad damage? What are you talking about? >> The "Batteries included" of Python is just *great* and I vote for >> *more* not less batteries! > > Well, in that case, why don't you agree to also include WxPython in > the Python package? Well, I don't like wx that much and others have already highlighted some of the problems with it. I think that adding redundancy is bad and I really want a GUI toolkit that makes it easy to quickly write a simple GUI, so I do not want wx to replace Tkinter. But yes, I wouldn't mind the inclusion of a large GUI package. >>> And one more thing. Not all the Python programmers create desktop >>> apps so a GUI lib is useless. Some of them use Python only for >>> web programming or only for system administration. >> >> Not all Python programmers do web programming, so please remove >> the useless HTML junk too. > > Why do you call it "html junk"? You said a GUI lib is useless because not all programmers write GUIs. so I say an HTML lib is useless because not all programmers write web stuff. Got it? Both are useful and I'm absolutely against any attempt to remove either from the stdlib. *That* would cause damage. >> Almost every beginner wants to do GUIs or at least some graphic >> stuff. Removing the GUI module from the stdlib would be plain >> wrong IMHO. But I don't understand the whole issue anyway. It >> isn't that you need to fire up your torrent client and wait 48 >> hours for the Python download to complete. Why remove useful (to >> many, not most) stuff from the lib? > > Yes it can be useful for some people, but why promote it instead of > promoting a better library for beginners? Which one? That's the whole point. There currently is no better GUI lib than Tkinter which allows quick and easy GUI programming and still has a large widget set, is pythonic and so on. PyGUI might be in the future. If you care that much go on and help making it happen. I have absolutely no problem with a better GUI lib, I just don't care much and those who seem to care enough to start a war over and over again seem to be unwilling to really do anything. > Octavian > From pruebauno at latinmail.com Tue Jan 18 13:39:43 2011 From: pruebauno at latinmail.com (nn) Date: Tue, 18 Jan 2011 10:39:43 -0800 (PST) Subject: move to end, in Python 3.2 Really? References: <58c17709-d68e-4448-b618-b6f594d0e8c5@t35g2000yqj.googlegroups.com> <125db7fe-036e-47c9-be89-50f05106936f@n2g2000pre.googlegroups.com> Message-ID: <8c6c051c-cb76-4e38-97c0-ad9b658d3b41@37g2000prx.googlegroups.com> On Jan 18, 12:20?am, Raymond Hettinger wrote: > On Jan 17, 6:51?pm, nn wrote: > > > ...But the api on this baffles me a bit: > > > >>> d = OrderedDict.fromkeys('abcde') > > >>> d.move_to_end('b', last=False) > > >>> ''.join(d.keys) > > > 'bacde' > > > I understand that "end" could potentially mean either end, but would > > "move_to_end" and "move_to_beginning" not have been clearer? > > The default (and normal usage) is to move an item to the last > position. > So, od.move_to_end(k) becomes a fast equivalent to v=d.pop(k) > followed by d[k]=v. > > The less common usage of moving to the beginning is done with > last=False. ?This parallels the existing API for od.popitem(): > > >>> od = OrderedDict.fromkeys('abcdefghi') > >>> od.move_to_end('c') ? ? ? ? ? ? ? # default case: ?move to last > >>> od.popitem() ? ? ? ? ? ? ? ? ? ? ?# default case: ?pop from last > ('c', None) > >>> od.move_to_end('d', last=False) ? # other case: ? ?move to first > >>> od.popitem(last=False) ? ? ? ? ? ?# other case: ? ?pop from first > > ('d', None) > > The existing list.pop() API is similar (though it takes an index > value instead of a boolean): > > >>> mylist.pop() ? ? ? ? ? ? ? ? ? ? ?# default case: ?pop from last > >>> mylist.pop(0) ? ? ? ? ? ? ? ? ? ? # other case: ? ?pop from first > > Those were the design considerations. ?Sorry you didn't like the > result. > > Raymond Ah that is where it came from! I didn't remember popitem used that API too. If you use them together it has a nice symmetry. I guess it is just that "end" is more confusing than "pop" in that context. Considering the precedence of popitem I withdraw my objection. I still think it looks a bit odd but it is not unreasonable either. Sometimes ugly consistency trumps beautiful inconsistency; c'est la vie... From emile at fenx.com Tue Jan 18 13:55:57 2011 From: emile at fenx.com (Emile van Sebille) Date: Tue, 18 Jan 2011 10:55:57 -0800 Subject: move to end, in Python 3.2 Really? In-Reply-To: <99e7061d-20d5-434b-9404-bdafd6a013ac@i17g2000vbq.googlegroups.com> References: <58c17709-d68e-4448-b618-b6f594d0e8c5@t35g2000yqj.googlegroups.com> <125db7fe-036e-47c9-be89-50f05106936f@n2g2000pre.googlegroups.com> <99e7061d-20d5-434b-9404-bdafd6a013ac@i17g2000vbq.googlegroups.com> Message-ID: On 1/18/2011 9:10 AM rantingrick said... > On Jan 18, 10:54 am, MRAB wrote: > >> Decisions are made after open discussion (although we're not sure about >> "move to end" :-)). You shouldn't complain about not being consulted if >> you don't take the time to join in... > > Well don't get wrong i want to join in --not that i have all the > solutions-- however python-dev is a dangerous place for the > uninitiated. And we can't have thousands and thousands of posts > clogging up the main pool because that would only serve to slow the > process to a grinding hault. > > However, we need some way that the average Python programmer can speak > up and be heard when any subject that he/she is passionate about comes > before the "council". These folks probably don't want to participate > in the highly competitive environment of Python dev. However they may > have very good ideas. I think we are doing this community a dis > service by not giving these voices an outlet. > > We need either some way to vote outside of Python dev. i think it > would be much easier to just have a site where all proposals can be > viewed by anyone and they can offer input without clogging up Python > dev with noob questions or bad ideas. Then the "council" can review > these suggestions and make a more informed decision. Some might say > "well that is what blogs and c.l.py is for" and i say wrong. I believe > more folks would get involved if they felt that the medium was real. > c.l.py is not that place (although it could be with some changes) and > python.dev is not that place. > > I am open to any ideas you may have. Brett Cannon used to (still does?) prepare twice monthly summaries of activity on python-dev which provided insight as to what was happening on that side of things. I don't know if he or anyone else still does so, but if so, a copy to this list would at least let everyone know if something was happening that you might want to weigh in on. see http://article.gmane.org/gmane.comp.python.devel/43893 Emile From rantingrick at gmail.com Tue Jan 18 14:03:55 2011 From: rantingrick at gmail.com (rantingrick) Date: Tue, 18 Jan 2011 11:03:55 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <79a8a$4d332d1a$4275d90a$3986@FUSE.NET> <64976187-88ad-47c9-9bc6-c0712a657264@j32g2000yqc.googlegroups.com> <3af4fd5e-8cc9-4cec-aad2-cbf82ad3bab3@l24g2000vby.googlegroups.com> Message-ID: On Jan 18, 12:25?pm, Arndt Roger Schneider wrote: > rantingrick schrieb: > > On Jan 18, 7:09 am, Arndt Roger Schneider > > We DO need to consider the mobile market in this decision. Maybe it is > > time for us to actually get on the cutting edge of GUI's. Maybe we > > should head an effort to create a REAL 21st century GUI that can > > handle desktop, mobile, and accessibility, and do it all whilst > > looking very sharp! Sure we rob from peter to pay paul. We will use > > Tkinters awesome API and geometry managers, wxPythons feature > > richness, and any other code we can steal to make this work! > > I am not sure whether this sarcasms or for real..., > so I'll take for genuine. No this is real, albeit a bit fantastical. Thats probably why you thought it was sarcasm :). However, we need to start a revolution in the GUI world. Currently we (as developers) are slaves to the OEM's and OS's. This must change. We must unify GUI coding the same way OpenGL unified graphics coding. Multiplicity is ruining any and all advancements in Graphical User Interfaces. Sure multiplicity is great in emerging systems (language, culture, GUI, etc, etc) However at some point you must reign in this multiplicity and harness the collective knowledge into an all encompassing standard. OpenGUI is that standard. It should be shipped with every OS in the world. This is the only way we can have mobile, desktop, and accessibility all combined into one beautiful package. Then the contest come down to who can create the best abstraction API. > Tk is also doomed, and Tkinter isn't Tk. > You are right about keeping the separate geometry > managers, though. > > For starters:http://kenai.com/projects/swank This looks like a very young project (beta) and i could not find a widget set. However i will investigate more. Thanks However we need to think beyond even a Python community scale. This problem is inherent in every language community out there. We to unify the GUI standard. And we are a decade behind in development. (yes i am completely serious about all of this!). From usernet at ilthio.net Tue Jan 18 14:05:02 2011 From: usernet at ilthio.net (Tim Harig) Date: Tue, 18 Jan 2011 19:05:02 +0000 (UTC) Subject: [OT] Python like lanugages [was Re: After C++, what with Python?] References: <86a904f8-05b0-435f-81d6-7450650f1679@glegroupsg2000goo.googlegroups.com> <4d329899$0$43988$742ec2ed@news.sonic.net> <7x8vylfcvz.fsf@ruckus.brouhaha.com> <4d32c7cf$0$29983$c3e8da3$5496439d@news.astraweb.com> Message-ID: On 2011-01-18, geremy condra wrote: > On Mon, Jan 17, 2011 at 4:02 PM, Tim Harig wrote: >> I really question that you get Java anywhere even close to C performance. >> Google reports they get within the same order of magnitude as C for >> their long-lived server processes where the JIT has had time to optimize >> its results. ?For shorter term processes such as desktop applications, >> Java performance stinks -- even after you discount the JVM starup time. > > I'm sorry, but you're wrong on this. Java's performance can be > excellent, particularly when it comes to mathematical functions. I > recall reading a pretty smug paper a few years ago describing how they > managed to beat C on a number of numerical benchmarks. I have no doubt that Java *can* occasionally beat *some* C for *some* benchmarks; but, overall, Java has a terrible reputation for performance. I worked with a company a few years ago that tried replacing a C VNC client with a Java one so that its technical support contractor's wouldn't need to have the VNC client installed on the agent's workstations. Several of the contracters had to upgrade their systems in order to use the Java version because it slowed down the machines so much that the agents could not perform their jobs effectively; and that is pretty typical from what I have seen with Java overall. Java performs very well with some select tasks. For others, it does exceedingly poor. That kind of hit or miss is pretty typical for JIT compilers in general. That isn't usually the case for fully compiled langauges where you are pretty much guaranteed to get decent, if not always the absolute top, performance. >> Ada is capable of C++ like performance *if* you compile it to remove *all* >> of runtime checking. ?Depending what checks you enable, it can run much >> slower. > > No idea, never used it. > >>> in line with the work of others. You can argue that it's good enough- >>> it is, for most cases- but taking a 20% performance hit rules it out >>> of a lot of systems work, and the C-Go gap in many cases is much >>> larger than that. >> >> I don't work anything that involves and absolute need for performance. > > Then don't argue about performance, it makes you look like a hack just > eager to shill for your language. What you don't seem to realize is there is often a performance level that is good enough. For many things, Python is good enough. Many others, where Python is insufficient, may still be acceptable to use Java. Some things require the absolute best performance and will probably always need C/C++ or equivilantly low level language. >> I could probably accept penalty several times that of C for higher >> level functionality; but, sometimes the penalty for Python is just >> too much. ?Many of my programs are very quick lived such that even >> loading an interpeter or VM can eclipse the actual runtime. ?Given less >> developmental effort required, I also find that I have more time to look >> for ways to optimize Go. ?There are many things (such as using alternate >> data structures rather then the build in slices and immutable strings) >> that can be used to accelerate Go when time permits and I suspect many >> more will be found as the language matures. > > This is inconsistent with your argument about PyPy. See my earlier comment. I can accept 2 to 3 times the overall performance of C for almost all of the problems that I deal with. When that multiple gets into the double digits, it can start to cause some real headaches for some problems. When that number reaches the upper double digits, it is acceptable for even fewer problems. Python is great for those problems where performance isn't critical and I make extensive use of it. Different methods of mixing Python and C (including manual, PyPy, SWIG, boost, etc) can extend Python's useful range; but, I have not seen the kind of speed improvements that bring it to less then an order of magnitude of C's speed overall. Even assuming that PyPy does actually manage to reach within a magnitude of C with the extra effort required to leverage two languages, why would I bother when I can do it with one? PyPy and similar methods where great when there was no other mid level alternative that supported Python like features. Now it just seems like using Python as a hammer for every problem whether or not it is the right tool for the job. >>> Go is also not an ideal language for enterprise development. It >>> provides no compatibility or support guarantees; in fact, the website >>> describes it as 'an experiment' and recommends it for 'adventurous >> >> There is no doubt that it is a young project and there are a number of >> things that will need to be improved to be effective for some branches >> of programming; but, that isn't a language restriction. > > It will nevertheless preclude its use in most enterprise software > development. That's most systems software. So you conclude that because it is not quite ready for prime time yet that it never will be? I can remember when people said C++ would never amount to anything either. >> Database bindings are another weak link outside of the more common >> open source databases. ?In both cases, Go readily capable of C library >> functions as a stop-gap until a native wrapper is available. ?Yes it will >> be nice once community has filled in the gaps; but, I am rather impressed >> at what is already available in less then a years time. ?There are a few >> libraries you may have missed here: > > Sounds like a two-language solution, ie, the thing you criticized Python for. Not quite. 1. My arguments for dual language solutions where never directed at Python proper. They were directed at PyPy. I am rather amazed at the number of things that can be accomplished in Python without having to bind to C. 2. There is a difference in binding to a solution that is already written in another language so as to not reinvent a wheel and implementing a *new* library in another language to be used exclusively with Python. From rantingrick at gmail.com Tue Jan 18 14:11:36 2011 From: rantingrick at gmail.com (rantingrick) Date: Tue, 18 Jan 2011 11:11:36 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <79a8a$4d332d1a$4275d90a$3986@FUSE.NET> <64976187-88ad-47c9-9bc6-c0712a657264@j32g2000yqc.googlegroups.com> <3af4fd5e-8cc9-4cec-aad2-cbf82ad3bab3@l24g2000vby.googlegroups.com> Message-ID: <9d0d0f8a-9684-4405-897c-141f2241070d@fo10g2000vbb.googlegroups.com> On Jan 18, 12:29?pm, Adam Skutt wrote: > Until we have pixel-perfect touch sensors, toolkits for devices with > pointer interfaces (e.g., PCs) and toolkits for devices with touch > interfaces (e.g., phones and tablets) will necessarily be different. > > You note this yourself: the UI paradigms that work well when you have > a pixel-perfect pointer do not work at all when you have a touch > screen, especially on a limited size and resolution display. > > Even if you're provided a "single" toolkit, you still end up with two, > maybe three, different applications, each using different widgets > targeted for the device they run on. ?And no one provides a "single" > toolkit: while Silverlight can run on the desktop, the web, and now on > Windows Phone, you can't use the same widgets everywhere; ditto with > Cocoa for OS X and Cocoa Touch for iTouch devices. > > While some further unification is obviously possible, it's rather > doubtful we'll ever have unified widgets that are truly workable on > the web, on the "desktop", and on a portable touch screen device. Adam now you are making sense. Everything you said here is true. This is why we must push for the OpenGUI standard. The entropy in GUIs has exploded exponentially and rendered them all useless. We must unify the collective knowledge base into a single system and shake up the GUI world from top to bottom. Any other effort is just wasted energy. Forget WxPython, Forget WxWidgets, Forget any and all GUI libraries that exists, they are all moot at this point and we are -years- DECADES behind in development and integration. See my reply to Rodger for more detail.. From wxjmfauth at gmail.com Tue Jan 18 14:12:14 2011 From: wxjmfauth at gmail.com (jmfauth) Date: Tue, 18 Jan 2011 11:12:14 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <79a8a$4d332d1a$4275d90a$3986@FUSE.NET> <64976187-88ad-47c9-9bc6-c0712a657264@j32g2000yqc.googlegroups.com> <3af4fd5e-8cc9-4cec-aad2-cbf82ad3bab3@l24g2000vby.googlegroups.com> Message-ID: > > > If you think the site is bad, send me a ONE better screenshot, or link > > thereto, of wx on WinXP/Vista/7. I promise to look at it. Then urge > > Robin to update the page. > No wxWidgets, but real Python / wxPython applications, all updated on Windows 7. http://spinecho.ze.cx/ From brian.curtin at gmail.com Tue Jan 18 14:16:58 2011 From: brian.curtin at gmail.com (Brian Curtin) Date: Tue, 18 Jan 2011 13:16:58 -0600 Subject: move to end, in Python 3.2 Really? In-Reply-To: <665f862b-0d8f-476a-ae51-d8fdc9767f0a@g26g2000vbi.googlegroups.com> References: <58c17709-d68e-4448-b618-b6f594d0e8c5@t35g2000yqj.googlegroups.com> <125db7fe-036e-47c9-be89-50f05106936f@n2g2000pre.googlegroups.com> <99e7061d-20d5-434b-9404-bdafd6a013ac@i17g2000vbq.googlegroups.com> <665f862b-0d8f-476a-ae51-d8fdc9767f0a@g26g2000vbi.googlegroups.com> Message-ID: On Tue, Jan 18, 2011 at 12:33, rantingrick wrote: > > On Jan 18, 11:56 am, Antoine Pitrou wrote: > > On Tue, 18 Jan 2011 09:10:48 -0800 (PST) > > > > rantingrick wrote: > > > > > Well don't get wrong i want to join in --not that i have all the > > > solutions-- > > > > Take a look athttp://docs.python.org/devguide/#contributing > > Thanks for this link Antoine however i think you missed the point of > my post. What i would like to see is an forum where the "noob" to > "average" python programmer can voice his/her opinion about the > current state or future state of Pythons syntax, stdlib, goals and > dreams, etc, al the while not fearing attack from all sides. Currently > such a place is non-existent. I believe many folks would get involved > if this "place" existed however it does not exist. I'm unaware of "attack from all sides" on python-dev, but the standards are high, as they should be. The discussion is open to everyone, but it's not generally about opinions, goals, dreams, etc. -- it's mostly about getting work done. python-ideas might be a list that would work for what you are looking for. It's a list of possible ideas to implement in Python. Some are half-baked ideas needing community help and input, some are fully thought out implementations asking if the community thinks it's worthy of inclusion. I'm not sure why this list, python-list, isn't a good venue for any of that. A lot of the people who follow python-dev also follow this list, e.g., Raymond and Antoine who already commented on this. I also believe that > these same folks have no interest in "debating" in the highly > competitive environmental of python-dev, python-ideas. Heck, even > c.l.py is far too competitive! They just basically want a forum were > they can come in and give their two cents and leave. > Sorry, it's not that easy, for good reason. We're talking about a programming language that has been around for quite a while, is used in many places for many reasons by many people, and the numbers surrounding just about every category are always rising. We're also talking about a group of volunteers who spend their time working on Python. Drive-by commenting likely serves little purpose other than noise. If you want to bring something up, by all means bring it up, but you will probably have to fight for it. We can't just have everyone throw two cent suggestions in a hat and move along. -------------- next part -------------- An HTML attachment was scrubbed... URL: From mark at markroseman.com Tue Jan 18 14:17:20 2011 From: mark at markroseman.com (Mark Roseman) Date: Tue, 18 Jan 2011 12:17:20 -0700 Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> 9-4a9f-b0e7-54bb681a6ea0@l8g2000yqh.googlegrouppppppp <4d337983$0$29983$c3e8da3$5496439d@news.astraweb.com> <044a5101-948d-4458-9c94-57dbb3e25f67@m35g2000vbn.googlegroups.com> <4d3467bf$0$29983$c3e8da3$5496439d@news.astraweb.com> <4D34B04E.8050309@web.de> <4266E8D7BA204BFEA5BF66C635CE1716@octavian> <4D35DCE8.5030002@web.de> Message-ID: If you guys spent 1/10th as much time articulating the problems you see with Tkinter (and being willing to listen when people offer solutions) as you do trying to convince everyone else you're right, you'd probably have ... well, anyway, no sense in being practical. From solipsis at pitrou.net Tue Jan 18 14:17:22 2011 From: solipsis at pitrou.net (Antoine Pitrou) Date: Tue, 18 Jan 2011 20:17:22 +0100 Subject: move to end, in Python 3.2 Really? References: <58c17709-d68e-4448-b618-b6f594d0e8c5@t35g2000yqj.googlegroups.com> <125db7fe-036e-47c9-be89-50f05106936f@n2g2000pre.googlegroups.com> <99e7061d-20d5-434b-9404-bdafd6a013ac@i17g2000vbq.googlegroups.com> <665f862b-0d8f-476a-ae51-d8fdc9767f0a@g26g2000vbi.googlegroups.com> Message-ID: <20110118201722.4fae8aad@pitrou.net> On Tue, 18 Jan 2011 10:33:45 -0800 (PST) rantingrick wrote: > > On Jan 18, 11:56?am, Antoine Pitrou wrote: > > On Tue, 18 Jan 2011 09:10:48 -0800 (PST) > > > > rantingrick wrote: > > > > > Well don't get wrong i want to join in --not that i have all the > > > solutions-- > > > > Take a look athttp://docs.python.org/devguide/#contributing > > Thanks for this link Antoine however i think you missed the point of > my post. You did say "I want to join in". > What i would like to see is an forum where the "noob" to > "average" python programmer can voice his/her opinion about the > current state or future state of Pythons syntax, stdlib, goals and > dreams, etc, al the while not fearing attack from all sides. Well the only way for that to happen is to put it up yourself. Or to gather some people around you to put it up together. Regards Antoine. From rantingrick at gmail.com Tue Jan 18 14:22:53 2011 From: rantingrick at gmail.com (rantingrick) Date: Tue, 18 Jan 2011 11:22:53 -0800 (PST) Subject: move to end, in Python 3.2 Really? References: <58c17709-d68e-4448-b618-b6f594d0e8c5@t35g2000yqj.googlegroups.com> <125db7fe-036e-47c9-be89-50f05106936f@n2g2000pre.googlegroups.com> <99e7061d-20d5-434b-9404-bdafd6a013ac@i17g2000vbq.googlegroups.com> Message-ID: On Jan 18, 12:55?pm, Emile van Sebille wrote: > On 1/18/2011 9:10 AM rantingrick said... > > > > > > > > > > > On Jan 18, 10:54 am, MRAB ?wrote: > > >> Decisions are made after open discussion (although we're not sure about > >> "move to end" :-)). You shouldn't complain about not being consulted if > >> you don't take the time to join in... > > > Well don't get wrong i want to join in --not that i have all the > > solutions-- however python-dev is a dangerous place for the > > uninitiated. And we can't have thousands and thousands of posts > > clogging up the main pool because that would only serve to slow the > > process to a grinding hault. > > > However, we need some way that the average Python programmer can speak > > up and be heard when any subject that he/she is passionate about comes > > before the "council". These folks probably don't want to participate > > in the highly competitive environment of Python dev. However they may > > have very good ideas. I think we are doing this community a dis > > service by not giving these voices an outlet. > > > We need either some way to vote outside of Python dev. i think it > > would be much easier to just have a site where all proposals can be > > viewed by anyone and they can offer input without clogging up Python > > dev with noob questions or bad ideas. Then the "council" can review > > these suggestions and make a more informed decision. Some might say > > "well that is what blogs and c.l.py is for" and i say wrong. I believe > > more folks would get involved if they felt that the medium was real. > > c.l.py is not that place (although it could be with some changes) and > > python.dev is not that place. > > > I am open to any ideas you may have. > > Brett Cannon used to (still does?) prepare twice monthly summaries of > activity on python-dev which provided insight as to what was happening > on that side of things. ?I don't know if he or anyone else still does > so, but if so, a copy to this list would at least let everyone know if > something was happening that you might want to weigh in on. > > seehttp://article.gmane.org/gmane.comp.python.devel/43893 > > Emile That is dated 2002? :D Thanks for offering a suggestion it was very welcome however i need to emphasize that what i am proposing is sort of "community discussion suggestion box". Like a "Python Suggestions" group or something. Where any and all suggestions, rants, complaints, ideas, etc, are welcome from anyone without fear of reprisals. However, in order for this to succeed the "elite" must take the time to actually read it. Maybe we could have some trusted "proof readers" who could sift out the spam and useless stuff and then send a modified version to the senate for congressional reviewing. Of course at that point the senate can further narrow down the list before sending over to the white house. This is the only way (short of sending out warnings in the python releases) that you can actually get a feel for what Joe and Jane Python programmer are happy with. From rantingrick at gmail.com Tue Jan 18 14:26:13 2011 From: rantingrick at gmail.com (rantingrick) Date: Tue, 18 Jan 2011 11:26:13 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> 9-4a9f-b0e7-54bb681a6ea0@l8g2000yqh.googlegrouppppppp <4d337983$0$29983$c3e8da3$5496439d@news.astraweb.com> <044a5101-948d-4458-9c94-57dbb3e25f67@m35g2000vbn.googlegroups.com> <4d3467bf$0$29983$c3e8da3$5496439d@news.astraweb.com> <4D34B04E.8050309@web.de> <4266E8D7BA204BFEA5BF66C635CE1716@octavian> <4D35DCE8.5030002@web.de> Message-ID: On Jan 18, 1:17?pm, Mark Roseman wrote: > If you guys spent 1/10th as much time articulating the problems you see > with Tkinter (and being willing to listen when people offer solutions) > as you do trying to convince everyone else you're right, you'd probably > have ... well, anyway, no sense in being practical. Well mark why don't you offer some facts on the merits of Tkinter versus WxPython (or libray X) instead of just contributing nothing. Heck you did not even interject an opinion? This is just argumentative speech Mark, i would really like some soild input from you since you (like myself) are neck deep in Tkinter code. From debatem1 at gmail.com Tue Jan 18 14:50:33 2011 From: debatem1 at gmail.com (geremy condra) Date: Tue, 18 Jan 2011 11:50:33 -0800 Subject: [OT] Python like lanugages [was Re: After C++, what with Python?] In-Reply-To: References: <86a904f8-05b0-435f-81d6-7450650f1679@glegroupsg2000goo.googlegroups.com> <4d329899$0$43988$742ec2ed@news.sonic.net> <7x8vylfcvz.fsf@ruckus.brouhaha.com> <4d32c7cf$0$29983$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Tue, Jan 18, 2011 at 11:05 AM, Tim Harig wrote: > Even assuming that PyPy does actually manage to reach within a magnitude > of C with the extra effort required to leverage two languages, why > would I bother when I can do it with one? ?PyPy and similar methods > where great when there was no other mid level alternative that supported > Python like features. ?Now it just seems like using Python as a hammer > for every problem whether or not it is the right tool for the job. You clearly have no idea what you're talking about regarding PyPy. You could at least have googled it before speaking about it. >>>> Go is also not an ideal language for enterprise development. It >>>> provides no compatibility or support guarantees; in fact, the website >>>> describes it as 'an experiment' and recommends it for 'adventurous >>> >>> There is no doubt that it is a young project and there are a number of >>> things that will need to be improved to be effective for some branches >>> of programming; but, that isn't a language restriction. >> >> It will nevertheless preclude its use in most enterprise software >> development. That's most systems software. > > So you conclude that because it is not quite ready for prime time yet that it > never will be? ?I can remember when people said C++ would never amount to > anything either. We're a year past the initial announcement that it was ready. It's still 'an experiment'. It doesn't have a ratified standard, committee, or governing body. The company that developed it seems to have no interest in enterprise support. They haven't done any serious marketing for it since the initial release. Five years is, to put it mildly, an overly enthusiastic timeline for the development of broad-based industry support under those conditions. >>> Database bindings are another weak link outside of the more common >>> open source databases. ?In both cases, Go readily capable of C library >>> functions as a stop-gap until a native wrapper is available. ?Yes it will >>> be nice once community has filled in the gaps; but, I am rather impressed >>> at what is already available in less then a years time. ?There are a few >>> libraries you may have missed here: >> >> Sounds like a two-language solution, ie, the thing you criticized Python for. > > Not quite. > > 1. My arguments for dual language solutions where never directed at Python > ? ? ? ?proper. ? They were directed at PyPy. ?I am rather amazed at > ? ? ? ?the number of things that can be accomplished in Python without > ? ? ? ?having to bind to C. Again, you don't know what you're talking about WRT PyPy. > 2. There is a difference in binding to a solution that is already written > ? ? ? ?in another language so as to not reinvent a wheel and implementing > ? ? ? ?a *new* library in another language to be used exclusively > ? ? ? ?with Python. Even if that binding is done for performance reasons? Geremy Condra From usernet at ilthio.net Tue Jan 18 14:53:57 2011 From: usernet at ilthio.net (Tim Harig) Date: Tue, 18 Jan 2011 19:53:57 +0000 (UTC) Subject: [OT] Python like lanugages [was Re: After C++, what with Python?] References: <86a904f8-05b0-435f-81d6-7450650f1679@glegroupsg2000goo.googlegroups.com> <4d329899$0$43988$742ec2ed@news.sonic.net> <7x8vylfcvz.fsf@ruckus.brouhaha.com> <4d32c7cf$0$29983$c3e8da3$5496439d@news.astraweb.com> <4d35a769$0$2258$a729d347@news.telepac.pt> Message-ID: On 2011-01-18, Terry Reedy wrote: > On 1/18/2011 10:30 AM, Tim Harig wrote: > >> Whether or not you actually agree with that economic reality is >> irrelevant. Those who fund commerical projects do; and, any developement >> tool which violates the security of the source is going to find itself >> climbing an uphill battle in trying to gain market penetration with >> commericial software producers. > > Of course. When I submit or commit patches, I am doing it mostly for > hobby, educational, and scientific users, and maybe website makers (who > make site I can visit). If commercial users piggyback on top, ok. I do > not know how many developers, if any, are after such market penetration. You kind of over-extended the intentions of my comment. It does not apply to open source software in general. I agree that open source authors are not interested in the quantitative value of market penetration. However, I am betting that most authors of developement tools would like to be able to use their tools on the job. I am sure that more software developers would love to develop using Python as part of their job. For some this is a reality; but, many more are stuck using their employer's choice of language. One of the factors that employers consider, when they choose a language, if they produce retail software is that the process of compiling will sufficiently obfiscate their code. From brian.curtin at gmail.com Tue Jan 18 15:08:46 2011 From: brian.curtin at gmail.com (Brian Curtin) Date: Tue, 18 Jan 2011 14:08:46 -0600 Subject: move to end, in Python 3.2 Really? In-Reply-To: References: <58c17709-d68e-4448-b618-b6f594d0e8c5@t35g2000yqj.googlegroups.com> <125db7fe-036e-47c9-be89-50f05106936f@n2g2000pre.googlegroups.com> <99e7061d-20d5-434b-9404-bdafd6a013ac@i17g2000vbq.googlegroups.com> Message-ID: On Tue, Jan 18, 2011 at 13:22, rantingrick wrote: > > Thanks for offering a suggestion it was very welcome however i need to > emphasize that what i am proposing is sort of "community discussion > suggestion box". Like a "Python Suggestions" group or something. Where > any and all suggestions, rants, complaints, ideas, etc, are welcome > from anyone without fear of reprisals. What is it with all of this talk of fear? Is there some group of people who were shamed out of python-dev that I wasn't aware of? It's not a hostile mailing list, and I'm not sure why you keep saying that it is... I understand maybe I don't feel that way because I've been reading it for a while, but even thinking back to when I was new around there, I never felt any amount of fear. Sure, I've talked to people who had things shot down and they took it harshly, but they realized it was just part of the game and it wasn't personal and they weren't kicked out of the group or anything. -------------- next part -------------- An HTML attachment was scrubbed... URL: From arndt.roger at addcom.de Tue Jan 18 15:20:32 2011 From: arndt.roger at addcom.de (Arndt Roger Schneider) Date: Tue, 18 Jan 2011 21:20:32 +0100 Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <79a8a$4d332d1a$4275d90a$3986@FUSE.NET> <64976187-88ad-47c9-9bc6-c0712a657264@j32g2000yqc.googlegroups.com> <3af4fd5e-8cc9-4cec-aad2-cbf82ad3bab3@l24g2000vby.googlegroups.com> Message-ID: rantingrick schrieb: > On Jan 18, 12:25 pm, Arndt Roger Schneider > wrote: > >>rantingrick schrieb: >> >>>On Jan 18, 7:09 am, Arndt Roger Schneider > > >>>We DO need to consider the mobile market in this decision. Maybe it is >>>time for us to actually get on the cutting edge of GUI's. Maybe we >>>should head an effort to create a REAL 21st century GUI that can >>>handle desktop, mobile, and accessibility, and do it all whilst >>>looking very sharp! Sure we rob from peter to pay paul. We will use >>>Tkinters awesome API and geometry managers, wxPythons feature >>>richness, and any other code we can steal to make this work! >> >>I am not sure whether this sarcasms or for real..., >>so I'll take for genuine. > > > > No this is real, albeit a bit fantastical. Thats probably why you > thought it was sarcasm :). > > However, we need to start a revolution in the GUI world. Currently we > (as developers) are slaves to the OEM's and OS's. This must change. We > must unify GUI coding the same way OpenGL unified graphics coding. > Multiplicity is ruining any and all advancements in Graphical User > Interfaces. Sure multiplicity is great in emerging systems (language, > culture, GUI, etc, etc) However at some point you must reign in this > multiplicity and harness the collective knowledge into an all > encompassing standard. OpenGUI is that standard. It should be shipped > with every OS in the world. This is the only way we can have mobile, > desktop, and accessibility all combined into one beautiful package. > Then the contest come down to who can create the best abstraction API. > There has been no advancement in GUI-Design. Today it looks and behaves just the way Bill Atkinson designed it. Technical revolutions are made by disruptive thoughts, which are never collective. ...The problem with gui-design:It requires an graphical artist, a well versed writer, a software architect and a programmer. The first two job description are the important ones. ...No OS-vender is going to allow that, it equals lost control. > > >>Tk is also doomed, and Tkinter isn't Tk. >>You are right about keeping the separate geometry >>managers, though. >> >>For starters:http://kenai.com/projects/swank > > > This looks like a very young project (beta) and i could not find a > widget set. However i will investigate more. Thanks > alpha > However we need to think beyond even a Python community scale. This > problem is inherent in every language community out there. We to unify > the GUI standard. And we are a decade behind in development. (yes i am > completely serious about all of this!). > > Then we did find common ground. -roger From orasnita at gmail.com Tue Jan 18 15:23:43 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Tue, 18 Jan 2011 22:23:43 +0200 Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com><4d337983$0$29983$c3e8da3$5496439d@news.astraweb.com><044a5101-948d-4458-9c94-57dbb3e25f67@m35g2000vbn.googlegroups.com><4d3467bf$0$29983$c3e8da3$5496439d@news.astraweb.com> <4D34B04E.8050309@web.de><4266E8D7BA204BFEA5BF66C635CE1716@octavian><4D35DCE8.5030002@web.de> <4D35DD47.1070304@web.de> Message-ID: <7A0C7934E65D4B85A584C06ADD3B6ECF@teddy> From: "Alexander Kapps" > Tkinter causes damage? Very bad damage? What are you talking about? I am talking about the fact that Python promotes Tkinter, and many beginners will start using it, and they will start creating applications with it, and they will learn to use it better than WxPython, and they will start believing that Tkinter is better because it is easier to use than WxPython, so they will start convincing others that Tkinter is the best, and they will start finding many reasons that show that Tkinter is better. And after this, they will say that they don't care about the real problems generated by GUIs like Tk. And a very big problem is that the applications that use Tk/GTK are not accessible for screen readers, so those applications will be just blank for people with visual impairments which need to use a screen reader. Those applications won't be less nice, or just a little harder to use. They won't be accessible at all and they will help the discrimination of the blind people, and not because of technical problems, because those problems can be solved with a better interface like Wx, which is not perfectly accessible either, but it is much better. That discrimination appears just because some people say that they don't care. > Well, I don't like wx that much and others have already highlighted > some of the problems with it. I think that adding redundancy is bad It is a redundancy for you, but have you imagined that for some people the display is the redundant part of the computer? > You said a GUI lib is useless because not all programmers write > GUIs. so I say an HTML lib is useless because not all programmers > write web stuff. Got it? Both are useful and I'm absolutely against > any attempt to remove either from the stdlib. *That* would cause damage. I didn't say that a GUI lib is useless. The GUIS that create discrimination by offering access only for some users (when there are other GUIS that can offer access to everyone) create damage and they should be avoided, and for avoiding them, the beginners need to understand this. But Python promotes that bad GUI lib by including it in the default package instead of promoting a better lib. > Which one? That's the whole point. There currently is no better GUI > lib than Tkinter which allows quick and easy GUI programming and Are you a beginner? A good programmer is not interested only to create an application with 10 lines of code, no matter the results. The application need to have a good quality and to be accessible by everyone if the technology allows it. Why do we like the portable GUIS and don't really like the native interfaces that don't work on other platforms? Because we want our programs to be usable by as many people as possible. Well, some platforms render the output as sound and Tkinter are not "portable" on those platforms (screen readers). > I have absolutely no problem with a better GUI lib, I just don't care Well, I was sure that you are one of those who don't care... Octavian From orasnita at gmail.com Tue Jan 18 15:29:28 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Tue, 18 Jan 2011 22:29:28 +0200 Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com>9-4a9f-b0e7-54bb681a6ea0@l8g2000yqh.googlegrouppppppp<4d337983$0$29983$c3e8da3$5496439d@news.astraweb.com><044a5101-948d-4458-9c94-57dbb3e25f67@m35g2000vbn.googlegroups.com><4d3467bf$0$29983$c3e8da3$5496439d@news.astraweb.com> <4D34B04E.8050309@web.de><4266E8D7BA204BFEA5BF66C635CE1716@octavian><4D35DCE8.5030002@web.de> Message-ID: <495ABC6A7F6C48A1BBCC32F181E5C4F0@teddy> From: "Mark Roseman" > If you guys spent 1/10th as much time articulating the problems you see > with Tkinter (and being willing to listen when people offer solutions) > as you do trying to convince everyone else you're right, you'd probably > have ... well, anyway, no sense in being practical. The problem: The beginners use the first GUI lib they find in the default Python package and they learn how to create applications which are not accessible for screen readers (at all), while there are better solutions. Is there any other solution for the problem that Python promotes this bad GUI than removing it from the default package? Not only Python does this. For the reason that "it is more simple and we don't care about the problems it generates", ActiveState does the same and it does the same with ActivePerl, but it doesn't mean that it is something good. Octavian From askutt at gmail.com Tue Jan 18 15:37:17 2011 From: askutt at gmail.com (Adam Skutt) Date: Tue, 18 Jan 2011 12:37:17 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <79a8a$4d332d1a$4275d90a$3986@FUSE.NET> <64976187-88ad-47c9-9bc6-c0712a657264@j32g2000yqc.googlegroups.com> <3af4fd5e-8cc9-4cec-aad2-cbf82ad3bab3@l24g2000vby.googlegroups.com> <9d0d0f8a-9684-4405-897c-141f2241070d@fo10g2000vbb.googlegroups.com> Message-ID: On Jan 18, 2:11?pm, rantingrick wrote: > Adam now you are making sense. Everything you said here is true. > This > is why we must push for the OpenGUI standard. Funny, I write considerable detail about why such a thing is a pipedream and useless even if it came to fruition, and you somehow believe I'm in support of such an absurd idea. If you believe what I said is true, then you cannot seriously support any sort of "OpenGUI" standard, and I advise you to google that term before you use it again. Tell me, are you a political science major? Heck, to be totally honest, I've never been 100% convinced that cross- platform GUI APIs were even such a good idea. I certainly use them, but only in situations that are very simple or where I'm OK with accepting the fact my application will not be truly a first-class application[1][2]. Even minor differences in presentation can have large ramifications on how applications should function and therefore be written. > The entropy in GUIs has > exploded exponentially and rendered them all useless. Only if you have no clue what you're talking about whatsoever. You perceive them as useless because you're apparently incapable of understanding the simplest GUI precepts, nevermind APIs, which is why you've gone from Pure Python GUI to wxWidgets to this OpenGUI bullshit you're now espousing. Desperately clinging to a position doesn't make you look intelligent. Plus, I'm not sure what entropy you're talking about, but I'm not seeing it. MS continues to innovate, Apple continues to innovate, some portions of the Linux community do innovative things. Though most people just want to put something together and call it a day, and the functionality provided by a lot of toolkits is beyond adequate for that. Adam [1] Or solely on Linux where all of the "native" toolkits have cross- platform support. [2] To say nothing about the explosion of web "applications" in the world today... From usernet at ilthio.net Tue Jan 18 15:44:20 2011 From: usernet at ilthio.net (Tim Harig) Date: Tue, 18 Jan 2011 20:44:20 +0000 (UTC) Subject: [OT] Python like lanugages [was Re: After C++, what with Python?] References: <86a904f8-05b0-435f-81d6-7450650f1679@glegroupsg2000goo.googlegroups.com> <4d329899$0$43988$742ec2ed@news.sonic.net> <7x8vylfcvz.fsf@ruckus.brouhaha.com> <4d32c7cf$0$29983$c3e8da3$5496439d@news.astraweb.com> Message-ID: On 2011-01-18, geremy condra wrote: > On Tue, Jan 18, 2011 at 11:05 AM, Tim Harig wrote: >> Even assuming that PyPy does actually manage to reach within a magnitude >> of C with the extra effort required to leverage two languages, why >> would I bother when I can do it with one? ?PyPy and similar methods >> where great when there was no other mid level alternative that supported >> Python like features. ?Now it just seems like using Python as a hammer >> for every problem whether or not it is the right tool for the job. > > You clearly have no idea what you're talking about regarding PyPy. You > could at least have googled it before speaking about it. No, I have watched several such projects over the years. Pysco, Unladen Swallow, Cython, PyPy, Shedskin, etc. Source to source translators, JITs, and C language integration all just add to complexity. You can't do this, you can't do that, you have to learn a new way of doing something else, ad nauseum. So when something new that provided Python like capabilities without many of Python's drawbacks came along, I jumped on it. It provides a much cleaner solution to the problem without kludges. I will use Python for what it does well and cleanly. For the rest, there are now better tools. Once again, its about the right tool for the right job. > Again, you don't know what you're talking about WRT PyPy. Nor do I really want to. I have found a much simpler solution to the problem. I would recommend it to many others that like the Python language but who occassionaly struggle with its implementation constraints. I would say that I am sorry that it doesn't work for you; but, you seem to prefer Java and Pypy anyway so we are both happy. >> 2. There is a difference in binding to a solution that is already written >> ? ? ? ?in another language so as to not reinvent a wheel and implementing >> ? ? ? ?a *new* library in another language to be used exclusively >> ? ? ? ?with Python. > > Even if that binding is done for performance reasons? Yep, that is pretty much the summation of my dual language argument. I don't expect a pure Python implementation of curses since there is a perfectly good C library available to bind to. Why reinvent the wheel. Resorting to writing packages in another language or compiling Python code into another source language is a kludge necessary because of the performance characteristics of the language. I suppose that is an acceptable kludge when that is your only alternative. For me it no longer is. From askutt at gmail.com Tue Jan 18 15:46:36 2011 From: askutt at gmail.com (Adam Skutt) Date: Tue, 18 Jan 2011 12:46:36 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <79a8a$4d332d1a$4275d90a$3986@FUSE.NET> <64976187-88ad-47c9-9bc6-c0712a657264@j32g2000yqc.googlegroups.com> <3af4fd5e-8cc9-4cec-aad2-cbf82ad3bab3@l24g2000vby.googlegroups.com> Message-ID: On Jan 18, 3:20?pm, Arndt Roger Schneider wrote: > There has been no advancement in GUI-Design. Today it looks and > behaves just the way Bill Atkinson designed it. That doesn't even begin to equate to a lack of advancement. It's also not true in the least. > Technical revolutions are made by disruptive thoughts, > which are never collective. Revolutions are statistical anomalies, so it's best not to depend on them for progress. It's not even apparent what revolution is necessary here. > ...The problem with gui-design:It requires an graphical artist, > a well versed writer, a software architect and a programmer. > The first two job description are the important ones. > > ...No OS-vender is going to allow that, it equals > lost control. > You need to go look at the people Apple, MS, Google, et al. hire; this statement is just patently false too. Plus, after a certainly level of functionality, the OS vendor does become rather irrelevant. Otherwise, the web would have never taken off an application platform: the HTML standard provides the smallest widget set of just about anything discussed, though it's painting / layout capabilities are both simultaneously far advanced and far worse. Yet, it is likely the way of the future for a large portion of us, like it or not. Adam From python at mrabarnett.plus.com Tue Jan 18 16:05:04 2011 From: python at mrabarnett.plus.com (MRAB) Date: Tue, 18 Jan 2011 21:05:04 +0000 Subject: move to end, in Python 3.2 Really? In-Reply-To: References: <58c17709-d68e-4448-b618-b6f594d0e8c5@t35g2000yqj.googlegroups.com> <125db7fe-036e-47c9-be89-50f05106936f@n2g2000pre.googlegroups.com> <99e7061d-20d5-434b-9404-bdafd6a013ac@i17g2000vbq.googlegroups.com> Message-ID: <4D360080.3000901@mrabarnett.plus.com> On 18/01/2011 19:22, rantingrick wrote: > On Jan 18, 12:55 pm, Emile van Sebille wrote: >> On 1/18/2011 9:10 AM rantingrick said... >> >>> On Jan 18, 10:54 am, MRAB wrote: >> >>>> Decisions are made after open discussion (although we're not sure about >>>> "move to end" :-)). You shouldn't complain about not being consulted if >>>> you don't take the time to join in... >> >>> Well don't get wrong i want to join in --not that i have all the >>> solutions-- however python-dev is a dangerous place for the >>> uninitiated. And we can't have thousands and thousands of posts >>> clogging up the main pool because that would only serve to slow the >>> process to a grinding hault. >> >>> However, we need some way that the average Python programmer can speak >>> up and be heard when any subject that he/she is passionate about comes >>> before the "council". These folks probably don't want to participate >>> in the highly competitive environment of Python dev. However they may >>> have very good ideas. I think we are doing this community a dis >>> service by not giving these voices an outlet. >> >>> We need either some way to vote outside of Python dev. i think it >>> would be much easier to just have a site where all proposals can be >>> viewed by anyone and they can offer input without clogging up Python >>> dev with noob questions or bad ideas. Then the "council" can review >>> these suggestions and make a more informed decision. Some might say >>> "well that is what blogs and c.l.py is for" and i say wrong. I believe >>> more folks would get involved if they felt that the medium was real. >>> c.l.py is not that place (although it could be with some changes) and >>> python.dev is not that place. >> >>> I am open to any ideas you may have. >> >> Brett Cannon used to (still does?) prepare twice monthly summaries of >> activity on python-dev which provided insight as to what was happening >> on that side of things. I don't know if he or anyone else still does >> so, but if so, a copy to this list would at least let everyone know if >> something was happening that you might want to weigh in on. >> >> seehttp://article.gmane.org/gmane.comp.python.devel/43893 >> >> Emile > > That is dated 2002? :D > > Thanks for offering a suggestion it was very welcome however i need to > emphasize that what i am proposing is sort of "community discussion > suggestion box". Like a "Python Suggestions" group or something. Where > any and all suggestions, rants, complaints, ideas, etc, are welcome > from anyone without fear of reprisals. > > However, in order for this to succeed the "elite" must take the time > to actually read it. Maybe we could have some trusted "proof readers" > who could sift out the spam and useless stuff and then send a modified > version to the senate for congressional reviewing. Of course at that > point the senate can further narrow down the list before sending over > to the white house. This is the only way (short of sending out > warnings in the python releases) that you can actually get a feel for > what Joe and Jane Python programmer are happy with. > The Python community are volunteers. Nothing gets done until someone volunteers to do it. The "suggestion box" is your idea. Why don't you set it up and report back? From tjreedy at udel.edu Tue Jan 18 16:07:55 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Tue, 18 Jan 2011 16:07:55 -0500 Subject: move to end, in Python 3.2 Really? In-Reply-To: References: <58c17709-d68e-4448-b618-b6f594d0e8c5@t35g2000yqj.googlegroups.com> <125db7fe-036e-47c9-be89-50f05106936f@n2g2000pre.googlegroups.com> Message-ID: On 1/18/2011 11:27 AM, rantingrick wrote: > On Jan 18, 6:46 am, Antoine Pitrou wrote: > >> Design considerations? Where were they discussed? I far as I know, nowhere until that post in this thread. > They were never discussed with the bulk of this community and that is > part of what i want to change. We have a very small group of folks > making all the decisions and that is fine. However this small group of > "privileged" folks needs to gather input from the rest of us > (peasants) on the value of such changes before making rash decisions. When proposed features are listed on the tracker, as I think this one should have been, anyone who registers can comment. Real names are strongly preferred (and required for elevated tracker and repository access). > Currently we have a closed set of intellectual inbreeding that is > rotting the community gene pool. Do you actually believe this nonsense, or are you just ranting for effect? In 2010, 20 people were granted commit access. We have 2 more new and active people this month. The active subset of these 22 comprise a substantial fraction of active developers. Without a constant influx of new people, the Python project would slowly die as people left to do other things. One way to demonstrate the needed technical and social skills for commit access is to participate on the tracker with comments, reviews, and patches. > We need more diversity in this > "milkshake" to bring about and foster healthy ideas. Python leaders already know we need more diversity of knowledge and skills to target Python at diverse platforms with diverse batteries. Last summer Guido said that we should be a bit more liberal with commit access. Right now, Brett Cannon is working under a PSF grant to greatly improve the developer docs so new developers can more easily get up to speed. One of the stated goals of moving the repository from svn to hg (a non-trivial project) is to make it easier for more people to contribute, with or without 'commit privileges'. -- Terry Jan Reedy From drsalists at gmail.com Tue Jan 18 16:18:51 2011 From: drsalists at gmail.com (Dan Stromberg) Date: Tue, 18 Jan 2011 13:18:51 -0800 Subject: __pycache__, one more good reason to stck with Python 2? In-Reply-To: References: <23e02e0d-b2f1-4b52-85ea-d1feba99dd37@22g2000prx.googlegroups.com> <4d3466d3$0$29983$c3e8da3$5496439d@news.astraweb.com> <0c62aacd-e6d2-4778-81d6-e06924192add@j1g2000vbl.googlegroups.com> <77ef8068-7f07-404f-8b0e-c039d1122659@e16g2000pri.googlegroups.com> Message-ID: On Tue, Jan 18, 2011 at 8:27 AM, Peter Otten <__peter__ at web.de> wrote: > Stefan Behnel wrote: > >> Peter Otten, 18.01.2011 10:04: >>> What's the advantage of 'find ... | xargs ...' over 'find ... -exec ...'? >> >> The former runs in parallel, the latter runs sequentially. > > This may sometimes be relevant, but I doubt that it matters in this > particular case. I don't think xargs is ever parallel, but GNU parallel is supposed to be a parallel tool with options and usage similar to those/that of xargs: http://www.gnu.org/software/parallel/ xargs' main advantages are: 1) Simpler quoting (correctness), especially if you use (GNU) "find -print0" with "xargs -0" 2) Far fewer exec's, which usually means much better performance From alex.kapps at web.de Tue Jan 18 16:24:54 2011 From: alex.kapps at web.de (Alexander Kapps) Date: Tue, 18 Jan 2011 22:24:54 +0100 Subject: Tkinter: The good, the bad, and the ugly! In-Reply-To: <7A0C7934E65D4B85A584C06ADD3B6ECF@teddy> References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com><4d337983$0$29983$c3e8da3$5496439d@news.astraweb.com><044a5101-948d-4458-9c94-57dbb3e25f67@m35g2000vbn.googlegroups.com><4d3467bf$0$29983$c3e8da3$5496439d@news.astraweb.com> <4D34B04E.8050309@web.de><4266E8D7BA204BFEA5BF66C635CE1716@octavian><4D35DCE8.5030002@web.de> <4D35DD47.1070304@web.de> <7A0C7934E65D4B85A584C06ADD3B6ECF@teddy> Message-ID: <4D360526.7070706@web.de> On 18.01.2011 21:23, Octavian Rasnita wrote: > From: "Alexander Kapps" >> Tkinter causes damage? Very bad damage? What are you talking about? > > I am talking about the fact that Python promotes Tkinter, and many beginners will start using it, and they will start creating applications with it, and they will learn to use it better than WxPython, and they will start believing that Tkinter is better because it is easier to use than WxPython, so they will start convincing others that Tkinter is the best, and they will start finding many reasons that show that Tkinter is better. And after this, they will say that they don't care about the real problems generated by GUIs like Tk. > And a very big problem is that the applications that use Tk/GTK are not accessible for screen readers, so those applications will be just blank for people with visual impairments which need to use a screen reader. > > Those applications won't be less nice, or just a little harder to use. They won't be accessible at all and they will help the discrimination of the blind people, and not because of technical problems, because those problems can be solved with a better interface like Wx, which is not perfectly accessible either, but it is much better. That discrimination appears just because some people say that they don't care. > >> Well, I don't like wx that much and others have already highlighted >> some of the problems with it. I think that adding redundancy is bad > > It is a redundancy for you, but have you imagined that for some people the display is the redundant part of the computer? I was talking about redundancy as in duplication of already existing parts. However, for some people, networking is superfluous. That's not a reason to remove the networking modules from the stdlib. Anyway, If you think duplicating functionality is a good approach here, go on, I don't mind. Just remember to stop somewhen and don't include 10 GUI toolkits and 20 HTML parsers just because some people don't like the already existing ones. >> You said a GUI lib is useless because not all programmers write >> GUIs. so I say an HTML lib is useless because not all programmers >> write web stuff. Got it? Both are useful and I'm absolutely against >> any attempt to remove either from the stdlib. *That* would cause damage. > > I didn't say that a GUI lib is useless. The GUIS that create discrimination by offering access only for some users (when there are other GUIS that can offer access to everyone) create damage and they should be avoided, and for avoiding them, the beginners need to understand this. But Python promotes that bad GUI lib by including it in the default package instead of promoting a better lib. Please read your previous post. Anyway *which* GUI offers access to everyone? >> Which one? That's the whole point. There currently is no better GUI >> lib than Tkinter which allows quick and easy GUI programming and > > Are you a beginner? A good programmer is not interested only to create an application with 10 lines of code, no matter the results. I'm neither a beginner, nor really a professional programmer. I occasionally do paid coding and that often includes small tools and helper utilities and one thing I can tell you: In approx 90% of those cases, people want a GUI. It hasn't to be fancy, they just don't want no command line tools. Tkinter is just great for quickly hacking together a GUI or for prototyping if somebody wants something more advanced. > The application need to have a good quality and to be accessible by everyone if the technology allows it. > Why do we like the portable GUIS and don't really like the native interfaces that don't work on other platforms? > Because we want our programs to be usable by as many people as possible. Well, some platforms render the output as sound and Tkinter are not "portable" on those platforms (screen readers). > >> I have absolutely no problem with a better GUI lib, I just don't care > > Well, I was sure that you are one of those who don't care... You make that sound as if I should feel guilty now. From arndt.roger at addcom.de Tue Jan 18 16:45:48 2011 From: arndt.roger at addcom.de (Arndt Roger Schneider) Date: Tue, 18 Jan 2011 22:45:48 +0100 Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <79a8a$4d332d1a$4275d90a$3986@FUSE.NET> <64976187-88ad-47c9-9bc6-c0712a657264@j32g2000yqc.googlegroups.com> <3af4fd5e-8cc9-4cec-aad2-cbf82ad3bab3@l24g2000vby.googlegroups.com> Message-ID: Adam Skutt schrieb: > On Jan 18, 8:09 am, Arndt Roger Schneider > wrote: > >>Back to rantingrick 21st century toolkit/framwork: >>Let's have a look at the numbers: >>Worlwide pc market are 300 Million pcs per year, >>this number includes desktops(2/3) and servers(1/3). >>Your gui app is not relevant on servers. > > > You should tell this "fact" to just about every major enterprise > software manufacturer out there. They all ship GUI tools intended to > be used on the server. Some of them ship only GUI tools or CLI tools > that are worthless, making you use the GUI tools. > > >>The desktop pc market is in decline; there is >>however a shift toward pc-servers, instead. >>It is anybodies guess how far the pc-desktop decline will go. >>Every 21st century toolkit or framework must run on >>mobile platforms! > > > Until we have pixel-perfect touch sensors, toolkits for devices with > pointer interfaces (e.g., PCs) and toolkits for devices with touch > interfaces (e.g., phones and tablets) will necessarily be different. > > You note this yourself: the UI paradigms that work well when you have > a pixel-perfect pointer do not work at all when you have a touch > screen, especially on a limited size and resolution display. > Yes I did and that's how it is. > Even if you're provided a "single" toolkit, you still end up with two, > maybe three, different applications, each using different widgets > targeted for the device they run on. And no one provides a "single" > toolkit: while Silverlight can run on the desktop, the web, and now on > Windows Phone, you can't use the same widgets everywhere; ditto with > Cocoa for OS X and Cocoa Touch for iTouch devices. > > While some further unification is obviously possible, it's rather > doubtful we'll ever have unified widgets that are truly workable on > the web, on the "desktop", and on a portable touch screen device. > Think about all the programmers earning their butter and bread :-). Forget toolkits and widgets for awhile. What remains are specific types of human/computer interactions, a visual representation on a screen and a predefined behaviour for said human action. E.g. a button is: A function gets asychnronously performed in response to a finger/mouse click and release inside a certain screen area. --A widget is essentially a logical abstraction. > >>wxWidgets was written ~1992, it is a copy of >>mfc, which in turn is a copy of MacApp. MacApp >>is also OSS, maintained through an industrie consortium. >>Why do you not use the original framework? >> > > > Because it's not cross-platform, I'd imagine. The entire point of > wxWidgets was to provide a cross-platform "OOP" UI toolkit. It > closely copies MFC since MFC and XView were the two "backends" it > supported. > MacApp is/was cross-platform, Apple pulled the plug on the non-mac platforms; the industrie consortium took charge of the other platforms. > >>Screen resolution: >> The time of 72ppi CRT monitors is over. A GUI >> framework/toolkit must be resolution independent, >> including all icons and indicators; >> it should use decluttering (newspeak:ZUI). >> > > > WPF is the only functional resolution-independent UI toolkit in > existence. While I don't disagree with you in principal, practice is > pretty heavily divorced from principal here. Principal doesn't help > me write GUI applications today. > > >>wxWidgets is not suitable for a modern type >>GUI ad thus clearly not the toolkit/framework >>of the 21st century. > > > None of the toolkits accessible from CPython are suitable for a 21st > century guy by your standard. If we talk about IronPython, > Silverlight becomes the closest, but it isn't a panacea by any stretch > of the imagination. > > Adam > According to Microsoft neither is silverlight. -roger From tjreedy at udel.edu Tue Jan 18 17:18:44 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Tue, 18 Jan 2011 17:18:44 -0500 Subject: Tkinter: The good, the bad, and the ugly! In-Reply-To: <7A0C7934E65D4B85A584C06ADD3B6ECF@teddy> References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com><4d337983$0$29983$c3e8da3$5496439d@news.astraweb.com><044a5101-948d-4458-9c94-57dbb3e25f67@m35g2000vbn.googlegroups.com><4d3467bf$0$29983$c3e8da3$5496439d@news.astraweb.com> <4D34B04E.8050309@web.de><4266E8D7BA204BFEA5BF66C635CE1716@octavian><4D35DCE8.5030002@web.de> <4D35DD47.1070304@web.de> <7A0C7934E65D4B85A584C06ADD3B6ECF@teddy> Message-ID: On 1/18/2011 3:23 PM, Octavian Rasnita wrote: > I am talking about the fact that Python promotes Tkinter Python uses tkinter as the only choice available for the stdlib. Others choices not in the stdlib are available for those who want something better. > TK are not accessible for screen readers, I did not know that. You could ask on the tracker that that fact be added to the docs. I would consider it reason to consider another choice if there ever were to be a suitable one offered. >> I'm absolutely >> against any attempt to remove either from the stdlib. *That* would >> cause damage. I agree. Besides IDLE and turtle, there are tools in the Tools directory that depend on tkinter. -- Terry Jan Reedy From taylorzr at gmail.com Tue Jan 18 17:20:40 2011 From: taylorzr at gmail.com (Zach) Date: Tue, 18 Jan 2011 17:20:40 -0500 Subject: [OT] Python like lanugages [was Re: After C++, what with Python?] In-Reply-To: References: <86a904f8-05b0-435f-81d6-7450650f1679@glegroupsg2000goo.googlegroups.com> <4d329899$0$43988$742ec2ed@news.sonic.net> <7x8vylfcvz.fsf@ruckus.brouhaha.com> <4d32c7cf$0$29983$c3e8da3$5496439d@news.astraweb.com> Message-ID: Cobra seems to similar to python. Or it at least compares itself to python. -------------- next part -------------- An HTML attachment was scrubbed... URL: From taylorzr at gmail.com Tue Jan 18 17:22:31 2011 From: taylorzr at gmail.com (Zach) Date: Tue, 18 Jan 2011 17:22:31 -0500 Subject: [OT] Python like lanugages [was Re: After C++, what with Python?] In-Reply-To: References: <86a904f8-05b0-435f-81d6-7450650f1679@glegroupsg2000goo.googlegroups.com> <4d329899$0$43988$742ec2ed@news.sonic.net> <7x8vylfcvz.fsf@ruckus.brouhaha.com> <4d32c7cf$0$29983$c3e8da3$5496439d@news.astraweb.com> Message-ID: Anyone have thoughts on Cobra? On Jan 18, 2011 4:20 PM, "Zach" wrote: > Cobra seems to similar to python. Or it at least compares itself to python. -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjreedy at udel.edu Tue Jan 18 17:28:47 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Tue, 18 Jan 2011 17:28:47 -0500 Subject: Tkinter: The good, the bad, and the ugly! In-Reply-To: References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <79a8a$4d332d1a$4275d90a$3986@FUSE.NET> <64976187-88ad-47c9-9bc6-c0712a657264@j32g2000yqc.googlegroups.com> <3af4fd5e-8cc9-4cec-aad2-cbf82ad3bab3@l24g2000vby.googlegroups.com> Message-ID: On 1/18/2011 2:12 PM, jmfauth wrote: >> >>> If you think the site is bad, send me a ONE better screenshot, or link >>> thereto, of wx on WinXP/Vista/7. I promise to look at it. Then urge >>> Robin to update the page. >> > > No wxWidgets, but real Python / wxPython applications, all updated on > Windows 7. > > http://spinecho.ze.cx/ Yes wxWidgets, underneath wxPython. And yes, look very nice. -- Terry Jan Reedy From tjreedy at udel.edu Tue Jan 18 17:33:15 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Tue, 18 Jan 2011 17:33:15 -0500 Subject: Tkinter: The good, the bad, and the ugly! In-Reply-To: <495ABC6A7F6C48A1BBCC32F181E5C4F0@teddy> References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com>9-4a9f-b0e7-54bb681a6ea0@l8g2000yqh.googlegrouppppppp<4d337983$0$29983$c3e8da3$5496439d@news.astraweb.com><044a5101-948d-4458-9c94-57dbb3e25f67@m35g2000vbn.googlegroups.com><4d3467bf$0$29983$c3e8da3$5496439d@news.astraweb.com> <4D34B04E.8050309@web.de><4266E8D7BA204BFEA5BF66C635CE1716@octavian><4D35DCE8.5030002@web.de> <495ABC6A7F6C48A1BBCC32F181E5C4F0@teddy> Message-ID: On 1/18/2011 3:29 PM, Octavian Rasnita wrote: > Is there any other solution for the problem that Python promotes this > bad GUI than removing it from the default package? I am generally for better accessibility, but I consider the notion that if everyone cannot have something, then no one should, to be rather pernicious. > Not only Python does this. For the reason that "it is more simple and > we don't care about the problems it generates", ActiveState does the > same and it does the same with ActivePerl, but it doesn't mean that > it is something good. So persuade them or someone to make it better, or is ActiveState actively opposed to that? -- Terry Jan Reedy From jake.biesinger at gmail.com Tue Jan 18 17:35:10 2011 From: jake.biesinger at gmail.com (Jake Biesinger) Date: Tue, 18 Jan 2011 14:35:10 -0800 (PST) Subject: Efficient python 2-d arrays? In-Reply-To: <6b865cda-5df4-4053-b5e4-f7deba45360e@l7g2000vbv.googlegroups.com> Message-ID: > Since you can't depend on your users installing the dependencies, is > it vital that your users run from source? You could bundle up your > application along with numpy and other dependencies using py2Exe or > similar. This also means you wouldn't have to require users to have > the right (or any) version of Python installed. It's a good suggestion, though I am far from familiar with the process. I've just finished implementing another alternative-- I'm doing a merge sort, where the array chunks are zipped together and then sorted using python's builtin sort then unzipped back to their original arrays. This seems fast enough and the reduced memory requirement for 2 arrays vs 1 list-of-tuples is substantial (1.5 GB vs 4GB). Thanks for the great suggestions! From jake.biesinger at gmail.com Tue Jan 18 17:36:55 2011 From: jake.biesinger at gmail.com (Jake Biesinger) Date: Tue, 18 Jan 2011 14:36:55 -0800 (PST) Subject: Efficient python 2-d arrays? In-Reply-To: <3ab5326f-bf39-4dfa-9875-a1bfd5ccab68@w29g2000vba.googlegroups.com> Message-ID: > Without using third party libraries, no not really. numpy has it > covered so there's not really a lot of demand for it. If your users > are loading 1.5 GB arrays into memory, it's probably not unreasonable > to expect them to have numpy installed. My users are biologists, and I can't expect them to have numpy (and the barrier to entry for this group is particularly high). From invalid at invalid.invalid Tue Jan 18 17:44:50 2011 From: invalid at invalid.invalid (Grant Edwards) Date: Tue, 18 Jan 2011 22:44:50 +0000 (UTC) Subject: move to end, in Python 3.2 Really? References: <58c17709-d68e-4448-b618-b6f594d0e8c5@t35g2000yqj.googlegroups.com> <125db7fe-036e-47c9-be89-50f05106936f@n2g2000pre.googlegroups.com> <99e7061d-20d5-434b-9404-bdafd6a013ac@i17g2000vbq.googlegroups.com> Message-ID: On 2011-01-18, MRAB wrote: > On 18/01/2011 19:22, rantingrick wrote: >> Thanks for offering a suggestion it was very welcome however i need to >> emphasize that what i am proposing is sort of "community discussion >> suggestion box". Like a "Python Suggestions" group or something. Where >> any and all suggestions, rants, complaints, ideas, etc, are welcome >> from anyone without fear of reprisals. >> >> However, in order for this to succeed the "elite" must take the time >> to actually read it. Maybe we could have some trusted "proof readers" >> who could sift out the spam and useless stuff and then send a modified >> version to the senate for congressional reviewing. Of course at that >> point the senate can further narrow down the list before sending over >> to the white house. This is the only way (short of sending out >> warnings in the python releases) that you can actually get a feel for >> what Joe and Jane Python programmer are happy with. > The Python community are volunteers. Nothing gets done until someone > volunteers to do it. The "suggestion box" is your idea. Why don't you > set it up and report back? He goes by the name of "ranting rick", and you're suggesting that instead of talking he rolls up his sleeves and does something. I suspect you're barking into the wind... -- Grant Edwards grant.b.edwards Yow! Yes, but will I at see the EASTER BUNNY in gmail.com skintight leather at an IRON MAIDEN concert? From askutt at gmail.com Tue Jan 18 17:57:02 2011 From: askutt at gmail.com (Adam Skutt) Date: Tue, 18 Jan 2011 14:57:02 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <79a8a$4d332d1a$4275d90a$3986@FUSE.NET> <64976187-88ad-47c9-9bc6-c0712a657264@j32g2000yqc.googlegroups.com> <3af4fd5e-8cc9-4cec-aad2-cbf82ad3bab3@l24g2000vby.googlegroups.com> Message-ID: On Jan 18, 4:45?pm, Arndt Roger Schneider wrote: > Adam Skutt schrieb: > > Until we have pixel-perfect touch sensors, toolkits for devices with > > pointer interfaces (e.g., PCs) and toolkits for devices with touch > > interfaces (e.g., phones and tablets) will necessarily be different. > > > You note this yourself: the UI paradigms that work well when you have > > a pixel-perfect pointer do not work at all when you have a touch > > screen, especially on a limited size and resolution display. > > Yes I did and that's how it is. And then you go and advocate a single toolkit! Do you not see the inherent contradiction there? While it's certainly not impossible, the case is hardly obvious for one GUI toolkit for all possible UIs. You certainly have not presented it, and rantingrick never will. > Think about all the programmers earning their butter and bread :-). > Forget toolkits and widgets for awhile. > What remains are specific types of human/computer interactions, > a visual representation on a screen and a predefined behaviour > for said human action. Also known as "toolkits and widgets". Talking about such things are inescapable. > > E.g. a button is: > A function gets asychnronously performed in response to > a finger/mouse click and release inside a certain screen area. > No, that is not the definition of a 'button', not even when we choose to ignore how it is rendered, which you cannot ignore even if you wish to pretend you can. Otherwise, I could always treat hyperlinks and buttons as equivalent and even interchangeable. Unfortunately, they are no such things. > --A widget is essentially a logical abstraction. No, as much as we try we cannot divorce presentation from behavior fully. > > Because it's not cross-platform, I'd imagine. ?The entire point of > > wxWidgets was to provide a cross-platform "OOP" UI toolkit. ?It > > closely copies MFC since MFC and XView were the two "backends" it > > supported. > > MacApp is/was cross-platform, Apple pulled the plug > on the non-mac platforms; the industrie > consortium took charge of the other platforms. > MacApp didn't even see the start of cross-platform development until 1996, four years after wxWidgets. It was not cross-platform from the start and only became cross-platform when all of Apple's other cross- platform endeavours failed. Adam From rantingrick at gmail.com Tue Jan 18 18:04:30 2011 From: rantingrick at gmail.com (rantingrick) Date: Tue, 18 Jan 2011 15:04:30 -0800 (PST) Subject: move to end, in Python 3.2 Really? References: <58c17709-d68e-4448-b618-b6f594d0e8c5@t35g2000yqj.googlegroups.com> <125db7fe-036e-47c9-be89-50f05106936f@n2g2000pre.googlegroups.com> <99e7061d-20d5-434b-9404-bdafd6a013ac@i17g2000vbq.googlegroups.com> Message-ID: <00e5a59a-2819-49fe-b124-4e71b191e267@z19g2000yqb.googlegroups.com> On Jan 18, 3:05?pm, MRAB wrote: > The Python community are volunteers. Nothing gets done until someone > volunteers to do it. The "suggestion box" is your idea. Why don't you > set it up and report back? Agreed, i would gladly accept you nominating me as the Suggestion Box president. However we need to decide where the best place to put the "suggestion box" will be. Sure i could open a website called "pythonsuggestionbox.com" however i doubt anybody that *needs* to find it ever would. Heck i would feel "lucky" if a few trolls dropped by and asked for the GIL to be removed. ;-) In light of that, the only place --and i would argue the best place-- is the official website with a nice link on the home page although i don't expect that will happen. In that case c.l.py becomes the winner by default. Why? Well imagine you are a new python user. Where would you look for help after downloading the installer? Of course you might go back to check out python.org a bit more. The next logical step would be python help and then c.l.py. So either we add a suggestions area to the official site OR make this group more accessible to the average user. If it were my choice, i would just make this group more accessible to newcomers and be done with it. Much eaiser, much less work, and more results will be produced. How can we make c.l.py more accessible you ask? Well a good start would be for some of the well known "elites" to make a public announcement. If we could convince Guido to make a speech that would be wonderful however i know he cannot do everything. """ In this statement we must stress that a new age of community has dawned -- an age of freedom. That all pythoneers are created equal and in the image of Guido. No, not of his physical image, but of his vision, his wisdom, and his compassion. That we will admonish those that wish to belittle the most feeble among us and elevate those who would carry the torch of community at the very expense of their own selfless vanity. That we are moving forward as a collective group united in vision, in spirit, and in solidarity for the future evolution of Python -- and for the greater good of all programming languages! """ Once we get c.l.py back on track i believe it will take some time but eventually the masses will return and rejoin our efforts. New users will mold into he community and we shall all reape the benefits. Hopefully with enough good will and collaboration we can do great things and save Python from an untimely demise. However we must act quickly, because the time is ticking away... From rantingrick at gmail.com Tue Jan 18 18:22:43 2011 From: rantingrick at gmail.com (rantingrick) Date: Tue, 18 Jan 2011 15:22:43 -0800 (PST) Subject: move to end, in Python 3.2 Really? References: <58c17709-d68e-4448-b618-b6f594d0e8c5@t35g2000yqj.googlegroups.com> <125db7fe-036e-47c9-be89-50f05106936f@n2g2000pre.googlegroups.com> Message-ID: On Jan 18, 3:07?pm, Terry Reedy wrote: > On 1/18/2011 11:27 AM, rantingrick wrote: > When proposed features are listed on the tracker, as I think this one > should have been, anyone who registers can comment. Real names are > strongly preferred (and required for elevated tracker and repository > access). Agreed. However you cannot expect the ordinary python programmers to follow the tracker. They are not a political as we. However they do have a voice and we must listen. How can we call ourselves a community when there exists no means by which the "real" users can express themselves? > > Currently we have a closed set of intellectual inbreeding that is > > rotting the community gene pool. > > Do you actually believe this nonsense, or are you just ranting for effect? This was a strong statement and it was meant to be strong. On on the face of it some might take it as an insult to the intelligence of our leaders -- i can assure you that is not the case! Of course we have good people at the top, however they are not hearing the voices screaming from below. They are making decisions in a vacuum. This cannot produce positive results for very much longer. I fear we have already begun the downward spiral as a community. We must get a grip and pull ourselves together before inertia rips us apart at the seams. > One way to demonstrate the needed technical and social skills for commit > access is to participate on the tracker with comments, reviews, and patches. We cannot even discuss the tracker until we fix this abomination called c.l.py. We need to focus on c.l.py. We need to get it back on track. And i want everyone to participate even the outright bullies and predators (if they can tone done the rhetoric and be nice again!). We as a community are existing in a vacuum. Likewise Python dev is existing in a vacuum. However both of us are in parallel universes. We must combine the head with the tail or we have nothing but component parts. Can a car function without wheels? Can a plane function without it's wings? No, an we are just component parts idle in some intellectual factory collecting dust! > ?> We need more diversity in this > > > "milkshake" to bring about and foster healthy ideas. > > Python leaders already know we need more diversity of knowledge and > skills to target Python at diverse platforms with diverse batteries. > Last summer Guido said that we should be a bit more liberal with commit > access. Right now, Brett Cannon is working under a PSF grant to greatly > improve the developer docs so new developers can more easily get up to > speed. One of the stated goals of moving the repository from svn to hg > (a non-trivial project) is to make it easier for more people to > contribute, with or without 'commit privileges'. This is a great advancement! Keep them coming! From fathead9000 at gmail.com Tue Jan 18 18:26:08 2011 From: fathead9000 at gmail.com (Michael Rauh) Date: Tue, 18 Jan 2011 15:26:08 -0800 (PST) Subject: Swampy Module installation Message-ID: <9dd545a1-b0ea-408c-9fe2-a2ce7d6a5a0a@m7g2000vbn.googlegroups.com> I am new to python, and attempting to install the learning module swampy. http://www.greenteapress.com/thinkpython/swampy/install.html Unfortunately, I am attempting to do this on windows vista, which does not appear to be cooperating. Once I click on the install link, it puts the file on the computer, and even if I place the file into the source folder for python, it still says that there is no module swampy. How can I get python to recognize the module as being there, and to run the suite? I admit, I may be placing it in the wrong directory, as I have so far been unable to change the working directory. Online the command os.chdir is said to change the directory, but it keeps giving an error, and saying that os is not recognized. Variations on this code do not seem to work either. From rantingrick at gmail.com Tue Jan 18 18:36:27 2011 From: rantingrick at gmail.com (rantingrick) Date: Tue, 18 Jan 2011 15:36:27 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <79a8a$4d332d1a$4275d90a$3986@FUSE.NET> <64976187-88ad-47c9-9bc6-c0712a657264@j32g2000yqc.googlegroups.com> <3af4fd5e-8cc9-4cec-aad2-cbf82ad3bab3@l24g2000vby.googlegroups.com> Message-ID: On Jan 18, 4:57?pm, Adam Skutt wrote: > On Jan 18, 4:45?pm, Arndt Roger Schneider > > E.g. a button is: > > A function gets asychnronously performed in response to > > a finger/mouse click and release inside a certain screen area. > > No, that is not the definition of a 'button', not even when we choose > to ignore how it is rendered, which you cannot ignore even if you wish > to pretend you can. ?Otherwise, I could always treat hyperlinks and > buttons as equivalent and even interchangeable. ?Unfortunately, they > are no such things. What! YES it is Adam! And you just exposed yourself as an argumentative moron! A hyperlink and a button are EXACTLY the same thing "functionality" wise. The fact that they look different has nothing to do with the argument. Would you say that a Ford Escort and a Dodge Viper do not function in basically the same way. Sure one looks much prettier and goes much faster however they both have four wheels, and engine, a drivetrain, an outer shell, burn gasoline, and are basically people movers. In other words they are both cars! *slap* > > --A widget is essentially a logical abstraction. > > No, as much as we try we cannot divorce presentation from behavior > fully. More argumentative crap. Adam you are incapable of compromise or reason... or maybe both. Try more facts next time. From tjreedy at udel.edu Tue Jan 18 18:44:26 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Tue, 18 Jan 2011 18:44:26 -0500 Subject: move to end, in Python 3.2 Really? In-Reply-To: References: <58c17709-d68e-4448-b618-b6f594d0e8c5@t35g2000yqj.googlegroups.com> <125db7fe-036e-47c9-be89-50f05106936f@n2g2000pre.googlegroups.com> Message-ID: On 1/18/2011 6:22 PM, rantingrick wrote: > This was a strong statement and it was meant to be strong. However, it was falso. > We cannot even discuss the tracker until we fix this abomination > called c.l.py. I have nothing directly to do with c.l.p and care nothing for it. I read the gmane.comp.python.general mirror of python-list, which filters out some of the worse of the input from c.l.p. I mostly focus on getting real work done on the tracker and repository and am only temporarily spending this much time here as a diversion. -- Terry Jan Reedy From aahz at pythoncraft.com Tue Jan 18 18:53:36 2011 From: aahz at pythoncraft.com (Aahz) Date: 18 Jan 2011 15:53:36 -0800 Subject: issubclass(dict, Mapping) References: <4d127d5e$0$29997$c3e8da3$5496439d@news.astraweb.com> Message-ID: In article , kj wrote: > >standard OOP semantics "...some experts might say a C++ program is not object-oriented without inheritance and virtual functions. As one of the early Smalltalk implementors myself, I can say they are full of themselves." --zconcept -- Aahz (aahz at pythoncraft.com) <*> http://www.pythoncraft.com/ "The volume of a pizza of thickness 'a' and radius 'z' is given by pi*z*z*a" From rantingrick at gmail.com Tue Jan 18 18:54:48 2011 From: rantingrick at gmail.com (rantingrick) Date: Tue, 18 Jan 2011 15:54:48 -0800 (PST) Subject: move to end, in Python 3.2 Really? References: <58c17709-d68e-4448-b618-b6f594d0e8c5@t35g2000yqj.googlegroups.com> <125db7fe-036e-47c9-be89-50f05106936f@n2g2000pre.googlegroups.com> Message-ID: And were the hell is Steve Holden? Why has he not weighed in on these (or any) discussions. He (Steve Holden) is second in command to the entire community. Yet we have yet to hear a peep from this fella. What gives Steve? And if Steve is too busy, who is next in the chain of command? Who is going to take responsibility for this catastrophe we call c.l.py? Is there no one is man enough to step up for this community? Are all of our leaders just sticking their heads in the sand hoping for this to "solve" itself? I would really like for some heavy weights to get involved here. From ethan at stoneleaf.us Tue Jan 18 18:56:29 2011 From: ethan at stoneleaf.us (Ethan Furman) Date: Tue, 18 Jan 2011 15:56:29 -0800 Subject: move to end, in Python 3.2 Really? In-Reply-To: References: <58c17709-d68e-4448-b618-b6f594d0e8c5@t35g2000yqj.googlegroups.com> <125db7fe-036e-47c9-be89-50f05106936f@n2g2000pre.googlegroups.com> <99e7061d-20d5-434b-9404-bdafd6a013ac@i17g2000vbq.googlegroups.com> Message-ID: <4D3628AD.4040605@stoneleaf.us> Grant Edwards wrote: > On 2011-01-18, MRAB wrote: >> On 18/01/2011 19:22, rantingrick wrote: >>> ... > >> The Python community are volunteers. Nothing gets done until someone >> volunteers to do it. The "suggestion box" is your idea. Why don't you >> set it up and report back? > > He goes by the name of "ranting rick", and you're suggesting that > instead of talking he rolls up his sleeves and does something. > > I suspect you're barking into the wind... To borrow from Dilbert*, perhaps rr is more of an idea rat. ~Ethan~ *http://www.dilbert.com/strips/comic/1994-12-17/ From rantingrick at gmail.com Tue Jan 18 19:00:25 2011 From: rantingrick at gmail.com (rantingrick) Date: Tue, 18 Jan 2011 16:00:25 -0800 (PST) Subject: move to end, in Python 3.2 Really? References: <58c17709-d68e-4448-b618-b6f594d0e8c5@t35g2000yqj.googlegroups.com> <125db7fe-036e-47c9-be89-50f05106936f@n2g2000pre.googlegroups.com> Message-ID: <6ba96f41-a158-43e7-80d2-6c541587e5a4@r29g2000yqj.googlegroups.com> On Jan 18, 5:44?pm, Terry Reedy wrote: > I have nothing directly to do with c.l.p and care nothing for it. I read > the gmane.comp.python.general mirror of python-list, which filters out > some of the worse of the input from c.l.p. I mostly focus on getting > real work done on the tracker and repository and am only temporarily > spending this much time here as a diversion. Well first of all i want to commend you for your valiant efforts. You are one the most helpful folks (anoung others) around and i believe you are a virtuous soul. However, you really should not just write off c.l.py like you have. Many new users (and old hats) still hang around here. Sure there is a lot of spam, and some trolling. However, we CAN take c.l.py back IF some heavy weights will get on board. Please don't allow c.l.py to become the habitat of vermin due to neglect. Why should we move to the sub burbs just because these fowl creatures are polluting our city? We need to run them out of town. From ben+python at benfinney.id.au Tue Jan 18 19:09:36 2011 From: ben+python at benfinney.id.au (Ben Finney) Date: Wed, 19 Jan 2011 11:09:36 +1100 Subject: Swampy Module installation References: <9dd545a1-b0ea-408c-9fe2-a2ce7d6a5a0a@m7g2000vbn.googlegroups.com> Message-ID: <87y66h4uv3.fsf@benfinney.id.au> Michael Rauh writes: > I am new to python, and attempting to install the learning module > swampy. http://www.greenteapress.com/thinkpython/swampy/install.html > Unfortunately, I am attempting to do this on windows vista, which does > not appear to be cooperating. I'm not familiar with the specifics of that OS, but you should read the Python on Windows FAQ thoroughly to see if that gets you further. -- \ ?? one of the main causes of the fall of the Roman Empire was | `\ that, lacking zero, they had no way to indicate successful | _o__) termination of their C programs.? ?Robert Firth | Ben Finney From askutt at gmail.com Tue Jan 18 19:23:30 2011 From: askutt at gmail.com (Adam Skutt) Date: Tue, 18 Jan 2011 16:23:30 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <79a8a$4d332d1a$4275d90a$3986@FUSE.NET> <64976187-88ad-47c9-9bc6-c0712a657264@j32g2000yqc.googlegroups.com> <3af4fd5e-8cc9-4cec-aad2-cbf82ad3bab3@l24g2000vby.googlegroups.com> Message-ID: <0fa4603c-6e27-4ee5-9761-000a61cd19a4@fx12g2000vbb.googlegroups.com> On Jan 18, 6:36?pm, rantingrick wrote: On Jan 18, 4:57 pm, Adam Skutt wrote: > On Jan 18, 4:45 pm, Arndt Roger Schneider > > > E.g. a button is: > > > A function gets asychnronously performed in response to > > > a finger/mouse click and release inside a certain screen area. > > No, that is not the definition of a 'button', not even when we choose > > to ignore how it is rendered, which you cannot ignore even if you wish > > to pretend you can. Otherwise, I could always treat hyperlinks and > > buttons as equivalent and even interchangeable. Unfortunately, they > > are no such things. > What! YES it is Adam! And you just exposed yourself as an > argumentative moron! > > A hyperlink and a button are EXACTLY the same thing "functionality" > wise. :active, :visited:, :hover, and the concept of "onhover" all would like to have a word with you. They have different presentation which yields to different functionality: if it's important to tell a user "Hey, you've been there before", then a button is entirely unsuitable, while a hyperlink is designed precisely for that situation. Hyperlinks change their presentation to indicate mouse focus (nevermind the mouse cursor itself normally), buttons don't necessarily do either[1]. Hyperlinks can certainly decay to become button-like, but buttons cannot do everything hyperlinks can do. Checkboxes and radio buttons are a much better rebuttal, as they usually present "almost" the same API and expect the same model on part of the application programmer. It's the "almost" that kills us: radio buttons only behave in the desired way when part of a button group, forcing us to be cognizant of the fact we're creating radio buttons (since we must create button groups as well). Checkboxes support tri-state functionality, and sometimes radiobuttons do as well. Pushbuttons do no such thing[2]. It'd be nice to be able to support the abstract notion of a "button" and get what I wanted, but that requires guessing at intent and computers are notoriously lousy at that. > The fact that they look different has nothing to do with the > argument. Actually it does, but they not only look different, they /behave/ differently. Both in terms of how a user interacts with them, and in terms of how we interact with them in code. > More argumentative crap. Adam you are incapable of compromise or > reason... or maybe both. Try more facts next time. I'm not the one suggesting that the only difference between a hyperlink and a button is how they are rendered, FFS man, have you ever even used a modern GUI? Are you posting from tin? Adam [1] Even when they do, it's not intended to be controlled by the application. Native button widgets have no real built-in support for user-controlled styling on mouse focus, you'd have to do the drawing yourself (at which point you might as well write a custom widget). [2] I'm ignoring the UI problems with radio buttons and checkboxes, of course. Point is, even among things where the differences are subtle, the differences have inescapable ramifications on the code I write. From rantingrick at gmail.com Tue Jan 18 19:53:28 2011 From: rantingrick at gmail.com (rantingrick) Date: Tue, 18 Jan 2011 16:53:28 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <79a8a$4d332d1a$4275d90a$3986@FUSE.NET> <64976187-88ad-47c9-9bc6-c0712a657264@j32g2000yqc.googlegroups.com> <3af4fd5e-8cc9-4cec-aad2-cbf82ad3bab3@l24g2000vby.googlegroups.com> <0fa4603c-6e27-4ee5-9761-000a61cd19a4@fx12g2000vbb.googlegroups.com> Message-ID: <2510bf88-1045-411f-9ccd-7ca7c3665454@l24g2000vby.googlegroups.com> On Jan 18, 6:23?pm, Adam Skutt wrote: > I'm not the one suggesting that the only difference between a > hyperlink and a button is how they are rendered, FFS man, have you > ever even used a modern GUI? Yes i have logged many hours building GUI's... and from the comments you've made so far... obviously more that you have! But your defiance intrigues me. You still argue in the face of undeniable fact. Ok, i will lower the bar a bit this time. They (the buttons) are exactly the same thing except for a few superficial differences. Both "buttons" wait for activity (either by pointer, or touch) and then execute a linked block of code. The fact that hyper-link displays a visual clue that it has been "activated" before is just superficial. Heck a "button" displays a visual clue that it is a button and you are not arguing that point? And this moronic argument of ":onhover" ":visited", and ":active" is completely unfounded as buttons have mouse events such as "Enter" and "Leave", just to name a few. Adam, it is now evident that your view of the world is, at best, a superficial one. You are shallow and incapable of any coherent abstract reasoning abilities. I genuinely hope this is due to some emotional distress you are suffering and not a chronic condition, because if not, you need to give some deep mediative thoughts to how you are perceiving the world around you to heal your mind of this improper processing. Being argumentative just for the sake of being argumentative is a never ending cycle of foolishness. Now, at some point earlier you had begin to display some coherency and insights. I sure hope that behavior will return soon..? From kb1pkl at aim.com Tue Jan 18 20:19:17 2011 From: kb1pkl at aim.com (Corey Richardson) Date: Tue, 18 Jan 2011 20:19:17 -0500 Subject: Tkinter: The good, the bad, and the ugly! In-Reply-To: <2510bf88-1045-411f-9ccd-7ca7c3665454@l24g2000vby.googlegroups.com> References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <79a8a$4d332d1a$4275d90a$3986@FUSE.NET> <64976187-88ad-47c9-9bc6-c0712a657264@j32g2000yqc.googlegroups.com> <3af4fd5e-8cc9-4cec-aad2-cbf82ad3bab3@l24g2000vby.googlegroups.com> <0fa4603c-6e27-4ee5-9761-000a61cd19a4@fx12g2000vbb.googlegroups.com> <2510bf88-1045-411f-9ccd-7ca7c3665454@l24g2000vby.googlegroups.com> Message-ID: <4D363C15.7030306@aim.com> On 01/18/2011 07:53 PM, rantingrick wrote: > On Jan 18, 6:23 pm, Adam Skutt wrote: > > [snip] > > Adam, it is now evident that your view of the world is, at best, a > superficial one. You are shallow and incapable of any coherent > abstract reasoning abilities. I genuinely hope this is due to some > emotional distress you are suffering and not a chronic condition, > because if not, you need to give some deep mediative thoughts to how > you are perceiving the world around you to heal your mind of this > improper processing. Being argumentative just for the sake of being > argumentative is a never ending cycle of foolishness. Now, at some > point earlier you had begin to display some coherency and insights. I > sure hope that behavior will return soon..? Because insulting others is completely how things get done. As to the button/hyperlink, they may both share some common functionality and even a common ancestor, they are different beings, otherwise they wouldn't be two separate things. It may even be that a hyperlink is a type of button, but that doesn't make a button a hyperlink. (Plant/tree, rectangle/square type deal). I for one am quite pleased with Tkinter up to this point. It allowed me to come in with extremely minimal GUI experience, and make something that worked with minimal effort. It was simple to understand, no concepts of slots and signals to learn. A project I'm working on requires PyQt, so I use PyQt. Is the fact that it's not in the stdlib a detriment? No. I think Tkinter _should_ be in the stdlib because it's simple. If something else were to take it's place I would hope that it is as easy to learn/use as Tkinter is. But I think this whole thread has gotten off topic. Why should Tkinter be replaced? Why was it added there in the first place? What should replace it, and why? Instead of arguing about little piddly details like the difference between a button and a hyperlink, just stick to the task at hand that you yourself presented. My two cents, ~Corey From rantingrick at gmail.com Tue Jan 18 20:23:06 2011 From: rantingrick at gmail.com (rantingrick) Date: Tue, 18 Jan 2011 17:23:06 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <79a8a$4d332d1a$4275d90a$3986@FUSE.NET> <64976187-88ad-47c9-9bc6-c0712a657264@j32g2000yqc.googlegroups.com> <3af4fd5e-8cc9-4cec-aad2-cbf82ad3bab3@l24g2000vby.googlegroups.com> <9d0d0f8a-9684-4405-897c-141f2241070d@fo10g2000vbb.googlegroups.com> Message-ID: On Jan 18, 2:37?pm, Adam Skutt wrote: > On Jan 18, 2:11?pm, rantingrick wrote: > > The entropy in GUIs has > > exploded exponentially and rendered them all useless. > > Only if you have no clue what you're talking about whatsoever. ?You > perceive them as useless because you're apparently incapable of > understanding the simplest GUI precepts, nevermind APIs, which is why > you've gone from Pure Python GUI to wxWidgets to this OpenGUI bullshit > you're now espousing. ?Desperately clinging to a position doesn't make > you look intelligent. > > Plus, I'm not sure what entropy you're talking about, but I'm not > seeing it. ?MS continues to innovate, Apple continues to innovate, > some portions of the Linux community do innovative things. ?Though > most people just want to put something together and call it a day, and > the functionality provided by a lot of toolkits is beyond adequate for > that. Adam, i am speaking specifically about how multiplicity is ruining everything. The multiplicity is "entropy incarnate". And selfishness is the heathen prodigy of multiplicity. What we have today is a zig saw puzzle of GUI libraries. Not one of them can solve all the GUI problems we have before us because of selfishness and lack of true cooperation between the diverse parties. And to add insult to injury none of the pieces where ever made so that they could mate correctly. We have been the victims of you own selfishness and vanity begotten directly from our fostering of multiplicity. Once you understand what i am talking about, you will see how it applies to almost every system we humans have ever created. And more disturbingly, how difficult it will be to undo this backward facing inertia we have set in motion. Years, decades, centuries have been lost due to nothing more than selfishness. When will we see the light? From patty at cruzio.com Tue Jan 18 20:39:43 2011 From: patty at cruzio.com (Patty) Date: Tue, 18 Jan 2011 17:39:43 -0800 Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <79a8a$4d332d1a$4275d90a$3986@FUSE.NET> <64976187-88ad-47c9-9bc6-c0712a657264@j32g2000yqc.googlegroups.com> <3af4fd5e-8cc9-4cec-aad2-cbf82ad3bab3@l24g2000vby.googlegroups.com> <0fa4603c-6e27-4ee5-9761-000a61cd19a4@fx12g2000vbb.googlegroups.com><2510bf88-1045-411f-9ccd-7ca7c3665454@l24g2000vby.googlegroups.com> <4D363C15.7030306@aim.com> Message-ID: <94898B418AC54E0BBD4C64003D9D5BAF@mycomputer> ----- Original Message ----- From: "Corey Richardson" To: Sent: Tuesday, January 18, 2011 5:19 PM Subject: Re: Tkinter: The good, the bad, and the ugly! > On 01/18/2011 07:53 PM, rantingrick wrote: >> On Jan 18, 6:23 pm, Adam Skutt wrote: >> >> [snip] >> >> Adam, it is now evident that your view of the world is, at best, a >> superficial one. You are shallow and incapable of any coherent >> abstract reasoning abilities. I genuinely hope this is due to some >> emotional distress you are suffering and not a chronic condition, >> because if not, you need to give some deep mediative thoughts to how >> you are perceiving the world around you to heal your mind of this >> improper processing. Being argumentative just for the sake of being >> argumentative is a never ending cycle of foolishness. Now, at some >> point earlier you had begin to display some coherency and insights. I >> sure hope that behavior will return soon..? > > Because insulting others is completely how things get done. As to the > button/hyperlink, they may both share some common functionality and even > a common ancestor, they are different beings, otherwise they wouldn't be > two separate things. It may even be that a hyperlink is a type of > button, but that doesn't make a button a hyperlink. (Plant/tree, > rectangle/square type deal). > > I for one am quite pleased with Tkinter up to this point. It allowed me > to come in with extremely minimal GUI experience, and make something > that worked with minimal effort. It was simple to understand, no > concepts of slots and signals to learn. A project I'm working on > requires PyQt, so I use PyQt. Is the fact that it's not in the stdlib a > detriment? No. I think Tkinter _should_ be in the stdlib because it's > simple. If something else were to take it's place I would hope that it > is as easy to learn/use as Tkinter is. > > But I think this whole thread has gotten off topic. Why should Tkinter > be replaced? Why was it added there in the first place? What should > replace it, and why? Instead of arguing about little piddly details like > the difference between a button and a hyperlink, just stick to the task > at hand that you yourself presented. > > My two cents, > ~Corey > -- > http://mail.python.org/mailman/listinfo/python-list > > I agree with Corey - I also had very little experience with creating a GUI and using Tkinter combined with PIL plus a little help from various docs and getting a couple questions answered, I was pleased to find that it required very few actual lines of code to create a basic small window and display text and pictures that I am happy with and I am sure I can use this small module as a base to expand on if I want to. Regards, Patty From rantingrick at gmail.com Tue Jan 18 20:41:15 2011 From: rantingrick at gmail.com (rantingrick) Date: Tue, 18 Jan 2011 17:41:15 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <64976187-88ad-47c9-9bc6-c0712a657264@j32g2000yqc.googlegroups.com> <3af4fd5e-8cc9-4cec-aad2-cbf82ad3bab3@l24g2000vby.googlegroups.com> <0fa4603c-6e27-4ee5-9761-000a61cd19a4@fx12g2000vbb.googlegroups.com> <2510bf88-1045-411f-9ccd-7ca7c3665454@l24g2000vby.googlegroups.com> Message-ID: On Jan 18, 7:19?pm, Corey Richardson wrote: > I for one am quite pleased with Tkinter up to this point. It allowed me > to come in with extremely minimal GUI experience, and make something > that worked with minimal effort. It was simple to understand, no > concepts of slots and signals to learn. I agree. I have written tons of code with Tkinter and i love both the simplistic API and the geometry managers to name a few pros. > If something else were to take it's place (Tkinter) I would hope that it > is as easy to learn/use as Tkinter is. I completely agree! And we should expect it to be even better! > But I think this whole thread has gotten off topic. Why should Tkinter > be replaced? Well there are many good reasons and most are not apparent to those with minimal to average Tkinter experience. My main beef with Tkinter is that it is limited --both widget wise and extensible wise-- and that we must recognize that web and mobile platforms are getting bigger every day. We cannot ignore this fact. The GUI landscape is changing fast and whilst desktop support will be needed for many years to come, mobile and web must be addressed and addressed quickly! > Why was it added there in the first place? Well from what i understand (and feel free to correct me anyone) Guido wanted a GUI both for batteries included and for ease of introductory GUI programming. So he choose Tkinter because it would be both easy to integrate and easy to use. And i totally agree with these ideas. However that was circa 1990's and we are now in 2011. I think Tkinter (whilst still quite useful) is well pasted it's prime. We must consider keeping Pythons stdlib up to date. And doing that might mean we need to make some very tough decisions. Guido brought about Python3000 and i think he's on the right track, however more must be done. Change while painful is always necessary. "Change with the times or get left behind." > What should > replace it, and why? Well that seems to be the burning question. Now, after considering all the options i can't see anything that truly moves us forward to were we "should" be. I do think wx would be a move "forward" however only a very *small* move in the larger scope of things. We need to think bigger, we need to think of mobile and web interfaces if we want Python to compete in the next 10 years. So when considering anything we must consider all three. > Instead of arguing about little piddly details like > the difference between a button and a hyperlink, just stick to the task > at hand that you yourself presented. You are absolutely correct Corey. Thanks for getting us back on topic! From nstinemates at gmail.com Tue Jan 18 20:46:40 2011 From: nstinemates at gmail.com (Nick Stinemates) Date: Tue, 18 Jan 2011 17:46:40 -0800 Subject: Tkinter: The good, the bad, and the ugly! In-Reply-To: References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <79a8a$4d332d1a$4275d90a$3986@FUSE.NET> <64976187-88ad-47c9-9bc6-c0712a657264@j32g2000yqc.googlegroups.com> <3af4fd5e-8cc9-4cec-aad2-cbf82ad3bab3@l24g2000vby.googlegroups.com> <9d0d0f8a-9684-4405-897c-141f2241070d@fo10g2000vbb.googlegroups.com> Message-ID: You make it very hard for me to take what you say seriously. I lurk on this list and I have created a filter where emails from you go in to Spam. Good luck. Nick On Tue, Jan 18, 2011 at 5:23 PM, rantingrick wrote: > On Jan 18, 2:37 pm, Adam Skutt wrote: > > On Jan 18, 2:11 pm, rantingrick wrote: > > > > The entropy in GUIs has > > > exploded exponentially and rendered them all useless. > > > > Only if you have no clue what you're talking about whatsoever. You > > perceive them as useless because you're apparently incapable of > > understanding the simplest GUI precepts, nevermind APIs, which is why > > you've gone from Pure Python GUI to wxWidgets to this OpenGUI bullshit > > you're now espousing. Desperately clinging to a position doesn't make > > you look intelligent. > > > > Plus, I'm not sure what entropy you're talking about, but I'm not > > seeing it. MS continues to innovate, Apple continues to innovate, > > some portions of the Linux community do innovative things. Though > > most people just want to put something together and call it a day, and > > the functionality provided by a lot of toolkits is beyond adequate for > > that. > > > Adam, i am speaking specifically about how multiplicity is ruining > everything. The multiplicity is "entropy incarnate". And selfishness > is the heathen prodigy of multiplicity. What we have today is a zig > saw puzzle of GUI libraries. Not one of them can solve all the GUI > problems we have before us because of selfishness and lack of true > cooperation between the diverse parties. And to add insult to injury > none of the pieces where ever made so that they could mate correctly. > We have been the victims of you own selfishness and vanity begotten > directly from our fostering of multiplicity. Once you understand what > i am talking about, you will see how it applies to almost every system > we humans have ever created. And more disturbingly, how difficult it > will be to undo this backward facing inertia we have set in motion. > Years, decades, centuries have been lost due to nothing more than > selfishness. When will we see the light? > -- > http://mail.python.org/mailman/listinfo/python-list > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rantingrick at gmail.com Tue Jan 18 20:54:08 2011 From: rantingrick at gmail.com (rantingrick) Date: Tue, 18 Jan 2011 17:54:08 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <64976187-88ad-47c9-9bc6-c0712a657264@j32g2000yqc.googlegroups.com> <3af4fd5e-8cc9-4cec-aad2-cbf82ad3bab3@l24g2000vby.googlegroups.com> <0fa4603c-6e27-4ee5-9761-000a61cd19a4@fx12g2000vbb.googlegroups.com><2510bf88-1045-411f-9ccd-7ca7c3665454@l24g2000vby.googlegroups.com> <4D363C15.7030306@aim.com> Message-ID: <137c9df1-aa56-471a-92ad-9b222dadb196@u32g2000yqe.googlegroups.com> On Jan 18, 7:39?pm, "Patty" wrote: > I agree with Corey - I also had very little experience with creating a GUI > and using Tkinter combined with PIL plus a little help from various docs > and getting a couple questions answered, I was pleased to find that it > required very few actual lines of code to create a basic small window and > display text and pictures that ?I am happy with and I am sure I can use this > small module as a base to expand on if I want to. Hello Patty and welcome to the debate, I am happy to see the simplicity of Tkinter has helped moved you into the joys of GUI programming. I remember my initial days with Tkinter and i remember the delight in achieving my first small GUI utilities. Like you, i love the simplistic nature of Tkinter and if TclTk had as large a widget base and maturity as wxWidgets then we would be closer to the 21st century GUI library that Python desperately needs. However as i know --and you will find out over time-- Tkinter is greatly lacking in very important widgets. Widgets that are part of every major GUI app you could imagine. If all you do is create utilities for yourself or small apps you can get by with Tkinter just fine. However if you try to go any further you will then realize the limits of TclTk --and not Tkinter-- are really the culprits behind the scenes. But again, all this is moot because as this debate has evolved so too has my understanding of where we need to be focusing or efforts -- and *desktop only* is not going to cut it for the future of Python's std- GUI-lib. We need to take a step back and see the larger picture. Currently we have our heads stuck in the vacuum of python land, however this GUI problem is much, much larger! From kb1pkl at aim.com Tue Jan 18 20:59:32 2011 From: kb1pkl at aim.com (Corey Richardson) Date: Tue, 18 Jan 2011 20:59:32 -0500 Subject: Tkinter: The good, the bad, and the ugly! In-Reply-To: References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <64976187-88ad-47c9-9bc6-c0712a657264@j32g2000yqc.googlegroups.com> <3af4fd5e-8cc9-4cec-aad2-cbf82ad3bab3@l24g2000vby.googlegroups.com> <0fa4603c-6e27-4ee5-9761-000a61cd19a4@fx12g2000vbb.googlegroups.com> <2510bf88-1045-411f-9ccd-7ca7c3665454@l24g2000vby.googlegroups.com> Message-ID: <4D364584.3060603@aim.com> On 01/18/2011 08:41 PM, rantingrick wrote: > On Jan 18, 7:19 pm, Corey Richardson wrote: > >> I for one am quite pleased with Tkinter up to this point. It allowed me >> to come in with extremely minimal GUI experience, and make something >> that worked with minimal effort. It was simple to understand, no >> concepts of slots and signals to learn. > > I agree. I have written tons of code with Tkinter and i love both the > simplistic API and the geometry managers to name a few pros. > > >> If something else were to take it's place (Tkinter) I would hope that it >> is as easy to learn/use as Tkinter is. > > I completely agree! And we should expect it to be even better! What out there is there that meets those requirements? > > >> But I think this whole thread has gotten off topic. Why should Tkinter >> be replaced? > > Well there are many good reasons and most are not apparent to those > with minimal to average Tkinter experience. My main beef with Tkinter > is that it is limited --both widget wise and extensible wise-- and > that we must recognize that web and mobile platforms are getting > bigger every day. We cannot ignore this fact. The GUI landscape is > changing fast and whilst desktop support will be needed for many years > to come, mobile and web must be addressed and addressed quickly! Mobile and web certainly have their place, but it Python the place for it? Sure, Python can be used as the back-end of web sites, but not up front like Java or Flash (aside from Jython). Especially mobile. Python was not intended for a mobile platform not should it be made to fit that niche. Python has its place, but your cell phone is not it. > > [snip] >> What should >> replace it, and why? > > Well that seems to be the burning question. Now, after considering all > the options i can't see anything that truly moves us forward to were > we "should" be. I do think wx would be a move "forward" however only a > very *small* move in the larger scope of things. We need to think > bigger, we need to think of mobile and web interfaces if we want > Python to compete in the next 10 years. So when considering anything > we must consider all three. > >From that, it appears we need to: 1. Replace Tkinter with something more modern and feature-complete, but just as easy to use. 2. Add a web framework/web-GUI As a web interface are you thinking something like Java's Swing or something like Django? Given the above, what do you guys (python-list, not just rantingrick) think fills the spot the best? Would these items inclusion in the stdlib entail unnecessary cruft added on to the size of the stdlib, are they completely cross-platform (as far as Python itself is)? Let's try not to get off track like this thing has been since it was started. Either get things done or shut up ;-). I think this is almost ready to split into a "real" thread, not just a giant cyclic argument that this thread has been. ~Corey From rantingrick at gmail.com Tue Jan 18 21:16:54 2011 From: rantingrick at gmail.com (rantingrick) Date: Tue, 18 Jan 2011 18:16:54 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <3af4fd5e-8cc9-4cec-aad2-cbf82ad3bab3@l24g2000vby.googlegroups.com> <0fa4603c-6e27-4ee5-9761-000a61cd19a4@fx12g2000vbb.googlegroups.com> <2510bf88-1045-411f-9ccd-7ca7c3665454@l24g2000vby.googlegroups.com> Message-ID: <2ef2fa6c-2ccf-453a-8f50-0ef7dbd7834d@j32g2000yqc.googlegroups.com> On Jan 18, 7:59?pm, Corey Richardson wrote: > On 01/18/2011 08:41 PM, rantingrick wrote: > >From that, it appears we need to: > > 1. Replace Tkinter with something more modern and feature-complete, but > just as easy to use. > 2. Add a web framework/web-GUI That would be a HUGE step in the correct direction. It would not solve all our problems however its a start. Like i mentioned earlier with Tkinter it is fact that sooner or later you will come up against the glass ceiling. At that point your only alternative is to toss away everything you have learned/written and re-learn another GUI library like wxPython. This is what bothers me most about Tkinter. It just sums to wasted time and energy. If we had a simplistic wxGUI in the stdlib, when you hit the ceiling and need to go further you could then scale nicely to the feature richness of wxPython as a 3rd party download -- WITHOUT relearning/rewriting everything! > Given the above, what do you guys (python-list, not just rantingrick) > think fills the spot the best? Well i hope some heavy weights weigh in however i must tell you that it don't happen very often. From kb1pkl at aim.com Tue Jan 18 21:27:57 2011 From: kb1pkl at aim.com (Corey Richardson) Date: Tue, 18 Jan 2011 21:27:57 -0500 Subject: Tkinter: The good, the bad, and the ugly! In-Reply-To: <2ef2fa6c-2ccf-453a-8f50-0ef7dbd7834d@j32g2000yqc.googlegroups.com> References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <3af4fd5e-8cc9-4cec-aad2-cbf82ad3bab3@l24g2000vby.googlegroups.com> <0fa4603c-6e27-4ee5-9761-000a61cd19a4@fx12g2000vbb.googlegroups.com> <2510bf88-1045-411f-9ccd-7ca7c3665454@l24g2000vby.googlegroups.com> <2ef2fa6c-2ccf-453a-8f50-0ef7dbd7834d@j32g2000yqc.googlegroups.com> Message-ID: <4D364C2D.5060106@aim.com> On 01/18/2011 09:16 PM, rantingrick wrote: > On Jan 18, 7:59 pm, Corey Richardson wrote: >> On 01/18/2011 08:41 PM, rantingrick wrote: > >> >From that, it appears we need to: >> >> 1. Replace Tkinter with something more modern and feature-complete, but >> just as easy to use. >> 2. Add a web framework/web-GUI > > That would be a HUGE step in the correct direction. It would not solve > all our problems however its a start. Like i mentioned earlier with > Tkinter it is fact that sooner or later you will come up against the > glass ceiling. At that point your only alternative is to toss away > everything you have learned/written and re-learn another GUI library > like wxPython. This is what bothers me most about Tkinter. It just > sums to wasted time and energy. If we had a simplistic wxGUI in the > stdlib, when you hit the ceiling and need to go further you could then > scale nicely to the feature richness of wxPython as a 3rd party > download -- WITHOUT relearning/rewriting everything! > You mentioned having a segment of wxPython in the stdlib earlier. If this actually feasible from a legal standpoint, and would the maintainers of wxPython be willing to put it in the stdlib? Not to mention the wonderful people over at python-dev. Why would you add in only a part of wxPython, instead of all of it? Is the work to cut it down really an advantage over the size of the full toolkit? From what I just checked, the source tarball is 40MB. Can that much really be added to the Python stdlib? What other alternatives are there, besides wxPython, that are perhaps a bit smaller. > >> Given the above, what do you guys (python-list, not just rantingrick) >> think fills the spot the best? > > Well i hope some heavy weights weigh in however i must tell you that > it don't happen very often. > > From askutt at gmail.com Tue Jan 18 21:43:25 2011 From: askutt at gmail.com (Adam Skutt) Date: Tue, 18 Jan 2011 18:43:25 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <3af4fd5e-8cc9-4cec-aad2-cbf82ad3bab3@l24g2000vby.googlegroups.com> <0fa4603c-6e27-4ee5-9761-000a61cd19a4@fx12g2000vbb.googlegroups.com> <2510bf88-1045-411f-9ccd-7ca7c3665454@l24g2000vby.googlegroups.com> Message-ID: On Jan 18, 8:59?pm, Corey Richardson wrote: > > > I completely agree! And we should expect it to be even better! > > What out there is there that meets those requirements? Nothing, and I somewhat doubt there ever will be. Tk is somewhat of an anomaly at this point. Most of the trend in GUI toolkits is to become more HTML/JS/CSS like in nature, which isn't something I personally agree with. I certainly don't think it makes life any easier for the programmer, especially starting out. It might make certain types of applications (e.g., CRUD) easier, but that's not a laudable goal in the least. > Mobile and web certainly have their place, but it Python the place for > it? Sure, Python can be used as the back-end of web sites, but not up > front like Java or Flash (aside from Jython). Especially mobile. Python > was not intended for a mobile platform not should it be made to fit that > niche. Python has its place, but your cell phone is not it. I don't think that's true per se, but I don't think it's relevant. A single GUI toolkit for traditional computers, for web, and mobile is a difficult task, one that no one has accomplished. MS has gotten closest, and I'd hesitate to call Silverlight a success. Plus, Silverlight is plugin-based rich applications (ala Flash), not HTML/ CSS/Javascript which is what most people mean/want for the web. Adding HTML/CSS/Javascript to the mix takes the problem from bad to awful, in my opinion. I'm sure the various Pyjamas users might take issue with that, but what works best inside a web browser (with its various enforced limitations) isn't what works best inside a client- side application (be it web delivered or not). > As a web interface are you thinking something like Java's Swing or > something like Django? You pretty clearly need both. There are times when web pages are what I want, there are times when they are inadequate and I need more functionality. You certainly don't want either Swing or Django, though. > > Given the above, what do you guys (python-list, not just rantingrick) > think fills the spot the best? > Nothing, but I'm not even convinced the spot needs to be filled. Certainly no one's made an actual case for why, much less how. Regardless, if it's really what you want, you'd have to write it yourself. Personally, while Silverlight has some interesting ideas, I'd recommend not using it as a base, especially if Python is your target language. > Would these items inclusion in the stdlib entail unnecessary cruft added > on to the size of the stdlib, are they completely cross-platform (as far > as Python itself is)? > Depends on exactly what you do, but you'd likely end up no bigger than .NET or Java. I'll leave it to others to decide whether that's a good or bad thing. > Let's try not to get off track like this thing has been since it was > started. That was and rantingrick's goal from the get go and still is his goal. Otherwise, he wouldn't have changed his position three times now and be overdue for a fourth. Otherwise, he would have answered my / your question about why bother putting a minimized version of wxWidgets in the standard library by now as opposed to the whole damn thing. He dodges technical questions because he lacks even the most elementary understanding. He'll do the same to you and only offer absurd platitudes and insults in return, as opposed to actual working technical solutions. Hell, he can't even offer up a consistent problem to solve, and he's honestly over do for changing it altogether.. Adam From rantingrick at gmail.com Tue Jan 18 21:46:42 2011 From: rantingrick at gmail.com (rantingrick) Date: Tue, 18 Jan 2011 18:46:42 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <0fa4603c-6e27-4ee5-9761-000a61cd19a4@fx12g2000vbb.googlegroups.com> <2510bf88-1045-411f-9ccd-7ca7c3665454@l24g2000vby.googlegroups.com> <2ef2fa6c-2ccf-453a-8f50-0ef7dbd7834d@j32g2000yqc.googlegroups.com> Message-ID: <6de7ffb8-ef5a-4596-99ca-de1a6ab1d2ab@z5g2000yqb.googlegroups.com> On Jan 18, 8:27?pm, Corey Richardson wrote: > You mentioned having a segment of wxPython in the stdlib earlier. If > this actually feasible from a legal standpoint, and would the > maintainers of wxPython be willing to put it in the stdlib? Not to > mention the wonderful people over at python-dev. This might come as a shock to you, but it really doesn't matter what the wxPython folks think about the inclusion of wxPython into the stdlib. If they are against it (or simply don't care) then they can continue to focus their efforts on the full version. No harm done, really. As far as python-dev is concerned -- it does matter! However if the community wants change, and makes enough noise, they will have no choice either. ;) > Why would you add in only a part of wxPython, instead of all of it? see my next answer for detail... > Is > the work to cut it down really an advantage over the size of the full > toolkit? From what I just checked, the source tarball is 40MB. Can that > much really be added to the Python stdlib? 40MB is far too big. Much of wxPython is thousands of widgets that have no buisness in the stdlib. We only want a very limited set (much like what Tkinter is composed of now) and then for the people who want to create professional GUI's they can download the full 40MB. The great advantage here is scalability. Tkinter cannot do this. And anybody who alludes to this is a liar. > What other alternatives are > there, besides wxPython, that are perhaps a bit smaller. Well i am open to any and all alternatives. However no many have been brought forward. My dream would be to have something completely python based, although i realize that the work involved is far too enormous. So we must build from something that already exists. Nothing is really perfect. WxPython IS NOT perfect however it is a step forward. As far as alternative here is a list... http://docs.python.org/faq/gui From rantingrick at gmail.com Tue Jan 18 21:54:59 2011 From: rantingrick at gmail.com (rantingrick) Date: Tue, 18 Jan 2011 18:54:59 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <3af4fd5e-8cc9-4cec-aad2-cbf82ad3bab3@l24g2000vby.googlegroups.com> <0fa4603c-6e27-4ee5-9761-000a61cd19a4@fx12g2000vbb.googlegroups.com> <2510bf88-1045-411f-9ccd-7ca7c3665454@l24g2000vby.googlegroups.com> Message-ID: <7e3d9f6e-84a2-4b43-ac26-e05082453469@c39g2000yqi.googlegroups.com> On Jan 18, 8:43?pm, Adam Skutt wrote: > That was and rantingrick's goal from the get go and still is his goal. > Otherwise, he wouldn't have changed his position three times now and > be overdue for a fourth. ?Otherwise, he would have answered my / your > question about why bother putting a minimized version of wxWidgets in > the standard library by now as opposed to the whole damn thing. ? You know Adam i was just begining to like you again ;). I HAVE answered that question a many, many times and if you actually take the time to read my posts AND comprhend them you would have found that answer by now. psst! Just recently i answered it again. And no, i will not quote myself for your convince. Get off your lazy butt and find it yourself! [...snip: Character assassination ...] From kb1pkl at aim.com Tue Jan 18 22:02:19 2011 From: kb1pkl at aim.com (Corey Richardson) Date: Tue, 18 Jan 2011 22:02:19 -0500 Subject: Tkinter: The good, the bad, and the ugly! In-Reply-To: <6de7ffb8-ef5a-4596-99ca-de1a6ab1d2ab@z5g2000yqb.googlegroups.com> References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <0fa4603c-6e27-4ee5-9761-000a61cd19a4@fx12g2000vbb.googlegroups.com> <2510bf88-1045-411f-9ccd-7ca7c3665454@l24g2000vby.googlegroups.com> <2ef2fa6c-2ccf-453a-8f50-0ef7dbd7834d@j32g2000yqc.googlegroups.com> <6de7ffb8-ef5a-4596-99ca-de1a6ab1d2ab@z5g2000yqb.googlegroups.com> Message-ID: <4D36543B.8020602@aim.com> On 01/18/2011 09:46 PM, rantingrick wrote: > On Jan 18, 8:27 pm, Corey Richardson wrote: > >> You mentioned having a segment of wxPython in the stdlib earlier. If >> this actually feasible from a legal standpoint, and would the >> maintainers of wxPython be willing to put it in the stdlib? Not to >> mention the wonderful people over at python-dev. > > This might come as a shock to you, but it really doesn't matter what > the wxPython folks think about the inclusion of wxPython into the > stdlib. If they are against it (or simply don't care) then they can > continue to focus their efforts on the full version. No harm done, > really. As far as python-dev is concerned -- it does matter! However > if the community wants change, and makes enough noise, they will have > no choice either. ;) > >> Why would you add in only a part of wxPython, instead of all of it? > > see my next answer for detail... > >> Is >> the work to cut it down really an advantage over the size of the full >> toolkit? From what I just checked, the source tarball is 40MB. Can that >> much really be added to the Python stdlib? > > 40MB is far too big. Much of wxPython is thousands of widgets that > have no buisness in the stdlib. We only want a very limited set (much > like what Tkinter is composed of now) and then for the people who want > to create professional GUI's they can download the full 40MB. The > great advantage here is scalability. Tkinter cannot do this. And > anybody who alludes to this is a liar. > >> What other alternatives are >> there, besides wxPython, that are perhaps a bit smaller. > > Well i am open to any and all alternatives. However no many have been > brought forward. My dream would be to have something completely python > based, although i realize that the work involved is far too enormous. > So we must build from something that already exists. Nothing is really > perfect. WxPython IS NOT perfect however it is a step forward. > > As far as alternative here is a list... > > http://docs.python.org/faq/gui If that's what you believe, I don't think many (if any) here have an issue with replacing Tkinter with something that has more features and is just as easy to use. Write up a full-on proposal, including technical feasibility of splitting up wxPython, and send it to python-ideas. After they give some feedback, modify and send to python-dev. If it's well written and makes sense, I'm sure they'll lend an ear. Just don't keep getting off topic and I'm sure people will take you more seriously next time. The insulting doesn't help either side. From rantingrick at gmail.com Tue Jan 18 22:24:57 2011 From: rantingrick at gmail.com (rantingrick) Date: Tue, 18 Jan 2011 19:24:57 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <0fa4603c-6e27-4ee5-9761-000a61cd19a4@fx12g2000vbb.googlegroups.com> <2510bf88-1045-411f-9ccd-7ca7c3665454@l24g2000vby.googlegroups.com> <2ef2fa6c-2ccf-453a-8f50-0ef7dbd7834d@j32g2000yqc.googlegroups.com> <6de7ffb8-ef5a-4596-99ca-de1a6ab1d2ab@z5g2000yqb.googlegroups.com> Message-ID: <507653e8-215f-4e60-b1aa-c3642b053be2@c39g2000yqi.googlegroups.com> On Jan 18, 9:02?pm, Corey Richardson wrote: > If that's what you believe, I don't think many (if any) here have an > issue with replacing Tkinter with something that has more features and > is just as easy to use. Yea, and you're basing that on facts from where? If you haven't noticed by now NEWSFLASH! nobody from Python-dev has weighed in. Where is Steve Holden on the issue... who knows? Where is his subordinate on this? > Write up a full-on proposal, including technical > feasibility of splitting up wxPython, and send it to python-ideas. After > they give some feedback, modify and send to python-dev. If it's well > written and makes sense, I'm sure they'll lend an ear. Obviously you've never dealt with these folks before have you? > Just don't keep > getting off topic and I'm sure people will take you more seriously next > time. The insulting doesn't help either side. Yea, thats all it takes Corey. Obviously you have not been around here long and know that because your spirit is not broken yet. But don't worry Corey, because if you hang around long enough these monsters will crucify you. Then you will understand why i have to rant so much, and why we find ourselves a full decade behind in GUI libraries with no good solution in sight. They can find a thousand reasons not to remove Tkinter and not one of them have an once of vision or thought applied. These people live on emotion, one hand washes the other, and back door politics. That is the current state of Python-dev as it relates to the "peasents". We are nothing to them. Python has lost all vision as a community. This is no doubt the beginning of the end. Better check out GO... From kb1pkl at aim.com Tue Jan 18 22:47:01 2011 From: kb1pkl at aim.com (Corey Richardson) Date: Tue, 18 Jan 2011 22:47:01 -0500 Subject: Tkinter: The good, the bad, and the ugly! In-Reply-To: <507653e8-215f-4e60-b1aa-c3642b053be2@c39g2000yqi.googlegroups.com> References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <0fa4603c-6e27-4ee5-9761-000a61cd19a4@fx12g2000vbb.googlegroups.com> <2510bf88-1045-411f-9ccd-7ca7c3665454@l24g2000vby.googlegroups.com> <2ef2fa6c-2ccf-453a-8f50-0ef7dbd7834d@j32g2000yqc.googlegroups.com> <6de7ffb8-ef5a-4596-99ca-de1a6ab1d2ab@z5g2000yqb.googlegroups.com> <507653e8-215f-4e60-b1aa-c3642b053be2@c39g2000yqi.googlegroups.com> Message-ID: <4D365EB5.9010001@aim.com> On 01/18/2011 10:24 PM, rantingrick wrote: > On Jan 18, 9:02 pm, Corey Richardson wrote: > >> If that's what you believe, I don't think many (if any) here have an >> issue with replacing Tkinter with something that has more features and >> is just as easy to use. > > Yea, and you're basing that on facts from where? If you haven't > noticed by now NEWSFLASH! nobody from Python-dev has weighed in. Where > is Steve Holden on the issue... who knows? Where is his subordinate on > this? > >> Write up a full-on proposal, including technical >> feasibility of splitting up wxPython, and send it to python-ideas. After >> they give some feedback, modify and send to python-dev. If it's well >> written and makes sense, I'm sure they'll lend an ear. > > Obviously you've never dealt with these folks before have you? > >> Just don't keep >> getting off topic and I'm sure people will take you more seriously next >> time. The insulting doesn't help either side. > > Yea, thats all it takes Corey. Obviously you have not been around > here long and know that because your spirit is not broken yet. But > don't worry Corey, because if you hang around long enough these > monsters will crucify you. Then you will understand why i have to rant > so much, and why we find ourselves a full decade behind in GUI > libraries with no good solution in sight. They can find a thousand > reasons not to remove Tkinter and not one of them have an once of > vision or thought applied. These people live on emotion, one hand > washes the other, and back door politics. That is the current state of > Python-dev as it relates to the "peasents". We are nothing to them. > > Python has lost all vision as a community. This is no doubt the > beginning of the end. Better check out GO... > > Bye. From askutt at gmail.com Tue Jan 18 22:54:59 2011 From: askutt at gmail.com (Adam Skutt) Date: Tue, 18 Jan 2011 19:54:59 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <0fa4603c-6e27-4ee5-9761-000a61cd19a4@fx12g2000vbb.googlegroups.com> <2510bf88-1045-411f-9ccd-7ca7c3665454@l24g2000vby.googlegroups.com> <2ef2fa6c-2ccf-453a-8f50-0ef7dbd7834d@j32g2000yqc.googlegroups.com> Message-ID: <5c6ff40f-05c1-4e38-89bc-b8c4745db7ce@i18g2000yqn.googlegroups.com> On Jan 18, 9:27?pm, Corey Richardson wrote: > > Why would you add in only a part of wxPython, instead of all of it? Is > the work to cut it down really an advantage over the size of the full > toolkit? From what I just checked, the source tarball is 40MB. Can that > much really be added to the Python stdlib? What other alternatives are > there, besides wxPython, that are perhaps a bit smaller. > The source tarball from the wxPython.org website contains a full version of wxWidgets in addition to the actual wxPython functionality. A python distribution would certainly contain solely the latter and require the end user to already have wxWidgets installed in a suitable fashion. The actual full wxPython binding is ~100 MiB uncompressed, ~15 MiB compressed BZIP2, but it also includes a lot of stuff that could possibly be removed and/or reduced, like full documentation, examples, etc. It can be shrunk even further by taking a dependency on swig and regenerating the bindings at compile time (they're shipped prebuilt). At which point, it's pretty damn small. Not as small as all of the Tk functionality, I think, but well under 10MiB compressed. The problem to me isn't the size (though some might find it objectionable), but the system dependencies you have to take: wxWidgets requires GTK+ on UNIX, which requires a whole mess of crap in term, plus swig, plus whatever else I may or may not be missing. I'm also not 100% certain as to whether it's as portable as Tk is today. At any rate, if the size is an issue, culling widgets is a lot of an effort for not much of a gain, especially when you look at the bigger picture of, "Every file I have to download to build python from scratch" Minimizing what's in the Python distribution does not change the size of the dependency set one bit, and that dwarfs the python code in any case. That is what you want to avoid in my opinion. Adam From kb1pkl at aim.com Tue Jan 18 23:10:06 2011 From: kb1pkl at aim.com (Corey Richardson) Date: Tue, 18 Jan 2011 23:10:06 -0500 Subject: Tkinter: The good, the bad, and the ugly! In-Reply-To: <5c6ff40f-05c1-4e38-89bc-b8c4745db7ce@i18g2000yqn.googlegroups.com> References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <0fa4603c-6e27-4ee5-9761-000a61cd19a4@fx12g2000vbb.googlegroups.com> <2510bf88-1045-411f-9ccd-7ca7c3665454@l24g2000vby.googlegroups.com> <2ef2fa6c-2ccf-453a-8f50-0ef7dbd7834d@j32g2000yqc.googlegroups.com> <5c6ff40f-05c1-4e38-89bc-b8c4745db7ce@i18g2000yqn.googlegroups.com> Message-ID: <4D36641E.4010800@aim.com> On 01/18/2011 10:54 PM, Adam Skutt wrote: > On Jan 18, 9:27 pm, Corey Richardson wrote: >> >> Why would you add in only a part of wxPython, instead of all of it? Is >> the work to cut it down really an advantage over the size of the full >> toolkit? From what I just checked, the source tarball is 40MB. Can that >> much really be added to the Python stdlib? What other alternatives are >> there, besides wxPython, that are perhaps a bit smaller. >> > The source tarball from the wxPython.org website contains a full > version of wxWidgets in addition to the actual wxPython > functionality. A python distribution would certainly contain solely > the latter and require the end user to already have wxWidgets > installed in a suitable fashion. The actual full wxPython binding is > ~100 MiB uncompressed, ~15 MiB compressed BZIP2, but it also includes > a lot of stuff that could possibly be removed and/or reduced, like > full documentation, examples, etc. It can be shrunk even further by > taking a dependency on swig and regenerating the bindings at compile > time (they're shipped prebuilt). At which point, it's pretty damn > small. Not as small as all of the Tk functionality, I think, but well > under 10MiB compressed. > > The problem to me isn't the size (though some might find it > objectionable), but the system dependencies you have to take: > wxWidgets requires GTK+ on UNIX, which requires a whole mess of crap > in term, plus swig, plus whatever else I may or may not be missing. > I'm also not 100% certain as to whether it's as portable as Tk is > today. > > At any rate, if the size is an issue, culling widgets is a lot of an > effort for not much of a gain, especially when you look at the bigger > picture of, "Every file I have to download to build python from > scratch" Minimizing what's in the Python distribution does not change > the size of the dependency set one bit, and that dwarfs the python > code in any case. That is what you want to avoid in my opinion. > > Adam That is a pretty large dependency to rely on, and it is rather undesirable IMO. ~Corey From rantingrick at gmail.com Tue Jan 18 23:15:41 2011 From: rantingrick at gmail.com (rantingrick) Date: Tue, 18 Jan 2011 20:15:41 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <0fa4603c-6e27-4ee5-9761-000a61cd19a4@fx12g2000vbb.googlegroups.com> <2510bf88-1045-411f-9ccd-7ca7c3665454@l24g2000vby.googlegroups.com> <2ef2fa6c-2ccf-453a-8f50-0ef7dbd7834d@j32g2000yqc.googlegroups.com> <5c6ff40f-05c1-4e38-89bc-b8c4745db7ce@i18g2000yqn.googlegroups.com> Message-ID: <34c3bae6-369f-427c-a28f-90ac53dea8f5@v17g2000vbo.googlegroups.com> On Jan 18, 10:10?pm, Corey Richardson wrote: > That is a pretty large dependency to rely on, and it is rather > undesirable IMO. And what exactly is undesirable? Unless you actually back up your statements with fact they just ring hallow. Can you offer any specific reasons why wx is a bad choice. And more importantly can you offer any viable alternatives? From kb1pkl at aim.com Tue Jan 18 23:35:26 2011 From: kb1pkl at aim.com (Corey Richardson) Date: Tue, 18 Jan 2011 23:35:26 -0500 Subject: Tkinter: The good, the bad, and the ugly! In-Reply-To: <34c3bae6-369f-427c-a28f-90ac53dea8f5@v17g2000vbo.googlegroups.com> References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <0fa4603c-6e27-4ee5-9761-000a61cd19a4@fx12g2000vbb.googlegroups.com> <2510bf88-1045-411f-9ccd-7ca7c3665454@l24g2000vby.googlegroups.com> <2ef2fa6c-2ccf-453a-8f50-0ef7dbd7834d@j32g2000yqc.googlegroups.com> <5c6ff40f-05c1-4e38-89bc-b8c4745db7ce@i18g2000yqn.googlegroups.com> <34c3bae6-369f-427c-a28f-90ac53dea8f5@v17g2000vbo.googlegroups.com> Message-ID: <4D366A0E.1050903@aim.com> On 01/18/2011 11:15 PM, rantingrick wrote: > On Jan 18, 10:10 pm, Corey Richardson wrote: > >> That is a pretty large dependency to rely on, and it is rather >> undesirable IMO. > > And what exactly is undesirable? Unless you actually back up your > statements with fact they just ring hallow. Can you offer any specific > reasons why wx is a bad choice. And more importantly can you offer any > viable alternatives? Go ahead and read Adam's fine post about the dependencies of wxwidgets. As for alternatives? I think Tkinter is fine for most of my purposes. When I need something else, I use PyQt. I can install python-minimal on Windows/Linux/What-have-you and know that Tkinter will run without needing GTK+ and SWIG, as Adam mentioned. If you want to get something done, here's an idea - do it yourself. That's what OS is all about. Don't just write something, implement it. If the folks over in python-dev want nothing to do with it, that's fine - make a package using your minimal wxpython version, I'm sure people will use it, especially if you make it as easy to use as Tkinter. I'm done with this thread. I inserted my 12 cents. Have a nice day, and good luck with your ventures. ~Corey From rantingrick at gmail.com Tue Jan 18 23:45:25 2011 From: rantingrick at gmail.com (rantingrick) Date: Tue, 18 Jan 2011 20:45:25 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <0fa4603c-6e27-4ee5-9761-000a61cd19a4@fx12g2000vbb.googlegroups.com> <2510bf88-1045-411f-9ccd-7ca7c3665454@l24g2000vby.googlegroups.com> <2ef2fa6c-2ccf-453a-8f50-0ef7dbd7834d@j32g2000yqc.googlegroups.com> <5c6ff40f-05c1-4e38-89bc-b8c4745db7ce@i18g2000yqn.googlegroups.com> <34c3bae6-369f-427c-a28f-90ac53dea8f5@v17g2000vbo.googlegroups.com> Message-ID: On Jan 18, 10:35?pm, Corey Richardson wrote: > I'm done with this thread. I inserted my 12 cents. Have a nice day, and > good luck with your ventures. Bye From rantingrick at gmail.com Wed Jan 19 00:32:59 2011 From: rantingrick at gmail.com (rantingrick) Date: Tue, 18 Jan 2011 21:32:59 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <0fa4603c-6e27-4ee5-9761-000a61cd19a4@fx12g2000vbb.googlegroups.com> <2510bf88-1045-411f-9ccd-7ca7c3665454@l24g2000vby.googlegroups.com> <2ef2fa6c-2ccf-453a-8f50-0ef7dbd7834d@j32g2000yqc.googlegroups.com> <5c6ff40f-05c1-4e38-89bc-b8c4745db7ce@i18g2000yqn.googlegroups.com> Message-ID: <9a036db2-9f32-441f-aa0f-698ac22fb152@e20g2000vbn.googlegroups.com> On Jan 18, 9:54?pm, Adam Skutt wrote: > On Jan 18, 9:27?pm, Corey Richardson wrote: >?At which point, it's pretty damn > small. ?Not as small as all of the Tk functionality, I think, but well > under 10MiB compressed. Yea but look at all your gaining. I would rather sacrifice a few megs for the rich functionality and scalability any day. > The problem to me isn't the size (though some might find it > objectionable), but the system dependencies you have to take: > wxWidgets requires GTK+ on UNIX UNIX? are you kidding? Even if these dependancies are needed the "UNIX" folks are damn capable of finding and installing them with great ease. Besides most ship with this out the box already! We are not talking about the lemmings who use windows or even the weekend linuxers here. If they are using UNIX then there is no need for "hand holding". > , which requires a whole mess of crap > in term, plus swig, plus whatever else I may or may not be missing. Thats quite an exaggeration Adam. > I'm also not 100% certain as to whether it's as portable as Tk is > today. Wx is just as portable as Tk From rantingrick at gmail.com Wed Jan 19 00:49:16 2011 From: rantingrick at gmail.com (rantingrick) Date: Tue, 18 Jan 2011 21:49:16 -0800 (PST) Subject: newby qn about functions References: Message-ID: On Jan 18, 12:01?pm, "Joe Goldthwaite" wrote: > I'm not sure I understand the question completely but maybe the function > below does what you want. > > def lower_case(s): > > ? ? return ?Testing Functions-lower case: ? + s.lower() > > print lower_case(?AbCdEfG?) > > ________________________________________ > From: python-list-bounces+joe=goldthwaites.... at python.org > [mailto:python-list-bounces+joe=goldthwaites.... at python.org] On Behalf Of > Cathy James > Sent: Tuesday, January 18, 2011 3:02 AM > To: python-l... at python.org > Subject: newby qn about functions > > #This has to be very simple, but I don't get it-please help > ? > def > lower_case(s): > ??? #return s > ??? print(s) > ??? #return s.lower() > ??? print(s.lower()) > s= > "Testing?Functions-lower case: " > lower_case(s) > """how can i use a return statement? to write a function that returns the > string "Testing?Functions-lower case: "and the lowercase representation of > its string parameter""" If I uncomment the above, nothing outputs to > console:( > ? > Much appreciation as always. Please don't top post as it gets very confusing to follow especially when you did not follow proper quoting standards by using the preferred quote prefix of ">". Have a look at this wiki article for more information... http://en.wikipedia.org/wiki/Posting_style Thanks From kianseong.low at logisticsconsulting.asia Wed Jan 19 01:02:42 2011 From: kianseong.low at logisticsconsulting.asia (low kian seong) Date: Wed, 19 Jan 2011 14:02:42 +0800 Subject: [rotatingloghandler]: How to read the logs produced ? Message-ID: Dear people, I am currently using concurrentrotatingfilehandler to handle my Python logs. The situation is okay when it's only one log, but when it needs to spill over to the next log (I configured to have 2) say test.log.2 then I see that the output is sort of shared between the first log test.log and test.log.2. Am I supposed to concatenate all the logs together to get my logs back ? Google hasn't brought back any results, so I am wondering is it just me using or reading the resultant logs wrong? Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From debatem1 at gmail.com Wed Jan 19 01:04:17 2011 From: debatem1 at gmail.com (geremy condra) Date: Tue, 18 Jan 2011 22:04:17 -0800 Subject: move to end, in Python 3.2 Really? In-Reply-To: References: <58c17709-d68e-4448-b618-b6f594d0e8c5@t35g2000yqj.googlegroups.com> <125db7fe-036e-47c9-be89-50f05106936f@n2g2000pre.googlegroups.com> Message-ID: On Tue, Jan 18, 2011 at 3:54 PM, rantingrick wrote: > > And were the hell is Steve Holden? Why has he not weighed in on these > (or any) discussions. He (Steve Holden) is second in command to the > entire community. Yet we have yet to hear a peep from this fella. What > gives Steve? > > And if Steve is too busy, who is next in the chain of command? Who is > going to take responsibility for this catastrophe we call c.l.py? Is > there no one is man enough to step up for this community? Are all of > our leaders just sticking their heads in the sand hoping for this to > "solve" itself? There's no chain of command here, genius. It's a mailing list. Geremy Condra From orasnita at gmail.com Wed Jan 19 01:10:28 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Wed, 19 Jan 2011 08:10:28 +0200 Subject: [OT] Python like lanugages [was Re: After C++, what with Python?] References: <86a904f8-05b0-435f-81d6-7450650f1679@glegroupsg2000goo.googlegroups.com><4d329899$0$43988$742ec2ed@news.sonic.net><7x8vylfcvz.fsf@ruckus.brouhaha.com> <4d32c7cf$0$29983$c3e8da3$5496439d@news.astraweb.com><4d35a769$0$2258$a729d347@news.telepac.pt> Message-ID: <503D269987294E7A95D87C488F37BB25@octavian> From: "Tim Harig" > On 2011-01-18, Terry Reedy wrote: >> On 1/18/2011 10:30 AM, Tim Harig wrote: >> >>> Whether or not you actually agree with that economic reality is >>> irrelevant. Those who fund commerical projects do; and, any >>> developement >>> tool which violates the security of the source is going to find itself >>> climbing an uphill battle in trying to gain market penetration with >>> commericial software producers. >> >> Of course. When I submit or commit patches, I am doing it mostly for >> hobby, educational, and scientific users, and maybe website makers (who >> make site I can visit). If commercial users piggyback on top, ok. I do >> not know how many developers, if any, are after such market penetration. > > You kind of over-extended the intentions of my comment. It does not apply > to open source software in general. I agree that open source authors are > not interested in the quantitative value of market penetration. However, > I > am betting that most authors of developement tools would like to be able > to > use their tools on the job. > > I am sure that more software developers would love to develop using > Python as part of their job. For some this is a reality; but, many more > are stuck using their employer's choice of language. One of the factors > that employers consider, when they choose a language, if they produce > retail software is that the process of compiling will sufficiently > obfiscate their code. > -- True. But aren't the Pyton bytecode-compiled files considered secure enough? Can they be easily decompiled? Octavian From orasnita at gmail.com Wed Jan 19 01:20:40 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Wed, 19 Jan 2011 08:20:40 +0200 Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com><4d337983$0$29983$c3e8da3$5496439d@news.astraweb.com><044a5101-948d-4458-9c94-57dbb3e25f67@m35g2000vbn.googlegroups.com><4d3467bf$0$29983$c3e8da3$5496439d@news.astraweb.com> <4D34B04E.8050309@web.de><4266E8D7BA204BFEA5BF66C635CE1716@octavian><4D35DCE8.5030002@web.de> <4D35DD47.1070304@web.de><7A0C7934E65D4B85A584C06ADD3B6ECF@teddy> <4D360526.7070706@web.de> Message-ID: From: "Alexander Kapps" >> I didn't say that a GUI lib is useless. The GUIS that create >> discrimination by offering access only for some users (when there are >> other GUIS that can offer access to everyone) create damage and they >> should be avoided, and for avoiding them, the beginners need to >> understand this. But Python promotes that bad GUI lib by including it in >> the default package instead of promoting a better lib. > > Please read your previous post. Anyway *which* GUI offers access to > everyone? You are right. There are probably no GUIs that offer access to everyone, no matter the language they speak, their health problems or the platforms they use, but what I want to say is that those GUIS that offer access to as many people as possible are those that should be promoted, not those who discriminate people without even wanting to do this. Octavian From orasnita at gmail.com Wed Jan 19 01:29:49 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Wed, 19 Jan 2011 08:29:49 +0200 Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <0fa4603c-6e27-4ee5-9761-000a61cd19a4@fx12g2000vbb.googlegroups.com> <2510bf88-1045-411f-9ccd-7ca7c3665454@l24g2000vby.googlegroups.com> <2ef2fa6c-2ccf-453a-8f50-0ef7dbd7834d@j32g2000yqc.googlegroups.com> <5c6ff40f-05c1-4e38-89bc-b8c4745db7ce@i18g2000yqn.googlegroups.com> <34c3bae6-369f-427c-a28f-90ac53dea8f5@v17g2000vbo.googlegroups.com> <4D366A0E.1050903@aim.com> Message-ID: <41A6B56828FC467B8CA2703B2A33E920@octavian> From: "Corey Richardson" > On 01/18/2011 11:15 PM, rantingrick wrote: >> On Jan 18, 10:10 pm, Corey Richardson wrote: >> >>> That is a pretty large dependency to rely on, and it is rather >>> undesirable IMO. >> >> And what exactly is undesirable? Unless you actually back up your >> statements with fact they just ring hallow. Can you offer any specific >> reasons why wx is a bad choice. And more importantly can you offer any >> viable alternatives? > > Go ahead and read Adam's fine post about the dependencies of wxwidgets. > As for alternatives? I think Tkinter is fine for most of my purposes. > When I need something else, I use PyQt. I can install python-minimal on > Windows/Linux/What-have-you and know that Tkinter will run without > needing GTK+ and SWIG, as Adam mentioned. If you want to get something > done, here's an idea - do it yourself. That's what OS is all about. > Don't just write something, implement it. If the folks over in > python-dev want nothing to do with it, that's fine - make a package > using your minimal wxpython version, I'm sure people will use it, > especially if you make it as easy to use as Tkinter. I don't think this is what we are talking about on this thread. If any Python programmer wants to use WxPython because it is better than Tkinter, then he/she can use it without any problem. I think we are talking about the GUI lib included in Python, the GUI which is promoted by Python. This GUI should be one which is better from the users' perspective, which is accessible for as many users as possible because the GUI that's promoted by Python is very important for the beginners. If you or someone else wants to create a stripped-down application which doesn't offer so many features then it wouldn't be any problem to get Tkinter and use it, but the beginners shouldn't learn first to use a GUI lib like Tkinter. Octavian From orasnita at gmail.com Wed Jan 19 01:37:02 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Wed, 19 Jan 2011 08:37:02 +0200 Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com><4d337983$0$29983$c3e8da3$5496439d@news.astraweb.com><044a5101-948d-4458-9c94-57dbb3e25f67@m35g2000vbn.googlegroups.com><4d3467bf$0$29983$c3e8da3$5496439d@news.astraweb.com> <4D34B04E.8050309@web.de><4266E8D7BA204BFEA5BF66C635CE1716@octavian><4D35DCE8.5030002@web.de> <4D35DD47.1070304@web.de><7A0C7934E65D4B85A584C06ADD3B6ECF@teddy> Message-ID: <410E9EB9AF154FE6AF31742FD1093E96@octavian> From: "Terry Reedy" > On 1/18/2011 3:23 PM, Octavian Rasnita wrote: > >> I am talking about the fact that Python promotes Tkinter > > Python uses tkinter as the only choice available for the stdlib. > Others choices not in the stdlib are available for those who want > something better. The users shouldn't want something better. Everyone should create GUIs which are accessible for everyone by default, without making any special effort for doing this. The programmers should make special efforts for making GUIS which are not accessible for as many users as possible if they want this but this way shouldn't be promoted by Python. >> TK are not accessible for screen readers, > > I did not know that. Most of the programmers don't know that and they don't even need to know that, but if a lib that create accessible GUIS would be promoted, most of the Python programmers would use that lib and would create good apps by default, without even knowing this. On the other hand, if they started to learn to create a bad GUI, of course that after that they will think that a supplemental effort is necessary for creating good GUIS with another lib and they won't like it. Octavian From mukunda.lohani2 at gmail.com Wed Jan 19 01:38:55 2011 From: mukunda.lohani2 at gmail.com (Mukunda Lohani) Date: Tue, 18 Jan 2011 22:38:55 -0800 (PST) Subject: Standard Abroad Study Programs Message-ID: Don't forget to click on the website:www.abroadstudy4all.weebly.com This website will provide you the most important information about the universal abroad study plan and counseling and the worldwide top universities and colleges. Furthermore, It will also give you the most reliable message about GWC and the right way to join to study abroad. Major Specialties of this Website: Abroad Study as a student Pursuing educational opportunity in another country Top Universities of USA Universities of Europe GWC-Online Job From orasnita at gmail.com Wed Jan 19 01:39:48 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Wed, 19 Jan 2011 08:39:48 +0200 Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com>9-4a9f-b0e7-54bb681a6ea0@l8g2000yqh.googlegrouppppppp<4d337983$0$29983$c3e8da3$5496439d@news.astraweb.com><044a5101-948d-4458-9c94-57dbb3e25f67@m35g2000vbn.googlegroups.com><4d3467bf$0$29983$c3e8da3$5496439d@news.astraweb.com> <4D34B04E.8050309@web.de><4266E8D7BA204BFEA5BF66C635CE1716@octavian><4D35DCE8.5030002@web.de> <495ABC6A7F6C48A1BBCC32F181E5C4F0@teddy> Message-ID: From: "Terry Reedy" > On 1/18/2011 3:29 PM, Octavian Rasnita wrote: > >> Is there any other solution for the problem that Python promotes this >> bad GUI than removing it from the default package? > > I am generally for better accessibility, but I consider the notion that if > everyone cannot have something, then no one should, to be rather > pernicious. Of course. I have the same opinion. But if using WxPython everyone can have access and that's why I think it should be promoted. wxWIDGETS lib is not perfect but it is much better for more categories of users... Octavian From timr at probo.com Wed Jan 19 02:21:14 2011 From: timr at probo.com (Tim Roberts) Date: Tue, 18 Jan 2011 23:21:14 -0800 Subject: UTF-8 question from Dive into Python 3 References: Message-ID: Tim Harig wrote: >On 2011-01-17, carlo wrote: > >> 2- If that were true, can you point me to some documentation about the >> math that, as Mark says, demonstrates this? > >It is true because UTF-8 is essentially an 8 bit encoding that resorts >to the next bit once it exhausts the addressible space of the current >byte it moves to the next one. Since the bytes are accessed and assessed >sequentially, they must be in big-endian order. You were doing excellently up to that last phrase. Endianness only applies when you treat a series of bytes as a larger entity. That doesn't apply to UTF-8. None of the bytes is more "significant" than any other, so by definition it is neither big-endian or little-endian. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From clp2 at rebertia.com Wed Jan 19 02:25:04 2011 From: clp2 at rebertia.com (Chris Rebert) Date: Tue, 18 Jan 2011 23:25:04 -0800 Subject: [rotatingloghandler]: How to read the logs produced ? In-Reply-To: References: Message-ID: On Tue, Jan 18, 2011 at 10:02 PM, low kian seong wrote: > Dear people, > I am currently using concurrentrotatingfilehandler to handle my Python logs. > The situation is okay when it's only one log, but when it needs to spill > over to the next log (I configured to have 2) say test.log.2 then I see that > the output is sort of shared between the first log test.log and test.log.2. > Am I supposed to concatenate all the logs together to get my logs back ? > Google hasn't brought back any results, so I am wondering is it just me > using or reading the resultant logs wrong? Since this is apparently a 3rd-party library (http://pypi.python.org/pypi/ConcurrentLogHandler/ ), have you tried asking the maintainer? (Who is evidently Lowell Alleman .) Could very well be a bug. Cheers, Chris -- http://blog.rebertia.com From kianseong.low at lcalink.com Wed Jan 19 02:27:43 2011 From: kianseong.low at lcalink.com (Low Kian Seong) Date: Wed, 19 Jan 2011 15:27:43 +0800 Subject: [rotatingloghandler]: How to read the logs produced ? In-Reply-To: References: Message-ID: <091CCA9C-13DC-4235-8456-749B2E6269E7@lcalink.com> (iphone) On Jan 19, 2011, at 3:25 PM, Chris Rebert wrote: > On Tue, Jan 18, 2011 at 10:02 PM, low kian seong > wrote: >> Dear people, >> I am currently using concurrentrotatingfilehandler to handle my Python logs. >> The situation is okay when it's only one log, but when it needs to spill >> over to the next log (I configured to have 2) say test.log.2 then I see that >> the output is sort of shared between the first log test.log and test.log.2. >> Am I supposed to concatenate all the logs together to get my logs back ? >> Google hasn't brought back any results, so I am wondering is it just me >> using or reading the resultant logs wrong? > > Since this is apparently a 3rd-party library > (http://pypi.python.org/pypi/ConcurrentLogHandler/ ), have you tried > asking the maintainer? (Who is evidently Lowell Alleman at_sign gmail period com>.) Could very well be a bug. > > Cheers, > Chris Actually the default concurrent log handler produces similar results. > -- > http://blog.rebertia.com From sliwinski at red-sky.pl Wed Jan 19 02:31:17 2011 From: sliwinski at red-sky.pl (=?ISO-8859-2?Q?Grzegorz_=A6liwi=F1ski?=) Date: Tue, 18 Jan 2011 23:31:17 -0800 (PST) Subject: Python unicode utf-8 characters and MySQL unicode utf-8 characters References: <1914ba89-7ecc-43d5-8fbc-9a45f27ae8c8@z5g2000yqb.googlegroups.com> Message-ID: On 18 Sty, 18:15, Kushal Kumaran wrote: > 2011/1/18 Grzegorz ?liwi?ski : > > > Hello, > > Recently I tried to insert some unicode object in utf-8 encoding into > > MySQL using MySQLdb, and got MySQL warnings on characters like: > > ???? i found somewhere in my data. I can't even read them. MySQL > > seems to cut the whole string after that characters off, so I get > > incomplete data. > > After a little bit of digging I found out, that MySQL usually supports > > utf-8 data but encoded into maximum three bytes. That's why I think it > > would help I f I was able to replace all larger unicode characters > > with replacement characters. > > > Is there any way, I could adjust python unicode utf-8 encoded strings > > to be accepted by mysql utf-8 columns? > > Did you pass the charset argument when creating your MySQLdb connection? > > -- > regards, > kushal Hello, yes, although I usually just use SET NAMES utf8; after encountering the problem first, I tried the charset option as well, but there's no difference. From clp2 at rebertia.com Wed Jan 19 02:45:36 2011 From: clp2 at rebertia.com (Chris Rebert) Date: Tue, 18 Jan 2011 23:45:36 -0800 Subject: [rotatingloghandler]: How to read the logs produced ? In-Reply-To: <091CCA9C-13DC-4235-8456-749B2E6269E7@lcalink.com> References: <091CCA9C-13DC-4235-8456-749B2E6269E7@lcalink.com> Message-ID: On Tue, Jan 18, 2011 at 11:27 PM, Low Kian Seong wrote: > On Jan 19, 2011, at 3:25 PM, Chris Rebert wrote: >> On Tue, Jan 18, 2011 at 10:02 PM, low kian seong >> wrote: >>> Dear people, >>> I am currently using concurrentrotatingfilehandler to handle my Python logs. >>> The situation is okay when it's only one log, but when it needs to spill >>> over to the next log (I configured to have 2) say test.log.2 then I see that >>> the output is sort of shared between the first log test.log and test.log.2. >>> Am I supposed to concatenate all the logs together to get my logs back ? >>> Google hasn't brought back any results, so I am wondering is it just me >>> using or reading the resultant logs wrong? >> >> Since this is apparently a 3rd-party library >> (http://pypi.python.org/pypi/ConcurrentLogHandler/ ), have you tried >> asking the maintainer? (Who is evidently Lowell Alleman > at_sign gmail period com>.) Could very well be a bug. >> > Actually the default concurrent log handler produces similar results. That wouldn't be particularly surprising: "15.7.10. Logging to a single file from multiple processes Although logging is thread-safe, and logging to a single file from multiple threads in a single process is supported, logging to a single file from multiple processes is **not** supported [...]" -- http://docs.python.org/library/logging.html Cheers, Chris From michael.ricordeau at gmail.com Wed Jan 19 03:06:58 2011 From: michael.ricordeau at gmail.com (Michael Ricordeau) Date: Wed, 19 Jan 2011 09:06:58 +0100 Subject: [rotatingloghandler]: How to read the logs produced ? In-Reply-To: References: <091CCA9C-13DC-4235-8456-749B2E6269E7@lcalink.com> Message-ID: <20110119090658.678f8bb6@moriz.interne> I suggest SyslogHandler in logging package to centralize all logs . http://docs.python.org/library/logging.html#sysloghandler In my opinion, rotating, parsing, filtering logs is a different task (for a sysadmin not a developper). I'm doing this for all my projects at work : - using SyslogHandler for logging application servers - using one syslog server to get all logs from application servers Le Tue, 18 Jan 2011 23:45:36 -0800, Chris Rebert a ?crit : > On Tue, Jan 18, 2011 at 11:27 PM, Low Kian Seong > wrote: > > On Jan 19, 2011, at 3:25 PM, Chris Rebert wrote: > >> On Tue, Jan 18, 2011 at 10:02 PM, low kian seong > >> wrote: > >>> Dear people, > >>> I am currently using concurrentrotatingfilehandler to handle my Python logs. > >>> The situation is okay when it's only one log, but when it needs to spill > >>> over to the next log (I configured to have 2) say test.log.2 then I see that > >>> the output is sort of shared between the first log test.log and test.log.2. > >>> Am I supposed to concatenate all the logs together to get my logs back ? > >>> Google hasn't brought back any results, so I am wondering is it just me > >>> using or reading the resultant logs wrong? > >> > >> Since this is apparently a 3rd-party library > >> (http://pypi.python.org/pypi/ConcurrentLogHandler/ ), have you tried > >> asking the maintainer? (Who is evidently Lowell Alleman >> at_sign gmail period com>.) Could very well be a bug. > >> > > Actually the default concurrent log handler produces similar results. > > That wouldn't be particularly surprising: > > "15.7.10. Logging to a single file from multiple processes > > Although logging is thread-safe, and logging to a single file from > multiple threads in a single process is supported, logging to a single > file from multiple processes is **not** supported [...]" > -- http://docs.python.org/library/logging.html > > Cheers, > Chris From stefan_ml at behnel.de Wed Jan 19 03:21:38 2011 From: stefan_ml at behnel.de (Stefan Behnel) Date: Wed, 19 Jan 2011 09:21:38 +0100 Subject: [OT] Python like lanugages [was Re: After C++, what with Python?] In-Reply-To: <503D269987294E7A95D87C488F37BB25@octavian> References: <86a904f8-05b0-435f-81d6-7450650f1679@glegroupsg2000goo.googlegroups.com><4d329899$0$43988$742ec2ed@news.sonic.net><7x8vylfcvz.fsf@ruckus.brouhaha.com> <4d32c7cf$0$29983$c3e8da3$5496439d@news.astraweb.com><4d35a769$0$2258$a729d347@news.telepac.pt> <503D269987294E7A95D87C488F37BB25@octavian> Message-ID: Octavian Rasnita, 19.01.2011 07:10: > aren't the Pyton bytecode-compiled files considered secure enough? > Can they be easily decompiled? Yes. Stefan From okopnik at gmail.com Wed Jan 19 03:30:43 2011 From: okopnik at gmail.com (=?UTF-8?B?SOKCgjAucHk=?=) Date: Wed, 19 Jan 2011 00:30:43 -0800 (PST) Subject: __pycache__, one more good reason to stck with Python 2? References: <23e02e0d-b2f1-4b52-85ea-d1feba99dd37@22g2000prx.googlegroups.com> <4d3466d3$0$29983$c3e8da3$5496439d@news.astraweb.com> <0c62aacd-e6d2-4778-81d6-e06924192add@j1g2000vbl.googlegroups.com> <77ef8068-7f07-404f-8b0e-c039d1122659@e16g2000pri.googlegroups.com> Message-ID: <69fa24fc-b3de-4099-a99c-7fd6be50ba64@d8g2000yqf.googlegroups.com> On Jan 18, 4:04?am, Peter Otten <__pete... at web.de> wrote: > > What's the advantage of 'find ... | xargs ...' over 'find ... -exec ...'? Portability. Running the '-exec' version will work fine in a directory with a relatively small number of files, but will fail on a large one. 'xargs', which is designed to handle exactly that situations, splits the returned output into chunks that can be handled by 'rm' and such. '|xargs' is always the preferred option when you don't know how large the output is going to be. From orasnita at gmail.com Wed Jan 19 05:31:27 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Wed, 19 Jan 2011 12:31:27 +0200 Subject: [OT] Python like lanugages [was Re: After C++, what with Python?] References: <86a904f8-05b0-435f-81d6-7450650f1679@glegroupsg2000goo.googlegroups.com><4d329899$0$43988$742ec2ed@news.sonic.net><7x8vylfcvz.fsf@ruckus.brouhaha.com> <4d32c7cf$0$29983$c3e8da3$5496439d@news.astraweb.com><4d35a769$0$2258$a729d347@news.telepac.pt> <503D269987294E7A95D87C488F37BB25@octavian> Message-ID: <828053EDBB174148B9895ADD5B9A0780@octavian> From: "Stefan Behnel" > Octavian Rasnita, 19.01.2011 07:10: >> aren't the Pyton bytecode-compiled files considered secure enough? >> Can they be easily decompiled? > > Yes. > > Stefan > Would it be hard to introduce the possibility of adding encryption of the bytecode similar to what the Zend encoder does for PHP or Filter::Crypto for Perl? Octavian From stefan_ml at behnel.de Wed Jan 19 05:41:16 2011 From: stefan_ml at behnel.de (Stefan Behnel) Date: Wed, 19 Jan 2011 11:41:16 +0100 Subject: [OT] Python like lanugages [was Re: After C++, what with Python?] In-Reply-To: <828053EDBB174148B9895ADD5B9A0780@octavian> References: <86a904f8-05b0-435f-81d6-7450650f1679@glegroupsg2000goo.googlegroups.com><4d329899$0$43988$742ec2ed@news.sonic.net><7x8vylfcvz.fsf@ruckus.brouhaha.com> <4d32c7cf$0$29983$c3e8da3$5496439d@news.astraweb.com><4d35a769$0$2258$a729d347@news.telepac.pt> <503D269987294E7A95D87C488F37BB25@octavian> <828053EDBB174148B9895ADD5B9A0780@octavian> Message-ID: Octavian Rasnita, 19.01.2011 11:31: > From: "Stefan Behnel" >> Octavian Rasnita, 19.01.2011 07:10: >>> aren't the Pyton bytecode-compiled files considered secure enough? >>> Can they be easily decompiled? >> >> Yes. FYI, just take a look at the 'dis' module. There are also decompilers available. IIRC, one is called "decompyle". > Would it be hard to introduce the possibility of adding encryption of the > bytecode similar to what the Zend encoder does for PHP or Filter::Crypto > for Perl? You can use an import hook to do anything you like. That includes decrypting a file and extracting a normal .pyc from it that can then be imported. However, that won't prevent users from inspecting the code at runtime if they get a handle at it (which they likely will if they try). Stefan From usernet at ilthio.net Wed Jan 19 06:34:53 2011 From: usernet at ilthio.net (Tim Harig) Date: Wed, 19 Jan 2011 11:34:53 +0000 (UTC) Subject: UTF-8 question from Dive into Python 3 References: Message-ID: On 2011-01-19, Tim Roberts wrote: > Tim Harig wrote: >>On 2011-01-17, carlo wrote: >> >>> 2- If that were true, can you point me to some documentation about the >>> math that, as Mark says, demonstrates this? >> >>It is true because UTF-8 is essentially an 8 bit encoding that resorts >>to the next bit once it exhausts the addressible space of the current >>byte it moves to the next one. Since the bytes are accessed and assessed >>sequentially, they must be in big-endian order. > > You were doing excellently up to that last phrase. Endianness only applies > when you treat a series of bytes as a larger entity. That doesn't apply to > UTF-8. None of the bytes is more "significant" than any other, so by > definition it is neither big-endian or little-endian. It depends how you process it and it doesn't generally make much difference in Python. Accessing UTF-8 data from C can be much trickier if you use a multibyte type to store the data. In that case, if happen to be on a little-endian architecture, it may be necessary to remember that the data is not in the order that your processor expects it to be for numeric operations and comparisons. That is why the FAQ I linked to says yes to the fact that you can consider UTF-8 to always be in big-endian order. Essentially all byte based data is big-endian. From askutt at gmail.com Wed Jan 19 07:25:59 2011 From: askutt at gmail.com (Adam Skutt) Date: Wed, 19 Jan 2011 04:25:59 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com><4d337983$0$29983$c3e8da3$5496439d@news.astraweb.com><044a5101-948d-4458-9c94-57dbb3e25f67@m35g2000vbn.googlegroups.com><4d3467bf$0$29983$c3e8da3$5496439d@news.astraweb.com> <4D34B04E.8050309@web.de><4266E8D7BA204BFEA5BF66C635CE1716@octavian><4D35DCE8.5030002@web.de> <4D35DD47.1070304@web.de> Message-ID: <42924000-3ffb-40f5-9cf8-70a9d767b944@k25g2000vbl.googlegroups.com> On Jan 18, 3:23?pm, "Octavian Rasnita" wrote: > From: "Alexander Kapps" > > > Tkinter causes damage? Very bad damage? What are you talking about? > > I am talking about the fact that Python promotes Tkinter, and many beginners will start using it, and they will start creating applications with it, and they will learn to use it better than WxPython, and they will start believing that Tkinter is better because it is easier to use than WxPython, so they will start convincing others that Tkinter is the best, and they will start finding many reasons that show that Tkinter is better. And after this, they will say that they don't care about the real problems generated by GUIs like Tk. > And a very big problem is that the applications that use Tk/GTK are not accessible for screen readers, so those applications will be just blank for people with visual impairments which need to use a screen reader. If you want functional accessibility support, you're going to have to write it in Python yourself, and get the accessibility manufacturers to support it. All of the cross-platform toolkits have poor to non- existent accessibility support. Accessibility issues aren't going to be fixed by going to a different GUI toolkit in the standard library. The alternative is to fix the accessibility support issues in the underlying library, and Tk is no less amenable to that than wxWidgets. If that's what you want, start coding then. You have a long climb ahead of you. Accessibility will never be a particular good argument for switching toolkits. All of the cross-platform offerings with Python bindings are far too broken to be even remotely interesting. > Why do we like the portable GUIS and don't really like the native interfaces that don't work on other platforms? > Because we want our programs to be usable by as many people as possible. Well, some platforms render the output as sound and Tkinter are not "portable" on those platforms (screen readers). Or we have cross-platform support as a requirement and no desire to develop the GUI interface three times over. Hence the continued popularity of Java GUIs. Adam From askutt at gmail.com Wed Jan 19 07:28:05 2011 From: askutt at gmail.com (Adam Skutt) Date: Wed, 19 Jan 2011 04:28:05 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com><4d337983$0$29983$c3e8da3$5496439d@news.astraweb.com><044a5101-948d-4458-9c94-57dbb3e25f67@m35g2000vbn.googlegroups.com><4d3467bf$0$29983$c3e8da3$5496439d@news.astraweb.com> <4D34B04E.8050309@web.de><4266E8D7BA204BFEA5BF66C635CE1716@octavian><4D35DCE8.5030002@web.de> <4D35DD47.1070304@web.de><7A0C7934E65D4B85A584C06ADD3B6ECF@teddy> Message-ID: On Jan 19, 1:37?am, "Octavian Rasnita" wrote: > > The users shouldn't want something better. Everyone should create GUIs which > are accessible for everyone by default, without making any special effort > for doing this. Accessibility always requires special effort, and I don't see how changing toolkits gets away from this. Adam From askutt at gmail.com Wed Jan 19 07:31:33 2011 From: askutt at gmail.com (Adam Skutt) Date: Wed, 19 Jan 2011 04:31:33 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com><4d337983$0$29983$c3e8da3$5496439d@news.astraweb.com><044a5101-948d-4458-9c94-57dbb3e25f67@m35g2000vbn.googlegroups.com><4d3467bf$0$29983$c3e8da3$5496439d@news.astraweb.com> <4D34B04E.8050309@web.de><4266E8D7BA204BFEA5BF66C635CE1716@octavian><4D35DCE8.5030002@web.de> <4D35DD47.1070304@web.de><7A0C7934E65D4B85A584C06ADD3B6ECF@teddy> Message-ID: On Jan 19, 1:37?am, "Octavian Rasnita" wrote: > > Most of the programmers don't know that and they don't even need to know > that, but if a lib that create accessible GUIS would be promoted, most of > the Python programmers would use that lib and would create good apps by > default, without even knowing this. Have you written an accessible application in any toolkit whatsoever? It is not magic, and it does not happen by default, even when solely using the standard widgets. Adam From solipsis at pitrou.net Wed Jan 19 07:34:56 2011 From: solipsis at pitrou.net (Antoine Pitrou) Date: Wed, 19 Jan 2011 13:34:56 +0100 Subject: UTF-8 question from Dive into Python 3 References: Message-ID: <20110119133456.2389ed94@pitrou.net> On Wed, 19 Jan 2011 11:34:53 +0000 (UTC) Tim Harig wrote: > That is why the FAQ I linked to > says yes to the fact that you can consider UTF-8 to always be in big-endian > order. It certainly doesn't. Read better. > Essentially all byte based data is big-endian. This is pure nonsense. From usernet at ilthio.net Wed Jan 19 09:00:13 2011 From: usernet at ilthio.net (Tim Harig) Date: Wed, 19 Jan 2011 14:00:13 +0000 (UTC) Subject: UTF-8 question from Dive into Python 3 References: Message-ID: Considering you post contained no information or evidence for your negations, I shouldn't even bother responding. I will bite once. Hopefully next time your arguments will contain some pith. On 2011-01-19, Antoine Pitrou wrote: > On Wed, 19 Jan 2011 11:34:53 +0000 (UTC) > Tim Harig wrote: >> That is why the FAQ I linked to >> says yes to the fact that you can consider UTF-8 to always be in big-endian >> order. > > It certainly doesn't. Read better. - Q: Can a UTF-8 data stream contain the BOM character (in UTF-8 form)? If - yes, then can I still assume the remaining UTF-8 bytes are in big-endian ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - order? ^^^^^^ - - A: Yes, UTF-8 can contain a BOM. However, it makes no difference as ^^^ - to the endianness of the byte stream. UTF-8 always has the same byte ^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - order. An initial BOM is only used as a signature -- an indication that ^^^^^^ - an otherwise unmarked text file is in UTF-8. Note that some recipients of - UTF-8 encoded data do not expect a BOM. Where UTF-8 is used transparently - in 8-bit environments, the use of a BOM will interfere with any protocol - or file format that expects specific ASCII characters at the beginning, - such as the use of "#!" of at the beginning of Unix shell scripts. The question that was not addressed was whether you can consider UTF-8 to be little endian. I pointed out why you cannot always make that assumption in my previous post. UTF-8 has no apparent endianess if you only store it as a byte stream. It does however have a byte order. If you store it using multibytes (six bytes for all UTF-8 possibilites) , which is useful if you want to have one storage container for each letter as opposed to one for each byte(1), the bytes will still have the same order but you have interrupted its sole existance as a byte stream and have returned it to the underlying multibyte oriented representation. If you attempt any numeric or binary operations on what is now a multibyte sequence, the processor will interpret the data using its own endian rules. If your processor is big-endian, then you don't have any problems. The processor will interpret the data in the order that it is stored. If your processor is little endian, then it will effectively change the order of the bytes for its own evaluation. So, you can always assume a big-endian and things will work out correctly while you cannot always make the same assumption as little endian without potential issues. The same holds true for any byte stream data. That is why I say that byte streams are essentially big endian. It is all a matter of how you look at it. I prefer to look at all data as endian even if it doesn't create endian issues because it forces me to consider any endian issues that might arise. If none do, I haven't really lost anything. If you simply assume that any byte sequence cannot have endian issues you ignore the possibility that such issues might not arise. When an issue like the above does, you end up with a potential bug. (1) For unicode it is probably better to convert to characters to UTF-32/UCS-4 for internal processing; but, creating a container large enough to hold any length of UTF-8 character will work. From mark at markroseman.com Wed Jan 19 09:32:45 2011 From: mark at markroseman.com (Mark Roseman) Date: Wed, 19 Jan 2011 07:32:45 -0700 Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <4d337983$0$29983$c3e8da3$5496439d@news.astraweb.com> <044a5101-948d-4458-9c94-57dbb3e25f67@m35g2000vbn.googlegroups.com> <4d3467bf$0$29983$c3e8da3$5496439d@news.astraweb.com> <4D34B04E.8050309@web.de> <4266E8D7BA204BFEA5BF66C635CE1716@octavian> <4D35DCE8.5030002@web.de> Message-ID: Octavian, Thank you for clearly articulating your concern that Tk does not provide any support for screen readers. While I believe that people can have legitimate differences of opinion as to whether this merits its removal/replacement from stdlib, there is no question that this is a serious and significant limitation of Tk. I will attempt to find out if there has been any work done in this area with Tk, and what it would take to address this important issue. Thanks again Mark From solipsis at pitrou.net Wed Jan 19 09:41:00 2011 From: solipsis at pitrou.net (Antoine Pitrou) Date: Wed, 19 Jan 2011 15:41:00 +0100 Subject: UTF-8 question from Dive into Python 3 References: Message-ID: <20110119154100.2f3bbdda@pitrou.net> On Wed, 19 Jan 2011 14:00:13 +0000 (UTC) Tim Harig wrote: > > - Q: Can a UTF-8 data stream contain the BOM character (in UTF-8 form)? If > - yes, then can I still assume the remaining UTF-8 bytes are in big-endian > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ > - order? > ^^^^^^ > - > - A: Yes, UTF-8 can contain a BOM. However, it makes no difference as > ^^^ > - to the endianness of the byte stream. UTF-8 always has the same byte > ^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ > - order. > ^^^^^^ Which certainly doesn't mean that byte order can be called "big endian" for any recognized definition of the latter. Similarly, ASCII test has its own order which certainly can't be characterized as either "little endian" or "big endian". > UTF-8 has no apparent endianess if you only store it as a byte stream. > It does however have a byte order. If you store it using multibytes > (six bytes for all UTF-8 possibilites) , which is useful if you want > to have one storage container for each letter as opposed to one for > each byte(1) That's a ridiculous proposition. Why would you waste so much space? UTF-8 exists *precisely* so that you can save space with most scripts. If you are ready to use 4+ bytes per character, just use UTF-32 which has much nicer properties. Bottom line: you are not describing UTF-8, only your own foolish interpretation of it. UTF-8 does not have any endianness since it is a byte stream and does not care about "machine words". Antoine. From steve+comp.lang.python at pearwood.info Wed Jan 19 09:42:14 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 19 Jan 2011 14:42:14 GMT Subject: __pycache__, one more good reason to stck with Python 2? References: <23e02e0d-b2f1-4b52-85ea-d1feba99dd37@22g2000prx.googlegroups.com> <4d3466d3$0$29983$c3e8da3$5496439d@news.astraweb.com> <0c62aacd-e6d2-4778-81d6-e06924192add@j1g2000vbl.googlegroups.com> <87vd1m6ezq.fsf@benfinney.id.au> <992b11a0-d35d-4b08-98ab-d08c90a86ec7@j1g2000vbl.googlegroups.com> Message-ID: <4d36f846$0$29983$c3e8da3$5496439d@news.astraweb.com> On Tue, 18 Jan 2011 00:58:14 -0800, jmfauth wrote: > It is now practically impossible to launch a Python application via a > .pyc file. When has that ever been possible? .pyc files are Python byte-code. You can't run them directly using Python (except via the import machinery), you can't run them as a script, they're not machine code. Unless you write a wrapper to import the file as a module, you can't directly execute .pyc files. > (For the fun, try to add the "parent directory" of a cached > file to the sys.path). I don't understand what you're getting at there. > About the caches, I'am just fearing, they will become finally garbage > collectors of orphan .pyc files, Python has seed/seeded(?). The .pyc > files may not be very pleasant, but at least you can use them and you > have that "feeling" of their existence. I my "computer experience", once > you start to cache/hide something for simplicity, the problems start. I will say that in general I'm not very happy with what seems like every second application creating huge disk caches in random locations. It's a PITA, and I wish they'd standardize on a single cache location, to make it easy to exclude them from backups, to sanitize the bred-crumbs and data trails applications leave, and so forth. But having said that, the __pycache__ idea isn't too bad. If you have this directory structure: ./module.py ./module.pyc and import module, the top-level .pyc file will continue to be used. If you delete module.py, leaving only the top-level .pyc, it will still continue to be used. That much hasn't changed. The only difference is if you start with only a .py file: ./module.py and import it, the cached version will be placed into __pycache__ instead. Unlike orphaned .pyc files in the top level, orphaned .pyc in the __pycache__ are considered stale and will be ignored. So they're safe to ignore, and safe to delete, at any time. Nothing is stopping you from moving the .pyc file into the top level and deleting the .py file, if you so desire. -- Steven From python at bdurham.com Wed Jan 19 09:53:40 2011 From: python at bdurham.com (python at bdurham.com) Date: Wed, 19 Jan 2011 09:53:40 -0500 Subject: Screen readers for Tkinter (was Re: Tkinter: The good, the bad, and the ugly!) In-Reply-To: References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com><4d337983$0$29983$c3e8da3$5496439d@news.astraweb.com><044a5101-948d-4458-9c94-57dbb3e25f67@m35g2000vbn.googlegroups.com><4d3467bf$0$29983$c3e8da3$5496439d@news.astraweb.com> <4D34B04E.8050309@web.de><4266E8D7BA204BFEA5BF66C635CE1716@octavian><4D35DCE8.5030002@web.de> Message-ID: <1295448820.26438.1416115629@webmail.messagingengine.com> Mark/Octavian, It sounds like Tka11y (spelled with the digit '1' vs. the letter 'L') addresses this problem for Linux users. According to its website, adding accessability support is as simple as changing one import statement. Details follow my signature. Malcolm Tka11y - Tk Accessibility http://tkinter.unpythonic.net/wiki/Tka11y Note: Currently, accessibility is only available via ATK <=> AT-SPI on Linux. Sorry, no Windows MSAA support. Download http://pypi.python.org/pypi/Tka11y A modification to Tkinter to make widgets visible to the AT-SPI layer so that tools like dogtail and Accerciser can see them. Tka11y uses Papi, the Python Accessibility Programming Interface, which in turn uses ATK, the GNOME Accessibility Toolkit, to expose Tkinter widgets to AT-SPI, the Assistive Technologies Service Provider Interface. This allows a Tkinter application's widgets to be viewed and/or controlled by a variety of assistive technologies such as Orca and Accerciser, and automated GUI testing tools such as dogtail and LDTP. These client tools usually use either cspi (C) or pyatspi (Python). Typical usage: import Tka11y as Tkinter or from Tka11y import * From solipsis at pitrou.net Wed Jan 19 10:00:20 2011 From: solipsis at pitrou.net (Antoine Pitrou) Date: Wed, 19 Jan 2011 16:00:20 +0100 Subject: __pycache__, one more good reason to stck with Python 2? References: <23e02e0d-b2f1-4b52-85ea-d1feba99dd37@22g2000prx.googlegroups.com> <4d3466d3$0$29983$c3e8da3$5496439d@news.astraweb.com> <0c62aacd-e6d2-4778-81d6-e06924192add@j1g2000vbl.googlegroups.com> <87vd1m6ezq.fsf@benfinney.id.au> <992b11a0-d35d-4b08-98ab-d08c90a86ec7@j1g2000vbl.googlegroups.com> <4d36f846$0$29983$c3e8da3$5496439d@news.astraweb.com> Message-ID: <20110119160020.36e6975a@pitrou.net> On 19 Jan 2011 14:42:14 GMT Steven D'Aprano wrote: > On Tue, 18 Jan 2011 00:58:14 -0800, jmfauth wrote: > > > It is now practically impossible to launch a Python application via a > > .pyc file. > > > When has that ever been possible? > > > .pyc files are Python byte-code. You can't run them directly using Python > (except via the import machinery), you can't run them as a script, > they're not machine code. Unless you write a wrapper to import the file > as a module, you can't directly execute .pyc files. It seems to work here: $ echo "print 'foo'" > toto.py $ python -m compileall -l . Listing . ... Compiling ./toto.py ... $ rm toto.py $ python toto.pyc foo But it still works under 3.2 even though the incantation is less pretty: $ echo "import sys; print(sys.version)" > toto.py $ __svn__/python -m compileall -l . Listing . ... Compiling ./toto.py ... $ rm toto.py $ __svn__/python __pycache__/toto.cpython-32.pyc 3.2rc1+ (py3k:88095M, Jan 18 2011, 17:12:15) [GCC 4.4.3] Regards Antoine. From askutt at gmail.com Wed Jan 19 10:11:51 2011 From: askutt at gmail.com (Adam Skutt) Date: Wed, 19 Jan 2011 07:11:51 -0800 (PST) Subject: UTF-8 question from Dive into Python 3 References: Message-ID: On Jan 19, 9:00?am, Tim Harig wrote: > > So, you can always assume a big-endian and things will work out correctly > while you cannot always make the same assumption as little endian > without potential issues. ?The same holds true for any byte stream data. You need to spend some serious time programming a serial port or other byte/bit-stream oriented interface, and then you'll realize the folly of your statement. > That is why I say that byte streams are essentially big endian. It is > all a matter of how you look at it. It is nothing of the sort. Some byte streams are in fact, little endian: when the bytes are combined into larger objects, the least- significant byte in the object comes first. A lot of industrial/ embedded stuff has byte streams with LSB leading in the sequence, CAN comes to mind as an example. The only way to know is for the standard describing the stream to tell you what to do. > > I prefer to look at all data as endian even if it doesn't create > endian issues because it forces me to consider any endian issues that > might arise. ?If none do, I haven't really lost anything. ? > If you simply assume that any byte sequence cannot have endian issues you ignore the > possibility that such issues might not arise. No, you must assume nothing unless you're told how to combine the bytes within a sequence into a larger element. Plus, not all byte streams support such operations! Some byte streams really are just a sequence of bytes and the bytes within the stream cannot be meaningfully combined into larger data types. If I give you a series of 8-bit (so 1 byte) samples from an analog-to-digital converter, tell me how to combine them into a 16, 32, or 64-bit integer. You cannot do it without altering the meaning of the samples; it is a completely non-nonsensical operation. Adam From invalid at invalid.invalid Wed Jan 19 10:18:14 2011 From: invalid at invalid.invalid (Grant Edwards) Date: Wed, 19 Jan 2011 15:18:14 +0000 (UTC) Subject: move to end, in Python 3.2 Really? References: <58c17709-d68e-4448-b618-b6f594d0e8c5@t35g2000yqj.googlegroups.com> <125db7fe-036e-47c9-be89-50f05106936f@n2g2000pre.googlegroups.com> Message-ID: On 2011-01-19, geremy condra wrote: > On Tue, Jan 18, 2011 at 3:54 PM, rantingrick wrote: >> >> And were the hell is Steve Holden? Why has he not weighed in on these >> (or any) discussions. He (Steve Holden) is second in command to the >> entire community. Yet we have yet to hear a peep from this fella. What >> gives Steve? >> >> And if Steve is too busy, who is next in the chain of command? Who is >> going to take responsibility for this catastrophe we call c.l.py? Is >> there no one is man enough to step up for this community? Are all of >> our leaders just sticking their heads in the sand hoping for this to >> "solve" itself? > > There's no chain of command here, genius. It's a mailing list. And an unmoderated Usenet newsgroup (which has even less of a chain of command than a mailing list). -- Grant Edwards grant.b.edwards Yow! I hope something GOOD at came in the mail today so gmail.com I have a REASON to live!! From orasnita at gmail.com Wed Jan 19 10:41:41 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Wed, 19 Jan 2011 17:41:41 +0200 Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com><4d337983$0$29983$c3e8da3$5496439d@news.astraweb.com><044a5101-948d-4458-9c94-57dbb3e25f67@m35g2000vbn.googlegroups.com><4d3467bf$0$29983$c3e8da3$5496439d@news.astraweb.com><4D34B04E.8050309@web.de><4266E8D7BA204BFEA5BF66C635CE1716@octavian><4D35DCE8.5030002@web.de><4D35DD47.1070304@web.de> <42924000-3ffb-40f5-9cf8-70a9d767b944@k25g2000vbl.googlegroups.com> Message-ID: <7760D30AEB9545969E0BD603874A6A6A@teddy> From: "Adam Skutt" On Jan 18, 3:23 pm, "Octavian Rasnita" wrote: > From: "Alexander Kapps" > > > Tkinter causes damage? Very bad damage? What are you talking about? > > I am talking about the fact that Python promotes Tkinter, and many beginners will start using it, and they will start creating applications with it, and they will learn to use it better than WxPython, and they will start believing that Tkinter is better because it is easier to use than WxPython, so they will start convincing others that Tkinter is the best, and they will start finding many reasons that show that Tkinter is better. And after this, they will say that they don't care about the real problems generated by GUIs like Tk. > And a very big problem is that the applications that use Tk/GTK are not accessible for screen readers, so those applications will be just blank for people with visual impairments which need to use a screen reader. > If you want functional accessibility support, you're going to have to > write it in Python yourself, and get the accessibility manufacturers > to support it. All of the cross-platform toolkits have poor to non- > existent accessibility support. Accessibility issues aren't going to > be fixed by going to a different GUI toolkit in the standard library. Not true. WxPython uses wxWIDGETS which uses the default OS widgets which usually offer the accessibility features. (At least under Windows, but most users that need accessibility use Windows anyway). > The alternative is to fix the accessibility support issues in the > underlying library, and Tk is no less amenable to that than > wxWidgets. If that's what you want, start coding then. You have a > long climb ahead of you. The underlying libraries for Windows offer the necessary accessibility and WxPython uses it, but Tkinter uses Tk not those libraries. > Accessibility will never be a particular good argument for switching > toolkits. All of the cross-platform offerings with Python bindings > are far too broken to be even remotely interesting. WxPython is not perfect but most of the objects it offers are accessible so this is not true. Only Tk and GTK are bad. > Why do we like the portable GUIS and don't really like the native interfaces that don't work on other platforms? > Because we want our programs to be usable by as many people as possible. Well, some platforms render the output as sound and Tkinter are not "portable" on those platforms (screen readers). > Or we have cross-platform support as a requirement and no desire to > develop the GUI interface three times over. Hence the continued > popularity of Java GUIs. Java GUIS are accessible. Maybe that's the reason. SWT offers the same kind of accessibility as WxPython and for SWING there is Java Access Bridge. So they are not as accessible as the native Windows GUI objects, but they are accessible, unlike Tk and GTK which are not. Octavian From usernet at ilthio.net Wed Jan 19 10:42:54 2011 From: usernet at ilthio.net (Tim Harig) Date: Wed, 19 Jan 2011 15:42:54 +0000 (UTC) Subject: UTF-8 question from Dive into Python 3 References: Message-ID: On 2011-01-19, Adam Skutt wrote: > On Jan 19, 9:00?am, Tim Harig wrote: >> That is why I say that byte streams are essentially big endian. It is >> all a matter of how you look at it. > > It is nothing of the sort. Some byte streams are in fact, little > endian: when the bytes are combined into larger objects, the least- > significant byte in the object comes first. A lot of industrial/ > embedded stuff has byte streams with LSB leading in the sequence, CAN > comes to mind as an example. You are correct. Point well made. From usernet at ilthio.net Wed Jan 19 11:03:11 2011 From: usernet at ilthio.net (Tim Harig) Date: Wed, 19 Jan 2011 16:03:11 +0000 (UTC) Subject: UTF-8 question from Dive into Python 3 References: Message-ID: On 2011-01-19, Antoine Pitrou wrote: > On Wed, 19 Jan 2011 14:00:13 +0000 (UTC) > Tim Harig wrote: >> UTF-8 has no apparent endianess if you only store it as a byte stream. >> It does however have a byte order. If you store it using multibytes >> (six bytes for all UTF-8 possibilites) , which is useful if you want >> to have one storage container for each letter as opposed to one for >> each byte(1) > > That's a ridiculous proposition. Why would you waste so much space? Space is only one tradeoff. There are many others to consider. I have created data structures with much higher overhead than that because they happen to make the problem easier and significantly faster for the operations that I am performing on the data. For many operations, it is just much faster and simpler to use a single character based container opposed to having to process an entire byte stream to determine individual letters from the bytes or to having adaptive size containers to store the data. > UTF-8 exists *precisely* so that you can save space with most scripts. UTF-8 has many reasons for existing. One of the biggest is that it is compatible for tools that were designed to process ASCII and other 8bit encodings. > If you are ready to use 4+ bytes per character, just use UTF-32 which > has much nicer properties. I already mentioned UTF-32/UCS-4 as a probable alternative; but, I might not want to have to worry about converting the encodings back and forth before and after processing them. That said, and more importantly, many variable length byte streams may not have alternate representations as unicode does. From orasnita at gmail.com Wed Jan 19 11:09:08 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Wed, 19 Jan 2011 18:09:08 +0200 Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com><4d337983$0$29983$c3e8da3$5496439d@news.astraweb.com><044a5101-948d-4458-9c94-57dbb3e25f67@m35g2000vbn.googlegroups.com><4d3467bf$0$29983$c3e8da3$5496439d@news.astraweb.com><4D34B04E.8050309@web.de><4266E8D7BA204BFEA5BF66C635CE1716@octavian><4D35DCE8.5030002@web.de><4D35DD47.1070304@web.de><7A0C7934E65D4B85A584C06ADD3B6ECF@teddy> Message-ID: <28F98C116D2949619D9BC88DF3C0D278@teddy> From: "Adam Skutt" On Jan 19, 1:37 am, "Octavian Rasnita" wrote: > > The users shouldn't want something better. Everyone should create GUIs which > are accessible for everyone by default, without making any special effort > for doing this. > Accessibility always requires special effort, and I don't see how > changing toolkits gets away from this. > > Adam This is the most false thing I ever heard and the most dangerous. The GUIS like wxWIDGETS and SWT (at least under Windows), Win32 GUI, MFC, WindowsForms (.Net), are accessible out of the box and they don't require any effort from the programmer. The programmer doesn't even know that the application will also offer accessibility features. Java SWING is not accessible out of the box, but Sun offers Java Access Bridge, a program which can be installed by the user which needs accessibility, so finally SWING GUIS are also pretty accessible (also without any effort from the programmer). (Which is not the case of Tk, Gtk and QT.) Octavian From orasnita at gmail.com Wed Jan 19 11:14:34 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Wed, 19 Jan 2011 18:14:34 +0200 Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com><4d337983$0$29983$c3e8da3$5496439d@news.astraweb.com><044a5101-948d-4458-9c94-57dbb3e25f67@m35g2000vbn.googlegroups.com><4d3467bf$0$29983$c3e8da3$5496439d@news.astraweb.com><4D34B04E.8050309@web.de><4266E8D7BA204BFEA5BF66C635CE1716@octavian><4D35DCE8.5030002@web.de><4D35DD47.1070304@web.de><7A0C7934E65D4B85A584C06ADD3B6ECF@teddy> Message-ID: From: "Adam Skutt" On Jan 19, 1:37 am, "Octavian Rasnita" wrote: > > Most of the programmers don't know that and they don't even need to know > that, but if a lib that create accessible GUIS would be promoted, most of > the Python programmers would use that lib and would create good apps by > default, without even knowing this. > Have you written an accessible application in any toolkit whatsoever? > It is not magic, and it does not happen by default, even when solely > using the standard widgets. > > Adam Of course I did. Using WxPerl, Win32::GUI Perl module, SWT and DotNet. (And without doing absolutely anything special for making them accessible). But it is very simple to test this. You can download a demo version of JAWS screen reader from www.freedomscientific.com that will run for 40 minutes or so and then you will need to reboot the computer to make it work again. It is the most used and most powerful screen reader. You will be able to see how accessible (or not accessible) are the applications made with any GUI lib. Octavian From orasnita at gmail.com Wed Jan 19 11:18:47 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Wed, 19 Jan 2011 18:18:47 +0200 Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com><4d337983$0$29983$c3e8da3$5496439d@news.astraweb.com><044a5101-948d-4458-9c94-57dbb3e25f67@m35g2000vbn.googlegroups.com><4d3467bf$0$29983$c3e8da3$5496439d@news.astraweb.com> <4D34B04E.8050309@web.de><4266E8D7BA204BFEA5BF66C635CE1716@octavian><4D35DCE8.5030002@web.de> Message-ID: From: "Mark Roseman" > Octavian, > > Thank you for clearly articulating your concern that Tk does not provide > any support for screen readers. > > While I believe that people can have legitimate differences of opinion > as to whether this merits its removal/replacement from stdlib, there is > no question that this is a serious and significant limitation of Tk. > > I will attempt to find out if there has been any work done in this area > with Tk, and what it would take to address this important issue. > > Thanks again > Mark Thank you Mark. I don't have anything against Tk, Gtk or QT or other GUI libs, but I just shown why some interfaces are much better than others, for very important reasons, which unfortunately can't be seen, so many programmers don't know about them and promote the discrimination without wanting to do that. Octavian From orasnita at gmail.com Wed Jan 19 11:27:12 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Wed, 19 Jan 2011 18:27:12 +0200 Subject: Screen readers for Tkinter (was Re: Tkinter: The good, the bad, and the ugly!) References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com><4d337983$0$29983$c3e8da3$5496439d@news.astraweb.com><044a5101-948d-4458-9c94-57dbb3e25f67@m35g2000vbn.googlegroups.com><4d3467bf$0$29983$c3e8da3$5496439d@news.astraweb.com><4D34B04E.8050309@web.de><4266E8D7BA204BFEA5BF66C635CE1716@octavian><4D35DCE8.5030002@web.de> <1295448820.26438.1416115629@webmail.messagingengine.com> Message-ID: <5296E6FB68964C239A84C2AF4007D2DD@teddy> From: > Mark/Octavian, > > It sounds like Tka11y (spelled with the digit '1' vs. the letter 'L') > addresses this problem for Linux users. > > According to its website, adding accessability support is as simple as > changing one import statement. > > Details follow my signature. > > Malcolm > > > Tka11y - Tk Accessibility > http://tkinter.unpythonic.net/wiki/Tka11y > > > Note: Currently, accessibility is only available via ATK <=> AT-SPI on > Linux. Sorry, no Windows MSAA support. This project is good, a step ahead, but in order to be really useful it should be the one provided by the default Python package. And of course, it should also offer support for Windows, since most of the computer users use Windows, especially those who need accessibility features. Octavian From solipsis at pitrou.net Wed Jan 19 11:27:25 2011 From: solipsis at pitrou.net (Antoine Pitrou) Date: Wed, 19 Jan 2011 17:27:25 +0100 Subject: UTF-8 question from Dive into Python 3 References: Message-ID: <20110119172725.203ea1c2@pitrou.net> On Wed, 19 Jan 2011 16:03:11 +0000 (UTC) Tim Harig wrote: > > For many operations, it is just much faster and simpler to use a single > character based container opposed to having to process an entire byte > stream to determine individual letters from the bytes or to having > adaptive size containers to store the data. You *have* to "process the entire byte stream" in order to determine boundaries of individual letters from the bytes if you want to use a "character based container", regardless of the exact representation. Once you do that it shouldn't be very costly to compute the actual code points. So, "much faster" sounds a bit dubious to me; especially if you factor in the cost of memory allocation, and the fact that a larger container will fit less easily in a data cache. > That said, and more importantly, many > variable length byte streams may not have alternate representations as > unicode does. This whole thread is about UTF-8 (see title) so I'm not sure what kind of relevance this is supposed to have. From wxjmfauth at gmail.com Wed Jan 19 11:30:12 2011 From: wxjmfauth at gmail.com (jmfauth) Date: Wed, 19 Jan 2011 08:30:12 -0800 (PST) Subject: __pycache__, one more good reason to stck with Python 2? References: <23e02e0d-b2f1-4b52-85ea-d1feba99dd37@22g2000prx.googlegroups.com> <4d3466d3$0$29983$c3e8da3$5496439d@news.astraweb.com> <0c62aacd-e6d2-4778-81d6-e06924192add@j1g2000vbl.googlegroups.com> <87vd1m6ezq.fsf@benfinney.id.au> <992b11a0-d35d-4b08-98ab-d08c90a86ec7@j1g2000vbl.googlegroups.com> <4d36f846$0$29983$c3e8da3$5496439d@news.astraweb.com> Message-ID: My "nightmare" was mainly due, because when I read the the "What's new?", I did not understand too much this caching stuff. It's only later, after testing some applications, I really got the surprise to understand it. (Py3.1 and Py3.2 pyc's mixture). Having said this, to tell you the truth. I do really not feel comfortable with it -- two "working directories", a subdir in a working dir containing only a few scripts, filenames, cache multiplications (I would have 1202 caches on my hd now). There are certainly advantages, just wondering if the balance is positive ou negative. Just for the story, I'm already somwehow experencing some funny stuff. My test working dir has already a full bloated cache. You may argue, that's my fault. I may reply: bof, that Python which is doing it...) (As a Windows users, I just wondering how this will impact tools like py2exe or cx_freeze). ----- Antoine Pitrou Yes, I can launch a pyc, when I have a single file. But what happens, if one of your cached .pyc file import a module with a name as defined in the parent directory? The machinery is broken. The parent dir is not in the sys.path. (Unless I'm understanding nothing or I have done a huge mistake in my tests). jmf From askutt at gmail.com Wed Jan 19 11:47:06 2011 From: askutt at gmail.com (Adam Skutt) Date: Wed, 19 Jan 2011 08:47:06 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com><4d337983$0$29983$c3e8da3$5496439d@news.astraweb.com><044a5101-948d-4458-9c94-57dbb3e25f67@m35g2000vbn.googlegroups.com><4d3467bf$0$29983$c3e8da3$5496439d@news.astraweb.com><4D34B04E.8050309@web.de><4266E8D7BA204BFEA5BF66C635CE1716@octavian><4D35DCE8.5030002@web.de><4D35DD47.1070304@web.de> Message-ID: <954d6443-a0c7-49fd-8883-73a767088da0@k9g2000pre.googlegroups.com> On Jan 19, 10:41?am, "Octavian Rasnita" wrote: > > Not true. WxPython uses wxWIDGETS which uses the default OS widgets which usually offer the accessibility features. > (At least under Windows, but most users that need accessibility use Windows anyway). > Right, under Windows, which is a problem. By your line of reasoning, you really should be supporting PySide / PyQt and not wxWidgets, since they at least play at cross-platform support. > > The alternative is to fix the accessibility support issues in the > > underlying library, and Tk is no less amenable to that than > > wxWidgets. ?If that's what you want, start coding then. ?You have a > > long climb ahead of you. > > The underlying libraries for Windows offer the necessary accessibility and WxPython uses it, but Tkinter uses Tk not those libraries. wxWidgets' support is completely inadequate for a true cross-platform system, the developers are aware of this and acknowledge this and believe a rewrite is necessary. Thus, it is currently really in no better state than Tk. > > Or we have cross-platform support as a requirement and no desire to > > develop the GUI interface three times over. ?Hence the continued > > popularity of Java GUIs. > > Java GUIS are accessible. Maybe that's the reason. No, the reason is as I stated, no more, no less. Accessibility doesn't enter into most designs. Adam From askutt at gmail.com Wed Jan 19 11:53:49 2011 From: askutt at gmail.com (Adam Skutt) Date: Wed, 19 Jan 2011 08:53:49 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com><4d337983$0$29983$c3e8da3$5496439d@news.astraweb.com><044a5101-948d-4458-9c94-57dbb3e25f67@m35g2000vbn.googlegroups.com><4d3467bf$0$29983$c3e8da3$5496439d@news.astraweb.com><4D34B04E.8050309@web.de><4266E8D7BA204BFEA5BF66C635CE1716@octavian><4D35DCE8.5030002@web.de><4D35DD47.1070304@web.de><7A0C7934E65D4B85A584C06ADD3B6ECF@teddy> Message-ID: <2edb4353-6dd5-4c46-80ac-4b406ea1637d@k11g2000vbf.googlegroups.com> On Jan 19, 11:09?am, "Octavian Rasnita" wrote: > From: "Adam Skutt" > > Accessibility always requires special effort, and I don't see how > > changing toolkits gets away from this. > > This is the most false thing I ever heard and the most dangerous. O RLY? http://www.wxwidgets.org/docs/technote/wxaccesstips.htm sure looks like there's a whole host of things that I, the application programmer, must do manually to enable an accessible application[1]. I can't just plop down controls and have an accessible application. > The programmer doesn't even know that the application will also offer accessibility features. No, accessibility requires consideration in the design and implementation of the GUIs, in all of those toolkits. It is not transparent, nor can it be transparent. It requires both consideration when laying out the widgets, but also ensuring that the widgets have specific properties set. How many applications have you ever used that had focus order bugs? That's an accessibility issue that requires programmer intervention to get right. Adam [1] That list is not comprehensive by a long shot. From invalid at invalid.invalid Wed Jan 19 12:10:07 2011 From: invalid at invalid.invalid (Grant Edwards) Date: Wed, 19 Jan 2011 17:10:07 +0000 (UTC) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <4d337983$0$29983$c3e8da3$5496439d@news.astraweb.com> <044a5101-948d-4458-9c94-57dbb3e25f67@m35g2000vbn.googlegroups.com> <4d3467bf$0$29983$c3e8da3$5496439d@news.astraweb.com> <4D34B04E.8050309@web.de> <4266E8D7BA204BFEA5BF66C635CE1716@octavian> <4D35DCE8.5030002@web.de> <4D35DD47.1070304@web.de> <42924000-3ffb-40f5-9cf8-70a9d767b944@k25g2000vbl.googlegroups.com> Message-ID: On 2011-01-19, Octavian Rasnita wrote: > From: "Adam Skutt" >> If you want functional accessibility support, you're going to have to >> write it in Python yourself, and get the accessibility manufacturers >> to support it. All of the cross-platform toolkits have poor to non- >> existent accessibility support. Accessibility issues aren't going to >> be fixed by going to a different GUI toolkit in the standard library. > > > Not true. WxPython uses wxWIDGETS which uses the default OS widgets There's no such thing as "default OS widgets" on Linux/Unix/BSD/etc. > which usually offer the accessibility features. (At least under > Windows, but most users that need accessibility use Windows anyway). [...] > WxPython is not perfect but most of the objects it offers are > accessible so this is not true. Only Tk and GTK are bad. On all of my computers, wxPython uses Gtk. There are other choices for wxWidget backends on Linux, but Gtk is by far the most common. IOW, if Gtk is bad, then wxPython is bad. -- Grant Edwards grant.b.edwards Yow! People humiliating at a salami! gmail.com From debatem1 at gmail.com Wed Jan 19 12:17:41 2011 From: debatem1 at gmail.com (geremy condra) Date: Wed, 19 Jan 2011 09:17:41 -0800 Subject: [OT] Python like lanugages [was Re: After C++, what with Python?] In-Reply-To: <828053EDBB174148B9895ADD5B9A0780@octavian> References: <86a904f8-05b0-435f-81d6-7450650f1679@glegroupsg2000goo.googlegroups.com> <4d329899$0$43988$742ec2ed@news.sonic.net> <7x8vylfcvz.fsf@ruckus.brouhaha.com> <4d32c7cf$0$29983$c3e8da3$5496439d@news.astraweb.com> <4d35a769$0$2258$a729d347@news.telepac.pt> <503D269987294E7A95D87C488F37BB25@octavian> <828053EDBB174148B9895ADD5B9A0780@octavian> Message-ID: On Wed, Jan 19, 2011 at 2:31 AM, Octavian Rasnita wrote: > From: "Stefan Behnel" >> >> Octavian Rasnita, 19.01.2011 07:10: >>> >>> aren't the Pyton bytecode-compiled files considered secure enough? >>> Can they be easily decompiled? >> >> Yes. >> >> Stefan >> > > > Would it be hard to introduce the possibility of adding encryption of the > bytecode similar to what the Zend encoder does for PHP or Filter::Crypto for > Perl? > > Octavian The iron law of cryptography: there is no cryptographic solution to a problem in which the attacker and intended recipient are the same person. Schemes like this are at most an annoyance to people willing to reverse engineer your code. Geremy Condra From atagar1 at gmail.com Wed Jan 19 12:40:29 2011 From: atagar1 at gmail.com (Damian Johnson) Date: Wed, 19 Jan 2011 09:40:29 -0800 Subject: Detecting Remaining Thread Message-ID: Hi, I've been trying to track down a familiar concurrency problem without any success: Unhandled exception in thread started by Error in sys.excepthook: Original exception was: I realize that this is due to a background thread still being alive and kicking when the application terminates (ie, a missing join() on a helper thread). However, threading.enumerate() is reporting that nothing except for the main thread is running at that point: 1/19/2011 09:30:41 [INFO] Arm is shutting down. Remaining threads: [<_MainThread(MainThread, started -1217079616)>] What other methods are there for troubleshooting this sort of issue? I've triple checked that my threads are daemons and joined when quitting but I must be missing something... As would be expected of a timing issue, this happens intermittently (1/5 of the time) and goes away if I add a short sleep at the end. Any help would be much appreciated. Thanks! -Damian From sherm.pendley at gmail.com Wed Jan 19 12:47:41 2011 From: sherm.pendley at gmail.com (Sherm Pendley) Date: Wed, 19 Jan 2011 12:47:41 -0500 Subject: __pycache__, one more good reason to stck with Python 2? References: <23e02e0d-b2f1-4b52-85ea-d1feba99dd37@22g2000prx.googlegroups.com> <4d3466d3$0$29983$c3e8da3$5496439d@news.astraweb.com> <0c62aacd-e6d2-4778-81d6-e06924192add@j1g2000vbl.googlegroups.com> <77ef8068-7f07-404f-8b0e-c039d1122659@e16g2000pri.googlegroups.com> <69fa24fc-b3de-4099-a99c-7fd6be50ba64@d8g2000yqf.googlegroups.com> Message-ID: H?0.py writes: > On Jan 18, 4:04?am, Peter Otten <__pete... at web.de> wrote: >> >> What's the advantage of 'find ... | xargs ...' over 'find ... -exec ...'? > > Portability. Running the '-exec' version will work fine in a directory > with a relatively small number of files, but will fail on a large one. How? -exec passes each file name to a separate invocation of the given command - it doesn't build one large command line with multiple args. sherm-- -- Sherm Pendley Cocoa Developer From usernet at ilthio.net Wed Jan 19 13:02:22 2011 From: usernet at ilthio.net (Tim Harig) Date: Wed, 19 Jan 2011 18:02:22 +0000 (UTC) Subject: UTF-8 question from Dive into Python 3 References: Message-ID: On 2011-01-19, Antoine Pitrou wrote: > On Wed, 19 Jan 2011 16:03:11 +0000 (UTC) > Tim Harig wrote: >> >> For many operations, it is just much faster and simpler to use a single >> character based container opposed to having to process an entire byte >> stream to determine individual letters from the bytes or to having >> adaptive size containers to store the data. > > You *have* to "process the entire byte stream" in order to determine > boundaries of individual letters from the bytes if you want to use a > "character based container", regardless of the exact representation. Right, but I only have to do that once. After that, I can directly address any piece of the stream that I choose. If I leave the information as a simple UTF-8 stream, I would have to walk the stream again, I would have to walk through the the first byte of all the characters from the beginning to make sure that I was only counting multibyte characters once until I found the character that I actually wanted. Converting to a fixed byte representation (UTF-32/UCS-4) or separating all of the bytes for each UTF-8 into 6 byte containers both make it possible to simply index the letters by a constant size. You will note that Python does the former. UTF-32/UCS-4 conversion is definitly supperior if you are actually doing any major but it adds the complexity and overhead of requiring the bit twiddling to make the conversions (once in, once again out). Some programs don't really care enough about what the data actually contains to make it worth while. They just want to be able to use the characters as black boxes. > Once you do that it shouldn't be very costly to compute the actual code > points. So, "much faster" sounds a bit dubious to me; especially if you You could I suppose keep a separate list of pointers to each letter so that you could use the pointer list for indexing or keep a list of the character sizes so that you can add them and calculate the variable width index; but, that adds overhead as well. From solipsis at pitrou.net Wed Jan 19 13:03:23 2011 From: solipsis at pitrou.net (Antoine Pitrou) Date: Wed, 19 Jan 2011 19:03:23 +0100 Subject: __pycache__, one more good reason to stck with Python 2? References: <23e02e0d-b2f1-4b52-85ea-d1feba99dd37@22g2000prx.googlegroups.com> <4d3466d3$0$29983$c3e8da3$5496439d@news.astraweb.com> <0c62aacd-e6d2-4778-81d6-e06924192add@j1g2000vbl.googlegroups.com> <87vd1m6ezq.fsf@benfinney.id.au> <992b11a0-d35d-4b08-98ab-d08c90a86ec7@j1g2000vbl.googlegroups.com> <4d36f846$0$29983$c3e8da3$5496439d@news.astraweb.com> Message-ID: <20110119190323.1d23ecfc@pitrou.net> On Wed, 19 Jan 2011 08:30:12 -0800 (PST) jmfauth wrote: > Yes, I can launch a pyc, when I have a single file. > But what happens, if one of your cached .pyc file import > a module with a name as defined in the parent directory? > The machinery is broken. The parent dir is not in the > sys.path. Well, you don't have to launch a pyc file anyway. Put all your code in some (pyc) modules on the standard Python path, and use a clear-text script with some trivial code to invoke a function from the compiled modules. Otherwise you can customize sys.path a little from your script, using __file__ and os.path.dirname. Nothing complicated AFAICT. (by the way, the fact that pyc files are version-specific should discourage any use outside of version-specific directories, e.g. /usr/lib/pythonX.Y/site-packages) Regards Antoine. From patty at cruzio.com Wed Jan 19 13:22:18 2011 From: patty at cruzio.com (patty at cruzio.com) Date: Wed, 19 Jan 2011 10:22:18 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! In-Reply-To: <9a036db2-9f32-441f-aa0f-698ac22fb152@e20g2000vbn.googlegroups.com> References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <0fa4603c-6e27-4ee5-9761-000a61cd19a4@fx12g2000vbb.googlegroups.com> <2510bf88-1045-411f-9ccd-7ca7c3665454@l24g2000vby.googlegroups.com> <2ef2fa6c-2ccf-453a-8f50-0ef7dbd7834d@j32g2000yqc.googlegroups.com> <5c6ff40f-05c1-4e38-89bc-b8c4745db7ce@i18g2000yqn.googlegroups.com> <9a036db2-9f32-441f-aa0f-698ac22fb152@e20g2000vbn.googlegroups.com> Message-ID: > On Jan 18, 9:54?pm, Adam Skutt wrote: >> On Jan 18, 9:27?pm, Corey Richardson wrote: >>?At which point, it's pretty damn >> small. ?Not as small as all of the Tk functionality, I think, but well >> under 10MiB compressed. > > Yea but look at all your gaining. I would rather sacrifice a few megs > for the rich functionality and scalability any day. > > >> The problem to me isn't the size (though some might find it >> objectionable), but the system dependencies you have to take: >> wxWidgets requires GTK+ on UNIX > > UNIX? are you kidding? Even if these dependancies are needed the > "UNIX" folks are damn capable of finding and installing them with > great ease. Besides most ship with this out the box already! We are > not talking about the lemmings who use windows or even the weekend > linuxers here. If they are using UNIX then there is no need for "hand > holding". > >> , which requires a whole mess of crap >> in term, plus swig, plus whatever else I may or may not be missing. > > Thats quite an exaggeration Adam. > >> I'm also not 100% certain as to whether it's as portable as Tk is >> today. > > Wx is just as portable as Tk > -- > http://mail.python.org/mailman/listinfo/python-list > > Now I think I understand a little better where you all are coming from -- I am a Unix person and I guess I expected to have to learn GUI's using whatever is provided for me by default. Which isn't a bad thing. And if I had to add additional software - and learn that - so be it. I am using a Windows XP system and a Windows 7 system presently. Some day I would like to switch out the Windows XP for Unix. Thanks for the link to the Python page about the various packages, that was enlightening. Who or what group is actually in charge of what libraries (and programming commands/methods such as the Python 3.x rewrite of 'print') goes into Python? Is this huge discussion really a few feature requests for additional libraries to be included for Windows programming? And aren't some of these libraries developed by 3rd parties? And how is that handled by the people in charge? Do they have to pay to license it or is this all freely contributed software? Patty From solipsis at pitrou.net Wed Jan 19 13:45:35 2011 From: solipsis at pitrou.net (Antoine Pitrou) Date: Wed, 19 Jan 2011 19:45:35 +0100 Subject: UTF-8 question from Dive into Python 3 References: Message-ID: <20110119194535.6ed1018a@pitrou.net> On Wed, 19 Jan 2011 18:02:22 +0000 (UTC) Tim Harig wrote: > On 2011-01-19, Antoine Pitrou wrote: > > On Wed, 19 Jan 2011 16:03:11 +0000 (UTC) > > Tim Harig wrote: > >> > >> For many operations, it is just much faster and simpler to use a single > >> character based container opposed to having to process an entire byte > >> stream to determine individual letters from the bytes or to having > >> adaptive size containers to store the data. > > > > You *have* to "process the entire byte stream" in order to determine > > boundaries of individual letters from the bytes if you want to use a > > "character based container", regardless of the exact representation. > > Right, but I only have to do that once. You only have to decode once as well. > If I leave the information as a > simple UTF-8 stream, That's not what we are talking about. We are talking about the supposed benefits of your 6-byte representation scheme versus proper decoding into fixed width code points. > UTF-32/UCS-4 conversion is definitly supperior if you are actually > doing any major but it adds the complexity and overhead of requiring > the bit twiddling to make the conversions (once in, once again out). "Bit twiddling" is not something processors are particularly bad at. Actually, modern processors are much better at arithmetic and logic than at recovering from mispredicted branches, which seems to suggest that discovering boundaries probably eats most of the CPU cycles. > Converting to a fixed byte > representation (UTF-32/UCS-4) or separating all of the bytes for each > UTF-8 into 6 byte containers both make it possible to simply index the > letters by a constant size. You will note that Python does the > former. Indeed, Python chose the wise option. Actually, I'd be curious of any real-world software which successfully chose your proposed approach. From wxjmfauth at gmail.com Wed Jan 19 14:12:52 2011 From: wxjmfauth at gmail.com (jmfauth) Date: Wed, 19 Jan 2011 11:12:52 -0800 (PST) Subject: __pycache__, one more good reason to stck with Python 2? References: <23e02e0d-b2f1-4b52-85ea-d1feba99dd37@22g2000prx.googlegroups.com> <4d3466d3$0$29983$c3e8da3$5496439d@news.astraweb.com> <0c62aacd-e6d2-4778-81d6-e06924192add@j1g2000vbl.googlegroups.com> <87vd1m6ezq.fsf@benfinney.id.au> <992b11a0-d35d-4b08-98ab-d08c90a86ec7@j1g2000vbl.googlegroups.com> <4d36f846$0$29983$c3e8da3$5496439d@news.astraweb.com> Message-ID: <83eccf0d-5a7e-4434-b20b-4bcab44fddb1@k42g2000yqa.googlegroups.com> On Jan 19, 7:03?pm, Antoine Pitrou wrote: > On Wed, 19 Jan 2011 08:30:12 -0800 (PST) > > jmfauth wrote: > > Yes, I can launch a pyc, when I have a single file. > > But what happens, if one of your cached .pyc file import > > a module with a name as defined in the parent directory? > > The machinery is broken. The parent dir is not in the > > sys.path. > > Well, you don't have to launch a pyc file anyway. Put all your code in > some (pyc) modules on the standard Python path, and use a clear-text > script with some trivial code to invoke a function from the compiled > modules. That's not the point. I'm toying. And the "behaviour" from now is deeply different from what it was. > Otherwise you can customize sys.path a little from your script, > using __file__ and os.path.dirname. Nothing complicated AFAICT. That's not as simple. You have too prepare the py file in such a way, that it recognizes the path of its ancestor py file. The "home dir" is no more the same. > (by the way, the fact that pyc files are version-specific should > discourage any use outside of version-specific directories, > e.g. /usr/lib/pythonX.Y/site-packages) Here we are. I'm just wondering if all this stuff is not just here in order to satisfy the missmatched Python installation on *x platforms compared to Windows whre each Python version lives cleanely in its isolated space. (Please no os war). jmf compared to From invalid at invalid.invalid Wed Jan 19 14:16:32 2011 From: invalid at invalid.invalid (Grant Edwards) Date: Wed, 19 Jan 2011 19:16:32 +0000 (UTC) Subject: [OT] Python like lanugages [was Re: After C++, what with Python?] References: <86a904f8-05b0-435f-81d6-7450650f1679@glegroupsg2000goo.googlegroups.com> <4d329899$0$43988$742ec2ed@news.sonic.net> <7x8vylfcvz.fsf@ruckus.brouhaha.com> <4d32c7cf$0$29983$c3e8da3$5496439d@news.astraweb.com> <4d35a769$0$2258$a729d347@news.telepac.pt> <503D269987294E7A95D87C488F37BB25@octavian> <828053EDBB174148B9895ADD5B9A0780@octavian> Message-ID: On 2011-01-19, geremy condra wrote: > On Wed, Jan 19, 2011 at 2:31 AM, Octavian Rasnita wrote: >> Would it be hard to introduce the possibility of adding encryption of the >> bytecode similar to what the Zend encoder does for PHP or Filter::Crypto for >> Perl? > > The iron law of cryptography: there is no cryptographic solution to a > problem in which the attacker and intended recipient are the same > person. > > Schemes like this are at most an annoyance to people willing to > reverse engineer your code. And they somehow usually end up being an annoyance to customers who are not trying to reverse engineer your code but are merely trying to use it legally. -- Grant Edwards grant.b.edwards Yow! I'd like MY data-base at JULIENNED and stir-fried! gmail.com From usernet at ilthio.net Wed Jan 19 14:18:49 2011 From: usernet at ilthio.net (Tim Harig) Date: Wed, 19 Jan 2011 19:18:49 +0000 (UTC) Subject: UTF-8 question from Dive into Python 3 References: Message-ID: On 2011-01-19, Antoine Pitrou wrote: > On Wed, 19 Jan 2011 18:02:22 +0000 (UTC) > Tim Harig wrote: >> Converting to a fixed byte >> representation (UTF-32/UCS-4) or separating all of the bytes for each >> UTF-8 into 6 byte containers both make it possible to simply index the >> letters by a constant size. You will note that Python does the >> former. > > Indeed, Python chose the wise option. Actually, I'd be curious of any > real-world software which successfully chose your proposed approach. The point is basically the same. I created an example because it was simpler to follow for demonstration purposes then an actual UTF-8 conversion to any official multibyte format. You obviously have no other purpose then to be contrary, so we ended up following tangents. As soon as you start to convert to a multibyte format the endian issues occur. For UTF-8 on big endian hardware, this is anti-climactic because all of the bits are already stored in proper order. Little endian systems will probably convert to a native native endian format. If you choose to ignore that, that is your perogative. Have a nice day. From pavlovevidence at gmail.com Wed Jan 19 14:30:36 2011 From: pavlovevidence at gmail.com (Carl Banks) Date: Wed, 19 Jan 2011 11:30:36 -0800 (PST) Subject: __pycache__, one more good reason to stck with Python 2? References: <23e02e0d-b2f1-4b52-85ea-d1feba99dd37@22g2000prx.googlegroups.com> <4d3466d3$0$29983$c3e8da3$5496439d@news.astraweb.com> <0c62aacd-e6d2-4778-81d6-e06924192add@j1g2000vbl.googlegroups.com> <87vd1m6ezq.fsf@benfinney.id.au> <992b11a0-d35d-4b08-98ab-d08c90a86ec7@j1g2000vbl.googlegroups.com> <4d36f846$0$29983$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Jan 19, 6:42?am, Steven D'Aprano wrote: > But having said that, the __pycache__ idea isn't too bad. If you have > this directory structure: > > ./module.py > ./module.pyc > > and import module, the top-level .pyc file will continue to be used. Nope. PEP 3147 says it now always uses __pycache__. Carl Banks From debatem1 at gmail.com Wed Jan 19 14:37:44 2011 From: debatem1 at gmail.com (geremy condra) Date: Wed, 19 Jan 2011 11:37:44 -0800 Subject: Tkinter: The good, the bad, and the ugly! In-Reply-To: References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <0fa4603c-6e27-4ee5-9761-000a61cd19a4@fx12g2000vbb.googlegroups.com> <2510bf88-1045-411f-9ccd-7ca7c3665454@l24g2000vby.googlegroups.com> <2ef2fa6c-2ccf-453a-8f50-0ef7dbd7834d@j32g2000yqc.googlegroups.com> <5c6ff40f-05c1-4e38-89bc-b8c4745db7ce@i18g2000yqn.googlegroups.com> <9a036db2-9f32-441f-aa0f-698ac22fb152@e20g2000vbn.googlegroups.com> Message-ID: On Wed, Jan 19, 2011 at 10:22 AM, wrote: > > Now I think I understand a little better where you all are coming from -- > I am a Unix person and I guess I expected to have to learn GUI's using > whatever is provided for me by default. Which isn't a bad thing. ? And if > I had to add additional software - and learn that - so be it. ?I am using > a Windows XP system and a Windows 7 system presently. ?Some day I would > like to switch out the Windows XP for Unix. Just dual boot, it isn't hard. > Thanks for the link to the Python page about the various packages, that > was enlightening. > > Who or what group is actually in charge of what libraries (and programming > commands/methods such as the Python 3.x rewrite of 'print') goes into > Python? Python's developers. There isn't really any other formal structure beyond that. > ?Is this huge discussion really a few feature requests for > additional libraries to be included for Windows programming? No, it's about other operating systems too, but what it comes down to is that rantingrick has been on the warpath about tkinter for a while, and hasn't proposed a particularly viable alternative. The sad thing is that if he weren't so unhinged his proposal would probably fare much better- I know I > ?And aren't some of these libraries developed by 3rd parties? Any library to replace tkinter would come from a third party, yes. >And how is that handled by the people in charge? Again, there aren't really people 'in charge' on this. Whoever wanted to push for this would have to do the legwork to make sure that the library on offer was good enough to win a lot of support from the community, was cross-platform, etc. They'd also have to convince someone with commit privs that it was a great idea, convince the rest of the dev group not to oppose it. After that would come the difficult task of slowly phasing tkinter out, which would involve substantial long-term commitment. In other words, whoever wants to push for this is in for a hard, multi-year slog. Nobody has stepped up to the plate to do any real work towards that goal. > Do they have to pay to license it or is this all freely contributed software? I can't imagine non-free code making it in. Geremy Condra From debatem1 at gmail.com Wed Jan 19 14:40:40 2011 From: debatem1 at gmail.com (geremy condra) Date: Wed, 19 Jan 2011 11:40:40 -0800 Subject: Tkinter: The good, the bad, and the ugly! In-Reply-To: References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <0fa4603c-6e27-4ee5-9761-000a61cd19a4@fx12g2000vbb.googlegroups.com> <2510bf88-1045-411f-9ccd-7ca7c3665454@l24g2000vby.googlegroups.com> <2ef2fa6c-2ccf-453a-8f50-0ef7dbd7834d@j32g2000yqc.googlegroups.com> <5c6ff40f-05c1-4e38-89bc-b8c4745db7ce@i18g2000yqn.googlegroups.com> <9a036db2-9f32-441f-aa0f-698ac22fb152@e20g2000vbn.googlegroups.com> Message-ID: On Wed, Jan 19, 2011 at 11:37 AM, geremy condra wrote: > No, it's about other operating systems too, but what it comes down to > is that rantingrick has been on the warpath about tkinter for a while, > and hasn't proposed a particularly viable alternative. The sad thing > is that if he weren't so unhinged his proposal would probably fare > much better- I know I Sorry for the truncation. I was going to say that I know I would be more supportive of it if he was building support for something instead of tearing everything else down. Geremy Condra From solipsis at pitrou.net Wed Jan 19 14:44:17 2011 From: solipsis at pitrou.net (Antoine Pitrou) Date: Wed, 19 Jan 2011 20:44:17 +0100 Subject: UTF-8 question from Dive into Python 3 References: Message-ID: <20110119204417.3683e10a@pitrou.net> On Wed, 19 Jan 2011 19:18:49 +0000 (UTC) Tim Harig wrote: > On 2011-01-19, Antoine Pitrou wrote: > > On Wed, 19 Jan 2011 18:02:22 +0000 (UTC) > > Tim Harig wrote: > >> Converting to a fixed byte > >> representation (UTF-32/UCS-4) or separating all of the bytes for each > >> UTF-8 into 6 byte containers both make it possible to simply index the > >> letters by a constant size. You will note that Python does the > >> former. > > > > Indeed, Python chose the wise option. Actually, I'd be curious of any > > real-world software which successfully chose your proposed approach. > > The point is basically the same. I created an example because it > was simpler to follow for demonstration purposes then an actual UTF-8 > conversion to any official multibyte format. You obviously have no > other purpose then to be contrary [...] Right. You were the one who jumped in and tried to lecture everyone on how UTF-8 was "big-endian", and now you are abandoning the one esoteric argument you found in support of that. > As soon as you start to convert to a multibyte format the endian issues > occur. Ok. Good luck with your "endian issues" which don't exist. From orasnita at gmail.com Wed Jan 19 15:33:24 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Wed, 19 Jan 2011 22:33:24 +0200 Subject: [OT] Python like lanugages [was Re: After C++, what with Python?] References: <86a904f8-05b0-435f-81d6-7450650f1679@glegroupsg2000goo.googlegroups.com><4d329899$0$43988$742ec2ed@news.sonic.net><7x8vylfcvz.fsf@ruckus.brouhaha.com><4d32c7cf$0$29983$c3e8da3$5496439d@news.astraweb.com><4d35a769$0$2258$a729d347@news.telepac.pt><503D269987294E7A95D87C488F37BB25@octavian><828053EDBB174148B9895ADD5B9A0780@octavian> Message-ID: From: "geremy condra" > On Wed, Jan 19, 2011 at 2:31 AM, Octavian Rasnita wrote: >> From: "Stefan Behnel" >>> >>> Octavian Rasnita, 19.01.2011 07:10: >>>> >>>> aren't the Pyton bytecode-compiled files considered secure enough? >>>> Can they be easily decompiled? >>> >>> Yes. >>> >>> Stefan >>> >> >> >> Would it be hard to introduce the possibility of adding encryption of the >> bytecode similar to what the Zend encoder does for PHP or Filter::Crypto for >> Perl? >> >> Octavian > > The iron law of cryptography: there is no cryptographic solution to a > problem in which the attacker and intended recipient are the same > person. > > Schemes like this are at most an annoyance to people willing to > reverse engineer your code. > > Geremy Condra I don't know how the Python bytecode works... how it is executed. I thought that Python parses the .py file and generates the bytecode that doesn't contain all the necessary information for re-creating the source code. (But that I agree, that might mean real compilation which is not the case...) Octavian From orasnita at gmail.com Wed Jan 19 15:41:04 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Wed, 19 Jan 2011 22:41:04 +0200 Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com><4d337983$0$29983$c3e8da3$5496439d@news.astraweb.com><044a5101-948d-4458-9c94-57dbb3e25f67@m35g2000vbn.googlegroups.com><4d3467bf$0$29983$c3e8da3$5496439d@news.astraweb.com><4D34B04E.8050309@web.de><4266E8D7BA204BFEA5BF66C635CE1716@octavian><4D35DCE8.5030002@web.de><4D35DD47.1070304@web.de> <954d6443-a0c7-49fd-8883-73a767088da0@k9g2000pre.googlegroups.com> Message-ID: <0C06CA2A6C8C417AA94D3D4AEFECF728@teddy> From: "Adam Skutt" > wxWidgets' support is completely inadequate for a true cross-platform > system, the developers are aware of this and acknowledge this and > believe a rewrite is necessary. Thus, it is currently really in no > better state than Tk. It depends on what you mean by a "true cross-platform" system. wxWIDGETS run on more platforms, so it is cross-platform and it is also accessible for more categories of users. Other systems are bad not only because they are not accessible for everyone, but also because they don't use the underlying GUI of the operating system they are used on, so they have a different look and feel. Even the accessibility, the possibility of accessing the GUIs with a keyboard also means look and feel. > > Or we have cross-platform support as a requirement and no desire to > > develop the GUI interface three times over. Hence the continued > > popularity of Java GUIs. > > Java GUIS are accessible. Maybe that's the reason. > No, the reason is as I stated, no more, no less. Accessibility > doesn't enter into most designs. Which are those "most designs"? I've shown you that the most used GUIS are made to be accessible out of the box and all the GUIS should offer these facilities. Octavian From timothy.c.delaney at gmail.com Wed Jan 19 15:43:53 2011 From: timothy.c.delaney at gmail.com (Tim Delaney) Date: Thu, 20 Jan 2011 07:43:53 +1100 Subject: [OT] Python like lanugages [was Re: After C++, what with Python?] In-Reply-To: References: <86a904f8-05b0-435f-81d6-7450650f1679@glegroupsg2000goo.googlegroups.com> <4d329899$0$43988$742ec2ed@news.sonic.net> <7x8vylfcvz.fsf@ruckus.brouhaha.com> <4d32c7cf$0$29983$c3e8da3$5496439d@news.astraweb.com> <4d35a769$0$2258$a729d347@news.telepac.pt> <503D269987294E7A95D87C488F37BB25@octavian> <828053EDBB174148B9895ADD5B9A0780@octavian> Message-ID: On 20 January 2011 06:16, Grant Edwards wrote: > On 2011-01-19, geremy condra wrote: > > On Wed, Jan 19, 2011 at 2:31 AM, Octavian Rasnita > wrote: > > >> Would it be hard to introduce the possibility of adding encryption of > the > >> bytecode similar to what the Zend encoder does for PHP or Filter::Crypto > for > >> Perl? > > > > The iron law of cryptography: there is no cryptographic solution to a > > problem in which the attacker and intended recipient are the same > > person. > > > > Schemes like this are at most an annoyance to people willing to > > reverse engineer your code. > > And they somehow usually end up being an annoyance to customers who > are not trying to reverse engineer your code but are merely trying to > use it legally. Absolutely. If you feel you absolutely *must* obfuscate your object code more than the python bytecode, just put it all into a separate module and compile it with Cython . Then you end up with machine-specific object code which is somewhat harder to reverse engineer for most people (but quite a few people are experts at doing so). As a bonus, Cython might speed it up too. Tim Delaney -------------- next part -------------- An HTML attachment was scrubbed... URL: From patty at cruzio.com Wed Jan 19 15:45:22 2011 From: patty at cruzio.com (Patty) Date: Wed, 19 Jan 2011 12:45:22 -0800 Subject: Tkinter: The good, the bad, and the ugly! References: Message-ID: ----- Original Message ----- From: "geremy condra" To: Cc: "rantingrick" ; Sent: Wednesday, January 19, 2011 11:37 AM Subject: Re: Tkinter: The good, the bad, and the ugly! On Wed, Jan 19, 2011 at 10:22 AM, wrote: > > Now I think I understand a little better where you all are coming from -- > I am a Unix person and I guess I expected to have to learn GUI's using > whatever is provided for me by default. Which isn't a bad thing. And if > I had to add additional software - and learn that - so be it. I am using > a Windows XP system and a Windows 7 system presently. Some day I would > like to switch out the Windows XP for Unix. Just dual boot, it isn't hard. True. I have a Compaq Presario that is so old hardware-wise that I don't think it could handle Unix or Linux. > Thanks for the link to the Python page about the various packages, that > was enlightening. > > Who or what group is actually in charge of what libraries (and programming > commands/methods such as the Python 3.x rewrite of 'print') goes into > Python? Python's developers. There isn't really any other formal structure beyond that. > Is this huge discussion really a few feature requests for > additional libraries to be included for Windows programming? No, it's about other operating systems too, but what it comes down to is that rantingrick has been on the warpath about tkinter for a while, and hasn't proposed a particularly viable alternative. The sad thing is that if he weren't so unhinged his proposal would probably fare much better- I know I > And aren't some of these libraries developed by 3rd parties? Any library to replace tkinter would come from a third party, yes. >And how is that handled by the people in charge? Again, there aren't really people 'in charge' on this. Whoever wanted to push for this would have to do the legwork to make sure that the library on offer was good enough to win a lot of support from the community, was cross-platform, etc. They'd also have to convince someone with commit privs that it was a great idea, convince the rest of the dev group not to oppose it. After that would come the difficult task of slowly phasing tkinter out, which would involve substantial long-term commitment. In other words, whoever wants to push for this is in for a hard, multi-year slog. Nobody has stepped up to the plate to do any real work towards that goal. > Do they have to pay to license it or is this all freely contributed > software? I can't imagine non-free code making it in. Geremy Condra >From my past experience - I think you are right, this is the course of events that would have to happen and yes, it would literally take years. Patty From emile at fenx.com Wed Jan 19 15:50:36 2011 From: emile at fenx.com (Emile van Sebille) Date: Wed, 19 Jan 2011 12:50:36 -0800 Subject: Tkinter: The good, the bad, and the ugly! In-Reply-To: References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <0fa4603c-6e27-4ee5-9761-000a61cd19a4@fx12g2000vbb.googlegroups.com> <2510bf88-1045-411f-9ccd-7ca7c3665454@l24g2000vby.googlegroups.com> <2ef2fa6c-2ccf-453a-8f50-0ef7dbd7834d@j32g2000yqc.googlegroups.com> <5c6ff40f-05c1-4e38-89bc-b8c4745db7ce@i18g2000yqn.googlegroups.com> <9a036db2-9f32-441f-aa0f-698ac22fb152@e20g2000vbn.googlegroups.com> Message-ID: On 1/19/2011 11:37 AM geremy condra said... > On Wed, Jan 19, 2011 at 10:22 AM, wrote: >> And aren't some of these libraries developed by 3rd parties? > > Any library to replace tkinter would come from a third party, yes. > >> And how is that handled by the people in charge? > > Again, there aren't really people 'in charge' on this. Whoever wanted > to push for this would have to do the legwork to make sure that the > library on offer was good enough to win a lot of support from the > community, was cross-platform, etc. They'd also have to convince > someone with commit privs that it was a great idea, convince the rest > of the dev group not to oppose it. ... and that they'd forevermore support it, which is likely to be as much of an obstacle. I suspect that's why even established libraries like PIL, numpy, mxDateTime or win32all never made it into the standard library. Emile From steve+comp.lang.python at pearwood.info Wed Jan 19 16:01:04 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 19 Jan 2011 21:01:04 GMT Subject: __pycache__, one more good reason to stck with Python 2? References: <23e02e0d-b2f1-4b52-85ea-d1feba99dd37@22g2000prx.googlegroups.com> <4d3466d3$0$29983$c3e8da3$5496439d@news.astraweb.com> <0c62aacd-e6d2-4778-81d6-e06924192add@j1g2000vbl.googlegroups.com> <87vd1m6ezq.fsf@benfinney.id.au> <992b11a0-d35d-4b08-98ab-d08c90a86ec7@j1g2000vbl.googlegroups.com> <4d36f846$0$29983$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4d37510f$0$29983$c3e8da3$5496439d@news.astraweb.com> On Wed, 19 Jan 2011 16:00:20 +0100, Antoine Pitrou wrote: >> .pyc files are Python byte-code. You can't run them directly using >> Python (except via the import machinery), you can't run them as a >> script, they're not machine code. Unless you write a wrapper to import >> the file as a module, you can't directly execute .pyc files. > > It seems to work here: [snip incantation] Then I stand corrected, thank you. I know I've seen problems executing .pyc files from the shell in the past... perhaps I was conflating details of something else. Ah, I know! [steve at sylar ~]$ chmod u+x toto.pyc [steve at sylar ~]$ ./toto.pyc : command not found ?? ./toto.pyc: line 2: syntax error near unexpected token `(' ./toto.pyc: line 2: `P7Mc at s dGHdS(tfooN((((s ./ toto.pys' -- Steven From orasnita at gmail.com Wed Jan 19 16:04:10 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Wed, 19 Jan 2011 23:04:10 +0200 Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com><4d337983$0$29983$c3e8da3$5496439d@news.astraweb.com><044a5101-948d-4458-9c94-57dbb3e25f67@m35g2000vbn.googlegroups.com><4d3467bf$0$29983$c3e8da3$5496439d@news.astraweb.com><4D34B04E.8050309@web.de><4266E8D7BA204BFEA5BF66C635CE1716@octavian><4D35DCE8.5030002@web.de><4D35DD47.1070304@web.de><7A0C7934E65D4B85A584C06ADD3B6ECF@teddy> <2edb4353-6dd5-4c46-80ac-4b406ea1637d@k11g2000vbf.googlegroups.com> Message-ID: <852627E6406040D488A14225023CFFE1@teddy> From: "Adam Skutt" On Jan 19, 11:09 am, "Octavian Rasnita" wrote: > From: "Adam Skutt" > > Accessibility always requires special effort, and I don't see how > > changing toolkits gets away from this. > > This is the most false thing I ever heard and the most dangerous. O RLY? http://www.wxwidgets.org/docs/technote/wxaccesstips.htm sure looks like there's a whole host of things that I, the application programmer, must do manually to enable an accessible application[1]. I can't just plop down controls and have an accessible application. Well, to be sincere, I thought that you don't care, or even worse, and I am sorry because I was thinking that way, but I see that you don't understand what accessible means. A GUI can be more or less accessible and the most accessible is the standard Win32 GUI / MFC. wxWIDGETS is not perfect because it has some controls that steal the focus and don't allow moving it to another control by using the tab key, or it has the HTML widget which is not accessible at all, but the most used controls like the buttons, list boxes, list views, text fields, radio buttons, check boxes... are perfectly accessible out of the box. Those rules for creating an accessible application are obvious; like the fact that a button need to contain a text label and not only an image, or that an image needs to have a tooltip defined, or that a radio button needs to have a label attached to it, but all those things can be solved by the programmer and usually the programmer create those text labels. If the programmer doesn't create those labels, the application won't be totally inaccessible. The users will tab around and they will hear that there is a button without name, or a radio button without name, but the user can use the application and by trial and error he/she might learn that the second button does this and the third button does that. But the interfaces created with Tk, Gtk and QT are completely inaccessible. This means that no object confirms that it got the focus, no text field returns the text it contains, and so on. Those applications are like an opened notepad.exe program with an empty file in which you try to tab around to move the cursor, but of course, nothing happends and you can't find any button, or list box in it. In the Tk applications only the menus are accessible but that's the entire accessibility it offers. > The programmer doesn't even know that the application will also offer accessibility features. No, accessibility requires consideration in the design and implementation of the GUIs, in all of those toolkits. It is not transparent, nor can it be transparent. It requires both consideration when laying out the widgets, but also ensuring that the widgets have specific properties set. How many applications have you ever used that had focus order bugs? That's an accessibility issue that requires programmer intervention to get right. Adam Yes, those things should be followed for creating a better app, but what I wanted to say is that no matter if you do those things or not in a Tk, Gtk or QT GUI, they will be useless, because the screen readers can't understand those GUIS even they have text labels, and even if you will see a focus rectangle around buttons. They don't report that those objects have the focus so the screen readers won't speak anything. Octavian From orasnita at gmail.com Wed Jan 19 16:20:33 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Wed, 19 Jan 2011 23:20:33 +0200 Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com><4d337983$0$29983$c3e8da3$5496439d@news.astraweb.com><044a5101-948d-4458-9c94-57dbb3e25f67@m35g2000vbn.googlegroups.com><4d3467bf$0$29983$c3e8da3$5496439d@news.astraweb.com> <4D34B04E.8050309@web.de><4266E8D7BA204BFEA5BF66C635CE1716@octavian> <4D35DCE8.5030002@web.de><4D35DD47.1070304@web.de><42924000-3ffb-40f5-9cf8-70a9d767b944@k25g2000vbl.googlegroups.com> Message-ID: From: "Grant Edwards" > On 2011-01-19, Octavian Rasnita wrote: >> From: "Adam Skutt" > >>> If you want functional accessibility support, you're going to have to >>> write it in Python yourself, and get the accessibility manufacturers >>> to support it. All of the cross-platform toolkits have poor to non- >>> existent accessibility support. Accessibility issues aren't going to >>> be fixed by going to a different GUI toolkit in the standard library. >> >> >> Not true. WxPython uses wxWIDGETS which uses the default OS widgets > > There's no such thing as "default OS widgets" on Linux/Unix/BSD/etc. > >> which usually offer the accessibility features. (At least under >> Windows, but most users that need accessibility use Windows anyway). > > [...] > >> WxPython is not perfect but most of the objects it offers are >> accessible so this is not true. Only Tk and GTK are bad. > > On all of my computers, wxPython uses Gtk. There are other choices > for wxWidget backends on Linux, but Gtk is by far the most common. > IOW, if Gtk is bad, then wxPython is bad. Not true. Gtk is accessible under Linux but it is not accessible under Windows. I am not talking from the perspective of what the GUI creators say, but about the reality. Adobe and Microsoft say that Flash and Silverlight are accessible because they offer accessibility features, but this is practically absolutely unimportant for the users, because the current screen readers don't offer support for them, so they are hard accessible respectively not accessible. I don't know why Gtk is not accessible under Windows but it can be accessed fine under Linux with Orca screen reader. Either it doesn't offer the accessibility features in its Windows version, or it offers the same thing under Windows but the screen readers that work under Windows don't offer support for it. I'd say that Silverlight is pretty new and it is expected that it is not accessible, but Gtk, QT and Tk are old enough but there is no support for them yet. Under Windows there are open source screen readers also, one of them beeing NVDA, which is made in Python, so we are not talking only about commercial programs that might not offer this support because of a commercial interest, however those screen readers don't offer support for those GUIS. Orca, the most used screen reader used under Linux is also made in Python, but under Linux it can access fine the Gtk interface. So I don't know why, but maybe it is hard for the screen reader manufacturers to make them support absolutely all the possible interfaces so they choose to support only the most used GUI under each OS. So the better term would be "the most used GUI type" and not "the default GUI type" for each OS. But I as I said, all these things can be tested using that screen reader I told you about. If you use Windows, and you have an application which is made using QT, Tk or Gtk, you can download JAWS from www.freedomscientific.com, install it and try to see what you hear when you use that application and you will see that you won't hear anything, while in an application that uses wxWIDGETS or standard Win32 GUI or MFC, the most used controls are perfectly accessible. Octavian From steve+comp.lang.python at pearwood.info Wed Jan 19 16:21:29 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 19 Jan 2011 21:21:29 GMT Subject: Tkinter: The good, the bad, and the ugly! References: Message-ID: <4d3755d9$0$29983$c3e8da3$5496439d@news.astraweb.com> On Wed, 19 Jan 2011 12:45:22 -0800, Patty wrote: > On Wed, Jan 19, 2011 at 10:22 AM, wrote: >> >> Now I think I understand a little better where you all are coming from >> -- I am a Unix person and I guess I expected to have to learn GUI's >> using whatever is provided for me by default. Which isn't a bad thing. >> And if I had to add additional software - and learn that - so be it. I >> am using a Windows XP system and a Windows 7 system presently. Some day >> I would like to switch out the Windows XP for Unix. > > Just dual boot, it isn't hard. > > > True. I have a Compaq Presario that is so old hardware-wise that I > don't think it could handle Unix or Linux. I think you have that backwards. You can usually run recent Linux on *much* older and cruftier hardware than will run recent Windows. You may have to forgo using the two heavyweight window managers, Gnome and KDE, in favour of a lightweight window manager, but some people would argue that's a benefit rather than a loss :) Here's an article that might be of interest: http://www.desktoplinux.com/articles/AT6185716632.html -- Steven From rantingrick at gmail.com Wed Jan 19 16:24:07 2011 From: rantingrick at gmail.com (rantingrick) Date: Wed, 19 Jan 2011 13:24:07 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <0fa4603c-6e27-4ee5-9761-000a61cd19a4@fx12g2000vbb.googlegroups.com> <2510bf88-1045-411f-9ccd-7ca7c3665454@l24g2000vby.googlegroups.com> <2ef2fa6c-2ccf-453a-8f50-0ef7dbd7834d@j32g2000yqc.googlegroups.com> <5c6ff40f-05c1-4e38-89bc-b8c4745db7ce@i18g2000yqn.googlegroups.com> <9a036db2-9f32-441f-aa0f-698ac22fb152@e20g2000vbn.googlegroups.com> Message-ID: <889f649f-6c35-4210-bd8d-1bf1a5c255ea@w2g2000yqb.googlegroups.com> On Jan 19, 12:22?pm, pa... at cruzio.com wrote: > Who or what group is actually in charge of what libraries (and programming > commands/methods such as the Python 3.x rewrite of 'print') goes into > Python? ? Well it comes down to "Guido, some Guys, and a mailing list". see this link fro more detail... http://www.python.org/dev/intro/ > Is this huge discussion really a few feature requests for > additional libraries to be included for Windows programming? No, this HUGE discussion is primarily about the worth of Tkinter as our chosen GUI module and whether or not we should replace it. It also contains (and rightly so!) undertones as to the lost vision within this community as a whole. Not to mention the missing cohesiveness to move forward in the correct direction. > ?And aren't > some of these libraries developed by 3rd parties? ? Yes Python has many 3rd party packages available. You should familiarize yourself with both the current stdlib AND the packages list. Both are here... http://pypi.python.org/pypi?:action=index http://docs.python.org/release/3.0.1/modindex.html > And how is that handled > by the people in charge? ?Do they have to pay to license it or is this all > freely contributed software? This statement needs clarification because i cannot decide if you are asking from a Python stdlib perspective or a 3rd party package perspective. In any event Python and the stdlib should be all free and open software. And shame on anyone who releases closed source software! Shame on you greedies! Shame on you! >:( From martin at address-in-sig.invalid Wed Jan 19 16:38:30 2011 From: martin at address-in-sig.invalid (Martin Gregorie) Date: Wed, 19 Jan 2011 21:38:30 +0000 (UTC) Subject: Tkinter: The good, the bad, and the ugly! References: Message-ID: On Wed, 19 Jan 2011 12:45:22 -0800, Patty wrote: > ----- Original Message ----- > From: "geremy condra" To: > On Wed, Jan 19, 2011 at 10:22 AM, wrote: >> >> Now I think I understand a little better where you all are coming from >> -- I am a Unix person and I guess I expected to have to learn GUI's >> using whatever is provided for me by default. Which isn't a bad thing. >> And if I had to add additional software - and learn that - so be it. I >> am using a Windows XP system and a Windows 7 system presently. Some day >> I would like to switch out the Windows XP for Unix. > > Just dual boot, it isn't hard. > IME you'll find that networking a Windows box to an older, slower PC thats rescued from the attic will be much more useful than a single dual-boot arrangement. Linux will run at a usable speed on a PC with 512 MB RAM and an 866 MHz P3, though some things, such as logging in, will be slow with a graphical desktop (runlevel 5), but if it has more RAM or you run an X-server on another PC, which could be running Windows, you'll execute commands, including graphical ones - provided you have X.11 forwarding enabled, a lot faster. The Linux box can also be headless if you haven't a screen and keyboard to spare. In short, Linux will run well on a PC that can't run anything more recent than Win98 at an acceptable speed. It doesn't need a lot of disk either - anything more than 30 GB will do. However, an optical drive is needed for installation. You can install Fedora from a CD drive provided the box is networked so it can retrieve most of its packages over the net, but using a DVD drive would be easier for a first install. > True. I have a Compaq Presario that is so old hardware-wise that I > don't think it could handle Unix or Linux. > What speed and type of CPU does it use? How much RAM? What's about disk and optical drives? FWIW my house server is an IMB Netvista that is at least 10 years old - 866MHz P3, 512 GB RAM, LG DVD drive, new 160GB hdd and runs Fedora 13. It is a bit slow at runlevel 5 (graphical desktop) when driven from its own console, but I usually access it over the house net from a more modern Core Duo laptop that runs Fedora 14. The NetVista is more than adequate for web and RDBMS development (Apache and PostgreSQL) in Python or Java and very fast for C compilation. -- martin@ | Martin Gregorie gregorie. | Essex, UK org | From steve+comp.lang.python at pearwood.info Wed Jan 19 16:43:12 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 19 Jan 2011 21:43:12 GMT Subject: __pycache__, one more good reason to stck with Python 2? References: <23e02e0d-b2f1-4b52-85ea-d1feba99dd37@22g2000prx.googlegroups.com> <4d3466d3$0$29983$c3e8da3$5496439d@news.astraweb.com> <0c62aacd-e6d2-4778-81d6-e06924192add@j1g2000vbl.googlegroups.com> <87vd1m6ezq.fsf@benfinney.id.au> <992b11a0-d35d-4b08-98ab-d08c90a86ec7@j1g2000vbl.googlegroups.com> <4d36f846$0$29983$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4d375af0$0$29983$c3e8da3$5496439d@news.astraweb.com> On Wed, 19 Jan 2011 11:30:36 -0800, Carl Banks wrote: > On Jan 19, 6:42?am, Steven D'Aprano +comp.lang.pyt... at pearwood.info> wrote: >> But having said that, the __pycache__ idea isn't too bad. If you have >> this directory structure: >> >> ./module.py >> ./module.pyc >> >> and import module, the top-level .pyc file will continue to be used. > > Nope. PEP 3147 says it now always uses __pycache__. Looks like the PEP is outdated then. [steve at sylar ~]$ rm __pycache__/* [steve at sylar ~]$ echo "print('spam spam spam')" > spam.py [steve at sylar ~]$ python3.2 -m compileall spam.py Compiling spam.py ... [steve at sylar ~]$ mv __pycache__/spam.cpython-32.pyc ./spam.pyc [steve at sylar ~]$ python3.2 -m spam spam spam spam [steve at sylar ~]$ ls __pycache__/ [steve at sylar ~]$ -- Steven From invalid at invalid.invalid Wed Jan 19 16:51:22 2011 From: invalid at invalid.invalid (Grant Edwards) Date: Wed, 19 Jan 2011 21:51:22 +0000 (UTC) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <4d337983$0$29983$c3e8da3$5496439d@news.astraweb.com> <044a5101-948d-4458-9c94-57dbb3e25f67@m35g2000vbn.googlegroups.com> <4d3467bf$0$29983$c3e8da3$5496439d@news.astraweb.com> <4D34B04E.8050309@web.de> <4266E8D7BA204BFEA5BF66C635CE1716@octavian> <4D35DCE8.5030002@web.de> <4D35DD47.1070304@web.de> <42924000-3ffb-40f5-9cf8-70a9d767b944@k25g2000vbl.googlegroups.com> Message-ID: On 2011-01-19, Octavian Rasnita wrote: > From: "Grant Edwards" > >>> WxPython is not perfect but most of the objects it offers are >>> accessible so this is not true. Only Tk and GTK are bad. >> >> On all of my computers, wxPython uses Gtk. There are other choices >> for wxWidget backends on Linux, but Gtk is by far the most common. >> IOW, if Gtk is bad, then wxPython is bad. > > Not true. I think you're playing a bit fast and loose with your accusations. Which of my statements was "not true"? 1) On all of my computers wxPython uses Gtk. 2) There are other backend choices on Linux besides Gtk. 3) Gtk is by far the most common wxWidgets backend on Linux/Unix. 4) If Gtk is bad then wxPython is bad. Note that 4) follows logically from 3), so to say that 4) is "not true" you have to show that 3) is "not true". -- Grant Edwards grant.b.edwards Yow! WHOA!! Ken and Barbie at are having TOO MUCH FUN!! gmail.com It must be the NEGATIVE IONS!! From tjreedy at udel.edu Wed Jan 19 16:57:40 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Wed, 19 Jan 2011 16:57:40 -0500 Subject: Screen readers for Tkinter (was Re: Tkinter: The good, the bad, and the ugly!) In-Reply-To: <5296E6FB68964C239A84C2AF4007D2DD@teddy> References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com><4d337983$0$29983$c3e8da3$5496439d@news.astraweb.com><044a5101-948d-4458-9c94-57dbb3e25f67@m35g2000vbn.googlegroups.com><4d3467bf$0$29983$c3e8da3$5496439d@news.astraweb.com><4D34B04E.8050309@web.de><4266E8D7BA204BFEA5BF66C635CE1716@octavian><4D35DCE8.5030002@web.de> <1295448820.26438.1416115629@webmail.messagingengine.com> <5296E6FB68964C239A84C2AF4007D2DD@teddy> Message-ID: On 1/19/2011 11:27 AM, Octavian Rasnita wrote: >> Note: Currently, accessibility is only available via ATK<=> AT-SPI on >> Linux. Sorry, no Windows MSAA support. > > > This project is good, a step ahead, but in order to be really useful it should be the one provided by the default Python package. > And of course, it should also offer support for Windows, since most of the computer users use Windows, especially those who need accessibility features. Octavian Please consider adding an 'Accessibility' page to the Python wiki with your info and the above for those interested. -- Terry Jan Reedy From rantingrick at gmail.com Wed Jan 19 17:01:12 2011 From: rantingrick at gmail.com (rantingrick) Date: Wed, 19 Jan 2011 14:01:12 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <4d337983$0$29983$c3e8da3$5496439d@news.astraweb.com> <044a5101-948d-4458-9c94-57dbb3e25f67@m35g2000vbn.googlegroups.com> <4d3467bf$0$29983$c3e8da3$5496439d@news.astraweb.com> <4D34B04E.8050309@web.de> <4266E8D7BA204BFEA5BF66C635CE1716@octavian> <4D35DCE8.5030002@web.de> <4D35DD47.1070304@web.de> <42924000-3ffb-40f5-9cf8-70a9d767b944@k25g2000vbl.googlegroups.com> Message-ID: <2b782e9e-3b9a-4e95-9d4f-ac60b823078d@g25g2000yqn.googlegroups.com> On Jan 19, 3:51?pm, Grant Edwards wrote: > On 2011-01-19, Octavian Rasnita wrote: > Which of my statements was "not true"? > > ?1) On all of my computers wxPython uses Gtk. > > ?2) There are other backend choices on Linux besides Gtk. > > ?3) Gtk is by far the most common wxWidgets backend on Linux/Unix. > > ?4) If Gtk is bad then wxPython is bad. > > Note that 4) follows logically from 3), so to say that 4) is "not > true" you have to show that 3) is "not true". All of these folks that keep blabbing about how they may need "this" dependency or "that" dependency on Linux/Unix either need to shut up or convert to a windows box with a nice installer exe that will hold your wiener while you pee. Really, you're only going to fool the lemmings with such BS arguments! Stop whining, you choose to use an advanced OS and stop blaming the rest of the world because of your choices! From alice at gothcandy.com Wed Jan 19 17:31:15 2011 From: alice at gothcandy.com (=?utf-8?Q?Alice_Bevan=E2=80=93McGregor?=) Date: Wed, 19 Jan 2011 14:31:15 -0800 Subject: __pycache__, one more good reason to stck with Python 2? References: <23e02e0d-b2f1-4b52-85ea-d1feba99dd37@22g2000prx.googlegroups.com> <4d3466d3$0$29983$c3e8da3$5496439d@news.astraweb.com> <0c62aacd-e6d2-4778-81d6-e06924192add@j1g2000vbl.googlegroups.com> <87vd1m6ezq.fsf@benfinney.id.au> <992b11a0-d35d-4b08-98ab-d08c90a86ec7@j1g2000vbl.googlegroups.com> <4d36f846$0$29983$c3e8da3$5496439d@news.astraweb.com> <4d37510f$0$29983$c3e8da3$5496439d@news.astraweb.com> Message-ID: On 2011-01-19 13:01:04 -0800, Steven D'Aprano said: > I know I've seen problems executing .pyc files from the shell in the > past... perhaps I was conflating details of something else. Ah, I know! > > [steve at sylar ~]$ chmod u+x toto.pyc > [steve at sylar ~]$ ./toto.pyc > : command not found ?? > ./toto.pyc: line 2: syntax error near unexpected token `(' > ./toto.pyc: line 2: `P7Mc at s dGHdS(tfooN((((s ./ > toto.pys' ... don't do that. I do not know why that would be expected to work, ever. (Unless you're crafty and wrap a real shell script around the .pyc, in which case it's no longer a .pyc.) ? Alice. From tjreedy at udel.edu Wed Jan 19 17:33:43 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Wed, 19 Jan 2011 17:33:43 -0500 Subject: UTF-8 question from Dive into Python 3 In-Reply-To: References: Message-ID: On 1/19/2011 1:02 PM, Tim Harig wrote: > Right, but I only have to do that once. After that, I can directly address > any piece of the stream that I choose. If I leave the information as a > simple UTF-8 stream, I would have to walk the stream again, I would have to > walk through the the first byte of all the characters from the beginning to > make sure that I was only counting multibyte characters once until I found > the character that I actually wanted. Converting to a fixed byte > representation (UTF-32/UCS-4) or separating all of the bytes for each > UTF-8 into 6 byte containers both make it possible to simply index the > letters by a constant size. You will note that Python does the former. The idea of using a custom fixed-width padded version of a UTF-8 steams waw initially shocking to me, but I can imagine that there are specialized applications, which slice-and-dice uninterpreted segments, for which that is appropriate. However, it is not germane to the folly of prefixing standard UTF-8 steams with a 3-byte magic number, mislabelled a 'byte-order-mark, thus making them non-standard. -- Terry Jan Reedy From tyler at tysdomain.com Wed Jan 19 17:40:18 2011 From: tyler at tysdomain.com (Littlefield, Tyler) Date: Wed, 19 Jan 2011 15:40:18 -0700 Subject: Screen readers for Tkinter (was Re: Tkinter: The good, the bad, and the ugly! Message-ID: <4D376852.6040100@tysdomain.com> >And of course, it should also offer support for Windows, since most of the computer users use Windows, especially those who need accessibility features. uh. no, and no. Plenty of those utilizing screen readers are using macs nowadays, as well as vinux or some derivitave there of. -- Thanks, Ty From askutt at gmail.com Wed Jan 19 17:40:35 2011 From: askutt at gmail.com (Adam Skutt) Date: Wed, 19 Jan 2011 14:40:35 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com><4d337983$0$29983$c3e8da3$5496439d@news.astraweb.com><044a5101-948d-4458-9c94-57dbb3e25f67@m35g2000vbn.googlegroups.com><4d3467bf$0$29983$c3e8da3$5496439d@news.astraweb.com><4D34B04E.8050309@web.de><4266E8D7BA204BFEA5BF66C635CE1716@octavian><4D35DCE8.5030002@web.de><4D35DD47.1070304@web.de><7A0C7934E65D4B85A584C06ADD3B6ECF@teddy> Message-ID: <799d1f10-f2b3-41fb-ade2-d31ff19918e5@t23g2000vby.googlegroups.com> On Jan 19, 4:04?pm, "Octavian Rasnita" wrote: > Those rules for creating an accessible application are obvious; like the fact that a button need to contain a text label and not only an image, or that an image needs to have a tooltip defined, or that a radio button needs to have a label attached to it, but all those things can be solved by the programmer and usually the programmer create those text labels. > The fact that /every/ toolkit provides accessibility guidelines over and above whatever other UI guidelines they provide tells me that creating an accessible application is hardly obvious. Plus, if it were really that simple, the accessibility situation wouldn't be so poor. > Yes, those things should be followed for creating a better app, but what I wanted to say is that no matter if you do those things or not in a Tk, Gtk or QT GUI, they will be useless, because the screen readers can't understand those GUIS even they have text labels, and even if you will see a focus rectangle around buttons. They don't report that those objects have the focus so the screen readers won't speak anything. Your "something is better than nothing" argument isn't particularly compelling to me personally as a justification for ripping out TkInter. And Qt is the only toolkit with some level of functioning accessibility support on all three major platforms, assuming the library and software are built correctly, so again, your argument is really for Qt, not for wxWidgets. Adam From rantingrick at gmail.com Wed Jan 19 18:04:37 2011 From: rantingrick at gmail.com (rantingrick) Date: Wed, 19 Jan 2011 15:04:37 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <0fa4603c-6e27-4ee5-9761-000a61cd19a4@fx12g2000vbb.googlegroups.com> <2510bf88-1045-411f-9ccd-7ca7c3665454@l24g2000vby.googlegroups.com> <2ef2fa6c-2ccf-453a-8f50-0ef7dbd7834d@j32g2000yqc.googlegroups.com> <5c6ff40f-05c1-4e38-89bc-b8c4745db7ce@i18g2000yqn.googlegroups.com> <9a036db2-9f32-441f-aa0f-698ac22fb152@e20g2000vbn.googlegroups.com> Message-ID: <981140f7-79d4-421d-88c1-c819f38a3d49@w2g2000yqb.googlegroups.com> On Wed, Jan 19, 2011 at 1:40 PM, geremy condra wrote: > On Wed, Jan 19, 2011 at 11:37 AM, geremy condra wrote: >> No, it's about other operating systems too, but what it comes down to >> is that rantingrick has been on the warpath about tkinter for a while, >> and hasn't proposed a particularly viable alternative. The sad thing >> is that if he weren't so unhinged his proposal would probably fare >> much better Look, the folks are c.l.py are far too touchy and they really need to lighten up. Really! The fact that my speech style and delivery does not fit some "cookie cutter" pre-directive is just BS. The Python community is NOT a homogeneous block you know, and it should not be! People have said to me in the past..."""Well you could participate at python-dev or python-ideas or the tracker but NOT as ranting rick, you need to use a better name"""... What? What does it matter what my name is anyway. This is just being pedantic!! > Sorry for the truncation. I was going to say that I know I would be > more supportive of it if he was building support for something instead > of tearing everything else down. I am not "tearing down" anything, however that was a nice try Geremy *wink*. The only thing that is being "torn down" is the solid wall of rabid resistance that has been slowly built by this community over many years. We have become too centralized and many folks are being left out of the community decision process. You (and others) act like my only concern is to destroy what has been built (Tkinter) and that is not the case! But like old governments, YOU (the python elite!) have lost all vision for the future. And you've also lost all connection with the people. I am desperately trying to to snap you out of this psychosis before it is too late! Tkinter will be the downfall of Python if we cannot muster the resolve to replace it with something that is current (or more current) technology. Stop fearing change and re-ignite the vision that GvR once had. From rantingrick at gmail.com Wed Jan 19 18:12:15 2011 From: rantingrick at gmail.com (rantingrick) Date: Wed, 19 Jan 2011 15:12:15 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com><4d337983$0$29983$c3e8da3$5496439d@news.astraweb.com><044a5101-948d-4458-9c94-57dbb3e25f67@m35g2000vbn.googlegroups.com><4d3467bf$0$29983$c3e8da3$5496439d@news.astraweb.com><4D34B04E.8050309@web.de><4266E8D7BA204BFEA5BF66C635CE1716@octavian><4D35DCE8.5030002@web.de><4D35DD47.1070304@web.de><7A0C7934E65D4B85A584C06ADD3B6ECF@teddy> Message-ID: On Jan 19, 4:40?pm, Adam Skutt wrote: > On Jan 19, 4:04?pm, "Octavian Rasnita" wrote: > > > Those rules for creating an accessible application are obvious; like the fact that a button need to contain a text label and not only an image, or that an image needs to have a tooltip defined, or that a radio button needs to have a label attached to it, but all those things can be solved by the programmer and usually the programmer create those text labels. > > The fact that /every/ toolkit provides accessibility guidelines over > and above whatever other UI guidelines they provide tells me that > creating an accessible application is hardly obvious. ?Plus, if it > were really that simple, the accessibility situation wouldn't be so > poor. > > > Yes, those things should be followed for creating a better app, but what I wanted to say is that no matter if you do those things or not in a Tk, Gtk or QT GUI, they will be useless, because the screen readers can't understand those GUIS even they have text labels, and even if you will see a focus rectangle around buttons. They don't report that those objects have the focus so the screen readers won't speak anything. > > Your "something is better than nothing" argument isn't particularly > compelling to me personally as a justification for ripping out > TkInter. ?And Qt is the only toolkit with some level of functioning > accessibility support on all three major platforms, assuming the > library and software are built correctly, so again, your argument is > really for Qt, not for wxWidgets. > > Adam Adam, please use the following style when posting to this group...Thanks. On Jan 19, 4:04 pm, "Octavian Rasnita" wrote: > Those rules for creating an accessible application are obvious; like > the fact that a button need to contain a text label and not only an > image, or that an image needs to have a tooltip defined, or that a > radio button needs to have a label attached to it, but all those > things can be solved by the programmer and usually the programmer > create those text labels. The fact that /every/ toolkit provides accessibility guidelines over and above whatever other UI guidelines they provide tells me that creating an accessible application is hardly obvious. Plus, if it were really that simple, the accessibility situation wouldn't be so poor. > Yes, those things should be followed for creating a better app, but > what I wanted to say is that no matter if you do those things or not > in a Tk, Gtk or QT GUI, they will be useless, because the screen > readers can't understand those GUIS even they have text labels, and > even if you will see a focus rectangle around buttons. They don't > report that those objects have the focus so the screen readers won't > speak anything. Your "something is better than nothing" argument isn't particularly compelling to me personally as a justification for ripping out TkInter. And Qt is the only toolkit with some level of functioning accessibility support on all three major platforms, assuming the library and software are built correctly, so again, your argument is really for Qt, not for wxWidgets. Adam From patty at cruzio.com Wed Jan 19 18:16:01 2011 From: patty at cruzio.com (Patty) Date: Wed, 19 Jan 2011 15:16:01 -0800 Subject: Tkinter: The good, the bad, and the ugly! Message-ID: On Jan 19, 12:22 pm, pa... at cruzio.com wrote: > Who or what group is actually in charge of what libraries (and programming > commands/methods such as the Python 3.x rewrite of 'print') goes into > Python? Well it comes down to "Guido, some Guys, and a mailing list". see this link fro more detail... http://www.python.org/dev/intro/ Well that explains Everything! > Is this huge discussion really a few feature requests for > additional libraries to be included for Windows programming? No, this HUGE discussion is primarily about the worth of Tkinter as our chosen GUI module and whether or not we should replace it. It also contains (and rightly so!) undertones as to the lost vision within this community as a whole. Not to mention the missing cohesiveness to move forward in the correct direction. I see why you say this. I think I am playing catchup with what has been going on for some time amongst you all. > And aren't > some of these libraries developed by 3rd parties? Yes Python has many 3rd party packages available. You should familiarize yourself with both the current stdlib AND the packages list. Both are here... http://pypi.python.org/pypi?:action=index http://docs.python.org/release/3.0.1/modindex.html > And how is that handled > by the people in charge? Do they have to pay to license it or is this all > freely contributed software? This statement needs clarification because i cannot decide if you are asking from a Python stdlib perspective or a 3rd party package perspective. In any event Python and the stdlib should be all free and open software. And shame on anyone who releases closed source software! Shame on you greedies! Shame on you! >:( And I am coming from background working at SCO for commercial SCO Unix and also commercial applications software. So free software is not something I am used to :) And understand what is involved with obtaining 3rd party pieces either by necessity or because of an acquistion. And the money part. It was complicated. So I was thinking from the python stdlib perspective. But your comment turned my thinking around to where it should be to discuss open source software. I don't think I am ready for the py-dev mailing list yet ;) But I do have some big ideas because of UCSC (University of California, Santa Cruz) being so close, their Computer Engineering Dept. is Really Good and I have some connections up there..... Patty -- http://mail.python.org/mailman/listinfo/python-list -------------- next part -------------- An HTML attachment was scrubbed... URL: From rantingrick at gmail.com Wed Jan 19 18:21:53 2011 From: rantingrick at gmail.com (rantingrick) Date: Wed, 19 Jan 2011 15:21:53 -0800 (PST) Subject: move to end, in Python 3.2 Really? References: <58c17709-d68e-4448-b618-b6f594d0e8c5@t35g2000yqj.googlegroups.com> <125db7fe-036e-47c9-be89-50f05106936f@n2g2000pre.googlegroups.com> Message-ID: <62f52f79-ab73-4e1d-89b0-e832f50c8807@v17g2000yqv.googlegroups.com> On Jan 19, 9:18?am, Grant Edwards wrote: > And an unmoderated Usenet newsgroup (which has even less of a chain of > command than a mailing list). Moderated status has nothing to do with it. The fact is that the "elite" no longer feel it necessary to care about the troubles of the Python peasants. This is evident by no posting from GvR for many years, and no posting from his subordinate (and the PSF chair!) Steve Holden. The last time Steve and i "rubbed shoulders" was when i chastised him for engaging in trollish behavior. So now i get it... He has time for trolling and flaming but no time for real discussion on topics that concern the very future evolution of this language? hmm. From andre.roberge at gmail.com Wed Jan 19 18:26:10 2011 From: andre.roberge at gmail.com (=?ISO-8859-1?Q?Andr=E9?=) Date: Wed, 19 Jan 2011 15:26:10 -0800 (PST) Subject: move to end, in Python 3.2 Really? In-Reply-To: <62f52f79-ab73-4e1d-89b0-e832f50c8807@v17g2000yqv.googlegroups.com> Message-ID: <88d57c7f-47d1-4961-b0d2-7d3471fc6650@glegroupsg2000goo.googlegroups.com> On Wednesday, January 19, 2011 7:21:53 PM UTC-4, rantingrick wrote: > On Jan 19, 9:18?am, Grant Edwards wrote: > > > And an unmoderated Usenet newsgroup (which has even less of a chain of > > command than a mailing list). > > Moderated status has nothing to do with it. The fact is that the > "elite" no longer feel it necessary to care about the troubles of the > Python peasants. This is evident by no posting from GvR for many > years, and no posting from his subordinate (and the PSF chair!) Steve > Holden. The last time Steve and i "rubbed shoulders" was when i > chastised him for engaging in trollish behavior. So now i get it... He > has time for trolling and flaming but no time for real discussion on > topics that concern the very future evolution of this language? hmm. Perhaps it is because they are either busy programming and/or busy organizing Pycon 2011. Some people do a lot, some people talk/write a lot. It is hard to find the time to do both ... From patty at cruzio.com Wed Jan 19 18:36:18 2011 From: patty at cruzio.com (Patty) Date: Wed, 19 Jan 2011 15:36:18 -0800 Subject: Tkinter: The good, the bad, and the ugly! Message-ID: <1E425CF2D2A449209115BC876FDA3555@mycomputer> On Wed, 19 Jan 2011 12:45:22 -0800, Patty wrote: > ----- Original Message ----- > From: "geremy condra" To: > On Wed, Jan 19, 2011 at 10:22 AM, wrote: >> >> Now I think I understand a little better where you all are coming from >> -- I am a Unix person and I guess I expected to have to learn GUI's >> using whatever is provided for me by default. Which isn't a bad thing. >> And if I had to add additional software - and learn that - so be it. I >> am using a Windows XP system and a Windows 7 system presently. Some day >> I would like to switch out the Windows XP for Unix. > > Just dual boot, it isn't hard. > IME you'll find that networking a Windows box to an older, slower PC thats rescued from the attic will be much more useful than a single dual-boot arrangement. Linux will run at a usable speed on a PC with 512 MB RAM and an 866 MHz P3, though some things, such as logging in, will be slow with a graphical desktop (runlevel 5), but if it has more RAM or you run an X-server on another PC, which could be running Windows, you'll execute commands, including graphical ones - provided you have X.11 forwarding enabled, a lot faster. The Linux box can also be headless if you haven't a screen and keyboard to spare. In short, Linux will run well on a PC that can't run anything more recent than Win98 at an acceptable speed. It doesn't need a lot of disk either - anything more than 30 GB will do. However, an optical drive is needed for installation. You can install Fedora from a CD drive provided the box is networked so it can retrieve most of its packages over the net, but using a DVD drive would be easier for a first install. > True. I have a Compaq Presario that is so old hardware-wise that I > don't think it could handle Unix or Linux. > What speed and type of CPU does it use? How much RAM? What's about disk and optical drives? FWIW my house server is an IMB Netvista that is at least 10 years old - 866MHz P3, 512 GB RAM, LG DVD drive, new 160GB hdd and runs Fedora 13. It is a bit slow at runlevel 5 (graphical desktop) when driven from its own console, but I usually access it over the house net from a more modern Core Duo laptop that runs Fedora 14. The NetVista is more than adequate for web and RDBMS development (Apache and PostgreSQL) in Python or Java and very fast for C compilation. -- martin@ | Martin Gregorie gregorie. | Essex, UK org | -- http://mail.python.org/mailman/listinfo/python-list Martin and Geremy - thank you for the suggestions. My Compaq Presario I know is maxed out on memory and I checked and my Maxtor drive says it is 28624 MB. I don't know if that is enough? I have my HP Mini Netbook running Windows 7 and do my Python programming on it. It is awesome! I don't really care if my Compaq had Windows XP plus Linux or just Linux. I would be happy to just back up what I want and install Linux for the whole Compaq and just have the two communicate. I really use the Compaq more as an email and file archive. I would probably rethink which software programming tools and languages I would want on each machine. I consider myself a C programmer and SQL and I am a linguist - several programming languages - so I would be more likely to want compilers and interpreters, favorite IDEs installed on whichever system. Patty -------------- next part -------------- An HTML attachment was scrubbed... URL: From rantingrick at gmail.com Wed Jan 19 18:42:57 2011 From: rantingrick at gmail.com (rantingrick) Date: Wed, 19 Jan 2011 15:42:57 -0800 (PST) Subject: move to end, in Python 3.2 Really? References: <88d57c7f-47d1-4961-b0d2-7d3471fc6650@glegroupsg2000goo.googlegroups.com> Message-ID: <91b73dea-8ca6-4f27-a300-fb21619dbec0@l17g2000yqe.googlegroups.com> On Jan 19, 5:26?pm, Andr? wrote: > Perhaps it is because they are either busy programming and/or busy > organizing Pycon 2011. Some people do a lot, some people talk/write > a lot. It is hard to find the time to do both ... Well perhaps. I am not suggesting that these people are not working on important issues. I am just pointing out an incident with Steve that could have been better spent on real discussion and not a flame war. Look, i am no perfect person and i do not expect that Steve is either. However attempting to say that somehow my work --engaging the community through lively debate in an attempt to re-energize the Python spirit GvR created so long ago that has now waxed cold-- is somehow less important than Steve's or anyones work is a little condescending to say the least. It takes many stones to build a house. And sometimes after you build the house you find the foundation is cracking. This could be due to poor planning in the design phase (which is not the case with Tkinter!!) OR it could be due to soil that is grown unstable (This is the case with Tkinter!!). Repairing a foundation after the fact is always going to be hard work but someone has do it. Someone has to gather the crew and create a battle plan. Well, thats me. However i cannot do this alone. I need the rest of you guys to share the load. From debatem1 at gmail.com Wed Jan 19 19:01:01 2011 From: debatem1 at gmail.com (geremy condra) Date: Wed, 19 Jan 2011 16:01:01 -0800 Subject: Tkinter: The good, the bad, and the ugly! In-Reply-To: <981140f7-79d4-421d-88c1-c819f38a3d49@w2g2000yqb.googlegroups.com> References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <0fa4603c-6e27-4ee5-9761-000a61cd19a4@fx12g2000vbb.googlegroups.com> <2510bf88-1045-411f-9ccd-7ca7c3665454@l24g2000vby.googlegroups.com> <2ef2fa6c-2ccf-453a-8f50-0ef7dbd7834d@j32g2000yqc.googlegroups.com> <5c6ff40f-05c1-4e38-89bc-b8c4745db7ce@i18g2000yqn.googlegroups.com> <9a036db2-9f32-441f-aa0f-698ac22fb152@e20g2000vbn.googlegroups.com> <981140f7-79d4-421d-88c1-c819f38a3d49@w2g2000yqb.googlegroups.com> Message-ID: On Wed, Jan 19, 2011 at 3:04 PM, rantingrick wrote: > > On Wed, Jan 19, 2011 at 1:40 PM, geremy condra > wrote: >> On Wed, Jan 19, 2011 at 11:37 AM, geremy condra wrote: >>> No, it's about other operating systems too, but what it comes down to >>> is that rantingrick has been on the warpath about tkinter for a while, >>> and hasn't proposed a particularly viable alternative. The sad thing >>> is that if he weren't so unhinged his proposal would probably fare >>> much better > > Look, the folks are c.l.py are far too touchy and they really need to > lighten up. Really! The fact that my speech style and delivery does > not fit some "cookie cutter" pre-directive is just BS. The Python > community is NOT a homogeneous block you know, and it should not be! > People have said to me in the past..."""Well you could participate at > python-dev or python-ideas or the tracker but NOT as ranting rick, you > need to use a better name"""... What? What does it matter what my name > is anyway. This is just being pedantic!! I'm not telling you to change your behavior. I'm telling you that the way you're doing things isn't effective. You can take that advice or not, just as I can decide to listen to you... or not. I also wouldn't advise you to change your name again. I think you've already landed on a couple of spam lists for that. >> Sorry for the truncation. I was going to say that I know I would be >> more supportive of it if he was building support for something instead >> of tearing everything else down. > > I am not "tearing down" anything, however that was a nice try Geremy > *wink*. The only thing that is being "torn down" is the solid wall of > rabid resistance that has been slowly built by this community over > many years. I don't think this is the case, first because you aren't very good at getting anybody to take you seriously and second because I don't think that resistance on this issue is as mindless as you claim. > We have become too centralized and many folks are being > left out of the community decision process. I disagree with the first half. The second I'm more prone to agree with, although I don't have a lot of great ideas about how to solve the problem. You seem to be full of ideas (most of which I think are terrible) but very short on actually getting anything done. Until you begin to remedy that I doubt very many people here will take you as seriously as you seem to want. Also, be careful with where you say 'we'- I certainly don't recognize your authority to speak on behalf of the community, and I suspect that an overwhelming majority of the community's other members feel the same way. > You (and others) act like > my only concern is to destroy what has been built (Tkinter) and that > is not the case! Seems like it from where I'm sitting. YMMV, but I think you would do much better if you focused on the problem of building a system that addressed the concerns others have raised rather than pretending they aren't valid concerns. > But like old governments, YOU (the python elite!) > have lost all vision for the future. Hey, cool, I'm a member of the elite now. You wouldn't happen to know how to list that on a resume, would you? > And you've also lost all > connection with the people. I am desperately trying to to snap you out > of this psychosis before it is too late! Tkinter will be the downfall > of Python if we cannot muster the resolve to replace it with something > that is current (or more current) technology. Citation needed. Geremy Condra From debatem1 at gmail.com Wed Jan 19 19:41:18 2011 From: debatem1 at gmail.com (geremy condra) Date: Wed, 19 Jan 2011 16:41:18 -0800 Subject: move to end, in Python 3.2 Really? In-Reply-To: <91b73dea-8ca6-4f27-a300-fb21619dbec0@l17g2000yqe.googlegroups.com> References: <88d57c7f-47d1-4961-b0d2-7d3471fc6650@glegroupsg2000goo.googlegroups.com> <91b73dea-8ca6-4f27-a300-fb21619dbec0@l17g2000yqe.googlegroups.com> Message-ID: On Wed, Jan 19, 2011 at 3:42 PM, rantingrick wrote: > Look, i am no perfect person and i do not expect that Steve is either. > However attempting to say that somehow my work --engaging the > community through lively debate in an attempt to re-energize the > Python spirit GvR created so long ago that has now waxed cold-- is > somehow less important than Steve's or anyones work is a little > condescending to say the least. Condescending or not, it's true. Geremy Condra From ckaynor at zindagigames.com Wed Jan 19 19:51:23 2011 From: ckaynor at zindagigames.com (Chris Kaynor) Date: Wed, 19 Jan 2011 16:51:23 -0800 Subject: collections.Set Binary Reflected Operations Message-ID: I am implemented a custom set-like type which interacts with some third-party software when retrieving and mutating the set, and have derived my custom type off of collections.MutableSet, however I have noticed that some of the magic methods supported by the built-in set do not fully function with my custom type. From this, I looked over the MutableSet definition in and it seems to be missing all of the reflected operators (__rsub__, __rand__, __ror__, __rxor__, and friends) for the operators it has defined. I can post a simple example case if desired. I am using Python 2.6.4 (with some in-house customizations), however a quick look over the svn repository shown on python.org makes it appear that these are also not implemented in Python 3. I was wondering if there is some reason for this, or if it was merely an oversight. Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: From rantingrick at gmail.com Wed Jan 19 19:53:17 2011 From: rantingrick at gmail.com (rantingrick) Date: Wed, 19 Jan 2011 16:53:17 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <2ef2fa6c-2ccf-453a-8f50-0ef7dbd7834d@j32g2000yqc.googlegroups.com> <5c6ff40f-05c1-4e38-89bc-b8c4745db7ce@i18g2000yqn.googlegroups.com> <9a036db2-9f32-441f-aa0f-698ac22fb152@e20g2000vbn.googlegroups.com> <981140f7-79d4-421d-88c1-c819f38a3d49@w2g2000yqb.googlegroups.com> Message-ID: <0d74f3b6-e534-4762-b5f4-af1187ee3b38@32g2000yqz.googlegroups.com> On Jan 19, 6:01?pm, geremy condra wrote: > I'm not telling you to change your behavior. I'm telling you that the > way you're doing things isn't effective. You can take that advice or > not, just as I can decide to listen to you... or not. > > I also wouldn't advise you to change your name again. I think you've > already landed on a couple of spam lists for that. Yes i know! The whole "name" issue was blown out of proportion. Look i think i should explain how this whole name conundrum started. When i first came to this list you can imagine that i was not prepared to divulge every detail about my identity and personal life (as most should not!). So i choose a cryptic and nonsensical name. Yes, i made it up! And at the time i never had any inclination that i would want to get so involved with this group. Well that was then and this is now... However, after i became "known" within the community many folks started to debase any of my arguments simply on the fact that my name was anonymous. So at that time i started using my real name "Rick Johnson" and my nickname as "rantingrick". After this people then accused my of "identity hopping". Even some of the same folks who previously were complaining about my cryptic first name choice! Now they were complain that i choose to use my REAL name. Ironic eh! So what it boils down to is this... some people on this list just hate me and trying to please them is a waste of time. > > I am not "tearing down" anything, however that was a nice try Geremy > > *wink*. The only thing that is being "torn down" is the solid wall of > > rabid resistance that has been slowly built by this community over > > many years. > > I don't think this is the case, first because you aren't very good at > getting anybody to take you seriously How "self absorbed" must someone be to blame *ME* because *THEY* cannot take *ME* seriously. Is this a joke Geremy? Sadly i know it to be true however because you are not the only person who carries this attitude. > and second because I don't think > that resistance on this issue is as mindless as you claim. i have exposed the baseless, nonsensical, and argumentative stance taken by some in an effort to sway public opinion with FUD and BS. So i would say that arguing with baseless facts does constitute "rabid resistance". What else could it be? > > We have become too centralized and many folks are being > > left out of the community decision process. > > I disagree with the first half. The second I'm more prone to agree > with, although I don't have a lot of great ideas about how to solve > the problem. Well maybe you are not a visionary, however i believe we still need you in other areas. > You seem to be full of ideas (most of which I think are > terrible) but very short on actually getting anything done. Until you > begin to remedy that I doubt very many people here will take you as > seriously as you seem to want. Look, every organization needs workers, visionaries, liaisons, supervisors, etc. I seem to fit nicely into a Visionary role. Maybe that bothers you? I don't know? But we all have our place Geremy. Do you think any organization could survive simply with robotic workers and no guidance? No, and why not? Because workers cannot see the big picture. They are too focused (and rightly so) on some small detail that encompasses their job duty. Only the supervisor/visionary has the luxury of looking at the problem from a global perspective. Think of Python-dev as a car. A car is a machine. A very complicated machine that needs a driver to harness it's power and give it direction and purpose. -- someone who can see "beyond" the horizon. Someone who can read a road map and then re-calculate a path if road construction blocks the current one. Without the car the driver is nothing, and without the driver the car is nothing. But together, they are a force to reckoned with. Well, unless the driver is Asian -- then all bets are off! :-) > Also, be careful with where you say 'we'- I certainly don't recognize > your authority to speak on behalf of the community, and I suspect that > an overwhelming majority of the community's other members feel the > same way. You see! This is the resistance i am talking about. You (and others) don't want to accept me as part of the community. If you did accept me, then my speaking collectively (we) would not be troubling to you. However i do not blame you directly for this prejudice. I think it is more of a sub-conscience undercurrent that pervades this community as a whole. A fear of outsiders. A xenophobia if you will. We need to change this now! From atagar1 at gmail.com Wed Jan 19 22:11:22 2011 From: atagar1 at gmail.com (Damian Johnson) Date: Wed, 19 Jan 2011 19:11:22 -0800 Subject: Detecting Remaining Thread In-Reply-To: References: Message-ID: Disregard, I figured it out. It turns out that the threads spawned by "thread.start_new_thread" are unreported by threading.enumerate. Cheers! -Damian On Wed, Jan 19, 2011 at 9:40 AM, Damian Johnson wrote: > Hi, I've been trying to track down a familiar concurrency problem > without any success: > Unhandled exception in thread started by > Error in sys.excepthook: > > Original exception was: > > I realize that this is due to a background thread still being alive > and kicking when the application terminates (ie, a missing join() on a > helper thread). However, threading.enumerate() is reporting that > nothing except for the main thread is running at that point: > 1/19/2011 09:30:41 [INFO] Arm is shutting down. Remaining threads: > [<_MainThread(MainThread, started -1217079616)>] > > What other methods are there for troubleshooting this sort of issue? > I've triple checked that my threads are daemons and joined when > quitting but I must be missing something... > > As would be expected of a timing issue, this happens intermittently > (1/5 of the time) and goes away if I add a short sleep at the end. Any > help would be much appreciated. Thanks! -Damian > From torriem at gmail.com Wed Jan 19 22:20:47 2011 From: torriem at gmail.com (Michael Torrie) Date: Wed, 19 Jan 2011 20:20:47 -0700 Subject: Tkinter: The good, the bad, and the ugly! In-Reply-To: References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <0fa4603c-6e27-4ee5-9761-000a61cd19a4@fx12g2000vbb.googlegroups.com> <2510bf88-1045-411f-9ccd-7ca7c3665454@l24g2000vby.googlegroups.com> <2ef2fa6c-2ccf-453a-8f50-0ef7dbd7834d@j32g2000yqc.googlegroups.com> <5c6ff40f-05c1-4e38-89bc-b8c4745db7ce@i18g2000yqn.googlegroups.com> <9a036db2-9f32-441f-aa0f-698ac22fb152@e20g2000vbn.googlegroups.com> <981140f7-79d4-421d-88c1-c819f38a3d49@w2g2000yqb.googlegroups.com> Message-ID: <4D37AA0F.3010601@gmail.com> On 01/19/2011 05:01 PM, geremy condra wrote: > On Wed, Jan 19, 2011 at 3:04 PM, rantingrick wrote: >> And you've also lost all >> connection with the people. I am desperately trying to to snap you out >> of this psychosis before it is too late! Tkinter will be the downfall >> of Python if we cannot muster the resolve to replace it with something >> that is current (or more current) technology. I don't see the original bizarre rants for some reason (spam filter likely), but I have to say this is the most ridiculous thing I've heard in some time. Tkinter the downfall of python? Wow. All of the python programmers I know (we use python every day at work) would say, "what is tkinter?" It's just not relevant to any of them that I know. Google probably uses as much Python as anyone, and their programmers would probably agree. Perhaps that's an argument to remove tkinter entirely, but not really a good one. In the meantime they happily crank out code with Django, or PyQt, or PyGTK, or even Tkinter--whatever tool is appropriate for the job. > Citation needed. Perhaps a reference to Xah Lee's web site would suffice. From debatem1 at gmail.com Wed Jan 19 22:22:27 2011 From: debatem1 at gmail.com (geremy condra) Date: Wed, 19 Jan 2011 19:22:27 -0800 Subject: Tkinter: The good, the bad, and the ugly! In-Reply-To: <0d74f3b6-e534-4762-b5f4-af1187ee3b38@32g2000yqz.googlegroups.com> References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <2ef2fa6c-2ccf-453a-8f50-0ef7dbd7834d@j32g2000yqc.googlegroups.com> <5c6ff40f-05c1-4e38-89bc-b8c4745db7ce@i18g2000yqn.googlegroups.com> <9a036db2-9f32-441f-aa0f-698ac22fb152@e20g2000vbn.googlegroups.com> <981140f7-79d4-421d-88c1-c819f38a3d49@w2g2000yqb.googlegroups.com> <0d74f3b6-e534-4762-b5f4-af1187ee3b38@32g2000yqz.googlegroups.com> Message-ID: On Wed, Jan 19, 2011 at 4:53 PM, rantingrick wrote: >> I don't think this is the case, first because you aren't very good at >> getting anybody to take you seriously > > How "self absorbed" must someone be to blame *ME* because *THEY* > cannot take *ME* seriously. Is this a joke Geremy? Sadly i know it to > be true however because you are not the only person who carries this > attitude. Welcome to real life. You convince people that you're right or they don't do what you say. >> and second because I don't think >> that resistance on this issue is as mindless as you claim. > > i have exposed the baseless, nonsensical, and argumentative stance > taken by some in an effort to sway public opinion with FUD and BS. So > i would say that arguing with baseless facts does constitute "rabid > resistance". What else could it be? Reasoned resistance seen through the eyes of someone whose judgement should not be trusted. >> I disagree with the first half. The second I'm more prone to agree >> with, although I don't have a lot of great ideas about how to solve >> the problem. > > Well maybe you are not a visionary, however i believe we still need > you in other areas. Oh, do tell. >> You seem to be full of ideas (most of which I think are >> terrible) but very short on actually getting anything done. Until you >> begin to remedy that I doubt very many people here will take you as >> seriously as you seem to want. > > Look, every organization needs workers, visionaries, liaisons, > supervisors, etc. I seem to fit nicely into a Visionary role. Maybe > that bothers you? I don't know? But we all have our place Geremy. Do > you think any organization could survive simply with robotic workers > and no guidance? No, and why not? Because workers cannot see the big > picture. They are too focused (and rightly so) on some small detail > that encompasses their job duty. Only the supervisor/visionary has the > luxury of looking at the problem from a global perspective. > > Think of Python-dev as a car. A car is a machine. A very complicated > machine that needs a driver to harness it's power and give it > direction and purpose. -- someone who can see "beyond" the horizon. > Someone who can read a road map and then re-calculate a path if road > construction blocks the current one. Without the car the driver is > nothing, and without the driver the car is nothing. Python already has leadership. It does not have a command structure. There is a difference, one that you would need to understand to be an effective leader. > But together, they > are a force to reckoned with. Well, unless the driver is Asian -- then > all bets are off! :-) Hahaha, racism was so funny in the 1700's! Now it's just asinine. >> Also, be careful with where you say 'we'- I certainly don't recognize >> your authority to speak on behalf of the community, and I suspect that >> an overwhelming majority of the community's other members feel the >> same way. > > You see! This is the resistance i am talking about. You (and others) > don't want to accept me as part of the community. If you did accept > me, then my speaking collectively (we) would not be troubling to you. > However i do not blame you directly for this prejudice. I think it is > more of a sub-conscience undercurrent that pervades this community as > a whole. A fear of outsiders. A xenophobia if you will. We need to > change this now! There's a difference between 'we should' and 'we must'. One implies that you are trying to convince, which is what communities of equals do. The other implies that you are trying to command, which is what idiots think they can do to communities of equals. Geremy Condra From rantingrick at gmail.com Wed Jan 19 22:56:47 2011 From: rantingrick at gmail.com (rantingrick) Date: Wed, 19 Jan 2011 19:56:47 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <2ef2fa6c-2ccf-453a-8f50-0ef7dbd7834d@j32g2000yqc.googlegroups.com> <5c6ff40f-05c1-4e38-89bc-b8c4745db7ce@i18g2000yqn.googlegroups.com> <9a036db2-9f32-441f-aa0f-698ac22fb152@e20g2000vbn.googlegroups.com> <981140f7-79d4-421d-88c1-c819f38a3d49@w2g2000yqb.googlegroups.com> <0d74f3b6-e534-4762-b5f4-af1187ee3b38@32g2000yqz.googlegroups.com> Message-ID: On Jan 19, 9:22?pm, geremy condra wrote: > Welcome to real life. You convince people that you're right or they > don't do what you say. Again you "think" (or miscomprehended rather!) that "somehow" i am here to "make" you do anything. On the contrary Geremy, i am here to "guide", to "foster", and to "build" a cohesive community of python programmers united in a common goal WITH a clear vision for the future. > >> and second because I don't think > >> that resistance on this issue is as mindless as you claim. > > > i have exposed the baseless, nonsensical, and argumentative stance > > taken by some in an effort to sway public opinion with FUD and BS. So > > i would say that arguing with baseless facts does constitute "rabid > > resistance". What else could it be? > > Reasoned resistance seen through the eyes of someone whose judgement > should not be trusted. Why is my judgment in question here. As you claim i have no authority within in this group, so why does my judgment scare you? > > But together, they > > are a force to reckoned with. Well, unless the driver is Asian -- then > > all bets are off! :-) > > Hahaha, racism was so funny in the 1700's! Now it's just asinine. Actually the joke is on you Geremy. Obviously you cannot tell the difference between "stereotypes" and "racism". And there is a HUGE, HUGE, difference! Asians are stereotypical bad drivers, just as white guys are stereotypical bad dancers, just as black guys have stereotypical huge cucumbers. The fact that you cannot distinguish racism from stereotype exposes three things about your personality (1.) You have no sense of humor and cannot laugh at yourself, (2.) You'll jump on any bandwagon just to discredit the person you are debating with outlandish and controversial accusations, and (3.) you are extremely shallow. This shows lack of intelligence, humor, and worse of all humility. Anyhow, do you have any actual arguments or ideas on keeping Tkinter or replacing Tkinter. Remember that is why we are here Geremy. From rantingrick at gmail.com Wed Jan 19 23:06:58 2011 From: rantingrick at gmail.com (rantingrick) Date: Wed, 19 Jan 2011 20:06:58 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <2ef2fa6c-2ccf-453a-8f50-0ef7dbd7834d@j32g2000yqc.googlegroups.com> <5c6ff40f-05c1-4e38-89bc-b8c4745db7ce@i18g2000yqn.googlegroups.com> <9a036db2-9f32-441f-aa0f-698ac22fb152@e20g2000vbn.googlegroups.com> <981140f7-79d4-421d-88c1-c819f38a3d49@w2g2000yqb.googlegroups.com> Message-ID: On Jan 19, 9:20?pm, Michael Torrie wrote: > > All of the python programmers I know (we use python every day at > work) would say, "what is tkinter?" It's just not relevant to any of > them that I know. > And that is the very point i am trying to make Micheal! TclTk is SO old and dated that most people don't even know it exists -- MUCH LESS TKINTER! > > In the meantime they happily crank out code with Django, or PyQt, or > PyGTK, or even Tkinter--whatever tool is appropriate for the job. > I noticed wxPython did not make your list. Was that conscience or sub- conscience because i find it hard to believe that none of them use wxPython... ever. However the REAL point is that they obviously prefer *anything* except Tkinter and only use Tkinter as a last resort. This is very interesting Micheal. From brian.curtin at gmail.com Wed Jan 19 23:35:08 2011 From: brian.curtin at gmail.com (Brian Curtin) Date: Wed, 19 Jan 2011 22:35:08 -0600 Subject: Tkinter: The good, the bad, and the ugly! In-Reply-To: <0d74f3b6-e534-4762-b5f4-af1187ee3b38@32g2000yqz.googlegroups.com> References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <2ef2fa6c-2ccf-453a-8f50-0ef7dbd7834d@j32g2000yqc.googlegroups.com> <5c6ff40f-05c1-4e38-89bc-b8c4745db7ce@i18g2000yqn.googlegroups.com> <9a036db2-9f32-441f-aa0f-698ac22fb152@e20g2000vbn.googlegroups.com> <981140f7-79d4-421d-88c1-c819f38a3d49@w2g2000yqb.googlegroups.com> <0d74f3b6-e534-4762-b5f4-af1187ee3b38@32g2000yqz.googlegroups.com> Message-ID: On Wed, Jan 19, 2011 at 18:53, rantingrick wrote: > Without the car the driver is > nothing, and without the driver the car is nothing. But together, they > are a force to reckoned with. Well, unless the driver is Asian -- then > all bets are off! :-) Welcome to the auto-deletion filter. -------------- next part -------------- An HTML attachment was scrubbed... URL: From debatem1 at gmail.com Thu Jan 20 00:15:00 2011 From: debatem1 at gmail.com (geremy condra) Date: Wed, 19 Jan 2011 21:15:00 -0800 Subject: Tkinter: The good, the bad, and the ugly! In-Reply-To: References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <2ef2fa6c-2ccf-453a-8f50-0ef7dbd7834d@j32g2000yqc.googlegroups.com> <5c6ff40f-05c1-4e38-89bc-b8c4745db7ce@i18g2000yqn.googlegroups.com> <9a036db2-9f32-441f-aa0f-698ac22fb152@e20g2000vbn.googlegroups.com> <981140f7-79d4-421d-88c1-c819f38a3d49@w2g2000yqb.googlegroups.com> <0d74f3b6-e534-4762-b5f4-af1187ee3b38@32g2000yqz.googlegroups.com> Message-ID: On Wed, Jan 19, 2011 at 7:56 PM, rantingrick wrote: >> > But together, they >> > are a force to reckoned with. Well, unless the driver is Asian -- then >> > all bets are off! :-) >> >> Hahaha, racism was so funny in the 1700's! Now it's just asinine. > > Actually the joke is on you Geremy. Obviously you cannot tell the > difference between "stereotypes" and "racism". And there is a HUGE, > HUGE, difference! Asians are stereotypical bad drivers, just as white > guys are stereotypical bad dancers, just as black guys have > stereotypical huge cucumbers. Congratulations; you are the second person better than a decade to land in my bozo bin. Don't bother replying- I won't be hearing from you. Geremy Condra From urban.dani at gmail.com Thu Jan 20 01:02:21 2011 From: urban.dani at gmail.com (Daniel Urban) Date: Thu, 20 Jan 2011 07:02:21 +0100 Subject: collections.Set Binary Reflected Operations In-Reply-To: References: Message-ID: On Thu, Jan 20, 2011 at 01:51, Chris Kaynor wrote: > I am implemented a custom set-like type which interacts with some > third-party software when retrieving and mutating the set, and have derived > my custom type off of collections.MutableSet, however I have noticed that > some of the magic methods supported by the built-in set do not fully > function with my custom type. From this,?I looked over the > MutableSet?definition?in and it seems to be missing all of the reflected > operators (__rsub__, __rand__, __ror__, __rxor__, and friends) for the > operators it has defined. I can post a simple example case if desired. > I am using Python 2.6.4 (with some in-house customizations), however a quick > look over the svn?repository?shown on python.org makes it appear that these > are also not implemented in Python 3. I was wondering if there is some > reason for this, or if it was merely an oversight. > Chris See http://bugs.python.org/issue8743 and also http://bugs.python.org/issue2226 Daniel From user at compgroups.net/ Thu Jan 20 01:16:02 2011 From: user at compgroups.net/ (WellsSUZETTE21) Date: Thu, 20 Jan 2011 00:16:02 -0600 Subject: newb References: Message-ID: I received 1 st mortgage loans when I was 25 and that supported my family very much. But, I need the bank loan once more time. From orasnita at gmail.com Thu Jan 20 02:09:12 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Thu, 20 Jan 2011 09:09:12 +0200 Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com><4d337983$0$29983$c3e8da3$5496439d@news.astraweb.com><044a5101-948d-4458-9c94-57dbb3e25f67@m35g2000vbn.googlegroups.com><4d3467bf$0$29983$c3e8da3$5496439d@news.astraweb.com> <4D34B04E.8050309@web.de><4266E8D7BA204BFEA5BF66C635CE1716@octavian> <4D35DCE8.5030002@web.de><4D35DD47.1070304@web.de><42924000-3ffb-40f5-9cf8-70a9d767b944@k25g2000vbl.googlegroups.com> Message-ID: <39D3B37016074EDABBE6BAF6F433D942@octavian> From: "Grant Edwards" >>> On all of my computers, wxPython uses Gtk. There are other choices >>> for wxWidget backends on Linux, but Gtk is by far the most common. >>> IOW, if Gtk is bad, then wxPython is bad. >> >> Not true. > > I think you're playing a bit fast and loose with your accusations. :-) I've made no accusations, but I only try to inform the people about the accessibility of different GUI libs. > Which of my statements was "not true"? > > 1) On all of my computers wxPython uses Gtk. > > 2) There are other backend choices on Linux besides Gtk. > > 3) Gtk is by far the most common wxWidgets backend on Linux/Unix. > > 4) If Gtk is bad then wxPython is bad. > > Note that 4) follows logically from 3), so to say that 4) is "not > true" you have to show that 3) is "not true". The wrong conclusion is that if Gtk is bad, then WxPython is bad. Gtk is inaccessible under Windows, not under Linux, but WxPython doesn't use Gtk under Windows so WxPython is OK. Under Linux Gtk is OK, but I don't know about Motif. Under Linux Motif might not be accessible, however note that I am not sure about Motif's accessibility. Octavian From orasnita at gmail.com Thu Jan 20 02:22:05 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Thu, 20 Jan 2011 09:22:05 +0200 Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com><4d337983$0$29983$c3e8da3$5496439d@news.astraweb.com><044a5101-948d-4458-9c94-57dbb3e25f67@m35g2000vbn.googlegroups.com><4d3467bf$0$29983$c3e8da3$5496439d@news.astraweb.com><4D34B04E.8050309@web.de><4266E8D7BA204BFEA5BF66C635CE1716@octavian><4D35DCE8.5030002@web.de><4D35DD47.1070304@web.de><7A0C7934E65D4B85A584C06ADD3B6ECF@teddy> <799d1f10-f2b3-41fb-ade2-d31ff19918e5@t23g2000vby.googlegroups.com> Message-ID: From: "Adam Skutt" The fact that /every/ toolkit provides accessibility guidelines over and above whatever other UI guidelines they provide tells me that creating an accessible application is hardly obvious. Plus, if it were really that simple, the accessibility situation wouldn't be so poor. :-) Where do you got the conclusion that the accessibility is so poor? The accessibility is not so great under Mac and under Linux it is less advanced than under Windows, but under Windows the accessibility is usually very good for most apps. All the standard Windows programs are accessible, all the DotNet programs are generally accessible, SWT and wxWIDGETS - based programs are accessible, SWING-based GUIS are also pretty accessible and even more strange interfaces like the one found in Winamp are accessible. Even Flash have a very limited accessibility although I think it is too much to say that it is accessible. But You keep telling me that it is hard to create accessible programs, which is false, but you don't know and don't want to try to see. Try to create a WxPython app that doesn't do anything but only displays some menus, buttons, combo boxes, list boxes, list views, tree views, text fields, check boxes, radio buttons... and you will see that they are very accessible with that screen reader I told you about, without requiring you to do anything special that you wouldn't do otherwise. > Yes, those things should be followed for creating a better app, but what I > wanted to say is that no matter if you do those things or not in a Tk, Gtk > or QT GUI, they will be useless, because the screen readers can't > understand those GUIS even they have text labels, and even if you will see > a focus rectangle around buttons. They don't report that those objects > have the focus so the screen readers won't speak anything. Your "something is better than nothing" argument isn't particularly compelling to me personally as a justification for ripping out TkInter. And Qt is the only toolkit with some level of functioning accessibility support on all three major platforms, assuming the library and software are built correctly, so again, your argument is really for Qt, not for wxWidgets. How do you came to the conclusion that QT is accessible on all operating system? I haven't seen any QT-based accessible interface, but WxPython offers that thing without any effort. When you talk about accessibility, try it yourself and don't take the word of the GUI widgets developers. Octavian From orasnita at gmail.com Thu Jan 20 02:33:23 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Thu, 20 Jan 2011 09:33:23 +0200 Subject: Screen readers for Tkinter (was Re: Tkinter: The good, the bad, and the ugly!) References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com><4d337983$0$29983$c3e8da3$5496439d@news.astraweb.com><044a5101-948d-4458-9c94-57dbb3e25f67@m35g2000vbn.googlegroups.com><4d3467bf$0$29983$c3e8da3$5496439d@news.astraweb.com><4D34B04E.8050309@web.de><4266E8D7BA204BFEA5BF66C635CE1716@octavian><4D35DCE8.5030002@web.de> <1295448820.26438.1416115629@webmail.messagingengine.com><5296E6FB68964C239A84C2AF4007D2DD@teddy> Message-ID: From: "Terry Reedy" > On 1/19/2011 11:27 AM, Octavian Rasnita wrote: > >>> Note: Currently, accessibility is only available via ATK<=> AT-SPI on >>> Linux. Sorry, no Windows MSAA support. >> >> >> This project is good, a step ahead, but in order to be really useful it >> should be the one provided by the default Python package. >> And of course, it should also offer support for Windows, since most of >> the computer users use Windows, especially those who need accessibility >> features. > > Octavian > > Please consider adding an 'Accessibility' page to the Python wiki with > your info and the above for those interested. > > -- > Terry Jan Reedy Well, I am not sure this is an interesting thing for the programmers. The programmers (including me) are usually interested to have the job done as fast as possible, with as few efforts as possible and to be easy to maintain. The GUIs should be accessible by default like in case of wxWIDGETS, SWT or WindowsForms. That's why I said that that lib should be included in Python implicitely eventually because if it is just promoted, the beginners won't know about it and most of the programmers won't care to add accessibility features with aditional efforts. Too bad that it doesn't support the accessibility for Windows though. Octavian From stefan_ml at behnel.de Thu Jan 20 02:35:24 2011 From: stefan_ml at behnel.de (Stefan Behnel) Date: Thu, 20 Jan 2011 08:35:24 +0100 Subject: [OT] Python like lanugages [was Re: After C++, what with Python?] In-Reply-To: References: <86a904f8-05b0-435f-81d6-7450650f1679@glegroupsg2000goo.googlegroups.com> <4d329899$0$43988$742ec2ed@news.sonic.net> <7x8vylfcvz.fsf@ruckus.brouhaha.com> <4d32c7cf$0$29983$c3e8da3$5496439d@news.astraweb.com> <4d3425fe$0$29983$c3e8da3$5496439d@news.astraweb.com> Message-ID: Tim Harig, 18.01.2011 12:37: > On 2011-01-18, Stefan Behnel wrote: >> Tim Harig, 17.01.2011 20:41: >>> I prefer a single language as opposed to a creolization of two. >> >> With the possible exception of Lisp, I find it hard to think of a language >> that's still alive and not the creolisation of (at least) two other >> languages. They all inherited from each other, sometimes right from the >> start ("lessons learned") and always during their subsequent life time. > > I am not talking about language influences. Cython effectively requires > two separate languages that interoperate. The end result is a mix > of two code written in two separate langauges. That is not a single > language solution. I don't really agree with the word "separate", and especially not "two codes". I think of Cython more as Python with the addition of C data types, integrated by a smart compiler. So the language actually is Python, it's just that you can apply it to a broader set of data representations. Stefan From donotreply at flickr.com Thu Jan 20 03:06:11 2011 From: donotreply at flickr.com (Flickr Mail) Date: 20 Jan 2011 08:06:11 +0000 Subject: =?utf-8?Q?=5BFlickr=5D_Your_upload_has_failed_with_the_following_message=3A?= Message-ID: <20110120080848.1AF53EE981@mail.python.org> If you think you shouldn't be getting this error, you can search our FAQs or send us a help case from http://flickr.com/help/ and we'll do out best to help! Thanks, The Flickr Team ------------------------------------------------- This information might be of use to us when diagnosing what went wrong : To Address: york65good at photos.flickr.com Cc Address: >From Address: python-list at python.org Message ID: <20110120080606.D05292C1C1 at www120.flickr.mud.yahoo.com> Parsed Addresses: york65good at photos.flickr.com Handling Server: www120 Handler Version: 69900OH HAI Transaction Log: www120-1295510770.email Logged Date: 20-01-2011 User NSID: 8109696 at N02 Blog Id: From rde at audaxis.com Thu Jan 20 04:04:12 2011 From: rde at audaxis.com (Romaric DEFAUX) Date: Thu, 20 Jan 2011 10:04:12 +0100 Subject: Need advices for mysqldb connection best practice Message-ID: <4D37FA8C.9060108@audaxis.com> Hi all, I've a problem with a mysql connection. I run a client/server application. Every hour, clients contact the server, send datas, and the server updates the database. Everything works perfectly. But after a while, I get in trouble with my db connection. I've got the impression my server application "mix" the cursors... I've got this kind of strange errors in my log : Traceback (most recent call last): File "/usr/local/lib/audaxis/system_serverbox.py", line 519, in __update_in_db old_serverbox.load_from_db(cursor, self.__id) File "/usr/local/lib/audaxis/system_serverbox.py", line 131, in load_from_db self.__uuid = row['uuid'] TypeError: 'NoneType' object is unsubscriptable Traceback (most recent call last): File "/usr/local/lib/audaxis/system_server.py", line 168, in process_data result += my_serverbox.save_website_list(cursor) File "/usr/local/lib/audaxis/system_serverbox.py", line 1197, in save_website_list old_serverbox.load_from_db(cursor, self.__id) File "/usr/local/lib/audaxis/system_serverbox.py", line 143, in load_from_db self.__load_disk_list_from_db(cursor) File "/usr/local/lib/audaxis/system_serverbox.py", line 203, in __load_disk_list_from_db my_disk.load_from_db(cursor, disk_id) File "/usr/local/lib/audaxis/system_disk.py", line 54, in load_from_db self.__fs = row['fs'] KeyError: 'fs' Traceback (most recent call last): File "/usr/local/lib/audaxis/system_serverbox.py", line 521, in __update_in_db __uuid_host = self.is_virtual(cursor) File "/usr/local/lib/audaxis/system_serverbox.py", line 339, in is_virtual result = row['uuid'] KeyError: 'uuid' and a lot of KeyError (at every update) The requests that produce these errors were working perfectly. And if I restart my server, everything is working fine again ! Here's part of my code (I removed some parts): I create a db connection like this in my object server: def connect(): con = MySQLdb.connect (host = "localhost", user = "myuser", passwd = "good_password", db = "my_db", cursorclass=DictCursor) con.ping(True) <- this normally activate auto-reconnection (or I did a mistake ?) con.cursor().execute('SET AUTOCOMMIT=1') return con self.__db_connection = connect() Then, each time a client connects : cursor = self.__db_connection.cursor() ...process the datas... cursor.close() So , I thought about some solutions : - restarting the server every sometimes (but it's the worst solution in my mind) - creating a connection (not only cursor) at each client connection (but I'm afraid it overloads the mysql server) - trying to find where I did a mistake, and correct the bug (that why I'm doing by writing this list :), or send me a link that could help me (before writing I googled for one hour and found nothing interresting in my case...) Thanks in advance for your advices ! Romaric From davea at ieee.org Thu Jan 20 05:46:08 2011 From: davea at ieee.org (Dave Angel) Date: Thu, 20 Jan 2011 05:46:08 -0500 Subject: [OT] Python like lanugages [was Re: After C++, what with Python?] In-Reply-To: References: <86a904f8-05b0-435f-81d6-7450650f1679@glegroupsg2000goo.googlegroups.com><4d329899$0$43988$742ec2ed@news.sonic.net><7x8vylfcvz.fsf@ruckus.brouhaha.com><4d32c7cf$0$29983$c3e8da3$5496439d@news.astraweb.com><4d35a769$0$2258$a729d347@news.telepac.pt><503D269987294E7A95D87C488F37BB25@octavian><828053EDBB174148B9895ADD5B9A0780@octavian> Message-ID: <4D381270.5090105@ieee.org> On 01/-10/-28163 02:59 PM, Octavian Rasnita wrote: > From: "geremy condra" >> On Wed, Jan 19, 2011 at 2:31 AM, Octavian Rasnita wrote: >>> >>> >>> Would it be hard to introduce the possibility of adding encryption of the >>> bytecode similar to what the Zend encoder does for PHP or Filter::Crypto for >>> Perl? >>> >>> Octavian >> >> The iron law of cryptography: there is no cryptographic solution to a >> problem in which the attacker and intended recipient are the same >> person. >> >> Schemes like this are at most an annoyance to people willing to >> reverse engineer your code. >> >> Geremy Condra > > > I don't know how the Python bytecode works... how it is executed. > > I thought that Python parses the .py file and generates the bytecode that doesn't contain all the necessary information for re-creating the source code. > (But that I agree, that might mean real compilation which is not the case...) > > Octavian > It's not hard to experiment with. I've written disassemblers for other byte-code formats, but not for Python's. The following is pasted together, so it may not be completely correct. But it's close. Python 2.6.5 (r265:79063, Apr 16 2010, 13:09:56) [GCC 4.4.3] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> def test(arg1, arg2): ... if arg1 < 65: ... print arg2 ... >>> import dis >>> dis.dis(test) 2 0 LOAD_FAST 0 (arg1) 3 LOAD_CONST 1 (65) 6 COMPARE_OP 0 (<) 9 JUMP_IF_FALSE 9 (to 21) 12 POP_TOP 3 13 LOAD_FAST 1 (arg2) 16 PRINT_ITEM 17 PRINT_NEWLINE 18 JUMP_FORWARD 1 (to 22) >> 21 POP_TOP >> 22 LOAD_CONST 0 (None) 25 RETURN_VALUE >>> Now, there are tools which reverse that into something pretty similar to python source. But you can see even from the built-in features that lots of information is there. I'd assume that something very similar is in the byte code files themselves. DaveA From askutt at gmail.com Thu Jan 20 07:22:22 2011 From: askutt at gmail.com (Adam Skutt) Date: Thu, 20 Jan 2011 04:22:22 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com><4d337983$0$29983$c3e8da3$5496439d@news.astraweb.com><044a5101-948d-4458-9c94-57dbb3e25f67@m35g2000vbn.googlegroups.com><4d3467bf$0$29983$c3e8da3$5496439d@news.astraweb.com><4D34B04E.8050309@web.de><4266E8D7BA204BFEA5BF66C635CE1716@octavian><4D35DCE8.5030002@web.de><4D35DD47.1070304@web.de><7A0C7934E65D4B85A584C06ADD3B6ECF@teddy> Message-ID: <098df916-13f0-4dfa-b4c5-d4b0b5cddc13@r29g2000yqj.googlegroups.com> On Jan 20, 2:22?am, "Octavian Rasnita" wrote: > Where do you got the conclusion that the accessibility is so poor? By an examination of the facts. MSAA is universally hated and all screen readers actively have to work around it and its many limitations (meaning that as an application programmer, you can do the "right" thing and still get undesired behavior through no fault of your own). I have no clue if it's replacement is better, but I do know few programs use it, so it's little comfort. The situation on Linux is still an outright disaster. Neither Qt4 nor GTK enable accessibility functionality automatically and support from the various distribution vendors is pretty limited. It is improving, however. Accessibility still requires special effort "over and above" the norm by the programmer whether you believe this to be the case or not. Most programmers aren't even aware of the fact they must consider it (a point you've made yourself before!) and hence commit various accessibility sins. This is mostly a cultural problem, not a technical one, but it's still a real problem. Plus, out of the stuff I run daily on Windows: two of the applications are entirely inaccessible: the Adobe AIR one and the Gtk one. Songbird, the XUL based music player, has some accessibility, but none of the navigation controls seem to be enabled, which would make it very difficult to actually use, I imagine. It's also not particularly keyboard friendly: you don't even get a visual focus indicator most of the time, even though the focus is moving. > But You keep telling me that it is hard to create accessible programs, which > is false, but you don't know and don't want to try to see. > Try to create a WxPython app that doesn't do anything but only displays some > menus, buttons, combo boxes, list boxes, list views, tree views, text > fields, check boxes, radio buttons... and you will see that they are very > accessible with that screen reader I told you about, without requiring you > to do anything special that you wouldn't do otherwise. Applications that only display these things aren't very interesting. And no, they still require additional effort. Most developers can't even be assed to get a sane tab focus order set, to say nothing of keyboard shortcuts, accessibility descriptions / proper label associations for buttons and other controls. It gets even more complicated when you get away from controls only meant to display text. How many web pages have you visited where images are missing alt tags? Do you really thing those same people are going to bother trying to do the right thing if asked to create a desktop GUI application? No, they're not, and you're going to get whatever happens automatically. Which isn't nothing (in some toolkits), but it's also not what one really wants, either. > > How do you came to the conclusion that QT is accessible on all operating > system? By actually going out, reading, and even testing? Qt has had functional accessibility support on OS X and Windows since Qt3, and functional support on Linux, OS X, and Windows since Qt4. It even extends to PySide, with a few limitations: you can't write custom accessible widgets in PySide, though I'm pretty confident they'd enable support if someone wrote a patch to enable the bindings. > When you talk about accessibility, try it yourself and don't take the word > of the GUI widgets developers. > I just did, NVDA was able to read my button text and its accessibility description just fine, both in C++ and Python versions of my Qt application. I didn't bother testing Linux or OS X, but I'm sure it would work there too. Adam From subscriptions at cagttraining.com Thu Jan 20 07:30:02 2011 From: subscriptions at cagttraining.com (Bill Felton) Date: Thu, 20 Jan 2011 07:30:02 -0500 Subject: Tkinter: The good, the bad, and the ugly! In-Reply-To: <4D37AA0F.3010601@gmail.com> References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <0fa4603c-6e27-4ee5-9761-000a61cd19a4@fx12g2000vbb.googlegroups.com> <2510bf88-1045-411f-9ccd-7ca7c3665454@l24g2000vby.googlegroups.com> <2ef2fa6c-2ccf-453a-8f50-0ef7dbd7834d@j32g2000yqc.googlegroups.com> <5c6ff40f-05c1-4e38-89bc-b8c4745db7ce@i18g2000yqn.googlegroups.com> <9a036db2-9f32-441f-aa0f-698ac22fb152@e20g2000vbn.googlegroups.com> <981140f7-79d4-421d-88c1-c819f38a3d49@w2g2000yqb.googlegroups.com> <4D37AA0F.3010601@gmail.com> Message-ID: <953B2583-5609-4C0C-9B4F-CA46F9E570F4@cagttraining.com> On Jan 19, 2011, at 10:20 PM, Michael Torrie wrote: > On 01/19/2011 05:01 PM, geremy condra wrote: >> On Wed, Jan 19, 2011 at 3:04 PM, rantingrick wrote: >>> And you've also lost all >>> connection with the people. I am desperately trying to to snap you out >>> of this psychosis before it is too late! Tkinter will be the downfall >>> of Python if we cannot muster the resolve to replace it with something >>> that is current (or more current) technology. > > I don't see the original bizarre rants for some reason (spam filter > likely), but I have to say this is the most ridiculous thing I've heard > in some time. Tkinter the downfall of python? Wow. All of the python > programmers I know (we use python every day at work) would say, "what > is tkinter?" It's just not relevant to any of them that I know. Google > probably uses as much Python as anyone, and their programmers would > probably agree. Perhaps that's an argument to remove tkinter entirely, > but not really a good one. > With some hesitation, I feel a need to jump in here. I'm a complete newbie to Python. I'm still learning the language. And you know what? I've ignored Tkinter. I quickly discovered the alternatives and am already working with wxPython. I can't believe anyone is so hung up by their own arrogance that they honestly believe that the mere *presence* of a gui kit inside of the standard distribution would prevent a newbie from learning about the existence and possible benefits of alternatives. Sure, *they* can see alternatives and evaluate why Tkinter might not be a good choice under conditions x or y or z, but god forbid anyone new to the language should have to confront those issues or be asked to make such a decision. How could we trust those lowly newbies to think *properly* about the issue! ESPECIALLY in a language widely touted for the vast array of external libraries available. The attitude that the standard distribution needs this kind of obsessive, hysterically blinkered, focused on irrelevant minutiae is far more likely to be the downfall of the language than the presence of a sub-optimal gui kit that no one is required to use. As one of 'the people' who is presumably the focus of rantingrick's concern, let me assure him Tkinter is a non-issue. MIchael is more in touch with my issues than rr, and appears to be suffering fewer disconnects from the reality of a programming language that ships with a large standard library and offers a plethora of extensions and alternatives, widely available and easy to find. cheers, Bill From giacomo.boffi at polimi.it Thu Jan 20 07:34:06 2011 From: giacomo.boffi at polimi.it (Giacomo Boffi) Date: Thu, 20 Jan 2011 13:34:06 +0100 Subject: Should there be a 'core' python install? References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <4d337983$0$29983$c3e8da3$5496439d@news.astraweb.com> <044a5101-948d-4458-9c94-57dbb3e25f67@m35g2000vbn.googlegroups.com> <4d3467bf$0$29983$c3e8da3$5496439d@news.astraweb.com> <0947517d-a2c4-44af-83cb-8ed4299b143a@k25g2000vbl.googlegroups.com> <3ac4634f-1c6f-4552-9e7f-a2d912a77dc2@f35g2000vbl.googlegroups.com> Message-ID: <8639onzrcx.fsf@aiuole.stru.polimi.it> "Martin P. Hellwig" writes: > Yep when I started looking much more at other toolkits, I started to > like Tkinter more and more. Maybe its simplicity, maybe the good design of Tk, -- BOMBED BY AIRCRAFT. SINKING. U-824. From funthyme at gmail.com Thu Jan 20 08:09:50 2011 From: funthyme at gmail.com (John Pinner) Date: Thu, 20 Jan 2011 05:09:50 -0800 (PST) Subject: __pycache__, one more good reason to stck with Python 2? References: <23e02e0d-b2f1-4b52-85ea-d1feba99dd37@22g2000prx.googlegroups.com> <4d3466d3$0$29983$c3e8da3$5496439d@news.astraweb.com> <0c62aacd-e6d2-4778-81d6-e06924192add@j1g2000vbl.googlegroups.com> <87vd1m6ezq.fsf@benfinney.id.au> <992b11a0-d35d-4b08-98ab-d08c90a86ec7@j1g2000vbl.googlegroups.com> <4d36f846$0$29983$c3e8da3$5496439d@news.astraweb.com> Message-ID: <9b90b457-9436-4f38-956a-bfafe3d0acdb@h17g2000pre.googlegroups.com> Hi You have disturbe my slumber, Steven ;-) On Jan 19, 2:42?pm, Steven D'Aprano wrote: > On Tue, 18 Jan 2011 00:58:14 -0800, jmfauth wrote: > > It is now practically impossible to launch a Python application via a > > .pyc file. > > When has that ever been possible? > > .pyc files are Python byte-code. You can't run them directly using Python > (except via the import machinery), you can't run them as a script, > they're not machine code. Unless you write a wrapper to import the file > as a module, you can't directly execute .pyc files. Not true. 'python myprog.pyc' has worked for as long as I have been using Python. Whether or not it is a good idea is another matter. Probably it would be best to check what you're saying before posting such a bald assertion, even though you were 110% sure of what you were saying. I've been there, done that, bought the tee-shirt. Best wishes, John -- From orasnita at gmail.com Thu Jan 20 08:19:13 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Thu, 20 Jan 2011 15:19:13 +0200 Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com><4d337983$0$29983$c3e8da3$5496439d@news.astraweb.com><044a5101-948d-4458-9c94-57dbb3e25f67@m35g2000vbn.googlegroups.com><4d3467bf$0$29983$c3e8da3$5496439d@news.astraweb.com><4D34B04E.8050309@web.de><4266E8D7BA204BFEA5BF66C635CE1716@octavian><4D35DCE8.5030002@web.de><4D35DD47.1070304@web.de><7A0C7934E65D4B85A584C06ADD3B6ECF@teddy> <098df916-13f0-4dfa-b4c5-d4b0b5cddc13@r29g2000yqj.googlegroups.com> Message-ID: <9236E86791634EE69D94C1ED2C515C24@octavian> From: "Adam Skutt" On Jan 20, 2:22 am, "Octavian Rasnita" wrote: > Where do you got the conclusion that the accessibility is so poor? By an examination of the facts. MSAA is universally hated and all screen readers actively have to work around it and its many limitations (meaning that as an application programmer, you can do the "right" thing and still get undesired behavior through no fault of your own). I have no clue if it's replacement is better, but I do know few programs use it, so it's little comfort. The Windows applications are not accessible only if they use MSAA. The screen readers know how to get the necessary information for making the interfaces accessible in other ways, but of course, it is harder for the screen reader manufacturers if the GUIs don't respect a standard. And if MSAA is hated it doesn't mean that the accessibility is so poor as you might think. The situation on Linux is still an outright disaster. Neither Qt4 nor GTK enable accessibility functionality automatically and support from the various distribution vendors is pretty limited. It is improving, however. It might be true, I don't know, because I use Linux only in command line mode. Accessibility still requires special effort "over and above" the norm by the programmer whether you believe this to be the case or not. I don't understand how I need to "believe" this, while I made perfectly accessible applications without doing special efforts for making them to be accessible. Of course, I don't consider something special to put a text label on a button, or radio button or check box. Most programmers aren't even aware of the fact they must consider it (a point you've made yourself before!) and hence commit various accessibility sins. This is mostly a cultural problem, not a technical one, but it's still a real problem. Yes, that's a problem but we divagate. The programmers need to take care about those details, like putting text labels on buttons, or tooltips for images, but these things are relevant only for accessible widgets. It *doesn't matter* if they put those labels if they use GUIS like Tk because they won't be accessible at all anyway. Plus, out of the stuff I run daily on Windows: two of the applications are entirely inaccessible: the Adobe AIR one and the Gtk one. Songbird, the XUL based music player, has some accessibility, but none of the navigation controls seem to be enabled, which would make it very difficult to actually use, I imagine. It's also not particularly keyboard friendly: you don't even get a visual focus indicator most of the time, even though the focus is moving. Yes of course, Adobe's products are at most very hard accessible or not accessible at all and I already said that Gtk is not accessible under Windows, just like Tk. > But You keep telling me that it is hard to create accessible programs, > which > is false, but you don't know and don't want to try to see. > Try to create a WxPython app that doesn't do anything but only displays > some > menus, buttons, combo boxes, list boxes, list views, tree views, text > fields, check boxes, radio buttons... and you will see that they are very > accessible with that screen reader I told you about, without requiring you > to do anything special that you wouldn't do otherwise. Applications that only display these things aren't very interesting. And no, they still require additional effort. Most developers can't even be assed to get a sane tab focus order set, Well, I haven't used WxPython until now, but only WxPerl, however the WxPerl programmers don't need to set the tab focus because by default the tab focus is set in the order of the controls on the form and I thought it should be the same in WxPython. So no special effort would be necessary. Are you sure you are not confusing accessibility with usability? Of course that an application which respects more usability rules is easier to use, and this means that it should have the controls with a right tab order, with clear text labels and so on, but we can talk about usability only for an accessible GUI. JAWS screen reader has its own programming language and it can be used for improving the usability of a program. It can do very many things and it has more than 1000 functions, but it can't do anything in the case of inaccessible interfaces like Tk. > to say nothing of keyboard shortcuts, accessibility descriptions / proper > label associations for buttons and other controls. It gets even more complicated when you get away from controls only meant to display text. How many web pages have you visited where images are missing alt tags? Do you really thing those same people are going to bother trying to do the right thing if asked to create a desktop GUI application? No, they're not, and you're going to get whatever happens automatically. Which isn't nothing (in some toolkits), but it's also not what one really wants, either. Yes, that's true, but as I said, some GUIS like WxPython offer the accessibility, so those controls are visible, and it is less important if they are in a right tab order or if some of the controls are not labeled, because the screen reader can solve these things. But the screen reader can't solve the absolute inaccessibility of GUIS like Tk because it can't read anything from it. > How do you came to the conclusion that QT is accessible on all operating > system? By actually going out, reading, and even testing? Qt has had functional accessibility support on OS X and Windows since Qt3, and functional support on Linux, OS X, and Windows since Qt4. It even extends to PySide, with a few limitations: you can't write custom accessible widgets in PySide, though I'm pretty confident they'd enable support if someone wrote a patch to enable the bindings. A GUI which offers accessible widgets only if they are coded specially for beeing accessible are not accessible at all, because most programmers won't care to make the applications accessible so the results will be bad anyway. > When you talk about accessibility, try it yourself and don't take the word > of the GUI widgets developers. > I just did, NVDA was able to read my button text and its accessibility description just fine, both in C++ and Python versions of my Qt application. I didn't bother testing Linux or OS X, but I'm sure it would work there too. Have you created that QT application with its default options? Without doing anything special to make it accessible? And most important, have you tested it with JAWS screen reader? (Or WindowEyes at least) because these are the most used screen readers. NVDA is pretty poor and it can't be used for very complex things (yet). Octavian From orasnita at gmail.com Thu Jan 20 08:26:13 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Thu, 20 Jan 2011 15:26:13 +0200 Subject: Tkinter: The good, the bad, and the ugly! References: <953B2583-5609-4C0C-9B4F-CA46F9E570F4@cagttraining.com> Message-ID: From: "Bill Felton" > I'm a complete newbie to Python. To Python, or to programming in general? (Because it is important) > I'm still learning the language. And you know what? I've ignored > Tkinter. Why did you do that? > I quickly discovered the alternatives and am already working with > wxPython. > I can't believe anyone is so hung up by their own arrogance that they > honestly believe that the mere *presence* of a gui kit inside of the > standard distribution would prevent a newbie from learning about the > existence and possible benefits of alternatives. Sure, *they* can see > alternatives and evaluate why Tkinter might not be a good choice under > conditions x or y or z, Nobody said that the fact that Python promotes Tkinter *prevents" the beginners to learn to use another GUI. I just say that if Python promotes Tkinter, the beginners that might not have experience programming in other languages might not know at all which is the difference between all those GUI types, and it might not know at all that there are more GUI types and it won't know for sure which are the differences between them. And for a real beginner in programming it could be harder and less important to make the effort of finding and downloading and installing another GUI just because it offer some features which are not interesting for most users, so he/she will prefer using what Python offers and he/she won't know that that solution is bad. Octavian From python at bdurham.com Thu Jan 20 08:48:55 2011 From: python at bdurham.com (python at bdurham.com) Date: Thu, 20 Jan 2011 08:48:55 -0500 Subject: Tkinter: The good, the bad, and the ugly! In-Reply-To: <953B2583-5609-4C0C-9B4F-CA46F9E570F4@cagttraining.com> References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <0fa4603c-6e27-4ee5-9761-000a61cd19a4@fx12g2000vbb.googlegroups.com> <2510bf88-1045-411f-9ccd-7ca7c3665454@l24g2000vby.googlegroups.com> <2ef2fa6c-2ccf-453a-8f50-0ef7dbd7834d@j32g2000yqc.googlegroups.com> <5c6ff40f-05c1-4e38-89bc-b8c4745db7ce@i18g2000yqn.googlegroups.com> <9a036db2-9f32-441f-aa0f-698ac22fb152@e20g2000vbn.googlegroups.com> <981140f7-79d4-421d-88c1-c819f38a3d49@w2g2000yqb.googlegroups.com><4D37AA0F.3010601@gmail.com> <953B2583-5609-4C0C-9B4F-CA46F9E570F4@cagttraining.com> Message-ID: <1295531335.9910.1416305309@webmail.messagingengine.com> Bill, > I can't believe anyone is so hung up by their own arrogance that they honestly believe that the mere *presence* of a gui kit inside of the standard distribution would prevent a newbie from learning about the existence and possible benefits of alternatives ... ESPECIALLY in a language widely touted for the vast array of external libraries available. The attitude that the standard distribution needs this kind of obsessive, hysterically blinkered, focused on irrelevant minutiae is far more likely to be the downfall of the language than the presence of a sub-optimal gui kit that no one is required to use ... +1 (very well said) Malcolm From marrina0012 at gmail.com Thu Jan 20 08:51:00 2011 From: marrina0012 at gmail.com (Marrina anderson tina) Date: Thu, 20 Jan 2011 05:51:00 -0800 (PST) Subject: USA Free classified site for free ad posting !!! Message-ID: We are providing free services for all !!! Guys, are you looking for having nice opportunity to post or submit your advertisement without any impediments! Just visit and get gigantic chance to give free advertisement in our here !!! Just visit at: http://www.webadlist.com/ From user at compgroups.net/ Thu Jan 20 09:16:50 2011 From: user at compgroups.net/ (lakshmi) Date: Thu, 20 Jan 2011 08:16:50 -0600 Subject: difference between python and matlab Message-ID: Is the programming related to image processing in python is advantageous or else in MATLAB From jarausch at skynet.be Thu Jan 20 09:31:09 2011 From: jarausch at skynet.be (Helmut Jarausch) Date: 20 Jan 2011 14:31:09 GMT Subject: getdefaultencoding - how to change this? Message-ID: <4d38472d$0$14250$ba620e4c@news.skynet.be> Hi, I've searched the net but didn't find the information I need. Using Python-2.7.1, I know, I can't modify defaultencoding at run time. Python even ignores export PYTHONIOENCODING=ISO8859-1 locale.getdefaultlocale()[1] returns 'ISO8859-1' still sys.stdout is using the ascii codec. How can I recompile Python (itself) to change this to iso8859-1 ? (My favourite editor cannot be told to use unicode.) Many thanks for a hint, Helmut. From askutt at gmail.com Thu Jan 20 09:40:44 2011 From: askutt at gmail.com (Adam Skutt) Date: Thu, 20 Jan 2011 06:40:44 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com><4d337983$0$29983$c3e8da3$5496439d@news.astraweb.com><044a5101-948d-4458-9c94-57dbb3e25f67@m35g2000vbn.googlegroups.com><4d3467bf$0$29983$c3e8da3$5496439d@news.astraweb.com><4D34B04E.8050309@web.de><4266E8D7BA204BFEA5BF66C635CE1716@octavian><4D35DCE8.5030002@web.de><4D35DD47.1070304@web.de><7A0C7934E65D4B85A584C06ADD3B6ECF@teddy> Message-ID: <3dfec259-7b57-4ed2-9aba-d9f4476a25b3@32g2000yqz.googlegroups.com> On Jan 20, 8:19?am, "Octavian Rasnita" wrote: > The Windows applications are not accessible only if they use MSAA. The > screen readers know how to get the necessary information for making the > interfaces accessible in other ways, but of course, it is harder for the > screen reader manufacturers if the GUIs don't respect a standard. Actually, JAWS uses MSAA dead last, as I understand it, because the API is truly that awful. But MSAA is necessary whenever you're not using a Win32 common control or most of the other stuff developed by MS. That means essentially every non-MS toolkit that's been discussed. > And if MSAA is hated it doesn't mean that the accessibility is so poor as > you might think. No, but it does mean precisely what I said: application developers can do the "right" thing and get the wrong result. > Yes, that's a problem but we divagate. If you believe that is a problem then you cannot say, "Accessibility does not require special effort" without contradicting yourself. If it did not require effort over and above the norm, then the cultural problem would not exist. > Yes of course, Adobe's products are at most very hard accessible or not > accessible at all and I already said that Gtk is not accessible under > Windows, just like Tk. Which means you're excluding a large swath of applications in your analysis. > Well, I haven't used WxPython until now, but only WxPerl, however the WxPerl > programmers don't need to set the tab focus because by default the tab focus > is set in the order of the controls on the form and I thought it should be > the same in WxPython. It's set in the order you create the controls (with some exceptions), which may or may not be the correct tab focus order. Moreover, the same FAQ I linked tells you that you need to set special styles to support proper tab order when tabbed widgets and certain other controls are involved, to say nothing of fall backs for certain other controls that aren't provided automatically. > Yes, that's true, but as I said, some GUIS like WxPython offer the > accessibility, so those controls are visible, and it is less important if > they are in a right tab order or if some of the controls are not labeled, > because the screen reader can solve these things. You've said yourself that it often requires trial and error on the part of the user, so which is it? > A GUI which offers accessible widgets only if they are coded specially for > beeing accessible are not accessible at all, That's the case with every GUI API on the planet: if you write a custom widget you must provide accessibility support for it. This is nothing new. > Have you created that QT application with its default options? Without doing > anything special to make it accessible? Yes, you don't have to do a thing, unless you're custom building Qt yourself. On Linux, you have to set QT_ACCESSIBILITY = 1, but Linux is the exception. > And most important, have you tested it with JAWS screen reader? (Or > WindowEyes at least) because these are the most used screen readers. > NVDA is pretty poor and it can't be used for very complex things (yet). > No, and I have zero interest in doing so. Point was merely to demonstrate your statement was false. Adam From bkline at rksystems.com Thu Jan 20 10:08:40 2011 From: bkline at rksystems.com (Bob Kline) Date: Thu, 20 Jan 2011 10:08:40 -0500 Subject: Part of RFC 822 ignored by email module Message-ID: <4D384FF8.6060708@rksystems.com> I just noticed that the following passage in RFC 822: The process of moving from this folded multiple-line representation of a header field to its single line represen- tation is called "unfolding". Unfolding is accomplished by regarding CRLF immediately followed by a LWSP-char as equivalent to the LWSP-char. is not being honored by the email module. The following two invocations of message_from_string() should return the same value, but that's not what happens: >>> import email >>> email.message_from_string("Subject: blah").get('SUBJECT') 'blah' >>> email.message_from_string("Subject:\n blah").get('SUBJECT') ' blah' Note the space in front of the second value returned, but missing from the first. Can someone convince me that this is not a bug? -- Bob Kline http://www.rksystems.com mailto:bkline at rksystems.com From rantingrick at gmail.com Thu Jan 20 10:11:16 2011 From: rantingrick at gmail.com (rantingrick) Date: Thu, 20 Jan 2011 07:11:16 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <2ef2fa6c-2ccf-453a-8f50-0ef7dbd7834d@j32g2000yqc.googlegroups.com> <5c6ff40f-05c1-4e38-89bc-b8c4745db7ce@i18g2000yqn.googlegroups.com> <9a036db2-9f32-441f-aa0f-698ac22fb152@e20g2000vbn.googlegroups.com> <981140f7-79d4-421d-88c1-c819f38a3d49@w2g2000yqb.googlegroups.com> <4D37AA0F.3010601@gmail.com> Message-ID: <6d1bfa09-591b-47a4-9d3f-3edcd20019da@z5g2000yqb.googlegroups.com> On Jan 20, 6:30?am, Bill Felton wrote: > With some hesitation, I feel a need to jump in here. I'm a complete > newbie to Python. I'm still learning the language. And you know > what? I've ignored Tkinter. Well it is really not a good idea to show your ignorance of a subject matter directly before offering your opinion on that same subject matter. Most people don't listen to the uninformed. Just FYI. However lucky for you i am a fair guy and will give anyone a chance, sometimes even two. ;-) > I quickly discovered the alternatives and am already working with > wxPython. But is wxPython the correct alternative for you? What is so bad about Tkinter exactly?. Why did you choose to skip it? There must be a compelling reason. Why did you go out of your way to download another GUI library when one exists in the stdlib? These are all good questions that demand answers. So far you've offered opinion and no facts. You said you ignored Tkinter but you did not explain why. Now would be a good time to inject some facts into your argument. > I can't believe anyone is so hung up by their own arrogance that > they honestly believe that the mere *presence* of a gui kit inside > of the standard distribution would prevent a newbie from learning > about the existence and possible benefits of alternatives. No one has ever said such an outlandish thing as this. You have missed the entire point of this thread, congratulations! Now, go back and read over the entire thread again and again until you comprehend it completely before making another post. I look forward to your coherent and lively discussion based on facts and not simply opinions. > Sure, *they* can see alternatives and evaluate why Tkinter might not > be a good choice under conditions x or y or z, but god forbid anyone > new to the language should have to confront those issues or be asked > to make such a decision. How could we trust those lowly newbies to > think *properly* about the issue! We can't. Are you actually suggestion that someone with NO experience with ANY of the GUI library available somehow has a better insight into choosing the best GUI library than someone who (i don't know) ACTUALLY HAS USED ALL OF THEM! Who's sock puppet are you Bill? Really. And if you are not a sock puppet i HOPE you are just trolling because this is a bombastic display of ignorance!. You could not be more *uninformed* my friend. Heck with your mindset, the "Cookie Monster" should replace Guido as BDFL. He has NO experience with anything besides chowing down cookies, perfect choice! > ESPECIALLY in a language widely touted for the vast array of > external libraries available.The attitude that the standard > distribution needs this kind of obsessive, hysterically blinkered, > focused on irrelevant minutiae is far more likely to be the downfall > of the language than the presence of a sub-optimal gui kit that no > one is required to use. Yes, and you just hit the nail on the the head! Why leave the stdlib full of cruft (Tkinter)? > As one of 'the people' who is presumably the focus of rantingrick's > concern, let me assure him Tkinter is a non-issue. MIchael is more > in touch with my issues than rr. FYI you are NOT one of the people that is the focus of my concern because YOU only see the world from a limited viewpoint. And i never proposed to solve every Python programmers problems. You completely misunderstand my intentions (along with everyone else!). I do not believe in "Utopian dreams". Some people will never be happy with the state of Python and that is OK. However, the goal is to keep the majority happy AND keep Python "presentable" and "competitive" for the next decade. I am sorry you don't fit into any of these categories but that is your own fault. Why? Because you are not concerned with the community as a whole. You are only concerned with YOURSELF. You are displaying both selfishness and ignorance at the same time. We don't care what selfish people think and we care even less what the ignorant think. If you decide to become a "team player" then you will be a part of this community. Lucky for you ignorance and selfishness are reversible personality traits. From rantingrick at gmail.com Thu Jan 20 10:13:00 2011 From: rantingrick at gmail.com (rantingrick) Date: Thu, 20 Jan 2011 07:13:00 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <2ef2fa6c-2ccf-453a-8f50-0ef7dbd7834d@j32g2000yqc.googlegroups.com> <5c6ff40f-05c1-4e38-89bc-b8c4745db7ce@i18g2000yqn.googlegroups.com> <9a036db2-9f32-441f-aa0f-698ac22fb152@e20g2000vbn.googlegroups.com> <981140f7-79d4-421d-88c1-c819f38a3d49@w2g2000yqb.googlegroups.com><4D37AA0F.3010601@gmail.com> <953B2583-5609-4C0C-9B4F-CA46F9E570F4@cagttraining.com> Message-ID: <94d38d79-a64b-4976-8f7e-cbd083fa5ad5@d8g2000yqf.googlegroups.com> On Jan 20, 7:48?am, pyt... at bdurham.com wrote: > Bill, [...snip...] > +1 (very well said) Yes maybe Bill should be BDFL or a core developer. He has all the answers. But no FACTS! From jarausch at skynet.be Thu Jan 20 10:39:34 2011 From: jarausch at skynet.be (Helmut Jarausch) Date: 20 Jan 2011 15:39:34 GMT Subject: getdefaultencoding - how to change this? References: <4d38472d$0$14250$ba620e4c@news.skynet.be> Message-ID: <4d385736$0$14253$ba620e4c@news.skynet.be> On Thu, 20 Jan 2011 14:31:09 +0000, Helmut Jarausch wrote: > Hi, > I've searched the net but didn't find the information I need. Using > Python-2.7.1, I know, I can't modify defaultencoding at run time. Python > even ignores > export PYTHONIOENCODING=ISO8859-1 > > locale.getdefaultlocale()[1] > returns > 'ISO8859-1' > > still sys.stdout is using the ascii codec. How can I recompile Python > (itself) to change this to iso8859-1 ? (My favourite editor cannot be > told to use unicode.) > Sorry for answering myself. One last trial did succeed. My locale as root differed from my locale as non-root user. After changing the root locale and recompiling Python, it works now. -- From invalid at invalid.invalid Thu Jan 20 10:42:55 2011 From: invalid at invalid.invalid (Grant Edwards) Date: Thu, 20 Jan 2011 15:42:55 +0000 (UTC) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <2510bf88-1045-411f-9ccd-7ca7c3665454@l24g2000vby.googlegroups.com> <2ef2fa6c-2ccf-453a-8f50-0ef7dbd7834d@j32g2000yqc.googlegroups.com> <5c6ff40f-05c1-4e38-89bc-b8c4745db7ce@i18g2000yqn.googlegroups.com> <9a036db2-9f32-441f-aa0f-698ac22fb152@e20g2000vbn.googlegroups.com> <981140f7-79d4-421d-88c1-c819f38a3d49@w2g2000yqb.googlegroups.com> Message-ID: On 2011-01-20, Michael Torrie wrote: > I don't see the original bizarre rants for some reason (spam filter > likely), but I have to say this is the most ridiculous thing I've heard > in some time. Tkinter the downfall of python? Wow. All of the python > programmers I know (we use python every day at work) would say, "what > is tkinter?" It's just not relevant to any of them that I know. Google > probably uses as much Python as anyone, and their programmers would > probably agree. Perhaps that's an argument to remove tkinter entirely, > but not really a good one. > > In the meantime they happily crank out code with Django, or PyQt, or > PyGTK, or even Tkinter--whatever tool is appropriate for the job. Tkinter has it's flaws. For example, the fact that it inclues a Tcl interpreter inside the black box annoys me because I think Tcl is an awful, awful language. That's somewhat irrational, so perhaps that's my flaw and not Tkinter's. However, Tkinter is easy to use (especially for simple tasks) and it _works_. I wrote a moderatly complex (to me) UI in Tkinter 10+ years ago. It still works fine. I couldn't say that about some wxPython programs a quarter that old. > Perhaps a reference to Xah Lee's web site would suffice. :) -- Grant Edwards grant.b.edwards Yow! What GOOD is a at CARDBOARD suitcase ANYWAY? gmail.com From jarausch at skynet.be Thu Jan 20 10:43:05 2011 From: jarausch at skynet.be (Helmut Jarausch) Date: 20 Jan 2011 15:43:05 GMT Subject: printing a list with non-ascii strings Message-ID: <4d385809$0$14253$ba620e4c@news.skynet.be> Hi, I don't understand Python's behaviour when printing a list. The following example uses 2 German non-ascii characters. #!/usr/bin/python # _*_ coding: latin1 _*_ L=["abc","s??","def"] print L[1],L The output of L[1] is correct, while the output of L shows up as ['abc', 's\xfc\xdf', 'def'] How can this be changed? Thanks for hint, Helmut. From invalid at invalid.invalid Thu Jan 20 10:44:07 2011 From: invalid at invalid.invalid (Grant Edwards) Date: Thu, 20 Jan 2011 15:44:07 +0000 (UTC) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <4d337983$0$29983$c3e8da3$5496439d@news.astraweb.com> <044a5101-948d-4458-9c94-57dbb3e25f67@m35g2000vbn.googlegroups.com> <4d3467bf$0$29983$c3e8da3$5496439d@news.astraweb.com> <4D34B04E.8050309@web.de> <4266E8D7BA204BFEA5BF66C635CE1716@octavian> <4D35DCE8.5030002@web.de> <4D35DD47.1070304@web.de> <42924000-3ffb-40f5-9cf8-70a9d767b944@k25g2000vbl.googlegroups.com> Message-ID: On 2011-01-20, Octavian Rasnita wrote: > From: "Grant Edwards" >>>> On all of my computers, wxPython uses Gtk. There are other choices >>>> for wxWidget backends on Linux, but Gtk is by far the most common. >>>> IOW, if Gtk is bad, then wxPython is bad. >>> >>> Not true. >> >> I think you're playing a bit fast and loose with your accusations. > > >:-) > I've made no accusations, Yes you have. You claimed what I stated was not true. > but I only try to inform the people about the > accessibility of different GUI libs. > >> Which of my statements was "not true"? >> >> 1) On all of my computers wxPython uses Gtk. >> >> 2) There are other backend choices on Linux besides Gtk. >> >> 3) Gtk is by far the most common wxWidgets backend on Linux/Unix. >> >> 4) If Gtk is bad then wxPython is bad. >> >> Note that 4) follows logically from 3), so to say that 4) is "not >> true" you have to show that 3) is "not true". > > The wrong conclusion is that if Gtk is bad, then WxPython is bad. Gtk > is inaccessible under Windows, not under Linux, but WxPython doesn't > use Gtk under Windows so WxPython is OK. Ah. I didn't realize we were operating under the premise that Windows was the only OS that mattered. Sorry. -- Grant Edwards grant.b.edwards Yow! Maybe I should have at asked for my Neutron Bomb gmail.com in PAISLEY -- From orasnita at gmail.com Thu Jan 20 10:44:22 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Thu, 20 Jan 2011 17:44:22 +0200 Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com><4d337983$0$29983$c3e8da3$5496439d@news.astraweb.com><044a5101-948d-4458-9c94-57dbb3e25f67@m35g2000vbn.googlegroups.com><4d3467bf$0$29983$c3e8da3$5496439d@news.astraweb.com><4D34B04E.8050309@web.de><4266E8D7BA204BFEA5BF66C635CE1716@octavian><4D35DCE8.5030002@web.de><4D35DD47.1070304@web.de><7A0C7934E65D4B85A584C06ADD3B6ECF@teddy> <3dfec259-7b57-4ed2-9aba-d9f4476a25b3@32g2000yqz.googlegroups.com> Message-ID: <56E10397013948838919D68AA6A89BFA@teddy> From: "Adam Skutt" Actually, JAWS uses MSAA dead last, as I understand it, because the API is truly that awful. But MSAA is necessary whenever you're not using a Win32 common control or most of the other stuff developed by MS. That means essentially every non-MS toolkit that's been discussed. Yes, but WxPython uses wxWIDGETS and wxWIDGETS use the standard Win32 controls under Windows, so they are accessible. And they use Gtk under Linux and Gtk is accessible under Linux also. That's why I said that WxPython should be prefered. > And if MSAA is hated it doesn't mean that the accessibility is so poor as > you might think. No, but it does mean precisely what I said: application developers can do the "right" thing and get the wrong result. Yes of course they can do that if they use the wrong tool. They can't do the right thing if they believe that Tk or Silverlight or Flash is accessible no matter if they follow the recommendations for accessibility, because the screen readers don't support those interfaces. > Yes, that's a problem but we divagate. If you believe that is a problem then you cannot say, "Accessibility does not require special effort" without contradicting yourself. If it did not require effort over and above the norm, then the cultural problem would not exist. Nope, the cultural problem exists because the programmers use the wrong interface, not because they just don't make the efforts for making that interface more accessible. To be more clear and not to include in the discussion many interfaces, we are comparing Tkinter and WxPython. Most users that require accessibility are using Windows and under Windows WxPython use the underlying Win32 GUI which is accessible, while Tk is not accessible at all, no matter what the programmers do in order to make the interface accessible. > Yes of course, Adobe's products are at most very hard accessible or not > accessible at all and I already said that Gtk is not accessible under > Windows, just like Tk. Which means you're excluding a large swath of applications in your analysis. I am not excluding anything. I said that all the Tk-based programs are inaccessible no matter what the programmer does to make it accessible, because the screen readers can't work with that interface. And I have also said which are the accessible interfaces: wxWIDGETS (which use Win32 GUI under Windows and Gtk under Linux), SWT (which I think it does exactly the same thing as wxWIDGETS), WindowsForms (DotNet) and SWING (if the user installs Java Access Bridge). Some of the interfaces created with other GUI libs might be accessible but it is not sure. What is sure is that the Tk-based interfaces are not accessible. > Well, I haven't used WxPython until now, but only WxPerl, however the WxPerl > programmers don't need to set the tab focus because by default the tab focus > is set in the order of the controls on the form and I thought it should be > the same in WxPython. It's set in the order you create the controls (with some exceptions), which may or may not be the correct tab focus order. Moreover, the same FAQ I linked tells you that you need to set special styles to support proper tab order when tabbed widgets and certain other controls are involved, to say nothing of fall backs for certain other controls that aren't provided automatically. Yes, but with or without a proper tab order, WxPython creates accessible apps, while Tkinter doesn't. > Yes, that's true, but as I said, some GUIS like WxPython offer the > accessibility, so those controls are visible, and it is less important if > they are in a right tab order or if some of the controls are not labeled, > because the screen reader can solve these things. You've said yourself that it often requires trial and error on the part of the user, so which is it? It depends if there is a JAWS script defined. JAWS provides by default scripts for dozens of popular applications for making them more usable. Each user can create his/her own script, because JAWS include that scripting language and a programming interface so the user can create their own script for an application for improving its usability, for labeling some not-named controls, for reading some parts of the screen when some events occur and many other things. If the user doesn't want or don't know how to create that script for improving the usability, he/she might need to learn how to use the application by trial and error, but what I want to show is that the user is *able* to use that application, even if the interface is not very friendly, but it would be absolutely impossible to use an application created with Tkinter. > A GUI which offers accessible widgets only if they are coded specially for > beeing accessible are not accessible at all, That's the case with every GUI API on the planet: if you write a custom widget you must provide accessibility support for it. This is nothing new. I am not talking about custom controls. Those things are the worst thing possible from the perspective of accessibility, because usually nobody cares about providing accessibility features. I am talking about standard controls. The standard controls provided by WxPython are accessible, no matter how usable and friendly they are, while the standard controls offered by Tkinter are absolutely inaccessible. > Have you created that QT application with its default options? Without doing > anything special to make it accessible? Yes, you don't have to do a thing, unless you're custom building Qt yourself. On Linux, you have to set QT_ACCESSIBILITY = 1, but Linux is the exception. > And most important, have you tested it with JAWS screen reader? (Or > WindowEyes at least) because these are the most used screen readers. > NVDA is pretty poor and it can't be used for very complex things (yet). > No, and I have zero interest in doing so. Point was merely to demonstrate your statement was false. My point was that Tkinter which uses Tk is bad, and I didn't tried too many QT-based applications. It would be nice if now QT would be accessible, but this won't mean too much if it would be accessible just for NVDA and not for the most used screen readers. And I don't see what you demonstrate when you wanted to show Tkinter it is comparing with WxPython... Octavian From philip at semanchuk.com Thu Jan 20 10:47:54 2011 From: philip at semanchuk.com (Philip Semanchuk) Date: Thu, 20 Jan 2011 10:47:54 -0500 Subject: getdefaultencoding - how to change this? In-Reply-To: <4d385736$0$14253$ba620e4c@news.skynet.be> References: <4d38472d$0$14250$ba620e4c@news.skynet.be> <4d385736$0$14253$ba620e4c@news.skynet.be> Message-ID: <31001839-2E89-4D3E-B3D4-26BFA6D00EAD@semanchuk.com> On Jan 20, 2011, at 10:39 AM, Helmut Jarausch wrote: > On Thu, 20 Jan 2011 14:31:09 +0000, Helmut Jarausch wrote: > >> Hi, >> I've searched the net but didn't find the information I need. Using >> Python-2.7.1, I know, I can't modify defaultencoding at run time. Python >> even ignores >> export PYTHONIOENCODING=ISO8859-1 >> >> locale.getdefaultlocale()[1] >> returns >> 'ISO8859-1' >> >> still sys.stdout is using the ascii codec. How can I recompile Python >> (itself) to change this to iso8859-1 ? (My favourite editor cannot be >> told to use unicode.) >> > > Sorry for answering myself. One last trial did succeed. > My locale as root differed from my locale as non-root user. > After changing the root locale and recompiling Python, it works now. I'm glad that worked for you. Alternatively, it seems like you can set the default encoding in site.py which sounds easier than recompiling Python. Cheers Philip From rantingrick at gmail.com Thu Jan 20 10:58:53 2011 From: rantingrick at gmail.com (rantingrick) Date: Thu, 20 Jan 2011 07:58:53 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <4d3467bf$0$29983$c3e8da3$5496439d@news.astraweb.com> <4D34B04E.8050309@web.de> <4266E8D7BA204BFEA5BF66C635CE1716@octavian> <4D35DCE8.5030002@web.de> <4D35DD47.1070304@web.de> <42924000-3ffb-40f5-9cf8-70a9d767b944@k25g2000vbl.googlegroups.com> Message-ID: <165b3519-c7f7-4d4d-8137-1558d4dabc20@v26g2000yqf.googlegroups.com> On Jan 20, 9:44?am, Grant Edwards wrote: > > The wrong conclusion is that if Gtk is bad, then WxPython is bad. Gtk > > is inaccessible under Windows, not under Linux, but WxPython doesn't > > use Gtk under Windows so WxPython is OK. > > Ah. ?I didn't realize we were operating under the premise that Windows > was the only OS that mattered. ?Sorry. Windows IS the only OS that matters WHEN we are talking about "hand holding". Anyone who uses Unix/Linux and cries about downloading dependencies is just doing so for sake of discrediting the opposite position. Only the lemmings would believe such nonsense. Unix/Linux are NOT hand holding OS's. Thats what windows is for. And the argument presented earlier (i think Octavian) about how the majority of accessibility users are using windows is spot on! Anyone who also denies this fact is just contributing more BS to the "devils advocates" here. I am not suggesting that accessibility is not important to a small sub set of Linux users. However the fact is that the majority of "special needs" folks use windows. And thats a fact! From benjamin.kaplan at case.edu Thu Jan 20 11:03:32 2011 From: benjamin.kaplan at case.edu (Benjamin Kaplan) Date: Thu, 20 Jan 2011 11:03:32 -0500 Subject: printing a list with non-ascii strings In-Reply-To: <4d385809$0$14253$ba620e4c@news.skynet.be> References: <4d385809$0$14253$ba620e4c@news.skynet.be> Message-ID: On Thu, Jan 20, 2011 at 10:43 AM, Helmut Jarausch wrote: > Hi, > > I don't understand Python's behaviour when printing a list. > The following example uses 2 German non-ascii characters. > > #!/usr/bin/python > # _*_ coding: latin1 _*_ > L=["abc","s??","def"] > print L[1],L > > The output of L[1] is correct, while the output of L shows up as > ['abc', 's\xfc\xdf', 'def'] > > How can this be changed? > > Thanks for hint, > Helmut. > > Use Python 3 if you can. Printing a list calls the repr(). In python 2, that showed the bytes for non-ascii characters. Python 3 will print the characters. > -- > http://mail.python.org/mailman/listinfo/python-list > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rustompmody at gmail.com Thu Jan 20 11:36:20 2011 From: rustompmody at gmail.com (rusi) Date: Thu, 20 Jan 2011 08:36:20 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <2ef2fa6c-2ccf-453a-8f50-0ef7dbd7834d@j32g2000yqc.googlegroups.com> <5c6ff40f-05c1-4e38-89bc-b8c4745db7ce@i18g2000yqn.googlegroups.com> <9a036db2-9f32-441f-aa0f-698ac22fb152@e20g2000vbn.googlegroups.com> <981140f7-79d4-421d-88c1-c819f38a3d49@w2g2000yqb.googlegroups.com> <4D37AA0F.3010601@gmail.com> Message-ID: <8871b602-2cd4-43c4-b289-63e0bc167714@z17g2000prz.googlegroups.com> On Jan 20, 5:30?pm, Bill Felton wrote: > With some hesitation, I feel a need to jump in here. ? This thread is now at 239 posts (and so I too hesitate...) The arguments for size, dependencies etc are what may be termed 'sys- ad' perspectives. The questions of 'it looks nice/ancient etc' are user issues. What about some programmer perspective? Using something like VB-in-.NET allows a programmer to put up significant uis with close to zero coding. Many programmers would look down on these as 'non-programmers' [I should know: I inhabited a university CS dept for nearly 20 years where Turing machines and lambda calculus are fashionable and getchar/ putchar programs are more hip than pleasant-looking GUIs. Many of our problems stem from the fact that this academic hubris is justified as objective] So the (to me) relevant questions relating to GUIs are for example: 1. Is glade (and others such) equal to wxpython, tkinter and other such 'backends'? 2. Can glade (or whichever is the best such tool today) compare to VB in .NET or does it look like a bad joke in comparison (I guess the current thing may not be VB but WPF but I dont want to pretend to know too much about windows) From robert.kern at gmail.com Thu Jan 20 11:46:37 2011 From: robert.kern at gmail.com (Robert Kern) Date: Thu, 20 Jan 2011 10:46:37 -0600 Subject: getdefaultencoding - how to change this? In-Reply-To: <4d38472d$0$14250$ba620e4c@news.skynet.be> References: <4d38472d$0$14250$ba620e4c@news.skynet.be> Message-ID: On 1/20/11 8:31 AM, Helmut Jarausch wrote: > Hi, > I've searched the net but didn't find the information I need. > Using Python-2.7.1, I know, I can't modify defaultencoding at run time. You're not supposed to. It must remain 'ascii'. Otherwise, you will break dict lookups among other things. Can you be specific about why you think you want to change this? What are you trying to achieve? It looks like you are conflating a variety of different behaviors below. > Python even ignores > export PYTHONIOENCODING=ISO8859-1 > > locale.getdefaultlocale()[1] > returns > 'ISO8859-1' This does not introspect the same thing as sys.getdefaultencoding(). > still sys.stdout is using the ascii codec. This reflects your terminal settings, not sys.getdefaultencoding(). I'm not sure why the PYTHONIOENCODING variable isn't affecting that. It works fine for me. > How can I recompile Python (itself) to change this to iso8859-1 ? > (My favourite editor cannot be told to use unicode.) You wouldn't want to change sys.getdefaultencoding() for this. That parameter affects how str and unicode objects are converted between each other without an explicit .encode()/.decode() call, not what encoding Python assumes for the parsing of the code. Instead, you want to use an encoding declaration in each file: http://docs.python.org/reference/lexical_analysis.html#encoding-declarations -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco From robert.kern at gmail.com Thu Jan 20 11:47:42 2011 From: robert.kern at gmail.com (Robert Kern) Date: Thu, 20 Jan 2011 10:47:42 -0600 Subject: getdefaultencoding - how to change this? In-Reply-To: <31001839-2E89-4D3E-B3D4-26BFA6D00EAD@semanchuk.com> References: <4d38472d$0$14250$ba620e4c@news.skynet.be> <4d385736$0$14253$ba620e4c@news.skynet.be> <31001839-2E89-4D3E-B3D4-26BFA6D00EAD@semanchuk.com> Message-ID: On 1/20/11 9:47 AM, Philip Semanchuk wrote: > I'm glad that worked for you. Alternatively, it seems like you can set the default encoding in site.py which sounds easier than recompiling Python. Never do that. It breaks dicts and makes your code non-portable. -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco From subscriptions at cagttraining.com Thu Jan 20 11:48:21 2011 From: subscriptions at cagttraining.com (Bill Felton) Date: Thu, 20 Jan 2011 11:48:21 -0500 Subject: Tkinter: The good, the bad, and the ugly! In-Reply-To: <6d1bfa09-591b-47a4-9d3f-3edcd20019da@z5g2000yqb.googlegroups.com> References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <2ef2fa6c-2ccf-453a-8f50-0ef7dbd7834d@j32g2000yqc.googlegroups.com> <5c6ff40f-05c1-4e38-89bc-b8c4745db7ce@i18g2000yqn.googlegroups.com> <9a036db2-9f32-441f-aa0f-698ac22fb152@e20g2000vbn.googlegroups.com> <981140f7-79d4-421d-88c1-c819f38a3d49@w2g2000yqb.googlegroups.com> <4D37AA0F.3010601@gmail.com> <6d1bfa09-591b-47a4-9d3f-3edcd20019da@z5g2000yqb.googlegroups.com> Message-ID: On Jan 20, 2011, at 10:11 AM, rantingrick wrote: > On Jan 20, 6:30 am, Bill Felton > wrote: > >> With some hesitation, I feel a need to jump in here. I'm a complete >> newbie to Python. I'm still learning the language. And you know >> what? I've ignored Tkinter. > > Well it is really not a good idea to show your ignorance of a subject > matter directly before offering your opinion on that same subject > matter. Most people don't listen to the uninformed. Just FYI. However > lucky for you i am a fair guy and will give anyone a chance, sometimes > even two. ;-) > You are too kind. Given that the strong implication of your point about 'downfall' was that newcomers would somehow be negatively impacted by Tkinter, I would think you would welcome input from that part of the audience. >> I quickly discovered the alternatives and am already working with >> wxPython. > > But is wxPython the correct alternative for you? What is so bad about > Tkinter exactly?. Why did you choose to skip it? There must be a > compelling reason. Why did you go out of your way to download another > GUI library when one exists in the stdlib? These are all good > questions that demand answers. So far you've offered opinion and no > facts. You said you ignored Tkinter but you did not explain why. Now > would be a good time to inject some facts into your argument. Ah, ah, ah, not appropriate to the point at hand. This isn't about me, this is about the absurd claim that the inclusion of Tkinter in the Python standard distribution is a 'downfall' point for the language. I think that point has been disabused, although you may well still be sticking with it. [snip] >> [Sure, *they* can see alternatives and evaluate why Tkinter might not >> be a good choice under conditions x or y or z, but god forbid anyone >> new to the language should have to confront those issues or be asked >> to make such a decision. How could we trust those lowly newbies to >> think *properly* about the issue! > > We can't. Are you actually suggestion that someone with NO experience > with ANY of the GUI library available somehow has a better insight > into choosing the best GUI library than someone who (i don't know) > ACTUALLY HAS USED ALL OF THEM! Ahs, I see, you have been infected by "the best bug". There is no such thing as 'the best' anything absent the standard that is used to judge. And multiple standards apply. > Who's sock puppet are you Bill? Really. > And if you are not a sock puppet i HOPE you are just trolling because > this is a bombastic display of ignorance!. rantingrick, meet mirror, mirror, meet rantingrick. I can't say I'm surprised to see this kind of response from you, this leap from my post to the assumption that I know nothing about programming or about GUIs. FWIW, I have 20+ years of experience with Smalltalk and am well aware of GUI issues and the manifold ways in which they must be approached and judged. Your little 'one size must fit all" attitude is what will be the downfall of Python, or any other language infected with it. We saw that with Smalltalk and its community, we see it everywhere. [snip] > > Yes, and you just hit the nail on the the head! Why leave the stdlib > full of cruft (Tkinter)? At least two reasons, one big one, one little one. The little one: because TKinter provides the base for such things as IDLE, which are a genuine boon to the newcomer. The big one: because you have somehow failed to demonstrate that Tkiinter is cruft. You've demonstrated you don't like it, you've asserted, at great length and in a wide variety of ways and countless posts, that it is cruft, but somehow the proof remains absent. Yet you whine about others not providing 'FACTS'. Why should anyone listen to you on this matter, most especially when you labor under the tedious delusion that there is such a thing as 'the best GUI' without constraint. Of course, you could always produce one... > >> As one of 'the people' who is presumably the focus of rantingrick's >> concern, let me assure him Tkinter is a non-issue. MIchael is more >> in touch with my issues than rr. > > FYI you are NOT one of the people that is the focus of my concern > because YOU only see the world from a limited viewpoint. EVERYONE sees the world from a limited viewpoint. Most of us realize this, and find those of you who don't at least faintly annoying. cheers, Bill -------------- next part -------------- An HTML attachment was scrubbed... URL: From philip at semanchuk.com Thu Jan 20 11:58:41 2011 From: philip at semanchuk.com (Philip Semanchuk) Date: Thu, 20 Jan 2011 11:58:41 -0500 Subject: getdefaultencoding - how to change this? In-Reply-To: References: <4d38472d$0$14250$ba620e4c@news.skynet.be> <4d385736$0$14253$ba620e4c@news.skynet.be> <31001839-2E89-4D3E-B3D4-26BFA6D00EAD@semanchuk.com> Message-ID: On Jan 20, 2011, at 11:47 AM, Robert Kern wrote: > On 1/20/11 9:47 AM, Philip Semanchuk wrote: > >> I'm glad that worked for you. Alternatively, it seems like you can set the default encoding in site.py which sounds easier than recompiling Python. > > Never do that. It breaks dicts and makes your code non-portable. I've never been tempted for the very non-portability reason you cite. I didn't know that it would break dicts, though. Thanks for the education. bye Philip From ckaynor at zindagigames.com Thu Jan 20 12:01:51 2011 From: ckaynor at zindagigames.com (Chris Kaynor) Date: Thu, 20 Jan 2011 09:01:51 -0800 Subject: collections.Set Binary Reflected Operations In-Reply-To: References: Message-ID: Okay, thats what I was looking for, thanks. In my case, I'll just implement the (needed) reflected operators in my class. Chris On Wed, Jan 19, 2011 at 10:02 PM, Daniel Urban wrote: > On Thu, Jan 20, 2011 at 01:51, Chris Kaynor > wrote: > > I am implemented a custom set-like type which interacts with some > > third-party software when retrieving and mutating the set, and have > derived > > my custom type off of collections.MutableSet, however I have noticed that > > some of the magic methods supported by the built-in set do not fully > > function with my custom type. From this, I looked over the > > MutableSet definition in and it seems to be missing all of the reflected > > operators (__rsub__, __rand__, __ror__, __rxor__, and friends) for the > > operators it has defined. I can post a simple example case if desired. > > I am using Python 2.6.4 (with some in-house customizations), however a > quick > > look over the svn repository shown on python.org makes it appear that > these > > are also not implemented in Python 3. I was wondering if there is some > > reason for this, or if it was merely an oversight. > > Chris > > See http://bugs.python.org/issue8743 and also > http://bugs.python.org/issue2226 > > > Daniel > -------------- next part -------------- An HTML attachment was scrubbed... URL: From python at mrabarnett.plus.com Thu Jan 20 12:13:37 2011 From: python at mrabarnett.plus.com (MRAB) Date: Thu, 20 Jan 2011 17:13:37 +0000 Subject: Tkinter: The good, the bad, and the ugly! In-Reply-To: <6d1bfa09-591b-47a4-9d3f-3edcd20019da@z5g2000yqb.googlegroups.com> References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <2ef2fa6c-2ccf-453a-8f50-0ef7dbd7834d@j32g2000yqc.googlegroups.com> <5c6ff40f-05c1-4e38-89bc-b8c4745db7ce@i18g2000yqn.googlegroups.com> <9a036db2-9f32-441f-aa0f-698ac22fb152@e20g2000vbn.googlegroups.com> <981140f7-79d4-421d-88c1-c819f38a3d49@w2g2000yqb.googlegroups.com> <4D37AA0F.3010601@gmail.com> <6d1bfa09-591b-47a4-9d3f-3edcd20019da@z5g2000yqb.googlegroups.com> Message-ID: <4D386D41.7010506@mrabarnett.plus.com> On 20/01/2011 15:11, rantingrick wrote: > On Jan 20, 6:30 am, Bill Felton > wrote: > [snip] >> As one of 'the people' who is presumably the focus of rantingrick's >> concern, let me assure him Tkinter is a non-issue. MIchael is more >> in touch with my issues than rr. > > FYI you are NOT one of the people that is the focus of my concern > because YOU only see the world from a limited viewpoint. And i never > proposed to solve every Python programmers problems. You completely > misunderstand my intentions (along with everyone else!). I do not > believe in "Utopian dreams". Some people will never be happy with the > state of Python and that is OK. However, the goal is to keep the > majority happy AND keep Python "presentable" and "competitive" for the > next decade. I am sorry you don't fit into any of these categories but > that is your own fault. Why? Because you are not concerned with the > community as a whole. You are only concerned with YOURSELF. You are > displaying both selfishness and ignorance at the same time. We don't > care what selfish people think and we care even less what the ignorant > think. If you decide to become a "team player" then you will be a part > of this community. Lucky for you ignorance and selfishness are > reversible personality traits. > So you're going to lead the "peasants" (your word) whether they like it or not, and any who don't want to follow are clearly being selfish and ignorant? Have you ever thought that if everyone is misunderstanding your intentions, then perhaps you're doing something wrong? (BTW, welcome to Pythonia, Bill! Most of us are friendly. :-)) From jarausch at skynet.be Thu Jan 20 12:20:14 2011 From: jarausch at skynet.be (Helmut Jarausch) Date: 20 Jan 2011 17:20:14 GMT Subject: getdefaultencoding - how to change this? References: <4d38472d$0$14250$ba620e4c@news.skynet.be> Message-ID: <4d386ece$0$14262$ba620e4c@news.skynet.be> On Thu, 20 Jan 2011 10:46:37 -0600, Robert Kern wrote: > On 1/20/11 8:31 AM, Helmut Jarausch wrote: >> Hi, >> I've searched the net but didn't find the information I need. Using >> Python-2.7.1, I know, I can't modify defaultencoding at run time. > > You're not supposed to. It must remain 'ascii'. Otherwise, you will > break dict lookups among other things. Can you be specific about why you > think you want to change this? What are you trying to achieve? It looks > like you are conflating a variety of different behaviors below. > >> Python even ignores >> export PYTHONIOENCODING=ISO8859-1 >> >> locale.getdefaultlocale()[1] >> returns >> 'ISO8859-1' > > This does not introspect the same thing as sys.getdefaultencoding(). > >> still sys.stdout is using the ascii codec. > > This reflects your terminal settings, not sys.getdefaultencoding(). I'm > not sure why the PYTHONIOENCODING variable isn't affecting that. It > works fine for me. > >> How can I recompile Python (itself) to change this to iso8859-1 ? (My >> favourite editor cannot be told to use unicode.) > > You wouldn't want to change sys.getdefaultencoding() for this. That > parameter affects how str and unicode objects are converted between each > other without an explicit .encode()/.decode() call, not what encoding > Python assumes for the parsing of the code. > > Instead, you want to use an encoding declaration in each file: > > http://docs.python.org/reference/lexical_analysis.html#encoding- declarations Thanks Robert, probably I wasn't too clear about my issue. I couldn't "print" any non-ascii character to my console although my console has an en_US.iso88591 locale. I didn't modfiy anything in Python's source code. I noticed that my root account still had an ASCII locale. Now I have changed it such that the root account has the same locale as non-root accounts. Recompiling Python under such a root account has rectified things. Now I can print non-ascii characters if they are properly encoded. Thanks, Helmut. -- From pavlovevidence at gmail.com Thu Jan 20 12:23:11 2011 From: pavlovevidence at gmail.com (Carl Banks) Date: Thu, 20 Jan 2011 09:23:11 -0800 (PST) Subject: Part of RFC 822 ignored by email module References: Message-ID: On Jan 20, 7:08?am, Bob Kline wrote: > I just noticed that the following passage in RFC 822: > > ? ? ? ? ?The process of moving ?from ?this ?folded ? multiple-line > ? ? ? ? ?representation ?of a header field to its single line represen- > ? ? ? ? ?tation is called "unfolding". ?Unfolding ?is ?accomplished ?by > ? ? ? ? ?regarding ? CRLF ? immediately ?followed ?by ?a ?LWSP-char ?as > ? ? ? ? ?equivalent to the LWSP-char. > > is not being honored by the email module. ?The following two invocations > of message_from_string() should return the same value, but that's not > what happens: > > ?>>> import email > ?>>> email.message_from_string("Subject: blah").get('SUBJECT') > 'blah' > ?>>> email.message_from_string("Subject:\n blah").get('SUBJECT') > ' blah' > > Note the space in front of the second value returned, but missing from > the first. ?Can someone convince me that this is not a bug? That's correct, according to my reading of RFC 822 (I doubt it's changed so I didn't bother to look up what the latest RFC on that subject is.) The RFC says that in a folded line the whitespace on the following line is considered a part of the line. Relevant quite (section 3.1.1): Each header field can be viewed as a single, logical line of ASCII characters, comprising a field-name and a field-body. For convenience, the field-body portion of this conceptual entity can be split into a multiple-line representation; this is called "folding". The general rule is that wherever there may be linear-white-space (NOT simply LWSP-chars), a CRLF immediately followed by AT LEAST one LWSP-char may instead be inserted. Thus, the single line To: "Joe & J. Harvey" , JJV @ BBN can be represented as: To: "Joe & J. Harvey" , JJV at BBN and To: "Joe & J. Harvey" , JJV @BBN and To: "Joe & J. Harvey" , JJV @ BBN The process of moving from this folded multiple-line representation of a header field to its single line represen- tation is called "unfolding". Unfolding is accomplished by regarding CRLF immediately followed by a LWSP-char as equivalent to the LWSP-char. Carl Banks From subscriptions at cagttraining.com Thu Jan 20 12:24:08 2011 From: subscriptions at cagttraining.com (Bill Felton) Date: Thu, 20 Jan 2011 12:24:08 -0500 Subject: Tkinter: The good, the bad, and the ugly! In-Reply-To: <4D386D41.7010506@mrabarnett.plus.com> References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <2ef2fa6c-2ccf-453a-8f50-0ef7dbd7834d@j32g2000yqc.googlegroups.com> <5c6ff40f-05c1-4e38-89bc-b8c4745db7ce@i18g2000yqn.googlegroups.com> <9a036db2-9f32-441f-aa0f-698ac22fb152@e20g2000vbn.googlegroups.com> <981140f7-79d4-421d-88c1-c819f38a3d49@w2g2000yqb.googlegroups.com> <4D37AA0F.3010601@gmail.com> <6d1bfa09-591b-47a4-9d3f-3edcd20019da@z5g2000yqb.googlegroups.com> <4D386D41.7010506@mrabarnett.plus.com> Message-ID: <840B14A0-2050-4595-8014-5059BED9EEEE@cagttraining.com> On Jan 20, 2011, at 12:13 PM, MRAB wrote: > On 20/01/2011 15:11, rantingrick wrote: >> On Jan 20, 6:30 am, Bill Felton >> wrote: >> > [snip] >>> As one of 'the people' who is presumably the focus of rantingrick's >>> concern, let me assure him Tkinter is a non-issue. MIchael is more >>> in touch with my issues than rr. >> >> FYI you are NOT one of the people that is the focus of my concern >> because YOU only see the world from a limited viewpoint. And i never >> proposed to solve every Python programmers problems. You completely >> misunderstand my intentions (along with everyone else!). I do not >> believe in "Utopian dreams". Some people will never be happy with the >> state of Python and that is OK. However, the goal is to keep the >> majority happy AND keep Python "presentable" and "competitive" for the >> next decade. I am sorry you don't fit into any of these categories but >> that is your own fault. Why? Because you are not concerned with the >> community as a whole. You are only concerned with YOURSELF. You are >> displaying both selfishness and ignorance at the same time. We don't >> care what selfish people think and we care even less what the ignorant >> think. If you decide to become a "team player" then you will be a part >> of this community. Lucky for you ignorance and selfishness are >> reversible personality traits. >> > So you're going to lead the "peasants" (your word) whether they like it > or not, and any who don't want to follow are clearly being selfish and > ignorant? > > Have you ever thought that if everyone is misunderstanding your > intentions, then perhaps you're doing something wrong? > > (BTW, welcome to Pythonia, Bill! Most of us are friendly. :-))\ Thanks! And yes, I had noticed that in general this is a congenial, thoughtful, and helpful community. While a lot of what is discussed is not of particular interest to me, there's been a lot that has been of interest and/or of value. So far, I'm pretty impressed with the language as well as the community. And it's wonderful to be involved with a language that has such voluminous supporting materials of all sorts. [I self-taught Smalltalk back in the early and mid-80's when there were 3 books and that's about it...] Hopefully I'll be able to contribute code, learning materials, or such like, at some point ;-) cheers, Bill From rantingrick at gmail.com Thu Jan 20 12:26:32 2011 From: rantingrick at gmail.com (rantingrick) Date: Thu, 20 Jan 2011 09:26:32 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <2ef2fa6c-2ccf-453a-8f50-0ef7dbd7834d@j32g2000yqc.googlegroups.com> <5c6ff40f-05c1-4e38-89bc-b8c4745db7ce@i18g2000yqn.googlegroups.com> <9a036db2-9f32-441f-aa0f-698ac22fb152@e20g2000vbn.googlegroups.com> <981140f7-79d4-421d-88c1-c819f38a3d49@w2g2000yqb.googlegroups.com> <4D37AA0F.3010601@gmail.com> <8871b602-2cd4-43c4-b289-63e0bc167714@z17g2000prz.googlegroups.com> Message-ID: <3506b8ca-b831-4ce3-8bf7-b6776d856fb9@e4g2000vbg.googlegroups.com> On Jan 20, 10:36?am, rusi wrote: > On Jan 20, 5:30?pm, Bill Felton > > With some hesitation, I feel a need to jump in here. ? > This thread is now at 239 posts (and so I too hesitate...) Why hesitate? Whether it be one post or a million posts, if you have ideas, opinions, or suggestions then by all means jump in and share them. If your words are FUD, not based on fact, or just completely ignorant, don't worry, someone will correct you :-) > The arguments for size, dependencies etc are what may be termed > 'sys-ad' perspectives. The questions of 'it looks nice/ancient etc' > are user issues. What about some programmer perspective? Size is very important. Dependencies are very important (within context!). So too are aesthetics just as important when considering a "graphics" module. In the end, Python should aim to bring the best looking, most advanced (but well tested!), scalable modules we can muster into the stdlib. At the time of it's inclusion Guido believed Tkinter was the best choice -- and i agree with him! However we are talking now about ~20 years of time between then and now. Is anyone so bombastic as to suggest that GUI has not changed significantly in that time. And likewise, is anyone so bombastic as to suggest that the lowly Tkinter module (and even worse TclTk) is representative of 21st century GUI programming? Heck, when Tkinter was added GUIs where just in their infancy as far as popular adoption is concerned! TclTk have lacked vision from the beginning. NEWSFLASH! They did not support themes until version 8.5! (~2009) And they still have much work to do if they ever want to compete with the likes of wxPython however i know thay will never reach that level of sophistication. TclTk as a community are not concerned about keeping up with he times, so be it! However we should not degrade "our" stdlib and "our" community with such backward thinking communities. We must move forward. We must pull our heads out of the sand or mentality will be our undoing. > Using something like VB-in-.NET allows a programmer to put up > significant uis with close to zero coding. Many programmers would > look down on these as 'non-programmers' Well i don't look down on these folks i just feel they are missing out on the richness and abstract thinking that creating the GUI mentally evokes. However. I believe it would be of great benefit to have a graphical GUI builder as part of any GUI package we consider for the stdlib. Do i think it should be IN the stdlib? Probably not due to size. But the fact that it is available for those who would like it to be is great. My biggest complaint with Tkinter is that it lacks so much functionality (even outside the stdlib!) that you really end up wasting your time learning and using it. Because eventually you will be forced to throw away everything you've learned and written and convert to something else. > So the (to me) relevant questions relating to GUIs are for example: > 1. Is glade (and others such) equal to wxpython, tkinter and other > such 'backends'? 2. Can glade (or whichever is the best such tool > today) compare to VB in .NET or does it look like a bad joke in > comparison (I guess the current thing may not be VB but WPF but I > dont want to pretend to know too much about windows) I think we need to add a graphical GUI builder to the list of important attributes of a 21st century GUI library. Not the most important, but still quite important. Especially if we want to "market" Python as a GUI language. And I am not saying we should market Python that way. So the attributes we must demand of a 21st century GUI library are a follows: * Quality Documentation (our problem really) * Cross Platform (their problem) * Rich Full Featured Widget Set. (their problem) * Simplistic API (our problem) * Scalability (their problem) * Accessibility (their problem) * Graphical GUI Builder. (Either or) Also some attributes related to the "Big Picture" of GUI and Python: * Mobile and Web support From subscriptions at cagttraining.com Thu Jan 20 12:27:17 2011 From: subscriptions at cagttraining.com (Bill Felton) Date: Thu, 20 Jan 2011 12:27:17 -0500 Subject: Tkinter: The good, the bad, and the ugly! Message-ID: <91F2DC6A-5A05-4ECD-BD82-18323375C579@cagttraining.com> On Jan 20, 2011, at 8:26 AM, Octavian Rasnita wrote: > From: "Bill Felton" >> I'm a complete newbie to Python. > > > To Python, or to programming in general? (Because it is important) Not to rantingrick's point as I understand it. But since you ask, new to Python, not new to programming. >25 yrs experience, most of it with Smalltalk. > > >> I'm still learning the language. And you know what? I've ignored Tkinter. > > > Why did you do that? 2 main reasons -- it hasn't come up yet, and I was attracted to wxPython by the promise of host-compatible look&feel, and the plethora of resources available for self-study in my preferred modes. > > >> I quickly discovered the alternatives and am already working with wxPython. >> I can't believe anyone is so hung up by their own arrogance that they honestly believe that the mere *presence* of a gui kit inside of the standard distribution would prevent a newbie from learning about the existence and possible benefits of alternatives. Sure, *they* can see alternatives and evaluate why Tkinter might not be a good choice under conditions x or y or z, > > > Nobody said that the fact that Python promotes Tkinter *prevents" the beginners to learn to use another GUI. It's an iunavoidable implication of rantingrick's rant about Tkinter and the downfall of Python. I would like to agree that only a deranged minority hold that Tkinter is either a 'downfall point' or prevents individuals from learning and using alternative GUIs. > I just say that if Python promotes Tkinter, the beginners that might not have experience programming in other languages might not know at all which is the difference between all those GUI types, and it might not know at all that there are more GUI types and it won't know for sure which are the differences between them. I agree. > > And for a real beginner in programming it could be harder and less important to make the effort of finding and downloading and installing another GUI just because it offer some features which are not interesting for most users, so he/she will prefer using what Python offers and he/she won't know that that solution is bad. I tend to agree, but weakly. Python is touted for it's vast library support, and that library is pretty much "in your face" if you use the web to look for the language and resources on the language. I have a lot of trouble believing that anyone smart enough to program [i.e., smart enough to tie their own shoes, basically] would not find and investigate those resources. Mind you, I think more focus on Tkinter in the learning materials would be a nice thing to have. Although bear in mind I may have a skewed view of what counts as good introductions to GUI toolkits given my early and long exposure to Smalltalk... Where's Python's toothpaste, sketchpad, etc? cheers, Bill PS. Still not used to a mailing list that sets the 'reply to' to the author, not the list, so inadvertently sent this only to Octavian. Rectified herewith, along with a promise to pay more attention ;-) -------------- next part -------------- An HTML attachment was scrubbed... URL: From ilja.golshtein at gmail.com Thu Jan 20 12:32:14 2011 From: ilja.golshtein at gmail.com (ilejn) Date: Thu, 20 Jan 2011 09:32:14 -0800 (PST) Subject: statement level resumable exception Message-ID: Hello! I have a sequence of a function calls. Basically it looks like f(arg1) f(arg2) ... f(argN) though real arguments are complex multilayer lists. The problem is some arguments are not known and I get NameError exceptions. The solutions I know 1. wrap every f call in try/except block 2. make (currently global) argument attributes of a class and use __getattr__ to convert unknown attributes to something recognizable by f. Is it possible to use something more elegant? I had a hope decorators are helpful here, though apparently they are not ... Suggestions? Thanks. PS. The question is about Python 2.4 From askutt at gmail.com Thu Jan 20 12:32:20 2011 From: askutt at gmail.com (Adam Skutt) Date: Thu, 20 Jan 2011 09:32:20 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com><4d337983$0$29983$c3e8da3$5496439d@news.astraweb.com><044a5101-948d-4458-9c94-57dbb3e25f67@m35g2000vbn.googlegroups.com><4d3467bf$0$29983$c3e8da3$5496439d@news.astraweb.com><4D34B04E.8050309@web.de><4266E8D7BA204BFEA5BF66C635CE1716@octavian><4D35DCE8.5030002@web.de><4D35DD47.1070304@web.de><7A0C7934E65D4B85A584C06ADD3B6ECF@teddy> Message-ID: <513d0274-1878-49a6-9382-31b6ae7aaef3@y9g2000prf.googlegroups.com> On Jan 20, 10:44?am, "Octavian Rasnita" wrote: > From: "Adam Skutt" > Actually, JAWS uses MSAA dead last, as I understand it, because the > API is truly that awful. ?But MSAA is necessary whenever you're not > using a Win32 common control or most of the other stuff developed by > MS. ?That means essentially every non-MS toolkit that's been > discussed. > > Yes, but WxPython uses wxWIDGETS and wxWIDGETS use the standard Win32 controls under Windows, so they are accessible. > And they use Gtk under Linux and Gtk is accessible under Linux also. wxGTK is not, though. wxWidgets is only accessible under Windows. Qt is accessible under Windwos, OS X, and anything that supports AT- SPI[1]. Yet, for some unfathomable reason, you keep promoting wxWidgets even though it is plainly the inferior solution. > Yes of course they can do that if they use the wrong tool. They can't do the right thing if they believe that Tk or Silverlight or Flash is accessible no matter if they follow the recommendations for accessibility, because the screen readers don't support those interfaces. No, even using the right tools: http://doc.qt.nokia.com/qq/qq24-accessibility.html#dealingwithquirks (a few years old, but AFAIK still relevant). It's a crap shoot even if I use tools that support accessibility, because the APIs aren't very good. Some of the new APIs improve the problem, but some reading suggests there will still be the need for a lot of special case handling on both sides of the table. > Nope, the cultural problem exists because the programmers use the wrong interface, not because they just don't make the efforts for making that interface more accessible. No, they don't think about it, they don't test, they don't make the necessary calls to enable accessible applications. Plenty of applications with poor to non-existent accessibility support are written with toolkits that support accessibility. > To be more clear and not to include in the discussion many interfaces, we are comparing Tkinter and WxPython. No, we're not comparing just them, because they're hardly the only solutions. > I am not excluding anything. I said that all the Tk-based programs are inaccessible no matter what the programmer does to make it accessible, because the screen readers can't work with that interface. > And I have also said which are the accessible interfaces: wxWIDGETS (which use Win32 GUI under Windows and Gtk under Linux), SWT (which I think it does exactly the same thing as wxWIDGETS), WindowsForms (DotNet) and SWING (if the user installs Java Access Bridge). This is not a complete list, or even a correct list, which was my point. > It depends if there is a JAWS script defined. Stop. You've insisted many times that I need to not do anything special for making accessible applications. Yet, JAWS has an API entirely for the purpose of enhancing accessibility for specific applications! So, which is it? If I don't need to do anything special, then why does the API exist? Oh right, it exists so people can compensate for developers shortcomings. It's very hard to take anything you say seriously when you repeatedly get basic facts wrong and when you make claims that aren't consistent with the facts. > If the user doesn't want or don't know how to create that script for improving the usability, he/she might need to learn how to use the application by trial and error, but what I want to show is that the user is *able* to use that application, even if the interface is not very friendly, but it would be absolutely impossible to use an application created with Tkinter. He / she might be able to use the application. It's a "maybe", not a "for sure", yet you consistently imply it's the latter. > I am not talking about custom controls. Those things are the worst thing possible from the perspective of accessibility, because usually nobody cares about providing accessibility features. Yet I was talking about custom controls, and plenty of applications use custom controls, so you cannot ignore them even if you'd wish to do so. > My point was that Tkinter which uses Tk is bad, and I didn't tried too many QT-based applications. No, you explicitly stated that Qt has zero accessibility support, which is simply false. You didn't say, "The ones I tried haven't worked", which is certainly possible depending on version and how Qt was compiled (since Qt is normally shipped with the application on Windows). You said, "But the interfaces created with Tk, Gtk and QT are completely inaccessible." > And I don't see what you demonstrate when you wanted to show Tkinter it is comparing with WxPython... I never said I was going to demonstrate anything between Tkinter and wxPython. Such a demonstrate is in your imagination. Adam From rantingrick at gmail.com Thu Jan 20 12:36:15 2011 From: rantingrick at gmail.com (rantingrick) Date: Thu, 20 Jan 2011 09:36:15 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <2ef2fa6c-2ccf-453a-8f50-0ef7dbd7834d@j32g2000yqc.googlegroups.com> <5c6ff40f-05c1-4e38-89bc-b8c4745db7ce@i18g2000yqn.googlegroups.com> <9a036db2-9f32-441f-aa0f-698ac22fb152@e20g2000vbn.googlegroups.com> <981140f7-79d4-421d-88c1-c819f38a3d49@w2g2000yqb.googlegroups.com> <4D37AA0F.3010601@gmail.com> <6d1bfa09-591b-47a4-9d3f-3edcd20019da@z5g2000yqb.googlegroups.com> Message-ID: <8b9bb649-6ac2-4845-8893-3f2bdf882daf@g26g2000vbz.googlegroups.com> On Jan 20, 11:13?am, MRAB wrote: > So you're going to lead the "peasants" (your word) whether they like it > or not, and any who don't want to follow are clearly being selfish and > ignorant? If you could read Bill's words and not find them to be overly selfish and ignorant then i don't know what to say. He clearly stated many times that he NEVER used Tkinter. However somehow we are to believe that he has some "magical" insight on the merits (or lack there of) of Tkinter? This IS THE VERY DEFINITION OF IGNORANCE MRAB. Ignorance is defined as the lack of knowledge. Bill has presented just that. However, even in light of such bombastic ignorance and selfish display I in good humility and grace offered Bill advice on how he could present more facts instead of just baseless opinion. I asked him very specific questions THAT IF he would answer MIGHT inject some facts into his baseless argument. However I bet we won't get any answers from him. PS: You never cease to amaze me MRAB. From smokefloat at gmail.com Thu Jan 20 12:42:21 2011 From: smokefloat at gmail.com (David Hutto) Date: Thu, 20 Jan 2011 09:42:21 -0800 (PST) Subject: Os designers are morons Message-ID: Forgive me for the listening 'troll perspective', but is there any simple solution to intertwining proprietary and open source mentalities? Common ground seems to be the hardware offerings. So why does it seem that the summit has lost it's common ground, which is the hardware we operate on? Electricians know more about multiple applications of energy affecting different sources than most programmers here with there allocation and deallocation of a space on the 'board'. Spatial concepts aren't that hard, and neither is the allocation/deallocation concepts in spatial analysis. So, quit arguing, and get to what you know. From bkline at rksystems.com Thu Jan 20 12:55:44 2011 From: bkline at rksystems.com (Bob Kline) Date: Thu, 20 Jan 2011 12:55:44 -0500 Subject: Part of RFC 822 ignored by email module In-Reply-To: References: Message-ID: <4D387720.40408@rksystems.com> On 1/20/2011 12:23 PM, Carl Banks wrote: > On Jan 20, 7:08 am, Bob Kline wrote: >> I just noticed that the following passage in RFC 822: >> >> The process of moving from this folded multiple-line >> representation of a header field to its single line represen- >> tation is called "unfolding". Unfolding is accomplished by >> regarding CRLF immediately followed by a LWSP-char as >> equivalent to the LWSP-char. >> >> is not being honored by the email module. The following two invocations >> of message_from_string() should return the same value, but that's not >> what happens: >> >> >>> import email >> >>> email.message_from_string("Subject: blah").get('SUBJECT') >> 'blah' >> >>> email.message_from_string("Subject:\n blah").get('SUBJECT') >> ' blah' >> >> Note the space in front of the second value returned, but missing from >> the first. Can someone convince me that this is not a bug? > That's correct, according to my reading of RFC 822 (I doubt it's > changed so I didn't bother to look up what the latest RFC on that > subject is.) > > The RFC says that in a folded line the whitespace on the following > line is considered a part of the line. Thanks for responding. I think your interpretation of the RFC is the same is mine. What I'm saying is that by not returning the same value in the two cases above the module is not "regarding CRLF immediately followed by a LWSP-char as equivalent to the LWSP-char." -- Bob Kline http://www.rksystems.com mailto:bkline at rksystems.com From python at mrabarnett.plus.com Thu Jan 20 13:12:05 2011 From: python at mrabarnett.plus.com (MRAB) Date: Thu, 20 Jan 2011 18:12:05 +0000 Subject: Tkinter: The good, the bad, and the ugly! In-Reply-To: <8b9bb649-6ac2-4845-8893-3f2bdf882daf@g26g2000vbz.googlegroups.com> References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <2ef2fa6c-2ccf-453a-8f50-0ef7dbd7834d@j32g2000yqc.googlegroups.com> <5c6ff40f-05c1-4e38-89bc-b8c4745db7ce@i18g2000yqn.googlegroups.com> <9a036db2-9f32-441f-aa0f-698ac22fb152@e20g2000vbn.googlegroups.com> <981140f7-79d4-421d-88c1-c819f38a3d49@w2g2000yqb.googlegroups.com> <4D37AA0F.3010601@gmail.com> <6d1bfa09-591b-47a4-9d3f-3edcd20019da@z5g2000yqb.googlegroups.com> <8b9bb649-6ac2-4845-8893-3f2bdf882daf@g26g2000vbz.googlegroups.com> Message-ID: <4D387AF5.4000206@mrabarnett.plus.com> On 20/01/2011 17:36, rantingrick wrote: > On Jan 20, 11:13 am, MRAB wrote: > >> So you're going to lead the "peasants" (your word) whether they like it >> or not, and any who don't want to follow are clearly being selfish and >> ignorant? > > If you could read Bill's words and not find them to be overly selfish > and ignorant then i don't know what to say. He clearly stated many > times that he NEVER used Tkinter. However somehow we are to believe > that he has some "magical" insight on the merits (or lack there of) of > Tkinter? This IS THE VERY DEFINITION OF IGNORANCE MRAB. Ignorance is > defined as the lack of knowledge. Bill has presented just that. > > However, even in light of such bombastic ignorance and selfish display > I in good humility and grace offered Bill advice on how he could > present more facts instead of just baseless opinion. I asked him very > specific questions THAT IF he would answer MIGHT inject some facts > into his baseless argument. However I bet we won't get any answers > from him. > > PS: You never cease to amaze me MRAB. The feeling is mutual. From nstinemates at gmail.com Thu Jan 20 13:15:28 2011 From: nstinemates at gmail.com (Nick Stinemates) Date: Thu, 20 Jan 2011 10:15:28 -0800 Subject: Tkinter: The good, the bad, and the ugly! In-Reply-To: <8b9bb649-6ac2-4845-8893-3f2bdf882daf@g26g2000vbz.googlegroups.com> References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <2ef2fa6c-2ccf-453a-8f50-0ef7dbd7834d@j32g2000yqc.googlegroups.com> <5c6ff40f-05c1-4e38-89bc-b8c4745db7ce@i18g2000yqn.googlegroups.com> <9a036db2-9f32-441f-aa0f-698ac22fb152@e20g2000vbn.googlegroups.com> <981140f7-79d4-421d-88c1-c819f38a3d49@w2g2000yqb.googlegroups.com> <4D37AA0F.3010601@gmail.com> <6d1bfa09-591b-47a4-9d3f-3edcd20019da@z5g2000yqb.googlegroups.com> <8b9bb649-6ac2-4845-8893-3f2bdf882daf@g26g2000vbz.googlegroups.com> Message-ID: > > > > So you're going to lead the "peasants" (your word) whether they like it > > or not, and any who don't want to follow are clearly being selfish and > > ignorant? > > If you could read Bill's words and not find them to be overly selfish > and ignorant then i don't know what to say. He clearly stated many > times that he NEVER used Tkinter. However somehow we are to believe > that he has some "magical" insight on the merits (or lack there of) of > Tkinter? This IS THE VERY DEFINITION OF IGNORANCE MRAB. Ignorance is > defined as the lack of knowledge. Bill has presented just that. > No, he's refuting your point that newbies are somehow paralyzed and cannot make a decision about which toolkit they would like to use. > > PS: You never cease to amaze me MRAB. > I am also amazed. Nick -------------- next part -------------- An HTML attachment was scrubbed... URL: From emile at fenx.com Thu Jan 20 13:17:01 2011 From: emile at fenx.com (Emile van Sebille) Date: Thu, 20 Jan 2011 10:17:01 -0800 Subject: Tkinter: The good, the bad, and the ugly! In-Reply-To: <513d0274-1878-49a6-9382-31b6ae7aaef3@y9g2000prf.googlegroups.com> References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com><4d337983$0$29983$c3e8da3$5496439d@news.astraweb.com><044a5101-948d-4458-9c94-57dbb3e25f67@m35g2000vbn.googlegroups.com><4d3467bf$0$29983$c3e8da3$5496439d@news.astraweb.com><4D34B04E.8050309@web.de><4266E8D7BA204BFEA5BF66C635CE1716@octavian><4D35DCE8.5030002@web.de><4D35DD47.1070304@web.de><7A0C7934E65D4B85A584C06ADD3B6ECF@teddy>< ih53k2$pjf$1@dough.gmane.org> <513d0274-1878-49a6-9382-31b6ae7aaef3@y9g2000prf.googlegroups.com> Message-ID: On 1/20/2011 9:32 AM Adam Skutt said... > On Jan 20, 10:44 am, "Octavian Rasnita" wrote: >> From: "Adam Skutt" >> Actually, JAWS uses MSAA dead last, as I understand it, because the >> API is truly that awful. But MSAA is necessary whenever you're not >> using a Win32 common control or most of the other stuff developed by >> MS. That means essentially every non-MS toolkit that's been >> discussed. >> >> Yes, but WxPython uses wxWIDGETS and wxWIDGETS use the standard Win32 controls under Windows, so they are accessible. >> And they use Gtk under Linux and Gtk is accessible under Linux also. > > wxGTK is not, though. wxWidgets is only accessible under Windows. Qt > is accessible under Windwos, OS X, and anything that supports AT- > SPI[1]. Yet, for some unfathomable reason, you keep promoting > wxWidgets even though it is plainly the inferior solution. The problem with QT is the license. From http://qt.nokia.com/products/licensing/: Qt Commercial Developer License The Qt Commercial Developer License is the correct license to use for the development of proprietary and/or commercial software with Qt where you do not want to share any source code. You must purchase a Qt Commercial Developer License from us or from one of our authorized resellers before you start developing commercial software as you are not permitted to begin your development with an open source licensed Qt version and convert to the commercially license version at a later . The Qt Commercial Developer License includes a restriction that prevents the combining of code developed with the Qt GNU LGPL v. 2.1 or GNU GPL v. 3.0 license versions with commercially licensed Qt code. From __peter__ at web.de Thu Jan 20 13:42:10 2011 From: __peter__ at web.de (Peter Otten) Date: Thu, 20 Jan 2011 19:42:10 +0100 Subject: printing a list with non-ascii strings References: <4d385809$0$14253$ba620e4c@news.skynet.be> Message-ID: Helmut Jarausch wrote: > I don't understand Python's behaviour when printing a list. > The following example uses 2 German non-ascii characters. > > #!/usr/bin/python > # _*_ coding: latin1 _*_ > L=["abc","s??","def"] > print L[1],L > > The output of L[1] is correct, while the output of L shows up as > ['abc', 's\xfc\xdf', 'def'] > > How can this be changed? Use unicode and follow Martin's recipe: http://mail.python.org/pipermail/python-list/2011-January/1263783.html From bkline at rksystems.com Thu Jan 20 13:44:02 2011 From: bkline at rksystems.com (Bob Kline) Date: Thu, 20 Jan 2011 13:44:02 -0500 Subject: Part of RFC 822 ignored by email module In-Reply-To: References: <4D384FF8.6060708@rksystems.com> Message-ID: <4D388272.8090907@rksystems.com> On 1/20/2011 12:58 PM, Dennis Lee Bieber wrote: > > I'd first be concerned about the absence of the line ending sequence > specified by the RFC: carriage return (CR; \r) followed by line feed > (LF; \n). I realized after I posted the original message that this might distract from the issue I'm asking about. The module is a little sloppy about its own generation of CRLF tokens when it serializes messages (it leaves the insertion of the CR to processing further downstream), and I was mimicking that behavior in what I fed to the method in my example. I should have avoided that problem and included the \r. Let's pretend that I did: the behavior is unaffected by the absence or presence of the CR character. > ... > > However, the module does appear to trim leading whitespace that > occurs between the : and text (and the line end is considered for that > trimming, but not any whitespace after it). Exactly. I'm focusing on the word "equivalent" in the RFC. Either the module is going to strip leading white space from the value or it's not. Returning different values for the unwrapped header, depending on whether wrapping was present, is failing to treat the two sequences as equivalent. Logically, the processing sequence should be: 1. Unwrap the header ("Subject:\r\n foo" becomes "Subject: foo") 2. Trim leading white space (" foo" becomes "foo") Ideally, the behavior of trimming the leading white space would be reflected documentation (but it isn't). -- Bob Kline http://www.rksystems.com mailto:bkline at rksystems.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From subscriptions at cagttraining.com Thu Jan 20 13:55:14 2011 From: subscriptions at cagttraining.com (Bill Felton) Date: Thu, 20 Jan 2011 13:55:14 -0500 Subject: Tkinter: The good, the bad, and the ugly! In-Reply-To: References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <2ef2fa6c-2ccf-453a-8f50-0ef7dbd7834d@j32g2000yqc.googlegroups.com> <5c6ff40f-05c1-4e38-89bc-b8c4745db7ce@i18g2000yqn.googlegroups.com> <9a036db2-9f32-441f-aa0f-698ac22fb152@e20g2000vbn.googlegroups.com> <981140f7-79d4-421d-88c1-c819f38a3d49@w2g2000yqb.googlegroups.com> <4D37AA0F.3010601@gmail.com> <6d1bfa09-591b-47a4-9d3f-3edcd20019da@z5g2000yqb.googlegroups.com> <8b9bb649-6ac2-4845-8893-3f2bdf882daf@g26g2000vbz.googlegroups.com> Message-ID: On Jan 20, 2011, at 1:15 PM, Nick Stinemates wrote: > > > So you're going to lead the "peasants" (your word) whether they like it > > or not, and any who don't want to follow are clearly being selfish and > > ignorant? > > If you could read Bill's words and not find them to be overly selfish > and ignorant then i don't know what to say. He clearly stated many > times that he NEVER used Tkinter. However somehow we are to believe > that he has some "magical" insight on the merits (or lack there of) of > Tkinter? This IS THE VERY DEFINITION OF IGNORANCE MRAB. Ignorance is > defined as the lack of knowledge. Bill has presented just that. > > No, he's refuting your point that newbies are somehow paralyzed and cannot make a decision about which toolkit they would like to use. > Precisely. I neither said nor intended the nonsense that somehow rr reads into my post. Geez, he can't even count -- I believe I said once that I haven't used Tkinter. But even twice or thrice would not warrant 'many times'... Well, he does appear to be an output only device, who still hasn't output the canonical 'best' GUI toolset... My point was not that Tkinter obviates all other gui toolkits, only that it doesn't need to be ripped out of the standard distro because it is not the cause of the heinous results that rr fears and never hesitates to impute to it. cheers, Bill -------------- next part -------------- An HTML attachment was scrubbed... URL: From clp2 at rebertia.com Thu Jan 20 13:58:55 2011 From: clp2 at rebertia.com (Chris Rebert) Date: Thu, 20 Jan 2011 10:58:55 -0800 Subject: statement level resumable exception In-Reply-To: References: Message-ID: On Thu, Jan 20, 2011 at 9:32 AM, ilejn wrote: > Hello! > > I have a sequence of a function calls. Basically it looks like > > f(arg1) > f(arg2) > ... > f(argN) > > though real arguments are complex multilayer lists. > > The problem is some arguments are not known and I get NameError > exceptions. Why aren't they known? It's a very bad code smell to have possibly completely-undefined variables. Cheers, Chris -- http://blog.rebertia.com From jake.biesinger at gmail.com Thu Jan 20 14:36:35 2011 From: jake.biesinger at gmail.com (Jake Biesinger) Date: Thu, 20 Jan 2011 11:36:35 -0800 (PST) Subject: Efficient python 2-d arrays? In-Reply-To: Message-ID: > Thanks for the great suggestions! On a related note, is there no way to efficiently sort a python array? >>> x = array('f', xrange(10000000)) >>> x.sort() --------------------------------------------------------------------------- AttributeError Traceback (most recent call last) /home/wbiesing/src/python-sort/ in () AttributeError: 'array.array' object has no attribute 'sort' >>> type(sorted(x)) Seems like a common enough task, but no way to do it efficiently without scipy/numpy. From solipsis at pitrou.net Thu Jan 20 14:37:01 2011 From: solipsis at pitrou.net (Antoine Pitrou) Date: Thu, 20 Jan 2011 20:37:01 +0100 Subject: getdefaultencoding - how to change this? References: <4d38472d$0$14250$ba620e4c@news.skynet.be> <4d386ece$0$14262$ba620e4c@news.skynet.be> Message-ID: <20110120203701.332e58db@pitrou.net> On 20 Jan 2011 17:20:14 GMT Helmut Jarausch wrote: > Thanks Robert, > probably I wasn't too clear about my issue. > I couldn't "print" any non-ascii character to my console although > my console has an en_US.iso88591 locale. Well, if you want a correct answer, you should paste actual code as well as its result on your system, rather than start by asking how to change getdefaultencoding (which you shouldn't do as explained by others). > I didn't modfiy anything in Python's source code. > I noticed that my root account still had an ASCII locale. > Now I have changed it such that the root account has the same locale > as non-root accounts. Recompiling Python under such a root account > has rectified things. Recompiling Python doesn't change its behaviour wrt. locales and encodings. All this is done at runtime. > Now I can print non-ascii characters if they are > properly encoded. You can *always* print characters if they are properly encoded. What you are asking is for Python to guess and do the encoding by itself, which is a different matter (and a poorly supported one under 2.x; Python 3 behaves much better in that regard). Regards Antoine. From orasnita at gmail.com Thu Jan 20 14:38:33 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Thu, 20 Jan 2011 21:38:33 +0200 Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com><4d337983$0$29983$c3e8da3$5496439d@news.astraweb.com><044a5101-948d-4458-9c94-57dbb3e25f67@m35g2000vbn.googlegroups.com><4d3467bf$0$29983$c3e8da3$5496439d@news.astraweb.com> <4D34B04E.8050309@web.de><4266E8D7BA204BFEA5BF66C635CE1716@octavian> <4D35DCE8.5030002@web.de><4D35DD47.1070304@web.de><42924000-3ffb-40f5-9cf8-70a9d767b944@k25g2000vbl.googlegroups.com> Message-ID: <337490499C414976805B96DB2B2F36CC@teddy> From: "Grant Edwards" WxPython is bad. Gtk >> is inaccessible under Windows, not under Linux, but WxPython doesn't >> use Gtk under Windows so WxPython is OK. > > Ah. I didn't realize we were operating under the premise that Windows > was the only OS that mattered. Sorry. This conclusion is hatefully because you have already read that Gtk is accessible under Linux, so WxPython doesn't offer accessibility only for Windows. >From the perspective of most of those who need accessibility however, yes, Windows is most important. Octavian From ilja.golshtein at gmail.com Thu Jan 20 14:49:54 2011 From: ilja.golshtein at gmail.com (ilejn) Date: Thu, 20 Jan 2011 11:49:54 -0800 (PST) Subject: statement level resumable exception References: Message-ID: Chris, this is a long story why arguments may be not known. Briefly these arguments come (or may come) from XML and may be not specified. A function call which does not have all arguments defined must be skipped as gracefully as possible. What I am asking about is how to achieve this goal. Thanks. On Jan 20, 9:58?pm, Chris Rebert wrote: > On Thu, Jan 20, 2011 at 9:32 AM, ilejn wrote: > > Hello! > > > I have a sequence of a function calls. Basically it looks like > > > f(arg1) > Why aren't they known? It's a very bad code smell to have possibly > completely-undefined variables. > > Cheers, > Chris > --http://blog.rebertia.com Best regards, Ilja Golshtein. From arnodel at gmail.com Thu Jan 20 14:51:48 2011 From: arnodel at gmail.com (Arnaud Delobelle) Date: Thu, 20 Jan 2011 19:51:48 +0000 Subject: printing a list with non-ascii strings References: <4d385809$0$14253$ba620e4c@news.skynet.be> Message-ID: <87sjwn9wvf.fsf@gmail.com> Helmut Jarausch writes: > Hi, > > I don't understand Python's behaviour when printing a list. > The following example uses 2 German non-ascii characters. > > #!/usr/bin/python > # _*_ coding: latin1 _*_ > L=["abc","s??","def"] > print L[1],L > > The output of L[1] is correct, while the output of L shows up as > ['abc', 's\xfc\xdf', 'def'] > > How can this be changed? > > Thanks for hint, > Helmut. That's because when you print a list, the code executed is roughly: print "[" + ", ".join(repr(x) for x in L) + "]" Now try: print repr("s??") I don't think this can be changed in Python 2.X. I vaguely remember discussions about this issue for Python 3 I think, but I can't remember the outcome and it is different anyway as Python 3 strings are not the same as Python 2 strings (they are the same as Python 2 unicode strings). The issue though is that the python interpreter doesn't know what encoding is supposed to be used for a string - a string in Python 2.X is a sequence of bytes. If you print the string, then the terminal encodes the bytes according to its settings, which has nothing to do with python - so the appearance will differ according to the locale configuration of the terminal. However, the repr() of a string needs to be consistent irrespective of the configuration of the terminal - so the only viable option is to use nothing but ASCII characters. Hence the difference. HTH -- Arnaud From arnodel at gmail.com Thu Jan 20 14:58:17 2011 From: arnodel at gmail.com (Arnaud Delobelle) Date: Thu, 20 Jan 2011 19:58:17 +0000 Subject: statement level resumable exception References: Message-ID: <87oc7b9wkm.fsf@gmail.com> ilejn writes: > Hello! > > I have a sequence of a function calls. Basically it looks like > > f(arg1) > f(arg2) > ... > f(argN) > > though real arguments are complex multilayer lists. > > The problem is some arguments are not known and I get NameError > exceptions. > > The solutions I know > 1. wrap every f call in try/except block > 2. make (currently global) argument attributes of a class and use > __getattr__ to convert unknown attributes to something recognizable by > f. for name in 'arg1', 'arg2', ... 'argN': try: arg = globals()[name] except NameError: continue f(arg) But this is a strange problem... Sounds like you should do it differently. -- Arnaud From orasnita at gmail.com Thu Jan 20 15:02:28 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Thu, 20 Jan 2011 22:02:28 +0200 Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com><4d337983$0$29983$c3e8da3$5496439d@news.astraweb.com><044a5101-948d-4458-9c94-57dbb3e25f67@m35g2000vbn.googlegroups.com><4d3467bf$0$29983$c3e8da3$5496439d@news.astraweb.com><4D34B04E.8050309@web.de><4266E8D7BA204BFEA5BF66C635CE1716@octavian><4D35DCE8.5030002@web.de><4D35DD47.1070304@web.de><7A0C7934E65D4B85A584C06ADD3B6ECF@teddy> <513d0274-1878-49a6-9382-31b6ae7aaef3@y9g2000prf.googlegroups.com> Message-ID: From: "Adam Skutt" > Yet, for some unfathomable reason, you keep promoting wxWidgets even though it is plainly the inferior solution. Inferior to what? I would be glad if you could tell me about a portable solution which is accessible with JAWS and Window Eyes, the most used screen readers under Windows (real glad). > Yes of course they can do that if they use the wrong tool. They can't do the right thing if they believe that Tk or Silverlight or Flash is accessible no matter if they follow the recommendations for accessibility, because the screen readers don't support those interfaces. No, even using the right tools: http://doc.qt.nokia.com/qq/qq24-accessibility.html#dealingwithquirks (a few years old, but AFAIK still relevant). It's a crap shoot even if I use tools that support accessibility, because the APIs aren't very good. Some of the new APIs improve the problem, but some reading suggests there will still be the need for a lot of special case handling on both sides of the table. Exactly. When you will read that thing on a GUI creator site it means that that GUI is not accessible because the screen readers don't support it yet. The GUI libs manufacturers will say that the screen readers are bad because they don't offer support for their GUI, although that GUI offers accessibility features. Well, I don't care that the screen readers are bad and don't support some libs. I care only if the interfaces created with a certain GUI lib is accessible out of the box as WxPython is under Windows. > Nope, the cultural problem exists because the programmers use the wrong interface, not because they just don't make the efforts for making that interface more accessible. No, they don't think about it, they don't test, they don't make the necessary calls to enable accessible applications. Plenty of applications with poor to non-existent accessibility support are written with toolkits that support accessibility. You confuse again the accessibility with the usability or you think that if a GUI lib offers accessibility features it is accessible. Well, a GUI lib is accessible only if JAWS and Window Eyes offer support for it because those are the screen readers used by the majority and this is because they have the most features. > To be more clear and not to include in the discussion many interfaces, we are comparing Tkinter and WxPython. No, we're not comparing just them, because they're hardly the only solutions. We were starting from the idea that Tkinter is worse than WxPython so let's come to that idea and not divagate. > I am not excluding anything. I said that all the Tk-based programs are inaccessible no matter what the programmer does to make it accessible, because the screen readers can't work with that interface. > And I have also said which are the accessible interfaces: wxWIDGETS (which use Win32 GUI under Windows and Gtk under Linux), SWT (which I think it does exactly the same thing as wxWIDGETS), WindowsForms (DotNet) and SWING (if the user installs Java Access Bridge). This is not a complete list, or even a correct list, which was my point. My point was that Tkinter shouldn't be promoted by Python because it doesn't create accessible GUI out of the box at least for Windows as WxPython does. > It depends if there is a JAWS script defined. Stop. You've insisted many times that I need to not do anything special for making accessible applications. Yet, JAWS has an API entirely for the purpose of enhancing accessibility for specific applications! So, which is it? If I don't need to do anything special, then why does the API exist? Oh right, it exists so people can compensate for developers shortcomings. I've told you a lot of times that you confuse accessibility with usability. And I told you that the JAWS scripts can't make an absolutely inaccessible application made with Tk to be accessible. And that's why Tkinter is bad. The JAWS scripts can only improve the usability, can make the application be much friendly, but if it is not accessible, it can't make it accessible, because if it could do it, there would be no accessibility issues anymore. It's very hard to take anything you say seriously when you repeatedly get basic facts wrong and when you make claims that aren't consistent with the facts. Which are those facts? > If the user doesn't want or don't know how to create that script for improving the usability, he/she might need to learn how to use the application by trial and error, but what I want to show is that the user is *able* to use that application, even if the interface is not very friendly, but it would be absolutely impossible to use an application created with Tkinter. He / she might be able to use the application. It's a "maybe", not a "for sure", yet you consistently imply it's the latter. Yes, but there is a chance to be able to use that application while if the application is done with Tk, she/he would have absolutely no chance to use it. > I am not talking about custom controls. Those things are the worst thing possible from the perspective of accessibility, because usually nobody cares about providing accessibility features. Yet I was talking about custom controls, and plenty of applications use custom controls, so you cannot ignore them even if you'd wish to do so. If the application uses custom controls and the programmer adds custom accessibility features for them (which usually never happends), that application might be accessible if it uses an accessible GUI lib. But if the programmer adds accessibility features to a Tk GUI, that GUI won't be accessible because the screen readers don't offer the necessary support for Tk. > My point was that Tkinter which uses Tk is bad, and I didn't tried too many QT-based applications. No, you explicitly stated that Qt has zero accessibility support, which is simply false. You didn't say, "The ones I tried haven't worked", which is certainly possible depending on version and how Qt was compiled (since Qt is normally shipped with the application on Windows). You said, "But the interfaces created with Tk, Gtk and QT are completely inaccessible." If QT is not consistent and some versions can be accessible and other versions not, it means that QT should be avoided just because it is not consistent. A sane GUI should offer accessibility by default in all its versions without needing to activate anything in order to make the application accessible. Octavian From robert.kern at gmail.com Thu Jan 20 15:16:15 2011 From: robert.kern at gmail.com (Robert Kern) Date: Thu, 20 Jan 2011 14:16:15 -0600 Subject: Efficient python 2-d arrays? In-Reply-To: References: Message-ID: On 1/20/11 1:36 PM, Jake Biesinger wrote: >> Thanks for the great suggestions! > > On a related note, is there no way to efficiently sort a python array? No. >>>> x = array('f', xrange(10000000)) >>>> x.sort() > --------------------------------------------------------------------------- > AttributeError Traceback (most recent call last) > > /home/wbiesing/src/python-sort/ in() > > AttributeError: 'array.array' object has no attribute 'sort' > >>>> type(sorted(x)) > > > Seems like a common enough task, but no way to do it efficiently without scipy/numpy. It's not really common. The array module is mostly used for data accumulation and interchange. Most people who need to compute things over efficiently-implemented homogeneous arrays use numpy. -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco From rantingrick at gmail.com Thu Jan 20 15:17:06 2011 From: rantingrick at gmail.com (rantingrick) Date: Thu, 20 Jan 2011 12:17:06 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com><4d337983$0$29983$c3e8da3$5496439d@news.astraweb.com><044a5101-948d-4458-9c94-57dbb3e25f67@m35g2000vbn.googlegroups.com><4d3467bf$0$29983$c3e8da3$5496439d@news.astraweb.com><4D34B04E.8050309@web.de><4266E8D7BA204BFEA5BF66C635CE1716@octavian><4D35DCE8.5030002@web.de><4D35DD47.1070304@web.de><7A0C7934E65D4B85A584C06ADD3B6ECF@teddy>< Message-ID: On Jan 20, 12:17?pm, Emile van Sebille wrote: > The problem with QT is the license. > > ?Fromhttp://qt.nokia.com/products/licensing/: > > Qt Commercial Developer License > The Qt Commercial Developer License is the correct license to use for > the development of proprietary and/or commercial software with Qt where > you do not want to share any source code. Well as far as i am concerned that takes QT out of the contest. So that leaves WxPython and pyGTK as the only viable options that are mature libraries. Both carry the LGPL license. http://www.pygtk.org/ http://www.wxwidgets.org/about/newlicen.htm One more is FLTK however it looks like a mirror of Tkinter so back in the same place: http://pyfltk.sourceforge.net/index.php#download From ilja.golshtein at gmail.com Thu Jan 20 15:32:56 2011 From: ilja.golshtein at gmail.com (ilejn) Date: Thu, 20 Jan 2011 12:32:56 -0800 (PST) Subject: statement level resumable exception References: <87oc7b9wkm.fsf@gmail.com> Message-ID: <62658b12-34b7-4ed5-9ecd-5182b53f7b31@t35g2000yqj.googlegroups.com> Arnaud, good idea, though I think it is not applicable in my case, because my arg1 ... argN are "complex multilayer lists". In reality it is not just f(arg1), it is more like f([[subarg1, 'aa', subarg2], []]) Regarding your remark it is a strange problem ... well, may be it is ;) Thanks anyway. On Jan 20, 10:58?pm, Arnaud Delobelle wrote: > ilejn writes: > > Hello! > > > I have a sequence of a function calls. Basically it looks like > > > f(arg1) > > f(arg2) > > ... > > f(argN) > > > though real arguments are complex multilayer lists. > > > The problem is some arguments are not known and I get NameError > > exceptions. > > > The solutions I know > > 1. wrap every f call in try/except block > > 2. make (currently global) argument attributes of a class and use > > __getattr__ to convert unknown attributes to something recognizable by > > f. > > for name in 'arg1', 'arg2', ... 'argN': > ? ? try: > ? ? ? ? arg = globals()[name] > ? ? except NameError: > ? ? ? ? continue > ? ? f(arg) > > But this is a strange problem... ?Sounds like you should do it > differently. > > -- > Arnaud Best regards, Ilja Golshtein. From askutt at gmail.com Thu Jan 20 15:37:21 2011 From: askutt at gmail.com (Adam Skutt) Date: Thu, 20 Jan 2011 12:37:21 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com><4d337983$0$29983$c3e8da3$5496439d@news.astraweb.com><044a5101-948d-4458-9c94-57dbb3e25f67@m35g2000vbn.googlegroups.com><4d3467bf$0$29983$c3e8da3$5496439d@news.astraweb.com><4D34B04E.8050309@web.de><4266E8D7BA204BFEA5BF66C635CE1716@octavian><4D35DCE8.5030002@web.de><4D35DD47.1070304@web.de><7A0C7934E65D4B85A584C06ADD3B6ECF@teddy>< Message-ID: <9003ae0f-0cb8-4ada-87d4-4a994747e89f@w29g2000vba.googlegroups.com> On Jan 20, 1:17?pm, Emile van Sebille wrote: > > The problem with QT is the license. Qt and wxWidgets are both LGPL and equally non-starters due to license, today. There was a hypothetical assumption on my part that the library would be made license compatible somehow, through the entire discussion. I didn't think it worth mentioning because I didn't think it all that relevant to any of the discussions that end ed up occurring here. Adam From arnodel at gmail.com Thu Jan 20 15:42:33 2011 From: arnodel at gmail.com (Arnaud Delobelle) Date: Thu, 20 Jan 2011 20:42:33 +0000 Subject: statement level resumable exception References: <87oc7b9wkm.fsf@gmail.com> <62658b12-34b7-4ed5-9ecd-5182b53f7b31@t35g2000yqj.googlegroups.com> Message-ID: <87k4hz9uiu.fsf@gmail.com> ilejn writes: > Arnaud, > > good idea, though I think it is not applicable in my case, > because my arg1 ... argN are "complex multilayer lists". > > In reality it is not just > f(arg1), > it is more like > f([[subarg1, 'aa', subarg2], []]) > > Regarding your remark it is a strange problem ... well, may be it > is ;) > > Thanks anyway. Are these lists automatically generated? -- Arnaud From martin at address-in-sig.invalid Thu Jan 20 15:48:19 2011 From: martin at address-in-sig.invalid (Martin Gregorie) Date: Thu, 20 Jan 2011 20:48:19 +0000 (UTC) Subject: Part of RFC 822 ignored by email module References: Message-ID: On Thu, 20 Jan 2011 12:55:44 -0500, Bob Kline wrote: > On 1/20/2011 12:23 PM, Carl Banks wrote: >> On Jan 20, 7:08 am, Bob Kline wrote: >>> I just noticed that the following passage in RFC 822: >>> >>> The process of moving from this folded multiple-line >>> representation of a header field to its single line >>> represen- tation is called "unfolding". Unfolding is >>> accomplished by regarding CRLF immediately followed >>> by a LWSP-char as equivalent to the LWSP-char. >>> >>> is not being honored by the email module. The following two >>> invocations of message_from_string() should return the same value, but >>> that's not what happens: >>> >>> >>> import email >>> >>> email.message_from_string("Subject: blah").get('SUBJECT') >>> 'blah' >>> >>> email.message_from_string("Subject:\n blah").get('SUBJECT') >>> ' blah' >>> >>> Note the space in front of the second value returned, but missing from >>> the first. Can someone convince me that this is not a bug? >> That's correct, according to my reading of RFC 822 (I doubt it's >> changed so I didn't bother to look up what the latest RFC on that >> subject is.) >> >> The RFC says that in a folded line the whitespace on the following line >> is considered a part of the line. > > Thanks for responding. I think your interpretation of the RFC is the > same is mine. What I'm saying is that by not returning the same value > in the two cases above the module is not "regarding CRLF immediately > followed by a LWSP-char as equivalent to the LWSP-char." > That's only a problem if your code cares about the composition of the whitespace and this, IMO is incorrect behaviour. When the separator between syntactic elements in a header is 'whitespace' it should not matter what combination of newlines, tabs and spaces make up the whitespace element. -- martin@ | Martin Gregorie gregorie. | Essex, UK org | From drsalists at gmail.com Thu Jan 20 15:48:37 2011 From: drsalists at gmail.com (Dan Stromberg) Date: Thu, 20 Jan 2011 12:48:37 -0800 Subject: Efficient python 2-d arrays? In-Reply-To: References: Message-ID: On Thu, Jan 20, 2011 at 11:36 AM, Jake Biesinger wrote: >> Thanks for the great suggestions! > > On a related note, is there no way to efficiently sort a python array? > > >>>> x = array('f', xrange(10000000)) >>>> x.sort() > --------------------------------------------------------------------------- > AttributeError ? ? ? ? ? ? ? ? ? ? ? ? ? ?Traceback (most recent call last) > > /home/wbiesing/src/python-sort/ in () > > AttributeError: 'array.array' object has no attribute 'sort' > >>>> type(sorted(x)) > > > Seems like a common enough task, but no way to do it efficiently without scipy/numpy. Tap, tap: Is this thing on? I keep sending messages to this list, but no one seems to "hear" what I'm writing. Anyway, I have a bunch of sorts in python (pure or cython, your option) at http://stromberg.dnsalias.org/cgi-bin/viewvc.cgi/sorts/compare/trunk/?root=svn The pure python versions should all work out of the box with an array.array. I tested the timsort on an array.array, and it worked well. Also, I just made a trivial modification (not checked in! ...but I did test it) to make the cythonized timsort support sorting arrays - just change the "list" type declarations to "object" (or perhaps "array.array") prior to compiling. I also just changed the license on them from GPL v3 to Apache v2. timsort truly is a somewhat supernatural algorithm. From askutt at gmail.com Thu Jan 20 15:49:46 2011 From: askutt at gmail.com (Adam Skutt) Date: Thu, 20 Jan 2011 12:49:46 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com><4d337983$0$29983$c3e8da3$5496439d@news.astraweb.com><044a5101-948d-4458-9c94-57dbb3e25f67@m35g2000vbn.googlegroups.com><4d3467bf$0$29983$c3e8da3$5496439d@news.astraweb.com><4D34B04E.8050309@web.de><4266E8D7BA204BFEA5BF66C635CE1716@octavian><4D35DCE8.5030002@web.de><4D35DD47.1070304@web.de><7A0C7934E65D4B85A584C06ADD3B6ECF@teddy> Message-ID: On Jan 20, 3:02?pm, "Octavian Rasnita" wrote: > From: "Adam Skutt" > Yet, for some unfathomable reason, you keep promoting > I would be glad if you could tell me about a portable solution which is accessible with JAWS and Window Eyes, the most used screen readers under Windows (real glad). I did, Qt. I'm not yournanny and I'm not going to go test it for you. There are bugs in the Qt database relating to JAWS functionality, so it others have plainly gotten it working to some degree. But honestly, why should I waste my time replying to you when you're too damn lazy to even use Google? I certainly won't be doing so in the future. "Lead a ignorant, thirsty horse to water, watch it die of thirst" and all that. > Exactly. When you will read that thing on a GUI creator site it means that that GUI is not accessible because the screen readers don't support it yet. > The GUI libs manufacturers will say that the screen readers are bad because they don't offer support for their GUI, although that GUI offers accessibility features. No, that's not what that page says or means. But I'm not going to be able to explain it to you any more clearly, so if you'd prefer to keep living in your own delusional, illydic world, that's your decision. Qt has been pretty clear in painting the blame on who it belongs on, which is not the screen reader vendors. Adam From rantingrick at gmail.com Thu Jan 20 15:51:58 2011 From: rantingrick at gmail.com (rantingrick) Date: Thu, 20 Jan 2011 12:51:58 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com><4d337983$0$29983$c3e8da3$5496439d@news.astraweb.com><044a5101-948d-4458-9c94-57dbb3e25f67@m35g2000vbn.googlegroups.com><4d3467bf$0$29983$c3e8da3$5496439d@news.astraweb.com><4D34B04E.8050309@web.de><4266E8D7BA204BFEA5BF66C635CE1716@octavian><4D35DCE8.5030002@web.de><4D35DD47.1070304@web.de><7A0C7934E65D4B85A584C06ADD3B6ECF@teddy>< <9003ae0f-0cb8-4ada-87d4-4a994747e89f@w29g2000vba.googlegroups.com> Message-ID: <4c3b90c9-6ab2-40bd-9ef2-29c81463dc71@l17g2000yqe.googlegroups.com> On Jan 20, 2:37?pm, Adam Skutt wrote: > On Jan 20, 1:17?pm, Emile van Sebille wrote: > > > > > The problem with QT is the license. > > Qt and wxWidgets are both LGPL and equally non-starters due to > license, today. Everything out there is LGPL! But you cannot just use that argument to keep Tkinter. So are you suggesting that we just hold on Tkinter forver! Are you mad? Can you image Python still lugging around the antiquated Tkinter module in 2020? That's a nightmare. You know damn good and well that even nine years from now TclTk will be two decades behind in development. AND SLOWER THAN EVER! From emile at fenx.com Thu Jan 20 15:55:39 2011 From: emile at fenx.com (Emile van Sebille) Date: Thu, 20 Jan 2011 12:55:39 -0800 Subject: statement level resumable exception In-Reply-To: References: Message-ID: On 1/20/2011 11:49 AM ilejn said... > Chris, > > this is a long story why arguments may be not known. > Briefly these arguments come (or may come) from XML and may be not > specified. > > A function call which does not have all arguments defined must be > skipped as gracefully as possible. > What I am asking about is how to achieve this goal. I might try using sets: required = set(('a','b','c')) if not (required - set(locals())): f(a,b,c) HTH, Emile From namekuseijin at gmail.com Thu Jan 20 15:59:18 2011 From: namekuseijin at gmail.com (namekuseijin) Date: Thu, 20 Jan 2011 12:59:18 -0800 (PST) Subject: Google AI challenge: planet war. Lisp won. References: <44a8f48f-e291-463e-a042-d0cbc31a2a4e@z17g2000prz.googlegroups.com> <1a10a457-6492-4ed6-98fd-bbb0829637c0@o23g2000prh.googlegroups.com> Message-ID: <5d2ce6df-08f9-44b1-9604-0a139d2d0d84@d8g2000yqf.googlegroups.com> On Dec 22 2010, 12:46?pm, Xah Lee wrote: > On Dec 20, 10:06?pm, "Jon Harrop" wrote: > > > Wasn't that the "challenge" where they wouldn't even accept solutions > > written in many other languages (including both OCaml and F#)? > > Ocaml is one of the supported lang. See: > > http://ai-contest.com/starter_packages.php > > there are 12 teams using OCaml. See:http://ai-contest.com/rankings.php > (click on the lang to see all teams using that lang) > > ?Xah PWNED From ilja.golshtein at gmail.com Thu Jan 20 16:03:04 2011 From: ilja.golshtein at gmail.com (ilejn) Date: Thu, 20 Jan 2011 13:03:04 -0800 (PST) Subject: statement level resumable exception References: <87oc7b9wkm.fsf@gmail.com> <62658b12-34b7-4ed5-9ecd-5182b53f7b31@t35g2000yqj.googlegroups.com> <87k4hz9uiu.fsf@gmail.com> Message-ID: Arnaud, these lists are not generated. Actually these lists are a sort of interpreted programs and contain some application logic. Here is an example [ [PUSH, [get_modified_interface, req]], [TIMEOUT, 3], [PULL, [out_interface, '']], [PULL, [err_interface, '']], [PULL, [out_mined_interface, req]], ] If any interface name is unknown the list must not be invoked (in other words, f function call with this list must be somehow bypassed). Thanks. On Jan 20, 11:42?pm, Arnaud Delobelle wrote: > ilejn writes: > > Arnaud, > > > good idea, though I think it is not applicable in my case, > > because my arg1 ... argN are "complex multilayer lists". > > > In reality it is not just > > f(arg1), > > it is more like > > f([[subarg1, 'aa', subarg2], []]) > > > Regarding your remark it is a strange problem ... well, may be it > > is ;) > > > Thanks anyway. > > Are these lists automatically generated? > > -- > Arnaud Best regards, Ilja Golshtein. From emile at fenx.com Thu Jan 20 16:06:48 2011 From: emile at fenx.com (Emile van Sebille) Date: Thu, 20 Jan 2011 13:06:48 -0800 Subject: Tkinter: The good, the bad, and the ugly! In-Reply-To: References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com><4d337983$0$29983$c3e8da3$5496439d@news.astraweb.com><044a5101-948d-4458-9c94-57dbb3e25f67@m35g2000vbn.googlegroups.com><4d3467bf$0$29983$c3e8da3$5496439d@news.astraweb.com><4D34B04E.8050309@web.de><4266E8D7BA204BFEA5BF66C635CE1716@octavian><4D35DCE8.5030002@web.de><4D35DD47.1070304@web.de><7A0C7934E65D4B85A584C06ADD3B6ECF@teddy>< Message-ID: On 1/20/2011 12:17 PM rantingrick said... > Well as far as i am concerned that takes QT out of the contest. So > that leaves WxPython and pyGTK as the only viable options that are > mature libraries. Both carry the LGPL license. > > http://www.pygtk.org/ > http://www.wxwidgets.org/about/newlicen.htm > You might find this interesting... http://mail.python.org/pipermail/python-announce-list/2000-November/000572.html Yes, it's old. That's part of the reason you get no traction on this. Emile From wxjmfauth at gmail.com Thu Jan 20 16:15:21 2011 From: wxjmfauth at gmail.com (jmfauth) Date: Thu, 20 Jan 2011 13:15:21 -0800 (PST) Subject: UTF-8 question from Dive into Python 3 References: Message-ID: On Jan 19, 11:33?pm, Terry Reedy wrote: > On 1/19/2011 1:02 PM, Tim Harig wrote: > > > Right, but I only have to do that once. ?After that, I can directly address > > any piece of the stream that I choose. ?If I leave the information as a > > simple UTF-8 stream, I would have to walk the stream again, I would have to > > walk through the the first byte of all the characters from the beginning to > > make sure that I was only counting multibyte characters once until I found > > the character that I actually wanted. ?Converting to a fixed byte > > representation (UTF-32/UCS-4) or separating all of the bytes for each > > UTF-8 into 6 byte containers both make it possible to simply index the > > letters by a constant size. ?You will note that Python does the former. > > The idea of using a custom fixed-width padded version of a UTF-8 steams > waw initially shocking to me, but I can imagine that there are > specialized applications, which slice-and-dice uninterpreted segments, > for which that is appropriate. However, it is not germane to the folly > of prefixing standard UTF-8 steams with a 3-byte magic number, > mislabelled a 'byte-order-mark, thus making them non-standard. > Unicode Book, 5.2.0, Chapter 2, Section 14, Page 51 - Paragraphe *Unicode Signature*. From bkline at rksystems.com Thu Jan 20 16:25:52 2011 From: bkline at rksystems.com (Bob Kline) Date: Thu, 20 Jan 2011 16:25:52 -0500 Subject: Part of RFC 822 ignored by email module In-Reply-To: References: Message-ID: <4D38A860.7060706@rksystems.com> On 1/20/2011 3:48 PM, Martin Gregorie wrote: > That's only a problem if your code cares about the composition of the > whitespace and this, IMO is incorrect behaviour. When the separator > between syntactic elements in a header is 'whitespace' it should not > matter what combination of newlines, tabs and spaces make up the > whitespace element. That would be true for what the RFC calls "structured" fields, but not for the others (such as the Subject header). -- Bob Kline http://www.rksystems.com mailto:bkline at rksystems.com From rantingrick at gmail.com Thu Jan 20 16:52:29 2011 From: rantingrick at gmail.com (rantingrick) Date: Thu, 20 Jan 2011 13:52:29 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com><4d337983$0$29983$c3e8da3$5496439d@news.astraweb.com><044a5101-948d-4458-9c94-57dbb3e25f67@m35g2000vbn.googlegroups.com><4d3467bf$0$29983$c3e8da3$5496439d@news.astraweb.com><4D34B04E.8050309@web.de><4266E8D7BA204BFEA5BF66C635CE1716@octavian><4D35DCE8.5030002@web.de><4D35DD47.1070304@web.de><7A0C7934E65D4B85A584C06ADD3B6ECF@teddy>< Message-ID: On Jan 20, 3:06?pm, Emile van Sebille wrote: > You might find this interesting... > http://mail.python.org/pipermail/python-announce-list/2000-November/0... > Yes, it's old. ?That's part of the reason you get no traction on this. Thanks Emile. This read was both hair raising and informative. Following is the relevant Tkinter parts posted verbatim with my comments sprinkled throughout... > However, this process is still in its infancy, and the announcement > caused much worrying in the Tcl/Tk user community about the > language's future and its continued maintenance. This affects > Python because Tk, through the Tkinter module, is the most GUI most > commonly used with Python. Tkinter is included in the source > distribution, it's the most extensively documented, and it's the > most portable, supported on the Big Three platforms, namely Windows, > Unix, and MacOS. It seems at the time (a decade ago) fantasies abounded about the importance of Tkinter. I find it highly unlikely that Tkinter was OR IS the "Most commonly used GUI with Python". Maybe the most commonly used GUI library for utilities, but that's about it > Fredrik Lundh first posted a note about the announcement, and Eric > S. Raymond raised the question of what this meant for Tkinter: "This > raises anew a question I've been meaning to bring up for the last > week: is it finally time to move away from Python's dependence on > Tcl/Tk for GUI support?" Yes (even a decade later!). > People were split on this question, though Guido was receptive to > the idea ("Yes, it may be time to have this discussion again.") and > pointed out some reasons to stick with Tkinter: "Tk has two very > high quality widgets: the Canvas and Text widgets are unsurpassed in > functionality and robustness by other widget sets. Not anymore Guido! > You can draw > more lines or characters per second in most toolkits, but few > toolkits offer the convenience of marks and tags, not having to deal > with refresh events, being able to group objects, move them around, > change attributes, etc., etc., etc." Thats a very weak argument. While i'll agree that the tagging system employed by the TK::Canvas widget is helpful, the same functionality can be reproduced by the programmer very easily. And i always prefer to work with objects as opposed to tags because of the obvious limitations. > Greg Wilson's reaction was "Yes please", and he went on to explain > what factors kept him using Tkinter for a recent course: http://www.python.org/pipermail/python-dev/2000-October/016757.html Well that link is broken so we will never know what greg said? > /F thought Tk was still a good choice, and said " ... and trust me, > the Python 2.0/Tk8.4/Tkinter3000 combo will rock ;-)". Tkinter3000 > is an improved Tk interface that /F has been working on, with more > flexibility and better performance. > http://tkinter.effbot.org Yea Frederic maybe Tkinter < exaggeration >"rocked the casba" in 2000, however we are building with steel and glass now, not rock and stone. > /F also hoped that the Tcl Core Team would become more receptive to > making it easier to use Tk from other languages without Tcl having > to be in the middle, which would let the maintainers of Tkinter and > the Perl/Tk interface participate more in Tk's development. Why in the world do WE -- THE Python community-- give two figs as to how useful TclTk is to OTHER communities? > Eric S. Raymond speculated about the success of Tcl's new > development model: "Good for Tcl: Osterhout's rather lame attempts > to develop under a mixed model have almost certainly come to an end > in favor of an Apache-like model funded by big Tcl users." > http://www.python.org/pipermail/python-dev/2000-October/016763.html > > Greg Ewing wondered if stdwin should be revived. GvR and Raymond > both thought that far too much work, and not productive of very good > results. "And stdwin would really look pathetic in this time", GvR > observed. Well Guido, just imagine how bad Tkinter will look in 10 years ;-) > Python isn't tied very tightly to Tk, of course; well-maintained and > reasonably complete bindings exist for many different GUI toolkits, > such as Qt, GTk+, wxWindows, Windows MFC, and a few more. > http://www.thekompany.com/projects/pykde/ > http://www.daa.com.au/~james/pygtk/ http://wxpython.org/ > http://http://www.oreillynet.com/pub/a/217 Well i'd have to disagree being that Tkinter is IN the STDLIB!!!! > wxWindows is probably the most obvious second candidate, since it > actually supports all of the Big Three platforms, and no other > toolkit does. Robin Dunn, author of the wxPython binding, posted to > discuss the status of wxWindows on the Mac: "My understanding is > that the version in CVS is nearly up to date with the features in > the MSW and GTK versions, though I haven't had a chance to use it > myself. ... The next step I guess is getting it wrapped up in > wxPython..." http://www.python.org/pipermail/python- > dev/2000-October/016764.html Finally some sanity in this thread! > There was no clear final decision, and my crystal ball didn't deign > to give an answer. Given all the uncertainties, it's probably best > to wait and see. If Tk's development continues to progress and > becomes more open to languages other than Tcl, Tkinter will probably > continue to be the most common Python GUI. Thats ridiculous. Just because Tk becomes more open to other developers (namely Perl, and Ruby) does not mean we should keep it around for the same reason. > If not, we can consider > this question in another 6 months, which will give wxWindows and > wxPython time to develop on the Mac platform. And who knows? Maybe > something else will happen, such as Qt or GTk+ being ported to the > Macintosh. Yea, i'll bet the author did not expect what has happened. * Very slow if any advancement of Tk. * wxPython became rich GUI library. * Tkinter used only for utility and toy apps. * An apathy for Tkinter within the community. * and more From sridharr at activestate.com Thu Jan 20 17:18:11 2011 From: sridharr at activestate.com (Sridhar Ratnakumar) Date: Thu, 20 Jan 2011 14:18:11 -0800 Subject: ANN: ActivePython 2.6.6.18 is now available Message-ID: <4D38B4A3.5030900@activestate.com> ActiveState is pleased to announce ActivePython 2.6.6.18, a complete, ready-to-install binary distribution of Python 2.6. Among other updates, this releases brings "postinstall" support to PyPM to facilitate installation of modules such as PyIMSL. http://www.activestate.com/activepython/downloads What's New in ActivePython-2.6.6.18 =================================== New Features & Upgrades ----------------------- - Upgrade to Tcl/Tk 8.5.9 (`changes `_) - Security upgrade to openssl-0.9.8q - [MacOSX] Tkinter now requires ActiveTcl 8.5 64-bit (not Apple's Tcl/Tk 8.5 on OSX) - Upgrade to PyPM 1.3.0: - Programmatic use via ``pypm.cmd(['install', 'foo'])`` - Support for postinstall and conditional user-notes - Package updates: - pip-0.8.2 Noteworthy Changes & Bug Fixes ------------------------------ - [Windows 64-bit] `issue8275 `_: turn off optimization for the ctypes module - PyPM bug fixes: - Fix needless truncation of output when piping (eg: ``pypm list | less``) - Respect download cache of ``*.pypm`` packages (don't redownload) - Bug #88882: Fix pickle incompatability (sqlite) on Python 3.x What is ActivePython? ===================== ActivePython is ActiveState's binary distribution of Python. Builds for Windows, Mac OS X, Linux are made freely available. Solaris, HP-UX and AIX builds, and access to older versions are available in ActivePython Business, Enterprise and OEM editions: http://www.activestate.com/python ActivePython includes the Python core and the many core extensions: zlib and bzip2 for data compression, the Berkeley DB (bsddb) and SQLite (sqlite3) database libraries, OpenSSL bindings for HTTPS support, the Tix GUI widgets for Tkinter, ElementTree for XML processing, ctypes (on supported platforms) for low-level library access, and others. The Windows distribution ships with PyWin32 -- a suite of Windows tools developed by Mark Hammond, including bindings to the Win32 API and Windows COM. ActivePython also includes a binary package manager for Python (PyPM) that can be used to install packages much easily. For example: C:\>pypm install mysql-python [...] C:\>python >>> import MySQLdb >>> See this page for full details: http://docs.activestate.com/activepython/2.6/whatsincluded.html As well, ActivePython ships with a wealth of documentation for both new and experienced Python programmers. In addition to the core Python docs, ActivePython includes the "What's New in Python" series, "Dive into Python", the Python FAQs & HOWTOs, and the Python Enhancement Proposals (PEPs). An online version of the docs can be found here: http://docs.activestate.com/activepython/2.6/ We would welcome any and all feedback to: activepython-feedback at activestate.com Please file bugs against ActivePython at: http://bugs.activestate.com/enter_bug.cgi?product=ActivePython Supported Platforms =================== ActivePython is available for the following platforms: - Windows (x86 and x64) - Mac OS X (x86 and x86_64; 10.5+) - Linux (x86 and x86_64) - Solaris/SPARC (32-bit and 64-bit) (Business, Enterprise or OEM edition only) - Solaris/x86 (32-bit) (Business, Enterprise or OEM edition only) - HP-UX/PA-RISC (32-bit) (Business, Enterprise or OEM edition only) - HP-UX/IA-64 (32-bit and 64-bit) (Enterprise or OEM edition only) - AIX/PowerPC (32-bit and 64-bit) (Business, Enterprise or OEM edition only) More information about the Business Edition can be found here: http://www.activestate.com/business-edition Custom builds are available in the Enterprise Edition: http://www.activestate.com/enterprise-edition Thanks, and enjoy! The Python Team -- Sridhar Ratnakumar sridharr at activestate.com From martin at address-in-sig.invalid Thu Jan 20 17:34:01 2011 From: martin at address-in-sig.invalid (Martin Gregorie) Date: Thu, 20 Jan 2011 22:34:01 +0000 (UTC) Subject: Part of RFC 822 ignored by email module References: Message-ID: On Thu, 20 Jan 2011 16:25:52 -0500, Bob Kline wrote: > On 1/20/2011 3:48 PM, Martin Gregorie wrote: >> That's only a problem if your code cares about the composition of the >> whitespace and this, IMO is incorrect behaviour. When the separator >> between syntactic elements in a header is 'whitespace' it should not >> matter what combination of newlines, tabs and spaces make up the >> whitespace element. > > That would be true for what the RFC calls "structured" fields, but not > for the others (such as the Subject header). Subject text comparisons should work correctly if you were to split the subject text using the 'whitespace' definition and then reassemble it using a single space in place of each whitespace separator. Its either that or assuming that all MUAs use the same line length and all use a line split of "CRLF " - the whitespace that's needed to align the continuation with the test on the first subject line. Many MUAs will do that, but its unlikely that all will. -- martin@ | Martin Gregorie gregorie. | Essex, UK org | From bkline at rksystems.com Thu Jan 20 17:58:36 2011 From: bkline at rksystems.com (Bob Kline) Date: Thu, 20 Jan 2011 17:58:36 -0500 Subject: Part of RFC 822 ignored by email module In-Reply-To: References: Message-ID: <4D38BE1C.2050209@rksystems.com> On 1/20/2011 5:34 PM, Martin Gregorie wrote: > On Thu, 20 Jan 2011 16:25:52 -0500, Bob Kline wrote: > >> On 1/20/2011 3:48 PM, Martin Gregorie wrote: >>> That's only a problem if your code cares about the composition of the >>> whitespace and this, IMO is incorrect behaviour. When the separator >>> between syntactic elements in a header is 'whitespace' it should not >>> matter what combination of newlines, tabs and spaces make up the >>> whitespace element. >> That would be true for what the RFC calls "structured" fields, but not >> for the others (such as the Subject header). > Subject text comparisons should work correctly if you were to split the > subject text using the 'whitespace' definition and then reassemble it > using a single space in place of each whitespace separator. Its either > that or assuming that all MUAs use the same line length and all use a > line split of "CRLF " - the whitespace that's needed to align the > continuation with the test on the first subject line. Many MUAs will do > that, but its unlikely that all will. Thanks. I'm not sure everyone would agree that it's OK to collapse multiple consecutive spaces into one, but I'm beginning to suspect that those more concerned with preserving as much as possible of the original message are in the minority. It sounds like my take-home distillation from this thread is "yes, the module ignores what the spec says about unfolding, but it doesn't matter." I guess I can live with that. -- Bob Kline http://www.rksystems.com mailto:bkline at rksystems.com From malaclypse2 at gmail.com Thu Jan 20 18:01:22 2011 From: malaclypse2 at gmail.com (Jerry Hill) Date: Thu, 20 Jan 2011 18:01:22 -0500 Subject: Tkinter: The good, the bad, and the ugly! In-Reply-To: References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <4d337983$0$29983$c3e8da3$5496439d@news.astraweb.com> <044a5101-948d-4458-9c94-57dbb3e25f67@m35g2000vbn.googlegroups.com> <4d3467bf$0$29983$c3e8da3$5496439d@news.astraweb.com> <4D34B04E.8050309@web.de> <4266E8D7BA204BFEA5BF66C635CE1716@octavian> <4D35DCE8.5030002@web.de> <4D35DD47.1070304@web.de> <7A0C7934E65D4B85A584C06ADD3B6ECF@teddy> Message-ID: On Thu, Jan 20, 2011 at 4:52 PM, rantingrick wrote: >> Greg Wilson's reaction was "Yes please", and he went on to explain >> what factors kept him using Tkinter for a recent course: > ? ? ? ?http://www.python.org/pipermail/python-dev/2000-October/016757.html > > Well that link is broken so we will never know what greg said? I think that's referring to this email: http://mail.python.org/pipermail/python-dev/2000-October/010046.html -- Jerry From python at mrabarnett.plus.com Thu Jan 20 18:08:11 2011 From: python at mrabarnett.plus.com (MRAB) Date: Thu, 20 Jan 2011 23:08:11 +0000 Subject: Tkinter: The good, the bad, and the ugly! In-Reply-To: References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com><4d337983$0$29983$c3e8da3$5496439d@news.astraweb.com><044a5101-948d-4458-9c94-57dbb3e25f67@m35g2000vbn.googlegroups.com><4d3467bf$0$29983$c3e8da3$5496439d@news.astraweb.com><4D34B04E.8050309@web.de><4266E8D7BA204BFEA5BF66C635CE1716@octavian><4D35DCE8.5030002@web.de><4D35DD47.1070304@web.de><7A0C7934E65D4B85A584C06ADD3B6ECF@teddy>< Message-ID: <4D38C05B.3090908@mrabarnett.plus.com> On 20/01/2011 21:52, rantingrick wrote: > On Jan 20, 3:06 pm, Emile van Sebille wrote: > [snip] >> Greg Wilson's reaction was "Yes please", and he went on to explain >> what factors kept him using Tkinter for a recent course: > http://www.python.org/pipermail/python-dev/2000-October/016757.html > > Well that link is broken so we will never know what greg said? > [snip] Yes: http://mail.python.org/pipermail/python-dev/2000-October.txt From rantingrick at gmail.com Thu Jan 20 18:14:11 2011 From: rantingrick at gmail.com (rantingrick) Date: Thu, 20 Jan 2011 15:14:11 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <4d337983$0$29983$c3e8da3$5496439d@news.astraweb.com> <044a5101-948d-4458-9c94-57dbb3e25f67@m35g2000vbn.googlegroups.com> <4d3467bf$0$29983$c3e8da3$5496439d@news.astraweb.com> <4D34B04E.8050309@web.de> <4266E8D7BA204BFEA5BF66C635CE1716@octavian> <4D35DCE8.5030002@web.de> <4D35DD47.1070304@web.de> <7A0C7934E65D4B85A584C06ADD3B6ECF@teddy> Message-ID: On Jan 20, 5:01?pm, Jerry Hill wrote: > On Thu, Jan 20, 2011 at 4:52 PM, rantingrick wrote: > >> Greg Wilson's reaction was "Yes please", and he went on to explain > >> what factors kept him using Tkinter for a recent course: > > ? ? ? ?http://www.python.org/pipermail/python-dev/2000-October/016757.html > > > Well that link is broken so we will never know what greg said? > > I think that's referring to this email:http://mail.python.org/pipermail/python-dev/2000-October/010046.html > > -- > Jerry Thanks Jerry this was the thread i was looking for. Two points for you ;-) From rantingrick at gmail.com Thu Jan 20 18:15:42 2011 From: rantingrick at gmail.com (rantingrick) Date: Thu, 20 Jan 2011 15:15:42 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com><4d337983$0$29983$c3e8da3$5496439d@news.astraweb.com><044a5101-948d-4458-9c94-57dbb3e25f67@m35g2000vbn.googlegroups.com><4d3467bf$0$29983$c3e8da3$5496439d@news.astraweb.com><4D34B04E.8050309@web.de><4266E8D7BA204BFEA5BF66C635CE1716@octavian><4D35DCE8.5030002@web.de><4D35DD47.1070304@web.de><7A0C7934E65D4B85A584C06ADD3B6ECF@teddy>< Message-ID: <699a37e4-e67c-4e32-b954-0866acb398fe@z19g2000yqb.googlegroups.com> On Jan 20, 5:08?pm, MRAB wrote: > On 20/01/2011 21:52, rantingrick wrote:> On Jan 20, 3:06 pm, Emile van Sebille ?wrote: > > [snip] > >> Greg Wilson's reaction was "Yes please", and he went on to explain > >> what factors kept him using Tkinter for a recent course: > > ? ?http://www.python.org/pipermail/python-dev/2000-October/016757.html > > > Well that link is broken so we will never know what greg said? > > [snip] > Yes: > ? ? ?http://mail.python.org/pipermail/python-dev/2000-October.txt Sorry MRAB. I could not find Greg's reply in this mountain of Usenet you posted a link to. You lose two points :(, oh wait, why should i be unhappy ;-) From rantingrick at gmail.com Thu Jan 20 18:31:59 2011 From: rantingrick at gmail.com (rantingrick) Date: Thu, 20 Jan 2011 15:31:59 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <4d337983$0$29983$c3e8da3$5496439d@news.astraweb.com> <044a5101-948d-4458-9c94-57dbb3e25f67@m35g2000vbn.googlegroups.com> <4d3467bf$0$29983$c3e8da3$5496439d@news.astraweb.com> <4D34B04E.8050309@web.de> <4266E8D7BA204BFEA5BF66C635CE1716@octavian> <4D35DCE8.5030002@web.de> <4D35DD47.1070304@web.de> <7A0C7934E65D4B85A584C06ADD3B6ECF@teddy> Message-ID: On Jan 20, 5:01?pm, Jerry Hill wrote: > I think that's referring to this email:http://mail.python.org/pipermail/python-dev/2000-October/010046.html ---- Greg Wilson ----- I thought about using wxPython in the most recent run of my Python course, but decided to stick to Tkinter because: - There isn't a wxWindows/wxPython book (matters a lot when organizations are trying to decide what to adopt for long-term use). ---- Greg Wilson ----- WxPython could use better docs even today (not sure of what books are available) however when we decide to integrate wx into the stdlib that would be the best time to write a comprihensive "python specific tutorial/docs ---- Greg Wilson ----- - Tkinter came packaged with the 1.5.2 installer, wxPython didn't. ---- Greg Wilson ----- Duh! And if wxPython came prepackaged this post whould never have existed eh? ---- Greg Wilson ----- - There aren't as many tools on top of wxPython as there are on top of Tkinter. In particular, I think that a vector drawing package on top of wxPython that did what Sketch does, but on Windows as well as Linux, would make a great subject for a book on Python, non-trivial OO, and HCI (hint, hint...) ---- Greg Wilson ----- Oh come on, this is about as weak as Guido's "tag" rant. A vector drawing app is not a tool it's an app! An besides more "tools" or apps will be written in wx when we integrate it into the stdlib, no doubt. These are really ridiculous reasons for not choosing wxPython and i suspect that you are just another one of the mindless "Tkinter" zombies who base their judgments on friendships and constituents. From nstinemates at gmail.com Thu Jan 20 18:42:42 2011 From: nstinemates at gmail.com (Nick Stinemates) Date: Thu, 20 Jan 2011 15:42:42 -0800 Subject: Tkinter: The good, the bad, and the ugly! In-Reply-To: References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com> <4d337983$0$29983$c3e8da3$5496439d@news.astraweb.com> <044a5101-948d-4458-9c94-57dbb3e25f67@m35g2000vbn.googlegroups.com> <4d3467bf$0$29983$c3e8da3$5496439d@news.astraweb.com> <4D34B04E.8050309@web.de> <4266E8D7BA204BFEA5BF66C635CE1716@octavian> <4D35DCE8.5030002@web.de> <4D35DD47.1070304@web.de> <7A0C7934E65D4B85A584C06ADD3B6ECF@teddy> Message-ID: > > ---- Greg Wilson ----- > I thought about using wxPython in the most recent run of my Python > course, but > decided to stick to Tkinter because: > > - There isn't a wxWindows/wxPython book (matters a lot when > organizations are > trying to decide what to adopt for long-term use). > ---- Greg Wilson ----- > > WxPython could use better docs even today (not sure of what books are > available) however when we decide to integrate wx into the stdlib that > would be the best time to write a comprihensive "python specific > tutorial/docs > > I disagree. All of the ducks should be in a row* **before* making a decision like this as it shows commitment from the community to making it happen. Nothing happens because we wish it to. Nick -------------- next part -------------- An HTML attachment was scrubbed... URL: From martin at address-in-sig.invalid Thu Jan 20 18:52:18 2011 From: martin at address-in-sig.invalid (Martin Gregorie) Date: Thu, 20 Jan 2011 23:52:18 +0000 (UTC) Subject: Part of RFC 822 ignored by email module References: Message-ID: On Thu, 20 Jan 2011 17:58:36 -0500, Bob Kline wrote: > Thanks. I'm not sure everyone would agree that it's OK to collapse > multiple consecutive spaces into one, but I'm beginning to suspect that > those more concerned with preserving as much as possible of the original > message are in the minority. It sounds like my take-home distillation > from this thread is "yes, the module ignores what the spec says about > unfolding, but it doesn't matter." I guess I can live with that. > I've been doing stuff in this area with the JavaMail package, though not as yet in Python. I've learnt that you parse the headers you can extract values that work well for comparisons, as database keys, etc. but are not guaranteed to let you reconstitute the original header byte for byte. If preserving the message exactly as received the solution is to parse the message to extract the headers and MIME parts you need for the application to carry out its function, but keep the original, unparsed message so you can pass it on. The other gotcha is assuming that the MUA author read and understood the RFCs. Very many barely glanced at RFCs and/or misunderstood them. Consequently, if you use strict parsing you'll be surprised how many messages get rejected for having invalid headers or MIME headers. Fot instance, the mistakes some MUAs make when outputting To, CC and BCC headers with multiple addresses have to be seen to be believed. If the Python e-mail module lets you, set it to use lenient parsing. If this isn't an option you may well find yourself having to fix up messages before you can parse them successfully. -- martin@ | Martin Gregorie gregorie. | Essex, UK org | From steve+comp.lang.python at pearwood.info Thu Jan 20 19:02:41 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 21 Jan 2011 00:02:41 GMT Subject: __pycache__, one more good reason to stck with Python 2? References: <23e02e0d-b2f1-4b52-85ea-d1feba99dd37@22g2000prx.googlegroups.com> <4d3466d3$0$29983$c3e8da3$5496439d@news.astraweb.com> <0c62aacd-e6d2-4778-81d6-e06924192add@j1g2000vbl.googlegroups.com> <87vd1m6ezq.fsf@benfinney.id.au> <992b11a0-d35d-4b08-98ab-d08c90a86ec7@j1g2000vbl.googlegroups.com> <4d36f846$0$29983$c3e8da3$5496439d@news.astraweb.com> <9b90b457-9436-4f38-956a-bfafe3d0acdb@h17g2000pre.googlegroups.com> Message-ID: <4d38cd20$0$29984$c3e8da3$5496439d@news.astraweb.com> On Thu, 20 Jan 2011 05:09:50 -0800, John Pinner wrote: > Hi > > You have disturbe my slumber, Steven ;-) > > On Jan 19, 2:42?pm, Steven D'Aprano +comp.lang.pyt... at pearwood.info> wrote: >> On Tue, 18 Jan 2011 00:58:14 -0800, jmfauth wrote: >> > It is now practically impossible to launch a Python application via a >> > .pyc file. >> >> When has that ever been possible? >> >> .pyc files are Python byte-code. You can't run them directly using >> Python (except via the import machinery), you can't run them as a >> script, they're not machine code. Unless you write a wrapper to import >> the file as a module, you can't directly execute .pyc files. > > Not true. 'python myprog.pyc' has worked for as long as I have been > using Python. Whether or not it is a good idea is another matter. > > Probably it would be best to check what you're saying before posting > such a bald assertion, even though you were 110% sure of what you were > saying. I've been there, done that, bought the tee-shirt. Yes, thank you, I've already been corrected over this :) But you got me thinking... how far back does this behaviour go? Apparently it goes back as long as I've been using Python too: [steve at sylar ~]$ echo "print 'spam spam spam'" > spam.py [steve at sylar ~]$ python1.5 Python 1.5.2 (#1, Apr 1 2009, 22:55:54) [GCC 4.1.2 20070925 (Red Hat 4.1.2-27)] on linux2 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> import spam spam spam spam >>> [steve at sylar ~]$ python1.5 spam.pyc spam spam spam But of course, .pyc files1.5 are version specific: [steve at sylar ~]$ python2.5 spam.pyc RuntimeError: Bad magic number in .pyc file -- Steven From shankarphy at gmail.com Thu Jan 20 19:03:59 2011 From: shankarphy at gmail.com (SANKAR .) Date: Fri, 21 Jan 2011 11:03:59 +1100 Subject: CRC 16bit function Message-ID: Hi There, I am looking for buitin function to calculate 16 bit checksum values of the lines in text file using python. I could find one for 32 bit but not for 16 bit. Can some one help me? Thanks Sankar -------------- next part -------------- An HTML attachment was scrubbed... URL: From jake.biesinger at gmail.com Thu Jan 20 19:07:35 2011 From: jake.biesinger at gmail.com (Jacob Biesinger) Date: Thu, 20 Jan 2011 16:07:35 -0800 Subject: Efficient python 2-d arrays? In-Reply-To: References: Message-ID: On Thu, Jan 20, 2011 at 12:48 PM, Dan Stromberg wrote: > On Thu, Jan 20, 2011 at 11:36 AM, Jake Biesinger > wrote: >>> Thanks for the great suggestions! >> >> On a related note, is there no way to efficiently sort a python array? >> >> >>>>> x = array('f', xrange(10000000)) >>>>> x.sort() >> --------------------------------------------------------------------------- >> AttributeError ? ? ? ? ? ? ? ? ? ? ? ? ? ?Traceback (most recent call last) >> >> /home/wbiesing/src/python-sort/ in () >> >> AttributeError: 'array.array' object has no attribute 'sort' >> >>>>> type(sorted(x)) >> >> >> Seems like a common enough task, but no way to do it efficiently without scipy/numpy. > > Tap, tap: Is this thing on? ?I keep sending messages to this list, but > no one seems to "hear" what I'm writing. Hey Dan, indeed thanks for the code; I pulled it down and played around with timsort a while ago. Timsort is indeed a beast. My current solution is to do an argsort. Since I can't roll with your cython implementations (pure python *only*), this seems a bit faster than sorting the original two lists using a modified pure-python timsort. Something along the lines of: args = sorted(range(len(seq1)), key=seq1.__getitem__) seq1 = [seq1[i] for i in args] seq2 = [seq2[i] for i in args] but the method suffers from a fairly high memory usage (big list of int's for args). If this barrier is too high, I will be switching over to your pure-python timsort. > Anyway, I have a bunch of sorts in python (pure or cython, your > option) at http://stromberg.dnsalias.org/cgi-bin/viewvc.cgi/sorts/compare/trunk/?root=svn > > The pure python versions should all work out of the box with an > array.array. ?I tested the timsort on an array.array, and it worked > well. your pylint runs fail for me, saying you should use disable, not disable-msg. pylint 0.23.0, astng 0.21.1, common 0.54.0 Python 2.6.6 (r266:84292, Sep 15 2010, 16:22:56) [GCC 4.4.5] > Also, I just made a trivial modification (not checked in! ...but I did > test it) to make the cythonized timsort support sorting arrays - just > change the "list" type declarations to "object" (or perhaps > "array.array") prior to compiling. I'm not very familiar with cython syntax-- how do you bring in the array module? cimport array? import array? I see you need to change cdef list to cdef array.array or something like that. Perhaps you could send a diff? Thanks! From python at mrabarnett.plus.com Thu Jan 20 19:10:19 2011 From: python at mrabarnett.plus.com (MRAB) Date: Fri, 21 Jan 2011 00:10:19 +0000 Subject: Tkinter: The good, the bad, and the ugly! In-Reply-To: <699a37e4-e67c-4e32-b954-0866acb398fe@z19g2000yqb.googlegroups.com> References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com><4d337983$0$29983$c3e8da3$5496439d@news.astraweb.com><044a5101-948d-4458-9c94-57dbb3e25f67@m35g2000vbn.googlegroups.com><4d3467bf$0$29983$c3e8da3$5496439d@news.astraweb.com><4D34B04E.8050309@web.de><4266E8D7BA204BFEA5BF66C635CE1716@octavian><4D35DCE8.5030002@web.de><4D35DD47.1070304@web.de><7A0C7934E65D4B85A584C06ADD3B6ECF@teddy>< <699a37e4-e67c-4e32-b954-0866acb398fe@z19g2000yqb.googlegroups.com> Message-ID: <4D38CEEB.9020408@mrabarnett.plus.com> On 20/01/2011 23:15, rantingrick wrote: > On Jan 20, 5:08 pm, MRAB wrote: >> On 20/01/2011 21:52, rantingrick wrote:> On Jan 20, 3:06 pm, Emile van Sebille wrote: >> >> [snip] >>>> Greg Wilson's reaction was "Yes please", and he went on to explain >>>> what factors kept him using Tkinter for a recent course: >>> http://www.python.org/pipermail/python-dev/2000-October/016757.html >> >>> Well that link is broken so we will never know what greg said? >> >> [snip] >> Yes: >> http://mail.python.org/pipermail/python-dev/2000-October.txt > > Sorry MRAB. I could not find Greg's reply in this mountain of Usenet > you posted a link to. You lose two points :(, oh wait, why should i be > unhappy ;-) > Did you try searching for "yes please"? It takes just seconds... From debatem1 at gmail.com Thu Jan 20 20:11:35 2011 From: debatem1 at gmail.com (geremy condra) Date: Thu, 20 Jan 2011 17:11:35 -0800 Subject: CRC 16bit function In-Reply-To: References: Message-ID: On Thu, Jan 20, 2011 at 4:03 PM, SANKAR . wrote: > Hi There, > > I am looking for buitin function to calculate? 16 bit checksum values of the > lines in text file using python. > I could find one for 32 bit but not for 16 bit. Can some one help me? Google's your friend. http://efreedom.com/Question/1-1767910/Checksum-Udp-Calculation-Python Geremy Condra From martin at v.loewis.de Thu Jan 20 20:19:47 2011 From: martin at v.loewis.de (Martin v. Loewis) Date: Fri, 21 Jan 2011 02:19:47 +0100 Subject: __pycache__, one more good reason to stck with Python 2? In-Reply-To: <4d37510f$0$29983$c3e8da3$5496439d@news.astraweb.com> References: <23e02e0d-b2f1-4b52-85ea-d1feba99dd37@22g2000prx.googlegroups.com> <4d3466d3$0$29983$c3e8da3$5496439d@news.astraweb.com> <0c62aacd-e6d2-4778-81d6-e06924192add@j1g2000vbl.googlegroups.com> <87vd1m6ezq.fsf@benfinney.id.au> <992b11a0-d35d-4b08-98ab-d08c90a86ec7@j1g2000vbl.googlegroups.com> <4d36f846$0$29983$c3e8da3$5496439d@news.astraweb.com> <4d37510f$0$29983$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4D38DF33.9030404@v.loewis.de> > I know I've seen problems executing .pyc files from the shell in the > past... perhaps I was conflating details of something else. Ah, I know! > > [steve at sylar ~]$ chmod u+x toto.pyc > [steve at sylar ~]$ ./toto.pyc > : command not found ?? > ./toto.pyc: line 2: syntax error near unexpected token `(' > ./toto.pyc: line 2: `P7Mc at s dGHdS(tfooN((((s ./ > toto.pys' Works fine here: martin at mira:/tmp$ cat >a.py print "Hello, world" martin at mira:/tmp$ python Python 2.6.6 (r266:84292, Dec 26 2010, 22:31:48) [GCC 4.4.5] on linux2 Type "help", "copyright", "credits" or "license" for more information. py> import a Hello, world py> martin at mira:/tmp$ chmod +x a.pyc martin at mira:/tmp$ ./a.pyc Hello, world Notice that it is a Linux feature that it can support Python bytecode as a "native" executable when properly configured. Windows has a very similar feature, though. I think OSX can support it as well, but I haven't tried. Regards, Martin From martin at v.loewis.de Thu Jan 20 20:30:58 2011 From: martin at v.loewis.de (Martin v. Loewis) Date: Fri, 21 Jan 2011 02:30:58 +0100 Subject: __pycache__, one more good reason to stck with Python 2? In-Reply-To: <4d38cd20$0$29984$c3e8da3$5496439d@news.astraweb.com> References: <23e02e0d-b2f1-4b52-85ea-d1feba99dd37@22g2000prx.googlegroups.com> <4d3466d3$0$29983$c3e8da3$5496439d@news.astraweb.com> <0c62aacd-e6d2-4778-81d6-e06924192add@j1g2000vbl.googlegroups.com> <87vd1m6ezq.fsf@benfinney.id.au> <992b11a0-d35d-4b08-98ab-d08c90a86ec7@j1g2000vbl.googlegroups.com> <4d36f846$0$29983$c3e8da3$5496439d@news.astraweb.com> <9b90b457-9436-4f38-956a-bfafe3d0acdb@h17g2000pre.googlegroups.com> <4d38cd20$0$29984$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4D38E1D2.70007@v.loewis.de> > But you got me thinking... how far back does this behaviour go? ================================= ==> Release 1.1 (11 Oct 1994) <== ================================= - Passing the interpreter a .pyc file as script argument will execute the code in that file. (On the Mac such files can be double-clicked!) - New module compileall generates .pyc files for all modules in a directory (tree) without also executing them [Notice that "on the Mac" refers to Mac System 7 here] ======================================= ==> Release 1.0.0 (26 January 1994) <== ======================================= * It is now possible to have a .pyc file without a corresponding .py file. (Warning: this may break existing installations if you have an old .pyc file lingering around somewhere on your module search path without a corresponding .py file, when there is a .py file for a module of the same name further down the path -- the new interpreter will find the first .pyc file and complain about it, while the old interpreter would ignore it and use the .py file further down.) Regards, Martin From drsalists at gmail.com Thu Jan 20 21:10:35 2011 From: drsalists at gmail.com (Dan Stromberg) Date: Thu, 20 Jan 2011 18:10:35 -0800 Subject: Efficient python 2-d arrays? In-Reply-To: References: Message-ID: On Thu, Jan 20, 2011 at 4:07 PM, Jacob Biesinger wrote: > On Thu, Jan 20, 2011 at 12:48 PM, Dan Stromberg wrote: >> On Thu, Jan 20, 2011 at 11:36 AM, Jake Biesinger >> wrote: >>>> Thanks for the great suggestions! >>> >>> On a related note, is there no way to efficiently sort a python array? >>> >>> >>>>>> x = array('f', xrange(10000000)) >>>>>> x.sort() >>> --------------------------------------------------------------------------- >>> AttributeError ? ? ? ? ? ? ? ? ? ? ? ? ? ?Traceback (most recent call last) >>> >>> /home/wbiesing/src/python-sort/ in () >>> >>> AttributeError: 'array.array' object has no attribute 'sort' >>> >>>>>> type(sorted(x)) >>> >>> >>> Seems like a common enough task, but no way to do it efficiently without scipy/numpy. >> >> Tap, tap: Is this thing on? ?I keep sending messages to this list, but >> no one seems to "hear" what I'm writing. > > Hey Dan, indeed thanks for the code; I pulled it down and played > around with timsort a while ago. Timsort is indeed a beast. My current > solution is to do an argsort. ?Since I can't roll with your cython > implementations (pure python *only*), this seems a bit faster than > sorting the original two lists using a modified pure-python timsort. > Something along the lines of: > > args = sorted(range(len(seq1)), key=seq1.__getitem__) > seq1 = [seq1[i] for i in args] > seq2 = [seq2[i] for i in args] > > but the method suffers from a fairly high memory usage (big list of > int's for args). ?If this barrier is too high, I will be switching > over to your pure-python timsort. Oh, cool. I guess I'm not a ghost after all. :) And an argsort sounds like a nice solution. >> Anyway, I have a bunch of sorts in python (pure or cython, your >> option) at http://stromberg.dnsalias.org/cgi-bin/viewvc.cgi/sorts/compare/trunk/?root=svn >> >> The pure python versions should all work out of the box with an >> array.array. ?I tested the timsort on an array.array, and it worked >> well. > > your pylint runs fail for me, saying you should use disable, not disable-msg. > pylint 0.23.0, > astng 0.21.1, common 0.54.0 > Python 2.6.6 (r266:84292, Sep 15 2010, 16:22:56) > [GCC 4.4.5] Earlier today I updated the code to deal with newer pylints - including the disable vs disable-msg thing. If you "svn update", you should get these changes. >> Also, I just made a trivial modification (not checked in! ...but I did >> test it) to make the cythonized timsort support sorting arrays - just >> change the "list" type declarations to "object" (or perhaps >> "array.array") prior to compiling. > > I'm not very familiar with cython syntax-- how do you bring in the array module? > cimport array? import array? I see you need to change cdef list to > cdef array.array or something like that. ?Perhaps you could send a > diff? http://stromberg.dnsalias.org/svn/sorts/compare/branches/arrays now has a version of timsort that expects objects (IOW, about anything, duck typed) instead of lists. I tried briefly to declare some of the types to be array.array, but perhaps Cython doesn't like that - I was getting compile-time errors from it. HTH. From nhodgson at bigpond.net.au Thu Jan 20 21:34:03 2011 From: nhodgson at bigpond.net.au (Neil Hodgson) Date: Fri, 21 Jan 2011 13:34:03 +1100 Subject: Tkinter: The good, the bad, and the ugly! In-Reply-To: References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com><4d337983$0$29983$c3e8da3$5496439d@news.astraweb.com><044a5101-948d-4458-9c94-57dbb3e25f67@m35g2000vbn.googlegroups.com><4d3467bf$0$29983$c3e8da3$5496439d@news.astraweb.com><4D34B04E.8050309@web.de><4266E8D7BA204BFEA5BF66C635CE1716@octavian><4D35DCE8.5030002@web.de><4D35DD47.1070304@web.de><7A0C7934E65D4B85A584C06ADD3B6ECF@teddy>< ih53k2$pjf$1@dough.gmane.org> <513d0274-1878-49a6-9382-31b6ae7aaef3@y9g2000prf.googlegroups.com> Message-ID: Emile van Sebille: > The problem with QT is the license. > > From http://qt.nokia.com/products/licensing/: > > Qt Commercial Developer License > The Qt Commercial Developer License is the correct license to use for > the development of proprietary and/or commercial software ... The LGPL version is also useful for producing commercial software. >From the same web page: """ Qt GNU LGPL v. 2.1 Version This version is available for development of proprietary and commercial applications in accordance with the terms and conditions of the GNU Lesser General Public License version 2.1. """ Developing a proprietary (closed source) application using LGPL libraries is normally not a problem as the only pieces of code you have to publish are changes to those LGPL libraries, not the application code. Most applications do not change the libraries. The "can't reuse LGPL code" clause is a restriction on what can be done with the Qt Commercial Developer License not on what can be done with the LGPL license. GTK+ has always been LGPL and that license has not been an obstacle to either open source or closed source projects. Neil From jeanfrancois.leberre at gmail.com Thu Jan 20 21:35:46 2011 From: jeanfrancois.leberre at gmail.com (Jean-Francois) Date: Thu, 20 Jan 2011 18:35:46 -0800 (PST) Subject: New instance of a class : not reset? Message-ID: Hi, In the following example, I don't understand why attribute 'data' is not reset when I get the new instance of Bag It works if I make a copy (data[:]) but I want to understand why Thanks class Bag(object): def __init__(self, data = []): self.data = data #self.data = data[:] def add(self, x): self.data.append(x) bag = Bag() print bag.data bag.add('toto') print bag.data bag = Bag() # new instance of Bag, all attributes clear? print bag.data # 'toto' is still there !!! From andre.roberge at gmail.com Thu Jan 20 21:46:26 2011 From: andre.roberge at gmail.com (=?ISO-8859-1?Q?Andr=E9?=) Date: Thu, 20 Jan 2011 18:46:26 -0800 (PST) Subject: New instance of a class : not reset? In-Reply-To: Message-ID: On Thursday, January 20, 2011 10:35:46 PM UTC-4, Jean-Francois wrote: > Hi, > > In the following example, I don't understand why attribute 'data' is > not reset when I get the new instance of Bag > It works if I make a copy (data[:]) but I want to understand why > > Thanks > > > class Bag(object): > def __init__(self, data = []): See http://docs.python.org/tutorial/controlflow.html#default-argument-values Read the text following "Important warning: The default value is evaluated only once.". Andr? > self.data = data > #self.data = data[:] > def add(self, x): > self.data.append(x) > > bag = Bag() > print bag.data > bag.add('toto') > print bag.data > bag = Bag() # new instance of Bag, all attributes clear? > print bag.data # 'toto' is still there !!! From python at mrabarnett.plus.com Thu Jan 20 21:55:16 2011 From: python at mrabarnett.plus.com (MRAB) Date: Fri, 21 Jan 2011 02:55:16 +0000 Subject: New instance of a class : not reset? In-Reply-To: References: Message-ID: <4D38F594.8050602@mrabarnett.plus.com> On 21/01/2011 02:35, Jean-Francois wrote: > Hi, > > In the following example, I don't understand why attribute 'data' is > not reset when I get the new instance of Bag > It works if I make a copy (data[:]) but I want to understand why > > Thanks > > > class Bag(object): > def __init__(self, data = []): > self.data = data > #self.data = data[:] > def add(self, x): > self.data.append(x) > > bag = Bag() > print bag.data > bag.add('toto') > print bag.data > bag = Bag() # new instance of Bag, all attributes clear? > print bag.data # 'toto' is still there !!! See: http://effbot.org/zone/default-values.htm From davea at ieee.org Thu Jan 20 22:10:00 2011 From: davea at ieee.org (Dave Angel) Date: Thu, 20 Jan 2011 22:10:00 -0500 Subject: CRC 16bit function In-Reply-To: References: Message-ID: <4D38F908.5060807@ieee.org> On 01/-10/-28163 02:59 PM, geremy condra wrote: > On Thu, Jan 20, 2011 at 4:03 PM, SANKAR . wrote: >> Hi There, >> >> I am looking for buitin function to calculate 16 bit checksum values of the >> lines in text file using python. >> I could find one for 32 bit but not for 16 bit. Can some one help me? > > Google's your friend. > > http://efreedom.com/Question/1-1767910/Checksum-Udp-Calculation-Python > > Geremy Condra > There are at least 3 commonly used checksum algorithms that give 16bit results. Two of them are CRC's, with different polynomials. And the third is the one's complement that Geremy posted the link to, used in tcp/ip traffic. Try http://bytes.com/topic/python/answers/27677-crc-16-a or http://bytes.com/topic/python/insights/887357-python-check-crc-frame-crc-16-ccitt The latter is likely to be extremely slow. DaveA From albert at spenarnc.xs4all.nl Thu Jan 20 23:51:46 2011 From: albert at spenarnc.xs4all.nl (Albert van der Horst) Date: 21 Jan 2011 04:51:46 GMT Subject: examples of realistic multiprocessing usage? References: <2011011611053732597-tomfsessile@gmailcom> Message-ID: In article , Adam Tauno Williams wrote: >On Mon, 2011-01-17 at 13:55 +0000, Albert van der Horst wrote: >> In article , >> Philip Semanchuk wrote: >> >> >I grepped through the code to see that it's using = >> >multiprocessing.Listener. I didn't go any further than that because our = >> >project is BSD licensed and the license for Gluino is unclear. Until I = >> >find out whether or not its under an equally permissive license, I can't = >> >borrow ideas and/or code from it. >> You have been brain washed by the Intellectual Properties congsy. >> Of course you can read through code to borrow idea's from it. > >I wouldn't; and there is no brain-washing. > >It is very unwise to look at GPL'd code if you are working on a non-GPL >project; the GPL is specifically and intentionally viral. The >distinction between reading-through-code-and-borrowing-ideas and >copying-code is thin and best left to lawyers. This is what some people want you to believe. Arm twisting by GPL-ers when you borrow their ideas? That is really unheard of. GPL-ers are not keen on getting the most monetary award by setting lawyers on you and go to court only reluctantly to enforce the license. > >Aside: Comments to the contrary often stand-on-their-head to make such >cases. For example: > >"You do have a choice under the GPL license: you can stop using the >stolen code and write your own, or you can decide you'd rather release >under the GPL. But the choice is yours. If you say, I choose neither, >then the court can impose an injunction to stop you from further >distribution, but it won't order your code released under the GPL. ... >Of course, you could avoid all such troubles in the first place by not >stealing GPL code to begin with" > Stealing code means just that, verbatim copies. When you read this carefully, you can see that reimplementing the stolen code is an option. Exactly what you say is legally impossible. It doesn't say: "you can stop using the stolen code, and now you're forever banned from writing your own, since you have seen our code" > >Seriously? What that basically means is you can't use GPL'd code in a >non-GPL'd product/project. Saying if you do it is OK, but you'll be >required to replace the code or change your license is >standing-on-ones-head. Risking a forced reimplementation of a core >component of an existing application is 'just nuts'. GPL-code is protected under *copyright law*, not patents or some such. That means that reimplementing idea's is okay. That is one of the things GPL tries to protect. Also we recognize the fact that the wheel is reinvented all the time and that there are a limited number of solutions to a problem. You could easily have come up with the same idea as me. Then you overlook another possibility. I have a lot of GPL-ed code on my site. If you want to use some of it commercially, you could contact me and negotiate a non-GPL license. You might be surprised how easy I'm on you, as long as you recognize where the code comes from. If you want to use it BSD-licensed, I would be even more lenient (unless strategic issues are at stake.) So pardon me, but not even looking at code you might learn from is pretty hysteric. Groetjes Albert -- -- Albert van der Horst, UTRECHT,THE NETHERLANDS Economic growth -- being exponential -- ultimately falters. albert at spe&ar&c.xs4all.nl &=n http://home.hccnet.nl/a.w.m.van.der.horst From longqian9509 at gmail.com Thu Jan 20 23:52:15 2011 From: longqian9509 at gmail.com (longqian9509 at gmail.com) Date: Thu, 20 Jan 2011 20:52:15 -0800 (PST) Subject: is it a bug in exec? Message-ID: <0629ea10-b667-4630-a99f-78168a3e0979@u6g2000yqk.googlegroups.com> In pyhton 3.1, I found the following code will succeed with argument 1 to 4 and fail with argument 5 to 9. It is really strange to me. I suspect it may be a buy in exec() function. Does anyone have some idea about it? Thanks. t1=""" class foo: def fun(): print('foo') def main(): global foo foo.fun() main() """ t2=""" class foo: def fun(): print('foo') def main(): foo.fun() main() """ import sys import copy if sys.argv[1]=='1': exec(t1) elif sys.argv[1]=='2': exec(t2) elif sys.argv[1]=='3': exec(t1,{},{}) elif sys.argv[1]=='4': exec(t2,globals(),locals()) elif sys.argv[1]=='5': exec(t2,{},{}) elif sys.argv[1]=='6': exec(t2,globals(),{}) elif sys.argv[1]=='7': exec(t2,{},locals()) elif sys.argv[1]=='8': exec(t2,copy.copy(globals()),locals()) elif sys.argv[1]=='9': exec(t2,globals(),copy.copy(locals())) From pavlovevidence at gmail.com Fri Jan 21 00:48:29 2011 From: pavlovevidence at gmail.com (Carl Banks) Date: Thu, 20 Jan 2011 21:48:29 -0800 (PST) Subject: Part of RFC 822 ignored by email module References: Message-ID: <6b41e8ba-aefc-443d-8c7e-d9caa8808c7e@y9g2000prf.googlegroups.com> On Jan 20, 9:55?am, Bob Kline wrote: > On 1/20/2011 12:23 PM, Carl Banks wrote: > > > > > On Jan 20, 7:08 am, Bob Kline ?wrote: > >> I just noticed that the following passage in RFC 822: > > >> ? ? ? ? ? The process of moving ?from ?this ?folded ? multiple-line > >> ? ? ? ? ? representation ?of a header field to its single line represen- > >> ? ? ? ? ? tation is called "unfolding". ?Unfolding ?is ?accomplished ?by > >> ? ? ? ? ? regarding ? CRLF ? immediately ?followed ?by ?a ?LWSP-char ?as > >> ? ? ? ? ? equivalent to the LWSP-char. > > >> is not being honored by the email module. ?The following two invocations > >> of message_from_string() should return the same value, but that's not > >> what happens: > > >> ? >>> ?import email > >> ? >>> ?email.message_from_string("Subject: blah").get('SUBJECT') > >> 'blah' > >> ? >>> ?email.message_from_string("Subject:\n blah").get('SUBJECT') > >> ' blah' > > >> Note the space in front of the second value returned, but missing from > >> the first. ?Can someone convince me that this is not a bug? > > That's correct, according to my reading of RFC 822 (I doubt it's > > changed so I didn't bother to look up what the latest RFC on that > > subject is.) > > > The RFC says that in a folded line the whitespace on the following > > line is considered a part of the line. > > Thanks for responding. ?I think your interpretation of the RFC is the > same is mine. ?What I'm saying is that by not returning the same value > in the two cases above the module is not "regarding CRLF immediately > followed by a LWSP-char as equivalent to the LWSP-char." That makes sense. The space after \n is part of the reconstructed subject and the email module should have treated it same as if the line hadn't been folded. I agree that it's a bug. The line-folding needs to be moved earlier in the parse process. Carl Banks From pavlovevidence at gmail.com Fri Jan 21 01:38:28 2011 From: pavlovevidence at gmail.com (Carl Banks) Date: Thu, 20 Jan 2011 22:38:28 -0800 (PST) Subject: Part of RFC 822 ignored by email module References: <4D384FF8.6060708@rksystems.com> Message-ID: On Jan 20, 9:58?am, Dennis Lee Bieber wrote: > On Thu, 20 Jan 2011 10:08:40 -0500, Bob Kline > declaimed the following in gmane.comp.python.general: > > > > > I just noticed that the following passage in RFC 822: > > > ? ? ? ? ?The process of moving ?from ?this ?folded ? multiple-line > > ? ? ? ? ?representation ?of a header field to its single line represen- > > ? ? ? ? ?tation is called "unfolding". ?Unfolding ?is ?accomplished ?by > > ? ? ? ? ?regarding ? CRLF ? immediately ?followed ?by ?a ?LWSP-char ?as > > ? ? ? ? ?equivalent to the LWSP-char. > > > is not being honored by the email module. ?The following two invocations > > of message_from_string() should return the same value, but that's not > > what happens: > > > ?>>> import email > > ?>>> email.message_from_string("Subject: blah").get('SUBJECT') > > 'blah' > > ?>>> email.message_from_string("Subject:\n blah").get('SUBJECT') > > ' blah' > > > Note the space in front of the second value returned, but missing from > > the first. ?Can someone convince me that this is not a bug? > > ? ? ? ? I'd first be concerned about the absence of the line ending sequence > specified by the RFC: carriage return (CR; \r) followed by line feed > (LF; \n). > > ? ? ? ? \n by itself is not an RFC compliant line ending (even if writing to > a file on Windows in text mode converts \n into \r\n). Though it does > appear the module accepts it as such. Well, I think that message_from_string() would have to accept any RFC822-compatible message, since it's documented as such, but it doesn't necessarily have to reject technically invalid ones. Well, the RFC is concerned mainly with the transmission format, and doesn't require libraries to force the user to input CRLF, so in general there's no reason \n isn't acceptable if the library allows it. However, message_from_string() is part of the transmission (it's documented as being able to accept RFC822-formatted messages) so it has to respect RFC 822 formatting. But I think it is ok for it to accept non-compliant messages that use LF or CR. (Any tool that isn't brain dead should, too.) The RFC doesn't specifically prohibit this. > ? ? ? ? Secondly, nothing in the spec says it trims leading whitespace from > the unwrapped lines. In fact, all it says is that the line ending itself > is removed from the string. > > >>> email.message_from_string("Subject:\r\n ? ? blah").get('SUBJECT') > > ' ? ? blah' I don't think this behavior is covered in the RFC since this happens after transmission. I.e., message_from_string "receives" the RFC822- compliant message, then it's mostly free to do what it wants with it, including stripping leading whitespace of header values. > ? ? ? ? However, the module does appear to trim leading whitespace that > occurs between the : and text (and the line end is considered for that > trimming, but not any whitespace after it). > > >>> email.message_from_string("Subject: ? ? ?blah\r\n ? ? blah").get('SUBJECT') > 'blah\r\n ? ? blah' > >>> email.message_from_string("Subject: ? ? ?blah\r\n ? ? blah").get('SUBJECT') > 'blah\r\n ? ? blah' > >>> email.message_from_string("Subject: ? ? ?blah\r\n ? ? blah ? ").get('SUBJECT') > > 'blah\r\n ? ? blah ? '>>> email.message_from_string("Subject: \r\n ? ? blah ? ").get('SUBJECT') > ' ? ? blah ? ' In this case the RFC does address the behavior downstream of transmission: it says that the whitespace following a folded line is equivalent to that line with just the whitespace, yet the email module treats them differently. This is unquestionably a bug. Carl Banks From arnodel at gmail.com Fri Jan 21 02:41:02 2011 From: arnodel at gmail.com (Arnaud Delobelle) Date: Fri, 21 Jan 2011 07:41:02 +0000 Subject: statement level resumable exception References: <87oc7b9wkm.fsf@gmail.com> <62658b12-34b7-4ed5-9ecd-5182b53f7b31@t35g2000yqj.googlegroups.com> <87k4hz9uiu.fsf@gmail.com> Message-ID: <87fwsmaelt.fsf@gmail.com> ilejn writes: > Arnaud, > > these lists are not generated. > > Actually these lists are a sort of interpreted programs and contain > some application logic. > > Here is an example > [ > [PUSH, [get_modified_interface, req]], > [TIMEOUT, 3], > [PULL, [out_interface, '']], > [PULL, [err_interface, '']], > [PULL, [out_mined_interface, req]], > ] > > If any interface name is unknown the list must not be invoked (in > other words, f function > call with this list must be somehow bypassed). > > Thanks. You could still use the same idea and delay evaluation of the lists. E.g. prg1 = """[ [PUSH, [get_modified_interface, req]], [TIMEOUT, 3], ... """ prg2 = """[ [OPCODE, [arguments, blah]], ... """ ... prgN = """...""" for prg in prg1, prg2, ..., prgN: try: prg = eval(prg) except NameError: continue f(prg) -- Arnaud From steve+comp.lang.python at pearwood.info Fri Jan 21 03:01:14 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 21 Jan 2011 08:01:14 GMT Subject: __pycache__, one more good reason to stck with Python 2? References: <23e02e0d-b2f1-4b52-85ea-d1feba99dd37@22g2000prx.googlegroups.com> <4d3466d3$0$29983$c3e8da3$5496439d@news.astraweb.com> <0c62aacd-e6d2-4778-81d6-e06924192add@j1g2000vbl.googlegroups.com> <87vd1m6ezq.fsf@benfinney.id.au> <992b11a0-d35d-4b08-98ab-d08c90a86ec7@j1g2000vbl.googlegroups.com> <4d36f846$0$29983$c3e8da3$5496439d@news.astraweb.com> <4d37510f$0$29983$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4d393d4a$0$29983$c3e8da3$5496439d@news.astraweb.com> On Wed, 19 Jan 2011 14:31:15 -0800, Alice Bevan?McGregor wrote: > On 2011-01-19 13:01:04 -0800, Steven D'Aprano said: >> I know I've seen problems executing .pyc files from the shell in the >> past... perhaps I was conflating details of something else. Ah, I know! >> >> [steve at sylar ~]$ chmod u+x toto.pyc >> [steve at sylar ~]$ ./toto.pyc >> : command not found ?? >> ./toto.pyc: line 2: syntax error near unexpected token `(' ./toto.pyc: >> line 2: `P7Mc at s dGHdS(tfooN((((s ./ toto.pys' > > ... don't do that. I do not know why that would be expected to work, > ever. (Unless you're crafty and wrap a real shell script around the > .pyc, in which case it's no longer a .pyc.) I didn't expect it to work, but I have seen others do it and be surprised that it doesn't. This is why I was pleasantly surprised to learn that `python toto.pyc` does work -- I was conflating the above failure with the issue under discussion. -- Steven From orasnita at gmail.com Fri Jan 21 03:05:24 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Fri, 21 Jan 2011 10:05:24 +0200 Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com><4d337983$0$29983$c3e8da3$5496439d@news.astraweb.com><044a5101-948d-4458-9c94-57dbb3e25f67@m35g2000vbn.googlegroups.com><4d3467bf$0$29983$c3e8da3$5496439d@news.astraweb.com><4D34B04E.8050309@web.de><4266E8D7BA204BFEA5BF66C635CE1716@octavian><4D35DCE8.5030002@web.de><4D35DD47.1070304@web.de><7A0C7934E65D4B85A584C06ADD3B6ECF@teddy> Message-ID: > From: "Adam Skutt" > Yet, for some unfathomable reason, > you keep promoting > I would be glad if you could tell me about a portable solution which is > accessible with JAWS and Window Eyes, the most used screen readers under > Windows (real glad). I did, Qt. I'm not yournanny and I'm not going to go test it for you. There are bugs in the Qt database relating to JAWS functionality, so it others have plainly gotten it working to some degree. But honestly, why should I waste my time replying to you when you're too damn lazy to even use Google? I certainly won't be doing so in the future. "Lead a ignorant, thirsty horse to water, watch it die of thirst" and all that. I have tried more QT-based apps and I couldn't find one to be accessible, while most widgets offered by WxPython are accessible out of the box. QT is really bad, but you hijacked the tread because as you can see even in the subject, we are talking about Tkinter, not about QT. If QT is not included by default in Python, it is not such a big problem because only those who care more about the visual aspect than about the accessibility use it, but Tkinter is bad because it is promoted and many beginners will start using it witout knowing how bad it is and why. You keep telling that you searched on the web for finding what the others say about accessibility but this is a very wrong way. Don't say anything about accessibility if you haven't tried personally. Octavian From steve+comp.lang.python at pearwood.info Fri Jan 21 03:14:52 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 21 Jan 2011 08:14:52 GMT Subject: is it a bug in exec? References: <0629ea10-b667-4630-a99f-78168a3e0979@u6g2000yqk.googlegroups.com> Message-ID: <4d39407c$0$29983$c3e8da3$5496439d@news.astraweb.com> On Thu, 20 Jan 2011 20:52:15 -0800, longqian9509 at gmail.com wrote: > In pyhton 3.1, I found the following code will succeed with argument 1 > to 4 and fail with argument 5 to 9. It is really strange to me. I > suspect it may be a buy in exec() function. Does anyone have some idea > about it? Thanks. What makes you think it's a bug? Is there anything in the documentation of exec that suggests to you that some other behaviour should occur? What version of Python are you using? Without knowing what behaviour you expect and what behaviour you see, how are we supposed to know if you've found a bug or not? I suggest you fire up the interactive interpreter and try this: t1 = """ class foo: def fun(): print('foo') def main(): global foo foo.fun() main() """ dg = {} dl = {} exec(t1, dg, dl) then inspect the values of dg and dl and see if it helps. If not, write back with what you expect to happen, and what you see instead. -- Steven From timr at probo.com Fri Jan 21 03:39:53 2011 From: timr at probo.com (Tim Roberts) Date: Fri, 21 Jan 2011 00:39:53 -0800 Subject: Part of RFC 822 ignored by email module References: Message-ID: <7chij6lnm3ln7phdr7536rvb0sb4iuqpbh@4ax.com> Bob Kline wrote: > >I just noticed that the following passage in RFC 822: For future interest, RFC 822 has LONG since been replaced, first by RFC 2822, then by RFC 5322. I believe the white space folding requirement is still there, but something that violates 822 but not 5322 (and there are several such things) is not all that important. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From ilja.golshtein at gmail.com Fri Jan 21 03:41:21 2011 From: ilja.golshtein at gmail.com (ilejn) Date: Fri, 21 Jan 2011 00:41:21 -0800 (PST) Subject: statement level resumable exception References: <87oc7b9wkm.fsf@gmail.com> <62658b12-34b7-4ed5-9ecd-5182b53f7b31@t35g2000yqj.googlegroups.com> <87k4hz9uiu.fsf@gmail.com> <87fwsmaelt.fsf@gmail.com> Message-ID: <52e20ce1-0e0c-4817-a61d-91437291883a@i18g2000yqn.googlegroups.com> Arnaud, it looks like a solution. Perhaps it is better than plain try/accept and than proxy class with __getattr__. It is not for free, e.g. because syntax check such as parentheses matching is lazy too, though looks very interesting. Thanks a lot! On Jan 21, 10:41?am, Arnaud Delobelle wrote: > ilejn writes: > > Arnaud, > > > these lists are not generated. > > > Actually these lists are a sort of interpreted programs and contain > > some application logic. > > > Here is an example > > ? ? ? ? [ > > ? ? ? ? [PUSH, [get_modified_interface, req]], > > ? ? ? ? [TIMEOUT, 3], > > ? ? ? ? [PULL, [out_interface, '']], > > ? ? ? ? [PULL, [err_interface, '']], > > ? ? ? ? [PULL, [out_mined_interface, req]], > > ? ? ? ? ] > > > If any interface name is unknown the list must not be invoked (in > > other words, f function > > call with this list must be somehow bypassed). > > > Thanks. > > You could still use the same idea and delay evaluation of the lists. E.g. > > prg1 = """[ > ? ? [PUSH, [get_modified_interface, req]], > ? ? [TIMEOUT, 3], > ? ? ... > """ > > prg2 = """[ > ? ? [OPCODE, [arguments, blah]], > ? ? ... > """ > > ... > > prgN = """...""" > > for prg in prg1, prg2, ..., prgN: > ? ? try: > ? ? ? ? prg = eval(prg) > ? ? except NameError: > ? ? ? ? continue > ? ? f(prg) > > -- > Arnaud Best regards, Ilja Golshtein From alt.mcarter at gmail.com Fri Jan 21 05:12:51 2011 From: alt.mcarter at gmail.com (Mark Carter) Date: Fri, 21 Jan 2011 02:12:51 -0800 (PST) Subject: Printing RTF file under win32 Message-ID: <2608cc6e-a385-4a31-ab9e-f740d231bf06@k11g2000vbf.googlegroups.com> I'm using Python 2.6.5 on win32. I would like to print a batch of RTF files on a printer. I don't want to use the win32api.ShellExecute command because that invokes Word, and Word has been configured in a strange way by one of our admins, making it inconvenient to use. What should I do? From research at johnohagan.com Fri Jan 21 05:20:29 2011 From: research at johnohagan.com (John O'Hagan) Date: Fri, 21 Jan 2011 10:20:29 +0000 Subject: Sending changed parameters into nested generators In-Reply-To: <201101210329.53456.research@johnohagan.com> References: <201101210329.53456.research@johnohagan.com> Message-ID: <201101211020.29967.research@johnohagan.com> On Fri, 21 Jan 2011, cbrown wrote: > On Nov 12, 10:52 pm, "John O'Hagan" wrote: > > On Sat, 13 Nov 2010, Steven D'Aprano wrote: > > > On Fri, 12 Nov 2010 09:47:26 +0000, John O'Hagan wrote: > > > > I have a generator function which takes as arguments another > > > > generator and a dictionary of other generators like this: > > > > > > > > def modgen(gen, gendict): > > > > for item in gen(): > > > > for k, v in gendict: > > > > do_something_called_k(item, v.next()) > > > > > > > > yield item > > > > > > [snip] > > > > > > > If anyone's still reading :) , how can I send new values to arbitrary > > > > sub- generators? > > > > > > I have a headache after reading your problem :( > > > > > > I think it's a good time to point you at the Zen, particularly these > > > five maxims: > > > > > > Beautiful is better than ugly. > > > Simple is better than complex. > > > Complex is better than complicated. > > > Flat is better than nested. > > > If the implementation is hard to explain, it's a bad idea. > > > > > > I'm afraid that your nested generators inside another generator idea > > > fails all of those... it's not elegant (beautiful), it's complicated, > > > it's nested, and the implementation is hard to explain. > > > > > > You could probably replace generators with full-blown iterators, but I > > > wonder what you're trying to accomplish that is so complicated that it > > > needs such complexity to solve it. What are you actually trying to > > > accomplish? Can you give a simple example of what practical task you > > > hope to perform? I suspect there's probably a more elegant way to > > > solve the problem. > > > > I hope there is! > > > > The project not practical but artistic; it's a real-time musical > > composition program. > > > > A (simplified) description: one module contains number-list generating > > functions, others contain functions designed to filter and modify the > > number lists produced, according to various parameters. Each such stream > > of number lists is assigned a musical meaning (e.g. pitch, rhythm, > > volume, etc) and they are combined to produce representations of musical >>phrases, which are sent to a backend which plays the music > >as it is produced, and makes PDF scores. > > >Each such "instrument" runs as a separate thread, so several can play >>together in acoordinated fashion. > > > > All the compositional interest lies in the selection of number-list >>generators and how their output is modified. For example, if I say "Play >>every third note up an octave" it's not very interesting, compared to "Play >>every nth note up an interval of m", where n and m vary according to some >>pattern. It gets even more interesting when that pattern is a function of x >>and y, which also vary according to another pattern, and so on. > > > > To that end, I have each parameter of each modifier set by another > > generator, such that the value may change with each iteration. This may > > continue recursively, until at some level we give a parameter a simple > > value. > > > > That's all working, but I also want it to be interactive. Each thread > > opens a terminal where new options can be entered, but so far it only >>works, as I mentioned, for changing the values in a top-level mutable >>object. > > I might first suggest this, although I have some caveats to add: > > def genfilter(evaluator, **param_sources): > while True: > params = {} > for param, gen in param_sources.iteritems(): > params[param] = gen.next() > yield evaluator(**params) > > You can then do things like: > >>> def concat(in1, in2): > >>> return str(in1)+"|"+str(in2) > >>> > >>> a = (i for i in range(1,5)) # generator based on a list > >>> b = (2*i for i in xrange(1,5)) # 'pure' generator > >>> c = genfilter(concat, in1=a, in2=b) [...] > or, more relevant to your original question regarding modifying things > > mid-stream: > >>> class Mult(): > >>> def __init__(self, multiplier): > >>> self.mulitplier = multiplier > >>> > >>> def multi(self, val): > >>> return val*self.multiplier > >>> > >>> m = Mult(2) > >>> a = (i for i in range(1,10)) > >>> b = (i for i in range(1,10)) > >>> c = genfilter(m.multi, val=b) > >>> d = genfilter(concat, in1=a, in2=c) > >>> d.next() [...] > But a real problem with this whole strategy is that a generator's > next() function is called every time it is evaluated. If the > relationship between your various generators forms a rooted tree, > that's not a problem, but I would think the relationships form a > directed acyclic graph, and in that case, you end up 'double > incrementing' nodes in a way you don't want: [...] > To solve that problem, you need a somewhat more complex solution: a > class that ensures that each previous stage is only invoked once per > 'pass'. I've got an idea for that, if that is of interest. Going for the record for pregnant pauses, I've taken on board the replies to my post (from Nov 12!), for which I thank you, and have come up with a solution. A simplified version follows. Chas's mention of trees made me realise that my program _is_ actually a tree of iterators, with each node receiving arguments from its children, so I made this class: class IterNode(object): """Iterator wrapper to give access to arguments to allow recursive updating""" def __init__(self, iterobj, arg): """Takes an iterator class or generator function, and its single arg""" self.arg = arg self.iterobj = iterobj self.iterator = iterobj(arg) def __iter__(self): return self def next(self): return self.iterator.next() def __eq__(self, other): return self.iterobj == other.iterobj and self.arg == other.arg def __ne__(self, other): return not self == other def deepdate(self, other): """Deep-update a nested IterNode""" if self != other: arg1, arg2 = self.arg, other.arg if arg1 != arg2: if isinstance(arg1, dict) and isinstance(arg2, dict): for k in arg1.copy().iterkeys(): if k not in arg2: del arg1[k] for k, v in arg2.iteritems(): if k in arg1: arg1[k].deepdate(v) else: arg1[k] = v else: self.__init__(other.iterobj, other.arg) ...And two custom iterator classes: for the root of the tree, the PhraseMaker iterator class is the only part really specific to music, in that it combines sequences from iterators into representations of musical phrases, assigning them to pitch, duration, volume etc.: class PhraseMaker(object): def __init__(self, iterdict): self.iterdict = iterdict self.iterator = self.phriterate() def __iter__(self): return self def next(self): return self.iterator.next() ##Omitting for brevity methods to combine ##sequences into musical phrases def phriterate(self): "Generate phrases" while True: phrase = [] for k, v in self.iterdict.iteritems(): getattr(self, k)(phrase, v.next()) yield phrase and for the branches, "SeqGen" is a fairly generic iterator which takes any sequence generators, and filters and modifies their output according to simple functions, whose arguments come from iterators themselves, like this: class SeqGen(object): def __init__(self, iterdict): self.iterdict = iterdict self.iterator = self.squiterate() def next(self): return self.iterator.next() def __iter__(self): return self def squiterate(self): generators = self.iterdict.pop('generator') genargs = self.iterdict.pop('genargs') for gen in generators: #Where "gens" is a module containing sequence generators: generator = getattr(gens, gen)(genargs.next()) current_values = [(k, v.next()) for k, v in self.iterdict.iteritems()] for seq in generator: for k, v in current_values: #Where "seqmods" is a module containing functions #which test or modify a sequence: if getattr(seqmods, k)(seq, v) is False: #Test for False because in-place modifiers return None break else: current_values = [(k, v.next()) for k, v in self.iterdict.iteritems()] yield seq The leaves of the tree are IterNodes whose arg is a list and which use this simple generator: def cycle(iterable): while True: for i in iterable: yield i I can build a tree of IterNodes from a nested dictionary like this: def itertree(dic, iterator=PhraseMaker): for k, v in dic.iteritems() : if isinstance(v, dict): dic[k] = itertree(v, SeqGen) else: dic[k] = IterNode(cycle, v) return IterNode(iterator, dic) d = {'a':[1,2,3], 'b':{'a':[4,5,6]}, 'c':{'a':{'a':[7,8,9], 'b':{'c':[10]}}}} itnod = itertree(d) and update it at any time, even during iteration, like this: new_d = {'a':[1,2,3], 'b':{'a':[4,5,6]}, 'c':{'a':{ 'b':[4]}}, 'd':{}} new_itnod = itertree(new_d) itnod.deepdate(new_itnod) (In real life the dictionary keys are the names of attributes of PhraseMaker, gens, or seqmods.) The problem Chas mentioned of consuming next() multiple times still applies to a tree because if a sequence fails a test on a particular value, we want to stay on that value till the test succeeds - which is why the SeqGen class has the "current_values" list in the squiterate method. (The real version actually has to keep count for each key in iterdict.) I would of course be interested in any other ideas. It works and is relatively easy to understand, but I still have feeling that I'm breathing my own exhaust and this is too complex... Regards, John From ahsanbagwan at gmail.com Fri Jan 21 05:39:48 2011 From: ahsanbagwan at gmail.com (sl33k_) Date: Fri, 21 Jan 2011 02:39:48 -0800 (PST) Subject: Namespaces Message-ID: What is namespace? And what is built-in namespace? From askutt at gmail.com Fri Jan 21 06:20:59 2011 From: askutt at gmail.com (Adam Skutt) Date: Fri, 21 Jan 2011 03:20:59 -0800 (PST) Subject: examples of realistic multiprocessing usage? References: <2011011611053732597-tomfsessile@gmailcom> Message-ID: <4bff00a3-09e8-43f4-a62d-5e12838b217e@n10g2000yqd.googlegroups.com> On Jan 20, 11:51?pm, Albert van der Horst wrote: > This is what some people want you to believe. Arm twisting by > GPL-ers when you borrow their ideas? That is really unheard of. Doesn't matter, you're still legally liable if your work is found to be derivative and lacking a fair use defense. It's not borrowing "ideas" that's problematic, it's proving that's all you did. For those of us with legal departments, we have no choice: if they don't believe we can prove our case, we're not using the code, period. The risk simply isn't worth it. > GPL-ers are not keen on getting the most monetary award by > setting lawyers on you and go to court only reluctantly to > enforce the license. And? Monetary award is hardly the only issue. > Stealing code means just that, verbatim copies. When you read this > carefully, you can see that reimplementing the stolen code is > an option. Exactly what you say is legally impossible. No, in the United States it means anything that constitutes a derivative work, since derivative works of GPL-licensed works must be released under the GPL. Merely copying ideas does not make one a derivative work, but one also must be prepared to show that's all that happened. As such, it would have to be a substantially different implementation, generally with some sort of added or useful value. Proving that can be difficult and may very well depend on what court you land in. > > So pardon me, but not even looking at code you might learn from > is pretty hysteric. Not at all. Separating ideas from implementation can be difficult, and convincing a judge of that vastly more so. It's a legitimate concern, and people who intend to ship proprietary software should definitely resort to GPL-licensed software last when looking for inspiration. Adam From funthyme at gmail.com Fri Jan 21 06:43:31 2011 From: funthyme at gmail.com (John Pinner) Date: Fri, 21 Jan 2011 03:43:31 -0800 (PST) Subject: getdefaultencoding - how to change this? References: <4d38472d$0$14250$ba620e4c@news.skynet.be> Message-ID: On Jan 20, 4:46?pm, Robert Kern wrote: > > Instead, you want to use an encoding declaration in each file: > > http://docs.python.org/reference/lexical_analysis.html#encoding-decla... All that this does is tell the interpreter how the source file is encoded, it does not affect default encodings etc. John -- From andreas.tawn at ubisoft.com Fri Jan 21 06:47:04 2011 From: andreas.tawn at ubisoft.com (Andreas Tawn) Date: Fri, 21 Jan 2011 12:47:04 +0100 Subject: Namespaces In-Reply-To: References: Message-ID: <654D9D97DA51AD479973BC2D5578603C0B9C4D8795@PDC-MAIL-CMS01.ubisoft.org> > What is namespace? And what is built-in namespace? > -- > http://mail.python.org/mailman/listinfo/python-list http://lmgtfy.com/?q=python+namespace From alex at moreati.org.uk Fri Jan 21 06:55:39 2011 From: alex at moreati.org.uk (Alex Willmer) Date: Fri, 21 Jan 2011 03:55:39 -0800 (PST) Subject: Namespaces References: Message-ID: On Jan 21, 10:39?am, sl33k_ wrote: > What is namespace? And what is built-in namespace? A namespace is a container for names, like a directory is a container for files. Names are the labels we use to refer to python objects (e.g. int, bool, sys), and each Python object - particularly modules and classes - provides separate namespace. The idea of a namespace is to isolate names from one another - so that if you import module_a and module_b and both have an object called foo then module_a.foo doesn't interfere with module_b.foo. The built-in namespace is where the core objects of Python are named. When you refer to an object such as int Python first searches the local scope (was it defined in the current function/method, i.e. the output of locals()), then module scope (was it defined in the current .py file, i.e. output of globals()) and finally in the object __builtins__. Hope that makes sense. I realised as I typed this my understanding of Python namespaces is not as 100% tight as I thought. Alex From funthyme at gmail.com Fri Jan 21 07:15:30 2011 From: funthyme at gmail.com (John Pinner) Date: Fri, 21 Jan 2011 04:15:30 -0800 (PST) Subject: getdefaultencoding - how to change this? References: <4d38472d$0$14250$ba620e4c@news.skynet.be> Message-ID: To answer the OP's original question: On Jan 20, 2:31?pm, Helmut Jarausch wrote: > Hi, > I've searched the net but didn't find the information I need. > Using Python-2.7.1, I know, I can't modify defaultencoding at run time. I think you can. There is a function setdefaultencoding in the sys module, but at startup when site.py runs the function gets deleted after it has been used, because as others have said it is a *bad* idea to change the default encoding (although I *think* changing it to utf8 should cause no harm). so if you reload sys, setdefaultencoding() becomes available again, and you can use it, with all the caveats mentioned: import sys reload(sys) sys.setdefaultencoding( 'utf-8' ) This works on a Unicode build of Python only. As has been said, you can change the default encoding in site.py, but this means that it gets changed for everyone/every Python program on the system, using setdefaultencoding() as above only changes it for the running program, and hopefully the change will have been made by someone who knows what they are doing and is aware of the possible consequences. > Python even ignores > export PYTHONIOENCODING=ISO8859-1 > > locale.getdefaultlocale()[1] > returns > 'ISO8859-1' > > still sys.stdout is using the ascii codec. > How can I recompile Python (itself) to change this to iso8859-1 ? You don't need to, nor should you. > (My favourite editor cannot be told to use unicode.) Maybe you need a new editor. scite works well with Python, and is cross-platform. John -- From joncle at googlemail.com Fri Jan 21 07:20:26 2011 From: joncle at googlemail.com (Jon Clements) Date: Fri, 21 Jan 2011 04:20:26 -0800 (PST) Subject: statement level resumable exception References: <87oc7b9wkm.fsf@gmail.com> <62658b12-34b7-4ed5-9ecd-5182b53f7b31@t35g2000yqj.googlegroups.com> <87k4hz9uiu.fsf@gmail.com> <87fwsmaelt.fsf@gmail.com> <52e20ce1-0e0c-4817-a61d-91437291883a@i18g2000yqn.googlegroups.com> Message-ID: <834fd020-f70a-44bc-8faf-f4f34e1ae73b@fo10g2000vbb.googlegroups.com> On Jan 21, 8:41?am, ilejn wrote: > Arnaud, > > it looks like a solution. > Perhaps it is better than plain try/accept and than proxy class with > __getattr__. > It is not for free, e.g. because syntax check such as parentheses > matching is lazy too, though looks > very interesting. > > Thanks a lot! > > On Jan 21, 10:41?am, Arnaud Delobelle wrote: > > > > > ilejn writes: > > > Arnaud, > > > > these lists are not generated. > > > > Actually these lists are a sort of interpreted programs and contain > > > some application logic. > > > > Here is an example > > > ? ? ? ? [ > > > ? ? ? ? [PUSH, [get_modified_interface, req]], > > > ? ? ? ? [TIMEOUT, 3], > > > ? ? ? ? [PULL, [out_interface, '']], > > > ? ? ? ? [PULL, [err_interface, '']], > > > ? ? ? ? [PULL, [out_mined_interface, req]], > > > ? ? ? ? ] > > > > If any interface name is unknown the list must not be invoked (in > > > other words, f function > > > call with this list must be somehow bypassed). > > > > Thanks. > > > You could still use the same idea and delay evaluation of the lists. E.g. > > > prg1 = """[ > > ? ? [PUSH, [get_modified_interface, req]], > > ? ? [TIMEOUT, 3], > > ? ? ... > > """ > > > prg2 = """[ > > ? ? [OPCODE, [arguments, blah]], > > ? ? ... > > """ > > > ... > > > prgN = """...""" > > > for prg in prg1, prg2, ..., prgN: > > ? ? try: > > ? ? ? ? prg = eval(prg) > > ? ? except NameError: > > ? ? ? ? continue > > ? ? f(prg) > > > -- > > Arnaud > > Best regards, > Ilja Golshtein Not sure if a good idea or not, but: I would probably use pyparsing and create a small grammar to parse your list data. If parsing an entry with an unknown interface, then skip to the next list entry. If the entire list parses, then you can execute your function calls. hth Jon. From davea at ieee.org Fri Jan 21 08:01:59 2011 From: davea at ieee.org (Dave Angel) Date: Fri, 21 Jan 2011 08:01:59 -0500 Subject: Namespaces In-Reply-To: References: Message-ID: <4D3983C7.70600@ieee.org> On 01/-10/-28163 02:59 PM, sl33k_ wrote: > What is namespace? And what is built-in namespace? > A namespace is a mapping from names to objects. When you write a statement xyz = 42 the system looks up "xyz" in some namespace and associates that "variable" with the object int(42). The key is that there are multiple namespaces defined. The built-in namespace (containing things such as open, help, next, input, and lots more) is always available. The global namespace, for symbols defined globally in the current module, is another namespace. If you're inside a function, there's a separate namespace for symbols defined in there (and they behave just a little differently). And you can explicitly specify a namespace with a prefix, which is one way you access symbols in another module, or within an instance of an object. Perhaps look at: http://bytebaker.com/2008/07/30/python-namespaces/ though I haven't personally studied the whole thing for accuracy. One other thing: dir() can be used to show you the names in a particular namespace. For example, dir(__builtins__) shows you the built-in namespace, while dir() shows you the global one. And after an import, dir() can show you those names: import os dir(os) DaveA From sparks.m at gmail.com Fri Jan 21 08:26:47 2011 From: sparks.m at gmail.com (Michael Sparks) Date: Fri, 21 Jan 2011 05:26:47 -0800 (PST) Subject: Namespaces References: Message-ID: <2775e396-9a3b-4a06-acff-be249448b840@w29g2000vba.googlegroups.com> On Jan 21, 10:39?am, sl33k_ wrote: > What is namespace? And what is built-in namespace? tl;dr - Namespaces are sets that contain names. You can think of namespaces as being /like/ boxes. A namespace is therefore an organisational tool, forming a similar purpose to human names & surnames - to identify the right value. (eg "Sparks" is a namespace, "Smith" is another.) The built-in namespace contains all the values which python understands which you _don't_ define that don't have dots in. (eg "int", "True", "None") Looking at this in more detail... We can create a simple namespace using an empty class Family: class Family(object): pass Sparks = Family() Smith = Family() Now clearly Sparks is a name, and Smith is a name. Those names are defined to be two different Family objects/values. (I'm going to deliberately sidestep which namespace "Sparks" and "Smith" sit inside for the moment.) The neat trick is that namespaces are values themselves. In fact the really neat trick is that every value contains a namespace. How do I define a name inside a namespace? Suppose I want to define the name "Michael" as a person inside the Sparks namespace, I can do that like this: class Person(object): pass Sparks.Michael = Person() I can then define the name Michael inside the Smith namespace as well: Smith.Michael = Person() As you can see, I can now refer to two different values with the same name - "Michael". This may look a little like sophistry, so let's suppose the Person we're referring to as Sparks.Michael has an height of 180cm, and a favourite colour of green, and Smith.Michael has a height of 120cm and a favourite colour of 120. In both cases, it makes sense for use to name the height value "height", and name the favourite colour value as "favourite_colour". If we did this though ... height = 180 favourite_colour = "green" height = 120 favourite_colour = "purple" .. python would only remember the most recent value of each. By recognising that every value is a namespace too, we can define those names inside their namespace. Sparks.Michael.height = 180 Sparks.Michael.favourite_colour = "green" Smith.Michael.height = 120 Smith.Michael.favourite_colour = "purple" Now the question that might arise is this: Given I can rewrite the examples above like this... class Family(object): pass class Person(object): pass Sparks = Family() Smith = Family() Sparks_Michael = Person() Smith_Michael = Person() Sparks_Michael_height = 180 Sparks_Michael_favourite_colour = "green" Smith_Michael_height = 120 Smith_Michael_favourite_colour = "purple" ... how is this different from before? Well in this latter version we're not using namespaces to organise our names. This means that if I want to write a function that prints a person's height and favourite colour, it has to look like this: def describe_person(height, favourite_colour): print "The person is", height, "cm tall" print "Their favourite colour is", favourite_colour Then if I want to use this, I have to do this: describe_person(Sparks_Michael_height, Sparks_Michael_favourite_colour) describe_person(Smith_Michael_height, Smith_Michael_favourite_colour) That's quite messy. What does it look like for the namespace version? def describe_person(somePerson): print "The person is", somePerson.height, "cm tall" print "Their favourite colour is", somePerson.favourite_colour describe_person(Sparks.Michael) describe_person(Smith.Michael) describe_person now expects to recieve a single value. Inside that value's namespace it expects to find the values "height" and "colour", and just uses them. As a result, when we use it, rather than passing in each low level attribute (height, colour) we can work at a more convenient level of working with People, and the higher level code becomes clearer. Not only this, if we decide to add an another name to both People ... Sparks.Michael.Pythonista = True Sparks.Michael.Pythonista = False ... we can change describe_person to use this: def describe_person(somePerson): print "The person is", somePerson.height, "cm tall" print "Their favourite colour is", somePerson.favourite_colour if somePerson.Pythonista: print "And they like python!" else: print "They don't know python" Then our code for describing them remains the same: describe_person(Sparks.Michael) describe_person(Smith.Michael) So far so good I hope. Namespaces can contain code as well as basic values. This means we can have ... tiggles = Cat() rover = Dog() jemima = Duck() tiggles.name = "tiggles" rover.name = "rover" jemima.name = "jemima" ... and we can get them all to have some behaviour called "make_noise" defined by the call to Cat(), Dog(), Duck() inside their namespace, which allows us to write: >>> tiggles.make_noise() Meow! >>> rover.make_noise() Woof! >>> jemima.make_noise() Quack! And again that means we can do things like: def describe_animal(animal): print animal.name, "goes", animal.make_noise() And use it like this: >>> describe_animal(tiggles) tiggles goes Meow! >>> describe_animal(rover) rover goes Woof! >>> describe_animal(jemima) jemima goes Quack! In addition to defining namespaces though with classes, I can define them using files. Suppose I have two files: humans.py animals.py And I have another one which is my main program: main.py Furthermore suppose that we decide to put the classes "Family", and "Person" into humans.py We also decide to put "Cat", "Dog" and "Duck into animals.py Inside main.py we need someone of pulling in these names and values in such a way that we can pull them in cleanly, which is where python's "import" function comes in. If we use it like this: import humans import animals This creates two namespaces - humans and animals. The namespace "humans" contains "Family" and "Person", mirroring the fact the functionality is defined in the file humans.py. The namespace "animals" contains "Cat", "Dog" and "Duck", mirroring the fact the functionality is defined in the file animals.py. So our code using this would look like this: Sparks = humans.Family() Smith = humans.Family() Sparks.Michael = humans.Person() Smith.Michael = humans.Person() tiggles = animals.Cat() rover = animals.Dog() jemima = animals.Duck() This can be a bit clunky if you're doing it a lot, so let's revisit where I said "I'm going to deliberately sidestep which namespace "Sparks" and "Smith" sit inside for the moment.". I mentioned that names like: - object - list - int - True .. ie names that you can use without defining are defined inside a namespace built-in to python - which is referred to as the built-in namespace. In particular, if I type: >>> object >>> int >>> True True Those names are defined from within the built-in namespace. Where are names like ... Sparks Smith humans animals ... being defined ? Well,it turns out that python (like many other languages) has global values (amongst others), and that global values are accessed via the global namespace: >>> import animals >>> import humans >>> Sparks = humans.Family() >>> Smith = humans.Family() >>> globals() {'animals': , 'humans': , 'Smith': , 'Sparks': , '__builtins__': , '__package__': None, '__name__': '__main__', '__doc__': None} As a result every name sits inside some namespace of some kind. A namespace is used for organising things, and so namespaces can themselves be names and treated as values. Inside a namespace a name can only refer to one value. (Though that value can be a list/tuple/ dict of course, or a piece of behaviour - such as a method or function) Python modules form namespaces. Python classes form namespaces. Python objects form namespaces. In the case of import this also explains the fact there are two forms of import. This version: import humans import animals Simply defines two names, based on the filename containing interesting functionality, which are namespaces containing other names and is used as above. The other looks like this: from humans import Family, Person from animals import Cat, Dog, Duck And still pulls in the same two files, but says "I'm only interested in these 5 things, and please use them to define the names Family, Person, Cat, Dog, Duck" in my global namespace so I can use it like this: Sparks = Family() Smith = Family() Sparks.Michael = Person() Smith.Michael = Person() tiggles = Cat() rover = Dog() jemima = Duck() Which is pretty useful. So what are they? "Namespaces are one honking great idea -- let's do more of those!" :-) Michael. From awilliam at whitemice.org Fri Jan 21 08:32:47 2011 From: awilliam at whitemice.org (Adam Tauno Williams) Date: Fri, 21 Jan 2011 08:32:47 -0500 Subject: examples of realistic multiprocessing usage? In-Reply-To: <4bff00a3-09e8-43f4-a62d-5e12838b217e@n10g2000yqd.googlegroups.com> References: <2011011611053732597-tomfsessile@gmailcom> <4bff00a3-09e8-43f4-a62d-5e12838b217e@n10g2000yqd.googlegroups.com> Message-ID: <1295616767.4129.5.camel@linux-yu4c.site> On Fri, 2011-01-21 at 03:20 -0800, Adam Skutt wrote: > On Jan 20, 11:51 pm, Albert van der Horst > wrote: > > This is what some people want you to believe. Arm twisting by > > GPL-ers when you borrow their ideas? That is really unheard of. > Doesn't matter, you're still legally liable if your work is found to > be derivative and lacking a fair use defense. It's not borrowing > "ideas" that's problematic, it's proving that's all you did. For > those of us with legal departments, we have no choice: if they don't > believe we can prove our case, we're not using the code, period. The > risk simply isn't worth it. +1, exactly. "reimplementation" is the defense of GPL is very often treated as *trivial*. Changing function names and variable names and indenting style is not "reimplementation". Reimplementation can be very difficult, time consuming, and error-prone. Anyway, legally define: "reimplementation". Have fun. > > So pardon me, but not even looking at code you might learn from > > is pretty hysteric. > Not at all. Separating ideas from implementation can be difficult, Honestly, IMNSHO, it is borders on *impossible*. Even statistical analysis of written prose or off-hand speech will reveal how pathologically derivative humans are in their use of language. And as that language gets forcibly more structured as in programming or technical documentation even more so. > and convincing a judge of that vastly more so. It's a legitimate > concern, and people who intend to ship proprietary software should > definitely resort to GPL-licensed software last when looking for > inspiration. From razajaffrey77 at gmail.com Fri Jan 21 08:38:09 2011 From: razajaffrey77 at gmail.com (RizlaJ) Date: Fri, 21 Jan 2011 05:38:09 -0800 (PST) Subject: Problems with FTP Message-ID: <58a2ada5-69d6-421b-a0c9-50b34ab8960a@v26g2000yqf.googlegroups.com> Hi all, I'm very new to python. I'm using Python 2.7, in a corporate environment, therefore am behind a proxy server, firewalls etc. I can ftp to a barclays capital ftp site ok in internet explorer, but I can't get the FTP from ftplib to work for me. Can someone please help! I've tried the following commands from my home personal machine (thefore no proxies etc) and the commands work fine and I'm able to enter my username and password and login successfuly - however in teh corporate environment I can't. I'm wondering if this is soemthing to do with security permissioning at work etc? At the shell I'm typing:- >>> from ftplib import FTP >>> ftp = FTP('indexftp.barcap.com') and get the following error: Traceback (most recent call last): File "", line 1, in ftp = FTP('indexftp.barcap.com') File "C:\Python27\lib\ftplib.py", line 117, in __init__ self.connect(host) File "C:\Python27\lib\ftplib.py", line 132, in connect self.sock = socket.create_connection((self.host, self.port), self.timeout) File "C:\Python27\lib\socket.py", line 571, in create_connection raise err error: [Errno 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond I wasn't expecting this error message next, i was expecting to be able to log on using the followign command :- >> ftp.login("username","password") Please help! thanks! From rde at audaxis.com Fri Jan 21 09:14:39 2011 From: rde at audaxis.com (Romaric DEFAUX) Date: Fri, 21 Jan 2011 15:14:39 +0100 Subject: Need advices for mysqldb connection best practice In-Reply-To: References: <4D37FA8C.9060108@audaxis.com> Message-ID: <4D3994CF.1020101@audaxis.com> Le 20/01/2011 18:58, Dennis Lee Bieber a ?crit : > On Thu, 20 Jan 2011 10:04:12 +0100, Romaric DEFAUX > declaimed the following in gmane.comp.python.general: > > >> So , I thought about some solutions : >> - restarting the server every sometimes (but it's the worst solution in >> my mind) >> - creating a connection (not only cursor) at each client connection (but >> I'm afraid it overloads the mysql server) >> - trying to find where I did a mistake, and correct the bug (that why >> I'm doing by writing this list :), or send me a link that could help me >> (before writing I googled for one hour and found nothing interresting in >> my case...) >> > Do you have multiple clients active at the same time -- using a > common code/process... (does each client connection start a thread)? > >>>> import MySQLdb >>>> MySQLdb.threadsafety > 1 > > From PEP 249: > """ > threadsafety > > Integer constant stating the level of thread safety the > interface supports. Possible values are: > > 0 Threads may not share the module. > 1 Threads may share the module, but not connections. > 2 Threads may share the module and connections. > 3 Threads may share the module, connections and > cursors. > > Sharing in the above context means that two threads may > use a resource without wrapping it using a mutex semaphore > to implement resource locking. Note that you cannot always > make external resources thread safe by managing access > using a mutex: the resource may rely on global variables > or other external sources that are beyond your control. > > """ > > > Also: > >> con.cursor().execute('SET AUTOCOMMIT=1') > Using .execute() for that may set the MySQL side for autocommit, but > the MySQLdb adapter will likely still be in the db-api specified mode of > NO autocommit. There is a low-level (that is, it is part of the DLL/SO > and not Python source) function for connections: > > con.autocommit(True) > > (the db-api creates connections and invokes con.autocommit(False)) > > This function should both set MySQL AND the db-api adapter for > autocommit operations. > > Personally -- it is better when running multiple clients to ensure > that each client is running as a complete transaction. That means the > each get their own connection and cursor(s), and manually do > con.commit() at the end of the transaction; if any errors happen, one > does a con.rollback() and can inform the user that the sequence failed. Thanks Dennis for your reply. I don't use thread. The reason is : - the time of connection between client and server is really quick, around one second - I've only around 120 clients, updating once an hour, so percent of collision is really low, and client can wait few seconds for the connection Now, I create a new db_connection at each client connection and it seems stable (no crash since yesterday vs 1 crash every 2 hours before). I understand why it's better to commit manually, but if I want to do that I have to rewrite lots of things, and it's not my priority at this time, because it's stable enough. So I kept the con.autocommit(True). But I keep your advices in an "improvements list" :) I know if number of clients increase a lot, I can search in these directions : - using thread - commiting manually to avoid inconsistents datas - using a pool of connections to reduce MySQL load Thanks again Romaric -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/pkcs7-signature Size: 5361 bytes Desc: S/MIME Cryptographic Signature URL: From neilc at norwich.edu Fri Jan 21 09:21:46 2011 From: neilc at norwich.edu (Neil Cerutti) Date: 21 Jan 2011 14:21:46 GMT Subject: Dealing with xml namespaces with ElementTree Message-ID: <8ptj3qF437U1@mid.individual.net> I have to parse many xml documents that senselessly(?) specify a single namespace for the whole document. After a couple of years, my approach has boiled down to the following three little helpers, for use with ElementTree: def insert_namespace(xpath): # Enable *simple* xpath searches by inserting the fscking namespace. return '/'.join('{{{}}}{}'.format(XMLNS, n) for n in xpath.split('/')) def find(et, xpath): return et.find(insert_namespace(xpath)) def findall(et, xpath): return et.findall(insert_namespace(xpath)) Instead of writing, e.g., et.find('{{0}}ab/{{0}}cd'.format(XMLNS), et al, I can use find(et, 'ab/cd'). Is there a better ElemenTree based approach I'm missing out on? And on the other hand, am I circumventing something important, or inviting bad limitations of some kind? -- Neil Cerutti From arndt.roger at addcom.de Fri Jan 21 09:38:09 2011 From: arndt.roger at addcom.de (Arndt Roger Schneider) Date: Fri, 21 Jan 2011 15:38:09 +0100 Subject: Screen readers for Tkinter (was Re: Tkinter: The good, the bad, and the ugly! References: Message-ID: Littlefield, Tyler schrieb: > >And of course, it should also offer support for Windows, since most of > the computer users use Windows, especially those who need accessibility > features. > uh. no, and no. > Plenty of those utilizing screen readers are using macs nowadays, as > well as vinux or some derivitave there of. > Do you have first hand experience with it under AQUA? I think Tk-aqua (also 8.6) should work out-of-the-box with brail-lines, text-to-speech and such; the older carbon built however wont... -roger From longqian9509 at gmail.com Fri Jan 21 10:29:04 2011 From: longqian9509 at gmail.com (long) Date: Fri, 21 Jan 2011 07:29:04 -0800 (PST) Subject: is it a bug in exec? References: <0629ea10-b667-4630-a99f-78168a3e0979@u6g2000yqk.googlegroups.com> <4d39407c$0$29983$c3e8da3$5496439d@news.astraweb.com> Message-ID: <90b84747-5057-44c0-ae81-42fbb277a817@t35g2000yqj.googlegroups.com> Of cause your code runs well. But if you remove the "global foo" in main(), it will fail. And it will succeed again if you call exec(t1) directly. I think this behavior is strange. Even I pass a shadow copy of globals and locals to exec, it still fails. So perhaps there is a basic difference between exec(t1,dg,dl) and exec(t1,globals(),locals()). What do you think about it? Thanks. On Jan 21, 2:14?am, Steven D'Aprano wrote: > On Thu, 20 Jan 2011 20:52:15 -0800, longqian9... at gmail.com wrote: > > In pyhton 3.1, I found the following code will succeed with argument 1 > > to 4 and fail with argument 5 to 9. It is really strange to me. I > > suspect it may be a buy in exec() function. Does anyone have some idea > > about it? Thanks. > > What makes you think it's a bug? Is there anything in the documentation > of exec that suggests to you that some other behaviour should occur? What > version of Python are you using? > > Without knowing what behaviour you expect and what behaviour you see, how > are we supposed to know if you've found a bug or not? > > I suggest you fire up the interactive interpreter and try this: > > t1 = """ > class foo: > ? ? def fun(): > ? ? ? ? print('foo') > > def main(): > ? ? global foo > ? ? foo.fun() > > main() > """ > > dg = {} > dl = {} > > exec(t1, dg, dl) > > then inspect the values of dg and dl and see if it helps. If not, write > back with what you expect to happen, and what you see instead. > > -- > Steven From rolf.oltmans at gmail.com Fri Jan 21 10:39:26 2011 From: rolf.oltmans at gmail.com (Oltmans) Date: Fri, 21 Jan 2011 07:39:26 -0800 (PST) Subject: Line breaks in list causing a small formatting problem while joining the list Message-ID: Hi Python gurus, hope you're doing well. I've a small problem. When I run the following code ___________________________________________________ >>> names = ['oltmans','abramhovic','\n','sal','lee'] >>> print '| ' + ' | '.join(names) | oltmans | abramhovic | | sal | lee ___________________________________________________ I get the output like above. However, I want it to output like below | oltmans | abramhovic | | sal | lee That is, there shouldn't be a space in the beginning of second line. The list can of course contain more than 5 elements. Any ideas? I will appreciate any hint. Thanks in advance. From __peter__ at web.de Fri Jan 21 11:25:35 2011 From: __peter__ at web.de (Peter Otten) Date: Fri, 21 Jan 2011 17:25:35 +0100 Subject: Line breaks in list causing a small formatting problem while joining the list References: Message-ID: Oltmans wrote: > Hi Python gurus, hope you're doing well. I've a small problem. > > When I run the following code > ___________________________________________________ >>>> names = ['oltmans','abramhovic','\n','sal','lee'] >>>> print '| ' + ' | '.join(names) > | oltmans | abramhovic | > | sal | lee > ___________________________________________________ > > I get the output like above. However, I want it to output like below > > | oltmans | abramhovic | > | sal | lee > > > That is, there shouldn't be a space in the beginning of second line. > The list can of course contain more than 5 elements. Any ideas? I will > appreciate any hint. Thanks in advance. >>> print "|%s|" % "|".join(n if n == "\n" else " %s " % n for n in names) | oltmans | abramhovic | | sal | lee | From robert.kern at gmail.com Fri Jan 21 11:31:51 2011 From: robert.kern at gmail.com (Robert Kern) Date: Fri, 21 Jan 2011 10:31:51 -0600 Subject: getdefaultencoding - how to change this? In-Reply-To: References: <4d38472d$0$14250$ba620e4c@news.skynet.be> Message-ID: On 1/21/11 5:43 AM, John Pinner wrote: > On Jan 20, 4:46 pm, Robert Kern wrote: > > > >> >> Instead, you want to use an encoding declaration in each file: >> >> http://docs.python.org/reference/lexical_analysis.html#encoding-decla... > > All that this does is tell the interpreter how the source file is > encoded, it does not affect default encodings etc. Yes! In the part of the OP's message that you snipped "(My favourite editor cannot be told to use unicode.)", that seemed to be part of his actual problem, not the default encoding. -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco From __peter__ at web.de Fri Jan 21 12:00:32 2011 From: __peter__ at web.de (Peter Otten) Date: Fri, 21 Jan 2011 18:00:32 +0100 Subject: is it a bug in exec? References: <0629ea10-b667-4630-a99f-78168a3e0979@u6g2000yqk.googlegroups.com> Message-ID: longqian9509 at gmail.com wrote: > In pyhton 3.1, I found the following code will succeed with argument 1 > to 4 and fail with argument 5 to 9. It is really strange to me. I > suspect it may be a buy in exec() function. Does anyone have some idea > about it? Thanks. > > > t1=""" > class foo: > def fun(): > print('foo') > def main(): > global foo > foo.fun() > main() > """ > t2=""" > class foo: > def fun(): > print('foo') > def main(): > foo.fun() > main() > """ > > import sys > import copy > if sys.argv[1]=='1': > exec(t1) > elif sys.argv[1]=='2': > exec(t2) > elif sys.argv[1]=='3': > exec(t1,{},{}) > elif sys.argv[1]=='4': > exec(t2,globals(),locals()) > elif sys.argv[1]=='5': > exec(t2,{},{}) > elif sys.argv[1]=='6': > exec(t2,globals(),{}) > elif sys.argv[1]=='7': > exec(t2,{},locals()) > elif sys.argv[1]=='8': > exec(t2,copy.copy(globals()),locals()) > elif sys.argv[1]=='9': > exec(t2,globals(),copy.copy(locals())) There are only two cases that matter: identical local/global namespaces and distinct local/global namespaces: >>> code = """\ ... x = 42 # put x into the local namespace ... def f(): ... print(x) # look up x in the global namespace ... f() ... """ >>> exec(code, {}, {}) Traceback (most recent call last): File "", line 1, in File "", line 4, in File "", line 3, in f NameError: global name 'x' is not defined >>> ns = {} >>> exec(code, ns, ns) 42 Also note that >>> globals() is locals() True on the module level. Peter From thomas at jollybox.de Fri Jan 21 12:05:51 2011 From: thomas at jollybox.de (Thomas Jollans) Date: Fri, 21 Jan 2011 18:05:51 +0100 Subject: Problems with FTP In-Reply-To: <58a2ada5-69d6-421b-a0c9-50b34ab8960a@v26g2000yqf.googlegroups.com> References: <58a2ada5-69d6-421b-a0c9-50b34ab8960a@v26g2000yqf.googlegroups.com> Message-ID: <201101211805.52455.thomas@jollybox.de> On Friday 21 January 2011, it occurred to RizlaJ to exclaim: > Hi all, I'm very new to python. I'm using Python 2.7, in a corporate > environment, therefore am behind a proxy server, firewalls etc. > > I can ftp to a barclays capital ftp site ok in internet explorer, but > I can't get the FTP from ftplib to work for me. Can someone please > help! It sounds very much like, as you said, you're behind a proxy, and have to use that proxy to connect to the FTP server. If you don't know the proxy settings, you might be able to find them in the IE configuration, or ask the local sysadmin. http://stackoverflow.com/questions/1293518/proxies-in-python-ftp-application It looks like you will have to ftp to the proxy server. Depending on the application, you might be able to use urllib2 instead. Thomas > > I've tried the following commands from my home personal machine > (thefore no proxies etc) and the commands work fine and I'm able to > enter my username and password and login successfuly - however in teh > corporate environment I can't. I'm wondering if this is soemthing to > do with security permissioning at work etc? > > At the shell I'm typing:- > > >>> from ftplib import FTP > >>> ftp = FTP('indexftp.barcap.com') > > and get the following error: > Traceback (most recent call last): > File "", line 1, in > ftp = FTP('indexftp.barcap.com') > File "C:\Python27\lib\ftplib.py", line 117, in __init__ > self.connect(host) > File "C:\Python27\lib\ftplib.py", line 132, in connect > self.sock = socket.create_connection((self.host, self.port), > self.timeout) > File "C:\Python27\lib\socket.py", line 571, in create_connection > raise err > error: [Errno 10060] A connection attempt failed because the connected > party did not properly respond after a period of time, or established > connection failed because connected host has failed to respond > > I wasn't expecting this error message next, i was expecting to be able > to log on using the followign command :- > > >> ftp.login("username","password") > > Please help! > > thanks! From thomas at jollybox.de Fri Jan 21 12:17:36 2011 From: thomas at jollybox.de (Thomas Jollans) Date: Fri, 21 Jan 2011 18:17:36 +0100 Subject: difference between python and matlab In-Reply-To: References: Message-ID: <201101211817.36951.thomas@jollybox.de> On Thursday 20 January 2011, it occurred to lakshmi to exclaim: > Is the programming related to image processing in python is advantageous or > else in MATLAB Tell us what you want to do, and what you know about doing this in Python and in MATLAB, if possible, ask a specific question. Then, somebody might be able to give you an educated and useful response. From rantingrick at gmail.com Fri Jan 21 12:36:42 2011 From: rantingrick at gmail.com (rantingrick) Date: Fri, 21 Jan 2011 09:36:42 -0800 (PST) Subject: Tkinter: The good, the bad, and the ugly! References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com><4d337983$0$29983$c3e8da3$5496439d@news.astraweb.com><044a5101-948d-4458-9c94-57dbb3e25f67@m35g2000vbn.googlegroups.com><4d3467bf$0$29983$c3e8da3$5496439d@news.astraweb.com><4D34B04E.8050309@web.de><4266E8D7BA204BFEA5BF66C635CE1716@octavian><4D35DCE8.5030002@web.de><4D35DD47.1070304@web.de><7A0C7934E65D4B85A584C06ADD3B6ECF@teddy>< Message-ID: <4749ad6d-ef08-4dfb-bfb7-144efed4d761@d8g2000yqf.googlegroups.com> On Jan 20, 8:34?pm, Neil Hodgson wrote: This is exactly what Aristotle meant when he said... """ Tolerance and Apathy are the last virtues of a dying society! """ Specifically no one here has the nerve to question/argue Guido when he offers such weak arguments like the "tag" argument. Can you really base the worth of any library on such a limited argument. I would bet that most people who use Tkinter ARE NOT using the canvas anyway. They are not interested in drawing simple lines and rects and just looking at them. No. They are intersted in creating GUIs with frames, buttons, labels, radiobuttons, checkbuttons, listboxes, textboxes, notebooks, comboboxes, and dialogs just to name a few. However in light of such a weak argument presented TEN YEARS AGO not one person dared to even question the BDFL. If i were Guido i would be disappointed. The very community he has built has degenerated into mindless goose stepping "yes" men. AND THAT WAS TEN YEARS AGO! Congratulations "yes men" you are the genesis of this self destruction. I think i should find a fiddle... From clp2 at rebertia.com Fri Jan 21 12:55:30 2011 From: clp2 at rebertia.com (Chris Rebert) Date: Fri, 21 Jan 2011 09:55:30 -0800 Subject: Printing RTF file under win32 In-Reply-To: <2608cc6e-a385-4a31-ab9e-f740d231bf06@k11g2000vbf.googlegroups.com> References: <2608cc6e-a385-4a31-ab9e-f740d231bf06@k11g2000vbf.googlegroups.com> Message-ID: On Fri, Jan 21, 2011 at 2:12 AM, Mark Carter wrote: > I'm using Python 2.6.5 on win32. I would like to print a batch of RTF > files on a printer. I don't want to use the win32api.ShellExecute > command because that invokes Word, and Word has been configured in a > strange way by one of our admins, making it inconvenient to use. > > What should I do? Invoke WordPad instead? http://en.wikipedia.org/wiki/WordPad Cheers, Chris From andreambu at gmail.com Fri Jan 21 13:06:04 2011 From: andreambu at gmail.com (Andrea Ambu) Date: Fri, 21 Jan 2011 19:06:04 +0100 Subject: difference between python and matlab In-Reply-To: References: Message-ID: On 20 January 2011 15:16, lakshmi wrote: > Is the programming related to image processing in python is advantageous or else in MATLAB > Matlab comes with a lot of builtins for image processing, pattern recognition and many other engineering-related things. If it's just a quick hack and you're familiar with matlab probably you'd get the job done more easily with it. But Thomas is right, it depends a lot on what you really need to do. -- Andrea From enleverLesX_XXmcX at XmclavXeauX.com.invalid Fri Jan 21 13:20:52 2011 From: enleverLesX_XXmcX at XmclavXeauX.com.invalid (Michel Claveau - MVP) Date: Fri, 21 Jan 2011 19:20:52 +0100 Subject: Printing RTF file under win32 References: <2608cc6e-a385-4a31-ab9e-f740d231bf06@k11g2000vbf.googlegroups.com> Message-ID: <4d39ce8c$0$32469$ba4acef3@reader.news.orange.fr> Hi! Try this line: "C:\Program Files\Windows NT\Accessories\wordpad.exe" /p D:\data\fil.rtf (change the path if you have a windows 64 bits) @-salutations -- Michel Claveau From python at mrabarnett.plus.com Fri Jan 21 13:54:23 2011 From: python at mrabarnett.plus.com (MRAB) Date: Fri, 21 Jan 2011 18:54:23 +0000 Subject: Line breaks in list causing a small formatting problem while joining the list In-Reply-To: References: Message-ID: <4D39D65F.3050506@mrabarnett.plus.com> On 21/01/2011 16:25, Peter Otten wrote: > Oltmans wrote: > >> Hi Python gurus, hope you're doing well. I've a small problem. >> >> When I run the following code >> ___________________________________________________ >>>>> names = ['oltmans','abramhovic','\n','sal','lee'] >>>>> print '| ' + ' | '.join(names) >> | oltmans | abramhovic | >> | sal | lee >> ___________________________________________________ >> >> I get the output like above. However, I want it to output like below >> >> | oltmans | abramhovic | >> | sal | lee >> >> >> That is, there shouldn't be a space in the beginning of second line. >> The list can of course contain more than 5 elements. Any ideas? I will >> appreciate any hint. Thanks in advance. > >>>> print "|%s|" % "|".join(n if n == "\n" else " %s " % n for n in names) > | oltmans | abramhovic | > | sal | lee | > Or: print ('| ' + ' | '.join(names)).replace("\n ", "\n") From g.rodola at gmail.com Fri Jan 21 14:32:57 2011 From: g.rodola at gmail.com (=?ISO-8859-1?Q?Giampaolo_Rodol=E0?=) Date: Fri, 21 Jan 2011 20:32:57 +0100 Subject: Problems with FTP In-Reply-To: <201101211805.52455.thomas@jollybox.de> References: <58a2ada5-69d6-421b-a0c9-50b34ab8960a@v26g2000yqf.googlegroups.com> <201101211805.52455.thomas@jollybox.de> Message-ID: The solution proposed on stackoverflow: from ftplib import FTP site = FTP('my_proxy') site.set_debuglevel(1) msg = site.login('anonymous at ftp.download.com', 'password') site.cwd('/pub') ...can not work. The "anonymous at ftp.download.com" part is pure fiction. Nothing like that has ever been mentioned in any RFC or implemented/supported by any server, as far as I know. I'd say the only way to proxy FTP is by using a SOCKS proxy. By looking at the error message it's likely that the company firewall is just blocking the FTP traffic. --- Giampaolo http://code.google.com/p/pyftpdlib/ http://code.google.com/p/psutil/ 2011/1/21 Thomas Jollans : > On Friday 21 January 2011, it occurred to RizlaJ to exclaim: >> Hi all, I'm very new to python. I'm using Python 2.7, in a corporate >> environment, therefore am behind a proxy server, firewalls etc. >> >> I can ftp to a barclays capital ftp site ok in internet explorer, but >> I can't get the FTP from ftplib to work for me. Can someone please >> help! > > It sounds very much like, as you said, you're behind a proxy, and have to use > that proxy to connect to the FTP server. If you don't know the proxy settings, > you might be able to find them in the IE configuration, or ask the local > sysadmin. > > http://stackoverflow.com/questions/1293518/proxies-in-python-ftp-application > > It looks like you will have to ftp to the proxy server. Depending on the > application, you might be able to use urllib2 instead. > > Thomas > >> >> I've tried the following commands from my home personal machine >> (thefore no proxies etc) and the commands work fine and I'm able to >> enter my username and password and login successfuly - however in teh >> corporate environment I can't. I'm wondering if this is soemthing to >> do with security permissioning at work etc? >> >> At the shell I'm typing:- >> >> >>> from ftplib import FTP >> >>> ftp = FTP('indexftp.barcap.com') >> >> and get the following error: >> Traceback (most recent call last): >> ? File "", line 1, in >> ? ? ftp = FTP('indexftp.barcap.com') >> ? File "C:\Python27\lib\ftplib.py", line 117, in __init__ >> ? ? self.connect(host) >> ? File "C:\Python27\lib\ftplib.py", line 132, in connect >> ? ? self.sock = socket.create_connection((self.host, self.port), >> self.timeout) >> ? File "C:\Python27\lib\socket.py", line 571, in create_connection >> ? ? raise err >> error: [Errno 10060] A connection attempt failed because the connected >> party did not properly respond after a period of time, or established >> connection failed because connected host has failed to respond >> >> I wasn't expecting this error message next, i was expecting to be able >> to log on using the followign command :- >> >> >> ftp.login("username","password") >> >> Please help! >> >> thanks! > -- > http://mail.python.org/mailman/listinfo/python-list > From gerald.britton at gmail.com Fri Jan 21 14:53:55 2011 From: gerald.britton at gmail.com (Gerald Britton) Date: Fri, 21 Jan 2011 14:53:55 -0500 Subject: PEP8, line continuations and string formatting operations Message-ID: Style question: PEP 8 suggests that line continuations be done by enclosing expressions in parentheses rather than using the line continuation character. In the same paragraph, it states a preference to put binary operators at the end of the line to be continued, so: x = (a + b) is preferred over: x = (a + b) Fair enough. What about string formatting operations (old style) though? The % symbols is a binary operator between a string and the substitution values. Strictly reading PEP 8 leads to: my_string = ("A long string with %s substitutions that %s the line should be %s." % ("many", "suggest", "continued") ) However, I often see the % on the continued line, immediately preceding the substitution variables, like this: my_string = ("A long string with %s substitutions that %s the line should be %s." % ("many", "suggest", "continued") ) This goes against the PEP 8 guidelines, but I prefer it since it makes the substitution variables "jump out" a bit more -- at least to me. So....what's the general feeling about this? Adhere to the PEP 8 binary operators style, or modify it for string formatting? -- Gerald Britton From razajaffrey77 at gmail.com Fri Jan 21 15:01:48 2011 From: razajaffrey77 at gmail.com (RizlaJ) Date: Fri, 21 Jan 2011 12:01:48 -0800 (PST) Subject: Problems with FTP References: <58a2ada5-69d6-421b-a0c9-50b34ab8960a@v26g2000yqf.googlegroups.com> <201101211805.52455.thomas@jollybox.de> Message-ID: <0f31a234-4cd0-452a-8204-5fd3ba7e7d45@k22g2000yqh.googlegroups.com> Hi Tom, Giampaolo, Thank you both for your swift replies. I have asked our IT dept to see if it is the firewall that is blocking the FTP. They are working on that side of things. However I would have thought that the following or some version of it would have worked:- >>> import urllib >>> proxies = ({'ftp':proxyserveraddress'}) >>> some_url = ({'ftp':'indexftp.barcap.com'}) >>> filehandle = urllib.urlopen(some_url, proxies=proxies) Traceback (most recent call last): File "", line 1, in filehandle = urllib.urlopen(some_url, proxies=proxies) File "C:\Python27\lib\urllib.py", line 84, in urlopen return opener.open(url) File "C:\Python27\lib\urllib.py", line 177, in open fullurl = unwrap(toBytes(fullurl)) File "C:\Python27\lib\urllib.py", line 1026, in unwrap url = url.strip() AttributeError: 'dict' object has no attribute 'strip' However as you can see there is an error - is this again related to the firewall do you think? Sorry for asking stupid questions! and thank you for your help in advance. From benjamin.kaplan at case.edu Fri Jan 21 15:19:58 2011 From: benjamin.kaplan at case.edu (Benjamin Kaplan) Date: Fri, 21 Jan 2011 15:19:58 -0500 Subject: Problems with FTP In-Reply-To: <0f31a234-4cd0-452a-8204-5fd3ba7e7d45@k22g2000yqh.googlegroups.com> References: <58a2ada5-69d6-421b-a0c9-50b34ab8960a@v26g2000yqf.googlegroups.com> <201101211805.52455.thomas@jollybox.de> <0f31a234-4cd0-452a-8204-5fd3ba7e7d45@k22g2000yqh.googlegroups.com> Message-ID: On Fri, Jan 21, 2011 at 3:01 PM, RizlaJ wrote: > Hi Tom, Giampaolo, > > Thank you both for your swift replies. I have asked our IT dept to see > if it is the firewall that is blocking the FTP. They are working on > that side of things. > > However I would have thought that the following or some version of it > would have worked:- > >>>> import urllib >>>> proxies = ({'ftp':proxyserveraddress'}) >>>> some_url = ({'ftp':'indexftp.barcap.com'}) >>>> filehandle = urllib.urlopen(some_url, proxies=proxies) > > Traceback (most recent call last): > ?File "", line 1, in > ? ?filehandle = urllib.urlopen(some_url, proxies=proxies) > ?File "C:\Python27\lib\urllib.py", line 84, in urlopen > ? ?return opener.open(url) > ?File "C:\Python27\lib\urllib.py", line 177, in open > ? ?fullurl = unwrap(toBytes(fullurl)) > ?File "C:\Python27\lib\urllib.py", line 1026, in unwrap > ? ?url = url.strip() > AttributeError: 'dict' object has no attribute 'strip' > > However as you can see there is an error - is this again related to > the firewall do you think? > > Sorry for asking stupid questions! and thank you for your help in > advance. The one has nothing to do with a firewall. It's telling you that the function is trying to call url.strip(). But url is a dict object which doesn't have a strip method. Which should tell you that some_url is being constructed incorrectly- it's supposed to be a string. > -- > http://mail.python.org/mailman/listinfo/python-list > From g.rodola at gmail.com Fri Jan 21 15:24:41 2011 From: g.rodola at gmail.com (=?ISO-8859-1?Q?Giampaolo_Rodol=E0?=) Date: Fri, 21 Jan 2011 21:24:41 +0100 Subject: Problems with FTP In-Reply-To: <0f31a234-4cd0-452a-8204-5fd3ba7e7d45@k22g2000yqh.googlegroups.com> References: <58a2ada5-69d6-421b-a0c9-50b34ab8960a@v26g2000yqf.googlegroups.com> <201101211805.52455.thomas@jollybox.de> <0f31a234-4cd0-452a-8204-5fd3ba7e7d45@k22g2000yqh.googlegroups.com> Message-ID: The standard FTP protocol does not supporty any kind of proxy-ing feature natively. The only closest thing to the concept of a "proxy" we can find in the FTP protocol is the site-to-site transfer feature: http://code.google.com/p/pyftpdlib/wiki/FAQ#What_is_FXP? ...but it's something different. By taking a look at your code, though, this is out of question anyway since you can't even connect to the server, let alone send proxy-like (non-standard) commands. I'd focus on investigating whether it's something with the internal network and forget about proxy-related problems since from here I can connect to indexftp.barcap.com. As for urllib's proxy option I'd say it's only valid for HTTP protocol. --- Giampaolo http://code.google.com/p/pyftpdlib/ http://code.google.com/p/psutil/ 2011/1/21 RizlaJ : > Hi Tom, Giampaolo, > > Thank you both for your swift replies. I have asked our IT dept to see > if it is the firewall that is blocking the FTP. They are working on > that side of things. > > However I would have thought that the following or some version of it > would have worked:- > >>>> import urllib >>>> proxies = ({'ftp':proxyserveraddress'}) >>>> some_url = ({'ftp':'indexftp.barcap.com'}) >>>> filehandle = urllib.urlopen(some_url, proxies=proxies) > > Traceback (most recent call last): > ?File "", line 1, in > ? ?filehandle = urllib.urlopen(some_url, proxies=proxies) > ?File "C:\Python27\lib\urllib.py", line 84, in urlopen > ? ?return opener.open(url) > ?File "C:\Python27\lib\urllib.py", line 177, in open > ? ?fullurl = unwrap(toBytes(fullurl)) > ?File "C:\Python27\lib\urllib.py", line 1026, in unwrap > ? ?url = url.strip() > AttributeError: 'dict' object has no attribute 'strip' > > However as you can see there is an error - is this again related to > the firewall do you think? > > Sorry for asking stupid questions! and thank you for your help in > advance. > -- > http://mail.python.org/mailman/listinfo/python-list > From razajaffrey77 at gmail.com Fri Jan 21 15:32:07 2011 From: razajaffrey77 at gmail.com (RizlaJ) Date: Fri, 21 Jan 2011 12:32:07 -0800 (PST) Subject: Problems with FTP References: <58a2ada5-69d6-421b-a0c9-50b34ab8960a@v26g2000yqf.googlegroups.com> <201101211805.52455.thomas@jollybox.de> <0f31a234-4cd0-452a-8204-5fd3ba7e7d45@k22g2000yqh.googlegroups.com> Message-ID: <816c0a8e-9eab-4292-8291-35afc48634be@29g2000yqq.googlegroups.com> Thanks Giampaolo, Benjamin for your responses. You are correct, if I can connect to the ftp site from home and you can connect too then the problem (as you state) lies at the firewall or some security issue. Thanks for your detailed responses, they've been very helpful to me. Kind Regards From drsalists at gmail.com Fri Jan 21 15:36:25 2011 From: drsalists at gmail.com (Dan Stromberg) Date: Fri, 21 Jan 2011 12:36:25 -0800 Subject: examples of realistic multiprocessing usage? In-Reply-To: <4bff00a3-09e8-43f4-a62d-5e12838b217e@n10g2000yqd.googlegroups.com> References: <2011011611053732597-tomfsessile@gmailcom> <4bff00a3-09e8-43f4-a62d-5e12838b217e@n10g2000yqd.googlegroups.com> Message-ID: On Fri, Jan 21, 2011 at 3:20 AM, Adam Skutt wrote: > On Jan 20, 11:51?pm, Albert van der Horst > wrote: >> This is what some people want you to believe. Arm twisting by >> GPL-ers when you borrow their ideas? That is really unheard of. > > Doesn't matter, you're still legally liable if your work is found to > be derivative and lacking a fair use defense. ?It's not borrowing > "ideas" that's problematic, it's proving that's all you did. ?For > those of us with legal departments, we have no choice: if they don't > believe we can prove our case, we're not using the code, period. ?The > risk simply isn't worth it. Many legal departments have an overblown sense of risk, I'm afraid. And I suppose that's somewhat natural, as it's mostly the legal people who are putting their necks on the line over such issues - though I wouldn't be surprised to see a disciplinary action or even firing of a techie over same. I worked at DATAllegro when it was acquired by Microsoft. The DATAllegro product had significant portions that were opensource code; Microsoft, of course, decided that they needed to "quarantine" (meaning "eliminate", in a weird, half-way sense) the opensource portions. Why did Microsoft do this? Why knowingly go through with the purchase of a product that had large opensource parts? Why was what they did considered "enough" as part of a complex due diligence process, to satisfy even Microsoft's copyright-extensionist lawyers? When I say "copyright extensionist", I mean: 1) Their legal department once told me that a small python module could not just be rewritten under a different license, legally, because a small module could not be made different enough to avoid issues. 2) Their onboarding process literally said "don't look at example code in programming books - it entails a legal risk for the company." What made them think DATAllegro's purchase price was still worth it, despite this perspective on copyright? I don't know; I have no first-hand knowledge of that process, though ironically I did help quarantine the "offending" code. But obviously Microsoft management, their board and their lawyers felt it was worth the risk at the price. I know it had something to do with contracting out to a 3rd party company to assess the risk and ascertain what portions "required" excising. Here's one such company: http://www.blackducksoftware.com/black-duck-suite A former coworker (not of Microsoft) suggested they were the only company in this business. I believe Black Duck has software that automatically detects opensource code in a body of work. IOW, it's quite possible to demonstrate that something isn't a derivative work, enough so to make even Microsoft's lawyers happy, given adequate funding for the purpose. So yeah, sometimes a programmer peeking at opensource code might be more of a risk (== expense) than a closed-source company is willing to take, but so might studying a book intended to help you learn programming. And how many programmers haven't studied a programming book at some time in their life? My intuition tells me (I'm not going into details - that feels too dangerous to me personally) that part of the issue Microsoft was trying to prevent, wasn't so much a matter of copyright safety, as trying to avoid being called hypocritical; they've made a lot of noise about how dangerous opensource is. If they then turn around and distribute opensource code artifacts as part of a Microsoft product, then they'll probably eventually get beaten up in the tech press yet again over the new matter. From python.list at tim.thechases.com Fri Jan 21 15:40:15 2011 From: python.list at tim.thechases.com (Tim Chase) Date: Fri, 21 Jan 2011 14:40:15 -0600 Subject: PEP8, line continuations and string formatting operations In-Reply-To: References: Message-ID: <4D39EF2F.3090303@tim.thechases.com> On 01/21/2011 01:53 PM, Gerald Britton wrote: > What about string formatting operations (old style) though? The % > symbols is a binary operator between a string and the substitution > values. Strictly reading PEP 8 leads to: > > my_string = ("A long string with %s substitutions that %s the line > should be %s." % > ("many", "suggest", "continued") > ) Depending on whether I have one item to map or multiple, I either bite the bullet and leave them all on one line: my_string = "A long string with only one %s substitution in it" % adjective if it's one substitution and the string is particularly long, I'll occasionally break the string itself: my_string = ("A long string with only one %s " "substitution in it that suggests " "being broken with a newline") % adjective For multiple parameters (a tuple), I'll usually cram both the "%" and the "(" on the same line: my_string = "A long %s with %s substitution%s in it" % ( "sentence", "several", "s", # plural ) which makes it a little easier to see all my parameters. Finally, a combination of the *really* long string and multiple parameters, I usually use a secondary variable for readability, something like fmt_string = ( "this is a %s %s with %s substitution%s in it " "and it extends over several %s" ) my_string = fmt_string % ( "long", "string", "multiple", "s", # plural "lines", ) I like to have the parameters on their own line (and a trailing comma) because it makes my diffs uncluttered when things are added/removed. That's just my own personal taste -- I too am interested in the perspectives of others on the list. -tkc From clp2 at rebertia.com Fri Jan 21 15:53:49 2011 From: clp2 at rebertia.com (Chris Rebert) Date: Fri, 21 Jan 2011 12:53:49 -0800 Subject: PEP8, line continuations and string formatting operations In-Reply-To: References: Message-ID: On Fri, Jan 21, 2011 at 11:53 AM, Gerald Britton wrote: > Style question: > > PEP 8 suggests that line continuations be done by enclosing > expressions in parentheses rather than using the line continuation > character. ?In the same paragraph, it states a preference to put > binary operators at the end of the line to be continued, so: > > x = (a + > ? ? ? b) > > is preferred over: > > x = (a > ? ? ? + b) > > Fair enough. > > What about string formatting operations (old style) though? Fair warning: They're deprecated and liable to possibly be removed: http://docs.python.org/dev/library/stdtypes.html#old-string-formatting-operations > The % > symbols is a binary operator between a string and the substitution > values. ?Strictly reading PEP 8 leads to: > > my_string = ("A long string with %s substitutions that %s the line > should be %s." % > ? ? ? ? ? ? ? ? ? ("many", "suggest", "continued") > ? ? ? ? ? ? ? ? ?) > > However, I often see the % on the continued line, immediately > preceding the substitution variables, like this: > > my_string = ("A long string with %s substitutions that %s the line > should be %s." > ? ? ? ? ? ? ? ? ? % ("many", "suggest", "continued") > ? ? ? ? ? ? ? ? ?) > > This goes against the PEP 8 guidelines, but I prefer it since it makes > the substitution variables "jump out" a bit more -- at least to me. Remember that PEP 8 itself says: "A Foolish Consistency is the Hobgoblin of Little Minds [...] But most importantly: know when to be inconsistent -- sometimes the style guide just doesn't apply. When in doubt, use your best judgment. Look at other examples and decide what looks best." i.e. Generally, don't read PEP 8 super-strictly. FWIW, your style seems reasonable and slightly preferable to me. Cheers, Chris -- http://blog.rebertia.com From philip at semanchuk.com Fri Jan 21 15:57:57 2011 From: philip at semanchuk.com (Philip Semanchuk) Date: Fri, 21 Jan 2011 15:57:57 -0500 Subject: examples of realistic multiprocessing usage? In-Reply-To: References: <2011011611053732597-tomfsessile@gmailcom> <4bff00a3-09e8-43f4-a62d-5e12838b217e@n10g2000yqd.googlegroups.com> Message-ID: On Jan 21, 2011, at 3:36 PM, Dan Stromberg wrote: > On Fri, Jan 21, 2011 at 3:20 AM, Adam Skutt wrote: >> On Jan 20, 11:51 pm, Albert van der Horst >> wrote: >>> This is what some people want you to believe. Arm twisting by >>> GPL-ers when you borrow their ideas? That is really unheard of. >> >> Doesn't matter, you're still legally liable if your work is found to >> be derivative and lacking a fair use defense. It's not borrowing >> "ideas" that's problematic, it's proving that's all you did. For >> those of us with legal departments, we have no choice: if they don't >> believe we can prove our case, we're not using the code, period. The >> risk simply isn't worth it. > > Many legal departments have an overblown sense of risk, I'm afraid. I carefully avoid GPLed code on our BSD-licensed project not because I need fear anyone's legal department, but out of respect for the author(s) of the GPL-ed code. The way I see it, the author of GPL-ed code gives away something valuable and asks for just one thing in return: respect the license. It strikes me as very selfish to deny them the one thing they ask for. JMHO, Philip From howe.steven at gmail.com Fri Jan 21 16:04:24 2011 From: howe.steven at gmail.com (GrayShark) Date: Fri, 21 Jan 2011 15:04:24 -0600 Subject: Line breaks in list causing a small formatting problem while joining the list References: Message-ID: On Fri, 21 Jan 2011 07:39:26 -0800, Oltmans wrote: > Hi Python gurus, hope you're doing well. I've a small problem. > > When I run the following code > ___________________________________________________ >>>> names = ['oltmans','abramhovic','\n','sal','lee'] print '| ' + ' | >>>> '.join(names) > | oltmans | abramhovic | > | sal | lee > ___________________________________________________ > > I get the output like above. However, I want it to output like below > > | oltmans | abramhovic | > | sal | lee > > > That is, there shouldn't be a space in the beginning of second line. The > list can of course contain more than 5 elements. Any ideas? I will > appreciate any hint. Thanks in advance. It looks like your trying to print a formatted list. With your code you are: 1) creating a string from a list, with added characters. 2) printing the new string. So, look at your string: names = ['oltmans','abramhovic','\n','sal','lee'] newNames = '| ' + ' | '.join( names ) >> newNames '| oltmans | abramhovic | \n | sal | lee' Now you can see your space after the newline (and a missing pipe symbol at the end). When you ask the compiler for newNames, you can see there is a space after the newline character. Naturally, the print operator prints out the space. If this is indeed a formatted list, you should try something else. Something like: # first get rid of you formatting element in the list '\n'. names = [ 'oltmans','abramhovic','sal','lee' ] # next iterate by twos via the function 'range( start, stop, step )' range( 0, len( names ), 2 ) [ 0, 2 ] # now fix up the printing by twos. >>> for x in range( 0, len( names ), 2 ): ... print '| %s | %s |' % ( names[ x ], names[ x + 1 ] ) ... | oltmans | abramhovic | | sal | lee | Next, make it pretty. The next step would be to find the longest string in your list. >>> def max( theList ): ... theMax = 0 ... for element in theList: ... if len( element ) > theMax: ... theMax = len( element ) ... return theMax >>> max( names ) 10 Now some centering of strings, from you list. >>> for x in range( 0, len( names ), 2 ): ... print '| %s | %s |' % \ ( names[ x ].center(10), \ names[ x +1 ].center(10) ) ... | oltmans | abramhovic | | sal | lee | Pretty list. Now make it obscure, like you are a perl programmer; don't forget to eat up memory as you go along .... def maxElement( aList ): lenList = [] for x in aList: lenList.append( len( x ) ) return sorted( lenList, reverse=True )[0] def formatLine( firstName, secondName, width ): return '| %s | %s | % \ ( firstName.center( width ), \ secondName.center( width ) ) theWidth = maxElement( names ) for x in range( 0, len( names ), 2 ): aLine = formatLines( names[x], names[x+1], theWidth ) print aLine Make sure to create at lest two additions files to store maxElement and formatLine, create an __init__.py and make a package, turn in the project and get expelled for being grandiose. steven. From longqian9509 at gmail.com Fri Jan 21 16:19:47 2011 From: longqian9509 at gmail.com (long) Date: Fri, 21 Jan 2011 13:19:47 -0800 (PST) Subject: is it a bug in exec? In-Reply-To: Message-ID: <5722cabf-9635-4795-8117-e1383f37e0ce@glegroupsg2000goo.googlegroups.com> I see now. Thank you so much. I think namespace is really a confusing part in Python. On Friday, January 21, 2011 11:00:32 AM UTC-6, Peter Otten wrote: > There are only two cases that matter: identical local/global namespaces and > distinct local/global namespaces: > > >>> code = """\ > ... x = 42 # put x into the local namespace > ... def f(): > ... print(x) # look up x in the global namespace > ... f() > ... """ > >>> exec(code, {}, {}) > Traceback (most recent call last): > File "", line 1, in > File "", line 4, in > File "", line 3, in f > NameError: global name 'x' is not defined > >>> ns = {} > >>> exec(code, ns, ns) > 42 > > Also note that > > >>> globals() is locals() > True > > on the module level. > > Peter From drsalists at gmail.com Fri Jan 21 16:34:44 2011 From: drsalists at gmail.com (Dan Stromberg) Date: Fri, 21 Jan 2011 13:34:44 -0800 Subject: examples of realistic multiprocessing usage? In-Reply-To: References: <2011011611053732597-tomfsessile@gmailcom> <4bff00a3-09e8-43f4-a62d-5e12838b217e@n10g2000yqd.googlegroups.com> Message-ID: On Fri, Jan 21, 2011 at 12:57 PM, Philip Semanchuk wrote: > On Jan 21, 2011, at 3:36 PM, Dan Stromberg wrote: >> On Fri, Jan 21, 2011 at 3:20 AM, Adam Skutt wrote: >>> On Jan 20, 11:51 pm, Albert van der Horst >>> wrote: >>>> This is what some people want you to believe. Arm twisting by >>>> GPL-ers when you borrow their ideas? That is really unheard of. >>> >>> Doesn't matter, you're still legally liable if your work is found to >>> be derivative and lacking a fair use defense. ?It's not borrowing >>> "ideas" that's problematic, it's proving that's all you did. ?For >>> those of us with legal departments, we have no choice: if they don't >>> believe we can prove our case, we're not using the code, period. ?The >>> risk simply isn't worth it. >> >> Many legal departments have an overblown sense of risk, I'm afraid. > > I carefully avoid GPLed code on our BSD-licensed project not because I need fear anyone's legal department, but out of respect for the author(s) of the GPL-ed code. The way I see it, the author of GPL-ed code gives away something valuable and asks for just one thing in return: respect the license. It strikes me as very selfish to deny them the one thing they ask for. That's very considerate, and yet, I think there are multiple senses of the word "avoid" above. If you're avoiding inspecting GPL'd code for ideas, I think if you ask most authors of GPL'd code, they'd be more than happy to allow you to. I've released GPL'd code quite a few times, and personally, I'm flattered when others want to look it over. If you're avoiding cutting and pasting from (or linking against) GPL'd code into something that isn't GPL-licensed, then that's very sensible. From cce at clarkevans.com Fri Jan 21 16:45:43 2011 From: cce at clarkevans.com (Clark C. Evans) Date: Fri, 21 Jan 2011 16:45:43 -0500 Subject: HTSQL 2.0 RC1 -- a Query Language for the Accidental Programmer Message-ID: <1295646343.4767.1416569759@webmail.messagingengine.com> Kirill Simonov and myself would like to introduce HTSQL, a novel approach to relational database access which is neither an ORM nor raw SQL. HTSQL is a URI-based high-level query language for relational databases. It's implemented as a Python WSGI application. Currently it supports PostgreSQL and SQLite (more databases & juicy features forthcoming). Homepage: http://htsql.org Download: http://pypi.python.org/pypi/HTSQL/ Source: http://bitbucket.org/prometheus/htsql At this point, HTSQL 2.0 may not be mature enough for production use; we expect to fill in any remaining gaps in the coming months. We're curious what you think. Join us in #htsql on freenode [1], subscribe to the mailing list [2] and please come to our PyCon 2011 talk [3]. Clark & Kirill [1] irc://irc.freenode.net/#htsql [2] http://lists.htsql.org/mailman/listinfo/htsql-users [3] http://us.pycon.org/2011/schedule/sessions/264/ From ddasilva at umd.edu Fri Jan 21 17:41:56 2011 From: ddasilva at umd.edu (Daniel da Silva) Date: Fri, 21 Jan 2011 14:41:56 -0800 (PST) Subject: Best way to administer code updates to server daemon Message-ID: Hi, I am writing a custom IRC server, and I was wondering would be the best way to administer code updates to the daemon. Am I doomed to have to restart the server every time I want to do an update (which would disconnect all clients)? I don't mind doing something a little more advanced if it means I can keep close to continuous uptime. Thanks, Daniel From mcnutt at utk.edu Fri Jan 21 17:59:33 2011 From: mcnutt at utk.edu (McNutt Jr, William R) Date: Fri, 21 Jan 2011 22:59:33 +0000 Subject: Python, Solaris 10, and Mailman Message-ID: <0CD7A72044B75D478D36624D96C5D4412FBB10@kmbx1.utk.tennessee.edu> I am attempting to install Mailman on a Sun Sunfire x4100 box running Solaris ten. I keep running into brick walls that the Mailman group looks at, shrugs, and says, that's a Python problem. Has ANYBODY actually made this work? Currently, I'm attempting to compile Python 2.4.4, which is the recommended distro for Mailman, and I'm getting: gcc -o python \ Modules/ccpython.o \ libpython2.4.a -lresolv -lsocket -lnsl -lrt -ldl -lm Undefined first referenced symbol in file __gxx_personality_v0 Modules/ccpython.o ld: fatal: Symbol referencing errors. No output written to python collect2: ld returned 1 exit status *** Error code 1 make: Fatal error: Command failed for target `python' -------------- next part -------------- An HTML attachment was scrubbed... URL: From python at mrabarnett.plus.com Fri Jan 21 18:26:43 2011 From: python at mrabarnett.plus.com (MRAB) Date: Fri, 21 Jan 2011 23:26:43 +0000 Subject: Best way to administer code updates to server daemon In-Reply-To: References: Message-ID: <4D3A1633.3040106@mrabarnett.plus.com> On 21/01/2011 22:41, Daniel da Silva wrote: > Hi, > > I am writing a custom IRC server, and I was wondering would be the > best way to administer code updates to the daemon. Am I doomed to have > to restart the server every time I want to do an update (which would > disconnect all clients)? I don't mind doing something a little more > advanced if it means I can keep close to continuous uptime. > As I see it, the server listens for a new client, starts a handler for that client (it might be starting the handler in a new thread), and then tidies up when the client disconnects. The server code could be split into the core and the handler. The core of the server might not be updated very often, so it would stay running, and the handler would be in another module. There could be more than one version of the handler available. When the core wanted to start a handler for a new client it would use the latest version of the handler, and when an old version of the handler was no longer being used by any client then it could be discarded. From edwinconnell at gmail.com Fri Jan 21 18:33:59 2011 From: edwinconnell at gmail.com (Ed Connell) Date: Fri, 21 Jan 2011 17:33:59 -0600 Subject: Short circuting Message-ID: Hi, Consider the following please: (re_section, re_name, etc are previously compiled patterns) result1 = re_section.search(line); result2 = re_name.search(line); result3 = re_data1.search(line); result4 = re_data2.search(line); if result1: last_section = result1.group()[18:-5] elif result2: last_name = result2.group(0)[6:-1] elif result3: data[last_section] = {last_name: result3.group()[13:-5]} elif result4: data[last_section] = {last_name: result4.group()[17:-5]} It gets my goat to have to obtain all resultx when I just want the first that is not None. (In theory, the number of results can be much longer.) I can think of alternatives (raising exceptions), but they all use deep indenting. Ideas? Ed -------------- next part -------------- An HTML attachment was scrubbed... URL: From pavlovevidence at gmail.com Fri Jan 21 18:39:31 2011 From: pavlovevidence at gmail.com (Carl Banks) Date: Fri, 21 Jan 2011 15:39:31 -0800 (PST) Subject: PEP8, line continuations and string formatting operations References: Message-ID: <1ecf312b-5154-4578-9301-5610f8d530ab@k14g2000pre.googlegroups.com> On Jan 21, 11:53?am, Gerald Britton wrote: > So....what's the general feeling about this? Adhere to the PEP 8 > binary operators style, or modify it for string formatting? Well, personally I ignore the "operator at end of first line" guideline altogether; I think it's much more readable with the operator on the following line, not even close. I'm starting to not fold lines with parentheses as much, either. Sometimes the parentheses break the flow too much, or suggest grouping where it isn't desirable. Carl Banks From alex.kapps at web.de Fri Jan 21 19:10:41 2011 From: alex.kapps at web.de (Alexander Kapps) Date: Sat, 22 Jan 2011 01:10:41 +0100 Subject: Short circuting In-Reply-To: References: Message-ID: <4D3A2081.1010509@web.de> On 22.01.2011 00:33, Ed Connell wrote: > Hi, > > Consider the following please: (re_section, re_name, etc are > previously compiled patterns) > > result1 = re_section.search(line); > result2 = re_name.search(line); > result3 = re_data1.search(line); > result4 = re_data2.search(line); > > if result1: > last_section = result1.group()[18:-5] > elif result2: > last_name = result2.group(0)[6:-1] > elif result3: > data[last_section] = {last_name: > result3.group()[13:-5]} > elif result4: > data[last_section] = {last_name: > result4.group()[17:-5]} > > It gets my goat to have to obtain all resultx when I just want the > first that is not None. (In theory, the number of results can be > much longer.) I can think of alternatives (raising exceptions), but > they all use deep indenting. > > Ideas? > > Ed > Maybe something like this (totally untested and probably wrong, I'm already quite tired): for pattern in (re_section, re_name, re_data1, re_data2): result = pattern.search(line): if result: if pattern == re_section: last_section = result1.group()[18:-5] elif pattern == re_name: last_name = result2.group(0)[6:-1] elif pattern == re_data1: data[last_section] = {last_name: result3.group()[13:-5]} elif pattern == re_data2: data[last_section] = {last_name: result4.group()[17:-5]} Also, if you have long if/elif ladders, look if you can apply the dictionary dispatch pattern. From alex.kapps at web.de Fri Jan 21 19:35:22 2011 From: alex.kapps at web.de (Alexander Kapps) Date: Sat, 22 Jan 2011 01:35:22 +0100 Subject: Short circuting In-Reply-To: <4D3A2081.1010509@web.de> References: <4D3A2081.1010509@web.de> Message-ID: <4D3A264A.1020503@web.de> On 22.01.2011 01:10, Alexander Kapps wrote: > On 22.01.2011 00:33, Ed Connell wrote: >> Hi, >> >> Consider the following please: (re_section, re_name, etc are >> previously compiled patterns) >> >> result1 = re_section.search(line); >> result2 = re_name.search(line); >> result3 = re_data1.search(line); >> result4 = re_data2.search(line); >> >> if result1: >> last_section = result1.group()[18:-5] >> elif result2: >> last_name = result2.group(0)[6:-1] >> elif result3: >> data[last_section] = {last_name: >> result3.group()[13:-5]} >> elif result4: >> data[last_section] = {last_name: >> result4.group()[17:-5]} >> >> It gets my goat to have to obtain all resultx when I just want the >> first that is not None. (In theory, the number of results can be >> much longer.) I can think of alternatives (raising exceptions), but >> they all use deep indenting. >> >> Ideas? >> >> Ed >> > > > Maybe something like this (totally untested and probably wrong, I'm > already quite tired): > > > for pattern in (re_section, re_name, re_data1, re_data2): > result = pattern.search(line): > if result: > if pattern == re_section: > last_section = result1.group()[18:-5] > elif pattern == re_name: > last_name = result2.group(0)[6:-1] > elif pattern == re_data1: > data[last_section] = {last_name: result3.group()[13:-5]} > elif pattern == re_data2: > data[last_section] = {last_name: result4.group()[17:-5]} > > > Also, if you have long if/elif ladders, look if you can apply the > dictionary dispatch pattern. Correction. Of course you need to break out of the loop as soon as a not None result is found: if result: if pattern == re_section: last_section = result1.group()[18:-5] ... break ... From solipsis at pitrou.net Fri Jan 21 20:10:38 2011 From: solipsis at pitrou.net (Antoine Pitrou) Date: Sat, 22 Jan 2011 02:10:38 +0100 Subject: Python, Solaris 10, and Mailman References: <0CD7A72044B75D478D36624D96C5D4412FBB10@kmbx1.utk.tennessee.edu> Message-ID: <20110122021038.42011cb1@pitrou.net> On Fri, 21 Jan 2011 22:59:33 +0000 "McNutt Jr, William R" wrote: > I am attempting to install Mailman on a Sun Sunfire x4100 box running Solaris ten. I keep running into brick walls that the Mailman group looks at, shrugs, and says, that's a Python problem. > > Has ANYBODY actually made this work? > > Currently, I'm attempting to compile Python 2.4.4, which is the recommended distro for Mailman, 2.4.4?? Do yourself a favour and choose a modern release. 2.4 hasn't been supported for years, and besides, the latest in that branch in 2.4.6. You can probably use whatever version of Python comes with Solaris, no need to build your own. Oh, and tell the Mailman guys that their recommendations are totally obsolete. Regards Antoine. From brenNOSPAMbarn at NObrenSPAMbarn.net Fri Jan 21 20:48:01 2011 From: brenNOSPAMbarn at NObrenSPAMbarn.net (OKB (not okblacke)) Date: Sat, 22 Jan 2011 01:48:01 +0000 (UTC) Subject: Krippendorff's alpha Message-ID: Does anyone know of a Python implementation of calculating Krippendorff's alpha? ( http://en.wikipedia.org/wiki/Krippendorff%27s_Alpha ) Thanks, -- --OKB (not okblacke) Brendan Barnwell "Do not follow where the path may lead. Go, instead, where there is no path, and leave a trail." --author unknown From debatem1 at gmail.com Fri Jan 21 21:03:13 2011 From: debatem1 at gmail.com (geremy condra) Date: Fri, 21 Jan 2011 18:03:13 -0800 Subject: Krippendorff's alpha In-Reply-To: References: Message-ID: On Fri, Jan 21, 2011 at 5:48 PM, OKB (not okblacke) wrote: > ? ? ? ?Does anyone know of a Python implementation of calculating > Krippendorff's alpha? ?( > http://en.wikipedia.org/wiki/Krippendorff%27s_Alpha ) First hit on google is [0], which has a full implementation, worked out example of how to use it, and a link to an excellent description of how it works and when to use it. Geremy Condra [0]: http://cswww.essex.ac.uk/Research/nle/arrau/alpha.html From steve+comp.lang.python at pearwood.info Fri Jan 21 21:21:45 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 22 Jan 2011 02:21:45 GMT Subject: Krippendorff's alpha References: Message-ID: <4d3a3f38$0$29983$c3e8da3$5496439d@news.astraweb.com> On Sat, 22 Jan 2011 01:48:01 +0000, OKB (not okblacke) wrote: > Does anyone know of a Python implementation of calculating > Krippendorff's alpha? ( > http://en.wikipedia.org/wiki/Krippendorff%27s_Alpha ) Google is your friend. Search for "Krippendorff's alpha python" and the very first link takes you to one. http://www.google.co.uk/search?q=Krippendorff%27s+alpha+python&ie=UTF-8&oe=UTF-8 -- Steven From python.list at tim.thechases.com Fri Jan 21 21:59:43 2011 From: python.list at tim.thechases.com (Tim Chase) Date: Fri, 21 Jan 2011 20:59:43 -0600 Subject: Short circuting In-Reply-To: References: Message-ID: <4D3A481F.7050601@tim.thechases.com> On 01/21/2011 05:33 PM, Ed Connell wrote: > Consider the following please: (re_section, re_name, etc are previously > compiled patterns) > > result1 = re_section.search(line); > result2 = re_name.search(line); > result3 = re_data1.search(line); > result4 = re_data2.search(line); > > if result1: > last_section = result1.group()[18:-5] > elif result2: > last_name = result2.group(0)[6:-1] > elif result3: > data[last_section] = {last_name: > result3.group()[13:-5]} > elif result4: > data[last_section] = {last_name: > result4.group()[17:-5]} > > It gets my goat to have to obtain all resultx when I just want the first > that is not None. (In theory, the number of results can be much longer.) The problem isn't so much the elif structure, but that you're doing different things with each result. If they were attributes of a class and value assignments (instead of top-level variables, sometimes calling .group() with no params & sometimes with "0", and a mix of strings/dicts), you could do something like line = "..." info = object() # some class with attributes to update for name, r, slc in ( ("section", re_section, slice(18,-5)), ("name", re_name, slice(6,-1)), ("data1", re_data1, slice(13,-5)), ("data2", re_data2, slice(17,-5)), ): result = r.search(line) if result: setattr(info, name, result.group(0)[slc]) break else: woah_none_matched(fail, fail, fail, do_I_care) So if you're doing predictable things with each, it's not too bad. -tkc From robert.kern at gmail.com Fri Jan 21 23:19:30 2011 From: robert.kern at gmail.com (Robert Kern) Date: Fri, 21 Jan 2011 22:19:30 -0600 Subject: Short circuting In-Reply-To: References: Message-ID: On 1/21/11 5:33 PM, Ed Connell wrote: > Hi, > > Consider the following please: (re_section, re_name, etc are previously > compiled patterns) > > result1 = re_section.search(line); > result2 = re_name.search(line); > result3 = re_data1.search(line); > result4 = re_data2.search(line); > > if result1: > last_section = result1.group()[18:-5] > elif result2: > last_name = result2.group(0)[6:-1] > elif result3: > data[last_section] = {last_name: > result3.group()[13:-5]} > elif result4: > data[last_section] = {last_name: > result4.group()[17:-5]} > > It gets my goat to have to obtain all resultx when I just want the first that is > not None. (In theory, the number of results can be much longer.) I can think > of alternatives (raising exceptions), but they all use deep indenting. parsers = [ ('section', re_section, lambda r: r.group()[18:-5]), ('name', re_name, lambda r: r.group()[6:-1]), ('data1', re_data1, lambda r: r.group()[13:-5]), ('data2', re_data2, lambda r: r.group()[17:-5]), ] data = {} for line in lines: values = {} for key, regex, extract in parsers: m = regex.search(line) if m is not None: values[key] = extract(m) break if 'data1' in values: data[values['section']] = {values['name']: values['data1']} elif 'data2' in values: data[values['section']] = {values['name']: values['data2']} -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco From brenNOSPAMbarn at NObrenSPAMbarn.net Fri Jan 21 23:51:10 2011 From: brenNOSPAMbarn at NObrenSPAMbarn.net (OKB (not okblacke)) Date: Sat, 22 Jan 2011 04:51:10 +0000 (UTC) Subject: Krippendorff's alpha References: <4d3a3f38$0$29983$c3e8da3$5496439d@news.astraweb.com> Message-ID: Steven D'Aprano wrote: > On Sat, 22 Jan 2011 01:48:01 +0000, OKB (not okblacke) wrote: > >> Does anyone know of a Python implementation of calculating >> Krippendorff's alpha? ( >> http://en.wikipedia.org/wiki/Krippendorff%27s_Alpha ) > > Google is your friend. Search for "Krippendorff's alpha python" and > the very first link takes you to one. > > http://www.google.co.uk/search?q=Krippendorff%27s+alpha+python&ie=UT > F-8&oe=UTF-8 Thanks to you and Geremy Condra for pointing me at this. I had done a search but somehow did not come upon that page. Perhaps I mistyped something. -- --OKB (not okblacke) Brendan Barnwell "Do not follow where the path may lead. Go, instead, where there is no path, and leave a trail." --author unknown From rustompmody at gmail.com Sat Jan 22 00:25:43 2011 From: rustompmody at gmail.com (rusi) Date: Fri, 21 Jan 2011 21:25:43 -0800 (PST) Subject: HTSQL 2.0 RC1 -- a Query Language for the Accidental Programmer References: Message-ID: On Jan 22, 2:45?am, "Clark C. Evans" wrote: > Kirill Simonov and myself would like to introduce HTSQL, a novel > approach to relational database access which is neither an ORM nor raw SQL. : > We're curious what you think. Thanks -- looks interesting. Given the claim htsql is higher level than sql I am interested in bill-of-materials type (recursive) queries. From no.email at nospam.invalid Sat Jan 22 00:27:01 2011 From: no.email at nospam.invalid (Paul Rubin) Date: Fri, 21 Jan 2011 21:27:01 -0800 Subject: Best way to administer code updates to server daemon References: Message-ID: <7xy66dwlsq.fsf@ruckus.brouhaha.com> Daniel da Silva writes: > I am writing a custom IRC server, and I was wondering would be the > best way to administer code updates to the daemon. Am I doomed to have > to restart the server every time I want to do an update (which would > disconnect all clients)? I don't mind doing something a little more > advanced if it means I can keep close to continuous uptime. There are several possible approaches: 1) load new code into the server with the import function, being careful about what data structures you can mess with etc. 2) have a simple front end proxy that maintains the inbound tcp connections to clients, and uses a connectionless or restartable protocol to pass the info to the server. Of course now you have the issue of how to update the proxy. But for a serious HA system you have to do stuff like this anyway. 3) Start the new server in a new process, and use the Linux SCM_RIGHTS message that lets you pass open file descriptors through Unix domain sockets, to hand off any open TCP connections from the old server to the new one. Maybe there are other ideas possible too. From premjee07 at gmail.com Sat Jan 22 02:24:49 2011 From: premjee07 at gmail.com (Free Online Jobs) Date: Fri, 21 Jan 2011 23:24:49 -0800 (PST) Subject: 3-Easy Steps to make your FREE Website using Free WEB SITE Software,.,..,To Earn Extra Online Money Message-ID: <17f72c0e-65dd-4882-879c-55eb34bec86b@c13g2000prc.googlegroups.com> http://freewebsitesoftware.info How to make free website , Earning tricks with FREE website ,.,.., Way to make free website using FREE website software,.,.,.,., http://freewebsitesoftware.info From torriem at gmail.com Sat Jan 22 02:36:57 2011 From: torriem at gmail.com (Michael Torrie) Date: Sat, 22 Jan 2011 00:36:57 -0700 Subject: Tkinter: The good, the bad, and the ugly! In-Reply-To: References: <6dc986a5-bcc2-4d2c-8fc2-5b4732096d3b@j29g2000yqm.googlegroups.com><4d337983$0$29983$c3e8da3$5496439d@news.astraweb.com><044a5101-948d-4458-9c94-57dbb3e25f67@m35g2000vbn.googlegroups.com><4d3467bf$0$29983$c3e8da3$5496439d@news.astraweb.com><4D34B04E.8050309@web.de><4266E8D7BA204BFEA5BF66C635CE1716@octavian><4D35DCE8.5030002@web.de><4D35DD47.1070304@web.de><7A0C7934E65D4B85A584C06ADD3B6ECF@teddy>< ih53k2$pjf$1@dough.gmane.org> <513d0274-1878-49a6-9382-31b6ae7aaef3@y9g2000prf.googlegroups.com> Message-ID: <4D3A8919.5030303@gmail.com> On 01/20/2011 11:17 AM, Emile van Sebille wrote: > The problem with QT is the license. PyQT indeed is licensed poorly for anything that's not GPL. But Qt itself is dual-licensed under GPL and the LGPL, as of version 4.6 I think. The LGPL license would seem to be quite acceptable even for commercial, closed-source programs. Is this not so? The license is at parity with GTK+. Eventually PySide will be stable and fast, and so the licensing issues involving PyQt won't matter. From user at compgroups.net/ Sat Jan 22 10:02:25 2011 From: user at compgroups.net/ (BurchALTA) Date: Sat, 22 Jan 2011 09:02:25 -0600 Subject: tilted text in the turtle module References: Message-ID: Every one remembers that men's life seems to be expensive, nevertheless different people require cash for various issues and not every person earns enough money. Thus to receive quick personal loans and bank loan should be a right solution. From cce at clarkevans.com Sat Jan 22 12:13:11 2011 From: cce at clarkevans.com (Clark C. Evans) Date: Sat, 22 Jan 2011 12:13:11 -0500 Subject: HTSQL 2.0 RC1 -- a Query Language for the Accidental Programmer In-Reply-To: References: Message-ID: <1295716391.32152.1416665025@webmail.messagingengine.com> On Fri, 21 Jan 2011 21:25 -0800, "rusi" wrote: > On Jan 22, 2:45?am, "Clark C. Evans" wrote: > > Kirill Simonov and myself would like to introduce HTSQL, a novel > > approach to relational database access which is neither an ORM > > nor raw SQL. > > Given the claim htsql is higher level than sql I am interested in > bill-of-materials type (recursive) queries. Rusi, HTSQL 2.0 does not yet support SQL's common table expressions. However, this particular use case, along with CUBE, server-side stored procedures, and related needs is what made us branch from our 1.X production release. Our immediate focus is SQL-92. Once we cover most SELECT patterns and SQL back-ends, we'll be looking at SQL:1999, SQL:2003, and SQL:2008 (as well as proprietary equivalents such as Oracle's CONNECT BY). Best, Clark From xi at gamma.dn.ua Sat Jan 22 12:20:07 2011 From: xi at gamma.dn.ua (Kirill Simonov) Date: Sat, 22 Jan 2011 12:20:07 -0500 Subject: HTSQL 2.0 RC1 -- a Query Language for the Accidental Programmer In-Reply-To: References: Message-ID: <4D3B11C7.7000108@gamma.dn.ua> On 01/22/2011 12:25 AM, rusi wrote: > On Jan 22, 2:45 am, "Clark C. Evans" wrote: >> Kirill Simonov and myself would like to introduce HTSQL, a novel >> approach to relational database access which is neither an ORM nor raw SQL. > : >> We're curious what you think. > > Thanks -- looks interesting. > > Given the claim htsql is higher level than sql I am interested in > bill-of-materials type (recursive) queries. Currently HTSQL does not support recursive queries. That said, it's certainly within the reach of HTSQL and I could sketch here how the support may look like: We add an operator `closure()` that, given a self-referential link `link`, produces a transitive closure `closure(link)` of the link. For example, take a table `program` with a link `program.part_of`. Then `program.closure(part_of)` is a plural link mapping a program to its super-programs, which you can use just like a regular plural link, for instance, in aggregate expressions. To return, for each program, a list of its super-programs: /program{code, /closure(part_of){code}} To return all sub-programs of a specific program 'xxx': /program?exists(closure(part_of).code='xxx') Compare that with /program{code, part_of.code} /program?part_of.code='xxx' I think it would be a modest improvement over a SQL alternative. I'm adding it to the roadmap right now, but don't hold your breath -- Q4 this year or early next year is a realistic ETA. I expect the implementation to be at least moderately painful and, obviously, it could only work with those backends that support WITH RECURSIVE. Thanks, Kirill From rustompmody at gmail.com Sat Jan 22 12:36:54 2011 From: rustompmody at gmail.com (rusi) Date: Sat, 22 Jan 2011 09:36:54 -0800 (PST) Subject: HTSQL 2.0 RC1 -- a Query Language for the Accidental Programmer References: Message-ID: <10d3ec9c-5444-4a51-9195-6bd7318618d7@j19g2000prh.googlegroups.com> On Jan 22, 10:20?pm, Kirill Simonov wrote: > On 01/22/2011 12:25 AM, rusi wrote: > > > On Jan 22, 2:45 am, "Clark C. Evans" ?wrote: > >> Kirill Simonov and myself would like to introduce HTSQL, a novel > >> approach to relational database access which is neither an ORM nor raw SQL. > > : > >> We're curious what you think. > > > Thanks -- looks interesting. > > > Given the claim htsql is higher level than sql I am interested in > > bill-of-materials type (recursive) queries. > > Currently HTSQL does not support recursive queries. ?That said, it's > certainly within the reach of HTSQL and I could sketch here how the > support may look like: > > We add an operator `closure()` that, given a self-referential link > `link`, produces a transitive closure `closure(link)` of the link. > > For example, take a table `program` with a link `program.part_of`. ?Then > `program.closure(part_of)` is a plural link mapping a program to its > super-programs, which you can use just like a regular plural link, for > instance, in aggregate expressions. > > To return, for each program, a list of its super-programs: > > ? ? ?/program{code, /closure(part_of){code}} > > To return all sub-programs of a specific program 'xxx': > > ? ? ?/program?exists(closure(part_of).code='xxx') > > Compare that with > > ? ? ?/program{code, part_of.code} > ? ? ?/program?part_of.code='xxx' > > I think it would be a modest improvement over a SQL alternative. > > I'm adding it to the roadmap right now, but don't hold your breath -- Q4 > this year or early next year is a realistic ETA. ?I expect the > implementation to be at least moderately painful and, obviously, it > could only work with those backends that support WITH RECURSIVE. O well... I was hoping for some some quick-queries (one-liners?) to probe firefox's bookmarks (which are in sqlite) From skunkworks at rikishi42.net Sat Jan 22 15:22:27 2011 From: skunkworks at rikishi42.net (Rikishi42) Date: Sat, 22 Jan 2011 21:22:27 +0100 Subject: Need GUI pop-up to edit a (unicode ?) string Message-ID: <3tqr08-bj2.ln1@murmur.very.softly> I'm in need for a graphical pop-up that will display a (unicode ?) string in a field, allow the user to change it and return the modified string. Maybe also keep the original one displayed above it. Something like this: +-------------------------------------------------+ | Please confirm or edit the following string | | | | Original_example_string | | | | +-------------------------------------------+ | | | Original_about_to_be_changed | | | +-------------------------------------------+ | | | | OK | | | +-------------------------------------------------+ I've never used any kind of graphical interface programing before, so I don't have a clue where to start. This would, however, be the *only* GUI part in the app at this point. >From what I can see the solution lays with PyQT, but the docs I find are courses that aim to teach the whole GUI tool. I only need a little pop-up to alow a user to edit part of a filename, for instance. I'm using Python 2.6.x on various Linux platforms (mainly openSUSE and Mint) and on Windows. Windows support is not important, in this case. -- When in doubt, use brute force. -- Ken Thompson From kb1pkl at aim.com Sat Jan 22 16:10:01 2011 From: kb1pkl at aim.com (Corey Richardson) Date: Sat, 22 Jan 2011 16:10:01 -0500 Subject: Need GUI pop-up to edit a (unicode ?) string In-Reply-To: <3tqr08-bj2.ln1@murmur.very.softly> References: <3tqr08-bj2.ln1@murmur.very.softly> Message-ID: <4D3B47A9.4080303@aim.com> On 01/22/2011 03:22 PM, Rikishi42 wrote: > > I'm in need for a graphical pop-up that will display a (unicode ?) string in > a field, allow the user to change it and return the modified string. > > Maybe also keep the original one displayed above it. > > > Something like this: > +-------------------------------------------------+ > | Please confirm or edit the following string | > | | > | Original_example_string | > | | > | +-------------------------------------------+ | > | | Original_about_to_be_changed | | > | +-------------------------------------------+ | > | | > | OK | > | | > +-------------------------------------------------+ > > > I've never used any kind of graphical interface programing before, so I > don't have a clue where to start. > This would, however, be the *only* GUI part in the app at this point. > >> From what I can see the solution lays with PyQT, but the docs I find are > courses that aim to teach the whole GUI tool. I only need a little pop-up to > alow a user to edit part of a filename, for instance. > > > I'm using Python 2.6.x on various Linux platforms (mainly openSUSE and Mint) > and on Windows. Windows support is not important, in this case. > > > If that is all you need, I suggest Tkinter. Nice and easy, comes built into Python. Looks like you need two labels, an entry, and a button. When I was learning Tkinter I used http://effbot.org/tkinterbook/. Hope it helped, ~Corey From debatem1 at gmail.com Sat Jan 22 17:57:58 2011 From: debatem1 at gmail.com (geremy condra) Date: Sat, 22 Jan 2011 14:57:58 -0800 Subject: Need GUI pop-up to edit a (unicode ?) string In-Reply-To: <3tqr08-bj2.ln1@murmur.very.softly> References: <3tqr08-bj2.ln1@murmur.very.softly> Message-ID: On Sat, Jan 22, 2011 at 12:22 PM, Rikishi42 wrote: > > I'm in need for a graphical pop-up that will display a (unicode ?) string in > a field, allow the user to change it and return the modified string. > > Maybe also keep the original one displayed above it. > > > Something like this: > +-------------------------------------------------+ > | ? Please confirm or edit the following string ? | > | ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? | > | ? ? Original_example_string ? ? ? ? ? ? ? ? ? ? | > | ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? | > | ?+-------------------------------------------+ ?| > | ?| ?Original_about_to_be_changed ? ? ? ? ? ? | ?| > | ?+-------------------------------------------+ ?| > | ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? | > | ? ? ? ? ? ? ? ? ? ? OK ? ? ? ? ? ? ? ? ? ? ? ? ?| > | ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? | > +-------------------------------------------------+ > > > I've never used any kind of graphical interface programing before, so I > don't have a clue where to start. > This would, however, be the *only* GUI part in the app at this point. > > >From what I can see the solution lays with PyQT, but the docs I find are > courses that aim to teach the whole GUI tool. I only need a little pop-up to > alow a user to edit part of a filename, for instance. > > > I'm using Python 2.6.x on various Linux platforms (mainly openSUSE and Mint) > and on Windows. Windows support is not important, in this case. If windows doesn't matter to you, just use Zenity. Here's a python function wrapping zenity that does what you want: import commands def confirm_or_edit(s): zenity = 'zenity' mode = '--entry' text = "--text='Please confirm or edit the following string:'" title = "--title='confirm or edit'" entry = "--entry-text='%s'" % s cmd = ' '.join([zenity, mode, text, title, entry]) status, output = commands.getstatusoutput(cmd) if status: raise Exception("Couldn't run zenity") return output There's also a full-blown API for zenity, but this should do what you want. Geremy Condra From skunkworks at rikishi42.net Sat Jan 22 18:27:13 2011 From: skunkworks at rikishi42.net (Rikishi42) Date: Sun, 23 Jan 2011 00:27:13 +0100 Subject: Need GUI pop-up to edit a (unicode ?) string References: <3tqr08-bj2.ln1@murmur.very.softly> Message-ID: On 2011-01-22, Corey Richardson wrote: > On 01/22/2011 03:22 PM, Rikishi42 wrote: >> >> I'm in need for a graphical pop-up that will display a (unicode ?) string in >> a field, allow the user to change it and return the modified string. >> > If that is all you need, I suggest Tkinter. Nice and easy, comes built > into Python. Looks like you need two labels, an entry, and a button. > When I was learning Tkinter I used http://effbot.org/tkinterbook/. I had to add Tkinter, which was not isntalled on my machine. But it looks easy enough, I'll definitively look into it. Thanks ! -- When in doubt, use brute force. -- Ken Thompson From pavlovevidence at gmail.com Sat Jan 22 18:38:42 2011 From: pavlovevidence at gmail.com (Carl Banks) Date: Sat, 22 Jan 2011 15:38:42 -0800 (PST) Subject: Best way to administer code updates to server daemon References: <7xy66dwlsq.fsf@ruckus.brouhaha.com> Message-ID: <3090b1fe-0d42-494b-9a05-36d4febcdcaf@k9g2000pre.googlegroups.com> On Jan 21, 9:27?pm, Paul Rubin wrote: > Maybe there are other ideas possible too. I don't know of any off-hand but there are probably virtual network drivers that sit between your server and the network stack that can keep a connection open. It seems like it'd be a common enough need that someone's figured out an easy way to handle it. Carl Banks From rantingrick at gmail.com Sat Jan 22 19:07:31 2011 From: rantingrick at gmail.com (rantingrick) Date: Sat, 22 Jan 2011 16:07:31 -0800 (PST) Subject: [Code Challenge] WxPython versus Tkinter. Message-ID: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> WxPython versus Tkinter (A code battle to the death!) by Rick Johnson. I have in many threads declared that Tkinter (and TclTk) is currently --and has been for a decade-- the wrong choice for Python's stdlib GUI. Throughout the 90's Tkinter was fine. However we have been in the 21st century for more than a decade and Tkinter is no longer relevant. Many people have argued (weakly) that Tkinter is still valid. However their arguments have been mostly baseless opinions that sadly lack vision for the future. In this thread i intend to slay my enemies with cold hard facts based on code. It is time to put your code where your mouth is (or you foot). This will be an open challenge to *anyone* in this community, in the world, and *even* the great Guido van Rossum himself! It is now time for you (python community) to prove the worth of Tkinter or accept its demise at my hands! Some of you may think this sounds like an impossible challenge. How can one man defend his position against the entire world! Yes, it would seem impossible for one man to face an entire community in open challenge! And in most cases only a fool would challenge the world. However, i have not one ounce of fear within me while facing these odds because my position is the correct position. My position is based on facts and NOT friendship, truth and NOT tantrums, and finally vision NOT vengance! I am on the correct side of history! It is time to prove once and for all how dated and worthless Tkinter is compared to wxPython. Yes, WxPython is not as advanced as i would like it to be for a 21st century GUI library. However compared to Tkinter, Wx is light years ahead! Wx is our best hope to move Python into the 21st century. So now is the time for all you naysayers, trolls, and minions to face me in mortal combat within the arena of truth and righteousness. Ready your minds and wield your text editors for we shall battle for the glory of Python! And when i have slayed the fools with their own foolishness then ye all shall be enlightened! So PUT UP OR SHUT THE HELL UP! --------------------------------------- Challenge 1: (Simple Directory Viewer) --------------------------------------- Create a simple Directory Viewer GUI. You CANNOT use a treectrl! The point of this challenge is to show that Tkinter has no support for a true ListCtrl widget. However the Wx::ListCtrl is fully featured! For wxPython the code is simply wielding a few built in classes. For Tkinter no such ListCtrl functionality exists. You CAN create the functionality yourself (and i know this because i HAVE created it!) however it involves tons of work and still can't hold a candle to the wx::ListCtrl --------------- Requirements: --------------- How the user navigates to a folder is not important but you must display the list of files/folders in two view modes with icons; 1. Display files in both ReportView and ListView. * Reportview: ...scrollable vertical list with three columns. * Listview: ...scrollable horizontal-ly wrapping list. Note: If you do not understand the view modes just run my code for an example. But the user must be able to switch between these two modes easily. How the switching is done is unimportant -- I simply used two buttons. 2. Columns * Minimum of three cols; Name, Size, and Type (reportview). * the "Name" column must include an icon AND label (both views). * columns must be sortable by the user (reportview). * columns must be sizable by the user (reportview). 3. Items * All must be editable in place (no popup editing allowed!). * All items must be selectable/deselectable by user. * All items must be delete-able by the user. That is the challenge. Step forth and battle if you can! ----------------- WxPython code: ----------------- https://sites.google.com/site/thefutureofpython/home/code-challenges I await any challengers... From no.email at nospam.invalid Sat Jan 22 19:37:49 2011 From: no.email at nospam.invalid (Paul Rubin) Date: Sat, 22 Jan 2011 16:37:49 -0800 Subject: Best way to administer code updates to server daemon References: <7xy66dwlsq.fsf@ruckus.brouhaha.com> <3090b1fe-0d42-494b-9a05-36d4febcdcaf@k9g2000pre.googlegroups.com> Message-ID: <7xhbd0xxnm.fsf@ruckus.brouhaha.com> Carl Banks writes: > I don't know of any off-hand but there are probably virtual network > drivers that sit between your server and the network stack that can > keep a connection open. > > It seems like it'd be a common enough need that someone's figured out > an easy way to handle it. I don't see big conceptual obstacles to making a network stack itself be able to package up the internal state of a TCP or even SSL connection, and hand it off to another computer over a LAN, so that you could have graceful turnover of live connections. They could even cross-update info about the connection for hardware failover. I woder if (e.g.) Erlang OTP already does something like that. I worked on a device with such a feature a while back, based on very special purpose hardware and software and a special (hardware) communication bus for the purpose, but with some careful coding it can probably be done with stock hardware and ethernet. From kwa at kuwata-lab.com Sat Jan 22 21:00:43 2011 From: kwa at kuwata-lab.com (Makoto Kuwata) Date: Sun, 23 Jan 2011 11:00:43 +0900 Subject: [ANN] Oktest 0.6.0 released - a new-style testing library Message-ID: Hi all, I released Oktest 0.6.0. http://pypi.python.org/pypi/Oktest/ http://packages.python.org/Oktest/ Oktest is a new-style testing library for Python. :: from oktest import ok ok (x) > 0 # same as assert_(x > 0) ok (s) == 'foo' # same as assertEqual(s, 'foo') ok (s) != 'foo' # same as assertNotEqual(s, 'foo') ok (f).raises(ValueError) # same as assertRaises(ValueError, f) ok (u'foo').is_a(unicode) # same as assert_(isinstance(u'foo', unicode)) not_ok (u'foo').is_a(int) # same as assert_(not isinstance(u'foo', int)) ok ('A.txt').is_file() # same as assert_(os.path.isfile('A.txt')) not_ok ('A.txt').is_dir() # same as assert_(not os.path.isdir('A.txt')) See http://packages.python.org/Oktest/ for details. NOTICE!! Oktest is a young project and specification may change in the future. New features in this release ---------------------------- Oktest supports Tracer class which can be mock or stub of function or method. Example to create fake object:: ## create fake objects from oktest.tracer import Tracer tr = Tracer() foo = tr.fake_obj(m1=100, m2=200) # method name and return-value bar = tr.fake_obj(m3=lambda self, x: x+1) # method name and body ## call fake methods ok (bar.m3(0)) == 1 ok (foo.m2(1,2,3)) == 200 # any argument can be passed ok (foo.m1(x=123)) == 100 # any argument can be passed ## check results ok (repr(tr[0])) == 'm3(0) #=> 1' ok (repr(tr[1])) == 'm2(1, 2, 3) #=> 200' ok (repr(tr[2])) == 'm1(x=123) #=> 100' There are several ways to check results:: from oktest.tracer import Tracer tr = Tracer() obj = tr.fake_obj(meth=9) ok (obj.meth(1, 2, x=3)) == 9 ## check results ok (repr(tr[0])) == 'meth(1, 2, x=3) #=> 9' ## or ok (tr[0].list()) == [obj, 'meth', (1, 2), {'x': 3}, 9] ## or ok (tr[0]) == [obj, 'meth', (1, 2), {'x': 3}, 9] ## or ok (tr[0].receiver).is_(obj) ok (tr[0].name) == 'meth' ok (tr[0].args) == (1, 2) ok (tr[0].kwargs) == {'x': 3} ok (tr[0].ret) == 9 Example to trace method call:: class Foo(object): def m1(self, x): return x + 1 def m2(self, y): return y + 1 obj = Foo() ## trace methods from oktest.tracer import Tracer tr = Tracer() def dummy(original_func, *args, **kwargs): #return original_func(*args, **kwargs) return 100 tr.fake_method(obj, m1=dummy, m2=200) ## call methods ok (obj.m1(1)) == 100 ok (obj.m2(2)) == 200 ## check results ok (tr[0]) == [obj, 'm1', (1,), {}, 100] ok (tr[1]) == [obj, 'm2', (2,), {}, 200] Example to trace function call:: def f(x): return x+1 def g(y): return f(y+1) + 1 ## trace functions from oktest.tracer import Tracer tr = Tracer() f = tr.trace_func(f) g = tr.trace_func(g) ## call functions ok (g(0)) == 3 ## check results ok (tr[0]) == [None, 'g', (0,), {}, 3] ok (tr[1]) == [None, 'f', (1,), {}, 2] Example to fake method call:: class Foo(object): def m1(self, x): return x + 1 def m2(self, y): return y + 1 obj = Foo() ## fake methods from oktest.tracer import Tracer tr = Tracer() def dummy(original_func, *args, **kwargs): #return original_func(*args, **kwargs) return 100 tr.fake_method(obj, m1=dummy, m2=200) ## call method ok (obj.m1(1)) == 100 ok (obj.m2(2)) == 200 ## check results ok (tr[0]) == [obj, 'm1', (1,), {}, 100] ok (tr[1]) == [obj, 'm2', (2,), {}, 200] Example to fake function call:: def f(x): return x*2 ## fake a function def dummy(original_func, x): #return original_func(x) return 'x=%s' % repr(x) from oktest.tracer import Tracer tr = Tracer() f = tr.fake_func(f, dummy) ## call function ok (f(3)) == 'x=3' ## check results ok (tr[0]) == [None, 'f', (3,), {}, 'x=3'] Have a nice weekend! -- regards, makoto kuwata From tjreedy at udel.edu Sat Jan 22 22:39:47 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Sat, 22 Jan 2011 22:39:47 -0500 Subject: [Code Challenge] WxPython versus Tkinter. In-Reply-To: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> Message-ID: On 1/22/2011 7:07 PM, rantingrick wrote: Near the beginning of this thread, I gently challenged you to produce a concrete, practical proposal for an stdlib addition that could be critiqued and improved. When you asked for problems with wxwidgets/wxpython, I gave some. Still waiting. > So PUT UP OR SHUT THE HELL UP! -- Terry Jan Reedy From dirk at pfln.invalid Sun Jan 23 01:15:38 2011 From: dirk at pfln.invalid (Deadly Dirk) Date: Sun, 23 Jan 2011 06:15:38 +0000 (UTC) Subject: Which non SQL Database ? References: Message-ID: On Sat, 04 Dec 2010 16:42:36 -0600, Jorge Biquez wrote: > Hello all. > > Newbie question. Sorry. > > As part of my process to learn python I am working on two personal > applications. Both will do it fine with a simple structure of data > stored in files. I now there are lot of databases around I can use but I > would like to know yoor advice on what other options you would consider > for the job (it is training so no pressure on performance). One > application will run as a desktop one,under Windows, Linux, Macintosh, > being able to update data, not much, not complex, not many records. The > second application, running behind web pages, will do the same, I mean, > process simple data, updating showing data. not much info, not complex. > As an excersice it is more than enough I guess and will let me learn > what I need for now. Talking with a friend about what he will do (he use > C only) he suggest to take a look on dBase format file since it is a > stable format, fast and the index structure will be fine or maybe go > with BD (Berkley) database file format (I hope I understood this one > correctly) . Plain files it is not an option since I would like to have > option to do rapid searches. > > What would do you suggest to take a look? If possible available under > the 3 plattforms. > > Thanks in advance for your comments. > > Jorge Biquez Well, two NoSQL databases that I have some experience with are MongoDB and CouchDB. The choice among them depends on your application. CouchDB is an extremely simple to set up, it is all about the web interface, as a matter of fact it communicates with the outside world using HTTP protocol, returning JSON objects. You can configure it using curl. It is also extremely fast but it doesn't allow you to run ad hoc queries. You have to create something called a "view". This is more akin to what people in the RDBMS world call a "materialized view". Views are created by running JavaScript function on every document in the database. Results are stored in B*Tree index and then modified as documents are being inserted, updated or deleted. It is completely schema free, there are no tables, collections or "shards". The primary language for programming Couch is JavaScript. The same thing applies to MongoDB which is equally fast but does allow ad hoc queries and has quite a few options how to do them. It allows you to do the same kind of querying as RDBMS software, with the exception of joins. No joins. It also allows map/reduce queries using JavaScript and is not completely schema free. Databases have sub-objects called "collections" which can be indexed or partitioned across several machines ("sharding"), which is an excellent thing for building shared-nothing clusters. Collections can be indexed and can be aggregated using JavaScript and Google's map/reduce. Scripting languages like Python are very well supported and linked against MongoDB, which tends to be faster then communicating using HTTP. I find MongoDB well suited for what is traditionally known as data warehousing. Of course, traditional RDBMS specimens like MySQL, PostgreSQL, Firebird, Oracle, MS SQL Server or DB2 still rule supreme and most of the MVC tools like Django or Turbo Gears are made for RDBMS schemas and can read things like the primary or foreign keys and include that into the application. In short, there is no universal answer to your question. If prices are a consideration, Couch, Mongo, MySQL, PostgreSQL, Firebird and SQL Lite 3 all cost about the same: $0. You will have to learn significantly less for starting with a NoSQL database, but if you need to create a serious application fast, RDBMS is still the right answer. You may want to look at this Youtube clip entitled "MongoDB is web scale": http://www.youtube.com/watch?v=b2F-DItXtZs -- I don't think, therefore I am not. From stackslip at gmail.com Sun Jan 23 01:43:04 2011 From: stackslip at gmail.com (Slie) Date: Sat, 22 Jan 2011 21:43:04 -0900 Subject: I'm interested in calculating time down to the femtosecond. Message-ID: <076E4FFD-54FA-4665-9F32-E446731D52C7@gmail.com> I found that there was a code submission at NumPy 1.4 but I can not find in the documentation search for Date nor have found anything other then that discussion of the ability. Anyone have any ideas suggestions? I just want my program to be able to calculate it nothing special. Thanks, From orasnita at gmail.com Sun Jan 23 02:53:25 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Sun, 23 Jan 2011 09:53:25 +0200 Subject: [Code Challenge] WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> Message-ID: From: "rantingrick" > > WxPython versus Tkinter (A code battle to the death!) > > by Rick Johnson. > > I have in many threads declared that Tkinter (and TclTk) is currently > --and has been for a decade-- the wrong choice for Python's stdlib > GUI. Throughout the 90's Tkinter was fine. However we have been in the > 21st century for more than a decade and Tkinter is no longer relevant. > Many people have argued (weakly) that Tkinter is still valid. However > their arguments have been mostly baseless opinions that sadly lack > vision for the future. > > In this thread i intend to slay my enemies with cold hard facts based > on code. It is time to put your code where your mouth is (or you > foot). This will be an open challenge to *anyone* in this community, > in the world, and *even* the great Guido van Rossum himself! It is now > time for you (python community) to prove the worth of Tkinter or > accept its demise at my hands! > > Some of you may think this sounds like an impossible challenge. How > can one man defend his position against the entire world! Yes, it > would seem impossible for one man to face an entire community in open > challenge! And in most cases only a fool would challenge the world. > However, i have not one ounce of fear within me while facing these > odds because my position is the correct position. My position is based > on facts and NOT friendship, truth and NOT tantrums, and finally > vision NOT vengance! I am on the correct side of history! > > It is time to prove once and for all how dated and worthless Tkinter > is compared to wxPython. Yes, WxPython is not as advanced as i would > like it to be for a 21st century GUI library. However compared to > Tkinter, Wx is light years ahead! Wx is our best hope to move Python > into the 21st century. > > So now is the time for all you naysayers, trolls, and minions to face > me in mortal combat within the arena of truth and righteousness. Ready > your minds and wield your text editors for we shall battle for the > glory of Python! And when i have slayed the fools with their own > foolishness then ye all shall be enlightened! > > So PUT UP OR SHUT THE HELL UP! > > > --------------------------------------- > Challenge 1: (Simple Directory Viewer) > --------------------------------------- > > Create a simple Directory Viewer GUI. You CANNOT use a treectrl! The > point of this challenge is to show that Tkinter has no support for a > true ListCtrl widget. However the Wx::ListCtrl is fully featured! For > wxPython the code is simply wielding a few built in classes. For > Tkinter no such ListCtrl functionality exists. You CAN create the > functionality yourself (and i know this because i HAVE created it!) > however it involves tons of work and still can't hold a candle to the > wx::ListCtrl > > --------------- > Requirements: > --------------- > > How the user navigates to a folder is not important but you must > display the list of files/folders in two view modes with icons; > > 1. Display files in both ReportView and ListView. > > * Reportview: > ...scrollable vertical list with three columns. > > * Listview: > ...scrollable horizontal-ly wrapping list. > > Note: If you do not understand the view modes just run my code for an > example. But the user must be able to switch between these two modes > easily. How the switching is done is unimportant -- I simply used two > buttons. > > 2. Columns > * Minimum of three cols; Name, Size, and Type (reportview). > * the "Name" column must include an icon AND label (both views). > * columns must be sortable by the user (reportview). > * columns must be sizable by the user (reportview). > > 3. Items > * All must be editable in place (no popup editing allowed!). > * All items must be selectable/deselectable by user. > * All items must be delete-able by the user. > > That is the challenge. Step forth and battle if you can! > > ----------------- > WxPython code: > ----------------- > > https://sites.google.com/site/thefutureofpython/home/code-challenges I have downloaded that simple program, launched it, and I've tested it with JAWS screen reader. It was fully accessible out of the box. Have you done something special for making it accessible for screen readers? (I guess not). Can be the same thing done with Tkinter? Octavian From stefan_ml at behnel.de Sun Jan 23 05:10:25 2011 From: stefan_ml at behnel.de (Stefan Behnel) Date: Sun, 23 Jan 2011 11:10:25 +0100 Subject: [Code Challenge] WxPython versus Tkinter. In-Reply-To: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> Message-ID: rantingrick, 23.01.2011 01:07: > I have in many threads declared that Tkinter (and TclTk) is currently > --and has been for a decade-- the wrong choice for Python's stdlib > GUI. [...] > It is time to prove once and for all how dated and worthless Tkinter > is compared to wxPython. What's the aim of that prove? If you are trying to pave the ground for getting wxPython in the stdlib instead of tkinter, I think that's bound to fail. Similar proposals have been rejected with the simple argument that adding a large library with a huge C dependency to the standard library without having a rock solid maintainer for both of them is not going to happen. Are you volunteering to maintain both wxPython and wxWidgets in the standard library for, say, twenty years to come? Stefan From rustompmody at gmail.com Sun Jan 23 05:18:34 2011 From: rustompmody at gmail.com (rusi) Date: Sun, 23 Jan 2011 02:18:34 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> Message-ID: On Jan 23, 5:07?am, rantingrick wrote: > WxPython versus Tkinter (A code battle to the death!) > > by Rick Johnson. > > I have in many threads declared that Tkinter (and TclTk) is currently > --and has been for a decade-- the wrong choice for Python's stdlib > GUI. Throughout the 90's Tkinter was fine. However we have been in the > 21st century for more than a decade and Tkinter is no longer relevant. > Many people have argued (weakly) that Tkinter is still valid. However > their arguments have been mostly baseless opinions that sadly lack > vision for the future. > > In this thread i intend to slay my enemies with cold hard facts based > on code. It is time to put your code where your mouth is (or you > foot). This will be an open challenge to *anyone* in this community, > in the world, and *even* the great Guido van Rossum himself! It is now > time for you (python community) to prove the worth of Tkinter or > accept its demise at my hands! > > Some of you may think this sounds like an impossible challenge. How > can one man defend his position against the entire world! Yes, it > would seem impossible for one man to face an entire community in open > challenge! And in most cases only a fool would challenge the world. > However, i have not one ounce of fear within me while facing these > odds because my position is the correct position. My position is based > on facts and NOT friendship, truth and NOT tantrums, and finally > vision NOT vengance! I am on the correct side of history! > > It is time to prove once and for all how dated and worthless Tkinter > is compared to wxPython. Yes, WxPython is not as advanced as i would > like it to be for a 21st century GUI library. However compared to > Tkinter, Wx is light years ahead! Wx is our best hope to move Python > into the 21st century. > > So now is the time for all you naysayers, trolls, and minions to face > me in mortal combat within the arena of truth and righteousness. Ready > your minds and wield your text editors for we shall battle for the > glory of Python! And when i have slayed the fools with their own > foolishness then ye all shall be enlightened! > > So PUT UP OR SHUT THE HELL UP! > > --------------------------------------- > ?Challenge 1: (Simple Directory Viewer) > --------------------------------------- > > Create a simple Directory Viewer GUI. You CANNOT use a treectrl! ?The > point of this challenge is to show that Tkinter has no support for a > true ListCtrl widget. However the Wx::ListCtrl is fully featured! For > wxPython the code is simply wielding a few built in classes. For > Tkinter no such ListCtrl functionality exists. You CAN create the > functionality yourself (and i know this because i HAVE created it!) > however it involves tons of work and still can't hold a candle to the > wx::ListCtrl > > --------------- > ?Requirements: > --------------- > > How the user navigates to a folder is not important but you must > display the list of files/folders in two view modes with icons; > > ?1. Display files in both ReportView and ListView. > > ? * Reportview: > ? ? ...scrollable vertical list with three columns. > > ? * Listview: > ? ? ...scrollable horizontal-ly wrapping list. > > Note: If you do not understand the view modes just run my code for an > example. But the user must be able to switch between these two modes > easily. How the switching is done is unimportant -- I simply used two > buttons. > > ?2. Columns > ? * Minimum of three cols; Name, Size, and Type (reportview). > ? * the "Name" column must include an icon AND label (both views). > ? * columns must be sortable by the user (reportview). > ? * columns must be sizable by the user (reportview). > > ?3. Items > ? * All must be editable in place (no popup editing allowed!). > ? * All items must be selectable/deselectable by user. > ? * All items must be delete-able by the user. > > That is the challenge. Step forth and battle if you can! > > ----------------- > ?WxPython code: > ----------------- > > https://sites.google.com/site/thefutureofpython/home/code-challenges > > I await any challengers... Tried the code with debian sid and default python (2.6) I get (after some loading... statements) Segmentation fault [Actually this is the first time in my 10 years of python that Ive seen a pure python module segfault :-) ] From steve+comp.lang.python at pearwood.info Sun Jan 23 05:30:14 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 23 Jan 2011 10:30:14 GMT Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> Message-ID: <4d3c0336$0$29983$c3e8da3$5496439d@news.astraweb.com> On Sun, 23 Jan 2011 02:18:34 -0800, rusi wrote: >> ?WxPython code: [...] > Tried the code with debian sid and default python (2.6) > > I get (after some loading... statements) > > Segmentation fault > > [Actually this is the first time in my 10 years of python that Ive seen > a pure python module segfault :-) ] wxPython is a front end to the wxWidgets (formerly wxWindows) toolkit, which is C++. I imagine that's what seg faulted. -- Steven From askutt at gmail.com Sun Jan 23 08:35:06 2011 From: askutt at gmail.com (Adam Skutt) Date: Sun, 23 Jan 2011 05:35:06 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> Message-ID: <480571f5-5731-4f8b-9cb4-1468478711bf@c39g2000yqi.googlegroups.com> On Jan 22, 7:07?pm, rantingrick wrote: > So PUT UP OR SHUT THE HELL UP! You first. Write actual working code first and then you can challenge people. I found 5 bugs in your code before I quit looking[1]. Can you find and fix them all? Also, I'm entirely ignoring the bad styling, bad default sizing, horrible UI, the fact you call rename "Edit", and the fact the context menu doesn't do anything. All of the are legitimate technical errors, i.e., you coded the program wrong. In the spirit of community I open the bug finding to everyone, but humbly ask you don't tell Mr. "rantingrick" Johnson about them. It can be our little secret ;) Adam [1] I think there might even be more, but I got lazy. From roy at panix.com Sun Jan 23 11:12:35 2011 From: roy at panix.com (Roy Smith) Date: Sun, 23 Jan 2011 11:12:35 -0500 Subject: Which non SQL Database ? References: Message-ID: In article , Deadly Dirk wrote: > The same thing applies to MongoDB which is equally fast but does allow ad > hoc queries and has quite a few options how to do them. It allows you to > do the same kind of querying as RDBMS software, with the exception of > joins. No joins. Well, sort of. You can use forEach() to get some join-like functionality. You don't get the full join optimization that SQL gives you, but at least you get to do some processing on the server side so you don't have to ship 40 gazillion records over the network to pick the three you wanted. > It also allows map/reduce queries using JavaScript and > is not completely schema free. What do you mean by "not completely schema free"? > Databases have sub-objects called "collections" which can be indexed > or partitioned across several machines ("sharding"), which is an > excellent thing for building shared-nothing clusters. We've been running Mongo 1.6.x for a few months. Based on our experiences, I'd say sharding is definitely not ready for prime time. There's two issues; stability and architecture. First, stability. We see mongos (the sharding proxy) crash a couple of times a week. We finally got the site stabilized by rigging upstart to monitor and automatically restart mongos when it crashes. Fortunately, mongos crashing doesn't cause any data loss (at least not that we've noticed). Hopefully this is something the 10gen folks will sort out in the 1.8 release. The architectural issues are more complex. Mongo can enforce uniqueness on a field, but only on non-sharded collection. Security (i.e. password authentication) does not work in a sharded environment. If I understand the release notes correctly, that's something which may get fixed in some future release. > Scripting languages like Python are > very well supported and linked against MongoDB The Python interface is very nice. In some ways, the JS interface is nicer, only because you can get away with less quoting, i.e. JS: find({inquisition: {$ne: 'spanish'}} Py: find({'inquisition': {'$ne': 'spanish'}} The PHP interface is (like everything in PHP), sucky: PHP: find(array('inquisition' => array('$ne' => 'spanish')) The common thread here is that unlike SQL, you're not feeding the database a string which it parses, you're feeding it a data structure. You're stuck with whatever data structure syntax the host language supports. Well, actually, that's not true. If you wanted to, you could write a front end which lets you execute: "find where inquisition != spanish" and have code to parse that and turn it into the required data structure. The odds of anybody doing that are pretty low, however. It would just feel wrong. In much the same way that SQLAlchemy's functional approach to building a SQL query just feels wrong to somebody who knows SQL. > I find MongoDB well suited for what is > traditionally known as data warehousing. I'll go along with that. It's a way to build a fast (possibly distributed, if they get sharding to work right) network datastore with some basic query capability. Compared to SQL, you end up doing a lot more work on the application side, and take on a lot more of the responsibility to enforce data integrity yourself. > You may want to look > at this Youtube clip entitled "MongoDB is web scale": > > http://www.youtube.com/watch?v=b2F-DItXtZs That's the funniest thing I've seen in a long time. The only sad part is that it's all true. There are some nice things to NO-SQL databases (particularly the schema-free part). A while ago, we discovered that about 200 of the 300,000 documents in one of our collections were effectively duplicates of other documents ("document" in mongo-speak means "record" or perhaps "row" in SQL-speak). It was trivial to add "is_dup_of" fields to just those 200 records, and a little bit of code in our application to check the retrieved documents for that field and retrieve the pointed-to document. In SQL, that would have meant adding another column, or perhaps another table. Either way would have been far more painful than the fix we were able to do in mongo. From rantingrick at gmail.com Sun Jan 23 11:57:50 2011 From: rantingrick at gmail.com (rantingrick) Date: Sun, 23 Jan 2011 08:57:50 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> Message-ID: On Jan 22, 9:39?pm, Terry Reedy wrote: > On 1/22/2011 7:07 PM, rantingrick wrote: > > Near the beginning of this thread, I gently challenged you to produce a > concrete, practical proposal for an stdlib addition that could be > critiqued and improved. When you asked for problems with > wxwidgets/wxpython, I gave some. Still waiting. You may have done this however i do not remember. With all the trolling that was going on (not you) i may have missed it. From rantingrick at gmail.com Sun Jan 23 11:59:59 2011 From: rantingrick at gmail.com (rantingrick) Date: Sun, 23 Jan 2011 08:59:59 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> Message-ID: <8e180134-c19b-4762-ae08-d78ed9034f29@j32g2000yqc.googlegroups.com> On Jan 23, 1:53?am, "Octavian Rasnita" wrote: > I have downloaded that simple program, launched it, and I've tested it with JAWS screen reader. > It was fully accessible out of the box. Excellent! > Have you done something special for making it accessible for screen readers? (I guess not). I did nothing to make the code more accessible, that is just another great attribute of 21st cenury GUI libraries. > Can be the same thing done with Tkinter? Not that i am aware of. From arndt.roger at addcom.de Sun Jan 23 12:06:57 2011 From: arndt.roger at addcom.de (Arndt Roger Schneider) Date: Sun, 23 Jan 2011 18:06:57 +0100 Subject: [Code Challenge] WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> Message-ID: rantingrick schrieb: [snip] 1. You cannot define the terms--restrict your opponent-- and battle it yourselves. 2. Your specified directory browser is useless. --At least define that the directory browser must have constant complexity to work with volatile data over a network... -roger From rantingrick at gmail.com Sun Jan 23 12:09:56 2011 From: rantingrick at gmail.com (rantingrick) Date: Sun, 23 Jan 2011 09:09:56 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> Message-ID: <033c3f90-03fb-4f65-bbae-bbc80a262685@l22g2000vbp.googlegroups.com> On Jan 23, 4:18?am, rusi wrote: > On Jan 23, 5:07?am, rantingrick wrote: > > > > > > > > > > > WxPython versus Tkinter (A code battle to the death!) > > > by Rick Johnson. > > > I have in many threads declared that Tkinter (and TclTk) is currently > > --and has been for a decade-- the wrong choice for Python's stdlib > > GUI. Throughout the 90's Tkinter was fine. However we have been in the > > 21st century for more than a decade and Tkinter is no longer relevant. > > Many people have argued (weakly) that Tkinter is still valid. However > > their arguments have been mostly baseless opinions that sadly lack > > vision for the future. > > > In this thread i intend to slay my enemies with cold hard facts based > > on code. It is time to put your code where your mouth is (or you > > foot). This will be an open challenge to *anyone* in this community, > > in the world, and *even* the great Guido van Rossum himself! It is now > > time for you (python community) to prove the worth of Tkinter or > > accept its demise at my hands! > > > Some of you may think this sounds like an impossible challenge. How > > can one man defend his position against the entire world! Yes, it > > would seem impossible for one man to face an entire community in open > > challenge! And in most cases only a fool would challenge the world. > > However, i have not one ounce of fear within me while facing these > > odds because my position is the correct position. My position is based > > on facts and NOT friendship, truth and NOT tantrums, and finally > > vision NOT vengance! I am on the correct side of history! > > > It is time to prove once and for all how dated and worthless Tkinter > > is compared to wxPython. Yes, WxPython is not as advanced as i would > > like it to be for a 21st century GUI library. However compared to > > Tkinter, Wx is light years ahead! Wx is our best hope to move Python > > into the 21st century. > > > So now is the time for all you naysayers, trolls, and minions to face > > me in mortal combat within the arena of truth and righteousness. Ready > > your minds and wield your text editors for we shall battle for the > > glory of Python! And when i have slayed the fools with their own > > foolishness then ye all shall be enlightened! > > > So PUT UP OR SHUT THE HELL UP! > > > --------------------------------------- > > ?Challenge 1: (Simple Directory Viewer) > > --------------------------------------- > > > Create a simple Directory Viewer GUI. You CANNOT use a treectrl! ?The > > point of this challenge is to show that Tkinter has no support for a > > true ListCtrl widget. However the Wx::ListCtrl is fully featured! For > > wxPython the code is simply wielding a few built in classes. For > > Tkinter no such ListCtrl functionality exists. You CAN create the > > functionality yourself (and i know this because i HAVE created it!) > > however it involves tons of work and still can't hold a candle to the > > wx::ListCtrl > > > --------------- > > ?Requirements: > > --------------- > > > How the user navigates to a folder is not important but you must > > display the list of files/folders in two view modes with icons; > > > ?1. Display files in both ReportView and ListView. > > > ? * Reportview: > > ? ? ...scrollable vertical list with three columns. > > > ? * Listview: > > ? ? ...scrollable horizontal-ly wrapping list. > > > Note: If you do not understand the view modes just run my code for an > > example. But the user must be able to switch between these two modes > > easily. How the switching is done is unimportant -- I simply used two > > buttons. > > > ?2. Columns > > ? * Minimum of three cols; Name, Size, and Type (reportview). > > ? * the "Name" column must include an icon AND label (both views). > > ? * columns must be sortable by the user (reportview). > > ? * columns must be sizable by the user (reportview). > > > ?3. Items > > ? * All must be editable in place (no popup editing allowed!). > > ? * All items must be selectable/deselectable by user. > > ? * All items must be delete-able by the user. > > > That is the challenge. Step forth and battle if you can! > > > ----------------- > > ?WxPython code: > > ----------------- > > >https://sites.google.com/site/thefutureofpython/home/code-challenges > > > I await any challengers... > > Tried the code with debian sid and default python (2.6) > > I get (after some loading... statements) > > Segmentation fault > > [Actually this is the first time in my 10 years of python that Ive > seen a pure python module segfault :-) ] Congratulations genius! However if you are really smart you would have read the note in the source that says "tested on windows only!". Segfault. Thanks for the laugh! From rantingrick at gmail.com Sun Jan 23 12:21:27 2011 From: rantingrick at gmail.com (rantingrick) Date: Sun, 23 Jan 2011 09:21:27 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <480571f5-5731-4f8b-9cb4-1468478711bf@c39g2000yqi.googlegroups.com> Message-ID: <2c951199-3dba-4d24-a5c2-f84081688f7e@u6g2000yqk.googlegroups.com> On Jan 23, 7:35?am, Adam Skutt wrote: > On Jan 22, 7:07?pm, rantingrick wrote: > You first. ?Write actual working code first and then you can challenge > people. The code does work. You just lack the skill to run it. > I found 5 bugs in your code before I quit looking[1]. What are these "so-called" bugs exactly? Remember this code is not meant to WOW anyone. It is a challenge to anybody who can reproduce the same functionality in Tkinter. The main point is to create a ListCtrl that has two view modes, icons, and editable items. You lack simple reading and comprehension skills Adam. > Can you > find and fix them all? ?Also, I'm entirely ignoring the bad styling, This is not a challenge about code styling. > bad default sizing, This is not a challenge about pretty GUIs. > horrible UI, the fact you call rename "Edit", pedantic troll! > and > the fact the context menu doesn't do anything. THIS IS A SIMPLE EXAMPLE FILE VIEWER. We don't to actually rename and delete files you moron. Get a life. Adam you were one of the biggest trolls in the "other" thread. We don't need you trolling up this one too. Can you write any code? I have produced code and no one has offered a rebuttal using the Tkinter module. This is because only a handful of the entire community has the skills to create something like this with Tkinter. I am one of them, Kevin is another, Guido is another, and there are a very few more. HOWEVER YOU ARE NOT IN THIS GROUP ADAM. You are a troll, and that is all you can do. Prove me wrong if you can... From rantingrick at gmail.com Sun Jan 23 12:21:57 2011 From: rantingrick at gmail.com (rantingrick) Date: Sun, 23 Jan 2011 09:21:57 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> Message-ID: <1a1b0e40-ac98-4234-a95d-80ed05de4e72@s5g2000yqm.googlegroups.com> On Jan 23, 4:10?am, Stefan Behnel wrote: > rantingrick, 23.01.2011 01:07: > > > I have in many threads declared that Tkinter (and TclTk) is currently > > --and has been for a decade-- the wrong choice for Python's stdlib > > GUI. ?[...] > > It is time to prove once and for all how dated and worthless Tkinter > > is compared to wxPython. > > What's the aim of that prove? If you are trying to pave the ground for > getting wxPython in the stdlib instead of tkinter, I think that's bound to > fail. Similar proposals have been rejected with the simple argument that > adding a large library with a huge C dependency to the standard library > without having a rock solid maintainer for both of them is not going to happen. Wait a minute, i am confused? What language is Python written in? Oh thats right Lisp! I am so dumb. How did i even get this job? :-) > Are you volunteering to maintain both wxPython and wxWidgets in the > standard library for, say, twenty years to come? WxPython needs lots of proper documentation aimed at beginners (so does Tkinter!). WxPython also needs a better API (however only VERY sightly!!). These are some areas where i can be very helpful. From rantingrick at gmail.com Sun Jan 23 12:23:35 2011 From: rantingrick at gmail.com (rantingrick) Date: Sun, 23 Jan 2011 09:23:35 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> Message-ID: On Jan 23, 11:06?am, Arndt Roger Schneider wrote: > rantingrick schrieb: > > [snip] > > 1. You cannot define the terms--restrict your opponent-- > ? ? and battle it yourselves. > 2. Your specified directory browser is useless. > ? ? --At least define that the directory browser must have > ? ? ? constant complexity to work with volatile > ? ? ? data over a network... > > -roger Get a life moron and post some code, if you can! From rantingrick at gmail.com Sun Jan 23 12:31:25 2011 From: rantingrick at gmail.com (rantingrick) Date: Sun, 23 Jan 2011 09:31:25 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> Message-ID: On Jan 22, 6:07?pm, rantingrick wrote: > I await any challengers... So far only trolls (besides Terry, Octavian, D'Aprano) have replied. In my time here within the Python community i have only met one person who shares my in-depth knowledge of Tkinter. That person is Kevin Waltzer. So outside of Python-dev and Guido. Kevin and I are are the ONLY people qualified to offer opinions on the worth or worthlessness of Tkinter. If anyone in this entire community thinks that they also are qualified then prove your worth by creating a ListCtrl in Tkinter that mirrors the wxPython ListCtrl in functionality. When you have done that, i will elevate you to my circle of enlightenment. Than and only then shall i even entertain you BS. Until then, anyone who tries to devalue my argument is just an ignorant troll. From invalid at invalid.invalid Sun Jan 23 12:33:09 2011 From: invalid at invalid.invalid (Grant Edwards) Date: Sun, 23 Jan 2011 17:33:09 +0000 (UTC) Subject: Need GUI pop-up to edit a (unicode ?) string References: <3tqr08-bj2.ln1@murmur.very.softly> Message-ID: On 2011-01-22, Corey Richardson wrote: > If that is all you need, I suggest Tkinter. Nice and easy, comes built > into Python. In some Linux distros, that is. Not in all of them. -- Grant From steve+comp.lang.python at pearwood.info Sun Jan 23 12:43:49 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 23 Jan 2011 17:43:49 GMT Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> Message-ID: <4d3c68d5$0$29983$c3e8da3$5496439d@news.astraweb.com> On Sun, 23 Jan 2011 09:31:25 -0800, rantingrick wrote: > So far only trolls (besides Terry, Octavian, D'Aprano) have replied. So apart from the non-trolls, only trolls have replied? -- Steven From kb1pkl at aim.com Sun Jan 23 12:54:41 2011 From: kb1pkl at aim.com (Corey Richardson) Date: Sun, 23 Jan 2011 12:54:41 -0500 Subject: WxPython versus Tkinter. In-Reply-To: References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> Message-ID: <4D3C6B61.2000807@aim.com> On 01/23/2011 05:18 AM, rusi wrote: > > Tried the code with debian sid and default python (2.6) > > I get (after some loading... statements) > > Segmentation fault > > [Actually this is the first time in my 10 years of python that Ive > seen a pure python module segfault :-) ] I also have a segfault. You should fix that, rantingrick :) From steve+comp.lang.python at pearwood.info Sun Jan 23 13:07:37 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 23 Jan 2011 18:07:37 GMT Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <1a1b0e40-ac98-4234-a95d-80ed05de4e72@s5g2000yqm.googlegroups.com> Message-ID: <4d3c6e69$0$29983$c3e8da3$5496439d@news.astraweb.com> On Sun, 23 Jan 2011 09:21:57 -0800, rantingrick wrote: > Wait a minute, i am confused? What language is Python written in? Oh > thats right Lisp! I am so dumb. How did i even get this job? :-) Python is written in C, Java, C#, Javascript, Haskell, Ocaml, and, yes, even Lisp. There's even a Python interpreter written in Python. Admittedly, the Ocaml implementation seems to be abandoned, and some of the others are more experimental, but they're all Python. -- Steven From askutt at gmail.com Sun Jan 23 13:09:47 2011 From: askutt at gmail.com (Adam Skutt) Date: Sun, 23 Jan 2011 10:09:47 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <480571f5-5731-4f8b-9cb4-1468478711bf@c39g2000yqi.googlegroups.com> <2c951199-3dba-4d24-a5c2-f84081688f7e@u6g2000yqk.googlegroups.com> Message-ID: <3e603997-5539-4660-bd83-7398bdab34a4@k30g2000vbn.googlegroups.com> On Jan 23, 12:21?pm, rantingrick wrote: > The code does work. You just lack the skill to run it. I not only possess the skill to run it, but to find fault it in through simple inspection. All of the bugs I found, but one, I found through reading the .py file. Heck, I'm so good that I guessed two of the bugs before I downloaded the code because both are rank amateur mistakes, and I'm not convinced you even rise to the level of amateur. > > What are these "so-called" bugs exactly? 1. There's a bug related to loading of your resources. 2. There's a bug related to when file I/O is performed. 3/4. There's at least two bugs related to handling of a specific mouse event. 5. There's a bug related to reporting errors to the user. All of these bugs, except one[1], show a grave misunderstanding about how GUI toolkits operate and/or how the underlying operating systems behave. >Remember this code is not meant to WOW anyone. That's apparent from simple inspection of the code! Not only does it not wow, it doesn't even illustrate your own example to a degree that could be reasonably considered competent. It demonstrates you didn't even test the functionality you provided in your own code, or that if you did, you're entirely clueless about GUI design fundamentals. > The main point is to create a > ListCtrl that has two view modes, icons, and editable items. You lack > simple reading and comprehension skills Adam. And your code will not do that in a whole host of common situations that a GUI application is reasonably expected to handle. It is not sufficiently robust to be interesting. > Adam you were one of the biggest trolls in the "other" thread. We > don't need you trolling up this one too. Can you write any code? I > have produced code and no one has offered a rebuttal using the Tkinter > module. This is because only a handful of the entire community has the > skills to create something like this with Tkinter. No, it's because your code is complete and utter shite and there's zero point in attempting to replicate it. Your code does not work, even if you think it does. I'm not the only person who's noted this. > HOWEVER YOU ARE NOT IN THIS GROUP ADAM. You are a troll, and that is > all you can do. Prove me wrong if you can... I already have. Confirmation of some of the bugs I've noted exists in this very thread. Thus, I'm quite capable of reading and comprehending Python code. The same remains to be seen with you. Adam [1] Which is only because wxWidgets has a bug in this regard. That being said, a workaround exists and trivial to find online. From tyler at tysdomain.com Sun Jan 23 13:30:51 2011 From: tyler at tysdomain.com (Littlefield, Tyler) Date: Sun, 23 Jan 2011 11:30:51 -0700 Subject: WxPython versus Tkinter. Message-ID: <4D3C73DB.5090608@tysdomain.com> >I also have a segfault. You should fix that, rantingrick It's clear that the mighty text editor he's wielding in his arena of champions while taking on the world all by himself does not come with a debugger, or even the ability to run the code. Might I suggest throwing your current weapon of mass destruction away and finding another? It's clearly lacking in some key features. -- Thanks, Ty From scottybmeup at earthlink.net Sun Jan 23 13:41:02 2011 From: scottybmeup at earthlink.net (Scott Meup) Date: Sun, 23 Jan 2011 11:41:02 -0700 Subject: documentation / reference help Message-ID: I'm trying tolearn Python. The documentation tells syntax, and other things about a command. But for too many commands, it doesn't tell what it does. for instance, in VB the 'return' command tells the program what line to execute after some event (usually an error). In Python it appears to return a value. Where does it return it to? I couldn't find anywhere on the Python website to find out or to ask Python to upgrade their documentation. Can somebody please recommend a source. From rantingrick at gmail.com Sun Jan 23 14:07:11 2011 From: rantingrick at gmail.com (rantingrick) Date: Sun, 23 Jan 2011 11:07:11 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <480571f5-5731-4f8b-9cb4-1468478711bf@c39g2000yqi.googlegroups.com> <2c951199-3dba-4d24-a5c2-f84081688f7e@u6g2000yqk.googlegroups.com> <3e603997-5539-4660-bd83-7398bdab34a4@k30g2000vbn.googlegroups.com> Message-ID: On Jan 23, 12:09?pm, Adam Skutt wrote: > On Jan 23, 12:21?pm, rantingrick wrote: > > What are these "so-called" bugs exactly? > > 1. There's a bug related to loading of your resources. > 2. There's a bug related to when file I/O is performed. > 3/4. There's at least two bugs related to handling of a specific mouse > event. > 5. There's a bug related to reporting errors to the user. Well then post a traceback. However you still miss the point. You will do anything to distract from the point. And what IS that point? Well that Tkinter is lackluster 20 years old rotware and you need to resort to these BS tactics to discredit me because 1). You cannot even create a Tkinter GUI at the basic level, and 2) you have no real argument based on facts! Post CODE Adam. Code! Surely you can handle copy/pasting a traceback i hope! From tyler at tysdomain.com Sun Jan 23 14:38:35 2011 From: tyler at tysdomain.com (Littlefield, Tyler) Date: Sun, 23 Jan 2011 12:38:35 -0700 Subject: documentation / reference help In-Reply-To: References: Message-ID: <4D3C83BB.8050701@tysdomain.com> The return value simply returns a value to the calling function, which the function can handle, however it wants. so: for example def add(a, b): return (a+b) That simply returns the value a+b, which you can use however you like, like so: i=add(2,3) will assign the return value to add. I recommend you check out the tutorial on python.org, which explains all of this; the documentation does not need updating, at least not in that respect. On 1/23/2011 11:41 AM, Scott Meup wrote: > I'm trying tolearn Python. The documentation tells syntax, and other things > about a command. But for too many commands, it doesn't tell what it does. > for instance, in VB the 'return' command tells the program what line to > execute after some event (usually an error). In Python it appears to return > a value. Where does it return it to? I couldn't find anywhere on the > Python website to find out or to ask Python to upgrade their documentation. > Can somebody please recommend a source. > > -- Thanks, Ty From askutt at gmail.com Sun Jan 23 14:42:24 2011 From: askutt at gmail.com (Adam Skutt) Date: Sun, 23 Jan 2011 11:42:24 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <480571f5-5731-4f8b-9cb4-1468478711bf@c39g2000yqi.googlegroups.com> <2c951199-3dba-4d24-a5c2-f84081688f7e@u6g2000yqk.googlegroups.com> <3e603997-5539-4660-bd83-7398bdab34a4@k30g2000vbn.googlegroups.com> Message-ID: <5edded76-fdac-4eb5-8480-25e3381e2fd4@g26g2000vbz.googlegroups.com> On Jan 23, 2:07?pm, rantingrick wrote: > Well then post a traceback. None of these issues will supply a traceback; in fact, in some of these cases, you went out of your way to ensure that would not happen. That's an additional bug (or 5 additional bugs depending how mean your tester/QA staff are). > ?However you still miss the point. You will do anything to distract > from the point. And what IS that point? Well that Tkinter is > lackluster 20 years old rotware The fact it doesn't provide a control found almost exclusively in file browsers and open/save dialogs does not mean that it is "20 years old rotware". > and you need to resort to these BS tactics to discredit me because 1). You cannot even create a Tkinter > GUI at the basic level, I certainly can, but there's no point in demonstrating my skill when you cannot create a wxWidgets GUI at a basic level. You made the challenge, you intentionally styled it as "rantingrick v. the world", so you need to actually bring something challenge worthy to the table first. That includes picking a challenge that's interesting and not over a relatively minor widget in the grand scheme of things. Qt, Swing, Gtk, and Win32 common controls[1] don't provide the same exact control either, should we view it as deficient? But regardless of the challenge, I don't think you're capable of posting a worthwhile example, which is why you dismiss all the problems found with it instead of actually fixing the code. > Post CODE Adam. Code! Surely you can handle copy/pasting a traceback i > hope! I certainly can. I don't have much hope for you writing code that provides tracebacks, much less actually useful ones. Adam [1] Hell, I'm not sure /any/ toolkit provides the whole of wxListCtrl functionality OOB, besides wxWidgets itself. Like I said, it's specific functionality isn't well suited. From emile at fenx.com Sun Jan 23 14:48:59 2011 From: emile at fenx.com (Emile van Sebille) Date: Sun, 23 Jan 2011 11:48:59 -0800 Subject: documentation / reference help In-Reply-To: References: Message-ID: On 1/23/2011 10:41 AM Scott Meup said... > I'm trying tolearn Python. The documentation tells syntax, and other things > about a command. But for too many commands, it doesn't tell what it does. > for instance, in VB the 'return' command tells the program what line to > execute after some event (usually an error). In Python it appears to return > a value. Where does it return it to? I couldn't find anywhere on the > Python website to find out or to ask Python to upgrade their documentation. > Can somebody please recommend a source. > > If you've had any programming experience or can otherwise make sense of it, start with the tutorial at http://docs.python.org/tutorial/ otherwise there're good resource links at http://wiki.python.org/moin/BeginnersGuide to get you started. Emile From cmpython at gmail.com Sun Jan 23 14:52:13 2011 From: cmpython at gmail.com (CM) Date: Sun, 23 Jan 2011 11:52:13 -0800 (PST) Subject: documentation / reference help References: Message-ID: <77562432-5369-45ec-b572-79adb93c818a@f20g2000vbc.googlegroups.com> On Jan 23, 2:38?pm, "Littlefield, Tyler" wrote: > The return value simply returns a value to the calling function, which > the function can handle, however it wants. so: for example > def add(a, b): > ? ?return (a+b) > > That simply returns the value a+b, which you can use however you like, > like so: i=add(2,3) will assign the return value to add. And return doesn't have to return a value(s). It can just cause the program's execution to not proceed further but to go back to the calling function, like: def checkAplusB(a, b): if a + b > 5: return > > I recommend you check out the tutorial on python.org, which explains all > of this; the documentation does not need updating, at least not in that > respect. > On 1/23/2011 11:41 AM, Scott Meup wrote: > > > I'm trying tolearn Python. ?The documentation tells syntax, and other things > > about a command. ?But for too many commands, it doesn't tell what it does. > > for instance, in VB the 'return' command tells the program what line to > > execute after some event (usually an error). In Python it appears to return > > a value. ?Where does it return it to? ?I couldn't find anywhere on the > > Python website to find out or to ask Python to upgrade their documentation. > > Can somebody please recommend a source. > > -- > > Thanks, > Ty From clp2 at rebertia.com Sun Jan 23 15:18:35 2011 From: clp2 at rebertia.com (Chris Rebert) Date: Sun, 23 Jan 2011 12:18:35 -0800 Subject: documentation / reference help In-Reply-To: <77562432-5369-45ec-b572-79adb93c818a@f20g2000vbc.googlegroups.com> References: <77562432-5369-45ec-b572-79adb93c818a@f20g2000vbc.googlegroups.com> Message-ID: On Sun, Jan 23, 2011 at 11:52 AM, CM wrote: > On Jan 23, 2:38?pm, "Littlefield, Tyler" wrote: >> The return value simply returns a value to the calling function, which >> the function can handle, however it wants. so: for example >> def add(a, b): >> ? ?return (a+b) >> >> That simply returns the value a+b, which you can use however you like, >> like so: i=add(2,3) will assign the return value to add. > > And return doesn't have to return a value(s). Pedantic nitpick: Technically it does; you're just not required to always explicitly provide one. Python uses None if you don't specify anything (i.e. a bare `return` === `return None`). By definition, every function returns *some* value. Cheers, Chris -- http://blog.rebertia.com From nagle at animats.com Sun Jan 23 15:19:38 2011 From: nagle at animats.com (John Nagle) Date: Sun, 23 Jan 2011 12:19:38 -0800 Subject: Which non SQL Database ? In-Reply-To: References: Message-ID: <4d3c8d53$0$44021$742ec2ed@news.sonic.net> On 1/22/2011 10:15 PM, Deadly Dirk wrote: > On Sat, 04 Dec 2010 16:42:36 -0600, Jorge Biquez wrote: > >> Hello all. >> >> Newbie question. Sorry. >> >> As part of my process to learn python I am working on two personal >> applications. Both will do it fine with a simple structure of data >> stored in files. I now there are lot of databases around I can use but I >> would like to know yoor advice on what other options you would consider >> for the job (it is training so no pressure on performance). For something like that, I'd suggest just using SQLite. It comes with the Python distribution, it's well documented, and reasonably easy to use. The "NoSQL" stuff is mostly for people doing really big databases for large web sites. The kind of operations where you have multiple data centers, thousands of rackmount servers, a huge traffic load, and smart people thinking about the implications of "eventually consistent". Google's BigTable and Facebook's Cassandra offer impressive performance at very large scale. But they're way overkill for a desktop app. Even the midrange systems, like CouchDB, are far too much machinery for a desktop app. John Nagle From rantingrick at gmail.com Sun Jan 23 15:23:13 2011 From: rantingrick at gmail.com (rantingrick) Date: Sun, 23 Jan 2011 12:23:13 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <480571f5-5731-4f8b-9cb4-1468478711bf@c39g2000yqi.googlegroups.com> <2c951199-3dba-4d24-a5c2-f84081688f7e@u6g2000yqk.googlegroups.com> <3e603997-5539-4660-bd83-7398bdab34a4@k30g2000vbn.googlegroups.com> <5edded76-fdac-4eb5-8480-25e3381e2fd4@g26g2000vbz.googlegroups.com> Message-ID: <1d7fdb0c-9f82-45ab-bf0e-99d210042f0d@j21g2000vbn.googlegroups.com> On Jan 23, 1:42?pm, Adam Skutt wrote: > On Jan 23, 2:07?pm, rantingrick wrote: > > > Well then post a traceback. > > None of these issues will supply a traceback; in fact, in some of > these cases, you went out of your way to ensure that would not > happen. ? psst: thats because they are FEATURES and NOT BUGS you idiot! I am not trying to create a working file browser so you can steal my code. No. I am displaying one use case for a very useful widget. I repeat, i am not going to code up a free file browser for you Adam. Get a life! > > ?However you still miss the point. You will do anything to distract > > from the point. And what IS that point? Well that Tkinter is > > lackluster 20 years old rotware > > The fact it doesn't provide a control found almost exclusively in file > browsers and open/save dialogs does not mean that it is "20 years old > rotware". A ListCtrl is useful for many, many purposes. Just one of them happens to be a file browser. Your statement comes as no great surprise to us because we all know how you severely lack any kind of vision or abstract reasoning abilities. > > and you need to resort to these BS tactics to discredit me because 1). You cannot even create a Tkinter > > GUI at the basic level, > > I certainly can, but there's no point in demonstrating my skill when > you cannot create a wxWidgets GUI at a basic level. BS. You're scared, You're under qualified. And it shows. BIGTIME! > ?You made the > challenge, you intentionally styled it as "rantingrick v. the world", > so you need to actually bring something challenge worthy to the table > first. Where is the world Adam? I am the only one who has summited code. > That includes picking a challenge that's interesting and not over a > relatively minor widget in the grand scheme of things. ListCtrl's are very useful. And i have many more challenges coming. WxPython outshines all the competition by leaps and bounds. The ListCtrl is just the beginning. > ?Qt, Swing, > Gtk, and Win32 common controls[1] don't provide the same exact control > either, should we view it as deficient? Yes. > But regardless of the challenge, You keep trying to divert attention from the point. Sorry but you're not going to fool anyone with this foolishness. > I don't think you're capable of > posting a worthwhile example, which is why you dismiss all the > problems found with it instead of actually fixing the code. Ditto! But at least i have some code to work with. Something to create a fact based argument from. You have nothing but your own foolishness to build from. > > Post CODE Adam. Code! Surely you can handle copy/pasting a traceback i > > hope! > > I certainly can. ?I don't have much hope for you writing code that > provides tracebacks, much less actually useful ones. I suppose you gauge the quality of code by how many tracebacks are printed. And it seems even more perverse that you expect code to spit exceptions! And when code fails to spit exceptions you get angry about it and claim the programmer is insufficient. Hmm, this would explain why you have yet to provide us with working (or even semi-working) code. Adam you are by far the most foolish person i have ever met. From cmpython at gmail.com Sun Jan 23 16:05:12 2011 From: cmpython at gmail.com (CM) Date: Sun, 23 Jan 2011 13:05:12 -0800 (PST) Subject: A and B but not C in list Message-ID: <8cae2caf-d3df-4ed3-9afb-29de97772298@m13g2000yqb.googlegroups.com> In Python, is there a recommended way to write conditionals of the form: "if A and B but not C or D in my list, do something." ? I may also have variations on this, like "if A but not B, C, or D". Do I have to just write out all the if and elifs with all possible conditions, or is there a handier and more code-maintainable way to deal with this? Thanks. From tyler at tysdomain.com Sun Jan 23 16:11:29 2011 From: tyler at tysdomain.com (Littlefield, Tyler) Date: Sun, 23 Jan 2011 14:11:29 -0700 Subject: WxPython versus Tkinter. In-Reply-To: <1d7fdb0c-9f82-45ab-bf0e-99d210042f0d@j21g2000vbn.googlegroups.com> References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <480571f5-5731-4f8b-9cb4-1468478711bf@c39g2000yqi.googlegroups.com> <2c951199-3dba-4d24-a5c2-f84081688f7e@u6g2000yqk.googlegroups.com> <3e603997-5539-4660-bd83-7398bdab34a4@k30g2000vbn.googlegroups.com> <5edded76-fdac-4eb5-8480-25e3381e2fd4@g26g2000vbz.googlegroups.com> <1d7fdb0c-9f82-45ab-bf0e-99d210042f0d@j21g2000vbn.googlegroups.com> Message-ID: <4D3C9981.8020107@tysdomain.com> RR, I have not seen anything useful from you thus far, except: 1) "you disagree with me, troll you must be," "2) who cares if my programs have bugs and don't compile cross-platform, defective code is code, none the less. 3) And a lot of unfounded arrogance in stating that no one understands Tkinter quite like yourself and a select handful of people. I hardly think that your tone, attitude and arguments are going to help you in your battle to prove that WXPython is superior to anything at all, if you can't manage to provide cross-platform bug-free code. No, no one else has yet provided code in this thread from what I have seen, since that's the point you keep making time and time again in numerous messages that keep cluttering my inbox, but no one really has to. You are making an argument with a lot of anger and faulty code, which is supposed to prove that the library, in which you can't write an application that is bug free (or as bug free as any program can be) and also maintain the cross-platform goal, which is a huge part of Python currently, is superior to another that you are screaming and throwing tantrums over. So I await your response, though my psychic powers tells me the response will be one of silence, "stfu, you're just a troll," or "where's the code, I'm not going to produce bug-free code so you can rip off -my- top security amazing file browser," since such things don't already exist anyway. On 1/23/2011 1:23 PM, rantingrick wrote: > On Jan 23, 1:42 pm, Adam Skutt wrote: >> On Jan 23, 2:07 pm, rantingrick wrote: >> >>> Well then post a traceback. >> None of these issues will supply a traceback; in fact, in some of >> these cases, you went out of your way to ensure that would not >> happen. > psst: thats because they are FEATURES and NOT BUGS you idiot! I am not > trying to create a working file browser so you can steal my code. No. > I am displaying one use case for a very useful widget. I repeat, i am > not going to code up a free file browser for you Adam. Get a life! > >>> However you still miss the point. You will do anything to distract >>> from the point. And what IS that point? Well that Tkinter is >>> lackluster 20 years old rotware >> The fact it doesn't provide a control found almost exclusively in file >> browsers and open/save dialogs does not mean that it is "20 years old >> rotware". > A ListCtrl is useful for many, many purposes. Just one of them happens > to be a file browser. Your statement comes as no great surprise to us > because we all know how you severely lack any kind of vision or > abstract reasoning abilities. > >>> and you need to resort to these BS tactics to discredit me because 1). You cannot even create a Tkinter >>> GUI at the basic level, >> I certainly can, but there's no point in demonstrating my skill when >> you cannot create a wxWidgets GUI at a basic level. > BS. You're scared, You're under qualified. And it shows. BIGTIME! > >> You made the >> challenge, you intentionally styled it as "rantingrick v. the world", >> so you need to actually bring something challenge worthy to the table >> first. > Where is the world Adam? I am the only one who has summited code. > > >> That includes picking a challenge that's interesting and not over a >> relatively minor widget in the grand scheme of things. > ListCtrl's are very useful. And i have many more challenges coming. > WxPython outshines all the competition by leaps and bounds. The > ListCtrl is just the beginning. > >> Qt, Swing, >> Gtk, and Win32 common controls[1] don't provide the same exact control >> either, should we view it as deficient? > Yes. > >> But regardless of the challenge, > You keep trying to divert attention from the point. Sorry but you're > not going to fool anyone with this foolishness. > >> I don't think you're capable of >> posting a worthwhile example, which is why you dismiss all the >> problems found with it instead of actually fixing the code. > Ditto! But at least i have some code to work with. Something to create > a fact based argument from. You have nothing but your own foolishness > to build from. > >>> Post CODE Adam. Code! Surely you can handle copy/pasting a traceback i >>> hope! >> I certainly can. I don't have much hope for you writing code that >> provides tracebacks, much less actually useful ones. > I suppose you gauge the quality of code by how many tracebacks are > printed. And it seems even more perverse that you expect code to spit > exceptions! And when code fails to spit exceptions you get angry about > it and claim the programmer is insufficient. Hmm, this would explain > why you have yet to provide us with working (or even semi-working) > code. Adam you are by far the most foolish person i have ever met. -- Thanks, Ty From kb1pkl at aim.com Sun Jan 23 16:13:24 2011 From: kb1pkl at aim.com (Corey Richardson) Date: Sun, 23 Jan 2011 16:13:24 -0500 Subject: A and B but not C in list In-Reply-To: <8cae2caf-d3df-4ed3-9afb-29de97772298@m13g2000yqb.googlegroups.com> References: <8cae2caf-d3df-4ed3-9afb-29de97772298@m13g2000yqb.googlegroups.com> Message-ID: <4D3C99F4.4000103@aim.com> On 01/23/2011 04:05 PM, CM wrote: > In Python, is there a recommended way to write conditionals of the > form: > > "if A and B but not C or D in my list, do something." ? > > I may also have variations on this, like "if A but not B, C, or D". > > Do I have to just write out all the if and elifs with all possible > conditions, or is there a handier and more code-maintainable way to > deal with this? > > Thanks. > > > > if (A in list and B in list) and (C not in list or D not in list): pass I'm sure the gurus on this list can come up with something better. From clp2 at rebertia.com Sun Jan 23 16:21:05 2011 From: clp2 at rebertia.com (Chris Rebert) Date: Sun, 23 Jan 2011 13:21:05 -0800 Subject: A and B but not C in list In-Reply-To: <8cae2caf-d3df-4ed3-9afb-29de97772298@m13g2000yqb.googlegroups.com> References: <8cae2caf-d3df-4ed3-9afb-29de97772298@m13g2000yqb.googlegroups.com> Message-ID: On Sun, Jan 23, 2011 at 1:05 PM, CM wrote: > In Python, is there a recommended way to write conditionals of the > form: > > "if A and B but not C or D in my list, do something." ?? > > I may also have variations on this, like "if A but not B, C, or D". > > Do I have to just write out all the if and elifs with all possible > conditions, or is there a handier and more code-maintainable way to > deal with this? Assuming your conditions all involve membership testing... Use the built-in any() and all() functions. For your first example: wanteds = [A, B] unwanteds = [C, D] if all(wanted in your_list for wanted in wanteds) and \ not any(unwanted in your_list for unwanted in unwanteds): do_whatever() You could pull this out into a separate function if you wish. Cheers, Chris -- http://blog.rebertia.com From g.rodola at gmail.com Sun Jan 23 16:22:56 2011 From: g.rodola at gmail.com (=?ISO-8859-1?Q?Giampaolo_Rodol=E0?=) Date: Sun, 23 Jan 2011 22:22:56 +0100 Subject: ANN: pyftpdlib 0.6.0 released Message-ID: Hi, I'm pleased to announce release 0.6.0 of Python FTP Server library (pyftpdlib). http://code.google.com/p/pyftpdlib/ === About === Python FTP server library provides an high-level portable interface to easily write asynchronous FTP/S servers with Python. Based on asyncore framework pyftpdlib is currently the most complete RFC-959 FTP server implementation available for Python programming language. === Major changes === This new version, aside from fixing some bugs, includes some important new features: * (finally) full FTPS (FTP over SSL/TS) support * configurable command line options * a standardized and improved logging system for commands and transfers * possibility to serve both IPv4 and IPv6 by using a single socket * enhanced Unix and Windows authorizers, moved from demo directory and included in main library with a set of new options such as the possibility to specify which users should be granted for access. * enabled TCP_NODELAY socket option for the FTP command channels resulting in pyftpdlib being twice faster. * a new UnixFilesystem class which permits the client to escape its home directory and navigate the real filesystem. A complete list of changes including enhancements, bug fixes and instructions for using the new functionalities is available here: http://code.google.com/p/pyftpdlib/wiki/ReleaseNotes06 If you think pyftpdlib is worth a donation you can do so by going here: http://code.google.com/p/pyftpdlib/wiki/Donate === More links === * Source tarball: http://pyftpdlib.googlecode.com/files/pyftpdlib-0.6.0.tar.gz * Online docs: http://code.google.com/p/pyftpdlib/wiki/Tutorial * FAQs: http://code.google.com/p/pyftpdlib/wiki/FAQ * RFCs compliance paper: http://code.google.com/p/pyftpdlib/wiki/RFCsCompliance * Issue tracker: http://code.google.com/p/pyftpdlib/issues/list Thanks, -- Giampaolo Rodola' < g.rodola [at] gmail [dot] com > From skunkworks at rikishi42.net Sun Jan 23 16:31:42 2011 From: skunkworks at rikishi42.net (Rikishi42) Date: Sun, 23 Jan 2011 22:31:42 +0100 Subject: Need GUI pop-up to edit a (unicode ?) string References: <3tqr08-bj2.ln1@murmur.very.softly> Message-ID: On 2011-01-22, geremy condra wrote: > If windows doesn't matter to you, just use Zenity. Here's a python > function wrapping zenity that does what you want: > > import commands > > def confirm_or_edit(s): > zenity = 'zenity' > mode = '--entry' > text = "--text='Please confirm or edit the following string:'" > title = "--title='confirm or edit'" > entry = "--entry-text='%s'" % s > cmd = ' '.join([zenity, mode, text, title, entry]) > status, output = commands.getstatusoutput(cmd) > if status: raise Exception("Couldn't run zenity") > return output > > There's also a full-blown API for zenity, but this should do what you want. Very, very nice. Thanks ! I'm amazed at how many GUI's are available. No wonder I couldn't find "the" interface, there are too many. :-) -- When in doubt, use brute force. -- Ken Thompson From lists at cheimes.de Sun Jan 23 16:34:33 2011 From: lists at cheimes.de (Christian Heimes) Date: Sun, 23 Jan 2011 22:34:33 +0100 Subject: A and B but not C in list In-Reply-To: <8cae2caf-d3df-4ed3-9afb-29de97772298@m13g2000yqb.googlegroups.com> References: <8cae2caf-d3df-4ed3-9afb-29de97772298@m13g2000yqb.googlegroups.com> Message-ID: Am 23.01.2011 22:05, schrieb CM: > In Python, is there a recommended way to write conditionals of the > form: > > "if A and B but not C or D in my list, do something." ? > > I may also have variations on this, like "if A but not B, C, or D". > > Do I have to just write out all the if and elifs with all possible > conditions, or is there a handier and more code-maintainable way to > deal with this? It's easier and faster if you convert the lists to sets first: your_set = set(your_list) if your_set.issuperset(set([A, B])) and your_set.isdisjoint(set([C, D])): ... Christian From tdldev at gmail.com Sun Jan 23 16:41:05 2011 From: tdldev at gmail.com (Verde Denim) Date: Sun, 23 Jan 2011 16:41:05 -0500 Subject: Which non SQL Database ? In-Reply-To: <4d3c8d53$0$44021$742ec2ed@news.sonic.net> References: <4d3c8d53$0$44021$742ec2ed@news.sonic.net> Message-ID: On Sun, Jan 23, 2011 at 3:19 PM, John Nagle wrote: > On 1/22/2011 10:15 PM, Deadly Dirk wrote: > >> On Sat, 04 Dec 2010 16:42:36 -0600, Jorge Biquez wrote: >> >> Hello all. >>> >>> Newbie question. Sorry. >>> >>> As part of my process to learn python I am working on two personal >>> applications. Both will do it fine with a simple structure of data >>> stored in files. I now there are lot of databases around I can use but I >>> would like to know yoor advice on what other options you would consider >>> for the job (it is training so no pressure on performance). >>> >> > For something like that, I'd suggest just using SQLite. It comes > with the Python distribution, it's well documented, and reasonably easy > to use. > > The "NoSQL" stuff is mostly for people doing really big databases > for large web sites. The kind of operations where you have multiple > data centers, thousands of rackmount servers, a huge traffic load, > and smart people thinking about the implications of "eventually > consistent". > > Google's BigTable and Facebook's Cassandra offer impressive > performance at very large scale. But they're way overkill for > a desktop app. Even the midrange systems, like CouchDB, are > far too much machinery for a desktop app. > > John Nagle > This may sound a bit 'old school', but if it's a non-sql solution you're after, what about c-isam ? Data is indexed and stored in flat files. For a personal app that maintains a small footprint, it's relative performance is acceptable. If the number of entities and attributes rises above a handful, however, I would recommend investing more thought in whether this is a permanent solution. Regards Jack > -- > http://mail.python.org/mailman/listinfo/python-list > -------------- next part -------------- An HTML attachment was scrubbed... URL: From askutt at gmail.com Sun Jan 23 17:03:26 2011 From: askutt at gmail.com (Adam Skutt) Date: Sun, 23 Jan 2011 14:03:26 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <480571f5-5731-4f8b-9cb4-1468478711bf@c39g2000yqi.googlegroups.com> <2c951199-3dba-4d24-a5c2-f84081688f7e@u6g2000yqk.googlegroups.com> <3e603997-5539-4660-bd83-7398bdab34a4@k30g2000vbn.googlegroups.com> <5edded76-fdac-4eb5-8480-25e3381e2fd4@g26g2000vbz.googlegroups.com> <1d7fdb0c-9f82-45ab-bf0e-99d210042f0d@j21g2000vbn.googlegroups.com> Message-ID: <4d34f9f4-25d1-4132-90e9-255bfdd2b506@d8g2000yqf.googlegroups.com> On Jan 23, 3:23?pm, rantingrick wrote: > psst: thats because they are FEATURES and NOT BUGS you idiot! Your application not displaying a directory listing, due to one of these "features", is desirable behavior? I think not. Your application hanging, due to one of these "features" is desirable behavior? I think not, nor do the wxWidgets, Qt, Swing, Cocoa, Gtk, Win32, et al. toolkit developers. > I am not trying to create a working file browser so you can steal my code. I have ethics, morals, and standards, all of which forbid me from stealing anything you write. > I am displaying one use case for a very useful widget. So useful that you've only found one toolkit that provides it OOB! > A ListCtrl is useful for many, many purposes. Just one of them happens > to be a file browser. The specific functionality the wxWidgets ListCtrl has over its alternatives in other toolkits is only really seen in file browsers. Your challenge explicitly relies on making use of that functionality and in no way, shape, or form illustrates the general utility of a wxListCtrl. When you amend the challenge, you can make the claim it's not about wxListCtrl's unique functionality. > > Qt, Swing, > > Gtk, and Win32 common controls[1] don't provide the same exact control > > either, should we view it as deficient? > Yes. Funny, given that the original purpose of wxWidgets was to provide a cross-platform MFC wrapper, I think you're in the minority of thought among those developers, to say nothing of developers in general. > I suppose you gauge the quality of code by how many tracebacks are > printed. And it seems even more perverse that you expect code to spit > exceptions! You're the one who asked for them originally, not I. I merely posited that since you provided code that prints no tracebacks and expected them (i.e., what you expect your code to do and what it does are two different things), that it is highly unlikely you're capable of providing me code that actually prints tracebacks, much less tracebacks that assist you in debugging. Put plainly, you have no clue whatsoever what your code actually does or how it accomplishes it, which is exactly what we'd expect. Adam From misnomer at gmail.com Sun Jan 23 17:07:40 2011 From: misnomer at gmail.com (Nicholas Devenish) Date: Sun, 23 Jan 2011 22:07:40 +0000 Subject: WxPython versus Tkinter. In-Reply-To: <3e603997-5539-4660-bd83-7398bdab34a4@k30g2000vbn.googlegroups.com> References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <480571f5-5731-4f8b-9cb4-1468478711bf@c39g2000yqi.googlegroups.com> <2c951199-3dba-4d24-a5c2-f84081688f7e@u6g2000yqk.googlegroups.com> <3e603997-5539-4660-bd83-7398bdab34a4@k30g2000vbn.googlegroups.com> Message-ID: Hi Adam, I'm still learning my way around wxPython and gui programming, been mostly linux and CLI since Visual Basic 5, and only recently started learning it. On 23/01/2011 18:09, Adam Skutt wrote: > 1. There's a bug related to loading of your resources. > 2. There's a bug related to when file I/O is performed. > 3/4. There's at least two bugs related to handling of a specific mouse > event. > 5. There's a bug related to reporting errors to the user. > > All of these bugs, except one[1], show a grave misunderstanding about > how GUI toolkits operate and/or how the underlying operating systems > behave. > > [1] Which is only because wxWidgets has a bug in this regard. That > being said, a workaround exists and trivial to find online. I'd be curious as to what these bugs are, as a learning exercise, if you don't mind. I don't mind a direct mail if you wish not to subject yourself to any more abuse on the list, as would almost certainly come. I'd especially like to be pointed at the error you refer to in [1]. On to the topic of the program direct, the 'List view' button doesn't seem to work on my platform, showing a blank folder icon and nothing else, but I don't know if that is related to any of these bugs. I actually looked around when I wanted to start learning gui programming, and chose wxPython because it seemed to use 'native' controls on all of the platforms. This file viewer just looks awful (is it supposed to flicker so much when I try to change the column size?) so I'm not exactly sure what it is supposed to prove. Nick From rantingrick at gmail.com Sun Jan 23 17:08:35 2011 From: rantingrick at gmail.com (rantingrick) Date: Sun, 23 Jan 2011 14:08:35 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <480571f5-5731-4f8b-9cb4-1468478711bf@c39g2000yqi.googlegroups.com> <2c951199-3dba-4d24-a5c2-f84081688f7e@u6g2000yqk.googlegroups.com> <3e603997-5539-4660-bd83-7398bdab34a4@k30g2000vbn.googlegroups.com> <5edded76-fdac-4eb5-8480-25e3381e2fd4@g26g2000vbz.googlegroups.com> <1d7fdb0c-9f82-45ab-bf0e-99d210042f0d@j21g2000vbn.googlegroups.com> Message-ID: <72084832-a4d5-43b5-9f7a-d6359013ebe9@s5g2000yqm.googlegroups.com> On Jan 23, 3:11?pm, "Littlefield, Tyler" wrote: > if you can't manage to provide cross-platform bug-free code. No one has posted even one traceback Tyler (including yourself!). And until they do i will assume that my code is bug free. I know it to be bug free on windows. If and when someone *actually* provides proof (supported by a traceback) then i will take them seriously. From david at boddie.org.uk Sun Jan 23 17:13:00 2011 From: david at boddie.org.uk (David Boddie) Date: Sun, 23 Jan 2011 23:13:00 +0100 Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> Message-ID: On Sunday 23 January 2011 17:57, rantingrick wrote: > On Jan 22, 9:39?pm, Terry Reedy wrote: >> On 1/22/2011 7:07 PM, rantingrick wrote: >> >> Near the beginning of this thread, I gently challenged you to produce a >> concrete, practical proposal for an stdlib addition that could be >> critiqued and improved. When you asked for problems with >> wxwidgets/wxpython, I gave some. Still waiting. > > You may have done this however i do not remember. With all the > trolling that was going on (not you) i may have missed it. ^^^ +1 QOTW David From hidura at gmail.com Sun Jan 23 17:21:05 2011 From: hidura at gmail.com (hidura at gmail.com) Date: Sun, 23 Jan 2011 22:21:05 +0000 Subject: How to execute foreing code from Python Message-ID: <20cf30433cec39ebdb049a8ae637@google.com> Hello i want to code from different languages using a Python script i know i can use os.system, but i don't know how to receive data or send arguments using that method if theres any another way to make it or there's a way to send arguments and receive data using os.system? Thanks in advance. -------------- next part -------------- An HTML attachment was scrubbed... URL: From kb1pkl at aim.com Sun Jan 23 17:25:10 2011 From: kb1pkl at aim.com (Corey Richardson) Date: Sun, 23 Jan 2011 17:25:10 -0500 Subject: WxPython versus Tkinter. In-Reply-To: <72084832-a4d5-43b5-9f7a-d6359013ebe9@s5g2000yqm.googlegroups.com> References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <480571f5-5731-4f8b-9cb4-1468478711bf@c39g2000yqi.googlegroups.com> <2c951199-3dba-4d24-a5c2-f84081688f7e@u6g2000yqk.googlegroups.com> <3e603997-5539-4660-bd83-7398bdab34a4@k30g2000vbn.googlegroups.com> <5edded76-fdac-4eb5-8480-25e3381e2fd4@g26g2000vbz.googlegroups.com> <1d7fdb0c-9f82-45ab-bf0e-99d210042f0d@j21g2000vbn.googlegroups.com> <72084832-a4d5-43b5-9f7a-d6359013ebe9@s5g2000yqm.googlegroups.com> Message-ID: <4D3CAAC6.7070000@aim.com> On 01/23/2011 05:08 PM, rantingrick wrote: > On Jan 23, 3:11 pm, "Littlefield, Tyler" wrote: > >> if you can't manage to provide cross-platform bug-free code. > > No one has posted even one traceback Tyler (including yourself!). And > until they do i will assume that my code is bug free. I know it to be > bug free on windows. If and when someone *actually* provides proof > (supported by a traceback) then i will take them seriously. > > There are more types of bugs than syntax errors, which are one of the only types of bug that raise exceptions in Python. Try looking at [1] or [2]. Here is the output on my system (Linux Mint 64bit): /home/corey/Downloads/Wx_Tk_Challenge/Bitmaps Loading Images: -- /home/corey/Downloads/Wx_Tk_Challenge/Bitmaps/file.bmp file.bmp -- /home/corey/Downloads/Wx_Tk_Challenge/Bitmaps/folder.bmp folder.bmp -- /home/corey/Downloads/Wx_Tk_Challenge/Bitmaps/link.bmp link.bmp ['folder', 'link', 'file'] Segmentation fault [1] http://en.wikipedia.org/wiki/Software_bug#Common_types_of_computer_bugs [2] http://msdn.microsoft.com/en-us/library/s9ek7a19%28v=vs.80%29.aspx From steve+comp.lang.python at pearwood.info Sun Jan 23 18:13:01 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 23 Jan 2011 23:13:01 GMT Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <480571f5-5731-4f8b-9cb4-1468478711bf@c39g2000yqi.googlegroups.com> <2c951199-3dba-4d24-a5c2-f84081688f7e@u6g2000yqk.googlegroups.com> <3e603997-5539-4660-bd83-7398bdab34a4@k30g2000vbn.googlegroups.com> <5edded76-fdac-4eb5-8480-25e3381e2fd4@g26g2000vbz.googlegroups.com> <1d7fdb0c-9f82-45ab-bf0e-99d210042f0d@j21g2000vbn.googlegroups.com> Message-ID: <4d3cb5fc$0$29983$c3e8da3$5496439d@news.astraweb.com> On Sun, 23 Jan 2011 12:23:13 -0800, rantingrick wrote: > I am not > trying to create a working file browser so you can steal my code. Dammit! There goes my brilliant idea for getting rich. Step 1: Start company. Step 2: Steal working file browser from Internet. Step 4: Profit! I think rantingrick's comment inadvertently shows in a nutshell everything wrong with this thread and why there is so little interest in his proposal. If RR is right about the GUI toolkit making or breaking the entire Python community, there should be hundreds of people with an opinion, not just a handful. (1) rantingrick is willing to spend *hours* brow-beating people, insulting them, and cajoling them into doing things *his* way, supposedly because of his deep concern for the Python community, but isn't willing to donate a lousy *file browser* to the community. (2) GUI programming is TOO DAMN HARD, and until that fact is addressed, it's difficult for the majority of people to care whether the toolkit used (or, more likely, not used at all) is Tkinter, or wxPython, or something else. For something as common as displaying a file browser, it should be as simple as this: import gui_toolkit # whichever path = gui_toolkit.select_file() Something like zenity: [steve at sylar ~]$ zenity --file-selection /home/steve/python/findsingle.py Of course there are times when you need to do more complicated things, and a decent toolkit should allow you to do so. But simple things should be simple, and as far as I can see, there are no GUI toolkits that make *anything* simple. -- Steven From steve+comp.lang.python at pearwood.info Sun Jan 23 18:21:31 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 23 Jan 2011 23:21:31 GMT Subject: A and B but not C in list References: <8cae2caf-d3df-4ed3-9afb-29de97772298@m13g2000yqb.googlegroups.com> Message-ID: <4d3cb7fb$0$29983$c3e8da3$5496439d@news.astraweb.com> On Sun, 23 Jan 2011 22:34:33 +0100, Christian Heimes wrote: > It's easier and faster if you convert the lists to sets first: > > your_set = set(your_list) > > if your_set.issuperset(set([A, B])) and your_set.isdisjoint(set([C, > D])): > ... "Easier" is a close thing. I find this easier to remember and write than set processing, even if it is a couple of characters longer: if all(x in your_list for x in (A, B)) and not any(x in your_list for x in (C, D)): ... And as for "faster", surely that will depend on the number of elements in your_list? The conversion from list to set doesn't happen for free, and it's likely that for small enough lists, that time may exceed any time savings you would otherwise gain. -- Steven From kw at codebykevin.com Sun Jan 23 18:23:47 2011 From: kw at codebykevin.com (Kevin Walzer) Date: Sun, 23 Jan 2011 18:23:47 -0500 Subject: [Code Challenge] WxPython versus Tkinter. In-Reply-To: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> Message-ID: <70498$4d3cb87c$4275d90a$4428@FUSE.NET> I found this code in the Demo/tkinter/ttk directory of the Python 2.7.1 source distribution. I'm NOT the author (credit should probably go to Guilherme Polo, developer of the Tkinter wrapper for the ttk themed widgets that is now in the stdlib). But, using a tree/listview widget that is part of the Tk/Tkinter core (NOT an extension), it presents a decent, simple file browser: """A directory browser using Ttk Treeview. Based on the demo found in Tk 8.5 library/demos/browse """ import os import glob import Tkinter import ttk def populate_tree(tree, node): if tree.set(node, "type") != 'directory': return path = tree.set(node, "fullpath") tree.delete(*tree.get_children(node)) parent = tree.parent(node) special_dirs = [] if parent else glob.glob('.') + glob.glob('..') for p in special_dirs + os.listdir(path): ptype = None p = os.path.join(path, p).replace('\\', '/') if os.path.isdir(p): ptype = "directory" elif os.path.isfile(p): ptype = "file" fname = os.path.split(p)[1] id = tree.insert(node, "end", text=fname, values=[p, ptype]) if ptype == 'directory': if fname not in ('.', '..'): tree.insert(id, 0, text="dummy") tree.item(id, text=fname) elif ptype == 'file': size = os.stat(p).st_size tree.set(id, "size", "%d bytes" % size) def populate_roots(tree): dir = os.path.abspath('.').replace('\\', '/') node = tree.insert('', 'end', text=dir, values=[dir, "directory"]) populate_tree(tree, node) def update_tree(event): tree = event.widget populate_tree(tree, tree.focus()) def change_dir(event): tree = event.widget node = tree.focus() if tree.parent(node): path = os.path.abspath(tree.set(node, "fullpath")) if os.path.isdir(path): os.chdir(path) tree.delete(tree.get_children('')) populate_roots(tree) def autoscroll(sbar, first, last): """Hide and show scrollbar as needed.""" first, last = float(first), float(last) if first <= 0 and last >= 1: sbar.grid_remove() else: sbar.grid() sbar.set(first, last) root = Tkinter.Tk() vsb = ttk.Scrollbar(orient="vertical") hsb = ttk.Scrollbar(orient="horizontal") tree = ttk.Treeview(columns=("fullpath", "type", "size"), displaycolumns="size", yscrollcommand=lambda f, l: autoscroll(vsb, f, l), xscrollcommand=lambda f, l:autoscroll(hsb, f, l)) vsb['command'] = tree.yview hsb['command'] = tree.xview tree.heading("#0", text="Directory Structure", anchor='w') tree.heading("size", text="File Size", anchor='w') tree.column("size", stretch=0, width=100) populate_roots(tree) tree.bind('<>', update_tree) tree.bind('', change_dir) # Arrange the tree and its scrollbars in the toplevel tree.grid(column=0, row=0, sticky='nswe') vsb.grid(column=1, row=0, sticky='ns') hsb.grid(column=0, row=1, sticky='ew') root.grid_columnconfigure(0, weight=1) root.grid_rowconfigure(0, weight=1) root.mainloop() -- Kevin Walzer Code by Kevin http://www.codebykevin.com From martin at v.loewis.de Sun Jan 23 18:27:53 2011 From: martin at v.loewis.de (Martin v. Loewis) Date: Mon, 24 Jan 2011 00:27:53 +0100 Subject: WxPython versus Tkinter. In-Reply-To: <033c3f90-03fb-4f65-bbae-bbc80a262685@l22g2000vbp.googlegroups.com> References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <033c3f90-03fb-4f65-bbae-bbc80a262685@l22g2000vbp.googlegroups.com> Message-ID: >> Segmentation fault >> >> [Actually this is the first time in my 10 years of python that Ive >> seen a pure python module segfault :-) ] > > Congratulations genius! However if you are really smart you would have > read the note in the source that says "tested on windows only!". > Segfault. Thanks for the laugh! I get the same: /tmp/Wx_Tk_Challenge/Bitmaps Loading Images: -- /tmp/Wx_Tk_Challenge/Bitmaps/file.bmp file.bmp -- /tmp/Wx_Tk_Challenge/Bitmaps/link.bmp link.bmp -- /tmp/Wx_Tk_Challenge/Bitmaps/folder.bmp folder.bmp ['folder', 'link', 'file'] Speicherzugriffsfehler Since you are asking for a traceback, here is one: Program received signal SIGSEGV, Segmentation fault. 0x00007ffff554c8cd in wxListMainWindow::InsertItem(wxListItem&) () from /usr/lib/libwx_gtk2u_core-2.6.so.0 (gdb) bt #0 0x00007ffff554c8cd in wxListMainWindow::InsertItem(wxListItem&) () from /usr/lib/libwx_gtk2u_core-2.6.so.0 #1 0x00007ffff554c940 in wxGenericListCtrl::InsertItem(wxListItem&) () from /usr/lib/libwx_gtk2u_core-2.6.so.0 #2 0x00007ffff554f012 in wxGenericListCtrl::InsertItem(long, wxString const&, int) () from /usr/lib/libwx_gtk2u_core-2.6.so.0 #3 0x00007fffee58c460 in ?? () from /usr/lib/python2.6/dist-packages/wx-2.6-gtk2-unicode/wx/_controls_.so #4 0x00000000004a794b in PyEval_EvalFrameEx () #5 0x00000000004a95c1 in PyEval_EvalCodeEx () #6 0x00000000004a7752 in PyEval_EvalFrameEx () #7 0x00000000004a84a0 in PyEval_EvalFrameEx () #8 0x00000000004a95c1 in PyEval_EvalCodeEx () #9 0x0000000000538b0d in ?? () #10 0x000000000041ef47 in PyObject_Call () #11 0x0000000000427c1f in ?? () #12 0x000000000041ef47 in PyObject_Call () #13 0x00000000004778ff in ?? () #14 0x000000000046f16f in ?? () #15 0x000000000041ef47 in PyObject_Call () #16 0x00000000004a72b8 in PyEval_EvalFrameEx () #17 0x00000000004a95c1 in PyEval_EvalCodeEx () #18 0x00000000004a9692 in PyEval_EvalCode () #19 0x00000000004c98be in PyRun_FileExFlags () #20 0x00000000004c9ad4 in PyRun_SimpleFileExFlags () #21 0x000000000041a6bd in Py_Main () #22 0x00007ffff69eac4d in __libc_start_main () from /lib/libc.so.6 #23 0x00000000004198d9 in _start () If you had expected a Python traceback, sorry Rick: it didn't produce one, since it crashed. So Rick you managed to crash wxPython, in just 248 lines of code. This doesn't give a very good impression of wxPython - "regular" Python libraries shouldn't crash the interpreter. Regards, Martin From clp2 at rebertia.com Sun Jan 23 18:30:45 2011 From: clp2 at rebertia.com (Chris Rebert) Date: Sun, 23 Jan 2011 15:30:45 -0800 Subject: How to execute foreing code from Python In-Reply-To: <20cf30433cec39ebdb049a8ae637@google.com> References: <20cf30433cec39ebdb049a8ae637@google.com> Message-ID: On Sun, Jan 23, 2011 at 2:21 PM, wrote: > Hello i want to code from different languages using a Python script i know i > can use os.system, but i don't know how to receive data or send arguments > using that method if theres any another way to make it or there's a way to > send arguments and receive data using os.system? Which other languages specifically? Also, the `subprocess` module (http://docs.python.org/library/subprocess.html ) is preferred over os.system(). Cheers, Chris -- http://blog.rebertia.com From martin at v.loewis.de Sun Jan 23 18:44:57 2011 From: martin at v.loewis.de (Martin v. Loewis) Date: Mon, 24 Jan 2011 00:44:57 +0100 Subject: WxPython versus Tkinter. In-Reply-To: <4d3cb5fc$0$29983$c3e8da3$5496439d@news.astraweb.com> References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <480571f5-5731-4f8b-9cb4-1468478711bf@c39g2000yqi.googlegroups.com> <2c951199-3dba-4d24-a5c2-f84081688f7e@u6g2000yqk.googlegroups.com> <3e603997-5539-4660-bd83-7398bdab34a4@k30g2000vbn.googlegroups.com> <5edded76-fdac-4eb5-8480-25e3381e2fd4@g26g2000vbz.googlegroups.com> <1d7fdb0c-9f82-45ab-bf0e-99d210042f0d@j21g2000vbn.googlegroups.com> <4d3cb5fc$0$29983$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4D3CBD79.3000905@v.loewis.de> > For something as common as displaying a file browser, it should be as > simple as this: > > import gui_toolkit # whichever > path = gui_toolkit.select_file() > > Something like zenity: > > [steve at sylar ~]$ zenity --file-selection > /home/steve/python/findsingle.py And indeed, it is that simple: python -c "import tkFileDialog as tkfd;print tkfd.askopenfilename()" Regards, Martin From rantingrick at gmail.com Sun Jan 23 19:07:43 2011 From: rantingrick at gmail.com (rantingrick) Date: Sun, 23 Jan 2011 16:07:43 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> Message-ID: <3a96fee1-995f-49f7-a967-f125cc3f1cdc@v26g2000yqf.googlegroups.com> On Jan 22, 6:07?pm, rantingrick wrote: > I await any challengers... WxPython Challenge 1 code updated... * Fixed tab traveral * Removed hand-holding code * Removed some cruft https://sites.google.com/site/thefutureofpython/home/code-challenges Good luck! From davea at ieee.org Sun Jan 23 19:24:36 2011 From: davea at ieee.org (Dave Angel) Date: Sun, 23 Jan 2011 19:24:36 -0500 Subject: How to execute foreing code from Python In-Reply-To: <20cf30433cec39ebdb049a8ae637@google.com> References: <20cf30433cec39ebdb049a8ae637@google.com> Message-ID: <4D3CC6C4.3060502@ieee.org> On 01/-10/-28163 02:59 PM, hidura at gmail.com wrote: > Hello i want to code from different languages using a Python script i > know i can use os.system, but i don't know how to receive data or send > arguments using that method if theres any another way to make it or > there's a way to send arguments and receive data using os.system? > > Thanks in advance. > That sentence runs on, and makes no sense to me. But I can guess that you would like to be able to write code in other languages, and call it from within a Python script. If you're on Windows, and the other language is a compiled one like C, compile it into a DLL, and call that DLL from Python. Ctypes is the first module to study. If you're on Linux, and the code in the other language was written by someone else, and is already compiled into an executable you cannot change, you probably should invoke it using the subprocess module. You can supply information to the executable via the commandline arguments and also via stdin, and you can receive results via the exit code, and via stdout. Any more details and options would need lots more information about your environment and your constraints. DaveA From kb1pkl at aim.com Sun Jan 23 19:30:26 2011 From: kb1pkl at aim.com (Corey Richardson) Date: Sun, 23 Jan 2011 19:30:26 -0500 Subject: WxPython versus Tkinter. In-Reply-To: <3a96fee1-995f-49f7-a967-f125cc3f1cdc@v26g2000yqf.googlegroups.com> References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <3a96fee1-995f-49f7-a967-f125cc3f1cdc@v26g2000yqf.googlegroups.com> Message-ID: <4D3CC822.4010703@aim.com> On 01/23/2011 07:07 PM, rantingrick wrote: > On Jan 22, 6:07 pm, rantingrick wrote: > >> I await any challengers... > > > WxPython Challenge 1 code updated... > > * Fixed tab traveral > * Removed hand-holding code > * Removed some cruft > > https://sites.google.com/site/thefutureofpython/home/code-challenges > > Good luck! Still doesn't fix the problem of the code not working on Linux boxes. Maybe wxPython isn't the best option, it doesn't appear very cross-platform. Still getting: Loading Images: -- /home/corey/Downloads/Wx_Tk_Challenge/Bitmaps/file.bmp, file.bmp -- /home/corey/Downloads/Wx_Tk_Challenge/Bitmaps/folder.bmp, folder.bmp -- /home/corey/Downloads/Wx_Tk_Challenge/Bitmaps/link.bmp, link.bmp imageMap.keys -> ['folder', 'link', 'file'] Segmentation fault From martin at v.loewis.de Sun Jan 23 19:31:43 2011 From: martin at v.loewis.de (Martin v. Loewis) Date: Mon, 24 Jan 2011 01:31:43 +0100 Subject: WxPython versus Tkinter. In-Reply-To: <3a96fee1-995f-49f7-a967-f125cc3f1cdc@v26g2000yqf.googlegroups.com> References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <3a96fee1-995f-49f7-a967-f125cc3f1cdc@v26g2000yqf.googlegroups.com> Message-ID: > WxPython Challenge 1 code updated... > > * Fixed tab traveral > * Removed hand-holding code > * Removed some cruft > > https://sites.google.com/site/thefutureofpython/home/code-challenges > > Good luck! Still crashes the interpreter. Regards, Martin From tjreedy at udel.edu Sun Jan 23 19:35:13 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Sun, 23 Jan 2011 19:35:13 -0500 Subject: A and B but not C in list In-Reply-To: <8cae2caf-d3df-4ed3-9afb-29de97772298@m13g2000yqb.googlegroups.com> References: <8cae2caf-d3df-4ed3-9afb-29de97772298@m13g2000yqb.googlegroups.com> Message-ID: On 1/23/2011 4:05 PM, CM wrote: > In Python, is there a recommended way to write conditionals of the > form: > > "if A and B but not C or D in my list, do something." ? > > I may also have variations on this, like "if A but not B, C, or D". > > Do I have to just write out all the if and elifs with all possible > conditions, or is there a handier and more code-maintainable way to > deal with this? The straightforward code if a in L and b in L and c not in L and d not in L scans the list 4 times. One scan be be done generically as follows: def req_pro(iterable, required = set(), prohibited = set()): for item in iterable: if item in prohibited: return False elif item in required: required.remove(item) else: return not required # should now be empty if req_pro(my_list, {A,B}, {C,D}): ... # untested, of course.. -- Terry Jan Reedy From tjreedy at udel.edu Sun Jan 23 19:48:00 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Sun, 23 Jan 2011 19:48:00 -0500 Subject: documentation / reference help In-Reply-To: References: Message-ID: On 1/23/2011 1:41 PM, Scott Meup wrote: > I'm trying tolearn Python. The documentation tells syntax, and other things > about a command. But for too many commands, it doesn't tell what it does. > for instance, in VB the 'return' command tells the program what line to > execute after some event (usually an error). In Python it appears to return > a value. Where does it return it to? The return object replaces the function call in the expression that contains the function call. Given: x = 1; j = [2,3]; def f(): return 4 the expression: x + y[1] + f() becomes: 1 + 3 + 4 In other words, names are looked up in the appropriate namespace and replaced with the object they are associated with in that namespace. Names followed by square brackets are replaced by the result of an indexing operation. Names followed by parentheses are called and replaced by the object returned. -- Terry Jan Reedy From rantingrick at gmail.com Sun Jan 23 20:12:27 2011 From: rantingrick at gmail.com (rantingrick) Date: Sun, 23 Jan 2011 17:12:27 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <70498$4d3cb87c$4275d90a$4428@FUSE.NET> Message-ID: On Jan 23, 5:23?pm, Kevin Walzer wrote: > I found this code in the Demo/tkinter/ttk directory of the Python 2.7.1 > source distribution. I'm NOT the author (credit should probably go to > Guilherme Polo, developer of the Tkinter wrapper for the ttk themed > widgets that is now in the stdlib). But, using a tree/listview widget > that is part of the Tk/Tkinter core (NOT an extension), ?it presents a > decent, simple file browser: > > """A directory browser using Ttk Treeview. The only way i can respond to this is to quite the requirements for my challenge... --------------------------------------- Challenge 1: (Simple Directory Viewer) --------------------------------------- Create a simple Directory Viewer GUI. You CANNOT use a treectrl! Any questions? From kw at codebykevin.com Sun Jan 23 20:16:52 2011 From: kw at codebykevin.com (Kevin Walzer) Date: Sun, 23 Jan 2011 20:16:52 -0500 Subject: WxPython versus Tkinter. In-Reply-To: References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <70498$4d3cb87c$4275d90a$4428@FUSE.NET> Message-ID: <63eea$4d3cd2fd$4275d90a$14984@FUSE.NET> On 1/23/11 8:12 PM, rantingrick wrote: > The only way i can respond to this is to quite the requirements for my > challenge... > > --------------------------------------- > Challenge 1: (Simple Directory Viewer) > --------------------------------------- > Create a simple Directory Viewer GUI. You CANNOT use a treectrl! > > > Any questions? Why not? I'd understand if this code made use of some Tk extension, as that's not quite an apples-to-apples comparison. But the treectrl is part of the core Tkinter widget set. There's no reason to exclude it unless you are deliberately trying to handicap Tk in your comparison. --Kevin -- Kevin Walzer Code by Kevin http://www.codebykevin.com From steve+comp.lang.python at pearwood.info Sun Jan 23 20:18:22 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 24 Jan 2011 01:18:22 GMT Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <480571f5-5731-4f8b-9cb4-1468478711bf@c39g2000yqi.googlegroups.com> <2c951199-3dba-4d24-a5c2-f84081688f7e@u6g2000yqk.googlegroups.com> <3e603997-5539-4660-bd83-7398bdab34a4@k30g2000vbn.googlegroups.com> <5edded76-fdac-4eb5-8480-25e3381e2fd4@g26g2000vbz.googlegroups.com> <1d7fdb0c-9f82-45ab-bf0e-99d210042f0d@j21g2000vbn.googlegroups.com> <4d3cb5fc$0$29983$c3e8da3$5496439d@news.astraweb.com> <4D3CBD79.3000905@v.loewis.de> Message-ID: <4d3cd35e$0$29974$c3e8da3$5496439d@news.astraweb.com> On Mon, 24 Jan 2011 00:44:57 +0100, Martin v. Loewis wrote: >> For something as common as displaying a file browser, it should be as >> simple as this: >> >> import gui_toolkit # whichever >> path = gui_toolkit.select_file() >> >> Something like zenity: >> >> [steve at sylar ~]$ zenity --file-selection >> /home/steve/python/findsingle.py > > And indeed, it is that simple: > > python -c "import tkFileDialog as tkfd;print tkfd.askopenfilename()" Brilliant! Pity that it is so ugly under Linux :( -- Steven From rantingrick at gmail.com Sun Jan 23 20:18:30 2011 From: rantingrick at gmail.com (rantingrick) Date: Sun, 23 Jan 2011 17:18:30 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <033c3f90-03fb-4f65-bbae-bbc80a262685@l22g2000vbp.googlegroups.com> Message-ID: On Jan 23, 5:27?pm, "Martin v. Loewis" wrote: > Since you are asking for a traceback, here is one: [...snip: barf...] > If you had expected a Python traceback, sorry Rick: it didn't produce > one, since it crashed. Well i did "expect" that you would at least include some info as to your OS and version. That would be helpful also. Obviously the wx.ImageList is barfing. Do you have the Bitmap folder containing the three images. Did you try to comment out the "_createImages()" line. Simple debug skills we are talking about here Martin, simple. But yet again this is only tested on Windows. I clearly noted that in the source. From rantingrick at gmail.com Sun Jan 23 20:25:12 2011 From: rantingrick at gmail.com (rantingrick) Date: Sun, 23 Jan 2011 17:25:12 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <480571f5-5731-4f8b-9cb4-1468478711bf@c39g2000yqi.googlegroups.com> <2c951199-3dba-4d24-a5c2-f84081688f7e@u6g2000yqk.googlegroups.com> <3e603997-5539-4660-bd83-7398bdab34a4@k30g2000vbn.googlegroups.com> <5edded76-fdac-4eb5-8480-25e3381e2fd4@g26g2000vbz.googlegroups.com> <1d7fdb0c-9f82-45ab-bf0e-99d210042f0d@j21g2000vbn.googlegroups.com> <4d3cb5fc$0$29983$c3e8da3$5496439d@news.astraweb.com> <4D3CBD79.3000905@v.loewis.de> Message-ID: <47190643-c3e1-4229-a456-fc505a13c10b@k22g2000yqh.googlegroups.com> On Jan 23, 5:44?pm, "Martin v. Loewis" wrote: > > For something as common as displaying a file browser, it should be as > > simple as this: > > > import gui_toolkit ?# whichever > > path = gui_toolkit.select_file() > > > Something like zenity: > > > [steve at sylar ~]$ zenity --file-selection > > /home/steve/python/findsingle.py > > And indeed, it is that simple: > > python -c "import tkFileDialog as tkfd;print tkfd.askopenfilename()" Martin the tkFileDialog.ask* uses the platform specific Open, Save dialogs which DO contain a ListCtrl. Obviously this ListCtrl is not available to Tkinter uses. You just exposed your weak knowledge of Tkinter and sadly you are very high on the community totem pole. Very sad :( From rantingrick at gmail.com Sun Jan 23 20:26:13 2011 From: rantingrick at gmail.com (rantingrick) Date: Sun, 23 Jan 2011 17:26:13 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <3a96fee1-995f-49f7-a967-f125cc3f1cdc@v26g2000yqf.googlegroups.com> Message-ID: <5aa673d3-bb9e-4905-b8eb-7c51b8a174d0@v17g2000yqv.googlegroups.com> On Jan 23, 6:31?pm, "Martin v. Loewis" wrote: > > WxPython Challenge 1 code updated... > > > ?* Fixed tab traveral > > ?* Removed hand-holding code > > ?* Removed some cruft > > > ?https://sites.google.com/site/thefutureofpython/home/code-challenges > > > Good luck! > > Still crashes the interpreter. What OS are you using? You failed to answer this last question lastime. From rantingrick at gmail.com Sun Jan 23 20:28:13 2011 From: rantingrick at gmail.com (rantingrick) Date: Sun, 23 Jan 2011 17:28:13 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <3a96fee1-995f-49f7-a967-f125cc3f1cdc@v26g2000yqf.googlegroups.com> Message-ID: <4ef41c75-8372-4a94-a93c-1b4e7a6e0759@m13g2000yqb.googlegroups.com> On Jan 23, 6:30?pm, Corey Richardson wrote: > On 01/23/2011 07:07 PM, rantingrick wrote: > > > On Jan 22, 6:07 pm, rantingrick ?wrote: > > >> I await any challengers... > > > WxPython Challenge 1 code updated... > > > ? * Fixed tab traveral > > ? * Removed hand-holding code > > ? * Removed some cruft > > > ? ?https://sites.google.com/site/thefutureofpython/home/code-challenges > > > Good luck! > > Still doesn't fix the problem of the code not working on Linux boxes. > Maybe wxPython isn't the best option, it doesn't appear very cross-platform. > Still getting: > > Loading Images: > ? -- /home/corey/Downloads/Wx_Tk_Challenge/Bitmaps/file.bmp, file.bmp > ? -- /home/corey/Downloads/Wx_Tk_Challenge/Bitmaps/folder.bmp, folder.bmp > ? -- /home/corey/Downloads/Wx_Tk_Challenge/Bitmaps/link.bmp, link.bmp > imageMap.keys -> ['folder', 'link', 'file'] > Segmentation fault Have you tried any debugging? Maybe Linux has some specific needs and NOT wxPython. Stop jumping to conclusions. From rantingrick at gmail.com Sun Jan 23 20:33:22 2011 From: rantingrick at gmail.com (rantingrick) Date: Sun, 23 Jan 2011 17:33:22 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <70498$4d3cb87c$4275d90a$4428@FUSE.NET> <63eea$4d3cd2fd$4275d90a$14984@FUSE.NET> Message-ID: <69465430-08b3-4069-99c7-72f4d3034c66@s5g2000yqm.googlegroups.com> On Jan 23, 7:16?pm, Kevin Walzer wrote: > On 1/23/11 8:12 PM, rantingrick wrote: > > > The only way i can respond to this is to quite the requirements for my > > challenge... > > > --------------------------------------- > > ? Challenge 1: (Simple Directory Viewer) > > --------------------------------------- > > Create a simple Directory Viewer GUI. You CANNOT use a treectrl! > > > Any questions? > > Why not? > > I'd understand if this code made use of some Tk extension, as that's not > quite an apples-to-apples comparison. But the treectrl is part of the > core Tkinter widget set. Well wxPython ha a treectrl too. And if we were comparing apples to apples then we would compare the wx.TreeCtrl to the Tk::TreeCtrl. However there are many things that a ListCtrl can do that a treectrl can't. The biggest difference.... COLUMNS > There's no reason to exclude it (Tk::TreeCtrl) unless you are > deliberately trying to handicap Tk in your comparison. I am not handicapping TclTk. They already did that themselves by refusing to keep up with 21st century GUI libraries. Sure, you can say Tkinter is a knife and wxPython is an AK47 but who's to blame when you bring a knife to gun fight Kevin? Switch to wx and enjoy the bloodbath. From rantingrick at gmail.com Sun Jan 23 20:36:21 2011 From: rantingrick at gmail.com (rantingrick) Date: Sun, 23 Jan 2011 17:36:21 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <480571f5-5731-4f8b-9cb4-1468478711bf@c39g2000yqi.googlegroups.com> <2c951199-3dba-4d24-a5c2-f84081688f7e@u6g2000yqk.googlegroups.com> <3e603997-5539-4660-bd83-7398bdab34a4@k30g2000vbn.googlegroups.com> <5edded76-fdac-4eb5-8480-25e3381e2fd4@g26g2000vbz.googlegroups.com> <1d7fdb0c-9f82-45ab-bf0e-99d210042f0d@j21g2000vbn.googlegroups.com> <4d3cb5fc$0$29983$c3e8da3$5496439d@news.astraweb.com> <4D3CBD79.3000905@v.loewis.de> <4d3cd35e$0$29974$c3e8da3$5496439d@news.astraweb.com> Message-ID: <743a0bfa-49ff-42b3-a462-f5976b653b21@l19g2000yqo.googlegroups.com> On Jan 23, 7:18?pm, Steven D'Aprano wrote: > On Mon, 24 Jan 2011 00:44:57 +0100, Martin v. Loewis wrote: > >> For something as common as displaying a file browser, it should be as > >> simple as this: > > >> import gui_toolkit ?# whichever > >> path = gui_toolkit.select_file() > > >> Something like zenity: > > >> [steve at sylar ~]$ zenity --file-selection > >> /home/steve/python/findsingle.py > > > And indeed, it is that simple: > > > python -c "import tkFileDialog as tkfd;print tkfd.askopenfilename()" > > Brilliant! No, that was even weaker than Guido's tag argument. At LEAST when Guido parrots off minor issues he uses some fact based argument. This is just pathetic! Only the lemmings would believe such nonsense. > Pity that it is so ugly under Linux :( And who's fault is that i wonder? From kb1pkl at aim.com Sun Jan 23 20:40:34 2011 From: kb1pkl at aim.com (Corey Richardson) Date: Sun, 23 Jan 2011 20:40:34 -0500 Subject: WxPython versus Tkinter. In-Reply-To: <47190643-c3e1-4229-a456-fc505a13c10b@k22g2000yqh.googlegroups.com> References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <480571f5-5731-4f8b-9cb4-1468478711bf@c39g2000yqi.googlegroups.com> <2c951199-3dba-4d24-a5c2-f84081688f7e@u6g2000yqk.googlegroups.com> <3e603997-5539-4660-bd83-7398bdab34a4@k30g2000vbn.googlegroups.com> <5edded76-fdac-4eb5-8480-25e3381e2fd4@g26g2000vbz.googlegroups.com> <1d7fdb0c-9f82-45ab-bf0e-99d210042f0d@j21g2000vbn.googlegroups.com> <4d3cb5fc$0$29983$c3e8da3$5496439d@news.astraweb.com> <4D3CBD79.3000905@v.loewis.de> <47190643-c3e1-4229-a456-fc505a13c10b@k22g2000yqh.googlegroups.com> Message-ID: <4D3CD892.1070103@aim.com> On 01/23/2011 08:25 PM, rantingrick wrote: > On Jan 23, 5:44 pm, "Martin v. Loewis" wrote: >>> For something as common as displaying a file browser, it should be as >>> simple as this: >> >>> import gui_toolkit # whichever >>> path = gui_toolkit.select_file() >> >>> Something like zenity: >> >>> [steve at sylar ~]$ zenity --file-selection >>> /home/steve/python/findsingle.py >> >> And indeed, it is that simple: >> >> python -c "import tkFileDialog as tkfd;print tkfd.askopenfilename()" > > > Martin the tkFileDialog.ask* uses the platform specific Open, Save > dialogs which DO contain a ListCtrl. Obviously this ListCtrl is not > available to Tkinter uses. You just exposed your weak knowledge of > Tkinter and sadly you are very high on the community totem pole. Very > sad :( > Actually, the people on the top of the totem pole were of less social status. http://podcasts.howstuffworks.com/hsw/podcasts/sysk/2009-11-17-sysk-totem-poles.mp3?_kip_ipx=1723793795-1295833113 (Finally, useful knowledge from listening to podcasts in my off-time!) You have also ignored that I gave the same information as him (minus the traceback), saying that I am on Linux Mint 64bit. Why can't we use a TreeCtrl? If we can't use all our widgets, why can you use all yours? ~Corey From rantingrick at gmail.com Sun Jan 23 20:50:24 2011 From: rantingrick at gmail.com (rantingrick) Date: Sun, 23 Jan 2011 17:50:24 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <480571f5-5731-4f8b-9cb4-1468478711bf@c39g2000yqi.googlegroups.com> <2c951199-3dba-4d24-a5c2-f84081688f7e@u6g2000yqk.googlegroups.com> <3e603997-5539-4660-bd83-7398bdab34a4@k30g2000vbn.googlegroups.com> <5edded76-fdac-4eb5-8480-25e3381e2fd4@g26g2000vbz.googlegroups.com> <1d7fdb0c-9f82-45ab-bf0e-99d210042f0d@j21g2000vbn.googlegroups.com> <4d3cb5fc$0$29983$c3e8da3$5496439d@news.astraweb.com> <4D3CBD79.3000905@v.loewis.de> <47190643-c3e1-4229-a456-fc505a13c10b@k22g2000yqh.googlegroups.com> Message-ID: <26ca9b38-3ecc-4276-a8cf-95bea74fc41c@r14g2000yqn.googlegroups.com> On Jan 23, 7:40?pm, Corey Richardson wrote: > Why can't we use a TreeCtrl? If we can't use all our widgets, why can > you use all yours? > > ~Corey Columns Corey, the key word here is "columns". One more time...COOOOOOLLLLLUUUMMMNNNSSSS. Is this starting to sink in yet Corey? From drsalists at gmail.com Sun Jan 23 21:06:36 2011 From: drsalists at gmail.com (Dan Stromberg) Date: Sun, 23 Jan 2011 18:06:36 -0800 Subject: How to execute foreing code from Python In-Reply-To: <4D3CC6C4.3060502@ieee.org> References: <20cf30433cec39ebdb049a8ae637@google.com> <4D3CC6C4.3060502@ieee.org> Message-ID: On Sun, Jan 23, 2011 at 4:24 PM, Dave Angel wrote: > On 01/-10/-28163 02:59 PM, hidura at gmail.com wrote: >> >> Hello i want to code from different languages using a Python script i >> know i can use os.system, but i don't know how to receive data or send >> arguments using that method if theres any another way to make it or >> there's a way to send arguments and receive data using os.system? >> >> Thanks in advance. >> > > That sentence runs on, and makes no sense to me. ?But I can guess that you > would like to be able to write code in other languages, and call it from > within a Python script. Well, clearly it made some sense, or you wouldn't be responding. > If you're on Windows, and the other language is a compiled one like C, > compile it into a DLL, and call that DLL from Python. ?Ctypes is the first > module to study. The DLL is but a weak mimicry of what *ix had for a long time before. On most *ix's, the .so is the analog to the windows DLL, though only AIX appears to suffer from the same kind of "DLL hell" that windows suffers from (which makes some historical if not technical sense, given that windows is related to OS/2, which like AIX is also from IBM). Using a .so, you can still use ctypes. You also have the option of using Cython, which is perhaps a bit better supported on *ix, but will likely now work on windows too. > If you're on Linux, and the code in the other language was written by > someone else, and is already compiled into an executable you cannot change, This is rare on Linux - almost everything is changeable on Linux, because it is almost entirely opensource - sometimes entirely so, depending on distribution choice and what 3rd party apps you install after the OS install. > you probably should invoke it using the subprocess module. This is an option on almost any OS, and in fact is probably a pretty good one on almost any OS, even if you do have source. Sadly, few windows programs are written to take advantage of this, perhaps because of the historical (dos/windows) command.com's fake pipes. You can communicate with a subprocess using pipes, or command line arguments, or files, or sockets, or shared memory. There are probably other options that aren't coming to mind just now. But usually, using pipes gives the loosest (best) coupling between processes. Microsoft appears to have recognized this to some extent by releasing powershell - though it uses object pipes rather than byte stream pipes. Object pipes appear to require less serialization, but also appear to be less loosely coupled. For remote pipes, powershell serializes to XML, while *ix pipes serialize exactly the same way remote local or remote. From kb1pkl at aim.com Sun Jan 23 21:06:57 2011 From: kb1pkl at aim.com (Corey Richardson) Date: Sun, 23 Jan 2011 21:06:57 -0500 Subject: WxPython versus Tkinter. In-Reply-To: <26ca9b38-3ecc-4276-a8cf-95bea74fc41c@r14g2000yqn.googlegroups.com> References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <480571f5-5731-4f8b-9cb4-1468478711bf@c39g2000yqi.googlegroups.com> <2c951199-3dba-4d24-a5c2-f84081688f7e@u6g2000yqk.googlegroups.com> <3e603997-5539-4660-bd83-7398bdab34a4@k30g2000vbn.googlegroups.com> <5edded76-fdac-4eb5-8480-25e3381e2fd4@g26g2000vbz.googlegroups.com> <1d7fdb0c-9f82-45ab-bf0e-99d210042f0d@j21g2000vbn.googlegroups.com> <4d3cb5fc$0$29983$c3e8da3$5496439d@news.astraweb.com> <4D3CBD79.3000905@v.loewis.de> <47190643-c3e1-4229-a456-fc505a13c10b@k22g2000yqh.googlegroups.com> <26ca9b38-3ecc-4276-a8cf-95bea74fc41c@r14g2000yqn.googlegroups.com> Message-ID: <4D3CDEC1.80102@aim.com> On 01/23/2011 08:50 PM, rantingrick wrote: > On Jan 23, 7:40 pm, Corey Richardson wrote: > >> Why can't we use a TreeCtrl? If we can't use all our widgets, why can >> you use all yours? >> >> ~Corey > > Columns Corey, the key word here is "columns". One more > time...COOOOOOLLLLLUUUMMMNNNSSSS. Is this starting to sink in yet > Corey? I sent that email before you sent your email explaining why (responded to Kevin), sorry that I can't see the future. From kb1pkl at aim.com Sun Jan 23 21:07:33 2011 From: kb1pkl at aim.com (Corey Richardson) Date: Sun, 23 Jan 2011 21:07:33 -0500 Subject: WxPython versus Tkinter. In-Reply-To: <4ef41c75-8372-4a94-a93c-1b4e7a6e0759@m13g2000yqb.googlegroups.com> References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <3a96fee1-995f-49f7-a967-f125cc3f1cdc@v26g2000yqf.googlegroups.com> <4ef41c75-8372-4a94-a93c-1b4e7a6e0759@m13g2000yqb.googlegroups.com> Message-ID: <4D3CDEE5.4010309@aim.com> On 01/23/2011 08:28 PM, rantingrick wrote: > On Jan 23, 6:30 pm, Corey Richardson wrote: >> On 01/23/2011 07:07 PM, rantingrick wrote: >> >>> On Jan 22, 6:07 pm, rantingrick wrote: >> >>>> I await any challengers... >> >>> WxPython Challenge 1 code updated... >> >>> * Fixed tab traveral >>> * Removed hand-holding code >>> * Removed some cruft >> >>> https://sites.google.com/site/thefutureofpython/home/code-challenges >> >>> Good luck! >> >> Still doesn't fix the problem of the code not working on Linux boxes. >> Maybe wxPython isn't the best option, it doesn't appear very cross-platform. >> Still getting: >> >> Loading Images: >> -- /home/corey/Downloads/Wx_Tk_Challenge/Bitmaps/file.bmp, file.bmp >> -- /home/corey/Downloads/Wx_Tk_Challenge/Bitmaps/folder.bmp, folder.bmp >> -- /home/corey/Downloads/Wx_Tk_Challenge/Bitmaps/link.bmp, link.bmp >> imageMap.keys -> ['folder', 'link', 'file'] >> Segmentation fault > > Have you tried any debugging? Maybe Linux has some specific needs and > NOT wxPython. Stop jumping to conclusions. Python (and supposedly wxPython) are cross-platform. Code that runs on one should run on the other unmodified. This is obviously not the case. Line 151 fails (determined from a simple binary search using print statements): index = self.InsertImageStringItem(sys.maxint, name, imageIdx) Maybe wxPython (really wxwidgets, python doesn't throw segfaults...that I've ever seen) isn't suited for the stdlib, unless this is a just a really silly bug somewhere in your programming (which I doubt it is). Looks like an issue with the method, because imageIdx is just a dictionary, sys.maxint is a (surprise!) integer, and name is a string. From hidura at gmail.com Sun Jan 23 21:16:26 2011 From: hidura at gmail.com (Hidura) Date: Sun, 23 Jan 2011 22:16:26 -0400 Subject: How to execute foreing code from Python In-Reply-To: References: <20cf30433cec39ebdb049a8ae637@google.com> <4D3CC6C4.3060502@ieee.org> Message-ID: Thanks to all for your fast responses. I will use this on a server running on Linux, so there is no problem with the OS and probably i will try to pipes and subprocess, but the pipes worry me because i can't stop the process using timeout or i don't found how to stop it... 2011/1/23, Dan Stromberg : > On Sun, Jan 23, 2011 at 4:24 PM, Dave Angel wrote: >> On 01/-10/-28163 02:59 PM, hidura at gmail.com wrote: >>> >>> Hello i want to code from different languages using a Python script i >>> know i can use os.system, but i don't know how to receive data or send >>> arguments using that method if theres any another way to make it or >>> there's a way to send arguments and receive data using os.system? >>> >>> Thanks in advance. >>> >> >> That sentence runs on, and makes no sense to me. ?But I can guess that you >> would like to be able to write code in other languages, and call it from >> within a Python script. > > Well, clearly it made some sense, or you wouldn't be responding. > >> If you're on Windows, and the other language is a compiled one like C, >> compile it into a DLL, and call that DLL from Python. ?Ctypes is the first >> module to study. > > The DLL is but a weak mimicry of what *ix had for a long time before. > On most *ix's, the .so is the analog to the windows DLL, though only > AIX appears to suffer from the same kind of "DLL hell" that windows > suffers from (which makes some historical if not technical sense, > given that windows is related to OS/2, which like AIX is also from > IBM). Using a .so, you can still use ctypes. You also have the > option of using Cython, which is perhaps a bit better supported on > *ix, but will likely now work on windows too. > >> If you're on Linux, and the code in the other language was written by >> someone else, and is already compiled into an executable you cannot >> change, > > This is rare on Linux - almost everything is changeable on Linux, > because it is almost entirely opensource - sometimes entirely so, > depending on distribution choice and what 3rd party apps you install > after the OS install. > >> you probably should invoke it using the subprocess module. > > This is an option on almost any OS, and in fact is probably a pretty > good one on almost any OS, even if you do have source. Sadly, few > windows programs are written to take advantage of this, perhaps > because of the historical (dos/windows) command.com's fake pipes. > > You can communicate with a subprocess using pipes, or command line > arguments, or files, or sockets, or shared memory. There are probably > other options that aren't coming to mind just now. But usually, using > pipes gives the loosest (best) coupling between processes. > > Microsoft appears to have recognized this to some extent by releasing > powershell - though it uses object pipes rather than byte stream > pipes. Object pipes appear to require less serialization, but also > appear to be less loosely coupled. For remote pipes, powershell > serializes to XML, while *ix pipes serialize exactly the same way > remote local or remote. > -- Enviado desde mi dispositivo m?vil Diego I. Hidalgo D. From kw at codebykevin.com Sun Jan 23 21:16:49 2011 From: kw at codebykevin.com (Kevin Walzer) Date: Sun, 23 Jan 2011 21:16:49 -0500 Subject: WxPython versus Tkinter. In-Reply-To: <69465430-08b3-4069-99c7-72f4d3034c66@s5g2000yqm.googlegroups.com> References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <70498$4d3cb87c$4275d90a$4428@FUSE.NET> <63eea$4d3cd2fd$4275d90a$14984@FUSE.NET> <69465430-08b3-4069-99c7-72f4d3034c66@s5g2000yqm.googlegroups.com> Message-ID: <705ad$4d3ce0fc$4275d90a$29144@FUSE.NET> On 1/23/11 8:33 PM, rantingrick wrote: > Well wxPython ha a treectrl too. And if we were comparing apples to > apples then we would compare the wx.TreeCtrl to the Tk::TreeCtrl. > However there are many things that a ListCtrl can do that a treectrl > can't. The biggest difference.... COLUMNS The ttk::treeview widget can also function as a multi-column listbox, and can include both tree and multi-column listbox features in a single window. It's a very flexible widget. -- Kevin Walzer Code by Kevin http://www.codebykevin.com From rantingrick at gmail.com Sun Jan 23 21:27:34 2011 From: rantingrick at gmail.com (rantingrick) Date: Sun, 23 Jan 2011 18:27:34 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <480571f5-5731-4f8b-9cb4-1468478711bf@c39g2000yqi.googlegroups.com> <2c951199-3dba-4d24-a5c2-f84081688f7e@u6g2000yqk.googlegroups.com> <3e603997-5539-4660-bd83-7398bdab34a4@k30g2000vbn.googlegroups.com> <5edded76-fdac-4eb5-8480-25e3381e2fd4@g26g2000vbz.googlegroups.com> <1d7fdb0c-9f82-45ab-bf0e-99d210042f0d@j21g2000vbn.googlegroups.com> <4d3cb5fc$0$29983$c3e8da3$5496439d@news.astraweb.com> <4D3CBD79.3000905@v.loewis.de> <47190643-c3e1-4229-a456-fc505a13c10b@k22g2000yqh.googlegroups.com> <26ca9b38-3ecc-4276-a8cf-95bea74fc41c@r14g2000yqn.googlegroups.com> Message-ID: <3a500c4d-d780-45da-bdef-bbc3d7c5d3e7@u6g2000yqk.googlegroups.com> On Jan 23, 8:06?pm, Corey Richardson wrote: > > Columns Corey, the key word here is "columns". One more > > time...COOOOOOLLLLLUUUMMMNNNSSSS. Is this starting to sink in yet > > Corey? > > I sent that email before you sent your email explaining why (responded > to Kevin), sorry that I can't see the future. Don't worry, I forgive you Corey. We can't *all* be visionaries ;-) From rantingrick at gmail.com Sun Jan 23 21:29:41 2011 From: rantingrick at gmail.com (rantingrick) Date: Sun, 23 Jan 2011 18:29:41 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <3a96fee1-995f-49f7-a967-f125cc3f1cdc@v26g2000yqf.googlegroups.com> <4ef41c75-8372-4a94-a93c-1b4e7a6e0759@m13g2000yqb.googlegroups.com> Message-ID: <127931eb-239e-4dce-a06e-b10132b83214@k3g2000yqc.googlegroups.com> On Jan 23, 8:07?pm, Corey Richardson wrote: > because imageIdx is just a dictionary, No, imageIdx is an integer. From rantingrick at gmail.com Sun Jan 23 21:34:18 2011 From: rantingrick at gmail.com (rantingrick) Date: Sun, 23 Jan 2011 18:34:18 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <70498$4d3cb87c$4275d90a$4428@FUSE.NET> <63eea$4d3cd2fd$4275d90a$14984@FUSE.NET> <69465430-08b3-4069-99c7-72f4d3034c66@s5g2000yqm.googlegroups.com> <705ad$4d3ce0fc$4275d90a$29144@FUSE.NET> Message-ID: <3d68e6fe-be68-4713-8330-20886d914547@r29g2000yqj.googlegroups.com> On Jan 23, 8:16?pm, Kevin Walzer wrote: > The ttk::treeview widget can also function as a multi-column listbox, > and can include both tree and multi-column listbox features in a single > window. It's a very flexible widget. Can we see some working code? I would love to see some code Kevin. You might satisfy the column requirement however you also need editable labels and two veiw modes; reportview and listview. Actually it sounds pretty much like a (wait for it...) TreeCtrl to me. PS: Be sure not to cause any segfaults because these linux folks can't debug for shite! From kb1pkl at aim.com Sun Jan 23 21:40:41 2011 From: kb1pkl at aim.com (Corey Richardson) Date: Sun, 23 Jan 2011 21:40:41 -0500 Subject: WxPython versus Tkinter. In-Reply-To: <127931eb-239e-4dce-a06e-b10132b83214@k3g2000yqc.googlegroups.com> References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <3a96fee1-995f-49f7-a967-f125cc3f1cdc@v26g2000yqf.googlegroups.com> <4ef41c75-8372-4a94-a93c-1b4e7a6e0759@m13g2000yqb.googlegroups.com> <127931eb-239e-4dce-a06e-b10132b83214@k3g2000yqc.googlegroups.com> Message-ID: <4D3CE6A9.4070707@aim.com> On 01/23/2011 09:29 PM, rantingrick wrote: > On Jan 23, 8:07 pm, Corey Richardson wrote: > >> because imageIdx is just a dictionary, > > No, imageIdx is an integer. You're right. imageIdx = self.imageMap[iconname] I confused imageIdx with self.imageMap. But that still doesn't fix my problem, so before I go diving into the wxPython source, anyone have a 'quick fix'? From rantingrick at gmail.com Sun Jan 23 21:47:31 2011 From: rantingrick at gmail.com (rantingrick) Date: Sun, 23 Jan 2011 18:47:31 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> Message-ID: <2092760a-1f32-48aa-aee1-d7d648b23c66@32g2000yqz.googlegroups.com> On Jan 22, 6:07?pm, rantingrick wrote: > I await any challengers... CODE UPDATE: * removed sys.maxint (not sure how it got there?) https://sites.google.com/site/thefutureofpython/home/code-challenges From steve+comp.lang.python at pearwood.info Sun Jan 23 21:48:08 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 24 Jan 2011 02:48:08 GMT Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <480571f5-5731-4f8b-9cb4-1468478711bf@c39g2000yqi.googlegroups.com> <2c951199-3dba-4d24-a5c2-f84081688f7e@u6g2000yqk.googlegroups.com> <3e603997-5539-4660-bd83-7398bdab34a4@k30g2000vbn.googlegroups.com> <5edded76-fdac-4eb5-8480-25e3381e2fd4@g26g2000vbz.googlegroups.com> <1d7fdb0c-9f82-45ab-bf0e-99d210042f0d@j21g2000vbn.googlegroups.com> <4d3cb5fc$0$29983$c3e8da3$5496439d@news.astraweb.com> <4D3CBD79.3000905@v.loewis.de> <47190643-c3e1-4229-a456-fc505a13c10b@k22g2000yqh.googlegroups.com> <26ca9b38-3ecc-4276-a8cf-95bea74fc41c@r14g2000yqn.googlegroups.com> Message-ID: <4d3ce868$0$29974$c3e8da3$5496439d@news.astraweb.com> On Sun, 23 Jan 2011 17:50:24 -0800, rantingrick wrote: > On Jan 23, 7:40?pm, Corey Richardson wrote: > >> Why can't we use a TreeCtrl? If we can't use all our widgets, why can >> you use all yours? >> >> ~Corey > > Columns Corey, the key word here is "columns". One more > time...COOOOOOLLLLLUUUMMMNNNSSSS. Is this starting to sink in yet Corey? When I run the code snippet Martin provided under Linux, the file selection box shows files in columns. That's part of the reason why I consider it ugly -- I'm an old Mac guy, and I still dislike file selection tools that use the Windows 95 style 2-D layout: a-file e-file ... b-file f-file y-file c-file g-file z-file d-file h-file instead of a simple vertical list: a-file b-file c-file ... z-file Call me a dinosaur if you will, but I hate horizontal scrolling. -- Steven From ian.g.kelly at gmail.com Sun Jan 23 22:05:49 2011 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Sun, 23 Jan 2011 20:05:49 -0700 Subject: A and B but not C in list In-Reply-To: References: <8cae2caf-d3df-4ed3-9afb-29de97772298@m13g2000yqb.googlegroups.com> Message-ID: On Sun, Jan 23, 2011 at 2:34 PM, Christian Heimes wrote: > your_set = set(your_list) > > if your_set.issuperset(set([A, B])) and your_set.isdisjoint(set([C, D])): if your_set.intersection([A, B, C, D]) == set([A, B]): ... Cheers, Ian From kb1pkl at aim.com Sun Jan 23 22:25:10 2011 From: kb1pkl at aim.com (Corey Richardson) Date: Sun, 23 Jan 2011 22:25:10 -0500 Subject: WxPython versus Tkinter. In-Reply-To: <2092760a-1f32-48aa-aee1-d7d648b23c66@32g2000yqz.googlegroups.com> References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <2092760a-1f32-48aa-aee1-d7d648b23c66@32g2000yqz.googlegroups.com> Message-ID: <4D3CF116.2020504@aim.com> On 01/23/2011 09:47 PM, rantingrick wrote: > On Jan 22, 6:07 pm, rantingrick wrote: > >> I await any challengers... > > CODE UPDATE: > > * removed sys.maxint (not sure how it got there?) > > > https://sites.google.com/site/thefutureofpython/home/code-challenges In the example at http://www.wxpython.org/OSCON2004/advanced/wxPython-Advanced-OSCON2004.pdf they use sys.maxint, which may be where you got it (wild shot in the dark!). The following result in a segfault: -------item-1--------------------- list_item = wx.ListItem() list_item.SetId(idx) list_item.SetText(name) list_item.SetWidth(50) index = self.InsertItem(list_item) -----------end-------------------- ------item-2---------------------- self.InsertStringItem(idx, name) -----------end-------------------- The following will launch the application: (drop in replacement for line 151): index = self.SetStringItem(idx, 0, name) No idea why, I've never used wxPython before today. Unfortunately, it doesn't actually show the items in the directory. Since I'm definitely not a wxPython user, would you mind making the above work, rantingrick? Not trying to worm out of anything, but this is way over my head. ~Corey From tyler at tysdomain.com Sun Jan 23 23:16:15 2011 From: tyler at tysdomain.com (Littlefield, Tyler) Date: Sun, 23 Jan 2011 21:16:15 -0700 Subject: WxPython versus Tkinter. In-Reply-To: <3d68e6fe-be68-4713-8330-20886d914547@r29g2000yqj.googlegroups.com> References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <70498$4d3cb87c$4275d90a$4428@FUSE.NET> <63eea$4d3cd2fd$4275d90a$14984@FUSE.NET> <69465430-08b3-4069-99c7-72f4d3034c66@s5g2000yqm.googlegroups.com> <705ad$4d3ce0fc$4275d90a$29144@FUSE.NET> <3d68e6fe-be68-4713-8330-20886d914547@r29g2000yqj.googlegroups.com> Message-ID: <4D3CFD0F.1080502@tysdomain.com> >PS: Be sure not to cause any segfaults because these linux folks can't >debug for shite! Or maybe it is that the person fighting and throwing insults around like candy at a parade can't code for shite. Or *gasp* the library that is supposedly cross-platform has issues on certain platforms. You provided a challenge to show how superior wxPython was. If it segfaults, that tells me that: 1) you can't code worth "shite," or 2) the library you are drooling over sucks and shouldn't be cross-platform. Which is it? I highly doubt there is a third option, but please feel free to tell me, rather than insulting again. On 1/23/2011 7:34 PM, rantingrick wrote: > On Jan 23, 8:16 pm, Kevin Walzer wrote: > >> The ttk::treeview widget can also function as a multi-column listbox, >> and can include both tree and multi-column listbox features in a single >> window. It's a very flexible widget. > Can we see some working code? I would love to see some code Kevin. You > might satisfy the column requirement however you also need editable > labels and two veiw modes; reportview and listview. Actually it > sounds pretty much like a (wait for it...) TreeCtrl to me. > > PS: Be sure not to cause any segfaults because these linux folks can't > debug for shite! -- Thanks, Ty From rustompmody at gmail.com Mon Jan 24 01:06:48 2011 From: rustompmody at gmail.com (rusi) Date: Sun, 23 Jan 2011 22:06:48 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <70498$4d3cb87c$4275d90a$4428@FUSE.NET> <63eea$4d3cd2fd$4275d90a$14984@FUSE.NET> <69465430-08b3-4069-99c7-72f4d3034c66@s5g2000yqm.googlegroups.com> <705ad$4d3ce0fc$4275d90a$29144@FUSE.NET> <3d68e6fe-be68-4713-8330-20886d914547@r29g2000yqj.googlegroups.com> Message-ID: On Jan 24, 9:16?am, "Littlefield, Tyler" wrote: > ?>PS: Be sure not to cause any segfaults because these linux folks can't > ?>debug for shite! > Or maybe it is that the person fighting and throwing insults around like > candy at a parade can't code for shite. Or *gasp* the library that is > supposedly cross-platform has issues on certain platforms. You provided > a challenge to show how superior wxPython was. If it segfaults, that > tells me that: 1) you can't code worth "shite," or 2) the library you > are drooling over sucks and shouldn't be cross-platform. Which is it? I > highly doubt there is a third option, but please feel free to tell me, > rather than insulting again. I think there is a third option About rr's code-ing ability... this thread is long enough :-) Likewise if a certain library not in python standard distribution does not work properly its the problem of the library. But if python crashes its not good for the image of python. Personal note 1: I am often teaching python with code I am seeing for the first time -- typically something the class presents me which we understand/debug/refactor together. Usually I am not afraid of python because errors are helpful and gentle. Segfaulting on the other hand is the last thing I want to see in such a context :-) Personal note 2: I dont regard myself as a gui programmer and Ive often wondered which toolkit to demonstrate. I probably wont be looking at wx now unless someone gives a convincing argument that the segfault did not happen "inside" wx. Of course as Steven pointed out wx is written in C++ which is almost certainly where the crash is occurring. But this is technical nitpicking. The real issue is that when coding in C/C++ segfaults are a daily affair. Whereas for python its the first time I am seeing it in 10 years... From santhosh.vkumar at gmail.com Mon Jan 24 01:10:10 2011 From: santhosh.vkumar at gmail.com (Santhosh Kumar) Date: Mon, 24 Jan 2011 11:40:10 +0530 Subject: Get input in Python Message-ID: Hi all, I am trying to get input from the file* open(sys.argv[1]). *So, while executing I will refer it as python filename.py sample_file.txt this will root to my sys.argv[]. So I need to follow the same but I also need to give input Example : python filename.py . How should I do coding for this. Thanks in Advance, Santhosh V.Kumar -------------- next part -------------- An HTML attachment was scrubbed... URL: From clp2 at rebertia.com Mon Jan 24 01:37:08 2011 From: clp2 at rebertia.com (Chris Rebert) Date: Sun, 23 Jan 2011 22:37:08 -0800 Subject: Get input in Python In-Reply-To: References: Message-ID: On Sun, Jan 23, 2011 at 10:10 PM, Santhosh Kumar wrote: > Hi all, > ?? ? ? ? ?I am trying to get input from the file?open(sys.argv[1]). So, > while executing I will refer it as python filename.py ?sample_file.txt ?this > will root to my sys.argv[]. So I need to follow the same but I also need to > give input Example : ?python filename.py . How > should I do coding for this. Just access the text using sys.argv like before. It's just another element in the list; there's nothing special about it. You just need to change the indices accordingly: from sys import argv text = argv[1] filepath = argv[2] # alternatively: # text, filepath = argv[1:] print("Your text input was:") print(text) print("The file's contents are:") with file(filepath, 'r') as f: print(f.read()) Usage: $ python 'Hello there Santhosh' something.txt Your text input was: Hello there Santhosh The file's contents are: Note that the text is quoted; this is required if your text contains spaces and/or shell special characters. Cheers, Chris -- http://blog.rebertia.com From orasnita at gmail.com Mon Jan 24 01:52:18 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Mon, 24 Jan 2011 08:52:18 +0200 Subject: [Code Challenge] WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <70498$4d3cb87c$4275d90a$4428@FUSE.NET> Message-ID: <682981AD3E82477BBF5C16E4514ECD60@octavian> From: "Kevin Walzer" >I found this code in the Demo/tkinter/ttk directory of the Python 2.7.1 >source distribution. I'm NOT the author (credit should probably go to >Guilherme Polo, developer of the Tkinter wrapper for the ttk themed widgets >that is now in the stdlib). But, using a tree/listview widget that is part >of the Tk/Tkinter core (NOT an extension), it presents a decent, simple >file browser: > Well, I have also tested the program dirbrowser.py, but it is not decent at all. I have tested it with JAWS screen reader and it is absolutely inaccessible. The single "accessible" things in it are the title bar which is "tk". It can't compare with the same program made using WxPython. And it can't be made to be more accessible than it is, because it uses Tk. So Tkinter is really bad. Octavian From orasnita at gmail.com Mon Jan 24 01:54:16 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Mon, 24 Jan 2011 08:54:16 +0200 Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com><70498$4d3cb87c$4275d90a$4428@FUSE.NET><63eea$4d3cd2fd$4275d90a$14984@FUSE.NET><69465430-08b3-4069-99c7-72f4d3034c66@s5g2000yqm.googlegroups.com> <705ad$4d3ce0fc$4275d90a$29144@FUSE.NET> Message-ID: From: "Kevin Walzer" > The ttk::treeview widget can also function as a multi-column listbox, and > can include both tree and multi-column listbox features in a single > window. It's a very flexible widget. But unfortunately it is not accessible for screen readers and it discriminates many potential users. Octavian From orasnita at gmail.com Mon Jan 24 01:58:29 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Mon, 24 Jan 2011 08:58:29 +0200 Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <70498$4d3cb87c$4275d90a$4428@FUSE.NET> <63eea$4d3cd2fd$4275d90a$14984@FUSE.NET> <69465430-08b3-4069-99c7-72f4d3034c66@s5g2000yqm.googlegroups.com> <705ad$4d3ce0fc$4275d90a$29144@FUSE.NET><3d68e6fe-be68-4713-8330-20886d914547@r29g2000yqj.googlegroups.com> <4D3CFD0F.1080502@tysdomain.com> Message-ID: <58325C0B6449487E97D2523C1685624F@octavian> From: "Littlefield, Tyler" > >PS: Be sure not to cause any segfaults because these linux folks can't > >debug for shite! > Or maybe it is that the person fighting and throwing insults around like > candy at a parade can't code for shite. Or *gasp* the library that is > supposedly cross-platform has issues on certain platforms. You provided a > challenge to show how superior wxPython was. If it segfaults, that tells > me that: 1) you can't code worth "shite," or 2) the library you are > drooling over sucks and shouldn't be cross-platform. Which is it? I highly > doubt there is a third option, but please feel free to tell me, rather > than insulting again. Hi Tyler, Are you able to use Tkinter-based applications under Windows? Or you have started to use Linux and now you don't care about the majority of users that need to use a screen reader? Octavian From israelu at elbit.co.il Mon Jan 24 02:02:25 2011 From: israelu at elbit.co.il (iu2) Date: Sun, 23 Jan 2011 23:02:25 -0800 (PST) Subject: Converting functions Message-ID: <6c099cc0-9772-4151-86b9-d72242fbbdea@k13g2000vbq.googlegroups.com> Hi all, I'm trying to convert functions - pass a few functions to a converting function, which change their behaviour and return the changed functions: >>> def cfuncs(*funcs): n = [] for f in funcs: def ff(*args, **key): print 'Start!', f.func_name res = f(*args, **key) print 'End', f.func_name return res n.append(ff) return n then I try it using two functions: >>> def f1(): print 'hello' >>> def f2(x): return 2 * x Eventually: >>> newfuncs = cfuncs(f1, f2) I would expect newfuncs to hold changed versions of f1 and f2, but what is actually contained in newfuncs is twice the changed version of f2. That is: >>> newfuncs[1](100) Start! f2 End f2 200 which is what I expected, but: >>> newfuncs[0]() Start! f2 Traceback (most recent call last): File "", line 1, in newfuncs[0]() File "", line 6, in ff res = f(*args, **key) TypeError: f2() takes exactly 1 argument (0 given) which is not. I'll appreciate your help in pointing out the mistake in defining cfuncs and how to fix it. Thank you very much! From orasnita at gmail.com Mon Jan 24 02:05:02 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Mon, 24 Jan 2011 09:05:02 +0200 Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com><480571f5-5731-4f8b-9cb4-1468478711bf@c39g2000yqi.googlegroups.com><2c951199-3dba-4d24-a5c2-f84081688f7e@u6g2000yqk.googlegroups.com><3e603997-5539-4660-bd83-7398bdab34a4@k30g2000vbn.googlegroups.com><5edded76-fdac-4eb5-8480-25e3381e2fd4@g26g2000vbz.googlegroups.com><1d7fdb0c-9f82-45ab-bf0e-99d210042f0d@j21g2000vbn.googlegroups.com><4d3cb5fc$0$29983$c3e8da3$5496439d@news.astraweb.com><4D3CBD79.3000905@v.loewis.de> <47190643-c3e1-4229-a456-fc505a13c10b@k22g2000yqh.googlegroups.com> Message-ID: <7AF6F130FBC2447BA7D595777B8723FF@octavian> From: "rantingrick" On Jan 23, 5:44 pm, "Martin v. Loewis" wrote: > > For something as common as displaying a file browser, it should be as > > simple as this: > > > import gui_toolkit # whichever > > path = gui_toolkit.select_file() > > > Something like zenity: > > > [steve at sylar ~]$ zenity --file-selection > > /home/steve/python/findsingle.py > > And indeed, it is that simple: > > python -c "import tkFileDialog as tkfd;print tkfd.askopenfilename()" Martin the tkFileDialog.ask* uses the platform specific Open, Save dialogs which DO contain a ListCtrl. Obviously this ListCtrl is not available to Tkinter uses. You just exposed your weak knowledge of Tkinter and sadly you are very high on the community totem pole. Very sad :( Aha, that's why that Open File window was accessible for JAWS screen reader, although it uses Tk... because actually it doesn't use Tk. Octavian From user at compgroups.net/ Mon Jan 24 02:18:08 2011 From: user at compgroups.net/ (fara) Date: Mon, 24 Jan 2011 01:18:08 -0600 Subject: switch from default env to virtualenv and back in script Message-ID: Hi, My default environment uses Python2.6 but I have a also virtualenv with Python2.7 with different packages. Is it possible to write a script where some parts are executed in the default Python2.6 environment and some others in the Python2.7 virtualenv. Something like this: ##### Start of pseudoscript import (Python2.6) packages execute code in Python2.6 switch to Python2.7 virtualenv import (Python2.7) packages execute code in the Python2.7 virtualenv and store information for later use switch back to default Python2.6 import (Python2.6) packages execute Python2.6 functions ##### End of pseudoscript Thanks Fara From enalicho at gmail.com Mon Jan 24 02:46:34 2011 From: enalicho at gmail.com (Noah Hall) Date: Mon, 24 Jan 2011 07:46:34 +0000 Subject: WxPython versus Tkinter. In-Reply-To: References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> Message-ID: On Sun, Jan 23, 2011 at 5:31 PM, rantingrick wrote: > So far only trolls (besides Terry, Octavian, D'Aprano) have replied. > In my time here within the Python community i have only met one person > who shares my in-depth knowledge of Tkinter. That person is Kevin > Waltzer. So outside of Python-dev and Guido. Kevin and I are are the > ONLY people qualified to offer opinions on the worth or worthlessness > of Tkinter. If anyone in this entire community thinks that they also > are qualified then prove your worth by creating a ListCtrl in Tkinter > that mirrors the wxPython ListCtrl in functionality. When you have > done that, i will elevate you to my circle of enlightenment. Than and > only then shall i even entertain you BS. Wow, someone's certainly feeling very self-important, ignoring the fact he can't follow conventions nor write cross-platform software. And before you start, no, I don't want to steal your "file browser". From __peter__ at web.de Mon Jan 24 02:51:24 2011 From: __peter__ at web.de (Peter Otten) Date: Mon, 24 Jan 2011 08:51:24 +0100 Subject: Converting functions References: <6c099cc0-9772-4151-86b9-d72242fbbdea@k13g2000vbq.googlegroups.com> Message-ID: iu2 wrote: > I'm trying to convert functions - pass a few functions to a converting > function, which change their behaviour and return the changed > functions: > > >>> def cfuncs(*funcs): > n = [] > for f in funcs: > def ff(*args, **key): > print 'Start!', f.func_name > res = f(*args, **key) > print 'End', f.func_name > return res > n.append(ff) > return n > > then I try it using two functions: > > >>> def f1(): > print 'hello' > > > >>> def f2(x): > return 2 * x > > Eventually: > >>> newfuncs = cfuncs(f1, f2) > > I would expect newfuncs to hold changed versions of f1 and f2, but > what is actually contained in newfuncs is twice the changed version of > f2. That is because the inner ff() references f which is a local variable of cfuncs(). By the time you invoke your newly created functions cfuncs() and thus the 'for f in funcs' loop has finished and the value of f is that of the last item in the funcs tuple. You can avoid the problem with another indirection def make_ff(f): def ff(*args, **key): print 'Start!', f.func_name res = f(*args, **key) print 'End', f.func_name return res return ff def cfuncs(*funcs): return [make_ff(f) for f in funcs] Peter From firedtoad at gmail.com Mon Jan 24 02:55:54 2011 From: firedtoad at gmail.com (wenhao zhang) Date: Mon, 24 Jan 2011 15:55:54 +0800 Subject: attend Message-ID: attend&& Join -------------- next part -------------- An HTML attachment was scrubbed... URL: From __peter__ at web.de Mon Jan 24 03:32:33 2011 From: __peter__ at web.de (Peter Otten) Date: Mon, 24 Jan 2011 09:32:33 +0100 Subject: documentation / reference help References: Message-ID: Scott Meup wrote: > I'm trying tolearn Python. The documentation tells syntax, and other > things > about a command. But for too many commands, it doesn't tell what it does. > for instance, in VB the 'return' command tells the program what line to > execute after some event (usually an error). In Python it appears to > return > a value. Where does it return it to? I couldn't find anywhere on the > Python website to find out or to ask Python to upgrade their > documentation. Can somebody please recommend a source. Python's return has nothing to do with with gosub ... return in Basic. I believe the analog to Python's return in VB is = exit function I. e. Function f(a, b) If a > b Then f = 42 Exit Function End If f = a + b End Function translates to def f(a, b): if a > b: return 42 return a + b in Python. From __peter__ at web.de Mon Jan 24 03:47:01 2011 From: __peter__ at web.de (Peter Otten) Date: Mon, 24 Jan 2011 09:47:01 +0100 Subject: A and B but not C in list References: <8cae2caf-d3df-4ed3-9afb-29de97772298@m13g2000yqb.googlegroups.com> Message-ID: Ian Kelly wrote: > On Sun, Jan 23, 2011 at 2:34 PM, Christian Heimes > wrote: >> your_set = set(your_list) >> >> if your_set.issuperset(set([A, B])) and your_set.isdisjoint(set([C, D])): > > if your_set.intersection([A, B, C, D]) == set([A, B]): > ... You can avoid converting your_list to a set with (using 2.7/3.x notation) if {A, B, C, D}.intersection(your_list) == {A, B}: ... The items in your_list still have to be hashable, so the approach is not as general as if (all(required in your_list for required in (A, B)) and not any(forbidden in your_list for forbidden in (C, D))): ... or similar. Also, it's not as easy to understand, so don't forget the explaining comment if you use the set-based approach. Peter From martin at v.loewis.de Mon Jan 24 03:56:16 2011 From: martin at v.loewis.de (Martin v. Loewis) Date: Mon, 24 Jan 2011 09:56:16 +0100 Subject: WxPython versus Tkinter. In-Reply-To: References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <033c3f90-03fb-4f65-bbae-bbc80a262685@l22g2000vbp.googlegroups.com> Message-ID: > Well i did "expect" that you would at least include some info as to > your OS and version. OS is Linux, wxPython is Debian python-wxgtk2.6 2.6.3.2.2-5+b1. > That would be helpful also. Obviously the > wx.ImageList is barfing. Do you have the Bitmap folder containing the > three images. Did you try to comment out the "_createImages()" line. If I do, I get Traceback (most recent call last): File "wxtk_challenge_1.py", line 222, in frame = AppFrame() File "wxtk_challenge_1.py", line 206, in __init__ self.listWidget.showDirectory(sys.prefix) File "wxtk_challenge_1.py", line 150, in showDirectory imageIdx = self.imageMap[iconname] KeyError: 'folder' If I then also comment out lines 150..154, I get a window, but it's empty (of course). > Simple debug skills we are talking about here Martin, simple. But yet > again this is only tested on Windows. I clearly noted that in the > source. Well Rick, this doesn't make look wxPython any better. Regards, Martin From israelu at elbit.co.il Mon Jan 24 04:19:40 2011 From: israelu at elbit.co.il (iu2) Date: Mon, 24 Jan 2011 01:19:40 -0800 (PST) Subject: Converting functions References: <6c099cc0-9772-4151-86b9-d72242fbbdea@k13g2000vbq.googlegroups.com> Message-ID: On Jan 24, 9:51?am, Peter Otten <__pete... at web.de> wrote: > iu2 wrote: > > I'm trying to convert functions - pass a few functions to a converting > > function, which change their behaviour and return the changed > > functions: > > > >>> def cfuncs(*funcs): > > ? ? ? ? n = [] > > ? ? ? ? for f in funcs: > > ? ? ? ? ? ? ? ? def ff(*args, **key): > > ? ? ? ? ? ? ? ? ? ? ? ? print 'Start!', f.func_name > > ? ? ? ? ? ? ? ? ? ? ? ? res = f(*args, **key) > > ? ? ? ? ? ? ? ? ? ? ? ? print 'End', f.func_name > > ? ? ? ? ? ? ? ? ? ? ? ? return res > > ? ? ? ? ? ? ? ? n.append(ff) > > ? ? ? ? return n > > > then I try it using two functions: > > > >>> def f1(): > > ? ? ? ? print 'hello' > > > >>> def f2(x): > > ? ? ? ? return 2 * x > > > Eventually: > > >>> newfuncs = cfuncs(f1, f2) > > > I would expect newfuncs to hold changed versions of f1 and f2, but > > what is actually contained in newfuncs is twice the changed version of > > f2. > > That is because the inner ff() references f which is a local variable of > cfuncs(). By the time you invoke your newly created functions cfuncs() and > thus the 'for f in funcs' loop has finished and the value of f is that of > the last item in the funcs tuple. You can avoid the problem with another > indirection > > def make_ff(f): > ? ? def ff(*args, **key): > ? ? ? ? print 'Start!', f.func_name > ? ? ? ? res = f(*args, **key) > ? ? ? ? print 'End', f.func_name > ? ? ? ? return res > ? ? return ff ? ? ? ? > > def cfuncs(*funcs): > ? ? return [make_ff(f) for f in funcs] > > Peter- Hide quoted text - > > - Show quoted text - Thanks! I thought a function definition creates a closure around all used vars. As I understand now only variables that are passed as function arguments can participate in a closure. From __peter__ at web.de Mon Jan 24 04:50:46 2011 From: __peter__ at web.de (Peter Otten) Date: Mon, 24 Jan 2011 10:50:46 +0100 Subject: Converting functions References: <6c099cc0-9772-4151-86b9-d72242fbbdea@k13g2000vbq.googlegroups.com> Message-ID: iu2 wrote: > I thought a function definition creates a closure around all used > vars. > As I understand now only variables that are passed as function > arguments can participate in a closure. No, it's just that all closures see the value of a variable at the time when the closure is run, not when it's defined. I don't know how to express it more clearly, so here's another example: >>> def f(): ... def g(): return a * a ... def h(): return a + a ... a = 5 ... return g, h ... >>> g, h = f() >>> g(), h() (25, 10) As you can see the local variable is not yet set when g() and h() are defined; but only the value by the time they are invoked matters. Here's a more involved generator version where the value may change between invocations: >>> def f(items): ... def g(): return a * a ... def h(): return a + a ... yield g, h ... for a in items: ... yield a ... >>> ff = f([2,3,4]) >>> g, h = next(ff) >>> g() Traceback (most recent call last): File "", line 1, in File "", line 2, in g NameError: free variable 'a' referenced before assignment in enclosing scope >>> next(ff) 2 >>> g(), h() (4, 4) >>> next(ff) 3 >>> g(), h() (9, 6) I think this behaviour is also called "late binding". Peter From james at funkymonkeysoftware.com Mon Jan 24 05:02:55 2011 From: james at funkymonkeysoftware.com (James Ravenscroft) Date: Mon, 24 Jan 2011 10:02:55 +0000 Subject: List behaviours with Clustering Algorithm Message-ID: <4D3D4E4F.1070705@funkymonkeysoftware.com> Dear All, I am currently trying to write a simple Agglomerative Clustering algorithm which sorts through my MP3 collection and uses associated Last.FM tags to cluster files into 'genres'. Unfortunately, I'm having some trouble with my algorithm and some tracks are ending up in multiple clusters. I have a feeling this is because of (my lack of understanding of) list behaviours within Python. This is all purely a learning exercise, so any input would be greatly appreciated The actual clustering method can be seen described here. Each Cluster is stored within the 'clusters' array and has two elements: the data containing song metadata such as artist, title and most importantly tags, and a weight: that is, the overall Euclidean weight of the cluster (based on the song data within). In theory, the algorithm runs in a loop until all clusters have been merged into a hierarchy. It takes the weight of each cluster and merges each cluster with their closest counterpart. My code has a lot of comments so it should be fairly easy to understand. Please see below: #-----------------------------Code Snippet -----------------------------------------------# def cluster(self): '''Run the clustering operation on the files ''' #add a cluster for each track to clusters for song in self.music.keys(): self.clusters.append({ 'data' : [song], 'weight' : long(0) }) currentLevel = 0 #current level of hierarchy #while there is more than one cluster in the sorting bank # i.e. we haven't achieved hierachy yet, run the algorithm while( len(self.clusters) > 1): print "Currently at Level %d" % currentLevel print "There are %d clusters at this level" % len(self.clusters) #store the level in the levels array self.levels.append(self.clusters) #empty the clusters list self.clusters = [] #find the weight of each current cluster for c in self.levels[currentLevel]: self.clusters.append({'data' : c['data'], 'weight' : self.__getClusterWeight(c['data'])}) #do the actual clustering tmp = [] for c in self.clusters: closestCluster = None closestDelta = float('inf') for c2 in self.clusters: #skip if this is the same node if(c == c2): continue delta = abs(c2['weight'] - c['weight']) if(delta < closestDelta): closestCluster = c2 closestDelta = delta print "Merging clusters %(c1)d and %(c2)d" % {'c1' : self.clusters.index(c), 'c2' : self.clusters.index(closestCluster)} #now merge the two clusters self.clusters.remove(closestCluster) self.clusters.remove(c) c['data'].extend(closestCluster['data']) tmp.append(c) #increment the level of the hierarchy self.clusters = tmp currentLevel += 1 #--------------------------------End Code Snippet ----------------------------# Thanks, James -- James Ravenscroft http://blog.funkymonkeysoftware.com/ From mailing at franzoni.eu Mon Jan 24 05:13:49 2011 From: mailing at franzoni.eu (Alan Franzoni) Date: Mon, 24 Jan 2011 11:13:49 +0100 Subject: Behaviour-based interface/protocol implementation? Message-ID: Hello, I'd like to have a system which lets me do certain actions if the duck-type of a certain objects matches what I expect, i.e. I'd like to have a formalization of what it's sometimes done through getattr() calls: if getattr(myobj, "somemethod", None) is not None: myobj.somemethod(somevalue) The above approach is sometimes too naive, because a) clutters code with many getattr calls and ifs b) I might want to check for multiple attributes and c) only checks for the method name and not for the method's signature. After looking at PyProtocols, zope.interface and python's own abc module, I'm left with a doubt: does any behaviour-based "interface testing" system exist for Python? I mean: all these three libraries use a register-based or inheritance-based approach; in abc, if I want instances of a class of mine "FooClass" to be "BarInterface" instances, I can either a) inherit from BarInterface or b) run "BarInterface.register(FooClass)". This poses some issues in a purely duck-typed context, IMHO. If an object perfectly satisfies the "BarInterface" signature, but it doesn't inherit from MyInterface and its class wasn't registered as a BarInterface implementor, the check "isinstance(myobj, BarInterface)" will yield a False result. This might not be a big deal if a) python >= 2.6 is used b) just checking for builtin interfaces - e.g. those defined in the "collections" module is required and c) you just require checking on basic types or on python builtin types (which correctly register builtin ABCs). What happens if I define my own ABC for my own purpose? There might be builtin objects, or third party libraries, which already offer objects that satisfy such interface, but I'd need to import such modules and register such classes as implementing my ABC, which is suboptimal. What I'd like to do is: class MyType(object): def someMethod(self, a, b): pass def otherMethod(self): pass class OtherType(object): def someMethod(self): pass def otherMethod(self): pass @DuckType class MyDuckType(object): def someMethod(self, a, b): pass def otherMethod(self): pass class TestDuckTypes(TestCase): def test_mytype_is_compatible_with_ducktype(self): myobj = MyType() self.assertEquals(True, MyDuckType.maybe_implemented_by(myobj)) def test_othertype_is_not_compatible_with_ducktype(self): myobj = OtherType() self.assertEquals(False, MyDuckType.maybe_implemented_by(myobj)) I'd like to do a kind of runtime-check for signatures. Of course there couldn't be an absolute certainty of interface implementation, because a runtime dynamic proxy method (accepting *args and **kwargs in its signature, as an example) might just fool my signature check. So, my questions are: a) does anything like that already exist in the python ecosystem? b) can anybody see any flaw either in what I'd like to do ("you shouldn't do that because...") or in the way I want to do it ("It won't work because...") -- Alan Franzoni -- contact me at public@[mysurname].eu From edmunds at laivas.lv Mon Jan 24 06:12:17 2011 From: edmunds at laivas.lv (Edmunds Cers) Date: Mon, 24 Jan 2011 12:12:17 +0100 Subject: Converting functions References: <6c099cc0-9772-4151-86b9-d72242fbbdea@k13g2000vbq.googlegroups.com> Message-ID: <4d3d5e93$0$1071$afc38c87@read01.usenet4all.se> Peter Otten <__peter__ at web.de> writes: > I don't know how to express it more clearly, so here's another example: > >>>> def f(): > ... def g(): return a * a > ... def h(): return a + a > ... a = 5 > ... return g, h > ... >>>> g, h = f() >>>> g(), h() > (25, 10) IMHO this whole confusion just shows that mingling assignment and binding makes understanding scope harder. In Python, the first assignment inside a function body also creates a binding (unless told not to do so by global) the scope of which is the _whole_ of the function body. A variable reference refers to the lexically innermost surrounding binding of said variable. Now, while it might seem that some magic happens in the example on the return of the function, this is in fact not so, since the assignment "a = 5" actually creates a binding for /a/ that is visible from the body of /g/, because the lexical scope of the binding is the whole body of /f/, so that the capture of the variable happens inside of the def expression (as one would expect) and not on return as you seem to imply. Slightly OT -- the above also explains why closed over variables are read only in Python. An assignment inside a closure would implicitly create a binding, so that all (even previous) references to that variable would refer to this new binding. > I think this behaviour is also called "late binding". "Retroactive implicit scope" would be closer. -- A change in perspective is worth 80 IQ points. --- Alan Kay From tchsprt.box at gmail.com Mon Jan 24 06:28:19 2011 From: tchsprt.box at gmail.com (Tech Support Box) Date: Mon, 24 Jan 2011 03:28:19 -0800 (PST) Subject: Multiple python installations mix their sys.prefix Message-ID: Hi there I have several versions of python2.4 installed: - the OS, rpm-installed one in /usr - Several other versions in /usr/local, installed with --prefix /usr/ local/inst-shared/ --exec-prefix /usr/local/inst/ My problem is when starting one of the versions from /usr/local, sys.prefix is set as "/usr" instead of the compile-time setting "/usr/ local/inst-shared/" and as a result sys.path contains paths from /usr, which shouldn't be there. After strace-ing the pythons from /usr/local and the one from /usr, it seems that python determines sys.prefix by first looking for os.py in every path component of the interpreter executable and adding "/lib/ python2.4/os.py" to it (i.e. stat()-ing for /usr/local/inst// bin/lib/python2.4/os.py, then /usr/local/inst//lib/python2.4/ os.py and so on) and only after it doesn't find os.py in any one of those paths does it look at the compile-time PREFIX setting. When doing this, it finds /usr/lib/python2.4/os.py (which belongs to the python installed at /usr) and determines that sys.prefix is /usr, which is wrong. The only fix I could come up with is setting PYTHONHOME before running python (which should be set differently for every version, and won't work in scripts using a shebang line) or moving /usr/lib/python2.4 to a different location (which is plain ugly). Is there a better way to make python take its compile-time option of prefix and *not* try to guess at runtime where it should be? Thanks. From __peter__ at web.de Mon Jan 24 06:43:34 2011 From: __peter__ at web.de (Peter Otten) Date: Mon, 24 Jan 2011 12:43:34 +0100 Subject: List behaviours with Clustering Algorithm References: Message-ID: James Ravenscroft wrote: > Dear All, > > I am currently trying to write a simple Agglomerative Clustering > algorithm which sorts through my MP3 collection and uses associated > Last.FM tags to cluster files into 'genres'. Unfortunately, I'm having > some trouble with my algorithm and some tracks are ending up in multiple > clusters. I have a feeling this is because of (my lack of understanding > of) list behaviours within Python. This is all purely a learning > exercise, so any input would be greatly appreciated > > The actual clustering method can be seen described here. Each Cluster is > stored within the 'clusters' array and has two elements: the data > containing song metadata such as artist, title and most importantly > tags, and a weight: that is, the overall Euclidean weight of the cluster > (based on the song data within). > > In theory, the algorithm runs in a loop until all clusters have been > merged into a hierarchy. It takes the weight of each cluster and merges > each cluster with their closest counterpart. My code has a lot of > comments so it should be fairly easy to understand. > tmp = [] > > for c in self.clusters: > > closestCluster = None > closestDelta = float('inf') > > for c2 in self.clusters: > > #skip if this is the same node > if(c == c2): > continue > > delta = abs(c2['weight'] - c['weight']) > > if(delta < closestDelta): > closestCluster = c2 > closestDelta = delta > > > print "Merging clusters %(c1)d and %(c2)d" % {'c1' : > self.clusters.index(c), > 'c2' : > self.clusters.index(closestCluster)} > #now merge the two clusters > self.clusters.remove(closestCluster) > self.clusters.remove(c) > > c['data'].extend(closestCluster['data']) > > tmp.append(c) I can't run your code because you didn't make it standalone, but I believe that the problem (at least one of them) is that you iterate over self.clusters and modify it from within the loop. That's a big no-no in python. A simple example to demonstrate the effects: >>> import random >>> old = range(10) >>> new = [] >>> for item in old: ... closest = random.choice(old) ... new.append((item, closest)) ... old.remove(item) ... old.remove(closest) ... >>> old [3, 4] >>> new [(0, 8), (2, 1), (5, 7), (9, 6)] The remedy is normally to iterate over a copy for item in list(old): ... but in your case that is probably not enough. Try something along these lines: # untested while len(self.clusters) > 1: c = self.clusters.pop() # find closest index for i, c2 in enumerate(self.clusters): ... if ...: closest_index = i closest = self.clusters.pop(closest_index) tmp.append(c + closest) if self.clusters: tmp.append(self.clusters[0]) Peter From __peter__ at web.de Mon Jan 24 06:55:07 2011 From: __peter__ at web.de (Peter Otten) Date: Mon, 24 Jan 2011 12:55:07 +0100 Subject: Converting functions References: <6c099cc0-9772-4151-86b9-d72242fbbdea@k13g2000vbq.googlegroups.com> <4d3d5e93$0$1071$afc38c87@read01.usenet4all.se> Message-ID: Edmunds Cers wrote: > Peter Otten <__peter__ at web.de> writes: > >> I don't know how to express it more clearly, so here's another example: >> >>>>> def f(): >> ... def g(): return a * a >> ... def h(): return a + a >> ... a = 5 >> ... return g, h >> ... >>>>> g, h = f() >>>>> g(), h() >> (25, 10) > > IMHO this whole confusion just shows that mingling assignment and > binding makes understanding scope harder. In Python, the first > assignment inside a function body also creates a binding (unless told > not to do so by global) the scope of which is the _whole_ of the > function body. A variable reference refers to the lexically innermost > surrounding binding of said variable. Now, while it might seem that some > magic happens in the example on the return of the function, this is in > fact not so, since the assignment "a = 5" actually creates a binding for > /a/ that is visible from the body of /g/, because the lexical scope of > the binding is the whole body of /f/, so that the capture of the > variable happens inside of the def expression (as one would expect) and > not on return as you seem to imply. > > Slightly OT -- the above also explains why closed over variables are > read only in Python. An assignment inside a closure would implicitly > create a binding, so that all (even previous) references to that > variable would refer to this new binding. Well, in Python 3 they no longer are, courtesy of the nonlocal statement: >>> def f(): ... def set(x): ... nonlocal a ... a = x ... def get(): ... return a ... return get, set ... a = 42 ... >>> get, set = f() >>> get() Traceback (most recent call last): File "", line 1, in File "", line 6, in get NameError: free variable 'a' referenced before assignment in enclosing scope >>> set(42) >>> get() 42 That closed-over variables are read-only by default is just to avoid the ambiguity about the scope they are supposed to live in, just like global variables that are to be changed from within a function. Peter From shrikant12 at ymail.com Mon Jan 24 07:19:08 2011 From: shrikant12 at ymail.com (shrikant kesharwani) Date: Mon, 24 Jan 2011 12:19:08 GMT Subject: Multiple python installations mix their sys.prefix References: Message-ID: <201112471852usenet@eggheadcafe.com> Hi, I have a web page through this page when I try to add a new user then users created successfully but when try resetting their password then I am getting errors? add New user successfully public static void AddUser(ADUser adUser) { // Local variables DirectoryEntry oDE = null; DirectoryEntry oDENewUser = null; DirectoryEntries oDEs = null; try { oDE = GetDirectoryEntry(GetADPath(PROD, adUser.UserType)); // 1. Create user account oDEs = oDE.Children; oDENewUser = oDEs.Add("CN=" + adUser.UserName, "user"); // 2. Set properties SetProperty(oDENewUser, "givenName", adUser.FirstName); SetProperty(oDENewUser, "sn", adUser.LastName); SetProperty(oDENewUser, "mail", adUser.Email); SetProperty(oDENewUser, "sAMAccountName", adUser.UserName); oDENewUser.CommitChanges(); /// 4. Enable account EnableAccount(oDENewUser); // 3. Set password //SetPassword(oDENewUser, adUser.Password); SetPassword1(oDENewUser.Path, adUser.Password); oDENewUser.CommitChanges(); oDENewUser.Close(); oDE.Close(); } catch (Exception ex) { throw ex; } } I have try the following 2 SetPassword methods but getting error. Method 1. internal static void SetPassword1(string path, string userPassword) { //Local variables DirectoryEntry usr = null; try { usr = new DirectoryEntry(); usr.Path = path; usr.AuthenticationType = AuthenticationTypes.Secure; object ret = usr.Invoke("SetPassword", userPassword); usr.CommitChanges(); usr.Close(); } catch (Exception ex) { throw ex; } } The exception raised (Error Code 80072035: The server is unwilling to process the request) Method 2. internal static void SetPassword(DirectoryEntry de, string userPassword) { //Local variables //DirectoryEntry usr = null; string quotePwd; byte[] pwdBin; try { quotePwd = String.Format(@"""{0}""", userPassword); pwdBin = System.Text.Encoding.Unicode.GetBytes(quotePwd); de.Properties["unicodePwd"].Value = pwdBin; de.CommitChanges(); //usr.Close(); } catch (Exception ex) { throw ex; } } The exception raised ("Exception has been thrown by the target of an invocation.") Is there an easy way to tell if there is a problem with changing a password? Please reply me as soon as possible. Thanks. Submitted via EggHeadCafe JSONP AJAX and ASP.NET Demystified http://www.eggheadcafe.com/tutorials/aspnet/b71ea548-93e0-4cec-9fb1-35f641b83e65/jsonp-ajax-and-aspnet-demystified.aspx From bryan.oakley at gmail.com Mon Jan 24 07:33:50 2011 From: bryan.oakley at gmail.com (Bryan) Date: Mon, 24 Jan 2011 04:33:50 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> Message-ID: <100e192f-9a6c-4c3a-8092-a65cd04eef64@o14g2000yqe.googlegroups.com> On Jan 23, 11:31?am, rantingrick wrote: > On Jan 22, 6:07?pm, rantingrick wrote: > > > I await any challengers... > > So far only trolls (besides Terry, Octavian, D'Aprano) have replied. > In my time here within the Python community i have only met one person > who shares my in-depth knowledge of Tkinter. That person is Kevin > Waltzer. So outside of Python-dev and Guido. Kevin and I are are the > ONLY people qualified to offer opinions on the worth or worthlessness > of Tkinter. If anyone in this entire community thinks that they also > are qualified then prove your worth by creating a ListCtrl in Tkinter > that mirrors the wxPython ListCtrl in functionality. When you have > done that, i will elevate you to my circle of enlightenment. Than and > only then shall i even entertain you BS. > > Until then, anyone who tries to devalue my argument is just an > ignorant troll. I think I'm qualified, though I guess only you can tell me if I measure up to your standards. I have 15 years or so of tk development, though admittedly mostly with Tcl. Most recently I've spent about the past year and a half with wxPython. For what it's worth, I am the only person on stackoverflow.com with the "tkinter" badge, which only means I've answered a bunch of questions on tkinter that others find helpful, nothing more. No offense, but your challenge is worthless, and your own entry in the challenge is remarkably weak. About the only thing you've proven is that wxPython has some built-in widgets that tkinter does not have, and that wxPython makes it hard to do cross-platform development. Does that surprise anyone? I'll give you a challenge: create a vector graphics program. wxPython doesn't have anything that can compare to the ease of use and power of tkinter's canvas. What does that prove? Only that tkinter has widgets wxPython does not. I don't think that will come as news to anyone. I could easily come up with other challenges where tkinter shines and wxPython falls flat on its face, but that proves nothing. What's really amusing is that your program segfaults on linux yet is supposed to show wxPython superiority. In my 15-20 years of tk development, you know how many segfaults I've seen? Approximately zero. Maybe there was one or two there somewhere, I don't know for certain. wxPython? It segfaults on me on a weekly basis (literally, thats not hyperbole). Which is the better toolkit? Fortunately for wxPython, the segfaults are mostly due to coding errors (typically, for lack of documentation). For the most part they don't happen once I release the code. All your challenges are going to prove is what we already know: both toolkits have strengths and weaknesses, and neither is perfect. I'll choose the tkinter binding event handling over wxPython any day of the week and twice on Sundays. It is _clearly_ and _by_far_ superior in every way. In fact, of the dozen or so toolkits I've used extensively over the last 20+ years, nothing comes close to the power of tkinter bindtags. The same can be said about tkinter's pack, place and grid geometry managers over wxPython's sizers. Tkinter wins _hands_down_. Easily. Not even close. Does that make tkinter better? No, just easier to use to do layout. Ultimately you can do pretty much the same thing with wxPython, just with more (and, arguably, less readable) code. On the other hand, wxPython clearly has more widgets. Some are very useful for very common tasks, such as file and image browsers. wxPython has the nice ability to draw on top of any widget, and the aui library shows a lot of promise. I spend a little less of my time "rolling my own" with wxPython. If you're doing a programmers editor it's hard to beat (and hard to program!) the styledtextctrl available with wxPython. It has features unique to coding editors that the tkinter text editor does not. That being said, the tkinter text editor is a marvel of simplicity and power. A project I'm doing now with a very specialized editor would be orders of magnitude easier to do with tkinter's text widget. So, all you've proven is that wxPython has different widgets than tkinter, and that it's hard to create a cross-platform GUI that looks nice in wxPython. It would be hard (but not impossible, by any stretch) for me to duplicate your code. Certainly, it would take more lines of code but that's about it. OTOH, it would be very difficult indeed to create a tkinter program that works on windows but segfaults on linux. That's also quite hard in tkinter. Frankly, I think a set of real-world challenges for all toolkits would be useful. The problem is, you have no intention of staging a fair fight. Your very first choice was to tie the hands of tkinter behind its back, so it's hard to take your challenge seriously. If you're serious, you'll find a disinterested third party and ask them to come up with a handful of use cases for testing toolkits, without giving them knowledge of which toolkits you intend to test. Anything less will be just a bunch of grandstanding. From lists at cheimes.de Mon Jan 24 07:34:25 2011 From: lists at cheimes.de (Christian Heimes) Date: Mon, 24 Jan 2011 13:34:25 +0100 Subject: A and B but not C in list In-Reply-To: References: <8cae2caf-d3df-4ed3-9afb-29de97772298@m13g2000yqb.googlegroups.com> Message-ID: Am 24.01.2011 04:05, schrieb Ian Kelly: > On Sun, Jan 23, 2011 at 2:34 PM, Christian Heimes wrote: >> your_set = set(your_list) >> >> if your_set.issuperset(set([A, B])) and your_set.isdisjoint(set([C, D])): > > if your_set.intersection([A, B, C, D]) == set([A, B]): > ... Ingenious but tricky :) Christian From rantingrick at gmail.com Mon Jan 24 07:38:18 2011 From: rantingrick at gmail.com (rantingrick) Date: Mon, 24 Jan 2011 04:38:18 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <480571f5-5731-4f8b-9cb4-1468478711bf@c39g2000yqi.googlegroups.com> <2c951199-3dba-4d24-a5c2-f84081688f7e@u6g2000yqk.googlegroups.com> <3e603997-5539-4660-bd83-7398bdab34a4@k30g2000vbn.googlegroups.com> <5edded76-fdac-4eb5-8480-25e3381e2fd4@g26g2000vbz.googlegroups.com> <1d7fdb0c-9f82-45ab-bf0e-99d210042f0d@j21g2000vbn.googlegroups.com> <4d3cb5fc$0$29983$c3e8da3$5496439d@news.astraweb.com> <4D3CBD79.3000905@v.loewis.de> <47190643-c3e1-4229-a456-fc505a13c10b@k22g2000yqh.googlegroups.com> <26ca9b38-3ecc-4276-a8cf-95bea74fc41c@r14g2000yqn.googlegroups.com> <4d3ce868$0$29974$c3e8da3$5496439d@news.astraweb.com> Message-ID: <722e9fe3-4cc4-444a-86a7-ca52a19b5bd7@o4g2000yqd.googlegroups.com> On Jan 23, 8:48?pm, Steven D'Aprano wrote: > When I run the code snippet Martin provided under Linux, the file > selection box shows files in columns. That's part of the reason why I > consider it ugly -- I'm an old Mac guy, and I still dislike file > selection tools that use the Windows 95 style 2-D layout: > > a-file ? ? ?e-file ? ? ?... > b-file ? ? ?f-file ? ? ?y-file > c-file ? ? ?g-file ? ? ?z-file > d-file ? ? ?h-file > > instead of a simple vertical list: > > a-file > b-file > c-file > ... > z-file > > Call me a dinosaur if you will, but I hate horizontal scrolling. Oh gawd Steven i hope you are just playing devils advocate here because now you are just being completely ridiculous. And if you want to see the list in vertical mode push the "Reportveiw" button. Wait, you *really* are a dinosaur! From rantingrick at gmail.com Mon Jan 24 08:04:44 2011 From: rantingrick at gmail.com (rantingrick) Date: Mon, 24 Jan 2011 05:04:44 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <033c3f90-03fb-4f65-bbae-bbc80a262685@l22g2000vbp.googlegroups.com> Message-ID: On Jan 24, 2:56?am, "Martin v. Loewis" wrote: > Well Rick, this doesn't make look wxPython any better. Well Martin this seems to be a Linux problem. And it may be a debian problem. Every Google search i landed on with wxPython+imagelist +sefault the user mentioned "debian"...hmm?. Has anybody tested this on Unbuntu? And if it segfaults on Ubuntu that just means you Linux guys need to do some debugging and offer a solution instead of pointing fingers. Linux OS is not a hand holding OS so stop your belly aching. All you guys know damn good and we can make wxPython completely cross platform. However the fact is that you DO NOT want to consider wxPython so you're NOT going to actually put forth some solutions. This thread has been an eye opener for myself and many people in the fact that this community has both lost vision and the apathy is so demoralizing that we cannot even work together to get some simple code debugged. The spirit of community, and each helping one another, does not exists! Congratulations python community, you have failed yourself! :( From bryan.oakley at gmail.com Mon Jan 24 08:06:22 2011 From: bryan.oakley at gmail.com (Bryan) Date: Mon, 24 Jan 2011 05:06:22 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <480571f5-5731-4f8b-9cb4-1468478711bf@c39g2000yqi.googlegroups.com> <2c951199-3dba-4d24-a5c2-f84081688f7e@u6g2000yqk.googlegroups.com> <3e603997-5539-4660-bd83-7398bdab34a4@k30g2000vbn.googlegroups.com> <5edded76-fdac-4eb5-8480-25e3381e2fd4@g26g2000vbz.googlegroups.com> <1d7fdb0c-9f82-45ab-bf0e-99d210042f0d@j21g2000vbn.googlegroups.com> <4d3cb5fc$0$29983$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Jan 23, 5:13?pm, Steven D'Aprano wrote: > On Sun, 23 Jan 2011 12:23:13 -0800, rantingrick wrote: > > I am not > > trying to create a working file browser so you can steal my code. > > Dammit! There goes my brilliant idea for getting rich. > > Step 1: Start company. > Step 2: Steal working file browser from Internet. > Step 4: Profit! > > I think rantingrick's comment inadvertently shows in a nutshell > everything wrong with this thread and why there is so little interest in > his proposal. If RR is right about the GUI toolkit making or breaking the > entire Python community, there should be hundreds of people with an > opinion, not just a handful. > > (1) rantingrick is willing to spend *hours* brow-beating people, > insulting them, and cajoling them into doing things *his* way, supposedly > because of his deep concern for the Python community, but isn't willing > to donate a lousy *file browser* to the community. > > (2) GUI programming is TOO DAMN HARD, and until that fact is addressed, > it's difficult for the majority of people to care whether the toolkit > used (or, more likely, not used at all) is Tkinter, or wxPython, or > something else. > > For something as common as displaying a file browser, it should be as > simple as this: > > import gui_toolkit ?# whichever > path = gui_toolkit.select_file() > You mean like: >>> import tkFileDialog >>> path=tkFileDialog.askopenfiles() >>> print path [] :-) (I think the actual point of contention isn't a file dialog, but a file browser like the windows explorer. From bryan.oakley at gmail.com Mon Jan 24 08:13:08 2011 From: bryan.oakley at gmail.com (Bryan) Date: Mon, 24 Jan 2011 05:13:08 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <70498$4d3cb87c$4275d90a$4428@FUSE.NET> Message-ID: <46c407b5-9bfe-406a-a2fe-c63caa771bf3@f2g2000vby.googlegroups.com> On Jan 23, 7:12?pm, rantingrick wrote: > On Jan 23, 5:23?pm, Kevin Walzer wrote: > > > I found this code in the Demo/tkinter/ttk directory of the Python 2.7.1 > > source distribution. I'm NOT the author (credit should probably go to > > Guilherme Polo, developer of the Tkinter wrapper for the ttk themed > > widgets that is now in the stdlib). But, using a tree/listview widget > > that is part of the Tk/Tkinter core (NOT an extension), ?it presents a > > decent, simple file browser: > > > """A directory browser using Ttk Treeview. > > The only way i can respond to this is to quite the requirements for my > challenge... > > --------------------------------------- > ?Challenge 1: (Simple Directory Viewer) > --------------------------------------- > Create a simple Directory Viewer GUI. You CANNOT use a treectrl! > > Any questions? So, what you're saying is, the real challenge you are presenting is "using the toolkit of your choice, open up a wx.ListCtrl widget". If you want a fair challenge don't say "you can't use widget X". All you're trying to prove is that tkinter doesn't have a wx.ListCtrl widget. I think most people can agree with you on that point. From bryan.oakley at gmail.com Mon Jan 24 08:16:12 2011 From: bryan.oakley at gmail.com (Bryan) Date: Mon, 24 Jan 2011 05:16:12 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <70498$4d3cb87c$4275d90a$4428@FUSE.NET> <63eea$4d3cd2fd$4275d90a$14984@FUSE.NET> <69465430-08b3-4069-99c7-72f4d3034c66@s5g2000yqm.googlegroups.com> Message-ID: On Jan 23, 7:33?pm, rantingrick wrote: > On Jan 23, 7:16?pm, Kevin Walzer wrote: > > > > > > > On 1/23/11 8:12 PM, rantingrick wrote: > > > > The only way i can respond to this is to quite the requirements for my > > > challenge... > > > > --------------------------------------- > > > ? Challenge 1: (Simple Directory Viewer) > > > --------------------------------------- > > > Create a simple Directory Viewer GUI. You CANNOT use a treectrl! > > > > Any questions? > > > Why not? > > > I'd understand if this code made use of some Tk extension, as that's not > > quite an apples-to-apples comparison. But the treectrl is part of the > > core Tkinter widget set. > > Well wxPython ha a treectrl too. And if we were comparing apples to > apples then we would compare the wx.TreeCtrl to the Tk::TreeCtrl. > However there are many things that a ListCtrl can do that a treectrl > can't. The biggest difference.... COLUMNS > > > There's no reason to exclude it (Tk::TreeCtrl) unless you are > > deliberately trying to handicap Tk in your comparison. > > I am not handicapping TclTk. They already did that themselves by > refusing to keep up with ?21st century GUI libraries. Sure, you can > say Tkinter is a knife and wxPython is an AK47 but who's to blame when > you bring a knife to gun fight Kevin? Switch to wx and enjoy the > bloodbath. "switch to wx and enjoy the bloodbath" That has *got* to be quote-of-the-week material. Sometimes when I've spent a day wrestling with wxPython I do indeed feel like I've been in a bloodbath! (I'm not picking on wxPython per se -- it's what I'm using for my current project -- just that the analogy was perhaps a bit more on target than rantingrick intended :-) From rantingrick at gmail.com Mon Jan 24 08:24:06 2011 From: rantingrick at gmail.com (rantingrick) Date: Mon, 24 Jan 2011 05:24:06 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <70498$4d3cb87c$4275d90a$4428@FUSE.NET> <46c407b5-9bfe-406a-a2fe-c63caa771bf3@f2g2000vby.googlegroups.com> Message-ID: <05fd32ee-e542-4622-afa8-a7cf4549df45@k42g2000yqa.googlegroups.com> On Jan 24, 7:13?am, Bryan wrote: > So, what you're saying is, the real challenge you are presenting is > "using the toolkit of your choice, open up a wx.ListCtrl widget". read the very first post which outlines the challenge. > If you want a fair challenge don't say "you can't use widget X". All > you're trying to prove is that tkinter doesn't have a wx.ListCtrl > widget. I think most people can agree with you on that point. Bryan you are clearly an idiot. I am demanding that from now on, you must have at least a 120 or higher IQ before participating in any of my threads. Really, if you are an idiot then you should not be allowed to vote or reproduce. However for this group i may have set the bar too high! From bryan.oakley at gmail.com Mon Jan 24 08:24:58 2011 From: bryan.oakley at gmail.com (Bryan) Date: Mon, 24 Jan 2011 05:24:58 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <70498$4d3cb87c$4275d90a$4428@FUSE.NET> <63eea$4d3cd2fd$4275d90a$14984@FUSE.NET> <69465430-08b3-4069-99c7-72f4d3034c66@s5g2000yqm.googlegroups.com> <705ad$4d3ce0fc$4275d90a$29144@FUSE.NET> <3d68e6fe-be68-4713-8330-20886d914547@r29g2000yqj.googlegroups.com> Message-ID: On Jan 24, 12:06?am, rusi wrote: > On Jan 24, 9:16?am, "Littlefield, Tyler" wrote: > > Of course as Steven pointed out wx is written in C++ which is almost > certainly where the crash is occurring. > But this is technical nitpicking. > The real issue is that when coding in C/C++ segfaults are a daily > affair. > Whereas for python its the first time I am seeing it in 10 years... In my experience, segfaults with wxPython aren't daily, but they are pretty much weekly. There are weeks that can go by without them, but then I'll have several in a week to bump up the average. wxPython is fairly sensitive to coding mistakes, and the documentation is sufficiently weak that it's easy to make coding mistakes. There are a lot of things you can do that aren't valid in particular contexts, and instead of throwing a catchable error you get a segfault. Plus, as we've seen, it's platform specific. So it's easy to create code that works great on one platform even with some bad code in it, and that same code will segfault on another platform. This shouldn't be enough to keep you from using wxPython, it just means you have to be a bit more diligent and you can't assume that your linux code will work on windows or visa versa without testing. tkinter seems far less susceptible to that. Mostly with tkinter the platform issues are true platform issues (font availability, file paths, etc). From orasnita at gmail.com Mon Jan 24 08:27:22 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Mon, 24 Jan 2011 15:27:22 +0200 Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <100e192f-9a6c-4c3a-8092-a65cd04eef64@o14g2000yqe.googlegroups.com> Message-ID: <1D826CCAB24E43ECB2C0AC790D17042F@octavian> From: "Bryan" > It would be hard (but not impossible, by any > stretch) for me to duplicate your code. Certainly, it would take more > lines of code but that's about it. OTOH, it would be very difficult > indeed to create a tkinter program that works on windows but segfaults > on linux. That's also quite hard in tkinter. I doubt you could do a program that offers the same features using Tkinter. That program will not be accessible for screen readers and this is a big problem, a vital problem for those that use a screen reader, because the program won't be accessible at all. Octavian From __peter__ at web.de Mon Jan 24 08:32:04 2011 From: __peter__ at web.de (Peter Otten) Date: Mon, 24 Jan 2011 14:32:04 +0100 Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <70498$4d3cb87c$4275d90a$4428@FUSE.NET> <46c407b5-9bfe-406a-a2fe-c63caa771bf3@f2g2000vby.googlegroups.com> <05fd32ee-e542-4622-afa8-a7cf4549df45@k42g2000yqa.googlegroups.com> Message-ID: rantingrick wrote: > I am demanding that from now on, you > must have at least a 120 or higher IQ before participating in any of > my threads. You mean, you are putting yourself in your own killfile ;) From rantingrick at gmail.com Mon Jan 24 08:32:42 2011 From: rantingrick at gmail.com (rantingrick) Date: Mon, 24 Jan 2011 05:32:42 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <70498$4d3cb87c$4275d90a$4428@FUSE.NET> <63eea$4d3cd2fd$4275d90a$14984@FUSE.NET> <69465430-08b3-4069-99c7-72f4d3034c66@s5g2000yqm.googlegroups.com> <705ad$4d3ce0fc$4275d90a$29144@FUSE.NET> <3d68e6fe-be68-4713-8330-20886d914547@r29g2000yqj.googlegroups.com> Message-ID: <2e6deec8-bdca-40ec-a759-6fa2951585fb@s5g2000yqm.googlegroups.com> On Jan 24, 7:24?am, Bryan wrote: > On Jan 24, 12:06?am, rusi wrote: > > > On Jan 24, 9:16?am, "Littlefield, Tyler" wrote: > > > Of course as Steven pointed out wx is written in C++ which is almost > > certainly where the crash is occurring. > > But this is technical nitpicking. > > The real issue is that when coding in C/C++ segfaults are a daily > > affair. > > Whereas for python its the first time I am seeing it in 10 years... > > In my experience, segfaults with wxPython aren't daily, but they are > pretty much weekly. hmm > There are weeks that can go by without them, but > then I'll have several in a week to bump up the average. Yes, and this could not be your problem, it must be wxPython. Right? *rolls-eyes* > wxPython is fairly sensitive to coding mistakes, Oh so now we get the picture... > and the documentation > is sufficiently weak that it's easy to make coding mistakes. That is somewhat true. > There are > a lot of things you can do that aren't valid in particular contexts, > and instead of throwing a catchable error you get a segfault. And we need to fix that instead just disqualifying a feature rich toolkit. > Plus, as > we've seen, it's platform specific. So it's easy to create code that > works great on one platform even with some bad code in it, and that > same code will segfault on another platform. Again, were is the community spirit. I have windows and you have linux. Let's write some code and do cross testing and then fix the bugs. > This shouldn't be enough to keep you from using wxPython, it just > means you have to be a bit more diligent and you can't assume that > your linux code will work on windows or visa versa without testing. Thank you! > tkinter seems far less susceptible to that. Mostly with tkinter the > platform issues are true platform issues (font availability, file > paths, etc). Yes because Tkinter is lacking. Because Tkinter is not even half the library that wx is. From g.rodola at gmail.com Mon Jan 24 08:36:19 2011 From: g.rodola at gmail.com (=?ISO-8859-1?Q?Giampaolo_Rodol=E0?=) Date: Mon, 24 Jan 2011 14:36:19 +0100 Subject: WxPython versus Tkinter. In-Reply-To: References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <033c3f90-03fb-4f65-bbae-bbc80a262685@l22g2000vbp.googlegroups.com> Message-ID: 2011/1/24 rantingrick : > On Jan 24, 2:56?am, "Martin v. Loewis" wrote: > >> Well Rick, this doesn't make look wxPython any better. > > Well Martin this seems to be a Linux problem. And it may be a debian > problem. Every Google search i landed on with wxPython+imagelist > +sefault the user mentioned "debian"...hmm?. Has anybody tested this > on Unbuntu? And if it segfaults on Ubuntu that just means you Linux > guys need to do some debugging and offer a solution instead of > pointing fingers. Linux OS is not a hand holding OS so stop your belly > aching. > > All you guys know damn good and we can make wxPython completely cross > platform. However the fact is that you DO NOT want to consider > wxPython so you're NOT going to actually put forth some solutions. > This thread has been an eye opener for myself and many people in the > fact that this community has both lost vision and the apathy is so > demoralizing that we cannot even work together to get some simple code > debugged. The spirit of community, and each helping one another, does > not exists! > > Congratulations python community, you have failed yourself! :( > -- > http://mail.python.org/mailman/listinfo/python-list > This is nonsense and you are clearly a troll. =) --- Giampaolo Rodol? http://code.google.com/p/pyftpdlib/ http://code.google.com/p/psutil/ From kw at codebykevin.com Mon Jan 24 08:40:43 2011 From: kw at codebykevin.com (Kevin Walzer) Date: Mon, 24 Jan 2011 08:40:43 -0500 Subject: [Code Challenge] WxPython versus Tkinter. In-Reply-To: References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <70498$4d3cb87c$4275d90a$4428@FUSE.NET> Message-ID: <20d8f$4d3d8140$4275d90a$14327@FUSE.NET> On 1/24/11 1:52 AM, Octavian Rasnita wrote: > > Well, I have also tested the program dirbrowser.py, but it is not decent > at all. > I have tested it with JAWS screen reader and it is absolutely inaccessible. > > The single "accessible" things in it are the title bar which is "tk". > It can't compare with the same program made using WxPython. > And it can't be made to be more accessible than it is, because it uses Tk. > > So Tkinter is really bad. If accessibility leads your criteria, then yes, Tk may be deficient. I can't speak to this on other platforms or with other toolkits. -- Kevin Walzer Code by Kevin http://www.codebykevin.com From kw at codebykevin.com Mon Jan 24 08:48:14 2011 From: kw at codebykevin.com (Kevin Walzer) Date: Mon, 24 Jan 2011 08:48:14 -0500 Subject: WxPython versus Tkinter. In-Reply-To: <05fd32ee-e542-4622-afa8-a7cf4549df45@k42g2000yqa.googlegroups.com> References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <70498$4d3cb87c$4275d90a$4428@FUSE.NET> <46c407b5-9bfe-406a-a2fe-c63caa771bf3@f2g2000vby.googlegroups.com> <05fd32ee-e542-4622-afa8-a7cf4549df45@k42g2000yqa.googlegroups.com> Message-ID: On 1/24/11 8:24 AM, rantingrick wrote: > > Bryan you are clearly an idiot. I am demanding that from now on, you > must have at least a 120 or higher IQ before participating in any of > my threads. Really, if you are an idiot then you should not be allowed > to vote or reproduce. However for this group i may have set the bar > too high! Rick, I've tried to give you the benefit of the doubt during this discussion, but I've had enough. Bryan Oakley is no idiot. You said elsewhere in this thread that my expertise with Tkinter was worth something, but Bryan's is worth far more. He is one of the foremost Tcl/Tk developers alive, author of many widely-used Tk widgets, and a long-term helpful presence on comp.lang.tcl. He's patiently answered many inflammatory questions from inexperienced or arrogant developers, and I've learned a tremendous amount from him. Job circumstances forced him to move into Python development a few years ago, and he now uses wxPython on a daily basis, while being active on Stack Overflow and elsewhere with answering questions about Tkinter. In short, I'd have a hard time imagining anyone more qualified to compare wxPython and Tkinter than Bryan Oakley. Also, it's not helpful for you to respond to people who disagree with you with this kind of name-calling. It certainly does not earn any respect for your arguments. --Kevin -- Kevin Walzer Code by Kevin http://www.codebykevin.com From rantingrick at gmail.com Mon Jan 24 09:15:55 2011 From: rantingrick at gmail.com (rantingrick) Date: Mon, 24 Jan 2011 06:15:55 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <100e192f-9a6c-4c3a-8092-a65cd04eef64@o14g2000yqe.googlegroups.com> Message-ID: <1ed86ac9-e8a9-48b3-8f27-bf480782eb82@w17g2000yqh.googlegroups.com> On Jan 24, 6:33?am, Bryan wrote: > I think I'm qualified, though I guess only you can tell me if I > measure up to your standards. Go on... > I have 15 years or so of tk development, > though admittedly mostly with Tcl. Most recently I've spent about the > past year and a half with wxPython. A year and a half and you are still producing buggy code? (you yourself admitted this!) > For what it's worth, I am the only > person on stackoverflow.com with the "tkinter" badge, which only means > I've answered a bunch of questions on tkinter that others find > helpful, nothing more. Well could we see a link to a few answered questions or get your nick so we can corroborate this statement ourselves? > No offense, but your challenge is worthless, and your own entry in the > challenge is remarkably weak. First rule when given a challenge you cannot answer due to ignorance: question the validity of the challenge. > About the only thing you've proven is > that wxPython has some built-in widgets that tkinter does not have, Well this is ONLY the first challenge Bryan. More will come. However, not until someone has the balls to answer my first challenge. > and that wxPython makes it hard to do cross-platform development. I don't think that is completely accurate Bryan. Harder than Tkinter, yes. Anything else is hyperbole. > Does > that surprise anyone? I'll give you a challenge: create a vector > graphics program. Answer my challenge first, then we talk. And obviously you do not understand the power of wx's Open Graphics Library (OGL). You'd better go check that out before you stick your Tkinter loving foot into your big mouth. > wxPython doesn't have anything that can compare to > the ease of use and power of tkinter's canvas. Thats more uninformed BS. You are really hurting your public image here bryan! > What does that prove? > Only that tkinter has widgets wxPython does not. I don't think that > will come as news to anyone. I could easily come up with other > challenges where tkinter shines and wxPython falls flat on its face, And these challenges are what? You see when you make empty challenges like this you look dumb. > What's really amusing is that your program segfaults on linux yet is > supposed to show wxPython superiority. Segfault or not wx is superior. > In my 15-20 years of tk > development, you know how many segfaults I've seen? Approximately > zero. BULLSHITE! > Maybe there was one or two there somewhere, Ah yes, the old conscience catches up fast to the habitual liars. > I don't know for > certain. Finally some truth! > wxPython? It segfaults on me on a weekly basis (literally, > thats not hyperbole). LIAR! LIAR! PANTS ON FIRE! ------------bryan------------- In my experience, segfaults with wxPython aren't daily, but they are pretty much weekly. There are weeks that can go by without them ------------bryan------------- > Which is the better toolkit? Fortunately for > wxPython, the segfaults are mostly due to coding errors Yea, ya think? > For the most part they don't happen once I > release the code. And yet you cannot offer a solution for this segfault. Interesting. > All your challenges are going to prove is what we already know: both > toolkits have strengths and weaknesses, and neither is perfect. And sadly that IS ALL you know. More fruits must be weighed in this decision. Like the fact that Tkinter is legacy and wxPython is current technology. > I'll > choose the tkinter binding event handling over wxPython any day of the > week and twice on Sundays. So will i. We should change the wxPython API! > It is _clearly_ and _by_far_ superior in > every way. True. We should change the wxPython API! > In fact, of the dozen or so toolkits I've used extensively > over the last 20+ years, nothing comes close to the power of tkinter > bindtags. *yawn*. Guido's advocate! > The same can be said about tkinter's pack, place and grid geometry > managers over wxPython's sizers. Agreed! We should change the wxPython API! > Does that make tkinter better? No, just easier to use > to do layout. Agreed! Because if we were really smart we would just change the wxPython API so that we have the simplicity of Tkinter and the feature richness of wxPython. See wax for ideas... http://wiki.wxpython.org/Wax > Ultimately you can do pretty much the same thing with > wxPython, just with more (and, arguably, less readable) code. Wrong. You can do much much more with wxPython. The ugliness of the code depends on the coders ability to create good or bad code. > On the other hand, wxPython clearly has more widgets. Some are very > useful for very common tasks, such as file and image browsers. and spreadsheets, and validated input, and multi-choice directory choosing, and multi choice lists, and Rich Text, and book controls, and Calendars, and Toolbars, and full image support, and masked edit controls, and scrolled panels, and styled text, and print support, and listctrl, and virtual listctrl and editable list ctrl, and REAL DND ,and GC, and GLCanvas, and JoyStick, and OGL, and shaped windows, and more, more, more... > wxPython has the nice ability to draw on top of any widget, and the > aui library shows a lot of promise. I spend a little less of my time > "rolling my own" with wxPython. You will always spend less time rolling in wxPython. > If you're doing a programmers editor it's hard to beat (and hard to > program!) the styledtextctrl available with wxPython. It has features > unique to coding editors that the tkinter text editor does not. That > being said, the tkinter text editor is a marvel of simplicity and > power. A project I'm doing now with a very specialized editor would be > orders of magnitude easier to do with tkinter's text widget. Which do you want, simplistic confinement or expansive elegance. You can't have both. And besides. One could easily create a simplistic "Tkinter like" textbox API using wxPython. You lack vision Bryan. We can bring all this into reality! > It would be hard (but not impossible, by any > stretch) for me to duplicate your code. PUT UP OR SHUT THE HELL UP! From tyler at tysdomain.com Mon Jan 24 09:16:01 2011 From: tyler at tysdomain.com (Littlefield, Tyler) Date: Mon, 24 Jan 2011 07:16:01 -0700 Subject: WxPython versus Tkinter. In-Reply-To: <58325C0B6449487E97D2523C1685624F@octavian> References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <70498$4d3cb87c$4275d90a$4428@FUSE.NET> <63eea$4d3cd2fd$4275d90a$14984@FUSE.NET> <69465430-08b3-4069-99c7-72f4d3034c66@s5g2000yqm.googlegroups.com> <705ad$4d3ce0fc$4275d90a$29144@FUSE.NET><3d68e6fe-be68-4713-8330-20886d914547@r29g2000yqj.googlegroups.com> <4D3CFD0F.1080502@tysdomain.com> <58325C0B6449487E97D2523C1685624F@octavian> Message-ID: <4D3D89A1.8050206@tysdomain.com> >Or you have started to use Linux and now you don't care about the majority of >users that need to use a screen reader? I said nothing the like. TkInter does have problemns with Jaws, but I'm not going to sit here and say the same thing over and over as you are doing. Get off the soapbox already. On 1/23/2011 11:58 PM, Octavian Rasnita wrote: > From: "Littlefield, Tyler" >> >PS: Be sure not to cause any segfaults because these linux folks can't >> >debug for shite! >> Or maybe it is that the person fighting and throwing insults around >> like candy at a parade can't code for shite. Or *gasp* the library >> that is supposedly cross-platform has issues on certain platforms. >> You provided a challenge to show how superior wxPython was. If it >> segfaults, that tells me that: 1) you can't code worth "shite," or 2) >> the library you are drooling over sucks and shouldn't be >> cross-platform. Which is it? I highly doubt there is a third option, >> but please feel free to tell me, rather than insulting again. > > > Hi Tyler, > > Are you able to use Tkinter-based applications under Windows? > Or you have started to use Linux and now you don't care about the > majority of users that need to use a screen reader? > > Octavian > -- Thanks, Ty From rantingrick at gmail.com Mon Jan 24 09:36:26 2011 From: rantingrick at gmail.com (rantingrick) Date: Mon, 24 Jan 2011 06:36:26 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <70498$4d3cb87c$4275d90a$4428@FUSE.NET> <46c407b5-9bfe-406a-a2fe-c63caa771bf3@f2g2000vby.googlegroups.com> <05fd32ee-e542-4622-afa8-a7cf4549df45@k42g2000yqa.googlegroups.com> Message-ID: <2eedabb5-7ce4-444a-abba-74d96cc93188@i18g2000yqn.googlegroups.com> On Jan 24, 7:48?am, Kevin Walzer wrote: > Rick, > > I've tried to give you the benefit of the doubt during this discussion, > but I've had enough. Bryan Oakley is no idiot. He is obviously lying to discredit me. And I have posted evidence of his hyperbole. > You said elsewhere in > this thread that my expertise with Tkinter was worth something, but > Bryan's is worth far more. He is one of the foremost Tcl/Tk developers > alive, author of many widely-used Tk widgets, and a long-term helpful > presence on comp.lang.tcl. He's patiently answered many inflammatory > questions from inexperienced or arrogant developers, and I've learned a > tremendous amount from him. Job circumstances forced him to move into > Python development a few years ago, and he now uses wxPython on a daily > basis, while being active on Stack Overflow and elsewhere with answering > questions about Tkinter. ?In short, I'd have a hard time imagining > anyone more qualified to compare wxPython and Tkinter than Bryan Oakley. Yet he has NO knowledge of wxPython and his Tkinter knowledge is lacking. > Also, it's not helpful for you to respond to people who disagree with > you with this kind of name-calling. It certainly does not earn any > respect for your arguments. Well i agree with that. However these people keep coming back with the same BS arguments... * the challenge is impossible. No the challenge is not impossible to complete. However due to Tkinters lacking richness. It is impossible to win against wxPython. So they resort to all this BS because they KNOW they cannot win. Just admit that wxPython wins this round and i'll move on to the next challenge. * wxPython is not cross platform. Total BS. * Yes wxPython has many widgets but most are not useful. Even more BS. And you wonder why i call people ignorant? I did give them the benefit of the doubt before saying these things. Bryan has yet to post any links so i can corroborate his "Tkinter" guru status. He has also clearly lied many times in his posts (which i have documented). And most importantly no one but myself has offered any code. From kyosohma at gmail.com Mon Jan 24 09:49:53 2011 From: kyosohma at gmail.com (Mike Driscoll) Date: Mon, 24 Jan 2011 06:49:53 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <70498$4d3cb87c$4275d90a$4428@FUSE.NET> <63eea$4d3cd2fd$4275d90a$14984@FUSE.NET> <69465430-08b3-4069-99c7-72f4d3034c66@s5g2000yqm.googlegroups.com> <705ad$4d3ce0fc$4275d90a$29144@FUSE.NET> <3d68e6fe-be68-4713-8330-20886d914547@r29g2000yqj.googlegroups.com> Message-ID: On Jan 24, 7:24?am, Bryan wrote: > On Jan 24, 12:06?am, rusi wrote: > > > On Jan 24, 9:16?am, "Littlefield, Tyler" wrote: > > > Of course as Steven pointed out wx is written in C++ which is almost > > certainly where the crash is occurring. > > But this is technical nitpicking. > > The real issue is that when coding in C/C++ segfaults are a daily > > affair. > > Whereas for python its the first time I am seeing it in 10 years... > > In my experience, segfaults with wxPython aren't daily, but they are > pretty much weekly. There are weeks that can go by without them, but > then I'll have several in a week to bump up the average. I've only run my code on Windows and Linux, but I haven't had this issue. The only time I've had segfaults was when I was first learning how to get threading and wx to work properly and when I was creating binaries with py2exe. On a completely different note, as a heavy wxPython user for almost 5 years, I have never seen the OP on our mailing list, dev group or IRC channel. While I like wx more than Tk, I think this thread is a terrible way to try to show that wx is better. I like the concept of creating a challenge to see which toolkit can do what, but this is not the way to go about it. Bryan, on the other hand, has been a Tkinter luminary who has helped me in the past when I was learning Tkinter and I won't be too surprised if he helps me again. I'm sorry he's had so much trouble with wx though. ------------------- Mike Driscoll Blog: http://blog.pythonlibrary.org From rantingrick at gmail.com Mon Jan 24 10:02:43 2011 From: rantingrick at gmail.com (rantingrick) Date: Mon, 24 Jan 2011 07:02:43 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <70498$4d3cb87c$4275d90a$4428@FUSE.NET> <63eea$4d3cd2fd$4275d90a$14984@FUSE.NET> <69465430-08b3-4069-99c7-72f4d3034c66@s5g2000yqm.googlegroups.com> <705ad$4d3ce0fc$4275d90a$29144@FUSE.NET> <3d68e6fe-be68-4713-8330-20886d914547@r29g2000yqj.googlegroups.com> Message-ID: <7d701221-cdf4-4679-beb3-90492dd52bce@i13g2000yqe.googlegroups.com> On Jan 24, 8:49?am, Mike Driscoll wrote: > On Jan 24, 7:24?am, Bryan wrote: > > In my experience, segfaults with wxPython aren't daily, but they are > > pretty much weekly. There are weeks that can go by without them, but > > then I'll have several in a week to bump up the average. > > I've only run my code on Windows and Linux, but I haven't had this > issue. The only time I've had segfaults was when I was first learning > how to get threading and wx to work properly and when I was creating > binaries with py2exe. Thanks. I knew these guys were full of it. > On a completely different note, as a heavy wxPython user for almost 5 > years, I have never seen the OP on our mailing list, dev group or IRC > channel. Thats because i have not been there. And yet i can produce code (maybe not perfectly). However those that have been around wx list for longer cannot. Interesting. > I like the concept of > creating a challenge to see which toolkit can do what, but this is not > the way to go about it. Well by all means offer some input. You have offered opinions but no ideas. I would love to hear any ideas you may have. And yes, Tkinter has a very likable API. I have mentioned this fact many times and in many threads. However when weighed on all factors wx will win. Because even though we may need to mold the wx API a bit, at least with wx we have a solid feature rich platform to work from. > Bryan, on the other hand, has been a Tkinter luminary who has helped > me in the past when I was learning Tkinter and I won't be too > surprised if he helps me again. I'm sorry he's had so much trouble > with wx though. :) From mauro.caceres at gmail.com Mon Jan 24 10:53:37 2011 From: mauro.caceres at gmail.com (Mauro Caceres) Date: Mon, 24 Jan 2011 12:53:37 -0300 Subject: Short circuting In-Reply-To: References: Message-ID: Another option could be something like this: You can add ids to your regexp, so you can retrive them latter using groupdict. Once you have the ids in place, you can join in a new regexp with the "|" operator which is not greedy, it will stop after the first match. pattern = (?P
re_section)|?Pre_section|... Then you can have another structure with the previous id and the actions you want to perform on them. actions = {'section': lambda r: r[18:-5], 'name': lambda r: r[6:-1]), ...} Finally you just need to iterate over the result. In this case the dictionary will have only one pair. result = pattern.search(line) if result: for key,val in result.groupdict().iteritems(): actions[key](val) .... -- Mauro C?ceres -------------- next part -------------- An HTML attachment was scrubbed... URL: From invalid at invalid.invalid Mon Jan 24 11:13:48 2011 From: invalid at invalid.invalid (Grant Edwards) Date: Mon, 24 Jan 2011 16:13:48 +0000 (UTC) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <70498$4d3cb87c$4275d90a$4428@FUSE.NET> <46c407b5-9bfe-406a-a2fe-c63caa771bf3@f2g2000vby.googlegroups.com> <05fd32ee-e542-4622-afa8-a7cf4549df45@k42g2000yqa.googlegroups.com> Message-ID: On 2011-01-24, rantingrick wrote: > Bryan you are clearly an idiot. I am demanding that from now on, you > must have at least a 120 or higher IQ before participating in any of > my threads. Rantingrick thinks certain threads belong to him. 'nuf said. -- Grant Edwards grant.b.edwards Yow! I'm gliding over a at NUCLEAR WASTE DUMP near gmail.com ATLANTA, Georgia!! From invalid at invalid.invalid Mon Jan 24 11:15:54 2011 From: invalid at invalid.invalid (Grant Edwards) Date: Mon, 24 Jan 2011 16:15:54 +0000 (UTC) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <3a96fee1-995f-49f7-a967-f125cc3f1cdc@v26g2000yqf.googlegroups.com> <4ef41c75-8372-4a94-a93c-1b4e7a6e0759@m13g2000yqb.googlegroups.com> Message-ID: On 2011-01-24, Corey Richardson wrote: > Python (and supposedly wxPython) are cross-platform. Code that runs on > one should run on the other unmodified. No, that's not what "cross-platform" really means. Cross-platform means that it's possible (and reasonably stright-forward) to write code that will run unmodified on multiple platforms. It doesn't mean that it's impossible to write code that will only work on one platform. -- Grant Edwards grant.b.edwards Yow! Someone in DAYTON, at Ohio is selling USED gmail.com CARPETS to a SERBO-CROATIAN From bborcic at gmail.com Mon Jan 24 11:31:26 2011 From: bborcic at gmail.com (Boris Borcic) Date: Mon, 24 Jan 2011 17:31:26 +0100 Subject: A and B but not C in list In-Reply-To: References: <8cae2caf-d3df-4ed3-9afb-29de97772298@m13g2000yqb.googlegroups.com> Message-ID: Terry Reedy wrote: > > The straightforward code > > if a in L and b in L and c not in L and d not in L > > scans the list 4 times. of course for a single scan one can setify the list and write S=set(L) if a in S and b in S and c not in S and d not in S or even, I guess, something like {a,b} <= S and not S & {c,d} also, I suppose that in some settings a,b,c,d could be made to belong to a class that has defined eg __nonzero__ = __bool__ = S.__contains__ so that the if statement would become if a and b and not c and not d btw, did anybody ask the OP which if any of A,B,C,D otoh and L otoh would vary fastest ? Whatever, BB From rantingrick at gmail.com Mon Jan 24 11:36:18 2011 From: rantingrick at gmail.com (rantingrick) Date: Mon, 24 Jan 2011 08:36:18 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <70498$4d3cb87c$4275d90a$4428@FUSE.NET> <46c407b5-9bfe-406a-a2fe-c63caa771bf3@f2g2000vby.googlegroups.com> <05fd32ee-e542-4622-afa8-a7cf4549df45@k42g2000yqa.googlegroups.com> Message-ID: <42b2e26f-54e4-4319-977b-66fc94ad64b5@e4g2000vbg.googlegroups.com> On Jan 24, 10:13?am, Grant Edwards wrote: > On 2011-01-24, rantingrick wrote: > > > Bryan you are clearly an idiot. I am demanding that from now on, you > > must have at least a 120 or higher IQ before participating in any of > > my threads. > > Rantingrick thinks certain threads belong to him. No these are free and open forums and all are welcome to come and listen to what i say :). Notice i only specified an IQ level and i made no demands as to how much Python knowledge was required. You can be a noob or a pro and participate. However i am not about to entertain trolls and ignorants because these people do not have the basic tools to contribute anything helpful. Whereas someone who has meager Python skills (but a reasonable IQ) CAN participate in lively and coherent debate all the while contributing in a positive way. These are the people i want to talk with. Some have dropped in already but failed to offer good debate. NOW IS YOUR CHANCE! Many folks here don't understand how to contribute in a positive way. NEWSFLASH! You can both disagree with me AND contribute to the debate in a positive way at the same time. Oh yes! One example would be for the "Linux whiners" to post a fix to my example code. If they are not going to answer the challenge with Tkinter code, then they should at least fix ONE measly little bug to prove their worth to this community. So far you have all failed BOTH challenges. From kyosohma at gmail.com Mon Jan 24 11:38:41 2011 From: kyosohma at gmail.com (Mike Driscoll) Date: Mon, 24 Jan 2011 08:38:41 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <70498$4d3cb87c$4275d90a$4428@FUSE.NET> <63eea$4d3cd2fd$4275d90a$14984@FUSE.NET> <69465430-08b3-4069-99c7-72f4d3034c66@s5g2000yqm.googlegroups.com> <705ad$4d3ce0fc$4275d90a$29144@FUSE.NET> <3d68e6fe-be68-4713-8330-20886d914547@r29g2000yqj.googlegroups.com> <7d701221-cdf4-4679-beb3-90492dd52bce@i13g2000yqe.googlegroups.com> Message-ID: On Jan 24, 9:02?am, rantingrick wrote: > On Jan 24, 8:49?am, Mike Driscoll wrote: > > > On Jan 24, 7:24?am, Bryan wrote: > > > In my experience, segfaults with wxPython aren't daily, but they are > > > pretty much weekly. There are weeks that can go by without them, but > > > then I'll have several in a week to bump up the average. > > > I've only run my code on Windows and Linux, but I haven't had this > > issue. The only time I've had segfaults was when I was first learning > > how to get threading and wx to work properly and when I was creating > > binaries with py2exe. > > Thanks. I knew these guys were full of it. Not necessarily. He may been using some of the generic widgets, like the agw stuff. The agw set is awesome, but they haven't been tested extensively on anything other than Windows because their author is a Windows programmer. > > I like the concept of > > creating a challenge to see which toolkit can do what, but this is not > > the way to go about it. > > Well by all means offer some input. You have offered opinions but no > ideas. I would love to hear any ideas you may have. And yes, Tkinter > has a very likable API. I have mentioned this fact many times and in > many threads. However when weighed on all factors wx will win. Because > even though we may need to mold the wx API a bit, at least with wx we > have a solid feature rich platform to work from. > I haven't gotten my ideas fleshed out yet. When I do, I will describe them. ------------------- Mike Driscoll Blog: http://blog.pythonlibrary.org From orasnita at gmail.com Mon Jan 24 12:02:22 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Mon, 24 Jan 2011 19:02:22 +0200 Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <70498$4d3cb87c$4275d90a$4428@FUSE.NET> <63eea$4d3cd2fd$4275d90a$14984@FUSE.NET> <69465430-08b3-4069-99c7-72f4d3034c66@s5g2000yqm.googlegroups.com> <705ad$4d3ce0fc$4275d90a$29144@FUSE.NET><3d68e6fe-be68-4713-8330-20886d914547@r29g2000yqj.googlegroups.com> <4D3CFD0F.1080502@tysdomain.com><58325C0B6449487E97D2523C1685624F@octavian> <4D3D89A1.8050206@tysdomain.com> Message-ID: From: "Littlefield, Tyler" > >Or you have started to use Linux and now you don't care about the > majority of >users that need to use a screen reader? > I said nothing the like. TkInter does have problemns with Jaws, but I'm > not going to sit here and say the same thing over and over as you are > doing. Get off the soapbox already. If something's wrong, the people need to know that what they like is wrong and the wrong things need to be changed with something better. And I just shown why Tkinter is a very bad tool. I'm not in love with wxWIDGETS because they also provide a few widgets which have problems. I like MFC, but unfortunately it is not portable. Octavian From santosh.tronics at gmail.com Mon Jan 24 12:09:31 2011 From: santosh.tronics at gmail.com (santosh hs) Date: Mon, 24 Jan 2011 09:09:31 -0800 (PST) Subject: Which is the best book to learn python Message-ID: <188c0a9f-4e93-4fae-b3f9-e7c84f8030fd@v31g2000pri.googlegroups.com> Hi All, i am beginner to python please tell me which is the best available reference for beginner to start from novice From ethan at stoneleaf.us Mon Jan 24 12:12:25 2011 From: ethan at stoneleaf.us (Ethan Furman) Date: Mon, 24 Jan 2011 09:12:25 -0800 Subject: [Code Challenge] WxPython versus Tkinter. In-Reply-To: References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> Message-ID: <4D3DB2F9.3090303@stoneleaf.us> Octavian Rasnita wrote: > From: "rantingrick" >> WxPython versus Tkinter (A code battle to the death!) >> >> by Rick Johnson. [...] Octavian, Please do not repost rr's crap in its entirety, or you'll find yourself added to many killfiles -- just like he is. ~Ethan~ From robert.kern at gmail.com Mon Jan 24 12:12:33 2011 From: robert.kern at gmail.com (Robert Kern) Date: Mon, 24 Jan 2011 11:12:33 -0600 Subject: I'm interested in calculating time down to the femtosecond. In-Reply-To: <076E4FFD-54FA-4665-9F32-E446731D52C7@gmail.com> References: <076E4FFD-54FA-4665-9F32-E446731D52C7@gmail.com> Message-ID: On 1/23/11 12:43 AM, Slie wrote: > > > I found that there was a code submission at NumPy 1.4 but I can not find in the documentation search for Date nor have found anything other then that discussion of the ability. > > Anyone have any ideas suggestions? I just want my program to be able to calculate it nothing special. You will want to ask questions about numpy on the numpy-discussion mailing list. http://www.scipy.org/Mailing_Lists It's difficult to understand your question, but I suspect that you are asking about the datetime and timedelta dtypes that were going to be added in 1.4. They were removed since the necessary modifications caused an unintended ABI break. They will return in a future release. -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco From rantingrick at gmail.com Mon Jan 24 12:17:01 2011 From: rantingrick at gmail.com (rantingrick) Date: Mon, 24 Jan 2011 09:17:01 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <70498$4d3cb87c$4275d90a$4428@FUSE.NET> <46c407b5-9bfe-406a-a2fe-c63caa771bf3@f2g2000vby.googlegroups.com> <05fd32ee-e542-4622-afa8-a7cf4549df45@k42g2000yqa.googlegroups.com> Message-ID: <709769f9-f99a-46c8-bcc1-7a03adf303c6@v17g2000vbo.googlegroups.com> On Jan 24, 7:32?am, Peter Otten <__pete... at web.de> wrote: > rantingrick wrote: > > I am demanding that from now on, you > > must have at least a 120 or higher IQ before participating in any of > > my threads. > > You mean, you are putting yourself in your own killfile ;) :) Actually i never use the killfile and never will. The main reason is because i believe in the old adage: "Keep friends close and enemies closer". But i don't have any enemies here (as far as i am concerned). However the real reason i will not use the killfile is because i believe that people can change. Even very wise people are not immune to bad decisions. Case in point: My initial disgust with Ruby was completely unfounded. Ruby has a lot to offer the programming world and while it is not my preferred language, we as Python programmers can learn much from Ruby and likewise Ruby can learn from us. I was being a closed minded idiot at the time. I have since evolved. In any event the killfile only serves as instant gratification for the selfish "one dimensional" folks among us. If you are so fearful of someone's words that you must hide your eyes from them then you lack basic self control. And in the end, the only thing you kill is your own humanity. :( From rantingrick at gmail.com Mon Jan 24 12:17:25 2011 From: rantingrick at gmail.com (rantingrick) Date: Mon, 24 Jan 2011 09:17:25 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <70498$4d3cb87c$4275d90a$4428@FUSE.NET> <63eea$4d3cd2fd$4275d90a$14984@FUSE.NET> <69465430-08b3-4069-99c7-72f4d3034c66@s5g2000yqm.googlegroups.com> <705ad$4d3ce0fc$4275d90a$29144@FUSE.NET> <3d68e6fe-be68-4713-8330-20886d914547@r29g2000yqj.googlegroups.com> <7d701221-cdf4-4679-beb3-90492dd52bce@i13g2000yqe.googlegroups.com> Message-ID: <31a0a893-6d0f-40cd-b84c-a7d3363138cb@f20g2000vbc.googlegroups.com> On Jan 24, 10:38?am, Mike Driscoll wrote: > I haven't gotten my ideas fleshed out yet. When I do, I will describe > them. I look forward to any proposals and i would like to be a part of this challenge both for wxPython and Tkinter since i have used both. From rantingrick at gmail.com Mon Jan 24 12:28:32 2011 From: rantingrick at gmail.com (rantingrick) Date: Mon, 24 Jan 2011 09:28:32 -0800 (PST) Subject: Need GUI pop-up to edit a (unicode ?) string References: <3tqr08-bj2.ln1@murmur.very.softly> Message-ID: On Jan 22, 2:22?pm, Rikishi42 wrote: > I'm in need for a graphical pop-up that will display a (unicode ?) string in > a field, allow the user to change it and return the modified string. > > Maybe also keep the original one displayed above it. > > Something like this: > +-------------------------------------------------+ > | ? Please confirm or edit the following string ? | > | ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? | > | ? ? Original_example_string ? ? ? ? ? ? ? ? ? ? | > | ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? | > | ?+-------------------------------------------+ ?| > | ?| ?Original_about_to_be_changed ? ? ? ? ? ? | ?| > | ?+-------------------------------------------+ ?| > | ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? | > | ? ? ? ? ? ? ? ? ? ? OK ? ? ? ? ? ? ? ? ? ? ? ? ?| > | ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? | > +-------------------------------------------------+ If you download wxPython and build it with unicdode support (i did not for my version!) you can use a simple textctrl and a statictext to display this. For an example of how to do this download the wxPython demo and in the tree menu under the "miscellaneous" node pick the "Unicode" example. You will be able to see both the source code and run a demo of this example strait from the demo GUI! If you need help turning the demo code into something usable for your script then post back here and i will help you create whatever you want. From hnsri49 at gmail.com Mon Jan 24 12:31:09 2011 From: hnsri49 at gmail.com (srinivas hn) Date: Mon, 24 Jan 2011 23:01:09 +0530 Subject: Which is the best book to learn python In-Reply-To: <188c0a9f-4e93-4fae-b3f9-e7c84f8030fd@v31g2000pri.googlegroups.com> References: <188c0a9f-4e93-4fae-b3f9-e7c84f8030fd@v31g2000pri.googlegroups.com> Message-ID: search for byte of python in google its good book for beginners . . CHEERS CNA 9986229891 On Mon, Jan 24, 2011 at 10:39 PM, santosh hs wrote: > Hi All, > i am beginner to python please tell me which is the best available > reference for beginner to start from novice > -- > http://mail.python.org/mailman/listinfo/python-list > -------------- next part -------------- An HTML attachment was scrubbed... URL: From jeanmichel at sequans.com Mon Jan 24 12:38:29 2011 From: jeanmichel at sequans.com (Jean-Michel Pichavant) Date: Mon, 24 Jan 2011 18:38:29 +0100 Subject: Which is the best book to learn python In-Reply-To: <188c0a9f-4e93-4fae-b3f9-e7c84f8030fd@v31g2000pri.googlegroups.com> References: <188c0a9f-4e93-4fae-b3f9-e7c84f8030fd@v31g2000pri.googlegroups.com> Message-ID: <4D3DB915.9060601@sequans.com> santosh hs wrote: > Hi All, > i am beginner to python please tell me which is the best available > reference for beginner to start from novice > Hi, You could have searched the archive, this question was raised many times. http://wiki.python.org/moin/IntroductoryBooks I read "Learning Python" when I started. Since it's the only one I read I cannot tell you which one is the best (if there is). Python is easy to learn, I'm not sure it's possible to write a bad book about it. JM From mark at markroseman.com Mon Jan 24 12:39:56 2011 From: mark at markroseman.com (Mark Roseman) Date: Mon, 24 Jan 2011 10:39:56 -0700 Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> 7c$4275d90a$44222222222222 <63eea$4d3cd2fd$4275d90a$14984@FUSE.NET> <69465430-08b3-4069-99c7-72f4d3034c66@s5g2000yqm.googlegroups.com> <705ad$4d3ce0fc$4275d90a$29144@FUSE.NET> Message-ID: "Octavian Rasnita" wrote: > But unfortunately it is not accessible for screen readers and it > discriminates many potential users. Octavian, thank you for very clearly making and repeating your point about screen readers. It is very obvious that at this point in time Tk (and hence Tkinter) is not a suitable candidate if screen readers are an important concern. In an ideal world, every GUI would be fully accessible. The reality is that sometimes, competing requirements will lead to accessibility being lower in the priority list than other things. So with different requirements and priorities, the "best" solution will be different. I don't object and in fact commend you for advocating for accessibility. I do feel you are not acknowledging and fully respecting that others may be in situations where accessibility may not be the primary concern. Thanks again Mark From cjwilliams43 at gmail.com Mon Jan 24 12:45:45 2011 From: cjwilliams43 at gmail.com (Colin J. Williams) Date: Mon, 24 Jan 2011 12:45:45 -0500 Subject: Which is the best book to learn python In-Reply-To: References: <188c0a9f-4e93-4fae-b3f9-e7c84f8030fd@v31g2000pri.googlegroups.com> Message-ID: On 24-Jan-11 12:38 PM, Jean-Michel Pichavant wrote: > santosh hs wrote: >> Hi All, >> i am beginner to python please tell me which is the best available >> reference for beginner to start from novice > > Hi, > > You could have searched the archive, this question was raised many times. > > http://wiki.python.org/moin/IntroductoryBooks > > I read "Learning Python" when I started. Since it's the only one I read > I cannot tell you which one is the best (if there is). > Python is easy to learn, I'm not sure it's possible to write a bad book > about it. > > JM > I liked Alex Martelli's Python in a nutshell, but it's a bit dated now. Colin W. From rantingrick at gmail.com Mon Jan 24 12:57:55 2011 From: rantingrick at gmail.com (rantingrick) Date: Mon, 24 Jan 2011 09:57:55 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> 7c$4275d90a$44222222222222 <63eea$4d3cd2fd$4275d90a$14984@FUSE.NET> <69465430-08b3-4069-99c7-72f4d3034c66@s5g2000yqm.googlegroups.com> <705ad$4d3ce0fc$4275d90a$29144@FUSE.NET> Message-ID: <73b412bc-5414-4747-8ee0-ce08cedb5cb3@v17g2000prc.googlegroups.com> On Jan 24, 11:39?am, Mark Roseman wrote: > ?"Octavian Rasnita" wrote: > > > But unfortunately it is not accessible for screen readers and it > > discriminates many potential users. > > Octavian, thank you for very clearly making and repeating your point > about screen readers. ?It is very obvious that at this point in time Tk > (and hence Tkinter) is not a suitable candidate if screen readers are an > important concern. > > In an ideal world, every GUI would be fully accessible. ?The reality is > that sometimes, competing requirements will lead to accessibility being > lower in the priority list than other things. ?So with different > requirements and priorities, the "best" solution will be different. > > I don't object and in fact commend you for advocating for accessibility. ? > I do feel you are not acknowledging and fully respecting that others may > be in situations where accessibility may not be the primary concern. ? Why don't you just tell him to shut the hell up Mark? Anyone can see that SHUT THE HELL UP is what you are implying here. Obviously you guys are worried terribly about accessibility hurting your "one dimensional" position of supporting the legacy TclTk. Otherwise you would not make veiled threats like this. Your post is an obvious veiled threat to anyone of average intelligence! Octavian has already been threatened with the kill file by Ethan for accidentally quoting me too much. You guys are very disappointing to this community. Everyone here needs a voice. We must never engage in behaviors that would limit speech from our community members who have the intelligence to offer reasonable arguments. Octavian is not a troll or spammer and should not be treated as such! Stop this threating of our community members NOW! From krzysztof.t.bieniasz at gmail.com Mon Jan 24 12:59:46 2011 From: krzysztof.t.bieniasz at gmail.com (Krzysztof Bieniasz) Date: Mon, 24 Jan 2011 17:59:46 +0000 (UTC) Subject: Which is the best book to learn python References: <188c0a9f-4e93-4fae-b3f9-e7c84f8030fd@v31g2000pri.googlegroups.com> Message-ID: Dnia Mon, 24 Jan 2011 09:09:31 -0800, santosh hs napisa?(a): > Hi All, > i am beginner to python please tell me which is the best available > reference for beginner to start from novice For most CS stuff O'Reilly is most often a good bet. Therefore I think you'll find Mark Lutz's "Learning Python" useful. From bryan.oakley at gmail.com Mon Jan 24 13:00:16 2011 From: bryan.oakley at gmail.com (Bryan) Date: Mon, 24 Jan 2011 10:00:16 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <100e192f-9a6c-4c3a-8092-a65cd04eef64@o14g2000yqe.googlegroups.com> Message-ID: On Jan 24, 7:27?am, "Octavian Rasnita" wrote: > From: "Bryan" > > > It would be hard (but not impossible, by any > > stretch) for me to duplicate your code. Certainly, it would take more > > lines of code but that's about it. OTOH, it would be very difficult > > indeed to create atkinterprogram that works on windows but segfaults > > on linux. That's also quite hard intkinter. > > I doubt you could do a program that offers the same features usingTkinter. > That program will not be accessible for screen readers and this is a big > problem, a vital problem for those that use a screen reader, because the > program won't be accessible at all. > > Octavian I wish I could respond to that, but I have no experience with screen readers. Are there any free ones, or ones with free trials, that I could try out? I'm not yet convinced it's any better or worse than wxPython since you're only a single datapoint, but of course it's possible. If you know of any free tools I can use to experiment, I'd appreciate you posting them in this newsgroup. Accessibility, like internationalization, is something few programmers spend much time thinking about. I can only imagine the frustration one must experience if all interactions had to be through a screen reader. From rantingrick at gmail.com Mon Jan 24 13:05:14 2011 From: rantingrick at gmail.com (rantingrick) Date: Mon, 24 Jan 2011 10:05:14 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <100e192f-9a6c-4c3a-8092-a65cd04eef64@o14g2000yqe.googlegroups.com> Message-ID: <668d4047-58a8-4208-8bd0-92a7c7344d2f@o9g2000pre.googlegroups.com> On Jan 24, 12:00?pm, Bryan wrote: > Accessibility, like internationalization, is something few programmers > spend much time thinking about. Thats another uninformed statement by you we can add to the mountains of useless cruft you have offered so far. Unicode IS internationalization and Guido thought it was SO important that Python3000 auto converts all strings to Unicode strings. Obviously he is moving us toward full Unicode only in the future (AS SHOULD ALL IMPLEMENTATIONS!). We need one and only one obvious way to do it. And Unicode is that way. From bryan.oakley at gmail.com Mon Jan 24 13:11:32 2011 From: bryan.oakley at gmail.com (Bryan) Date: Mon, 24 Jan 2011 10:11:32 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <70498$4d3cb87c$4275d90a$4428@FUSE.NET> <63eea$4d3cd2fd$4275d90a$14984@FUSE.NET> <69465430-08b3-4069-99c7-72f4d3034c66@s5g2000yqm.googlegroups.com> <705ad$4d3ce0fc$4275d90a$29144@FUSE.NET> <3d68e6fe-be68-4713-8330-20886d914547@r29g2000yqj.googlegroups.com> <2e6deec8-bdca-40ec-a759-6fa2951585fb@s5g2000yqm.googlegroups.com> Message-ID: <32a5f619-f085-4a1e-adf1-54290610cad0@u13g2000prd.googlegroups.com> On Jan 24, 7:32?am, rantingrick wrote: > On Jan 24, 7:24?am, Bryan wrote: > > > On Jan 24, 12:06?am, rusi wrote: > > > > On Jan 24, 9:16?am, "Littlefield, Tyler" wrote: > > > > Of course as Steven pointed out wx is written in C++ which is almost > > > certainly where the crash is occurring. > > > But this is technical nitpicking. > > > The real issue is that when coding in C/C++ segfaults are a daily > > > affair. > > > Whereas forpythonits the first time I am seeing it in 10 years... > > > In my experience, segfaults withwxPythonaren't daily, but they are > > pretty much weekly. > > hmm > > > There are weeks that can go by without them, but > > then I'll have several in a week to bump up the average. > > Yes, and this could not be your problem, it must bewxPython. Right? > *rolls-eyes* Correct. A scripting language should *never* segfault. If it does, it is a bug in the language or library. It is a provable fact that wxPython segfaults. You yourself proved that. That is, in and of itself, *not* a reason to pick some other toolkit. It's merely a datapoint. It's not a datapoint you can just sweep under the rug, however, like you seem to want to do. > > > ?There are > > a lot of things you can do that aren't valid in particular contexts, > > and instead of throwing a catchable error you get a segfault. > > And we need to fix that instead just disqualifying a feature rich > toolkit. I think if you re-read my post you'll see I don't disqualify it as a rich toolkit. wxPython is a fine toolkit. Better than tkinter in some ways, worse in others. segfaults is one aspect in which it is measurably worse. From tyler at tysdomain.com Mon Jan 24 13:21:07 2011 From: tyler at tysdomain.com (Littlefield, Tyler) Date: Mon, 24 Jan 2011 11:21:07 -0700 Subject: WxPython versus Tkinter. In-Reply-To: References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> 7c$4275d90a$44222222222222 <63eea$4d3cd2fd$4275d90a$14984@FUSE.NET> <69465430-08b3-4069-99c7-72f4d3034c66@s5g2000yqm.googlegroups.com> <705ad$4d3ce0fc$4275d90a$29144@FUSE.NET> Message-ID: <4D3DC313.8040905@tysdomain.com> Hello, I have been on another list with Octavian, and he takes his accessibility a bit to seriously. If things went his way, he wants laws where -everything- has to be accessible, and it is illegal not to do so. As a sidenote, I would like to preface everything I'm going to say by mentioning the fact that I have been using a screen reader for many years, so I understand some of where he is coming from. I think my goal, (and I differ from Octavian here), is to try to find fixes for things, rather than saying "this sucks, it does not work with a reader, and thus it shouldn't be used). Having done a lot of development work in the past, I can't say "hey you, I want you to make this app accessible, and because you used TKInter it's not, so use something else, but nothing that isn't accessible." Rather, I believe those pushing accessibility should concentrate on the root cause; that of fixing TKInter, and not forcing everyone else to use a different library. I believe that the approach is the main key here, and I have had this argument many times. If I wrote an app, and someone said something along the lines of "you need to change a core library because it doesn't work with this program," my first response would be who the hell are you to say what I need to use? We need to take the approach of "This is what is wrong, this is why, this is possibly how it could be fixed. Would you be willing to do so?" So, with all of this said, TKInter -is- unaccesssible for us. My arguments have not been for or against one or the other in this thread, but more to get RR to make a better point. Because eventually, WX would benafit those using a screen reader a lot more than say, TKInter will. That doesn't mean that I'm saying that we need to make it a part of the stdlib as of yesterday, because segfaults from someone with 10+ years of experience (multiple people, actually) says a lot, whether or not RR wants to acknowledge said facts. I can not with good conchence say that the switch should be done just for accessibility purposes. Obviously it would be awesome, but I think Octavian is just focusing on himself, and not the actual big picture here. From rantingrick at gmail.com Mon Jan 24 13:26:54 2011 From: rantingrick at gmail.com (rantingrick) Date: Mon, 24 Jan 2011 10:26:54 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <70498$4d3cb87c$4275d90a$4428@FUSE.NET> <63eea$4d3cd2fd$4275d90a$14984@FUSE.NET> <69465430-08b3-4069-99c7-72f4d3034c66@s5g2000yqm.googlegroups.com> <705ad$4d3ce0fc$4275d90a$29144@FUSE.NET> <3d68e6fe-be68-4713-8330-20886d914547@r29g2000yqj.googlegroups.com> <2e6deec8-bdca-40ec-a759-6fa2951585fb@s5g2000yqm.googlegroups.com> <32a5f619-f085-4a1e-adf1-54290610cad0@u13g2000prd.googlegroups.com> Message-ID: On Jan 24, 12:11?pm, Bryan wrote: > It is a provable fact that wxPython segfaults. You yourself proved > that. That is, in and of itself, *not* a reason to pick some other > toolkit. It's merely a datapoint. It's not a datapoint you can just > sweep under the rug, however, like you seem to want to do. Ok, now you are talking with facts and we can have a real debate! Yes wxPython can be made to segfault by the user in some circumstances. And YES this is very undesirable and it is the direct product of a poorly written API. However! I do not blame the wxPython creators or even Robin Dunn himself for this problem. Robin has stated many times that he wants to keep wxPython as close to wxWidgets as possible and he also said there is room for a "top level" API. This is why wxPython proper has no business in the stdlib! We need an abstraction API written in Python. So my point is, we need to create this API independent of wxPython. You can think of it as "wx-inter" if you like. > I think if you re-read my post you'll see I don't disqualify it as a > rich toolkit. wxPython is a fine toolkit. Better than tkinter in some > ways, worse in others. segfaults is one aspect in which it is > measurably worse. Again: good argument! And i stand on my last reply. If you would be interested i would like to work on this abstraction API with you. Are you interested? How free are you? We need to work together to solve this problem. From ethan at stoneleaf.us Mon Jan 24 13:28:31 2011 From: ethan at stoneleaf.us (Ethan Furman) Date: Mon, 24 Jan 2011 10:28:31 -0800 Subject: WxPython versus Tkinter. In-Reply-To: References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> 7c$4275d90a$44222222222222 <63eea$4d3cd2fd$4275d90a$14984@FUSE.NET> <69465430-08b3-4069-99c7-72f4d3034c66@s5g2000yqm.googlegroups.com> <705ad$4d3ce0fc$4275d90a$29144@FUSE.NET> Message-ID: <4D3DC4CF.3020606@stoneleaf.us> Mark Roseman wrote: > > I don't object and in fact commend you for advocating for accessibility. > I do feel you are not acknowledging and fully respecting that others may > be in situations where accessibility may not be the primary concern. Well said. ~Ethan~ From tyler at tysdomain.com Mon Jan 24 13:31:41 2011 From: tyler at tysdomain.com (Littlefield, Tyler) Date: Mon, 24 Jan 2011 11:31:41 -0700 Subject: WxPython versus Tkinter. In-Reply-To: References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <100e192f-9a6c-4c3a-8092-a65cd04eef64@o14g2000yqe.googlegroups.com> Message-ID: <4D3DC58D.3010407@tysdomain.com> Bryan: Here's a pretty good list for you. Windows: Jaws for Windows (http://freedomscientific.com). Not free, but you get a 40 minute demo before you need to reboot. Nonvisual Desktop Access: http://www.nvda-project.org/ Free, open source, written in python (with some core stuff in c/c++). Linux: Orca live.gnome.org/Orca Fre, open source. If you don't want to install that bloated mess on a box (I sympathise), and you can grab a vmware vinux or a live cd or whatever from: http://vinux.org.uk OSX: OSX comes built in with Voiceover, just hold down the command key and hit F5. Use the same keystroke to turn it off. Enjoy! From enalicho at gmail.com Mon Jan 24 13:33:40 2011 From: enalicho at gmail.com (Noah Hall) Date: Mon, 24 Jan 2011 18:33:40 +0000 Subject: WxPython versus Tkinter. In-Reply-To: <73b412bc-5414-4747-8ee0-ce08cedb5cb3@v17g2000prc.googlegroups.com> References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <63eea$4d3cd2fd$4275d90a$14984@FUSE.NET> <69465430-08b3-4069-99c7-72f4d3034c66@s5g2000yqm.googlegroups.com> <705ad$4d3ce0fc$4275d90a$29144@FUSE.NET> <73b412bc-5414-4747-8ee0-ce08cedb5cb3@v17g2000prc.googlegroups.com> Message-ID: On Mon, Jan 24, 2011 at 5:57 PM, rantingrick wrote: > Why don't you just tell him to shut the hell up Mark? > accidentally quoting me too much. You guys are very disappointing to > this community. Everyone here needs a voice. We must never engage in > behaviors that would limit speech from our community members who have > the intelligence to offer reasonable arguments. Octavian is not a > troll or spammer and should not be treated as such! Stop this > threating of our community members NOW! Oh, the irony. It's not so much what you're saying, but the way you're saying it. You're not allowed to treat people like that - no matter how much you *think* you're right. You've done nothing but accuse anyone disagreeing with you of being a troll and then proceed to curse them. I don't know why you're surprised people won't discuss matters with you. It sounds like you have a lot of growing up you need to do. From bryan.oakley at gmail.com Mon Jan 24 13:39:59 2011 From: bryan.oakley at gmail.com (Bryan) Date: Mon, 24 Jan 2011 10:39:59 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <100e192f-9a6c-4c3a-8092-a65cd04eef64@o14g2000yqe.googlegroups.com> <1ed86ac9-e8a9-48b3-8f27-bf480782eb82@w17g2000yqh.googlegroups.com> Message-ID: On Jan 24, 8:15?am, rantingrick wrote: > On Jan 24, 6:33?am, Bryan wrote: > > > I think I'm qualified, though I guess only you can tell me if I > > measure up to your standards. > > Go on... > > > I have 15 years or so of tk development, > > though admittedly mostly with Tcl. Most recently I've spent about the > > past year and a half withwxPython. > > A year and a half and you are still producing buggy code? (you > yourself admitted this!) Of course! You'll not find a single programmer who creates bug-free code. (I'm beginning to think we're dealing with a software-based troll programmed to focus in on specific words in order to set up strawman arguments) > > > For what it's worth, I am the only > > person on stackoverflow.com with the "tkinter" badge, which only means > > I've answered a bunch of questions ontkinterthat others find > > helpful, nothing more. > > Well could we see a link to a few answered questions or get your nick > so we can corroborate this statement ourselves? Sure! I don't feel compelled to answer your demands but this one is harmless enough. http://stackoverflow.com/users/7432/bryan-oakley if you want, you can also do a search on google groups for my other email address "oakley at bardo.clearlight.com". I have a history in comp.lang.tcl that goes back to almost the dawn of time. I'm the 8th most prolific poster (and pretty much all answers, very few questions), though I'd be higher except I used a different email for a year or so back in 2002-2004 http://groups.google.com/group/comp.lang.tcl/about > > > No offense, but your challenge is worthless, and your own entry in the > > challenge is remarkably weak. > > First rule when given a challenge you cannot answer due to ignorance: > question the validity of the challenge. And the first rule for dealing with someone who gives facts that don't agree with you is to call them names. > > > ?About the only thing you've proven is > > thatwxPythonhas some built-in widgets thattkinterdoes not have, > > Well this is ONLY the first challenge Bryan. More will come. However, > not until someone has the balls to answer my first challenge. Honestly, your challenge is childish. The rules are self-serving and the outcome proves nothing. Your challenge serves nothing but to prove wxPython has a built-in widget that tkinter does not. Nobody disputes that. Proving it in code is pointless when it's a well known, documented fact. > > > and thatwxPythonmakes it hard to do cross-platform development. > > I don't think that is completely accurate Bryan. Harder thanTkinter, > yes. Anything else is hyperbole. > > > Does > > that surprise anyone? I'll give you a challenge: create a vector > > graphics program. > > Answer my challenge first, then we talk. And obviously you do not > understand the power of wx's Open Graphics Library (OGL). You'd better > go check that out before you stick yourTkinterloving foot into your > big mouth. I stand corrected. It was early, that was the first thing that came to mind. >... > > What's really amusing is that your program segfaults on linux yet is > > supposed to showwxPythonsuperiority. > > Segfault or not wx is superior. I don't know if you realize it, but that's a funny statement. > > > In my 15-20 years of tk > > development, you know how many segfaults I've seen? Approximately > > zero. > > BULLSHITE! No, seriously. Tcl/tk and python/tkinter are both remarkably stable in this regard. You want a programming challenge? Try creating an app using either of those combinations to get a segfault. I'm not saying it can't be done, but it _is_ challenging. > ... > LIAR! LIAR! PANTS ON FIRE! Ok, now I'm pretty certain I'm responding to a bot. Time to move on. From rantingrick at gmail.com Mon Jan 24 13:48:53 2011 From: rantingrick at gmail.com (rantingrick) Date: Mon, 24 Jan 2011 10:48:53 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> 7c$4275d90a$44222222222222 <63eea$4d3cd2fd$4275d90a$14984@FUSE.NET> <69465430-08b3-4069-99c7-72f4d3034c66@s5g2000yqm.googlegroups.com> <705ad$4d3ce0fc$4275d90a$29144@FUSE.NET> Message-ID: <5f8c1256-f07c-43be-8307-d36991e9be24@m35g2000vbn.googlegroups.com> On Jan 24, 12:21?pm, "Littlefield, Tyler" wrote: [...snip: good discussion...] > Rather, I believe > those pushing accessibility should concentrate on the root cause; that > of fixing TKInter, and not forcing everyone else to use a different library. Now you go too far! And this is an ironic position from someone who supports the stdlib GUI that IS forced on us by default. Sure you can choose a different library, but in the case of a user (and accessibility is a big USER concern when that user is handicapped!) the library is already chosen (Tkinter:which does not support accessibility) by the developer . I can also argue that Tkinter's inclusion in the stdlib is proliferating non-compliance with accessibility. I'll bet you would not park in a handicap spot however you support a GUI library that ignores handicap people? IRONIC! > I believe that the approach is the main key here, and I have had this > argument many times. If I wrote an app, and someone said something along > the lines of "you need to change a core library because it doesn't work > with this program," my first response would be who the hell are you to > say what I need to use? Well these people you are chastising are disabled people. Who the hell are YOU to be high and mighty about it? I guess these "disabled" people get what they deserve huh! Maybe we should just do the world a favor and exterminate them like the Nazis? That way we don't have to cater to their selfish needs! > We need to take the approach of "This is what is > wrong, this is why, this is possibly how it could be fixed. Would you be > willing to do so?" WE ALL NEED TO TAKE THAT APPROACH TYLER, INCLUDING YOURSELF!!! > So, with all of this said, TKInter -is- unaccesssible for us. My > arguments have not been for or against one or the other in this thread, > but more to get RR to make a better point. Yea, and i just made it. > Because eventually, WX would > benafit those using a screen reader a lot more than say, TKInter will. > That doesn't mean that I'm saying that we need to make it a part of the > stdlib as of yesterday, because segfaults from someone with 10+ years of > experience (multiple people, actually) says a lot, whether or not RR > wants to acknowledge said facts. I can not with good conchence say that > the switch should be done just for accessibility purposes. No one said accessibility was the only argument. However it IS very important in todays time. We are not living in the dark ages, much less under Hitlers rule! If a GUI library has refused to recognize accessibility concerns a decade into the 21st century, just how long must we wait Tyler? HOW LONG? > Obviously it > would be awesome, but I think Octavian is just focusing on himself, and > not the actual big picture here. Yes Octavian is the only disabled person in the world. What a selfish, selfish person he is. Shame on you Octavian, Shame on You! You just showed your true colors Tyler, very sad. :( From bryan.oakley at gmail.com Mon Jan 24 14:00:43 2011 From: bryan.oakley at gmail.com (Bryan) Date: Mon, 24 Jan 2011 11:00:43 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <70498$4d3cb87c$4275d90a$4428@FUSE.NET> <63eea$4d3cd2fd$4275d90a$14984@FUSE.NET> <69465430-08b3-4069-99c7-72f4d3034c66@s5g2000yqm.googlegroups.com> <705ad$4d3ce0fc$4275d90a$29144@FUSE.NET> <3d68e6fe-be68-4713-8330-20886d914547@r29g2000yqj.googlegroups.com> Message-ID: On Jan 24, 8:49?am, Mike Driscoll wrote: > > Bryan, on the other hand, has been aTkinterluminary who has helped > me in the past when I was learningTkinterand I won't be too > surprised if he helps me again. I'm sorry he's had so much trouble > with wx though. Thanks for the kind words, I appreciate it. I'm puzzled by the problems I have with wxPython, too. It's taken me longer to get a grasp on some concepts that I would have guessed. The first time I got a segfault I was stunned but shrugged it off. A segfault in a scripting language? Blasphemy! Now I'm not so stunned anymore, but I still shrug them off. Part of the blame certainly rests on my shoulder. With only a year and a half or so under my belt with wxPython there's still lots I have to learn and the documentation only gets me so far. What's the rule of thumb -- it takes 10 years to become an expert on a subject? The underlying architecture of tk is so solid, so well designed (IMHO) that you (well, I) take a lot of stuff for granted. Then you switch to something like wxPython where the foundation is maybe a little shaky in exchange for a much richer library of widgets, and the transition is bound to be bumpy. It's not generally a matter of "better" or "worse", just "different". The key to success is to realize both of the toolkits are just that -- toolkits. They aren't religion, they aren't an assault on family values or a threat to national security. They are tools to get the job done. Instead of saying "mine is better than yours" it's better to learn the strengths and weaknesses of both (or all) and pick the right one for the job. Attempting to prove that any of these toolkits is "best" is tilting at windmills. Personally, I think tkinter is the right choice as a built-in toolkit but I'll admit to bias. The basics are really simple, and for 90% of the stuff you're going to code in a scripting language it has all the features you need. If you specifically need something like the styledtextctrl or grid of wxPython, or maybe you're concerned with accessibility or some feature that's not built in to tkinter, by all means switch to a different toolkit. That's the beauty of these GUI toolkits -- you can keep the language you love (python, in the case of this newsgroup) yet pick the GUI toolkit that best helps you solve the problem at hand. Instead of fighting over the differences, raise a pint in celebration of their diversity. :-) From mark at markroseman.com Mon Jan 24 14:21:02 2011 From: mark at markroseman.com (Mark Roseman) Date: Mon, 24 Jan 2011 12:21:02 -0700 Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <63eea$4d3cd2fd$4275d90a$14984@FUSE.NET> <69465430-08b3-4069-99c7-72f4d3034c66@s5g2000yqm.googlegroups.com> <705ad$4d3ce0fc$4275d90a$29144@FUSE.NET> Message-ID: "Littlefield, Tyler" wrote: > Rather, I believe > those pushing accessibility should concentrate on the root cause; that > of fixing TKInter, and not forcing everyone else to use a different library. Here, here. From my queries to some of the Tcl/Tk folks, it seems that while the knowledge and expertise is not present in the core developer community, they would be more than happy to help people who do have some knowledge in this area so that Tk could be made to be more accessible. Grand conspiracies aside, I think the development communities behind most GUI toolkits would be very receptive to people who could help make developing accessible applications with their toolkits feasible. (And if/when this does get done for Tk, I promise at least to make sure that the tutorial at http:///www.tkdocs.com covers this topic). Mark From bryan.oakley at gmail.com Mon Jan 24 14:23:32 2011 From: bryan.oakley at gmail.com (Bryan) Date: Mon, 24 Jan 2011 11:23:32 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <100e192f-9a6c-4c3a-8092-a65cd04eef64@o14g2000yqe.googlegroups.com> <668d4047-58a8-4208-8bd0-92a7c7344d2f@o9g2000pre.googlegroups.com> Message-ID: On Jan 24, 12:05?pm, rantingrick wrote: > On Jan 24, 12:00?pm, Bryan wrote: > > > Accessibility, like internationalization, is something few programmers > > spend much time thinking about. > > Thats another uninformed statement by you we can add to the mountains > of useless cruft you have offered so far. Unicode IS > internationalization and Guido thought it was SO important that > Python3000 auto converts all strings to Unicode strings. Obviously he > is moving us toward full Unicode only in the future (AS SHOULD ALL > IMPLEMENTATIONS!). We need one and only one obvious way to do it. And > Unicode is that way. Ok, great. You've identified one programmer who thinks about internationalization. Not much of a compelling argument there. However, I think you missed my point. My point wasn't that people like Guido don't think of these topics. It's that the people in the trenches who use these tools don't think about these topics. How many of your co-workers actively think about internationalization and accessibility? I'm guessing none, but maybe you're lucking and work in a particularly enlightened team. I've perhaps worked closely with a few hundred programmers in my career, and very few of them thought of these subjects. In my experience it's just not something the programmer in the trenches thinks about. That is the point I was trying to make. From python at mrabarnett.plus.com Mon Jan 24 14:25:23 2011 From: python at mrabarnett.plus.com (MRAB) Date: Mon, 24 Jan 2011 19:25:23 +0000 Subject: WxPython versus Tkinter. In-Reply-To: <668d4047-58a8-4208-8bd0-92a7c7344d2f@o9g2000pre.googlegroups.com> References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <100e192f-9a6c-4c3a-8092-a65cd04eef64@o14g2000yqe.googlegroups.com> <668d4047-58a8-4208-8bd0-92a7c7344d2f@o9g2000pre.googlegroups.com> Message-ID: <4D3DD223.4080602@mrabarnett.plus.com> On 24/01/2011 18:05, rantingrick wrote: > On Jan 24, 12:00 pm, Bryan wrote: > >> Accessibility, like internationalization, is something few programmers >> spend much time thinking about. > > Thats another uninformed statement by you we can add to the mountains > of useless cruft you have offered so far. Unicode IS > internationalization and Guido thought it was SO important that > Python3000 auto converts all strings to Unicode strings. Obviously he > is moving us toward full Unicode only in the future (AS SHOULD ALL > IMPLEMENTATIONS!). We need one and only one obvious way to do it. And > Unicode is that way. > There's more to internationalization than just Unicode. There's the ability to handle messages in various languages which have a different syntax and grammar. There's an interesting Perl-oriented article on it here: http://search.cpan.org/dist/Locale-Maketext/lib/Locale/Maketext/TPJ13.pod#A_Localization_Horror_Story:_It_Could_Happen_To_You From bryan.oakley at gmail.com Mon Jan 24 14:25:39 2011 From: bryan.oakley at gmail.com (Bryan) Date: Mon, 24 Jan 2011 11:25:39 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <100e192f-9a6c-4c3a-8092-a65cd04eef64@o14g2000yqe.googlegroups.com> Message-ID: On Jan 24, 12:31?pm, "Littlefield, Tyler" wrote: > Bryan: Here's a pretty good list for you. > Windows: > Jaws for Windows (http://freedomscientific.com). Not free, but you get a > 40 minute demo before you need to reboot. > Nonvisual Desktop Access:http://www.nvda-project.org/ > Free, open source, written in python (with some core stuff in c/c++). > Linux: > Orca live.gnome.org/Orca > Fre, open source. If you don't want to install that bloated mess on a > box (I sympathise), and you can grab a vmware vinux or a live cd or > whatever from:http://vinux.org.uk > OSX: > OSX comes built in with Voiceover, just hold down the command key and > hit F5. Use the same keystroke to turn it off. > Enjoy! Thanks! I appreciate it. From tyler at tysdomain.com Mon Jan 24 14:26:44 2011 From: tyler at tysdomain.com (Littlefield, Tyler) Date: Mon, 24 Jan 2011 12:26:44 -0700 Subject: WxPython versus Tkinter. In-Reply-To: <5f8c1256-f07c-43be-8307-d36991e9be24@m35g2000vbn.googlegroups.com> References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> 7c$4275d90a$44222222222222 <63eea$4d3cd2fd$4275d90a$14984@FUSE.NET> <69465430-08b3-4069-99c7-72f4d3034c66@s5g2000yqm.googlegroups.com> <705ad$4d3ce0fc$4275d90a$29144@FUSE.NET> <5f8c1256-f07c-43be-8307-d36991e9be24@m35g2000vbn.googlegroups.com> Message-ID: <4D3DD274.7030301@tysdomain.com> RR, I do hate to break the news to you, but I am -blind-, which is why I am using a screen reader. So I'm not parking anywhere--the DMV refuses to give me a license for some odd reason. What was that post about IQ you made earlier?... From emile at fenx.com Mon Jan 24 14:30:45 2011 From: emile at fenx.com (Emile van Sebille) Date: Mon, 24 Jan 2011 11:30:45 -0800 Subject: WxPython versus Tkinter. In-Reply-To: References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <70498$4d3cb87c$4275d90a$4428@FUSE.NET> <46c407b5-9bfe-406a-a2fe-c63caa771bf3@f2g2000vby.googlegroups.com> <05fd32ee-e542-4622-afa8-a7cf4549df45@k42g2000yqa.googlegroups.com> Message-ID: On 1/24/2011 8:13 AM Grant Edwards said... > On 2011-01-24, rantingrick wrote: > >> Bryan you are clearly an idiot. I am demanding that from now on, you >> must have at least a 120 or higher IQ before participating in any of >> my threads. > > Rantingrick thinks certain threads belong to him. > > 'nuf said. > Can we reopen the python-gui list? That'd be the appropriate place to hammer together a PEP to replace tkinter in the standard library. Emile From python at mrabarnett.plus.com Mon Jan 24 14:34:27 2011 From: python at mrabarnett.plus.com (MRAB) Date: Mon, 24 Jan 2011 19:34:27 +0000 Subject: WxPython versus Tkinter. In-Reply-To: <5f8c1256-f07c-43be-8307-d36991e9be24@m35g2000vbn.googlegroups.com> References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> 7c$4275d90a$44222222222222 <63eea$4d3cd2fd$4275d90a$14984@FUSE.NET> <69465430-08b3-4069-99c7-72f4d3034c66@s5g2000yqm.googlegroups.com> <705ad$4d3ce0fc$4275d90a$29144@FUSE.NET> <5f8c1256-f07c-43be-8307-d36991e9be24@m35g2000vbn.googlegroups.com> Message-ID: <4D3DD443.5070906@mrabarnett.plus.com> On 24/01/2011 18:48, rantingrick wrote: > On Jan 24, 12:21 pm, "Littlefield, Tyler" wrote: > > [...snip: good discussion...] > >> Rather, I believe >> those pushing accessibility should concentrate on the root cause; that >> of fixing TKInter, and not forcing everyone else to use a different library. > > Now you go too far! > > And this is an ironic position from someone who supports the stdlib > GUI that IS forced on us by default. Sure you can choose a different > library, but in the case of a user (and accessibility is a big USER > concern when that user is handicapped!) the library is already chosen > (Tkinter:which does not support accessibility) by the developer . I > can also argue that Tkinter's inclusion in the stdlib is proliferating > non-compliance with accessibility. I'll bet you would not park in a > handicap spot however you support a GUI library that ignores handicap > people? IRONIC! > >> I believe that the approach is the main key here, and I have had this >> argument many times. If I wrote an app, and someone said something along >> the lines of "you need to change a core library because it doesn't work >> with this program," my first response would be who the hell are you to >> say what I need to use? > > Well these people you are chastising are disabled people. Who the hell > are YOU to be high and mighty about it? I guess these "disabled" > people get what they deserve huh! Maybe we should just do the world a > favor and exterminate them like the Nazis? That way we don't have to > cater to their selfish needs! > [snip] I'd like to invoke Godwin's law at this point. From ellen.crawford at verigy.com Mon Jan 24 14:41:31 2011 From: ellen.crawford at verigy.com (Crawford, Ellen) Date: Mon, 24 Jan 2011 13:41:31 -0600 Subject: Convert month name to month number faster Message-ID: From jim at lsfdev.com Mon Jan 24 14:42:26 2011 From: jim at lsfdev.com (thompjs) Date: Mon, 24 Jan 2011 11:42:26 -0800 (PST) Subject: Python 3.1 cx_Oracle 5.0.2 "ImportError: DLL load failed: The specified module could not be found." In-Reply-To: References: <1e071bb5-3d28-4cc2-9541-83c08a474164@v15g2000prn.googlegroups.com> Message-ID: <30748079.post@talk.nabble.com> I'm having similar issue but everything seems to be installed in correct places. Loaded "CX_ORACLE.PYD" at address 0x6BD80000. Successfully hooked module. Loaded "OCI.DLL" at address 0x10000000. Successfully hooked module. Unloaded "CX_ORACLE.PYD" at address 0x6BD80000. Unloaded "OCI.DLL" at address 0x10000000. LoadLibraryExA("C:\JSTData\Python27\lib\site-packages\cx_Oracle.pyd", 0x00000000, LOAD_WITH_ALTERED_SEARCH_PATH) returned NULL. Error: The specified procedure could not be found (127). Why is cx_Oracle not found after it has been hooked? Thanks to anyone that can shed some light on this. -- View this message in context: http://old.nabble.com/Python-3.1-cx_Oracle-5.0.2-%22ImportError%3A-DLL-load-failed%3A-The--specified-module-could-not-be-found.%22-tp26422168p30748079.html Sent from the Python - python-list mailing list archive at Nabble.com. From dmaziuk at bmrb.wisc.edu Mon Jan 24 14:44:55 2011 From: dmaziuk at bmrb.wisc.edu (dmaziuk) Date: Mon, 24 Jan 2011 11:44:55 -0800 (PST) Subject: how to tell if cursor is sqlite.Cursor or psycopg2.Cursor Message-ID: <7f1931cd-a15b-44a9-8cf9-b0af0bdfec7d@d8g2000yqf.googlegroups.com> Hi everyone, I've wrapper class around some sql statements and I'm trying to add a method that does: if my_cursor is a sqlite cursor, then run "select last_insert_rowid()" else if it's a psycopg2 cursor, then run "select currval( 'my_sequence' )" etc. The best I can come up with is import both psycopg2 and sqlite and then do if isinstance( self._curs, sqlite.Cursor ) : ... elif isinstance( self._curs, psycopg2._psycopg.cursor ) : ... and I can't help thinking there has to be another way to find out what kind of thing self._curs is. Is there a better way? TIA Dima From robin at alldunn.com Mon Jan 24 14:57:54 2011 From: robin at alldunn.com (Robin Dunn) Date: Mon, 24 Jan 2011 11:57:54 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <3a96fee1-995f-49f7-a967-f125cc3f1cdc@v26g2000yqf.googlegroups.com> Message-ID: On Jan 23, 4:31?pm, "Martin v. Loewis" wrote: > > WxPython Challenge 1 code updated... > > > ?* Fixed tab traveral > > ?* Removed hand-holding code > > ?* Removed some cruft > > > ?https://sites.google.com/site/thefutureofpython/home/code-challenges > > > Good luck! > > Still crashes the interpreter. The crash on Linux is due to SetSingleStyle removing the all items and the columns when the mode of the listctrl is changed, and then the code continues on with the assumption that the columns still exist and the crash happens when an item is added to column zero and there is no column zero. Apparently the native widget on Windows doesn't have that limitation. BTW, if the linux wx packages had the runtime assertions turned on then you would have seen a Python exception with some clues that would probably help solve the problem. I don't know about others but on Ubuntu you can install the *wx*-dbg packages to get a version with the assertions turned on. Hopefully that will change starting with 2.9 as wx now turns on the assertions by default for builds configured normally, and the wx-dev team recommends that the assertions are not turned off, except in rare circumstances. BTW, on behalf of the wxPython community I'd like to apologize for the havoc caused by the flaming troll escaping from his cage. In general wxPython users are much less militant and zealotty and honor everyone's freedom to choose which ever UI tool kit works the best for their own needs. --Robin From orasnita at gmail.com Mon Jan 24 14:58:10 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Mon, 24 Jan 2011 21:58:10 +0200 Subject: [Code Challenge] WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <4D3DB2F9.3090303@stoneleaf.us> Message-ID: <5199876F801C41E08F3E4969745F3E47@teddy> From: "Ethan Furman" > Octavian Rasnita wrote: >> From: "rantingrick" >>> WxPython versus Tkinter (A code battle to the death!) >>> >>> by Rick Johnson. > [...] > > Octavian, > > Please do not repost rr's crap in its entirety, or you'll find yourself > added to many killfiles -- just like he is. :-) I am not posting anyone's crap. I just informed why Tkinter is bad. And I also don't say that WxPython is ideal, but just that it has some very important features that Tk doesn't offer. Octavian From rantingrick at gmail.com Mon Jan 24 15:00:16 2011 From: rantingrick at gmail.com (rantingrick) Date: Mon, 24 Jan 2011 12:00:16 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> 7c$4275d90a$44222222222222 <63eea$4d3cd2fd$4275d90a$14984@FUSE.NET> <69465430-08b3-4069-99c7-72f4d3034c66@s5g2000yqm.googlegroups.com> <705ad$4d3ce0fc$4275d90a$29144@FUSE.NET> <5f8c1256-f07c-43be-8307-d36991e9be24@m35g2000vbn.googlegroups.com> Message-ID: On Jan 24, 1:34?pm, MRAB wrote: > [snip] > I'd like to invoke Godwin's law at this point. Actually no. And i'll give good reason. Tyler's argument, which lacked greatly in compassion for people with disabilities brought out my accusation. It was not an accusation meant to merely insult just to invoke a flame war; which is the definition of Godwins Law. It is a fact that Tyler displayed despicable intolerance for people who have disabilities and such a correlation to totalitarian regimes was not only the correct response but in fact the only response to such veiled hate speech. We cannot allow such displays to slip by unchallenged by this community. And hopefully Tyler will see the unjust position he has taken and beg for forgiveness. From rantingrick at gmail.com Mon Jan 24 15:03:29 2011 From: rantingrick at gmail.com (rantingrick) Date: Mon, 24 Jan 2011 12:03:29 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <3a96fee1-995f-49f7-a967-f125cc3f1cdc@v26g2000yqf.googlegroups.com> Message-ID: On Jan 24, 1:57?pm, Robin Dunn wrote: > On Jan 23, 4:31?pm, "Martin v. Loewis" wrote: > > > > WxPython Challenge 1 code updated... > > > > ?* Fixed tab traveral > > > ?* Removed hand-holding code > > > ?* Removed some cruft > > > > ?https://sites.google.com/site/thefutureofpython/home/code-challenges > > > > Good luck! > > > Still crashes the interpreter. > > The crash on Linux is due to SetSingleStyle removing the all items and > the columns when the mode of the listctrl is changed, and then the > code continues on with the assumption that the columns still exist and > the crash happens when an item is added to column zero and there is no > column zero. ?Apparently the native widget on Windows doesn't have > that limitation. ?BTW, if the linux wx packages had the runtime > assertions turned on then you would have seen a Python exception with > some clues that would probably help solve the problem. In your face Linux users! Learn how to debug already! > BTW, on behalf of the wxPython community I'd like to apologize for the > havoc caused by the flaming troll escaping from his cage. ?In general > wxPython users are much less militant and zealotty and honor > everyone's freedom to choose which ever UI tool kit works the best for > their own needs. Well we forgive Byran, but we will not forget! :) From rantingrick at gmail.com Mon Jan 24 15:11:07 2011 From: rantingrick at gmail.com (rantingrick) Date: Mon, 24 Jan 2011 12:11:07 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> Message-ID: <66b4baf9-7714-45ae-9cac-39b06ee3f70e@k42g2000yqa.googlegroups.com> On Jan 22, 6:07?pm, rantingrick wrote: > I await any challengers... CODE UPDATE * fixed linux whiners bug https://sites.google.com/site/thefutureofpython/home/code-challenges From orasnita at gmail.com Mon Jan 24 15:14:16 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Mon, 24 Jan 2011 22:14:16 +0200 Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com>7c$4275d90a$44222222222222 <63eea$4d3cd2fd$4275d90a$14984@FUSE.NET><69465430-08b3-4069-99c7-72f4d3034c66@s5g2000yqm.googlegroups.com><705ad$4d3ce0fc$4275d90a$29144@FUSE.NET> Message-ID: <2C62A0CDCAEF4D4DA1CBC37C10149006@teddy> From: "Mark Roseman" > Octavian, thank you for very clearly making and repeating your point > about screen readers. It is very obvious that at this point in time Tk > (and hence Tkinter) is not a suitable candidate if screen readers are an > important concern. The screen readers are always an important concern if the GUI is used in a program that could be interesting for those who need a screen reader. Of course that if that program is Corel Draw or Photoshop or a video-editing application it is not important to offer accessibility for screen readers, but most of the programs are not that kind of apps. > In an ideal world, every GUI would be fully accessible. The reality is > that sometimes, competing requirements will lead to accessibility being > lower in the priority list than other things. So with different > requirements and priorities, the "best" solution will be different. Yes of course I agree with this. But if... let's say Python would promote a better GUI than Tkinter, most Python programmers would probably start to learn to use that GUI, and they would be able to use it better than other GUIS, and the competing requirements might force them to use that GUI because they will be able to code the GUI easier with it and so on. And if something doesn't work in that GUI, (segfaults for example) more and more programmers might become interested to solve those bugs in order to have a better GUI, and finally it would be much better than now, and... for more people. > I don't object and in fact commend you for advocating for accessibility. > I do feel you are not acknowledging and fully respecting that others may > be in situations where accessibility may not be the primary concern. I think that the accessibility shouldn't be a concern at all, because I think it is too much to ask for such a thing from the programmers. The applications should be accessible by default, by just using the right GUI which offer the necessary accessibility features. Well yes, if some fields are not labeled or some images don't have a text associated with them... if somebody is interested he/she could ask those features added later and it would be very simple to add them, but if the program is made with Tkinter... then nothing could be made to improve the accessibility. Let's imagine that Python doesn't offer any GUI lib and that no Python programmer knows to use a GUI lib. What would the majority of Python programmer choose if Python would start to offer support for WxPython and Tkinter and WxPython would be packaged in the default distribution? I think that the preference for Tk is because it is old and there are very many programmers that know to use it very well because these days the size of a program is not important. I have also heard that there is no enough support for WxPython in order to maintain it very well. This is a problem indeed and if it is true it can be a valid reason why WxPython is not considered, but WxPython is pretty well maintained. Aren't the WxPython developers willing to continue to maintain it if it will be added to Python distribution? Octavian From robin at alldunn.com Mon Jan 24 15:24:24 2011 From: robin at alldunn.com (Robin Dunn) Date: Mon, 24 Jan 2011 12:24:24 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <3a96fee1-995f-49f7-a967-f125cc3f1cdc@v26g2000yqf.googlegroups.com> Message-ID: On Jan 24, 12:03?pm, rantingrick wrote: > On Jan 24, 1:57?pm, Robin Dunn wrote: > > BTW, on behalf of the wxPython community I'd like to apologize for the > > havoc caused by the flaming troll escaping from his cage. ?In general > > wxPython users are much less militant and zealotty and honor > > everyone's freedom to choose which ever UI tool kit works the best for > > their own needs. > > Well we forgive Byran, but we will not forget! :) For the record, that is not who I was referring to. --Robin From rantingrick at gmail.com Mon Jan 24 15:33:32 2011 From: rantingrick at gmail.com (rantingrick) Date: Mon, 24 Jan 2011 12:33:32 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <100e192f-9a6c-4c3a-8092-a65cd04eef64@o14g2000yqe.googlegroups.com> <668d4047-58a8-4208-8bd0-92a7c7344d2f@o9g2000pre.googlegroups.com> Message-ID: <7228de23-5fb8-42bf-9916-b579d61583f9@f9g2000vbq.googlegroups.com> On Jan 24, 1:23?pm, Bryan wrote: > Ok, great. You've identified one programmer who thinks about > internationalization. Not much of a compelling argument there. Oh Bryan your view so simplistic. There is a whole world out there you know. > However, I think you missed my point. My point wasn't that people like > Guido don't think of these topics. It's that the people in the > trenches who use these tools don't think about these topics. How many > of your co-workers actively think about internationalization and > accessibility? No, you've missed the point AGAIN! It doesn't matter what the developers "think" about accessibility. It matters what they "DO" about it. Most people in YOUR organization don't consider accessibility because accessibility does not concern them . Just like people who dump toxic chemicals into your drinking water don't concern themselves when you get cancer. They don't care because they are unaffected. SELFISHNESS is the key word here! These people have 20/20 vision, perfect hearing, and all their extremities still attached. Sadly however they lack a brain that can comprehend even the most basic form of compassion for those who don't have these luxuries! If ANY of these selfish idiots was in a car accident and lost an arm and both eyes, i'd bet a million dollars that the next time they sit down to use a computer they will realize just how important accessibility is. I would bet that accessibility would become a major buzz word around your office then! > I'm guessing none, but maybe you're lucking and work in > a particularly enlightened team. I've perhaps worked closely with a > few hundred programmers in my career, and very few of them thought of > these subjects. In my experience it's just not something the > programmer in the trenches thinks about. That is the point I was > trying to make. Yes and you made your selfishness quite clear! Be careful my friend, because as Tyler found out, this mindset becomes a slippery slope *very* quickly! From orasnita at gmail.com Mon Jan 24 15:33:34 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Mon, 24 Jan 2011 22:33:34 +0200 Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> 7c$4275d90a$44222222222222<63eea$4d3cd2fd$4275d90a$14984@FUSE.NET> <69465430-08b3-4069-99c7-72f4d3034c66@s5g2000yqm.googlegroups.com> <705ad$4d3ce0fc$4275d90a$29144@FUSE.NET> <4D3DC313.8040905@tysdomain.com> Message-ID: From: "Littlefield, Tyler" > Hello, > > I have been on another list with Octavian, and he takes his > accessibility a bit to seriously. If things went his way, he wants laws > where -everything- has to be accessible, and it is illegal not to do so. Is the discrimination legal in your country? If you create a program only for a part of the population knowing very well that you do that, without having technical issues, (because as you know, there are very well known technical solutions for it), it means that you discriminate a part of the population. Of course, as I explained, if you want to create a drawing program or a video-editing application, there are technical issues that don't allow you to offer that program to everyone, so it is not your fault at all in that case. > As a sidenote, I would like to preface everything I'm going to say by > mentioning the fact that I have been using a screen reader for many > years, so I understand some of where he is coming from. > > I think my goal, (and I differ from Octavian here), is to try to find > fixes for things, rather than saying "this sucks, it does not work with > a reader, and thus it shouldn't be used). Having done a lot of > development work in the past, I can't say "hey you, I want you to make > this app accessible, and because you used TKInter it's not, so use > something else, but nothing that isn't accessible." Rather, I believe > those pushing accessibility should concentrate on the root cause; that > of fixing TKInter, and not forcing everyone else to use a different library. This is like saying that those who need a screen reader should better find a solution for their health problems and after they will find it, they won't need a screen reader. >From the accessibility perspective there are already accessible interfaces so that's solved and it just need to be used. Making Tkinter would be great, but it would not be a solution if it won't be used after it will be accessible. If Tk would be made accessible but Python would start including a QT GUI or another one that wouldn't be accessible and the programmers would start using that GUI, the result is that the apps won't be accessible. If there is a solution now for this problem, and not in a bad GUI lib that doesn't many features, but one which is very fast and full of widgets, then that solution should be promoted by Python. I don't say (as you pretend) that all the programmers should be forced to use it or at least to prefer it. I said that it should be promoted because it is the right tool. I think that the political corectness term was invented in USA... > I believe that the approach is the main key here, and I have had this > argument many times. If I wrote an app, and someone said something along > the lines of "you need to change a core library because it doesn't work > with this program," my first response would be who the hell are you to > say what I need to use? We need to take the approach of "This is what is > wrong, this is why, this is possibly how it could be fixed. Would you be > willing to do so?" With other words, you are very happy when you can't use a program because it is not accessible, thinking that as a programmer you won't be forced by someone else or laws to learn to use the right tool. Or you may be willing to change all the programs in the world which are not accessible because they use a bad GUI. > So, with all of this said, TKInter -is- unaccesssible for us. My > arguments have not been for or against one or the other in this thread, > but more to get RR to make a better point. Because eventually, WX would > benafit those using a screen reader a lot more than say, TKInter will. > That doesn't mean that I'm saying that we need to make it a part of the > stdlib as of yesterday, because segfaults from someone with 10+ years of > experience (multiple people, actually) says a lot, whether or not RR > wants to acknowledge said facts. Those segfaults would disappear much faster if WxPython would become more interesting and if it would become a part of Python distribution because there would be much more programmers interested about it and willing to solve its problems under some platforms. WxPython has some problems under some platforms used by a minority of users. Tkinter has some problems for another minority of users. The big picture is the worst thing possible and it is not that I can't see it, but I can't agree with it. The big picture is that very many people simply don't care and this is not something good. Octavian From joncle at googlemail.com Mon Jan 24 15:41:46 2011 From: joncle at googlemail.com (Jon Clements) Date: Mon, 24 Jan 2011 12:41:46 -0800 (PST) Subject: how to tell if cursor is sqlite.Cursor or psycopg2.Cursor References: <7f1931cd-a15b-44a9-8cf9-b0af0bdfec7d@d8g2000yqf.googlegroups.com> Message-ID: <7edfe2ce-5d8f-43b3-9eea-b8121012d309@v17g2000prc.googlegroups.com> On Jan 24, 7:44?pm, dmaziuk wrote: > Hi everyone, > > I've wrapper class around some sql statements and I'm trying to add a > method that does: > ? if my_cursor is a sqlite cursor, then run "select > last_insert_rowid()" > ? else if it's a psycopg2 cursor, then run "select > currval( 'my_sequence' )" > ? etc. > The best I can come up with is import both psycopg2 and sqlite and > then do > ?if isinstance( self._curs, sqlite.Cursor ) : ... > ?elif isinstance( self._curs, psycopg2._psycopg.cursor ) : ... > and I can't help thinking there has to be another way to find out what > kind of thing self._curs is. Is there a better way? > > TIA > Dima I'm not 100% sure but maybe look at SQLAlchemy (or other Python ORMs) as a wrapper. That *might* abstract the "last ID" across different DB's. And still enable direct SQL querying. Jon. From orasnita at gmail.com Mon Jan 24 15:45:13 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Mon, 24 Jan 2011 22:45:13 +0200 Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com>7c$4275d90a$44222222222222 <63eea$4d3cd2fd$4275d90a$14984@FUSE.NET><69465430-08b3-4069-99c7-72f4d3034c66@s5g2000yqm.googlegroups.com><705ad$4d3ce0fc$4275d90a$29144@FUSE.NET> <5f8c1256-f07c-43be-8307-d36991e9be24@m35g2000vbn.googlegroups.com> Message-ID: From: "rantingrick" > Obviously it > would be awesome, but I think Octavian is just focusing on himself, and > not the actual big picture here. Yes Octavian is the only disabled person in the world. What a selfish, selfish person he is. Shame on you Octavian, Shame on You! You just showed your true colors Tyler, very sad. :( I understand Tyler because I know some blind people. It is very frustrating to be able to think better than many other sighted people and to be able to do very many complex things, but to not be able to do very basic things while they can do them very easy. Because of this, many blind people try to show that they are like the sighted, that they can do everything, that they are independent, so they like to talk about the movies they watch, they like to have touch-pad mobile phones and so on, even though the accessibility of those gadgets is really low. I don't speak from the perspective of a programmer because a programmer, even a blind one, can create the program he wants, to be accessible of course, but I speak from the perspective of the users because they are not programmers, they can't do anything to improve the accessibility of the programs that other people can use very easy. And what's worst is that most of those inaccessible programs are not that way because the programmer that created them consciously chosen the GUI lib because of who know what specific reasons, competitive or of other kind. Most of the time the programmer uses the GUI lib that she/he knows better and think that would be easier to create the program with. Most of them don't even know about accessibility, there are very many programmers in some countries that don't even imagine that some people can use a computer with a screen reader. Octavian From python at mrabarnett.plus.com Mon Jan 24 15:46:09 2011 From: python at mrabarnett.plus.com (MRAB) Date: Mon, 24 Jan 2011 20:46:09 +0000 Subject: how to tell if cursor is sqlite.Cursor or psycopg2.Cursor In-Reply-To: <7f1931cd-a15b-44a9-8cf9-b0af0bdfec7d@d8g2000yqf.googlegroups.com> References: <7f1931cd-a15b-44a9-8cf9-b0af0bdfec7d@d8g2000yqf.googlegroups.com> Message-ID: <4D3DE511.7010206@mrabarnett.plus.com> On 24/01/2011 19:44, dmaziuk wrote: > Hi everyone, > > I've wrapper class around some sql statements and I'm trying to add a > method that does: > if my_cursor is a sqlite cursor, then run "select > last_insert_rowid()" > else if it's a psycopg2 cursor, then run "select > currval( 'my_sequence' )" > etc. > The best I can come up with is import both psycopg2 and sqlite and > then do > if isinstance( self._curs, sqlite.Cursor ) : ... > elif isinstance( self._curs, psycopg2._psycopg.cursor ) : ... > and I can't help thinking there has to be another way to find out what > kind of thing self._curs is. Is there a better way? > I quick hack might be to look at repr(my_cursor). For sqlite3 I get: '' From bryan.oakley at gmail.com Mon Jan 24 15:49:08 2011 From: bryan.oakley at gmail.com (Bryan) Date: Mon, 24 Jan 2011 12:49:08 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <100e192f-9a6c-4c3a-8092-a65cd04eef64@o14g2000yqe.googlegroups.com> <668d4047-58a8-4208-8bd0-92a7c7344d2f@o9g2000pre.googlegroups.com> <7228de23-5fb8-42bf-9916-b579d61583f9@f9g2000vbq.googlegroups.com> Message-ID: On Jan 24, 2:33?pm, rantingrick wrote: > > Yes and you made your selfishness quite clear! Be careful my friend, > because as Tyler found out, this mindset becomes a slippery slope > *very* quickly! I merely made the observation that most programmers don't think about these topics and it would be good to get some more enlightenment, you now you're accusing me of selfishness? That's an impressive mental leap, though I don't think you quite made it to the other side. Did you perhaps interpret my comment as "programmers SHOULDN'T think about..."? I'm not saying programmers shouldn't think about these things. On the contrary, all programmers _should_ think about them. They don't, at least in my experience. That's a problem, it needs to be fixed. If you think that's a mindset that's on a slippery slope, you're the only one. From orasnita at gmail.com Mon Jan 24 15:49:20 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Mon, 24 Jan 2011 22:49:20 +0200 Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com><63eea$4d3cd2fd$4275d90a$14984@FUSE.NET><69465430-08b3-4069-99c7-72f4d3034c66@s5g2000yqm.googlegroups.com><705ad$4d3ce0fc$4275d90a$29144@FUSE.NET> Message-ID: From: "Mark Roseman" > "Littlefield, Tyler" wrote: >> Rather, I believe >> those pushing accessibility should concentrate on the root cause; that >> of fixing TKInter, and not forcing everyone else to use a different library. > > > Here, here. From my queries to some of the Tcl/Tk folks, it seems that > while the knowledge and expertise is not present in the core developer > community, they would be more than happy to help people who do have some > knowledge in this area so that Tk could be made to be more accessible. > > Grand conspiracies aside, I think the development communities behind > most GUI toolkits would be very receptive to people who could help make > developing accessible applications with their toolkits feasible. > > (And if/when this does get done for Tk, I promise at least to make sure > that the tutorial at http:///www.tkdocs.com covers this topic). > > Mark It would be great if the Tk/Tkinter developers would be interested in making this GUI lib accessible. There are no many people that know about this thing, but there are standards like MSAA that can be followed by them if they really want to offer accessibility. I guess that if Tkinter would support MSAA (Microsoft Active Accessibility) in its Windows version, the screen readers would be able to offer support for Tk (or it might be offered by default... I don't know). Octavian From orasnita at gmail.com Mon Jan 24 15:53:57 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Mon, 24 Jan 2011 22:53:57 +0200 Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com><100e192f-9a6c-4c3a-8092-a65cd04eef64@o14g2000yqe.googlegroups.com> Message-ID: <42F739DFCE5E4A5F9C953F816A0C55FE@teddy> From: "Bryan" I wish I could respond to that, but I have no experience with screen readers. Are there any free ones, or ones with free trials, that I could try out? I'm not yet convinced it's any better or worse than wxPython since you're only a single datapoint, but of course it's possible. If you know of any free tools I can use to experiment, I'd appreciate you posting them in this newsgroup. Accessibility, like internationalization, is something few programmers spend much time thinking about. I can only imagine the frustration one must experience if all interactions had to be through a screen reader. Hi Bryan, (And thank you for your interest) The most used screen reader and the one that have the most features is JAWS that can be downloaded from: http://www.freedomscientific.com/downloads/jaws/jaws-downloads.asp You can use it for 40 minutes after which you need to restart the computer to be able to use it again. You can test that simple sample WxPython app and compare it with any Tk-based app. Please tell us what you find. Octavian From orasnita at gmail.com Mon Jan 24 15:58:31 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Mon, 24 Jan 2011 22:58:31 +0200 Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <100e192f-9a6c-4c3a-8092-a65cd04eef64@o14g2000yqe.googlegroups.com> <668d4047-58a8-4208-8bd0-92a7c7344d2f@o9g2000pre.googlegroups.com> <4D3DD223.4080602@mrabarnett.plus.com> Message-ID: <8D90F9A9A31F428E855A6787FDFDFC0C@teddy> From: "MRAB" > On 24/01/2011 18:05, rantingrick wrote: >> On Jan 24, 12:00 pm, Bryan wrote: >> >>> Accessibility, like internationalization, is something few programmers >>> spend much time thinking about. >> >> Thats another uninformed statement by you we can add to the mountains >> of useless cruft you have offered so far. Unicode IS >> internationalization and Guido thought it was SO important that >> Python3000 auto converts all strings to Unicode strings. Obviously he >> is moving us toward full Unicode only in the future (AS SHOULD ALL >> IMPLEMENTATIONS!). We need one and only one obvious way to do it. And >> Unicode is that way. >> > There's more to internationalization than just Unicode. There's the > ability to handle messages in various languages which have a different > syntax and grammar. > > There's an interesting Perl-oriented article on it here: > > http://search.cpan.org/dist/Locale-Maketext/lib/Locale/Maketext/TPJ13.pod#A_Localization_Horror_Story:_It_Could_Happen_To_You > -- Perl offers a great support for I18n/L10N including its native support for UTF-8, and I am glad that Python 3 will also have improvements for it. Just like the I18N, it would be a good idea if Python will also start to promote the accessibility, because just like the internationalization, it is targetted to make the programs accessible by as many users as possible. Octavian From orasnita at gmail.com Mon Jan 24 16:09:40 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Mon, 24 Jan 2011 23:09:40 +0200 Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com>7c$4275d90a$44222222222222 <63eea$4d3cd2fd$4275d90a$14984@FUSE.NET><69465430-08b3-4069-99c7-72f4d3034c66@s5g2000yqm.googlegroups.com><705ad$4d3ce0fc$4275d90a$29144@FUSE.NET><5f8c1256-f07c-43be-8307-d36991e9be24@m35g2000vbn.googlegroups.com> Message-ID: <4F28A96E8FD64E3CB793D5FFEEC748D5@teddy> From: "rantingrick" Tyler's argument, which lacked greatly in compassion for people with disabilities brought out my accusation. It was not an accusation meant to merely insult just to invoke a flame war; which is the definition of Godwins Law. It is a fact that Tyler displayed despicable intolerance for people who have disabilities and such a correlation to totalitarian regimes was not only the correct response but in fact the only response to such veiled hate speech. We cannot allow such displays to slip by unchallenged by this community. And hopefully Tyler will see the unjust position he has taken and beg for forgiveness. Tyler is not intolerant. He is a blind person. He is one that cares more to please the others that might help it more in its life than to advocate for the benefit of the entire world. Octavian From james at funkymonkeysoftware.com Mon Jan 24 16:15:23 2011 From: james at funkymonkeysoftware.com (James Ravenscroft) Date: Mon, 24 Jan 2011 21:15:23 +0000 Subject: List behaviours with Clustering Algorithm In-Reply-To: References: Message-ID: <4D3DEBEB.1020700@funkymonkeysoftware.com> Peter > > I can't run your code because you didn't make it standalone, Thanks for the heads up, I've made a simple version of the clusterer which you can view on pastebin: http://pastebin.com/7HmAkmfj If you have time to look through my code I would be very grateful! > > but in your case that is probably not enough. > > Try something along these lines: > > > > # untested > > while len(self.clusters) > 1: > > c = self.clusters.pop() > > # find closest index > > for i, c2 in enumerate(self.clusters): > > ... > > if ...: > > closest_index = i > > closest = self.clusters.pop(closest_index) > > tmp.append(c + closest) > > if self.clusters: > > tmp.append(self.clusters[0]) I had a go at implementing something along the lines above and I'm still getting very bizarre results. There does appear to be some sort of logic to it though, if you look at the graph chart, you can see that It seems to be doing the clustering right and then forgetting to remove the old groupings providing this "cloning" effect for some cluster groups. Chart: http://img826.imageshack.us/i/clusters.png/ Thanks, James -- James Ravenscroft Funky Monkey Software - Bespoke Web and Software Solutions http://www.funkymonkeysoftware.com/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From rantingrick at gmail.com Mon Jan 24 16:17:36 2011 From: rantingrick at gmail.com (rantingrick) Date: Mon, 24 Jan 2011 13:17:36 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <100e192f-9a6c-4c3a-8092-a65cd04eef64@o14g2000yqe.googlegroups.com> <668d4047-58a8-4208-8bd0-92a7c7344d2f@o9g2000pre.googlegroups.com> <7228de23-5fb8-42bf-9916-b579d61583f9@f9g2000vbq.googlegroups.com> Message-ID: On Jan 24, 2:49?pm, Bryan wrote: > On Jan 24, 2:33?pm, rantingrick wrote: > > > Yes and you made your selfishness quite clear! Be careful my friend, > > because as Tyler found out, this mindset becomes a slippery slope > > *very* quickly! > > I merely made the observation that most programmers don't think about > these topics and it would be good to get some more enlightenment, you > now you're accusing me of selfishness? If you are not part of the solution then you are part of the problem. I think you *do* want to help proliferate accessibility. However, you have not displayed the attitude that we need to win the fight. You see, selfishness is a natural human trait. We all harbor selfishness to some degree. Even myself! We cannot fully ever be free of this selfishness. However we can fight and suppress selfishness until it's ill effects have no "noticeable" effect. This is what i am speaking of when i say that you are part of the problem. You need to educate your co-workers about accessibility. You need to make them aware of their own selfish and erroneous ways. Then and only then shall *you* be part of the solution. But don't expect that they will just roll over! This will be an uphill battle so we must be persistent! They need to choose libraries that are supporting accessibility. Or at least choose a library that is *aware* of accessibility and is moving forward into full blown support of accessibility. A comment was made earlier by Mark Roseman about how he would document accessibly in Tkinter *if* someone else would bring Tk accessibility into being. This is just one more example of someone paying lip service to a problem without actually suppressing his selfishness and producing some action. Mark needs to sound the battle call at his site. He needs to send an email to the TclTk-dev team daily and ask how they are coming along with accessibility. Then he needs to post the response -- or lack there of-- on his site for all to see. He needs to change his attitude from passive to aggressive. Then and only then shall change come. Change happens only when people demand change. And sadly the power to change accessibility lies not in the hands of those directly affected but in the hands of those twice removed from the torments of accessibility. This is the same problem all GUI developers face with the multiplicity of GUI libraries. If we could get these selfish and moronic OS developers to agree on one GUI standard then our lives, and the lives of our users would be bliss. Then we could have universal accessibility, universal rich widget sets, universal cross platform- ability, universal speed, universal look and feel, etc, etc. From ethan at stoneleaf.us Mon Jan 24 16:23:51 2011 From: ethan at stoneleaf.us (Ethan Furman) Date: Mon, 24 Jan 2011 13:23:51 -0800 Subject: WxPython versus Tkinter. In-Reply-To: References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <033c3f90-03fb-4f65-bbae-bbc80a262685@l22g2000vbp.googlegroups.com> Message-ID: <4D3DEDE7.5020302@stoneleaf.us> On Sun, 23 Jan 2011 12:23:13 -0800, rantingrick wrote: > I am not > trying to create a working file browser so you can steal my code. 2011/1/24 rantingrick : > This thread has been an eye opener for myself [...] > we cannot even work together to get some simple code > debugged. Aha! So you want to steal our code to fix yours? Why am I not surprised? ~Ethan~ From nhodgson at bigpond.net.au Mon Jan 24 16:47:36 2011 From: nhodgson at bigpond.net.au (Neil Hodgson) Date: Tue, 25 Jan 2011 08:47:36 +1100 Subject: WxPython versus Tkinter. In-Reply-To: References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com><63eea$4d3cd2fd$4275d90a$14984@FUSE.NET><69465430-08b3-4069-99c7-72f4d3034c66@s5g2000yqm.googlegroups.com><705ad$4d3ce0fc$4275d90a$29144@FUSE.NET> Message-ID: <2sm%o.8695$gM3.6118@viwinnwfe01.internal.bigpond.com> Octavian Rasnita: > There are no many people that know about this thing, > but there are standards like MSAA that can be followed > by them if they really want to offer accessibility. I > guess that if Tkinter would support MSAA (Microsoft > Active Accessibility) in its Windows version, the screen > readers would be able to offer support for Tk (or it > might be offered by default... I don't know). MSAA was superseded by Microsoft UI Automation in 2005 which in turn was superseded by Windows Automation API in Windows 7. http://msdn.microsoft.com/en-us/library/dd561932(v=vs.85).aspx Making Tk as accessible as Windows or GTK+ would be a huge job. Neil From alan.isaac at gmail.com Mon Jan 24 16:51:20 2011 From: alan.isaac at gmail.com (Alan) Date: Mon, 24 Jan 2011 13:51:20 -0800 (PST) Subject: why are functions greater than numbers? Message-ID: <2773df41-2a43-46bc-b2bd-7cbdd91aff55@u18g2000prh.googlegroups.com> Why do function objects compare in this way to numbers? Thanks, Alan Isaac >>> def f(): return ... >>> f>5 True From tyler at tysdomain.com Mon Jan 24 16:53:50 2011 From: tyler at tysdomain.com (Littlefield, Tyler) Date: Mon, 24 Jan 2011 14:53:50 -0700 Subject: WxPython versus Tkinter. In-Reply-To: <4D3DD443.5070906@mrabarnett.plus.com> References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> 7c$4275d90a$44222222222222 <63eea$4d3cd2fd$4275d90a$14984@FUSE.NET> <69465430-08b3-4069-99c7-72f4d3034c66@s5g2000yqm.googlegroups.com> <705ad$4d3ce0fc$4275d90a$29144@FUSE.NET> <5f8c1256-f07c-43be-8307-d36991e9be24@m35g2000vbn.googlegroups.com> <4D3DD443.5070906@mrabarnett.plus.com> Message-ID: <4D3DF4EE.2020900@tysdomain.com> RR, you idiot. Did you -not- read that I was blind and using a screen reader? And wasn't it -you- yelling at someone about reading and comprehention? On 1/24/2011 12:34 PM, MRAB wrote: > On 24/01/2011 18:48, rantingrick wrote: >> On Jan 24, 12:21 pm, "Littlefield, Tyler" wrote: >> >> [...snip: good discussion...] >> >>> Rather, I believe >>> those pushing accessibility should concentrate on the root cause; that >>> of fixing TKInter, and not forcing everyone else to use a different >>> library. >> >> Now you go too far! >> >> And this is an ironic position from someone who supports the stdlib >> GUI that IS forced on us by default. Sure you can choose a different >> library, but in the case of a user (and accessibility is a big USER >> concern when that user is handicapped!) the library is already chosen >> (Tkinter:which does not support accessibility) by the developer . I >> can also argue that Tkinter's inclusion in the stdlib is proliferating >> non-compliance with accessibility. I'll bet you would not park in a >> handicap spot however you support a GUI library that ignores handicap >> people? IRONIC! >> >>> I believe that the approach is the main key here, and I have had this >>> argument many times. If I wrote an app, and someone said something >>> along >>> the lines of "you need to change a core library because it doesn't work >>> with this program," my first response would be who the hell are you to >>> say what I need to use? >> >> Well these people you are chastising are disabled people. Who the hell >> are YOU to be high and mighty about it? I guess these "disabled" >> people get what they deserve huh! Maybe we should just do the world a >> favor and exterminate them like the Nazis? That way we don't have to >> cater to their selfish needs! >> > [snip] > I'd like to invoke Godwin's law at this point. -- Thanks, Ty From rantingrick at gmail.com Mon Jan 24 16:54:59 2011 From: rantingrick at gmail.com (rantingrick) Date: Mon, 24 Jan 2011 13:54:59 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com><63eea$4d3cd2fd$4275d90a$14984@FUSE.NET><69465430-08b3-4069-99c7-72f4d3034c66@s5g2000yqm.googlegroups.com><705ad$4d3ce0fc$4275d90a$29144@FUSE.NET> <2sm%o.8695$gM3.6118@viwinnwfe01.internal.bigpond.com> Message-ID: <0c3c61b0-d056-4757-b7e4-fecdf9a6e217@fm22g2000vbb.googlegroups.com> On Jan 24, 3:47?pm, Neil Hodgson wrote: > ? ?Making Tk as accessible as Windows or GTK+ would be a huge job. Not if we used the underlying MS library! Windows has such a rich library why not use it? Why must we constantly re-invent the wheel? Windowing GUIs are not recent technology. These things have been around for decades. When are we going to agree on a damn standard. Is it not far passed time to drop the selfishness and work together? I said it before... "Multiplicity is very important in emerging systems however at some point we must reign in the madness else entropy will destroy the entire system." Selfishness = Multiplicity = Entropy = Shock = Stagnation = None From andrea.gavana at gmail.com Mon Jan 24 16:58:36 2011 From: andrea.gavana at gmail.com (Infinity77) Date: Mon, 24 Jan 2011 13:58:36 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <3a96fee1-995f-49f7-a967-f125cc3f1cdc@v26g2000yqf.googlegroups.com> Message-ID: <023e19ed-69d1-4155-a114-0d00c227b8f6@u18g2000prh.googlegroups.com> On Jan 24, 9:57?pm, Robin Dunn wrote: > On Jan 23, 4:31?pm, "Martin v. Loewis" wrote: > > > > WxPython Challenge 1 code updated... > > > > ?* Fixed tab traveral > > > ?* Removed hand-holding code > > > ?* Removed some cruft > > > > ?https://sites.google.com/site/thefutureofpython/home/code-challenges > > > > Good luck! > > > Still crashes the interpreter. > > The crash on Linux is due to SetSingleStyle removing the all items and > the columns when the mode of the listctrl is changed, and then the > code continues on with the assumption that the columns still exist and > the crash happens when an item is added to column zero and there is no > column zero. ?Apparently the native widget on Windows doesn't have > that limitation. ?BTW, if the linux wx packages had the runtime > assertions turned on then you would have seen a Python exception with > some clues that would probably help solve the problem. I don't know > about others but on Ubuntu you can install the *wx*-dbg packages to > get a version with the assertions turned on. ?Hopefully that will > change starting with 2.9 as wx now turns on the assertions by default > for builds configured normally, and the wx-dev team recommends that > the assertions are not turned off, except in rare circumstances. > > BTW, on behalf of the wxPython community I'd like to apologize for the > havoc caused by the flaming troll escaping from his cage. ?In general > wxPython users are much less militant and zealotty and honor > everyone's freedom to choose which ever UI tool kit works the best for > their own needs. I have been involved in the wxPython development for many years (mostly on implementation of custom widgets, in the AGW library), and I share Robin's concerns about this kind of "publicity" given to wxPython. Python comes with TK as a "battery included" UI toolkit. I'm perfectly fine with this, as I am not going to use it anyway. Whether in the future TK will be replaced by PyGTK, PyQT, PySide, etc... in the standard library, it won't make any difference to those aficionados developers who use wxPython. We'll still download the wxPython binaries/sources/whatever and use it to develop our own GUIs. There is simply no match between wxPython and X (substitute X with whatever GUI toolkit you like). This is obviously my very biased opinion. It is very unfortunate that this topic "wxPython vs. Tkinter" has drifted to another flame war, as there is really no point in this kind of discussion. As a general rule, a GUI-newbie should try all the GUI toolkits out there and settle with the one which looks easier/nicer/ more convenient/more feature rich. As usual, it is a matter of personal taste. For those experiencing with wxPython for the first time, I highly suggest you to join our wxPython mailing list: you'll find a friendly place, with many experienced developers answering questions and a BDFL who's there (almost) every day offering solutions for the toughest problems. Andrea. From tyler at tysdomain.com Mon Jan 24 17:02:43 2011 From: tyler at tysdomain.com (Littlefield, Tyler) Date: Mon, 24 Jan 2011 15:02:43 -0700 Subject: WxPython versus Tkinter. In-Reply-To: References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com><63eea$4d3cd2fd$4275d90a$14984@FUSE.NET><69465430-08b3-4069-99c7-72f4d3034c66@s5g2000yqm.googlegroups.com><705ad$4d3ce0fc$4275d90a$29144@FUSE.NET> Message-ID: <4D3DF703.7080506@tysdomain.com> >It would be great if the Tk/Tkinter developers would be interested in making >this GUI lib accessible. They're not going to do it without knowing what makes accessible accessible, and why it needs to be so. So, rather than tell the world about how -some- blind people want to be like sighted people (we call that independence in my world), why not go help out? It's bad, you want a switch, and you've already said that they're using a lib that is unaccessible. So fix the lib, and you will have fixed tons of programs without fixing the program. That is all I ment by finding the root of the problem, not "everyone with readers should fix their health problems." You take my words, blow them out of perportion and at the end of the day, you are still sitting here complaining about the lack of accessibility, rather than doing something about it. This is awesome. We for sure need more complainers and less people to do what the complainers are complaining about! On 1/24/2011 1:49 PM, Octavian Rasnita wrote: > From: "Mark Roseman" >> "Littlefield, Tyler" wrote: >>> Rather, I believe >>> those pushing accessibility should concentrate on the root cause; that >>> of fixing TKInter, and not forcing everyone else to use a different library. >> >> Here, here. From my queries to some of the Tcl/Tk folks, it seems that >> while the knowledge and expertise is not present in the core developer >> community, they would be more than happy to help people who do have some >> knowledge in this area so that Tk could be made to be more accessible. >> >> Grand conspiracies aside, I think the development communities behind >> most GUI toolkits would be very receptive to people who could help make >> developing accessible applications with their toolkits feasible. >> >> (And if/when this does get done for Tk, I promise at least to make sure >> that the tutorial at http:///www.tkdocs.com covers this topic). >> >> Mark > > It would be great if the Tk/Tkinter developers would be interested in making this GUI lib accessible. > There are no many people that know about this thing, but there are standards like MSAA that can be followed by them if they really want to offer accessibility. > I guess that if Tkinter would support MSAA (Microsoft Active Accessibility) in its Windows version, the screen readers would be able to offer support for Tk (or it might be offered by default... I don't know). > > Octavian > -- Thanks, Ty From nhodgson at bigpond.net.au Mon Jan 24 17:08:10 2011 From: nhodgson at bigpond.net.au (Neil Hodgson) Date: Tue, 25 Jan 2011 09:08:10 +1100 Subject: WxPython versus Tkinter. In-Reply-To: <0c3c61b0-d056-4757-b7e4-fecdf9a6e217@fm22g2000vbb.googlegroups.com> References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com><63eea$4d3cd2fd$4275d90a$14984@FUSE.NET><69465430-08b3-4069-99c7-72f4d3034c66@s5g2000yqm.googlegroups.com><705ad$4d3ce0fc$4275d90a$29144@FUSE.NET> <2sm%o.8695$gM3.6118@viwinnwfe01.internal.bigpond.com> <0c3c61b0-d056-4757-b7e4-fecdf9a6e217@fm22g2000vbb.googlegroups.com> Message-ID: rantingrick: > Not if we used the underlying MS library! Windows has such a rich > library why not use it? Why must we constantly re-invent the wheel? It is up to the GUI toolkit or application to implement the interfaces defined by Windows Automation API on every object it displays. The standard Windows controls have this implemented. Tk does not use these controls so would have to do all that work again. Neil From rantingrick at gmail.com Mon Jan 24 17:16:53 2011 From: rantingrick at gmail.com (rantingrick) Date: Mon, 24 Jan 2011 14:16:53 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <3a96fee1-995f-49f7-a967-f125cc3f1cdc@v26g2000yqf.googlegroups.com> <023e19ed-69d1-4155-a114-0d00c227b8f6@u18g2000prh.googlegroups.com> Message-ID: <06dd3a10-03a4-4d43-a10e-cadf5105a7c4@t23g2000vby.googlegroups.com> On Jan 24, 3:58?pm, Infinity77 wrote: > I have been involved in the wxPython development for many years > (mostly on implementation of custom widgets, in the AGW library), and > I share Robin's concerns about this kind of "publicity" given to > wxPython. Who cares what you think about wxPython's publicity. A module was created and put on public display and can be ridiculed or supported by anyone who so desires. > Python comes with TK as a "battery included" UI toolkit. I'm perfectly > fine with this, as I am not going to use it anyway. Whether in the > future TK will be replaced by PyGTK, PyQT, PySide, etc... in the > standard library, it won't make any difference to those aficionados > developers who use wxPython. We'll still download the wxPython > binaries/sources/whatever and use it to develop our own GUIs. Good, and again i cannot stress how little we care about your opinion. Why do we not care. Well because you are looking at this from a wxPython perspective. You are being selfish. We are considering this from a global Python perspective. What is good for Python may not be good for you, in any event, it is for us to decide. You can join our discussion when your perspective changes from "me" to "us". And the "us" is the Python langauge NOT wxPython. > It is very unfortunate that this topic "wxPython vs. Tkinter" has > drifted to another flame war, There is no flame war here > as there is really no point in this kind > of discussion. Says you. but who are you to say what is important to us. Go back to wxPython. > As a general rule, a GUI-newbie should try all the GUI > toolkits out there and settle with the one which looks easier/nicer/ > more convenient/more feature rich. As usual, it is a matter of > personal taste. And i agree. I think any sane person could agree also. However you miss the point of this conversation. We are looking at Python from a global perspective. You are limited in your views, and obviously very biased. And i know the real reason you and Robin do not want wxPython in the stdlib. Because you do not want to lose your selfish status within the wxPython community. When wxPython becomes a stdlib module then you will answer directly to Guido and Python-dev. You are not fooling anyone with this grandstanding. Selfishness = Multiplicity = Entropy = Shock = Stagnation = None From tyler at tysdomain.com Mon Jan 24 17:19:03 2011 From: tyler at tysdomain.com (Littlefield, Tyler) Date: Mon, 24 Jan 2011 15:19:03 -0700 Subject: WxPython versus Tkinter. In-Reply-To: References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com>7c$4275d90a$44222222222222 <63eea$4d3cd2fd$4275d90a$14984@FUSE.NET><69465430-08b3-4069-99c7-72f4d3034c66@s5g2000yqm.googlegroups.com><705ad$4d3ce0fc$4275d90a$29144@FUSE.NET> <5f8c1256-f07c-43be-8307-d36991e9be24@m35g2000vbn.googlegroups.com> Message-ID: <4D3DFAD7.40902@tysdomain.com> >Because of this, many blind people try to show that they are like the sighted, that they can do everything, that they are >independent, so they like to >talk about the movies they watch, they like to have touch-pad mobile phones and so on, even though the accessibility of >those gadgets is really low. While I am getting off topic here, I just had to comment... Yes, I do talk about "watching" tv. Not having working eyeballs doesn't limit me from using a word that people with common sense can just equate to listening to tv. And neither does not having working eyeballs limit me from -listening- to tv, which is what I and other blind people that want to "watch" tv do. And guess what? I can use a phone with a touch screen. It's called an IPhone, and it's got a screen reader built in. Nifty, huh? It just helps me in my goal to be just like sighted people, blame Apple for making a touch screen accessible. I say this all because I want to make a point. I don't expect the world to revolve around what is and isn't accessible. While laws do exist, if I ran around quoting the ADA (Americans with Disabilities Act) at everyone who didn't make things accessible (whether on the computer, at school, at a store), I'd just be wasting time. Rather I like to blend in, be independant and adapt things. Now, since i am a programmer this means that I am able to do a lot more in the form of adaptation on the computer, and this is my goal; if something is broke, fix the root or work with the developer. Don't just whine about it not being accessible. It will get you nowhere, and it's people like Octavian I dread having had people meat before because by golly, -everything- better be accessible. So, call me a Nazi or whatever, that's just how I feel. The world doesn't come on a silver platter, and so if Octavian, or I, or anyone else wants any sort of changes done (as in the changes to TkInter), work needs to go into helping these changes come about. Making a library part of the STDLib and then worrying about the fact that it segfaults later is foolish, especially if you are going to do it just for accessibility. And regardless of whether RR gets his deepest wish and it is made part of the STDLib, people will still use TKInter. What then, for those with readers? Should we just abolish TKInter altogether? On 1/24/2011 1:45 PM, Octavian Rasnita wrote: > From: "rantingrick" >> Obviously it >> would be awesome, but I think Octavian is just focusing on himself, and >> not the actual big picture here. > Yes Octavian is the only disabled person in the world. What > a selfish, selfish person he is. Shame on you Octavian, Shame on You! > > > You just showed your true colors Tyler, very sad. :( > > > I understand Tyler because I know some blind people. > It is very frustrating to be able to think better than many other sighted people and to be able to do very many complex things, but to not be able to do very basic things while they can do them very easy. > Because of this, many blind people try to show that they are like the sighted, that they can do everything, that they are independent, so they like to talk about the movies they watch, they like to have touch-pad mobile phones and so on, even though the accessibility of those gadgets is really low. > > I don't speak from the perspective of a programmer because a programmer, even a blind one, can create the program he wants, to be accessible of course, but I speak from the perspective of the users because they are not programmers, they can't do anything to improve the accessibility of the programs that other people can use very easy. > > And what's worst is that most of those inaccessible programs are not that way because the programmer that created them consciously chosen the GUI lib because of who know what specific reasons, competitive or of other kind. Most of the time the programmer uses the GUI lib that she/he knows better and think that would be easier to create the program with. Most of them don't even know about accessibility, there are very many programmers in some countries that don't even imagine that some people can use a computer with a screen reader. > Octavian > -- Thanks, Ty From mgroth86 at gmail.com Mon Jan 24 17:25:09 2011 From: mgroth86 at gmail.com (Matthew Roth) Date: Mon, 24 Jan 2011 14:25:09 -0800 (PST) Subject: trouble installing MySQLdb (cygwin) + Bonus question Message-ID: Hi, I'm a python newbie. By newbie I mean two days ago. It was suggested to me that I work with python. Unfortunately at work I must run this on a windows machiene. However, I am having difficultly installing MySQLdb. First is it even possible under my current environment? I am using python(2.6.5) through cygwin, and have mySQL(Ver 14.14 Distrib 5.5.8 for Win32) installed in windows 7 which mysql returns: /cygdrive/c/Program Files/MySQL/MySQL Server 5.5/bin/mysql when I run python setup.py build it returns: -- $ python setup.py build /bin/sh: mysql_config: command not found Traceback (most recent call last): File "setup.py", line 15, in metadata, options = get_config() File "/home/Matt/MySQL-python-1.2.3/setup_posix.py", line 43, in get_config libs = mysql_config("libs_r") File "/home/Matt/MySQL-python-1.2.3/setup_posix.py", line 24, in mysql_config raise EnvironmentError("%s not found" % (mysql_config.path,)) EnvironmentError: mysql_config not found -- I've explored various avenues all day to no avail. Can anyone offer a solution or a direction to work towards. One avenue was ignorning the check for posix, and having it run setup_windows, but this just brings in problems with _winreg(?) seeing how I have a posix version of python through cygwin. Lastly, for the bonus question. Why MySQLdb why not something like this: -- import os cmd = 'mysql -uroot -pxxx db -e "SELECT * FROM tblxxx;"' os.system(cmd) -- why is this a poor idea? Best, Matt From rantingrick at gmail.com Mon Jan 24 17:30:38 2011 From: rantingrick at gmail.com (rantingrick) Date: Mon, 24 Jan 2011 14:30:38 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> 7c$4275d90a$44222222222222 <63eea$4d3cd2fd$4275d90a$14984@FUSE.NET> <69465430-08b3-4069-99c7-72f4d3034c66@s5g2000yqm.googlegroups.com> <705ad$4d3ce0fc$4275d90a$29144@FUSE.NET> <5f8c1256-f07c-43be-8307-d36991e9be24@m35g2000vbn.googlegroups.com> <4D3DD443.5070906@mrabarnett.plus.com> Message-ID: On Jan 24, 3:53?pm, "Littlefield, Tyler" wrote: > RR, you idiot. Did you -not- read that I was blind and using a screen > reader? And wasn't it -you- yelling at someone about reading and > comprehention? > On 1/24/2011 12:34 PM, MRAB wrote: Are you telling me that you are blind? You better not be lying about this Tyler because the only thing worse than an compassionate person is who impersonates a blind person for sake of winning an argument. Now, if you really are blind then why the heck would you be supporting Tkinter? Tkinter has no support for accessibility -- as Octavian pointed out. However, you seem to want to keep Tkinter at all costs. Why? And furthermore why are you so rabidly resistive to wxPython? From benjamin.kaplan at case.edu Mon Jan 24 17:36:44 2011 From: benjamin.kaplan at case.edu (Benjamin Kaplan) Date: Mon, 24 Jan 2011 17:36:44 -0500 Subject: why are functions greater than numbers? In-Reply-To: <2773df41-2a43-46bc-b2bd-7cbdd91aff55@u18g2000prh.googlegroups.com> References: <2773df41-2a43-46bc-b2bd-7cbdd91aff55@u18g2000prh.googlegroups.com> Message-ID: On Jan 24, 2011 5:31 PM, "Alan" wrote: > > Why do function objects compare in this way to numbers? > Thanks, > Alan Isaac > > > >>> def f(): return > ... > >>> f>5 > True > Python 2 returned an arbitrary but consistent ordering for almost all comparisons, just in case you were doing something weird like sorting a list with mixed types. Python 3 will throw an exception if you try doing something silly like compare a function to a number. -------------- next part -------------- An HTML attachment was scrubbed... URL: From ian.g.kelly at gmail.com Mon Jan 24 17:39:40 2011 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Mon, 24 Jan 2011 15:39:40 -0700 Subject: why are functions greater than numbers? In-Reply-To: <2773df41-2a43-46bc-b2bd-7cbdd91aff55@u18g2000prh.googlegroups.com> References: <2773df41-2a43-46bc-b2bd-7cbdd91aff55@u18g2000prh.googlegroups.com> Message-ID: On Mon, Jan 24, 2011 at 2:51 PM, Alan wrote: > Why do function objects compare in this way to numbers? > Thanks, > Alan Isaac > > >>>> def f(): return > ... >>>> f>5 > True http://docs.python.org/library/stdtypes.html#comparisons Python 3 fixes this particular wart. From drsalists at gmail.com Mon Jan 24 17:40:45 2011 From: drsalists at gmail.com (Dan Stromberg) Date: Mon, 24 Jan 2011 14:40:45 -0800 Subject: why are functions greater than numbers? In-Reply-To: <2773df41-2a43-46bc-b2bd-7cbdd91aff55@u18g2000prh.googlegroups.com> References: <2773df41-2a43-46bc-b2bd-7cbdd91aff55@u18g2000prh.googlegroups.com> Message-ID: On Mon, Jan 24, 2011 at 1:51 PM, Alan wrote: > Why do function objects compare in this way to numbers? > Thanks, > Alan Isaac > > >>>> def f(): return > ... >>>> f>5 > True > > -- > http://mail.python.org/mailman/listinfo/python-list > They shouldn't, but did in 2.x, and no longer do in 3.x: $ /usr/local/cpython-3.1/bin/python3 cmd started 2011 Mon Jan 24 02:39:50 PM Python 3.1.2 (r312:79147, Aug 18 2010, 18:21:44) [GCC 4.4.3] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> def f(): ... return 'abc' ... >>> f > 5 Traceback (most recent call last): File "", line 1, in TypeError: unorderable types: function() > int() >>> From rantingrick at gmail.com Mon Jan 24 17:41:03 2011 From: rantingrick at gmail.com (rantingrick) Date: Mon, 24 Jan 2011 14:41:03 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com>7c$4275d90a$44222222222222 <63eea$4d3cd2fd$4275d90a$14984@FUSE.NET><69465430-08b3-4069-99c7-72f4d3034c66@s5g2000yqm.googlegroups.com><705ad$4d3ce0fc$4275d90a$29144@FUSE.NET> <5f8c1256-f07c-43be-8307-d36991e9be24@m35g2000vbn.googlegroups.com> Message-ID: On Jan 24, 4:19?pm, "Littlefield, Tyler" wrote: > I say this all because I want to make a point. I don't expect the world > to revolve around what is and isn't accessible. While laws do exist, if > I ran around quoting the ADA (Americans with Disabilities Act) at > everyone who didn't make things accessible (whether on the computer, at > school, at a store), I'd just be wasting time. I disagree, you would be educating people and you would be suppressing selfishness. > Rather I like to blend > in, be independant and adapt things. Now, since i am a programmer this > means that I am able to do a lot more in the form of adaptation on the > computer, and this is my goal; if something is broke, fix the root or > work with the developer. Have you tried to "fix" Tkinters non-existent accessibility? Have you campaigned for change? Have you written any code? Just FYI: Tkinter has been around for 20 plus years! > Don't just whine about it not being accessible. > It will get you nowhere, and it's people like Octavian I dread having > had people meat before because by golly, -everything- better be accessible. You know Tyler for someone that depends on accessibility as much as you you sure are a supporter of non-compliance. I think you are lying about being blind. And if you are, i am disgusted. > So, call me a Nazi or whatever, that's just how I feel. The world > doesn't come on a silver platter, and so if Octavian, or I, or anyone > else wants any sort of changes done (as in the changes to TkInter), work > needs to go into helping these changes come about. Yes and making an argument is part of that work. Good arguments change minds. > Making a library part > of the STDLib and then worrying about the fact that it segfaults later > is foolish, Of course it's foolish to do that. No one is suggesting that we throw wxPython in the stdlib as is. We know some work needs to be done. Heck maybe an abstraction API needs to be written. Don't be so theatrical Tyler, it wins you no points. > especially if you are going to do it just for accessibility. We are not doing it JUST for accessibility! Accessibility is just one of many reasons. The most important reason is to keep Python relevant in the 21st century. > And regardless of whether RR gets his deepest wish and it is made part > of the STDLib, people will still use TKInter. Yes, i am not trying to destroy Tkinter. I am trying to tell you that Tkinter is dead weight for Python. > What then, for those with > readers? Should we just abolish TKInter altogether? > On 1/24/2011 1:45 PM, Octavian Rasnita wrote: Well if i were a blind person i would use the most accessible GUI available. From python at mrabarnett.plus.com Mon Jan 24 17:56:48 2011 From: python at mrabarnett.plus.com (MRAB) Date: Mon, 24 Jan 2011 22:56:48 +0000 Subject: why are functions greater than numbers? In-Reply-To: <2773df41-2a43-46bc-b2bd-7cbdd91aff55@u18g2000prh.googlegroups.com> References: <2773df41-2a43-46bc-b2bd-7cbdd91aff55@u18g2000prh.googlegroups.com> Message-ID: <4D3E03B0.8080104@mrabarnett.plus.com> On 24/01/2011 21:51, Alan wrote: > Why do function objects compare in this way to numbers? > Thanks, > Alan Isaac > > >>>> def f(): return > ... >>>> f>5 > True > In Python 2 any object can be compared in this way to any other. The result is arbitrary but consistent. In Python 3 that has changed because in practice it's more trouble than it's worth: >>> def f(): return >>> f>5 Traceback (most recent call last): File "", line 1, in f>5 TypeError: unorderable types: function() > int() It's usually a good sign that there's a bug somewhere. From bryan.oakley at gmail.com Mon Jan 24 17:57:38 2011 From: bryan.oakley at gmail.com (Bryan) Date: Mon, 24 Jan 2011 14:57:38 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <3a96fee1-995f-49f7-a967-f125cc3f1cdc@v26g2000yqf.googlegroups.com> <023e19ed-69d1-4155-a114-0d00c227b8f6@u18g2000prh.googlegroups.com> <06dd3a10-03a4-4d43-a10e-cadf5105a7c4@t23g2000vby.googlegroups.com> Message-ID: <62841207-105b-4d47-8e64-574e03180c41@15g2000vbz.googlegroups.com> On Jan 24, 4:16?pm, rantingrick wrote: > ... > Good, and again i cannot stress how little we care about your opinion. You keep using the word "we". I do not think it means what you think it means. From steve+comp.lang.python at pearwood.info Mon Jan 24 18:04:03 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 24 Jan 2011 23:04:03 GMT Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <3a96fee1-995f-49f7-a967-f125cc3f1cdc@v26g2000yqf.googlegroups.com> Message-ID: <4d3e0563$0$29983$c3e8da3$5496439d@news.astraweb.com> On Mon, 24 Jan 2011 12:24:24 -0800, Robin Dunn wrote: > On Jan 24, 12:03?pm, rantingrick wrote: >> On Jan 24, 1:57?pm, Robin Dunn wrote: > >> > BTW, on behalf of the wxPython community I'd like to apologize for >> > the havoc caused by the flaming troll escaping from his cage. ?In >> > general wxPython users are much less militant and zealotty and honor >> > everyone's freedom to choose which ever UI tool kit works the best >> > for their own needs. >> >> Well we forgive Byran, but we will not forget! :) > > For the record, that is not who I was referring to. I don't believe that anyone in their right mind could have imagined even for a second that you were referring to Bryan. -- Steven From tjreedy at udel.edu Mon Jan 24 18:13:45 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Mon, 24 Jan 2011 18:13:45 -0500 Subject: why are functions greater than numbers? In-Reply-To: <2773df41-2a43-46bc-b2bd-7cbdd91aff55@u18g2000prh.googlegroups.com> References: <2773df41-2a43-46bc-b2bd-7cbdd91aff55@u18g2000prh.googlegroups.com> Message-ID: On 1/24/2011 4:51 PM, Alan wrote: > Why do function objects compare in this way to numbers? > Thanks, > Alan Isaac > > >>>> def f(): return > ... >>>> f>5 > True In 3.x >>> def f(): pass >>> f > 5 Traceback (most recent call last): File "", line 1, in f > 5 TypeError: unorderable types: function() > int() There is a historical explanation in many past posts and probably in the FAQ. -- Terry Jan Reedy From emile at fenx.com Mon Jan 24 18:17:47 2011 From: emile at fenx.com (Emile van Sebille) Date: Mon, 24 Jan 2011 15:17:47 -0800 Subject: why are functions greater than numbers? In-Reply-To: <2773df41-2a43-46bc-b2bd-7cbdd91aff55@u18g2000prh.googlegroups.com> References: <2773df41-2a43-46bc-b2bd-7cbdd91aff55@u18g2000prh.googlegroups.com> Message-ID: On 1/24/2011 1:51 PM Alan said... > Why do function objects compare in this way to numbers? To provide ordering capabilities. IIRC, comparisons of differing types are arbitrary but consistent. Emile > Thanks, > Alan Isaac > > >>>> def f(): return > ... >>>> f>5 > True > From steve+comp.lang.python at pearwood.info Mon Jan 24 18:23:54 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 24 Jan 2011 23:23:54 GMT Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <70498$4d3cb87c$4275d90a$4428@FUSE.NET> <46c407b5-9bfe-406a-a2fe-c63caa771bf3@f2g2000vby.googlegroups.com> <05fd32ee-e542-4622-afa8-a7cf4549df45@k42g2000yqa.googlegroups.com> <709769f9-f99a-46c8-bcc1-7a03adf303c6@v17g2000vbo.googlegroups.com> Message-ID: <4d3e0a0a$0$29983$c3e8da3$5496439d@news.astraweb.com> On Mon, 24 Jan 2011 09:17:01 -0800, rantingrick wrote: > I was > being a closed minded idiot at the time. I have since evolved. "Was"? It's been fun (for some definition of fun) watching your grandstanding, your haranguing the community into doing things your way, your insulting the blind for being insufficiently demanding of screen-reader support, and generally bullying everyone here. Unfortunately I've wasted far too much time reading your theatrics. It's time for another six months in the kill-file, I think. -- Steven From dmaziuk at bmrb.wisc.edu Mon Jan 24 18:25:01 2011 From: dmaziuk at bmrb.wisc.edu (dmaziuk) Date: Mon, 24 Jan 2011 15:25:01 -0800 (PST) Subject: how to tell if cursor is sqlite.Cursor or psycopg2.Cursor In-Reply-To: Message-ID: For psycopg2: '' (of course, this could also be due to RHEL5's ancient python). Dima From dmaziuk at bmrb.wisc.edu Mon Jan 24 18:25:01 2011 From: dmaziuk at bmrb.wisc.edu (dmaziuk) Date: Mon, 24 Jan 2011 15:25:01 -0800 (PST) Subject: how to tell if cursor is sqlite.Cursor or psycopg2.Cursor In-Reply-To: Message-ID: For psycopg2: '' (of course, this could also be due to RHEL5's ancient python). Dima From invalid at invalid.invalid Mon Jan 24 18:31:50 2011 From: invalid at invalid.invalid (Grant Edwards) Date: Mon, 24 Jan 2011 23:31:50 +0000 (UTC) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <70498$4d3cb87c$4275d90a$4428@FUSE.NET> <46c407b5-9bfe-406a-a2fe-c63caa771bf3@f2g2000vby.googlegroups.com> <05fd32ee-e542-4622-afa8-a7cf4549df45@k42g2000yqa.googlegroups.com> <709769f9-f99a-46c8-bcc1-7a03adf303c6@v17g2000vbo.googlegroups.com> <4d3e0a0a$0$29983$c3e8da3$5496439d@news.astraweb.com> Message-ID: On 2011-01-24, Steven D'Aprano wrote: > On Mon, 24 Jan 2011 09:17:01 -0800, rantingrick wrote: > >> I was being a closed minded idiot at the time. I have since evolved. > > "Was"? > > It's been fun (for some definition of fun) watching your > grandstanding, your haranguing the community into doing things your > way, your insulting the blind for being insufficiently demanding of > screen-reader support, and generally bullying everyone here. > Unfortunately I've wasted far too much time reading your theatrics. Unfortunately, some of us have been guilty of poking him with a stick just to watch him jump and yell. > It's time for another six months in the kill-file, I think. That doesn't really help much. RR has been in my killfile since before his first posting. But, thanks to people who quote his rantings in their entirety, I think I've seen pretty much all of them. -- Grant Edwards grant.b.edwards Yow! FROZEN ENTREES may at be flung by members of gmail.com opposing SWANSON SECTS ... From rantingrick at gmail.com Mon Jan 24 19:07:30 2011 From: rantingrick at gmail.com (rantingrick) Date: Mon, 24 Jan 2011 16:07:30 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <70498$4d3cb87c$4275d90a$4428@FUSE.NET> <46c407b5-9bfe-406a-a2fe-c63caa771bf3@f2g2000vby.googlegroups.com> <05fd32ee-e542-4622-afa8-a7cf4549df45@k42g2000yqa.googlegroups.com> <709769f9-f99a-46c8-bcc1-7a03adf303c6@v17g2000vbo.googlegroups.com> <4d3e0a0a$0$29983$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4829dc4d-be50-417b-b292-bea118472c0c@k13g2000vbq.googlegroups.com> On Jan 24, 5:31?pm, Grant Edwards wrote: > On 2011-01-24, Steven D'Aprano wrote: > > > On Mon, 24 Jan 2011 09:17:01 -0800, rantingrick wrote: > > >> I was being a closed minded idiot at the time. I have since evolved. > > > "Was"? > [...snip: Steven Trolling...] > > Unfortunately I've wasted far too much time reading your theatrics. > > Unfortunately, some of us have been guilty of poking him with a stick > just to watch him jump and yell. Every one of my threads (or threads i replied to) Steven has trolled them all. He never engages me in direct battle because he lacks the mental prowess i possess. He fears me and it shows. He fears me because i have a vision and he has none. He fears me because HE fears change. Should i post links to all the threads you have trolled up Steven as evidence of your trollish behavior? You never had the balls to engage me and you never will! Sadly you are one of the most knowledgeable within this group yet you spend 99% of your time trolling for your own self gratification. Why have you not offered any opinions on Wx versus Tkinter? Why have you not offered any code? BECAUSE YOU ARE A TROLL! Plain and simple. > > It's time for another six months in the kill-file, I think. Good riddance! Make it a year, ten years, i don't care! > That doesn't really help much. ?RR has been in my killfile since > before his first posting. But, thanks to people who quote his rantings > in their entirety, I think I've seen pretty much all of them. Well kill file D'Aprano and just shrink your listener even more. The funny thing about selfishness and arrogance is that they are both self defeating. However many in this group wear these attributes with pride. Yes, go ahead and stick your head in the sand and imagine the world does not exist -- because when you do you leave your backside sticking out in a good position for kicking! *kick* From robin at alldunn.com Mon Jan 24 19:32:39 2011 From: robin at alldunn.com (Robin Dunn) Date: Mon, 24 Jan 2011 16:32:39 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <3a96fee1-995f-49f7-a967-f125cc3f1cdc@v26g2000yqf.googlegroups.com> <023e19ed-69d1-4155-a114-0d00c227b8f6@u18g2000prh.googlegroups.com> <06dd3a10-03a4-4d43-a10e-cadf5105a7c4@t23g2000vby.googlegroups.com> Message-ID: On Jan 24, 2:16?pm, rantingrick wrote: > And i know the real reason you and Robin do not want wxPython > in the stdlib. Because you do not want to lose your selfish status > within the wxPython community. When wxPython becomes a stdlib module > then you will answer directly to Guido and Python-dev. You are not > fooling anyone with this grandstanding. Oh my, the BS certainly is getting deep around here. It doesn't look like my hip-waders will be enough... Now where did I put that full- body bio-hazard environment suit? --Robin From alex.kapps at web.de Mon Jan 24 19:37:18 2011 From: alex.kapps at web.de (Alexander Kapps) Date: Tue, 25 Jan 2011 01:37:18 +0100 Subject: WxPython versus Tkinter. In-Reply-To: <4d3e0563$0$29983$c3e8da3$5496439d@news.astraweb.com> References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <3a96fee1-995f-49f7-a967-f125cc3f1cdc@v26g2000yqf.googlegroups.com> <4d3e0563$0$29983$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4D3E1B3E.5010105@web.de> There are two completely different issues here: 1. Tyler's/Octavian's very valid (but AFAICT now somewhat over-expressed) point that Tk/Tkinter isn't accessible. I accept this, but don't see any point against Tk(inter) in this per se. Tk(inter) could be advanced to support screen readers and such. 2. RR's aggressive, insulting, self-praising war against Tk(inter) (which, IIRC, he ones praised) I *really* don't understand why RR gets so much attention. He has (massively!) insulted everybody around, has shown his low knowledge and understanding, his selfish and arrogant behaviour, etc. As I see it, please don't fall trap when RR now supports the accessible issue. I'm quite sure, that he just misuses that. Now that Godwin has been called, let me say also this: Check some earlier posts of RR (especially unicode related, but also his whole "command structure", "leader", "one for all", etc stuff) and it should be clear who is the izan. (*) Wake me, if RR is chased out of town and we can start a real discussion about the future of Python GUIs and accessibility. (*) I'm German and I just *KNOW* what to think about people who accuse random opponents as aniz. Our politicians do that quite regularly and the *ONLY* aim behind this is plain and simply to discredit the opponent when the arguments run out. From steve+comp.lang.python at pearwood.info Mon Jan 24 20:41:52 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 25 Jan 2011 01:41:52 GMT Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <3a96fee1-995f-49f7-a967-f125cc3f1cdc@v26g2000yqf.googlegroups.com> <4d3e0563$0$29983$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4d3e2a5f$0$29970$c3e8da3$5496439d@news.astraweb.com> On Tue, 25 Jan 2011 01:37:18 +0100, Alexander Kapps wrote: > I *really* don't understand why RR gets so much attention. He has > (massively!) insulted everybody around, has shown his low knowledge and > understanding, his selfish and arrogant behaviour, etc. http://xkcd.com/386/ -- Steven From rantingrick at gmail.com Mon Jan 24 21:58:48 2011 From: rantingrick at gmail.com (rantingrick) Date: Mon, 24 Jan 2011 18:58:48 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <66b4baf9-7714-45ae-9cac-39b06ee3f70e@k42g2000yqa.googlegroups.com> Message-ID: <438a06b0-eefa-423d-af6b-497e34ce6ce0@u6g2000yqk.googlegroups.com> On Jan 24, 2:11?pm, rantingrick wrote: > On Jan 22, 6:07?pm, rantingrick wrote: > > > I await any challengers... > > CODE UPDATE > > ?* fixed linux whiners bug > > https://sites.google.com/site/thefutureofpython/home/code-challenges So what? Now that the code runs without segfault nobody has nothing to say? I guess you have nothing to complain about now huh? So go ahead and admit wxPython won this round so we can move on to round two, our post some Tkinter ListCtrl code. From tyler at tysdomain.com Mon Jan 24 22:28:55 2011 From: tyler at tysdomain.com (Littlefield, Tyler) Date: Mon, 24 Jan 2011 20:28:55 -0700 Subject: WxPython versus Tkinter. Message-ID: <4D3E4377.3060807@tysdomain.com> >I think you are lying about being blind. And if you are, i am disgusted. By golly, you caught me in the act! shhh, don't tell everyone; it's all an elaborate front. The braille, the screen reader, the cane... I just like to fake it. block quote Well if i were a blind person i would use the most accessible GUI>available. block quote end And we already do. I haven't campaigned for changes with TKInter or spoken to anyone about them, because I haven't downloaded a program to find out it was written to use TKInter, and thus unacccessible. I'm not saying that there aren't any, just saying it's not something I have had problems with mainstream to need to make things accessible. If I want a program that's not accessible, chances are I can make it accessible, or I can find a program that does just as much, or better yet, I can ask the developer to work with me on it. While quoting ADA at people might provide for some education, eventually people are going to get tired of it and I've done nothing useful at the end of the day. There -is- a point when it's useful, but I suppose it comes down to who you are. If you want to sit around and say "TKInter == horrible and bad and evil and cruel because it doesn't work with my reader," over and over, so be it. If you want to scream and yell and start quoting laws at people who just may not know that there are people with screen readers out there (I've explained some of this to many different people many times, in terms of what a reader is), then that's your loss, because they more than likely are not going to care to work with you. -- Thanks, Ty From ameyer2 at yahoo.com Mon Jan 24 22:38:52 2011 From: ameyer2 at yahoo.com (Alan Meyer) Date: Mon, 24 Jan 2011 22:38:52 -0500 Subject: Swampy Module installation In-Reply-To: <9dd545a1-b0ea-408c-9fe2-a2ce7d6a5a0a@m7g2000vbn.googlegroups.com> References: <9dd545a1-b0ea-408c-9fe2-a2ce7d6a5a0a@m7g2000vbn.googlegroups.com> Message-ID: On 01/18/2011 06:26 PM, Michael Rauh wrote: > I am new to python, and attempting to install the learning module > swampy. http://www.greenteapress.com/thinkpython/swampy/install.html > Unfortunately, I am attempting to do this on windows vista, which does > not appear to be cooperating. Once I click on the install link, it > puts the file on the computer, and even if I place the file into the > source folder for python, it still says that there is no module > swampy. How can I get python to recognize the module as being there, > and to run the suite? I admit, I may be placing it in the wrong > directory, as I have so far been unable to change the working > directory. Online the command os.chdir is said to change the > directory, but it keeps giving an error, and saying that os is not > recognized. Variations on this code do not seem to work either. Did you run: python setup.py install After you unzip the package you should see a program named "setup.py" which is a standard convention for a program to install a package. There's information about all this, for example at: http://docs.python.org/install/index.html, however you might find it a little overwhelming until you get further into Python. Good luck. Alan From me+list/python at ixokai.io Mon Jan 24 22:54:07 2011 From: me+list/python at ixokai.io (Stephen Hansen) Date: Mon, 24 Jan 2011 19:54:07 -0800 Subject: WxPython versus Tkinter. In-Reply-To: <06dd3a10-03a4-4d43-a10e-cadf5105a7c4@t23g2000vby.googlegroups.com> References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <3a96fee1-995f-49f7-a967-f125cc3f1cdc@v26g2000yqf.googlegroups.com> <023e19ed-69d1-4155-a114-0d00c227b8f6@u18g2000prh.googlegroups.com> <06dd3a10-03a4-4d43-a10e-cadf5105a7c4@t23g2000vby.googlegroups.com> Message-ID: <4D3E495F.7010201@ixokai.io> On 1/24/11 2:16 PM, rantingrick wrote: > On Jan 24, 3:58 pm, Infinity77 wrote: > >> I have been involved in the wxPython development for many years >> (mostly on implementation of custom widgets, in the AGW library), and >> I share Robin's concerns about this kind of "publicity" given to >> wxPython. > > Who cares what you think about wxPython's publicity. A module was > created and put on public display and can be ridiculed or supported by > anyone who so desires. > >> Python comes with TK as a "battery included" UI toolkit. I'm perfectly >> fine with this, as I am not going to use it anyway. Whether in the >> future TK will be replaced by PyGTK, PyQT, PySide, etc... in the >> standard library, it won't make any difference to those aficionados >> developers who use wxPython. We'll still download the wxPython >> binaries/sources/whatever and use it to develop our own GUIs. > > Good, and again i cannot stress how little we care about your opinion. > Why do we not care. Well because you are looking at this from a > wxPython perspective. You are being selfish. We are considering this > from a global Python perspective. What is good for Python may not be > good for you, in any event, it is for us to decide. You can join our > discussion when your perspective changes from "me" to "us". And the > "us" is the Python langauge NOT wxPython. > > >> It is very unfortunate that this topic "wxPython vs. Tkinter" has >> drifted to another flame war, > > There is no flame war here > >> as there is really no point in this kind >> of discussion. > > Says you. but who are you to say what is important to us. Go back to > wxPython. > >> As a general rule, a GUI-newbie should try all the GUI >> toolkits out there and settle with the one which looks easier/nicer/ >> more convenient/more feature rich. As usual, it is a matter of >> personal taste. > > And i agree. I think any sane person could agree also. However you > miss the point of this conversation. We are looking at Python from a > global perspective. You are limited in your views, and obviously very > biased. And i know the real reason you and Robin do not want wxPython > in the stdlib. Because you do not want to lose your selfish status > within the wxPython community. When wxPython becomes a stdlib module > then you will answer directly to Guido and Python-dev. You are not > fooling anyone with this grandstanding. I can't believe I'm actually getting into this, but-- wxPython is open source, and technically anyone has the legal right to include it in whatever they want -- but no module goes into stdlib, period, without it being donated by its authors for that purpose. Period. Python-dev is not so discourteous as to absorb someone elses code without their go-ahead (and more then that: they don't generally absorb anyone elses code without that person making a _commitment_ to supporting it, in the stdlib, for multiple years). So: no author answers to Guido unless they decide they want to. Not that I'm suggesting Robin wouldn't go for it if someone with actual standing asked: but I'm not suggesting he would, either. I have no idea if the stdlib development cycle fits the wxPython one, since wxPython tracks wxWidgets releases. (Totally notwithstanding the elephant in the room that nothing new is going to go into 2.x at all, and wxPython doesn't presently support 3.x.) Robin actually has an unappealable veto over the whole idea, if he so chose to exercise it. Just thought I'd interject some reality into your delusion that there is some Python Kingdom and that King Guido can "decide" all manner of things and it'll cause them to happen. But we've had this conversation before, you and I. Also, rick != the_community. You don't get to speak for "we". But we've had that conversation too, you and I. -- Stephen Hansen ... Also: Ixokai ... Mail: me+list/python (AT) ixokai (DOT) io ... Blog: http://meh.ixokai.io/ -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 487 bytes Desc: OpenPGP digital signature URL: From rantingrick at gmail.com Mon Jan 24 23:32:00 2011 From: rantingrick at gmail.com (rantingrick) Date: Mon, 24 Jan 2011 20:32:00 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <3a96fee1-995f-49f7-a967-f125cc3f1cdc@v26g2000yqf.googlegroups.com> <023e19ed-69d1-4155-a114-0d00c227b8f6@u18g2000prh.googlegroups.com> <06dd3a10-03a4-4d43-a10e-cadf5105a7c4@t23g2000vby.googlegroups.com> Message-ID: <34a0ffa4-1fa9-46eb-a53f-4338e8ffd1ed@i17g2000vbq.googlegroups.com> On Jan 24, 9:54?pm, Stephen Hansen wrote: > On 1/24/11 2:16 PM, rantingrick wrote: > wxPython is open source, and technically anyone has the legal right to > include it in whatever they want -- but no module goes into stdlib, > period, without it being donated by its authors for that purpose. Ok. So you are saying that wxPython *could* possibly go into the stdlib and equally wxPython could possibly *not* go into th stdlib? Ok, go on... > Period. Python-dev is not so discourteous as to absorb someone elses > code without their go-ahead (and more then that: they don't generally > absorb anyone elses code without that person making a _commitment_ to > supporting it, in the stdlib, for multiple years). > > So: no author answers to Guido unless they decide they want to. Ok? So you are saying that wxPython *could* possibly go into the stdlib and equally wxPython could possibly *not* go into th stdlib? Ok, go on... > Not that I'm suggesting Robin wouldn't go for it if someone with actual > standing asked: but I'm not suggesting he would, either. Ok! So you are saying that wxPython *could* possibly go into the stdlib and equally wxPython could possibly *not* go into th stdlib? Ok, go on... > I have no idea > if the stdlib development cycle fits the wxPython one, since wxPython > tracks wxWidgets releases. (Totally notwithstanding the elephant in the > room that nothing new is going to go into 2.x at all, and wxPython > doesn't presently support 3.x.) OK,OK,OK!! So you are saying that wxPython *could* possibly go into the stdlib and equally wxPython could possibly *not* go into th stdlib? HOWEVER no matter what it FOR SURE can't go into Python2.x! Ok, go on... > Robin actually has an unappealable veto over the whole idea, if he so > chose to exercise it. GEESH!! So you are saying that wxPython *could* possibly go into the stdlib and equally wxPython could possibly *not* go into th stdlib? Ok, go on... > Just thought I'd interject some reality into your delusion that there is > some Python Kingdom and that King Guido can "decide" all manner of > things and it'll cause them to happen. Stephen can i sum up your post as..."it could go either way"? PS: And you guys wonder why i rant so much! :-) From jason.swails at gmail.com Mon Jan 24 23:39:07 2011 From: jason.swails at gmail.com (Jason Swails) Date: Mon, 24 Jan 2011 23:39:07 -0500 Subject: WxPython versus Tkinter. In-Reply-To: <4D3E495F.7010201@ixokai.io> References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <3a96fee1-995f-49f7-a967-f125cc3f1cdc@v26g2000yqf.googlegroups.com> <023e19ed-69d1-4155-a114-0d00c227b8f6@u18g2000prh.googlegroups.com> <06dd3a10-03a4-4d43-a10e-cadf5105a7c4@t23g2000vby.googlegroups.com> <4D3E495F.7010201@ixokai.io> Message-ID: Oddly enough, this post STARTED right around the time I joined the list. (Tkinter: The good, the bad, the ugly) It's been an interesting metamorphosis to watch as the ranting(rick) started quasi-civil and "discussionary", then evolved within a matter of weeks to violence and hyperbole. A lot of rather hyperbolic comparisons have been drawn (i.e. Nazis, limitless selfishness, complete idiocy, etc.), but I think I may have one avoids hyperbole altogether. This thread is a fast-forwarded, condensed version of the US political rhetoric as it's evolved over the past 200 years, culminating in today's ridiculous environment in which opposing opinions can do no better than condemn the entire country (or world in *our* view) to utter destruction. And I may add that today's US government, and the arguments upon which it throws itself, is probably one of the most ineffective in the country's history (of course this comparison will probably be tossed away as unrelated, irrelevant, and moronic; doesn't change its uncanny similarity :) ). In this rendition, however, we have both sides being played by the same actor (perhaps with 1 or 2 supporting roles). Two valuable things I have taken away from this extended argument: 1) This being my first super-high volume mailing list with the occasional neurotically opinionated poster, MRAB introduced me to Godwin's law for the first time. Considering its context, much to my amusement (thank you). 2) Steven's XKCD comic that I had not seen before. Also, considering its context, much to my amusement. For any comments as to my post's uselessness and my overall idiocy, etc., I've provided the below space for you to have as much fun as you'd like. --------------------------------- --------------------------------- While that may not be enough space, a couple well-placed carriage returns should do the trick. I suppose the only reason some people respond is that it's fun to poke the fire harmlessly and watch small flaming ash go flying everywhere. The internet is inflammable after all (how else could it still be here after so many flame wars?) Hoping you all have a peaceful night, Jason On Mon, Jan 24, 2011 at 10:54 PM, Stephen Hansen wrote: > On 1/24/11 2:16 PM, rantingrick wrote: > > On Jan 24, 3:58 pm, Infinity77 wrote: > > > >> I have been involved in the wxPython development for many years > >> (mostly on implementation of custom widgets, in the AGW library), and > >> I share Robin's concerns about this kind of "publicity" given to > >> wxPython. > > > > Who cares what you think about wxPython's publicity. A module was > > created and put on public display and can be ridiculed or supported by > > anyone who so desires. > > > >> Python comes with TK as a "battery included" UI toolkit. I'm perfectly > >> fine with this, as I am not going to use it anyway. Whether in the > >> future TK will be replaced by PyGTK, PyQT, PySide, etc... in the > >> standard library, it won't make any difference to those aficionados > >> developers who use wxPython. We'll still download the wxPython > >> binaries/sources/whatever and use it to develop our own GUIs. > > > > Good, and again i cannot stress how little we care about your opinion. > > Why do we not care. Well because you are looking at this from a > > wxPython perspective. You are being selfish. We are considering this > > from a global Python perspective. What is good for Python may not be > > good for you, in any event, it is for us to decide. You can join our > > discussion when your perspective changes from "me" to "us". And the > > "us" is the Python langauge NOT wxPython. > > > > > >> It is very unfortunate that this topic "wxPython vs. Tkinter" has > >> drifted to another flame war, > > > > There is no flame war here > > > >> as there is really no point in this kind > >> of discussion. > > > > Says you. but who are you to say what is important to us. Go back to > > wxPython. > > > >> As a general rule, a GUI-newbie should try all the GUI > >> toolkits out there and settle with the one which looks easier/nicer/ > >> more convenient/more feature rich. As usual, it is a matter of > >> personal taste. > > > > And i agree. I think any sane person could agree also. However you > > miss the point of this conversation. We are looking at Python from a > > global perspective. You are limited in your views, and obviously very > > biased. And i know the real reason you and Robin do not want wxPython > > in the stdlib. Because you do not want to lose your selfish status > > within the wxPython community. When wxPython becomes a stdlib module > > then you will answer directly to Guido and Python-dev. You are not > > fooling anyone with this grandstanding. > > I can't believe I'm actually getting into this, but-- > > wxPython is open source, and technically anyone has the legal right to > include it in whatever they want -- but no module goes into stdlib, > period, without it being donated by its authors for that purpose. > Period. Python-dev is not so discourteous as to absorb someone elses > code without their go-ahead (and more then that: they don't generally > absorb anyone elses code without that person making a _commitment_ to > supporting it, in the stdlib, for multiple years). > > So: no author answers to Guido unless they decide they want to. > > Not that I'm suggesting Robin wouldn't go for it if someone with actual > standing asked: but I'm not suggesting he would, either. I have no idea > if the stdlib development cycle fits the wxPython one, since wxPython > tracks wxWidgets releases. (Totally notwithstanding the elephant in the > room that nothing new is going to go into 2.x at all, and wxPython > doesn't presently support 3.x.) > > Robin actually has an unappealable veto over the whole idea, if he so > chose to exercise it. > > Just thought I'd interject some reality into your delusion that there is > some Python Kingdom and that King Guido can "decide" all manner of > things and it'll cause them to happen. > > But we've had this conversation before, you and I. > > Also, rick != the_community. You don't get to speak for "we". > > But we've had that conversation too, you and I. > > > -- > > Stephen Hansen > ... Also: Ixokai > ... Mail: me+list/python (AT) ixokai (DOT) io > ... Blog: http://meh.ixokai.io/ > > > -- > http://mail.python.org/mailman/listinfo/python-list > > -- Jason M. Swails Quantum Theory Project, University of Florida Ph.D. Graduate Student 352-392-4032 -------------- next part -------------- An HTML attachment was scrubbed... URL: From me+list/python at ixokai.io Mon Jan 24 23:51:12 2011 From: me+list/python at ixokai.io (Stephen Hansen) Date: Mon, 24 Jan 2011 20:51:12 -0800 Subject: WxPython versus Tkinter. In-Reply-To: <34a0ffa4-1fa9-46eb-a53f-4338e8ffd1ed@i17g2000vbq.googlegroups.com> References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <3a96fee1-995f-49f7-a967-f125cc3f1cdc@v26g2000yqf.googlegroups.com> <023e19ed-69d1-4155-a114-0d00c227b8f6@u18g2000prh.googlegroups.com> <06dd3a10-03a4-4d43-a10e-cadf5105a7c4@t23g2000vby.googlegroups.com> <34a0ffa4-1fa9-46eb-a53f-4338e8ffd1ed@i17g2000vbq.googlegroups.com> Message-ID: <4D3E56C0.40207@ixokai.io> On 1/24/11 8:32 PM, rantingrick wrote: > On Jan 24, 9:54 pm, Stephen Hansen wrote: >> On 1/24/11 2:16 PM, rantingrick wrote: > >> wxPython is open source, and technically anyone has the legal right to >> include it in whatever they want -- but no module goes into stdlib, >> period, without it being donated by its authors for that purpose. > > Ok. So you are saying that wxPython *could* possibly go into the > stdlib and equally wxPython could possibly *not* go into th stdlib? > Ok, go on... No. I am saying as a matter of legal permissibility, it may be included in the stdlib. But, as a matter of both policy and ethical behavior, it will not without it being donated by the author. The words are not big. You can understand them, if you try, really hard. Honest. -- Stephen Hansen ... Also: Ixokai ... Mail: me+list/python (AT) ixokai (DOT) io ... Blog: http://meh.ixokai.io/ -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 487 bytes Desc: OpenPGP digital signature URL: From chris.gonnerman at newcenturycomputers.net Mon Jan 24 23:52:13 2011 From: chris.gonnerman at newcenturycomputers.net (Chris Gonnerman) Date: Mon, 24 Jan 2011 22:52:13 -0600 Subject: [Python] how to tell if cursor is sqlite.Cursor or psycopg2.Cursor In-Reply-To: <7f1931cd-a15b-44a9-8cf9-b0af0bdfec7d@d8g2000yqf.googlegroups.com> References: <7f1931cd-a15b-44a9-8cf9-b0af0bdfec7d@d8g2000yqf.googlegroups.com> Message-ID: <4D3E56FD.1090601@newcenturycomputers.net> You're looking at it wrong. It doesn't matter what type of cursor it is, only if you can get the correct number. So use a try...except: try: cursor.execute(""" select last_insert_rowid() """) except: cursor.execute(""" select currval('my_sequence') """) That's just a quick-and-dirty example; you might need to pretty it up, or actually declare the type of exception you're expecting (always a good idea, but I didn't feel like looking up the right sqlite exception). Good luck! From tshinnic at io.com Tue Jan 25 00:02:48 2011 From: tshinnic at io.com (Thomas L. Shinnick) Date: Mon, 24 Jan 2011 23:02:48 -0600 Subject: WxPython versus Tkinter. In-Reply-To: References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <3a96fee1-995f-49f7-a967-f125cc3f1cdc@v26g2000yqf.googlegroups.com> <023e19ed-69d1-4155-a114-0d00c227b8f6@u18g2000prh.googlegroups.com> <06dd3a10-03a4-4d43-a10e-cadf5105a7c4@t23g2000vby.googlegroups.com> <4D3E495F.7010201@ixokai.io> Message-ID: <28.8A.00963.7895E3D4@hrndva-omtalb.mail.rr.com> At 10:39 PM 1/24/2011, Jason Swails wrote: [snip] >Two valuable things I have taken away from this extended >argument: 1) This being my first super-high volume mailing list >with the occasional neurotically opinionated poster, MRAB introduced >me to Godwin's law for the first time. Considering its context, >much to my amusement (thank you). 2) Steven's XKCD comic that I had >not seen before. Also, considering its context, much to my amusement. More wisdom therein ... http://xkcd.com/438/ -- I'm a pessimist about probabilities; I'm an optimist about possibilities. Lewis Mumford (1895-1990) From rantingrick at gmail.com Tue Jan 25 00:16:11 2011 From: rantingrick at gmail.com (rantingrick) Date: Mon, 24 Jan 2011 21:16:11 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <3a96fee1-995f-49f7-a967-f125cc3f1cdc@v26g2000yqf.googlegroups.com> <023e19ed-69d1-4155-a114-0d00c227b8f6@u18g2000prh.googlegroups.com> <06dd3a10-03a4-4d43-a10e-cadf5105a7c4@t23g2000vby.googlegroups.com> <34a0ffa4-1fa9-46eb-a53f-4338e8ffd1ed@i17g2000vbq.googlegroups.com> Message-ID: <3cf33238-dff6-487d-be19-e3fd0b020163@j1g2000vbl.googlegroups.com> On Jan 24, 10:51?pm, Stephen Hansen wrote: > No. I am saying as a matter of legal permissibility, it may be included > in the stdlib. > > But, as a matter of both policy and ethical behavior, it will not > without it being donated by the author. I don't think you have any idea of what you are saying because you keep parroting off the same thing in slightly different ways. I'm having flashbacks to Forrest Gump... Bubba: Anyway, like I was sayin', shrimp is the fruit of the sea. You can barbecue it, boil it, broil it, bake it, saute it. Dey's uh, shrimp-kabobs, shrimp creole, shrimp gumbo. Pan fried, deep fried, stir-fried. There's pineapple shrimp, lemon shrimp, coconut shrimp, pepper shrimp, shrimp soup, shrimp stew, shrimp salad, shrimp and potatoes, shrimp burger, shrimp sandwich. That- that's about it. So after presenting us with well known knowledge (and repeating it many times) i feel compelled to bring us back to the subject matter at hand. Do you have any actual argument to present that adds some compelling ideas about Tkinters worth, or non worth? From jeanfrancois.leberre at gmail.com Tue Jan 25 01:06:30 2011 From: jeanfrancois.leberre at gmail.com (Jean-Francois) Date: Mon, 24 Jan 2011 22:06:30 -0800 (PST) Subject: New instance of a class : not reset? References: Message-ID: Great thank you From jason.swails at gmail.com Tue Jan 25 01:18:14 2011 From: jason.swails at gmail.com (Jason Swails) Date: Tue, 25 Jan 2011 01:18:14 -0500 Subject: WxPython versus Tkinter. In-Reply-To: <3cf33238-dff6-487d-be19-e3fd0b020163@j1g2000vbl.googlegroups.com> References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <3a96fee1-995f-49f7-a967-f125cc3f1cdc@v26g2000yqf.googlegroups.com> <023e19ed-69d1-4155-a114-0d00c227b8f6@u18g2000prh.googlegroups.com> <06dd3a10-03a4-4d43-a10e-cadf5105a7c4@t23g2000vby.googlegroups.com> <34a0ffa4-1fa9-46eb-a53f-4338e8ffd1ed@i17g2000vbq.googlegroups.com> <3cf33238-dff6-487d-be19-e3fd0b020163@j1g2000vbl.googlegroups.com> Message-ID: On Tue, Jan 25, 2011 at 12:16 AM, rantingrick wrote: > On Jan 24, 10:51 pm, Stephen Hansen wrote: > > > No. I am saying as a matter of legal permissibility, it may be included > > in the stdlib. > > > > But, as a matter of both policy and ethical behavior, it will not > > without it being donated by the author. > > I don't think you have any idea of what you are saying because you > keep parroting off the same thing in slightly different ways. I'm > having flashbacks to Forrest Gump... > > Bubba: Anyway, like I was sayin', shrimp is the fruit of the sea. You > can barbecue it, boil it, broil it, bake it, saute it. Dey's uh, > shrimp-kabobs, shrimp creole, shrimp gumbo. Pan fried, deep fried, > stir-fried. There's pineapple shrimp, lemon shrimp, coconut shrimp, > pepper shrimp, shrimp soup, shrimp stew, shrimp salad, shrimp and > potatoes, shrimp burger, shrimp sandwich. That- that's about it. > > So after presenting us with well known knowledge (and repeating it > many times) i feel compelled to bring us back to the subject matter at > hand. Do you have any actual argument to present that adds some > compelling ideas about Tkinters worth, or non worth? > It is worth more than everything you have said on this topic to date. (At least one useful application has been written with Tkinter.) Not a single useful application has been written from a single one of your (all too many and all too often irrelevant) words so far. In just this email you managed to write 2 senseless paragraphs filled with gibberish, rambling garbage that serves literally no purpose, just to say that the previous poster deviated from topic. You have destroyed the initial meaning behind your very first post with countless misspelled, poorly constructed insults. Nobody is listening to what few points you may (but probably don't) have left. And here's the kicker: if any of your points are even close to valid and the community does decide to depart from Tkinter (mobile computing is probably the biggest argument for it), then it will be pioneered by the next sane person that suggests it and you'll still be the crazy relegated to so many people's spam box. (All of whom have contributed more to Python than the last 3 weeks of your life spent on this web of trash). While you may claim to understand computers and computing (although I'd argue you no longer see it as a tool, which it is, but rather as a religion to be wielded as so many others have in the past), they are programmed and designed by people. What is this "people" thing I'm talking about? It's ok, you wouldn't understand. Suffice it to say that nearly all projects of the magnitude you seem to be projecting requires joint collaboration and participation of these people things that have long since forgotten your point and stopped listening to you. Here's to hoping that affords you some sense of success and accomplishment, Jason P.S. I appreciated the other XKCD comic, though that one I had seen. :) > -- > http://mail.python.org/mailman/listinfo/python-list > -- Jason M. Swails Quantum Theory Project, University of Florida Ph.D. Graduate Student 352-392-4032 -------------- next part -------------- An HTML attachment was scrubbed... URL: From orasnita at gmail.com Tue Jan 25 01:28:17 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Tue, 25 Jan 2011 08:28:17 +0200 Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com><3a96fee1-995f-49f7-a967-f125cc3f1cdc@v26g2000yqf.googlegroups.com> <023e19ed-69d1-4155-a114-0d00c227b8f6@u18g2000prh.googlegroups.com> Message-ID: <9ED792CC7FD646868946501493090F96@octavian> From: "Infinity77" > As a general rule, a GUI-newbie should try all the GUI > toolkits out there and settle with the one which looks easier/nicer/ Yes it would be nice, but... does it happen that way usually? :-) Octavian From orasnita at gmail.com Tue Jan 25 01:44:54 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Tue, 25 Jan 2011 08:44:54 +0200 Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com><63eea$4d3cd2fd$4275d90a$14984@FUSE.NET><69465430-08b3-4069-99c7-72f4d3034c66@s5g2000yqm.googlegroups.com><705ad$4d3ce0fc$4275d90a$29144@FUSE.NET> <4D3DF703.7080506@tysdomain.com> Message-ID: <7986537898554D59A141CA00BCA7A44B@octavian> From: "Littlefield, Tyler" > >It would be great if the Tk/Tkinter developers would be interested in > making >this GUI lib accessible. > They're not going to do it without knowing what makes accessible > accessible, and why it needs to be so. So, rather than tell the world > about how -some- blind people want to be like sighted people (we call that > independence in my world), why not go help out? It's bad, you want a > switch, and you've already said that they're using a lib that is > unaccessible. So fix the lib, and you will have fixed tons of programs > without fixing the program. That is all I ment by finding the root of the > problem, not "everyone with readers should fix their health problems." You > take my words, blow them out of perportion and at the end of the day, you > are still sitting here complaining about the lack of accessibility, rather > than doing something about it. This is awesome. We for sure need more > complainers and less people to do what the complainers are complaining > about! The solution for accessibility doesn't need to be found because it is already found. Making Tkinter accessible won't matter if it won't be used in Python anymore. Or is there a God law that tells that only Tk-based GUIs can be included in Python? Octavian From clp2 at rebertia.com Tue Jan 25 01:55:52 2011 From: clp2 at rebertia.com (Chris Rebert) Date: Mon, 24 Jan 2011 22:55:52 -0800 Subject: Behaviour-based interface/protocol implementation? In-Reply-To: References: Message-ID: On Mon, Jan 24, 2011 at 2:13 AM, Alan Franzoni wrote: > Hello, > I'd like to have a system which lets me do certain actions if the > duck-type of a certain objects matches what I expect, i.e. I'd like to > have a formalization of what it's sometimes done through getattr() > calls: > > if getattr(myobj, "somemethod", None) is not None: > ? ?myobj.somemethod(somevalue) > > > The above approach is sometimes too naive, because a) clutters code > with many getattr calls and ifs b) I might want to check for multiple > attributes and c) only checks for the method name and not for the > method's signature. > > After looking at PyProtocols, zope.interface and python's own abc > module, I'm left with a doubt: does any behaviour-based "interface > testing" system exist for Python? > > > I mean: > all these three libraries use a register-based or inheritance-based > approach; in abc, if I want instances of a class of mine "FooClass" to > be "BarInterface" instances, I can either a) inherit from BarInterface > or b) run "BarInterface.register(FooClass)". Not true actually: Python 2.7.1 (r271:86832, Dec 5 2010, 00:12:20) [GCC 4.2.1 (Apple Inc. build 5664)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> class MyContainer(object):# no special inheritance ... def __len__(self): ... return 42 ... >>> # didn't do any registration. >>> from collections import Sized >>> issubclass(MyContainer, Sized) True >>> isinstance(MyContainer(), Sized) True Several of the other ABCs in the `collections` module (which are based on the `abc` module) work similarly. Registration and subclassing are just additional ways to indicate support for an interface. Provided the ABC is properly coded, registration/subclassing isn't mandatory. > What happens if I define my own ABC for my own purpose? There might be > builtin objects, or third party libraries, which already offer objects > that satisfy such interface, but I'd need to import such modules and > register such classes as implementing my ABC, which is suboptimal. > I'd like to do a kind of runtime-check for signatures. Of course there > couldn't be an absolute certainty of interface implementation, because > a runtime dynamic proxy method (accepting *args and **kwargs in its > signature, as an example) ?might ?just fool my signature check. > > So, my questions are: > > a) does anything like that already exist in the python ecosystem? Not precisely that I know of, no. The `abc`/`collections` system comes closest, but it does not check method signatures; it merely verifies methods' existence. You could *definitely* write something like that by combining the `abc` and `inspect` modules though: http://docs.python.org/library/inspect.html#inspect.getargspec http://docs.python.org/library/abc.html#abc.ABCMeta.__subclasshook__ > b) can anybody see any flaw either in what I'd like to do ("you > shouldn't do that because...") Duck typing partisans would question what the point of such an elaborate mechanism would be when it won't change the fact that your type errors will still occur at run-time and be of essentially the same character as if you didn't use such a mechanism in the first place. But I'm not such a partisan; not that they wouldn't have a point though. At /some/ point, you're just fighting the inherent nature of the language, which is a losing battle (unless perhaps the language is a Lisp). Cheers, Chris -- http://blog.rebertia.com From orasnita at gmail.com Tue Jan 25 02:00:10 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Tue, 25 Jan 2011 09:00:10 +0200 Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com>7c$4275d90a$44222222222222 <63eea$4d3cd2fd$4275d90a$14984@FUSE.NET><69465430-08b3-4069-99c7-72f4d3034c66@s5g2000yqm.googlegroups.com><705ad$4d3ce0fc$4275d90a$29144@FUSE.NET> <5f8c1256-f07c-43be-8307-d36991e9be24@m35g2000vbn.googlegroups.com> <4D3DFAD7.40902@tysdomain.com> Message-ID: <25327AB5A2244628B2732C061A4488BF@octavian> From: "Littlefield, Tyler" > >Because of this, many blind people try to show that they are like the > sighted, that they can do everything, that they are >independent, so they > like to > >talk about the movies they watch, they like to have touch-pad mobile > phones and so on, even though the accessibility of >those gadgets is > really low. > While I am getting off topic here, I just had to comment... > Yes, I do talk about "watching" tv. Not having working eyeballs doesn't > limit me from using a word that people with common sense can just equate > to listening to tv. And neither does not having working eyeballs limit me > from -listening- to tv, which is what I and other blind people that want > to "watch" tv do. And guess what? I can use a phone with a touch screen. > It's called an IPhone, and it's got a screen reader built in. Nifty, huh? > It just helps me in my goal to be just like sighted people, blame Apple > for making a touch screen accessible. >From your messages I was sure that you are one of those guys. :-) But can you imagine that not everyone is 20 years old and not everyone is passionate about "cool" gadgets and not everyone is motivated to test as much things as possible and look cool in their gang? Try to care more about the others and not only about yourself just because that way is more easy and effective. > I say this all because I want to make a point. I don't expect the world to > revolve around what is and isn't accessible. Nobody cares about what you expect, because it seems that you are interested only in what helps you immediately as easy as possible. Nobody should think about what is accessible or not accessible because ideally, everything should be designed to be accessible to everyone or at least to as many people as possible. > While laws do exist, if I ran around quoting the ADA (Americans with > Disabilities Act) at everyone who didn't make things accessible (whether > on the computer, at school, at a store), I'd just be wasting time. Oh, and you care more about your insignifiant time than the potential to promote the accessibility for millions of users worldwide? I don't blame you because everyone is a little selfish, some more and some less, but at least don't try to demonstrate that the selfish atitude is the one that should be folowed because it is more efective on the short term and more simple. > Rather I like to blend in, be independant and adapt things. Now, since i > am a programmer this means that I am able to do a lot more in the form of > adaptation on the computer, and this is my goal; This is a selfish atitude again. As I already said, any blind programmer can choose the right language and/or GUI lib to make an accessible app so he/she will be very happy, but what about the rest of the people? Do you think that the discrimination is something normal? > So, call me a Nazi or whatever, that's just how I feel. Ok, nazi is just another political party and there are very many people like you, so this is not a problem. But don't try to convince the others that the nazist opinions are those that should be promoted. Octavian From orasnita at gmail.com Tue Jan 25 02:19:20 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Tue, 25 Jan 2011 09:19:20 +0200 Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com> Message-ID: From: "Littlefield, Tyler" > And we already do. I haven't campaigned for changes with TKInter or spoken > to anyone about them, because I haven't downloaded a program to find out > it was > written to use TKInter, and thus unacccessible. I'm not saying that there > aren't any, just saying it's not something I have had problems with > mainstream > to need to make things accessible. If I want a program that's not > accessible, chances are I can make it accessible, or I can find a program > that does just > as much, or better yet, I can ask the developer to work with me on it. > While quoting ADA at people might provide for some education, eventually > people > are going to get tired of it and I've done nothing useful at the end of > the day. There -is- a point when it's useful, but I suppose it comes down > to who > you are. If you want to sit around and say "TKInter == horrible and bad > and evil and cruel because it doesn't work with my reader," over and over, > so be > it. If you want to scream and yell and start quoting laws at people who > just may not know that there are people with screen readers out there > (I've explained > some of this to many different people many times, in terms of what a > reader is), then that's your loss, because they more than likely are not > going to > care to work with you. Wow! I, I, I, I... is there a sentence that doesn't talk about your self interests? When I informed the Python community about Tkinter's problems and why it shouldn't be promoted I didn't do it only for my selfish interests, because for my private use I can create the programs as I want, so if I don't like WxPython I don't use WxPython, and if I don't like Tkinter I don't use Tkinter so it is not a problem if Python promotes a bad GUI from this perspective. You haven't downloaded any inaccessible program made with Tkinter, you didn't have any problems, You can create an accessible program if you can't find an accessible one, you care only to please the other for working with you and so on. But don't you care about the millions of blind people like you which are not programmers? Don't you care that most programmers don't know about accessibility and they just don't create accessible programs not because they don't want, but because they don't know about this thing? Retorical question... It is obviously that you don't care. Ok, you don't care. There are very many like you. But do you think that this is the right atitude? To not care about the others at all but only about your selfish interests because the alternative is a loss of time? Can't you see that this isn't normal? Can't you see that some people don't even believe you that you are blind but you still promote the non-accessible programs? But there could be an explanation for this too. You might look great in your gang if the other blind people you know are not able to use some programs but you are able to create your own which are accessible. You will appear really special. Octavian From bob.martin at excite.com Tue Jan 25 03:02:28 2011 From: bob.martin at excite.com (Bob Martin) Date: Tue, 25 Jan 2011 08:02:28 GMT Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> Message-ID: <8q7eckF9ilU2@mid.individual.net> in 650595 20110124 192332 Bryan wrote: >On Jan 24, 12:05=A0pm, rantingrick wrote: >> On Jan 24, 12:00=A0pm, Bryan wrote: >> >> > Accessibility, like internationalization, is something few programmers >> > spend much time thinking about. >> >> Thats another uninformed statement by you we can add to the mountains >> of useless cruft you have offered so far. Unicode IS >> internationalization and Guido thought it was SO important that >> Python3000 auto converts all strings to Unicode strings. Obviously he >> is moving us toward full Unicode only in the future (AS SHOULD ALL >> IMPLEMENTATIONS!). We need one and only one obvious way to do it. And >> Unicode is that way. > >Ok, great. You've identified one programmer who thinks about >internationalization. Not much of a compelling argument there. > >However, I think you missed my point. My point wasn't that people like >Guido don't think of these topics. It's that the people in the >trenches who use these tools don't think about these topics. How many >of your co-workers actively think about internationalization and >accessibility? I'm guessing none, but maybe you're lucking and work in >a particularly enlightened team. I've perhaps worked closely with a >few hundred programmers in my career, and very few of them thought of >these subjects. In my experience it's just not something the >programmer in the trenches thinks about. That is the point I was >trying to make. Sorry, but I have to disagree with you here. I spent my working life as a programmer with a very large multi-national IT company and all software had to be fully "internationalized" (otherwise known as NLS) or it didn't get used. Do you think the whole world speaks US English? From me+list/python at ixokai.io Tue Jan 25 03:28:59 2011 From: me+list/python at ixokai.io (Stephen Hansen) Date: Tue, 25 Jan 2011 00:28:59 -0800 Subject: WxPython versus Tkinter. In-Reply-To: <7986537898554D59A141CA00BCA7A44B@octavian> References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com><63eea$4d3cd2fd$4275d90a$14984@FUSE.NET><69465430-08b3-4069-99c7-72f4d3034c66@s5g2000yqm.googlegroups.com><705ad$4d3ce0fc$4275d90a$29144@FUSE.NET> <4D3DF703.7080506@tysdomain.com> <7986537898554D59A141CA00BCA7A44B@octavian> Message-ID: <4D3E89CB.4010400@ixokai.io> On 1/24/11 10:44 PM, Octavian Rasnita wrote: > Or is there a God law that tells that only Tk-based GUIs can be included > in Python? There is no other viable option at this time for inclusion in the standard library; that's simple fact. There are options for people to write GUI's in python that are accessible. Those options do include the requirement of installing a third-party library. That's not onerous. Removing TK from the standard library at this point can't happen (at least until a theoretical Python 4K): at least not without a 100% compatible replacement which is functionally impossible (since it would have to be compatible with TK addons, too). Adding a secondary GUI framework would have to have an incredibly compelling argument behind it: and developers pledging years of maintenance in the python stdlib tree and with the python stdlib development practices, because python-dev is overworked as it is. It would need to be based on python 3.[2|3], need extensive tests and documentation in a format compatible with python.org's documentation, and solid cross-platform capability AND it be free of segfaultness, AND the more code it is the harder it is to support its inclusion, as the maintenance burden just becomes untenable-- and it would need to be PEP-8 compliant-- and-- All of that doesn't hold for wxPython. I use wxPython in my day job. I like wxPython a lot. It belongs outside of the standard library. If someone wants to devote man-years of development time to solve all of the above to make it fit the stdlib, all power to you. So far, it seems there maybe is two people who think it may be worth their time. I'm fine with installing wxPython as a third-party library. -- Stephen Hansen ... Also: Ixokai ... Mail: me+list/python (AT) ixokai (DOT) io ... Blog: http://meh.ixokai.io/ -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 487 bytes Desc: OpenPGP digital signature URL: From me+list/python at ixokai.io Tue Jan 25 03:50:46 2011 From: me+list/python at ixokai.io (Stephen Hansen) Date: Tue, 25 Jan 2011 00:50:46 -0800 Subject: [Code Challenge] WxPython versus Tkinter. In-Reply-To: <5199876F801C41E08F3E4969745F3E47@teddy> References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <4D3DB2F9.3090303@stoneleaf.us> <5199876F801C41E08F3E4969745F3E47@teddy> Message-ID: <4D3E8EE6.7020601@ixokai.io> On 1/24/11 11:58 AM, Octavian Rasnita wrote: >> From: "Ethan Furman" >> Please do not repost rr's crap in its entirety, or you'll find yourself >> added to many killfiles -- just like he is. > I am not posting anyone's crap. I just informed why Tkinter is bad. > And I also don't say that WxPython is ideal, but just that it has some very important features that Tk doesn't offer. Belatedly: The complaint was not that you had something to say in reply, but that as you replied, you quoted the entire original post. Netiquette holds that you should edit out your replies to include only those things / statements you're actually responding to. By just blanket replying and including the whole rant, you are posting that whole rant. Needlessly, as its already been said. If you cut it down and only include the points that you're responding to, you include the specific context needed to understand your statements, while minimizing the need for people to parse through noise. -- Stephen Hansen ... Also: Ixokai ... Mail: me+list/python (AT) ixokai (DOT) io ... Blog: http://meh.ixokai.io/ -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 487 bytes Desc: OpenPGP digital signature URL: From list at qtrac.plus.com Tue Jan 25 03:56:03 2011 From: list at qtrac.plus.com (Mark Summerfield) Date: Tue, 25 Jan 2011 00:56:03 -0800 (PST) Subject: Which is the best book to learn python References: <188c0a9f-4e93-4fae-b3f9-e7c84f8030fd@v31g2000pri.googlegroups.com> Message-ID: On Jan 24, 5:09?pm, santosh hs wrote: > Hi All, > i am beginner to python please tell me which is the best available > reference for beginner to start from novice If you want to learn Python 3 and have some prior programming experience (in any modern procedural or object oriented language), you might find "Programming in Python 3" (http://www.qtrac.eu/py3book.html) to be a good choice. (I'm biased though since I wrote it;-) From nospam at example.com Tue Jan 25 04:24:02 2011 From: nospam at example.com (Adam) Date: Tue, 25 Jan 2011 22:24:02 +1300 Subject: which scipy binary for Win32 Message-ID: Am looking at http://sourceforge.net/projects/scipy/files/scipy/0.8.0/ and I wonder which is the binary to install on WinXP ? As pointed to by this page, http://www.scipy.org/Download All I can see on that sourceforge page are the huge python2.6 and python2.7 Powerpacks, at 43megs or so each. The scipy-0.8.0.zip seems to require compilation. FYI: I'm installing Python 2.7, so have uninstalled all Python2.5 and Python2.6, including older numpy, scipy and matplotlib. Presently, prior to installation, I have; python-2.7.1.msi (15.628 meg) numpy-1.5.1-win32-superpack-python2.7.exe (5.354 meg) matplotlib-1.0.1.win32-py2.7.exe (8.105 meg) Does the scipy 2.7 Powerpack include numpy anyway ? Any recommendations or pointers appreciated. Thanks. From dave.hirschfeld at gmail.com Tue Jan 25 04:34:58 2011 From: dave.hirschfeld at gmail.com (Dave Hirschfeld) Date: Tue, 25 Jan 2011 09:34:58 +0000 (UTC) Subject: which scipy binary for Win32 References: Message-ID: Adam example.com> writes: > > Am looking at > http://sourceforge.net/projects/scipy/files/scipy/0.8.0/ > and I wonder which is the binary to install on WinXP ? > As pointed to by this page, http://www.scipy.org/Download > > All I can see on that sourceforge page are the huge > python2.6 and python2.7 Powerpacks, at 43megs or so > each. The scipy-0.8.0.zip seems to require compilation. > > > Any recommendations or pointers appreciated. Thanks. > > I'd say the easiest thing to do would be to get one of the superpack binaries. I would probably go for the 9.0rc (http://sourceforge.net/projects/scipy/files/scipy/0.9.0rc1/) as it will likely have fewer bugs that 8.0 and will make your code more future-proof in a fast changing world. That said, not everyone likes living on the bleeding edge... AFAIK the superpack binaries don't include numpy but are so big because they contain several versions of scipy depending on whether your cpu supports SSE1/SSE2 or not at all. The correct version will be detected and installed automatically. HTH, Dave From geoff.bache at gmail.com Tue Jan 25 05:25:53 2011 From: geoff.bache at gmail.com (Geoff Bache) Date: Tue, 25 Jan 2011 02:25:53 -0800 (PST) Subject: Finding the right Python executable on Windows Message-ID: <38326da6-8b30-4f88-b232-acdcd33b7d61@o14g2000yqe.googlegroups.com> Hi all, I have a Python process on Windows and would like to start a Python subprocess using the same interpreter. I wonder how to go about this? First, I tried the obvious subprocess.Popen([ sys.executable, "subproc.py", ... ]) but that fails, because my process has a "native launcher", (i.e. C: \path\mylauncher.exe, which is just a wrapper around the Python program) and hence sys.executable returns this path instead of the interpreter location. It isn't appropriate to use the launcher for the subprocess. I also tried using sys.exec_prefix but there didn't seem to be any standard location for the interpreter under this directory in any case. I feel certain there must be some way to do this as it seems a rather basic thing somehow, can anyone give me a hint? Regards, Geoff Bache From bryan.oakley at gmail.com Tue Jan 25 06:50:33 2011 From: bryan.oakley at gmail.com (Bryan) Date: Tue, 25 Jan 2011 03:50:33 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <8q7eckF9ilU2@mid.individual.net> Message-ID: On Jan 25, 2:02?am, Bob Martin wrote: > in 650595 20110124 192332 Bryan wrote: > > > > > > >On Jan 24, 12:05=A0pm, rantingrick wrote: > >> On Jan 24, 12:00=A0pm, Bryan wrote: > > >> > Accessibility, like internationalization, is something few programmers > >> > spend much time thinking about. > > >> Thats another uninformed statement by you we can add to the mountains > >> of useless cruft you have offered so far. Unicode IS > >> internationalization and Guido thought it was SO important that > >> Python3000 auto converts all strings to Unicode strings. Obviously he > >> is moving us toward full Unicode only in the future (AS SHOULD ALL > >> IMPLEMENTATIONS!). We need one and only one obvious way to do it. And > >> Unicode is that way. > > >Ok, great. You've identified one programmer who thinks about > >internationalization. Not much of a compelling argument there. > > >However, I think you missed my point. My point wasn't that people like > >Guido don't think of these topics. It's that the people in the > >trenches who use these tools don't think about these topics. How many > >of your co-workers actively think about internationalization and > >accessibility? I'm guessing none, but maybe you're lucking and work in > >a particularly enlightened team. I've perhaps worked closely with a > >few hundred programmers in my career, and very few of them thought of > >these subjects. In my experience it's just not something the > >programmer in the trenches thinks about. That is the point I was > >trying to make. > > Sorry, but I have to disagree with you here. ?I spent my working life as a programmer > with a very large multi-national IT company and all software had to be fully > "internationalized" (otherwise known as NLS) or it didn't get used. ? > Do you think the whole world speaks US English? No, absolutely not. I don't see how you go from "I don't think all developers think about i18n" to "I think everyone speaks english". Most very large companies think about this a lot. Most hugely successful software is probably internationalized. Together those two groups make up a tiny fraction of all software. Think about all the free software you use -- how much of it is internationalized and optimized for accessibility? I bet not much. I wish I could say more than half of all software is internationalized but I just don't believe that to be true based on my own personal observation. I definitely agree that many companies, both large and small, do the right thing here. From my experience though, many != most. I hope I'm wrong though, because that means the we're all headed in the right direction. From bob.martin at excite.com Tue Jan 25 07:03:30 2011 From: bob.martin at excite.com (Bob Martin) Date: Tue, 25 Jan 2011 12:03:30 GMT Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> Message-ID: <8q7sgiF5tpU1@mid.individual.net> in 650672 20110125 115033 Bryan wrote: >On Jan 25, 2:02=A0am, Bob Martin wrote: >> in 650595 20110124 192332 Bryan wrote: >> >> >> >> >> >> >On Jan 24, 12:05=3DA0pm, rantingrick wrote: >> >> On Jan 24, 12:00=3DA0pm, Bryan wrote: >> >> >> > Accessibility, like internationalization, is something few programme= >rs >> >> > spend much time thinking about. >> >> >> Thats another uninformed statement by you we can add to the mountains >> >> of useless cruft you have offered so far. Unicode IS >> >> internationalization and Guido thought it was SO important that >> >> Python3000 auto converts all strings to Unicode strings. Obviously he >> >> is moving us toward full Unicode only in the future (AS SHOULD ALL >> >> IMPLEMENTATIONS!). We need one and only one obvious way to do it. And >> >> Unicode is that way. >> >> >Ok, great. You've identified one programmer who thinks about >> >internationalization. Not much of a compelling argument there. >> >> >However, I think you missed my point. My point wasn't that people like >> >Guido don't think of these topics. It's that the people in the >> >trenches who use these tools don't think about these topics. How many >> >of your co-workers actively think about internationalization and >> >accessibility? I'm guessing none, but maybe you're lucking and work in >> >a particularly enlightened team. I've perhaps worked closely with a >> >few hundred programmers in my career, and very few of them thought of >> >these subjects. In my experience it's just not something the >> >programmer in the trenches thinks about. That is the point I was >> >trying to make. >> >> Sorry, but I have to disagree with you here. =A0I spent my working life a= >s a programmer >> with a very large multi-national IT company and all software had to be fu= >lly >> "internationalized" (otherwise known as NLS) or it didn't get used. =A0 >> Do you think the whole world speaks US English? > >No, absolutely not. I don't see how you go from "I don't think all >developers think about i18n" to "I think everyone speaks english". I said "US English", not just English, and you didn't say "I don't think all developers think about i18n", you said "I'm guessing none". Big difference. I think your attitude to this is US-only. > >Most very large companies think about this a lot. Most hugely >successful software is probably internationalized. Together those two >groups make up a tiny fraction of all software. Think about all the >free software you use -- how much of it is internationalized and >optimized for accessibility? I bet not much. I wish I could say more >than half of all software is internationalized but I just don't >believe that to be true based on my own personal observation. "I bet not much" - there you go again ;-) You'll find that nearly all software used in Europe (and most other parts) is internationalized or it wouldn't stand a chance. > >I definitely agree that many companies, both large and small, do the >right thing here. From my experience though, many !=3D most. I hope I'm >wrong though, because that means the we're all headed in the right >direction. From python at bdurham.com Tue Jan 25 08:17:14 2011 From: python at bdurham.com (python at bdurham.com) Date: Tue, 25 Jan 2011 08:17:14 -0500 Subject: WxPython versus Tkinter. In-Reply-To: References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com><63eea$4d3cd2fd$4275d90a$14984@FUSE.NET><69465430-08b3-4069-99c7-72f4d3034c66@s5g2000yqm.googlegroups.com><705ad$4d3ce0fc$4275d90a$29144@FUSE.NET> Message-ID: <1295961434.16173.1417116997@webmail.messagingengine.com> Mark, > From my queries to some of the Tcl/Tk folks, it seems that while the knowledge and expertise is not present in the core developer community, they would be more than happy to help people who do have some knowledge in this area so that Tk could be made to be more accessible. Some ideas here: Linux: Linux users can use the free and small Tka11y library from the site below. To use this library, one replaces "import Tkinter" with "import Tka11y" - couldn't be easier! http://tkinter.unpythonic.net/wiki/Tka11y Mac OS X: Quoting Arndt Roger Schneider from this list: "I think Tk-aqua (also 8.6) should work out-of-the-box with brail-lines, text-to-speech and such; the older carbon built however won't." I'm not sure what is involved in using an independent version of Tkinter that's newer than the build of Tkinter that ships with the standard library? Windows: While there appears(?) to be no built-in accessability for Windows versions of Tkinter I've seen Windows Tkinter applications that have used Windows native TTS functionality to provide a limited form of accessability for users with poor vision. > And if/when this does get done for Tk, I promise at least to make sure that the tutorial at http:///www.tkdocs.com covers this topic I really enjoyed your tkdocs.com site!! Based on the new ttk functionality you covered on your site, my company actually began moving GUI projects from wxPython back to Tkinter. How's that for an odd trend?! :) Malcolm From ethan at stoneleaf.us Tue Jan 25 08:57:03 2011 From: ethan at stoneleaf.us (Ethan Furman) Date: Tue, 25 Jan 2011 05:57:03 -0800 Subject: WxPython versus Tkinter. In-Reply-To: References: <4D3E4377.3060807@tysdomain.com> Message-ID: <4D3ED6AF.7020601@stoneleaf.us> -plonk- From tyler at tysdomain.com Tue Jan 25 09:11:10 2011 From: tyler at tysdomain.com (Littlefield, Tyler) Date: Tue, 25 Jan 2011 07:11:10 -0700 Subject: WxPython versus Tkinter. In-Reply-To: References: <4D3E4377.3060807@tysdomain.com> Message-ID: <4D3ED9FE.1070304@tysdomain.com> >Wow! I, I, I, I... is there a sentence that doesn't talk about your self interests? It is clear you have been taking lessons from RR; the word I does not convey self interest, in fact, it is the best word suited to speaking of oppinions (which is all that these are), in the first person. Lets move on, shall we? >You haven't downloaded any inaccessible program made with Tkinter, you didn't have any problems, You can create an accessible program if you can't find >an accessible one, you care only to please the other for working with you and so on. No. I said, I can find a program that is accessible, if I find one that isn't. Totally different from making one, and any user at all has said power. Granted, there are conditions where this doesn't work, but my idea of -fixing- TKInter would solve a lot of problems. >Don't you care that most programmers don't know about accessibility and they just don't create accessible programs not because they don't want, but because >they don't know about this thing? Of course I do. Non accessibility hurts you, as much as me, as much as anyone else when I have to take time away to try to make a program accessible. But, here is the thing; I have suggested work on TKInter to make such programs accessible, and I am perfectly willing to participate, as much as time allows, in such work. You are trying to make me come across as some evil cruel person because I don't submit to "hit them over the head with the hammer that is the ADA and force compliance," but rather I want to work with someone. At the end of the day, you lose, I win in general. People have made comments about the fact that all you did was parrot the evilness of TKInter to many threads, and now you've made comments on laws in existance that will help us. If you will note, no one even blinked at said laws. Now, the idea of fixing the problem (and not just switching libraries out of the STDLib, because as Ixokai already pointed out in another post, that won't happen), will get us much farther; whether or not Python, or anything else uses TKInter, it will be accessible, with some work put into talking to the community and I'll probably jump in the trenches myself and hammer out some code. >Retorical question... It is obviously that you don't care. Nope. I, as a blind person obviously don't care. Which is why I've spent so much time trying to push the idea of fixing TKInter. what a horrible horrible person I am. >Ok, you don't care. There are very many like you. But do you think that this is the right atitude? To not care about the >others at all but only about your selfish interests because the alternative is a loss of time? A loss of time? Where. I am not a proponent of forcing a lib into the STDLib while said library currently has problems (RR's segfaults, I'm "looking" at you). I know and accept the fact that Python is not going to become unstable with a library, in the hopes that some day people will start using wx since it's just there and voila, everything will be peaches and cream for us screen-reader using folks. >Can't you see that this isn't normal? Can't you see that some people don't even believe you that you are blind but you >still promote the non-accessible programs? RR's non-belief of me being blind or otherwise was to help his own argument, not because I'm promoting anything. >But there could be an explanation for this too. You might look great in your gang if the other blind people you know are >not able to use some programs but you are able to create your own which are accessible. You will appear really special. Yep. I'm talking about fixing a library to be more accessible so I can look great in my "gang" of sighted people I try so hard to blend in with, by daring to use such words as "watch." You mentioned the millions of people that I may help by quoting accessibility laws at, and here I say, you over estimate your self importance. If I went into my school and started yelling about the ADA, I would possibly get somewhere, but they would end up doing the bear minimum in order to comply with such laws. As a result, I don't really get what I want, and someone walks away from the encounter with the idea that all the blind people are the same, which may be a problem for someone who wishes to get employed. Now, on the other hand, if I were to walk into somewhere, say "hey, this is really unaccessible, and this is how we can fix it," from my experience, 9 times out of ten it will get fixed. That other 10% is where the ADA and other such laws come in. Through this encounter, someone walks away with a lot more respect for me, and if something should come up later, I can generally go talk to them. You have this "pity me," "I don't want to be a part of the sighted community," attitude, which will get you nowhere. If you limit yourself (by not doing such things as watching tv, or using phones with touchpads), that is -your- own fault, and no one elses. I say this because I used to be the same way, and I can garentee, if you give it time and start being a lot different with people, rather than just promoting your ADA laws and hiding behind your wall you've put up to save you from having to deal with things, you will be much happier. My preaching done with, I'd like to urge everyone to put this in a bit of perspective; essentially, what I don't want is someone walking away with Octavian's attitude as a stariotype for us all. From brian.curtin at gmail.com Tue Jan 25 09:24:08 2011 From: brian.curtin at gmail.com (Brian Curtin) Date: Tue, 25 Jan 2011 08:24:08 -0600 Subject: Finding the right Python executable on Windows In-Reply-To: <38326da6-8b30-4f88-b232-acdcd33b7d61@o14g2000yqe.googlegroups.com> References: <38326da6-8b30-4f88-b232-acdcd33b7d61@o14g2000yqe.googlegroups.com> Message-ID: On Tue, Jan 25, 2011 at 04:25, Geoff Bache wrote: > Hi all, > > I have a Python process on Windows and would like to start a Python > subprocess using the same interpreter. I wonder how to go about this? > > First, I tried the obvious > > subprocess.Popen([ sys.executable, "subproc.py", ... ]) > > but that fails, because my process has a "native launcher", (i.e. C: > \path\mylauncher.exe, which is just a wrapper around the Python > program) and hence sys.executable returns this path instead of the > interpreter location. It isn't appropriate to use the launcher for the > subprocess. > > I also tried using sys.exec_prefix but there didn't seem to be any > standard location for the interpreter under this directory in any > case. > > I feel certain there must be some way to do this as it seems a rather > basic thing somehow, can anyone give me a hint? > > Regards, > Geoff Bache If sys.executable doesn't work due to this "native launcher", you could try something like this: >>> import os >>> import sys >>> full_path = None >>> for path in sys.path: ... full = os.path.join(path, "python.exe") ... if os.path.exists(full): ... full_path = full ... >>> full_path 'c:\\python31\\python.exe' -------------- next part -------------- An HTML attachment was scrubbed... URL: From cournape at gmail.com Tue Jan 25 09:33:04 2011 From: cournape at gmail.com (David Cournapeau) Date: Tue, 25 Jan 2011 23:33:04 +0900 Subject: which scipy binary for Win32 In-Reply-To: References: Message-ID: On Tue, Jan 25, 2011 at 6:24 PM, Adam wrote: > Am looking at > http://sourceforge.net/projects/scipy/files/scipy/0.8.0/ > and I wonder which is the binary to install on WinXP ? > As pointed to by this page, http://www.scipy.org/Download > > All I can see on that sourceforge page are the huge > python2.6 and python2.7 Powerpacks, at 43megs or so > each. The scipy-0.8.0.zip seems to require compilation. What make you think those are not the right ones ? The size is caused by the presence of three architectures (sse2, sse3 and no sse support) inside the binary installer. > Does the scipy 2.7 Powerpack include numpy anyway ? No, you need to install numpy first. cheers, David From mgroth86 at gmail.com Tue Jan 25 10:05:50 2011 From: mgroth86 at gmail.com (Matthew Roth) Date: Tue, 25 Jan 2011 07:05:50 -0800 (PST) Subject: trouble installing MySQLdb (cygwin) + Bonus question References: Message-ID: <501470fc-c588-47d2-954d-17d825c5191c@v17g2000prc.googlegroups.com> On Jan 25, 4:30?am, Dennis Lee Bieber wrote: > On Mon, 24 Jan 2011 14:25:09 -0800 (PST), Matthew Roth > declaimed the following in > gmane.comp.python.general: > > > > > I've explored various avenues all day to no avail. Can anyone offer a > > solution or a direction to work towards. One avenue was ignorning the > > check for posix, and having it run setup_windows, but this just brings > > in problems with _winreg(?) seeing how I have a posix version of > > python through cygwin. > > ? ? ? ? Maybe you need the development headers for MySQL? -- I do believe I have them. Perhaps I need to find the correct way to point to them. I believe it is looking for the dev headers for a linux client when I am using a client for windows via cygwin. Or perhaps I should look into installing a separate linux mysql client in cygwin. I read of a similiar problem with perl, but the documentation felt a bit dated and several steps would no longer function correctly. > > > Lastly, for the bonus question. > > Why MySQLdb why not something like this: > > -- > > import os > > cmd = 'mysql -uroot -pxxx db -e "SELECT * FROM tblxxx;"' > > os.system(cmd) > > ? ? ? ? Passing username/password to a shell command that might be parsed by > some outside process? Security leak! -- I do indeed see that. However, all my python calls will be done within my local intranet. But is this a reason to not use os module at all? fetching a dirlisting or mkdir is still a valid reason to use the os Module, correct? > > ? ? ? ? Second -- MySQL is a server model DBMS; it doesn't have to be on the > local machine. -- unfortunately, for my use it does. We do have an old centOs box here, but the mysql running on that is severely outdated and so too is the python. I have been discouraged from upgrading the former, and the latter I was told only if I could do it through yum. Making an altinstall form source seems to be discouraged. Good news is I think they have decided to upgrade our development box. > > ? ? ? ? Third -- ever heard of TRANSACTIONS? How would you handle a > transaction if every SQL statement was a totally independent process? > -- No. quite to my embarrassment I haven't. But this is not to say I have not used them. It sounds as if I have. But, you can put more than one sql statement into a cmdline. mysql = "mysql -uuser -ppass db -e \"SELECT CURTIME(); CREATE TABLE tempTBL ( freq INT, x INT, y VARCHAR(255), PRIMARY KEY(x, y); LOAD XML INFLE 'doc' INTO TABLE tempTBL ROWS IDENTIFIED BY ''; INSERT INTO freqTbl(x,y,freq) SELECT x,y,freq FROM tempTBL ON DUPLICATE KEY UPDATE freq=tempTbl.freq+freqTbl.freq; SELECT CURTIME();\" os.system(mysql) I haven't tested that, but I know it works at the command line. I do fully intend to use MySQLdb through python and conduct more of the processing and parsing in python. It will be a learning experience. I have a background in anthropology, not computer science. But I love learning all this, and love that my place of employment encourages me to learn this. Unfortunately with self-learning you can sometimes miss out on important concepts and still accomplish tasks. Thank you for your reply. > ? ? ? ? Wulfraed ? ? ? ? ? ? ? ? Dennis Lee Bieber ? ? ? ? AF6VN > ? ? ? ? wlfr... at ix.netcom.com ? ?HTTP://wlfraed.home.netcom.com/ From misnomer at gmail.com Tue Jan 25 10:13:08 2011 From: misnomer at gmail.com (Nicholas Devenish) Date: Tue, 25 Jan 2011 15:13:08 +0000 Subject: WxPython versus Tkinter. In-Reply-To: References: <4D3E4377.3060807@tysdomain.com> Message-ID: <9MB%o.14110$%64.6074@unlimited.newshosting.com> On 25/01/2011 14:11, Littlefield, Tyler wrote: > My preaching done with, I'd like to urge everyone to put this in a bit of > perspective; essentially, what I don't want is someone walking away with > Octavian's attitude as a stariotype for us all. I can't speak for everyone (I don't have that presumption), but to me, given the two data points, you are certainly coming across as more level-headed, and thus representative. Octavians posts sound more and more like rantingricks as time goes on, which is not a good thing. This entire debate is silly, anyway; wx is doing perfectly well as a separate, but easily installed library, and I can't forsee a situation where it's inclusion in the standard library would happen. Even if a python newbie does start with TK, learning a second GUI toolkit shouldn't be that much of a struggle for them. I think even more damaging to any python newcomers than choosing the 'wrong' gui toolkit would be stumbling across this thread whilst looking for a toolkit; and thinking some of the behaviour here was representative of the python (or wx) community as a whole, which couldn't be further from the truth. I know that if I had found this thread when looking around I would certainly have been put off of wx (which is the toolkit I decided on when looking around). Perhaps there is room for a balanced, adult discussion on the future of GUI toolkits in python; But I don't believe that this can happen here without substantial changes to a certain persons attitudes (or other peoples kill files). From nitinpawar432 at gmail.com Tue Jan 25 10:16:48 2011 From: nitinpawar432 at gmail.com (Nitin Pawar) Date: Tue, 25 Jan 2011 20:46:48 +0530 Subject: trouble installing MySQLdb (cygwin) + Bonus question In-Reply-To: <501470fc-c588-47d2-954d-17d825c5191c@v17g2000prc.googlegroups.com> References: <501470fc-c588-47d2-954d-17d825c5191c@v17g2000prc.googlegroups.com> Message-ID: Nothing againest mysqlDB but I had tried using it sometimes and found it little difficult to use when you left the connections open idle for sometime . I had used PySQLPool then to solve my issues. Give it a try, I would recommend it. Thanks, nitin On Tue, Jan 25, 2011 at 8:35 PM, Matthew Roth wrote: > On Jan 25, 4:30 am, Dennis Lee Bieber wrote: > > On Mon, 24 Jan 2011 14:25:09 -0800 (PST), Matthew Roth > > declaimed the following in > > gmane.comp.python.general: > > > > > > > > > I've explored various avenues all day to no avail. Can anyone offer a > > > solution or a direction to work towards. One avenue was ignorning the > > > check for posix, and having it run setup_windows, but this just brings > > > in problems with _winreg(?) seeing how I have a posix version of > > > python through cygwin. > > > > Maybe you need the development headers for MySQL? > -- > I do believe I have them. Perhaps I need to find the correct way to > point to them. > I believe it is looking for the dev headers for a linux client when I > am using a client for windows via cygwin. > > Or perhaps I should look into installing a separate linux mysql client > in cygwin. > I read of a similiar problem with perl, but the documentation felt a > bit dated and several steps would no longer function correctly. > > > > > > Lastly, for the bonus question. > > > Why MySQLdb why not something like this: > > > -- > > > import os > > > cmd = 'mysql -uroot -pxxx db -e "SELECT * FROM tblxxx;"' > > > os.system(cmd) > > > > Passing username/password to a shell command that might be parsed > by > > some outside process? Security leak! > -- > I do indeed see that. However, all my python calls will be done within > my local intranet. > But is this a reason to not use os module at all? fetching a > dirlisting or mkdir is still > a valid reason to use the os Module, correct? > > > > Second -- MySQL is a server model DBMS; it doesn't have to be on > the > > local machine. > -- > unfortunately, for my use it does. We do have an old centOs box here, > but the mysql running on that is severely outdated and so too is the > python. > I have been discouraged from upgrading the former, and the latter I > was told only if I could do it through yum. Making an altinstall form > source seems to be > discouraged. Good news is I think they have decided to upgrade our > development box. > > > > Third -- ever heard of TRANSACTIONS? How would you handle a > > transaction if every SQL statement was a totally independent process? > > -- > No. quite to my embarrassment I haven't. But this is not to say I have > not used them. It sounds as if I have. > But, you can put more than one sql statement into a cmdline. > mysql = "mysql -uuser -ppass db -e \"SELECT CURTIME(); > CREATE TABLE tempTBL ( > freq INT, > x INT, > y VARCHAR(255), > PRIMARY KEY(x, y); > > LOAD XML INFLE 'doc' > INTO TABLE tempTBL > ROWS IDENTIFIED BY ''; > > INSERT INTO freqTbl(x,y,freq) > SELECT x,y,freq FROM tempTBL > ON DUPLICATE KEY UPDATE freq=tempTbl.freq+freqTbl.freq; > > SELECT CURTIME();\" > os.system(mysql) > > I haven't tested that, but I know it works at the command line. > I do fully intend to use MySQLdb through python and conduct more of > the processing and parsing in python. It will be a learning > experience. I have a background in anthropology, not computer science. > But I love learning all this, and love that my place of employment > encourages me to learn this. Unfortunately with self-learning you can > sometimes miss out on important concepts and still accomplish tasks. > > Thank you for your reply. > > > > Wulfraed Dennis Lee Bieber AF6VN > > wlfr... at ix.netcom.com HTTP://wlfraed.home.netcom.com/ > > -- > http://mail.python.org/mailman/listinfo/python-list > -- Nitin Pawar -------------- next part -------------- An HTML attachment was scrubbed... URL: From bryan.oakley at gmail.com Tue Jan 25 10:19:01 2011 From: bryan.oakley at gmail.com (Bryan) Date: Tue, 25 Jan 2011 07:19:01 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <8q7sgiF5tpU1@mid.individual.net> Message-ID: <19891784-d6a3-41ac-a097-5902a6323bc0@o21g2000prn.googlegroups.com> On Jan 25, 6:03?am, Bob Martin wrote: > in 650672 20110125 115033 Bryan wrote: > >> Do you think the whole world speaks US English? > > >No, absolutely not. I don't see how you go from "I don't think all > >developers think about i18n" to "I think everyone speaks english". > > I said "US English", not just English, and you didn't say > "I don't think all developers think about i18n", you said "I'm guessing none". > Big difference. ?I think your attitude to this is US-only. Ah! Now I understand your comment. Yes, without realizing it I was referring only to software developers in the US not having an internationalization mindset. I should have been more clear, and obviously I was making a poor generalization. Do non-US-based developers focus a lot on accessibility too, since that's what really started this whole sub-thread? From rustompmody at gmail.com Tue Jan 25 10:29:05 2011 From: rustompmody at gmail.com (rusi) Date: Tue, 25 Jan 2011 07:29:05 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <8q7sgiF5tpU1@mid.individual.net> <19891784-d6a3-41ac-a097-5902a6323bc0@o21g2000prn.googlegroups.com> Message-ID: <0b12cdb1-45b4-41e4-9bdb-074ee669d76b@k14g2000pre.googlegroups.com> Just trying to sift the BS from the real issues Heres a list of the issues relating to GUI toolkits Look Nativity-1 (as in apps look like other apps on the OS) Nativity-2 (as in uses 'bare-metal' and not a separate interpreter) Themeing (ttk) Efficiency (extra interpreter) Cross Platform Stability (crashes on some OSes) Programmability Accessibility i18n Availability of gui builder Licence From mailing at franzoni.eu Tue Jan 25 10:32:19 2011 From: mailing at franzoni.eu (Alan Franzoni) Date: Tue, 25 Jan 2011 16:32:19 +0100 Subject: Behaviour-based interface/protocol implementation? In-Reply-To: References: Message-ID: On Tue, Jan 25, 2011 at 7:55 AM, Chris Rebert wrote: > Not true actually: > > Python 2.7.1 (r271:86832, Dec ?5 2010, 00:12:20) > [GCC 4.2.1 (Apple Inc. build 5664)] on darwin > Type "help", "copyright", "credits" or "license" for more information. >>>> class MyContainer(object):# no special inheritance > ... ? ? def __len__(self): > ... ? ? ? ? return 42 > ... >>>> # didn't do any registration. >>>> from collections import Sized >>>> issubclass(MyContainer, Sized) > True >>>> isinstance(MyContainer(), Sized) > True You're right, I forgot about subclass check. But that's really a placebo, because it statically checks the object's *class* for such method, not the actual instance: from collections import Sized class MyObj(object): pass mo = MyObj() mo.__len__ = lambda: 1 print isinstance(mo, Sized) False > Not precisely that I know of, no. The `abc`/`collections` system comes > closest, but it does not check method signatures; it merely verifies > methods' existence. It only verifies the method's existence on the class. It does nothing of what I'd like at runtime. > You could *definitely* write something like that by combining the > `abc` and `inspect` modules though: > http://docs.python.org/library/inspect.html#inspect.getargspec > http://docs.python.org/library/abc.html#abc.ABCMeta.__subclasshook__ Yes, I'm experimenting with inspect for signature matching. > Duck typing partisans would question what the point of such an > elaborate mechanism would be when it won't change the fact that your > type errors will still occur at run-time and be of essentially the > same character as if you didn't use such a mechanism in the first > place. The point is that this way I might identify ducktypes - at runtime - in a way that doesn't clutter code. getattr() blocks are simply boring. Of course the runtime exception-check approach might work as well (call the method and see whether it crashes) and I may finally pick that approach, but I'd like not to clutter my code with explicit try...except blocks. The very same approach might help. The chance for signature mismatch is of course high when using extreme runtime dynamic proxies (methods with *args, **kwargs signature), but at least I won't try faking static typing. Anything I fetch would just be runtime information. -- Alan Franzoni -- contact me at public@[mysurname].eu From bob.martin at excite.com Tue Jan 25 10:37:07 2011 From: bob.martin at excite.com (Bob Martin) Date: Tue, 25 Jan 2011 15:37:07 GMT Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <19891784-d6a3-41ac-a097-5902a6323bc0@o21g2000prn.googlegroups.com> Message-ID: <8q8913F2slU1@mid.individual.net> in 650680 20110125 151901 Bryan wrote: >On Jan 25, 6:03=A0am, Bob Martin wrote: >> in 650672 20110125 115033 Bryan wrote: >> >> Do you think the whole world speaks US English? >> >> >No, absolutely not. I don't see how you go from "I don't think all >> >developers think about i18n" to "I think everyone speaks english". >> >> I said "US English", not just English, and you didn't say >> "I don't think all developers think about i18n", you said "I'm guessing n= >one". >> Big difference. =A0I think your attitude to this is US-only. > >Ah! Now I understand your comment. Yes, without realizing it I was >referring only to software developers in the US not having an >internationalization mindset. I should have been more clear, and >obviously I was making a poor generalization. > >Do non-US-based developers focus a lot on accessibility too, since >that's what really started this whole sub-thread? I don't think so; it was never a requirement for the software I wrote, though I know I had some blind users. But NLS was a must and it has to be designed in from the start - very difficult to add it later. From funthyme at gmail.com Tue Jan 25 11:02:08 2011 From: funthyme at gmail.com (John Pinner) Date: Tue, 25 Jan 2011 08:02:08 -0800 (PST) Subject: Which is the best book to learn python References: <188c0a9f-4e93-4fae-b3f9-e7c84f8030fd@v31g2000pri.googlegroups.com> Message-ID: On Jan 25, 8:56?am, Mark Summerfield wrote: > On Jan 24, 5:09?pm, santosh hs wrote: > > > Hi All, > > i am beginner to python please tell me which is the best available > > reference for beginner to start from novice > > If you want to learn Python 3 and have some prior programming > experience (in any modern procedural or object oriented language), you > might find > "Programming in Python 3" (http://www.qtrac.eu/py3book.html) to be a > good choice. (I'm biased though since I wrote it;-) You may be biased, but you're right :-) Nice book. John -- From orasnita at gmail.com Tue Jan 25 11:16:06 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Tue, 25 Jan 2011 18:16:06 +0200 Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com> <4D3ED9FE.1070304@tysdomain.com> Message-ID: <19272564BBF2480085CE52D8304895D7@teddy> From: "Littlefield, Tyler" > >Wow! I, I, I, I... is there a sentence that doesn't talk about your > self interests? > It is clear you have been taking lessons from RR; the word I does not > convey self interest, in fact, it is the best word suited to speaking of > oppinions (which is all that these are), in the first person. Lets move > on, shall we? The opinions can also be about other people, not only about your own interests. And in that case you might start by telling what *they* like, or what *they* need, or about *they* want or other things that involves *they* and not only you. > >You haven't downloaded any inaccessible program made with Tkinter, you > didn't have any problems, You can create an accessible program if you > can't find > >an accessible one, you care only to please the other for working with > you and so on. > No. I said, I can find a program that is accessible, if I find one that > isn't. Totally different from making one, and any user at all has said > power. Granted, there are conditions where this doesn't work, but my > idea of -fixing- TKInter would solve a lot of problems. The idea has no value when it is just an idea. Tk is a very old GUI so there may be many reasons why it is not accessible yet. When it will be accessible, then we will be able to consider it useful, but until then... it is useful but not for everyone. > >Don't you care that most programmers don't know about accessibility > and they just don't create accessible programs not because they don't > want, but because > >they don't know about this thing? > Of course I do. Non accessibility hurts you, as much as me, as much as > anyone else when I have to take time away to try to make a program > accessible. But, here is the thing; I have suggested work on TKInter to > make such programs accessible, and I am perfectly willing to > participate, as much as time allows, in such work. You are trying to > make me come across as some evil cruel person because I don't submit to > "hit them over the head with the hammer that is the ADA and force > compliance," but rather I want to work with someone. At the end of the > day, you lose, I win in general. People have made comments about the > fact that all you did was parrot the evilness of TKInter to many > threads, and now you've made comments on laws in existance that will > help us. If you will note, no one even blinked at said laws. Now, the What laws are you talking about? I have told only about the discrimination. Are you talking about another law, or do you really think that the discrimination is OK from your perspective if this opinion can help you to have a good image in a potential employer's eyes, in order to have a personal benefit? > >Retorical question... It is obviously that you don't care. > Nope. I, as a blind person obviously don't care. Which is why I've spent > so much time trying to push the idea of fixing TKInter. what a horrible > horrible person I am. It is very good if you spend time to make Tkinter accessible, but until it will really be accessible, it is not accessible at all so your efforts have absolutely no value for those who try to use a program but can't do it because it is not accessible. MS and Adobe also pretend that Silverlight and Flash are accessible, but who cares about they say when I have seen that they are not really accessible? > >Ok, you don't care. There are very many like you. But do you think > that this is the right atitude? To not care about the >others at all but > only about your selfish interests because the alternative is a loss of > time? > A loss of time? Where. I am not a proponent of forcing a lib into the > STDLib while said library currently has problems (RR's segfaults, I'm > "looking" at you). I know and accept the fact that Python is not going > to become unstable with a library, in the hopes that some day people > will start using wx since it's just there and voila, everything will be > peaches and cream for us screen-reader using folks. Why do you think that WxPython won't work fine? WxPerl works very well and WxPython even has a better documentation than WxPerl. Why do you think that WxPython can't be improved? Why do you think that only Tkinter can be improved to be accessible, which mean a lot of changes, but WxPython can't be corrected to not give that segfault? > >Can't you see that this isn't normal? Can't you see that some people > don't even believe you that you are blind but you >still promote the > non-accessible programs? > RR's non-belief of me being blind or otherwise was to help his own > argument, not because I'm promoting anything. Oh yes you are promoting Tkinter just because you see that the majority of Python users prefer Tkinter, because you are interested much more on adapting to the society than helping the society to know why it needs to change. As you said, it is easier and much more effective of course. > >But there could be an explanation for this too. You might look great > in your gang if the other blind people you know are >not able to use > some programs but you are able to create your own which are accessible. > You will appear really special. > Yep. I'm talking about fixing a library to be more accessible so I can > look great in my "gang" of sighted people I try so hard to blend in > with, by daring to use such words as "watch." I'm sorry, I don't have anything against you, but I can tell you that I don't like the guys that like to appear great for just talking about something. If you want to be great, make Tkinter to be accessible and convince the Python developers to include your fork in the Python distribution. That thing would be great, not only talking about what you intend to do. Until then, there is another solution which is already available. > You mentioned the millions of people that I may help by quoting > accessibility laws at, and here I say, you over estimate your self > importance. If I went into my school and started yelling about the ADA, > I would possibly get somewhere, but they would end up doing the bear > minimum in order to comply with such laws. As a result, I don't really > get what I want, and someone walks away from the encounter with the idea > that all the blind people are the same, which may be a problem for > someone who wishes to get employed. And what do you think it is more important? To know that your atitude helped millions of blind people like you all over the world to have a much more accessible life, or only to play nice, to not disturb anyone and hope to have bigger chances to get a job? > You have this "pity me," "I don't want to be a part of the sighted > community," attitude, which will get you nowhere. I don't think that you as a blind person should have the atitude of "pitty me" as you say, because the others shouldn't make special applications for you with bigger efforts because of pitty. The other should make common applications like for anybody else that doesn't have that health problem, applications that should be accessible by default, and they should do it from the respect for you as to any other person, thinking that his/her application need to be accessible to the people, and that some of the people access it using their eyes, other people access it using their ears or hands, and so on. If the person that makes that application doesn't care about some potential users that simply can't use it because of some health problems, than that person should not be respected. It is very simple. She/he should not be respected because she/he has a wrong atitude. But in most cases the programmers create inaccessible applications not because they don't care, but because they are not informed, because Python promotes a bad GUI lib, and they start learning to use it, and finally they prefer it. Well, I think that the programmers need to be better informed, that's why I have lost so much time answering to this thread. > I'd like to urge everyone to put this in a bit of > perspective; essentially, what I don't want is someone walking away with > Octavian's attitude as a stariotype for us all. Your atitude is really one of a sclave that tries to make pleasure for those who might help you to get a job or let you integrate in a society that otherwise don't respect the disabled people which are different than them. And if somebody tries to advocate for the benefit of the majority of simple users which are not programmers but simple computer users, you don't care at all about them because you just want to show that you are exactly like the sighted people, meaning that you also want to show that you also don't care about those who are different. Nice atitude. Octavian From rantingrick at gmail.com Tue Jan 25 11:36:05 2011 From: rantingrick at gmail.com (rantingrick) Date: Tue, 25 Jan 2011 08:36:05 -0800 (PST) Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com> <9MB%o.14110$%64.6074@unlimited.newshosting.com> Message-ID: <607ba3a8-838c-46fc-be56-829c303f2544@c13g2000prc.googlegroups.com> On Jan 25, 9:13?am, Nicholas Devenish wrote: > I think even more damaging to any python newcomers than choosing the > 'wrong' gui toolkit would be stumbling across this thread whilst looking > for a toolkit; and thinking some of the behaviour here was > representative of the python (or wx) community as a whole, which > couldn't be further from the truth. I know that if I had found this > thread when looking around I would certainly have been put off of wx > (which is the toolkit I decided on when looking around). Well then that would show how shallow and jealous you are. It would also show how you have no ability to think for yourself. That you are an emotional creature who refuses to use reason and logic in your decision process. Stop jumping on the troll wagon and start thinking for yourself! From rantingrick at gmail.com Tue Jan 25 11:46:30 2011 From: rantingrick at gmail.com (rantingrick) Date: Tue, 25 Jan 2011 08:46:30 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <8q7sgiF5tpU1@mid.individual.net> <19891784-d6a3-41ac-a097-5902a6323bc0@o21g2000prn.googlegroups.com> <0b12cdb1-45b4-41e4-9bdb-074ee669d76b@k14g2000pre.googlegroups.com> Message-ID: <6172f40f-3ab5-4626-aabc-7e5a44953dcf@f20g2000prn.googlegroups.com> On Jan 25, 9:29?am, rusi wrote: > Just trying to sift the BS from the real issues > > Heres a list of the issues relating to GUI toolkits Finally someone who knows what the argument is really about! Thanks rusi! > Look There is no doubt wxPython has better look and feel. (+1 wx) > Nativity-1 (as in apps look like other apps on the OS) Again (+1 wx) > Nativity-2 (as in uses 'bare-metal' and not a separate interpreter) Well Tk uses a separate interpretor so (+1 wx) > Themeing (ttk) Yes Tk has themes now. Not sure about how useful they are and what wx offers so (+0 both) > Efficiency (extra interpreter) Well wx is by far more efficient (+1 wx) > Cross Platform Wx is cross platform but has some warts. We need to create an abstraction API to insulate the new users from segfaults and make wx a safe cross platform GUI so (+1 Tkinter) > Stability (crashes on some OSes) Wx is stable but does has some warts as is. (+1 Tkinter) > Programmability Wx needs a better API whereas Tkinter is ok (+1 Tkinter) > Accessibility Well we know Tkinter in not accessable (+1 wx) > i18n (+1 wx) > Availability of gui builder +0 both > Licence Tkinter is completely open source and wx is LGPL. Some find this to be a problem however i don't (+0 both) Tkinter: 3 wxPython: 6 From rantingrick at gmail.com Tue Jan 25 11:53:43 2011 From: rantingrick at gmail.com (rantingrick) Date: Tue, 25 Jan 2011 08:53:43 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <19891784-d6a3-41ac-a097-5902a6323bc0@o21g2000prn.googlegroups.com> <8q8913F2slU1@mid.individual.net> Message-ID: <7a6f53b6-d729-4be1-8ebe-b29b6b1c184d@21g2000prv.googlegroups.com> On Jan 25, 9:37?am, Bob Martin wrote: > I don't think so; it was never a requirement for the software I wrote, > though I know I had some blind users. ?But NLS was a must and it has > to be designed in from the start - very difficult to add it later. Thats the point i keep trying to make about accessibility. Those who are affected directly by accessibility (the users) are not in control of accessibilities inclusion. However those that are in control are twice removed from the torments of needing accessibility. What is wrong with this picture? Well specifically, if the developers refuse (or are oblivious) to include accessibility support then the users are just screwed! Plain and simple. GUI library developers have a responsibility to include support for accessibility because if they don't no one else can! From dmaziuk at bmrb.wisc.edu Tue Jan 25 12:22:05 2011 From: dmaziuk at bmrb.wisc.edu (dmaziuk) Date: Tue, 25 Jan 2011 09:22:05 -0800 (PST) Subject: [Python] how to tell if cursor is sqlite.Cursor or psycopg2.Cursor In-Reply-To: Message-ID: <5b13a8df-b1be-410d-b116-5c4f38ca287a@glegroupsg2000goo.googlegroups.com> D'oh. You're right, of course. Thank you Dima From tjreedy at udel.edu Tue Jan 25 12:48:15 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Tue, 25 Jan 2011 12:48:15 -0500 Subject: Behaviour-based interface/protocol implementation? In-Reply-To: References: Message-ID: On 1/25/2011 10:32 AM, Alan Franzoni wrote: > You're right, I forgot about subclass check. But that's really a > placebo, because it statically checks the object's *class* for such > method, That is exactly the proper check. Instance *methods* are defined on the class. > not the actual instance: Function attributes of instances are not methods. This is especially true of special methods. > from collections import Sized > > class MyObj(object): > pass > > mo = MyObj() > mo.__len__ = lambda: 1 > > > print isinstance(mo, Sized) > False This is correct! print(len(mo)) TypeError: object of type 'MyObj' has no len() -- Terry Jan Reedy From usernet at ilthio.net Tue Jan 25 13:01:14 2011 From: usernet at ilthio.net (Tim Harig) Date: Tue, 25 Jan 2011 18:01:14 +0000 (UTC) Subject: Which is the best book to learn python References: <188c0a9f-4e93-4fae-b3f9-e7c84f8030fd@v31g2000pri.googlegroups.com> Message-ID: On 2011-01-25, Mark Summerfield wrote: > On Jan 24, 5:09?pm, santosh hs wrote: >> Hi All, >> i am beginner to python please tell me which is the best available >> reference for beginner to start from novice > > If you want to learn Python 3 and have some prior programming > experience (in any modern procedural or object oriented language), you > might find > "Programming in Python 3" (http://www.qtrac.eu/py3book.html) to be a > good choice. (I'm biased though since I wrote it;-) I am usually a big fan for O'reilly books and I started learning Python from the first edition of _Learning Python_. It's not a bad book and it will get you started. I cannot speak for the latest edition which seems to contain quite a bit more then the version I read. When Python 3 was released, I decided to try relearn Python 3 from scratch rather then trying to simply figure out the differences between versions. I picked up Mr. Summerfield's book because it seemed to be the first book to cover Python 3 excusively and I was rather impressed. I would definitely recommend it to others. [OT] P.S. to Mark Summerfield. You have been hanging around in the Go Nuts mailing list. Is that any indication that you might be considering writing a book on Go? If you do, you will have at least one customer. From tjreedy at udel.edu Tue Jan 25 13:07:31 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Tue, 25 Jan 2011 13:07:31 -0500 Subject: WxPython versus Tkinter. In-Reply-To: <8q7sgiF5tpU1@mid.individual.net> References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <8q7sgiF5tpU1@mid.individual.net> Message-ID: On 1/25/2011 7:03 AM, Bob Martin wrote: > "I bet not much" - there you go again ;-) > You'll find that nearly all software used in Europe (and most other parts) > is internationalized or it wouldn't stand a chance. I suspected that is true of today's Europe, but do you have any evidence that software written in Japan, for instance, is any more internationalized than US software? I would expect the opposite since they tend to use, and still use their Japanese-only encodings with their unique writing system. -- Terry Jan Reedy From cralef at earthlink.net Tue Jan 25 13:08:34 2011 From: cralef at earthlink.net (Craig Leffel) Date: Tue, 25 Jan 2011 11:08:34 -0700 Subject: documentation / reference help References: Message-ID: Where does it return the value to? What do I need to put in the calling function so that I can use that value? I need a variable name to refer to. Shouldn't I have to define that variable someplace? "Littlefield, Tyler" wrote in message news:mailman.1103.1295811520.6505.python-list at python.org... > The return value simply returns a value to the calling function, which the > function can handle, however it wants. so: for example > def add(a, b): > return (a+b) > > That simply returns the value a+b, which you can use however you like, > like so: i=add(2,3) will assign the return value to add. > > I recommend you check out the tutorial on python.org, which explains all > of this; the documentation does not need updating, at least not in that > respect. > On 1/23/2011 11:41 AM, Scott Meup wrote: >> I'm trying tolearn Python. The documentation tells syntax, and other >> things >> about a command. But for too many commands, it doesn't tell what it >> does. >> for instance, in VB the 'return' command tells the program what line to >> execute after some event (usually an error). In Python it appears to >> return >> a value. Where does it return it to? I couldn't find anywhere on the >> Python website to find out or to ask Python to upgrade their >> documentation. >> Can somebody please recommend a source. >> >> > > > -- > > Thanks, > Ty > From tjreedy at udel.edu Tue Jan 25 13:15:19 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Tue, 25 Jan 2011 13:15:19 -0500 Subject: WxPython versus Tkinter. In-Reply-To: <0b12cdb1-45b4-41e4-9bdb-074ee669d76b@k14g2000pre.googlegroups.com> References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <8q7sgiF5tpU1@mid.individual.net> <19891784-d6a3-41ac-a097-5902a6323bc0@o21g2000prn.googlegroups.com> <0b12cdb1-45b4-41e4-9bdb-074ee669d76b@k14g2000pre.googlegroups.com> Message-ID: On 1/25/2011 10:29 AM, rusi wrote: > Just trying to sift the BS from the real issues > > Heres a list of the issues relating to GUI toolkits > > > Look > Nativity-1 (as in apps look like other apps on the OS) > Nativity-2 (as in uses 'bare-metal' and not a separate interpreter) > Themeing (ttk) > Efficiency (extra interpreter) > Cross Platform > Stability (crashes on some OSes) > Programmability > Accessibility > i18n > Availability of gui builder > Licence Good as far as it goes, but this list leaves out several requirements (already posted by me, Steve Hansen, and others) for a Python 3 new stdlib module. It does not matter for the stdlib if wxpython is 3 times as good as tkinter, by some measure, as long as it is ineligible. -- Terry Jan Reedy From benjamin.kaplan at case.edu Tue Jan 25 13:32:48 2011 From: benjamin.kaplan at case.edu (Benjamin Kaplan) Date: Tue, 25 Jan 2011 13:32:48 -0500 Subject: documentation / reference help Message-ID: On Jan 25, 2011 1:19 PM, "Craig Leffel" wrote: > > Where does it return the value to? > > What do I need to put in the calling function so that I can use that value? > I need a variable name to refer to. Shouldn't I have to define that variable > someplace? > Python functions are like mathematical functions. The function call itself evaluates to a value (whatever is returned) which can be stored to a variable. y = f(x) You can even use the result without directly storing it in a variable. print f(g(x)) > "Littlefield, Tyler" wrote in message > news:mailman.1103.1295811520.6505.python-list at python.org... > > The return value simply returns a value to the calling function, which the > > function can handle, however it wants. so: for example > > def add(a, b): > > return (a+b) > > > > That simply returns the value a+b, which you can use however you like, > > like so: i=add(2,3) will assign the return value to add. > > > > I recommend you check out the tutorial on python.org, which explains all > > of this; the documentation does not need updating, at least not in that > > respect. > > On 1/23/2011 11:41 AM, Scott Meup wrote: > >> I'm trying tolearn Python. The documentation tells syntax, and other > >> things > >> about a command. But for too many commands, it doesn't tell what it > >> does. > >> for instance, in VB the 'return' command tells the program what line to > >> execute after some event (usually an error). In Python it appears to > >> return > >> a value. Where does it return it to? I couldn't find anywhere on the > >> Python website to find out or to ask Python to upgrade their > >> documentation. > >> Can somebody please recommend a source. > >> > >> > > > > > > -- > > > > Thanks, > > Ty > > > > > > -- > http://mail.python.org/mailman/listinfo/python-list -------------- next part -------------- An HTML attachment was scrubbed... URL: From smokefloat at gmail.com Tue Jan 25 13:38:33 2011 From: smokefloat at gmail.com (David Hutto) Date: Tue, 25 Jan 2011 10:38:33 -0800 (PST) Subject: Which is the best book to learn python References: <188c0a9f-4e93-4fae-b3f9-e7c84f8030fd@v31g2000pri.googlegroups.com> Message-ID: <504ce080-c77b-4b69-a19e-75eca4c4e099@v31g2000pri.googlegroups.com> Building Skills In Python has been a great learning tool, and reference(I don't exactly learn linearly): homepage.mac.com/s_lott/books/python.html From cmpython at gmail.com Tue Jan 25 14:16:05 2011 From: cmpython at gmail.com (CM) Date: Tue, 25 Jan 2011 11:16:05 -0800 (PST) Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com> <9MB%o.14110$%64.6074@unlimited.newshosting.com> Message-ID: On Jan 25, 10:13?am, Nicholas Devenish wrote: Nicholas, > I think even more damaging to any python newcomers than choosing the > 'wrong' gui toolkit would be stumbling across this thread whilst looking > for a toolkit; and thinking some of the behaviour here was > representative of the python (or wx) community as a whole, which > couldn't be further from the truth. I know that if I had found this > thread when looking around I would certainly have been put off of wx > (which is the toolkit I decided on when looking around). I don't know--you sound too reasonable to extrapolate from this goofy thread to a huge toolkit project that has been around for years and is used in project such as Audacity (that's the wxWidgets version, but close enough). But yes, it almost at times seemed like--from what I could manage to read--this thread was a "psy-ops" (psychological operations) trick to turn off wxPython adopters by associating it with juvenile nonsense, and yes, on a quick scan it could turn people off. Which would be a shame, because, as you, Andrea, and others have noted, wxPython is a nice toolkit. For those interested, download it and make sure to download the Demo, that shows what can be done with it. (Very early in this discussion the screenshots on the website came up; they are horrifically out of date and wxPython deserves better and looks great on, say, Windows 7 or Ubuntu....well, it looks native, and that's the point). > Perhaps there is room for a balanced, adult discussion on the future of > GUI toolkits in python; But I don't believe that this can happen here > without substantial changes to a certain persons attitudes (or other > peoples kill files). It would be more likely that wxPython would be in the stdlib than those attitudes will change. :D But what I would enjoy is a discussion about GUIs in terms of "develop once, deploy many". For example, pyjamas, since I think being able to develop one GUI that works as desktop or web-based is kind of exciting. Unfortunately, it seems it is far off from anything easily usable at this point. Part of that might be it doesn't have a big enough community of developers yet. It's also just really difficult, I'm sure. Another interesting issue in this is mobile phone app development. It is frustrating to devote a lot of time to learning a desktop widget toolkit and Python and while that is occurring the culture moves more and more toward app use in which that is not too applicable. Some of that cannot be helped if Apple, e.g., restricts what can be used on their phones. I guess for Android one can already develop with PyQt and it will run on desktop or phone? From orasnita at gmail.com Tue Jan 25 14:24:55 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Tue, 25 Jan 2011 21:24:55 +0200 Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com> <9MB%o.14110$%64.6074@unlimited.newshosting.com> Message-ID: <4A48EDF6D7634F2E994661A457451E87@teddy> From: "Nicholas Devenish" > I can't speak for everyone (I don't have that presumption), but to me, > given the two data points, you are certainly coming across as more > level-headed, and thus representative. Octavians posts sound more and > more like rantingricks as time goes on, which is not a good thing. Can you tell why? Because you probably don't care about those who can't use the programs made with Tkinter or because you consider the discrimination something normal, right? And you said that it is not a good thing. Good thing for whom? For the blind people Tkinter is the worst thing possible. Or do you want to say that it is not true? > This entire debate is silly, anyway; wx is doing perfectly well as a > separate, but easily installed library, and I can't forsee a situation > where it's inclusion in the standard library would happen. Even if a > python newbie does start with TK, learning a second GUI toolkit > shouldn't be that much of a struggle for them. No, it shouldn't be, but I see that you don't understand after this long thread why Tkinter should be avoided. WxPython shouldn't be the second choice. WxPython shouldn't be the first choice or the single choice. The single choices should be always only those who don't introduce discrimination. Don't you agree with this? Well, for the moment only WxPython doesn't include discrimination if we are talking about portable GUIs. Please tell me if I wasn't clear enough or what you don't agree with. > I think even more damaging to any python newcomers than choosing the > 'wrong' gui toolkit would be stumbling across this thread whilst looking > for a toolkit; and thinking some of the behaviour here was > representative of the python (or wx) community as a whole, which > couldn't be further from the truth. I know that if I had found this > thread when looking around I would certainly have been put off of wx > (which is the toolkit I decided on when looking around). Why? You are not clear at all. What damage generates this thread to WxPython? > Perhaps there is room for a balanced, adult discussion on the future of > GUI toolkits in python; But I don't believe that this can happen here > without substantial changes to a certain persons attitudes (or other > peoples kill files). The atitude that needs to be changed is the one that considerates the majority more important than a minority which is a minority because of health problems, a minority that is a minority without its will. In my country there is a law that says that the society should adapt to the people with disabilities (and not viceversa), and that law is probably copied from the legislation of other european countries. That law is a very good one, but the problem is that nobody cares to respect it, because most of the people have Tyler's opinion. Yes, I know, that's life, which is not right, that's faith, bla bla, but it doesn't mean that my atitude need to be changed. The atitude that needs to be changed is the one that considers the discrimination something normal and the one that considers that the disabled people should adapt to the society even though most of them can't do that because of their health problems. Octavian From rantingrick at gmail.com Tue Jan 25 14:25:06 2011 From: rantingrick at gmail.com (rantingrick) Date: Tue, 25 Jan 2011 11:25:06 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <8q7sgiF5tpU1@mid.individual.net> <19891784-d6a3-41ac-a097-5902a6323bc0@o21g2000prn.googlegroups.com> <0b12cdb1-45b4-41e4-9bdb-074ee669d76b@k14g2000pre.googlegroups.com> Message-ID: <7bb56aba-0f96-4b7e-a78d-3398003a0e38@c39g2000yqi.googlegroups.com> On Jan 25, 12:15?pm, Terry Reedy wrote: > On 1/25/2011 10:29 AM, rusi wrote: > > > > > > > > > > > Just trying to sift the BS from the real issues > > > Heres a list of the issues relating to GUI toolkits > > > Look > > Nativity-1 (as in apps look like other apps on the OS) > > Nativity-2 (as in uses 'bare-metal' and not a separate interpreter) > > Themeing (ttk) > > Efficiency (extra interpreter) > > Cross Platform > > Stability (crashes on some OSes) > > Programmability > > Accessibility > > i18n > > Availability of gui builder > > Licence > > It does not matter for the stdlib if wxpython is 3 times > as good as tkinter, by some measure, as long as it is ineligible. Terry, i think rusi was just posting a general list of some likable attributes of a 21st century GUI library. No were did he mention the words "wx" or "python". ------------------ The Sad Reality ------------------ Sadly the fact is that the "elite" have already made a decision. And they don't care how bad "Tkinter" is for Python's stdlib or how good "GUI library X" is for Python's stdlib. They do not want to make a change. They are in bed with TclTk. They have lost all vision. This is the reality. --------------------------- What can we do about it? --------------------------- However, like all totalitarian regimes, when the peasants start demanding equality and then storm the castle... then and only then will the closed minded and selfish elite listen! So we need to make noise, a lot of noise. And we need to be persistent. We need to demand equality through accessibility. We need to demand feature rich libraries that do not cripple us like Tkinter. We need to demand that Pythons community re-establish a vision for the future. A vision that is representative of ALL the people -- and not a few fat cats at the top. -------------------------------- From Dictatorship to Democracy -------------------------------- I have time and time again given examples of how python-dev can get a real idea of what the wider community is thinking. One of these ideas would be to send out a "Tkinter Removal Warning" that would be displayed when the Python installer was run and every time Tkinter is imported. The warning would show a website were people could vote to keep Tkinter in the stdlib. This is the only way we can truly understand what our community members are thinking about Tkinter. Anything else is purely speculation. ----------------------------------------------- The silence of the peasants, and an awakening ----------------------------------------------- Many folks out there share our views that Tkinter is a weight around Python's neck, however they are too fearful to speak out for fear of excommunication (the kill file!). However i must tell all of you that just as other nations have risen against their own brutal governments and survived, so to shall you IF you combine your voices as one. There is power in numbers that no "elite theocracy" can deny. United we can re-establish the original dream that build Python. Guido forged the path and we must not let his work be in vain. But now the community has been so overrun with trolls, naysayers, and negative mind sets that infect any semblance of civility and remove good judgment from our coffers. We are doomed unless we re-awake the dream. From orasnita at gmail.com Tue Jan 25 14:32:15 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Tue, 25 Jan 2011 21:32:15 +0200 Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com><8q7sgiF5tpU1@mid.individual.net> <19891784-d6a3-41ac-a097-5902a6323bc0@o21g2000prn.googlegroups.com> Message-ID: From: "Bryan" Do non-US-based developers focus a lot on accessibility too, since that's what really started this whole sub-thread? Almost nobody focuses on accessibility, and nobody should focus on accessibility. If you target a program for your national population and your national population speak a single language, then no, you won't need to use I18N. If you create a graphic design application so you evidently target it to the sighted people, it is obviously that you won't need to make an accessible application. But if you make a program that could be used by the whole world then you should use I18N and that program should also be accessible to everyone, not only sighted, or only English-speakers, because otherwise that application creates discrimination. Usually I18N is offered using gettext so the users that want that application translated in their language can do the translation themselves, but if the application uses Tkinter, those who need a screen reader cannot do absolutely anything to make it accessible. And Tyler's idea that if he finds an inaccessible application he can try to makes its own is not a valid idea, because not all the millions of users are programmers. Octavian From debatem1 at gmail.com Tue Jan 25 14:33:52 2011 From: debatem1 at gmail.com (geremy condra) Date: Tue, 25 Jan 2011 11:33:52 -0800 Subject: WxPython versus Tkinter. In-Reply-To: References: <4D3E4377.3060807@tysdomain.com> <9MB%o.14110$%64.6074@unlimited.newshosting.com> Message-ID: On Tue, Jan 25, 2011 at 11:16 AM, CM wrote: > Another interesting issue in this is mobile phone app development. ?It > is frustrating to devote a lot of time to learning a desktop widget > toolkit and Python and while that is occurring the culture moves more > and more toward app use in which that is not too applicable. ?Some of > that cannot be helped if Apple, e.g., restricts what can be used on > their phones. ?I guess for Android one can already develop with PyQt > and it will run on desktop or phone? No. It's very difficult to do real development on android unless you're using Java, and even if that weren't the case Qt itself would require an enormous effort to port. Perhaps you meant MeeGo? Geremy Condra From orasnita at gmail.com Tue Jan 25 14:35:31 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Tue, 25 Jan 2011 21:35:31 +0200 Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com><8q7sgiF5tpU1@mid.individual.net><19891784-d6a3-41ac-a097-5902a6323bc0@o21g2000prn.googlegroups.com><0b12cdb1-45b4-41e4-9bdb-074ee669d76b@k14g2000pre.googlegroups.com> <6172f40f-3ab5-4626-aabc-7e5a44953dcf@f20g2000prn.googlegroups.com> Message-ID: From: "rantingrick" > Availability of gui builder +0 both I thought that there are a few GUI builders for Wx. Isn't this true? Octavian From orasnita at gmail.com Tue Jan 25 14:38:08 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Tue, 25 Jan 2011 21:38:08 +0200 Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <8q7sgiF5tpU1@mid.individual.net> <19891784-d6a3-41ac-a097-5902a6323bc0@o21g2000prn.googlegroups.com><0b12cdb1-45b4-41e4-9bdb-074ee669d76b@k14g2000pre.googlegroups.com> Message-ID: <048FB74272D440A0915ABC7D76AE262B@teddy> From: "Terry Reedy" > Good as far as it goes, but this list leaves out several requirements > (already posted by me, Steve Hansen, and others) for a Python 3 new > stdlib module. It does not matter for the stdlib if wxpython is 3 times > as good as tkinter, by some measure, as long as it is ineligible. Why is WxPython ineligible? I ask because I want to be sure I understand. I remember just that reason that there are no enough maintainers in order to be a good default GUI for Python, which is a real problem if it is true. Octavian From cmpython at gmail.com Tue Jan 25 14:40:05 2011 From: cmpython at gmail.com (CM) Date: Tue, 25 Jan 2011 11:40:05 -0800 (PST) Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com> <9MB%o.14110$%64.6074@unlimited.newshosting.com> Message-ID: <7948346b-6c91-4896-8d41-75a9010fc29d@x6g2000prf.googlegroups.com> On Jan 25, 2:33?pm, geremy condra wrote: > On Tue, Jan 25, 2011 at 11:16 AM, CM wrote: > > Another interesting issue in this is mobile phone app development. ?It > > is frustrating to devote a lot of time to learning a desktop widget > > toolkit and Python and while that is occurring the culture moves more > > and more toward app use in which that is not too applicable. ?Some of > > that cannot be helped if Apple, e.g., restricts what can be used on > > their phones. ?I guess for Android one can already develop with PyQt > > and it will run on desktop or phone? > > No. It's very difficult to do real development on android unless > you're using Java, and even if that weren't the case Qt itself would > require an enormous effort to port. Perhaps you meant MeeGo? I think insted of Android I should have said "Nokia phones". Is that closer? I am completely out of the mobile phones loop, so I have no sense of any of this. What is MeeGo? At this point, can Python be used for app development on any mobile phone (realistically)? Thanks. From orasnita at gmail.com Tue Jan 25 14:43:43 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Tue, 25 Jan 2011 21:43:43 +0200 Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com><19891784-d6a3-41ac-a097-5902a6323bc0@o21g2000prn.googlegroups.com> <8q8913F2slU1@mid.individual.net> Message-ID: <2B2DA9107A06420C8A9EE32CD593EE8E@teddy> From: "Bob Martin" ... >>Do non-US-based developers focus a lot on accessibility too, since >>that's what really started this whole sub-thread? > > I don't think so; it was never a requirement for the software I wrote, > though I know I had some blind users. But NLS was a must and it has > to be designed in from the start - very difficult to add it later. :-) Remembering about MSAA (MS Active Accessibility), what you said makes me think to "Active Discrimination". It seems that for comercial reasons those who need to use a screen reader are discriminated because it is not profitable to make the effort to make an accessible program. This is a valid problem and the companies can't and shouldn't be forced to offer accessibility if this causes them financial damages. That's why the prefered solutions for creating a GUI should be one which is relatively accessible out of the box, because in that case the programmers don't even need to think to accessibility, but it is offered. Octavian From orasnita at gmail.com Tue Jan 25 14:53:45 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Tue, 25 Jan 2011 21:53:45 +0200 Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <8q7sgiF5tpU1@mid.individual.net> Message-ID: <21AC916D59AC48828C7552D4BBB2129D@teddy> From: "Terry Reedy" To: Sent: Tuesday, January 25, 2011 8:07 PM Subject: Re: WxPython versus Tkinter. > On 1/25/2011 7:03 AM, Bob Martin wrote: > >> "I bet not much" - there you go again ;-) >> You'll find that nearly all software used in Europe (and most other parts) >> is internationalized or it wouldn't stand a chance. > > I suspected that is true of today's Europe, but do you have any evidence > that software written in Japan, for instance, is any more > internationalized than US software? I would expect the opposite since > they tend to use, and still use their Japanese-only encodings with their > unique writing system. Yes Terry, you are right. In the cases where the software is targetted only to japanese speakers (but I can't imagine an example) making only japanese applications is OK. But as probably most of the software could be used by those who can't read hiragana/katakana/kanji if it would offer I18N, then it is not OK. Nobody should be blamed for making a bad software. Not the americans, not the japanese and not the europeans (because in Europe there are also a lot of uni-lingual applications). The bad software which is not accessible for some people, (because the language is not accessible or because the interface is not accessible) is usually made because of commercial constraints, or because of time constraints, or simply because of lack of knowledge about these issues. The people should be very well informed, and constantly, and not only on a single thread ona single mailing list and after many years or even generations, the things will change hopefully. The ones that should be blamed are those who know about these inaccessibility problems but simply don't care. Octavian From debatem1 at gmail.com Tue Jan 25 14:56:38 2011 From: debatem1 at gmail.com (geremy condra) Date: Tue, 25 Jan 2011 11:56:38 -0800 Subject: WxPython versus Tkinter. In-Reply-To: <7948346b-6c91-4896-8d41-75a9010fc29d@x6g2000prf.googlegroups.com> References: <4D3E4377.3060807@tysdomain.com> <9MB%o.14110$%64.6074@unlimited.newshosting.com> <7948346b-6c91-4896-8d41-75a9010fc29d@x6g2000prf.googlegroups.com> Message-ID: On Tue, Jan 25, 2011 at 11:40 AM, CM wrote: > On Jan 25, 2:33?pm, geremy condra wrote: >> On Tue, Jan 25, 2011 at 11:16 AM, CM wrote: >> >?I guess for Android one can already develop with PyQt >> > and it will run on desktop or phone? >> >> No. It's very difficult to do real development on android unless >> you're using Java, and even if that weren't the case Qt itself would >> require an enormous effort to port. Perhaps you meant MeeGo? > > I think insted of Android I should have said "Nokia phones". ?Is that > closer? ?I am completely out of the mobile phones loop, so I have no > sense of any of this. ?What is MeeGo? MeeGo is Nokia's next generation mobile OS, and Symbian is its current one. > At this point, can Python be used for app development on any mobile > phone (realistically)? Python development on either Symbian or MeeGo is reasonably painless. Geremy Condra From debatem1 at gmail.com Tue Jan 25 15:01:01 2011 From: debatem1 at gmail.com (geremy condra) Date: Tue, 25 Jan 2011 12:01:01 -0800 Subject: WxPython versus Tkinter. In-Reply-To: <4A48EDF6D7634F2E994661A457451E87@teddy> References: <4D3E4377.3060807@tysdomain.com> <9MB%o.14110$%64.6074@unlimited.newshosting.com> <4A48EDF6D7634F2E994661A457451E87@teddy> Message-ID: On Tue, Jan 25, 2011 at 11:24 AM, Octavian Rasnita wrote: > Yes, I know, that's life, which is not right, that's faith, bla bla, but it doesn't mean that my atitude need to be changed. There's a difference between having an opinion and having an attitude. You have both, and it doesn't do you a lot of favors. Geremy Condra From rantingrick at gmail.com Tue Jan 25 15:05:56 2011 From: rantingrick at gmail.com (rantingrick) Date: Tue, 25 Jan 2011 12:05:56 -0800 (PST) Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com> <9MB%o.14110$%64.6074@unlimited.newshosting.com> <7948346b-6c91-4896-8d41-75a9010fc29d@x6g2000prf.googlegroups.com> Message-ID: On Jan 25, 1:40?pm, CM wrote: > At this point, can Python be used for app development on any mobile > phone (realistically)? No as long as Tkinter is in the stdlib (if your talking stdlib?) From rantingrick at gmail.com Tue Jan 25 15:09:46 2011 From: rantingrick at gmail.com (rantingrick) Date: Tue, 25 Jan 2011 12:09:46 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com><8q7sgiF5tpU1@mid.individual.net><19891784-d6a3-41ac-a097-5902a6323bc0@o21g2000prn.googlegroups.com><0b12cdb1-45b4-41e4-9bdb-074ee669d76b@k14g2000pre.googlegroups.com> <6172f40f-3ab5-4626-aabc-7e5a44953dcf@f20g2000prn.googlegroups.com> Message-ID: On Jan 25, 1:35?pm, "Octavian Rasnita" wrote: > From: "rantingrick" > > > Availability of gui builder > > +0 both > > I thought that there are a few GUI builders for Wx. Isn't this true? Oops! Yes it seems there are. I was unaware of them since i never use GUI builders. So another +1 for wxPython! Here are a few i found... http://wxglade.sourceforge.net/index.php#description http://boa-constructor.sourceforge.net/ Thanks for correcting me Octavian. From mafunk at nmsu.edu Tue Jan 25 15:13:02 2011 From: mafunk at nmsu.edu (Matt Funk) Date: Tue, 25 Jan 2011 13:13:02 -0700 Subject: numpy/matlab compatibility Message-ID: <4D3F2ECE.8070200@nmsu.edu> Hi, i am fairly new to python. I was wondering of the following is do-able in python: 1) a = rand(10,1) 2) Y = a 3) mask = Y > 100; 4) Y(mask) = 100; 5) a = a+Y Basically i am getting stuck on line 4). I was wondering if it is possible or not with python? (The above is working matlab code) thanks matt From rantingrick at gmail.com Tue Jan 25 15:15:06 2011 From: rantingrick at gmail.com (rantingrick) Date: Tue, 25 Jan 2011 12:15:06 -0800 (PST) Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com> <9MB%o.14110$%64.6074@unlimited.newshosting.com> <4A48EDF6D7634F2E994661A457451E87@teddy> Message-ID: <9684e450-36df-4036-89b8-951543b8adf5@w29g2000vba.googlegroups.com> On Jan 25, 2:01?pm, geremy condra wrote: > On Tue, Jan 25, 2011 at 11:24 AM, Octavian Rasnita wrote: > > Yes, I know, that's life, which is not right, that's faith, bla bla, but it doesn't mean that my atitude need to be changed. > > There's a difference between having an opinion and having an attitude. > You have both, and it doesn't do you a lot of favors. There is likewise a difference between reading someones words (objectively) uninfluenced by emotions or personal prejudices, or not. You understand? From mgroth86 at gmail.com Tue Jan 25 15:17:49 2011 From: mgroth86 at gmail.com (Matthew Roth) Date: Tue, 25 Jan 2011 12:17:49 -0800 (PST) Subject: trouble installing MySQLdb (cygwin) + Bonus question References: <501470fc-c588-47d2-954d-17d825c5191c@v17g2000prc.googlegroups.com> Message-ID: Thank you. I appreciate you explanation and tolerance of my ignorance. However unfortunate, this still does not solve my major issue. From emile at fenx.com Tue Jan 25 15:29:23 2011 From: emile at fenx.com (Emile van Sebille) Date: Tue, 25 Jan 2011 12:29:23 -0800 Subject: WxPython versus Tkinter. In-Reply-To: <7bb56aba-0f96-4b7e-a78d-3398003a0e38@c39g2000yqi.googlegroups.com> References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <8q7sgiF5tpU1@mid.individual.net> <19891784-d6a3-41ac-a097-5902a6323bc0@o21g2000prn.googlegroups.com> <0b12cdb1-45b4-41e4-9bdb-074ee669d76b@k14g2000pre.googlegroups.com> <7bb56aba-0f96-4b7e-a78d-3398003a0e38@c39g2000yqi.googlegroups.com> Message-ID: On 1/25/2011 11:25 AM rantingrick said... Classic insanity. Emile From emile at fenx.com Tue Jan 25 15:36:11 2011 From: emile at fenx.com (Emile van Sebille) Date: Tue, 25 Jan 2011 12:36:11 -0800 Subject: WxPython versus Tkinter. In-Reply-To: <048FB74272D440A0915ABC7D76AE262B@teddy> References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <8q7sgiF5tpU1@mid.individual.net> <19891784-d6a3-41ac-a097-5902a6323bc0@o21g2000prn.googlegroups.com><0b12cdb1-45b4-41e4-9bdb-074ee669d76b@k14g2000pre.googlegroups.com> <048FB74272D440A0915ABC7D76AE262B@teddy> Message-ID: On 1/25/2011 11:38 AM Octavian Rasnita said... > From: "Terry Reedy" >> Good as far as it goes, but this list leaves out several requirements >> (already posted by me, Steve Hansen, and others) for a Python 3 new >> stdlib module. It does not matter for the stdlib if wxpython is 3 times >> as good as tkinter, by some measure, as long as it is ineligible. > > > > Why is WxPython ineligible? I think Terry's point was compatibility with python3 -- which wx apparently isn't yet. Emile From smokefloat at gmail.com Tue Jan 25 15:40:31 2011 From: smokefloat at gmail.com (David Hutto) Date: Tue, 25 Jan 2011 12:40:31 -0800 (PST) Subject: python challenges Message-ID: <350ae5f3-8172-4461-b9b1-055e80868f38@r40g2000prh.googlegroups.com> Python is, of course, a language based on a lower level to allow higher level interactivity and ease of use. So, to define the challenges of python, are to define the challenges of what it wraps around. Moving from lower level to the higher level of python, what needs to take place at each level of the hierarchy it's placed on in order for it to become 'perfect'? From malaclypse2 at gmail.com Tue Jan 25 15:51:49 2011 From: malaclypse2 at gmail.com (Jerry Hill) Date: Tue, 25 Jan 2011 15:51:49 -0500 Subject: numpy/matlab compatibility In-Reply-To: <4D3F2ECE.8070200@nmsu.edu> References: <4D3F2ECE.8070200@nmsu.edu> Message-ID: On Tue, Jan 25, 2011 at 3:13 PM, Matt Funk wrote: > 1) a = rand(10,1) > 2) Y = a > 3) mask = Y > 100; > 4) Y(mask) = 100; > 5) a = a+Y > > Basically i am getting stuck on line 4). I was wondering if it is > possible or not with python? > (The above is working matlab code) > For those of us who don't know Matlab, what does that code do? -- Jerry -------------- next part -------------- An HTML attachment was scrubbed... URL: From orasnita at gmail.com Tue Jan 25 15:55:43 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Tue, 25 Jan 2011 22:55:43 +0200 Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com><9MB%o.14110$%64.6074@unlimited.newshosting.com> Message-ID: <59F6E65E3D9A46AD8D7A3863F3C1DC84@teddy> > this thread was a "psy-ops" (psychological operations) trick to turn off wxPython adopters by associating it with juvenile nonsense Do you think the need for accessibility is a nonsense? Or do you think it is something juvenile? Octavian From rouzbeh.t at gmail.com Tue Jan 25 15:56:11 2011 From: rouzbeh.t at gmail.com (Rouzbeh Torki) Date: Wed, 26 Jan 2011 00:26:11 +0330 Subject: PyBluez for iPhone Message-ID: Hi, My name is Rouzbeh. I work with Python and PyBluez on my laptop. I have already installed Python on my iPhone. But I want to work with iPhone-Bluetooth so I need Bluetooth Library in Python ( like PyBluez ). Is there any Bluetooth library for iphone in python or not ? where can I download the library ? thank you best regards -- *** < Rouzbeh > *** -------------- next part -------------- An HTML attachment was scrubbed... URL: From orasnita at gmail.com Tue Jan 25 16:03:19 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Tue, 25 Jan 2011 23:03:19 +0200 Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com><9MB%o.14110$%64.6074@unlimited.newshosting.com><4A48EDF6D7634F2E994661A457451E87@teddy> Message-ID: From: "geremy condra" > On Tue, Jan 25, 2011 at 11:24 AM, Octavian Rasnita wrote: > >> Yes, I know, that's life, which is not right, that's faith, bla bla, but it doesn't mean that my atitude need to be changed. > > There's a difference between having an opinion and having an attitude. > You have both, and it doesn't do you a lot of favors. I don't understand. Please be more clear. Have I said something wrong? Did I use bad words? Or what was it wrong? I have just an opinion, but that opinion won't change until the opinion of those who pretend that the discrimination is something normal. Do you think that this is not normal? Or you recommend me to be just like Tyler that can't use all the apps he could use if they were accessible, but he doesn't care because he cares much more to play nice in order to be accepted in this not-right society? Octavian From nagle at animats.com Tue Jan 25 16:34:26 2011 From: nagle at animats.com (John Nagle) Date: Tue, 25 Jan 2011 13:34:26 -0800 Subject: trouble installing MySQLdb (cygwin) + Bonus question In-Reply-To: <501470fc-c588-47d2-954d-17d825c5191c@v17g2000prc.googlegroups.com> References: <501470fc-c588-47d2-954d-17d825c5191c@v17g2000prc.googlegroups.com> Message-ID: <4d3f41d9$0$44021$742ec2ed@news.sonic.net> On 1/25/2011 7:05 AM, Matthew Roth wrote: > On Jan 25, 4:30 am, Dennis Lee Bieber wrote: >> On Mon, 24 Jan 2011 14:25:09 -0800 (PST), Matthew Roth >> declaimed the following in >> gmane.comp.python.general: >> Second -- MySQL is a server model DBMS; it doesn't have to be on the >> local machine. > -- > unfortunately, for my use it does. We do have an old centOs box here, > but the mysql running on that is severely outdated and so too is the > python. You can install a MySQL server under Windows, and talk to the server from the Cygwin environment. That's a useful way to test. John Nagle From kb1pkl at aim.com Tue Jan 25 16:41:58 2011 From: kb1pkl at aim.com (Corey Richardson) Date: Tue, 25 Jan 2011 16:41:58 -0500 Subject: WxPython versus Tkinter. In-Reply-To: <59F6E65E3D9A46AD8D7A3863F3C1DC84@teddy> References: <4D3E4377.3060807@tysdomain.com><9MB%o.14110$%64.6074@unlimited.newshosting.com> <59F6E65E3D9A46AD8D7A3863F3C1DC84@teddy> Message-ID: <4D3F43A6.2080703@aim.com> On 01/25/2011 03:55 PM, Octavian Rasnita wrote: > >> this thread was a "psy-ops" (psychological >> operations) trick to turn off wxPython adopters by associating it with >> juvenile nonsense > > Do you think the need for accessibility is a nonsense? > Or do you think it is something juvenile? > > > Octavian > Do you honestly think he was talking about the accessibility problem? IMO that should move to another thread, because this one is simply about, as the subject suggests, "WxPython versus Tkinter". From bryan.oakley at gmail.com Tue Jan 25 16:54:29 2011 From: bryan.oakley at gmail.com (Bryan) Date: Tue, 25 Jan 2011 13:54:29 -0800 (PST) Subject: Need GUI pop-up to edit a (unicode ?) string References: <3tqr08-bj2.ln1@murmur.very.softly> Message-ID: <7691fe98-37af-4ddf-a8a8-eadeef0d4a6e@y2g2000prf.googlegroups.com> On Jan 22, 2:22?pm, Rikishi42 wrote: > I'm in need for a graphical pop-up that will display a (unicode ?) string in > a field, allow the user to change it and return the modified string. > > Maybe also keep the original one displayed above it. > > Something like this: > +-------------------------------------------------+ > | ? Please confirm or edit the following string ? | > | ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? | > | ? ? Original_example_string ? ? ? ? ? ? ? ? ? ? | > | ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? | > | ?+-------------------------------------------+ ?| > | ?| ?Original_about_to_be_changed ? ? ? ? ? ? | ?| > | ?+-------------------------------------------+ ?| > | ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? | > | ? ? ? ? ? ? ? ? ? ? OK ? ? ? ? ? ? ? ? ? ? ? ? ?| > | ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? | > +-------------------------------------------------+ > > I've never used any kind of graphical interface programing before, so I > don't have a clue where to start. > This would, however, be the *only* GUI part in the app at this point. > > From what I can see the solution lays with PyQT, but the docs I find are > courses that aim to teach the whole GUI tool. I only need a little pop-up to > alow a user to edit part of a filename, for instance. > > I'm using Python 2.6.x on various Linux platforms (mainly openSUSE and Mint) > and on Windows. Windows support is not important, in this case. tkinter is likely the easiest solution. Here's a quick hack, assuming you want a program with a single window, rather than dialog you can pop up. This has no cancel button since you didn't specify you wanted one. It just pops up a window, and when you press ok, or dismiss via the window manager, the edited value will be printed to stdout. It's not a perfect solution but it gives you a feel for how easy it is to do with tkinter. import Tkinter as tk class App(tk.Tk): def __init__(self, s): tk.Tk.__init__(self) self.wm_title("Edit the string") # the main layout is composed of four areas: # 1) the label / instructions # 2) the original value # 3) the edit field # 4) a row of buttons label = tk.Label(self, text="Please confirm or edit the following string:") oframe = tk.LabelFrame(text="Original:") eframe = tk.LabelFrame(text="Edited:") buttons = tk.Frame(self) orig = tk.Entry(self, width=40) edit = tk.Entry(self, width=40) edit.insert(0, s) orig.insert(0, s) orig.config(state="disabled") ok = tk.Button(self, text="Ok", command=self.ok, default="active") # this does all the layout label.pack(side="top", fill="both", expand=True) oframe.pack(side="top", fill="both", expand=True, padx=4) eframe.pack(side="top", fill="both", expand=True, padx=4, pady=(4,0)) orig.pack(in_=oframe, side="top", fill="x", padx=4, pady=4) edit.pack(in_=eframe, side="top", fill="x", padx=4, pady=4) buttons.pack(side="bottom", fill="x", pady=4) ok.pack(in_=buttons, expand=True) edit.select_range(0, "end") edit.bind("", lambda event: self.ok) self.wm_protocol("WM_DELETE_WINDOW", self.ok) edit.focus() # keep a reference so self.ok can access it self.edit = edit def ok(self): value = self.edit.get() print value self.destroy() if __name__ == "__main__": import sys try: s = sys.argv[1] except: s = "Hello, world" app = App(s) app.mainloop() From steve+comp.lang.python at pearwood.info Tue Jan 25 16:56:49 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 25 Jan 2011 21:56:49 GMT Subject: numpy/matlab compatibility References: Message-ID: <4d3f4721$0$29983$c3e8da3$5496439d@news.astraweb.com> On Tue, 25 Jan 2011 13:13:02 -0700, Matt Funk wrote: > Hi, > > i am fairly new to python. I was wondering of the following is do-able > in python: > > 1) a = rand(10,1) > 2) Y = a > 3) mask = Y > 100; > 4) Y(mask) = 100; > 5) a = a+Y > > Basically i am getting stuck on line 4). I was wondering if it is > possible or not with python? > (The above is working matlab code) Not everybody here uses Matlab. Considering that this is a Python list, not a Matlab list, it may be that the only person who understands what the above code does is you. (Unlikely, but not *that* unlikely.) If you want us to help you, you should help us by telling us what the above code does, and what you've tried (if anything), and what error you get when you try. Alternatively, you could try a Matlab forum, and ask for help converting it to Python there, or much more likely to succeed, a specialist numpy mailing list. You're very likely to find people with experience in both numpy and Matlab there. -- Steven From mafunk at nmsu.edu Tue Jan 25 16:58:00 2011 From: mafunk at nmsu.edu (Matt Funk) Date: Tue, 25 Jan 2011 14:58:00 -0700 Subject: numpy/matlab compatibility In-Reply-To: References: <4D3F2ECE.8070200@nmsu.edu> Message-ID: <4D3F4768.402@nmsu.edu> Hi, thank you Andrea. That is exactly what i was looking for. Great. Andrea explained what the Matlab code does below. Sorry about the confusion. I was under the impression that numpy was leaning very heavily on Matlab for its syntax and thus i assumed that Matlab was mostly known for those using numpy. Andrea: you are right about the value 100. It should have been 0.5. The original code has a different vector which is tested against 100. I tried to simply reproduce the functionality with a random vector. Thus the confusion. Again, thanks for the input. matt On 1/25/2011 2:36 PM, Andrea Ambu wrote: > > > On Tue, Jan 25, 2011 at 9:13 PM, Matt Funk > wrote: > > Hi, > > i am fairly new to python. I was wondering of the following is do-able > in python: > > 1) a = rand(10,1) > 2) Y = a > 3) mask = Y > 100; > 4) Y(mask) = 100; > 5) a = a+Y > > > No. Not like that. > > You do literally: > a = rand(10, 1) > Y = a > mask = Y>100 > Y = where(mask, 100, Y) > a = a+Y > > > More Pythonically: > a = rand(10, 1) > a = where(a > 100, a + 100, a + a) > > > For those who don't speak Matlab: > > 1) a = rand(10,1) ; generates a 10x1 matrix for random number 0 < n < 1 > 2) Y = a > 3) mask = Y > 100; similar to: mask = [i>100 for i in Y] > 4) Y(mask) = 100; sets to 100 elements of Y with index i for which > mask[i] = True > 5) a = a+Y ; sums the two matrices element by element (like you do in > linear algebra) > > > Anyway... rand generates number from 0 up to 1 (both in python and > matlab)... when are they > 100? > > > > Basically i am getting stuck on line 4). I was wondering if it is > possible or not with python? > (The above is working matlab code) > > thanks > matt > -- > http://mail.python.org/mailman/listinfo/python-list > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From steve+comp.lang.python at pearwood.info Tue Jan 25 16:58:49 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 25 Jan 2011 21:58:49 GMT Subject: python challenges References: <350ae5f3-8172-4461-b9b1-055e80868f38@r40g2000prh.googlegroups.com> Message-ID: <4d3f4799$0$29983$c3e8da3$5496439d@news.astraweb.com> On Tue, 25 Jan 2011 12:40:31 -0800, David Hutto wrote: > Python is, of course, a language based on a lower level to allow higher > level interactivity and ease of use. So, to define the challenges of > python, are to define the challenges of what it wraps around. Moving > from lower level to the higher level of python, what needs to take place > at each level of the hierarchy it's placed on in order for it to become > 'perfect'? Define "perfect". -- Steven From misnomer at gmail.com Tue Jan 25 17:03:20 2011 From: misnomer at gmail.com (Nicholas Devenish) Date: Tue, 25 Jan 2011 22:03:20 +0000 Subject: numpy/matlab compatibility In-Reply-To: References: Message-ID: On 25/01/2011 20:13, Matt Funk wrote: > 1) a = rand(10,1) > 2) Y = a > 3) mask = Y> 100; > 4) Y(mask) = 100; > 5) a = a+Y > > Basically i am getting stuck on line 4). I was wondering if it is > possible or not with python? > (The above is working matlab code) I don't understand this matlab code completely (I would expect rand to return in the range 0-1, so would expect (Y > 100) to match nothing). Nonetheless, to achieve line 4 I believe you are looking for: >>> Y[mask] = 100 However, you can also do directly: >>> Y[Y>100] = 100 This won't work exactly as you anticipate, because presumably in matlab the line 'Y = a' makes a copy of 'a' (it has been a long time since I used matlab). In python, Y and a will still refer to the same object, so altering Y will also alter a. The *most literal* translation to python of your sample is probably: >> import numpy >> a = numpy.random.rand(10,1) >> Y = a.copy() >> mask = Y > 100 >> Y[mask] = 100 >> a = a + Y From backgoodoo at gmail.com Tue Jan 25 17:12:52 2011 From: backgoodoo at gmail.com (Back9) Date: Tue, 25 Jan 2011 14:12:52 -0800 (PST) Subject: A http server Message-ID: Hi, I'm trying to set up a http server to handle a single POST request. That POST request is to upload a huge file and the server is supposed to handle it with the just POST request. With my python sample code, multiple post requests are working well, but that is not my solution. I need a single POST request handling in the http server side. Does anyone have a good idea for this case or sample code? TIA From robert.kern at gmail.com Tue Jan 25 17:21:43 2011 From: robert.kern at gmail.com (Robert Kern) Date: Tue, 25 Jan 2011 16:21:43 -0600 Subject: numpy/matlab compatibility In-Reply-To: <4D3F2ECE.8070200@nmsu.edu> References: <4D3F2ECE.8070200@nmsu.edu> Message-ID: On 1/25/11 2:13 PM, Matt Funk wrote: > Hi, > > i am fairly new to python. I was wondering of the following is do-able > in python: > > 1) a = rand(10,1) > 2) Y = a > 3) mask = Y> 100; > 4) Y(mask) = 100; > 5) a = a+Y > > Basically i am getting stuck on line 4). I was wondering if it is > possible or not with python? > (The above is working matlab code) You will want to ask numpy questions on the numpy-discussion mailing list instead of here. http://www.scipy.org/Mailing_Lists When asking how to replicate a particular MATLAB behavior, please describe (and preferably also *show*) what the given MATLAB code does. We're not all familiar with MATLAB, and even if we are, we may not know which specific aspect of the code you want us to replicate. You will also want to check out this page: http://www.scipy.org/NumPy_for_Matlab_Users To answer your specific questions: 1) a = numpy.random.random_sample([10, 1]) 2) Y = a.copy() # In Python assignment to a new name does not copy the object. You seem to want a copy in this case. numpy arrays have a .copy() method, though most Python objects don't. 3) mask = Y > 0.5 # Note that Y only has values in [0..1) at this point, so using 100 here will create a boolean mask with only False entries. This is probably not what you wanted to show, so I used 0.5 instead. 4) Y[mask] = 100 5) a = a + Y # Or "a += Y" if you want to modify "a" in-place. -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco From misnomer at gmail.com Tue Jan 25 17:45:54 2011 From: misnomer at gmail.com (Nicholas Devenish) Date: Tue, 25 Jan 2011 22:45:54 +0000 Subject: WxPython versus Tkinter. In-Reply-To: References: <4D3E4377.3060807@tysdomain.com> <9MB%o.14110$%64.6074@unlimited.newshosting.com> Message-ID: On 25/01/2011 19:24, Octavian Rasnita wrote: > Can you tell why? Because you probably don't care about those who can't use the programs made with Tkinter or because you consider the discrimination something normal, right? > And you said that it is not a good thing. Good thing for whom? For the blind people Tkinter is the worst thing possible. Or do you want to say that it is not true? > No, it shouldn't be, but I see that you don't understand after this long thread why Tkinter should be avoided. > WxPython shouldn't be the second choice. WxPython shouldn't be the first choice or the single choice. The single choices should be always only those who don't introduce discrimination. Don't you agree with this? > Well, for the moment only WxPython doesn't include discrimination if we are talking about portable GUIs. > Please tell me if I wasn't clear enough or what you don't agree with. > The atitude that needs to be changed is the one that considerates the majority more important than a minority which is a minority because of health problems, a minority that is a minority without its will. > > In my country there is a law that says that the society should adapt to the people with disabilities (and not viceversa), and that law is probably copied from the legislation of other european countries. That law is a very good one, but the problem is that nobody cares to respect it, because most of the people have Tyler's opinion. > Yes, I know, that's life, which is not right, that's faith, bla bla, but it doesn't mean that my atitude need to be changed. The atitude that needs to be changed is the one that considers the discrimination something normal and the one that considers that the disabled people should adapt to the society even though most of them can't do that because of their health problems. Octavian, we get it - you are on the warpath about accessibility. And this is, in a way, a good thing, because, yes, programmers should in general think more about accessibility when designing their programs. But nobody was ever persuaded to consider a complicated and subtle issue by hostile holier-than-thou arrogance, which is what rantingricks posts started out with, and what your posts have been slowly turning into. This is what is 'not a good thing', in case you genuinely didn't understand the context of my previous message. Look at the response your earlier posts got, with experienced developers showing an interest in actually trying out accessibility tools. Compare this with the defensive replies you have been getting more recently. But this thread is not about that, and the accessibility issue is mostly a red herring that rantingrick has grabbed hold of to swing around like a battleaxe, because nobody is going to say that accessibility doesn't matter. Discrimination in many forms, is a real problem in our societies, and one that is not going to be solved overnight, much as you might wish it. Stigmatizing perfectly repectful people who haven't encountered your needs before, or don't agree that accessibility is the only thing that matters, is not going to solve any issues. From debatem1 at gmail.com Tue Jan 25 17:55:34 2011 From: debatem1 at gmail.com (geremy condra) Date: Tue, 25 Jan 2011 14:55:34 -0800 Subject: WxPython versus Tkinter. In-Reply-To: References: <4D3E4377.3060807@tysdomain.com> <9MB%o.14110$%64.6074@unlimited.newshosting.com> <4A48EDF6D7634F2E994661A457451E87@teddy> Message-ID: On Tue, Jan 25, 2011 at 1:03 PM, Octavian Rasnita wrote: > From: "geremy condra" >> On Tue, Jan 25, 2011 at 11:24 AM, Octavian Rasnita wrote: >> >>> Yes, I know, that's life, which is not right, that's faith, bla bla, but it doesn't mean that my atitude need to be changed. >> >> There's a difference between having an opinion and having an attitude. >> You have both, and it doesn't do you a lot of favors. > > > I don't understand. Please be more clear. There's a difference between what you say and how you say it. If a friend came up to you and said "give me $100 right now!", you probably wouldn't do it. If the same friend came up to you and said "I know this is a big thing to ask, but I really need $100 and I can't guarantee I'll be able to pay you back. Could you please help me?" I don't know very many people who would refuse if they were able to help. The reason is simple: the first does not acknowledge the value of the person doing the favor, and the second does. More concretely, you have an opinion that not supporting accessibility is discrimination. Tyler has an opinion that not supporting accessibility is a bug. Are you going to demand that he change his opinion? Or are you going to ask that he consider yours? > Have I said something wrong? Did I use bad words? Or what was it wrong? I think it was uncivil. It was rude, unkind, and generally disagreeable. I lost respect for you, and by proxy, for your point of view. In other words, you lost support not because fewer people agree with your position, but because fewer people want to agree with you. > I have just an opinion, but that opinion won't change until the opinion of those who pretend that the discrimination is something normal. > Do you think that this is not normal? I didn't ask you to change your opinion. I told you that you would be more effective if you changed your attitude. Like rantingrick, you're free to ignore that advice, but it is good advice for both you and the community, and I urge you to take it. > Or you recommend me to be just like Tyler that can't use all the apps he could use if they were accessible, but he doesn't care because he cares much more to play nice in order to be accepted in this not-right society? I would recommend that you learn to be civil to those you disagree with. The alternative is to be surrounded by them. Geremy Condra From mgroth86 at gmail.com Tue Jan 25 17:59:25 2011 From: mgroth86 at gmail.com (Matthew Roth) Date: Tue, 25 Jan 2011 14:59:25 -0800 (PST) Subject: trouble installing MySQLdb (cygwin) + Bonus question References: <501470fc-c588-47d2-954d-17d825c5191c@v17g2000prc.googlegroups.com> <4d3f41d9$0$44021$742ec2ed@news.sonic.net> Message-ID: On Jan 25, 9:34?pm, John Nagle wrote: > On 1/25/2011 7:05 AM, Matthew Roth wrote: > > > On Jan 25, 4:30 am, Dennis Lee Bieber ?wrote: > >> On Mon, 24 Jan 2011 14:25:09 -0800 (PST), Matthew Roth > >> ?declaimed the following in > >> gmane.comp.python.general: > >> ? ? ? ? ?Second -- MySQL is a server model DBMS; it doesn't have to be on the > >> local machine. > > -- > > unfortunately, for my use it does. We do have an old centOs box here, > > but the mysql running on that is severely outdated and so too is the > > python. > > ? ? You can install a MySQL server under Windows, and talk to the server > from the Cygwin environment. ?That's a useful way to test. > > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? John Nagle Right, that is precisely what I have. I am able to talk to it from cygwin, however, during the installing of the MySQLdb module it cannot find the mysql_config. This is because It is not installed? The setup sees that I am on a posix system not windows, as python is installed in cygwin, a virtual posix system. I am trying to bulid a mysql client from source for cygwin, however, I am running into an error there. Unless, can I talk to the windows mysql_config? if so, what does that look like From misnomer at gmail.com Tue Jan 25 18:01:48 2011 From: misnomer at gmail.com (Nicholas Devenish) Date: Tue, 25 Jan 2011 23:01:48 +0000 Subject: WxPython versus Tkinter. In-Reply-To: References: <4D3E4377.3060807@tysdomain.com> <9MB%o.14110$%64.6074@unlimited.newshosting.com> Message-ID: On 25/01/2011 19:16, CM wrote: > On Jan 25, 10:13 am, Nicholas Devenish wrote: > > I don't know--you sound too reasonable to extrapolate from this goofy > thread to a huge toolkit project that has been around for years and is > used in project such as Audacity (that's the wxWidgets version, but > close enough). But yes, it almost at times seemed like--from what I > could manage to read--this thread was a "psy-ops" (psychological > operations) trick to turn off wxPython adopters by associating it with > juvenile nonsense, and yes, on a quick scan it could turn people > off. Personally, no, it probably wouldn't have caused me not to use wx. But it certainly would have put a mental tick in the against box, because a frameworks community matters. As a little aside, a personal example is Django, whose tutorial contained what to my un-django-trained eye looked like an inconsistency bug, without explanation. I filed a bug report, and apparently many other people have had the same misassumption (indicating a problem with the tutorial). The bug was closed with words effectively equivalent to "Stupid newbie". Ignoring the fact that documentation being consistently misinterpreted should indicate a real problem, why should I put my time and effort into learning a framework with a community that is so hostile, when there are plenty of alternatives? > Which would be a shame, because, as you, Andrea, and others have > noted, wxPython is a nice toolkit. For those interested, download it > and make sure to download the Demo, that shows what can be done with > it. (Very early in this discussion the screenshots on the website > came up; they are horrifically out of date and wxPython deserves > better and looks great on, say, Windows 7 or Ubuntu....well, it looks > native, and that's the point). I actually chose wxPython partly on the strength of it's native-ness - it looks like other mac applications, and doesn't run through X11, but I was also extremely impressed by the comprehensive wxPython demo. That, and installation seemed to be pretty easy, whereas GTK looked a little like a minefield (QT I have a personal bias against, because for whatever reason I associate it with KDE and in general dislike kde's 'look' and design philosopy). > But what I would enjoy is a discussion about GUIs in terms of "develop > once, deploy many". For example, pyjamas, since I think being able to > develop one GUI that works as desktop or web-based is kind of > exciting. Unfortunately, it seems it is far off from anything easily > usable at this point. Part of that might be it doesn't have a big > enough community of developers yet. It's also just really difficult, > I'm sure. I was only aware of pyjamas as a "Python to Javascript" compiler, and didn't know you could write desktop applications in it too. One to watch! From rantingrick at gmail.com Tue Jan 25 18:02:18 2011 From: rantingrick at gmail.com (rantingrick) Date: Tue, 25 Jan 2011 15:02:18 -0800 (PST) Subject: Need GUI pop-up to edit a (unicode ?) string References: <3tqr08-bj2.ln1@murmur.very.softly> <7691fe98-37af-4ddf-a8a8-eadeef0d4a6e@y2g2000prf.googlegroups.com> Message-ID: <541c02df-b1fc-4376-bf17-e0531fe5c4bf@r29g2000yqj.googlegroups.com> On Jan 25, 3:54?pm, Bryan wrote: > tkinter is likely the easiest solution. Here's a quick hack, [...snip code...] Well this is nice Bryan however it should be much easier than this. Basically your code is creating most of the functionality that should be wrapped up in a Dialog class. Tkinter has the tkSimpleDialog from which one can inherit and build custom dialogs like the one you have here however it has a major flaw! Fredrick choose not give the class a show method and instead just threw all the code that should be in a "show" method into the __init__ method. This is not a good idea. And i'll explain why... What Fredrick was trying to do was to make noob programmers life easier. And he accomplished this in a specific way! However by NOT creating a show method he has at the same time handicapped these same people! The proper way to use a dialog class is... * Subclass a built-in in Dialog class and insert some widgets. class MyDialog(tkSimpleDialog.Dialog): blah * Create and instance of your custom dialog. dlg = MyDialog(blah) * Configure any widget values (if needed!) dlg.origText['text'] = unicodestring * and show the dialog dlg.show(blah) This design pattern promotes reuse-ability and encapsulation. However with Fredricks design you cannot configure the contained widgets after creating the instance because the dialog has entered a local event loop brought on by "self.wait_window(self)" which is in the DAMN INITIAL METHOD! This is a major flaw in the design and i would be happy to fix the flaw. However our "friend" Fredrick decided to copyright the module to himself! What a jerk! Which is quite disgusting considering that Tkinter, and TclTk are completely open source! And i don't want to hear any arguments about invoking the __init__ method because if you read the source you will see why doing that is completely ridiculous because of Fredericks design. This is another example of how few people actually use Tkinter. If many people where using the module obviously bad code such as this would not exist for 14 years! Someone would have complained. If Frederic wants some pointers for how to create a proper dialog he should contact me, or we should have a discussion here. The sad thing is that this dialog has not been fixed since 1997. And you people wonder why i hate Tkinter! From drobinow at gmail.com Tue Jan 25 18:20:26 2011 From: drobinow at gmail.com (David Robinow) Date: Tue, 25 Jan 2011 18:20:26 -0500 Subject: trouble installing MySQLdb (cygwin) + Bonus question In-Reply-To: References: <501470fc-c588-47d2-954d-17d825c5191c@v17g2000prc.googlegroups.com> <4d3f41d9$0$44021$742ec2ed@news.sonic.net> Message-ID: On Tue, Jan 25, 2011 at 5:59 PM, Matthew Roth wrote: > On Jan 25, 9:34?pm, John Nagle wrote: ... >> ? ? You can install a MySQL server under Windows, and talk to the server >> from the Cygwin environment. ?That's a useful way to test. >> >> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? John Nagle > > Right, that is precisely what I have. I am able to talk to it from > cygwin, however, during the installing of the MySQLdb module it cannot > find the mysql_config. This is because It is not installed? The setup > sees that I am on a posix system not windows, as python is installed > in cygwin, a virtual posix system. I am trying to bulid a mysql client > from source for cygwin, however, I am running into an error there. > > Unless, can I talk to the windows mysql_config? if so, what does that > look like The obvious answer is to use a Windows python. You haven't explained why you think you need to run a cygwin python. Can you explain that? From harijay at gmail.com Tue Jan 25 18:28:32 2011 From: harijay at gmail.com (harijay) Date: Tue, 25 Jan 2011 15:28:32 -0800 (PST) Subject: Using select.kqueue to monitor garageband transcode completion Message-ID: I want to automate a series of functions in python that trigger when the OSX application Garagband finishes writing to a file called "todays_recording.mp3". A Typical transcode process takes 20 minutes , and I fancy starting the python program immediately after I start the transcode and then walking away. For the present moment I have a silly implementation that does something like the code pasted below. I was looking online for smarter I/O monitoring and I came across the kqueue classes inside of the select module which could be used to monitor the kernel events in BSD - so it should work on OSX. However being a newbie , I cannot understand how to setup the select.kqueue event to look for garageband closing , i.e finish writing the transcoded mp3 file. I did see some code on comp.lang.python about this in a post from Ritesh Nadhani (pasted below as well). But I dont understand what the events mean . Looking for help to monitor the file closing using select.kqueue. Thanks Hari My Pseudocode for clunky monitoring of file i/o completion: while True: try: today_file = open("todays_recording.mp3","r") my_custom_function_to_process_file(today_file) except IOError: print "File not ready yet..continuing to wait" ############### Some source code I came across on comp.lang.python ( courtesy Ritesh Vadvani) related to this ############## import select26 as select import os kq = select.kqueue() fd = os.open("/tmp/a.txt", os.O_RDONLY) # I dont understand this line below ev = [select.kevent(fd, filter=select.KQ_FILTER_VNODE, flags=select.KQ_EV_ADD | select.KQ_EV_ENABLE | select.KQ_EV_ONESHOT, fflags=select.KQ_NOTE_WRITE | select.KQ_NOTE_DELETE | select.KQ_NOTE_EXTEND)] kq.control(ev, 0, 0) try: while True: evts = kq.control(ev, 1, None) if len(evts): print evts except KeyboardInterrupt: pass else: kq.close() os.close(fd) From ben+python at benfinney.id.au Tue Jan 25 18:29:46 2011 From: ben+python at benfinney.id.au (Ben Finney) Date: Wed, 26 Jan 2011 10:29:46 +1100 Subject: python challenges References: <350ae5f3-8172-4461-b9b1-055e80868f38@r40g2000prh.googlegroups.com> Message-ID: <87pqrk36l1.fsf@benfinney.id.au> David Hutto writes: > Python is, of course, a language based on a lower level to allow > higher level interactivity and ease of use. So, to define the > challenges of python, are to define the challenges of what it wraps > around. That seems like a framing of the issue designed to get a particular kind of answer. Why frame it that way? Why is the above forumlation better than, for example: Python is, of course, a language based on the English language. So, to define the challenges of Python is to define the challenges of the English lexis and grammar. For one thing, I don't agree that Python is ?a language based on a lower level?. A lower level of what? Python doesn't have any particular ?lower level?. Its *implementations* do ? each implementation wraps around different lower levels ? but you're talking about the language, aren't you? > Moving from lower level to the higher level of python, what needs to > take place at each level of the hierarchy it's placed on in order for > it to become 'perfect'? Perhaps you'd like to present what you think the answer to this question is, and we can discuss that. -- \ ?If we listen only to those who are like us, we will squander | `\ the great opportunity before us: To live together peacefully in | _o__) a world of unresolved differences.? ?David Weinberger | Ben Finney From rantingrick at gmail.com Tue Jan 25 18:33:03 2011 From: rantingrick at gmail.com (rantingrick) Date: Tue, 25 Jan 2011 15:33:03 -0800 (PST) Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com><9MB%o.14110$%64.6074@unlimited.newshosting.com> <59F6E65E3D9A46AD8D7A3863F3C1DC84@teddy> Message-ID: <27f53f8c-7862-4366-9352-82ae9a2f3970@k3g2000yqc.googlegroups.com> On Jan 25, 3:41?pm, Corey Richardson wrote: > Do you honestly think he was talking about the accessibility problem? > IMO that should move to another thread, because this one is simply > about, as the subject suggests, "WxPython versus Tkinter". Corey again (like many) you lack a global perspective. Anybody who has read along with his thread knows we are covering some pretty big issues here. WxPython is just the vehicle. The big picture is simply: Tkinter is old and in many ways insufficient for 21st century GUIs. We need to decide what should come next. I believe wxPython is our best hope. Wx may not be the best it can be, but it is the best we have at this time. There is more than "meets the eye" Corey! From rantingrick at gmail.com Tue Jan 25 18:39:13 2011 From: rantingrick at gmail.com (rantingrick) Date: Tue, 25 Jan 2011 15:39:13 -0800 (PST) Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com> <9MB%o.14110$%64.6074@unlimited.newshosting.com> Message-ID: <6fa3089d-f085-4929-9136-1eafeea436e7@f30g2000yqa.googlegroups.com> On Jan 25, 4:45?pm, Nicholas Devenish wrote: > But this thread is not about that, and the accessibility issue is mostly > a red herring that rantingrick has grabbed hold of to swing around like > a battleaxe, because nobody is going to say that accessibility doesn't > matter. Stop trying to exacerbate the situation Nick. You are one of the folks that has no fact based arguments to present so now you are plating the victim of my fact based argument. You are losing, and losing sucks! Stop trying to gain ground simply by hiding facts from the voters. Losers hate fact, because a fact based argument will dissolve BS faster than the speed of light. Get off the troll wagon and start contributing to the discussion in a positive way. From rantingrick at gmail.com Tue Jan 25 18:45:27 2011 From: rantingrick at gmail.com (rantingrick) Date: Tue, 25 Jan 2011 15:45:27 -0800 (PST) Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com> <9MB%o.14110$%64.6074@unlimited.newshosting.com> <4A48EDF6D7634F2E994661A457451E87@teddy> Message-ID: On Jan 25, 4:55?pm, geremy condra wrote: > There's a difference between what you say and how you say it. If a > friend came up to you and said "give me $100 right now!", you probably > wouldn't do it. What if someone was extorting him and he really needed the money "right now"? > If the same friend came up to you and said "I know > this is a big thing to ask, but I really need $100 and I can't > guarantee I'll be able to pay you back. Could you please help me?" I > don't know very many people who would refuse if they were able to > help. The reason is simple: the first does not acknowledge the value > of the person doing the favor, and the second does. No i see what this is about. YOU ARE PART OF THE ELITE and WE are part of the piss on peasants. We need to grovel at your feet and stroke your ego before you will give us an audience. We are nothing, we are pathetic, and you are all knowing. Ok, NOW i get it! > I would recommend that you learn to be civil to those you disagree > with. The alternative is to be surrounded by them. That sounds like a veiled threat to me Geremy! Your scare tactics are not working so go home. From emile at fenx.com Tue Jan 25 18:47:07 2011 From: emile at fenx.com (Emile van Sebille) Date: Tue, 25 Jan 2011 15:47:07 -0800 Subject: WxPython versus Tkinter. In-Reply-To: <59F6E65E3D9A46AD8D7A3863F3C1DC84@teddy> References: <4D3E4377.3060807@tysdomain.com><9MB%o.14110$%64.6074@unlimited.newshosting.com> <59F6E65E3D9A46AD8D7A3863F3C1DC84@teddy> Message-ID: On 1/25/2011 12:55 PM Octavian Rasnita said... > >> this thread was a "psy-ops" (psychological > operations) trick to turn off wxPython adopters by associating it with > juvenile nonsense > > Do you think the need for accessibility is a nonsense? > Or do you think it is something juvenile? Are third party installations nonsense? Or should python come with all libraries for all potential applications? And then always keep up with best of breed? Emile From rantingrick at gmail.com Tue Jan 25 18:49:46 2011 From: rantingrick at gmail.com (rantingrick) Date: Tue, 25 Jan 2011 15:49:46 -0800 (PST) Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com> <9MB%o.14110$%64.6074@unlimited.newshosting.com> Message-ID: <5a5e15f3-ae0f-4561-8969-e9afde3829dc@g26g2000vba.googlegroups.com> On Jan 25, 5:01?pm, Nicholas Devenish wrote: > why should I put my time and effort into learning a framework > with a community that is so hostile, when there are plenty of alternatives? That is exactly the point i have been making about this community (at c.l.py) We are not as noob friendly as we should be. If anyone dares commit ideas and they are not "accepted" yet, then that person will be pounced on and beaten. I have seen it time and time again. I have experienced this firsthand! From mgroth86 at gmail.com Tue Jan 25 18:51:06 2011 From: mgroth86 at gmail.com (Matthew Roth) Date: Tue, 25 Jan 2011 15:51:06 -0800 (PST) Subject: trouble installing MySQLdb (cygwin) + Bonus question References: <501470fc-c588-47d2-954d-17d825c5191c@v17g2000prc.googlegroups.com> <4d3f41d9$0$44021$742ec2ed@news.sonic.net> Message-ID: On Jan 25, 6:20?pm, David Robinow wrote: > On Tue, Jan 25, 2011 at 5:59 PM, Matthew Roth wrote: > > On Jan 25, 9:34?pm, John Nagle wrote: > ... > >> ? ? You can install a MySQL server under Windows, and talk to the server > >> from the Cygwin environment. ?That's a useful way to test. > > >> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? John Nagle > > > Right, that is precisely what I have. I am able to talk to it from > > cygwin, however, during the installing of the MySQLdb module it cannot > > find the mysql_config. This is because It is not installed? The setup > > sees that I am on a posix system not windows, as python is installed > > in cygwin, a virtual posix system. I am trying to bulid a mysql client > > from source for cygwin, however, I am running into an error there. > > > Unless, can I talk to the windows mysql_config? if so, what does that > > look like > > ?The obvious answer is to use a Windows python. You haven't explained > why you think you need to run a cygwin python. Can you explain that? Good question. There isn't a solid explanation. heretofore, I have been using a lot of bash scripting in combination with awk sed and some perl. I was directed to look into python. My tasks were becoming increasingly complex and memory intensive. I started with a desire to connect to a mysql server. For that I needed to install the MySQLdb module. I am having difficultly in acomplishment of this task. I suppose for the time it has taken, using windows python would have been the simpler route. Anyway, I have done some tinkering and have moved passed the mysql_config problem. Thanks to Davids reminder that I have mysql on windows. Meaning when setup.py called setup_posix.py It was essentially calling mysql_config. Well mysql_config was in a far off folder. I setup a symbolic link and that worked. However I was then presented with a new problem. In direct relation to that far off folder. Dreaded spaces. (i headed the log) -- running build running build_py copying MySQLdb/release.py -> build/lib.cygwin-1.7.7-i686-2.6/MySQLdb running build_ext building '_mysql' extension creating build/temp.cygwin-1.7.7-i686-2.6 gcc -fno-strict-aliasing -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict- prototypes -Dversion_info=(1,2,3,'final' ,0) -D__version__=1.2.3 -I/usr/include/python2.6 -c _mysql.c -o build/ temp.cygwin-1.7.7-i686-2.6/_mysql. o "-I/cygdrive/c/Program Files/MySQL/MySQL Server 5.5/include" "/MT" "/Zi" "/O2" "/Ob1" "/D" "NDEBUG" "- DDBUG_OFF" gcc: "-I/cygdrive/c/Program: No such file or directory -- there is much more, but obviously the problem is " gcc: "-I/cygdrive/c/ Program: No such file or directory" what I need to do is have it point to /cygdrive/c/Program\ Files/MySQL/ MySQL\ Server\ 5.5/include and not cygdrive/c/Program Files/MySQL/ MySQL Server 5.5/include. I am currently trying to track that down. I think I am going to leave work and go grab some dinner. perhaps I will solve this later tonight. Best, Matt From sohel807 at gmail.com Tue Jan 25 18:52:37 2011 From: sohel807 at gmail.com (Akand Islam) Date: Tue, 25 Jan 2011 15:52:37 -0800 (PST) Subject: adding "Print" menu in wxPython Message-ID: <05c1f4b3-941c-45b1-9370-a88653d1083a@e16g2000pri.googlegroups.com> To make a simple editor using wxPython, sample code is available in wxPython's tutorial page (http://wiki.wxpython.org/ WxHowtoSmallEditor). However, in addition I want to add "print" menu which will print the contents of editor (i.e. whatever written in editor). I will appreciate if someone please show me how to add printing option. Thanks, Akand From martin at v.loewis.de Tue Jan 25 18:56:59 2011 From: martin at v.loewis.de (Martin v. Loewis) Date: Wed, 26 Jan 2011 00:56:59 +0100 Subject: WxPython versus Tkinter. In-Reply-To: <8q7sgiF5tpU1@mid.individual.net> References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <8q7sgiF5tpU1@mid.individual.net> Message-ID: <4D3F634B.3040804@v.loewis.de> > You'll find that nearly all software used in Europe (and most other parts) > is internationalized or it wouldn't stand a chance. You mean, in lines of code? I very much doubt that. A lot of software gets written, in particular for web servers, that is only German, around here. Nobody thinks this is wrong, since the audience is expected to speak German, anyway. I think all the shell scripts that people write every day account for more lines of code than operating systems, office software, server applications, web frameworks combined. And these one-time use pieces of software are certainly not internationalized - not even in companies that have a policy that all software must support i18n. If you want examples, here are some: http://www.heise.de/ct/foren/ (web forum) http://arztsuche.spiegel.de/ (medical directory) http://portal.mytum.de/termine/index_html (university calendar - the software itself is bilingual; the content is not at all) etc. Regards, Martin From rantingrick at gmail.com Tue Jan 25 18:57:44 2011 From: rantingrick at gmail.com (rantingrick) Date: Tue, 25 Jan 2011 15:57:44 -0800 (PST) Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com><9MB%o.14110$%64.6074@unlimited.newshosting.com> <59F6E65E3D9A46AD8D7A3863F3C1DC84@teddy> Message-ID: On Jan 25, 5:47?pm, Emile van Sebille wrote: > Are third party installations nonsense? Of course not. > Or should python come with all > libraries for all potential applications? Again, of course not. No one has suggested such bombastic ideas in this thread, you are the first. > And then always keep up with > best of breed? Yes, Python should be as close to the "cutting edge" as possible. What does that mean exactly? Well we don't wont to be so close that we cut a finger (web interfaces). However at the same time we don't want to find ourselves two decades behind in evolution (Tkinter). There must be some middle ground. I believe some form of modified wxPython IS that middle ground. Five to tens years from now, web/mobile interfaces may be the middle ground. How much longer are we going to wait? How much longer can we wait without making a move? The Tkinter module is like a scared rabbit, frozen with fear, and unable to move. So too are we. Change with the times are get left behind! From andreambu at gmail.com Tue Jan 25 18:58:48 2011 From: andreambu at gmail.com (Andrea Ambu) Date: Wed, 26 Jan 2011 00:58:48 +0100 Subject: Fwd: numpy/matlab compatibility In-Reply-To: References: <4D3F2ECE.8070200@nmsu.edu> Message-ID: I replied to Matt only ARGH! ---------- Forwarded message ---------- From: Andrea Ambu Date: 25 January 2011 22:36 Subject: Re: numpy/matlab compatibility To: Matt Funk On Tue, Jan 25, 2011 at 9:13 PM, Matt Funk wrote: > > Hi, > > i am fairly new to python. I was wondering of the following is do-able > in python: > > 1) a = rand(10,1) > 2) Y = a > 3) mask = Y > 100; > 4) Y(mask) = 100; > 5) a = a+Y > No. Not like that. You do literally: a = rand(10, 1) Y = a mask = Y>100 Y = where(mask, 100, Y) a = a+Y More Pythonically: a = rand(10, 1) a = where(a > 100, a + 100, a + a) For those who don't speak Matlab: 1) a = rand(10,1) ; generates a 10x1 matrix for random number 0 < n < 1 2) Y = a 3) mask = Y > 100; similar to: mask = [i>100 for i in Y] 4) Y(mask) = 100; sets to 100 elements of Y with index i for which mask[i] = True 5) a = a+Y ; sums the two?matrices element by element (like you do in linear algebra) Anyway... rand generates number from 0 up to 1 (both in python and matlab)... when are they > 100? > > Basically i am getting stuck on line 4). I was wondering if it is > possible or not with python? > (The above is working matlab code) > > thanks > matt > -- > http://mail.python.org/mailman/listinfo/python-list -- Andrea From emile at fenx.com Tue Jan 25 19:14:01 2011 From: emile at fenx.com (Emile van Sebille) Date: Tue, 25 Jan 2011 16:14:01 -0800 Subject: WxPython versus Tkinter. In-Reply-To: <27f53f8c-7862-4366-9352-82ae9a2f3970@k3g2000yqc.googlegroups.com> References: <4D3E4377.3060807@tysdomain.com><9MB%o.14110$%64.6074@unlimited.newshosting.com> <59F6E65E3D9A46AD8D7A3863F3C1DC84@teddy> <27f53f8c-7862-4366-9352-82ae9a2f3970@k3g2000yqc.googlegroups.com> Message-ID: On 1/25/2011 3:33 PM rantingrick said... > Tkinter is old and in many ways insufficient for 21st century GUIs. We > need to decide what should come next. I believe wxPython is our best > hope. Wx may not be the best it can be, but it is the best we have at > this time. Then you should immediately volunteer to bring wxPython to python3 compatibility -- as it is, it's not even close... Start thinking about upping your game from ranting to doing. Emile From rantingrick at gmail.com Tue Jan 25 19:30:54 2011 From: rantingrick at gmail.com (rantingrick) Date: Tue, 25 Jan 2011 16:30:54 -0800 (PST) Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com><9MB%o.14110$%64.6074@unlimited.newshosting.com> <59F6E65E3D9A46AD8D7A3863F3C1DC84@teddy> <27f53f8c-7862-4366-9352-82ae9a2f3970@k3g2000yqc.googlegroups.com> Message-ID: On Jan 25, 6:14?pm, Emile van Sebille wrote: > On 1/25/2011 3:33 PM rantingrick said... > > > Tkinter is old and in many ways insufficient for 21st century GUIs. We > > need to decide what should come next. I believe wxPython is our best > > hope. Wx may not be the best it can be, but it is the best we have at > > this time. > > Then you should immediately volunteer to bring wxPython to python3 > compatibility -- as it is, it's not even close... Thats the kind of advice i want to hear. Now we are engaging in positive discussion. Now we (you and I) are acting like fellow members of the same community. Thank You Emile. With this sort of positive outlook we can move forward. But how do "you" feel about wxPython. If "you" had a choice would "you" volunteer for wxPython and move it towards Python 3 standards? If not, then what would "you" do. I think we can both agree that there is room to grow beyond the capabilities of Tkinter. From ian.g.kelly at gmail.com Tue Jan 25 19:40:46 2011 From: ian.g.kelly at gmail.com (Ian) Date: Tue, 25 Jan 2011 16:40:46 -0800 (PST) Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com> <9MB%o.14110$%64.6074@unlimited.newshosting.com> Message-ID: <3a0595be-695a-41aa-aba9-504bcc3d16d4@fm22g2000vbb.googlegroups.com> On Jan 25, 4:01?pm, Nicholas Devenish wrote: > Personally, no, it probably wouldn't have caused me not to use wx. But > it certainly would have put a mental tick in the against box, because a > frameworks community matters. As a little aside, a personal example is > Django, whose tutorial contained what to my un-django-trained eye looked > like an inconsistency bug, without explanation. I filed a bug report, > and apparently many other people have had the same misassumption > (indicating a problem with the tutorial). The bug was closed with words > effectively equivalent to "Stupid newbie". Ignoring the fact that > documentation being consistently misinterpreted should indicate a real > problem, why should I put my time and effort into learning a framework > with a community that is so hostile, when there are plenty of alternatives? Speaking as a Django user and occasional developer, I'm sorry to hear that you had a bad experience with the Django community. I have generally found it to be friendly and helpful, at least on the mailing list and the IRC channel. The ticket triagers have 1800+ open tickets to organize, so they can get ornery about duplicates at times. Are you referring to ticket #14081? I expect the reason this hasn't been addressed is because nobody has submitted a patch or suggested an improved wording. If you were to make a suggestion, I doubt that anybody would be hostile to the idea of improving the tutorial. Cheers, Ian From luismgz at gmail.com Tue Jan 25 19:43:38 2011 From: luismgz at gmail.com (=?ISO-8859-1?Q?Luis_M=2E_Gonz=E1lez?=) Date: Tue, 25 Jan 2011 16:43:38 -0800 (PST) Subject: Which is the best book to learn python References: <188c0a9f-4e93-4fae-b3f9-e7c84f8030fd@v31g2000pri.googlegroups.com> Message-ID: <53fd6f58-594e-48de-bc19-1408b4dcb580@29g2000prb.googlegroups.com> On Jan 24, 2:09?pm, santosh hs wrote: > Hi All, > i am beginner to python please tell me which is the best available > reference for beginner to start from novice If you are a complete beginner to programming, I suggest start with a tutorial such as "A Byte of Python" (google this). I learned my first steps with Josh Cogliati's "Non-Programmers Tutorial For Python" http://www.oopweb.com/Python/Documents/easytut/VolumeFrames.html . The suggestions above are very good if you are new to programming en general (not only to python). If you have some experience, you may look to something more advanced, such as "Dive into Python". All these resources are available online for free. If you want to but a book, I like "Beginning Python: From Novice to Professional". Hope this helps... Luis From rantingrick at gmail.com Tue Jan 25 19:54:43 2011 From: rantingrick at gmail.com (rantingrick) Date: Tue, 25 Jan 2011 16:54:43 -0800 (PST) Subject: adding "Print" menu in wxPython References: <05c1f4b3-941c-45b1-9370-a88653d1083a@e16g2000pri.googlegroups.com> Message-ID: On Jan 25, 5:52?pm, Akand Islam wrote: > > I will appreciate if someone please show me how to add > printing option. Hello Akand, Well the first step would be to create a stub "OnPrint" method and add a command to the File menu named "Print" that calls the "OnPrint" method. Can you do this part yourself? All the answers you need are in the source you linked to. Give it your best shot and then post some code with a specific question if you get stuck. From emile at fenx.com Tue Jan 25 19:55:34 2011 From: emile at fenx.com (Emile van Sebille) Date: Tue, 25 Jan 2011 16:55:34 -0800 Subject: WxPython versus Tkinter. In-Reply-To: <5a5e15f3-ae0f-4561-8969-e9afde3829dc@g26g2000vba.googlegroups.com> References: <4D3E4377.3060807@tysdomain.com> <9MB%o.14110$%64.6074@unlimited.newshosting.com> <5a5e15f3-ae0f-4561-8969-e9afde3829dc@g26g2000vba.googlegroups.com> Message-ID: On 1/25/2011 3:49 PM rantingrick said... > On Jan 25, 5:01 pm, Nicholas Devenish wrote: > >> why should I put my time and effort into learning a framework >> with a community that is so hostile, when there are plenty of alternatives? > > That is exactly the point i have been making about this community (at > c.l.py) We are not as noob friendly as we should be. If anyone dares > commit ideas and they are not "accepted" yet, then that person will be > pounced on and beaten. I have seen it time and time again. I have > experienced this firsthand! Oh, that everyone should blindly accept you as is and without regard for established protocols -- we certainly should all jump to your slightest whim. Get a fucking clue. Emile From emile at fenx.com Tue Jan 25 20:06:19 2011 From: emile at fenx.com (Emile van Sebille) Date: Tue, 25 Jan 2011 17:06:19 -0800 Subject: WxPython versus Tkinter. In-Reply-To: References: <4D3E4377.3060807@tysdomain.com><9MB%o.14110$%64.6074@unlimited.newshosting.com> <59F6E65E3D9A46AD8D7A3863F3C1DC84@teddy> Message-ID: On 1/25/2011 3:57 PM rantingrick said... > On Jan 25, 5:47 pm, Emile van Sebille wrote: > >> Are third party installations nonsense? > > Of course not. > So install wxPython and move on. Or start doing. Join one of the many GUI projects that would like to be in the standard library and do more than make a smelly breeze. Emile From rantingrick at gmail.com Tue Jan 25 20:07:07 2011 From: rantingrick at gmail.com (rantingrick) Date: Tue, 25 Jan 2011 17:07:07 -0800 (PST) Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com> <9MB%o.14110$%64.6074@unlimited.newshosting.com> <5a5e15f3-ae0f-4561-8969-e9afde3829dc@g26g2000vba.googlegroups.com> Message-ID: <1b955dcf-77e2-4130-9b5b-276cfedccd9c@a10g2000vby.googlegroups.com> On Jan 25, 6:55?pm, Emile van Sebille wrote: > Oh, that everyone should blindly accept you as is and without regard for > established protocols What protocols? Where is this standard posted? Can you give me a link? I would like to know what is expected of me. > -- we certainly should all jump to your slightest > whim. > > Get a [CENSORED] clue. Thats not very nice Emile. What is it going to take for you (and others) to take me seriously? I have been within this group for more than four years and you still do not accept me. I have been ridiculed, brow beaten, laughed at, trolled, and any negative thing that can be done to someone. Heck, in my very first post i was crucified by the community. I'll admit that I have made some mistakes -- and i have apologized for them. Maybe you need to be a little more accepting of me. Maybe this group IS not a homogeneous block as you would like. Maybe we ALL need to be a little more humble to each other. What do you think Emile? From misnomer at gmail.com Tue Jan 25 20:10:51 2011 From: misnomer at gmail.com (Nicholas Devenish) Date: Wed, 26 Jan 2011 01:10:51 +0000 Subject: WxPython versus Tkinter In-Reply-To: <3a0595be-695a-41aa-aba9-504bcc3d16d4@fm22g2000vbb.googlegroups.com> References: <4D3E4377.3060807@tysdomain.com> <9MB%o.14110$%64.6074@unlimited.newshosting.com> <3a0595be-695a-41aa-aba9-504bcc3d16d4@fm22g2000vbb.googlegroups.com> Message-ID: On 26/01/2011 00:40, Ian wrote: > Are you referring to ticket #14081? I expect the reason this hasn't > been addressed is because nobody has submitted a patch or suggested an > improved wording. If you were to make a suggestion, I doubt that > anybody would be hostile to the idea of improving the tutorial. Actually, it was that ticket, good hunting. It's not so much that it was marked as duplicate, but that the bug it's marked "Yet another" duplicate of is marked 'invalid', implying that the Django developers consider it not a bug (i.e. user error, and not something to be patched or reworded). If it was open, even as a long-term low-priority documentation bug, then closing and marking the duplicate report wouldn't have felt prickly at all. I did some digging at the time, and there were indeed several more instances of this confusion arising (that I failed to find in my cursory search before posting the report); if intelligent people are getting confused over the tutorial, (a document specifically designed for people unfamiliar with the framework), then it sure sounds like a documentation bug. Especially as, in some of the tickets, the responder explained the issue (so, a need to explain) before closing the ticket. Essentially, if people are hostile to the idea of accepting a documentation problem, surely they might react the same way to a patch for it. And this is the first impression I got of the django community; because I am only a casual user, I subsequently didn't feel any need to potentially 'fight against the system' over the issue. I'll take your encouraging comments on the general friend-and-helpful-ness of the Django community onboard. Thanks, Nick From rantingrick at gmail.com Tue Jan 25 20:12:21 2011 From: rantingrick at gmail.com (rantingrick) Date: Tue, 25 Jan 2011 17:12:21 -0800 (PST) Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com><9MB%o.14110$%64.6074@unlimited.newshosting.com> <59F6E65E3D9A46AD8D7A3863F3C1DC84@teddy> Message-ID: On Jan 25, 7:06?pm, Emile van Sebille wrote: > On 1/25/2011 3:57 PM rantingrick said... > > > On Jan 25, 5:47 pm, Emile van Sebille ?wrote: > > >> Are third party installations nonsense? > > > Of course not. > > So install wxPython and move on. ? See you are missing the point again. The point behind this whole challenge is that Tkinter is antiquity and Tkinter is making Python into antiquity simply by being in the stdlib. That is the entire point. Also, i have said many times that NO GUI library is TRULY 21st century however wxPython would be a far better base to start from than Tkinter. TclTk is never going to scale properly. The TclTk folks do not have a vision for the future. We need to move Python forward. And Tkinter is not forward. Tkinter is stagnation. 1990's stagnation. This is 2011. THAT, is my point. From rantingrick at gmail.com Tue Jan 25 20:17:03 2011 From: rantingrick at gmail.com (rantingrick) Date: Tue, 25 Jan 2011 17:17:03 -0800 (PST) Subject: WxPython versus Tkinter References: <4D3E4377.3060807@tysdomain.com> <9MB%o.14110$%64.6074@unlimited.newshosting.com> <3a0595be-695a-41aa-aba9-504bcc3d16d4@fm22g2000vbb.googlegroups.com> Message-ID: On Jan 25, 7:10?pm, Nicholas Devenish wrote: > Essentially, if people are hostile to the idea of accepting a > documentation problem, surely they might react the same way to a patch > for it. This is my very point about writing any code. Only a fool would spend years developing a code base if he had no assurances anyone would use it. First, a smart developer will test the waters through discussion. This is the first step. First garner support. Then code. Then publish. Then maintain. These are the essential steps for productivity. From torriem at gmail.com Tue Jan 25 20:18:01 2011 From: torriem at gmail.com (Michael Torrie) Date: Tue, 25 Jan 2011 18:18:01 -0700 Subject: WxPython versus Tkinter. In-Reply-To: <4D3C9981.8020107@tysdomain.com> References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <480571f5-5731-4f8b-9cb4-1468478711bf@c39g2000yqi.googlegroups.com> <2c951199-3dba-4d24-a5c2-f84081688f7e@u6g2000yqk.googlegroups.com> <3e603997-5539-4660-bd83-7398bdab34a4@k30g2000vbn.googlegroups.com> <5edded76-fdac-4eb5-8480-25e3381e2fd4@g26g2000vbz.googlegroups.com> <1d7fdb0c-9f82-45ab-bf0e-99d210042f0d@j21g2000vbn.googlegroups.com> <4D3C9981.8020107@tysdomain.com> Message-ID: <4D3F7649.7080309@gmail.com> On 01/23/2011 02:11 PM, Littlefield, Tyler wrote: > I hardly think that your tone, attitude and arguments are going to help > you in your battle to prove that WXPython is superior to anything at > all, if you can't manage to provide cross-platform bug-free code. Sadly you're wasting your breath. He just doesn't understand what you are saying. Further he honestly does not think he has an attitude or fallacious arguments. I find his posts fascinating, really. In the meantime I suppose we can reply for sport (not a fair fight really), or just leave him be. From craigyk at me.com Tue Jan 25 20:19:00 2011 From: craigyk at me.com (Craig Yoshioka) Date: Tue, 25 Jan 2011 17:19:00 -0800 Subject: help with multiprocessing pool Message-ID: Hi all, I could really use some help with a problem I'm having. I wrote a function that can take a pattern of actions and it apply it to the filesystem. It takes a list of starting paths, and a pattern like this: pattern = { InGlob('Test/**'):{ MatchRemove('DS_Store'):[], NoMatchAdd('(alhpaID_)|(DS_Store)','warnings'):[], MatchAdd('alphaID_','alpha_found'):[], InDir('alphaID_'):{ NoMatchAdd('(betaID_)|(DS_Store)','warnings'):[], InDir('betaID_'):{ NoMatchAdd('(gammaID_)|(DS_Store)','warnings'):[], MatchAdd('gammaID_','gamma_found'):[] }}}} so if you run evalFSPattern(['Volumes/**'],pattern) it'll return a dictionary where: dict['gamma_found'] = [list of paths that matched] (i.e. '/Volumes/HD1/Test/alphaID_3382/betaID_38824/gammaID_848384') dict['warning'] = [list of paths that failed to match] (ie. '/Volumes/HD1/Test/alphaID_3382/gammaID_47383') Since some of these volumes are on network shares I also wanted to parallelize this so that it would not block on IO. I started the parallelization by using multiprocessing.Pool and got it to work if I ran the fsparser from the interpreter. It ran in *much* less time and produced correct output that matched the non-parallelized version. The problem begins if I then try to use the parallelized function from within the code. For example I wrote a class whose instances are created around valid FS paths, that are cached to reduce expensive FS lookups. class Experiment(object): SlidePaths = None @classmethod def getSlidePaths(cls): if cls.SlidePaths == None: cls.SlidePaths = fsparser(['/Volumes/**'],pattern) return cls.SlidePaths @classmethod def lookupPathWithGammaID(cls,id): paths = cls.getSlidePaths() ... return paths[selected] @classmethod def fromGamaID(cls,id): path = cls.lookupPathWithGammaID(id) return cls(path) def __init__(self,path) self.Path = path ... ... If I do the following from the interpreter it works: >>>from experiment import Experiment >>>expt = Experiment.fromGammaID(10102) but if I write a script called test.py: from experiment import Experiment expt1 = Experiment.fromGammaID(10102) expt2 = Experiment.fromGammaID(10103) comparison = expt1.compareTo(expt2) it fails, if I try to import it or run it from bash prompt: >>> from test import comparison (hangs forever) $ python test.py (hangs forever) I would really like some help trying to figure this out... I thought it should work easily since all the spawned processes don't share data or state (their results are merged in the main thread). The classes used in the pattern are also simple python objects (use python primitives). These are the main functions: def mapAction(pool,paths,action): merge = {'next':[]} for result in pool.map(action,paths): if result == None: continue merge = mergeDicts(merge,result) return merge def mergeDicts(d1,d2): for key in d2: if key not in d1: d1[key] = d2[key] else: d1[key] += d2[key] return d1 def evalFSPattern(paths,pattern): pool = Pool(10) results = {} for action in pattern: tomerge1 = mapAction(pool,paths,action) tomerge2 = evalFSPattern(tomerge1['next'],pattern[action]) del tomerge1['next'] results = mergeDicts(results,tomerge1) results = mergeDicts(results,tomerge2) return results the classes used in the pattern (InGlob,NoMatchAdd,etc.) are callable classes that take a single parameter (a path) and return a dict result or None which makes them trivial to adapt to Pool.map. Note if I change the mapAction function to: def mapAction(pool,paths,action): merge = {'next':[]} for path in paths: result = action(path) if result == None: continue merge = mergeDicts(merge,result) return merge everything works just fine. Thanks. From torriem at gmail.com Tue Jan 25 20:19:42 2011 From: torriem at gmail.com (Michael Torrie) Date: Tue, 25 Jan 2011 18:19:42 -0700 Subject: WxPython versus Tkinter. In-Reply-To: <4d3c6e69$0$29983$c3e8da3$5496439d@news.astraweb.com> References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <1a1b0e40-ac98-4234-a95d-80ed05de4e72@s5g2000yqm.googlegroups.com> <4d3c6e69$0$29983$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4D3F76AE.9080500@gmail.com> On Sun, 23 Jan 2011 09:21:57 -0800, rantingrick wrote: > Wait a minute, i am confused? What language is Python written in? Oh > thats right Lisp! I am so dumb. How did i even get this job? :-) What job is this? Inquiring minds wish to know. From rantingrick at gmail.com Tue Jan 25 20:50:53 2011 From: rantingrick at gmail.com (rantingrick) Date: Tue, 25 Jan 2011 17:50:53 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <1a1b0e40-ac98-4234-a95d-80ed05de4e72@s5g2000yqm.googlegroups.com> <4d3c6e69$0$29983$c3e8da3$5496439d@news.astraweb.com> Message-ID: <5fbb428b-cc00-46c7-81f5-66ae6d8706f7@r14g2000yqn.googlegroups.com> On Jan 25, 7:19?pm, Michael Torrie wrote: > On Sun, 23 Jan 2011 09:21:57 -0800, rantingrick wrote: > > Wait a minute, i am confused? What language is Python written in? Oh > > thats right Lisp! I am so dumb. How did i even get this job? :-) > > What job is this? ?Inquiring minds wish to know. On Jan 25, 7:19pm, Michael Torrie wrote: > What job is this? Inquiring minds wish to know. Well my job is that of any humble community member. To be an intrical part of a large heterogeneous group of folks all working toward a common goal, who may *not* always and completely agree, however, all of whom respect one another on a basic and fundamental level. Each member has a responsibility to listen contently to his fellow members ideas and offer objective responses devoid of emotional baggage. Each member should gracefully and selflessly help those who are new to the group to feel more welcome. And most importantly we should all collectively keep our minds focused for the future of Python. We must not let Python grow stagnate. No, we must constantly push for further evolution. These changes will at times seem too painful to bear, that can be expected. However the changes are vital for our future evolution. For without change we would squander all the hard work of the many who have come before us. But together, united in community, and in vision, we shall keep the Python dream alive for many years to come! From python.list at tim.thechases.com Tue Jan 25 21:12:23 2011 From: python.list at tim.thechases.com (Tim Chase) Date: Tue, 25 Jan 2011 20:12:23 -0600 Subject: WxPython versus Tkinter. In-Reply-To: <1b955dcf-77e2-4130-9b5b-276cfedccd9c@a10g2000vby.googlegroups.com> References: <4D3E4377.3060807@tysdomain.com> <9MB%o.14110$%64.6074@unlimited.newshosting.com> <5a5e15f3-ae0f-4561-8969-e9afde3829dc@g26g2000vba.googlegroups.com> <1b955dcf-77e2-4130-9b5b-276cfedccd9c@a10g2000vby.googlegroups.com> Message-ID: <4D3F8307.1030309@tim.thechases.com> On 01/25/2011 07:07 PM, rantingrick wrote: > What is it going to take for you (and others) to take me seriously? Easy: Stop ranting, start writing quality code. -tkc From bryan.oakley at gmail.com Tue Jan 25 21:13:53 2011 From: bryan.oakley at gmail.com (Bryan) Date: Tue, 25 Jan 2011 18:13:53 -0800 (PST) Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com> <9MB%o.14110$%64.6074@unlimited.newshosting.com> <5a5e15f3-ae0f-4561-8969-e9afde3829dc@g26g2000vba.googlegroups.com> <1b955dcf-77e2-4130-9b5b-276cfedccd9c@a10g2000vby.googlegroups.com> Message-ID: On Jan 25, 7:07?pm, rantingrick wrote: > What is it going to take for you (and others) to take me seriously? If somebody answers that question, will you listen? That will be the first step. I know that may sound facetious but that's not my intention. It's my honest opinion based entirely on this single thread. Take a deep breath and listen to what people are telling you. You need to stop being intolerably illogical, childish, contentious and abusive. You are screaming in a room while covering your ears and closing your eyes and stomping your feet. Even if your argument had merit, nobody cares because you are too difficult to deal with to the point that it has become sadly humorous. You are very effectively sabotaging the very cause you are trying to promote due entirely to your poor attitude. From andre.roberge at gmail.com Tue Jan 25 22:10:54 2011 From: andre.roberge at gmail.com (=?ISO-8859-1?Q?Andr=E9?=) Date: Tue, 25 Jan 2011 19:10:54 -0800 (PST) Subject: WxPython versus Tkinter. In-Reply-To: Message-ID: <2b6f6afc-9150-4478-8c80-e7b4f9d74363@glegroupsg2000goo.googlegroups.com> On Tuesday, January 25, 2011 10:12:23 PM UTC-4, Tim Chase wrote: > On 01/25/2011 07:07 PM, rantingrick wrote: > > What is it going to take for you (and others) to take me seriously? > > Easy: Stop ranting, start writing quality code. > +1 Andr? > -tkc From andre.roberge at gmail.com Tue Jan 25 22:10:54 2011 From: andre.roberge at gmail.com (=?ISO-8859-1?Q?Andr=E9?=) Date: Tue, 25 Jan 2011 19:10:54 -0800 (PST) Subject: WxPython versus Tkinter. In-Reply-To: Message-ID: <2b6f6afc-9150-4478-8c80-e7b4f9d74363@glegroupsg2000goo.googlegroups.com> On Tuesday, January 25, 2011 10:12:23 PM UTC-4, Tim Chase wrote: > On 01/25/2011 07:07 PM, rantingrick wrote: > > What is it going to take for you (and others) to take me seriously? > > Easy: Stop ranting, start writing quality code. > +1 Andr? > -tkc From python at mrabarnett.plus.com Tue Jan 25 22:32:08 2011 From: python at mrabarnett.plus.com (MRAB) Date: Wed, 26 Jan 2011 03:32:08 +0000 Subject: WxPython versus Tkinter. In-Reply-To: <2b6f6afc-9150-4478-8c80-e7b4f9d74363@glegroupsg2000goo.googlegroups.com> References: <2b6f6afc-9150-4478-8c80-e7b4f9d74363@glegroupsg2000goo.googlegroups.com> Message-ID: <4D3F95B8.6060701@mrabarnett.plus.com> On 26/01/2011 03:10, Andr? wrote: > On Tuesday, January 25, 2011 10:12:23 PM UTC-4, Tim Chase wrote: >> On 01/25/2011 07:07 PM, rantingrick wrote: >>> What is it going to take for you (and others) to take me seriously? >> >> Easy: Stop ranting, start writing quality code. >> > +1 > Andr? > +1 From sohel807 at gmail.com Tue Jan 25 22:51:01 2011 From: sohel807 at gmail.com (Akand Islam) Date: Tue, 25 Jan 2011 19:51:01 -0800 (PST) Subject: adding "Print" menu in wxPython References: <05c1f4b3-941c-45b1-9370-a88653d1083a@e16g2000pri.googlegroups.com> Message-ID: <66d035ae-cb4f-4ad3-836d-f8394ad90475@q8g2000prm.googlegroups.com> Thanks for your response. Actually I already know I have to create "OnPrint" method followed by adding the menu named "Print" that calls "OnPrint" method. But the problem I am facing is to implement it. Here are the codes I am adding (from Tutorial) which make an editor and I want to add printing option so that I can print whatever is written in the editor. I will appreciate if you add coding with this file. =========================================================================================== import wx import os.path class MainWindow(wx.Frame): def __init__(self, filename='noname.txt'): super(MainWindow, self).__init__(None, size=(400,200)) self.filename = filename self.dirname = '.' self.CreateInteriorWindowComponents() self.CreateExteriorWindowComponents() def CreateInteriorWindowComponents(self): ''' Create "interior" window components. In this case it is just a simple multiline text control. ''' self.control = wx.TextCtrl(self, style=wx.TE_MULTILINE) def CreateExteriorWindowComponents(self): ''' Create "exterior" window components, such as menu and status bar. ''' self.CreateMenu() self.CreateStatusBar() self.SetTitle() def CreateMenu(self): fileMenu = wx.Menu() for id, label, helpText, handler in \ [(wx.ID_ABOUT, '&About', 'Information about this program', self.OnAbout), (wx.ID_OPEN, '&Open', 'Open a new file', self.OnOpen), (wx.ID_SAVE, '&Save', 'Save the current file', self.OnSave), (wx.ID_SAVEAS, 'Save &As', 'Save the file under a different name', self.OnSaveAs), (None, None, None, None), (wx.ID_EXIT, 'E&xit', 'Terminate the program', self.OnExit)]: if id == None: fileMenu.AppendSeparator() else: item = fileMenu.Append(id, label, helpText) self.Bind(wx.EVT_MENU, handler, item) menuBar = wx.MenuBar() menuBar.Append(fileMenu, '&File') # Add the fileMenu to the MenuBar self.SetMenuBar(menuBar) # Add the menuBar to the Frame def SetTitle(self): # MainWindow.SetTitle overrides wx.Frame.SetTitle, so we have to # call it using super: super(MainWindow, self).SetTitle('Editor %s'%self.filename) # Helper methods: def defaultFileDialogOptions(self): ''' Return a dictionary with file dialog options that can be used in both the save file dialog as well as in the open file dialog. ''' return dict(message='Choose a file', defaultDir=self.dirname, wildcard='*.*') def askUserForFilename(self, **dialogOptions): dialog = wx.FileDialog(self, **dialogOptions) if dialog.ShowModal() == wx.ID_OK: userProvidedFilename = True self.filename = dialog.GetFilename() self.dirname = dialog.GetDirectory() self.SetTitle() # Update the window title with the new filename else: userProvidedFilename = False dialog.Destroy() return userProvidedFilename # Event handlers: def OnAbout(self, event): dialog = wx.MessageDialog(self, 'A sample editor\n' 'in wxPython', 'About Sample Editor', wx.OK) dialog.ShowModal() dialog.Destroy() def OnExit(self, event): self.Close() # Close the main window. def OnSave(self, event): textfile = open(os.path.join(self.dirname, self.filename), 'w') textfile.write(self.control.GetValue()) textfile.close() def OnOpen(self, event): if self.askUserForFilename(style=wx.OPEN, **self.defaultFileDialogOptions()): textfile = open(os.path.join(self.dirname, self.filename), 'r') self.control.SetValue(textfile.read()) textfile.close() def OnSaveAs(self, event): if self.askUserForFilename(defaultFile=self.filename, style=wx.SAVE, **self.defaultFileDialogOptions()): self.OnSave(event) app = wx.App() frame = MainWindow() frame.Show() app.MainLoop() ==================================================================================== -- Akand On Jan 25, 6:54?pm, rantingrick wrote: > On Jan 25, 5:52?pm, Akand Islam wrote: > > > > > I will appreciate if someone please show me how to add > > printing option. > > Hello Akand, > > Well the first step would be to create a stub "OnPrint" method and add > a command to the File menu named "Print" that calls the "OnPrint" > method. Can you do this part yourself? All the answers you need are in > the source you linked to. Give it your best shot and then post some > code with a specific question if you get stuck. From steve+comp.lang.python at pearwood.info Tue Jan 25 23:21:40 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 26 Jan 2011 04:21:40 GMT Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com> <9MB%o.14110$%64.6074@unlimited.newshosting.com> <5a5e15f3-ae0f-4561-8969-e9afde3829dc@g26g2000vba.googlegroups.com> <1b955dcf-77e2-4130-9b5b-276cfedccd9c@a10g2000vby.googlegroups.com> Message-ID: <4d3fa153$0$29983$c3e8da3$5496439d@news.astraweb.com> On Tue, 25 Jan 2011 20:12:23 -0600, Tim Chase wrote: > On 01/25/2011 07:07 PM, rantingrick wrote: >> What is it going to take for you (and others) to take me seriously? > > Easy: Stop ranting, start writing quality code. Quality code is a good thing, but there are people who write good code but are so obnoxious that you wouldn't listen to a word they have to say, and people who are only mediocre or average coders, but are otherwise helpful and friendly. I'm amazed that Rick actually asked that question. Was he being sarcastic? In virtually every thread he takes part in, he is implicitly or explicitly told what he needs to do to be taken seriously: - stop ranting; - it's not all about him; - stop using "we" when he really means "me"; - he is not the conscience of the Python community; - stop pretending to be speaking for the community when it's obvious the community doesn't agree with him; - stop insulting everyone unless they agree with him; - if people don't agree with Rick, that doesn't mean they're in thrall to a hide-bound reactionary elite that has lost all touch with what makes Python good; - enough with the hero-worship of Guido (except when he's insulting Guido as well); - stop demanding others do all the work -- if Rick thinks something should be done, he should start a project and begin building it, then ask for volunteers to help; - listen to others' criticisms, don't just dismiss them without thought; - there's no shame in being mistaken if you are big enough to admit, and learn from, your errors; - enough with the over-blown melodrama, Python isn't going to be destroyed just because there's some tiny little corner that doesn't meet Rick's idea of perfection. That would do for starters. TL;DR. The shorter version: stop being a dick, and people will treat you seriously. -- Steven From tyler at tysdomain.com Tue Jan 25 23:37:06 2011 From: tyler at tysdomain.com (Littlefield, Tyler) Date: Tue, 25 Jan 2011 21:37:06 -0700 Subject: WxPython versus Tkinter. In-Reply-To: <1b955dcf-77e2-4130-9b5b-276cfedccd9c@a10g2000vby.googlegroups.com> References: <4D3E4377.3060807@tysdomain.com> <9MB%o.14110$%64.6074@unlimited.newshosting.com> <5a5e15f3-ae0f-4561-8969-e9afde3829dc@g26g2000vba.googlegroups.com> <1b955dcf-77e2-4130-9b5b-276cfedccd9c@a10g2000vby.googlegroups.com> Message-ID: <4D3FA4F2.6070307@tysdomain.com> >What do you think Emile? I think that that starts with you. You want to be more accepting when it comes to you, but you've had no problems calling people an idiot and otherwise insulting them just as you are complaining about. On 1/25/2011 6:07 PM, rantingrick wrote: > On Jan 25, 6:55 pm, Emile van Sebille wrote: > >> Oh, that everyone should blindly accept you as is and without regard for >> established protocols > What protocols? Where is this standard posted? Can you give me a link? > I would like to know what is expected of me. > >> -- we certainly should all jump to your slightest >> whim. >> >> Get a [CENSORED] clue. > Thats not very nice Emile. > > What is it going to take for you (and others) to take me seriously? I > have been within this group for more than four years and you still do > not accept me. I have been ridiculed, brow beaten, laughed at, > trolled, and any negative thing that can be done to someone. Heck, in > my very first post i was crucified by the community. I'll admit that I > have made some mistakes -- and i have apologized for them. Maybe you > need to be a little more accepting of me. Maybe this group IS not a > homogeneous block as you would like. Maybe we ALL need to be a little > more humble to each other. > > What do you think Emile? > -- Thanks, Ty From rustompmody at gmail.com Wed Jan 26 00:26:45 2011 From: rustompmody at gmail.com (rusi) Date: Tue, 25 Jan 2011 21:26:45 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <8q7sgiF5tpU1@mid.individual.net> <19891784-d6a3-41ac-a097-5902a6323bc0@o21g2000prn.googlegroups.com> <0b12cdb1-45b4-41e4-9bdb-074ee669d76b@k14g2000pre.googlegroups.com> Message-ID: <68c131c6-4d70-4587-a16f-8fc5a6f44de3@m13g2000yqb.googlegroups.com> On Jan 25, 11:15?pm, Terry Reedy wrote: > On 1/25/2011 10:29 AM, rusi wrote: > > > > > Just trying to sift the BS from the real issues > > > Heres a list of the issues relating to GUI toolkits > > > Look > > Nativity-1 (as in apps look like other apps on the OS) > > Nativity-2 (as in uses 'bare-metal' and not a separate interpreter) > > Themeing (ttk) > > Efficiency (extra interpreter) > > Cross Platform > > Stability (crashes on some OSes) > > Programmability > > Accessibility > > i18n > > Availability of gui builder > > Licence > > Good as far as it goes, but this list leaves out several requirements > (already posted by me, Steve Hansen, and others) for a Python 3 new > stdlib module. It does not matter for the stdlib if wxpython is 3 times > as good as tkinter, by some measure, as long as it is ineligible. > > -- > Terry Jan Reedy Thanks Terry -- so I add that to the list Works with Python 3 Look Nativity-1 (as in apps look like other apps on the OS) Nativity-2 (as in uses 'bare-metal' and not a separate interpreter) Themeing (ttk) Efficiency (extra interpreter) Cross Platform Stability (crashes on some OSes) Programmability Accessibility i18n Availability of gui builder Licence I should have mentioned earlier (doing it now) -- it maybe better to deal with this list breadth-first -- ie to expand it to include all the issues rather than going depth-first into each one. There are surely others like: Fun to use (very important when teaching/learning but hard to quantify) RR: You gave equal weights to each point. This does not work in general. eg I am chary about using a toolkit that crashes (If crashes are ok why not use C/C++ ?) And there is another dimension to the "breadth" which needs inclusion -- Qt and Gtk are equally contenders with Tkinter and Wx. (Any others Ive missed?) From nair331 at gmail.com Wed Jan 26 00:54:31 2011 From: nair331 at gmail.com (nair rajiv) Date: Wed, 26 Jan 2011 11:24:31 +0530 Subject: python interpreter Message-ID: Hi, I was exploring python. I wanted to know more about the python interpreter i.e the technical details of how it has been written. If I am directed to the code that also will be fine. The implementation of python data structures lists, tuples and dictionaries. If there exists any online documentation on the implementation aspects of python, please direct me to it. Rajiv Nair -------------- next part -------------- An HTML attachment was scrubbed... URL: From hidura at gmail.com Wed Jan 26 00:55:02 2011 From: hidura at gmail.com (Hidura) Date: Wed, 26 Jan 2011 01:55:02 -0400 Subject: How to execute foreing code from Python In-Reply-To: References: <20cf30433cec39ebdb049a8ae637@google.com> <4D3CC6C4.3060502@ieee.org> Message-ID: Hello, i understand how to execute a command on the terminal in linux, but what i can't get it is the execution of programs and send the data as arguments, the problem is that i can't execute the program and when i execute the program give me an error with the stdin... This is the code: argPath = "test1" args = open(argPath, 'w') if self.extract.getByAttr(self.block, 'name', 'args') != None: args.write(""+self.extract.getByAttr(self.block, 'name', 'args')[0].toxml()+"") else: args.write('') car = Popen(shlex.split('python3.1 /home/hidura/webapps/karinapp/Suite/ForeingCode/saveCSS.py', stdin=args, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True) args.close() dataOut = car.stdout.read().decode() log = car.stderr.read().decode() if dataOut!='': return dataOut.split('\n') elif log != '': return log.split('\n')[0] else: return None And the code from the saveCSS.py from xml.dom.minidom import parseString import os import sys class savCSS: """This class has to save the changes on the css file. """ def __init__(self, args): document = parseString(args) request = document.firstChild address = request.getElementsByTagName('element')[0] newdata = request.getElementsByTagName('element')[1] cssfl = open("/webapps/karinapp/Suite/"+address.getAttribute('value'), 'r') cssData = cssfl.read() cssfl.close() dataCSS = '' for child in newdata.childNodes: if child.nodeType == 3: dataCSS += child.nodeValue nwcssDict = {} for piece in dataCSS.split('}'): nwcssDict[piece.split('{')[0]] = piece.split('{')[1] cssDict = {} for piece in cssData.split('}'): cssDict[piece.split('{')[0]] = piece.split('{')[1] for key in nwcssDict: if key in cssDict == True: del cssDict[key] cssDict[key] = nwcssDict[key] result = '' for key in cssDict: result += key+"{"+cssDict[key]+"}" cssfl = open(cssfl.name, 'a') cssfl.write(result) cssfl.close() if __name__ == "__main__": print(sys.stdin) savCSS(input) On Sun, Jan 23, 2011 at 10:16 PM, Hidura wrote: > Thanks to all for your fast responses. I will use this on a server > running on Linux, so there is no problem with the OS and probably i > will try to pipes and subprocess, but the pipes worry me because i > can't stop the process using timeout or i don't found how to stop > it... > > > 2011/1/23, Dan Stromberg : > > On Sun, Jan 23, 2011 at 4:24 PM, Dave Angel wrote: > >> On 01/-10/-28163 02:59 PM, hidura at gmail.com wrote: > >>> > >>> Hello i want to code from different languages using a Python script i > >>> know i can use os.system, but i don't know how to receive data or send > >>> arguments using that method if theres any another way to make it or > >>> there's a way to send arguments and receive data using os.system? > >>> > >>> Thanks in advance. > >>> > >> > >> That sentence runs on, and makes no sense to me. But I can guess that > you > >> would like to be able to write code in other languages, and call it from > >> within a Python script. > > > > Well, clearly it made some sense, or you wouldn't be responding. > > > >> If you're on Windows, and the other language is a compiled one like C, > >> compile it into a DLL, and call that DLL from Python. Ctypes is the > first > >> module to study. > > > > The DLL is but a weak mimicry of what *ix had for a long time before. > > On most *ix's, the .so is the analog to the windows DLL, though only > > AIX appears to suffer from the same kind of "DLL hell" that windows > > suffers from (which makes some historical if not technical sense, > > given that windows is related to OS/2, which like AIX is also from > > IBM). Using a .so, you can still use ctypes. You also have the > > option of using Cython, which is perhaps a bit better supported on > > *ix, but will likely now work on windows too. > > > >> If you're on Linux, and the code in the other language was written by > >> someone else, and is already compiled into an executable you cannot > >> change, > > > > This is rare on Linux - almost everything is changeable on Linux, > > because it is almost entirely opensource - sometimes entirely so, > > depending on distribution choice and what 3rd party apps you install > > after the OS install. > > > >> you probably should invoke it using the subprocess module. > > > > This is an option on almost any OS, and in fact is probably a pretty > > good one on almost any OS, even if you do have source. Sadly, few > > windows programs are written to take advantage of this, perhaps > > because of the historical (dos/windows) command.com's fake pipes. > > > > You can communicate with a subprocess using pipes, or command line > > arguments, or files, or sockets, or shared memory. There are probably > > other options that aren't coming to mind just now. But usually, using > > pipes gives the loosest (best) coupling between processes. > > > > Microsoft appears to have recognized this to some extent by releasing > > powershell - though it uses object pipes rather than byte stream > > pipes. Object pipes appear to require less serialization, but also > > appear to be less loosely coupled. For remote pipes, powershell > > serializes to XML, while *ix pipes serialize exactly the same way > > remote local or remote. > > > > -- > Enviado desde mi dispositivo m?vil > > Diego I. Hidalgo D. > -- Diego I. Hidalgo D. -------------- next part -------------- An HTML attachment was scrubbed... URL: From orasnita at gmail.com Wed Jan 26 01:08:40 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Wed, 26 Jan 2011 08:08:40 +0200 Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <8q7sgiF5tpU1@mid.individual.net> <19891784-d6a3-41ac-a097-5902a6323bc0@o21g2000prn.googlegroups.com><0b12cdb1-45b4-41e4-9bdb-074ee669d76b@k14g2000pre.googlegroups.com> <048FB74272D440A0915ABC7D76AE262B@teddy> Message-ID: <5782E9AD8A8342D691EB3549E5E0ED7B@octavian> From: "Emile van Sebille" >> Why is WxPython ineligible? > > I think Terry's point was compatibility with python3 -- which wx > apparently isn't yet. > > Emile Well, I didn't know this, and it is a valid reason. This means that it is true that there is no enough maintainance force to keep WxPython updated. Did I understand correctly? Octavian From orasnita at gmail.com Wed Jan 26 01:18:37 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Wed, 26 Jan 2011 08:18:37 +0200 Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com><9MB%o.14110$%64.6074@unlimited.newshosting.com><59F6E65E3D9A46AD8D7A3863F3C1DC84@teddy> <27f53f8c-7862-4366-9352-82ae9a2f3970@k3g2000yqc.googlegroups.com> Message-ID: <7F4FDC467BCF47D4A069B29246FBDB17@octavian> From: "rantingrick" On Jan 25, 3:41 pm, Corey Richardson wrote: > Do you honestly think he was talking about the accessibility problem? > IMO that should move to another thread, because this one is simply > about, as the subject suggests, "WxPython versus Tkinter". Corey again (like many) you lack a global perspective. Anybody who has read along with his thread knows we are covering some pretty big issues here. WxPython is just the vehicle. The big picture is simply: Tkinter is old and in many ways insufficient for 21st century GUIs. We need to decide what should come next. I believe wxPython is our best hope. Wx may not be the best it can be, but it is the best we have at this time. There is more than "meets the eye" Corey! -- I will tell you what I think and many of you won't like this. :-) I think that nothing is "sufficient" and nothing should last forever. The people don't need Tkinter. They don't need WxPython. They don't need Python. Do you think that Python is a language that will be used forever? The people don't necessarily need to use a computer. Do you think that the computers as they are today will be used until the end of the time? The people do need to have an easier life, to make as little efforts as possible and to obtain as much benefit as possible and for the moment the computers and Python and a GUI lib help them do this, so these things are just some other means for obtaining what they need. What we don't agree is that some of the list members think that only the selfishness is the right ATITUDE AND SAY THAT I should change mine because I should care more about my own benefits and don't care at all about the others. Octavian From rantingrick at gmail.com Wed Jan 26 01:19:28 2011 From: rantingrick at gmail.com (rantingrick) Date: Tue, 25 Jan 2011 22:19:28 -0800 (PST) Subject: adding "Print" menu in wxPython References: <05c1f4b3-941c-45b1-9370-a88653d1083a@e16g2000pri.googlegroups.com> <66d035ae-cb4f-4ad3-836d-f8394ad90475@q8g2000prm.googlegroups.com> Message-ID: <7775b108-b04b-44a9-abae-1e58842b3186@b25g2000vbz.googlegroups.com> On Jan 25, 9:51?pm, Akand Islam wrote: > Thanks for your response. Actually I already know I have to create > "OnPrint" method followed by adding the menu named "Print" that calls > "OnPrint" method. But the problem I am facing is to implement it. Here > are the codes I am adding (from Tutorial) which make an editor and I > want to add printing option so that I can print whatever is written in > the editor. I will appreciate if you add coding with this file. Well i don't see where you added the methods or the menu command. * scratches head* Man I've got to tell you that this code is a horrible example to learn from! The styling abominations and obfuscation is just simply atrocious! It seems the author was trying to confuse everyone including himself! So i modified it just a bit. I added the OnPrint method however i am leaving it up to you to build the Print menu and do the binding. I put some comments where you need to add the print menu. Just look at how the other menus are created and you'll figure it out ;) Let us know if you need more help. #--START CODE--# import wx import os.path, sys class MainWindow(wx.Frame): def __init__(self, filename='noname.txt'): wx.Frame.__init__(self, None, size=(400,200)) self.filename = filename self.dirname = '.' self.control = wx.TextCtrl(self, style=wx.TE_MULTILINE) self.CreateMenu() self.CreateStatusBar() self.SetTitle() def CreateMenu(self): fileMenu = wx.Menu() item = fileMenu.Append(wx.ID_ABOUT, '&About', 'Info') self.Bind(wx.EVT_MENU, self.OnAbout, item) item = fileMenu.Append( wx.ID_OPEN, '&Open', 'Info') self.Bind(wx.EVT_MENU, self.OnOpen, item) item = fileMenu.Append(wx.ID_SAVE, '&Save', 'Info') self.Bind(wx.EVT_MENU, self.OnSave, item) item = fileMenu.Append(wx.ID_SAVEAS, 'Save &As', 'Info') self.Bind(wx.EVT_MENU, self.OnSaveAs, item) # psst: Hey put the print menu here!!!! # psst: do the binding here!!!! fileMenu.AppendSeparator() item = fileMenu.Append(wx.ID_EXIT, 'E&xit', 'Terminate the program') self.Bind(wx.EVT_MENU, self.OnExit, item) menuBar = wx.MenuBar() menuBar.Append(fileMenu, '&File') # Add the fileMenu to the MenuBar self.SetMenuBar(menuBar) # Add the menuBar to the Frame def SetTitle(self): # MainWindow.SetTitle overrides wx.Frame.SetTitle, so we have to # call it using super: super(MainWindow, self).SetTitle('Editor %s'%self.filename) def defaultFileDialogOptions(self): ''' Return a dictionary with file dialog options that can be used in both the save file dialog as well as in the open file dialog. ''' return dict( message='Choose a file', defaultDir=self.dirname, wildcard='*.*' ) def askUserForFilename(self, **dialogOptions): dialog = wx.FileDialog(self, **dialogOptions) if dialog.ShowModal() == wx.ID_OK: userProvidedFilename = True self.filename = dialog.GetFilename() self.dirname = dialog.GetDirectory() self.SetTitle() # Update the window title with the new filename else: userProvidedFilename = False dialog.Destroy() return userProvidedFilename # Event handlers: def OnAbout(self, event): dialog = wx.MessageDialog(self, 'A sample editor\n' 'in wxPython', 'About Sample Editor', wx.OK) dialog.ShowModal() dialog.Destroy() def OnExit(self, event): self.Close() # Close the main window. def OnSave(self, event): textfile = open(os.path.join(self.dirname, self.filename), 'w') textfile.write(self.control.GetValue()) textfile.close() def OnOpen(self, event): if self.askUserForFilename( style=wx.OPEN,**self.defaultFileDialogOptions() ): textfile = open(os.path.join(self.dirname, self.filename), 'r') self.control.SetValue(textfile.read()) textfile.close() def OnSaveAs(self, event): if self.askUserForFilename( defaultFile=self.filename, style=wx.SAVE, **self.defaultFileDialogOptions() ): self.OnSave(event) def OnPrint(self, event): sys.stdout.write(self.control.GetValue()) app = wx.App() frame = MainWindow() frame.Show() app.MainLoop() #--END CODE--# From orasnita at gmail.com Wed Jan 26 01:25:22 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Wed, 26 Jan 2011 08:25:22 +0200 Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com><9MB%o.14110$%64.6074@unlimited.newshosting.com> <59F6E65E3D9A46AD8D7A3863F3C1DC84@teddy> <27f53f8c-7862-4366-9352-82ae9a2f3970@k3g2000yqc.googlegroups.com> Message-ID: <718D13777F254C839F9564BC4275DE0A@octavian> From: "Emile van Sebille" > On 1/25/2011 3:33 PM rantingrick said... > >> Tkinter is old and in many ways insufficient for 21st century GUIs. We >> need to decide what should come next. I believe wxPython is our best >> hope. Wx may not be the best it can be, but it is the best we have at >> this time. > > Then you should immediately volunteer to bring wxPython to python3 > compatibility -- as it is, it's not even close... > > Start thinking about upping your game from ranting to doing. > > Emile Hi Emile, >From my point of view this discussion is finished for the moment, because you are right, WxPython is not as fast developed as it needs, because Python 3 is not compatible with Python 2. If no solution is found for this big problem, then yes, WxPython can't be included in the Python distribution because there is nothing that can be included. I don't know why you didn't say this before. :-) The other part of the discussion is related to the accessibility and care for accessibility and that discussion is not nice at all, because it shows how selfish are most of the people and they consider this a virtue. Octavian From orasnita at gmail.com Wed Jan 26 01:33:25 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Wed, 26 Jan 2011 08:33:25 +0200 Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com><9MB%o.14110$%64.6074@unlimited.newshosting.com> <59F6E65E3D9A46AD8D7A3863F3C1DC84@teddy> Message-ID: <1A345664905B4009B482F0EDF4ECE7DA@octavian> From: "Emile van Sebille" > Are third party installations nonsense? Or should python come with all > libraries for all potential applications? And then always keep up with > best of breed? Python should not include all the libraries for all the potential applications, but it should promote the tools that don't generate discrimination without even willing to do that. If there is no accessible portable GUI lib for Python 3 as you said, then it is very normal that Python can't promote it, because there is nothing to promote if Python 3 doesn't offer accessible portable interfaces. But this is the real reason and not the fact that the accessibility shouldn't be important nor that my atitude of caring for the others is not right and should be changed with a more selfish one. Octavian From tjreedy at udel.edu Wed Jan 26 01:53:06 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Wed, 26 Jan 2011 01:53:06 -0500 Subject: Need GUI pop-up to edit a (unicode ?) string In-Reply-To: <541c02df-b1fc-4376-bf17-e0531fe5c4bf@r29g2000yqj.googlegroups.com> References: <3tqr08-bj2.ln1@murmur.very.softly> <7691fe98-37af-4ddf-a8a8-eadeef0d4a6e@y2g2000prf.googlegroups.com> <541c02df-b1fc-4376-bf17-e0531fe5c4bf@r29g2000yqj.googlegroups.com> Message-ID: On 1/25/2011 6:02 PM, rantingrick wrote: > This design pattern promotes reuse-ability and encapsulation. However > with Fredricks design you cannot configure the contained widgets after > creating the instance because the dialog has entered a local event > loop brought on by "self.wait_window(self)" which is in the DAMN > INITIAL METHOD! I only see "self.wait_window(self)" in the Dialog base class and not in SimpleDialog, which is what I though you were talking about. It is the last line of Dialog.__init__. It appears that the intention is that all configuration be done in the body and button_box methods which are called earlier. > This is a major flaw in the design and i would be > happy to fix the flaw. However our "friend" Fredrick decided to > copyright the module to himself! As far as I know, anything contributed to the stdlib has been licensed by the author to be redistributed under the Python license and can be patched by the developers. (This is one reason for people to not contribute their code to the stdlib.) -- Terry Jan Reedy From rantingrick at gmail.com Wed Jan 26 01:54:47 2011 From: rantingrick at gmail.com (rantingrick) Date: Tue, 25 Jan 2011 22:54:47 -0800 (PST) Subject: adding "Print" menu in wxPython References: <05c1f4b3-941c-45b1-9370-a88653d1083a@e16g2000pri.googlegroups.com> <66d035ae-cb4f-4ad3-836d-f8394ad90475@q8g2000prm.googlegroups.com> <7775b108-b04b-44a9-abae-1e58842b3186@b25g2000vbz.googlegroups.com> Message-ID: On Jan 26, 12:19?am, rantingrick wrote: Actually i found more cruft. Here is something that would be acceptable although i had to wrap lines shorter than i normally would for the sake of Usenet. Who ever wrote that code should be lashed 50 times! You still need some error handling for the open and save file methods but crikey i can't do everything ;-) #--STARTCODE--# import wx import os.path, sys class MainWindow(wx.Frame): def __init__(self, filename='noname.txt'): wx.Frame.__init__(self, None, size=(400,200)) self.filename = filename self.dirname = '.' self.control = wx.TextCtrl(self, style=wx.TE_MULTILINE) self.CreateMenu() self.CreateStatusBar() self.SetTitle('Editor %s'%self.filename) self.dlgdefaults = { 'message':'Choose a file', 'defaultDir':self.dirname, 'wildcard':'*.*' } def CreateMenu(self): fileMenu = wx.Menu() item = fileMenu.Append(wx.ID_ABOUT, '&About', 'Info') self.Bind(wx.EVT_MENU, self.OnAbout, item) item = fileMenu.Append( wx.ID_OPEN, '&Open', 'Info') self.Bind(wx.EVT_MENU, self.OnOpen, item) item = fileMenu.Append(wx.ID_SAVE, '&Save', 'Info') self.Bind(wx.EVT_MENU, self.OnSave, item) item = fileMenu.Append(wx.ID_SAVEAS, 'Save &As', 'Info') self.Bind(wx.EVT_MENU, self.OnSaveAs, item) # # psst: Hey put the print menu here!!!! # psst: do the binding here!!!! # fileMenu.AppendSeparator() item = fileMenu.Append(wx.ID_EXIT, 'E&xit', 'Exit') self.Bind(wx.EVT_MENU, self.OnExit, item) menuBar = wx.MenuBar() # Add the fileMenu to the MenuBar menuBar.Append(fileMenu, '&File') # Add the menuBar to the Frame self.SetMenuBar(menuBar) def askUserForFilename(self, **kw): dialog = wx.FileDialog(self, **kw) if dialog.ShowModal() == wx.ID_OK: userProvidedFilename = True self.filename = dialog.GetFilename() self.dirname = dialog.GetDirectory() self.SetTitle('Editor %s'%(self.filename)) else: userProvidedFilename = False dialog.Destroy() return userProvidedFilename def OnAbout(self, event): dialog = wx.MessageDialog( self, 'A sample editor in wxPython', 'About Sample Editor', wx.OK ) dialog.ShowModal() dialog.Destroy() def OnExit(self, event): self.Close() def OnSave(self, event): textfile = open(os.path.join(self.dirname, self.filename), 'w') textfile.write(self.control.GetValue()) textfile.close() def OnOpen(self, event): if self.askUserForFilename( style=wx.OPEN, **self.dlgdefaults ): textfile = open(os.path.join(self.dirname, self.filename), 'r') self.control.SetValue(textfile.read()) textfile.close() def OnSaveAs(self, event): if self.askUserForFilename( defaultFile=self.filename, style=wx.SAVE, **self.dlgdefaults ): self.OnSave(event) def OnPrint(self, event): sys.stdout.write(self.control.GetValue()) app = wx.App() frame = MainWindow() frame.Show() app.MainLoop() #--ENDCODE--# From orasnita at gmail.com Wed Jan 26 02:10:27 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Wed, 26 Jan 2011 09:10:27 +0200 Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com><9MB%o.14110$%64.6074@unlimited.newshosting.com><4A48EDF6D7634F2E994661A457451E87@teddy> Message-ID: <753A4C5A6658470085804B13C80340F2@octavian> From: "geremy condra" > There's a difference between what you say and how you say it. If a > friend came up to you and said "give me $100 right now!", you probably > wouldn't do it. If the same friend came up to you and said "I know > this is a big thing to ask, but I really need $100 and I can't > guarantee I'll be able to pay you back. Could you please help me?" I Are you even thinking that the second sentence is much harder to express? Do you imagine that my knowledge of English is limited by the fact that it is not my native language and it is a language not spoken by very many people in my country? I simply might not be able to express so nice as you like that I need 100 bucks from you, but I might be able to just tell you that "need 100 dollars. now". I could argue much more nice and expressive if we were speaking Romanian and not English. But I don't condemn you for this, because many years ago when I was in school I had the opinion that some foreign colleagues are a little stupid just because they were not able to express very well the ideas which were not very simple, and well, they were not stupid at all, but they didn't know my language well enough and they probably would think the same thing about me if we were speaking in Russian. > don't know very many people who would refuse if they were able to > help. The reason is simple: the first does not acknowledge the value > of the person doing the favor, and the second does. Exactly what I said. They are doing the same mistake as I did 20 years ago. By the way, can't you see any syntactic dissacords in my phrases? Haven't you think that my English might not be as fluent to be able to express everything I want to say very well? > More concretely, you have an opinion that not supporting accessibility > is discrimination. Tyler has an opinion that not supporting > accessibility is a bug. This is not always true. Not supporting accessibility when *it is not possible* yes, it is a bug as you say, so we agree here. But not supporting accessibility because the programmer *doesn't want this*, it is not a bug, but discrimination. Don't you agree with this? And if Python would have been able to support accessibility it would have mean that it promotes discrimination because it promotes the wrong tool, but it seems that Python 3 doesn't have an accessible GUI lib for the moment, so no, it is not discrimination (but Emile told us that there is no support for WxPython in Python 3 just today, so I didn't know this and I already wondered why nobody told about this real problem). > Are you going to demand that he change his > opinion? Or are you going to ask that he consider yours? It seems that the discrimination should be something that should be discussed if and when it should be applied, isn't it? Well, I think that everyone should understand why the programs must be accessible and why everybody should care about all the users of an application and that it is not normal to not care. >> Have I said something wrong? Did I use bad words? Or what was it wrong? > > I think it was uncivil. It was rude, unkind, and generally > disagreeable. I lost respect for you, and by proxy, for your point of > view. In other words, you lost support not because fewer people agree > with your position, but because fewer people want to agree with you. You are also very unkind and rude when you say that the disabled that need to use a screen reader should be a kind of second hand people that need to beg for a little accessibility. When you create a program, why do you create a visual interface for it? Why don't you create just an audio interface? You do this because otherwise you would not please those who can see. Why shouldn't be something normal, and that *should be not be discussable at all* to offer the same accessibility to everyone? And you didn't say what was rude from what I said. You said just that it was rude. Oh yes I know that it is unkind because most of the people don't even like to talk personally with disabled people, but this doesn't mean that the disabled people are something not normal, but those who have those biases towards those who are very different. >> I have just an opinion, but that opinion won't change until the opinion >> of those who pretend that the discrimination is something normal. >> Do you think that this is not normal? > > I didn't ask you to change your opinion. I told you that you would be > more effective if you changed your attitude. Like rantingrick, you're > free to ignore that advice, but it is good advice for both you and the > community, and I urge you to take it. About what community? It would be better for the community of the disabled? Or you don't care about that community? >> Or you recommend me to be just like Tyler that can't use all the apps he >> could use if they were accessible, but he doesn't care because he cares >> much more to play nice in order to be accepted in this not-right society? > > I would recommend that you learn to be civil to those you disagree > with. The alternative is to be surrounded by them. Aha, you show that old fact that the majority is more important because it has more power, the fact Tyler is afraid. The majority can be also wrong, the majority can also have bad feelings, and that majority that have the power to change things should be informed and convinced to change them. If the majority doesn't care about the minorities which are minorities without willing to be so, then it means that it is wrong. Octavian From rantingrick at gmail.com Wed Jan 26 02:11:27 2011 From: rantingrick at gmail.com (rantingrick) Date: Tue, 25 Jan 2011 23:11:27 -0800 (PST) Subject: Need GUI pop-up to edit a (unicode ?) string References: <3tqr08-bj2.ln1@murmur.very.softly> <7691fe98-37af-4ddf-a8a8-eadeef0d4a6e@y2g2000prf.googlegroups.com> <541c02df-b1fc-4376-bf17-e0531fe5c4bf@r29g2000yqj.googlegroups.com> Message-ID: <3f724ff2-d571-4f50-92e1-45eaf9ab163d@r16g2000prh.googlegroups.com> On Jan 26, 12:53?am, Terry Reedy wrote: > I only see "self.wait_window(self)" in the Dialog base class and not in > SimpleDialog, which is what I though you were talking about. It is the > last line of Dialog.__init__. Yes. In the module "tkSimpleDialog" the class "Dialog" is what i am referring to. Sorry for the confusion. > It appears that the intention is that all > configuration be done in the body and button_box methods which are > called earlier. Yes exactly. And this works well most of the time. However there are many times where you may want to create a dialog with say a Label. And you do not want to hard code the string displayed on the label. However you cannot change the string once you initialize the dialog because it enters a "modal wait loop". So what i am proposing is that we change tkSimpleDialog to be like any other modal dialogs out there. We move the modal code into a show method and use the dialog like i suggested. I can send you a patch if you would be interested. My patch does break backward compatibility. However we can make it compatible somehow. Or an alternative approach would be to create a new dialog module and then depreciate tkSimpleDialog. Let me know on or off list if you are interested. > As far as I know, anything contributed to the stdlib has been licensed > by the author to be redistributed under the Python license and can be > patched by the developers. (This is one reason for people to not > contribute their code to the stdlib.) I don't understand what that means. Are you suggesting that contributing code is bad? From orasnita at gmail.com Wed Jan 26 02:27:43 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Wed, 26 Jan 2011 09:27:43 +0200 Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com> <9MB%o.14110$%64.6074@unlimited.newshosting.com> Message-ID: <10BC7C2D6ECE4DAE8D7866CDFDA51911@octavian> From: "Nicholas Devenish" > Octavian, we get it - you are on the warpath about accessibility. And this > is, in a way, a good thing, because, yes, programmers should in general > think more about accessibility when designing their programs. But nobody > was ever persuaded to consider a complicated and subtle issue by hostile > holier-than-thou arrogance, which is what rantingricks posts started out > with, and what your posts have been slowly turning into. This is what is > 'not a good thing', in case you genuinely didn't understand the context of > my previous message. Look at the response your earlier posts got, with > experienced developers showing an interest in actually trying out > accessibility tools. Compare this with the defensive replies you have been > getting more recently. Hi Nicholas, Thank you for your nice words. I admit that I don't understand absolutely everything (for example I have met "holier-than-thou" only in a song of Metallica, but I don't know what it really means :-) I know only that Tk is very old and it is still not accessible and it doesn't mean too much if some developers say that they are interested in making it accessible, because even with a hard work, a GUI lib like Tkinter may be made accessible only after years of work, because the accessibility standards change, the main OS used by the majority of users also change... and I thought that Python already offers a solution for this problem. However I can see that for the moment it doesn't offer it because WxPython is not compatible with Python 3. (I am wondering if there would be any change if Python 3 could be used with WxPython). > But this thread is not about that, and the accessibility issue is mostly a > red herring that rantingrick has grabbed hold of to swing around like a > battleaxe, because nobody is going to say that accessibility doesn't > matter. Discrimination in many forms, is a real problem in our societies, > and one that is not going to be solved overnight, much as you might wish > it. Stigmatizing perfectly repectful people who haven't encountered your > needs before, or don't agree that accessibility is the only thing that > matters, is not going to solve any issues. Well, I am on this list just for a few weeks, and I don't know yet who is respectable and who is not, who is an expert or not, and so on. I just expressed my opinion that if there is a solution for accessibility it should be prefered and it should be promoted by Python. Actually this is the main idea. Nobody should force the developers to use that accessible solution, but those who don't use it should understand and accept that they are using a not recommended and a wrong tool. Of course that there may be many cases in which such a wrong tool would be prefered for commercial reasons, but the developers that do that should understand that they are doing something wrong. Octavian From orasnita at gmail.com Wed Jan 26 02:40:41 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Wed, 26 Jan 2011 09:40:41 +0200 Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com><9MB%o.14110$%64.6074@unlimited.newshosting.com><5a5e15f3-ae0f-4561-8969-e9afde3829dc@g26g2000vba.googlegroups.com><1b955dcf-77e2-4130-9b5b-276cfedccd9c@a10g2000vby.googlegroups.com> <4d3fa153$0$29983$c3e8da3$5496439d@news.astraweb.com> Message-ID: <5DA17921A6C04D0EB337FBDFD9B5D41E@octavian> From: "Steven D'Aprano" > Quality code is a good thing, but there are people who write good code > but are so obnoxious that you wouldn't listen to a word they have to say, > and people who are only mediocre or average coders, but are otherwise > helpful and friendly. > > I'm amazed that Rick actually asked that question. Was he being sarcastic? > > In virtually every thread he takes part in, he is implicitly or > explicitly told what he needs to do to be taken seriously: > > - stop ranting; > - it's not all about him; > - stop using "we" when he really means "me"; > - he is not the conscience of the Python community; > - stop pretending to be speaking for the community when it's > obvious the community doesn't agree with him; > - stop insulting everyone unless they agree with him; > - if people don't agree with Rick, that doesn't mean they're in > thrall to a hide-bound reactionary elite that has lost all > touch with what makes Python good; > - enough with the hero-worship of Guido (except when he's > insulting Guido as well); > - stop demanding others do all the work -- if Rick thinks > something should be done, he should start a project and begin > building it, then ask for volunteers to help; > - listen to others' criticisms, don't just dismiss them without > thought; > - there's no shame in being mistaken if you are big enough to > admit, and learn from, your errors; > - enough with the over-blown melodrama, Python isn't going to be > destroyed just because there's some tiny little corner that > doesn't meet Rick's idea of perfection. > > > That would do for starters. > > > TL;DR. The shorter version: stop being a dick, and people will treat you > seriously. > Wow! now I think I understand some of the atitudes on this list. It seems that some of the list members know each other very well, and they have strong opinions, maybe for good reasons, I don't know, and I just dropped some messages without knowing who is considered good, who is the bad, who are those with valuable opinions and so on. I am sorry if I offended someone, but the main idea I just wanted to express was that Python should promote the accessibility and deprecate those tools which are not accessible. That's all. It should not force anyone to use anything but it just promote the right tools (which is not the case now, but it seems that there is a technical reason for this... the fact that WxPython can't be used in Python 3). Octavian From me+list/python at ixokai.io Wed Jan 26 03:08:01 2011 From: me+list/python at ixokai.io (Stephen Hansen) Date: Wed, 26 Jan 2011 00:08:01 -0800 Subject: WxPython versus Tkinter. In-Reply-To: <4d3fa153$0$29983$c3e8da3$5496439d@news.astraweb.com> References: <4D3E4377.3060807@tysdomain.com> <9MB%o.14110$%64.6074@unlimited.newshosting.com> <5a5e15f3-ae0f-4561-8969-e9afde3829dc@g26g2000vba.googlegroups.com> <1b955dcf-77e2-4130-9b5b-276cfedccd9c@a10g2000vby.googlegroups.com> <4d3fa153$0$29983$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4D3FD661.6050508@ixokai.io> On 1/25/11 8:21 PM, Steven D'Aprano wrote: > TL;DR. The shorter version: stop being a dick, and people will treat you > seriously. I actually read the original list, and agreed with every point. But this concise summary spells it out perfectly. Stop being a dick, rick. -- Stephen Hansen ... Also: Ixokai ... Mail: me+list/python (AT) ixokai (DOT) io ... Blog: http://meh.ixokai.io/ -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 487 bytes Desc: OpenPGP digital signature URL: From ahsanbagwan at gmail.com Wed Jan 26 03:08:41 2011 From: ahsanbagwan at gmail.com (sl33k_) Date: Wed, 26 Jan 2011 00:08:41 -0800 (PST) Subject: Syntax help Message-ID: <5029d50e-06e2-408f-b9ef-be7c649d8616@fu15g2000vbb.googlegroups.com> How to read syntax like this given in the documentation of python? (Newbie) defparameter ::= parameter ["=" expression] http://docs.python.org/reference/compound_stmts.html#function-definitions From arnodel at gmail.com Wed Jan 26 03:10:23 2011 From: arnodel at gmail.com (Arnaud Delobelle) Date: Wed, 26 Jan 2011 08:10:23 +0000 Subject: A and B but not C in list References: <8cae2caf-d3df-4ed3-9afb-29de97772298@m13g2000yqb.googlegroups.com> Message-ID: <87zkqo9jbk.fsf@gmail.com> Terry Reedy writes: > On 1/23/2011 4:05 PM, CM wrote: >> In Python, is there a recommended way to write conditionals of the >> form: >> >> "if A and B but not C or D in my list, do something." ? >> >> I may also have variations on this, like "if A but not B, C, or D". >> >> Do I have to just write out all the if and elifs with all possible >> conditions, or is there a handier and more code-maintainable way to >> deal with this? > > The straightforward code > > if a in L and b in L and c not in L and d not in L > > scans the list 4 times. One scan be be done generically as follows: > > def req_pro(iterable, required = set(), prohibited = set()): > for item in iterable: > if item in prohibited: > return False > elif item in required: > required.remove(item) > else: > return not required # should now be empty > > if req_pro(my_list, {A,B}, {C,D}): ... > # untested, of course.. But what's better? Four fast list scans or one slow one? -- Arnaud From tjreedy at udel.edu Wed Jan 26 03:11:55 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Wed, 26 Jan 2011 03:11:55 -0500 Subject: Need GUI pop-up to edit a (unicode ?) string In-Reply-To: <3f724ff2-d571-4f50-92e1-45eaf9ab163d@r16g2000prh.googlegroups.com> References: <3tqr08-bj2.ln1@murmur.very.softly> <7691fe98-37af-4ddf-a8a8-eadeef0d4a6e@y2g2000prf.googlegroups.com> <541c02df-b1fc-4376-bf17-e0531fe5c4bf@r29g2000yqj.googlegroups.com> <3f724ff2-d571-4f50-92e1-45eaf9ab163d@r16g2000prh.googlegroups.com> Message-ID: On 1/26/2011 2:11 AM, rantingrick wrote: > On Jan 26, 12:53 am, Terry Reedy wrote: > >> I only see "self.wait_window(self)" in the Dialog base class and not in >> SimpleDialog, which is what I though you were talking about. It is the >> last line of Dialog.__init__. > > Yes. In the module "tkSimpleDialog" In 3.x, the module is now tk.simpledialog -- all lower case. The purpose of all lowercase module names is to avoid confusion with upper case class names. > the class "Dialog" is what i am > referring to. Sorry for the confusion. and there is also a SimpleDialog class. > >> It appears that the intention is that all >> configuration be done in the body and button_box methods which are >> called earlier. > > Yes exactly. And this works well most of the time. However there are > many times where you may want to create a dialog with say a Label. And > you do not want to hard code the string displayed on the label. > However you cannot change the string once you initialize the dialog > because it enters a "modal wait loop". So what i am proposing is that > we change tkSimpleDialog to be like any other modal dialogs out there. SimpleDialog has a go method. Dialog does not, but I see no reason (yet) why it could not. > We move the modal code into a show method and use the dialog like i > suggested. I can send you a patch if you would be interested. I saw that first and was puzzled what you were asking. Clearer now. > My patch > does break backward compatibility. However we can make it compatible > somehow. Or an alternative approach would be to create a new dialog > module and then depreciate tkSimpleDialog. Let me know on or off list > if you are interested. > >> As far as I know, anything contributed to the stdlib has been licensed >> by the author to be redistributed under the Python license and can be >> patched by the developers. (This is one reason for people to not >> contribute their code to the stdlib.) > > I don't understand what that means. Are you suggesting that > contributing code is bad? If you write code and want to keep absolute control over it -- the api, the doc, the coding style, and the test methods -- then yes it can be bad, especially for people who are not active core developers. Contributing can also be a great -- if the module already meets with approval or if one is flexible and wants the critical review and likely improvement and increased usage. It depends on one's goal in writing the code. -- Terry Jan Reedy From geoff.bache at gmail.com Wed Jan 26 03:17:33 2011 From: geoff.bache at gmail.com (Geoff Bache) Date: Wed, 26 Jan 2011 09:17:33 +0100 Subject: Finding the right Python executable on Windows In-Reply-To: References: <38326da6-8b30-4f88-b232-acdcd33b7d61@o14g2000yqe.googlegroups.com> Message-ID: On Tue, Jan 25, 2011 at 3:24 PM, Brian Curtin wrote: > On Tue, Jan 25, 2011 at 04:25, Geoff Bache wrote: >> >> Hi all, >> >> I have a Python process on Windows and would like to start a Python >> subprocess using the same interpreter. I wonder how to go about this? >> >> First, I tried the obvious >> >> subprocess.Popen([ sys.executable, "subproc.py", ... ]) >> >> but that fails, because my process has a "native launcher", (i.e. C: >> \path\mylauncher.exe, which is just a wrapper around the Python >> program) and hence sys.executable returns this path instead of the >> interpreter location. It isn't appropriate to use the launcher for the >> subprocess. >> >> I also tried using sys.exec_prefix but there didn't seem to be any >> standard location for the interpreter under this directory in any >> case. >> >> I feel certain there must be some way to do this as it seems a rather >> basic thing somehow, can anyone give me a hint? >> >> Regards, >> Geoff Bache > > If?sys.executable doesn't work due to this "native launcher", you could > try?something like this: >>>> import os >>>> import sys >>>> full_path = None >>>> for path in sys.path: > ... ? ? full = os.path.join(path, "python.exe") > ... ? ? if os.path.exists(full): > ... ? ? ? ? ? ? full_path = full > ... >>>> full_path > 'c:\\python31\\python.exe' Thanks Brian! It never occurred to me that the Python executable would be on sys.path, but it seems to be on the installations I've tried on Windows. It isn't on other platforms of course, but it's easy enough to only do this on Windows. I wonder why it's like this? I can't see anything in that directory I could import... Regards, Geoff From nagle at animats.com Wed Jan 26 03:18:20 2011 From: nagle at animats.com (John Nagle) Date: Wed, 26 Jan 2011 00:18:20 -0800 Subject: trouble installing MySQLdb (cygwin) + Bonus question In-Reply-To: References: <501470fc-c588-47d2-954d-17d825c5191c@v17g2000prc.googlegroups.com> <4d3f41d9$0$44021$742ec2ed@news.sonic.net> Message-ID: <4d3fd8c2$0$44011$742ec2ed@news.sonic.net> On 1/25/2011 3:51 PM, Matthew Roth wrote: > On Jan 25, 6:20 pm, David Robinow wrote: >> On Tue, Jan 25, 2011 at 5:59 PM, Matthew Roth wrote: >>> On Jan 25, 9:34 pm, John Nagle wrote: >> ... >>>> You can install a MySQL server under Windows, and talk to the server >>>> from the Cygwin environment. That's a useful way to test. >> >>>> John Nagle >> >>> Right, that is precisely what I have. I am able to talk to it from >>> cygwin, however, during the installing of the MySQLdb module it cannot >>> find the mysql_config. This is because It is not installed? The setup >>> sees that I am on a posix system not windows, as python is installed >>> in cygwin, a virtual posix system. I am trying to bulid a mysql client >>> from source for cygwin, however, I am running into an error there. >> >>> Unless, can I talk to the windows mysql_config? if so, what does that >>> look like >> >> The obvious answer is to use a Windows python. You haven't explained >> why you think you need to run a cygwin python. Can you explain that? > > > Good question. There isn't a solid explanation. heretofore, I have > been using a lot of bash scripting in combination with awk sed and > some perl. I was directed to look into python. My tasks were becoming > increasingly complex and memory intensive. I started with a desire to > connect to a mysql server. For that I needed to install the MySQLdb > module. I am having difficultly in acomplishment of this task. I > suppose for the time it has taken, using windows python would have > been the simpler route. Oh. And all this time, I thought it was because you needed to run on a Linux server and were using Cygwin for debugging. I routinely develop Python on Windows and run on Linux servers. This works fine, provided that you can find versions of any necessary C modules for Python for both platforms. John Nagle From rustompmody at gmail.com Wed Jan 26 03:33:52 2011 From: rustompmody at gmail.com (rusi) Date: Wed, 26 Jan 2011 00:33:52 -0800 (PST) Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com><9MB%o.14110$%64.6074@unlimited.newshosting.com><59F6E65E3D9A46AD8D7A3863F3C1DC84@teddy> <27f53f8c-7862-4366-9352-82ae9a2f3970@k3g2000yqc.googlegroups.com> Message-ID: On Jan 26, 11:18?am, "Octavian Rasnita" wrote: > From: "rantingrick" > On Jan 25, 3:41 pm, Corey Richardson wrote: > > > Do you honestly think he was talking about the accessibility problem? > > IMO that should move to another thread, because this one is simply > > about, as the subject suggests, "WxPython versus Tkinter". > > Corey again (like many) you lack a global perspective. Anybody who has > read along with his thread knows we are covering some pretty big > issues here. WxPython is just the vehicle. The big picture is simply: > Tkinter is old and in many ways insufficient for 21st century GUIs. We > need to decide what should come next. I believe wxPython is our best > hope. Wx may not be the best it can be, but it is the best we have at > this time. There is more than "meets the eye" Corey! > -- > > I will tell you what I think and many of you won't like this. :-) > I think that nothing is "sufficient" and nothing should last forever. > > The people don't need Tkinter. They don't need WxPython. They don't need > Python. Do you think that Python is a language that will be used forever? > The people don't necessarily need to use a computer. Do you think that the > computers as they are today will be used until the end of the time? > > The people do need to have an easier life, to make as little efforts as > possible and to obtain as much benefit as possible and for the moment the > computers and Python and a GUI lib help them do this, so these things are > just some other means for obtaining what they need. > > What we don't agree is that some of the list members think that only the > selfishness is the right ATITUDE AND SAY THAT I should change mine because I > should care more about my own benefits and don't care at all about the > others. > > Octavian Hi Octavian, Normally I would expect talks of selfishness etc to be too OT for a python list. However since nobody is saying that (yet) let me point you to a passage from the upanishads: http://www.hindu-blog.com/2007/10/brihadaranyaka-upanishads-quotes-sage.html From steve+comp.lang.python at pearwood.info Wed Jan 26 03:40:40 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 26 Jan 2011 08:40:40 GMT Subject: Syntax help References: <5029d50e-06e2-408f-b9ef-be7c649d8616@fu15g2000vbb.googlegroups.com> Message-ID: <4d3fde08$0$29983$c3e8da3$5496439d@news.astraweb.com> On Wed, 26 Jan 2011 00:08:41 -0800, sl33k_ wrote: > How to read syntax like this given in the documentation of python? > (Newbie) > > defparameter ::= parameter ["=" expression] > > http://docs.python.org/reference/compound_stmts.html#function- definitions See here for an explanation: http://docs.python.org/reference/introduction.html#notation What you are looking at is not Python code, instead it is a formal description of what Python syntax looks like, based on a slightly modified BNF syntax: http://en.wikipedia.org/wiki/Backus?Naur_Form This tells you that a "defparameter" looks like a "parameter" followed optionally by an equals sign and an expression. For example, here is a line of Python code: def function(x, y=42**3): "x" is a defparameter made up of a parameter on it's own, while "y=42**3" is a defparameter made up of three parts: the parameter part "y", the equals sign, and the expression part "42**3". -- Steven From ch at thansen.de Wed Jan 26 03:51:47 2011 From: ch at thansen.de (ch at thansen.de) Date: Wed, 26 Jan 2011 09:51:47 +0100 Subject: Syntax help In-Reply-To: <5029d50e-06e2-408f-b9ef-be7c649d8616@fu15g2000vbb.googlegroups.com> References: <5029d50e-06e2-408f-b9ef-be7c649d8616@fu15g2000vbb.googlegroups.com> Message-ID: On 26.01.2011 09:08, sl33k_ wrote: > How to read syntax like this given in the documentation of python? > (Newbie) > > defparameter ::= parameter ["=" expression] http://en.wikipedia.org/wiki/Backus-Naur_Form From mailing at franzoni.eu Wed Jan 26 04:00:57 2011 From: mailing at franzoni.eu (Alan Franzoni) Date: Wed, 26 Jan 2011 10:00:57 +0100 Subject: Behaviour-based interface/protocol implementation? In-Reply-To: References: Message-ID: On Tue, Jan 25, 2011 at 6:48 PM, Terry Reedy wrote: > This is correct! > > print(len(mo)) > TypeError: object of type 'MyObj' has no len() That's interesting. I must admit I was not thinking about special methods in my original post, I used that example just because of Chris response. by the way, define 'correct' - if that means 'that's how this works in python', it's a tautology, not correctness :-) Instead I think this highlights an asymmetry in how python handles special methods, and makes it less ducktyped than I wanted. Consider this: class MyObject(object): @staticmethod def __len__(): return 1 mo = MyObject() print mo.__len__ print len(mo) class LenObj(object): def __len__(self): return 3 lo = LenObj() print lo.__len__ print len(lo) import types class OtherObj(object): pass oo = OtherObj() def __len__(self): return 2 oo.__len__ = types.MethodType(__len__, oo, OtherObj) print oo.__len__ print len(oo) Output: 1 > 3 > Traceback (most recent call last): File "pymethods.py", line 34, in print len(oo) TypeError: object of type 'OtherObj' has no len() The problem is not "function attributes" - the problem is that the __len__() method must be set on the class, not on the instance. I think this is not completely clear here: http://docs.python.org/reference/datamodel.html By the way, my original post didn't take into account special methods - let's suppose they don't exist for a moment. I'd just like to check *at runtime* whether an object *any object!* respects a certain signature. *I don't want to care about the class of that object because I want true duck typing*. I mean, I should be able to pass *anything* that responds to a certain contract: @DuckType class MyInterface(object): def someMethod(self): pass def otherMethod(self, a, b): pass class SomeObj(object): @classmethod def someMethod(cls): pass @classmethod def otherMethod(cls, a, b): pass class OtherObj(object): def someMethod(self): pass def otherMethod(cls, a, b): pass class ThirdObj(object): pass oo = OtherObj() to = ThirdObj() to.someMethod = lambda: None to.otherMethod = lambda a,b: None MyInterface.maybe_implemented_by(oo) # -> True MyInterface.maybe_implemented_by(to) # -> True MyInterface.maybe_implemented_by(SomeObj) # -> True That's just what I'd like and I suppose can't be currently done with current ABC, PyProtocols or zope.interface implementations, right? -- Alan Franzoni -- contact me at public@[mysurname].eu From johann.spies at gmail.com Wed Jan 26 04:07:33 2011 From: johann.spies at gmail.com (Johann Spies) Date: Wed, 26 Jan 2011 11:07:33 +0200 Subject: Convert XML to SQL Message-ID: I an not a Python newbie but working with xml is new to me. I get data through a soap connection, using suds, and want to convert that to objects which I can use to populate a rather complex database. I have been able to parse the xml using tree = etree.iterparse(infile,events=("start","end")) but it seems like a lot of work to get that to sql-objects. I have seen references to lxml.objectify and have created a object containing the contents of a whole file using tree = objectify.parse(fileobject) That object contains for example the data of 605 records and I do not know how to use it. I could not figure out from the lxml.objectify documentation how to do it. In the end I want to use data from about 54 fields of each records. I would like to have a list of dictionaries as a result of the parsing. From there it should not be too difficult to create sql. I have seen some references to BeautifulSoap but I am not sure which is the best way to go. So: Is there a better tool than lxml to do this? Is it possible to do it just using suds? The suds documentation did not really help me to do this with complex data. Are there good tutorials for the xml->sql process? Regards Johann -- May grace and peace be yours in abundance through the full knowledge of God and of Jesus our Lord! His divine power has given us everything we need for life and godliness through the full knowledge of the one who called us by his own glory and excellence. 2 Pet. 1:2b,3a -------------- next part -------------- An HTML attachment was scrubbed... URL: From orasnita at gmail.com Wed Jan 26 04:29:11 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Wed, 26 Jan 2011 11:29:11 +0200 Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com><9MB%o.14110$%64.6074@unlimited.newshosting.com><59F6E65E3D9A46AD8D7A3863F3C1DC84@teddy><27f53f8c-7862-4366-9352-82ae9a2f3970@k3g2000yqc.googlegroups.com> Message-ID: From: "rusi" On Jan 26, 11:18 am, "Octavian Rasnita" wrote: > From: "rantingrick" > On Jan 25, 3:41 pm, Corey Richardson wrote: > > > Do you honestly think he was talking about the accessibility problem? > > IMO that should move to another thread, because this one is simply > > about, as the subject suggests, "WxPython versus Tkinter". > > Corey again (like many) you lack a global perspective. Anybody who has > read along with his thread knows we are covering some pretty big > issues here. WxPython is just the vehicle. The big picture is simply: > Tkinter is old and in many ways insufficient for 21st century GUIs. We > need to decide what should come next. I believe wxPython is our best > hope. Wx may not be the best it can be, but it is the best we have at > this time. There is more than "meets the eye" Corey! > -- > > I will tell you what I think and many of you won't like this. :-) > I think that nothing is "sufficient" and nothing should last forever. > > The people don't need Tkinter. They don't need WxPython. They don't need > Python. Do you think that Python is a language that will be used forever? > The people don't necessarily need to use a computer. Do you think that the > computers as they are today will be used until the end of the time? > > The people do need to have an easier life, to make as little efforts as > possible and to obtain as much benefit as possible and for the moment the > computers and Python and a GUI lib help them do this, so these things are > just some other means for obtaining what they need. > > What we don't agree is that some of the list members think that only the > selfishness is the right ATITUDE AND SAY THAT I should change mine because > I > should care more about my own benefits and don't care at all about the > others. > > Octavian Hi Octavian, Normally I would expect talks of selfishness etc to be too OT for a python list. However since nobody is saying that (yet) let me point you to a passage from the upanishads: http://www.hindu-blog.com/2007/10/brihadaranyaka-upanishads-quotes-sage.html -- Nice passage, but I think that you have also noticed that the most important things it talks about are the closed people, the gods, the brahmana and kshatriya, but well, in India there other chasts than brahmana and kshatriya but only these 2 chasts of priests - the spiritual power and the military - the force power are considered important. The indian culture is great for many things, but it is not great when talking about discrimination, because even now that their laws forbid the chasts-based discrimination, many people there still believe that somebody from brahman or kshatriya chasts have a bigger value than the others. I don't say that those people are not right, nor that those who have the power are not more valuable than the others right now, but I say that it is not normal to consider this way of thinking a right way, because on the long term this should change and there should be no privileged group. Octavian From stefan_ml at behnel.de Wed Jan 26 04:29:35 2011 From: stefan_ml at behnel.de (Stefan Behnel) Date: Wed, 26 Jan 2011 10:29:35 +0100 Subject: Convert XML to SQL In-Reply-To: References: Message-ID: Johann Spies, 26.01.2011 10:07: > I an not a Python newbie but working with xml is new to me. > > I get data through a soap connection, using suds, and want to convert that > to objects which I can use to populate a rather complex database. Your problem description is pretty comprehensive in general. It would be helpful to see an example snippet of the XML that you parse. > I have been able to parse the xml using > > tree = etree.iterparse(infile,events=("start","end")) but it seems like a > lot of work to get that to sql-objects. > > I have seen references to lxml.objectify and have created a object > containing the contents of a whole file using > > tree = objectify.parse(fileobject) > > That object contains for example the data of 605 records and I do not know > how to use it. I could not figure out from the lxml.objectify documentation > how to do it. > > In the end I want to use data from about 54 fields of each records. I would > like to have a list of dictionaries as a result of the parsing. From there > it should not be too difficult to create sql. I think iterparse() is a good way to deal with this, as is objectify. iterparse() has the advantage that you can dispose of handled records, thus keeping memory usage low (if that's an issue here). Using objectify, you would usually do something like this: tree = objectify.parse(fileobject) root = tree.getroot() for record in root.xml_record_tag: title_name = record.title.text It really just depends on what your XML looks like. In the above, I assumed that each record hangs directly below the root tag and is called "xml_record_tag". I also assumed that each record has a "title" tag with text content. With iterparse(), you would intercept on your record elements and then use the ElementTree API, commonly the findtext() and findall() methods of the root object, to get at the specific record fields. Like this: for _, element in ET.iterparse(fileobject): if element.tag == 'xml_record_tag': title_name = element.findtext('title') Does this help? Stefan From __peter__ at web.de Wed Jan 26 04:43:06 2011 From: __peter__ at web.de (Peter Otten) Date: Wed, 26 Jan 2011 10:43:06 +0100 Subject: List behaviours with Clustering Algorithm References: <4D3DEBEB.1020700@funkymonkeysoftware.com> Message-ID: James Ravenscroft wrote: >> > I can't run your code because you didn't make it standalone, > Thanks for the heads up, I've made a simple version of the clusterer > which you can view on pastebin: http://pastebin.com/7HmAkmfj If you have > time to look through my code I would be very grateful! > > > >> > but in your case that is probably not enough. >> > Try something along these lines: >> > >> > # untested >> > while len(self.clusters) > 1: >> > c = self.clusters.pop() >> > # find closest index >> > for i, c2 in enumerate(self.clusters): >> > ... >> > if ...: >> > closest_index = i >> > closest = self.clusters.pop(closest_index) >> > tmp.append(c + closest) >> > if self.clusters: >> > tmp.append(self.clusters[0]) > I had a go at implementing something along the lines above and I'm still > getting very bizarre results. There does appear to be some sort of logic > to it though, if you look at the graph chart, you can see that It seems > to be doing the clustering right and then forgetting to remove the old > groupings providing this "cloning" effect for some cluster groups. I'm sorry I can't infer the intended algorithm from the code you provide. Perhaps you can give a short description in plain English? However, here's the implementation of the algorithm you mention as described on wikipedia: http://en.wikipedia.org/wiki/Cluster_analysis#Agglomerative_hierarchical_clustering Repeatedly merge the two closest clusters until there's only one left. To keep track of the two merged clusters I've added a "children" key to your node dictionaries. The intermediate states of the tree are also put into the levels variable (I suppose that's the purpose of your levels attribute). The main difference to your code is that (1) list modifications occur only in the outer while loop, so both inner loops can become for-loops again. (2) test all pairs before choosing the pair debug = True def cluster(self): '''Run the clustering operation on the files ''' clusters = [] #add a cluster for each track to clusters for song in self.music: clusters.append({'data' : [song]}) levels = [] while len(clusters) > 1: # calculate weights for c in clusters: c["weight"] = self.__getClusterWeight(c['data']) # find closest pair closestDelta = float('inf') closestPair = None for i, a in enumerate(clusters): for k, b in enumerate(clusters): if i == k: break delta = abs(a['weight'] - b['weight']) if delta < closestDelta: closestPair = i, k closestDelta = delta # merge closest pair hi, lo = closestPair left = clusters[lo] right = clusters.pop(hi) clusters[lo] = {"data": left["data"] + right["data"], "children": [left, right]} # keep track of the intermediate tree states levels.append(list(clusters)) if self.debug: print ("stage %d" % len(levels)).center(40, "-") for c in clusters: print c["data"] # store tree self.clusters = clusters self.levels = levels Note that there's some potential for optimisation. For example, you could move the weight calculation out of the while-loop and just calculate the weight for the newly merged node. Peter From jeanmichel at sequans.com Wed Jan 26 05:05:51 2011 From: jeanmichel at sequans.com (Jean-Michel Pichavant) Date: Wed, 26 Jan 2011 11:05:51 +0100 Subject: Syntax help In-Reply-To: <5029d50e-06e2-408f-b9ef-be7c649d8616@fu15g2000vbb.googlegroups.com> References: <5029d50e-06e2-408f-b9ef-be7c649d8616@fu15g2000vbb.googlegroups.com> Message-ID: <4D3FF1FF.1000808@sequans.com> sl33k_ wrote: > How to read syntax like this given in the documentation of python? > (Newbie) > > defparameter ::= parameter ["=" expression] > > http://docs.python.org/reference/compound_stmts.html#function-definitions > Just in case you're about to learn python using these defintions: Nobody's learning a syntax that way. They are not meant to be understood by newcommers. They are accurate, non amiguous, exhaustive definition of the syntax. Some people familiar with working on grammars may effectively use it, but the majority of the people will prefer a fine explanation with examples (provided right after the grammar defintions). Unless you really need to work on some python parsing stuff, you can just ignore them. JM From stefan_ml at behnel.de Wed Jan 26 05:51:06 2011 From: stefan_ml at behnel.de (Stefan Behnel) Date: Wed, 26 Jan 2011 11:51:06 +0100 Subject: Convert XML to SQL In-Reply-To: References: Message-ID: Stefan Behnel, 26.01.2011 10:29: > Johann Spies, 26.01.2011 10:07: >> I an not a Python newbie but working with xml is new to me. >> >> I get data through a soap connection, using suds, and want to convert that >> to objects which I can use to populate a rather complex database. > > Your problem description is pretty comprehensive in general. It would be > helpful to see an example snippet of the XML that you parse. [example received in private e-mail] >> I have been able to parse the xml using >> >> tree = etree.iterparse(infile,events=("start","end")) but it seems like a >> lot of work to get that to sql-objects. >> >> I have seen references to lxml.objectify and have created a object >> containing the contents of a whole file using >> >> tree = objectify.parse(fileobject) >> >> That object contains for example the data of 605 records and I do not know >> how to use it. I could not figure out from the lxml.objectify documentation >> how to do it. >> >> In the end I want to use data from about 54 fields of each records. I would >> like to have a list of dictionaries as a result of the parsing. From there >> it should not be too difficult to create sql. > > I think iterparse() is a good way to deal with this, as is objectify. > iterparse() has the advantage that you can dispose of handled records, thus > keeping memory usage low (if that's an issue here). > > Using objectify, you would usually do something like this: > > tree = objectify.parse(fileobject) > root = tree.getroot() > for record in root.xml_record_tag: > title_name = record.title.text > > It really just depends on what your XML looks like. In the above, I assumed > that each record hangs directly below the root tag and is called > "xml_record_tag". I also assumed that each record has a "title" tag with > text content. The example you sent me is almost perfect for lxml.objectify. Basically, you'd do something like this: for record in root.REC: refs = [ ref.text for ref in record.item.refs.ref ] publisher = record.item.copyright.publisher.text for issue in record.issue: units = [ unit.text for unit in issue.units.unit ] and so on. The same in ET: for record in root.findall('REC'): refs = [ ref.text for ref in record.findall('item/refs/ref') ] publisher = record.findtext('item/copyright/publisher') for issue in record.findall('issue'): units = [ unit.text for unit in issue.findall('units/unit') ] Not much harder either. Stefan From xheruacles at gmail.com Wed Jan 26 05:59:26 2011 From: xheruacles at gmail.com (Xavier Heruacles) Date: Wed, 26 Jan 2011 18:59:26 +0800 Subject: how to read the last line of a huge file??? Message-ID: I have do some log processing which is usually huge. The length of each line is variable. How can I get the last line?? Don't tell me to use readlines or something like linecache... -------------- next part -------------- An HTML attachment was scrubbed... URL: From davea at ieee.org Wed Jan 26 06:59:52 2011 From: davea at ieee.org (Dave Angel) Date: Wed, 26 Jan 2011 06:59:52 -0500 Subject: python interpreter In-Reply-To: References: Message-ID: <4D400CB8.90300@ieee.org> On 01/-10/-28163 02:59 PM, nair rajiv wrote: > Hi, > > I was exploring python. I wanted to know more about the python > interpreter i.e the technical details of how it has been written. If I am > directed > to the code that also will be fine. The implementation of python data > structures lists, tuples and dictionaries. > If there exists any online documentation on the implementation aspects > of python, please direct me to it. > > > Rajiv Nair > For sources: Go to www.Python.org, and click on the link on the left side called "Source Distribution" If yo do that in the 2.7.1 section you'll get a file called python-2.7.1.tar.bz2 Or you could click a little lower, and get the sources to 3.1.3 DaveA From johann.spies at gmail.com Wed Jan 26 07:22:14 2011 From: johann.spies at gmail.com (Johann Spies) Date: Wed, 26 Jan 2011 14:22:14 +0200 Subject: Convert XML to SQL In-Reply-To: References: Message-ID: On 26 January 2011 12:51, Stefan Behnel wrote: > > The example you sent me is almost perfect for lxml.objectify. Basically, > you'd do something like this: > > Thank you very much. You have helped me a lot. Regards Johann -- May grace and peace be yours in abundance through the full knowledge of God and of Jesus our Lord! His divine power has given us everything we need for life and godliness through the full knowledge of the one who called us by his own glory and excellence. 2 Pet. 1:2b,3a -------------- next part -------------- An HTML attachment was scrubbed... URL: From stefan_ml at behnel.de Wed Jan 26 07:37:21 2011 From: stefan_ml at behnel.de (Stefan Behnel) Date: Wed, 26 Jan 2011 13:37:21 +0100 Subject: Convert XML to SQL In-Reply-To: References: Message-ID: Johann Spies, 26.01.2011 13:22: > On 26 January 2011 12:51, Stefan Behnel wrote: >> The example you sent me is almost perfect for lxml.objectify. Basically, >> you'd do something like this: >> > Thank you very much. You have helped me a lot. You're welcome. If you have any suggestions how to improve the documentation of lxml.objectify, you can take the opportunity to give something back. Stefan From python.list at tim.thechases.com Wed Jan 26 07:39:50 2011 From: python.list at tim.thechases.com (Tim Chase) Date: Wed, 26 Jan 2011 06:39:50 -0600 Subject: Syntax help In-Reply-To: <4D3FF1FF.1000808@sequans.com> References: <5029d50e-06e2-408f-b9ef-be7c649d8616@fu15g2000vbb.googlegroups.com> <4D3FF1FF.1000808@sequans.com> Message-ID: <4D401616.5090209@tim.thechases.com> On 01/26/2011 04:05 AM, Jean-Michel Pichavant wrote: >> How to read syntax like this given in the documentation of python? >> (Newbie) >> >> defparameter ::= parameter ["=" expression] > > Just in case you're about to learn python using these defintions: > > Nobody's learning a syntax that way. > They are not meant to be understood by newcommers. They are accurate, > non amiguous, exhaustive definition of the syntax. I second Jen-Michel's suggestion -- it's like learning to drive by reading the Chilton's (mechanic's manual) and all your local/national laws on transportation. I suppose it's theoretically possible, but you likely want something geared at teaching, and only reach for this when you're in trouble :) -tkc From tyler at tysdomain.com Wed Jan 26 09:20:56 2011 From: tyler at tysdomain.com (Littlefield, Tyler) Date: Wed, 26 Jan 2011 07:20:56 -0700 Subject: WxPython versus Tkinter. Message-ID: <4D402DC8.6080806@tysdomain.com> >Exactly what I said. They are doing the same mistake as I did 20 years ago. and are still making now... Lack of English and grammar isn't the problem... From tyler at tysdomain.com Wed Jan 26 09:23:20 2011 From: tyler at tysdomain.com (Littlefield, Tyler) Date: Wed, 26 Jan 2011 07:23:20 -0700 Subject: WxPython versus Tkinter. Message-ID: <4D402E58.9090001@tysdomain.com> >I don't know why you didn't say this before. Comprehention, Octavian. I've made that point multiple times, but your to stuck on talking about how selfish people are. >The other part of the discussion is related to the accessibility and care for >accessibility and that discussion is not nice at all, because it shows how >selfish are most of the people and they consider this a virtue. Selfish? We've had multiple people get interested, and I've had a couple of messages off-list about the accessibility, (probably so they wouldn't have to deal with you). We've even had one person ask for a list of screen readers, (and I note you only gave him the one -you- use for the OS -you- use). There's no selfishness, just your not knowing when to jump off the soapbox and stop parroting something just for the sake of complaining about it. It's been admitted that TKInter is not accessible, and discussion has even been made about fixing it. Yes, it will take a while, but nothing comes in over night. And getting WXPython to the point where it is usable in python 3, as has also been mentioned before by many people is going to take a lot of work, as well. On 1/25/2011 11:25 PM, Octavian Rasnita wrote: block quote From: "Emile van Sebille" block quote On 1/25/2011 3:33 PM rantingrick said... block quote Tkinter is old and in many ways insufficient for 21st century GUIs. We need to decide what should come next. I believe wxPython is our best hope. Wx may not be the best it can be, but it is the best we have at this time. block quote end Then you should immediately volunteer to bring wxPython to python3 compatibility -- as it is, it's not even close... Start thinking about upping your game from ranting to doing. Emile block quote end Hi Emile, block quote From my point of view this discussion is finished for the moment, because block quote end you are right, WxPython is not as fast developed as it needs, because Python 3 is not compatible with Python 2. If no solution is found for this big problem, then yes, WxPython can't be included in the Python distribution because there is nothing that can be included. I don't know why you didn't say this before. The other part of the discussion is related to the accessibility and care for accessibility and that discussion is not nice at all, because it shows how selfish are most of the people and they consider this a virtue. Octavian block quote end -- Thanks, Ty From orasnita at gmail.com Wed Jan 26 10:26:18 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Wed, 26 Jan 2011 17:26:18 +0200 Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com><9MB%o.14110$%64.6074@unlimited.newshosting.com> <59F6E65E3D9A46AD8D7A3863F3C1DC84@teddy> <27f53f8c-7862-4366-9352-82ae9a2f3970@k3g2000yqc.googlegroups.com> <718D13777F254C839F9564BC4275DE0A@octavian> <4D402C42.1030407@tysdomain.com> Message-ID: From: "Littlefield, Tyler" > >I don't know why you didn't say this before. > Comprehention, Octavian. I've made that point multiple times, but your > to stuck on talking about how selfish people are. You didn't say that WxPython can't be used with Python 3. Have you said that? > >The other part of the discussion is related to the accessibility and > care for >accessibility and that discussion is not nice at all, because > it shows how > >selfish are most of the people and they consider this a virtue. > Selfish? We've had multiple people get interested, I am not interested if the people are getting interested. I am interested to have a solution right now, and at least for Python 2, a solution is already available. > and I've had a couple > of messages off-list about the accessibility, (probably so they wouldn't > have to deal with you). We've even had one person ask for a list of > screen readers, (and I note you only gave him the one you use for the OS For the majority of blind users it is less relevant if a GUI is accessible under Linux or Mac. I gave that example because a GUI should be first accessible with JAWS because it is the most used screen reader. Octavian From orasnita at gmail.com Wed Jan 26 10:47:49 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Wed, 26 Jan 2011 17:47:49 +0200 Subject: WxPython versus Tkinter. References: <4D402E58.9090001@tysdomain.com> Message-ID: From: "Littlefield, Tyler" > >I don't know why you didn't say this before. > Comprehention, Octavian. I've made that point multiple times, but your > to stuck on talking about how selfish people are. You didn't say that WxPython doesn't work on Python 3, so I don't know what you are talking about. > >The other part of the discussion is related to the accessibility and > care for >accessibility and that discussion is not nice at all, because > it shows > how > >selfish are most of the people and they consider this a virtue. > Selfish? We've had multiple people get interested, and I've had a couple > of messages off-list about the accessibility, (probably so they wouldn't > have > to deal with you). We've even had one person ask for a list of screen > readers, (and I note you only gave him the one -you- use for the OS > -you- use). There's > no selfishness, just your not knowing when to jump off the soapbox and I couldn't find the word soapbox in the dictionary so I don't know what it means. I guess that not the soap + box. Please be more clear and not talk like the high school kids. > stop parroting something just for the sake of complaining about it. It's > been admitted that TKInter is not accessible, And I was saying the same thing. What's the problem? Because I keep telling it? > and discussion has even > been made about fixing it. Yes, it will take a while, but nothing comes > in over night. And getting WXPython to the point where it is usable in > python 3, as has also been mentioned before by many people is going to > take a lot of work, as well. Do you think that this really matters? Do you think that if Python 3 will have support for WxPython much earlier than Tkinter will be accessible, and if WxPython will be fixed to not give segfaults, WxPython will be included in the Python distribution? I guess that it won't, so it is less important that WxPython has bugs or that it is not available for Python 3. But we'll see. I can assure you that if after 5 years WxPython will be available for Python 3 but Tk will still be inaccessible for the most used screen reader, Tkinter will still be the default GUI lib. (And 5 years doesn't mean overnight) Octavian From mail2bansi at gmail.com Wed Jan 26 10:51:19 2011 From: mail2bansi at gmail.com (bansi) Date: Wed, 26 Jan 2011 07:51:19 -0800 (PST) Subject: Is it possible to pass CSV Reader Object As Argument to another Python File ??? Message-ID: <2c35653e-3565-48c6-8939-b6b09b885e3f@d23g2000prj.googlegroups.com> I have following two python scripts -namelookupWrapper.py -namelookup.py The namelookupWrapper.py takes input of "memberId", "memberName" from CLI and has following code snippet idf = sys.argv[1] namef = sys.argv[2] real_script = "C:\\Splunk\\etc\\apps\\search\\bin\\namelookup.py" r = csv.reader(sys.stdin) os.execv(python_executable, [ python_executable, real_script ] + sys.argv[1:] ) Wondering how would i pass csv reader object "r" as an argument using os.execv() to another python script i.e. namelookup.py From emile at fenx.com Wed Jan 26 10:54:02 2011 From: emile at fenx.com (Emile van Sebille) Date: Wed, 26 Jan 2011 07:54:02 -0800 Subject: WxPython versus Tkinter. In-Reply-To: <1b955dcf-77e2-4130-9b5b-276cfedccd9c@a10g2000vby.googlegroups.com> References: <4D3E4377.3060807@tysdomain.com> <9MB%o.14110$%64.6074@unlimited.newshosting.com> <5a5e15f3-ae0f-4561-8969-e9afde3829dc@g26g2000vba.googlegroups.com> <1b955dcf-77e2-4130-9b5b-276cfedccd9c@a10g2000vby.googlegroups.com> Message-ID: On 1/25/2011 5:07 PM rantingrick said... > On Jan 25, 6:55 pm, Emile van Sebille wrote: > >> Oh, that everyone should blindly accept you as is and without regard for >> established protocols > > What protocols? Where is this standard posted? Can you give me a link? > I would like to know what is expected of me. Do your homework. Roughly as follows: Write a PEP. See http://www.python.org/dev/peps/pep-0001/ Petition to reopen the GUI SIG list (probably not a major hurdle) and beat out the details there. Submit the PEP and defend it. Submit a prototype implementation. Substantiate that the project will be long term supportable. And finally, get it accepted. Emile From tyler at tysdomain.com Wed Jan 26 10:57:48 2011 From: tyler at tysdomain.com (Littlefield, Tyler) Date: Wed, 26 Jan 2011 08:57:48 -0700 Subject: WxPython versus Tkinter. In-Reply-To: References: <4D3E4377.3060807@tysdomain.com><9MB%o.14110$%64.6074@unlimited.newshosting.com> <59F6E65E3D9A46AD8D7A3863F3C1DC84@teddy> <27f53f8c-7862-4366-9352-82ae9a2f3970@k3g2000yqc.googlegroups.com> <718D13777F254C839F9564BC4275DE0A@octavian> <4D402C42.1030407@tysdomain.com> Message-ID: <4D40447C.4010108@tysdomain.com> >with JAWS because it is the most used screen reader. Get off your me soapbox. Jaws is not the most used. NVDA is taking over, quite fast, and lots of people have totally switched to mac or Vinux because of the problems with Jaws. It's most used in corporate sektors still maybe, but lots of end-users are migrating to Window Eyes, NVDA or OSX because of the fact that it is both cheaper and NVDA is open source, not to mention free. Just because Jaws -was- most used and -you- use it, doesn't mean it still remains so. On 1/26/2011 8:26 AM, Octavian Rasnita wrote: > From: "Littlefield, Tyler" >>> I don't know why you didn't say this before. >> Comprehention, Octavian. I've made that point multiple times, but your >> to stuck on talking about how selfish people are. > You didn't say that WxPython can't be used with Python 3. Have you said that? > >>> The other part of the discussion is related to the accessibility and >> care for>accessibility and that discussion is not nice at all, because >> it shows how >>> selfish are most of the people and they consider this a virtue. >> Selfish? We've had multiple people get interested, > I am not interested if the people are getting interested. I am interested to have a solution right now, and at least for Python 2, a solution is already available. > >> and I've had a couple >> of messages off-list about the accessibility, (probably so they wouldn't >> have to deal with you). We've even had one person ask for a list of >> screen readers, (and I note you only gave him the one you use for the OS > For the majority of blind users it is less relevant if a GUI is accessible under Linux or Mac. I gave that example because a GUI should be first accessible with JAWS because it is the most used screen reader. > > Octavian > -- Thanks, Ty From emile at fenx.com Wed Jan 26 11:00:01 2011 From: emile at fenx.com (Emile van Sebille) Date: Wed, 26 Jan 2011 08:00:01 -0800 Subject: WxPython versus Tkinter. In-Reply-To: <5782E9AD8A8342D691EB3549E5E0ED7B@octavian> References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <8q7sgiF5tpU1@mid.individual.net> <19891784-d6a3-41ac-a097-5902a6323bc0@o21g2000prn.googlegroups.com><0b12cdb1-45b4-41e4-9bdb-074ee669d76b@k14g2000pre.googlegroups.com> <048FB74272D440A0915ABC7D76AE262B@teddy> <5782E9AD8A8342D691EB3549E5E0ED7B@octavian> Message-ID: On 1/25/2011 10:08 PM Octavian Rasnita said... > From: "Emile van Sebille" >>> Why is WxPython ineligible? >> >> I think Terry's point was compatibility with python3 -- which wx >> apparently isn't yet. >> >> Emile > > > Well, I didn't know this, and it is a valid reason. > This means that it is true that there is no enough maintainance force to > keep WxPython updated. > Did I understand correctly? Not at all -- wxPython is an active funded ongoing project. Review the roadmap at http://wiki.wxpython.org/TentativeRoadmap and particularly the final paragraph on Python3.x support. Emile From bryan.oakley at gmail.com Wed Jan 26 11:00:25 2011 From: bryan.oakley at gmail.com (Bryan) Date: Wed, 26 Jan 2011 08:00:25 -0800 (PST) Subject: WxPython versus Tkinter. References: <4D402E58.9090001@tysdomain.com> Message-ID: <79f15901-3a0b-4749-8cd9-d2560406bee7@l15g2000prg.googlegroups.com> On Jan 26, 9:47?am, "Octavian Rasnita" wrote: > I couldn't find the word soapbox in the dictionary so I don't know what it means. I guess that not the soap + box. > Please be more clear and not talk like the high school kids. http://en.wikipedia.org/wiki/Soapbox From rantingrick at gmail.com Wed Jan 26 11:00:30 2011 From: rantingrick at gmail.com (rantingrick) Date: Wed, 26 Jan 2011 08:00:30 -0800 (PST) Subject: Bugs/issues in tkinter.simpledialog!! Message-ID: I just installed Python 3,0 on my machine. I cannot use 3.0 exclusively yet however i was interested in just poking around and acquiring a taste if you will. I was happy to find that the new Tkinter module names now follow convention and are placed correctly... example: "tkinter.simpledialog" However some things never change it seems and some improvements are actually a step backwards. The same problems with the unit test in 2.x got ported to 3.x. And the new SimpleDialog is just more lackluster code like we've seen before. I was hoping to be amazed, i am disappointed and disgusted. It is obvious that whoever is writing/ maintaining the tkinter code base does NOT understand tkinter completely and this is blinding apparent by reading the source code! ----------- Issues ----------- First lets start with the problems that migrated from 2.x... (tkinter.simpledialog) #-- ISSUE 1 --# In the test() function we still have code that uses the "quit" method instead of "destroy". Calling the "quit" method only tells Tkinter to stop processing events, IT DOES NOT DESTROY THE WIDGET!! And on windows the the root will then become unresponsive -- you cannot close the window, you cannot do anything. I have said time and time again. DO NOT USE THE QUIT METHOD UNLESS YOU KNOW WHAT THE HECK YOU ARE DOING! So the code needs to be this... OLD: q = Button(root, text='Quit', command=t.quit) NEW: q = Button(root, text='Quit', command=root.destroy) #-- ISSUE 2: --# The author used a very strange method by which to denote the default button in the SimpleDialog class. He choose to set the relief to RIDGE and the border "8". This not only looks horrible (and exposes the authors ignorance of tkinter) but a much more elegant solution is provided by the TclTk folks. All buttons have a "default" option that will display the button with a nice border so the user can visually see which button is active. So the code should be this.... OLD: if num == default: b.config(relief=RIDGE, borderwidth=8) NEW: if num == default: b.config(default=ACTIVE) Last but not least i am puzzled as to why we choose the method name "go" over "show". for "showing" the dialog. SimpleDialog uses no inheritance so name clashes are mum. Why would anyone choose "go" over "show" for a modal dialog? I would really like an explanation for this. Other minor issues exists. I may describe them later. At this time we need to fix these grave abominations first. From sohel807 at gmail.com Wed Jan 26 11:07:39 2011 From: sohel807 at gmail.com (Akand Islam) Date: Wed, 26 Jan 2011 08:07:39 -0800 (PST) Subject: adding "Print" menu in wxPython References: <05c1f4b3-941c-45b1-9370-a88653d1083a@e16g2000pri.googlegroups.com> <66d035ae-cb4f-4ad3-836d-f8394ad90475@q8g2000prm.googlegroups.com> <7775b108-b04b-44a9-abae-1e58842b3186@b25g2000vbz.googlegroups.com> Message-ID: <3517483e-3222-4d29-9198-1f1d4fc396f1@w17g2000yqh.googlegroups.com> On Jan 26, 12:54?am, rantingrick wrote: > On Jan 26, 12:19?am, rantingrick wrote: > > Actually i found more cruft. Here is something that would be > acceptable although i had to wrap lines shorter than i normally would > for the sake of Usenet. Who ever wrote that code should be lashed 50 > times! You still need some error handling for the open and save file > methods but crikey i can't do everything ;-) > > #--STARTCODE--# > import wx > import os.path, sys > > class MainWindow(wx.Frame): > ? ? def __init__(self, filename='noname.txt'): > ? ? ? ? wx.Frame.__init__(self, None, size=(400,200)) > ? ? ? ? self.filename = filename > ? ? ? ? self.dirname = '.' > ? ? ? ? self.control = wx.TextCtrl(self, style=wx.TE_MULTILINE) > ? ? ? ? self.CreateMenu() > ? ? ? ? self.CreateStatusBar() > ? ? ? ? self.SetTitle('Editor %s'%self.filename) > ? ? ? ? self.dlgdefaults = { > ? ? ? ? ? ? 'message':'Choose a file', > ? ? ? ? ? ? 'defaultDir':self.dirname, > ? ? ? ? ? ? 'wildcard':'*.*' > ? ? ? ? ? ? } > > ? ? def CreateMenu(self): > ? ? ? ? fileMenu = wx.Menu() > ? ? ? ? item = fileMenu.Append(wx.ID_ABOUT, '&About', 'Info') > ? ? ? ? self.Bind(wx.EVT_MENU, self.OnAbout, item) > ? ? ? ? item = fileMenu.Append( wx.ID_OPEN, '&Open', 'Info') > ? ? ? ? self.Bind(wx.EVT_MENU, self.OnOpen, item) > ? ? ? ? item = fileMenu.Append(wx.ID_SAVE, '&Save', 'Info') > ? ? ? ? self.Bind(wx.EVT_MENU, self.OnSave, item) > ? ? ? ? item = fileMenu.Append(wx.ID_SAVEAS, 'Save &As', 'Info') > ? ? ? ? self.Bind(wx.EVT_MENU, self.OnSaveAs, item) > ? ? ? ? # > ? ? ? ? # psst: Hey put the print menu here!!!! > ? ? ? ? # psst: do the binding here!!!! > ? ? ? ? # > ? ? ? ? fileMenu.AppendSeparator() > ? ? ? ? item = fileMenu.Append(wx.ID_EXIT, 'E&xit', 'Exit') > ? ? ? ? self.Bind(wx.EVT_MENU, self.OnExit, item) > ? ? ? ? menuBar = wx.MenuBar() > ? ? ? ? # Add the fileMenu to the MenuBar > ? ? ? ? menuBar.Append(fileMenu, '&File') > ? ? ? ? # Add the menuBar to the Frame > ? ? ? ? self.SetMenuBar(menuBar) > > ? ? def askUserForFilename(self, **kw): > ? ? ? ? dialog = wx.FileDialog(self, **kw) > ? ? ? ? if dialog.ShowModal() == wx.ID_OK: > ? ? ? ? ? ? userProvidedFilename = True > ? ? ? ? ? ? self.filename = dialog.GetFilename() > ? ? ? ? ? ? self.dirname = dialog.GetDirectory() > ? ? ? ? ? ? self.SetTitle('Editor %s'%(self.filename)) > ? ? ? ? else: > ? ? ? ? ? ? userProvidedFilename = False > ? ? ? ? dialog.Destroy() > ? ? ? ? return userProvidedFilename > > ? ? def OnAbout(self, event): > ? ? ? ? dialog = wx.MessageDialog( > ? ? ? ? ? ? self, > ? ? ? ? ? ? 'A sample editor in wxPython', > ? ? ? ? ? ? 'About Sample Editor', > ? ? ? ? ? ? wx.OK > ? ? ? ? ? ? ) > ? ? ? ? dialog.ShowModal() > ? ? ? ? dialog.Destroy() > > ? ? def OnExit(self, event): > ? ? ? ? self.Close() > > ? ? def OnSave(self, event): > ? ? ? ? textfile = open(os.path.join(self.dirname, self.filename), > 'w') > ? ? ? ? textfile.write(self.control.GetValue()) > ? ? ? ? textfile.close() > > ? ? def OnOpen(self, event): > ? ? ? ? if self.askUserForFilename( > ? ? ? ? ? ? style=wx.OPEN, > ? ? ? ? ? ? **self.dlgdefaults > ? ? ? ? ? ? ): > ? ? ? ? ? ? textfile = open(os.path.join(self.dirname, self.filename), > 'r') > ? ? ? ? ? ? self.control.SetValue(textfile.read()) > ? ? ? ? ? ? textfile.close() > > ? ? def OnSaveAs(self, event): > ? ? ? ? if self.askUserForFilename( > ? ? ? ? ? ? defaultFile=self.filename, > ? ? ? ? ? ? style=wx.SAVE, > ? ? ? ? ? ? **self.dlgdefaults > ? ? ? ? ? ? ): > ? ? ? ? ? ? self.OnSave(event) > > ? ? def OnPrint(self, event): > ? ? ? ? sys.stdout.write(self.control.GetValue()) > > app = wx.App() > frame = MainWindow() > frame.Show() > app.MainLoop() > > #--ENDCODE--# I really appreciate your cooperation. The codes you have written print in command window, but I want to print (i.e. a popup window will appear to select printer in order to print). Please assist me regarding this. I am optimist that I can take care menu creating, binding, error handling by myself. Therefore you can only show me the "OnPrint" function to fulfill my purpose. -- Akand From tgrav at mac.com Wed Jan 26 11:11:55 2011 From: tgrav at mac.com (Tommy Grav) Date: Wed, 26 Jan 2011 11:11:55 -0500 Subject: WxPython versus Tkinter. In-Reply-To: References: <4D3E4377.3060807@tysdomain.com> <9MB%o.14110$%64.6074@unlimited.newshosting.com> <59F6E65E3D9A46AD8D7A3863F3C1DC84@teddy> <27f53f8c-7862-4366-9352-82ae9a2f3970@k3g2000yqc.googlegroups.com> <718D13777F254C839F9564BC4275DE0A@octavian> <4D402C42.1030407@tysdomain.com> Message-ID: <39327F93-9814-42D0-9EA2-92F6A5E783D7@mac.com> On Jan 26, 2011, at 10:26 AM, Octavian Rasnita wrote: > You didn't say that WxPython can't be used with Python 3. Have you said that? Some besides Peter pointed this out a few days ago. >>> The other part of the discussion is related to the accessibility and >> care for >accessibility and that discussion is not nice at all, because >> it shows how >>> selfish are most of the people and they consider this a virtue. >> Selfish? We've had multiple people get interested, > > I am not interested if the people are getting interested. I am interested to have a solution right now, and at least for Python 2, a solution is already available. Python 2 is in bug-fix mode and no major modifications will be done to this version of Python. This means that Tkinter will not be replaced in Python 2. If you want a fix now, you either have to fix Tkinter in a backwards compatible way to work with Python 2, or you have to get wxPython (or some other GUI package) ready for Python 3. Cheers Tommy From mail2bansi at gmail.com Wed Jan 26 11:16:02 2011 From: mail2bansi at gmail.com (Bansilal Haudakari) Date: Wed, 26 Jan 2011 11:16:02 -0500 Subject: Is it possible to pass CSV Reader Object As Argument to another Python File ??? Options Message-ID: I have following two python scripts -namelookupWrapper.py -namelookup.py The namelookupWrapper.py takes input of "memberId", "memberName" from CLI and has following code snippet idf = sys.argv[1] namef = sys.argv[2] real_script = "C:\\Splunk\\etc\\apps\\search\\bin\\namelookup.py" r = csv.reader(sys.stdin) os.execv(python_executable, [ python_executable, real_script ] + sys.argv[1:] ) Wondering how would i pass csv reader object "r" as an argument using os.execv() to another python script i.e. namelookup.py Regards, Bansi ----------------------------------------------------- Bansilal Haudakari SUN Certified Enterprise JAVA Architect / Programmer http://bansihaudakari.wordpress.com/ L:703-445-2894 -------------- next part -------------- An HTML attachment was scrubbed... URL: From emile at fenx.com Wed Jan 26 11:30:15 2011 From: emile at fenx.com (Emile van Sebille) Date: Wed, 26 Jan 2011 08:30:15 -0800 Subject: Is it possible to pass CSV Reader Object As Argument to another Python File ??? In-Reply-To: <2c35653e-3565-48c6-8939-b6b09b885e3f@d23g2000prj.googlegroups.com> References: <2c35653e-3565-48c6-8939-b6b09b885e3f@d23g2000prj.googlegroups.com> Message-ID: On 1/26/2011 7:51 AM bansi said... > I have following two python scripts > -namelookupWrapper.py > -namelookup.py > > > The namelookupWrapper.py takes input of "memberId", "memberName" from > CLI and has following code snippet > > idf = sys.argv[1] > namef = sys.argv[2] > real_script = "C:\\Splunk\\etc\\apps\\search\\bin\\namelookup.py" > r = csv.reader(sys.stdin) > os.execv(python_executable, [ python_executable, real_script ] + > sys.argv[1:] ) > > > > Wondering how would i pass csv reader object "r" as an argument using > os.execv() to another python script i.e. namelookup.py > I suspect you're on the wrong path. You probably want to import namelookup within namelooupWrapper to use the functions it defines. Consider: [root at fcfw2 src]# cat > test1.py def say(what): print what [root at fcfw2 src]# cat > test2.py #!/usr/local/bin/python import sys from test1 import say say(sys.argv[1]) [root at fcfw2 src]# chmod a+x test2.py [root at fcfw2 src]# ./test2.py hello hello HTH, Emile From mpnordland at gmail.com Wed Jan 26 11:32:03 2011 From: mpnordland at gmail.com (mpnordland) Date: Wed, 26 Jan 2011 11:32:03 -0500 Subject: open() mode args Message-ID: What is the correct file mode to pass to open() when I want to both read and write on the open file? From robert.kern at gmail.com Wed Jan 26 11:35:04 2011 From: robert.kern at gmail.com (Robert Kern) Date: Wed, 26 Jan 2011 10:35:04 -0600 Subject: WxPython versus Tkinter. In-Reply-To: References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <8q7sgiF5tpU1@mid.individual.net> <19891784-d6a3-41ac-a097-5902a6323bc0@o21g2000prn.googlegroups.com><0b12cdb1-45b4-41e4-9bdb-074ee669d76b@k14g2000pre.googlegroups.com> <048FB74272D440A0915ABC7D76AE262B@teddy> <5782E9AD8A8342D691EB3549E5E0ED7B@octavian> Message-ID: On 1/26/11 10:00 AM, Emile van Sebille wrote: > On 1/25/2011 10:08 PM Octavian Rasnita said... >> From: "Emile van Sebille" >>>> Why is WxPython ineligible? >>> >>> I think Terry's point was compatibility with python3 -- which wx >>> apparently isn't yet. >>> >>> Emile >> >> >> Well, I didn't know this, and it is a valid reason. >> This means that it is true that there is no enough maintainance force to >> keep WxPython updated. >> Did I understand correctly? > > Not at all -- wxPython is an active funded ongoing project. Review the roadmap > at http://wiki.wxpython.org/TentativeRoadmap and particularly the final > paragraph on Python3.x support. That's not Terry's point. The reasons he's referring to (and stated previously) are as follows: 1. The license of wxWidgets and wxPython is not as permissive as Python's. The Python developers, as a matter of policy, do not want to include code into the standard library that is less permissive than the current license. 2. The Python developers require someone to commit to maintaining contributed code for a number of years. No one has done so. See reason #3. 3. The wxPython developers do not want wxPython in the standard library, not least because they want to develop and release wxPython at a different pace and release cycle than the standard library. 4. The Python developers have committed to maintaining backwards compatibility in the standard library for a very long time. Even if they included wxPython into the standard library, they would have to provide a Tkinter module that works like the current one. I do not believe it is feasible to write a Tkinter workalike that uses wxPython, so we would still be relying on Tcl/Tk. There is certainly enough maintenance force to keep wxPython updated and ported to Python 3, but only *outside* of the standard library. -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco From emile at fenx.com Wed Jan 26 11:43:36 2011 From: emile at fenx.com (Emile van Sebille) Date: Wed, 26 Jan 2011 08:43:36 -0800 Subject: Bugs/issues in tkinter.simpledialog!! In-Reply-To: References: Message-ID: On 1/26/2011 8:00 AM rantingrick said... > > I just installed Python 3,0 on my machine. Try it again on the current release candidate -- http://www.python.org/download/releases/3.2/ -- testing old first release code and reporting on its problems won't get any traction. Verify the problem continues to exist in the current maintained version and then ask. If you get confirmation that the behavior is likely a bug, file a bug report so those who can and do can do (or at least consider). See http://docs.python.org/bugs.html http://www.python.org/dev/peps/pep-0003/ Emile From rantingrick at gmail.com Wed Jan 26 11:45:01 2011 From: rantingrick at gmail.com (rantingrick) Date: Wed, 26 Jan 2011 08:45:01 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> Message-ID: <80914a32-527c-445c-828e-20066fdc2b8c@y19g2000prb.googlegroups.com> On Jan 22, 6:07?pm, rantingrick wrote: > --------------------------------------- > ?Challenge 1: (Simple Directory Viewer) > --------------------------------------- > > Create a simple Directory Viewer GUI. You CANNOT use a treectrl! ?The > point of this challenge is to show that Tkinter has no support for a > true ListCtrl widget. However the Wx::ListCtrl is fully featured! For > wxPython the code is simply wielding a few built in classes. For > Tkinter no such ListCtrl functionality exists. You CAN create the > functionality yourself (and i know this because i HAVE created it!) > however it involves tons of work and still can't hold a candle to the > wx::ListCtrl > > --------------- > ?Requirements: > --------------- > > How the user navigates to a folder is not important but you must > display the list of files/folders in two view modes with icons; > > ?1. Display files in both ReportView and ListView. > > ? * Reportview: > ? ? ...scrollable vertical list with three columns. > > ? * Listview: > ? ? ...scrollable horizontal-ly wrapping list. > > Note: If you do not understand the view modes just run my code for an > example. But the user must be able to switch between these two modes > easily. How the switching is done is unimportant -- I simply used two > buttons. > > ?2. Columns > ? * Minimum of three cols; Name, Size, and Type (reportview). > ? * the "Name" column must include an icon AND label (both views). > ? * columns must be sortable by the user (reportview). > ? * columns must be sizable by the user (reportview). > > ?3. Items > ? * All must be editable in place (no popup editing allowed!). > ? * All items must be selectable/deselectable by user. > ? * All items must be delete-able by the user. > > That is the challenge. Step forth and battle if you can! > > ----------------- > ?WxPython code: > ----------------- > > https://sites.google.com/site/thefutureofpython/home/code-challenges > > I await any challengers... So we have come this far and still not one challenger. Neither can one person admit that the wxPython ListCtrl is far superior than widget TclTk contains. But that really does not matter now. The point is that TclTk have grown stagnate and have been that way for many years. Whilst Tkinter does sport a beautiful API we have no way to scale the module because TclTk is limited. New Python programmers will start out (like i did) with Tkinter and love its simplicity, however eventually they will come to understand that all their spend energy writing Tkinter has been for nothing. They will realize that Tkinter is 1990's technology migrated into the 21st century. That is point i am making. Some people can handle the truth. Denial is to be expected. If you are out there and your not one of the redundant trolls who keep parroting off and assassination my character please drop by and insert your opinion on the value of Tkinter. Just make sure to use facts and not emotion driven drivel. If you choose to be a troll i cannot stop you, and i would not. However i will not respond to trollish posts anymore. It is quite clear that a hand full of the same old folks want to stop me at all costs -- even at the expense of their own soul. Psst: If you notice they are not yelling about the code anymore because it is bug free. They are only interested in spreading discontent and not solving problems. That is a blindingly apparent fact. Anyway i still await a solid challenge. Either in code or in words based on facts. Until then i will consider myself victorious by default. From steve+comp.lang.python at pearwood.info Wed Jan 26 11:53:23 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 26 Jan 2011 16:53:23 GMT Subject: open() mode args References: Message-ID: <4d405182$0$29983$c3e8da3$5496439d@news.astraweb.com> On Wed, 26 Jan 2011 11:32:03 -0500, mpnordland wrote: > What is the correct file mode to pass to open() when I want to both read > and write on the open file? open("filename", "r+") for text mode, "r+b" for binary mode. If your operating system does not distinguish between the two, you can use either. More detail is available in the Fine Manual, or in the interactive help: help(open) at the Python prompt. -- Steven From rantingrick at gmail.com Wed Jan 26 11:53:58 2011 From: rantingrick at gmail.com (rantingrick) Date: Wed, 26 Jan 2011 08:53:58 -0800 (PST) Subject: Bugs/issues in tkinter.simpledialog!! References: Message-ID: <412e4d83-f750-441d-bfc5-d96c0559e069@e9g2000prn.googlegroups.com> On Jan 26, 10:43?am, Emile van Sebille wrote: > On 1/26/2011 8:00 AM rantingrick said... > > I just installed Python 3,0 on my machine. > > Try it again on the current release candidate --http://www.python.org/download/releases/3.2/-- testing old first > > Seehttp://docs.python.org/bugs.htmlhttp://www.python.org/dev/peps/pep-0003/ Why would i want to waste bandwidth downloading an RC? Can i not just browse the source online? I only need to check one module. Where is the source available for viewing "simpledialog" online? Thanks PS: The version i have now is 3.1.1 (but i would like to see the newest version available, just not download it!) From ms419 at freezone.co.uk Wed Jan 26 12:04:56 2011 From: ms419 at freezone.co.uk (Jack Bates) Date: Wed, 26 Jan 2011 09:04:56 -0800 Subject: method-to-instance binding, callable generator decorator Message-ID: <1296061496.1121.10.camel@selene> Am struggling to understand Python method-to-instance binding Anyone know why this example throws a TypeError? > #!/usr/bin/env python > > import functools > > # Take a generator function (i.e. a callable which returns a generator) and > # return a callable which calls .send() > class coroutine: > def __init__(self, function): > self.function = function > > functools.update_wrapper(self, function) > > def __call__(self, *args, **kwds): > try: > return self.generator.send(args) > > except AttributeError: > self.generator = self.function(*args, **kwds) > > return self.generator.next() > > # Each time we're called, advance to next yield > @coroutine > def test(): > yield 'call me once' > yield 'call me twice' > > # Works like a charm : ) > assert 'call me once' == test() > assert 'call me twice' == test() > > class Test: > > # Each time we're called, advance to next yield > @coroutine > def test(self): > yield 'call me once' > yield 'call me twice' > > test = Test() > > # TypeError, WTF? > assert 'call me once' == test.test() > assert 'call me twice' == test.test() https://gist.github.com/797019 Am trying to write a decorator such that each time I call a function, it advances to the next "yield" - I plan to use functions like this as fixtures in tests Does a decorator like this already exist in the Python standard library? From orasnita at gmail.com Wed Jan 26 12:04:57 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Wed, 26 Jan 2011 19:04:57 +0200 Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com><9MB%o.14110$%64.6074@unlimited.newshosting.com> <59F6E65E3D9A46AD8D7A3863F3C1DC84@teddy> <27f53f8c-7862-4366-9352-82ae9a2f3970@k3g2000yqc.googlegroups.com> <718D13777F254C839F9564BC4275DE0A@octavian> <4D402C42.1030407@tysdomain.com> <4D40447C.4010108@tysdomain.com> Message-ID: <33C68A0874BE4C66AB478EDFB64C2C1D@teddy> From: "Littlefield, Tyler" > >with JAWS because it is the most used screen reader. > Get off your me soapbox. Jaws is not the most used. NVDA is taking over, > quite fast, and lots of people have totally switched to mac or Vinux Lots of people means an insignifiant percent of users compared with the percent of Windows users. NVDA is mostly used as a second screen reader in case that something wrong happends with the first one. It doesn't support a good voice synthesizer like Eloquence or IBM Via voice, but only eSpeak which sounds horrible, it doesn't have a scripting language ready to use as JAWS and Window Eyes do, it doesn't offer the possibility of reading with the mouse cursor as JAWS does with its so called JAWS cursor, it offers a poor accessibility in many applications and many other issues. > because of the problems with Jaws. It's most used in corporate sektors > still maybe, but lots of end-users are migrating to Window Eyes, NVDA or > OSX because of the fact that it is both cheaper and NVDA is open source, > not to mention free. Just because Jaws -was- most used and -you- use it, > doesn't mean it still remains so. Window Eyes always was cheaper than JAWS, however it was never the most used screen reader because it also have its problems. I don't understand why you care so much about what will *probably* happen in the future and don't care about the present. An indian saying says that on the long term will be everything fine (because we will be all dead:) But you are talking just to show how right you are. If you remember about our discussion, we were talking about how inaccessible is Tkinter, and well Tkinter has the same inaccessibility level under Window Eyes and NVDA just like under JAWS, so I don't know why is it so important to name all those screen readers if someone wants to test Tkinter. I thought that if someone wants to test how inaccessible is Tkinter, JAWS would be enough because Tkinter is also inaccessible for the other screen readers, and I thought that it would be normally to test the accessibility using the screen reader that offer the most features. Octavian From orasnita at gmail.com Wed Jan 26 12:09:33 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Wed, 26 Jan 2011 19:09:33 +0200 Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com> <9MB%o.14110$%64.6074@unlimited.newshosting.com> <59F6E65E3D9A46AD8D7A3863F3C1DC84@teddy> <27f53f8c-7862-4366-9352-82ae9a2f3970@k3g2000yqc.googlegroups.com> <718D13777F254C839F9564BC4275DE0A@octavian> <4D402C42.1030407@tysdomain.com> <39327F93-9814-42D0-9EA2-92F6A5E783D7@mac.com> Message-ID: From: "Tommy Grav" >> You didn't say that WxPython can't be used with Python 3. Have you said that? > > Some besides Peter pointed this out a few days ago. I don't remember to have read that. But who knows, maybe I have missed it. Does anyone have that message? > Python 2 is in bug-fix mode and no major modifications will be done to this version of Python. This means that Tkinter will not be replaced in Python 2. Of course. That's why I said that this is a real problem and that I understand the real reason why WxPython can't be included in the Python distribution. Octavian From mail2bansi at gmail.com Wed Jan 26 12:14:48 2011 From: mail2bansi at gmail.com (bansi) Date: Wed, 26 Jan 2011 09:14:48 -0800 (PST) Subject: Is it possible to pass CSV Reader Object As Argument to another Python File ??? References: <2c35653e-3565-48c6-8939-b6b09b885e3f@d23g2000prj.googlegroups.com> Message-ID: <29813d68-75c9-49cb-a14c-e62f4304d6c5@z26g2000prf.googlegroups.com> On Jan 26, 11:30?am, Emile van Sebille wrote: > On 1/26/2011 7:51 AM bansi said... > > > > > > > I have following two python scripts > > -namelookupWrapper.py > > -namelookup.py > > > The namelookupWrapper.py takes input of "memberId", "memberName" from > > CLI and has following code snippet > > > idf = sys.argv[1] > > namef = sys.argv[2] > > real_script = "C:\\Splunk\\etc\\apps\\search\\bin\\namelookup.py" > > r = csv.reader(sys.stdin) > > os.execv(python_executable, [ python_executable, real_script ] + > > sys.argv[1:] ) > > > Wondering how would i pass csv reader object "r" as an argument using > > os.execv() to another python script i.e. namelookup.py > > I suspect you're on the wrong path. ?You probably want to import > namelookup within namelooupWrapper to use the functions it defines. > > Consider: > > [root at fcfw2 src]# cat > test1.py > > def say(what): print what > > [root at fcfw2 src]# cat > test2.py > > #!/usr/local/bin/python > import sys > from test1 import say > say(sys.argv[1]) > > [root at fcfw2 src]# chmod a+x test2.py > > [root at fcfw2 src]# ./test2.py hello > hello > > HTH, > > Emile- Hide quoted text - > > - Show quoted text - Emile, Thanks for quick response. I am not sure if "import namelookup within namelooupWrapper" helps because they are two independent scripts which has to be executed in sequence. First namelookupWrapper.py running under Python 2.6 accept arguments from stdin and uses csv reader object to read it i.e. r=csv.reader(sys.stdin) And then it has to pass csv reader object to another python script namelookup.py running under Python 2.7 because it uses pyodbc to connect to database and iterates thru reader object Any better ideas/suggestions will be greatly appreciated From orasnita at gmail.com Wed Jan 26 12:19:17 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Wed, 26 Jan 2011 19:19:17 +0200 Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <8q7sgiF5tpU1@mid.individual.net> <19891784-d6a3-41ac-a097-5902a6323bc0@o21g2000prn.googlegroups.com><0b12cdb1-45b4-41e4-9bdb-074ee669d76b@k14g2000pre.googlegroups.com> <048FB74272D440A0915ABC7D76AE262B@teddy> <5782E9AD8A8342D691EB3549E5E0ED7B@octavian> Message-ID: <43FCB75BBC57406799C87AD6FC781EFC@teddy> From: "Emile van Sebille" ... >> Well, I didn't know this, and it is a valid reason. >> This means that it is true that there is no enough maintainance force to >> keep WxPython updated. >> Did I understand correctly? > > Not at all -- wxPython is an active funded ongoing project. Review the > roadmap at http://wiki.wxpython.org/TentativeRoadmap and particularly > the final paragraph on Python3.x support. > > Emile But somebody said that the core Python developers, or Guido said that WxPython won't be included in the core distribution because it doesn't have a strong team of maintainers... with other words but this was the idea. So I still don't understand why WxPython can't be a good solution. If WxPython is well maintained, let's pretend that the maintainers solved that bug that make the apps give a segfault, and let's pretend that it works under Python 3. Can it be a good choice for replacing Tkinter? I don't know why, but I have a feeling that even in these cases WxPython is still not wanted and I don't understand why. I can see that the people try to find some false arguments like the one that WxPython is bigger than Tkinter, but really, who cares today about a few aditional megabytes? What do you think it is more important, to offer accessibility for most of the users, or to create small applications? (Note that I didn't say that Tkinter should be forbidden, so if somebody in some edge cases need to make a very small program, he/she could do it very well.) So I still don't understand why WxPython wouldn't be prefered even all its problems would be solved. Octavian From gerald.britton at gmail.com Wed Jan 26 12:20:06 2011 From: gerald.britton at gmail.com (Gerald Britton) Date: Wed, 26 Jan 2011 12:20:06 -0500 Subject: Slice lists and extended slicing Message-ID: I'm looking at extended slicing and wondering when and how to use slice lists: slicing ::= simple_slicing | extended_slicing simple_slicing ::= primary "[" short_slice "]" extended_slicing ::= primary "[" slice_list "]" slice_list ::= slice_item ("," slice_item)* [","] slice_item ::= expression | proper_slice | ellipsis proper_slice ::= short_slice | long_slice short_slice ::= [lower_bound] ":" [upper_bound] long_slice ::= short_slice ":" [stride] lower_bound ::= expression upper_bound ::= expression stride ::= expression ellipsis The semantics for an extended slicing are as follows. The primary must evaluate to a mapping object, and it is indexed with a key that is constructed from the slice list, as follows. If the slice list contains at least one comma, the key is a tuple containing the conversion of the slice items; otherwise, the conversion of the lone slice item is the key. The conversion of a slice item that is an expression is that expression. The conversion of an ellipsis slice item is the built-in Ellipsis object. The conversion of a proper slice is a slice object (see section The standard type hierarchy) whose start, stop and step attributes are the values of the expressions given as lower bound, upper bound and stride, respectively, substituting None for missing expressions. I'd thought that I could do this: >>> l = [1,2,3,4,5] >>> l[0:1, 3:4] Traceback (most recent call last): File "", line 1, in TypeError: list indices must be integers, not tuple but that clearly doesn't work! So, when and how can one use slice lists? -- Gerald Britton From mpnordland at gmail.com Wed Jan 26 12:21:38 2011 From: mpnordland at gmail.com (mpnordland) Date: Wed, 26 Jan 2011 12:21:38 -0500 Subject: open() mode args In-Reply-To: <4d405182$0$29983$c3e8da3$5496439d@news.astraweb.com> References: <4d405182$0$29983$c3e8da3$5496439d@news.astraweb.com> Message-ID: thanks From emile at fenx.com Wed Jan 26 12:28:20 2011 From: emile at fenx.com (Emile van Sebille) Date: Wed, 26 Jan 2011 09:28:20 -0800 Subject: method-to-instance binding, callable generator decorator In-Reply-To: <1296061496.1121.10.camel@selene> References: <1296061496.1121.10.camel@selene> Message-ID: On 1/26/2011 9:04 AM Jack Bates said... > Am struggling to understand Python method-to-instance binding > > Anyone know why this example throws a TypeError? > >> > #!/usr/bin/env python >> > >> > import functools >> > >> > # Take a generator function (i.e. a callable which returns a generator) and >> > # return a callable which calls .send() >> > class coroutine: >> > def __init__(self, function): >> > self.function = function >> > >> > functools.update_wrapper(self, function) >> > >> > def __call__(self, *args, **kwds): >> > try: >> > return self.generator.send(args) >> > >> > except AttributeError: >> > self.generator = self.function(*args, **kwds) >> > >> > return self.generator.next() >> > >> > # Each time we're called, advance to next yield >> > @coroutine >> > def test(): >> > yield 'call me once' >> > yield 'call me twice' define test >> > >> > # Works like a charm : ) >> > assert 'call me once' == test() >> > assert 'call me twice' == test() >> > >> > class Test: >> > >> > # Each time we're called, advance to next yield >> > @coroutine >> > def test(self): >> > yield 'call me once' >> > yield 'call me twice' >> > >> > test = Test() I'm not sure, but you've shadowed the test function above here. >> > >> > # TypeError, WTF? >> > assert 'call me once' == test.test() >> > assert 'call me twice' == test.test() > https://gist.github.com/797019 > > Am trying to write a decorator such that each time I call a function, it > advances to the next "yield" - I plan to use functions like this as > fixtures in tests > > Does a decorator like this already exist in the Python standard library? From rantingrick at gmail.com Wed Jan 26 12:38:12 2011 From: rantingrick at gmail.com (rantingrick) Date: Wed, 26 Jan 2011 09:38:12 -0800 (PST) Subject: adding "Print" menu in wxPython References: <05c1f4b3-941c-45b1-9370-a88653d1083a@e16g2000pri.googlegroups.com> <66d035ae-cb4f-4ad3-836d-f8394ad90475@q8g2000prm.googlegroups.com> <7775b108-b04b-44a9-abae-1e58842b3186@b25g2000vbz.googlegroups.com> <3517483e-3222-4d29-9198-1f1d4fc396f1@w17g2000yqh.googlegroups.com> Message-ID: <79983aa5-01a4-421e-b6d9-7f45119c10b0@f21g2000prn.googlegroups.com> On Jan 26, 10:07?am, Akand Islam wrote: > I really appreciate your cooperation. The codes you have written print > in command window, but I want to print (i.e. a popup window will > appear to select printer in order to print). Please assist me > regarding this. Ok, read on... > I am optimist that I can take care menu creating, > binding, error handling by myself. Therefore you can only show me the > "OnPrint" function to fulfill my purpose. Yes but how can i be sure? You still failed to post code proving that you can do this. I don't mind helping folks and i will go out on a limb for anyone however i will not build the tree of knowledge for you. You must prove that you are at least making an attempt to learn. If i do all the work then you won't learn anything. Heck, i even cleaned up the horrible code and put comments exactly where you need to create the menu. I could not have made this challenge any easier. So show me some proof that you are trying then we will move on to next step. You must attack problems step by step. From orasnita at gmail.com Wed Jan 26 12:46:07 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Wed, 26 Jan 2011 19:46:07 +0200 Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <8q7sgiF5tpU1@mid.individual.net> <19891784-d6a3-41ac-a097-5902a6323bc0@o21g2000prn.googlegroups.com><0b12cdb1-45b4-41e4-9bdb-074ee669d76b@k14g2000pre.googlegroups.com> <048FB74272D440A0915ABC7D76AE262B@teddy> <5782E9AD8A8342D691EB3549E5E0ED7B@octavian> Message-ID: From: "Robert Kern" > That's not Terry's point. The reasons he's referring to (and stated previously) > are as follows: > > 1. The license of wxWidgets and wxPython is not as permissive as Python's. The > Python developers, as a matter of policy, do not want to include code into the > standard library that is less permissive than the current license. This is the worst and... sorry for the word, but real stupid thing. I mean, I don't consider a correct thinking to care more about the permissiveness of a licence which is anyway open source, more than about the accessibility. Try to think that for some people Tkinter displays just a black filled rectangle. In that case would you still think that it is "correct" to keep that kind of GUI because of some differences between open source licences? > 2. The Python developers require someone to commit to maintaining contributed > code for a number of years. No one has done so. See reason #3. In that case I understand that there are enough WxPython developers, well funded, but there is no commitment from them. >From Python's perspective, there are not enough maintainers that can offer that commitment and yes, this is a real reason why the core Python developers can't include WxPython. > 3. The wxPython developers do not want wxPython in the standard library, not > least because they want to develop and release wxPython at a different pace and > release cycle than the standard library. >From the message of a list member which (but maybe I am wrong) appear to be a WxPython developer, I suspected that the WxPython developers might not want their work to be included in the Python distribution. I am not really sure about this because I haven't seen any message from a WxPython developer telling that yes, I am a WxPython developer and we don't want to allow including WxPython in the Python distro, and I almost don't believe that, but if it is true, I don't know why they didn't said that, because WxPython is their work and of course that if they don't accept to maintain a WxPython as apart of Python distribution, then this discussion doesn't have any meaning. I have only heard that WxPython will never be included, but without beeing more clear. Who knows, maybe some of those who said that are WxPython developers but for me they are just some names because I don't know them... The next (or previous) points are not important anymore if the WxPython developers don't want their work to be included in the Python distribution. So, is it true? That was the cause for which WxPython can't be promoted by Python? Because the WxPython developers don't want this? If the answer is yes, then too bad, because as I said, it's their work and they can do whatever they like with it. Octavian From benjamin.kaplan at case.edu Wed Jan 26 12:52:41 2011 From: benjamin.kaplan at case.edu (Benjamin Kaplan) Date: Wed, 26 Jan 2011 12:52:41 -0500 Subject: Slice lists and extended slicing In-Reply-To: References: Message-ID: On Wed, Jan 26, 2011 at 12:20 PM, Gerald Britton wrote: > I'm looking at extended slicing and wondering when and how to use slice lists: > > slicing ? ? ? ? ?::= ?simple_slicing | extended_slicing > simple_slicing ? ::= ?primary "[" short_slice "]" > extended_slicing ::= ?primary "[" slice_list "]" > slice_list ? ? ? ::= ?slice_item ("," slice_item)* [","] > slice_item ? ? ? ::= ?expression | proper_slice | ellipsis > proper_slice ? ? ::= ?short_slice | long_slice > short_slice ? ? ?::= ?[lower_bound] ":" [upper_bound] > long_slice ? ? ? ::= ?short_slice ":" [stride] > lower_bound ? ? ?::= ?expression > upper_bound ? ? ?::= ?expression > stride ? ? ? ? ? ::= ?expression > ellipsis > > The semantics for an extended slicing are as follows. The primary must > evaluate to a mapping object, and it is indexed with a key that is > constructed from the slice list, as follows. If the slice list > contains at least one comma, the key is a tuple containing the > conversion of the slice items; otherwise, the conversion of the lone > slice item is the key. The conversion of a slice item that is an > expression is that expression. The conversion of an ellipsis slice > item is the built-in Ellipsis object. The conversion of a proper slice > is a slice object (see section The standard type hierarchy) whose > start, stop and step attributes are the values of the expressions > given as lower bound, upper bound and stride, respectively, > substituting None for missing expressions. > > I'd thought that I could do this: > >>>> l = [1,2,3,4,5] >>>> l[0:1, 3:4] > Traceback (most recent call last): > ?File "", line 1, in > TypeError: list indices must be integers, not tuple > > but that clearly doesn't work! ?So, when and how can one use slice lists? > > -- > Gerald Britton If you're trying to learn a language, I would suggest reading tutorials, not the grammar. As you can see from the error thrown, the operation is syntactically valid (you don't get a syntax error). It's just that lists don't accept them. I don't know of any built-in data type that takes slice lists but numpy matrices will. >>> a = numpy.matrix([[1,2,3],[4,5,6],[7,8,9]]) matrix([[1, 2, 3], [4, 5, 6], [7, 8, 9]]) >>> a[0:2,1:3] matrix([[2, 3], [5, 6]]) > -- > http://mail.python.org/mailman/listinfo/python-list > From benjamin.kaplan at case.edu Wed Jan 26 12:55:18 2011 From: benjamin.kaplan at case.edu (Benjamin Kaplan) Date: Wed, 26 Jan 2011 12:55:18 -0500 Subject: Bugs/issues in tkinter.simpledialog!! In-Reply-To: <412e4d83-f750-441d-bfc5-d96c0559e069@e9g2000prn.googlegroups.com> References: <412e4d83-f750-441d-bfc5-d96c0559e069@e9g2000prn.googlegroups.com> Message-ID: On Wed, Jan 26, 2011 at 11:53 AM, rantingrick wrote: > On Jan 26, 10:43?am, Emile van Sebille wrote: >> On 1/26/2011 8:00 AM rantingrick said... > >> > I just installed Python 3,0 on my machine. >> >> Try it again on the current release candidate --http://www.python.org/download/releases/3.2/-- testing old first >> >> Seehttp://docs.python.org/bugs.htmlhttp://www.python.org/dev/peps/pep-0003/ > > Why would i want to waste bandwidth downloading an RC? Can i not just > browse the source online? I only need to check one module. Where is > the source available for viewing "simpledialog" online? > > Thanks > > PS: The version i have now is 3.1.1 (but i would like to see the > newest version available, just not download it!) The code is hosted on http://svn.python.org If you just one that one file, it's at http://svn.python.org/view/python/trunk/Lib/lib-tk/tkSimpleDialog.py?view=markup > -- > http://mail.python.org/mailman/listinfo/python-list > From jeanmichel at sequans.com Wed Jan 26 12:55:53 2011 From: jeanmichel at sequans.com (Jean-Michel Pichavant) Date: Wed, 26 Jan 2011 18:55:53 +0100 Subject: method-to-instance binding, callable generator decorator In-Reply-To: <1296061496.1121.10.camel@selene> References: <1296061496.1121.10.camel@selene> Message-ID: <4D406029.8060809@sequans.com> Jack Bates wrote: > Am struggling to understand Python method-to-instance binding > > Anyone know why this example throws a TypeError? > > >> #!/usr/bin/env python >> >> import functools >> >> # Take a generator function (i.e. a callable which returns a generator) and >> # return a callable which calls .send() >> class coroutine: >> def __init__(self, function): >> self.function = function >> >> functools.update_wrapper(self, function) >> >> def __call__(self, *args, **kwds): >> try: >> return self.generator.send(args) >> >> except AttributeError: >> self.generator = self.function(*args, **kwds) >> >> return self.generator.next() >> >> # Each time we're called, advance to next yield >> @coroutine >> def test(): >> yield 'call me once' >> yield 'call me twice' >> >> # Works like a charm : ) >> assert 'call me once' == test() >> assert 'call me twice' == test() >> >> class Test: >> >> # Each time we're called, advance to next yield >> @coroutine >> def test(self): >> yield 'call me once' >> yield 'call me twice' >> >> test = Test() >> >> # TypeError, WTF? >> assert 'call me once' == test.test() >> assert 'call me twice' == test.test() >> > > https://gist.github.com/797019 > > Am trying to write a decorator such that each time I call a function, it > advances to the next "yield" - I plan to use functions like this as > fixtures in tests > > Does a decorator like this already exist in the Python standard library? > At the time you set the self.function attribute, its value is an unbound method, and thus must be called with the instance as first attribute. Since "self.generator = self.function(*args, **kwds)" doesn't pass the self arguement as 1st parameter, you have to do it yourself. replace your last 2 lines by assert 'call me once' == test.test(test) assert 'call me twice' == test.test(test) One alternative is to decorate, once the instance is created, ie. the method is bound to the instance and does not require to pass the instance as 1st argument: class Test2: def test2(self): yield 'call me once' yield 'call me twice' test2 = Test2() test2.test2 = coroutine(test2.test2) assert 'call me once' == test2.test2() assert 'call me twice' == test2.test2() I'm not sure it's a standard way to proceed though, it looks rather strange. I'm not familiar with decorators, but my guess is that one decorator cannot (except through the above tricks) decorate functions AND unbound methods. In order to make your original coroutine decorator work with unbound methods, and only unbound methods, change self.generator = self.function(*args, **kwds) into self.generator = self.function(self, *args, **kwds) Hope it helps, JM From robert.kern at gmail.com Wed Jan 26 13:06:24 2011 From: robert.kern at gmail.com (Robert Kern) Date: Wed, 26 Jan 2011 12:06:24 -0600 Subject: Slice lists and extended slicing In-Reply-To: References: Message-ID: On 1/26/11 11:20 AM, Gerald Britton wrote: > I'm looking at extended slicing and wondering when and how to use slice lists: > > slicing ::= simple_slicing | extended_slicing > simple_slicing ::= primary "[" short_slice "]" > extended_slicing ::= primary "[" slice_list "]" > slice_list ::= slice_item ("," slice_item)* [","] > slice_item ::= expression | proper_slice | ellipsis > proper_slice ::= short_slice | long_slice > short_slice ::= [lower_bound] ":" [upper_bound] > long_slice ::= short_slice ":" [stride] > lower_bound ::= expression > upper_bound ::= expression > stride ::= expression > ellipsis > > The semantics for an extended slicing are as follows. The primary must > evaluate to a mapping object, and it is indexed with a key that is > constructed from the slice list, as follows. If the slice list > contains at least one comma, the key is a tuple containing the > conversion of the slice items; otherwise, the conversion of the lone > slice item is the key. The conversion of a slice item that is an > expression is that expression. The conversion of an ellipsis slice > item is the built-in Ellipsis object. The conversion of a proper slice > is a slice object (see section The standard type hierarchy) whose > start, stop and step attributes are the values of the expressions > given as lower bound, upper bound and stride, respectively, > substituting None for missing expressions. > > I'd thought that I could do this: > >>>> l = [1,2,3,4,5] >>>> l[0:1, 3:4] > Traceback (most recent call last): > File "", line 1, in > TypeError: list indices must be integers, not tuple > > but that clearly doesn't work! So, when and how can one use slice lists? The object just needs to implement its __getitem__(self, key) method appropriately. list objects have an implementation that only processes integer indices and slices. The original semantics that motivated this syntax feature is not to take several slices from a sequence and concatenate them together. Rather, it was to support multidimensional slices for numpy arrays (or rather, numpy's predecessor Numeric). [~] |1> from numpy import arange [~] |2> A = arange(20).reshape([4,5]) [~] |3> A array([[ 0, 1, 2, 3, 4], [ 5, 6, 7, 8, 9], [10, 11, 12, 13, 14], [15, 16, 17, 18, 19]]) [~] |4> A[1:3, 2:4] array([[ 7, 8], [12, 13]]) list objects could be written to interpret a tuple of slices any way it wants to, including the semantics you seem to have expected. I would suggest, though, that the need for those semantics isn't common enough to warrant the syntactic sugar. -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco From clp2 at rebertia.com Wed Jan 26 13:17:45 2011 From: clp2 at rebertia.com (Chris Rebert) Date: Wed, 26 Jan 2011 10:17:45 -0800 Subject: Slice lists and extended slicing In-Reply-To: References: Message-ID: On Wed, Jan 26, 2011 at 9:20 AM, Gerald Britton wrote: > I'm looking at extended slicing and wondering when and how to use slice lists: > > slicing ? ? ? ? ?::= ?simple_slicing | extended_slicing > simple_slicing ? ::= ?primary "[" short_slice "]" > extended_slicing ::= ?primary "[" slice_list "]" > slice_list ? ? ? ::= ?slice_item ("," slice_item)* [","] > slice_item ? ? ? ::= ?expression | proper_slice | ellipsis > proper_slice ? ? ::= ?short_slice | long_slice > short_slice ? ? ?::= ?[lower_bound] ":" [upper_bound] > long_slice ? ? ? ::= ?short_slice ":" [stride] > lower_bound ? ? ?::= ?expression > upper_bound ? ? ?::= ?expression > stride ? ? ? ? ? ::= ?expression > ellipsis > > The semantics for an extended slicing are as follows. The primary must > evaluate to a mapping object, and it is indexed with a key that is > constructed from the slice list, as follows. If the slice list > contains at least one comma, the key is a tuple containing the > conversion of the slice items; otherwise, the conversion of the lone > slice item is the key. The conversion of a slice item that is an > expression is that expression. The conversion of an ellipsis slice > item is the built-in Ellipsis object. The conversion of a proper slice > is a slice object (see section The standard type hierarchy) whose > start, stop and step attributes are the values of the expressions > given as lower bound, upper bound and stride, respectively, > substituting None for missing expressions. > > I'd thought that I could do this: > >>>> l = [1,2,3,4,5] >>>> l[0:1, 3:4] > Traceback (most recent call last): > ?File "", line 1, in > TypeError: list indices must be integers, not tuple > > but that clearly doesn't work! ?So, when and how can one use slice lists? When the object you're slicing supports it, which is rarely. None of the built-in types support multiple proper_slices like your example; I know of no std lib classes that do either. However, the 3rd party matrix library NumPy very well might. Normally, one would instead write your example as: l[0:1] + l[3:4] Cheers, Chris -- http://blog.rebertia.com From rantingrick at gmail.com Wed Jan 26 13:19:39 2011 From: rantingrick at gmail.com (rantingrick) Date: Wed, 26 Jan 2011 10:19:39 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <8q7sgiF5tpU1@mid.individual.net> <19891784-d6a3-41ac-a097-5902a6323bc0@o21g2000prn.googlegroups.com><0b12cdb1-45b4-41e4-9bdb-074ee669d76b@k14g2000pre.googlegroups.com> <048FB74272D440A0915ABC7D76AE262B@teddy> <5782E9AD8A8342D691EB3549E5E0ED7B@octavian> Message-ID: <9649b12c-46b3-475a-8c33-2790d13f5a46@j19g2000prh.googlegroups.com> On Jan 26, 10:35?am, Robert Kern wrote: > On 1/26/11 10:00 AM, Emile van Sebille wrote: > That's not Terry's point. The reasons he's referring to (and stated previously) > are as follows: > > 1. The license of wxWidgets and wxPython is not as permissive as Python's. The > Python developers, as a matter of policy, do not want to include code into the > standard library that is less permissive than the current license. This is actually a weak argument and i'll explain why. GUI libraries are very complicated and time consuming projects. Just think of all the work involved just to get a library working on one platform... much less THREE or more platforms! And while i am a huge believer in 100% open source software you've got to understand why most libraries are restrictive for commercial usage or worse. Yes TclTk IS fully opensource and i applaud them for it! However like the old adage say: "You get what you pay for". > 2. The Python developers require someone to commit to maintaining contributed > code for a number of years. No one has done so. See reason #3. > > 3. The wxPython developers do not want wxPython in the standard library, not > least because they want to develop and release wxPython at a different pace and > release cycle than the standard library. I have already shown why this does not matter. The current wxPython API is NOT good for Python. We DO NOT want segfaults and "C++ looking" code written by the users of a Python stdlib module. Robin has stated that there exists room for an abstraction layer on top of wxPython and he is correct. He has also stated that he wants to keep "his wxPython" as close to WxWidgets as possible. So be it! We will never want to include wxPython "proper" in the stdlib anyway because it is SO unpythonic!! No. All we have to do is create an abstraction API that calls wxPython until we can create OUR OWN wxPython from WxWidgets. Call it Wxpy if you like. > 4. The Python developers have committed to maintaining backwards compatibility > in the standard library for a very long time. Even if they included wxPython > into the standard library, they would have to provide a Tkinter module that > works like the current one. I do not believe it is feasible to write a Tkinter > workalike that uses wxPython, so we would still be relying on Tcl/Tk. Fine support Tkinter until Python4000 i don't care. But we must move forward. We must accept that Tkinter is already legacy and there is no moving forward now. We will support Tkinter for backwards compadibility however we will start to integrate a truly Pythonic WxPython abstraction API and include just the API module in the stdlib. Then we don't have to maintain a huge library, just a small module with a wxPython 3rd party dependency. Then at some point in the future when the stdlib is ripe, we can THEN include some form of wxWidgets, and dump Tkinter forever. At least then we would be moving towards something. Currently we are stagnate. > > There is certainly enough maintenance force to keep wxPython updated and ported > to Python 3, but only *outside* of the standard library. So let wxPython due what wxPython does best. We will use them as long as we need until we can create a stdlib compliant wxPython ourselves. They would be fools not to work with us! Because eventually when no 3rd party download is needed, all their work would go into the bit bucket. I doubt Robin is that foolish. He seems like a smart fellow to me -- even though he refuses to comply with PEP8 :) SUMMARY: We create an abstraction API atop "Robin's WxPython". We include only the API in the stdlib at this time and we keep Tkinter in maintenance. Then over the next few years we start a fresh wxPython project that will be acceptable for the stdlib. Something that we can plug our API into. We steal as much from Robin as we can (or get him to cooperate). Then when the time is right, we dump Tkinter and integrate the new Wxpy module into the stdlib. Then we will be back on track. From malaclypse2 at gmail.com Wed Jan 26 13:21:12 2011 From: malaclypse2 at gmail.com (Jerry Hill) Date: Wed, 26 Jan 2011 13:21:12 -0500 Subject: Bugs/issues in tkinter.simpledialog!! In-Reply-To: <412e4d83-f750-441d-bfc5-d96c0559e069@e9g2000prn.googlegroups.com> References: <412e4d83-f750-441d-bfc5-d96c0559e069@e9g2000prn.googlegroups.com> Message-ID: On Wed, Jan 26, 2011 at 11:53 AM, rantingrick wrote: > Why would i want to waste bandwidth downloading an RC? Can i not just > browse the source online? If I understand what you're asking for, the answer is http://svn.python.org/view . If you're specifically looking for 3.2rc1, then I believe you could look at http://svn.python.org/view/python/tags/r32rc1/ > I only need to check one module. Where is > the source available for viewing "simpledialog" online? > Again, assuming you're looking for the 3.2rc1 code in particular: http://svn.python.org/view/python/tags/r32rc1/Lib/tkinter/simpledialog.py?view=markup -- Jerry -------------- next part -------------- An HTML attachment was scrubbed... URL: From emile at fenx.com Wed Jan 26 13:22:13 2011 From: emile at fenx.com (Emile van Sebille) Date: Wed, 26 Jan 2011 10:22:13 -0800 Subject: Slice lists and extended slicing In-Reply-To: References: Message-ID: On 1/26/2011 9:20 AM Gerald Britton said... > I'm looking at extended slicing and wondering when and how to use slice lists: I think the use of the term slice_list below is simply as the content between the encompassing brackets, eg in mylist[1:2:3] slice_list refers to 1:2:3. So, you don't actually 'use' a slice_list - that's what the passed in value is called. So, here are some example of how slicing is used: >>> a = range(10) [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] >>> a[:3] # the first three [0, 1, 2] >>> a[-3:] # the last three [7, 8, 9] >>> a[3:-3] # start and stop [3, 4, 5, 6] >>> a[::2] # take every other [0, 2, 4, 6, 8] >>> a[::-2] # take every other from the end [9, 7, 5, 3, 1] >>> a[3:-3:2] # take every other within start stop [3, 5] >>> a[3:-3:-2] # I'm not sure exactly why I didn't get something here [] >>> a[-3:3:-2] # but apparently the polarity of stride within start stop matters [7, 5] >>> HTH Emile > > slicing ::= simple_slicing | extended_slicing > simple_slicing ::= primary "[" short_slice "]" > extended_slicing ::= primary "[" slice_list "]" > slice_list ::= slice_item ("," slice_item)* [","] > slice_item ::= expression | proper_slice | ellipsis > proper_slice ::= short_slice | long_slice > short_slice ::= [lower_bound] ":" [upper_bound] > long_slice ::= short_slice ":" [stride] > lower_bound ::= expression > upper_bound ::= expression > stride ::= expression > ellipsis > > The semantics for an extended slicing are as follows. The primary must > evaluate to a mapping object, and it is indexed with a key that is > constructed from the slice list, as follows. If the slice list > contains at least one comma, the key is a tuple containing the > conversion of the slice items; otherwise, the conversion of the lone > slice item is the key. The conversion of a slice item that is an > expression is that expression. The conversion of an ellipsis slice > item is the built-in Ellipsis object. The conversion of a proper slice > is a slice object (see section The standard type hierarchy) whose > start, stop and step attributes are the values of the expressions > given as lower bound, upper bound and stride, respectively, > substituting None for missing expressions. > > I'd thought that I could do this: > >>>> l = [1,2,3,4,5] >>>> l[0:1, 3:4] > Traceback (most recent call last): > File "", line 1, in > TypeError: list indices must be integers, not tuple > > but that clearly doesn't work! So, when and how can one use slice lists? > From urban.dani at gmail.com Wed Jan 26 13:23:36 2011 From: urban.dani at gmail.com (Daniel Urban) Date: Wed, 26 Jan 2011 19:23:36 +0100 Subject: Behaviour-based interface/protocol implementation? In-Reply-To: References: Message-ID: > That's just what I'd like and I suppose can't be currently done with > current ABC, PyProtocols or zope.interface implementations, right? It can. With __instancecheck__ you can override isinstance. It is possible (for example) to write a subclass of abc.ABCMeta, which extends __instancecheck__ to use an _instancehook classmethod similarly to __subclasshook__. Then in your MyInterface class you can implement _instancehook to check for methods/signatures/whatever you want. Daniel From debatem1 at gmail.com Wed Jan 26 13:28:45 2011 From: debatem1 at gmail.com (geremy condra) Date: Wed, 26 Jan 2011 10:28:45 -0800 Subject: WxPython versus Tkinter. In-Reply-To: <753A4C5A6658470085804B13C80340F2@octavian> References: <4D3E4377.3060807@tysdomain.com> <9MB%o.14110$%64.6074@unlimited.newshosting.com> <4A48EDF6D7634F2E994661A457451E87@teddy> <753A4C5A6658470085804B13C80340F2@octavian> Message-ID: On Tue, Jan 25, 2011 at 11:10 PM, Octavian Rasnita wrote: > From: "geremy condra" >> >> There's a difference between what you say and how you say it. If a >> friend came up to you and said "give me $100 right now!", you probably >> wouldn't do it. If the same friend came up to you and said "I know >> this is a big thing to ask, but I really need $100 and I can't >> guarantee I'll be able to pay you back. Could you please help me?" I > > Are you even thinking that the second sentence is much harder to express? > Do you imagine that my knowledge of English is limited by the fact that it > is not my native language and it is a language not spoken by very many > people in my country? > I simply might not be able to express so nice as you like that I need 100 > bucks from you, but I might be able to just tell you that "need 100 dollars. > now". > I could argue much more nice and expressive if we were speaking Romanian and > not English. At least 40% of my coworkers do not speak English as their native language. Your problem is not the language. Your problem is your attitude. > But I don't condemn you for this, because many years ago when I was in > school I had the opinion that some foreign colleagues are a little stupid > just because they were not able to express very well the ideas which were > not very simple, and well, they were not stupid at all, but they didn't know > my language well enough and they probably would think the same thing about > me if we were speaking in Russian. I don't have that problem. >> don't know very many people who would refuse if they were able to >> help. The reason is simple: the first does not acknowledge the value >> of the person doing the favor, and the second does. > > Exactly what I said. They are doing the same mistake as I did 20 years ago. > By the way, can't you see any syntactic dissacords in my phrases? Haven't > you think that my English might not be as fluent to be able to express > everything I want to say very well? As I mentioned earlier, you'll find I don't have a lot of pity for you in this. >> More concretely, you have an opinion that not supporting accessibility >> is discrimination. Tyler has an opinion that not supporting >> accessibility is a bug. > > This is not always true. Not supporting accessibility when *it is not > possible* yes, it is a bug as you say, so we agree here. > But not supporting accessibility because the programmer *doesn't want this*, > it is not a bug, but discrimination. Don't you agree with this? > And if Python would have been able to support accessibility it would have > mean that it promotes discrimination because it promotes the wrong tool, but > it seems that Python 3 doesn't have an accessible GUI lib for the moment, so > no, it is not discrimination (but Emile told us that there is no support for > WxPython in Python 3 just today, so I didn't know this and I already > wondered why nobody told about this real problem). Keep in mind, I'm not saying this. This is a sketch of your point of view and Tyler's point of view. >> Are you going to demand that he change his >> opinion? Or are you going to ask that he consider yours? > > It seems that the discrimination should be something that should be > discussed if and when it should be applied, isn't it? > Well, I think that everyone should understand why the programs must be > accessible and why everybody should care about all the users of an > application and that it is not normal to not care. Ah! I think I see where you're going wrong. It *is* normal not to care- not just about this, but about any given special interest other than your own. You have to convince people to care, or they don't- and you're not convincing, just yelling. >>> Have I said something wrong? Did I use bad words? Or what was it wrong? >> >> I think it was uncivil. It was rude, unkind, and generally >> disagreeable. I lost respect for you, and by proxy, for your point of >> view. In other words, you lost support not because fewer people agree >> with your position, but because fewer people want to agree with you. > > You are also very unkind and rude when you say that the disabled that need > to use a screen reader should be a kind of second hand people that need to > beg for a little accessibility. I don't say this. Don't try to stuff me into a strawman argument. > When you create a program, why do you create a visual interface for it? Why > don't you create just an audio interface? I don't create a visual interface. I have never found it necessary for my line of work, and have little stake in this discussion besides that of advocating civility on this list. > You do this because otherwise you would not please those who can see. Why > shouldn't be something normal, and that *should be not be discussable at > all* to offer the same accessibility to everyone? You can discuss it. You just have to convince others that you're right, and you're not doing that well. I offered you some advice on how to go about doing it better. > And you didn't say what was rude from what I said. You said just that it was > rude. I can provide quotes, if you like. > Oh yes I know that it is unkind because most of the people don't even like > to talk personally with disabled people, but this doesn't mean that the > disabled people are something not normal, but those who have those biases > towards those who are very different. I don't have this problem. >> I didn't ask you to change your opinion. I told you that you would be >> more effective if you changed your attitude. Like rantingrick, you're >> free to ignore that advice, but it is good advice for both you and the >> community, and I urge you to take it. > > About what community? It would be better for the community of the disabled? > Or you don't care about that community? I think it would be better for the Python community if you were more civil and for the disabled community if you were more successful. The two go hand in hand. >>> Or you recommend me to be just like Tyler that can't use all the apps he >>> could use if they were accessible, but he doesn't care because he cares much >>> more to play nice in order to be accepted in this not-right society? >> >> I would recommend that you learn to be civil to those you disagree >> with. The alternative is to be surrounded by them. > > Aha, you show that old fact that the majority is more important because it > has more power, the fact Tyler is afraid. More people have the power to accomplish what fewer cannot. You want big changes, you will need big support, and people won't just move to your side because you're angry. You have to convince them. > The majority can be also wrong, the majority can also have bad feelings, and > that majority that have the power to change things should be informed and > convinced to change them. Yes, absolutely. > If the majority doesn't care about the minorities which are minorities > without willing to be so, then it means that it is wrong. I don't know that's the case, and I suspect there are shades of grey you are not acknowledging here. Geremy Condra From clp2 at rebertia.com Wed Jan 26 13:31:43 2011 From: clp2 at rebertia.com (Chris Rebert) Date: Wed, 26 Jan 2011 10:31:43 -0800 Subject: Is it possible to pass CSV Reader Object As Argument to another Python File ??? In-Reply-To: <2c35653e-3565-48c6-8939-b6b09b885e3f@d23g2000prj.googlegroups.com> References: <2c35653e-3565-48c6-8939-b6b09b885e3f@d23g2000prj.googlegroups.com> Message-ID: On Wed, Jan 26, 2011 at 7:51 AM, bansi wrote: > I have following two python scripts > -namelookupWrapper.py > -namelookup.py > > > The namelookupWrapper.py takes input of "memberId", "memberName" from > CLI and has following code snippet > > idf = sys.argv[1] > namef = sys.argv[2] > real_script = "C:\\Splunk\\etc\\apps\\search\\bin\\namelookup.py" > r = csv.reader(sys.stdin) > os.execv(python_executable, [ python_executable, real_script ] + > sys.argv[1:] ) > > Wondering how would i pass csv reader object "r" as an argument using > os.execv() to another python script i.e. namelookup.py It's not possible to pass Python objects between processes in such a manner. Given that "independent" scripts can't directly take objects as input anyway, I doubt the two scripts are truly independent from each other. I would therefore concur with van Sebille that you should just rewrite them so that one script imports from the other rather than spawning the other. It should not be too hard to port the Python 2.6 script to Python 2.7 (or vice-versa if necessary). Cheers, Chris -- http://blog.rebertia.com From nstinemates at gmail.com Wed Jan 26 13:42:24 2011 From: nstinemates at gmail.com (Nick Stinemates) Date: Wed, 26 Jan 2011 10:42:24 -0800 Subject: Bugs/issues in tkinter.simpledialog!! In-Reply-To: References: Message-ID: > However some things never change it seems and some improvements are > actually a step backwards. The same problems with the unit test in 2.x > got ported to 3.x. And the new SimpleDialog is just more lackluster > code like we've seen before. I was hoping to be amazed, i am > disappointed and disgusted. It is obvious that whoever is writing/ > maintaining the tkinter code base does NOT understand tkinter > completely and this is blinding apparent by reading the source code! > ----------- > Issues > ----------- > > First lets start with the problems that migrated from 2.x... > (tkinter.simpledialog) > > #-- ISSUE 1 --# > In the test() function we still have code that uses the "quit" method > instead of "destroy". Calling the "quit" method only tells Tkinter to > stop processing events, IT DOES NOT DESTROY THE WIDGET!! And on > windows the the root will then become unresponsive -- you cannot close > the window, you cannot do anything. I have said time and time again. > DO NOT USE THE QUIT METHOD UNLESS YOU KNOW WHAT THE HECK YOU ARE > DOING! So the code needs to be this... > > OLD: > q = Button(root, text='Quit', command=t.quit) > > NEW: > q = Button(root, text='Quit', command=root.destroy) > > > #-- ISSUE 2: --# > The author used a very strange method by which to denote the default > button in the SimpleDialog class. He choose to set the relief to RIDGE > and the border "8". This not only looks horrible (and exposes the > authors ignorance of tkinter) but a much more elegant solution is > provided by the TclTk folks. All buttons have a "default" option that > will display the button with a nice border so the user can visually > see which button is active. So the code should be this.... > > OLD: > if num == default: > b.config(relief=RIDGE, borderwidth=8) > > NEW: > if num == default: > b.config(default=ACTIVE) > > > Last but not least i am puzzled as to why we choose the method name > "go" over "show". for "showing" the dialog. SimpleDialog uses no > inheritance so name clashes are mum. Why would anyone choose "go" over > "show" for a modal dialog? I would really like an explanation for > this. > > Sounds like you need to help by: Creating a bug report Attaching a patch Thanks for the help, Rick. Nick -------------- next part -------------- An HTML attachment was scrubbed... URL: From subhabangalore at gmail.com Wed Jan 26 13:47:05 2011 From: subhabangalore at gmail.com (Subhabrata) Date: Wed, 26 Jan 2011 10:47:05 -0800 (PST) Subject: Question on Open Project Message-ID: <076881d4-6437-487b-a061-252dab625460@k21g2000prb.googlegroups.com> Dear Room, I am a python programmer, from India(New Delhi area), and was in Bangalore for long days. My specialization is Natural Language Processing, -Machine Learning(worked on Naive Bayes, SVM, HMM, CRF). I am looking for some open projects in Python-in Machine Learning/NLP area, preferably from India(as many a times personal interaction is helpful) which I can do from home. If anyone knows of any reliable link. Best, Subhabrata. From robert.kern at gmail.com Wed Jan 26 14:00:23 2011 From: robert.kern at gmail.com (Robert Kern) Date: Wed, 26 Jan 2011 13:00:23 -0600 Subject: WxPython versus Tkinter. In-Reply-To: References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <8q7sgiF5tpU1@mid.individual.net> <19891784-d6a3-41ac-a097-5902a6323bc0@o21g2000prn.googlegroups.com><0b12cdb1-45b4-41e4-9bdb-074ee669d76b@k14g2000pre.googlegroups.com> <048FB74272D440A0915ABC7D76AE262B@teddy> <5782E9AD8A8342D691EB3549E5E0ED7B@octavian> Message-ID: On 1/26/11 11:46 AM, Octavian Rasnita wrote: > From: "Robert Kern" >> That's not Terry's point. The reasons he's referring to (and stated previously) >> are as follows: >> >> 1. The license of wxWidgets and wxPython is not as permissive as Python's. The >> Python developers, as a matter of policy, do not want to include code into the >> standard library that is less permissive than the current license. > > This is the worst and... sorry for the word, but real stupid thing. > I mean, I don't consider a correct thinking to care more about the permissiveness of a licence which is anyway open source, more than about the accessibility. Being able to say that all of a project is available under the substantively the same license is really important. It's very hard to get people to use your software if some parts are under one license and other parts are under a substantively different one. You are free to decide what licenses you want to distribute software under; the PSF has that freedom as well. > Try to think that for some people Tkinter displays just a black filled rectangle. In that case would you still think that it is "correct" to keep that kind of GUI because of some differences between open source licences? This is a reason for application developers to use wxPython, not for the Python developers to include wxPython in the standard library. The standard library neither claims nor aims to do everything. There are many things that Tkinter cannot do that wxPython can. None of those things are reasons to replace Tkinter with wxPython in the standard library. Not everything useful has to be in the standard library. Python has a vibrant ecosystem of third party packages. wxPython is probably the most widely used GUI toolkit in Python. It has not been harmed (and I would argue that it has been very much helped) by not being in the standard library. Nor has it been harmed by the presence of Tkinter in the standard library. If wxPython had been included in the Python standard library, it would not have been able to easily follow the advancements of the underlying wxWidgets toolkit, and it would be a much less strong GUI toolkit. >> 2. The Python developers require someone to commit to maintaining contributed >> code for a number of years. No one has done so. See reason #3. > > In that case I understand that there are enough WxPython developers, well funded, but there is no commitment from them. Correct, they have not committed to maintaining wxPython as part of the standard library (although they are committed to maintaining wxPython outside of it). They have not even suggested that wxPython should be part of the standard library. >> From Python's perspective, there are not enough maintainers that can offer that commitment and yes, this is a real reason why the core Python developers can't include WxPython. > >> 3. The wxPython developers do not want wxPython in the standard library, not >> least because they want to develop and release wxPython at a different pace and >> release cycle than the standard library. > > >> From the message of a list member which (but maybe I am wrong) appear to be a WxPython developer, I suspected that the WxPython developers might not want their work to be included in the Python distribution. > I am not really sure about this because I haven't seen any message from a WxPython developer telling that yes, I am a WxPython developer and we don't want to allow including WxPython in the Python distro, and I almost don't believe that, but if it is true, I don't know why they didn't said that, because WxPython is their work and of course that if they don't accept to maintain a WxPython as apart of Python distribution, then this discussion doesn't have any meaning. Robin, if you're still paying attention to this thread, would you mind chiming in? Robin Dunn is the wxPython project lead. > I have only heard that WxPython will never be included, but without beeing more clear. > Who knows, maybe some of those who said that are WxPython developers but for me they are just some names because I don't know them... > > The next (or previous) points are not important anymore if the WxPython developers don't want their work to be included in the Python distribution. > > So, is it true? That was the cause for which WxPython can't be promoted by Python? There is a large difference between the being "promoted by Python" and being "included in Python's standard library. The latter is the issue at hand, not the former. wxPython is already "promoted" by Python's documentation: http://docs.python.org/library/othergui.html -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco From misnomer at gmail.com Wed Jan 26 14:02:37 2011 From: misnomer at gmail.com (Nicholas Devenish) Date: Wed, 26 Jan 2011 19:02:37 +0000 Subject: WxPython versus Tkinter. In-Reply-To: <9649b12c-46b3-475a-8c33-2790d13f5a46@j19g2000prh.googlegroups.com> References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <8q7sgiF5tpU1@mid.individual.net> <19891784-d6a3-41ac-a097-5902a6323bc0@o21g2000prn.googlegroups.com><0b12cdb1-45b4-41e4-9bdb-074ee669d76b@k14g2000pre.googlegroups.com> <048FB74272D440A0915ABC7D76AE262B@teddy> <5782E9AD8A8342D691EB3549E5E0ED7B@octavian> <9649b12c-46b3-475a-8c33-2790d13f5a46@j19g2000prh.googlegroups.com> Message-ID: On 26/01/2011 18:19, rantingrick wrote: > SUMMARY: We create an abstraction API atop "Robin's WxPython". We > include only the API in the stdlib at this time and we keep Tkinter in > maintenance. Then over the next few years we start a fresh wxPython > project that will be acceptable for the stdlib. Something that we can > plug our API into. We steal as much from Robin as we can (or get him > to cooperate). Then when the time is right, we dump Tkinter and > integrate the new Wxpy module into the stdlib. Then we will be back on > track. I look forward to reading your PEP and initial design documents, though I suspect you would need the latter and to get some a decent portion of work done before it would even be considered as an inclusion into the standard library. I strongly suspect that your response to this suggestion would be the ironic "more talk and no action from X". Many capable developers have their own occupations and might not have the spare time or desire to spend on a project where all evidence suggests would be a (non-benevolent) dictatorship where they would be endlessly browbeaten. You have continuously tried to outright present yourself as a 'visionary' and speaker for the python community and then asked why people don't take you seriously. People would take you a lot more seriously if you showed that you had the vision and capability to drive development of such a serious undertaking, and manage such a team of developers, whom you have first managed to attract to the project. If you actually seriously believe this should happen and that you are the best person to drive it, the way to go about it is probably: - Write some design documents, or even code, laying out what you think the interface should be. - Put it out to the community, listen to advice, make changes (it will NOT be perfect) and gather support. - Provide an initial implementation Somebody in the old thread said something which made sense, which I paraphrase as: "Only idiots think they can command communities of equals." This is something to keep closely in mind in your continuing, what can only be described as 'crusades'. This, along with the fact that people remember first impressions, and are usually cautious about reversing opinions developed through many examples of uncivility. Heck, I am probably wasting my time with this post; but you come across as genuine in your held central beliefs, and so either serious or the most dedicated and adept troll I have ever encountered. In the case of the former, I hold an optimistic view that most people are capable of self-asessment. In the case of the latter, consider me successfully trolled. Nick From robert.kern at gmail.com Wed Jan 26 14:05:29 2011 From: robert.kern at gmail.com (Robert Kern) Date: Wed, 26 Jan 2011 13:05:29 -0600 Subject: WxPython versus Tkinter. In-Reply-To: <43FCB75BBC57406799C87AD6FC781EFC@teddy> References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <8q7sgiF5tpU1@mid.individual.net> <19891784-d6a3-41ac-a097-5902a6323bc0@o21g2000prn.googlegroups.com><0b12cdb1-45b4-41e4-9bdb-074ee669d76b@k14g2000pre.googlegroups.com> <048FB74272D440A0915ABC7D76AE262B@teddy> <5782E9AD8A8342D691EB3549E5E0ED7B@octavian> <43FCB75BBC57406799C87AD6FC781EFC@teddy> Message-ID: On 1/26/11 11:19 AM, Octavian Rasnita wrote: > From: "Emile van Sebille" > ... >>> Well, I didn't know this, and it is a valid reason. >>> This means that it is true that there is no enough maintainance force to >>> keep WxPython updated. >>> Did I understand correctly? >> >> Not at all -- wxPython is an active funded ongoing project. Review the >> roadmap at http://wiki.wxpython.org/TentativeRoadmap and particularly >> the final paragraph on Python3.x support. >> >> Emile > > But somebody said that the core Python developers, or Guido said that WxPython won't be included in the core distribution because it doesn't have a strong team of maintainers... with other words but this was the idea. No, you are misrepresenting what was said. What is required is that someone make an active commitment to maintain wxPython as part of the standard library *specifically*. That means that the package has to follow Python's release cycle. The wxPython developers do not wish to do that. They can develop wxPython much better outside of the standard library. -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco From alex.kapps at web.de Wed Jan 26 14:16:49 2011 From: alex.kapps at web.de (Alexander Kapps) Date: Wed, 26 Jan 2011 20:16:49 +0100 Subject: WxPython versus Tkinter. In-Reply-To: <33C68A0874BE4C66AB478EDFB64C2C1D@teddy> References: <4D3E4377.3060807@tysdomain.com><9MB%o.14110$%64.6074@unlimited.newshosting.com> <59F6E65E3D9A46AD8D7A3863F3C1DC84@teddy> <27f53f8c-7862-4366-9352-82ae9a2f3970@k3g2000yqc.googlegroups.com> <718D13777F254C839F9564BC4275DE0A@octavian> <4D402C42.1030407@tysdomain.com> <4D40447C.4010108@tysdomain.com> <33C68A0874BE4C66AB478EDFB64C2C1D@teddy> Message-ID: <4D407321.3090705@web.de> On 26.01.2011 18:04, Octavian Rasnita wrote: > From: "Littlefield, Tyler" >>> with JAWS because it is the most used screen reader. >> Get off your me soapbox. Jaws is not the most used. NVDA is taking over, >> quite fast, and lots of people have totally switched to mac or Vinux > > Lots of people means an insignifiant percent of users compared with the percent of Windows users. Please don't use the lower Linux user percentage as an argument here. If you follow that path further, you would need to agree that it's only an "insignificant" percent of people who need a screen reader, so why bother? Note carefully: I am *not* saying that one shouldn't bother about the "minority" of people who need accessibility, just that you can't use an argument that ignores another minority (Linux user) if you fight for your minority (and no, Linux isn't anymore a "freak-os". Several countries (getting more) have started to migrate governmental IT infrastructures to Linux, so if you mean it serious, you just need to care for their, possibly impaired, workers too.) (Also please don't weigh my words to strong; I'm no native english speaker and my wording might be clumsy. Try to understand what I really wanted to say or ask back.) From tyler at tysdomain.com Wed Jan 26 14:17:07 2011 From: tyler at tysdomain.com (Littlefield, Tyler) Date: Wed, 26 Jan 2011 12:17:07 -0700 Subject: WxPython versus Tkinter. In-Reply-To: <33C68A0874BE4C66AB478EDFB64C2C1D@teddy> References: <4D3E4377.3060807@tysdomain.com><9MB%o.14110$%64.6074@unlimited.newshosting.com> <59F6E65E3D9A46AD8D7A3863F3C1DC84@teddy> <27f53f8c-7862-4366-9352-82ae9a2f3970@k3g2000yqc.googlegroups.com> <718D13777F254C839F9564BC4275DE0A@octavian> <4D402C42.1030407@tysdomain.com> <4D40447C.4010108@tysdomain.com> <33C68A0874BE4C66AB478EDFB64C2C1D@teddy> Message-ID: <4D407333.1070301@tysdomain.com> It doesn't support a good voice synthesizer like Eloquence or IBM Via voice, but only eSpeak which sounds horrible, it doesn't have a scripting language ready to use as JAWS and Window Eyes do, it doesn't offer the possibility of reading with the mouse cursor as JAWS does with its so called JAWS cursor, it offers a poor accessibility in many applications and many other issues. You are wrong, on all accounts. On 1/26/2011 10:04 AM, Octavian Rasnita wrote: > From: "Littlefield, Tyler" >>> with JAWS because it is the most used screen reader. >> Get off your me soapbox. Jaws is not the most used. NVDA is taking over, >> quite fast, and lots of people have totally switched to mac or Vinux > Lots of people means an insignifiant percent of users compared with the percent of Windows users. > NVDA is mostly used as a second screen reader in case that something wrong happends with the first one. > It doesn't support a good voice synthesizer like Eloquence or IBM Via voice, but only eSpeak which sounds horrible, it doesn't have a scripting language ready to use as JAWS and Window Eyes do, it doesn't offer the possibility of reading with the mouse cursor as JAWS does with its so called JAWS cursor, it offers a poor accessibility in many applications and many other issues. > >> because of the problems with Jaws. It's most used in corporate sektors >> still maybe, but lots of end-users are migrating to Window Eyes, NVDA or >> OSX because of the fact that it is both cheaper and NVDA is open source, >> not to mention free. Just because Jaws -was- most used and -you- use it, >> doesn't mean it still remains so. > > Window Eyes always was cheaper than JAWS, however it was never the most used screen reader because it also have its problems. > I don't understand why you care so much about what will *probably* happen in the future and don't care about the present. > An indian saying says that on the long term will be everything fine (because we will be all dead:) > > But you are talking just to show how right you are. If you remember about our discussion, we were talking about how inaccessible is Tkinter, and well Tkinter has the same inaccessibility level under Window Eyes and NVDA just like under JAWS, so I don't know why is it so important to name all those screen readers if someone wants to test Tkinter. > I thought that if someone wants to test how inaccessible is Tkinter, JAWS would be enough because Tkinter is also inaccessible for the other screen readers, and I thought that it would be normally to test the accessibility using the screen reader that offer the most features. > > Octavian > > > -- Thanks, Ty From rustompmody at gmail.com Wed Jan 26 14:17:58 2011 From: rustompmody at gmail.com (rusi) Date: Wed, 26 Jan 2011 11:17:58 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <8q7sgiF5tpU1@mid.individual.net> <19891784-d6a3-41ac-a097-5902a6323bc0@o21g2000prn.googlegroups.com><0b12cdb1-45b4-41e4-9bdb-074ee669d76b@k14g2000pre.googlegroups.com> <048FB74272D440A0915ABC7D76AE262B@teddy> <5782E9AD8A8342D691EB3549E5E0ED7B@octavian> <9649b12c-46b3-475a-8c33-2790d13f5a46@j19g2000prh.googlegroups.com> Message-ID: <9c8e1ceb-df66-4ed1-9a2c-087343bf7351@j32g2000prh.googlegroups.com> On Jan 27, 12:02?am, Nicholas Devenish wrote: > > Heck, I am probably wasting my time with this post; but you come across > as genuine in your held central beliefs, and so either serious or the > most dedicated and adept troll I have ever encountered. In the case of > the former, I hold an optimistic view that most people are capable of > self-asessment. In the case of the latter, consider me successfully trolled. RR: I'd just like to add -- Do consider whom your verbal violence hurts most. You may also want to google for Erik Naggum From rantingrick at gmail.com Wed Jan 26 14:59:11 2011 From: rantingrick at gmail.com (rantingrick) Date: Wed, 26 Jan 2011 11:59:11 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <8q7sgiF5tpU1@mid.individual.net> <19891784-d6a3-41ac-a097-5902a6323bc0@o21g2000prn.googlegroups.com><0b12cdb1-45b4-41e4-9bdb-074ee669d76b@k14g2000pre.googlegroups.com> <048FB74272D440A0915ABC7D76AE262B@teddy> <5782E9AD8A8342D691EB3549E5E0ED7B@octavian> <9649b12c-46b3-475a-8c33-2790d13f5a46@j19g2000prh.googlegroups.com> Message-ID: <65232137-9ac6-485b-a663-9379a1622c8c@w29g2000vba.googlegroups.com> On Jan 26, 1:02?pm, Nicholas Devenish wrote: > I look forward to reading your PEP and initial design documents, though > I suspect you would need the latter and to get some a decent portion of > work done before it would even be considered as an inclusion into the > standard library. Yes i want to create an API similar to Tkinter but we cannot mirror exactly Tkinter because wx takes a completely different approach to GUI building. We need to steal all the good attributes of Tkinter (and there are quite a few!), learn from them, and evolve the next generation of API. Tkinter will not be a waste because we will stand on the shoulders of Tkinter and reach even higher! Some of the worthwhile "must haves" are: * Geometry managers (pack, place, grid) The geometry managers of Tkinter are just too beautiful to let die. Wx forces you to use Sizers which are a terrible obstacle to the new GUI programmer. And if you want focus traversal then you must also use Panels. This multiplicity is just too ugly for a high level API like i am suggesting. We will need some auto generation of panels and easier to use Sizers wrapped up in a nice Tkinter Geometry Manager like API. This will take some work. However it can be done. * Tagging systems for a TextCtrl and Canvas. Although i challenged Guido on his argument about tagging, i do much agree that tagging is a *very* powerful feature of the TK::Text and TK::Canvas widgets and we should no doubt incorporate this into the API. And this would be one of the easier aspects of the design. * Event binding Here is another area for improvement. While wx has been moving towards a more "Tkinter like" binding of widget events there is still much to be desired. However the binding is not all bad so we should not spend too much time here if only for very small payoffs. * Segfaults We must protect Python users from segfaults. This is really a wxPython's problem however we could insulate the programmer through many techniques on our end. Like for instance: Recreating the columns of a list control after configuration of a single style. However configuration needs a look at also! * Styles One of the things that always bothered me about Tkinter was lack of styles. I know this has been addressed however in the past one would create many widgets that should share a similar style but Tkinter forced you to feed redundant style options to all of them. We need a way to create style objects and then use them everywhere. I think wx supports this already. This is just a very meager list. Much more needs consideration. However this would be a good launch point toward some stated and attainable goals. There is already a quite mature (citaion needed) start with a project called wax. Check it out here... http://wiki.wxpython.org/Wax > Many capable developers have > their own occupations and might not have the spare time or desire to > spend on a project where all evidence suggests would be a > (non-benevolent) dictatorship where they would be endlessly browbeaten. Well i don't want to be a dictator. I believe that in any healthy community, every member should be a king, however no ONE member ever wears the crown. What i mean is, everyone has a special skill that makes them stand out from the crowd. Something that you do better than the other members. So when the needs of my skill-set are present, i will step forth and lead, and when the needs of your skill-set are present, i will sit back and listen and follow YOUR lead. This is how the strongest groups tackle the largest problems with ease. > You have continuously tried to outright present yourself as a > 'visionary' and speaker for the python community and then asked why > people don't take you seriously. People would take you a lot more > seriously if you showed that you had the vision and capability to drive > development of such a serious undertaking, and manage such a team of > developers, whom you have first managed to attract to the project. Agreed, and i hope to demonstrate these skills soon. However like i mentioned in my last statement, i am not a god, much less a dictator. No single man or woman can accomplish these huge problems alone. It takes a team of united folks all simultaneousness willing to lead AND follow when the time is right for the greater good of a common goal. > > ? - Write some design documents, or even code, laying out what you think > the interface should be. > ? - Put it out to the community, listen to advice, make changes (it will > NOT be perfect) and gather support. > I believe we are in this stage now. However much more discussion is needed. From me+list/python at ixokai.io Wed Jan 26 15:07:35 2011 From: me+list/python at ixokai.io (Stephen Hansen) Date: Wed, 26 Jan 2011 12:07:35 -0800 Subject: WxPython versus Tkinter. In-Reply-To: <43FCB75BBC57406799C87AD6FC781EFC@teddy> References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <8q7sgiF5tpU1@mid.individual.net> <19891784-d6a3-41ac-a097-5902a6323bc0@o21g2000prn.googlegroups.com><0b12cdb1-45b4-41e4-9bdb-074ee669d76b@k14g2000pre.googlegroups.com> <048FB74272D440A0915ABC7D76AE262B@teddy> <5782E9AD8A8342D691EB3549E5E0ED7B@octavian> <43FCB75BBC57406799C87AD6FC781EFC@teddy> Message-ID: <4D407F07.6020808@ixokai.io> On 1/26/11 9:19 AM, Octavian Rasnita wrote: > From: "Emile van Sebille" > ... >>> Well, I didn't know this, and it is a valid reason. >>> This means that it is true that there is no enough maintainance force to >>> keep WxPython updated. >>> Did I understand correctly? >> >> Not at all -- wxPython is an active funded ongoing project. Review the >> roadmap at http://wiki.wxpython.org/TentativeRoadmap and particularly >> the final paragraph on Python3.x support. > > But somebody said that the core Python developers, or Guido said that WxPython won't be included in the core distribution because it doesn't have a strong team of maintainers... with other words but this was the idea. That isn't, at all, what people said. What they said was that for a new library to be included in the stdlib, it must have maintainers willing to *commit* for years to *maintain* it IN the stdlib. Maintaining something in the stdlib is very different then maintaining something out of the stdlib. The stdlib has quite a few rules: and it evolves at a certain set speed. wxPython is a wrapper around a third-party library which evolves at a totally different rate: if wxPython were included in the stdlib, these two completely separate development cycles could result in significant hardship for the maintainers and more importantly, for the USERS. Does Python now hold up a release waiting for the wxWidgets team to put out a new version with great new features? Or, does Python release as normal, and just by happenstance does wxWidgets release a great new release a month later-- and now Python users can't get it for a year or two when the next feature release of Python is available? Either way, the maintainers job is more difficult, and users are harmed. There's a reason that libs that go into the stdlib tend to be very static and extremely slow paced in their evolution. Now, Robin could decide to maintain wxPython in two places: as a third-party library, and every release cycle sync in the latest to the core stdlib. That's been done: but its actually extremely problematic itself, and is asking for a lot of extra work. wxPython as a third-party library is maintained: certainly. But that doesn't mean wxPython in the stdlib would be maintained. Then again, it may be that they would be fine with moving into the stdlib-- but since its not a viable option for numerous other reasons, they never bothered to give it any real consideration. > So I still don't understand why WxPython can't be a good solution. > If WxPython is well maintained, let's pretend that the maintainers solved that bug that make the apps give a segfault, and let's pretend that it works under Python 3. > Can it be a good choice for replacing Tkinter? That's hand-waving a LOT of stuff with "let's pretend", but okay. Let's pretend that the lib is modified and fixed up so that segfaults don't happen (and, IIUC, the next version may be); and let's pretend it works under Python 3 (does that leave me in the dust, as someone who would love to get some wxPython updates but who is only using Python 2.5?). There's a bunch of hurdles that would need solving before its a candidate for inclusion: (off the top of my head) 1. Tkinter can not be removed without a 100% compatible replacement for the forseeable future. 100%. No exception on that 100%. This includes people downloading TK extensions and using them in their Python apps: because if thats not possible, real applications will fail. Please understand before you move on. This is one of the hurdles of the stdlib that make maintaining something in it harder then maintaining something out of it: there are strict compatibility requirements and rules. It might be a great thing for humanity to have Python include an accessible GUI toolkit in the standard library: but that doesn't mean the rules can be broken in doing it. Since its basically impossible to be compatible as such, what you'd have to do is add wx while leaving tk, not replacing it. So: 2. New additions must be PEP-8 compliant; wx is not. 3. New additions must include unit tests; I actually don't know if wx does. I've always found it a pain in the butt to test GUI stuff-- but TK is tested (to some degree, I'm not sure how good the coverage is: I just remember tweaking my buildslave to make it run the tests :)). 4. The documentation would have to all be totally rewritten to fit the stdlib documentation format 5. The license thing needs solving from a legal standpoint (new code is traditionally donated to the PSF under the Apache license, which then in turn re-licenses the code under the Python license). You may think its stupid to let something like that get in the way, but sorry: we live in a lawyer's world. 6. Someone would have to commit to maintaining it _in_ the stdlib. 7. Someone would have to work on integrating the wx build requirements with the stdlib's build requirements for all the platforms -- and this can be quite a bit. If this makes the release maintainers jobs a lot harder ... well, they may need some more hands on deck. ... and more. There's a lot of work there. A lot. A lot a lot. And that's just hand-waving away some really significant obstacles with Let's Pretend. Besides: did you know a not insignificant number of people would like to do away with the stdlib in its entirety? And, more then a few actually are pushing for the stdlib to be forked off of CPython, and instead end up shared by all the major Python implementations (CPython, Jython, PyPy, IronPython, what else?) as a common resource? Not saying either group would win (though the latter sounds like a very cool thing to me), but what does either say about the implication of including wxPython? > I can see that the people try to find some false arguments like the one that WxPython is bigger than Tkinter, but really, who cares today about a few aditional megabytes? I'm sorry, but you're confusing what you care about with what other people care about. You do it a lot. But you seem actually honest in your efforts, so I give you the benefit of the doubt. Size does matter to some people, and legitimately so. Still others care deeply about what is bundled with Python because they're in environments where installing third-party libraries isn't allowed: these two interests can stand in opposition to one-another, but that does not make either /false/, and it does not mean that either is /right/. There are many interests involved in a language like Python which has broad usage in extremely varied fields and endeavors: most of which never come near this list. And some people have absolutely no need-- no need at all-- for any sort of GUI programming at all. This group is actually really, really big. The argument is not false: for YOU it is not compelling, and hell, for me I don't find it compelling either. But it is a valid issue which has to be weighed and taken into consideration. Maybe after that is done, on balance, its deemed to be not that big of a deal. But maybe when added up with other concerns, it is. > What do you think it is more important, to offer accessibility for most of the users, or to create small applications? I think its important to do both. And wxPython living on in a third-party library fits that perfectly well. -- Stephen Hansen ... Also: Ixokai ... Mail: me+list/python (AT) ixokai (DOT) io ... Blog: http://meh.ixokai.io/ -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 487 bytes Desc: OpenPGP digital signature URL: From mail2bansi at gmail.com Wed Jan 26 15:24:33 2011 From: mail2bansi at gmail.com (bansi) Date: Wed, 26 Jan 2011 12:24:33 -0800 (PST) Subject: Is it possible to pass CSV Reader Object As Argument to another Python File ??? References: <2c35653e-3565-48c6-8939-b6b09b885e3f@d23g2000prj.googlegroups.com> Message-ID: <876b6c52-1a6d-4afa-83e9-fa987c9359a5@v31g2000pri.googlegroups.com> On Jan 26, 1:31?pm, Chris Rebert wrote: > On Wed, Jan 26, 2011 at 7:51 AM, bansi wrote: > > I have following two python scripts > > -namelookupWrapper.py > > -namelookup.py > > > The namelookupWrapper.py takes input of "memberId", "memberName" from > > CLI and has following code snippet > > > idf = sys.argv[1] > > namef = sys.argv[2] > > real_script = "C:\\Splunk\\etc\\apps\\search\\bin\\namelookup.py" > > r = csv.reader(sys.stdin) > > os.execv(python_executable, [ python_executable, real_script ] + > > sys.argv[1:] ) > > > Wondering how would i pass csv reader object "r" as an argument using > > os.execv() to another python script i.e. namelookup.py > > It's not possible to pass Python objects between processes in such a > manner. Given that "independent" scripts can't directly take objects > as input anyway, I doubt the two scripts are truly independent from > each other. I would therefore concur with van Sebille that you should > just rewrite them so that one script imports from the other rather > than spawning the other. It should not be too hard to port the Python > 2.6 script to Python 2.7 (or vice-versa if necessary). > > Cheers, > Chris > --http://blog.rebertia.com- Hide quoted text - > > - Show quoted text - Thanks Chris. Sorry for mis-communicating, the two python scripts are dependant in a way that namelookupWrapper.py needs to pass csv record object to another python script If thats not possible then please let me know how to do the workaround i didnt understood the import thing and not sure if it helps in my case Here are the details namelookupwrapper.py - takes input from stdin. Using csv reader object i iterate thru the input which looks like as shown below [MemberId, MemberName] [123, ] [456, ] [989, ] Now i have another script i.e. namelookup.py running under Python 2.7 using pyodbc to retrieve Member Names from database for a given Member Id in namelooupWrapper.py So please let me know how to accomplish this From ahsanbagwan at gmail.com Wed Jan 26 15:26:25 2011 From: ahsanbagwan at gmail.com (sl33k_) Date: Wed, 26 Jan 2011 12:26:25 -0800 (PST) Subject: Return Statement Message-ID: How does "return True" and "return False" affect the execution of the calling function? From rantingrick at gmail.com Wed Jan 26 15:37:24 2011 From: rantingrick at gmail.com (rantingrick) Date: Wed, 26 Jan 2011 12:37:24 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <8q7sgiF5tpU1@mid.individual.net> <19891784-d6a3-41ac-a097-5902a6323bc0@o21g2000prn.googlegroups.com><0b12cdb1-45b4-41e4-9bdb-074ee669d76b@k14g2000pre.googlegroups.com> <048FB74272D440A0915ABC7D76AE262B@teddy> <5782E9AD8A8342D691EB3549E5E0ED7B@octavian> <43FCB75BBC57406799C87AD6FC781EFC@teddy> Message-ID: <7952a09c-4e61-4661-9873-7e0bd897b1ee@y2g2000prf.googlegroups.com> On Jan 26, 2:07?pm, Stephen Hansen wrote: > And some people have absolutely no need-- no need at all-- for any sort > of GUI programming at all. This group is actually really, really big. Stephen "Strawman" Hansen: If he only had a brain! :-) That is the most obvious straw-man to date in this thread. What about the large portion of folks who don't use all the datatypes (queue, weakref, etc) or how about numeric and math modules (fractions, decimal, etc) or how about data persistence, or Cryptograhic, or curses! or, multimedia services, or, or. You see NOT everyone uses everything in the stdlib and most use much less than half. However we would be fools to claim "batteries included" and NOT support GUI! From rantingrick at gmail.com Wed Jan 26 15:40:38 2011 From: rantingrick at gmail.com (rantingrick) Date: Wed, 26 Jan 2011 12:40:38 -0800 (PST) Subject: Return Statement References: Message-ID: On Jan 26, 2:26?pm, sl33k_ wrote: > How does "return True" and "return False" affect the execution of the > calling function? >>> def f1(): pass >>> print f1() None >>> def f2(): return >>> print f2() None >>> def f3(): return True >>> print f3() True >>> def f4(): return False >>> print f4() False >>> def f5(): return 'Strawman' >>> print f5() Strawman ...any questions? From rantingrick at gmail.com Wed Jan 26 15:41:52 2011 From: rantingrick at gmail.com (rantingrick) Date: Wed, 26 Jan 2011 12:41:52 -0800 (PST) Subject: Bugs/issues in tkinter.simpledialog!! References: <412e4d83-f750-441d-bfc5-d96c0559e069@e9g2000prn.googlegroups.com> Message-ID: On Jan 26, 11:55?am, Benjamin Kaplan wrote: > The code is hosted onhttp://svn.python.org Thanks! From orasnita at gmail.com Wed Jan 26 15:46:18 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Wed, 26 Jan 2011 22:46:18 +0200 Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com><9MB%o.14110$%64.6074@unlimited.newshosting.com><4A48EDF6D7634F2E994661A457451E87@teddy><753A4C5A6658470085804B13C80340F2@octavian> Message-ID: From: "geremy condra" > At least 40% of my coworkers do not speak English as their native > language. Your problem is not the language. Your problem is your > attitude. The atitude considered nice is just duplicity for convincing others, and I don't like duplicity. I like to know exactly what the people think and I want them know what I think. I don't want to convince anyone, but I just want to inform the others and let them know if they are doing something not recommended. I agree, telling the people that they are doing something wrong, directly, without sugar, might be considered a bad atitude by those who prefer duplicity and nice words just for the sake of socializing, but is that atitude worst than of those who don't care about discriminatory practices? >> But I don't condemn you for this, because many years ago when I was in >> school I had the opinion that some foreign colleagues are a little stupid >> just because they were not able to express very well the ideas which were >> not very simple, and well, they were not stupid at all, but they didn't know >> my language well enough and they probably would think the same thing about >> me if we were speaking in Russian. > > I don't have that problem. Oh yes you do as well as many others and it is obvious because I have seen that some of you consider me to be very angry, but I am not angry nor nervous at all so there may be something else. If I say that I don't like a certain country because it attacks other countries, it doesn't mean that I am nervous or angry. I am just expressing my opinions about that country. About those who use Tkinter I can't even say that I don't like them or something like that, because it is very normal that most of Python programmers should prefer it, because it was promoted a long time by Python. What I said is that it is not OK that Python promoted and keeps promoting a GUI lib that creates discrimination, but I don't know where you have seen that anger. >> Exactly what I said. They are doing the same mistake as I did 20 years ago. >> By the way, can't you see any syntactic dissacords in my phrases? Haven't >> you think that my English might not be as fluent to be able to express >> everything I want to say very well? > > As I mentioned earlier, you'll find I don't have a lot of pity for you in this. I don't need your pitty, but I can see that you misunderstand me, thinking that I am angry, thinking that I want to force everyone to use a GUI lib, and I thought that my English may not be clear enough to make you understand what I want to say. >> But not supporting accessibility because the programmer *doesn't want this*, >> it is not a bug, but discrimination. Don't you agree with this? >> And if Python would have been able to support accessibility it would have >> mean that it promotes discrimination because it promotes the wrong tool, but >> it seems that Python 3 doesn't have an accessible GUI lib for the moment, so >> no, it is not discrimination (but Emile told us that there is no support for >> WxPython in Python 3 just today, so I didn't know this and I already >> wondered why nobody told about this real problem). > > Keep in mind, I'm not saying this. Saying what? I don't understand what you were not saying. > This is a sketch of your point of view and Tyler's point of view. What has the phrase I told above with what Tyler said? I said that if somebody can create accessible programs but doesn't *want* to do that, this generates discrimination. Don't you agree with this? >> Well, I think that everyone should understand why the programs must be >> accessible and why everybody should care about all the users of an >> application and that it is not normal to not care. > > Ah! I think I see where you're going wrong. It *is* normal not to > care- not just about this, but about any given special interest other > than your own. You have to convince people to care, or they don't- and > you're not convincing, just yelling. Where did I say that it is normal to not care about other things? I have also agreed that it is important to have support for Python 3, that it is also important the commercial point of view, it is also important to have a GUI lib without bugs that generates errors, and you are again and again misunderstanding me thinking that I am yelling, even though I am writing all these things very calm. And I am not trying to convince anyone. I mean, we are not in the previous century and I hope that I don't need to convince anyone that offering accessibility for everyone is very important. Do you think that on this list there still are members that need to be convinced about this things? Do you really think that there are members that can't understand the importance of accessibility and they need to be convinced, persuaded, motivated with nice words? Do you have such a bad idea about them? I am sure that they all know very well why the accessibility is important and I was just trying to tell them that Tkinter doesn't create accessible apps. >> You are also very unkind and rude when you say that the disabled that need >> to use a screen reader should be a kind of second hand people that need to >> beg for a little accessibility. > > I don't say this. Don't try to stuff me into a strawman argument. Then why do you ask nice words from me and an atitude which should be nice for the others? We are not negociating here and I am not trying to convince anyone. I am just giving them the information that Tkinter creates inaccessible apps, and this creates discrimination, which is very true. It is not nice to talk about these things, , but first it is not nice for those discriminated, not for the others. >> When you create a program, why do you create a visual interface for it? Why >> don't you create just an audio interface? > > I don't create a visual interface. I have never found it necessary for > my line of work, and have little stake in this discussion besides that > of advocating civility on this list. You are confusing civility with dupplicity. I was very civilized here. I didn't called names, I didn't used bad words but I am just trying to show why what the majority does is bad. Well, from its point of view this may mean that it is not civilized because it doesn't like it. >> You do this because otherwise you would not please those who can see. Why >> shouldn't be something normal, and that *should be not be discussable at >> all* to offer the same accessibility to everyone? > > You can discuss it. You just have to convince others that you're > right, and you're not doing that well. I offered you some advice on > how to go about doing it better. Well, I see that you really think than now in 2011 the people need to be convinced that the accessibility is important. >> And you didn't say what was rude from what I said. You said just that it was >> rude. > > I can provide quotes, if you like. Yes please do it. >> Oh yes I know that it is unkind because most of the people don't even like >> to talk personally with disabled people, but this doesn't mean that the >> disabled people are something not normal, but those who have those biases >> towards those who are very different. > > I don't have this problem. Oh yes you do have it, because otherwise you wouldn't consider my messages as angry and not civilized just because they are not nice and candy and they don't try to convince the others that they should do something, because they are different from what you expect. > I think it would be better for the Python community if you were more > civil and for the disabled community if you were more successful. The > two go hand in hand. I see that you see me as a paid advocate that should succeed convincing a certain group to do a certain thing, but I already told that I am not trying to convince anyone. I just said that now in our era all the people should be very well convinced about the importance of accessibility, and there are very many resources on the net that talk about accessibility if there is somebody that doesn't know what we are talking about, so I don't need to convince anyone. But I think that this is a false argument, because I doubt that there are list members that don't know the importance of accessibility. > More people have the power to accomplish what fewer cannot. You want > big changes, you will need big support, and people won't just move to > your side because you're angry. You have to convince them. I am not angry, but I am not trying to convince anyone about the importance of accessibility because its importance is very well known. The problems are those who are aware about the accessibility but that still don't care. They are the people that should be taken with nice words? Doesn't that mean begging for a little accessibility as I said above? >> If the majority doesn't care about the minorities which are minorities >> without willing to be so, then it means that it is wrong. > > I don't know that's the case, and I suspect there are shades of grey > you are not acknowledging here. If you are acknowledging, then please give some examples of shades of gray. Octavian From rantingrick at gmail.com Wed Jan 26 15:47:04 2011 From: rantingrick at gmail.com (rantingrick) Date: Wed, 26 Jan 2011 12:47:04 -0800 (PST) Subject: Bugs/issues in tkinter.simpledialog!! References: <412e4d83-f750-441d-bfc5-d96c0559e069@e9g2000prn.googlegroups.com> Message-ID: <3ae4f147-646d-4b81-84ec-dc95c3c89021@h17g2000pre.googlegroups.com> On Jan 26, 11:55?am, Benjamin Kaplan wrote: [...snip...] Well i should have looked before i leaped :) This looks like an old 2.x version. I am looking for the newest version with is renamed to "simpledialog" and contains a new class called "SimpleDialog". Do you know were i can view this module? Thanks again. From bryan.oakley at gmail.com Wed Jan 26 16:05:07 2011 From: bryan.oakley at gmail.com (Bryan) Date: Wed, 26 Jan 2011 13:05:07 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <8q7sgiF5tpU1@mid.individual.net> <19891784-d6a3-41ac-a097-5902a6323bc0@o21g2000prn.googlegroups.com><0b12cdb1-45b4-41e4-9bdb-074ee669d76b@k14g2000pre.googlegroups.com> <048FB74272D440A0915ABC7D76AE262B@teddy> <5782E9AD8A8342D691EB3549E5E0ED7B@octavian> <43FCB75BBC57406799C87AD6FC781EFC@teddy> <7952a09c-4e61-4661-9873-7e0bd897b1ee@y2g2000prf.googlegroups.com> Message-ID: On Jan 26, 2:37?pm, rantingrick wrote: > On Jan 26, 2:07?pm, Stephen Hansen wrote: > > > And some people have absolutely no need-- no need at all-- for any sort > > of GUI programming at all. This group is actually really, really big. > > Stephen "Strawman" Hansen: If he only had a brain! :-) > > That is the most obvious straw-man to date in this thread. What about > the large portion of folks who don't use all the datatypes (queue, > weakref, etc) or how about numeric and math modules (fractions, > decimal, etc) or how about data persistence, or Cryptograhic, or > curses! or, multimedia services, or, or. > > You see NOT everyone uses everything in the stdlib and most use much > less than half. However we would be fools to claim "batteries > included" and NOT support GUI! You show a remarkable, awe-inspiring ability to completely miss every salient point of a well articulated argument. From rantingrick at gmail.com Wed Jan 26 16:08:39 2011 From: rantingrick at gmail.com (rantingrick) Date: Wed, 26 Jan 2011 13:08:39 -0800 (PST) Subject: Need GUI pop-up to edit a (unicode ?) string References: <3tqr08-bj2.ln1@murmur.very.softly> <7691fe98-37af-4ddf-a8a8-eadeef0d4a6e@y2g2000prf.googlegroups.com> <541c02df-b1fc-4376-bf17-e0531fe5c4bf@r29g2000yqj.googlegroups.com> <3f724ff2-d571-4f50-92e1-45eaf9ab163d@r16g2000prh.googlegroups.com> Message-ID: On Jan 26, 2:11?am, Terry Reedy wrote: > In 3.x, the module is now tk.simpledialog -- all lower case. The purpose > of all lowercase module names is to avoid confusion with upper case > class names. Yes Terry, i found the new module and documented the bugs in a new thread. I am not sure if the bugs are still present in the current RC (Note: i have 3.1.1 installed) however i would bet they are. As soon as i can find the current source in svn i'll update the "bug thread". However i cannot find it. If you can give a link that would be great! From emile at fenx.com Wed Jan 26 16:11:41 2011 From: emile at fenx.com (Emile van Sebille) Date: Wed, 26 Jan 2011 13:11:41 -0800 Subject: how to read the last line of a huge file??? In-Reply-To: References: Message-ID: On 1/26/2011 2:59 AM Xavier Heruacles said... > I have do some log processing which is usually huge. The length of each line > is variable. How can I get the last line?? Don't tell me to use readlines or > something like linecache... > > seek -rw-rw---- 1 autofax mail 1061716366 Jan 26 12:45 autofax [root at wsgfw3 root]# python2 Python 2.3.5 (#1, Aug 3 2005, 08:40:39) [GCC 3.2.3 20030502 (Red Hat Linux 3.2.3-52)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> f = open('/var/spool/mail/autofax') >>> f.seek(1061710000) >>> lines = f.read() >>> len(lines) 6366 >>> flavor to taste. Emile From python at mrabarnett.plus.com Wed Jan 26 16:22:44 2011 From: python at mrabarnett.plus.com (MRAB) Date: Wed, 26 Jan 2011 21:22:44 +0000 Subject: how to read the last line of a huge file??? In-Reply-To: References: Message-ID: <4D4090A4.3030403@mrabarnett.plus.com> On 26/01/2011 10:59, Xavier Heruacles wrote: > I have do some log processing which is usually huge. The length of each > line is variable. How can I get the last line?? Don't tell me to use > readlines or something like linecache... > Seek to somewhere near the end and then read use readlines(). If you get fewer than 2 lines then you can't be sure that you have the entire last line, so seek a little farther from the end and try again. From williem75 at gmail.com Wed Jan 26 16:25:04 2011 From: williem75 at gmail.com (williem75 at gmail.com) Date: Wed, 26 Jan 2011 15:25:04 -0600 Subject: Python-list Digest, Vol 88, Issue 69 Message-ID: Sent from my LG phone python-list-request at python.org wrote: >Send Python-list mailing list submissions to > python-list at python.org > >To subscribe or unsubscribe via the World Wide Web, visit > http://mail.python.org/mailman/listinfo/python-list >or, via email, send a message with subject or body 'help' to > python-list-request at python.org > >You can reach the person managing the list at > python-list-owner at python.org > >When replying, please edit your Subject line so it is more specific >than "Re: Contents of Python-list digest..." > >Today's Topics: > > 1. Re: Python use growing fast (Alice Bevan?McGregor) > 2. Re: order of importing modules (Chris Rebert) > 3. Re: How to Buffer Serialized Objects to Disk (MRAB) > 4. Re: How to Buffer Serialized Objects to Disk (Chris Rebert) > 5. Re: How to Buffer Serialized Objects to Disk (Peter Otten) > 6. Re: Best way to automatically copy out attachments from an > email (Chris Rebert) > 7. Re: Parsing string for " " (Aahz) > 8. Re: Nested structures question (Tim Harig) > 9. Re: How to Buffer Serialized Objects to Disk (Scott McCarty) > >On 2011-01-10 19:49:47 -0800, Roy Smith said: > >> One of the surprising (to me, anyway) uses of JavaScript is as the >> scripting language for MongoDB (http://www.mongodb.org/). > >I just wish they'd drop spidermonkey and go with V8 or another, faster >and more modern engine. :( > > - Alice. > > > > >> Dan Stromberg wrote: >>> On Tue, Jan 11, 2011 at 4:30 PM, Catherine Moroney >>> wrote: >>>> >>>> In what order does python import modules on a Linux system? ?I have a >>>> package that is both installed in /usr/lib64/python2.5/site-packages, >>>> and a newer version of the same module in a working directory. >>>> >>>> I want to import the version from the working directory, but when I >>>> print module.__file__ in the interpreter after importing the module, >>>> I get the version that's in site-packages. >>>> >>>> I've played with the PYTHONPATH environmental variable by setting it >>>> to just the path of the working directory, but when I import the module >>>> I still pick up the version in site-packages. >>>> >>>> /usr/lib64 is in my PATH variable, but doesn't appear anywhere else. ?I >>>> don't want to remove /usr/lib64 from my PATH because that will break >>>> a lot of stuff. >>>> >>>> Can I force python to import from my PYTHONPATH first, before looking >>>> in the system directory? >>>> >>> Please import sys and inspect sys.path; this defines the search path >>> for imports. >>> >>> By looking at sys.path, you can see where in the search order your >>> $PYTHONPATH is going. >>> >On Wed, Jan 12, 2011 at 11:07 AM, Catherine Moroney > wrote: >> I've looked at my sys.path variable and I see that it has >> a whole bunch of site-package directories, followed by the >> contents of my $PYTHONPATH variable, followed by a list of >> misc site-package variables (see below). > >> But, I'm curious as to where the first bunch of 'site-package' >> entries come from. ?The >> /usr/lib64/python2.5/site-packages/pyhdfeos-1.0_r57_58-py2.5-linux-x86_64.egg >> is not present in any of my environmental variables yet it shows up >> as one of the first entries in sys.path. > >You probably have a .pth file somewhere that adds it (since it's an >egg, probably site-packages/easy-install.pth). >See http://docs.python.org/install/index.html#modifying-python-s-search-path > >Cheers, >Chris >-- >http://blog.rebertia.com > > >On 12/01/2011 21:05, Scott McCarty wrote: >> Sorry to ask this question. I have search the list archives and googled, >> but I don't even know what words to find what I am looking for, I am >> just looking for a little kick in the right direction. >> >> I have a Python based log analysis program called petit >> (http://crunchtools.com/petit). I am trying to modify it to manage the >> main object types to and from disk. >> >> Essentially, I have one object which is a list of a bunch of "Entry" >> objects. The Entry objects have date, time, date, etc fields which I use >> for analysis techniques. At the very beginning I build up the list of >> objects then would like to start pickling it while building to save >> memory. I want to be able to process more entries than I have memory. >> With a strait list it looks like I could build from xreadlines(), but >> once you turn it into a more complex object, I don't quick know where to go. >> >> I understand how to pickle the entire data structure, but I need >> something that will manage the memory/disk allocation? Any thoughts? >> >To me it sounds like you need to use a database. > > >On Wed, Jan 12, 2011 at 1:05 PM, Scott McCarty wrote: >> Sorry to ask this question. I have search the list archives and googled, but >> I don't even know what words to find what I am looking for, I am just >> looking for a little kick in the right direction. >> I have a Python based log analysis program called petit >> (http://crunchtools.com/petit). I am trying to modify it to manage the main >> object types to and from disk. >> Essentially, I have one object which is a list of a bunch of "Entry" >> objects. The Entry objects have date, time, date, etc fields which I use for >> analysis techniques. At the very beginning I build up the list of objects >> then would like to start pickling it while building to save memory. I want >> to be able to process more entries than I have memory. With a strait list it >> looks like I could build from xreadlines(), but once you turn it into a more >> complex object, I don't quick know where to go. >> I understand how to pickle the entire data structure, but I need something >> that will manage the memory/disk allocation? ?Any thoughts? > >You could subclass `list` and use sys.getsizeof() >[http://docs.python.org/library/sys.html#sys.getsizeof ] to keep track >of the size of the elements, and then start pickling them to disk once >the total size reaches some preset limit. >But like MRAB said, using a proper database, e.g. SQLite >(http://docs.python.org/library/sqlite3.html ), wouldn't be a bad idea >either. > >Cheers, >Chris >-- >http://blog.rebertia.com > > >Scott McCarty wrote: > >> Sorry to ask this question. I have search the list archives and googled, >> but I don't even know what words to find what I am looking for, I am just >> looking for a little kick in the right direction. >> >> I have a Python based log analysis program called petit ( >> http://crunchtools.com/petit). I am trying to modify it to manage the main >> object types to and from disk. >> >> Essentially, I have one object which is a list of a bunch of "Entry" >> objects. The Entry objects have date, time, date, etc fields which I use >> for analysis techniques. At the very beginning I build up the list of >> objects then would like to start pickling it while building to save >> memory. I want to be able to process more entries than I have memory. With >> a strait list it looks like I could build from xreadlines(), but once you >> turn it into a more complex object, I don't quick know where to go. >> >> I understand how to pickle the entire data structure, but I need something >> that will manage the memory/disk allocation? Any thoughts? > >You can write multiple pickled objects into a single file: > >import cPickle as pickle > >def dump(filename, items): > with open(filename, "wb") as out: > dump = pickle.Pickler(out).dump > for item in items: > dump(item) > >def load(filename): > with open(filename, "rb") as instream: > load = pickle.Unpickler(instream).load > while True: > try: > item = load() > except EOFError: > break > yield item > >if __name__ == "__main__": > filename = "tmp.pickle" > from collections import namedtuple > T = namedtuple("T", "alpha beta") > dump(filename, (T(a, b) for a, b in zip("abc", [1,2,3]))) > for item in load(filename): > print item > >To get random access you'd have to maintain a list containing the offsets of >the entries in the file. >However, a simple database like SQLite is probably sufficient for the kind >of entries you have in mind, and it allows operations like aggregation, >sorting and grouping out of the box. > >Peter > > > >On Wed, Jan 12, 2011 at 10:59 AM, Matty Sarro wrote: >> As of now here is my situation: >> I am working on a system to aggregate IT data and logs. A number of >> important data are gathered by a third party system. The only >> immediate way I have to access the data is to have their system >> automatically email me updates in CSV format every hour. If I set up a >> mail client on the server, this shouldn't be a huge issue. >> >> However, is there a way to automatically open the emails, and copy the >> attachments to a directory based on the filename? Kind of a weird >> project, I know. Just looking for some ideas hence posting this on two >> lists. > >Parsing out email attachments: >http://docs.python.org/library/email.parser.html >http://docs.python.org/library/email.message.html#module-email.message > >Parsing the extension from a filename: >http://docs.python.org/library/os.path.html#os.path.splitext > >Retrieving email from a mail server: >http://docs.python.org/library/poplib.html >http://docs.python.org/library/imaplib.html > >You could poll for new messages via a cron job or the `sched` module >(http://docs.python.org/library/sched.html ). Or if the messages are >being delivered locally, you could use inotify bindings or similar to >watch the appropriate directory for incoming mail. Integration with a >mail server itself is also a possibility, but I don't know much about >that. > >Cheers, >Chris >-- >http://blog.rebertia.com > > >In article <0d7143ca-45cf-44c3-9e8d-acb867c52037 at f30g2000yqa.googlegroups.com>, >Daniel da Silva wrote: >> >>I have come across a task where I would like to scan a short 20-80 >>character line of text for instances of " ". Ideally >> could be of any tense. > >In Soviet Russia, you! >-- >Aahz (aahz at pythoncraft.com) <*> http://www.pythoncraft.com/ > >"Think of it as evolution in action." --Tony Rand > > >In case you still need help: > >- # Set the initial values >- the_number= random.randrange(100) + 1 >- tries = 0 >- guess = None >- >- # Guessing loop >- while guess != the_number and tries < 7: >- guess = int(raw_input("Take a guess: ")) >- if guess > the_number: >- print "Lower..." >- elif guess < the_number: >- print "Higher..." >- tries += 1 >- >- # did the user guess correctly to make too many guesses? >- if guess == the_number: >- print "You guessed it! The number was", the_number >- print "And it only took you", tries, "tries!\n" >- else: >- print "Wow you suck! It should only take at most 7 tries!" >- >- raw_input("Press Enter to exit the program.") > > >Been digging ever since I posted this. I suspected that the response might >be use a database. I am worried I am trying to reinvent the wheel. The >problem is I don't want any dependencies and I also don't need persistence >program runs. I kind of wanted to keep the use of petit very similar to cat, >head, awk, etc. But, that said, I have realized that if I provide the >analysis features as an API, you very well, might want persistence between >runs. > >What about using an array inside a shelve? > >Just got done messing with this in python shell: > >import shelve > >d = shelve.open(filename="/root/test.shelf", protocol=-1) > >d["log"] = () >d["log"].append("test1") >d["log"].append("test2") >d["log"].append("test3") > >Then, always interacting with d["log"], for example: > >for i in d["log"]: > print i > >Thoughts? > > >I know this won't manage memory, but it will keep the footprint down right? >On Wed, Jan 12, 2011 at 5:04 PM, Peter Otten <__peter__ at web.de> wrote: > >> Scott McCarty wrote: >> >> > Sorry to ask this question. I have search the list archives and googled, >> > but I don't even know what words to find what I am looking for, I am just >> > looking for a little kick in the right direction. >> > >> > I have a Python based log analysis program called petit ( >> > http://crunchtools.com/petit). I am trying to modify it to manage the >> main >> > object types to and from disk. >> > >> > Essentially, I have one object which is a list of a bunch of "Entry" >> > objects. The Entry objects have date, time, date, etc fields which I use >> > for analysis techniques. At the very beginning I build up the list of >> > objects then would like to start pickling it while building to save >> > memory. I want to be able to process more entries than I have memory. >> With >> > a strait list it looks like I could build from xreadlines(), but once you >> > turn it into a more complex object, I don't quick know where to go. >> > >> > I understand how to pickle the entire data structure, but I need >> something >> > that will manage the memory/disk allocation? Any thoughts? >> >> You can write multiple pickled objects into a single file: >> >> import cPickle as pickle >> >> def dump(filename, items): >> with open(filename, "wb") as out: >> dump = pickle.Pickler(out).dump >> for item in items: >> dump(item) >> >> def load(filename): >> with open(filename, "rb") as instream: >> load = pickle.Unpickler(instream).load >> while True: >> try: >> item = load() >> except EOFError: >> break >> yield item >> >> if __name__ == "__main__": >> filename = "tmp.pickle" >> from collections import namedtuple >> T = namedtuple("T", "alpha beta") >> dump(filename, (T(a, b) for a, b in zip("abc", [1,2,3]))) >> for item in load(filename): >> print item >> >> To get random access you'd have to maintain a list containing the offsets >> of >> the entries in the file. >> However, a simple database like SQLite is probably sufficient for the kind >> of entries you have in mind, and it allows operations like aggregation, >> sorting and grouping out of the box. >> >> Peter >> >> -- >> http://mail.python.org/mailman/listinfo/python-list >> > >-- >http://mail.python.org/mailman/listinfo/python-list From williem75 at gmail.com Wed Jan 26 16:25:26 2011 From: williem75 at gmail.com (williem75 at gmail.com) Date: Wed, 26 Jan 2011 15:25:26 -0600 Subject: Python-list Digest, Vol 88, Issue 69 Message-ID: Sent from my LG phone python-list-request at python.org wrote: >Send Python-list mailing list submissions to > python-list at python.org > >To subscribe or unsubscribe via the World Wide Web, visit > http://mail.python.org/mailman/listinfo/python-list >or, via email, send a message with subject or body 'help' to > python-list-request at python.org > >You can reach the person managing the list at > python-list-owner at python.org > >When replying, please edit your Subject line so it is more specific >than "Re: Contents of Python-list digest..." > >Today's Topics: > > 1. Re: Python use growing fast (Alice Bevan?McGregor) > 2. Re: order of importing modules (Chris Rebert) > 3. Re: How to Buffer Serialized Objects to Disk (MRAB) > 4. Re: How to Buffer Serialized Objects to Disk (Chris Rebert) > 5. Re: How to Buffer Serialized Objects to Disk (Peter Otten) > 6. Re: Best way to automatically copy out attachments from an > email (Chris Rebert) > 7. Re: Parsing string for " " (Aahz) > 8. Re: Nested structures question (Tim Harig) > 9. Re: How to Buffer Serialized Objects to Disk (Scott McCarty) > >On 2011-01-10 19:49:47 -0800, Roy Smith said: > >> One of the surprising (to me, anyway) uses of JavaScript is as the >> scripting language for MongoDB (http://www.mongodb.org/). > >I just wish they'd drop spidermonkey and go with V8 or another, faster >and more modern engine. :( > > - Alice. > > > > >> Dan Stromberg wrote: >>> On Tue, Jan 11, 2011 at 4:30 PM, Catherine Moroney >>> wrote: >>>> >>>> In what order does python import modules on a Linux system? ?I have a >>>> package that is both installed in /usr/lib64/python2.5/site-packages, >>>> and a newer version of the same module in a working directory. >>>> >>>> I want to import the version from the working directory, but when I >>>> print module.__file__ in the interpreter after importing the module, >>>> I get the version that's in site-packages. >>>> >>>> I've played with the PYTHONPATH environmental variable by setting it >>>> to just the path of the working directory, but when I import the module >>>> I still pick up the version in site-packages. >>>> >>>> /usr/lib64 is in my PATH variable, but doesn't appear anywhere else. ?I >>>> don't want to remove /usr/lib64 from my PATH because that will break >>>> a lot of stuff. >>>> >>>> Can I force python to import from my PYTHONPATH first, before looking >>>> in the system directory? >>>> >>> Please import sys and inspect sys.path; this defines the search path >>> for imports. >>> >>> By looking at sys.path, you can see where in the search order your >>> $PYTHONPATH is going. >>> >On Wed, Jan 12, 2011 at 11:07 AM, Catherine Moroney > wrote: >> I've looked at my sys.path variable and I see that it has >> a whole bunch of site-package directories, followed by the >> contents of my $PYTHONPATH variable, followed by a list of >> misc site-package variables (see below). > >> But, I'm curious as to where the first bunch of 'site-package' >> entries come from. ?The >> /usr/lib64/python2.5/site-packages/pyhdfeos-1.0_r57_58-py2.5-linux-x86_64.egg >> is not present in any of my environmental variables yet it shows up >> as one of the first entries in sys.path. > >You probably have a .pth file somewhere that adds it (since it's an >egg, probably site-packages/easy-install.pth). >See http://docs.python.org/install/index.html#modifying-python-s-search-path > >Cheers, >Chris >-- >http://blog.rebertia.com > > >On 12/01/2011 21:05, Scott McCarty wrote: >> Sorry to ask this question. I have search the list archives and googled, >> but I don't even know what words to find what I am looking for, I am >> just looking for a little kick in the right direction. >> >> I have a Python based log analysis program called petit >> (http://crunchtools.com/petit). I am trying to modify it to manage the >> main object types to and from disk. >> >> Essentially, I have one object which is a list of a bunch of "Entry" >> objects. The Entry objects have date, time, date, etc fields which I use >> for analysis techniques. At the very beginning I build up the list of >> objects then would like to start pickling it while building to save >> memory. I want to be able to process more entries than I have memory. >> With a strait list it looks like I could build from xreadlines(), but >> once you turn it into a more complex object, I don't quick know where to go. >> >> I understand how to pickle the entire data structure, but I need >> something that will manage the memory/disk allocation? Any thoughts? >> >To me it sounds like you need to use a database. > > >On Wed, Jan 12, 2011 at 1:05 PM, Scott McCarty wrote: >> Sorry to ask this question. I have search the list archives and googled, but >> I don't even know what words to find what I am looking for, I am just >> looking for a little kick in the right direction. >> I have a Python based log analysis program called petit >> (http://crunchtools.com/petit). I am trying to modify it to manage the main >> object types to and from disk. >> Essentially, I have one object which is a list of a bunch of "Entry" >> objects. The Entry objects have date, time, date, etc fields which I use for >> analysis techniques. At the very beginning I build up the list of objects >> then would like to start pickling it while building to save memory. I want >> to be able to process more entries than I have memory. With a strait list it >> looks like I could build from xreadlines(), but once you turn it into a more >> complex object, I don't quick know where to go. >> I understand how to pickle the entire data structure, but I need something >> that will manage the memory/disk allocation? ?Any thoughts? > >You could subclass `list` and use sys.getsizeof() >[http://docs.python.org/library/sys.html#sys.getsizeof ] to keep track >of the size of the elements, and then start pickling them to disk once >the total size reaches some preset limit. >But like MRAB said, using a proper database, e.g. SQLite >(http://docs.python.org/library/sqlite3.html ), wouldn't be a bad idea >either. > >Cheers, >Chris >-- >http://blog.rebertia.com > > >Scott McCarty wrote: > >> Sorry to ask this question. I have search the list archives and googled, >> but I don't even know what words to find what I am looking for, I am just >> looking for a little kick in the right direction. >> >> I have a Python based log analysis program called petit ( >> http://crunchtools.com/petit). I am trying to modify it to manage the main >> object types to and from disk. >> >> Essentially, I have one object which is a list of a bunch of "Entry" >> objects. The Entry objects have date, time, date, etc fields which I use >> for analysis techniques. At the very beginning I build up the list of >> objects then would like to start pickling it while building to save >> memory. I want to be able to process more entries than I have memory. With >> a strait list it looks like I could build from xreadlines(), but once you >> turn it into a more complex object, I don't quick know where to go. >> >> I understand how to pickle the entire data structure, but I need something >> that will manage the memory/disk allocation? Any thoughts? > >You can write multiple pickled objects into a single file: > >import cPickle as pickle > >def dump(filename, items): > with open(filename, "wb") as out: > dump = pickle.Pickler(out).dump > for item in items: > dump(item) > >def load(filename): > with open(filename, "rb") as instream: > load = pickle.Unpickler(instream).load > while True: > try: > item = load() > except EOFError: > break > yield item > >if __name__ == "__main__": > filename = "tmp.pickle" > from collections import namedtuple > T = namedtuple("T", "alpha beta") > dump(filename, (T(a, b) for a, b in zip("abc", [1,2,3]))) > for item in load(filename): > print item > >To get random access you'd have to maintain a list containing the offsets of >the entries in the file. >However, a simple database like SQLite is probably sufficient for the kind >of entries you have in mind, and it allows operations like aggregation, >sorting and grouping out of the box. > >Peter > > > >On Wed, Jan 12, 2011 at 10:59 AM, Matty Sarro wrote: >> As of now here is my situation: >> I am working on a system to aggregate IT data and logs. A number of >> important data are gathered by a third party system. The only >> immediate way I have to access the data is to have their system >> automatically email me updates in CSV format every hour. If I set up a >> mail client on the server, this shouldn't be a huge issue. >> >> However, is there a way to automatically open the emails, and copy the >> attachments to a directory based on the filename? Kind of a weird >> project, I know. Just looking for some ideas hence posting this on two >> lists. > >Parsing out email attachments: >http://docs.python.org/library/email.parser.html >http://docs.python.org/library/email.message.html#module-email.message > >Parsing the extension from a filename: >http://docs.python.org/library/os.path.html#os.path.splitext > >Retrieving email from a mail server: >http://docs.python.org/library/poplib.html >http://docs.python.org/library/imaplib.html > >You could poll for new messages via a cron job or the `sched` module >(http://docs.python.org/library/sched.html ). Or if the messages are >being delivered locally, you could use inotify bindings or similar to >watch the appropriate directory for incoming mail. Integration with a >mail server itself is also a possibility, but I don't know much about >that. > >Cheers, >Chris >-- >http://blog.rebertia.com > > >In article <0d7143ca-45cf-44c3-9e8d-acb867c52037 at f30g2000yqa.googlegroups.com>, >Daniel da Silva wrote: >> >>I have come across a task where I would like to scan a short 20-80 >>character line of text for instances of " ". Ideally >> could be of any tense. > >In Soviet Russia, you! >-- >Aahz (aahz at pythoncraft.com) <*> http://www.pythoncraft.com/ > >"Think of it as evolution in action." --Tony Rand > > >In case you still need help: > >- # Set the initial values >- the_number= random.randrange(100) + 1 >- tries = 0 >- guess = None >- >- # Guessing loop >- while guess != the_number and tries < 7: >- guess = int(raw_input("Take a guess: ")) >- if guess > the_number: >- print "Lower..." >- elif guess < the_number: >- print "Higher..." >- tries += 1 >- >- # did the user guess correctly to make too many guesses? >- if guess == the_number: >- print "You guessed it! The number was", the_number >- print "And it only took you", tries, "tries!\n" >- else: >- print "Wow you suck! It should only take at most 7 tries!" >- >- raw_input("Press Enter to exit the program.") > > >Been digging ever since I posted this. I suspected that the response might >be use a database. I am worried I am trying to reinvent the wheel. The >problem is I don't want any dependencies and I also don't need persistence >program runs. I kind of wanted to keep the use of petit very similar to cat, >head, awk, etc. But, that said, I have realized that if I provide the >analysis features as an API, you very well, might want persistence between >runs. > >What about using an array inside a shelve? > >Just got done messing with this in python shell: > >import shelve > >d = shelve.open(filename="/root/test.shelf", protocol=-1) > >d["log"] = () >d["log"].append("test1") >d["log"].append("test2") >d["log"].append("test3") > >Then, always interacting with d["log"], for example: > >for i in d["log"]: > print i > >Thoughts? > > >I know this won't manage memory, but it will keep the footprint down right? >On Wed, Jan 12, 2011 at 5:04 PM, Peter Otten <__peter__ at web.de> wrote: > >> Scott McCarty wrote: >> >> > Sorry to ask this question. I have search the list archives and googled, >> > but I don't even know what words to find what I am looking for, I am just >> > looking for a little kick in the right direction. >> > >> > I have a Python based log analysis program called petit ( >> > http://crunchtools.com/petit). I am trying to modify it to manage the >> main >> > object types to and from disk. >> > >> > Essentially, I have one object which is a list of a bunch of "Entry" >> > objects. The Entry objects have date, time, date, etc fields which I use >> > for analysis techniques. At the very beginning I build up the list of >> > objects then would like to start pickling it while building to save >> > memory. I want to be able to process more entries than I have memory. >> With >> > a strait list it looks like I could build from xreadlines(), but once you >> > turn it into a more complex object, I don't quick know where to go. >> > >> > I understand how to pickle the entire data structure, but I need >> something >> > that will manage the memory/disk allocation? Any thoughts? >> >> You can write multiple pickled objects into a single file: >> >> import cPickle as pickle >> >> def dump(filename, items): >> with open(filename, "wb") as out: >> dump = pickle.Pickler(out).dump >> for item in items: >> dump(item) >> >> def load(filename): >> with open(filename, "rb") as instream: >> load = pickle.Unpickler(instream).load >> while True: >> try: >> item = load() >> except EOFError: >> break >> yield item >> >> if __name__ == "__main__": >> filename = "tmp.pickle" >> from collections import namedtuple >> T = namedtuple("T", "alpha beta") >> dump(filename, (T(a, b) for a, b in zip("abc", [1,2,3]))) >> for item in load(filename): >> print item >> >> To get random access you'd have to maintain a list containing the offsets >> of >> the entries in the file. >> However, a simple database like SQLite is probably sufficient for the kind >> of entries you have in mind, and it allows operations like aggregation, >> sorting and grouping out of the box. >> >> Peter >> >> -- >> http://mail.python.org/mailman/listinfo/python-list >> > >-- >http://mail.python.org/mailman/listinfo/python-list From williem75 at gmail.com Wed Jan 26 16:25:54 2011 From: williem75 at gmail.com (williem75 at gmail.com) Date: Wed, 26 Jan 2011 15:25:54 -0600 Subject: Python-list Digest, Vol 88, Issue 67 Message-ID: Sent from my LG phone python-list-request at python.org wrote: >Send Python-list mailing list submissions to > python-list at python.org > >To subscribe or unsubscribe via the World Wide Web, visit > http://mail.python.org/mailman/listinfo/python-list >or, via email, send a message with subject or body 'help' to > python-list-request at python.org > >You can reach the person managing the list at > python-list-owner at python.org > >When replying, please edit your Subject line so it is more specific >than "Re: Contents of Python-list digest..." > >Today's Topics: > > 1. Re: Python use growing fast (Colin J. Williams) > 2. Career path - where next? (Alan Harris-Reid) > 3. Re: Career path - where next? (Terry Reedy) > 4. Re: Python use growing fast (Terry Reedy) > 5. Re: Ideas for a module to process command line arguments > (Alice Bevan?McGregor) > 6. Re: Python use growing fast (Krzysztof Bieniasz) > 7. Re: Career path - where next? (Jon Clements) > 8. Re: Career path - where next? (Philip Semanchuk) > 9. Best way to automatically copy out attachments from an email > (Matty Sarro) > 10. How to populate all possible hierarchical clusterings from a > set of elements? (justin) > >On 10-Jan-11 16:02 PM, MRAB wrote: >> On 10/01/2011 20:29, Dan Stromberg wrote: >>> I invite folks to check out Tiobe's Language Popularity Rankings: >>> >>> http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html >>> >>> The gist is: Python grew faster than any other programming language >>> over the last year, according to this (slightly arbitrary, but better >>> than no indicator) ranking. >>> >>> ...despite our wikipedia page whose first paragraph almost seems like >>> it was written with the intention of scaring off new converts, with >>> its "unusual" comment: >>> >>> http://en.wikipedia.org/wiki/Python_%28programming_language%29 >>> >>> (Like it or not, people do frequently confuse the descriptive for the >>> normative) >> >> It shows an example of Python code, which happens to have 2 syntax >> errors! > >Why not correct the Wikipedia entry? > >Colin W. > > > >Hi there, I wonder if any Python folk out there can help me. > >For many years I was a contractor developing desktop and web >applications using Visual Foxpro as my main language, with Foxpro, >SQL-server and Oracle as back-end databases. Unfortunately Foxpro was >killed-off by Microsoft, hence my work dried-up and my last 'big' >contract ended about a year ago. Since then I have taken time off >programming doing house-renovation, and in the last 6 months I have been >updating my programming skills by learning Python (3) with SQLite, >JavaScript, HTML and CSS to a level where I can create and deploy >data-based web-sites. > >My situation now is that I am reasonably comfortable with the above >languages and am now in a position where I wish to return to employment >using my new and/or existing skills (contract/permanent, full/part-time >or teleworking). However, I have yet to find any UK vacancy which will >accept a relative 'beginner' - they all require at least 2-3 years >Python in a commercial environment. It's a catch-22 situation - it's >hard to get a job without experience, but you need a job to get >experience in the 1st place! > >I would even consider doing small projects for nothing so that I can >'get my foot in the door' (although I hope to be wise-enough to know >when I am being taken advantage of!). I am also mailing CVs to agencies >I think may be interested. > >If anyone out has ideas as to how to proceed towards achieving my goal, >I would be grateful for any advice. > >Regards, >Alan Harris-Reid > > > >On 1/12/2011 11:37 AM, Alan Harris-Reid wrote: > >... >> updating my programming skills by learning Python (3) with SQLite, >> JavaScript, HTML and CSS to a level where I can create and deploy >> data-based web-sites. >... >> I would even consider doing small projects for nothing so that I can >> 'get my foot in the door' (although I hope to be wise-enough to know > >I believe both Roundup/Python tracker and PyPI (Python package index) >are based on sqlite and have small projects available/needed. I cannot >help you otherwise. Good luck. > >-- >Terry Jan Reedy > > > >On 1/12/2011 9:51 AM, Colin J. Williams wrote: > >>> It shows an example of Python code, which happens to have 2 syntax >>> errors! >> >> Why not correct the Wikipedia entry? > >As I reported early, the errors, if any, are in .png and .svg images of >text, which would have to be replaced, not corrected. Would be good >since the imaged snippet is a haphazard except from a much larger file >and inane out of context. > >-- >Terry Jan Reedy > > > >On 2011-01-11 21:41:24 -0800, Michele Simionato said: > >> Originally plac too was able to recognize flags automatically by >> looking at the default value (if the default value is a boolean then >> the option is a flag); however I removed that functionality because I >> wanted to be able to differentiate between flag and (smart) options >> (see >> http://micheles.googlecode.com/hg/plac/doc/plac.html#scripts-with-options-and-smart-options). > >Not >> >entirely sure what you mean by 'smart' options. If your'e referring to >using a single hyphen and a list of characters to represent a long >option (which, to the rest of the world, use two leading hyphens) then >that's pretty weird. ;) > >Consider most of the GNU tools: > > ls -lvh > tar -xzvf file.tgz (goes so far as to make the leading hyphen optional!) > less -ceF logfile > bc -qw > ps -aux (same as tar) > >And even third-party tools: > > mysql -fH > pg_dump -abO ... > >One major system in the world that doesn't really differentiate between >long and short options is... DOS, and by extension, Windows. But they >also use / as a switch character. > >Anyway; I'm happy with what I have wrought (and am continuing to update >with support for class-based sub-command dispatch) and will be >utilizing it for all scripts in the Marrow suite. To each their own, >but reinvention itself can be for motivations other than NIH. I wanted >something pure-Python, portable across the 3k barrier without code >modification (no 2to3), that didn't use optparse, getopt, or argparse >and basically be a translation layer. It can be simpler than that, as >marrow.script demonstrates. > > - Alice. > > > > >> As I reported early, the errors, if any, are in .png and .svg images of >> text, which would have to be replaced, not corrected. Would be good >> since the imaged snippet is a haphazard except from a much larger file >> and inane out of context. > >I don't think it really is a big deal. I mean, this is merely an >illustration for the syntax-highlighted python code. So the message >isn't: "Go ahead and try it with your Python". It's rather "Look, you can >have colorful highlighting of python code, isn't that cool?!" It actually >presents the specific indentation of Python code and therefore it is >mostly useful to someone who never used Python. And actually I wouldn't >expect any Python programmer to look for feedback on Wikipedia. It's not >that I have anything against Wikipedia -- on the contrary, I use it all >the time. But remember that it's an encyclopedia not a Python manual. > > >On Jan 12, 4:37?pm, Alan Harris-Reid >wrote: >> Hi there, I wonder if any Python folk out there can help me. >> >> For many years I was a contractor developing desktop and web >> applications using Visual Foxpro as my main language, with Foxpro, >> SQL-server and Oracle as back-end databases. ?Unfortunately Foxpro was >> killed-off by Microsoft, hence my work dried-up and my last 'big' >> contract ended about a year ago. ?Since then I have taken time off >> programming doing house-renovation, and in the last 6 months I have been >> updating my programming skills by learning Python (3) with SQLite, >> JavaScript, HTML and CSS to a level where I can create and deploy >> data-based web-sites. >> >> My situation now is that I am reasonably comfortable with the above >> languages and am now in a position where I wish to return to employment >> using my new and/or existing skills (contract/permanent, full/part-time >> or teleworking). ? However, I have yet to find any UK vacancy which will >> accept a relative 'beginner' - they all require at least 2-3 years >> Python in a commercial environment. ?It's a catch-22 situation - it's >> hard to get a job without experience, but you need a job to get >> experience in the 1st place! >> >> I would even consider doing small projects for nothing so that I can >> 'get my foot in the door' (although I hope to be wise-enough to know >> when I am being taken advantage of!). ?I am also mailing CVs to agencies >> I think may be interested. >> >> If anyone out has ideas as to how to proceed towards achieving my goal, >> I would be grateful for any advice. >> >> Regards, >> Alan Harris-Reid > >Hi Alan, > >Just some ideas (not in any order, just as they're thought of):- > >- Emphasise your experience with Oracle & SQL Server, and use Python >as a "I also have". It may be someone will accept that as viable >(saves them a DBA or something), and maybe you'll get into an >experienced group and get on the job training. (I assume you have good >SQL skills). > >- Look at cwjobs.co.uk / monster / etc..., and search for Python. Get >a list of agencies there. Phone them *first*, explain what is it >you've done, and what you can do. If the person seems to know what >they're talking about send your CV - but chase often. > >- Look at web-frameworks. Django seems to be the most listed for >"required"/"nice to have". Also check out javascript-frameworks - >jquery & extjs are the biggest 2, so at least you can say you've had >some experience. > >- Perhaps phone your local job centre, and ask for a contact for their >local volunteer centre. They might have something like work for a >small charity that just needs a couple of pages done. The idea being: >1) If it's a cause you believe in, it makes up for not getting paid; >2) You can use it as an example and reference; 3) You might be able to >use it as networking - might get a free lunch from an event and meet >someone with money, that's impressed with your good will and work, and >just happens to have a job going spare... > >- Build a copy of your CV designed for the web. Make sure it looks >good, is HTML/CSS compliant, and even add some nice interactive stuff >to it, and include it as a link in your CV. [The other thing you can >do, is only display the CV on entry of a short PIN (different for each >one you send - '2431' or something'), then you can log who's bothered >looking at it, and when, enabling timing of a follow-up better)]. > >- Look in local papers for local companies that offer not necessarily >web design, but possibly just print design. See if you can't have a >chat with them and get some work your way. Other options might be new- >starts up, non-chain pubs, community/sports clubs, a local church for >fund-raising, your local chinese/indian takeaway - wouldn't hurt to >put their menu online with an online order form would it!? [What you >might find about this, is that as they're not likely to be technical, >you can take your own time, charge a reasonable amount, experiment a >little and learn, and not have too tight deadlines or someone looking >over your shoulder]. > >Brain (or somewhere else) dump finished. > >hth > >Jon. > > > > >On Jan 12, 2011, at 11:37 AM, Alan Harris-Reid wrote: > >> >> Hi there, I wonder if any Python folk out there can help me. >> >> For many years I was a contractor developing desktop and web applications using Visual Foxpro as my main language, with Foxpro, SQL-server and Oracle as back-end databases. Unfortunately Foxpro was killed-off by Microsoft, hence my work dried-up and my last 'big' contract ended about a year ago. Since then I have taken time off programming doing house-renovation, and in the last 6 months I have been updating my programming skills by learning Python (3) with SQLite, JavaScript, HTML and CSS to a level where I can create and deploy data-based web-sites. >> >> My situation now is that I am reasonably comfortable with the above languages and am now in a position where I wish to return to employment using my new and/or existing skills (contract/permanent, full/part-time or teleworking). However, I have yet to find any UK vacancy which will accept a relative 'beginner' - they all require at least 2-3 years Python in a commercial environment. It's a catch-22 situation - it's hard to get a job without experience, but you need a job to get experience in the 1st place! >> >> I would even consider doing small projects for nothing so that I can 'get my foot in the door' (although I hope to be wise-enough to know when I am being taken advantage of!). I am also mailing CVs to agencies I think may be interested. >> >> If anyone out has ideas as to how to proceed towards achieving my goal, I would be grateful for any advice. > >Contributing to open source projects (your own or someone else's) will help to convince some employers that you're worth taking a look at. If nothing else it gives you a public example of the work that you can point them to. > >Good luck >Philip > >As of now here is my situation: >I am working on a system to aggregate IT data and logs. A number of >important data are gathered by a third party system. The only >immediate way I have to access the data is to have their system >automatically email me updates in CSV format every hour. If I set up a >mail client on the server, this shouldn't be a huge issue. > >However, is there a way to automatically open the emails, and copy the >attachments to a directory based on the filename? Kind of a weird >project, I know. Just looking for some ideas hence posting this on two >lists. > >Thanks all, and happy hump day! >-Matty > > >The title sounds too complex, but my question is actually simple. > >Suppose I have [1,2,3,4,5], then there are many ways of making >clustering. >Among them, I want to pair up terminals until there is only one left >at the end. >For example, ((((1,2),3),4),5), (1,(2,(3,(4,5)))), or (((1,2),(3,4)), >5) would be legitimate ones. > >How do you think can I, using the modules of Python such as itertools >as much as possible, make all possible such clusterings? > >Thanks in advance, >Justin. > > >-- >http://mail.python.org/mailman/listinfo/python-list From me+list/python at ixokai.io Wed Jan 26 16:33:15 2011 From: me+list/python at ixokai.io (Stephen Hansen) Date: Wed, 26 Jan 2011 13:33:15 -0800 Subject: Return Statement In-Reply-To: References: Message-ID: <4D40931B.5030003@ixokai.io> On 1/26/11 12:26 PM, sl33k_ wrote: > How does "return True" and "return False" affect the execution of the > calling function? It doesn't -- the value 'True' or 'False' is simply returned, and assigned to a name if the calling function does so explicitly. But there's no built in affects. If you want it to alter the execution, you have to do so yourself, i.e.: def myfun(): return True def myfun2(): return False if myfun(): print "Something is true!" myfun2() print "I'm called. Cuz, the return value of myfun2 was simply discarded." -- Stephen Hansen ... Also: Ixokai ... Mail: me+list/python (AT) ixokai (DOT) io ... Blog: http://meh.ixokai.io/ -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 487 bytes Desc: OpenPGP digital signature URL: From kb1pkl at aim.com Wed Jan 26 16:34:43 2011 From: kb1pkl at aim.com (Corey Richardson) Date: Wed, 26 Jan 2011 16:34:43 -0500 Subject: WxPython versus Tkinter. In-Reply-To: <7F4FDC467BCF47D4A069B29246FBDB17@octavian> References: <4D3E4377.3060807@tysdomain.com><9MB%o.14110$%64.6074@unlimited.newshosting.com><59F6E65E3D9A46AD8D7A3863F3C1DC84@teddy> <27f53f8c-7862-4366-9352-82ae9a2f3970@k3g2000yqc.googlegroups.com> <7F4FDC467BCF47D4A069B29246FBDB17@octavian> Message-ID: <4D409373.80908@aim.com> On 01/26/2011 01:18 AM, Octavian Rasnita wrote: > From: "rantingrick" > On Jan 25, 3:41 pm, Corey Richardson wrote: > >> Do you honestly think he was talking about the accessibility problem? >> IMO that should move to another thread, because this one is simply >> about, as the subject suggests, "WxPython versus Tkinter". > > Corey again (like many) you lack a global perspective. Anybody who has > read along with his thread knows we are covering some pretty big > issues here. WxPython is just the vehicle. The big picture is simply: > Tkinter is old and in many ways insufficient for 21st century GUIs. We > need to decide what should come next. I believe wxPython is our best > hope. Wx may not be the best it can be, but it is the best we have at > this time. There is more than "meets the eye" Corey! I think he was referring to the large amount of trolling and immature behaviour displayed. It would be a horrible thing to think that accessibility is _bad_, unless of course it takes away from usability to sighted users or is tons harder to implement (the technical reasons you mentioned earlier). I understand that this thread is about the deficiencies of Tkinter (and many other GUI toolkits) and that Wx is far better than lots of what we have (but still has its issues). I personally despise writing GUI's, but I do it when I have to. I'm a fan of tkinter and wx because they are (in my very little experience) very easy to use. The issue I was raising with your post was really context. He wasn't bashing specifically on accessibility or a toolkit, but more of the attitudes and overall tone of some of the posts. Hope that cleared it up for you. (This would be a good time for python-gui to be opened up IMO, since it appears lots of discussion is being generated) ~Corey From brendan.simon at etrix.com.au Wed Jan 26 16:35:43 2011 From: brendan.simon at etrix.com.au (Brendan Simon (eTRIX)) Date: Thu, 27 Jan 2011 08:35:43 +1100 Subject: WxPython versus Tkinter. In-Reply-To: References: Message-ID: <4D4093AF.80806@etrix.com.au> Since it seems the python motto is "Batteries included", then it would seem to me that wxPython is the natural fit as it also has "Batteries included" (e.g. accessibility, native look-n-feel, mature and evolving, can produce simple or complex gui programs, etc, etc). -- Brendan Simon www.etrix.com.au From ben+python at benfinney.id.au Wed Jan 26 16:36:51 2011 From: ben+python at benfinney.id.au (Ben Finney) Date: Thu, 27 Jan 2011 08:36:51 +1100 Subject: Is it possible to pass CSV Reader Object As Argument to another Python File ??? References: <2c35653e-3565-48c6-8939-b6b09b885e3f@d23g2000prj.googlegroups.com> <876b6c52-1a6d-4afa-83e9-fa987c9359a5@v31g2000pri.googlegroups.com> Message-ID: <87lj272vpo.fsf@benfinney.id.au> bansi writes: > Thanks Chris. Sorry for mis-communicating, the two python scripts are > dependant in a way that namelookupWrapper.py needs to pass csv record > object to another python script Why have you structured them that way, though? What constraint is keeping you from doing the work in a single process, where the CSV reader object can be shared? > If thats not possible then please let me know how to do the workaround > i didnt understood the import thing and not sure if it helps in my > case The problem as you've described it so far is best solved by having a single process accessing the CSV reader object in memory. If that doesn't suit your use case, you'll need to explain why not. -- \ ?To have the choice between proprietary software packages, is | `\ being able to choose your master. Freedom means not having a | _o__) master.? ?Richard M. Stallman, 2007-05-16 | Ben Finney From alan.isaac at gmail.com Wed Jan 26 16:37:20 2011 From: alan.isaac at gmail.com (Alan) Date: Wed, 26 Jan 2011 13:37:20 -0800 (PST) Subject: use class factory to set required class variables? Message-ID: I have a class ``A`` that is intentionally incomplete: it has methods that refer to class variables that do not exist. The class ``A`` has several complicated methods, a number of which reference the "missing" class variables. Obviously, I do not directly use ``A``. I have a class factory ``f``` that subclasses ``A`` *only* in order to define the class variables. The motivation/problem: I did this because I need many versions of class ``A``, which differ only in the class variables, which are not known until run time. Q: On the face of it, did I pick a reasonable solution to my problem? If so is this a standard pattern? If not, can you mention a better approach? My solution is working for me, but the class ``A`` is bugging me, because of the odd (to me) way in which it is incomplete. Obviously, I'm not a computer science type ... Thanks, Alan Isaac From k.bx at ya.ru Wed Jan 26 16:40:01 2011 From: k.bx at ya.ru (kost BebiX) Date: Wed, 26 Jan 2011 23:40:01 +0200 Subject: how to read the last line of a huge file??? In-Reply-To: References: Message-ID: <132701296078004@web19.yandex.ru> 26.01.2011, 12:59, "Xavier Heruacles" : > I have do some log processing which is usually huge. The length of each line is variable. How can I get the last line?? Don't tell me to use readlines or something like linecache... -- > http://mail.python.org/mailman/listinfo/python-list Well, it's very simple. Don't store the whole log in one file. Create new one and archive the old one every night. You will also get a lot of free space this way. Or store it in some MongoDB's capped collection. It's fast and queryable (if you need). Good luck! -- jabber: k.bx at ya.ru From emile at fenx.com Wed Jan 26 16:41:47 2011 From: emile at fenx.com (Emile van Sebille) Date: Wed, 26 Jan 2011 13:41:47 -0800 Subject: Return Statement In-Reply-To: References: Message-ID: On 1/26/2011 12:26 PM sl33k_ said... > How does "return True" and "return False" affect the execution of the > calling function? That depends on the calling function. It will control what it does next generally based on the returned value, but it could also simply store the result. def isACustomer(custID): 1 return custID in currentCustList def isActive(custId): 2 return custID in openInvoicesByCustID for custID in custList: 3 if isACustomer(custID): 4 activeFlag = isActive(custID) Here, 1 and 2 return True or False depending on the inclusion test. 3 causes the subsequent code block to be executed when True is returned 4 stores True of False in activeFlag for subsequent use. Emile From alan.isaac at gmail.com Wed Jan 26 16:45:54 2011 From: alan.isaac at gmail.com (Alan) Date: Wed, 26 Jan 2011 13:45:54 -0800 (PST) Subject: use class factory to set required class variables? References: Message-ID: <6a08e86a-b400-4d11-b440-f7888f99b8c3@f21g2000prn.googlegroups.com> On Jan 26, 4:37?pm, Alan wrote: > I have a class factory ``f``` that subclasses ``A`` *only* in > order to define the class variables. I suppose it would be clearer to say that `f` *returns* subclasses of `A`. Hopefully that was clear ... Alan Isaac From alex.kapps at web.de Wed Jan 26 16:46:02 2011 From: alex.kapps at web.de (Alexander Kapps) Date: Wed, 26 Jan 2011 22:46:02 +0100 Subject: Return Statement In-Reply-To: References: Message-ID: <4D40961A.1050206@web.de> On 26.01.2011 21:26, sl33k_ wrote: > How does "return True" and "return False" affect the execution of the > calling function? If only affects the calling function if you use the return value: def foo(): return True def bar1(): foo() # nothing difference, whether foo() returns True or False def bar2() if foo(): print "foo returned True or any other non-false value" else: print "foo returned False or any other non-True value" From invalid at invalid.invalid Wed Jan 26 16:48:02 2011 From: invalid at invalid.invalid (Grant Edwards) Date: Wed, 26 Jan 2011 21:48:02 +0000 (UTC) Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com> <9MB%o.14110$%64.6074@unlimited.newshosting.com> <4A48EDF6D7634F2E994661A457451E87@teddy> <753A4C5A6658470085804B13C80340F2@octavian> Message-ID: On 2011-01-26, Octavian Rasnita wrote: > From: "geremy condra" >> At least 40% of my coworkers do not speak English as their native >> language. Your problem is not the language. Your problem is your >> attitude. > > The atitude considered nice is just duplicity for convincing others, > and I don't like duplicity. And, based on your behavior, you apparently don't like convincing others or advancing the cause of accessibility. It seems you prefer to annoy and alienate others. > I like to know exactly what the people think and I want them know > what I think. That can be accomplished in a polite and respectful manner. You claim to be advocating for , and trying to accomplish , yet your actions indicate the opposite by their counter-productive nature. > I don't want to convince anyone, but I just want to inform the others > and let them know if they are doing something not recommended. IOW, you don't really care about increasing accessibility, you just want to hear the sound of your own voice as you shout into the wind. If you actually cared about accessibility for the handicapped, you would care about convincing others to care also -- because that's the only way the situation can be improved. > I agree, telling the people that they are doing something wrong, > directly, without sugar, might be considered a bad atitude by those > who prefer duplicity and nice words just for the sake of socializing, > but is that atitude worst than of those who don't care about > discriminatory practices? Yes, it is worse. People who don't care are neither helping nor hurting your cause. However, you're actively hurting it. People will not separate your personality from the cause you espouse. You may not like it, but that's a fact. If you are in favor of XYZ, and act rude and insulting while espousing XYZ, people will react against not only you but _also_ XYZ. You can claim that's neither "right" nor "fair" nor "good" nor whatever. But it's a fact -- just like gravity. You may not like it or find it convenient. But if you insist on ignoring it you're just going to crash into the ground over and over and over again. -- Grant Edwards grant.b.edwards Yow! I smell a RANCID at CORN DOG! gmail.com From mpnordland at gmail.com Wed Jan 26 16:50:01 2011 From: mpnordland at gmail.com (mpnordland) Date: Wed, 26 Jan 2011 16:50:01 -0500 Subject: replacing lines in a file Message-ID: Attached are a config file parser that i'm working on, and a example config file. Basically, what my problem is is in write_config, it should search through the file, and replace the lines with whatever the modified version is, it is also designed to ignore comments. To see my problem (which is hard to describe) please first look at the config file, and then run config-parse.py then look at the config file again. One of two things should happen: nothing, or something weird should happen on the last line. -------------- next part -------------- A non-text attachment was scrubbed... Name: config-parse.py Type: text/x-python Size: 1382 bytes Desc: not available URL: -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: net-responsibility.conf2 URL: From ben+python at benfinney.id.au Wed Jan 26 16:51:55 2011 From: ben+python at benfinney.id.au (Ben Finney) Date: Thu, 27 Jan 2011 08:51:55 +1100 Subject: Return Statement References: Message-ID: <87hbcv2v0k.fsf@benfinney.id.au> sl33k_ writes: > How does "return True" and "return False" affect the execution of the > calling function? The object ?True?, or the object ?False?, is returned to the calling statement, and the function call evaluates to that return value. That may sound facetious, but it's as specific as I can be without knowing what aspect of the return semantics are confusing you. You will probably find great benefit in working through the entire Python tutorial . Not just read, but *do*: perform each example, experiment with each section until you understand it, and only then go on. -- \ ?Ladies, leave your clothes here and spend the afternoon having | `\ a good time.? ?laundry, Rome | _o__) | Ben Finney From mpnordland at gmail.com Wed Jan 26 16:56:05 2011 From: mpnordland at gmail.com (mpnordland) Date: Wed, 26 Jan 2011 16:56:05 -0500 Subject: Return Statement In-Reply-To: References: Message-ID: On 01/26/2011 03:26 PM, sl33k_ wrote: > How does "return True" and "return False" affect the execution of the > calling function? Basically it will affect it in whatever way you design it to for example: def lie_test(statement): if statement is True: return False else: return False Now, this is psuedo code somewhat. "if statement is True:" would always equate to "True" unless statement was an empty string, None, or 0. As to return False if statement equals true, look at the function name. It is testing to see if it is a lie, and if it is true, then it's not a lie. From tjreedy at udel.edu Wed Jan 26 16:57:20 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Wed, 26 Jan 2011 16:57:20 -0500 Subject: Bugs/issues in tkinter.simpledialog!! In-Reply-To: <412e4d83-f750-441d-bfc5-d96c0559e069@e9g2000prn.googlegroups.com> References: <412e4d83-f750-441d-bfc5-d96c0559e069@e9g2000prn.googlegroups.com> Message-ID: On 1/26/2011 11:53 AM, rantingrick wrote: To answer your other post, one of the main people to touch tkinter in the last 3 years was Guilherme Polo, who worked on it during and after a Google Summer of Code project. He does not seen to be active currently. There are currently 63 open issues on the tracker listing tkinter as a component. There are probably a few that could be closed. When I have learned more, I should be able to review any patched sitting around. > On Jan 26, 10:43 am, Emile van Sebille wrote: >> On 1/26/2011 8:00 AM rantingrick said... >>> I just installed Python 3,0 on my machine. >> >> Try it again on the current release candidate --http://www.python.org/download/releases/3.2/-- testing old first >> >> Seehttp://docs.python.org/bugs.htmlhttp://www.python.org/dev/peps/pep-0003/ > > Why would i want to waste bandwidth downloading an RC? Can i not just > browse the source online? I only need to check one module. Where is > the source available for viewing "simpledialog" online? > > Thanks > > PS: The version i have now is 3.1.1 (but i would like to see the > newest version available, just not download it!) I was hoping you meant 3.1.something, not 3.0. Latest is 3.1.3. 3.2c2 will be out very soon, and 3.2 2 weeks after if no problems arise. As far as the doc and stdlib go, 3.2 is probably one of the most improved releases ever, as they got almost all the attention with no syntax changes allowed. When it is out, I will strongly recommend upgrading, absent a really good reason not to. >(but i would like to see the > newest version available, just not download it!) http://svn.python.org/view/python/branches/py3k/Lib/tkinter/simpledialog.py?revision=81010&view=markup go back up a step and you can look at the log of changes. For current python 3 in general: http://svn.python.org/view/python/branches/py3k/ If you install TortoiseSVN, it is trivial to download the whole source tree. I believe you could also just download a subtree, like the tkinter and/or idlelib subtrees. Sometime after 3.2 is out, we will move from svn to hg and above will change. -- Terry Jan Reedy From mpnordland at gmail.com Wed Jan 26 17:00:35 2011 From: mpnordland at gmail.com (mpnordland) Date: Wed, 26 Jan 2011 17:00:35 -0500 Subject: WxPython versus Tkinter. In-Reply-To: References: <4D402E58.9090001@tysdomain.com> Message-ID: Segfaults in wxPython are caused by the debug assertions not being turned on. see Robin Dunn's (the creator of wxPython) response From tjreedy at udel.edu Wed Jan 26 17:08:14 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Wed, 26 Jan 2011 17:08:14 -0500 Subject: Slice lists and extended slicing In-Reply-To: References: Message-ID: On 1/26/2011 12:52 PM, Benjamin Kaplan wrote: > If you're trying to learn a language, I would suggest reading > tutorials, not the grammar. I second that. > As you can see from the error thrown, the > operation is syntactically valid (you don't get a syntax error). It's > just that lists don't accept them. I don't know of any built-in data > type that takes slice lists but numpy matrices will. > >>>> a = numpy.matrix([[1,2,3],[4,5,6],[7,8,9]]) > matrix([[1, 2, 3], > [4, 5, 6], > [7, 8, 9]]) > >>>> a[0:2,1:3] > matrix([[2, 3], > [5, 6]]) Which is to say, slice lists are a specialized feature added specifically for numerical python, now numpy. Ignore then unless and until you happen to install and use numpy, or something similar that also uses them. -- Terry Jan Reedy From rantingrick at gmail.com Wed Jan 26 17:35:36 2011 From: rantingrick at gmail.com (rantingrick) Date: Wed, 26 Jan 2011 14:35:36 -0800 (PST) Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com> <9MB%o.14110$%64.6074@unlimited.newshosting.com> <4A48EDF6D7634F2E994661A457451E87@teddy> <753A4C5A6658470085804B13C80340F2@octavian> Message-ID: On Jan 26, 3:48?pm, Grant Edwards wrote: > People will not separate your personality from the cause you espouse. > You may not like it, but that's a fact. ?If you are in favor of XYZ, > and act rude and insulting while espousing XYZ, people will react > against not only you but _also_ XYZ. A certain small subset of any group will always be emotionally driven. However we should not concern ourselves with this sort of non- objectivity. Some people make rash decisions not based in reality. What we *should* concern ourselves with is fostering pure objectivity. Because objectivity is the virtue of intelligent beings. Objectivity fosters creativity of which progress is the direct progeny. From debatem1 at gmail.com Wed Jan 26 17:38:28 2011 From: debatem1 at gmail.com (geremy condra) Date: Wed, 26 Jan 2011 14:38:28 -0800 Subject: WxPython versus Tkinter. In-Reply-To: References: <4D3E4377.3060807@tysdomain.com> <9MB%o.14110$%64.6074@unlimited.newshosting.com> <4A48EDF6D7634F2E994661A457451E87@teddy> <753A4C5A6658470085804B13C80340F2@octavian> Message-ID: On Wed, Jan 26, 2011 at 12:46 PM, Octavian Rasnita wrote: > I am not trying to convince anyone. I mean, we are not in the previous century and I hope that I don't need to convince anyone that offering accessibility for everyone is very important. Do you think that on this list there still are members that need to be convinced about this things? Do you really think that there are members that can't understand the importance of accessibility and they need to be convinced, persuaded, motivated with nice words? Do you have such a bad idea about them? > I am sure that they all know very well why the accessibility is important and I was just trying to tell them that Tkinter doesn't create accessible apps. The rest of your email seems to hinge on this point, so I'm just going to address it here and if you feel like I left something out, let me know. The bottom line is that, yes, you do still have to convince people that accessibility is important if you want them to do anything about it. I have to do almost exactly the same thing in my field- everybody knows that security is important, but every time I go to disclose a vulnerability I have to be very careful if I want to convince the vendor to fix the problem. During those discussions, an ounce of civility is worth more than ten tons of righteousness, not only because it helps convince people to do what you want but because they frequently walk away from it feeling good about the experience and eager to not make the same mistake again. Geremy Condra From tjreedy at udel.edu Wed Jan 26 17:57:22 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Wed, 26 Jan 2011 17:57:22 -0500 Subject: WxPython versus Tkinter. In-Reply-To: References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <8q7sgiF5tpU1@mid.individual.net> <19891784-d6a3-41ac-a097-5902a6323bc0@o21g2000prn.googlegroups.com><0b12cdb1-45b4-41e4-9bdb-074ee669d76b@k14g2000pre.googlegroups.com> <048FB74272D440A0915ABC7D76AE262B@teddy> <5782E9AD8A8342D691EB3549E5E0ED7B@octavian> Message-ID: On 1/26/2011 11:35 AM, Robert Kern wrote: > On 1/26/11 10:00 AM, Emile van Sebille wrote: >> On 1/25/2011 10:08 PM Octavian Rasnita said... >>> From: "Emile van Sebille" >>>>> Why is WxPython ineligible? >>>> >>>> I think Terry's point was compatibility with python3 -- which wx >>>> apparently isn't yet. >>>> >>>> Emile >>> >>> >>> Well, I didn't know this, and it is a valid reason. >>> This means that it is true that there is no enough maintainance force to >>> keep WxPython updated. >>> Did I understand correctly? >> >> Not at all -- wxPython is an active funded ongoing project. Review the >> roadmap >> at http://wiki.wxpython.org/TentativeRoadmap and particularly the final >> paragraph on Python3.x support. > > That's not Terry's point. The reasons he's referring to (and stated > previously) are as follows: > > 1. The license of wxWidgets and wxPython is not as permissive as > Python's. The Python developers, as a matter of policy, do not want to > include code into the standard library that is less permissive than the > current license. > > 2. The Python developers require someone to commit to maintaining > contributed code for a number of years. No one has done so. See reason #3. > > 3. The wxPython developers do not want wxPython in the standard library, > not least because they want to develop and release wxPython at a > different pace and release cycle than the standard library. > > 4. The Python developers have committed to maintaining backwards > compatibility in the standard library for a very long time. Even if they > included wxPython into the standard library, they would have to provide > a Tkinter module that works like the current one. I do not believe it is > feasible to write a Tkinter workalike that uses wxPython, so we would > still be relying on Tcl/Tk. Yes, very well put. Another point is non-gui baggage. In my opinion, and I suspect others, this should be minimal to absent. Tk itself is purely a gui package -- abstract widgits, geometry placers to make them visible, and an event system to make them active. But it does have the baggage of needing tcl included. About a decade ago, some people had the idea of removing the tcl dependency, but nothing seems to have come of that. For some people, the tcl baggage is reason enough to be rid of tk. Qt, in contrast to tk, is not a gui package, but an application framework and library that includes QtGui as one of about 10 modules. There is also, for instance QtSockets and QtScript (now included in QtCore). Qt as a whole could not go into the stdlib. From what I remember when I looked at the WxWidgets feature list some years ago, WxWidgets does not come with a scripting language, but also has more that strictly gui stuff. So I think it would also need to be subsetted. PyGui seems to be purely a gui package, but it appear to be aimed only at 2.x with no interest in 3.x. > There is certainly enough maintenance force to keep wxPython updated and > ported to Python 3, but only *outside* of the standard library. I got the opposite impression from the link above. As of last May, 3.x support is deferred until a new C++ code generator is written, and that is deferred until new features are added and released. So it seems the project needs another person to either code the new code generator or learn how to port Capi code (or both). Since there is no 2to3 for Capi (as opposed to Python code), I do not even know is a single code base is possible. I am sure that whoever works on a wxPython port could learn from whoever did the numpy port. -- Terry Jan Reedy From tyler at tysdomain.com Wed Jan 26 18:06:18 2011 From: tyler at tysdomain.com (Littlefield, Tyler) Date: Wed, 26 Jan 2011 16:06:18 -0700 Subject: WxPython versus Tkinter. In-Reply-To: <7952a09c-4e61-4661-9873-7e0bd897b1ee@y2g2000prf.googlegroups.com> References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <8q7sgiF5tpU1@mid.individual.net> <19891784-d6a3-41ac-a097-5902a6323bc0@o21g2000prn.googlegroups.com><0b12cdb1-45b4-41e4-9bdb-074ee669d76b@k14g2000pre.googlegroups.com> <048FB74272D440A0915ABC7D76AE262B@teddy> <5782E9AD8A8342D691EB3549E5E0ED7B@octavian> <43FCB75BBC57406799C87AD6FC781EFC@teddy> <7952a09c-4e61-4661-9873-7e0bd897b1ee@y2g2000prf.googlegroups.com> Message-ID: <4D40A8EA.5020008@tysdomain.com> >Stephen "Strawman" Hansen: If he only had a brain! And you want -us- to take -you- seriously? Tell me, what did you accomplish with that insult? Beyond elevating your own ego and trolling some more, anyway. On 1/26/2011 1:37 PM, rantingrick wrote: > On Jan 26, 2:07 pm, Stephen Hansen wrote: > >> And some people have absolutely no need-- no need at all-- for any sort >> of GUI programming at all. This group is actually really, really big. > Stephen "Strawman" Hansen: If he only had a brain! :-) > > That is the most obvious straw-man to date in this thread. What about > the large portion of folks who don't use all the datatypes (queue, > weakref, etc) or how about numeric and math modules (fractions, > decimal, etc) or how about data persistence, or Cryptograhic, or > curses! or, multimedia services, or, or. > > You see NOT everyone uses everything in the stdlib and most use much > less than half. However we would be fools to claim "batteries > included" and NOT support GUI! -- Thanks, Ty From tyler at tysdomain.com Wed Jan 26 18:08:47 2011 From: tyler at tysdomain.com (Littlefield, Tyler) Date: Wed, 26 Jan 2011 16:08:47 -0700 Subject: WxPython versus Tkinter. In-Reply-To: References: <4D3E4377.3060807@tysdomain.com><9MB%o.14110$%64.6074@unlimited.newshosting.com><4A48EDF6D7634F2E994661A457451E87@teddy><753A4C5A6658470085804B13C80340F2@octavian> Message-ID: <4D40A97F.8090209@tysdomain.com> >I don't want to convince anyone, but I just want to inform the others and let >them know if they are doing something not recommended. not recommended by -you-, which is different than by a community or the subset of people you are attempting to represent. furthermore, your attidude is that of "comply to my definition of what is needed, or you are selfish, rude, mean, cruel, etc." Then when that fails, you try cramming words in people's mouth to make them feel like they kick puppies, and to bring everyone else to this same conclusion. On 1/26/2011 1:46 PM, Octavian Rasnita wrote: > From: "geremy condra" >> At least 40% of my coworkers do not speak English as their native >> language. Your problem is not the language. Your problem is your >> attitude. > The atitude considered nice is just duplicity for convincing others, and I don't like duplicity. I like to know exactly what the people think and I want them know what I think. > I don't want to convince anyone, but I just want to inform the others and let them know if they are doing something not recommended. > > I agree, telling the people that they are doing something wrong, directly, without sugar, might be considered a bad atitude by those who prefer duplicity and nice words just for the sake of socializing, but is that atitude worst than of those who don't care about discriminatory practices? > > >>> But I don't condemn you for this, because many years ago when I was in >>> school I had the opinion that some foreign colleagues are a little stupid >>> just because they were not able to express very well the ideas which were >>> not very simple, and well, they were not stupid at all, but they didn't know >>> my language well enough and they probably would think the same thing about >>> me if we were speaking in Russian. >> I don't have that problem. > Oh yes you do as well as many others and it is obvious because I have seen that some of you consider me to be very angry, but I am not angry nor nervous at all so there may be something else. > If I say that I don't like a certain country because it attacks other countries, it doesn't mean that I am nervous or angry. I am just expressing my opinions about that country. > About those who use Tkinter I can't even say that I don't like them or something like that, because it is very normal that most of Python programmers should prefer it, because it was promoted a long time by Python. What I said is that it is not OK that Python promoted and keeps promoting a GUI lib that creates discrimination, but I don't know where you have seen that anger. > >>> Exactly what I said. They are doing the same mistake as I did 20 years ago. >>> By the way, can't you see any syntactic dissacords in my phrases? Haven't >>> you think that my English might not be as fluent to be able to express >>> everything I want to say very well? >> As I mentioned earlier, you'll find I don't have a lot of pity for you in this. > I don't need your pitty, but I can see that you misunderstand me, thinking that I am angry, thinking that I want to force everyone to use a GUI lib, and I thought that my English may not be clear enough to make you understand what I want to say. > >>> But not supporting accessibility because the programmer *doesn't want this*, >>> it is not a bug, but discrimination. Don't you agree with this? >>> And if Python would have been able to support accessibility it would have >>> mean that it promotes discrimination because it promotes the wrong tool, but >>> it seems that Python 3 doesn't have an accessible GUI lib for the moment, so >>> no, it is not discrimination (but Emile told us that there is no support for >>> WxPython in Python 3 just today, so I didn't know this and I already >>> wondered why nobody told about this real problem). >> Keep in mind, I'm not saying this. > Saying what? I don't understand what you were not saying. > >> This is a sketch of your point of view and Tyler's point of view. > What has the phrase I told above with what Tyler said? > I said that if somebody can create accessible programs but doesn't *want* to do that, this generates discrimination. > Don't you agree with this? > >>> Well, I think that everyone should understand why the programs must be >>> accessible and why everybody should care about all the users of an >>> application and that it is not normal to not care. >> Ah! I think I see where you're going wrong. It *is* normal not to >> care- not just about this, but about any given special interest other >> than your own. You have to convince people to care, or they don't- and >> you're not convincing, just yelling. > Where did I say that it is normal to not care about other things? > I have also agreed that it is important to have support for Python 3, that it is also important the commercial point of view, it is also important to have a GUI lib without bugs that generates errors, and you are again and again misunderstanding me thinking that I am yelling, even though I am writing all these things very calm. > > And I am not trying to convince anyone. I mean, we are not in the previous century and I hope that I don't need to convince anyone that offering accessibility for everyone is very important. Do you think that on this list there still are members that need to be convinced about this things? Do you really think that there are members that can't understand the importance of accessibility and they need to be convinced, persuaded, motivated with nice words? Do you have such a bad idea about them? > I am sure that they all know very well why the accessibility is important and I was just trying to tell them that Tkinter doesn't create accessible apps. > > >>> You are also very unkind and rude when you say that the disabled that need >>> to use a screen reader should be a kind of second hand people that need to >>> beg for a little accessibility. >> I don't say this. Don't try to stuff me into a strawman argument. > Then why do you ask nice words from me and an atitude which should be nice for the others? > We are not negociating here and I am not trying to convince anyone. I am just giving them the information that Tkinter creates inaccessible apps, and this creates discrimination, which is very true. It is not nice to talk about these things, , but first it is not nice for those discriminated, not for the others. > > >>> When you create a program, why do you create a visual interface for it? Why >>> don't you create just an audio interface? >> I don't create a visual interface. I have never found it necessary for >> my line of work, and have little stake in this discussion besides that >> of advocating civility on this list. > You are confusing civility with dupplicity. I was very civilized here. I didn't called names, I didn't used bad words but I am just trying to show why what the majority does is bad. Well, from its point of view this may mean that it is not civilized because it doesn't like it. > > >>> You do this because otherwise you would not please those who can see. Why >>> shouldn't be something normal, and that *should be not be discussable at >>> all* to offer the same accessibility to everyone? >> You can discuss it. You just have to convince others that you're >> right, and you're not doing that well. I offered you some advice on >> how to go about doing it better. > Well, I see that you really think than now in 2011 the people need to be convinced that the accessibility is important. > > >>> And you didn't say what was rude from what I said. You said just that it was >>> rude. >> I can provide quotes, if you like. > Yes please do it. > >>> Oh yes I know that it is unkind because most of the people don't even like >>> to talk personally with disabled people, but this doesn't mean that the >>> disabled people are something not normal, but those who have those biases >>> towards those who are very different. >> I don't have this problem. > Oh yes you do have it, because otherwise you wouldn't consider my messages as angry and not civilized just because they are not nice and candy and they don't try to convince the others that they should do something, because they are different from what you expect. > >> I think it would be better for the Python community if you were more >> civil and for the disabled community if you were more successful. The >> two go hand in hand. > I see that you see me as a paid advocate that should succeed convincing a certain group to do a certain thing, but I already told that I am not trying to convince anyone. > I just said that now in our era all the people should be very well convinced about the importance of accessibility, and there are very many resources on the net that talk about accessibility if there is somebody that doesn't know what we are talking about, so I don't need to convince anyone. > But I think that this is a false argument, because I doubt that there are list members that don't know the importance of accessibility. > > >> More people have the power to accomplish what fewer cannot. You want >> big changes, you will need big support, and people won't just move to >> your side because you're angry. You have to convince them. > I am not angry, but I am not trying to convince anyone about the importance of accessibility because its importance is very well known. > The problems are those who are aware about the accessibility but that still don't care. They are the people that should be taken with nice words? Doesn't that mean begging for a little accessibility as I said above? > > >>> If the majority doesn't care about the minorities which are minorities >>> without willing to be so, then it means that it is wrong. >> I don't know that's the case, and I suspect there are shades of grey >> you are not acknowledging here. > If you are acknowledging, then please give some examples of shades of gray. > > Octavian > -- Thanks, Ty From tjreedy at udel.edu Wed Jan 26 18:09:25 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Wed, 26 Jan 2011 18:09:25 -0500 Subject: WxPython versus Tkinter. In-Reply-To: <79f15901-3a0b-4749-8cd9-d2560406bee7@l15g2000prg.googlegroups.com> References: <4D402E58.9090001@tysdomain.com> <79f15901-3a0b-4749-8cd9-d2560406bee7@l15g2000prg.googlegroups.com> Message-ID: On 1/26/2011 11:00 AM, Bryan wrote: > On Jan 26, 9:47 am, "Octavian Rasnita" wrote: > >> I couldn't find the word soapbox in the dictionary Then get a better dictionary, or use on of the free, online ones. http://www.merriam-webster.com/dictionary/soapbox Definition of SOAPBOX : an improvised platform used by a self-appointed, spontaneous, or informal orator; broadly : something that provides an outlet for delivering opinions Soap used to be delivered to local general stores in sturdy wooden boxes, a bit longer than milk cartons. Flipped top down on the grass of a public area, the bottom was used as a speaking platform. Being sturdy, kids sometimes put wheels on them to ride in and even race. Hence, 'soapbox (or soap box) derby'. >> Please be more clear and not talk like the high school kids. Please give up the insults. I have stopped reading your repetitive posts and only saw this one because Bryan quoted it. > http://en.wikipedia.org/wiki/Soapbox -- Terry Jan Reedy From mail2bansi at gmail.com Wed Jan 26 18:10:49 2011 From: mail2bansi at gmail.com (bansi) Date: Wed, 26 Jan 2011 15:10:49 -0800 (PST) Subject: Is it possible to pass CSV Reader Object As Argument to another Python File ??? References: <2c35653e-3565-48c6-8939-b6b09b885e3f@d23g2000prj.googlegroups.com> <876b6c52-1a6d-4afa-83e9-fa987c9359a5@v31g2000pri.googlegroups.com> <87lj272vpo.fsf@benfinney.id.au> Message-ID: <5b4183bc-45f2-4fca-a0d4-25537306ebec@u13g2000prd.googlegroups.com> On Jan 26, 4:36?pm, Ben Finney wrote: > bansi writes: > > Thanks Chris. Sorry for mis-communicating, the two python scripts are > > dependant in a way that namelookupWrapper.py needs to pass csv record > > object to another python script > > Why have you structured them that way, though? What constraint is > keeping you from doing the work in a single process, where the CSV > reader object can be shared? > > > If thats not possible then please let me know how to do the workaround > > i didnt understood the import thing and not sure if it helps in my > > case > > The problem as you've described it so far is best solved by having a > single process accessing the CSV reader object in memory. If that > doesn't suit your use case, you'll need to explain why not. > > -- > ?\ ? ? ? ?To have the choice between proprietary software packages, is | > ? `\ ? ? ?being able to choose your master. Freedom means not having a | > _o__) ? ? ? ? ? ? ? ? ? ? ? ?master.? ?Richard M. Stallman, 2007-05-16 | > Ben Finney Thanks Ben for quick response. The constraint is in using third party tool called Splunk which has in-built Python 2.6 which doesnt support pyodbc on Windows 64 bit OS. Hence i have to install Python 2.7 for pyodbc. That means namelookupwrapper.py acts as a wrapper running under Splunk environment taking input from Splunk via stdin and storing it in csv reader object and then needs to call actual script namelookup.py under Python 2.7 for making connection to database Hope i have clarified a bit From me+list/python at ixokai.io Wed Jan 26 18:13:50 2011 From: me+list/python at ixokai.io (Stephen Hansen) Date: Wed, 26 Jan 2011 15:13:50 -0800 Subject: WxPython versus Tkinter. In-Reply-To: <4D4093AF.80806@etrix.com.au> References: <4D4093AF.80806@etrix.com.au> Message-ID: <4D40AAAE.80102@ixokai.io> On 1/26/11 1:35 PM, Brendan Simon (eTRIX) wrote: > Since it seems the python motto is "Batteries included", then it would > seem to me that wxPython is the natural fit as it also has "Batteries > included" (e.g. accessibility, native look-n-feel, mature and evolving, > can produce simple or complex gui programs, etc, etc). That is not the Python motto. It is a philosophy which factors into decisions of things to add to the standard library; but there are other factors as well. It emphatically doesn't mean to include everything, or even most things. It means providing broad support for a wide range of common tasks and generally encourages including mature, best-of-breed modules that emerge out in the wider ecosystem that are suitable for inclusion. wxPython is mature: best-of-breed is a long-debated, and its not suitable for inclusion for various reasons discussed elsewhere. -- Stephen Hansen ... Also: Ixokai ... Mail: me+list/python (AT) ixokai (DOT) io ... Blog: http://meh.ixokai.io/ -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 487 bytes Desc: OpenPGP digital signature URL: From ethan at stoneleaf.us Wed Jan 26 18:25:17 2011 From: ethan at stoneleaf.us (Ethan Furman) Date: Wed, 26 Jan 2011 15:25:17 -0800 Subject: Is it possible to pass CSV Reader Object As Argument to another Python File ??? In-Reply-To: <87lj272vpo.fsf@benfinney.id.au> References: <2c35653e-3565-48c6-8939-b6b09b885e3f@d23g2000prj.googlegroups.com> <876b6c52-1a6d-4afa-83e9-fa987c9359a5@v31g2000pri.googlegroups.com> <87lj272vpo.fsf@benfinney.id.au> Message-ID: <4D40AD5D.8020301@stoneleaf.us> bansi wrote: > First namelookupWrapper.py running under Python 2.6 accept arguments > from stdin and uses csv reader object to read it i.e. > r=csv.reader(sys.stdin) > > And then it has to pass csv reader object to another python script > namelookup.py running under Python 2.7 because it uses pyodbc to > connect to database and iterates thru reader object Ben Finney wrote: > bansi writes: > >> Thanks Chris. Sorry for mis-communicating, the two python scripts are >> dependant in a way that namelookupWrapper.py needs to pass csv record >> object to another python script > > Why have you structured them that way, though? What constraint is > keeping you from doing the work in a single process, where the CSV > reader object can be shared? > >> If thats not possible then please let me know how to do the workaround >> i didnt understood the import thing and not sure if it helps in my >> case > > The problem as you've described it so far is best solved by having a > single process accessing the CSV reader object in memory. If that > doesn't suit your use case, you'll need to explain why not. > In other words, why can't you use Python 2.7 to accept input and generate a csv.reader? ~Ethan~ From me+list/python at ixokai.io Wed Jan 26 18:27:08 2011 From: me+list/python at ixokai.io (Stephen Hansen) Date: Wed, 26 Jan 2011 15:27:08 -0800 Subject: WxPython versus Tkinter. In-Reply-To: <7952a09c-4e61-4661-9873-7e0bd897b1ee@y2g2000prf.googlegroups.com> References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <8q7sgiF5tpU1@mid.individual.net> <19891784-d6a3-41ac-a097-5902a6323bc0@o21g2000prn.googlegroups.com><0b12cdb1-45b4-41e4-9bdb-074ee669d76b@k14g2000pre.googlegroups.com> <048FB74272D440A0915ABC7D76AE262B@teddy> <5782E9AD8A8342D691EB3549E5E0ED7B@octavian> <43FCB75BBC57406799C87AD6FC781EFC@teddy> <7952a09c-4e61-4661-9873-7e0bd897b1ee@y2g2000prf.googlegroups.com> Message-ID: <4D40ADCC.3080505@ixokai.io> On 1/26/11 12:37 PM, rantingrick wrote: > On Jan 26, 2:07 pm, Stephen Hansen wrote: > >> And some people have absolutely no need-- no need at all-- for any sort >> of GUI programming at all. This group is actually really, really big. > > Stephen "Strawman" Hansen: If he only had a brain! :-) > > That is the most obvious straw-man to date in this thread. What about > the large portion of folks who don't use all the datatypes (queue, > weakref, etc) or how about numeric and math modules (fractions, > decimal, etc) or how about data persistence, or Cryptograhic, or > curses! or, multimedia services, or, or. > > You see NOT everyone uses everything in the stdlib and most use much > less than half. However we would be fools to claim "batteries > included" and NOT support GUI! As usual, you selectively quote and completely miss the point. Hint: the quoted portion was not an argument for or against inclusion of anything. The funny thing is, by selectively quoting the phrase and using it to imply that I was making a straw-man argument against inclusion with that statement -- which, point of fact, I was not -- you are yourself, making a straw-man argument. http://en.wikipedia.org/wiki/Straw_man "To "attack a straw man" is to create the illusion of having refuted a proposition by substituting it with a superficially similar yet unequivalent proposition (the "straw man"), and refuting it, without ever having actually refuted the original position." I can't decide if you're just ignorant or if you're an artful troll with a sense of irony and did it on purpose. -- Stephen Hansen ... Also: Ixokai ... Mail: me+list/python (AT) ixokai (DOT) io ... Blog: http://meh.ixokai.io/ -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 487 bytes Desc: OpenPGP digital signature URL: From hidura at gmail.com Wed Jan 26 18:27:31 2011 From: hidura at gmail.com (hidura at gmail.com) Date: Wed, 26 Jan 2011 23:27:31 +0000 Subject: Problems receiving arguments on a subprocess Message-ID: <20cf304341ce5a013a049ac82df4@google.com> Hello i am trying to make a subprocess that will have to send data as an arguments and is executing the script but don't receiving anything. Here is the code of the subprocess: car = Popen(shlex.split(self.block.getAttribute('cmd')), stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) data = car.communicate(str(""+self.extract.getByAttr(self.block, 'name', 'args')[0].toxml()+"").encode()) dataOut = data[0].decode() log = data[1].decode() print(dataOut) if car.returncode < 1: return dataOut.split('\n') else: print(log) return log Here is the code of the script: """ Created By: hidura On Date: Jan 25, 2011 """ from xml.dom.minidom import parseString import os import sys class savCSS: """This class has to save the changes on the css file. """ def __init__(self, args): document = parseString(args) request = document.firstChild address = request.getElementsByTagName('element')[0] newdata = request.getElementsByTagName('element')[1] cssfl = open("/webapps/karinapp/Suite/"+address.getAttribute('value'), 'r') cssData = cssfl.read() cssfl.close() dataCSS = '' for child in newdata.childNodes: if child.nodeType == 3: dataCSS += child.nodeValue nwcssDict = {} for piece in dataCSS.split('}'): nwcssDict[piece.split('{')[0]] = piece.split('{')[1] cssDict = {} for piece in cssData.split('}'): cssDict[piece.split('{')[0]] = piece.split('{')[1] for key in nwcssDict: if key in cssDict == True: del cssDict[key] cssDict[key] = nwcssDict[key] result = '' for key in cssDict: result += key+"{"+cssDict[key]+"}" cssfl = open(cssfl.name, 'a') cssfl.write(result) cssfl.close() if __name__ == "__main__": print(sys.stdin.read()) savCSS(sys.stdin.read()) Thanks in advance -------------- next part -------------- An HTML attachment was scrubbed... URL: From python at mrabarnett.plus.com Wed Jan 26 18:49:00 2011 From: python at mrabarnett.plus.com (MRAB) Date: Wed, 26 Jan 2011 23:49:00 +0000 Subject: replacing lines in a file In-Reply-To: References: Message-ID: <4D40B2EC.1070309@mrabarnett.plus.com> On 26/01/2011 21:50, mpnordland wrote: > Attached are a config file parser that i'm working on, and a example > config file. Basically, what my problem is is in write_config, it should > search through the file, and replace the lines with whatever the > modified version is, it is also designed to ignore comments. To see my > problem (which is hard to describe) please first look at the config > file, and then run config-parse.py then look at the config file again. > One of two things should happen: nothing, or something weird should > happen on the last line. > > #!/usr/bin/python > import fileinput > > def read_config(file): > config={} > if isinstance(file, type('str')) : > config_file=open_config_file(file, 'r') > if not config_file: > return 1 > for option in config_file: > option=option.replace('\n','') > if option!='' and '#' not in option: > option=option.split(':') > config[option[0]]=option[1] > config_file.close() > return config > else: > print "the file paramenter should be a string contianing a file path" > return 1 > Sometimes the function returns the config (a dict) and sometimes it returns 1. The Pythonic way would be to raise an exception if there's an error. > def write_config(config, file): > if isinstance(config, type({})) and isinstance(file, type('str')): > config_file=open_config_file(file,'r+') > if not config_file: > return 1 > > for line in config_file: > line=line.replace('\n','') > if line!='' and '#' not in line: > option=line.split(':') > new_line = option[0]+':'+config[option[0]] + '\n' > > print config_file.write(line.replace(line, new_line)) You're reading a line from the file and then writing the new line over whatever follows it. Suppose you have a file containing "123\n45\n678\n". You open the file. You're at position 0. You read the first line "123\n". You're now at position 4. You write "XYZ\n". You're now at position 8. The file now contains "123\nXYZ\n78\n". You've just overwritten the second line and part of the third line. > config_file.close() > else: > print "The config arg must be a dictionary and/or the file arg must be a string containing a file path" > def open_config_file(file, mode): > try: > config_file=open(file,mode) > except IOError: > print "That File Doesn't exist!" > return None > return config_file > > if __name__ == '__main__': > file = './net-responsibility.conf2' > config=read_config(file) > print config > config["logfile"]=' 5' > file = './net-responsibility.conf2' > write_config(config, file) From rantingrick at gmail.com Wed Jan 26 18:57:46 2011 From: rantingrick at gmail.com (rantingrick) Date: Wed, 26 Jan 2011 15:57:46 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <8q7sgiF5tpU1@mid.individual.net> <19891784-d6a3-41ac-a097-5902a6323bc0@o21g2000prn.googlegroups.com><0b12cdb1-45b4-41e4-9bdb-074ee669d76b@k14g2000pre.googlegroups.com> <048FB74272D440A0915ABC7D76AE262B@teddy> <5782E9AD8A8342D691EB3549E5E0ED7B@octavian> Message-ID: <0338ce09-e954-4dcd-b164-e23db77986da@g26g2000vba.googlegroups.com> On Jan 26, 4:57?pm, Terry Reedy wrote: > PyGui seems to be purely a gui package, but it appear to be aimed only > at 2.x with no interest in 3.x. I really like pyGUI. We would have to do a ton of work to get it even to the scale of Tkinter. In hindsight the project seems like something Python should have considered from the beginning. Had we have started with something like pyGUI 20 years ago, i'd bet we would be better off today since we could control the development internally. PROS: * small * cross platform?? * pythonic * under our control * unlimited possibilities CONS: * not feature rich * huge amount of work needed Although pyGUI would probably never measure up to wxPython. I still have a special place in my heart for such an ambitious and visionary undertaking. You can read the goals at Greg's site. Every time i do i get a tear in my eye thinking of the possibilities. http://www.cosc.canterbury.ac.nz/greg.ewing/python_gui/ From robert.kern at gmail.com Wed Jan 26 19:23:44 2011 From: robert.kern at gmail.com (Robert Kern) Date: Wed, 26 Jan 2011 18:23:44 -0600 Subject: WxPython versus Tkinter. In-Reply-To: References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <8q7sgiF5tpU1@mid.individual.net> <19891784-d6a3-41ac-a097-5902a6323bc0@o21g2000prn.googlegroups.com><0b12cdb1-45b4-41e4-9bdb-074ee669d76b@k14g2000pre.googlegroups.com> <048FB74272D440A0915ABC7D76AE262B@teddy> <5782E9AD8A8342D691EB3549E5E0ED7B@octavian> Message-ID: On 1/26/11 4:57 PM, Terry Reedy wrote: > From what I remember when I looked at the WxWidgets feature list some years > ago, WxWidgets does not come with a scripting language, but also has more that > strictly gui stuff. So I think it would also need to be subsetted. For what it's worth, wxPython tries not to wrap parts of wxWidgets that can be replicated by the standard library. I do believe they wrap some non-GUI parts of wxWidgets that are needed to work with certain GUI widgets, but don't quote me on that. > On 1/26/2011 11:35 AM, Robert Kern wrote: >> There is certainly enough maintenance force to keep wxPython updated and >> ported to Python 3, but only *outside* of the standard library. > > I got the opposite impression from the link above. As of last May, 3.x support > is deferred until a new C++ code generator is written, and that is deferred > until new features are added and released. So it seems the project needs another > person to either code the new code generator or learn how to port Capi code (or > both). Since there is no 2to3 for Capi (as opposed to Python code), I do not > even know is a single code base is possible. I am sure that whoever works on a > wxPython port could learn from whoever did the numpy port. In loose terms, what we learned from the experience was that it actually isn't so bad once you knuckle down to it. But yes, it does look like some more volunteer effort would be needed to get Python 3 support soon. I note that I did not specify any particular deadline. :-) I just wanted to disabuse Octavian of the idea that we are claiming that the wxPython team is inadequate in general. -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco From tjreedy at udel.edu Wed Jan 26 19:46:09 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Wed, 26 Jan 2011 19:46:09 -0500 Subject: WxPython versus Tkinter. In-Reply-To: <4D407F07.6020808@ixokai.io> References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <8q7sgiF5tpU1@mid.individual.net> <19891784-d6a3-41ac-a097-5902a6323bc0@o21g2000prn.googlegroups.com><0b12cdb1-45b4-41e4-9bdb-074ee669d76b@k14g2000pre.googlegroups.com> <048FB74272D440A0915ABC7D76AE262B@teddy> <5782E9AD8A8342D691EB3549E5E0ED7B@octavian> <43FCB75BBC57406799C87AD6FC781EFC@teddy> <4D407F07.6020808@ixokai.io> Message-ID: On 1/26/2011 3:07 PM, Stephen Hansen wrote: > And, more then a few actually > are pushing for the stdlib to be forked off of CPython, and instead end > up shared by all the major Python implementations (CPython, Jython, > PyPy, IronPython, what else?) as a common resource? This would be a 'split', not a 'fork' (important difference). There are really two ideas here. 1. As many modules as possible would have a pure Python reference implementation. Any implementation could use that until it choose to replace or supplement with a native-language implementation. For instance, itertools in coded in C for speed, but the docs give Python (near) equivalents for clarity. A common Python stdlib would have a Python-coded itertools. CPython would actually run the C-coded equivalent renamed _itertools. Maintaining both versions in parallel would be more work, so this could only happen if other implementors chipped in to help. Stephen, you are the first I know of to ask whether such a project would affect addition of new modules. Hard to say. 2. Separate tests that test compliance with the Python specs (for both language and stdlib) from tests that test implementation-specific behaviors. The current CPython test suite mixes both together. If separated, other implementations could (and would) use the Python tests, and their people would be more willing to help improve the Python tests. Many stdlib modules are not at 100% coverage and need expansion. For instance, "1+1 == 2" tests Python behavior, while "a,b=1,1; id(a)==id(b)" tests a CPython implementation detail. Last I knew, both types of tests are in the same test file. Reference count tests, for example, are also CPython-specific. Both of these ideas will be looked at after the hg migration. -- Terry Jan Reedy From mail2bansi at gmail.com Wed Jan 26 19:57:41 2011 From: mail2bansi at gmail.com (bansi) Date: Wed, 26 Jan 2011 16:57:41 -0800 (PST) Subject: Is it possible to pass CSV Reader Object As Argument to another Python File ??? References: <2c35653e-3565-48c6-8939-b6b09b885e3f@d23g2000prj.googlegroups.com> <876b6c52-1a6d-4afa-83e9-fa987c9359a5@v31g2000pri.googlegroups.com> <87lj272vpo.fsf@benfinney.id.au> Message-ID: On Jan 26, 6:25?pm, Ethan Furman wrote: > bansi wrote: > > ?> First namelookupWrapper.py running under Python 2.6 accept arguments > ?> from stdin and uses csv reader object to read it i.e. > ?> r=csv.reader(sys.stdin) > ?> > ?> And then it has to pass csv reader object to another python script > ?> namelookup.py running under Python 2.7 because it uses pyodbc to > ?> connect to database and iterates thru reader object > > > > > > Ben Finney wrote: > > bansi writes: > > >> Thanks Chris. Sorry for mis-communicating, the two python scripts are > >> dependant in a way that namelookupWrapper.py needs to pass csv record > >> object to another python script > > > Why have you structured them that way, though? What constraint is > > keeping you from doing the work in a single process, where the CSV > > reader object can be shared? > > >> If thats not possible then please let me know how to do the workaround > >> i didnt understood the import thing and not sure if it helps in my > >> case > > > The problem as you've described it so far is best solved by having a > > single process accessing the CSV reader object in memory. If that > > doesn't suit your use case, you'll need to explain why not. > > In other words, why can't you use Python 2.7 to accept input and > generate a csv.reader? > > ~Ethan~- Hide quoted text - > > - Show quoted text - Ethan, The python script takes the input from Splunk (http://www.splunk.com/ base/Documentation/) which supports only Python 2.6 So the real constraint is Splunk supports only Python 2.6 . As you know Python 2.6 doesnt support or doesnt have pyodbc install for Windows 64 bit OS So i installed Python 2.7 and thereafter pyodbc install for Windows 64 bit OS for Python 2.7 From clp2 at rebertia.com Wed Jan 26 20:24:36 2011 From: clp2 at rebertia.com (Chris Rebert) Date: Wed, 26 Jan 2011 17:24:36 -0800 Subject: Problems receiving arguments on a subprocess In-Reply-To: <20cf304341ce5a013a049ac82df4@google.com> References: <20cf304341ce5a013a049ac82df4@google.com> Message-ID: On Wed, Jan 26, 2011 at 3:27 PM, wrote: > Hello i am trying to make a subprocess that will have to send data as an > arguments and is executing the script but don't receiving anything. Command-line arguments, or stream/file input via stdin? I think you mean the latter. The term "argument(s)" is not typically used to describe the latter. How exactly did you conclude that the script isn't receiving anything? > Here is the code of the subprocess: > car = Popen(shlex.split(self.block.getAttribute('cmd')), > stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) > data = car.communicate(str(""+self.extract.getByAttr(self.block, > 'name', 'args')[0].toxml()+"").encode()) > > dataOut = data[0].decode() > log = data[1].decode() > print(dataOut) > > if car.returncode < 1: > return dataOut.split('\n') > > else: > print(log) > return log If you still have problems, try printing `log` unconditionally and then checking that you still get no output. Also, please ensure future posts preserve the indentation in your code. It's rather annoying (and imprecise) to have to infer it. > Here is the code of the script: > > if __name__ == "__main__": > > print(sys.stdin.read()) > savCSS(sys.stdin.read()) You do realize the second .read() will *always* return an empty string, right? The first .read() already read all of the stdin stream, so there's nothing left for the second .read() to get. I suspect this is the cause of your problem. Remove the line involving print(). Cheers, Chris -- http://blog.rebertia.com From hidura at gmail.com Wed Jan 26 20:29:24 2011 From: hidura at gmail.com (Hidura) Date: Wed, 26 Jan 2011 21:29:24 -0400 Subject: Problems receiving arguments on a subprocess In-Reply-To: <20cf304341ce5a013a049ac82df4@google.com> References: <20cf304341ce5a013a049ac82df4@google.com> Message-ID: The print line it doesn't print anything that's why i say is not receiving anything. 2011/1/26, hidura at gmail.com : > Hello i am trying to make a subprocess that will have to send data as an > arguments and is executing the script but don't receiving anything. > > Here is the code of the subprocess: > car = Popen(shlex.split(self.block.getAttribute('cmd')), > stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) > data = > car.communicate(str(""+self.extract.getByAttr(self.block, 'name', > 'args')[0].toxml()+"").encode()) > > > > dataOut = data[0].decode() > log = data[1].decode() > print(dataOut) > > if car.returncode < 1: > return dataOut.split('\n') > > else: > print(log) > return log > > Here is the code of the script: > > """ > Created By: hidura > On Date: Jan 25, 2011 > """ > from xml.dom.minidom import parseString > import os > import sys > > class savCSS: > """This class has to save > the changes on the css file. > """ > > def __init__(self, args): > > document = parseString(args) > request = document.firstChild > > address = request.getElementsByTagName('element')[0] > newdata = request.getElementsByTagName('element')[1] > > cssfl = open("/webapps/karinapp/Suite/"+address.getAttribute('value'), 'r') > cssData = cssfl.read() > cssfl.close() > > dataCSS = '' > for child in newdata.childNodes: > if child.nodeType == 3: > dataCSS += child.nodeValue > > nwcssDict = {} > > for piece in dataCSS.split('}'): > nwcssDict[piece.split('{')[0]] = piece.split('{')[1] > > > cssDict = {} > > for piece in cssData.split('}'): > cssDict[piece.split('{')[0]] = piece.split('{')[1] > > > for key in nwcssDict: > if key in cssDict == True: > del cssDict[key] > > cssDict[key] = nwcssDict[key] > > > result = '' > for key in cssDict: > result += key+"{"+cssDict[key]+"}" > > > cssfl = open(cssfl.name, 'a') > cssfl.write(result) > cssfl.close() > > > > if __name__ == "__main__": > > print(sys.stdin.read()) > savCSS(sys.stdin.read()) > > > Thanks in advance > -- Enviado desde mi dispositivo m?vil Diego I. Hidalgo D. From python at mrabarnett.plus.com Wed Jan 26 20:31:03 2011 From: python at mrabarnett.plus.com (MRAB) Date: Thu, 27 Jan 2011 01:31:03 +0000 Subject: Is it possible to pass CSV Reader Object As Argument to another Python File ??? In-Reply-To: References: <2c35653e-3565-48c6-8939-b6b09b885e3f@d23g2000prj.googlegroups.com> <876b6c52-1a6d-4afa-83e9-fa987c9359a5@v31g2000pri.googlegroups.com> <87lj272vpo.fsf@benfinney.id.au> Message-ID: <4D40CAD7.1000301@mrabarnett.plus.com> On 27/01/2011 00:57, bansi wrote: > On Jan 26, 6:25 pm, Ethan Furman wrote: >> bansi wrote: >> >> > First namelookupWrapper.py running under Python 2.6 accept arguments >> > from stdin and uses csv reader object to read it i.e. >> > r=csv.reader(sys.stdin) >> > >> > And then it has to pass csv reader object to another python script >> > namelookup.py running under Python 2.7 because it uses pyodbc to >> > connect to database and iterates thru reader object >> >> >> >> >> >> Ben Finney wrote: >>> bansi writes: >> >>>> Thanks Chris. Sorry for mis-communicating, the two python scripts are >>>> dependant in a way that namelookupWrapper.py needs to pass csv record >>>> object to another python script >> >>> Why have you structured them that way, though? What constraint is >>> keeping you from doing the work in a single process, where the CSV >>> reader object can be shared? >> >>>> If thats not possible then please let me know how to do the workaround >>>> i didnt understood the import thing and not sure if it helps in my >>>> case >> >>> The problem as you've described it so far is best solved by having a >>> single process accessing the CSV reader object in memory. If that >>> doesn't suit your use case, you'll need to explain why not. >> >> In other words, why can't you use Python 2.7 to accept input and >> generate a csv.reader? >> >> ~Ethan~- Hide quoted text - >> >> - Show quoted text - > > Ethan, > The python script takes the input from Splunk (http://www.splunk.com/ > base/Documentation/) which supports only Python 2.6 > So the real constraint is Splunk supports only Python 2.6 . > > As you know Python 2.6 doesnt support or doesnt have pyodbc install > for Windows 64 bit OS > So i installed Python 2.7 and thereafter pyodbc install for Windows 64 > bit OS for Python 2.7 Have you actually tried Splunk with Python 2.7? It might not work with versions which are earlier than Python 2.6, but that doesn't necessarily mean that it won't work with versions of Python 2 which are later than Python 2.6 (unless the documentation says that it must be Python 2.6). From jbravado at gmail.com Wed Jan 26 21:00:51 2011 From: jbravado at gmail.com (JB) Date: Wed, 26 Jan 2011 18:00:51 -0800 (PST) Subject: Executing multiple subprocesses and waiting Message-ID: <106dca00-5ad8-4f10-af99-01525e72f9fb@z26g2000prf.googlegroups.com> One of my python scripts that takes a bunch of inputs from a tKinter gui, generates a set of command line stings, and then threads them off to subprocess for calls to other programs like Nuke and our render farm has recently started randomly crashing pythonw.exe. I'm taking a look at my threading setup and attempting to clean it up. I was wondering what a smart way of doing what I describe is? Take a list of strings containing command line calls to other programs, process them one at a time (waiting for the previous one to complete before starting the next) and then finishing elegantly. Currently, the gui passes them all to a "workerThread" which loops through each string, sending it to a "processThread" which makes a call to subprocess to execute it. This has worked fine for over a year so the recent crashing is mystifying me. I'm wondering if it's increased network stress (we've grown) or something similar? Any thoughts and suggestions on waiting for threads to complete are appreciated. From reilly.christopher at gmail.com Wed Jan 26 21:17:23 2011 From: reilly.christopher at gmail.com (Chris) Date: Wed, 26 Jan 2011 18:17:23 -0800 (PST) Subject: Decorator question Message-ID: <5c4ce9cb-c68d-457e-ad63-c320f3a46224@p7g2000prb.googlegroups.com> I have a class (A, for instance) that possesses a boolean (A.b, for instance) that is liable to change over an instance's lifetime. Many of the methods of this class (A.foo, for instance) should not execute as long as this boolean is false, but should instead raise an exception. Can I use a decorator to implement this functionality? More exactly, could I define a function called 'checker' that accomplishes this: def checker(f): ... class A(): b = True @checker def foo(self,...): print 'in foo' a = A() a.foo() a.b = False a.foo() would result in: 'in foo' Exception: ... This exact solution isn't necessary, just something that doesn't require me to have the clunky: def foo(self,...): if self.b: ... else: raise Exception('b attribute must be true before executing this method') in every method. Thanks, Chris From reilly.christopher at gmail.com Wed Jan 26 21:37:57 2011 From: reilly.christopher at gmail.com (Chris) Date: Wed, 26 Jan 2011 18:37:57 -0800 (PST) Subject: Decorator question References: <5c4ce9cb-c68d-457e-ad63-c320f3a46224@p7g2000prb.googlegroups.com> Message-ID: On Jan 26, 6:17?pm, Chris wrote: > I have a class (A, for instance) that possesses a boolean (A.b, for > instance) that is liable to change over an instance's lifetime. > > Many of the methods of this class (A.foo, for instance) should not > execute as long as this boolean is false, but should instead raise an > exception. > > Can I use a decorator to implement this functionality? ?More exactly, > could I define a function called 'checker' that accomplishes this: > > def checker(f): > ? ? ... > > class A(): > > ? ? b = True > > ? ? @checker > ? ? def foo(self,...): > ? ? ? ? print 'in foo' > > a = A() > a.foo() > a.b = False > a.foo() > > would result in: > > 'in foo' > Exception: ... > > This exact solution isn't necessary, just something that doesn't > require me to have the clunky: > > def foo(self,...): > ? ? if self.b: > ? ? ? ? ... > ? ? else: raise Exception('b attribute must be true before executing > this method') > > in every method. > > Thanks, > > Chris Sorry, discovered answer here: http://stackoverflow.com/questions/2309124/get-class-in-python-decorator From python at mrabarnett.plus.com Wed Jan 26 21:40:59 2011 From: python at mrabarnett.plus.com (MRAB) Date: Thu, 27 Jan 2011 02:40:59 +0000 Subject: Decorator question In-Reply-To: <5c4ce9cb-c68d-457e-ad63-c320f3a46224@p7g2000prb.googlegroups.com> References: <5c4ce9cb-c68d-457e-ad63-c320f3a46224@p7g2000prb.googlegroups.com> Message-ID: <4D40DB3B.1050201@mrabarnett.plus.com> On 27/01/2011 02:17, Chris wrote: > I have a class (A, for instance) that possesses a boolean (A.b, for > instance) that is liable to change over an instance's lifetime. > > Many of the methods of this class (A.foo, for instance) should not > execute as long as this boolean is false, but should instead raise an > exception. > > Can I use a decorator to implement this functionality? More exactly, > could I define a function called 'checker' that accomplishes this: > > def checker(f): > ... > > class A(): > > b = True > > @checker > def foo(self,...): > print 'in foo' > > a = A() > a.foo() > a.b = False > a.foo() > > would result in: > > 'in foo' > Exception: ... > > This exact solution isn't necessary, just something that doesn't > require me to have the clunky: > > def foo(self,...): > if self.b: > ... > else: raise Exception('b attribute must be true before executing > this method') > > in every method. > How about this: def checker(func): def wrapper(self, *args, **kwargs): if not self.b: raise Exception('b attribute must be true before executing this method') return func(self, *args, **kwargs) return wrapper From tshinnic at io.com Wed Jan 26 21:42:04 2011 From: tshinnic at io.com (Thomas L. Shinnick) Date: Wed, 26 Jan 2011 20:42:04 -0600 Subject: Decorator question In-Reply-To: <5c4ce9cb-c68d-457e-ad63-c320f3a46224@p7g2000prb.googlegrou ps.com> References: <5c4ce9cb-c68d-457e-ad63-c320f3a46224@p7g2000prb.googlegroups.com> Message-ID: At 08:17 PM 1/26/2011, Chris wrote: >I have a class (A, for instance) that possesses a boolean (A.b, for >instance) that is liable to change over an instance's lifetime. > >Many of the methods of this class (A.foo, for instance) should not >execute as long as this boolean is false, but should instead raise an >exception. > >Can I use a decorator to implement this functionality? More exactly, >could I define a function called 'checker' that accomplishes this: Mark Summerfield's book "Programming in Python 3" has an example something like this (p.357) called 'positive_result'. I hesitate to quote the entire thing, so I'll quote only the inner 'half' of the decorator: def wrapper(*args, **kwargs): result = function(*args, **kwargs) assert result >= 0, function.__name__ + "() result isn't >= 0" return result I would guess you would have to count on the first item in the methods' args to be self, and use that to test whether your attribute is false/true? Mark? >def checker(f): > ... > >class A(): > > b = True > > @checker > def foo(self,...): > print 'in foo' > >a = A() >a.foo() >a.b = False >a.foo() > >would result in: > >'in foo' >Exception: ... > >This exact solution isn't necessary, just something that doesn't >require me to have the clunky: > >def foo(self,...): > if self.b: > ... > else: raise Exception('b attribute must be true before executing >this method') > >in every method. > >Thanks, > >Chris >-- From wuwei23 at gmail.com Wed Jan 26 21:59:01 2011 From: wuwei23 at gmail.com (alex23) Date: Wed, 26 Jan 2011 18:59:01 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <8q7sgiF5tpU1@mid.individual.net> <19891784-d6a3-41ac-a097-5902a6323bc0@o21g2000prn.googlegroups.com> <0b12cdb1-45b4-41e4-9bdb-074ee669d76b@k14g2000pre.googlegroups.com> <7bb56aba-0f96-4b7e-a78d-3398003a0e38@c39g2000yqi.googlegroups.com> Message-ID: On Jan 26, 5:25?am, rantingrick wrote: > A vision that > is representative of ALL the people -- and not a few fat cats at the > top. [...] > This is the only way we can truly > understand what our community members are thinking about Tkinter. > Anything else is purely speculation. [...] > Many folks out there share our views that Tkinter is a weight around > Python's neck, however they are too fearful to speak out for fear of > excommunication (the kill file!). So even though the majority of opinions are counter to yours, those people are the arrogant 'fat cats' who aren't listening to 'the people'? You criticise others for making generalised statements about the desires of other coders, but you believe that you speak for a silent majority, whose presence is somehow known and sensed by you through some magical force? Can we all just accept that rr/rantingrick is a troll and let these thread die? This is, what, the 3rd? 4th? year of his endless tirade against TKinter. Most people with an actual problem WOULD HAVE RELEASED CODE BY NOW. From wuwei23 at gmail.com Wed Jan 26 22:11:29 2011 From: wuwei23 at gmail.com (alex23) Date: Wed, 26 Jan 2011 19:11:29 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com><63eea$4d3cd2fd$4275d90a$14984@FUSE.NET><69465430-08b3-4069-99c7-72f4d3034c66@s5g2000yqm.googlegroups.com><705ad$4d3ce0fc$4275d90a$29144@FUSE.NET> <2sm%o.8695$gM3.6118@viwinnwfe01.internal.bigpond.com> <0c3c61b0-d056-4757-b7e4-fecdf9a6e217@fm22g2000vbb.googlegroups.com> Message-ID: <94c48579-aed0-4987-aaa4-0f7b6209d9bb@8g2000prt.googlegroups.com> rantingrick wrote: > Not if we used the underlying MS library! Windows has such a rich > library why not use it? Why must we constantly re-invent the wheel? Isn't restricting a GUI toolkit to just one of the major OSes the absolute opposite of 'accessible'? From wuwei23 at gmail.com Wed Jan 26 22:35:10 2011 From: wuwei23 at gmail.com (alex23) Date: Wed, 26 Jan 2011 19:35:10 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <3a96fee1-995f-49f7-a967-f125cc3f1cdc@v26g2000yqf.googlegroups.com> <023e19ed-69d1-4155-a114-0d00c227b8f6@u18g2000prh.googlegroups.com> Message-ID: <6a71b56a-81bc-4983-91db-ca672560ab2c@f30g2000yqa.googlegroups.com> Infinity77 wrote: > It is very unfortunate that this topic "wxPython vs. Tkinter" has > drifted to another flame war, as there is really no point in this kind > of discussion. I don't think it's wxPython that's causing the flames in this thread :) From bryan.oakley at gmail.com Wed Jan 26 22:36:24 2011 From: bryan.oakley at gmail.com (Bryan) Date: Wed, 26 Jan 2011 19:36:24 -0800 (PST) Subject: Need GUI pop-up to edit a (unicode ?) string References: <3tqr08-bj2.ln1@murmur.very.softly> <7691fe98-37af-4ddf-a8a8-eadeef0d4a6e@y2g2000prf.googlegroups.com> <541c02df-b1fc-4376-bf17-e0531fe5c4bf@r29g2000yqj.googlegroups.com> Message-ID: <9d072d4b-325e-4b41-82ef-d97d8cfd3c5a@y11g2000yqa.googlegroups.com> On Jan 25, 5:02?pm, rantingrick wrote: > On Jan 25, 3:54?pm, Bryan wrote: > ... And you people wonder why i hate Tkinter! Honestly, I don't think anyone wonders why _you_ hate Tkinter, you've made that abundantly clear. From wuwei23 at gmail.com Wed Jan 26 22:53:16 2011 From: wuwei23 at gmail.com (alex23) Date: Wed, 26 Jan 2011 19:53:16 -0800 (PST) Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com><9MB%o.14110$%64.6074@unlimited.newshosting.com><5a5e15f3-ae0f-4561-8969-e9afde3829dc@g26g2000vba.googlegroups.com><1b955dcf-77e2-4130-9b5b-276cfedccd9c@a10g2000vby.googlegroups.com> <4d3fa153$0$29983$c3e8da3$5496439d@news.astraweb.com> Message-ID: <880f2a34-52a2-4e49-a12c-02c8062dd23e@e13g2000yqb.googlegroups.com> "Octavian Rasnita" wrote: > I am sorry if I offended someone, but the main idea I just wanted to express > was that Python should promote the accessibility and deprecate those tools > which are not accessible. That's all. Thank you, I was having a hard time understanding your position from the 3,493,027 posts you made to this thread reiterating that point. From rustompmody at gmail.com Wed Jan 26 22:54:29 2011 From: rustompmody at gmail.com (rusi) Date: Wed, 26 Jan 2011 19:54:29 -0800 (PST) Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com> <9MB%o.14110$%64.6074@unlimited.newshosting.com> <4A48EDF6D7634F2E994661A457451E87@teddy> <753A4C5A6658470085804B13C80340F2@octavian> Message-ID: <9a799be3-e4d9-4f64-9bf9-194eca79256f@r5g2000yql.googlegroups.com> On Jan 27, 3:35?am, rantingrick wrote: > On Jan 26, 3:48?pm, Grant Edwards wrote: > > > People will not separate your personality from the cause you espouse. > > You may not like it, but that's a fact. ?If you are in favor of XYZ, > > and act rude and insulting while espousing XYZ, people will react > > against not only you but _also_ XYZ. > > A certain small subset of any group will always be emotionally driven. > However we should not concern ourselves with this sort of non- > objectivity. Some people make rash decisions not based in reality. > What we *should* concern ourselves with is fostering pure objectivity. > Because objectivity is the virtue of intelligent beings. Objectivity > fosters creativity of which progress is the direct progeny. Man is a rational animal. All my life I've been trying to find evidence of this -- Bertrand Russel From me+list/python at ixokai.io Wed Jan 26 23:48:28 2011 From: me+list/python at ixokai.io (Stephen Hansen) Date: Wed, 26 Jan 2011 20:48:28 -0800 Subject: Need GUI pop-up to edit a (unicode ?) string In-Reply-To: <541c02df-b1fc-4376-bf17-e0531fe5c4bf@r29g2000yqj.googlegroups.com> References: <3tqr08-bj2.ln1@murmur.very.softly> <7691fe98-37af-4ddf-a8a8-eadeef0d4a6e@y2g2000prf.googlegroups.com> <541c02df-b1fc-4376-bf17-e0531fe5c4bf@r29g2000yqj.googlegroups.com> Message-ID: <4D40F91C.7060208@ixokai.io> On 1/25/11 3:02 PM, rantingrick wrote: > This is a major flaw in the design and i would be > happy to fix the flaw. However our "friend" Fredrick decided to > copyright the module to himself! What a jerk! Which is quite > disgusting considering that Tkinter, and TclTk are completely open > source! Uh. ... LOL. Copyright doesn't mean what you think it means. Tkinter is copyrighted. Python is copyrighted. Tcl/TK is copyrgithed. In fact: everything that is "open source" is copyrighted. By definition[* see footnote]. Open source is simply copyrighted material that has been released under a *license* that allows you to copy it, too: sometimes with some significant catches (i.e., GPL), sometimes with basically no strings at all except not to sue (i.e., MIT). So. Its a major flaw? Well! Go fix it, you have every right to. Python's source is released under a rather liberal license, allowing you to do just about anything you want with it. Including fix it and even-- gasp-- submit those fixes to the bug-tracker for inclusion. -- Stephen Hansen ... Also: Ixokai ... Mail: me+list/python (AT) ixokai (DOT) io ... Blog: http://meh.ixokai.io/ * Some software has no copyright, such as SQLITE: it has been released into the public domain. But that is exceedingly rare, and can be a bit complicated as public domain and its meaning varies from jurisdiction to jurisdiction. Whereas copyright is pretty standard across the board and subject to a whole lot of international treaties. I'm really not sure you can legitimately call public domain software open source: its free to use, modify, and do anything you want with (provided you're in a jurisdiction which recognizes public domain), but it has its own particular legal ... issues. Then again, IANAL. -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 487 bytes Desc: OpenPGP digital signature URL: From rantingrick at gmail.com Thu Jan 27 00:11:28 2011 From: rantingrick at gmail.com (rantingrick) Date: Wed, 26 Jan 2011 21:11:28 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <8q7sgiF5tpU1@mid.individual.net> <19891784-d6a3-41ac-a097-5902a6323bc0@o21g2000prn.googlegroups.com> <0b12cdb1-45b4-41e4-9bdb-074ee669d76b@k14g2000pre.googlegroups.com> <7bb56aba-0f96-4b7e-a78d-3398003a0e38@c39g2000yqi.googlegroups.com> Message-ID: <2cb3435a-b489-40f5-8392-1edb47ff1311@o10g2000vbg.googlegroups.com> On Jan 26, 8:59?pm, alex23 wrote: > This is, what, the 3rd? 4th? year of his endless tirade > against TKinter. Alex, i have not been against Tkinter for 4 years. I just recently realized (about a year ago) the limitations of Tkinter and started thinking of alternatives. Tip of the day: Before misrepresenting someone's position and overshooting an estimate by three years, first make sure you've actually read most of what they have written. HTH From rantingrick at gmail.com Thu Jan 27 00:12:40 2011 From: rantingrick at gmail.com (rantingrick) Date: Wed, 26 Jan 2011 21:12:40 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com><63eea$4d3cd2fd$4275d90a$14984@FUSE.NET><69465430-08b3-4069-99c7-72f4d3034c66@s5g2000yqm.googlegroups.com><705ad$4d3ce0fc$4275d90a$29144@FUSE.NET> <2sm%o.8695$gM3.6118@viwinnwfe01.internal.bigpond.com> <0c3c61b0-d056-4757-b7e4-fecdf9a6e217@fm22g2000vbb.googlegroups.com> <94c48579-aed0-4987-aaa4-0f7b6209d9bb@8g2000prt.googlegroups.com> Message-ID: <704dd789-0eb2-4a33-9f2b-2363d3f5793f@s18g2000vbe.googlegroups.com> On Jan 26, 9:11?pm, alex23 wrote: > rantingrick wrote: > > Not if we used the underlying MS library! Windows has such a rich > > library why not use it? Why must we constantly re-invent the wheel? > > Isn't restricting a GUI toolkit to just one of the major OSes the > absolute opposite of 'accessible'? You'll need to read that snippet in context to understand what i was talking about. Again, see my "tip of the day" in my last post to you. From orasnita at gmail.com Thu Jan 27 02:02:41 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Thu, 27 Jan 2011 09:02:41 +0200 Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <8q7sgiF5tpU1@mid.individual.net> <19891784-d6a3-41ac-a097-5902a6323bc0@o21g2000prn.googlegroups.com><0b12cdb1-45b4-41e4-9bdb-074ee669d76b@k14g2000pre.googlegroups.com> <048FB74272D440A0915ABC7D76AE262B@teddy> <5782E9AD8A8342D691EB3549E5E0ED7B@octavian> Message-ID: <43549D4396F34EA697C45AA40EA12BC8@octavian> From: "Robert Kern" > in? Robin Dunn is the wxPython project lead. Ok, in this case I understand why WxPython can't be included in stdlib. I think there was a communication problem because the oldest list members start with the idea that all the list members know who is who and they may be thinking that I don't want to accept the reality or that I have bad feelings about some list members or something like that. > There is a large difference between the being "promoted by Python" and > being "included in Python's standard library. The latter is the issue at > hand, not the former. wxPython is already "promoted" by Python's > documentation: If there is a bigger chance that a beginner start using Tkinter without knowing its issues, this means that Python promotes the wrong tool. As I said, the main issue is not that Python doesn't promote WxPython. I have even suggested that Python might not include any GUI if this would be prefered, but what's wrong is that Python promotes a GUI which is not accessible by including it as a default GUI. As we all know, Python doesn't care too much about maintaining a backward compatibility and there are much many other things which are not compatible between different Python versions, but some Python programmers consider this a virtue because they say that what was wrong was eliminated. If they are right, then why wouldn't be a good idea to also remove a wrong GUI lib? Just because the majority prefers it? Octavian From orasnita at gmail.com Thu Jan 27 02:12:18 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Thu, 27 Jan 2011 09:12:18 +0200 Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com><9MB%o.14110$%64.6074@unlimited.newshosting.com> <59F6E65E3D9A46AD8D7A3863F3C1DC84@teddy> <27f53f8c-7862-4366-9352-82ae9a2f3970@k3g2000yqc.googlegroups.com> <718D13777F254C839F9564BC4275DE0A@octavian> <4D402C42.1030407@tysdomain.com> <4D40447C.4010108@tysdomain.com><33C68A0874BE4C66AB478EDFB64C2C1D@teddy> <4D407321.3090705@web.de> Message-ID: From: "Alexander Kapps" > Please don't use the lower Linux user percentage as an argument here. If > you follow that path further, you would need to agree that it's only an > "insignificant" percent of people who need a screen reader, so why bother? I didn't say that the Linux users or Mac users are not important. MFC or standard Win32 GUI is better accessible than wxWIDGETS but I considered that wxWIDGETS should be prefered (and not only Win32 controls) because it is *portable*, exactly because it also work on other platforms than Windows. But this doesn't mean that giving the most used screen reader as an example for testing the inaccessibility of Tk is not something that should be done (especially that Tk-based GUIS are inaccessible for other screen readers also.) Octavian From orasnita at gmail.com Thu Jan 27 02:14:17 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Thu, 27 Jan 2011 09:14:17 +0200 Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com><9MB%o.14110$%64.6074@unlimited.newshosting.com> <59F6E65E3D9A46AD8D7A3863F3C1DC84@teddy> <27f53f8c-7862-4366-9352-82ae9a2f3970@k3g2000yqc.googlegroups.com> <718D13777F254C839F9564BC4275DE0A@octavian> <4D402C42.1030407@tysdomain.com> <4D40447C.4010108@tysdomain.com><33C68A0874BE4C66AB478EDFB64C2C1D@teddy> <4D407333.1070301@tysdomain.com> Message-ID: <82865E7A54C048C398B4F4160FC43B57@octavian> From: "Littlefield, Tyler" > It doesn't support a good voice synthesizer like Eloquence or IBM Via > voice, but only eSpeak which sounds horrible, it doesn't have a scripting > language > ready to use as JAWS and Window Eyes do, it doesn't offer the possibility > of reading with the mouse cursor as JAWS does with its so called JAWS > cursor, > it offers a poor accessibility in many applications and many other issues. > > > You are wrong, on all accounts. I have specificly asked about these things on the NVDA mailing list at the end of the last year, and I have also tried NVDA and all those things are very true. Which are those "wrong" things? Octavian From orasnita at gmail.com Thu Jan 27 02:23:28 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Thu, 27 Jan 2011 09:23:28 +0200 Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com><9MB%o.14110$%64.6074@unlimited.newshosting.com><4A48EDF6D7634F2E994661A457451E87@teddy><753A4C5A6658470085804B13C80340F2@octavian> Message-ID: <1415933D9839404492EBA93213DD5F05@octavian> From: "geremy condra" The bottom line is that, yes, you do still have to convince people that accessibility is important if you want them to do anything about it. I have to do almost exactly the same thing in my field- everybody knows that security is important, but every time I go to disclose a vulnerability I have to be very careful if I want to convince the vendor to fix the problem. During those discussions, an ounce of civility is worth more than ten tons of righteousness, not only because it helps convince people to do what you want but because they frequently walk away from it feeling good about the experience and eager to not make the same mistake again. Yes you might be right. It is just my way of communicating and it might be too direct and some people might not like it. I always consider the expressions like "How do you do" as having absolutely no value, because they are just nice expressions made for easing the communication, but yes, most people seem to like them and don't like to discuss directly about the sensible problems. As the other list members have started thinking that I know who is who and they thought that I should understand why WxPython can't be included, I have made the same mistake by thinking that the others are really aware about the importance of accessibility. But you are right, this may be a mistake from my part too and I am sorry if I offended somebody. Octavian From orasnita at gmail.com Thu Jan 27 02:28:15 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Thu, 27 Jan 2011 09:28:15 +0200 Subject: WxPython versus Tkinter. References: <4D4093AF.80806@etrix.com.au> Message-ID: From: "Brendan Simon (eTRIX)" > Since it seems the python motto is "Batteries included", then it would > seem to me that wxPython is the natural fit as it also has "Batteries > included" (e.g. accessibility, native look-n-feel, mature and evolving, > can produce simple or complex gui programs, etc, etc). Yes Brendan, you are perfectly right, but unfortunately WxPython developers don't want to have it included in the stdlib. Finally I understood that this is the main problem, because if they would want to do it in the conditions imposed by Python, it would have been much easier and many of other problems could have been solved. But WxPython is their work and they decision is their. Octavian From orasnita at gmail.com Thu Jan 27 03:13:02 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Thu, 27 Jan 2011 10:13:02 +0200 Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com><9MB%o.14110$%64.6074@unlimited.newshosting.com><4A48EDF6D7634F2E994661A457451E87@teddy><753A4C5A6658470085804B13C80340F2@octavian> Message-ID: From: "Grant Edwards" > And, based on your behavior, you apparently don't like convincing > others or advancing the cause of accessibility. It seems you prefer to > annoy and alienate others. >From what I said, what was annoying? >> I don't want to convince anyone, but I just want to inform the others >> and let them know if they are doing something not recommended. > > IOW, you don't really care about increasing accessibility, you just > want to hear the sound of your own voice as you shout into the wind. Where have you seen that I don't care about accessibility? I say that I don't need to convince because today everyone should be convinced about accessibility, because we are talking with programmers here, not with cow-boys. >> but is that atitude worst than of those who don't care about >> discriminatory practices? > > Yes, it is worse. People who don't care are neither helping nor > hurting your cause. However, you're actively hurting it. I was talking *only* to those who care and I just informed them that Tkinter is not accessible. Was that so bad or so impolitely as you said? Do you think that there are so many those who don't care (even on this list) and I hurt them? Do you think that I should care about the feeling of those who don't care about the accessibility? Do you think that they have bigger problems than those who are hurt by lack of care? > People will not separate your personality from the cause you espouse. Wow! that's really bad. I thought that I might find here people that might have something against my opinions, that is very normal, that's why we are discussing, but I didn't think that I will also find people that will have something against me, just because of my opinions. I know people with different political opinions, with different programming languages preferences, that like other kind of women, that prefer other kkind of food, with whom I have often philosophical debates often, but whith whom I can be a good friend and collaborator and co-worker for some projects. > You may not like it, but that's a fact. If you are in favor of XYZ, > and act rude and insulting while espousing XYZ, people will react > against not only you but _also_ XYZ. I know what you are reffering to. :-) And I was hoping that there won't be people that don't like me personally for what I think about some things that have nothing related to them personally. But I don't say that you are wrong. After some reactions on the list I can say that you might be really right. Octavian From orasnita at gmail.com Thu Jan 27 03:17:36 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Thu, 27 Jan 2011 10:17:36 +0200 Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com><9MB%o.14110$%64.6074@unlimited.newshosting.com><4A48EDF6D7634F2E994661A457451E87@teddy><753A4C5A6658470085804B13C80340F2@octavian> <4D40A97F.8090209@tysdomain.com> Message-ID: <00ABBA322416409EB749102EB1CC5E61@octavian> From: "Littlefield, Tyler" > >I don't want to convince anyone, but I just want to inform the others > and let >them know if they are doing something not recommended. > not recommended by -you-, which is different than by a community or the > subset of people you are attempting to represent. furthermore, your > attidude is that of "comply to my definition of what is needed, or you are > selfish, rude, mean, cruel, etc." Then when that fails, you try cramming > words in people's mouth to make them feel like they kick puppies, and to > bring everyone else to this same conclusion. We are talking about accessibility here. Are you saying that Tkinter can be recommended from the perspective of accessibility? Octavian From steve+comp.lang.python at pearwood.info Thu Jan 27 04:03:29 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 27 Jan 2011 09:03:29 GMT Subject: use class factory to set required class variables? References: Message-ID: <4d4134e1$0$29983$c3e8da3$5496439d@news.astraweb.com> On Wed, 26 Jan 2011 13:37:20 -0800, Alan wrote: > I have a class ``A`` that is intentionally incomplete: it has methods > that refer to class variables that do not exist. For the record, in Python it is usual to refer to "attributes" rather than "class variables" and "instance variables". In Python, classes are first-class objects (pun not intended) like ints, strings, floats etc., and so a "class variable" would be a variable holding a class, just as a string variable would be a variable holding a string, an int variable holds an int, etc. > The class ``A`` has > several complicated methods, a number of which reference the "missing" > class variables. Obviously, I do not directly use ``A``. This is called an abstract class -- you need to subclass it to use it. > I have a class factory ``f``` that subclasses ``A`` *only* in order to > define the class variables. > > The motivation/problem: > I did this because I need many versions of class ``A``, which differ > only in the class variables, which are not known until run time. > > Q: On the face of it, did I pick a reasonable solution to my problem? > If so is this a standard pattern? If not, can you mention a better > approach? You have a class factory which subclasses an abstract class. Seems perfectly reasonable to me. More than reasonable -- it sounds like a *good* way of dealing with the problem. -- Steven From alice at gothcandy.com Thu Jan 27 04:04:07 2011 From: alice at gothcandy.com (=?utf-8?Q?Alice_Bevan=E2=80=93McGregor?=) Date: Thu, 27 Jan 2011 01:04:07 -0800 Subject: how to read the last line of a huge file??? References: Message-ID: On 2011-01-26 02:59:26 -0800, Xavier Heruacles said: > I have do some log processing which is usually huge. The length of each > line is variable. How can I get the last line?? Don't tell me to use > readlines or something like linecache... This is not optimum or efficient, but it works! If you want to see what's going on, use 4 instead of 4096 and 8 instead of 8192 and add a print statement to the bottom of the while loop. :) import os with open('biglogfile.log', 'r') as fh: fh.seek(-4096, os.SEEK_END) buffer = fh.read(4096) # We are expecting a trailing newline. while "\n" not in buffer[:-1]: fh.seek(-8192, os.SEEK_CUR) buffer = fh.read(4096) + buffer # Eliminate empty lines, they aren't useful. lines = [line for line in buffer.split('\n') if line] print lines[-1] ? Alice. :) From list at qtrac.plus.com Thu Jan 27 05:06:53 2011 From: list at qtrac.plus.com (Mark Summerfield) Date: Thu, 27 Jan 2011 02:06:53 -0800 (PST) Subject: Decorator question References: <5c4ce9cb-c68d-457e-ad63-c320f3a46224@p7g2000prb.googlegroups.com> Message-ID: <0e8f26be-eb7b-414b-8fa3-e639c7943ba4@m20g2000prc.googlegroups.com> On Jan 27, 2:42?am, "Thomas L. Shinnick" wrote: > At 08:17 PM 1/26/2011, Chris wrote: > > >I have a class (A, for instance) that possesses a boolean (A.b, for > >instance) that is liable to change over an instance's lifetime. > > >Many of the methods of this class (A.foo, for instance) should not > >execute as long as this boolean is false, but should instead raise an > >exception. > > >Can I use a decorator to implement this functionality? ?More exactly, > >could I define a function called 'checker' that accomplishes this: > > Mark Summerfield's book "Programming in Python 3" has an example > something like this (p.357) called 'positive_result'. ? I hesitate to > quote the entire thing, so I'll quote only the inner 'half' of the decorator: > ? ? ? ? ?def wrapper(*args, **kwargs): > ? ? ? ? ? ? ?result = function(*args, **kwargs) > ? ? ? ? ? ? ?assert result >= 0, function.__name__ + "() result isn't >= 0" > ? ? ? ? ? ? ?return result > > I would guess you would have to count on the first item in the > methods' args to be self, and use that to test whether your attribute > is false/true? > > Mark? > > >def checker(f): > > ? ? ... > > >class A(): > > > ? ? b = True > > > ? ? @checker > > ? ? def foo(self,...): > > ? ? ? ? print 'in foo' > > >a = A() > >a.foo() > >a.b = False > >a.foo() > > >would result in: > > >'in foo' > >Exception: ... > > >This exact solution isn't necessary, just something that doesn't > >require me to have the clunky: > > >def foo(self,...): > > ? ? if self.b: > > ? ? ? ? ... > > ? ? else: raise Exception('b attribute must be true before executing > >this method') > > >in every method. > > >Thanks, > > >Chris Here's a simple example that I think does what you're after: ########################################## #!/usr/bin/env python3 import functools def execute_if_valid(function): @functools.wraps(function) def wrapper(*args, **kwargs): if not args[0].valid: raise Exception("invalid instance") return function(*args, **kwargs) return wrapper class A: valid = True def foo(self): print("called foo() on a valid or invalid instance") @execute_if_valid def bar(self): print("called bar() on a valid instance") a = A() a.foo() a.bar() a.valid = False a.foo() a.bar() ########################################## Here's its output: ########################################## called foo() on a valid or invalid instance called bar() on a valid instance called foo() on a valid or invalid instance Traceback (most recent call last): File "./test.py", line 32, in a.bar() File "./test.py", line 10, in wrapper raise Exception("invalid instance") Exception: invalid instance ########################################## From jeanmichel at sequans.com Thu Jan 27 05:15:37 2011 From: jeanmichel at sequans.com (Jean-Michel Pichavant) Date: Thu, 27 Jan 2011 11:15:37 +0100 Subject: use class factory to set required class variables? In-Reply-To: References: Message-ID: <4D4145C9.6060106@sequans.com> Alan wrote: > I have a class ``A`` that is intentionally incomplete: > it has methods that refer to class variables that do not exist. > The class ``A`` has several complicated methods, a number > of which reference the "missing" class variables. > Obviously, I do not directly use ``A``. > > I have a class factory ``f``` that subclasses ``A`` *only* in > order to define the class variables. > > The motivation/problem: > I did this because I need many versions of class ``A``, > which differ only in the class variables, which are not > known until run time. > > Q: On the face of it, did I pick a reasonable solution to > my problem? If so is this a standard pattern? If not, > can you mention a better approach? > > My solution is working for me, but the class ``A`` > is bugging me, because of the odd (to me) way in > which it is incomplete. Obviously, I'm not a > computer science type ... > > Thanks, > Alan Isaac > > Your design is perfectly fine. A is an abstract class, aka interface class. This is a very common pattern, that can solve many problems. However, and this is a personal advice, try to declare all the required attributes/methods in the abstract class, setting them to None or raising a NotImplementedError. That would help anyone, including you, to know what is required to define when subclassing A. class A: A_VALUE = None def aMethod(self): raise NotImplementedError() FYI, there is a python module that provide some feature to enhance your abstract classes: http://docs.python.org/library/abc.html. These are more advanced features, you may just ignore that module for now. JM From g.rodola at gmail.com Thu Jan 27 05:35:41 2011 From: g.rodola at gmail.com (=?ISO-8859-1?Q?Giampaolo_Rodol=E0?=) Date: Thu, 27 Jan 2011 11:35:41 +0100 Subject: WxPython versus Tkinter. In-Reply-To: <4D4093AF.80806@etrix.com.au> References: <4D4093AF.80806@etrix.com.au> Message-ID: wxPython is not suitable for inclusion for many reasons. One reason is that it is a *huge* library which requires a lot of constant work (bugfixing, documentation, lots of commits, etc...) which cannot weight on python development. Keeping the two worlds separated is better for both of them, especially for wxPython which doesn't have to follow the strict politics surrounding the python stdlib. For example, wxPython is free to break some API backward compatibility on every new major version if this is desired. Such a thing couldn't happen if it were in the stdlib for obvious reasons. --- Giampaolo http://code.google.com/p/pyftpdlib/ http://code.google.com/p/psutil/ 2011/1/26 Brendan Simon (eTRIX) : > Since it seems the python motto is "Batteries included", then it would seem > to me that wxPython is the natural fit as it also has "Batteries included" > (e.g. accessibility, native look-n-feel, mature and evolving, can produce > simple or complex gui programs, etc, etc). > > -- > Brendan Simon > www.etrix.com.au > > -- > http://mail.python.org/mailman/listinfo/python-list > From jeanmichel at sequans.com Thu Jan 27 05:44:03 2011 From: jeanmichel at sequans.com (Jean-Michel Pichavant) Date: Thu, 27 Jan 2011 11:44:03 +0100 Subject: Executing multiple subprocesses and waiting In-Reply-To: <106dca00-5ad8-4f10-af99-01525e72f9fb@z26g2000prf.googlegroups.com> References: <106dca00-5ad8-4f10-af99-01525e72f9fb@z26g2000prf.googlegroups.com> Message-ID: <4D414C73.9000503@sequans.com> JB wrote: > One of my python scripts that takes a bunch of inputs from a tKinter > gui, generates a set of command line stings, and then threads them off > to subprocess for calls to other programs like Nuke and our render > farm has recently started randomly crashing pythonw.exe. > > I'm taking a look at my threading setup and attempting to clean it up. > I was wondering what a smart way of doing what I describe is? Take a > list of strings containing command line calls to other programs, > process them one at a time (waiting for the previous one to complete > before starting the next) and then finishing elegantly. Currently, the > gui passes them all to a "workerThread" which loops through each > string, sending it to a "processThread" which makes a call to > subprocess to execute it. > > This has worked fine for over a year so the recent crashing is > mystifying me. I'm wondering if it's increased network stress (we've > grown) or something similar? > > Any thoughts and suggestions on waiting for threads to complete are > appreciated. > Google 'Python execnet'. The main purpose of this module is to execute jobs on a bunch of different machines. However by simply declaring your local as unique available gateway, execnet will take care of queueing the jobs on your local. Look for examples with 'Popen' type gateways. I love this module, (and any other that are doing the network stuff for you). JM From python at bdurham.com Thu Jan 27 06:33:27 2011 From: python at bdurham.com (python at bdurham.com) Date: Thu, 27 Jan 2011 06:33:27 -0500 Subject: WxPython versus Tkinter. In-Reply-To: References: <4D3E4377.3060807@tysdomain.com><9MB%o.14110$%64.6074@unlimited.newshosting.com> <59F6E65E3D9A46AD8D7A3863F3C1DC84@teddy> <27f53f8c-7862-4366-9352-82ae9a2f3970@k3g2000yqc.googlegroups.com> <718D13777F254C839F9564BC4275DE0A@octavian> <4D402C42.1030407@tysdomain.com> <4D40447C.4010108@tysdomain.com><33C68A0874BE4C66AB478EDFB64C2C1D@teddy><4D407321.3090705@web.de> Message-ID: <1296128007.17192.1417506961@webmail.messagingengine.com> Octavian, If I understand your message, you are frustrated with Tkinter because it doesn't support accessability. In several messages on this thread I pointed out that Tkinter can easily be made accessable under Linux and Mac OS X. Rather than throw out Tkinter entirely, why not work with the community to make Tkinter accessable under Windows. That sounds a lot easier than trying to fight for wxWidgets as a Tkinter replacement when so many good arguments have been made against this strategy. Malcolm From subscriptions at cagttraining.com Thu Jan 27 06:45:25 2011 From: subscriptions at cagttraining.com (Bill Felton) Date: Thu, 27 Jan 2011 06:45:25 -0500 Subject: use class factory to set required class variables? In-Reply-To: <4d4134e1$0$29983$c3e8da3$5496439d@news.astraweb.com> References: <4d4134e1$0$29983$c3e8da3$5496439d@news.astraweb.com> Message-ID: <5EFD8083-E2CE-4331-96CD-08C6A2C08CF7@cagttraining.com> On Jan 27, 2011, at 4:03 AM, Steven D'Aprano wrote: > On Wed, 26 Jan 2011 13:37:20 -0800, Alan wrote: > >> I have a class ``A`` that is intentionally incomplete: it has methods >> that refer to class variables that do not exist. > > For the record, in Python it is usual to refer to "attributes" rather > than "class variables" and "instance variables". In Python, classes are > first-class objects (pun not intended) like ints, strings, floats etc., > and so a "class variable" would be a variable holding a class, just as a > string variable would be a variable holding a string, an int variable > holds an int, etc. > Being nit-picky, this is a slightly flawed justification of the terminology. In Smalltalk, classes are first class objects (pun similarly not intended). Yet in Smalltalk we refer to class variables and instance variables. These are not necessarily variables that 'hold' classes. In fact, all classes are instances, and so all variables hold instances... So there's something not quite right about your 'first class objects ... so ... would be a ...'. This may well be a standard Python convention, and it is certainly not objectionable. But it isn't well-justified on the basis of the 'first-class-ness' of classes as objects... Best regards, Bill From ahsanbagwan at gmail.com Thu Jan 27 07:10:00 2011 From: ahsanbagwan at gmail.com (sl33k_) Date: Thu, 27 Jan 2011 04:10:00 -0800 (PST) Subject: Wrappers in python Message-ID: <2100032d-dd99-4b10-b445-76b5dd1efb91@r19g2000prm.googlegroups.com> What are wrappers? What entities do they wrap around? Struggling to understand the concept. From orasnita at gmail.com Thu Jan 27 07:21:06 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Thu, 27 Jan 2011 14:21:06 +0200 Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com><9MB%o.14110$%64.6074@unlimited.newshosting.com> <59F6E65E3D9A46AD8D7A3863F3C1DC84@teddy> <27f53f8c-7862-4366-9352-82ae9a2f3970@k3g2000yqc.googlegroups.com> <718D13777F254C839F9564BC4275DE0A@octavian> <4D402C42.1030407@tysdomain.com> <4D40447C.4010108@tysdomain.com><33C68A0874BE4C66AB478EDFB64C2C1D@teddy><4D407321.3090705@web.de> <1296128007.17192.1417506961@webmail.messagingengine.com> Message-ID: <1E1D9F437DC4497BAB23BFC5F4ED8DAF@octavian> From: > Octavian, > > If I understand your message, you are frustrated with Tkinter because it > doesn't support accessability. > > In several messages on this thread I pointed out that Tkinter can easily > be made accessable under Linux and Mac OS X. > > Rather than throw out Tkinter entirely, why not work with the community > to make Tkinter accessable under Windows. I am willing to help, but unfortunately I don't know neither TCL or C nor the technical details about the accessibility standards that need to be implemented. I am mainly a web/CLI programmer. I know Perl very well and I just started to also learn Python especially because Python is a little better than Perl for creating desktop apps for Windows. In these conditions, if I could be of any help, I am willing to contribute, but to be sincere I don't think that I would be a great help. If someone knows more about this field and thinks that I could be helpful however, I'd like to know. Octavian From jeanmichel at sequans.com Thu Jan 27 07:57:20 2011 From: jeanmichel at sequans.com (Jean-Michel Pichavant) Date: Thu, 27 Jan 2011 13:57:20 +0100 Subject: Wrappers in python In-Reply-To: <2100032d-dd99-4b10-b445-76b5dd1efb91@r19g2000prm.googlegroups.com> References: <2100032d-dd99-4b10-b445-76b5dd1efb91@r19g2000prm.googlegroups.com> Message-ID: <4D416BB0.4010405@sequans.com> sl33k_ wrote: > What are wrappers? > > What entities do they wrap around? > > Struggling to understand the concept. > We would need a little bit of a context to answer that question, you could be refering to differents things. I'll give it a try on one common usage for wrapper: A wrapper is a python module that interface between python and a 3rd party library offering a non python interface. Consider Google chart api. This is the native URL API: https://chart.googleapis.com/chart?cht=p3&chd=t:60,40&chs=250x100&chl=Hello|World pygooglechart is the python wrapper for that api, allowing you to get the same effect, using Python objects: from pygooglechart import PieChart3D # Create a chart object of 250x100 pixels chart = PieChart3D(250, 100) # Add some data chart.add_data([20, 10]) # Assign the labels to the pie data chart.set_pie_labels(['Hello', 'World']) # Print the chart URL print chart.get_url() Python wrapper allows users to write only python code, even when calling non python 3rd libraries. Another example of wrapper is pgdb. It allows you to interface with a postgreSQL database without knowing about the native interface, you can commit and fetch data from the database by writing python code only. Nice ! JM From roy at panix.com Thu Jan 27 08:55:21 2011 From: roy at panix.com (Roy Smith) Date: Thu, 27 Jan 2011 08:55:21 -0500 Subject: how to read the last line of a huge file??? References: Message-ID: In article , Alice Bevan???McGregor wrote: > On 2011-01-26 02:59:26 -0800, Xavier Heruacles said: > > > I have do some log processing which is usually huge. The length of each > > line is variable. How can I get the last line?? Don't tell me to use > > readlines or something like linecache... > > This is not optimum or efficient, but it works! If you want to see > what's going on, use 4 instead of 4096 and 8 instead of 8192 and add a > print statement to the bottom of the while loop. :) > > import os > > with open('biglogfile.log', 'r') as fh: > fh.seek(-4096, os.SEEK_END) > buffer = fh.read(4096) > > # We are expecting a trailing newline. > while "\n" not in buffer[:-1]: > fh.seek(-8192, os.SEEK_CUR) > buffer = fh.read(4096) + buffer > > # Eliminate empty lines, they aren't useful. > lines = [line for line in buffer.split('\n') if line] > print lines[-1] > > ??? Alice. :) Back in the old days, if you wanted to read a file backwards, you just used a tape drive that had read-reverse capability :-) From tyler at tysdomain.com Thu Jan 27 09:20:47 2011 From: tyler at tysdomain.com (Littlefield, Tyler) Date: Thu, 27 Jan 2011 07:20:47 -0700 Subject: WxPython versus Tkinter. Message-ID: <4D417F3F.8090101@tysdomain.com> >but what's wrong is that Python promotes a GUI which is not accessible by including it as a default GUI. You seem to have overlooked this multiple times and instead decided to shove words in my mouth and continue on your line of selfishness which is justified apparently now by the fact that you are ESL. I have mentioned many, many times that we work to make TKInter accessible; it is something I plan to start working on this weekend. But rather than that, you seem to still want to switch gui libraries in python, which I might add, will not happen over night, nor will the accessibilifying (my new word) TKInter. It's a process that will take time. So, I ask since you keep jumping around this point, what is wrong with fixing TKInter? -- Thanks, Ty From tyler at tysdomain.com Thu Jan 27 09:21:18 2011 From: tyler at tysdomain.com (Littlefield, Tyler) Date: Thu, 27 Jan 2011 07:21:18 -0700 Subject: WxPython versus Tkinter. Message-ID: <4D417F5E.9090203@tysdomain.com> Eloq is an add-on, but it does support it. >but only eSpeak which sounds horrible That's your personal preference. Plenty use and like ESpeak. >it doesn't have a scripting language ready to use as JAWS and Window Eyes do, Scripting is done in Python, (no, not some native scripting language), and are done as modules. You write your script in python, and off you go. Problem solved. >it doesn't offer the possibility of reading with the mouse cursor as JAWS does with its so called JAWS cursor, It's called flat review. Googling this term brings up a key reference at like the third or fourth result down. >it offers a poor accessibility in many applications Very very very wrong. It works better with some apps than Jaws does, and about as good in many others. NVDA (like all other readers, and any program for that matter) still does have problems, but none that you mentioned. >and many other issues. -other- says that there were issues to begin with; the only issue here is you promoting the most "widely used screen reader," because it's what you use, and you not being able to use google and do your homework before you start talking about products you know nothing of. -- Thanks, Ty From k.bx at ya.ru Thu Jan 27 09:25:03 2011 From: k.bx at ya.ru (kost BebiX) Date: Thu, 27 Jan 2011 16:25:03 +0200 Subject: how to read the last line of a huge file??? In-Reply-To: References: Message-ID: <125461296138303@web109.yandex.ru> 27.01.2011, 15:55, "Roy Smith" : > In article ;, > ?Alice Bevan?McGregor ; wrote: > >> ?On 2011-01-26 02:59:26 -0800, Xavier Heruacles said: >>> ?I have do some log processing which is usually huge. The length of each >>> ?line is variable. How can I get the last line?? Don't tell me to use >>> ?readlines or something like linecache... >> ?This is not optimum or efficient, but it works! ?If you want to see >> ?what's going on, use 4 instead of 4096 and 8 instead of 8192 and add a >> ?print statement to the bottom of the while loop. ?:) >> >> ?import os >> >> ?with open('biglogfile.log', 'r') as fh: >> ?????fh.seek(-4096, os.SEEK_END) >> ?????buffer = fh.read(4096) >> >> ?????# We are expecting a trailing newline. >> ?????while "\n" not in buffer[:-1]: >> ?????????fh.seek(-8192, os.SEEK_CUR) >> ?????????buffer = fh.read(4096) + buffer >> >> ?????# Eliminate empty lines, they aren't useful. >> ?????lines = [line for line in buffer.split('\n') if line] >> ?????print lines[-1] >> >> ?????????? Alice. ?:) > > Back in the old days, if you wanted to read a file backwards, you just > used a tape drive that had read-reverse capability :-) > > -- > http://mail.python.org/mailman/listinfo/python-list Yeah. And if you wanted to zoom image -- you just had to go couple steps closer to it) -- jabber: k.bx at ya.ru From tyler at tysdomain.com Thu Jan 27 09:25:24 2011 From: tyler at tysdomain.com (Littlefield, Tyler) Date: Thu, 27 Jan 2011 07:25:24 -0700 Subject: WxPython versus Tkinter. In-Reply-To: <00ABBA322416409EB749102EB1CC5E61@octavian> References: <4D3E4377.3060807@tysdomain.com><9MB%o.14110$%64.6074@unlimited.newshosting.com><4A48EDF6D7634F2E994661A457451E87@teddy><753A4C5A6658470085804B13C80340F2@octavian> <4D40A97F.8090209@tysdomain.com> <00ABBA322416409EB749102EB1CC5E61@octavian> Message-ID: <4D418054.8050002@tysdomain.com> >We are talking about accessibility here. Are you saying that Tkinter can be >recommended from the perspective of accessibility? See my comment about shoving words in people's mouths; I did not hint, nor did I come near saying that in that message. On 1/27/2011 1:17 AM, Octavian Rasnita wrote: > From: "Littlefield, Tyler" >> >I don't want to convince anyone, but I just want to inform the others >> and let >them know if they are doing something not recommended. >> not recommended by -you-, which is different than by a community or >> the subset of people you are attempting to represent. furthermore, >> your attidude is that of "comply to my definition of what is needed, >> or you are selfish, rude, mean, cruel, etc." Then when that fails, >> you try cramming words in people's mouth to make them feel like they >> kick puppies, and to bring everyone else to this same conclusion. > > > We are talking about accessibility here. Are you saying that Tkinter > can be recommended from the perspective of accessibility? > > Octavian > -- Thanks, Ty From philip at semanchuk.com Thu Jan 27 09:39:41 2011 From: philip at semanchuk.com (Philip Semanchuk) Date: Thu, 27 Jan 2011 09:39:41 -0500 Subject: help with multiprocessing pool In-Reply-To: References: Message-ID: <2A124DD5-95F2-4DE0-AB0F-5D3EA39A230B@semanchuk.com> On Jan 25, 2011, at 8:19 PM, Craig Yoshioka wrote: > Hi all, > > I could really use some help with a problem I'm having. Hiya Craig, I don't know if I can help, but it's really difficult to do without a full working example. Also, your code has several OS X-isms in it so I guess that's the platform you're on. But in case you're on Windows, note that that platform requires some extra care when using multiprocessing: http://docs.python.org/library/multiprocessing.html#windows Good luck Philip > I wrote a function that can take a pattern of actions and it apply it to the filesystem. > It takes a list of starting paths, and a pattern like this: > > pattern = { > InGlob('Test/**'):{ > MatchRemove('DS_Store'):[], > NoMatchAdd('(alhpaID_)|(DS_Store)','warnings'):[], > MatchAdd('alphaID_','alpha_found'):[], > InDir('alphaID_'):{ > NoMatchAdd('(betaID_)|(DS_Store)','warnings'):[], > InDir('betaID_'):{ > NoMatchAdd('(gammaID_)|(DS_Store)','warnings'):[], > MatchAdd('gammaID_','gamma_found'):[] }}}} > > so if you run evalFSPattern(['Volumes/**'],pattern) it'll return a dictionary where: > > dict['gamma_found'] = [list of paths that matched] (i.e. '/Volumes/HD1/Test/alphaID_3382/betaID_38824/gammaID_848384') > dict['warning'] = [list of paths that failed to match] (ie. '/Volumes/HD1/Test/alphaID_3382/gammaID_47383') > > Since some of these volumes are on network shares I also wanted to parallelize this so that it would not block on IO. I started the parallelization by using multiprocessing.Pool and got it to work if I ran the fsparser from the interpreter. It ran in *much* less time and produced correct output that matched the non-parallelized version. The problem begins if I then try to use the parallelized function from within the code. > > For example I wrote a class whose instances are created around valid FS paths, that are cached to reduce expensive FS lookups. > > class Experiment(object): > > SlidePaths = None > > @classmethod > def getSlidePaths(cls): > if cls.SlidePaths == None: > cls.SlidePaths = fsparser(['/Volumes/**'],pattern) > return cls.SlidePaths > > @classmethod > def lookupPathWithGammaID(cls,id): > paths = cls.getSlidePaths() > ... > return paths[selected] > > @classmethod > def fromGamaID(cls,id): > path = cls.lookupPathWithGammaID(id) > return cls(path) > > def __init__(self,path) > self.Path = path > ... > > ... > > If I do the following from the interpreter it works: > >>>> from experiment import Experiment >>>> expt = Experiment.fromGammaID(10102) > > but if I write a script called test.py: > > from experiment import Experiment > expt1 = Experiment.fromGammaID(10102) > expt2 = Experiment.fromGammaID(10103) > comparison = expt1.compareTo(expt2) > > it fails, if I try to import it or run it from bash prompt: > >>>> from test import comparison (hangs forever) > $ python test.py (hangs forever) > > I would really like some help trying to figure this out... I thought it should work easily since all the spawned processes don't share data or state (their results are merged in the main thread). The classes used in the pattern are also simple python objects (use python primitives). > > > These are the main functions: > > def mapAction(pool,paths,action): > merge = {'next':[]} > for result in pool.map(action,paths): > if result == None: > continue > merge = mergeDicts(merge,result) > return merge > > > def mergeDicts(d1,d2): > for key in d2: > if key not in d1: > d1[key] = d2[key] > else: > d1[key] += d2[key] > return d1 > > > def evalFSPattern(paths,pattern): > pool = Pool(10) > results = {} > for action in pattern: > tomerge1 = mapAction(pool,paths,action) > tomerge2 = evalFSPattern(tomerge1['next'],pattern[action]) > del tomerge1['next'] > results = mergeDicts(results,tomerge1) > results = mergeDicts(results,tomerge2) > return results > > the classes used in the pattern (InGlob,NoMatchAdd,etc.) are callable classes that take a single parameter (a path) and return a dict result or None which makes them trivial to adapt to Pool.map. > > Note if I change the mapAction function to: > > def mapAction(pool,paths,action): > merge = {'next':[]} > for path in paths: > result = action(path) > if result == None: > continue > merge = mergeDicts(merge,result) > return merge > > everything works just fine. > > > Thanks. > > > -- > http://mail.python.org/mailman/listinfo/python-list From emile at fenx.com Thu Jan 27 09:51:37 2011 From: emile at fenx.com (Emile van Sebille) Date: Thu, 27 Jan 2011 06:51:37 -0800 Subject: WxPython versus Tkinter. In-Reply-To: <43549D4396F34EA697C45AA40EA12BC8@octavian> References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <8q7sgiF5tpU1@mid.individual.net> <19891784-d6a3-41ac-a097-5902a6323bc0@o21g2000prn.googlegroups.com><0b12cdb1-45b4-41e4-9bdb-074ee669d76b@k14g2000pre.googlegroups.com> <048FB74272D440A0915ABC7D76AE262B@teddy> <5782E9AD8A8342D691EB3549E5E0ED7B@octavian> <43549D4396F34EA697C45AA40EA12BC8@octavian> Message-ID: On 1/26/2011 11:02 PM Octavian Rasnita said... > As we all know, Python doesn't care too much about maintaining a > backward compatibility Where'd you get this idea? Between v2 and v3 yes, that was the intent. But otherwise, I think there's another miscommunication behind this... See http://www.python.org/dev/peps/pep-0291/ Emile From bhell at spamfence.net Thu Jan 27 10:12:17 2011 From: bhell at spamfence.net (Benjamin Hell) Date: Thu, 27 Jan 2011 16:12:17 +0100 Subject: Which is the best book to learn python In-Reply-To: <53fd6f58-594e-48de-bc19-1408b4dcb580@29g2000prb.googlegroups.com> References: <188c0a9f-4e93-4fae-b3f9-e7c84f8030fd@v31g2000pri.googlegroups.com> <53fd6f58-594e-48de-bc19-1408b4dcb580@29g2000prb.googlegroups.com> Message-ID: <8qdgahFvmvU1@mid.individual.net> On 2011-01-26 01:43 , Luis M. Gonz?lez wrote: > On Jan 24, 2:09 pm, santosh hs wrote: >> i am beginner to python please tell me which is the best available >> reference for beginner to start from novice > > If you are a complete beginner to programming, I suggest start with a > tutorial such as "A Byte of Python" (google this). > I learned my first steps with Josh Cogliati's "Non-Programmers > Tutorial For Python" http://www.oopweb.com/Python/Documents/easytut/VolumeFrames.html Josh moved this tutorial to Wikibooks some years ago, where it has been improved since then. Today there are two versions, one for Python 2.x and one for Python 3: http://en.wikibooks.org/wiki/Non-Programmer's_Tutorial_for_Python_2.6 http://en.wikibooks.org/wiki/Non-Programmer's_Tutorial_for_Python_3 I have used it to introduce people to programming with very good results. If you want to get the maximum out of Lutz & Asher's "Learning Python", which is a very good book as well, you should have programmed in some way before. Ben From lukin.s.v at gmail.com Thu Jan 27 10:49:45 2011 From: lukin.s.v at gmail.com (Sergey Lukin) Date: Thu, 27 Jan 2011 16:49:45 +0100 Subject: Pickling/Unpickling python Exceptions Message-ID: Hi all, I'm migrating code from python 2.4 to python 2.6 and I've got into troubles with pickling/unpickling python Exceptions. The following code works fine in 2.4 but not in 2.6. See Exception1 example I have found on python mail list similar problem http://mail.python.org/pipermail/python-list/2009-December/1228773.html They recommend to use __reduce__. But this does not help as I'm getting different Exception class after pickle See Exception_with_reduce example I also have found possible solution to this problem here http://bugs.python.org/issue1692335 As a workaround they propose to pass Exception arguments into base class See Exception2 example But there is another problem. Constructor is called 2 times which is not acceptable to me. Could you please advice on the solution? ------------------------------------------ test program ------------------------------------------ import cPickle class Exception1(Exception): def __init__(self,arg1): print "constructor called" Exception.__init__(self) class Exception2(Exception): def __init__(self,arg1): print "constructor called" Exception.__init__(self,arg1) class Exception_with_reduce(Exception): def __reduce__(self): try: getnewargs = self.__getnewargs__ except AttributeError: newargs = (self.__class__,) else: newargs = (self.__class__,) + getnewargs() try: getstate = self.__getstate__ except AttributeError: state = self.__dict__ else: state = getstate() return (Exception, newargs, state) def __init__(self,arg1): print "constructor called" Exception.__init__(self,arg1) def test(E,args): try: print ">>",E.__name__ e = E(*args) print "- pickling" s = cPickle.dumps(e) print "- unpickling" e = cPickle.loads(s) if E != e.__class__: print "! failed: expected %s, got %s"%(E.__name__,e.__class__.__name__) except Exception, e: print "! failed:",e print "\ finished" print import os if os.path.isfile("/home/ast1/blabla"): try: s = open("/home/ast1/blabla","r").read() e = cPickle.loads(s) print e.__class__ except Exception, e: print "error:",e test(Exception1,[1]) test(Exception2,[1]) test(Exception_with_reduce,[1]) ------------------------------------------ ------------------------------------------ run results on python 2.6: ------------------------------------------ constructor called >> Exception1 constructor called - pickling - unpickling ! failed: ('__init__() takes exactly 2 arguments (1 given)', , ()) \ finished >> Exception2 constructor called - pickling - unpickling constructor called \ finished >> Exception_with_reduce constructor called - pickling - unpickling ! failed: expected Exception_with_reduce, got Exception \ finished ------------------------------------------ run results on python 2.4: ------------------------------------------ __main__.Exception2 >> Exception1 constructor called - pickling - unpickling \ finished >> Exception2 constructor called - pickling - unpickling \ finished >> Exception_with_reduce constructor called - pickling - unpickling \ finished -------------- next part -------------- An HTML attachment was scrubbed... URL: From orasnita at gmail.com Thu Jan 27 11:12:52 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Thu, 27 Jan 2011 18:12:52 +0200 Subject: WxPython versus Tkinter. References: <4D417F3F.8090101@tysdomain.com> Message-ID: From: "Littlefield, Tyler" > >but what's wrong is that Python promotes a GUI which is not accessible > by including it as a default GUI. > You seem to have overlooked this multiple times and instead decided to > shove words in my mouth and continue on your line of selfishness which > is justified apparently now by the fact that you are ESL. I have > mentioned many, many times that we work to make TKInter accessible; it > is something I plan to start working on this weekend. But rather than > that, you seem to still want to switch gui libraries in python, which I > might add, will not happen over night, nor will the accessibilifying (my > new word) TKInter. It's a process that will take time. So, I ask since > you keep jumping around this point, what is wrong with fixing TKInter? Hi Tyler, Nothing is wrong with adding accessibility to Tkinter. It is really great. What's wrong is that it is not available now and I believe only what I can see, because only what can be used now can be helpful. If Tkinter will be accessible in the future it will be very great, but it will be only in that moment. It is not now. Now we have just your promise that you will try to make Tk accessible but I think that you agree that for the moment this has no value for those who need accessibility. Octavian From me+list/python at ixokai.io Thu Jan 27 11:59:24 2011 From: me+list/python at ixokai.io (Stephen Hansen) Date: Thu, 27 Jan 2011 08:59:24 -0800 Subject: WxPython versus Tkinter. In-Reply-To: <43549D4396F34EA697C45AA40EA12BC8@octavian> References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <8q7sgiF5tpU1@mid.individual.net> <19891784-d6a3-41ac-a097-5902a6323bc0@o21g2000prn.googlegroups.com><0b12cdb1-45b4-41e4-9bdb-074ee669d76b@k14g2000pre.googlegroups.com> <048FB74272D440A0915ABC7D76AE262B@teddy> <5782E9AD8A8342D691EB3549E5E0ED7B@octavian> <43549D4396F34EA697C45AA40EA12BC8@octavian> Message-ID: <4D41A46C.8000308@ixokai.io> On 1/26/11 11:02 PM, Octavian Rasnita wrote: > As we all know, Python doesn't care too much about maintaining a > backward compatibility What? Nonsense. There are strict compatibility requirements. There was a one-time break with these; 2.x->3.x -- but that's it. It may never happen again. If another happens, its years down the road. If ever. -- Stephen Hansen ... Also: Ixokai ... Mail: me+list/python (AT) ixokai (DOT) io ... Blog: http://meh.ixokai.io/ -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 487 bytes Desc: OpenPGP digital signature URL: From ethan at stoneleaf.us Thu Jan 27 12:16:04 2011 From: ethan at stoneleaf.us (Ethan Furman) Date: Thu, 27 Jan 2011 09:16:04 -0800 Subject: WxPython versus Tkinter. In-Reply-To: <9a799be3-e4d9-4f64-9bf9-194eca79256f@r5g2000yql.googlegroups.com> References: <4D3E4377.3060807@tysdomain.com> <9MB%o.14110$%64.6074@unlimited.newshosting.com> <4A48EDF6D7634F2E994661A457451E87@teddy> <753A4C5A6658470085804B13C80340F2@octavian> <9a799be3-e4d9-4f64-9bf9-194eca79256f@r5g2000yql.googlegroups.com> Message-ID: <4D41A854.8090500@stoneleaf.us> On Jan 27, 3:35 am, rantingrick wrote: > A certain small subset of any group will always be emotionally driven. > However we should not concern ourselves with this sort of non- > objectivity. So, would this be like when rr disqualified himself by demanding posters have at least a 120 IQ? ;) ~Ethan~ From santosh.tronics at gmail.com Thu Jan 27 12:20:18 2011 From: santosh.tronics at gmail.com (santosh hs) Date: Thu, 27 Jan 2011 22:50:18 +0530 Subject: Which is the best book to learn python In-Reply-To: <4D3DB915.9060601@sequans.com> References: <188c0a9f-4e93-4fae-b3f9-e7c84f8030fd@v31g2000pri.googlegroups.com> <4D3DB915.9060601@sequans.com> Message-ID: I am very new to object oriented concept, so I need to learn everything frm basic, Will the above books fulfill My need On Monday, January 24, 2011, Jean-Michel Pichavant wrote: > santosh hs wrote: > > Hi All, > i am beginner to python please tell me which is the best available > reference for beginner to start from novice > > > > Hi, > > You could have searched the archive, this question was raised many times. > > http://wiki.python.org/moin/IntroductoryBooks > > I read "Learning Python" when I started. Since it's the only one I read I cannot tell you which one is the best (if there is). > Python is easy to learn, I'm not sure it's possible to write a bad book about it. > > JM > > From orasnita at gmail.com Thu Jan 27 12:22:55 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Thu, 27 Jan 2011 19:22:55 +0200 Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com><9MB%o.14110$%64.6074@unlimited.newshosting.com> <59F6E65E3D9A46AD8D7A3863F3C1DC84@teddy> <27f53f8c-7862-4366-9352-82ae9a2f3970@k3g2000yqc.googlegroups.com> <718D13777F254C839F9564BC4275DE0A@octavian> <4D402C42.1030407@tysdomain.com> <4D40447C.4010108@tysdomain.com><33C68A0874BE4C66AB478EDFB64C2C1D@teddy> <4D407333.1070301@tysdomain.com> <82865E7A54C048C398B4F4160FC43B57@octavian> <4D417EFC.70800@tysdomain.com> Message-ID: <57C3CFA0C7EE4578B0C6EAA267AAE678@teddy> From: "Littlefield, Tyler" > >It doesn't support a good voice synthesizer like Eloquence or IBM Via > voice > Eloq is an add-on, but it does support it. If you are saying this, it means that you haven't used it for a long time, or you just heard about it by searching on the web. Eloq is supported, but only as an unofficial hack because the NVDA developers pretend that it is illegally to offer support for Eloquence. They said that Nuance ask them to remove that support from NVDA, and as a consequence, the support for Eloquence was removed and it is harder to find the NVDA Eloquence driver from unofficial sources (and that unofficial support is not the same under all versions of NVDA...) > >but only eSpeak which sounds horrible > That's your personal preference. Plenty use and like ESpeak. That's my personal preference and the preference of all the blind people I know in my country with only one or two exceptions. (If you'd know Romanian, I could give you the address of a forum to ask there if you don't believe me.) And note that Eloquence doesn't support my native language, but eSpeak does it, however they still don't like eSpeak. Why do you think we don't like it? Because it is so good? > >it doesn't have a scripting language ready to use as JAWS and Window > Eyes do, > Scripting is done in Python, (no, not some native scripting language), > and are done as modules. You write your script in python, and off you > go. Problem solved. Have you done such a script for NVDA? I've created a sample script in Python that uses the COM interface and I have asked on the NVDA mailing list and on NVDA-dev mailing list if I can use it, but NVDA doesn't offer that feature yet. And I was saying that "NVDA doesn't have a scripting language ready to use". The scripting language can be Python, but it should accept a scripting code, easy to install with a copy/paste, not an NVDA patch. That means "ready to use". >it doesn't offer the possibility of reading with the mouse cursor as JAWS does with its so called JAWS cursor, It's called flat review. Googling this term brings up a key reference at like the third or fourth result down. Tyler, you are a Linux and Mac user and you search with Google and try to explain how many things you know about NVDA, but it is obviously that what JAWS can offer NVDA can't. That flat review can be used to read some things from the screen, and they say that it might also show the coordinates of the objects, however unlike JAWS, it can't show the coordinates of each character on the screen, and this is important by someone who is totally blind for checking the positions of different text elements on a web page, or in a desktop app. But NVDA can't be used for that. > the only issue here is you promoting the most "widely used screen reader," because it's what you use, and you not being able to use google and do your homework before you start talking about products you know nothing of. Tyler, the other list members sustain you because you are also against changing something in order to improve the accessibility and just promise that you will make Tk accessible, and I am sure they won't say anything about your atitude, but your atitude really sucks because it is obviously that you don't know many things about NVDA, and you haven't tried it, you even show that you don't care about the most used OS, you use Mac and Linux, but keep telling me that I don't know about it although I am an NVDA user for a long time. And all these useless phrases are just for answering to your useless hijack of the discussion, because we are not talking about NVDA here, but about the lack of accessibility in Tk-based applications, and Tk is as inaccessible in JAWS as in NVDA, Window Eyes or other screen readers, so it doesn't matter what screen reader we use for testing that inaccessibility. Octavian From mark at markroseman.com Thu Jan 27 12:31:08 2011 From: mark at markroseman.com (Mark Roseman) Date: Thu, 27 Jan 2011 10:31:08 -0700 Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> 0-47ef-a8b0-ca55d52ef683@1g20000qz.googlegroupssssss db3-4108-8a13-cc7d51f00b49@29g2200prb.googlegrooooooooo 5tpU1@mid.indivvvvvvvvvvv 784-d6a3-41ac-aa97-5902a6323bc00o21g2000prn.goooooooooooooooo <048FB74272D440A0915ABC7D76AE262B@teddy> <5782E9AD8A8342D691EB3549E5E0ED7B@octavian> Message-ID: Terry Reedy wrote: > Tk itself is purely a gui package -- abstract widgits, geometry placers > to make them visible, and an event system to make them active. But it > does have the baggage of needing tcl included. About a decade ago, some > people had the idea of removing the tcl dependency, but nothing seems to > have come of that. For some people, the tcl baggage is reason enough to > be rid of tk. Thanks for raising this point. While I don't want to exhaustively respond to this, I would like to raise a few important points. 1. The performance issues of having Tk use Tcl are negligible; the bulk of Tk (code-wise and time-wise) are spent in C. Tcl itself is also very fast nowadays, using all the usual techniques that modern dynamic languages use. 2. Some people do have moral/purity objections to including Tcl, and while I understand where the sentiment comes from, I think there are few solid engineering reasons for this. 3. Removing Tcl from Tk makes keeping up with changes in Tk very difficult. The Perl people found this out; Perl/Tk extracted Tcl, and as a result remained using a 10 year old version of Tk because upgrading would have been too painful. The newer Perl binding (Tkx) is in fact a ridiculously thin binding over the Tcl API, and makes keeping up to date with the newest Tk changes trivial, often requiring no code changes in the Perl binding. If anyone does have questions, comments or concerns about Python including a Tcl interpreter to use Tk, I'd be happy to try to explain or address them. Mark From invalid at invalid.invalid Thu Jan 27 12:47:14 2011 From: invalid at invalid.invalid (Grant Edwards) Date: Thu, 27 Jan 2011 17:47:14 +0000 (UTC) Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com> <9MB%o.14110$%64.6074@unlimited.newshosting.com> <4A48EDF6D7634F2E994661A457451E87@teddy> <753A4C5A6658470085804B13C80340F2@octavian> Message-ID: On 2011-01-27, Octavian Rasnita wrote: > Yes you might be right. It is just my way of communicating and it > might be too direct and some people might not like it. Too direct is putting it mildly. > I always consider the expressions like "How do you do" as having > absolutely no value, because they are just nice expressions made for > easing the communication, So you're saying that you don't see any value in easing communication, nor presumably in communication itself? > but yes, most people seem to like them and don't like to discuss > directly about the sensible problems. If you don't care about communicating with others, then being civil probably does have no value (except for keeping a job or being avoiding being beaten up on the playground). If you want to communicate (especially if you want somebody else to _do_ something), then being civil and following normal social rules (etiquette) is _very_ valuable. Without it the only thing you accomplish is to turn people against you and whatever you're saying. There is no inherent "value" in driving on the right side of the road vs. the left. However, there is a lot of value in driving on the side of road that others expect you to. I'd tell you to try driving on the other side of the road sometime to see how "easing communication" can be valuable, but I'm afraid you'd try it... -- Grant Edwards grant.b.edwards Yow! I'm RELIGIOUS!! at I love a man with gmail.com a HAIRPIECE!! Equip me with MISSILES!! From orasnita at gmail.com Thu Jan 27 12:54:15 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Thu, 27 Jan 2011 19:54:15 +0200 Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com><9MB%o.14110$%64.6074@unlimited.newshosting.com><4A48EDF6D7634F2E994661A457451E87@teddy><753A4C5A6658470085804B13C80340F2@octavian> <4D40A97F.8090209@tysdomain.com><00ABBA322416409EB749102EB1CC5E61@octavian> <4D418054.8050002@tysdomain.com> Message-ID: From: "Littlefield, Tyler" > >We are talking about accessibility here. Are you saying that Tkinter > can be >recommended from the perspective of accessibility? > See my comment about shoving words in people's mouths; I did not hint, > nor did I come near saying that in that message. But you asked who says that Tkinter is not recommended. Everything that's not accessible is not recommended. Tkinter should be at most accepted because there is no better solution, at least for Python 3, not because it is the recommended solution. Octavian From invalid at invalid.invalid Thu Jan 27 12:55:45 2011 From: invalid at invalid.invalid (Grant Edwards) Date: Thu, 27 Jan 2011 17:55:45 +0000 (UTC) Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com> <9MB%o.14110$%64.6074@unlimited.newshosting.com> <4A48EDF6D7634F2E994661A457451E87@teddy> <753A4C5A6658470085804B13C80340F2@octavian> Message-ID: On 2011-01-27, Octavian Rasnita wrote: > From: "Grant Edwards" >> And, based on your behavior, you apparently don't like convincing >> others or advancing the cause of accessibility. It seems you prefer to >> annoy and alienate others. > >>From what I said, what was annoying? > >>> I don't want to convince anyone, but I just want to inform the others >>> and let them know if they are doing something not recommended. >> >> IOW, you don't really care about increasing accessibility, you just >> want to hear the sound of your own voice as you shout into the wind. > > Where have you seen that I don't care about accessibility? You said that you don't care about convincing anybody either that accessibility is import or about convincing anybody to do anything about it. To me that means you don't care about accessiblity. >> People will not separate your personality from the cause you espouse. > > Wow! that's really bad. It's less than ideal, but it the way people are. Is that a surprise to you? > I thought that I might find here people that might have something > against my opinions, that is very normal, that's why we are > discussing, but I didn't think that I will also find people that will > have something against me, just because of my opinions. That's not what I said. I said that if you state your opininions in a rude, insulting, or disrepectful manner, that will turn people against your opinions regardless of the inherent value of the actual opinions themselves. This should not be a surprise to anybody over the age of three. > I know people with different political opinions, with different > programming languages preferences, that like other kind of women, > that prefer other kkind of food, with whom I have often philosophical > debates often, but whith whom I can be a good friend and collaborator > and co-worker for some projects. That's not what we're talking about. We're not talking about your opinions on some unrelated topic. We're talking about the manner in which you express your opinions on this topic. >> You may not like it, but that's a fact. If you are in favor of XYZ, >> and act rude and insulting while espousing XYZ, people will react >> against not only you but _also_ XYZ. > > I know what you are reffering to. :-) > > And I was hoping that there won't be people that don't like me > personally for what I think about some things that have nothing > related to them personally. Again, it's not your beliefs about other tops that are causing problems for you. What's causing problems is the manner in which you are expressing your beliefs about this topic. > But I don't say that you are wrong. After some reactions on the list > I can say that you might be really right. -- Grant Edwards grant.b.edwards Yow! I would like to at urinate in an OVULAR, gmail.com porcelain pool -- From invalid at invalid.invalid Thu Jan 27 12:57:50 2011 From: invalid at invalid.invalid (Grant Edwards) Date: Thu, 27 Jan 2011 17:57:50 +0000 (UTC) Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com> <9MB%o.14110$%64.6074@unlimited.newshosting.com> <59F6E65E3D9A46AD8D7A3863F3C1DC84@teddy> <27f53f8c-7862-4366-9352-82ae9a2f3970@k3g2000yqc.googlegroups.com> <718D13777F254C839F9564BC4275DE0A@octavian> <4D402C42.1030407@tysdomain.com> <4D40447C.4010108@tysdomain.com> <33C68A0874BE4C66AB478EDFB64C2C1D@teddy> <4D407321.3090705@web.de> <1296128007.17192.1417506961@webmail.messagingengine.com> Message-ID: On 2011-01-27, Octavian Rasnita wrote: > From: Octavian, > >> If I understand your message, you are frustrated with Tkinter because >> it doesn't support accessability. >> >> In several messages on this thread I pointed out that Tkinter can >> easily be made accessable under Linux and Mac OS X. >> >> Rather than throw out Tkinter entirely, why not work with the community >> to make Tkinter accessable under Windows. > > > I am willing to help, but unfortunately I don't know neither TCL or C > nor the technical details about the accessibility standards that need > to be implemented. I am mainly a web/CLI programmer. A very important way to help would be to test accessibility features and post accurate, detailed, bug-reports. -- Grant Edwards grant.b.edwards Yow! I'm not available at for comment.. gmail.com From invalid at invalid.invalid Thu Jan 27 13:04:09 2011 From: invalid at invalid.invalid (Grant Edwards) Date: Thu, 27 Jan 2011 18:04:09 +0000 (UTC) Subject: Need GUI pop-up to edit a (unicode ?) string References: <3tqr08-bj2.ln1@murmur.very.softly> <7691fe98-37af-4ddf-a8a8-eadeef0d4a6e@y2g2000prf.googlegroups.com> <541c02df-b1fc-4376-bf17-e0531fe5c4bf@r29g2000yqj.googlegroups.com> Message-ID: On 2011-01-27, Stephen Hansen wrote: > On 1/25/11 3:02 PM, rantingrick wrote: >> This is a major flaw in the design and i would be >> happy to fix the flaw. However our "friend" Fredrick decided to >> copyright the module to himself! What a jerk! Which is quite >> disgusting considering that Tkinter, and TclTk are completely open >> source! > > Uh. ... LOL. > > Copyright doesn't mean what you think it means. > > Tkinter is copyrighted. Python is copyrighted. Tcl/TK is copyrgithed. > > In fact: everything that is "open source" is copyrighted. By > definition[* see footnote]. One (domestic US) exception would be open-source software written by an employee of the US federal government. Works produced by the US Government are not copyrighted under US domestic copyright law. Such works are copyrighted under international law (which is probably what the Python maintainers care about). -- Grant Edwards grant.b.edwards Yow! Wow! Look!! A stray at meatball!! Let's interview gmail.com it! From orasnita at gmail.com Thu Jan 27 13:09:01 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Thu, 27 Jan 2011 20:09:01 +0200 Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <8q7sgiF5tpU1@mid.individual.net> <19891784-d6a3-41ac-a097-5902a6323bc0@o21g2000prn.googlegroups.com><0b12cdb1-45b4-41e4-9bdb-074ee669d76b@k14g2000pre.googlegroups.com> <048FB74272D440A0915ABC7D76AE262B@teddy> <5782E9AD8A8342D691EB3549E5E0ED7B@octavian> <43549D4396F34EA697C45AA40EA12BC8@octavian> Message-ID: <5858167B51BD4813A1D36C2D90D255F2@teddy> From: "Emile van Sebille" > On 1/26/2011 11:02 PM Octavian Rasnita said... > >> As we all know, Python doesn't care too much about maintaining a >> backward compatibility > > Where'd you get this idea? Between v2 and v3 yes, that was the intent. To be sincere I was thinking to the differences between Python 2 and 3. > But otherwise, I think there's another miscommunication behind this... It might be true, however I have seen some modules that say that are ment for Python 2.5, for 2.6 or for 2.7, so there seem to be differences between these versions also. py2exe offers the following installation kits, depending on the Python version. If you know, please tell me why there are different packages for different versions of Python? py2exe-0.6.9.win32-py2.5.exe py2exe-0.6.9.win32-py2.4.exe py2exe-0.6.9.win32-py2.3.exe py2exe-0.6.9.win32-py2.6.exe py2exe-0.6.9.win32-py2.7.exe Thanks. Octavian From rantingrick at gmail.com Thu Jan 27 13:11:55 2011 From: rantingrick at gmail.com (rantingrick) Date: Thu, 27 Jan 2011 10:11:55 -0800 (PST) Subject: WxPython versus Tkinter. References: <4D4093AF.80806@etrix.com.au> Message-ID: On Jan 27, 1:28?am, "Octavian Rasnita" wrote: > From: "Brendan Simon (eTRIX)" > > > Since it seems the python motto is "Batteries included", then it would > > seem to me that wxPython is the natural fit as it also has "Batteries > > included" (e.g. accessibility, native look-n-feel, mature and evolving, > > can produce simple or complex gui programs, etc, etc). > > Yes Brendan, you are perfectly right, but unfortunately WxPython developers > don't want to have it included in the stdlib. [...] > But WxPython is their work and they decision is their. Actually we don't want "Robins wxPython" in the stdlib "as is" anyway. What we DO want is an abstraction API for the short term that plugs into Robin's wx. Then over the long term we will either convince him to create a better API OR just create our own wxPython directly from WxWidgets and mold it into the stdlib. So hinging on the argument of what one *single* man thinks is a non-starter. We all respect Robin however python is greater then me, then you, and yes, EVEN Guido van Rossum! Python belongs to the world now. And what is best for Python's community AS A WHOLE is what we should be concerned about. From craigyk at me.com Thu Jan 27 13:12:37 2011 From: craigyk at me.com (Craig Yoshioka) Date: Thu, 27 Jan 2011 10:12:37 -0800 Subject: help with multiprocessing pool In-Reply-To: <2A124DD5-95F2-4DE0-AB0F-5D3EA39A230B@semanchuk.com> References: <2A124DD5-95F2-4DE0-AB0F-5D3EA39A230B@semanchuk.com> Message-ID: The code will be multi-platform. The OSXisms are there as an example, though I am developing on OS X machine. I've distilled my problem down to a simpler case, so hopefully that'll help troubleshoot. I have 2 files: test.py: -------------------------------------------------------------- from multiprocessing import Pool def square(x): return x*x def squares(numbers): pool = Pool(12) return pool.map(square,numbers) test2.py: -------------------------------------------------------------- from test import squares maxvalues = squares(range(3)) print maxvalues Now if I import squares into the interactive interpreter: from test import squares print squares(range(3)) I get the correct result, but if I try to import maxvalues from test2 the interactive interpreter python hangs. if I run the script from bash, though, it seems to run fine. I think it might have something to do with this note in the docs, though I am not sure how to use this information to fix my problem: Note: Functionality within this package requires that the __main__ method be importable by the children. This is covered inProgramming guidelines however it is worth pointing out here. This means that some examples, such as themultiprocessing.Pool examples will not work in the interactive interpreter. Thanks. On Jan 27, 2011, at 6:39 AM, Philip Semanchuk wrote: > > On Jan 25, 2011, at 8:19 PM, Craig Yoshioka wrote: > >> Hi all, >> >> I could really use some help with a problem I'm having. > > > Hiya Craig, > I don't know if I can help, but it's really difficult to do without a full working example. > > Also, your code has several OS X-isms in it so I guess that's the platform you're on. But in case you're on Windows, note that that platform requires some extra care when using multiprocessing: > http://docs.python.org/library/multiprocessing.html#windows > > > Good luck > Philip > > >> I wrote a function that can take a pattern of actions and it apply it to the filesystem. >> It takes a list of starting paths, and a pattern like this: >> >> pattern = { >> InGlob('Test/**'):{ >> MatchRemove('DS_Store'):[], >> NoMatchAdd('(alhpaID_)|(DS_Store)','warnings'):[], >> MatchAdd('alphaID_','alpha_found'):[], >> InDir('alphaID_'):{ >> NoMatchAdd('(betaID_)|(DS_Store)','warnings'):[], >> InDir('betaID_'):{ >> NoMatchAdd('(gammaID_)|(DS_Store)','warnings'):[], >> MatchAdd('gammaID_','gamma_found'):[] }}}} >> >> so if you run evalFSPattern(['Volumes/**'],pattern) it'll return a dictionary where: >> >> dict['gamma_found'] = [list of paths that matched] (i.e. '/Volumes/HD1/Test/alphaID_3382/betaID_38824/gammaID_848384') >> dict['warning'] = [list of paths that failed to match] (ie. '/Volumes/HD1/Test/alphaID_3382/gammaID_47383') >> >> Since some of these volumes are on network shares I also wanted to parallelize this so that it would not block on IO. I started the parallelization by using multiprocessing.Pool and got it to work if I ran the fsparser from the interpreter. It ran in *much* less time and produced correct output that matched the non-parallelized version. The problem begins if I then try to use the parallelized function from within the code. >> >> For example I wrote a class whose instances are created around valid FS paths, that are cached to reduce expensive FS lookups. >> >> class Experiment(object): >> >> SlidePaths = None >> >> @classmethod >> def getSlidePaths(cls): >> if cls.SlidePaths == None: >> cls.SlidePaths = fsparser(['/Volumes/**'],pattern) >> return cls.SlidePaths >> >> @classmethod >> def lookupPathWithGammaID(cls,id): >> paths = cls.getSlidePaths() >> ... >> return paths[selected] >> >> @classmethod >> def fromGamaID(cls,id): >> path = cls.lookupPathWithGammaID(id) >> return cls(path) >> >> def __init__(self,path) >> self.Path = path >> ... >> >> ... >> >> If I do the following from the interpreter it works: >> >>>>> from experiment import Experiment >>>>> expt = Experiment.fromGammaID(10102) >> >> but if I write a script called test.py: >> >> from experiment import Experiment >> expt1 = Experiment.fromGammaID(10102) >> expt2 = Experiment.fromGammaID(10103) >> comparison = expt1.compareTo(expt2) >> >> it fails, if I try to import it or run it from bash prompt: >> >>>>> from test import comparison (hangs forever) >> $ python test.py (hangs forever) >> >> I would really like some help trying to figure this out... I thought it should work easily since all the spawned processes don't share data or state (their results are merged in the main thread). The classes used in the pattern are also simple python objects (use python primitives). >> >> >> These are the main functions: >> >> def mapAction(pool,paths,action): >> merge = {'next':[]} >> for result in pool.map(action,paths): >> if result == None: >> continue >> merge = mergeDicts(merge,result) >> return merge >> >> >> def mergeDicts(d1,d2): >> for key in d2: >> if key not in d1: >> d1[key] = d2[key] >> else: >> d1[key] += d2[key] >> return d1 >> >> >> def evalFSPattern(paths,pattern): >> pool = Pool(10) >> results = {} >> for action in pattern: >> tomerge1 = mapAction(pool,paths,action) >> tomerge2 = evalFSPattern(tomerge1['next'],pattern[action]) >> del tomerge1['next'] >> results = mergeDicts(results,tomerge1) >> results = mergeDicts(results,tomerge2) >> return results >> >> the classes used in the pattern (InGlob,NoMatchAdd,etc.) are callable classes that take a single parameter (a path) and return a dict result or None which makes them trivial to adapt to Pool.map. >> >> Note if I change the mapAction function to: >> >> def mapAction(pool,paths,action): >> merge = {'next':[]} >> for path in paths: >> result = action(path) >> if result == None: >> continue >> merge = mergeDicts(merge,result) >> return merge >> >> everything works just fine. >> >> >> Thanks. >> >> >> -- >> http://mail.python.org/mailman/listinfo/python-list > > -- > http://mail.python.org/mailman/listinfo/python-list From me+list/python at ixokai.io Thu Jan 27 13:13:03 2011 From: me+list/python at ixokai.io (Stephen Hansen) Date: Thu, 27 Jan 2011 10:13:03 -0800 Subject: WxPython versus Tkinter. In-Reply-To: References: <4D3E4377.3060807@tysdomain.com> <9MB%o.14110$%64.6074@unlimited.newshosting.com> <4A48EDF6D7634F2E994661A457451E87@teddy> <753A4C5A6658470085804B13C80340F2@octavian> Message-ID: <4D41B5AF.8020200@ixokai.io> On 1/27/11 9:55 AM, Grant Edwards wrote: > On 2011-01-27, Octavian Rasnita wrote: >> From: "Grant Edwards" >>> People will not separate your personality from the cause you espouse. >> >> Wow! that's really bad. > > It's less than ideal, but it the way people are. > > Is that a surprise to you? Seriously. Octavian's attitude in this thread makes me want to go use Tkinter just to spite him. And I'm net-buds with Tyler, and I'm working on a project that I thought accessibility for the blind was very important for. But no more! Way to set the cause back, Octavian. :P You have -1 converts! -- Stephen Hansen ... Also: Ixokai ... Mail: me+list/python (AT) ixokai (DOT) io ... Blog: http://meh.ixokai.io/ * Disclaimer: You are stupid if you think this is true. But seriously, Octavian makes it REALLY hard to continue caring about something that I actually cared about before and thought was important. -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 487 bytes Desc: OpenPGP digital signature URL: From iwanttogetspammed at gmx.net Thu Jan 27 13:16:09 2011 From: iwanttogetspammed at gmx.net (hein) Date: Thu, 27 Jan 2011 10:16:09 -0800 (PST) Subject: lxml.etree, namespaces and element insertion Message-ID: The other day i was processing an xml tree using lxml.etree. That tree contained a namespace. During that processing i inserted an element. Later on i tried to find that element using xpath. And to my suprise that element was not found! Maybe my suprise is just the result of my marginal knowledge about xml namespaces. After some examination i found out that the reason for not finding the element was that i did not supply a namespace when inserting the element. This behavior can be reproduced be the folowing code: from lxml import etree import sys print "Python: ", sys.version_info print "lxml.etree:", etree.__version__ string_data = [ '', '', '' ] trees = map(etree.fromstring, string_data) print "\n Before insertion:" for t in trees: print etree.tostring(t, pretty_print=True) trees[1].insert(-1, etree.Element("sometag")) trees[2].insert(-1, etree.Element("{NameSpace.com}sometag", nsmap={None : "NameSpace.com"})) print "\n After insertion:" for t in trees: print etree.tostring(t, pretty_print=True) print "\n Using xpath:" for t in trees: elements = t.xpath("//ns:sometag", namespaces={'ns': 'NameSpace.com'}) print len(elements), if elements: print [e.tag for e in elements] else: print elements Its output is: Python: (2, 6, 6, 'final', 0) lxml.etree: 2.2.8 Before insertion: After insertion: Using xpath: 1 ['{NameSpace.com}sometag'] 0 [] 1 ['{NameSpace.com}sometag'] So my suprise was that in the second case the xpath result is an empty list. I have two questions on this: - Is what i am seeing expected behavior? - How am i supposed to detect a missing namespace, if there are no differences in the serialized representation? (That's what i initially used to debug the problem.) From tyler at tysdomain.com Thu Jan 27 13:17:27 2011 From: tyler at tysdomain.com (Littlefield, Tyler) Date: Thu, 27 Jan 2011 11:17:27 -0700 Subject: WxPython versus Tkinter. In-Reply-To: <57C3CFA0C7EE4578B0C6EAA267AAE678@teddy> References: <4D3E4377.3060807@tysdomain.com><9MB%o.14110$%64.6074@unlimited.newshosting.com> <59F6E65E3D9A46AD8D7A3863F3C1DC84@teddy> <27f53f8c-7862-4366-9352-82ae9a2f3970@k3g2000yqc.googlegroups.com> <718D13777F254C839F9564BC4275DE0A@octavian> <4D402C42.1030407@tysdomain.com> <4D40447C.4010108@tysdomain.com><33C68A0874BE4C66AB478EDFB64C2C1D@teddy> <4D407333.1070301@tysdomain.com> <82865E7A54C048C398B4F4160FC43B57@octavian> <4D417EFC.70800@tysdomain.com> <57C3CFA0C7EE4578B0C6EAA267AAE678@teddy> Message-ID: <4D41B6B7.7010609@tysdomain.com> >Tyler, you are a Linux and Mac user and you search with Google and try to >explain how many things you know about NVDA, but it is obviously that what >JAWS 1) Because you, your crew, and your group on a specific forum doesn't like ESpeak doesn't disqualify an entire reader. The eloquence fixes are illegal to be packaged with NVDA, so you -need- to get a separate patch, yes. That doesn't mean it can't be done. As to me being a Linux and Mac user, that doesn't disqualify what I'm telling you either, because unlike your limitations, I don't just decide to only use one reader. I use Linux, Mac, and windows (windows more than both, actually). Yes, I'm giving you what I got from googling, because that's my way of telling you to do your homework before you start ranting about a reader you clearly know nothing of. The fact that it appears on google says a lot. At least to me, maybe it's something you haven't been able to comprehend. On 1/27/2011 10:22 AM, Octavian Rasnita wrote: > From: "Littlefield, Tyler" >>> It doesn't support a good voice synthesizer like Eloquence or IBM Via >> voice >> Eloq is an add-on, but it does support it. > If you are saying this, it means that you haven't used it for a long time, or you just heard about it by searching on the web. Eloq is supported, but only as an unofficial hack because the NVDA developers pretend that it is illegally to offer support for Eloquence. They said that Nuance ask them to remove that support from NVDA, and as a consequence, the support for Eloquence was removed and it is harder to find the NVDA Eloquence driver from unofficial sources (and that unofficial support is not the same under all versions of NVDA...) > >>> but only eSpeak which sounds horrible >> That's your personal preference. Plenty use and like ESpeak. > That's my personal preference and the preference of all the blind people I know in my country with only one or two exceptions. (If you'd know Romanian, I could give you the address of a forum to ask there if you don't believe me.) > And note that Eloquence doesn't support my native language, but eSpeak does it, however they still don't like eSpeak. Why do you think we don't like it? Because it is so good? > >>> it doesn't have a scripting language ready to use as JAWS and Window >> Eyes do, >> Scripting is done in Python, (no, not some native scripting language), >> and are done as modules. You write your script in python, and off you >> go. Problem solved. > Have you done such a script for NVDA? > I've created a sample script in Python that uses the COM interface and I have asked on the NVDA mailing list and on NVDA-dev mailing list if I can use it, but NVDA doesn't offer that feature yet. And I was saying that "NVDA doesn't have a scripting language ready to use". The scripting language can be Python, but it should accept a scripting code, easy to install with a copy/paste, not an NVDA patch. That means "ready to use". > > >it doesn't offer the possibility of reading with the mouse cursor as > JAWS does with its so called JAWS cursor, > It's called flat review. Googling this term brings up a key reference at > like the third or fourth result down. > > Tyler, you are a Linux and Mac user and you search with Google and try to explain how many things you know about NVDA, but it is obviously that what JAWS can offer NVDA can't. That flat review can be used to read some things from the screen, and they say that it might also show the coordinates of the objects, however unlike JAWS, it can't show the coordinates of each character on the screen, and this is important by someone who is totally blind for checking the positions of different text elements on a web page, or in a desktop app. But NVDA can't be used for that. > >> the only issue here is you promoting the most "widely used screen reader," because it's what > you use, > and you not being able to use google and do your homework before you > start talking about products you know nothing of. > > Tyler, the other list members sustain you because you are also against changing something in order to improve the accessibility and just promise that you will make Tk accessible, and I am sure they won't say anything about your atitude, but your atitude really sucks because it is obviously that you don't know many things about NVDA, and you haven't tried it, you even show that you don't care about the most used OS, you use Mac and Linux, but keep telling me that I don't know about it although I am an NVDA user for a long time. > > And all these useless phrases are just for answering to your useless hijack of the discussion, because we are not talking about NVDA here, but about the lack of accessibility in Tk-based applications, and Tk is as inaccessible in JAWS as in NVDA, Window Eyes or other screen readers, so it doesn't matter what screen reader we use for testing that inaccessibility. > > Octavian > > -- Thanks, Ty From me+list/python at ixokai.io Thu Jan 27 13:18:58 2011 From: me+list/python at ixokai.io (Stephen Hansen) Date: Thu, 27 Jan 2011 10:18:58 -0800 Subject: Need GUI pop-up to edit a (unicode ?) string In-Reply-To: References: <3tqr08-bj2.ln1@murmur.very.softly> <7691fe98-37af-4ddf-a8a8-eadeef0d4a6e@y2g2000prf.googlegroups.com> <541c02df-b1fc-4376-bf17-e0531fe5c4bf@r29g2000yqj.googlegroups.com> Message-ID: <4D41B712.1020504@ixokai.io> On 1/27/11 10:04 AM, Grant Edwards wrote: > On 2011-01-27, Stephen Hansen wrote: >> On 1/25/11 3:02 PM, rantingrick wrote: >>> This is a major flaw in the design and i would be >>> happy to fix the flaw. However our "friend" Fredrick decided to >>> copyright the module to himself! What a jerk! Which is quite >>> disgusting considering that Tkinter, and TclTk are completely open >>> source! >> >> Uh. ... LOL. >> >> Copyright doesn't mean what you think it means. >> >> Tkinter is copyrighted. Python is copyrighted. Tcl/TK is copyrgithed. >> >> In fact: everything that is "open source" is copyrighted. By >> definition[* see footnote]. > > One (domestic US) exception would be open-source software written by > an employee of the US federal government. Works produced by the US > Government are not copyrighted under US domestic copyright law. Such > works are copyrighted under international law (which is probably what > the Python maintainers care about). I've actually wondered a bit about that: but the only open source software that I'm aware of that's been government-adjacent has ended up being written/owned by some University or joint venture funded by a government agency -- it didn't fall into the public domain category of content created directly by the federal government. Are you aware of any code out there that is? Just curious. I'm not arguing that the exception doesn't exist or anything. -- Stephen Hansen ... Also: Ixokai ... Mail: me+list/python (AT) ixokai (DOT) io ... Blog: http://meh.ixokai.io/ -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 487 bytes Desc: OpenPGP digital signature URL: From rantingrick at gmail.com Thu Jan 27 13:21:52 2011 From: rantingrick at gmail.com (rantingrick) Date: Thu, 27 Jan 2011 10:21:52 -0800 (PST) Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com><9MB%o.14110$%64.6074@unlimited.newshosting.com><4A48EDF6D7634F2E994661A457451E87@teddy><753A4C5A6658470085804B13C80340F2@octavian> Message-ID: <8a71f330-a634-4e48-bea2-ddde6e70a71a@m7g2000vbq.googlegroups.com> On Jan 27, 2:13?am, "Octavian Rasnita" wrote: > > You may not like it, but that's a fact. ?If you are in favor of XYZ, > > and act rude and insulting while espousing XYZ, people will react > > against not only you but _also_ XYZ. > > I know what you are reffering to. :-) > And I was hoping that there won't be people that don't like me personally > for what I think about some things that have nothing related to them > personally. > But I don't say that you are wrong. After some reactions on the list I can > say that you might be really right. Sadly many people lack the ability to make objective decisions. They let emotion get in the way of good choices. People should put aside petty differences and make judgments solely on facts. Yes, you can disagree with someone passionately on one subject and yet agree passionately on another. Case in point: If Guido and myself sit down for a political discussion we would probably poke each others eyes out in a very short time. However i still hold a great respect for Guido and that will never change. Now matter how much i may disagree with him on certain matters, he still forged the path and brought us Python. I will never think harsh of him just because we do not agree on everything. I believe in freedom of speech, freedom of expression, and freedom of ideas. Some of you out there need to take this advice yourselves. Stop hating those who may thing differently because one day you may find out your position was wrong. From rantingrick at gmail.com Thu Jan 27 13:24:55 2011 From: rantingrick at gmail.com (rantingrick) Date: Thu, 27 Jan 2011 10:24:55 -0800 (PST) Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com><9MB%o.14110$%64.6074@unlimited.newshosting.com><4A48EDF6D7634F2E994661A457451E87@teddy><753A4C5A6658470085804B13C80340F2@octavian> <4D40A97F.8090209@tysdomain.com> Message-ID: <3869f767-f8e9-4067-a32a-a2e12e6d4e1b@z31g2000vbs.googlegroups.com> On Jan 27, 2:17?am, "Octavian Rasnita" wrote: > From: "Littlefield, Tyler" [...] > > Then when that fails, you try cramming > > words in people's mouth to make them feel like they kick puppies, and to > > bring everyone else to this same conclusion. Tyler no one can *make* you *feel* like anything unless you let them. Actually i think what you are *feeling* now is guilt. The human conscience has a way of catching up with us when we exaggerate too much. From emile at fenx.com Thu Jan 27 13:30:59 2011 From: emile at fenx.com (Emile van Sebille) Date: Thu, 27 Jan 2011 10:30:59 -0800 Subject: WxPython versus Tkinter. In-Reply-To: <5858167B51BD4813A1D36C2D90D255F2@teddy> References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <8q7sgiF5tpU1@mid.individual.net> <19891784-d6a3-41ac-a097-5902a6323bc0@o21g2000prn.googlegroups.com><0b12cdb1-45b4-41e4-9bdb-074ee669d76b@k14g2000pre.googlegroups.com> <048FB74272D440A0915ABC7D76AE262B@teddy> <5782E9AD8A8342D691EB3549E5E0ED7B@octavian> <43549D4396F34EA697C45AA40EA12BC8@octavian> <5858167B51BD4813A1D36C2D90D255F2@teddy> Message-ID: On 1/27/2011 10:09 AM Octavian Rasnita said... > From: "Emile van Sebille" >> On 1/26/2011 11:02 PM Octavian Rasnita said... >> >>> As we all know, Python doesn't care too much about maintaining a >>> backward compatibility >> >> Where'd you get this idea? Between v2 and v3 yes, that was the intent. > > To be sincere I was thinking to the differences between Python 2 and 3. > >> But otherwise, I think there's another miscommunication behind this... > > It might be true, however I have seen some modules that say that are ment for Python 2.5, for 2.6 or for 2.7, so there seem to be differences between these versions also. Yes - but don't confuse forward compatibility (which means programs you write today in the current version will work on the prior versions) with backward compatibility (which means programs written for earlier versions will run under newer versions) I suspect that a lot of python 1.x code will work just fine under 2.x just as most 2.n will work under 2.m (where m>n). There are few exceptions, and those mostly in the standard library. I recall only getting stung once (something to do with passing in a tuple instead of two parameters in one or another imported module). Emile From rantingrick at gmail.com Thu Jan 27 13:33:59 2011 From: rantingrick at gmail.com (rantingrick) Date: Thu, 27 Jan 2011 10:33:59 -0800 (PST) Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com><9MB%o.14110$%64.6074@unlimited.newshosting.com> <59F6E65E3D9A46AD8D7A3863F3C1DC84@teddy> <27f53f8c-7862-4366-9352-82ae9a2f3970@k3g2000yqc.googlegroups.com> <718D13777F254C839F9564BC4275DE0A@octavian> <4D402C42.1030407@tysdomain.com> <4D40447C.4010108@tysdomain.com> <33C68A0874BE4C66AB478EDFB64C2C1D@teddy> Message-ID: On Jan 26, 1:16?pm, Alexander Kapps wrote: > Please don't use the lower Linux user percentage as an argument > here. If you follow that path further, you would need to agree that > it's only an "insignificant" percent of people who need a screen > reader, so why bother? Please don't use the lower accessibility percentage to prop up the low Linux percentage in an attempt to win your argument. Because healthy Linux users ARE NOT equal to handicapped people! And let's just get to the real point of this statement... This argument stems from me saying that Lunux users should stop complaining about downloading gtk to use wxPython because they use a non-hand- holding OS. And now you attempt to compare yourself to handicapped people in a veiled way so we feel sorry for you? Well it worked! I DO feel sorry for you. Congratulations! From g.rodola at gmail.com Thu Jan 27 13:35:46 2011 From: g.rodola at gmail.com (=?ISO-8859-1?Q?Giampaolo_Rodol=E0?=) Date: Thu, 27 Jan 2011 19:35:46 +0100 Subject: WxPython versus Tkinter. In-Reply-To: <5858167B51BD4813A1D36C2D90D255F2@teddy> References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <8q7sgiF5tpU1@mid.individual.net> <19891784-d6a3-41ac-a097-5902a6323bc0@o21g2000prn.googlegroups.com> <0b12cdb1-45b4-41e4-9bdb-074ee669d76b@k14g2000pre.googlegroups.com> <048FB74272D440A0915ABC7D76AE262B@teddy> <5782E9AD8A8342D691EB3549E5E0ED7B@octavian> <43549D4396F34EA697C45AA40EA12BC8@octavian> <5858167B51BD4813A1D36C2D90D255F2@teddy> Message-ID: > It might be true, however I have seen some modules that say that are ment for Python 2.5, for 2.6 or for 2.7, so there seem to be differences between these versions also. Python cares *a lot* about maintaining backward compatibiilty between all major versions. This is so true that I managed to use a unique code base for pyftpdlib which supports python from 2.3 to 2.7. Same for psutil which covers versions from 2.4 to 3.2 by using a unique code base! > It might be true, however I have seen some modules that say that are ment for Python 2.5, for 2.6 or for 2.7, so there seem to be differences between these versions also. Usually the differences between one version and another rely on *new features* only. One might decide to target a module only for a certain version of the 2.x serie because that certain version introduced a new functionnality which was not available before (silly example http://docs.python.org/library/os.html#os.initgroups ). All the other functionnalities are likely to remain the same and fully backward compatible. > py2exe offers the following installation kits, depending on the Python version. If you know, please tell me why there are different packages for different versions of Python? > > py2exe-0.6.9.win32-py2.5.exe > py2exe-0.6.9.win32-py2.4.exe > py2exe-0.6.9.win32-py2.3.exe > py2exe-0.6.9.win32-py2.6.exe > py2exe-0.6.9.win32-py2.7.exe That's a different story: those are pre-compiled binaries which are generated from a *unique* source code which support all those versions. If you have a compiler you can install pywin32 extension by using any Python version. --- Giampaolo http://code.google.com/p/pyftpdlib/ http://code.google.com/p/psutil/ 2011/1/27 Octavian Rasnita : > From: "Emile van Sebille" >> On 1/26/2011 11:02 PM Octavian Rasnita said... >> >>> As we all know, Python doesn't care too much about maintaining a >>> backward compatibility >> >> Where'd you get this idea? ?Between v2 and v3 yes, that was the intent. > > To be sincere I was thinking to the differences between Python 2 and 3. > >> ?But otherwise, I think there's another miscommunication behind this... > > It might be true, however I have seen some modules that say that are ment for Python 2.5, for 2.6 or for 2.7, so there seem to be differences between these versions also. > > py2exe offers the following installation kits, depending on the Python version. If you know, please tell me why there are different packages for different versions of Python? > > py2exe-0.6.9.win32-py2.5.exe > py2exe-0.6.9.win32-py2.4.exe > py2exe-0.6.9.win32-py2.3.exe > py2exe-0.6.9.win32-py2.6.exe > py2exe-0.6.9.win32-py2.7.exe > > Thanks. > > Octavian > > -- > http://mail.python.org/mailman/listinfo/python-list > From philip at semanchuk.com Thu Jan 27 13:38:00 2011 From: philip at semanchuk.com (Philip Semanchuk) Date: Thu, 27 Jan 2011 13:38:00 -0500 Subject: help with multiprocessing pool In-Reply-To: References: <2A124DD5-95F2-4DE0-AB0F-5D3EA39A230B@semanchuk.com> Message-ID: <016BC5FD-80F5-4578-9448-A592AD626C18@semanchuk.com> On Jan 27, 2011, at 1:12 PM, Craig Yoshioka wrote: > The code will be multi-platform. The OSXisms are there as an example, though I am developing on OS X machine. > > I've distilled my problem down to a simpler case, so hopefully that'll help troubleshoot. > > I have 2 files: > > test.py: > -------------------------------------------------------------- > from multiprocessing import Pool > > def square(x): > return x*x > > def squares(numbers): > pool = Pool(12) > return pool.map(square,numbers) > > > test2.py: > -------------------------------------------------------------- > from test import squares > > maxvalues = squares(range(3)) > print maxvalues > > > > Now if I import squares into the interactive interpreter: > > from test import squares > print squares(range(3)) > > I get the correct result, but if I try to import maxvalues from test2 the interactive interpreter python hangs. > if I run the script from bash, though, it seems to run fine. The short, complete example is much more useful, but it sounds like it demonstrates a different problem than you first described. Your first posting said that your code worked in the interpreter but failed when run from the command line. This code has the opposite problem. Correct? > I think it might have something to do with this note in the docs, though I am not sure how to use this information to fix my problem: > > Note: Functionality within this package requires that the __main__ method be importable by the children. This is covered inProgramming guidelines however it is worth pointing out here. This means that some examples, such as themultiprocessing.Pool examples will not work in the interactive interpreter. I suspect this is the problem with the demo above. Your original code ran fine in the interpreter, though, correct? bye Philip > > On Jan 27, 2011, at 6:39 AM, Philip Semanchuk wrote: > >> >> On Jan 25, 2011, at 8:19 PM, Craig Yoshioka wrote: >> >>> Hi all, >>> >>> I could really use some help with a problem I'm having. >> >> >> Hiya Craig, >> I don't know if I can help, but it's really difficult to do without a full working example. >> >> Also, your code has several OS X-isms in it so I guess that's the platform you're on. But in case you're on Windows, note that that platform requires some extra care when using multiprocessing: >> http://docs.python.org/library/multiprocessing.html#windows >> >> >> Good luck >> Philip >> >> >>> I wrote a function that can take a pattern of actions and it apply it to the filesystem. >>> It takes a list of starting paths, and a pattern like this: >>> >>> pattern = { >>> InGlob('Test/**'):{ >>> MatchRemove('DS_Store'):[], >>> NoMatchAdd('(alhpaID_)|(DS_Store)','warnings'):[], >>> MatchAdd('alphaID_','alpha_found'):[], >>> InDir('alphaID_'):{ >>> NoMatchAdd('(betaID_)|(DS_Store)','warnings'):[], >>> InDir('betaID_'):{ >>> NoMatchAdd('(gammaID_)|(DS_Store)','warnings'):[], >>> MatchAdd('gammaID_','gamma_found'):[] }}}} >>> >>> so if you run evalFSPattern(['Volumes/**'],pattern) it'll return a dictionary where: >>> >>> dict['gamma_found'] = [list of paths that matched] (i.e. '/Volumes/HD1/Test/alphaID_3382/betaID_38824/gammaID_848384') >>> dict['warning'] = [list of paths that failed to match] (ie. '/Volumes/HD1/Test/alphaID_3382/gammaID_47383') >>> >>> Since some of these volumes are on network shares I also wanted to parallelize this so that it would not block on IO. I started the parallelization by using multiprocessing.Pool and got it to work if I ran the fsparser from the interpreter. It ran in *much* less time and produced correct output that matched the non-parallelized version. The problem begins if I then try to use the parallelized function from within the code. >>> >>> For example I wrote a class whose instances are created around valid FS paths, that are cached to reduce expensive FS lookups. >>> >>> class Experiment(object): >>> >>> SlidePaths = None >>> >>> @classmethod >>> def getSlidePaths(cls): >>> if cls.SlidePaths == None: >>> cls.SlidePaths = fsparser(['/Volumes/**'],pattern) >>> return cls.SlidePaths >>> >>> @classmethod >>> def lookupPathWithGammaID(cls,id): >>> paths = cls.getSlidePaths() >>> ... >>> return paths[selected] >>> >>> @classmethod >>> def fromGamaID(cls,id): >>> path = cls.lookupPathWithGammaID(id) >>> return cls(path) >>> >>> def __init__(self,path) >>> self.Path = path >>> ... >>> >>> ... >>> >>> If I do the following from the interpreter it works: >>> >>>>>> from experiment import Experiment >>>>>> expt = Experiment.fromGammaID(10102) >>> >>> but if I write a script called test.py: >>> >>> from experiment import Experiment >>> expt1 = Experiment.fromGammaID(10102) >>> expt2 = Experiment.fromGammaID(10103) >>> comparison = expt1.compareTo(expt2) >>> >>> it fails, if I try to import it or run it from bash prompt: >>> >>>>>> from test import comparison (hangs forever) >>> $ python test.py (hangs forever) >>> >>> I would really like some help trying to figure this out... I thought it should work easily since all the spawned processes don't share data or state (their results are merged in the main thread). The classes used in the pattern are also simple python objects (use python primitives). >>> >>> >>> These are the main functions: >>> >>> def mapAction(pool,paths,action): >>> merge = {'next':[]} >>> for result in pool.map(action,paths): >>> if result == None: >>> continue >>> merge = mergeDicts(merge,result) >>> return merge >>> >>> >>> def mergeDicts(d1,d2): >>> for key in d2: >>> if key not in d1: >>> d1[key] = d2[key] >>> else: >>> d1[key] += d2[key] >>> return d1 >>> >>> >>> def evalFSPattern(paths,pattern): >>> pool = Pool(10) >>> results = {} >>> for action in pattern: >>> tomerge1 = mapAction(pool,paths,action) >>> tomerge2 = evalFSPattern(tomerge1['next'],pattern[action]) >>> del tomerge1['next'] >>> results = mergeDicts(results,tomerge1) >>> results = mergeDicts(results,tomerge2) >>> return results >>> >>> the classes used in the pattern (InGlob,NoMatchAdd,etc.) are callable classes that take a single parameter (a path) and return a dict result or None which makes them trivial to adapt to Pool.map. >>> >>> Note if I change the mapAction function to: >>> >>> def mapAction(pool,paths,action): >>> merge = {'next':[]} >>> for path in paths: >>> result = action(path) >>> if result == None: >>> continue >>> merge = mergeDicts(merge,result) >>> return merge >>> >>> everything works just fine. >>> >>> >>> Thanks. >>> >>> >>> -- >>> http://mail.python.org/mailman/listinfo/python-list >> >> -- >> http://mail.python.org/mailman/listinfo/python-list > From invalid at invalid.invalid Thu Jan 27 13:41:22 2011 From: invalid at invalid.invalid (Grant Edwards) Date: Thu, 27 Jan 2011 18:41:22 +0000 (UTC) Subject: Need GUI pop-up to edit a (unicode ?) string References: <3tqr08-bj2.ln1@murmur.very.softly> <7691fe98-37af-4ddf-a8a8-eadeef0d4a6e@y2g2000prf.googlegroups.com> <541c02df-b1fc-4376-bf17-e0531fe5c4bf@r29g2000yqj.googlegroups.com> Message-ID: On 2011-01-27, Stephen Hansen wrote: > On 1/27/11 10:04 AM, Grant Edwards wrote: >> On 2011-01-27, Stephen Hansen wrote: >> >>> In fact: everything that is "open source" is copyrighted. By >>> definition[* see footnote]. >> >> One (domestic US) exception would be open-source software written by >> an employee of the US federal government. Works produced by the US >> Government are not copyrighted under US domestic copyright law. Such >> works are copyrighted under international law (which is probably what >> the Python maintainers care about). > > I've actually wondered a bit about that: but the only open source > software that I'm aware of that's been government-adjacent has ended > up being written/owned by some University or joint venture funded by > a government agency -- it didn't fall into the public domain category > of content created directly by the federal government. That seems to be the usual case. > Are you aware of any code out there that is? Just curious. I'm not > arguing that the exception doesn't exist or anything. No, I can't point to anything significant or recent. I have vague memories of stuff from a long time ago (back when open-source software travelled hand-to-hand on DECUS tapes) written by people at NOAA or USGS that was copyright-free. -- Grant Edwards grant.b.edwards Yow! RELATIVES!! at gmail.com From tyler at tysdomain.com Thu Jan 27 13:43:14 2011 From: tyler at tysdomain.com (Littlefield, Tyler) Date: Thu, 27 Jan 2011 11:43:14 -0700 Subject: WxPython versus Tkinter. In-Reply-To: <4D41B5AF.8020200@ixokai.io> References: <4D3E4377.3060807@tysdomain.com> <9MB%o.14110$%64.6074@unlimited.newshosting.com> <4A48EDF6D7634F2E994661A457451E87@teddy> <753A4C5A6658470085804B13C80340F2@octavian> <4D41B5AF.8020200@ixokai.io> Message-ID: <4D41BCC2.2060906@tysdomain.com> >* Disclaimer: You are stupid if you think this is true. But seriously, >Octavian makes it REALLY hard to continue caring about something that I >actually cared about before and thought was important. People like Octavian do that. Sadly, it is one of the things holding the blind community back. I hope that with my arguments (for those that didn't just toss everything related to this thread), I have been able to get people to see a little differently and not consider Octavian as the voice for us all. I am by no means the guru with accessibility, but I can boast having worked with all three platforms (and now IOS) that were mentioned in this thread in terms of accessibility. If someone would like to make an app more accessible or anything the like, I would love to give comments and feedback. From jeanmichel at sequans.com Thu Jan 27 13:43:56 2011 From: jeanmichel at sequans.com (Jean-Michel Pichavant) Date: Thu, 27 Jan 2011 19:43:56 +0100 Subject: Which is the best book to learn python In-Reply-To: References: <188c0a9f-4e93-4fae-b3f9-e7c84f8030fd@v31g2000pri.googlegroups.com> <4D3DB915.9060601@sequans.com> Message-ID: <4D41BCEC.1040302@sequans.com> santosh hs wrote: > I am very new to object oriented concept, so I need to learn > everything frm basic, Will the above books fulfill > My need > > > read this http://www.freenetpages.co.uk/hp/alan.gauld/tutclass.htm and stop when they start to talk about VBscript :) JM From rantingrick at gmail.com Thu Jan 27 13:45:58 2011 From: rantingrick at gmail.com (rantingrick) Date: Thu, 27 Jan 2011 10:45:58 -0800 (PST) Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com> <9MB%o.14110$%64.6074@unlimited.newshosting.com> <4A48EDF6D7634F2E994661A457451E87@teddy> <753A4C5A6658470085804B13C80340F2@octavian> Message-ID: <84519d45-f584-4fab-b51c-cd53bde6c09a@p16g2000vbs.googlegroups.com> On Jan 27, 11:47?am, Grant Edwards wrote: > On 2011-01-27, Octavian Rasnita wrote: > If you don't care about communicating with others, then being civil > probably does have no value (except for keeping a job or being > avoiding being beaten up on the playground). ?If you want to > communicate (especially if you want somebody else to _do_ something), > then being civil and following normal social rules (etiquette) is > _very_ valuable. Without it the only thing you accomplish is to turn > people against you and whatever you're saying. When has Octavian been uncivil? This lecture of Octavian is ludicris! > There is no inherent "value" in driving on the right side of the road > vs. the left. ?However, there is a lot of value in driving on the side > of road that others expect you to. ?I'd tell you to try driving on the > other side of the road sometime to see how "easing communication" can > be valuable, but I'm afraid you'd try it... So i get it. When Ocatavian agrees with YOU he will be driving on the "right" side of the road. Until then, he is breaking the law and could cause a head on collision that could kill people. Wow good thing you were here to warn him of his "illegal" position and set him strait! You are such a friendly totalitarian, how do you keep a strait face -- Col. Hans Landa? From luismgz at gmail.com Thu Jan 27 13:53:50 2011 From: luismgz at gmail.com (=?ISO-8859-1?Q?Luis_M=2E_Gonz=E1lez?=) Date: Thu, 27 Jan 2011 10:53:50 -0800 (PST) Subject: Which is the best book to learn python References: <188c0a9f-4e93-4fae-b3f9-e7c84f8030fd@v31g2000pri.googlegroups.com> <4D3DB915.9060601@sequans.com> Message-ID: <4c677b91-a1e9-4700-ade8-35edaba550f5@l22g2000pre.googlegroups.com> On Jan 27, 3:43?pm, Jean-Michel Pichavant wrote: > santosh hs wrote: > > I am very new to object oriented concept, ?so I need to learn > > everything frm basic, Will the above books fulfill > > ?My need > > read thishttp://www.freenetpages.co.uk/hp/alan.gauld/tutclass.htm > > and stop when they start to talk about VBscript :) > > JM I strongly second this suggestion. Alan Gauld's example of a banking application was just what I needed to finally understand object oriented programming. This is how my head made the "click". Luis From mailing at franzoni.eu Thu Jan 27 14:03:18 2011 From: mailing at franzoni.eu (Alan Franzoni) Date: Thu, 27 Jan 2011 20:03:18 +0100 Subject: Behaviour-based interface/protocol implementation? In-Reply-To: References: Message-ID: On Wed, Jan 26, 2011 at 7:23 PM, Daniel Urban wrote: >> That's just what I'd like and I suppose can't be currently done with >> current ABC, PyProtocols or zope.interface implementations, right? > > It can. With __instancecheck__ you can override isinstance. It is > possible (for example) to write a subclass of abc.ABCMeta, which > extends __instancecheck__ to use an _instancehook classmethod > similarly to __subclasshook__. Then in your MyInterface class you can > implement _instancehook to check for methods/signatures/whatever you > want. Yes, __instancecheck__ could be used as an alternative hook with respect to maybe_implemented_by(), but there's no such logic for signature checking. That's a minor detail, I think. -- Alan Franzoni -- contact me at public@[mysurname].eu From me+list/python at ixokai.io Thu Jan 27 14:03:59 2011 From: me+list/python at ixokai.io (Stephen Hansen) Date: Thu, 27 Jan 2011 11:03:59 -0800 Subject: WxPython versus Tkinter. In-Reply-To: References: <4D4093AF.80806@etrix.com.au> Message-ID: <4D41C19F.4060306@ixokai.io> On 1/27/11 10:11 AM, rantingrick wrote: > On Jan 27, 1:28 am, "Octavian Rasnita" wrote: >> But WxPython is their work and they decision is their. > Actually we The word "we" does not mean what you think it means. -- Stephen Hansen ... Also: Ixokai ... Mail: me+list/python (AT) ixokai (DOT) io ... Blog: http://meh.ixokai.io/ -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 487 bytes Desc: OpenPGP digital signature URL: From mailing at franzoni.eu Thu Jan 27 14:05:19 2011 From: mailing at franzoni.eu (Alan Franzoni) Date: Thu, 27 Jan 2011 20:05:19 +0100 Subject: Behaviour-based interface/protocol implementation? In-Reply-To: References: Message-ID: On Thu, Jan 27, 2011 at 8:03 PM, Alan Franzoni wrote: > Yes, __instancecheck__ could be used as an alternative hook with > respect to maybe_implemented_by(), but there's no such logic for > signature checking. That's a minor detail, I think. On the contrary, now that I double checked, it can't be used that way; I don't want to modify the object I'm testing (it could be a third party object) nor I want to force it to be "registered" as a certain ABC; so __instancecheck__() is just useless here. -- Alan Franzoni -- contact me at public@[mysurname].eu From rustompmody at gmail.com Thu Jan 27 14:05:30 2011 From: rustompmody at gmail.com (rusi) Date: Thu, 27 Jan 2011 11:05:30 -0800 (PST) Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com> <9MB%o.14110$%64.6074@unlimited.newshosting.com> <4A48EDF6D7634F2E994661A457451E87@teddy> <753A4C5A6658470085804B13C80340F2@octavian> <84519d45-f584-4fab-b51c-cd53bde6c09a@p16g2000vbs.googlegroups.com> Message-ID: <793e3d37-f59c-4053-b38e-24bb48c44807@l22g2000pre.googlegroups.com> On Jan 27, 11:45?pm, rantingrick wrote: > > When has Octavian been uncivil? This lecture of Octavian is ludicris! > You are such a friendly totalitarian, how do you keep a strait face -- > Col. Hans Landa? And this mutual 'support' between Octavian and Ranter is ludicris(sic) Its quite clear to everyone here that -- RR has no interest in accessibility and is using it only for brownie points -- Octavian has no interest in a 21st century snazzy-looking toolkit which he cant see You guys would do yourselves a favor by forgetting about wx and getting your hands dirty with tkinter: - Octavian to (help) make it accessible - RR to make it look modern From stefan_ml at behnel.de Thu Jan 27 14:33:46 2011 From: stefan_ml at behnel.de (Stefan Behnel) Date: Thu, 27 Jan 2011 20:33:46 +0100 Subject: lxml.etree, namespaces and element insertion In-Reply-To: References: Message-ID: hein, 27.01.2011 19:16: > The other day i was processing an xml tree using lxml.etree. That tree > contained a namespace. During that processing i inserted an element. > Later on > i tried to find that element using xpath. And to my suprise that > element was > not found! Maybe my suprise is just the result of my marginal > knowledge about xml namespaces. > > After some examination i found out that the reason for not finding the > element > was that i did not supply a namespace when inserting the element. > [...] > I have two questions on this: > > - Is what i am seeing expected behavior? Yes. It's a common problem for new users, though. > - How am i supposed to detect a missing namespace, if there are no > differences > in the serialized representation? (That's what i initially used to > debug the problem.) This is a known problem of XML namespaces, which were only designed as an add-on to XML after the fact. The only advice I can give: be careful with the default namespace. Stefan From tjreedy at udel.edu Thu Jan 27 14:36:39 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Thu, 27 Jan 2011 14:36:39 -0500 Subject: WxPython versus Tkinter. In-Reply-To: References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> 0-47ef-a8b0-ca55d52ef683@1g20000qz.googlegroupssssss db3-4108-8a13-cc7d51f00b49@29g2200prb.googlegrooooooooo 5tpU1@mid.indivvvvvvvvvvv 784-d6a3-41ac-aa97-5902a6323bc00o21g2000prn.goooooooooooooooo <048FB74272D440A0915ABC7D76AE262B@teddy> <5782E9AD8A8342D691EB3549E5E0ED7B@octavian> Message-ID: On 1/27/2011 12:31 PM, Mark Roseman wrote: > Terry Reedy wrote: >> Tk itself is purely a gui package -- abstract widgits, geometry placers >> to make them visible, and an event system to make them active. But it >> does have the baggage of needing tcl included. About a decade ago, some >> people had the idea of removing the tcl dependency, but nothing seems to >> have come of that. For some people, the tcl baggage is reason enough to >> be rid of tk. > > > Thanks for raising this point. While I don't want to exhaustively > respond to this, I would like to raise a few important points. > > 1. The performance issues of having Tk use Tcl are negligible; the bulk > of Tk (code-wise and time-wise) are spent in C. Tcl itself is also very > fast nowadays, using all the usual techniques that modern dynamic > languages use. I have the impression that tcl is mostly used in initial setup and configuration, as opposed to repetitive drawing to the screen. But I do not really know. > > 2. Some people do have moral/purity objections to including Tcl, and > while I understand where the sentiment comes from, I think there are few > solid engineering reasons for this. There are two types of objections which have much less force now than a decade ago. One is the size issue. A tcl-less tk would presumably be smaller and thus add less to the Window distribution. The other is that tcl and Python were once seen as competing scripting languages, so why promote the competitor? Well, if there really was a contest, Python won. > 3. Removing Tcl from Tk makes keeping up with changes in Tk very > difficult. The Perl people found this out; Perl/Tk extracted Tcl, and > as a result remained using a 10 year old version of Tk because upgrading > would have been too painful. The newer Perl binding (Tkx) is in fact a > ridiculously thin binding over the Tcl API, and makes keeping up to date > with the newest Tk changes trivial, often requiring no code changes in > the Perl binding. Good point. Python should (continue to) just use the latest tk from its maintainers. If *they* were to decouple it from tcl (unlikely, it seems), fine. If not, so be it ;-). > If anyone does have questions, comments or concerns about Python > including a Tcl interpreter to use Tk, I'd be happy to try to explain or > address them. Thanks for the additional info. We need more of that. --- Terry Jan Reedy From alex.kapps at web.de Thu Jan 27 14:45:55 2011 From: alex.kapps at web.de (Alexander Kapps) Date: Thu, 27 Jan 2011 20:45:55 +0100 Subject: WxPython versus Tkinter. In-Reply-To: References: <4D3E4377.3060807@tysdomain.com><9MB%o.14110$%64.6074@unlimited.newshosting.com> <59F6E65E3D9A46AD8D7A3863F3C1DC84@teddy> <27f53f8c-7862-4366-9352-82ae9a2f3970@k3g2000yqc.googlegroups.com> <718D13777F254C839F9564BC4275DE0A@octavian> <4D402C42.1030407@tysdomain.com> <4D40447C.4010108@tysdomain.com> <33C68A0874BE4C66AB478EDFB64C2C1D@teddy> Message-ID: <4D41CB73.9090608@web.de> On 27.01.2011 19:33, rantingrick wrote: > Please don't use the lower accessibility percentage to prop up the low > Linux percentage in an attempt to win your argument. Because healthy > Linux users ARE NOT equal to handicapped people! Please don't put words into my mouth, idiot. And read my complete post. Nobody compares Linux users with handicapped people. I equalize handicapped Linux users with handicapped Windows users. And like it or not, the number of Linux users (handicapped or not) is raising. Again read my complete post. > And let's just get to the real point of this statement... This > argument stems from me saying that Lunux users should stop complaining > about downloading gtk to use wxPython because they use a non-hand- > holding OS. Another example of your limited understanding. Do you really believe the problem lies in downloading dependencies? Hasn't somebody already explained that it's about development dependencies? > And now you attempt to compare yourself to handicapped > people in a veiled way so we feel sorry for you? Well it worked! I DO > feel sorry for you. Congratulations! I'm entirely sure that you deliberately misunderstood me and now try to discredit me with putting this nonsense into my mouth. You are really a sad, disgusting asshole. Don't bother replying. I won't read. (How many more plonks will it take till you consider changing your behaviour?) From mark at markroseman.com Thu Jan 27 14:51:52 2011 From: mark at markroseman.com (Mark Roseman) Date: Thu, 27 Jan 2011 12:51:52 -0700 Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <048FB74272D440A0915ABC7D76AE262B@teddy> <5782E9AD8A8342D691EB3549E5E0ED7B@octavian> Message-ID: Terry Reedy wrote: > > 1. The performance issues of having Tk use Tcl are negligible; the bulk > > of Tk (code-wise and time-wise) are spent in C. Tcl itself is also very > > fast nowadays, using all the usual techniques that modern dynamic > > languages use. > > I have the impression that tcl is mostly used in initial setup and > configuration, as opposed to repetitive drawing to the screen. But I do > not really know. Tcl as a scripting language is used during some initialization things, used to invoke callbacks, and a few other non-performance critical areas. It sometimes helps to think of Tcl as a very powerful C library that happens to have a scripting language on top. :-) For example, there are C functions in the Tcl library that do things like string management, cross platform I/O, very efficient hash tables, dynamic lists, etc. that are used everywhere inside Tk. But none of those calls mean a trip through the Tcl interpreter per se. Every dynamic language would have similar internals of course, though with slight differences and different API's. Mark From ethan at stoneleaf.us Thu Jan 27 14:58:40 2011 From: ethan at stoneleaf.us (Ethan Furman) Date: Thu, 27 Jan 2011 11:58:40 -0800 Subject: Behaviour-based interface/protocol implementation? In-Reply-To: References: Message-ID: <4D41CE70.1090900@stoneleaf.us> Alan Franzoni wrote: > Hello, > I'd like to have a system which lets me do certain actions if the > duck-type of a certain objects matches what I expect, i.e. I'd like to > have a formalization of what it's sometimes done through getattr() > calls: > > if getattr(myobj, "somemethod", None) is not None: > myobj.somemethod(somevalue) [...] > > I'd like to do a kind of runtime-check for signatures. Of course there > couldn't be an absolute certainty of interface implementation, because > a runtime dynamic proxy method (accepting *args and **kwargs in its > signature, as an example) might just fool my signature check. When you signature check, do you mean counting the number of arguments, or actually checking argument types? ~Ethan~ From tjreedy at udel.edu Thu Jan 27 15:00:38 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Thu, 27 Jan 2011 15:00:38 -0500 Subject: WxPython versus Tkinter. In-Reply-To: References: <4D3E4377.3060807@tysdomain.com><9MB%o.14110$%64.6074@unlimited.newshosting.com><4A48EDF6D7634F2E994661A457451E87@teddy><753A4C5A6658470085804B13C80340F2@octavian> <4D40A97F.8090209@tysdomain.com><00ABBA322416409EB749102EB1CC5E61@octavian> <4D418054.8050002@tysdomain.com> Message-ID: On 1/27/2011 12:54 PM, Octavian Rasnita wrote: > Everything that's not accessible is not recommended. By you. We get that. >Tkinter should be at most accepted because there is no better solution, As I said at the beginning of this thread, tkinter is currently the only option. What would have happened if there had been a real competitor when 3.0 was being developed? What would happen in the future if one were developed? I do not think anyone really knows. > at least for Python 3, not because it is the recommended solution. AS far as I know, Guido has never recommended any particular gui and I believe he has avoided doing so when asked. He is happy that there are different choices. -- Terry Jan Reedy From tyler at tysdomain.com Thu Jan 27 15:22:38 2011 From: tyler at tysdomain.com (Littlefield, Tyler) Date: Thu, 27 Jan 2011 13:22:38 -0700 Subject: WxPython versus Tkinter. In-Reply-To: <4D41CB73.9090608@web.de> References: <4D3E4377.3060807@tysdomain.com><9MB%o.14110$%64.6074@unlimited.newshosting.com> <59F6E65E3D9A46AD8D7A3863F3C1DC84@teddy> <27f53f8c-7862-4366-9352-82ae9a2f3970@k3g2000yqc.googlegroups.com> <718D13777F254C839F9564BC4275DE0A@octavian> <4D402C42.1030407@tysdomain.com> <4D40447C.4010108@tysdomain.com> <33C68A0874BE4C66AB478EDFB64C2C1D@teddy> <4D41CB73.9090608@web.de> Message-ID: <4D41D40E.7060700@tysdomain.com> >Because healthy Linux users ARE NOT equal to handicapped people! O? I bet I could run circles around RR in the shell, any day. Why are you trying to promote accessibility for a group of people you consider not equal to a group of "healthy" people? From tjreedy at udel.edu Thu Jan 27 15:42:25 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Thu, 27 Jan 2011 15:42:25 -0500 Subject: WxPython versus Tkinter. In-Reply-To: References: <4D3E4377.3060807@tysdomain.com> <9MB%o.14110$%64.6074@unlimited.newshosting.com> <59F6E65E3D9A46AD8D7A3863F3C1DC84@teddy> <27f53f8c-7862-4366-9352-82ae9a2f3970@k3g2000yqc.googlegroups.com> <718D13777F254C839F9564BC4275DE0A@octavian> <4D402C42.1030407@tysdomain.com> <4D40447C.4010108@tysdomain.com> <33C68A0874BE4C66AB478EDFB64C2C1D@teddy> <4D407321.3090705@web.de> <1296128007.17192.1417506961@webmail.messagingengine.com> Message-ID: On 1/27/2011 12:57 PM, Grant Edwards wrote: > A very important way to help would be to test accessibility features > and post accurate, detailed, bug-reports. For example: pygui pretty much uses native widgets on Windows and OX and gtk (I believe) on *nix. How is the accessibility of those widget sets *as accessed through pygui*? Is it different from the 'native' accessibility of each of those set? -- Terry Jan Reedy From rantingrick at gmail.com Thu Jan 27 15:47:17 2011 From: rantingrick at gmail.com (rantingrick) Date: Thu, 27 Jan 2011 12:47:17 -0800 (PST) Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com><9MB%o.14110$%64.6074@unlimited.newshosting.com><4A48EDF6D7634F2E994661A457451E87@teddy><753A4C5A6658470085804B13C80340F2@octavian> <4D40A97F.8090209@tysdomain.com><00ABBA322416409EB749102EB1CC5E61@octavian> <4D418054.8050002@tysdomain.com> Message-ID: <171961f5-00da-444b-95fa-f3d95a685956@24g2000yqa.googlegroups.com> On Jan 27, 2:00?pm, Terry Reedy wrote: > AS far as I know, Guido has never recommended any particular gui and I > believe he has avoided doing so when asked. He is happy that there are > different choices. different choices OUTSIDE the stdlib. INSIDE the stdlib we have no choice. Just wanted to make that clear. From neilc at norwich.edu Thu Jan 27 16:06:49 2011 From: neilc at norwich.edu (Neil Cerutti) Date: 27 Jan 2011 21:06:49 GMT Subject: lxml.etree, namespaces and element insertion References: Message-ID: <8qe539FscdU1@mid.individual.net> On 2011-01-27, hein wrote: > - How am i supposed to detect a missing namespace, if there > are no differences in the serialized representation? (That's > what i initially used to debug the problem.) lxml's pretty printer is at fault, as it emits unprefixed names whenever possible while serializing. For debugging, try using .dump instead. Hopefully that makes the error obvious. -- Neil Cerutti From rantingrick at gmail.com Thu Jan 27 16:10:09 2011 From: rantingrick at gmail.com (rantingrick) Date: Thu, 27 Jan 2011 13:10:09 -0800 (PST) Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com><9MB%o.14110$%64.6074@unlimited.newshosting.com><4A48EDF6D7634F2E994661A457451E87@teddy><753A4C5A6658470085804B13C80340F2@octavian> <4D40A97F.8090209@tysdomain.com><00ABBA322416409EB749102EB1CC5E61@octavian> <4D418054.8050002@tysdomain.com> Message-ID: <1a37f3d8-b580-4d6d-a5a3-de8cc1e656dd@y26g2000yqd.googlegroups.com> On Jan 27, 2:00?pm, Terry Reedy wrote: > On 1/27/2011 12:54 PM, Octavian Rasnita wrote: > > > Everything that's not accessible is not recommended. > > By you. We get that. > > ?>Tkinter should be at most accepted because there is no better solution, > > As I said at the beginning of this thread, tkinter is currently the only > option. What would have happened if there had been a real competitor > when 3.0 was being developed? What would happen in the future if one > were developed? I do not think anyone really knows. > > > at least for Python 3, not because it is the recommended solution. > > AS far as I know, Guido has never recommended any particular gui and I > believe he has avoided doing so when asked. Yes but his silence speaks louder than words. He is saying " While i won't defend Tkinter publicly, i won't promote any others as well". This is a standard response you'd expect from a politician. These types of questions avoid dealing with the elephant in the room. We can't just assume that Tkinter is best for Python just because "Guido" does not want to "ruffle" some features. Actually if you look back over the very few post where Guido did offer an argument for Tkinter you'll the find the argument to be very weak. And to make matters worse no one has the balls to question or argue Guido. Now whilst i greatly respect Guido i will not hesitate for one second to call him on weak arguments. Case in point: Just recently i posted one of Guido's such arguments in another thread and responded to the argument. The original thread was from roughly eight years ago. Yes this is how long it has been since Guido offered argument for Tkinter. Does he honestly think that the world has not changed significantly in eight years as to render Tkinter into legacy? Does he also want us to believe that the world has not changed dramatically in the last twenty years since Tkinter was introduced? I have yet to get a response for his weak argument eight years ago and i can expect we will hear nothing now. My point is this: If you (Guido) are going to offer weak arguments then you must answer challenges to these weak arguments with facts. So I now challenge Guido to inject a solid argument for keeping Tkinter and i challenge him now. Before the entire world we will hash this out once and for all. Just be aware Guido, that i will NOT be afraid to question your facts and present good arguments based on fact. If you *do* inject your opinion on this very important subject matter --and do so here in a public forum-- then i believe the community will take you more seriously. And *i* will take you more seriously. All of your subordinates are unable to challenge me. Will you answer the challenge Guido van Rossum? Will you? The community at large needs to know what Guido van Rossum thinks. You owe us that much Guido. From mailing at franzoni.eu Thu Jan 27 16:12:45 2011 From: mailing at franzoni.eu (Alan Franzoni) Date: Thu, 27 Jan 2011 22:12:45 +0100 Subject: Behaviour-based interface/protocol implementation? In-Reply-To: <4D41CE70.1090900@stoneleaf.us> References: <4D41CE70.1090900@stoneleaf.us> Message-ID: On Thu, Jan 27, 2011 at 8:58 PM, Ethan Furman wrote: > When you signature check, do you mean counting the number of arguments, or > actually checking argument types? In order to check for argument types I should either assume type annotation (python 3 only, optional) or parse the docstring for the method, which might not be available or be out of sync. I just want to check for method name, number and/or names of the arguments. It might not be trivial in python because the very same argument can be passed either as a positional or a kw argument, so def method1(self, a, b): ... def method1(self, c, d): ... could satisfy or not the very same interface, depending whether the args are passed as postional or kw. -- Alan Franzoni -- contact me at public@[mysurname].eu From emile at fenx.com Thu Jan 27 16:19:42 2011 From: emile at fenx.com (Emile van Sebille) Date: Thu, 27 Jan 2011 13:19:42 -0800 Subject: WxPython versus Tkinter. In-Reply-To: <171961f5-00da-444b-95fa-f3d95a685956@24g2000yqa.googlegroups.com> References: <4D3E4377.3060807@tysdomain.com><9MB%o.14110$%64.6074@unlimited.newshosting.com><4A48EDF6D7634F2E994661A457451E87@teddy><753A4C5A6658470085804B13C80340F2@octavian> <4D40A97F.8090209@tysdomain.com><00ABBA322416409EB749102EB1CC5E61@octavian> <4D418054.8050002@tysdomain.com> <171961f5-00da-444b-95fa-f3d95a685956@24g2000yqa.googlegroups.com> Message-ID: On 1/27/2011 12:47 PM rantingrick said... > different choices OUTSIDE the stdlib. INSIDE the stdlib we have no > choice. Just wanted to make that clear. Only when you restrict yourself to the artificial restriction of 'no third party downloads allowed -- python must supply the right choice for my application no matter what' On that basis, os's ought to come with your browser and editor of choice as choice is the domain of the environment - not the user. If you think anyone capable of writing a gui application is incapable and needs to be babysat to that degree, then we're all stupid. T'ain't so. Emile From pavlovevidence at gmail.com Thu Jan 27 16:30:26 2011 From: pavlovevidence at gmail.com (Carl Banks) Date: Thu, 27 Jan 2011 13:30:26 -0800 (PST) Subject: Behaviour-based interface/protocol implementation? References: Message-ID: <999ee2b0-95b7-49be-a33d-f9c040ab21f5@32g2000yql.googlegroups.com> On Jan 24, 2:13?am, Alan Franzoni wrote: > Hello, > I'd like to have a system which lets me do certain actions if the > duck-type of a certain objects matches what I expect, i.e. I'd like to > have a formalization of what it's sometimes done through getattr() > calls: > > if getattr(myobj, "somemethod", None) is not None: > ? ? myobj.somemethod(somevalue) > > The above approach is sometimes too naive, because a) clutters code > with many getattr calls and ifs b) I might want to check for multiple > attributes and c) only checks for the method name and not for the > method's signature. Write some kind of signature proxy to do it. class SomeSignature(object): def __init__(self,target): self.target = target def somemethod(self,value): if hasattr(self.target,"somemethod"): self.target.somemethod(value) SomeSignature(myobj).somemethod(somevalue) Generalizing the proxy to easily accommodate all kinds of signatures to your heart's delight left as an exercise (and it's likley to involve metaclass programming). > After looking at PyProtocols, zope.interface and python's own abc > module, I'm left with a doubt: does any behaviour-based "interface > testing" system exist for Python? Based on this thread, you have quite specific requirements, so it's doubtful someone else has implemented exactly what you want. And because it hasn't been mentioned in this thread yet--surprisingly-- many people in Python prefer the EAFP strategy, "Easier to Ask Forgiveness than Permission", that is, to just do it and handle the resulting exception: try: myobj.somemethod(somevalue) except AttributeError: # doesn't fit signature, so do nothing pass Personally, I have my doubts about the method in general. It's definitely preferrable in many cases (like opening a file, where it avoids a race condition) but for something like this I don't see it working out too well. But I'm just throwing it out there. Carl Banks From rantingrick at gmail.com Thu Jan 27 16:38:52 2011 From: rantingrick at gmail.com (rantingrick) Date: Thu, 27 Jan 2011 13:38:52 -0800 (PST) Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com><9MB%o.14110$%64.6074@unlimited.newshosting.com><4A48EDF6D7634F2E994661A457451E87@teddy><753A4C5A6658470085804B13C80340F2@octavian> <4D40A97F.8090209@tysdomain.com><00ABBA322416409EB749102EB1CC5E61@octavian> <4D418054.8050002@tysdomain.com> <171961f5-00da-444b-95fa-f3d95a685956@24g2000yqa.googlegroups.com> Message-ID: On Jan 27, 3:19?pm, Emile van Sebille wrote: > On 1/27/2011 12:47 PM rantingrick said... > > > different choices OUTSIDE the stdlib. INSIDE the stdlib we have no > > choice. Just wanted to make that clear. > > Only when you restrict yourself to the artificial restriction of 'no > third party downloads allowed -- python must supply the right choice for > my application no matter what' Some people ARE in enviroments where they would like to add third party downloads but cannot. > On that basis, os's ought to come with your browser and editor of choice > as choice is the domain of the environment - not the user. Well then explain why Windows still ships with that god awful windows explorer? Tkinter IS Windows Explorer. Antiquated, legacy, bloatware. And it need to die! But this misses the entire point. We are not trying to please everyone because THAT would be impossible. What we are trying to do is keep Python relevant in the 21st century. Continuing to lug Tkinter around is killing Python's evolution. From kb1pkl at aim.com Thu Jan 27 16:48:42 2011 From: kb1pkl at aim.com (Corey Richardson) Date: Thu, 27 Jan 2011 16:48:42 -0500 Subject: WxPython versus Tkinter. In-Reply-To: <1a37f3d8-b580-4d6d-a5a3-de8cc1e656dd@y26g2000yqd.googlegroups.com> References: <4D3E4377.3060807@tysdomain.com><9MB%o.14110$%64.6074@unlimited.newshosting.com><4A48EDF6D7634F2E994661A457451E87@teddy><753A4C5A6658470085804B13C80340F2@octavian> <4D40A97F.8090209@tysdomain.com><00ABBA322416409EB749102EB1CC5E61@octavian> <4D418054.8050002@tysdomain.com> <1a37f3d8-b580-4d6d-a5a3-de8cc1e656dd@y26g2000yqd.googlegroups.com> Message-ID: <4D41E83A.3030209@aim.com> On 01/27/2011 04:10 PM, rantingrick wrote: > On Jan 27, 2:00 pm, Terry Reedy wrote: >> On 1/27/2011 12:54 PM, Octavian Rasnita wrote: >> >>> Everything that's not accessible is not recommended. >> >> By you. We get that. >> >> >Tkinter should be at most accepted because there is no better solution, >> >> As I said at the beginning of this thread, tkinter is currently the only >> option. What would have happened if there had been a real competitor >> when 3.0 was being developed? What would happen in the future if one >> were developed? I do not think anyone really knows. >> >>> at least for Python 3, not because it is the recommended solution. >> >> AS far as I know, Guido has never recommended any particular gui and I >> believe he has avoided doing so when asked. > > Yes but his silence speaks louder than words. He is saying " While i > won't defend Tkinter publicly, i won't promote any others as well". > This is a standard response you'd expect from a politician. These > types of questions avoid dealing with the elephant in the room. > > We can't just assume that Tkinter is best for Python just because > "Guido" does not want to "ruffle" some features. Actually if you look > back over the very few post where Guido did offer an argument for > Tkinter you'll the find the argument to be very weak. And to make > matters worse no one has the balls to question or argue Guido. Now > whilst i greatly respect Guido i will not hesitate for one second to > call him on weak arguments. > > Case in point: Just recently i posted one of Guido's such arguments in > another thread and responded to the argument. The original thread was > from roughly eight years ago. Yes this is how long it has been since > Guido offered argument for Tkinter. Does he honestly think that the > world has not changed significantly in eight years as to render > Tkinter into legacy? Does he also want us to believe that the world > has not changed dramatically in the last twenty years since Tkinter > was introduced? I have yet to get a response for his weak argument > eight years ago and i can expect we will hear nothing now. > wxPython is the best and most mature cross-platform GUI toolkit, given a number of constraints. The only reason wxPython isn't the standard Python GUI toolkit is that Tkinter was there first. -- Guido van Rossum (from http://www.wxpython.org/quotes.php) A weak argument - yes. But the thought is there, and it's the thought that counts, right? ;-) From tyler at tysdomain.com Thu Jan 27 16:49:21 2011 From: tyler at tysdomain.com (Littlefield, Tyler) Date: Thu, 27 Jan 2011 14:49:21 -0700 Subject: WxPython versus Tkinter. Message-ID: <4D41E861.9040604@tysdomain.com> >Yes but his silence speaks louder than words. He is saying " While i >won't defend Tkinter publicly, i won't promote any others as well". That's the best translation I've ever heard: taking silence and diverting it into your own meaning for what you want it to mean. From invalid at invalid.invalid Thu Jan 27 16:54:57 2011 From: invalid at invalid.invalid (Grant Edwards) Date: Thu, 27 Jan 2011 21:54:57 +0000 (UTC) Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com> <9MB%o.14110$%64.6074@unlimited.newshosting.com> <4A48EDF6D7634F2E994661A457451E87@teddy> <753A4C5A6658470085804B13C80340F2@octavian> <4D40A97F.8090209@tysdomain.com> <00ABBA322416409EB749102EB1CC5E61@octavian> <4D418054.8050002@tysdomain.com> <1a37f3d8-b580-4d6d-a5a3-de8cc1e656dd@y26g2000yqd.googlegroups.com> Message-ID: On 2011-01-27, rantingrick wrote: >> AS far as I know, Guido has never recommended any particular gui and I >> believe he has avoided doing so when asked. > > Yes but his silence speaks louder than words. He is saying " While i > won't defend Tkinter publicly, i won't promote any others as well". > This is a standard response you'd expect from a politician. These > types of questions avoid dealing with the elephant in the room. I think there are a lot of people who think that including a GUI in the standard library was a mistake and the best solution would be to get rid of Tkinter and replace it with nothing. If I were Guido and thought that, I'd probably keep mum about it as well. :) [I'm not claiming Guidoe does think that, but there are some pretty good arguments for not including a GUI at all.] > The community at large needs to know what Guido van Rossum thinks. You > owe us that much Guido. He doesn't "owe" you or me anything. -- Grant Edwards grant.b.edwards Yow! I'm not available at for comment.. gmail.com From emile at fenx.com Thu Jan 27 17:06:01 2011 From: emile at fenx.com (Emile van Sebille) Date: Thu, 27 Jan 2011 14:06:01 -0800 Subject: WxPython versus Tkinter. In-Reply-To: References: <4D3E4377.3060807@tysdomain.com><9MB%o.14110$%64.6074@unlimited.newshosting.com><4A48EDF6D7634F2E994661A457451E87@teddy><753A4C5A6658470085804B13C80340F2@octavian> <4D40A97F.8090209@tysdomain.com><00ABBA322416409EB749102EB1CC5E61@octavian> <4D418054.8050002@tysdomain.com> <171961f5-00da-444b-95fa-f3d95a685956@24g2000yqa.googlegroups.com> Message-ID: On 1/27/2011 1:38 PM rantingrick said... > Continuing to lug Tkinter around > is killing Python's evolution. Huh? Can you provide a reference where someone passed over python because of tkinter's inclusion in the standard library? You certainly can't mean that python's evolution over the past 10+ years from 1.5 days to 3.2rc1 was effectively killed. Why would anyone assume any different for the next ten? Emile From rantingrick at gmail.com Thu Jan 27 17:08:37 2011 From: rantingrick at gmail.com (rantingrick) Date: Thu, 27 Jan 2011 14:08:37 -0800 (PST) Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com><9MB%o.14110$%64.6074@unlimited.newshosting.com><4A48EDF6D7634F2E994661A457451E87@teddy><753A4C5A6658470085804B13C80340F2@octavian> <4D40A97F.8090209@tysdomain.com><00ABBA322416409EB749102EB1CC5E61@octavian> <4D418054.8050002@tysdomain.com> <1a37f3d8-b580-4d6d-a5a3-de8cc1e656dd@y26g2000yqd.googlegroups.com> Message-ID: On Jan 27, 3:48?pm, Corey Richardson wrote: > On 01/27/2011 04:10 PM, rantingrick wrote: > > > > > > > > > > > On Jan 27, 2:00 pm, Terry Reedy wrote: > >> On 1/27/2011 12:54 PM, Octavian Rasnita wrote: > > >>> Everything that's not accessible is not recommended. > > >> By you. We get that. > > >> ?>Tkinter should be at most accepted because there is no better solution, > > >> As I said at the beginning of this thread, tkinter is currently the only > >> option. What would have happened if there had been a real competitor > >> when 3.0 was being developed? What would happen in the future if one > >> were developed? I do not think anyone really knows. > > >>> at least for Python 3, not because it is the recommended solution. > > >> AS far as I know, Guido has never recommended any particular gui and I > >> believe he has avoided doing so when asked. > > > Yes but his silence speaks louder than words. He is saying " While i > > won't defend Tkinter publicly, i won't promote any others as well". > > This is a standard response you'd expect from a politician. These > > types of questions avoid dealing with the elephant in the room. > > > We can't just assume that Tkinter is best for Python just because > > "Guido" does not want to "ruffle" some features. Actually if you look > > back over the very few post where Guido did offer an argument for > > Tkinter you'll the find the argument to be very weak. And to make > > matters worse no one has the balls to question or argue Guido. Now > > whilst i greatly respect Guido i will not hesitate for one second to > > call him on weak arguments. > > > Case in point: Just recently i posted one of Guido's such arguments in > > another thread and responded to the argument. The original thread was > > from roughly eight years ago. Yes this is how long it has been since > > Guido offered argument for Tkinter. Does he honestly think that the > > world has not changed significantly in eight years as to render > > Tkinter into legacy? Does he also want us to believe that the world > > has not changed dramatically in the last twenty years since Tkinter > > was introduced? I have yet to get a response for his weak argument > > eight years ago and i can expect we will hear nothing now. > > wxPython is the best and most mature cross-platform GUI toolkit, given a > number of constraints. The only reason wxPython isn't the standard > Python GUI toolkit is that Tkinter was there first. > -- Guido van Rossum You forgot to put a date on that statement. Like of all of Guido's statements about Python they are from many, many years ago. And when i say many years i am talking 1990's. NEWSFLASH! The world has changed, GUI's have changed. All we have are these quotes from the 1990's to go on and i have had enough of this silence from Guido. Guid, SHOW YOURSELF! Come out from behind the safety and security of python-dev. Come out and show the peasants that you are in fact still a part of this community. Come out and walk among us. Come out and re- join the people in united celebration of 21st century evolution. But most of all, come out and defend those weak arguments you gave eight years ago. Even IF we "imagine" your arguments where enough to keep Tkinter then, how can you expect us to believe that now those arguments still hold merit in the year 2011? It is high time for you (Guido van Rossum) to weigh in on this discussion. The time of myths and legends is over, the time of community is NOW! Show yourself! From python at rcn.com Thu Jan 27 17:15:26 2011 From: python at rcn.com (Raymond Hettinger) Date: Thu, 27 Jan 2011 14:15:26 -0800 (PST) Subject: Wrappers in python References: <2100032d-dd99-4b10-b445-76b5dd1efb91@r19g2000prm.googlegroups.com> Message-ID: <8e225711-c412-4d3c-97f7-96d9ad17dabb@o7g2000prn.googlegroups.com> On Jan 27, 4:10?am, sl33k_ wrote: > What are wrappers? > > ?What entities do they wrap around? > > Struggling to understand the concept. http://www.castle-cadenza.demon.co.uk/wrapper.htm Raymond From mailing at franzoni.eu Thu Jan 27 17:23:56 2011 From: mailing at franzoni.eu (Alan Franzoni) Date: Thu, 27 Jan 2011 23:23:56 +0100 Subject: Behaviour-based interface/protocol implementation? In-Reply-To: <999ee2b0-95b7-49be-a33d-f9c040ab21f5@32g2000yql.googlegroups.com> References: <999ee2b0-95b7-49be-a33d-f9c040ab21f5@32g2000yql.googlegroups.com> Message-ID: On Thu, Jan 27, 2011 at 10:30 PM, Carl Banks wrote: > Write some kind of signature proxy to do it. I don't have a specific implementation idea yet, I see how that grows. > Based on this thread, you have quite specific requirements, so it's > doubtful someone else has implemented exactly what you want. Yes, but asking is better than blinding reimplementing :-) > And because it hasn't been mentioned in this thread yet--surprisingly-- > many people in Python prefer the EAFP strategy, "Easier to Ask > Forgiveness than Permission", that is, to just do it and handle the > resulting exception: > > try: > ? ?myobj.somemethod(somevalue) > except AttributeError: > ? ?# doesn't fit signature, so do nothing > ? ?pass Sure. That's an approach. But this has drawbacks. - it violates the CQS principle: http://en.wikipedia.org/wiki/Command-query_separation - Maybe my interface has not just a single method, and I might want to call multiple methods on my object. I need to check for all signatures before proceeding. - When calling the method, if an exception is raised - either AttributeError or TypeError most of the times - it could not be generated from my own call, but from a call deeper into the stack; It's easy to just think "that object doesn't support that interface" I could mistake an object for not supporting an interface, and I could silently swallow a true runtime exception instead. Maybe some stack analysis could be performed, but I'd prefer to check as much as I can *before* calling. - Sometimes I'd like to group objects depending on their *behaviour* (not their type), and then feed them somewhere else without actually calling their methods. If I can know their behaviour just after they've been called, it might be just too late. -- Alan Franzoni -- contact me at public@[mysurname].eu From rantingrick at gmail.com Thu Jan 27 17:24:12 2011 From: rantingrick at gmail.com (rantingrick) Date: Thu, 27 Jan 2011 14:24:12 -0800 (PST) Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com><9MB%o.14110$%64.6074@unlimited.newshosting.com><4A48EDF6D7634F2E994661A457451E87@teddy><753A4C5A6658470085804B13C80340F2@octavian> <4D40A97F.8090209@tysdomain.com><00ABBA322416409EB749102EB1CC5E61@octavian> <4D418054.8050002@tysdomain.com> <1a37f3d8-b580-4d6d-a5a3-de8cc1e656dd@y26g2000yqd.googlegroups.com> Message-ID: On Jan 27, 3:48?pm, Corey Richardson wrote: > A weak argument - yes. But the thought is there, and it's the thought > that counts, right? ;-) What thought? It screams lack of thought to me. We should just ignore a clearly better option because some other option was chosen first, THATS IT? Thats the best he can do? And it shows lack of resolve to move forward even in light of clearly better solutions. It boils down to lack of vision. They say as you grow older you start "setting your ways". Case in point <-- From rantingrick at gmail.com Thu Jan 27 17:28:39 2011 From: rantingrick at gmail.com (rantingrick) Date: Thu, 27 Jan 2011 14:28:39 -0800 (PST) Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com> <9MB%o.14110$%64.6074@unlimited.newshosting.com> <4A48EDF6D7634F2E994661A457451E87@teddy> <753A4C5A6658470085804B13C80340F2@octavian> <4D40A97F.8090209@tysdomain.com> <00ABBA322416409EB749102EB1CC5E61@octavian> <4D418054.8050002@tysdomain.com> <1a37f3d8-b580-4d6d-a5a3-de8cc1e656dd@y26g2000yqd.googlegroups.com> Message-ID: <1797b519-88f2-4b4f-832b-e8392619ac2e@q14g2000vbf.googlegroups.com> On Jan 27, 3:54?pm, Grant Edwards wrote: > On 2011-01-27, rantingrick wrote: > > >> AS far as I know, Guido has never recommended any particular gui and I > >> believe he has avoided doing so when asked. > > > Yes but his silence speaks louder than words. He is saying " While i > > won't defend Tkinter publicly, i won't promote any others as well". > > This is a standard response you'd expect from a politician. These > > types of questions avoid dealing with the elephant in the room. > > I think there are a lot of people who think that including a GUI in > the standard library was a mistake and the best solution would be to > get rid of Tkinter and replace it with nothing. ?If I were Guido and > thought that, I'd probably keep mum about it as well. :) Well i have considered that *maybe* he does feel this way. And by removing Tkinter not only would we take a huge burden from py-dev but we would also free Tkinter from the chains of stdlib. Could this help move Tkinter forward, i think so. > > The community at large needs to know what Guido van Rossum thinks. You > > owe us that much Guido. > > He doesn't "owe" you or me anything. Actually yes, he must give us good reason for this "holding on" to legacy technology. We deserve at least the respect of an explanation. That IS NOT too much to ask. I am tired of hearing Guido's thoughts second hand, i want to hear it strait from the horses mouth! From kb1pkl at aim.com Thu Jan 27 17:39:15 2011 From: kb1pkl at aim.com (Corey Richardson) Date: Thu, 27 Jan 2011 17:39:15 -0500 Subject: WxPython versus Tkinter. In-Reply-To: References: <4D3E4377.3060807@tysdomain.com><9MB%o.14110$%64.6074@unlimited.newshosting.com><4A48EDF6D7634F2E994661A457451E87@teddy><753A4C5A6658470085804B13C80340F2@octavian> <4D40A97F.8090209@tysdomain.com><00ABBA322416409EB749102EB1CC5E61@octavian> <4D418054.8050002@tysdomain.com> <1a37f3d8-b580-4d6d-a5a3-de8cc1e656dd@y26g2000yqd.googlegroups.com> Message-ID: <4D41F413.8000501@aim.com> On 01/27/2011 05:08 PM, rantingrick wrote: >> wxPython is the best and most mature cross-platform GUI toolkit, given a >> number of constraints. The only reason wxPython isn't the standard >> Python GUI toolkit is that Tkinter was there first. >> -- Guido van Rossum > > You forgot to put a date on that statement. I didn't forget - there was no date provided. From urban.dani at gmail.com Thu Jan 27 17:41:08 2011 From: urban.dani at gmail.com (Daniel Urban) Date: Thu, 27 Jan 2011 23:41:08 +0100 Subject: Behaviour-based interface/protocol implementation? In-Reply-To: References: Message-ID: On Thu, Jan 27, 2011 at 20:05, Alan Franzoni wrote: > On Thu, Jan 27, 2011 at 8:03 PM, Alan Franzoni wrote: >> Yes, __instancecheck__ could be used as an alternative hook with >> respect to maybe_implemented_by(), but there's no such logic for >> signature checking. That's a minor detail, I think. > > On the contrary, now that I double checked, it can't be used that way; > I don't want to modify the object I'm testing (it could be a third > party object) nor I want to force it to be "registered" as a certain > ABC; so __instancecheck__() is just useless here. Actually it can. You don't have to modify the object, just check for the desired methods/signature/whatever. See for example the implementation of collections.Hashable.__subclasshook__ in _abcoll.py and the abc.ABCMeta.__instancecheck__ method. Daniel From robert.kern at gmail.com Thu Jan 27 17:43:43 2011 From: robert.kern at gmail.com (Robert Kern) Date: Thu, 27 Jan 2011 16:43:43 -0600 Subject: Need GUI pop-up to edit a (unicode ?) string In-Reply-To: <4D41B712.1020504@ixokai.io> References: <3tqr08-bj2.ln1@murmur.very.softly> <7691fe98-37af-4ddf-a8a8-eadeef0d4a6e@y2g2000prf.googlegroups.com> <541c02df-b1fc-4376-bf17-e0531fe5c4bf@r29g2000yqj.googlegroups.com> <4D41B712.1020504@ixokai.io> Message-ID: On 2011-01-27 12:18 , Stephen Hansen wrote: > On 1/27/11 10:04 AM, Grant Edwards wrote: >> On 2011-01-27, Stephen Hansen wrote: >>> On 1/25/11 3:02 PM, rantingrick wrote: >>>> This is a major flaw in the design and i would be >>>> happy to fix the flaw. However our "friend" Fredrick decided to >>>> copyright the module to himself! What a jerk! Which is quite >>>> disgusting considering that Tkinter, and TclTk are completely open >>>> source! >>> >>> Uh. ... LOL. >>> >>> Copyright doesn't mean what you think it means. >>> >>> Tkinter is copyrighted. Python is copyrighted. Tcl/TK is copyrgithed. >>> >>> In fact: everything that is "open source" is copyrighted. By >>> definition[* see footnote]. >> >> One (domestic US) exception would be open-source software written by >> an employee of the US federal government. Works produced by the US >> Government are not copyrighted under US domestic copyright law. Such >> works are copyrighted under international law (which is probably what >> the Python maintainers care about). > > I've actually wondered a bit about that: but the only open source > software that I'm aware of that's been government-adjacent has ended up > being written/owned by some University or joint venture funded by a > government agency -- it didn't fall into the public domain category of > content created directly by the federal government. > > Are you aware of any code out there that is? Just curious. I'm not > arguing that the exception doesn't exist or anything. A lot of stuff from NIST is legitimately public domain. E.g. http://fingerprint.nist.gov/NFIS/ -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco From aahz at pythoncraft.com Thu Jan 27 17:47:54 2011 From: aahz at pythoncraft.com (Aahz) Date: 27 Jan 2011 14:47:54 -0800 Subject: Creating custom Python objects from C code References: Message-ID: In article , Eric Frederich wrote: > >I have read through all the documentation here: > > http://docs.python.org/extending/newtypes.html > >I have not seen any documentation anywhere else explaining how to >create custom defined objects from C. I have this need to create >custom objects from C and pass them as arguments to a function call. You should definitely investigate Cython, but if you really want to roll your own, look in the examples inside the Python source itself. -- Aahz (aahz at pythoncraft.com) <*> http://www.pythoncraft.com/ "All problems in computer science can be solved by another level of indirection." --Butler Lampson From ethan at stoneleaf.us Thu Jan 27 18:11:49 2011 From: ethan at stoneleaf.us (Ethan Furman) Date: Thu, 27 Jan 2011 15:11:49 -0800 Subject: Return Statement In-Reply-To: References: Message-ID: <4D41FBB5.3050509@stoneleaf.us> mpnordland wrote: > On 01/26/2011 03:26 PM, sl33k_ wrote: >> How does "return True" and "return False" affect the execution of the >> calling function? > > Basically it will affect it in whatever way you design it to for example: > def lie_test(statement): > if statement is True: > return False > else: > return False > Now, this is psuedo code somewhat. > "if statement is True:" would always equate to "True" unless statement > was an empty string, None, or 0. Um, no. Python 2.5.4 (r254:67916, Dec 23 2008, 15:10:54) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. --> if 'some stuff' is True: ... print 'True' ... else: ... print "it's a dang lie!" ... it's a dang lie! You need either < if bool(statement) is True: >, or < if bool(statement): >, or, simplest, < if statement: > > As to return False if statement equals > true, look at the function name. It is testing to see if it is a lie, > and if it is true, then it's not a lie. Your last statement, though, should be return True -- the way you have it now the function always returns False. ~Ethan~ From emile at fenx.com Thu Jan 27 18:28:59 2011 From: emile at fenx.com (Emile van Sebille) Date: Thu, 27 Jan 2011 15:28:59 -0800 Subject: WxPython versus Tkinter. In-Reply-To: <1797b519-88f2-4b4f-832b-e8392619ac2e@q14g2000vbf.googlegroups.com> References: <4D3E4377.3060807@tysdomain.com> <9MB%o.14110$%64.6074@unlimited.newshosting.com> <4A48EDF6D7634F2E994661A457451E87@teddy> <753A4C5A6658470085804B13C80340F2@octavian> <4D40A97F.8090209@tysdomain.com> <00ABBA322416409EB749102EB1CC5E61@octavian> <4D418054.8050002@tysdomain.com> <1a37f3d8-b580-4d6d-a5a3-de8cc1e656dd@y26g2000yqd.googlegroups.com> <1797b519-88f2-4b4f-832b-e8392619ac2e@q14g2000vbf.googlegroups.com> Message-ID: On 1/27/2011 2:28 PM rantingrick said... > And by > removing Tkinter not only would we take a huge burden from py-dev but > we would also free Tkinter from the chains of stdlib. Actually, IIRC, very little effort is put into maintaining tkinter by the py-dev crowd. I think I saw a post by Martin that he'll put some time in every couple years integrating submitted patches. So, no traction with that argument either. Emile From craigyk at me.com Thu Jan 27 18:44:31 2011 From: craigyk at me.com (Craig Yoshioka) Date: Thu, 27 Jan 2011 15:44:31 -0800 Subject: help with multiprocessing pool In-Reply-To: <016BC5FD-80F5-4578-9448-A592AD626C18@semanchuk.com> References: <2A124DD5-95F2-4DE0-AB0F-5D3EA39A230B@semanchuk.com> <016BC5FD-80F5-4578-9448-A592AD626C18@semanchuk.com> Message-ID: I did eventually get the original code to run from the command line but not the interpreter, so the new example does have a similar problem. Of course it's not as simple as saying I can't run an imported parallelized function from the interpreter because I can, as long as the parallelized function is being invoked directly. But if I caused the parallelized function to be invoked indirectly, for example, by importing a class that uses the parallelized function to set a class variable, it'll hang the interpreter. for now I added the following to any module that uses parallelized functions import __main__ if hasattr(__main__,'__file__'): __SHOULD_MULTITHREAD__ = True else: __SHOULD_MULTITHREAD__ = False and the parallelized functions check this flag to determine wether to run serially or not. This at least lets me import my classes into the interpreter so I can 'play' with them, although they initialize much slower. I'm not sure why Pool needs the __main__ module, except maybe someone sticks centralized process tracking information in there... sigh add it to the fuel of my love/hate with Python. On Jan 27, 2011, at 10:38 AM, Philip Semanchuk wrote: > > On Jan 27, 2011, at 1:12 PM, Craig Yoshioka wrote: > >> The code will be multi-platform. The OSXisms are there as an example, though I am developing on OS X machine. >> >> I've distilled my problem down to a simpler case, so hopefully that'll help troubleshoot. >> >> I have 2 files: >> >> test.py: >> -------------------------------------------------------------- >> from multiprocessing import Pool >> >> def square(x): >> return x*x >> >> def squares(numbers): >> pool = Pool(12) >> return pool.map(square,numbers) >> >> >> test2.py: >> -------------------------------------------------------------- >> from test import squares >> >> maxvalues = squares(range(3)) >> print maxvalues >> >> >> >> Now if I import squares into the interactive interpreter: >> >> from test import squares >> print squares(range(3)) >> >> I get the correct result, but if I try to import maxvalues from test2 the interactive interpreter python hangs. >> if I run the script from bash, though, it seems to run fine. > > The short, complete example is much more useful, but it sounds like it demonstrates a different problem than you first described. Your first posting said that your code worked in the interpreter but failed when run from the command line. This code has the opposite problem. Correct? > >> I think it might have something to do with this note in the docs, though I am not sure how to use this information to fix my problem: >> >> Note: Functionality within this package requires that the __main__ method be importable by the children. This is covered inProgramming guidelines however it is worth pointing out here. This means that some examples, such as themultiprocessing.Pool examples will not work in the interactive interpreter. > > I suspect this is the problem with the demo above. Your original code ran fine in the interpreter, though, correct? > > bye > Philip > > >> >> On Jan 27, 2011, at 6:39 AM, Philip Semanchuk wrote: >> >>> >>> On Jan 25, 2011, at 8:19 PM, Craig Yoshioka wrote: >>> >>>> Hi all, >>>> >>>> I could really use some help with a problem I'm having. >>> >>> >>> Hiya Craig, >>> I don't know if I can help, but it's really difficult to do without a full working example. >>> >>> Also, your code has several OS X-isms in it so I guess that's the platform you're on. But in case you're on Windows, note that that platform requires some extra care when using multiprocessing: >>> http://docs.python.org/library/multiprocessing.html#windows >>> >>> >>> Good luck >>> Philip >>> >>> >>>> I wrote a function that can take a pattern of actions and it apply it to the filesystem. >>>> It takes a list of starting paths, and a pattern like this: >>>> >>>> pattern = { >>>> InGlob('Test/**'):{ >>>> MatchRemove('DS_Store'):[], >>>> NoMatchAdd('(alhpaID_)|(DS_Store)','warnings'):[], >>>> MatchAdd('alphaID_','alpha_found'):[], >>>> InDir('alphaID_'):{ >>>> NoMatchAdd('(betaID_)|(DS_Store)','warnings'):[], >>>> InDir('betaID_'):{ >>>> NoMatchAdd('(gammaID_)|(DS_Store)','warnings'):[], >>>> MatchAdd('gammaID_','gamma_found'):[] }}}} >>>> >>>> so if you run evalFSPattern(['Volumes/**'],pattern) it'll return a dictionary where: >>>> >>>> dict['gamma_found'] = [list of paths that matched] (i.e. '/Volumes/HD1/Test/alphaID_3382/betaID_38824/gammaID_848384') >>>> dict['warning'] = [list of paths that failed to match] (ie. '/Volumes/HD1/Test/alphaID_3382/gammaID_47383') >>>> >>>> Since some of these volumes are on network shares I also wanted to parallelize this so that it would not block on IO. I started the parallelization by using multiprocessing.Pool and got it to work if I ran the fsparser from the interpreter. It ran in *much* less time and produced correct output that matched the non-parallelized version. The problem begins if I then try to use the parallelized function from within the code. >>>> >>>> For example I wrote a class whose instances are created around valid FS paths, that are cached to reduce expensive FS lookups. >>>> >>>> class Experiment(object): >>>> >>>> SlidePaths = None >>>> >>>> @classmethod >>>> def getSlidePaths(cls): >>>> if cls.SlidePaths == None: >>>> cls.SlidePaths = fsparser(['/Volumes/**'],pattern) >>>> return cls.SlidePaths >>>> >>>> @classmethod >>>> def lookupPathWithGammaID(cls,id): >>>> paths = cls.getSlidePaths() >>>> ... >>>> return paths[selected] >>>> >>>> @classmethod >>>> def fromGamaID(cls,id): >>>> path = cls.lookupPathWithGammaID(id) >>>> return cls(path) >>>> >>>> def __init__(self,path) >>>> self.Path = path >>>> ... >>>> >>>> ... >>>> >>>> If I do the following from the interpreter it works: >>>> >>>>>>> from experiment import Experiment >>>>>>> expt = Experiment.fromGammaID(10102) >>>> >>>> but if I write a script called test.py: >>>> >>>> from experiment import Experiment >>>> expt1 = Experiment.fromGammaID(10102) >>>> expt2 = Experiment.fromGammaID(10103) >>>> comparison = expt1.compareTo(expt2) >>>> >>>> it fails, if I try to import it or run it from bash prompt: >>>> >>>>>>> from test import comparison (hangs forever) >>>> $ python test.py (hangs forever) >>>> >>>> I would really like some help trying to figure this out... I thought it should work easily since all the spawned processes don't share data or state (their results are merged in the main thread). The classes used in the pattern are also simple python objects (use python primitives). >>>> >>>> >>>> These are the main functions: >>>> >>>> def mapAction(pool,paths,action): >>>> merge = {'next':[]} >>>> for result in pool.map(action,paths): >>>> if result == None: >>>> continue >>>> merge = mergeDicts(merge,result) >>>> return merge >>>> >>>> >>>> def mergeDicts(d1,d2): >>>> for key in d2: >>>> if key not in d1: >>>> d1[key] = d2[key] >>>> else: >>>> d1[key] += d2[key] >>>> return d1 >>>> >>>> >>>> def evalFSPattern(paths,pattern): >>>> pool = Pool(10) >>>> results = {} >>>> for action in pattern: >>>> tomerge1 = mapAction(pool,paths,action) >>>> tomerge2 = evalFSPattern(tomerge1['next'],pattern[action]) >>>> del tomerge1['next'] >>>> results = mergeDicts(results,tomerge1) >>>> results = mergeDicts(results,tomerge2) >>>> return results >>>> >>>> the classes used in the pattern (InGlob,NoMatchAdd,etc.) are callable classes that take a single parameter (a path) and return a dict result or None which makes them trivial to adapt to Pool.map. >>>> >>>> Note if I change the mapAction function to: >>>> >>>> def mapAction(pool,paths,action): >>>> merge = {'next':[]} >>>> for path in paths: >>>> result = action(path) >>>> if result == None: >>>> continue >>>> merge = mergeDicts(merge,result) >>>> return merge >>>> >>>> everything works just fine. >>>> >>>> >>>> Thanks. >>>> >>>> >>>> -- >>>> http://mail.python.org/mailman/listinfo/python-list >>> >>> -- >>> http://mail.python.org/mailman/listinfo/python-list >> > > -- > http://mail.python.org/mailman/listinfo/python-list From kw at codebykevin.com Thu Jan 27 18:50:44 2011 From: kw at codebykevin.com (Kevin Walzer) Date: Thu, 27 Jan 2011 18:50:44 -0500 Subject: WxPython versus Tkinter. In-Reply-To: References: <4D4093AF.80806@etrix.com.au> Message-ID: On 1/27/11 1:11 PM, rantingrick wrote: > Actually we don't want "Robins wxPython" in the stdlib "as is" anyway. > What we DO want is an abstraction API for the short term that plugs > into Robin's wx. Then over the long term we will either convince him > to create a better API OR just create our own wxPython directly from > WxWidgets and mold it into the stdlib. So hinging on the argument of > what one*single* man thinks is a non-starter. I saw this comment elsewhere in the thread, and I'm a bit confused. As I understand it, you want to layer a Tkinter-style abstraction API over wxPython? You had mentioned that you want to include something like Tkinter's grid/pack/place management API's, its event-handling mechanism, its use of tags, and a few other things? I'd like to suggest that these things are already in the stdlib, in the form of Tkinter itself. And at least some thing these things are tightly bound to Tkinter's inclusion of the Tcl interpreter. For instance, Tcl has a powerful and flexible event loop mechanism. Does wxWidgets have something similar? And are Tkinter's grid/pack/place geometry managers (which are defined at the C level) compatible with wx sizers, which are also defined at the lower C++ level? While this thread has taken many twists and turns, it nonetheless seems to me that the proposal being offered is to layer a Tkinter-style API over a Tkinter-scale subset of wxPython's widgets (listbox, button, menu, etc.). After all that work, what would really be gained? We'd have the same small core of widgets, with an arguably less stable base (since wxPython seems to have problems with segfaults on Linux). It is not persuasive to say that Tkinter is "legacy" while wxPython is "the future." Both Tk and wxWidgets date to the early 1990s. Tk did stagnate for a number of years, but its development in the past few years has been reinvigorated by the ttk themed widgets, in addition to various extension packages that use Tk's C API, and it is now a peer to wxWidgets in its GUI capabilties. I can't speak to Tkinter's performance relative to wxPython and the Tcl interpreter, but any performance gains that are achieved by wxPython's underlying C++ library may be obviated by lesser stability. After all the back-and-forth, I am simply not persuaded, especially since the proposal being offered is not to replace Tkinter with wxPython in the stdlib, but to instead replace Tkinter with a yet-to-be-designed wxTkinter amalgamation (a Tkinter body on a wxPython chassis). --Kevin -- Kevin Walzer Code by Kevin http://www.codebykevin.com From tjreedy at udel.edu Thu Jan 27 18:58:26 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Thu, 27 Jan 2011 18:58:26 -0500 Subject: WxPython versus Tkinter. In-Reply-To: <4D41E83A.3030209@aim.com> References: <4D3E4377.3060807@tysdomain.com><9MB%o.14110$%64.6074@unlimited.newshosting.com><4A48EDF6D7634F2E994661A457451E87@teddy><753A4C5A6658470085804B13C80340F2@octavian> <4D40A97F.8090209@tysdomain.com><00ABBA322416409EB749102EB1CC5E61@octavian> <4D418054.8050002@tysdomain.com> <1a37f3d8-b580-4d6d-a5a3-de8cc1e656dd@y26g2000yqd.googlegroups.com> <4D41E83A.3030209@aim.com> Message-ID: On 1/27/2011 4:48 PM, Corey Richardson wrote: > wxPython is the best and most mature cross-platform GUI toolkit, given a > number of constraints. The only reason wxPython isn't the standard > Python GUI toolkit is that Tkinter was there first. > -- Guido van Rossum > > (from http://www.wxpython.org/quotes.php) Of course, that is not the only reason now. Python has moved on to a 21st century version, while wxpython is still stuck on the 20century version. -- Terry Jan Reedy From mpnordland at gmail.com Thu Jan 27 19:16:58 2011 From: mpnordland at gmail.com (mpnordland) Date: Thu, 27 Jan 2011 19:16:58 -0500 Subject: Return Statement In-Reply-To: <4D41FBB5.3050509@stoneleaf.us> References: <4D41FBB5.3050509@stoneleaf.us> Message-ID: I stand corrected :) From rantingrick at gmail.com Thu Jan 27 19:54:34 2011 From: rantingrick at gmail.com (rantingrick) Date: Thu, 27 Jan 2011 16:54:34 -0800 (PST) Subject: WxPython versus Tkinter. References: <4D4093AF.80806@etrix.com.au> Message-ID: <0973f16e-ae4b-4adf-be99-6955be3d3cca@s28g2000prb.googlegroups.com> On Jan 27, 5:50?pm, Kevin Walzer wrote: > On 1/27/11 1:11 PM, rantingrick wrote: [...] Hello again Kevin and nice to have you back! Yes the minor details have been evolving over the course of this and another thread. We have been floating new ideas all along the way in an effort to get the best result. In the very beginning because we all know that wxPython IS HUGE i offered a divide and conquer approach... * Small "Tkinter-like" stdlib module. * Full featured third party download. By doing this we can keep the stdlib smaller and leave the bulk of wx in a 3rd party download. Then we floated around installing the entire wxPython library because after all hard drives are only getting bigger. However i think that neither are the best Option. In any event the ideas (like any ideas in a lively discussion) are very fluid in nature. Part of generating the best conclusion is by twisting and turning every idea until it fits neatly into some stated goals. And yes, we want to get the most bang for our community buck! I am now convinced that "Robins wxPython" is woefully inadequate due to the API. We can never consider putting such a blasphemy into the stdlib. Does that mean we should ignore the great benefits of wxWidgets? HELL NO, we would be fools if we did! Now i am thinking along the lines of an abstraction API that plugs into wxPython. We keep Tkinter until say "Python4000", but in the meantime we create a "pythonic wxPython" from the ground up (stealing as much as we can from Robin!). By doing this we can integrate wxPython at whatever rate the community can bear at the time. The only thing better would be to convince all GUI library creators to start thinking globally. To start setting a global standard for all GUI libraries. Then all we would have to do is create a Python API and just "plug" it in generically to WX, TK, GTK, QT, Etc, Etc. I know this sounds like a pipe dream, but this is what must happen at some point. And we should all be demanding this everyday. Always Remember: Selfishness = Multiplicity = Entropy = Shock = Stagnation = None > While this thread has taken many twists and turns, it nonetheless seems > to me that the proposal being offered is to layer a Tkinter-style API > over a Tkinter-scale subset of wxPython's widgets (listbox, button, > menu, etc.). After all that work, what would really be gained? We'd have > the same small core of widgets, with an arguably less stable base (since > wxPython seems to have problems with segfaults on Linux). Yes this discussion has taken many turns. Read my previous statement for insight. > It is not persuasive to say that Tkinter is "legacy" while wxPython is > "the future." Both Tk and wxWidgets date to the early 1990s. Tk did > stagnate for a number of years, but its development in the past few > years has been reinvigorated by the ttk themed widgets, in addition to > various extension packages that use Tk's C API, Yes Tk has just recently "come out of stagnation". But for how long? How long must we wait for them to "get it together"? Thats my point. We will all be dead and rotting by the time Tkinter is including a ListCtrl and accessibility. And i don't know about you Kevin, but i really don't want to wait that long! > and it is now a peer to > wxWidgets in its GUI capabilties. I can't speak to Tkinter's performance > relative to wxPython and the Tcl interpreter, but any performance gains > that are achieved by wxPython's underlying C++ library may be obviated > by lesser stability. wxPython IS NOT less stable than Tkinter: That is a FACT. However, WxPythons API was written in such a horribly unpythonic way (sorry Robin) that someone could find themselves in trouble IF they are not experienced enough to use the library. However, we can easily fix an API. What we can't fix is lack of vision and stagnation in an outside community. We must help ourselves because no one else is going to do it for us! > After all the back-and-forth, I am simply not persuaded, especially > since the proposal being offered is not to replace Tkinter with wxPython > in the stdlib, but to instead replace Tkinter with a yet-to-be-designed > wxTkinter amalgamation (a Tkinter body on a wxPython chassis). Not exactly Kevin. What i intend to do is take your Yugo (Tkinter) to my shop and rip out the antiquated engine, rusty transmission, and remove those "may-pop" tires. Then i plan to replace them with the best high performance parts that are available (wxWidgets) and probably even give her a nice paint job too (Tkinter API)! And when i am done, all your friends are going to be jealous and all the women are going to want a ride in your new hotrod. Kevin, i am going to make you the coolest cat in town! But nobody said it was going to an easy task! ;-) From mpnordland at gmail.com Thu Jan 27 19:58:22 2011 From: mpnordland at gmail.com (mpnordland) Date: Thu, 27 Jan 2011 19:58:22 -0500 Subject: replacing lines in a file In-Reply-To: <4D40B2EC.1070309@mrabarnett.plus.com> References: <4D40B2EC.1070309@mrabarnett.plus.com> Message-ID: thanks for explaining what I was doing wrong and how reading the file works. What would you suggest I do to remedy the situation? From misnomer at gmail.com Thu Jan 27 20:24:52 2011 From: misnomer at gmail.com (Nicholas Devenish) Date: Fri, 28 Jan 2011 01:24:52 +0000 Subject: WxPython versus Tkinter. In-Reply-To: <0973f16e-ae4b-4adf-be99-6955be3d3cca@s28g2000prb.googlegroups.com> References: <4D4093AF.80806@etrix.com.au> <0973f16e-ae4b-4adf-be99-6955be3d3cca@s28g2000prb.googlegroups.com> Message-ID: On 28/01/2011 00:54, rantingrick AKA "Brian" wrote: > Yes the minor details have been evolving over the course of this and > another thread. We have been floating new ideas all along the way in > an effort to get the best result. In the very beginning because we all > know that wxPython IS HUGE i offered a divide and conquer approach... In other, greater words: "He's making it up as he goes along." From python at mrabarnett.plus.com Thu Jan 27 21:38:44 2011 From: python at mrabarnett.plus.com (MRAB) Date: Fri, 28 Jan 2011 02:38:44 +0000 Subject: replacing lines in a file In-Reply-To: References: <4D40B2EC.1070309@mrabarnett.plus.com> Message-ID: <4D422C34.2010001@mrabarnett.plus.com> On 28/01/2011 00:58, mpnordland wrote: > thanks for explaining what I was doing wrong and how reading the file > works. What would you suggest I do to remedy the situation? > Write the new config out to a new file and then replace the old file with the new file. I'd use shutil.move(...) to do the replacement. This means that the existing config file will remain unchanged until you've successfully created the new config file (it's somewhat annoying if you're modifying a file and there's an exception part way through due to a bug, leaving 'invalid' contents!) From wuwei23 at gmail.com Thu Jan 27 21:53:03 2011 From: wuwei23 at gmail.com (alex23) Date: Thu, 27 Jan 2011 18:53:03 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com><63eea$4d3cd2fd$4275d90a$14984@FUSE.NET><69465430-08b3-4069-99c7-72f4d3034c66@s5g2000yqm.googlegroups.com><705ad$4d3ce0fc$4275d90a$29144@FUSE.NET> <2sm%o.8695$gM3.6118@viwinnwfe01.internal.bigpond.com> <0c3c61b0-d056-4757-b7e4-fecdf9a6e217@fm22g2000vbb.googlegroups.com> <94c48579-aed0-4987-aaa4-0f7b6209d9bb@8g2000prt.googlegroups.com> <704dd789-0eb2-4a33-9f2b-2363d3f5793f@s18g2000vbe.googlegroups.com> Message-ID: rantingrick wrote: > You'll need to read that snippet in context to understand what i was > talking about. Again, see my "tip of the day" in my last post to you. Pass. I'd have to see value in what you say inside of the endless masturbatory self-aggrandizement that you pass off as "visionary" posts. Instead it's all blah blah blah RUBY ASSHOLES blah blah INCOHERENT IDEA blah LAZY BASTARDS WHO DON'T APPRECIATE ME etc etc From kb1pkl at aim.com Thu Jan 27 22:00:25 2011 From: kb1pkl at aim.com (Corey Richardson) Date: Thu, 27 Jan 2011 22:00:25 -0500 Subject: WxPython versus Tkinter. In-Reply-To: References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com><63eea$4d3cd2fd$4275d90a$14984@FUSE.NET><69465430-08b3-4069-99c7-72f4d3034c66@s5g2000yqm.googlegroups.com><705ad$4d3ce0fc$4275d90a$29144@FUSE.NET> <2sm%o.8695$gM3.6118@viwinnwfe01.internal.bigpond.com> <0c3c61b0-d056-4757-b7e4-fecdf9a6e217@fm22g2000vbb.googlegroups.com> <94c48579-aed0-4987-aaa4-0f7b6209d9bb@8g2000prt.googlegroups.com> <704dd789-0eb2-4a33-9f2b-2363d3f5793f@s18g2000vbe.googlegroups.com> Message-ID: <4D423149.105@aim.com> On 01/27/2011 09:53 PM, alex23 wrote: > rantingrick wrote: >> You'll need to read that snippet in context to understand what i was >> talking about. Again, see my "tip of the day" in my last post to you. > > Pass. I'd have to see value in what you say inside of the endless > masturbatory self-aggrandizement that you pass off as "visionary" > posts. Instead it's all blah blah blah RUBY ASSHOLES blah blah > INCOHERENT IDEA blah LAZY BASTARDS WHO DON'T APPRECIATE ME etc etc Because insults and flaming totally get anyone anywhere. If you don't have anything civil to say, don't say it at all (Because sometimes un-nice things need to be said). From wuwei23 at gmail.com Thu Jan 27 22:00:45 2011 From: wuwei23 at gmail.com (alex23) Date: Thu, 27 Jan 2011 19:00:45 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <8q7sgiF5tpU1@mid.individual.net> <19891784-d6a3-41ac-a097-5902a6323bc0@o21g2000prn.googlegroups.com><0b12cdb1-45b4-41e4-9bdb-074ee669d76b@k14g2000pre.googlegroups.com> <048FB74272D440A0915ABC7D76AE262B@teddy> <5782E9AD8A8342D691EB3549E5E0ED7B@octavian> Message-ID: <409f37bb-6eb4-49ee-95cc-c4a9ea91b207@s29g2000pra.googlegroups.com> "Octavian Rasnita" wrote: > Ok, in this case I understand why WxPython can't be included in stdlib. > I think there was a communication problem because the oldest list members > start with the idea that all the list members know who is who and they may > be thinking that I don't want to accept the reality or that I have bad > feelings about some list members or something like that. The only expectation I as a list member have of you is that you maybe hit the web and do a bit of search & research before starting on an endless tirade. Implying that it was the responsibility of everyone here to explain every little aspect of an issue you're supposedly passionate about makes you seem either lazy or ignorant. From wuwei23 at gmail.com Thu Jan 27 22:07:20 2011 From: wuwei23 at gmail.com (alex23) Date: Thu, 27 Jan 2011 19:07:20 -0800 (PST) Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com><9MB%o.14110$%64.6074@unlimited.newshosting.com><4A48EDF6D7634F2E994661A457451E87@teddy><753A4C5A6658470085804B13C80340F2@octavian> <4D40A97F.8090209@tysdomain.com><00ABBA322416409EB749102EB1CC5E61@octavian> <4D418054.8050002@tysdomain.com> <171961f5-00da-444b-95fa-f3d95a685956@24g2000yqa.googlegroups.com> Message-ID: <3ec30430-9a40-4f0c-8d8f-cda09ac3c3ac@u11g2000prk.googlegroups.com> rantingrick wrote: > different choices OUTSIDE the stdlib. INSIDE the stdlib we have no > choice. Just wanted to make that clear. Because packaging a dependency with your application is an arcane art lost to modern times? From brian.curtin at gmail.com Thu Jan 27 23:18:41 2011 From: brian.curtin at gmail.com (Brian Curtin) Date: Thu, 27 Jan 2011 22:18:41 -0600 Subject: PSF Sprints - Call For Applications Message-ID: Hello Python Users! On behalf of the Python Software Foundation?s sponsored sprint group, I wanted to drop your group a quick note introducing us. If you?re already familiar with our sponsored sprints, you?ll be happy to know we made a few changes to help both sprint groups and Python even more. The PSF recently set aside funding to be distributed to groups who spend time contributing to the Python ecosystem, often in the form of development sprints. Our goal is to help you help Python, so whether it?s buying meals or renting meeting space for your all-day hackathon, we have a budget set aside to reimburse your expenses up to $300 USD (up from $250). If your goal is to make the Python world a better place, and you work on the problems facing Python today, we want to help you. We?re looking for groups of hackers that spend their time fixing and expanding the wide variety of Python interpreters, libraries, tools, and anything else affecting the community.We?re also looking for groups who want to help and get started but don?t have the resources to get together. Whether your group is separated by a train ride or lacking a shared space, we want to help you. On-boarding new contributors to open source Python projects is an especially important area that we?d like to work with.This means if you have a Python project and you want to sprint -- we want to help you.Some sprints we?ve sponsored include the porting of Genshi to Python 3, improvements to packaging (Distribute/distutils), and most recently, the PyPy winter sprint in Switzerland. If your group is interested in hosting a sprint, check out the full details of our call for applications at http://www.pythonsprints.com/cfa/ and contact us at sprints at python.org. Thanks for your time, and happy sprinting! Brian Curtin Jesse Noller http://www.pythonsprints.com/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From rantingrick at gmail.com Fri Jan 28 00:34:01 2011 From: rantingrick at gmail.com (rantingrick) Date: Thu, 27 Jan 2011 21:34:01 -0800 (PST) Subject: Bugs/issues in tkinter.simpledialog!! References: <412e4d83-f750-441d-bfc5-d96c0559e069@e9g2000prn.googlegroups.com> Message-ID: On Jan 26, 3:57?pm, Terry Reedy wrote: > On 1/26/2011 11:53 AM, rantingrick wrote: > > To answer your other post, one of the main people to touch tkinter in > the last 3 years was Guilherme Polo, who worked on it during and after a > Google Summer of Code project. He does not seen to be active currently. > > There are currently 63 open issues on the tracker listing tkinter as a > component. There are probably a few that could be closed. When I have > learned more, I should be able to review any patched sitting around. Well i tried searching for "Tkinter" issues on the tracker and just got annoyed quickly and left. It seems far to complicated to do searches with this software. Anyhoo, i did find the most current version of tksimpledialog.py and sure enough all the issues i have documented have been ported into this new version. From research at johnohagan.com Fri Jan 28 01:29:10 2011 From: research at johnohagan.com (John O'Hagan) Date: Fri, 28 Jan 2011 06:29:10 +0000 Subject: how to read the last line of a huge file??? In-Reply-To: References: Message-ID: <201101280629.11288.research@johnohagan.com> On Wed, 26 Jan 2011, Xavier Heruacles wrote: > I have do some log processing which is usually huge. The length of each > line is variable. How can I get the last line?? Don't tell me to use > readlines or something like linecache... file.seek takes an optional 'whence' argument which is 2 for the end, so you can just work back from there till you hit the first newline that has anything after it: def lastline(filename): offset = 0 line = '' with open(filename) as f: while True: offset -= 1 f.seek(offset, 2) nextline = f.next() if nextline == '\n' and line.strip(): return line else: line = nextline John From vaduvoiutibi at yahoo.com Fri Jan 28 02:34:57 2011 From: vaduvoiutibi at yahoo.com (Vaduvoiu Tiberiu) Date: Thu, 27 Jan 2011 23:34:57 -0800 (PST) Subject: dictionary error: list assignment index out of range Message-ID: <753474.31840.qm@web113802.mail.gq1.yahoo.com> Hy everyone, I'm trying to learng python for a week or two and there's a thing that is really disturbing me as I do not understand what the problem is. I'm trying to use a dictionary to remember when a user has visited a city. Code is really basic: in the class init method I added self.visited = [] and in the function where i check if city was visited: cityNumber = 1 #example if (not cityNumber in self.visited): #do some stuff self.visited[cityNumber] = "true" Apparently the last line causes the error: list assignment index out of range. I read that this is the simplest way to assign a value to a dictionary(dict[key]=value). So why is the error appearing?? Thanks a lot in advance -------------- next part -------------- An HTML attachment was scrubbed... URL: From vaduvoiutibi at yahoo.com Fri Jan 28 02:39:58 2011 From: vaduvoiutibi at yahoo.com (Vaduvoiu Tiberiu) Date: Thu, 27 Jan 2011 23:39:58 -0800 (PST) Subject: dictionary error: list assignment index out of range Message-ID: <588467.15109.qm@web113814.mail.gq1.yahoo.com> Well, to quote firefox: this is embarrassing. I've realized the dictionary initialization is wrong, as [] means its a tuple, I should use {}. That's why I don't like working nights..it's only in the morning when you start seeing things better. I apologize for the mail. Cheers ________________________________ From: Vaduvoiu Tiberiu To: python-list at python.org Sent: Fri, January 28, 2011 9:34:57 AM Subject: dictionary error: list assignment index out of range Hy everyone, I'm trying to learng python for a week or two and there's a thing that is really disturbing me as I do not understand what the problem is. I'm trying to use a dictionary to remember when a user has visited a city. Code is really basic: in the class init method I added self.visited = [] and in the function where i check if city was visited: cityNumber = 1 #example if (not cityNumber in self.visited): #do some stuff self.visited[cityNumber] = "true" Apparently the last line causes the error: list assignment index out of range. I read that this is the simplest way to assign a value to a dictionary(dict[key]=value). So why is the error appearing?? Thanks a lot in advance -------------- next part -------------- An HTML attachment was scrubbed... URL: From orasnita at gmail.com Fri Jan 28 03:33:31 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Fri, 28 Jan 2011 10:33:31 +0200 Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com><9MB%o.14110$%64.6074@unlimited.newshosting.com><4A48EDF6D7634F2E994661A457451E87@teddy><753A4C5A6658470085804B13C80340F2@octavian> Message-ID: <3482A10ED46D4A70B519125BE5D19DF9@octavian> From: "Grant Edwards" > So you're saying that you don't see any value in easing communication, > nor presumably in communication itself? No, I don't want to say that, but I want to say that if it is obviously that the others don't care about the main issue discussed, then the communication just for the sake of communication has no value. If the others do care, but they are just uninformed, then I guess they wouldn't be upset by a direct communication that just tell them what's wrong. > If you don't care about communicating with others, then being civil > probably does have no value (except for keeping a job or being > avoiding being beaten up on the playground). If you want to > communicate (especially if you want somebody else to _do_ something), > then being civil and following normal social rules (etiquette) is > _very_ valuable. Without it the only thing you accomplish is to turn > people against you and whatever you're saying. How can we talk about etiquette when exactly this etiquette is the one that needs to be changed? As you say, the etiquette is in favor of the preferences of the majority, but how should react someone, what he/she should say in order to make the others understand that that etiquette is bad because it discriminates some categories of people? And those minorities are not minorities because they want, or because they simply don't want to change their way, but because they can't do that. > There is no inherent "value" in driving on the right side of the road > vs. the left. However, there is a lot of value in driving on the side > of road that others expect you to. I'd tell you to try driving on the > other side of the road sometime to see how "easing communication" can > be valuable, but I'm afraid you'd try it... You are right in that case, but the comparison is not good because yes there is a value in creating accessible GUIS. Those who drive on the left, the minority, can adapt to drive on the right. If their cars have the wheels on the right, there are technical solutions for that problem... they ccan change their cars. But if an application uses Tk, those minorities that have problems don't have any technical solution to solve them, because there are not accessible versions for all the inaccessible apps. Try to imagine that it will appear an incurable disease for those who drive on the right. What do you think it will happen? Probably they all would start driving on the left. But what it would be happening if only a small minorities of those who drive on the right will get that disease, say those between 18 and 25? Probably it won't happen anything and those that are below 25 won't be able to drive a car, because they are too few and too unimportant, and they would have too small power to change things in favor of all. And that would mean discrimination. The people are free and as someone said, the man is a rational animal, so the power differences rank the world and not the truth and etiquette, because the etiquette is also imposed by the majority and about those who have the power. And I fully agree with you and others said regarding to this, but what I said is that all that majority should do what it wants, however it should always remember at least that it is not doing the right thing. Yes, I know that this opinion that those who create shortcomings should not feel good for what they do or even think, is something which is not helpful for me, and it might not be helpful for those who use a screen reader either in the present, exactly because of those bad and unfair sentiments, but I hope that this will change in the future. And here I agree, I am not talking only about the accessibility to computers, but about all the image that the blind people have in the healthy's people mind. Octavian From orasnita at gmail.com Fri Jan 28 03:33:38 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Fri, 28 Jan 2011 10:33:38 +0200 Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com><9MB%o.14110$%64.6074@unlimited.newshosting.com><4A48EDF6D7634F2E994661A457451E87@teddy><753A4C5A6658470085804B13C80340F2@octavian><84519d45-f584-4fab-b51c-cd53bde6c09a@p16g2000vbs.googlegroups.com> <793e3d37-f59c-4053-b38e-24bb48c44807@l22g2000pre.googlegroups.com> Message-ID: <20F7065AF3F24C72992FB20FBA68BAC2@octavian> From: "rusi" Its quite clear to everyone here that -- Octavian has no interest in a 21st century snazzy-looking toolkit Oh well I am interested, but with the condition that toolkit to be accessible, however Tkinter is not. Is it too much to expect from a "21st century snazzy-looking toolkit" to be accessable to screen readers? Octavian From orasnita at gmail.com Fri Jan 28 03:33:42 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Fri, 28 Jan 2011 10:33:42 +0200 Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com><9MB%o.14110$%64.6074@unlimited.newshosting.com><4A48EDF6D7634F2E994661A457451E87@teddy><753A4C5A6658470085804B13C80340F2@octavian> Message-ID: <8C94A3B3E1EC44D1B24E0A572DC2B087@octavian> From: "Grant Edwards" > You said that you don't care about convincing anybody either that > accessibility is import or about convincing anybody to do anything > about it. To me that means you don't care about accessiblity. And you are wrong. If you don't try to convince someone that Python is a good language, does that mean that you don't care about Python? You might be thinking that the people on the list *already know* that Python is a good language. And I also think that in the 21st century *every programmer* should know that the accessibility is important. >>> People will not separate your personality from the cause you espouse. >> >> Wow! that's really bad. > > It's less than ideal, but it the way people are. > Is that a surprise to you? No, but I am pretending that I don't know, because the those people are not thinking correctly and it should be a shame for someone to have bad opinions about a person just because that person has different opinions. And the world should be ideal. Of course, it will never be, but we should follow that direction at least and not consider it bad just because that way require big and uncomfortable changes. >> I thought that I might find here people that might have something >> against my opinions, that is very normal, that's why we are >> discussing, but I didn't think that I will also find people that will >> have something against me, just because of my opinions. > > That's not what I said. I said that if you state your opininions in a > rude, insulting, or disrepectful manner, that will turn people against > your opinions regardless of the inherent value of the actual opinions I have asked for a few times, but nobody answered. From what I said, what was rude, insulting and disrespectable? > That's not what we're talking about. We're not talking about your > opinions on some unrelated topic. We're talking about the manner in > which you express your opinions on this topic. And again, what's that "manner"? Do you really think that the opinions of the majority are always more valid than those of minorities, no matter the consequences? > Again, it's not your beliefs about other tops that are causing > problems for you. What's causing problems is the manner in which you > are expressing your beliefs about this topic. My beliefs are that the majority doesn't care about the minority of screen reader users, because if it would care, it would be promoting accessible tools. Don't you agree with this? Or you don't like the atitude of expressing it so clear and like to hide those sensible things? Octavian From orasnita at gmail.com Fri Jan 28 03:33:46 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Fri, 28 Jan 2011 10:33:46 +0200 Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com> <9MB%o.14110$%64.6074@unlimited.newshosting.com> <4A48EDF6D7634F2E994661A457451E87@teddy> <753A4C5A6658470085804B13C80340F2@octavian> <4D41B5AF.8020200@ixokai.io> Message-ID: From: "Stephen Hansen" > Seriously. Octavian's attitude in this thread makes me want to go use > Tkinter just to spite him. Oh yes? And this would probably mean that your atitude is a very good and normal one, right? Octavian From orasnita at gmail.com Fri Jan 28 03:33:50 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Fri, 28 Jan 2011 10:33:50 +0200 Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com> <9MB%o.14110$%64.6074@unlimited.newshosting.com> <4A48EDF6D7634F2E994661A457451E87@teddy> <753A4C5A6658470085804B13C80340F2@octavian> <4D41B5AF.8020200@ixokai.io> <4D41BCC2.2060906@tysdomain.com> Message-ID: From: "Littlefield, Tyler" > >* Disclaimer: You are stupid if you think this is true. But seriously, > >Octavian makes it REALLY hard to continue caring about something that I > >actually cared about before and thought was important. When I told about what the community of the blind from my country cares, or what I care, the others told me that that is not important. I am sure that won't say the same thing to your post in which you also say about what you care, just because you have the same opinions like them. > People like Octavian do that. Sadly, it is one of the things holding the > blind community back. I hope that with my arguments (for those that didn't > just toss everything related to this thread), I have been able to get > people to see a little differently and not consider Octavian as the voice > for us all. Who are those "us all"? Are you a representative voice for all the screen reader users? (Even though most of them use JAWS that you don't seem to like) Or do you agree with the associations of the blind in your country do when they fight with different companies because they make discrimination by not offering accessible products? Or you are more representative than those associations? Octavian From orasnita at gmail.com Fri Jan 28 03:33:53 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Fri, 28 Jan 2011 10:33:53 +0200 Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com><9MB%o.14110$%64.6074@unlimited.newshosting.com><59F6E65E3D9A46AD8D7A3863F3C1DC84@teddy><27f53f8c-7862-4366-9352-82ae9a2f3970@k3g2000yqc.googlegroups.com><718D13777F254C839F9564BC4275DE0A@octavian><4D402C42.1030407@tysdomain.com><4D40447C.4010108@tysdomain.com><33C68A0874BE4C66AB478EDFB64C2C1D@teddy><4D407321.3090705@web.de> <1296128007.17192.1417506961@webmail.messagingengine.com> Message-ID: From: "Grant Edwards" > A very important way to help would be to test accessibility features > and post accurate, detailed, bug-reports. > I am willing to do that. I have tested that program made with WxPython and I have posted here what I found, hoping that there will appear a Tkinter-based app to test. For the moment, the accessibility of Tkinter is something like: - The menus are accessible, at least those at the top of the window, I don't know about the context menus, because I don't know a Tk-based app that uses context menus. - The rest of the widgets are completely inaccessible. What can I say more? Octavian From orasnita at gmail.com Fri Jan 28 03:33:55 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Fri, 28 Jan 2011 10:33:55 +0200 Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com> <9MB%o.14110$%64.6074@unlimited.newshosting.com> <59F6E65E3D9A46AD8D7A3863F3C1DC84@teddy> <27f53f8c-7862-4366-9352-82ae9a2f3970@k3g2000yqc.googlegroups.com> <718D13777F254C839F9564BC4275DE0A@octavian> <4D402C42.1030407@tysdomain.com> <4D40447C.4010108@tysdomain.com> <33C68A0874BE4C66AB478EDFB64C2C1D@teddy> <4D407321.3090705@web.de> <1296128007.17192.1417506961@webmail.messagingengine.com> Message-ID: <8775C617C7B241759AC122A69955D42A@octavian> From: "Terry Reedy" > For example: pygui pretty much uses native widgets on Windows and OX and > gtk (I believe) on *nix. How is the accessibility of those widget sets *as > accessed through pygui*? Is it different from the 'native' accessibility > of each of those set? Thank you for telling about this GUI lib! I have tested the sample apps it offers and the standard dialogs are very accessible. I hope it is the same in case of the other common controls like list boxes, list views, check boxes, radio buttons, combo boxes, tree views... How complete is this GUI lib compared with others that can be used in Python apps? I am asking this, because I read: "Get the library and its documentation included in the core Python distribution, so that truly cross-platform GUI applications may be written that will run on any Python installation, anywhere." And this would be great! Octavian From orasnita at gmail.com Fri Jan 28 03:33:58 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Fri, 28 Jan 2011 10:33:58 +0200 Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com><8q7sgiF5tpU1@mid.individual.net><19891784-d6a3-41ac-a097-5902a6323bc0@o21g2000prn.googlegroups.com><0b12cdb1-45b4-41e4-9bdb-074ee669d76b@k14g2000pre.googlegroups.com><048FB74272D440A0915ABC7D76AE262B@teddy><5782E9AD8A8342D691EB3549E5E0ED7B@octavian><43549D4396F34EA697C45AA40EA12BC8@octavian><5858167B51BD4813A1D36C2D90D255F2@teddy> Message-ID: <1629FC367B75424EB32E4D9A7C355B8F@octavian> From: "Giampaolo Rodol?" ... > py2exe offers the following installation kits, depending on the Python > version. If you know, please tell me why there are different packages for > different versions of Python? > > py2exe-0.6.9.win32-py2.5.exe > py2exe-0.6.9.win32-py2.4.exe > py2exe-0.6.9.win32-py2.3.exe > py2exe-0.6.9.win32-py2.6.exe > py2exe-0.6.9.win32-py2.7.exe That's a different story: those are pre-compiled binaries which are generated from a *unique* source code which support all those versions. If you have a compiler you can install pywin32 extension by using any Python version. Thank you Giampaolo. Now I understand and it is a good thing. Octavian From orasnita at gmail.com Fri Jan 28 03:34:01 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Fri, 28 Jan 2011 10:34:01 +0200 Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com><9MB%o.14110$%64.6074@unlimited.newshosting.com> <59F6E65E3D9A46AD8D7A3863F3C1DC84@teddy> <27f53f8c-7862-4366-9352-82ae9a2f3970@k3g2000yqc.googlegroups.com> <718D13777F254C839F9564BC4275DE0A@octavian> <4D402C42.1030407@tysdomain.com> <4D40447C.4010108@tysdomain.com><33C68A0874BE4C66AB478EDFB64C2C1D@teddy> <4D407333.1070301@tysdomain.com><82865E7A54C048C398B4F4160FC43B57@octavian><4D417EFC.70800@tysdomain.com><57C3CFA0C7EE4578B0C6EAA267AAE678@teddy> <4D41B6B7.7010609@tysdomain.com> Message-ID: <409FABAAA3D74ADCB11E06C676282650@octavian> From: "Littlefield, Tyler" > what >JAWS Tyler, did I used bad words in my posts as you do now? I didn't, but the other list members told me that my atitude is not good, that I am not civilized, because I have a different opinion than them. I am sure *nobody* will tell you that thing even though they can also see your posts. > 1) Because you, your crew, and your group on a specific forum doesn't like > ESpeak doesn't disqualify an entire reader. The eloquence fixes are > illegal to be packaged with NVDA, so you -need- to get a separate patch, > yes. That doesn't mean it can't be done. Are you hearing yourself? You say that it is illegal, but that it can be done. Nice. And by the way, that group I told you about is not my group, but the group of most active young blind computer users in my country. > As to me being a Linux and Mac user, that doesn't disqualify what I'm > telling you either, because unlike your limitations, I don't just decide > to only use one reader. I use Linux, Mac, and windows (windows more than > both, actually). Yes, I'm giving you what I got from googling, because > that's my way of telling you to do your homework before you start ranting > about a reader you clearly know nothing of. The fact that it appears on > google says a lot. At least to me, maybe it's something you haven't been > able to comprehend. It also appears on Google an article in which the NVDA developers say why NVDA doesn't offer support for Eloquence anymore, and if you would have been such a great Google user you would have seen that NVDA doesn't offer those features I told you about. And I see that you continue this useless discussion about screen readers that you have started just because I gave only JAWS as an example of a screen reader that can be used to test the inaccessibility of Tkinter, while Tkinter is inaccessible for other screen readers also anyway. Octavian From orasnita at gmail.com Fri Jan 28 03:34:04 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Fri, 28 Jan 2011 10:34:04 +0200 Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com><9MB%o.14110$%64.6074@unlimited.newshosting.com> <59F6E65E3D9A46AD8D7A3863F3C1DC84@teddy> <27f53f8c-7862-4366-9352-82ae9a2f3970@k3g2000yqc.googlegroups.com> <718D13777F254C839F9564BC4275DE0A@octavian> <4D402C42.1030407@tysdomain.com> <4D40447C.4010108@tysdomain.com> <33C68A0874BE4C66AB478EDFB64C2C1D@teddy> <4D41CB73.9090608@web.de> <4D41D40E.7060700@tysdomain.com> Message-ID: <21659D90CEE24DAFBD4B8E81083504DF@octavian> From: "Littlefield, Tyler" > >Because healthy Linux users ARE NOT equal to handicapped people! > O? I bet I could run circles around RR in the shell, any day. Why are you > trying to promote accessibility for a group of people you consider not > equal to a group of "healthy" people? > What do you mean by equal? The accessibility features should make the world more equal, but neither the accessibility is not able to make everything perfect and make us all really equal. The word "handicap" implies that there is no an equality of possibilities and chances, and that's why the accessibility features are needed. I know that you want to appear as a genius guy that can't detect the light with his eyes, but that which is absolutely equal to the others without needing accessibility features, but this is an obvious exageration. Octavian From orasnita at gmail.com Fri Jan 28 03:34:07 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Fri, 28 Jan 2011 10:34:07 +0200 Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com><9MB%o.14110$%64.6074@unlimited.newshosting.com><4A48EDF6D7634F2E994661A457451E87@teddy><753A4C5A6658470085804B13C80340F2@octavian> <4D40A97F.8090209@tysdomain.com><00ABBA322416409EB749102EB1CC5E61@octavian> <4D418054.8050002@tysdomain.com> <1a37f3d8-b580-4d6d-a5a3-de8cc1e656dd@y26g2000yqd.googlegroups.com> <4D41E83A.3030209@aim.com> Message-ID: From: "Corey Richardson" > wxPython is the best and most mature cross-platform GUI toolkit, given a > number of constraints. The only reason wxPython isn't the standard > Python GUI toolkit is that Tkinter was there first. > -- Guido van Rossum Oh, how can Guido say this about that bad WxPython that gives those errors under Linux... :-) Now seriously, this is the kind of opinion that need to change. "First", at the beginning, there were no screen readers and no accessibility was possible. But now it is possible and if this possibility requires that kind of change, *I think* that it would be absolutely normal to be done. If we would say about everything that "it was first", then we should not change anything important because of that reason. Octavian From orasnita at gmail.com Fri Jan 28 03:34:10 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Fri, 28 Jan 2011 10:34:10 +0200 Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com><9MB%o.14110$%64.6074@unlimited.newshosting.com><4A48EDF6D7634F2E994661A457451E87@teddy><753A4C5A6658470085804B13C80340F2@octavian> <4D40A97F.8090209@tysdomain.com><00ABBA322416409EB749102EB1CC5E61@octavian> <4D418054.8050002@tysdomain.com> <1a37f3d8-b580-4d6d-a5a3-de8cc1e656dd@y26g2000yqd.googlegroups.com><4D41E83A.3030209@aim.com> Message-ID: <6CABCB34902E4A5FB9FB27934899701E@octavian> From: "Terry Reedy" >> wxPython is the best and most mature cross-platform GUI toolkit, given a >> number of constraints. The only reason wxPython isn't the standard >> Python GUI toolkit is that Tkinter was there first. >> -- Guido van Rossum >> >> (from http://www.wxpython.org/quotes.php) > > Of course, that is not the only reason now. Python has moved on to a 21st > century version, while wxpython is still stuck on the 20century version. > I don't say you are not right, but can you say that Tkinter is a 21st century lib if it doesn't offer even the accessibility features? Octavian From orasnita at gmail.com Fri Jan 28 03:34:14 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Fri, 28 Jan 2011 10:34:14 +0200 Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com><9MB%o.14110$%64.6074@unlimited.newshosting.com><4A48EDF6D7634F2E994661A457451E87@teddy><753A4C5A6658470085804B13C80340F2@octavian><4D40A97F.8090209@tysdomain.com><00ABBA322416409EB749102EB1CC5E61@octavian><4D418054.8050002@tysdomain.com><1a37f3d8-b580-4d6d-a5a3-de8cc1e656dd@y26g2000yqd.googlegroups.com> Message-ID: <367D4A6371234191887F0BA13FE6E9BA@octavian> From: "Grant Edwards" > I think there are a lot of people who think that including a GUI in > the standard library was a mistake and the best solution would be to > get rid of Tkinter and replace it with nothing. If I were Guido and > thought that, I'd probably keep mum about it as well. :) > > [I'm not claiming Guidoe does think that, but there are some pretty > good arguments for not including a GUI at all.] Fully agree. But you will hear reactions with "batteries" :-) Octavian From orasnita at gmail.com Fri Jan 28 03:34:18 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Fri, 28 Jan 2011 10:34:18 +0200 Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com><8q7sgiF5tpU1@mid.individual.net><19891784-d6a3-41ac-a097-5902a6323bc0@o21g2000prn.googlegroups.com><0b12cdb1-45b4-41e4-9bdb-074ee669d76b@k14g2000pre.googlegroups.com><048FB74272D440A0915ABC7D76AE262B@teddy><5782E9AD8A8342D691EB3549E5E0ED7B@octavian> <409f37bb-6eb4-49ee-95cc-c4a9ea91b207@s29g2000pra.googlegroups.com> Message-ID: <4664C576A1244B57A6163EC4A01DA92A@octavian> From: "alex23" > "Octavian Rasnita" wrote: >> Ok, in this case I understand why WxPython can't be included in stdlib. >> I think there was a communication problem because the oldest list members >> start with the idea that all the list members know who is who and they >> may >> be thinking that I don't want to accept the reality or that I have bad >> feelings about some list members or something like that. > > The only expectation I as a list member have of you is that you maybe > hit the web and do a bit of search & research before starting on an > endless tirade. Implying that it was the responsibility of everyone > here to explain every little aspect of an issue you're supposedly > passionate about makes you seem either lazy or ignorant. Hi Alex, You are right, I was lazy and didn't searched on the net to find who are all the list members that answered to my posts for understanding better their position, so it's my fault. Octavian From orasnita at gmail.com Fri Jan 28 03:43:27 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Fri, 28 Jan 2011 10:43:27 +0200 Subject: dictionary error: list assignment index out of range References: <588467.15109.qm@web113814.mail.gq1.yahoo.com> Message-ID: <910F48A9614D47E5AA1960DE94F78A27@octavian> From: Vaduvoiu Tiberiu > Well, to quote firefox: this is embarrassing. I've realized the dictionary initialization is wrong, as [] means its a tuple, I should use {}. That's why I > don't like working nights..it's only in the morning when you start seeing things better. I apologize for the mail. Cheers [] is for lists. () is for tuples. HTH. Octavian -------------- next part -------------- An HTML attachment was scrubbed... URL: From mailing at franzoni.eu Fri Jan 28 05:32:06 2011 From: mailing at franzoni.eu (Alan Franzoni) Date: Fri, 28 Jan 2011 11:32:06 +0100 Subject: Behaviour-based interface/protocol implementation? In-Reply-To: References: Message-ID: On Thu, Jan 27, 2011 at 11:41 PM, Daniel Urban wrote: > Actually it can. You don't have to modify the object, just check for > the desired methods/signature/whatever. See for example the > implementation of collections.Hashable.__subclasshook__ in _abcoll.py > and the abc.ABCMeta.__instancecheck__ method. Mmh, I don't get your examples (subclasshook checks for *classes*, not instances, and ABCMeta is a metaclass whose instance is an ABC), but after properly looking at the PEP (__instancecheck__ seems to be poorly documented in python standard docs) I've seen that yes, __instancecheck__ on an ABC can actually be used in place of maybe_implemented_by and hooking into isinstance(). Thanks! -- Alan Franzoni -- contact me at public@[mysurname].eu From research at johnohagan.com Fri Jan 28 05:36:00 2011 From: research at johnohagan.com (John O'Hagan) Date: Fri, 28 Jan 2011 10:36:00 +0000 Subject: Algorithm for generating pitch-class sets in prime form Message-ID: <201101281036.00656.research@johnohagan.com> I'm looking for some help coming up with an algorithm to produce lists which meet the following criterion (you don't need to know music to get this): In musical pitch-class set theory, "prime form" is defined as the most tightly- packed-to-the-left rotation of a set's interval structure. Prime forms are important in music because they provide the unique simplest form of any pitch structure. I'm writing a python program which uses this principle. For example: the sequence [2, 6, 9] (which happens to be a D major chord) would be put in prime form by: - Sorting and transposing it so it starts on zero: [0, 4, 7] - Expressing it as intervals: [4, 3, 5] (the last number is the distance to the octave) - Rotating the intervals such that the biggest interval is at the end; if there are more than one biggest intervals, we want the rotation with the smallest first interval, and if that is also tied, the one with the smallest second interval, and so on. In this example we are already there. An easy way of finding a prime form in Python is: def prime_form(seq): pcs = sorted(list(set(seq))) intervals = ([pcs[i + 1] - pcs[i] for i in range(len(pcs) - 1)] + [12 + min(pcs) - pcs[-1]]) rotations = [intervals[i:] + intervals[:i] for i in range(len(intervals))] prime_intervals = min([i for i in rotations if i[-1] == max(intervals)]) return [sum(prime_intervals[:i]) for i in range(len(prime_intervals))] But I'm looking for a way of generating sequences already in prime form without duplication or omission. One promising approach is using a function which generates all the (ordered) partitions of a number, and producing the multiset permutations of each partition, which gives us all the possible interval structures (but many of which are rotationally equivalent): def full(num): for part in partitions(num): for perm in multiset_permutations(part): yield perm (The actual functions I'm using for this are at the end of this message.) To start narrowing it down to prime forms, we can chop off the largest interval from the end, permute the rest, and replace it on the end of each permutation: def full(num): for part in partitions(num): if len(part) == 1: yield part else: for perm in multiset_permutations(part[:-1]): yield perm + part[-1] but this produces a lot of false positives in cases where there is more than one largest interval. I imagine a solution might work by removing the largest intervals from each partition, permuting the remaining intervals, and into each permutation inserting the large intervals, one at the end and the others in each possible place that satisfies the requirements. And that's where I'm getting lost. Any clues, suggestions or solutions? Regards, John The functions: def partitions(num): if num == 0: yield [] return for part in partitions(num-1): yield [1] + part if part and (len(part) < 2 or part[1] > part[0]): yield [part[0] + 1] + part[1:] def _reverse(seq, start, end): "A sub-function for multiset_permutations" #seq = seq[:start] + reversed(seq[start:end]) + seq[end:] end -= 1 if end <= start: return while True: seq[start], seq[end] = seq[end], seq[start] if start == end or start+1 == end: return start += 1 end -= 1 def multiset_permutations(seq): first = 0 last = len(seq) yield seq if last == 1: raise StopIteration while True: next = last - 1 while True: next1 = next next -= 1 if seq[next] < seq[next1]: mid = last - 1 while seq[next] >= seq[mid]: mid -= 1 seq[next], seq[mid] = seq[mid], seq[next] _reverse(seq, next1, last) yield seq break if next == first: raise StopIteration raise StopIteration From urban.dani at gmail.com Fri Jan 28 06:00:58 2011 From: urban.dani at gmail.com (Daniel Urban) Date: Fri, 28 Jan 2011 12:00:58 +0100 Subject: Behaviour-based interface/protocol implementation? In-Reply-To: References: Message-ID: On Fri, Jan 28, 2011 at 11:32, Alan Franzoni wrote: > On Thu, Jan 27, 2011 at 11:41 PM, Daniel Urban wrote: > >> Actually it can. You don't have to modify the object, just check for >> the desired methods/signature/whatever. See for example the >> implementation of collections.Hashable.__subclasshook__ in _abcoll.py >> and the abc.ABCMeta.__instancecheck__ method. > > Mmh, I don't get your examples (subclasshook checks for *classes*, not > instances, and ABCMeta is a metaclass whose instance is an ABC), but > after properly looking at the PEP (__instancecheck__ seems to be > poorly documented in python standard docs) I've seen that yes, > __instancecheck__ on an ABC can actually be used in place of > maybe_implemented_by and hooking into isinstance(). Exactly. I mentioned subclasshook because it is possible to define a similar "instancehook", which would check for instances. Daniel From ajaysachin44 at gmail.com Fri Jan 28 06:12:35 2011 From: ajaysachin44 at gmail.com (Vijay Varma) Date: Fri, 28 Jan 2011 03:12:35 -0800 (PST) Subject: Make Money Online Message-ID: <5d9285c5-4686-4c69-b286-266c4601f856@s9g2000vbh.googlegroups.com> Get New ideas for easy way of employment and buisness by just sitting at your home.Online jobs are one of the most liked jobs by youngsters and even by elders, after retirement or can do even as a part time job.Just Sing Up for Google Adsense,Adbrite,Bidvertiser etc adds company & earn up to 1254 $ per month Hurry Up ! offer limted for first 2000 persons only http://www.knowledge2know.com/incomesource.htm From orasnita at gmail.com Fri Jan 28 08:38:21 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Fri, 28 Jan 2011 15:38:21 +0200 Subject: WxPython versus Tkinter. References: <4D41E861.9040604@tysdomain.com> Message-ID: <180208786DB640C79FE59EF029E62717@octavian> From: "Littlefield, Tyler" > >Yes but his silence speaks louder than words. He is saying " While i > >won't defend Tkinter publicly, i won't promote any others as well". > That's the best translation I've ever heard: taking silence and diverting > it into your own meaning for what you want it to mean. And he is perfectly right. A library included in the stdlib is obviously promoted without beeing necessary to tell the world "use it". Octavian From rantingrick at gmail.com Fri Jan 28 09:09:07 2011 From: rantingrick at gmail.com (rantingrick) Date: Fri, 28 Jan 2011 06:09:07 -0800 (PST) Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com> <9MB%o.14110$%64.6074@unlimited.newshosting.com> <59F6E65E3D9A46AD8D7A3863F3C1DC84@teddy> <27f53f8c-7862-4366-9352-82ae9a2f3970@k3g2000yqc.googlegroups.com> <718D13777F254C839F9564BC4275DE0A@octavian> <4D402C42.1030407@tysdomain.com> <4D40447C.4010108@tysdomain.com> <33C68A0874BE4C66AB478EDFB64C2C1D@teddy> <4D407321.3090705@web.de> <1296128007.17192.1417506961@webmail.messagingengine.com> Message-ID: <8a9bdf33-4f0e-4a82-bc60-4ccafac468e3@k15g2000prk.googlegroups.com> On Jan 28, 2:33?am, "Octavian Rasnita" wrote: > From: "Terry Reedy" > > > For example: pygui pretty much uses native widgets on Windows and OX and > > gtk (I believe) on *nix. How is the accessibility of those widget sets *as > > accessed through pygui*? Is it different from the 'native' accessibility > > of each of those set? > > Thank you for telling about this GUI lib! > I have tested the sample apps it offers and the standard dialogs are very > accessible. I hope it is the same in case of the other common controls like > list boxes, list views, check boxes, radio buttons, combo boxes, tree > views... It is great to hear that pyGUI is accessible! You know, if we cannot have wxPython in the stdlib my next choice would be pyGUI. Heck, we should have started with pyGUI 20 years ago and we would better off today! From rantingrick at gmail.com Fri Jan 28 09:18:03 2011 From: rantingrick at gmail.com (rantingrick) Date: Fri, 28 Jan 2011 06:18:03 -0800 (PST) Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com> <9MB%o.14110$%64.6074@unlimited.newshosting.com> <4A48EDF6D7634F2E994661A457451E87@teddy> <753A4C5A6658470085804B13C80340F2@octavian> Message-ID: <90450b74-2d66-4a78-8a9f-0c3807607848@o14g2000prb.googlegroups.com> On Jan 27, 12:13?pm, Stephen Hansen wrote: > Seriously. Octavian's attitude in this thread makes me want to go use > Tkinter just to spite him. And I'm net-buds with Tyler, and I'm working > on a project that I thought accessibility for the blind was very > important for. But no more! Well Stephen that would mean you would have to actually *learn* to use Tkinter, and from your own admission (not very long ago!) you don't know anything about Tkinter. Remember our Tk-Wx geometry challenge? Nice try! ;-) Everyone on this list knows that Kevin and myself are the *only* people who know how to wield Tkinter past some simple utility GUI's. From rantingrick at gmail.com Fri Jan 28 09:21:19 2011 From: rantingrick at gmail.com (rantingrick) Date: Fri, 28 Jan 2011 06:21:19 -0800 (PST) Subject: WxPython versus Tkinter. References: Message-ID: <51e446d7-adb2-4507-93c1-37dc80baa4cb@o18g2000prh.googlegroups.com> On Jan 27, 3:49?pm, "Littlefield, Tyler" wrote: > ?>Yes but his silence speaks louder than words. He is saying " While i > ?>won't defend Tkinter publicly, i won't promote any others as well". > That's the best translation I've ever heard: taking silence and > diverting it into your own meaning for what you want it to mean. Oh Tyler, your just jealous that i beat you to the punch! :-) From malaclypse2 at gmail.com Fri Jan 28 09:36:53 2011 From: malaclypse2 at gmail.com (Jerry Hill) Date: Fri, 28 Jan 2011 09:36:53 -0500 Subject: Bugs/issues in tkinter.simpledialog!! In-Reply-To: References: <412e4d83-f750-441d-bfc5-d96c0559e069@e9g2000prn.googlegroups.com> Message-ID: On Fri, Jan 28, 2011 at 12:34 AM, rantingrick wrote: > Well i tried searching for "Tkinter" issues on the tracker and just > got annoyed quickly and left. It seems far to complicated to do > searches with this software. > You should apply some of the persistence that you show on the mailing list to the problem! Go to http://bugs.python.org On the left hand side, there's a link to the search page (listed just below "Issues"). Click that. Find the list box labeled "Components" and select "Tkinter" from the drop down. Click Search. Bob's your uncle! -- Jerry -------------- next part -------------- An HTML attachment was scrubbed... URL: From mail2bansi at gmail.com Fri Jan 28 09:46:04 2011 From: mail2bansi at gmail.com (bansi) Date: Fri, 28 Jan 2011 06:46:04 -0800 (PST) Subject: Is it possible to pass CSV Reader Object As Argument to another Python File ??? References: <2c35653e-3565-48c6-8939-b6b09b885e3f@d23g2000prj.googlegroups.com> <876b6c52-1a6d-4afa-83e9-fa987c9359a5@v31g2000pri.googlegroups.com> <87lj272vpo.fsf@benfinney.id.au> Message-ID: <430714cd-20b4-4a67-bd2d-54e8f0c44ad5@s18g2000vbe.googlegroups.com> On Jan 26, 8:31?pm, MRAB wrote: > On 27/01/2011 00:57, bansi wrote: > > > > > > > On Jan 26, 6:25 pm, Ethan Furman ?wrote: > >> bansi wrote: > > >> ? > ?First namelookupWrapper.py running under Python 2.6 accept arguments > >> ? > ?from stdin and uses csv reader object to read it i.e. > >> ? > ?r=csv.reader(sys.stdin) > > >> ? > ?And then it has to pass csv reader object to another python script > >> ? > ?namelookup.py running under Python 2.7 because it uses pyodbc to > >> ? > ?connect to database and iterates thru reader object > > >> Ben Finney wrote: > >>> bansi ?writes: > > >>>> Thanks Chris. Sorry for mis-communicating, the two python scripts are > >>>> dependant in a way that namelookupWrapper.py needs to pass csv record > >>>> object to another python script > > >>> Why have you structured them that way, though? What constraint is > >>> keeping you from doing the work in a single process, where the CSV > >>> reader object can be shared? > > >>>> If thats not possible then please let me know how to do the workaround > >>>> i didnt understood the import thing and not sure if it helps in my > >>>> case > > >>> The problem as you've described it so far is best solved by having a > >>> single process accessing the CSV reader object in memory. If that > >>> doesn't suit your use case, you'll need to explain why not. > > >> In other words, why can't you use Python 2.7 to accept input and > >> generate a csv.reader? > > >> ~Ethan~- Hide quoted text - > > >> - Show quoted text - > > > Ethan, > > The python script takes the input from Splunk (http://www.splunk.com/ > > base/Documentation/) which supports only Python 2.6 > > So the real constraint is Splunk supports only Python 2.6 . > > > As you know Python 2.6 doesnt support or doesnt have pyodbc install > > for Windows ?64 bit OS > > So i installed Python 2.7 and thereafter pyodbc install for Windows 64 > > bit OS for Python 2.7 > > Have you actually tried Splunk with Python 2.7? It might not work with > versions which are earlier than Python 2.6, but that doesn't > necessarily mean that it won't work with versions of Python 2 which are > later than Python 2.6 (unless the documentation says that it must be > Python 2.6).- Hide quoted text - > > - Show quoted text - Splunk's latest version 4.1.6 doesn't support Python 2.7 I tried the import trick but it didnt work because the real script which runs under Python 2.7 has import pyodbc so it results in following error c:\Splunk\etc\apps\search\bin>splunk cmd python namelookupWrapper.py memberId memberName < memberInput.csv Traceback (most recent call last): File "namelookupWrapper.py", line 3, in import namelookup File "c:\Splunk\etc\apps\search\bin\namelookup.py", line 7, in import pyodbc ImportError: DLL load failed: The specified module could not be found. Please let me know if i am missing something on import. If so please provide me with an example From g.rodola at gmail.com Fri Jan 28 09:52:55 2011 From: g.rodola at gmail.com (=?ISO-8859-1?Q?Giampaolo_Rodol=E0?=) Date: Fri, 28 Jan 2011 15:52:55 +0100 Subject: Bugs/issues in tkinter.simpledialog!! In-Reply-To: References: Message-ID: 2011/1/26 rantingrick : > > I just installed Python 3,0 on my machine. I cannot use 3.0 > exclusively yet however i was interested in just poking around and > acquiring a taste if you will. I was happy to find that the new > Tkinter module names now follow convention and are placed correctly... > example: "tkinter.simpledialog" > > However some things never change it seems and some improvements are > actually a step backwards. The same problems with the unit test in 2.x > got ported to 3.x. And the new SimpleDialog is just more lackluster > code like we've seen before. I was hoping to be amazed, i am > disappointed and disgusted. It is obvious that whoever is writing/ > maintaining the tkinter code base does NOT understand tkinter > completely and this is blinding apparent by reading the source code! > > ----------- > ?Issues > ----------- > > First lets start with the problems that migrated from 2.x... > (tkinter.simpledialog) > > #-- ISSUE 1 --# > In the test() function we still have code that uses the "quit" method > instead of "destroy". Calling the "quit" method only tells Tkinter to > stop processing events, IT DOES NOT DESTROY THE WIDGET!! And on > windows the the root will then become unresponsive -- you cannot close > the window, you cannot do anything. I have said time and time again. > DO NOT USE THE QUIT METHOD UNLESS YOU KNOW WHAT THE HECK YOU ARE > DOING! So the code needs to be this... > > OLD: > ? q = Button(root, text='Quit', command=t.quit) > > NEW: > ? q = Button(root, text='Quit', command=root.destroy) > > > #-- ISSUE 2: --# > The author used a very strange method by which to denote the default > button in the SimpleDialog class. He choose to set the relief to RIDGE > and the border "8". This not only looks horrible (and exposes the > authors ignorance of tkinter) but a much more elegant solution is > provided by the TclTk folks. All buttons have a "default" option that > will display the button with a nice border so the user can visually > see which button is active. So the code should be this.... > > OLD: > ? ? ? ? ? ?if num == default: > ? ? ? ? ? ? ? ?b.config(relief=RIDGE, borderwidth=8) > > NEW: > ? ? ? ? ? ?if num == default: > ? ? ? ? ? ? ? ?b.config(default=ACTIVE) > > > Last but not least i am puzzled as to why we choose the method name > "go" over "show". for "showing" the dialog. ?SimpleDialog uses no > inheritance so name clashes are mum. Why would anyone choose "go" over > "show" for a modal dialog? I would really like an explanation for > this. > > > Other minor issues exists. I may describe them later. At this time we > need to fix these grave abominations first. > -- > http://mail.python.org/mailman/listinfo/python-list Why don't you file a ticket on the bug tracker instead of wasting yours and other people's time here by making appear another rant against Tkinter as a bug report? It's been 3 days in a row you've been doing this. Aren't you tired? Seriously! This has come to not even being a rant anymore. It's just nonsense. --- Giampaolo http://code.google.com/p/pyftpdlib/ http://code.google.com/p/psutil/ From tyler at tysdomain.com Fri Jan 28 10:15:52 2011 From: tyler at tysdomain.com (Littlefield, Tyler) Date: Fri, 28 Jan 2011 08:15:52 -0700 Subject: WxPython versus Tkinter. In-Reply-To: References: <4D3E4377.3060807@tysdomain.com> <9MB%o.14110$%64.6074@unlimited.newshosting.com> <4A48EDF6D7634F2E994661A457451E87@teddy> <753A4C5A6658470085804B13C80340F2@octavian> <4D41B5AF.8020200@ixokai.io> <4D41BCC2.2060906@tysdomain.com> Message-ID: <4D42DDA8.4080100@tysdomain.com> >Are you a representative voice for all the screen reader users? (Even though >most of them use JAWS that you don't seem to like) Newsflash: I didn't say I didn't like Jaws, and I'm using Jaws -right now-. I don't like jaws and see a lot of future for NVDA as it is both free and open source. I like that a lot more than paying what, $1300 or so for a program that will allow me to use the computer? Plus the obligatory $260 for two updates so I can update once every four months, regardless of whether or not I want to update. If you want to rant and scream about accessibility, yell at the people charging an arm and a leg to make things accessible. On 1/28/2011 1:33 AM, Octavian Rasnita wrote: > From: "Littlefield, Tyler" >> >* Disclaimer: You are stupid if you think this is true. But seriously, >> >Octavian makes it REALLY hard to continue caring about something that I >> >actually cared about before and thought was important. > > When I told about what the community of the blind from my country > cares, or > what I care, the others told me that that is not important. I am sure > that > won't say the same thing to your post in which you also say about what > you > care, just because you have the same opinions like them. > >> People like Octavian do that. Sadly, it is one of the things holding the >> blind community back. I hope that with my arguments (for those that >> didn't >> just toss everything related to this thread), I have been able to get >> people to see a little differently and not consider Octavian as the >> voice >> for us all. > > > Who are those "us all"? > Are you a representative voice for all the screen reader users? (Even > though > most of them use JAWS that you don't seem to like) > Or do you agree with the associations of the blind in your country do > when > they fight with different companies because they make discrimination > by not > offering accessible products? > Or you are more representative than those associations? > > Octavian > -- Thanks, Ty From invalid at invalid.invalid Fri Jan 28 10:52:19 2011 From: invalid at invalid.invalid (Grant Edwards) Date: Fri, 28 Jan 2011 15:52:19 +0000 (UTC) Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com> <9MB%o.14110$%64.6074@unlimited.newshosting.com> <4A48EDF6D7634F2E994661A457451E87@teddy> <753A4C5A6658470085804B13C80340F2@octavian> Message-ID: On 2011-01-28, Octavian Rasnita wrote: > How can we talk about etiquette when exactly this etiquette is the one that > needs to be changed? Huh? > As you say, the etiquette is in favor of the preferences of the majority, > but how should react someone, what he/she should say in order to make the > others understand that that etiquette is bad because it discriminates some > categories of people? Please explain what etiquette you are talking about that is discriminatory. > You are right in that case, but the comparison is not good because yes there > is a value in creating accessible GUIS. I'm not arguing against creating accessible GUIs. I'm not saying that you shouldn't argue in favor of doing so. I'm just saying that the _way_ you are presenting your argument is counter-productive. > Those who drive on the left, the minority, can adapt to drive on the > right. If their cars have the wheels on the right, there are > technical solutions for that problem... they ccan change their cars. > But if an application uses Tk, those minorities that have problems > don't have any technical solution to solve them, because there are > not accessible versions for all the inaccessible apps. You've completely missed the analogy. I'm not saying that people who need/want accessible apps are "driving on the left". I'm saying that by the manner in which you espouse accessibility you are driving on the left. > Try to imagine that it will appear an incurable disease for those who drive > on the right. What do you think it will happen? Probably they all would > start driving on the left. I'm not saying accessibility isn't good or important. I'm saying you're _hurting_ the cause of accessiblity by the manner in which you lobby for it. But, you seem unable or unwilling to understand that. When somebody tells you you're being rude, insulting, or disrepectful, they're _not_ saying that accessibility is not important. They're just telling you that you're being rude, insulting , or disrepectful. [plonk] -- Grant Edwards grant.b.edwards Yow! There's enough money at here to buy 5000 cans of gmail.com Noodle-Roni! From bryan.oakley at gmail.com Fri Jan 28 10:52:22 2011 From: bryan.oakley at gmail.com (Bryan) Date: Fri, 28 Jan 2011 07:52:22 -0800 (PST) Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com> <9MB%o.14110$%64.6074@unlimited.newshosting.com> <4A48EDF6D7634F2E994661A457451E87@teddy> <753A4C5A6658470085804B13C80340F2@octavian> <90450b74-2d66-4a78-8a9f-0c3807607848@o14g2000prb.googlegroups.com> Message-ID: On Jan 28, 8:18?am, rantingrick wrote: > On Jan 27, 12:13?pm, Stephen Hansen wrote: > > > Seriously. Octavian's attitude in this thread makes me want to go use > > Tkinter just to spite him. And I'm net-buds with Tyler, and I'm working > > on a project that I thought accessibility for the blind was very > > important for. But no more! > > Well Stephen that would mean you would have to actually *learn* to use > Tkinter, and from your own admission (not very long ago!) you don't > know anything about Tkinter. Remember our Tk-Wx geometry challenge? > Nice try! ;-) Do you have a link to this challenge? I assume it's a different one than the challenge that started this thread since the one that started this thread had nothing to do with geometry. > > Everyone on this list knows that Kevin and myself are the *only* > people who know how to wield Tkinter past some simple utility GUI's. I beg your pardon. Neither statement is true. There are more experts than you realize, and "this list" knows there are more experts than you and Kevin. There's a possible third misconception in your statement that's not worth discussing at this point. From invalid at invalid.invalid Fri Jan 28 10:56:26 2011 From: invalid at invalid.invalid (Grant Edwards) Date: Fri, 28 Jan 2011 15:56:26 +0000 (UTC) Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com> <9MB%o.14110$%64.6074@unlimited.newshosting.com> <4A48EDF6D7634F2E994661A457451E87@teddy> <753A4C5A6658470085804B13C80340F2@octavian> <4D41B5AF.8020200@ixokai.io> Message-ID: On 2011-01-28, Octavian Rasnita wrote: > From: "Stephen Hansen" >> Seriously. Octavian's attitude in this thread makes me want to go use >> Tkinter just to spite him. > > Oh yes? And this would probably mean that your atitude is a very good > and normal one, right? Good? No. Normal? Yes. I'm beginning to think that Octavian has some fundamental problems when it comes to empathy and social interaction skills. I think he genuinly has no clue how others perceive his postings nor does he understand what we mean by etiquette. -- Grant Edwards grant.b.edwards Yow! HOORAY, Ronald!! at Now YOU can marry LINDA gmail.com RONSTADT too!! From invalid at invalid.invalid Fri Jan 28 10:57:54 2011 From: invalid at invalid.invalid (Grant Edwards) Date: Fri, 28 Jan 2011 15:57:54 +0000 (UTC) Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com> <9MB%o.14110$%64.6074@unlimited.newshosting.com> <59F6E65E3D9A46AD8D7A3863F3C1DC84@teddy> <27f53f8c-7862-4366-9352-82ae9a2f3970@k3g2000yqc.googlegroups.com> <718D13777F254C839F9564BC4275DE0A@octavian> <4D402C42.1030407@tysdomain.com> <4D40447C.4010108@tysdomain.com> <33C68A0874BE4C66AB478EDFB64C2C1D@teddy> <4D407321.3090705@web.de> <1296128007.17192.1417506961@webmail.messagingengine.com> Message-ID: On 2011-01-28, Octavian Rasnita wrote: > From: "Grant Edwards" >> A very important way to help would be to test accessibility features >> and post accurate, detailed, bug-reports. > I am willing to do that. I have tested that program made with > WxPython and I have posted here what I found, The wxPython mailing list and/or bug-tracker is the right place for that. > What can I say more? You don't need to say more. You need to say less and say it differently. -- Grant Edwards grant.b.edwards Yow! Do you guys know we at just passed thru a BLACK gmail.com HOLE in space? From deets at web.de Fri Jan 28 11:13:24 2011 From: deets at web.de (Diez B. Roggisch) Date: Fri, 28 Jan 2011 17:13:24 +0100 Subject: A http server References: Message-ID: Back9 writes: > Hi, > I'm trying to set up a http server to handle a single POST request. > That POST request is to upload a huge file and the server is supposed > to handle it with the just POST request. > With my python sample code, multiple post requests are working well, > but that is not my solution. > I need a single POST request handling in the http server side. > Does anyone have a good idea for this case or sample code? Why doesn't the single post not work with your sample code? Where is your sample code? It might be a good idea to use WSGI for this, to stream out the POST-body to a temporary file. Can you use mod_wsgi in conjuction with Apache? If not, some pure WSGI-server implementation such as Paster might be enough. Diez From kw at codebykevin.com Fri Jan 28 11:16:49 2011 From: kw at codebykevin.com (Kevin Walzer) Date: Fri, 28 Jan 2011 11:16:49 -0500 Subject: WxPython versus Tkinter. In-Reply-To: <90450b74-2d66-4a78-8a9f-0c3807607848@o14g2000prb.googlegroups.com> References: <4D3E4377.3060807@tysdomain.com> <9MB%o.14110$%64.6074@unlimited.newshosting.com> <4A48EDF6D7634F2E994661A457451E87@teddy> <753A4C5A6658470085804B13C80340F2@octavian> <90450b74-2d66-4a78-8a9f-0c3807607848@o14g2000prb.googlegroups.com> Message-ID: <18c47$4d42eba6$4275d90a$21758@FUSE.NET> On 1/28/11 9:18 AM, rantingrick wrote: > Everyone on this list knows that Kevin and myself are the *only* > people who know how to wield Tkinter past some simple utility GUI's. I strongly disagree with this statement. --Kevin -- Kevin Walzer Code by Kevin http://www.codebykevin.com From bryan.oakley at gmail.com Fri Jan 28 11:27:53 2011 From: bryan.oakley at gmail.com (Bryan) Date: Fri, 28 Jan 2011 08:27:53 -0800 (PST) Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com> <9MB%o.14110$%64.6074@unlimited.newshosting.com> <4A48EDF6D7634F2E994661A457451E87@teddy> <753A4C5A6658470085804B13C80340F2@octavian> <90450b74-2d66-4a78-8a9f-0c3807607848@o14g2000prb.googlegroups.com> <18c47$4d42eba6$4275d90a$21758@FUSE.NET> Message-ID: <9132f237-6101-4d28-a6b1-bfbfb4b0048a@p12g2000vbo.googlegroups.com> On Jan 28, 10:16?am, Kevin Walzer wrote: > On 1/28/11 9:18 AM, rantingrick wrote: > > > Everyone on this list knows that Kevin and myself are the *only* > > people who know how to wield Tkinter past some simple utility GUI's. > > I strongly disagree with this statement. > (BTW, Kevin, Congrats on getting a tk app accepted by the Mac app store. That's an impressive feat!) From me+list/python at ixokai.io Fri Jan 28 12:26:49 2011 From: me+list/python at ixokai.io (Stephen Hansen) Date: Fri, 28 Jan 2011 09:26:49 -0800 Subject: WxPython versus Tkinter. In-Reply-To: <90450b74-2d66-4a78-8a9f-0c3807607848@o14g2000prb.googlegroups.com> References: <4D3E4377.3060807@tysdomain.com> <9MB%o.14110$%64.6074@unlimited.newshosting.com> <4A48EDF6D7634F2E994661A457451E87@teddy> <753A4C5A6658470085804B13C80340F2@octavian> <90450b74-2d66-4a78-8a9f-0c3807607848@o14g2000prb.googlegroups.com> Message-ID: <4D42FC59.6000507@ixokai.io> On 1/28/11 6:18 AM, rantingrick wrote: > On Jan 27, 12:13 pm, Stephen Hansen wrote: > >> Seriously. Octavian's attitude in this thread makes me want to go use >> Tkinter just to spite him. And I'm net-buds with Tyler, and I'm working >> on a project that I thought accessibility for the blind was very >> important for. But no more! > > Well Stephen that would mean you would have to actually *learn* to use > Tkinter, and from your own admission (not very long ago!) you don't > know anything about Tkinter. Remember our Tk-Wx geometry challenge? > Nice try! ;-) And? Gee-whiz-golly, I might have to learn something new. OH NOES. Its friday again. > Everyone on this list knows that Kevin and myself are the *only* > people who know how to wield Tkinter past some simple utility GUI's. Hah. No. -- Stephen Hansen ... Also: Ixokai ... Mail: me+list/python (AT) ixokai (DOT) io ... Blog: http://meh.ixokai.io/ -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 487 bytes Desc: OpenPGP digital signature URL: From python at mrabarnett.plus.com Fri Jan 28 13:15:38 2011 From: python at mrabarnett.plus.com (MRAB) Date: Fri, 28 Jan 2011 18:15:38 +0000 Subject: WxPython versus Tkinter. In-Reply-To: <409FABAAA3D74ADCB11E06C676282650@octavian> References: <4D3E4377.3060807@tysdomain.com><9MB%o.14110$%64.6074@unlimited.newshosting.com> <59F6E65E3D9A46AD8D7A3863F3C1DC84@teddy> <27f53f8c-7862-4366-9352-82ae9a2f3970@k3g2000yqc.googlegroups.com> <718D13777F254C839F9564BC4275DE0A@octavian> <4D402C42.1030407@tysdomain.com> <4D40447C.4010108@tysdomain.com><33C68A0874BE4C66AB478EDFB64C2C1D@teddy> <4D407333.1070301@tysdomain.com><82865E7A54C048C398B4F4160FC43B57@octavian><4D417EFC.70800@tysdomain.com><57C3CFA0C7EE4578B0C6EAA267AAE678@teddy> <4D41B6B7.7010609@tysdomain.com> <409FABAAA3D74ADCB11E06C676282650@octavian> Message-ID: <4D4307CA.1070800@mrabarnett.plus.com> On 28/01/2011 08:34, Octavian Rasnita wrote: > From: "Littlefield, Tyler" >> what >JAWS > > Tyler, did I used bad words in my posts as you do now? > I didn't, but the other list members told me that my atitude is not good, > that I am not civilized, because I have a different opinion than them. > I am sure *nobody* will tell you that thing even though they can also see > your posts. > [snip] They are saying that your attitude is not good because your attitude is not good. They are not saying that your opinion is not good. It's not what you say but how you say it. From python at rcn.com Fri Jan 28 13:32:34 2011 From: python at rcn.com (Raymond Hettinger) Date: Fri, 28 Jan 2011 10:32:34 -0800 (PST) Subject: Use the Source Luke Message-ID: <094f6fc5-7242-46c7-b454-4cb29d0c6ef9@q40g2000prh.googlegroups.com> I hoping a new trend will start with dev's putting direct source code links in their documentation: http://rhettinger.wordpress.com/2011/01/28/open-your-source-more/ I'm looking for more examples of projects that routinely link their docs back into relavant sections of code. Have any of you all seen other examples besides the Go language docs and the Python docs? Raymond From mail2bansi at gmail.com Fri Jan 28 13:33:18 2011 From: mail2bansi at gmail.com (bansi) Date: Fri, 28 Jan 2011 10:33:18 -0800 (PST) Subject: Is it possible to pass CSV Reader Object As Argument to another Python File ??? References: <2c35653e-3565-48c6-8939-b6b09b885e3f@d23g2000prj.googlegroups.com> <876b6c52-1a6d-4afa-83e9-fa987c9359a5@v31g2000pri.googlegroups.com> <87lj272vpo.fsf@benfinney.id.au> <430714cd-20b4-4a67-bd2d-54e8f0c44ad5@s18g2000vbe.googlegroups.com> Message-ID: <2c9f82cd-756b-4460-940b-31e2a866f24e@n36g2000pre.googlegroups.com> On Jan 28, 9:46?am, bansi wrote: > On Jan 26, 8:31?pm, MRAB wrote: > > > > > > > On 27/01/2011 00:57, bansi wrote: > > > > On Jan 26, 6:25 pm, Ethan Furman ?wrote: > > >> bansi wrote: > > > >> ? > ?First namelookupWrapper.py running under Python 2.6 accept arguments > > >> ? > ?from stdin and uses csv reader object to read it i.e. > > >> ? > ?r=csv.reader(sys.stdin) > > > >> ? > ?And then it has to pass csv reader object to another python script > > >> ? > ?namelookup.py running under Python 2.7 because it uses pyodbc to > > >> ? > ?connect to database and iterates thru reader object > > > >> Ben Finney wrote: > > >>> bansi ?writes: > > > >>>> Thanks Chris. Sorry for mis-communicating, the two python scripts are > > >>>> dependant in a way that namelookupWrapper.py needs to pass csv record > > >>>> object to another python script > > > >>> Why have you structured them that way, though? What constraint is > > >>> keeping you from doing the work in a single process, where the CSV > > >>> reader object can be shared? > > > >>>> If thats not possible then please let me know how to do the workaround > > >>>> i didnt understood the import thing and not sure if it helps in my > > >>>> case > > > >>> The problem as you've described it so far is best solved by having a > > >>> single process accessing the CSV reader object in memory. If that > > >>> doesn't suit your use case, you'll need to explain why not. > > > >> In other words, why can't you use Python 2.7 to accept input and > > >> generate a csv.reader? > > > >> ~Ethan~- Hide quoted text - > > > >> - Show quoted text - > > > > Ethan, > > > The python script takes the input from Splunk (http://www.splunk.com/ > > > base/Documentation/) which supports only Python 2.6 > > > So the real constraint is Splunk supports only Python 2.6 . > > > > As you know Python 2.6 doesnt support or doesnt have pyodbc install > > > for Windows ?64 bit OS > > > So i installed Python 2.7 and thereafter pyodbc install for Windows 64 > > > bit OS for Python 2.7 > > > Have you actually tried Splunk with Python 2.7? It might not work with > > versions which are earlier than Python 2.6, but that doesn't > > necessarily mean that it won't work with versions of Python 2 which are > > later than Python 2.6 (unless the documentation says that it must be > > Python 2.6).- Hide quoted text - > > > - Show quoted text - > > Splunk's latest version 4.1.6 doesn't support Python 2.7 > I tried the import trick but it didnt work because the real script > which runs under Python 2.7 has import pyodbc so it results in > following error > > c:\Splunk\etc\apps\search\bin>splunk cmd python namelookupWrapper.py > memberId memberName < memberInput.csv > Traceback (most recent call last): > ? File "namelookupWrapper.py", line 3, in > ? ? import namelookup > ? File "c:\Splunk\etc\apps\search\bin\namelookup.py", line 7, in > > ? ? import pyodbc > ImportError: DLL load failed: The specified module could not be found. > > Please let me know if i am missing something on import. If so please > provide me with an example- Hide quoted text - > > - Show quoted text - Here are some more details from my earlier posting. Please click the below link http://answers.splunk.com/questions/11145/its-getting-mysterious-to-make-the-lookup-script-work From benjamin.kaplan at case.edu Fri Jan 28 13:52:15 2011 From: benjamin.kaplan at case.edu (Benjamin Kaplan) Date: Fri, 28 Jan 2011 13:52:15 -0500 Subject: Is it possible to pass CSV Reader Object As Argument to another Python File ??? In-Reply-To: <2c9f82cd-756b-4460-940b-31e2a866f24e@n36g2000pre.googlegroups.com> References: <2c35653e-3565-48c6-8939-b6b09b885e3f@d23g2000prj.googlegroups.com> <876b6c52-1a6d-4afa-83e9-fa987c9359a5@v31g2000pri.googlegroups.com> <87lj272vpo.fsf@benfinney.id.au> <430714cd-20b4-4a67-bd2d-54e8f0c44ad5@s18g2000vbe.googlegroups.com> <2c9f82cd-756b-4460-940b-31e2a866f24e@n36g2000pre.googlegroups.com> Message-ID: On Fri, Jan 28, 2011 at 1:33 PM, bansi wrote: > On Jan 28, 9:46?am, bansi wrote: >> On Jan 26, 8:31?pm, MRAB wrote: >> >> >> >> >> >> > On 27/01/2011 00:57, bansi wrote: >> >> > > On Jan 26, 6:25 pm, Ethan Furman ?wrote: >> > >> bansi wrote: >> >> > >> ? > ?First namelookupWrapper.py running under Python 2.6 accept arguments >> > >> ? > ?from stdin and uses csv reader object to read it i.e. >> > >> ? > ?r=csv.reader(sys.stdin) >> >> > >> ? > ?And then it has to pass csv reader object to another python script >> > >> ? > ?namelookup.py running under Python 2.7 because it uses pyodbc to >> > >> ? > ?connect to database and iterates thru reader object >> >> > >> Ben Finney wrote: >> > >>> bansi ?writes: >> >> > >>>> Thanks Chris. Sorry for mis-communicating, the two python scripts are >> > >>>> dependant in a way that namelookupWrapper.py needs to pass csv record >> > >>>> object to another python script >> >> > >>> Why have you structured them that way, though? What constraint is >> > >>> keeping you from doing the work in a single process, where the CSV >> > >>> reader object can be shared? >> >> > >>>> If thats not possible then please let me know how to do the workaround >> > >>>> i didnt understood the import thing and not sure if it helps in my >> > >>>> case >> >> > >>> The problem as you've described it so far is best solved by having a >> > >>> single process accessing the CSV reader object in memory. If that >> > >>> doesn't suit your use case, you'll need to explain why not. >> >> > >> In other words, why can't you use Python 2.7 to accept input and >> > >> generate a csv.reader? >> >> > >> ~Ethan~- Hide quoted text - >> >> > >> - Show quoted text - >> >> > > Ethan, >> > > The python script takes the input from Splunk (http://www.splunk.com/ >> > > base/Documentation/) which supports only Python 2.6 >> > > So the real constraint is Splunk supports only Python 2.6 . >> >> > > As you know Python 2.6 doesnt support or doesnt have pyodbc install >> > > for Windows ?64 bit OS >> > > So i installed Python 2.7 and thereafter pyodbc install for Windows 64 >> > > bit OS for Python 2.7 >> >> > Have you actually tried Splunk with Python 2.7? It might not work with >> > versions which are earlier than Python 2.6, but that doesn't >> > necessarily mean that it won't work with versions of Python 2 which are >> > later than Python 2.6 (unless the documentation says that it must be >> > Python 2.6).- Hide quoted text - >> >> > - Show quoted text - >> >> Splunk's latest version 4.1.6 doesn't support Python 2.7 >> I tried the import trick but it didnt work because the real script >> which runs under Python 2.7 has import pyodbc so it results in >> following error >> >> c:\Splunk\etc\apps\search\bin>splunk cmd python namelookupWrapper.py >> memberId memberName < memberInput.csv >> Traceback (most recent call last): >> ? File "namelookupWrapper.py", line 3, in >> ? ? import namelookup >> ? File "c:\Splunk\etc\apps\search\bin\namelookup.py", line 7, in >> >> ? ? import pyodbc >> ImportError: DLL load failed: The specified module could not be found. >> >> Please let me know if i am missing something on import. If so please >> provide me with an example- Hide quoted text - >> >> - Show quoted text - > > Here are some more details from my earlier posting. Please click the > below link > > http://answers.splunk.com/questions/11145/its-getting-mysterious-to-make-the-lookup-script-work > -- > http://mail.python.org/mailman/listinfo/python-list > Have you tried downloading the source for PyODBC and compiling it yourself? All you need to do is python setup.py install. My guess would be that it works just fine on 64-bit Python 2.6, they just never released a re-compiled version of it for that platform. From alan.isaac at gmail.com Fri Jan 28 14:02:49 2011 From: alan.isaac at gmail.com (Alan) Date: Fri, 28 Jan 2011 11:02:49 -0800 (PST) Subject: can't use multiprocessing with class factory? Message-ID: Can the below example be fixed to work? Thanks, Alan Isaac import multiprocessing as mp class Test(object): pass def class_factory(x): class ConcreteTest(Test): _x = x return ConcreteTest def f(cls): print cls._x if __name__ == '__main__': pool = mp.Pool(2) pool.map(f, [class_factory(i) for i in range(4)]) From robert.kern at gmail.com Fri Jan 28 14:23:35 2011 From: robert.kern at gmail.com (Robert Kern) Date: Fri, 28 Jan 2011 13:23:35 -0600 Subject: can't use multiprocessing with class factory? In-Reply-To: References: Message-ID: On 1/28/11 1:02 PM, Alan wrote: > Can the below example be fixed to work? > Thanks, > Alan Isaac > > import multiprocessing as mp > > class Test(object): > pass > > def class_factory(x): > class ConcreteTest(Test): > _x = x > return ConcreteTest > > def f(cls): > print cls._x > > if __name__ == '__main__': > pool = mp.Pool(2) > pool.map(f, [class_factory(i) for i in range(4)]) Send the (pickleable) factory and the arguments used to construct the instance, not the unpickleable instance itself. def g(factory, i): cls = factory(i) print cls._x if __name__ == '__main__': pool = mp.Pool(2) pool.map(g, zip([class_factory] * 4, range(4))) By the way, when asking for help like this, show us what your code did and describe what results you want. It can often be hard to figure out exactly what you mean by "work". -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco From urban.dani at gmail.com Fri Jan 28 14:25:08 2011 From: urban.dani at gmail.com (Daniel Urban) Date: Fri, 28 Jan 2011 20:25:08 +0100 Subject: can't use multiprocessing with class factory? In-Reply-To: References: Message-ID: On Fri, Jan 28, 2011 at 20:02, Alan wrote: > Can the below example be fixed to work? > Thanks, > Alan Isaac > > import multiprocessing as mp > > class Test(object): > ? ?pass > > def class_factory(x): > ? ?class ConcreteTest(Test): > ? ? ? ?_x = x > ? ?return ConcreteTest > > def f(cls): > ? ?print cls._x > > if __name__ == '__main__': > ? ?pool = mp.Pool(2) > ? ?pool.map(f, [class_factory(i) for i in range(4)]) Only classes defined on the top level of a module are picklable (see http://docs.python.org/dev/py3k/library/pickle#what-can-be-pickled-and-unpickled ). The collections.namedtuple class factory function works around this limitation by setting the __module__ attribute of the created class, but I'm not sure if this solution can be used in this case. Daniel From hidura at gmail.com Fri Jan 28 14:34:35 2011 From: hidura at gmail.com (Hidura) Date: Fri, 28 Jan 2011 15:34:35 -0400 Subject: can't use multiprocessing with class factory? In-Reply-To: References: Message-ID: What is the output? 2011/1/28, Alan : > Can the below example be fixed to work? > Thanks, > Alan Isaac > > import multiprocessing as mp > > class Test(object): > pass > > def class_factory(x): > class ConcreteTest(Test): > _x = x > return ConcreteTest > > def f(cls): > print cls._x > > if __name__ == '__main__': > pool = mp.Pool(2) > pool.map(f, [class_factory(i) for i in range(4)]) > > -- > http://mail.python.org/mailman/listinfo/python-list > -- Enviado desde mi dispositivo m?vil Diego I. Hidalgo D. From robert.kern at gmail.com Fri Jan 28 14:42:21 2011 From: robert.kern at gmail.com (Robert Kern) Date: Fri, 28 Jan 2011 13:42:21 -0600 Subject: can't use multiprocessing with class factory? In-Reply-To: References: Message-ID: On 1/28/11 1:25 PM, Daniel Urban wrote: > Only classes defined on the top level of a module are picklable (see > http://docs.python.org/dev/py3k/library/pickle#what-can-be-pickled-and-unpickled > ). The collections.namedtuple class factory function works around this > limitation by setting the __module__ attribute of the created class, > but I'm not sure if this solution can be used in this case. namedtuple's trick only works when you assign the created class to a name at the module level. E.g. MyFancyTuple = collections.namedtuple(...) The trick won't work for "anonymous" classes like the above use case. -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco From subhakolkata1234 at gmail.com Fri Jan 28 15:01:59 2011 From: subhakolkata1234 at gmail.com (joy99) Date: Fri, 28 Jan 2011 12:01:59 -0800 (PST) Subject: Question on Python Freelance Projects in NLP and Machine Learning Message-ID: <2c1cbfb6-9dc6-4ef3-82b4-46e16d246745@a28g2000prb.googlegroups.com> Dear Room, I am a Python programmer from India. I am looking for some freelance Python projects, preferably in Natural Language Processing and Machine Learning. If any one knows of it, please let me know. Best Regards, Subhabrata Banerjee. From rantingrick at gmail.com Fri Jan 28 15:24:55 2011 From: rantingrick at gmail.com (rantingrick) Date: Fri, 28 Jan 2011 12:24:55 -0800 (PST) Subject: Bugs/issues in tkinter.simpledialog!! References: Message-ID: On Jan 28, 8:52?am, Giampaolo Rodol? wrote: > Why don't you file a ticket on the bug tracker instead of wasting > yours and other people's time here by making appear another rant > against Tkinter as a bug report? Why don't you instead thank me for helping out instead of jumping to irate conclusions? It would *seem* that if YOU cared about the future of Python you would be more *accepting* of my help. > [...snip: shameless plugs...] Oh, i see why you dropped by; First to score some points on my behalf and then to plug your own software. Interesting. From alan.isaac at gmail.com Fri Jan 28 15:26:12 2011 From: alan.isaac at gmail.com (Alan) Date: Fri, 28 Jan 2011 12:26:12 -0800 (PST) Subject: can't use multiprocessing with class factory? References: Message-ID: <11c4bb6f-815b-4b64-ace2-2549b7cf8b5b@s28g2000prb.googlegroups.com> On Jan 28, 2:23 pm, Robert Kern wrote: > Send the (pickleable) factory and the arguments used to construct the instance, > not the unpickleable instance itself. > > def g(factory, i): > cls = factory(i) > print cls._x > > if __name__ == '__main__': > pool = mp.Pool(2) > pool.map(g, zip([class_factory] * 4, range(4))) If I change that to g((factory,i)) it does work. Thanks! Alan From rantingrick at gmail.com Fri Jan 28 15:30:20 2011 From: rantingrick at gmail.com (rantingrick) Date: Fri, 28 Jan 2011 12:30:20 -0800 (PST) Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com> <9MB%o.14110$%64.6074@unlimited.newshosting.com> <4A48EDF6D7634F2E994661A457451E87@teddy> <753A4C5A6658470085804B13C80340F2@octavian> Message-ID: <8ccd9099-0f9c-444a-bdfc-1fda779cb02b@i40g2000yqh.googlegroups.com> On Jan 28, 9:52?am, Grant Edwards wrote: > [plonk] Why is it necessarily for you guys to advertise when you plonk. Just plonk and shut up about it. Nobody cares what you do with your own incoming email. Really, are you that self centered as to think we actually care? [zing] From no.email at nospam.invalid Fri Jan 28 15:30:23 2011 From: no.email at nospam.invalid (Paul Rubin) Date: Fri, 28 Jan 2011 12:30:23 -0800 Subject: Use the Source Luke References: <094f6fc5-7242-46c7-b454-4cb29d0c6ef9@q40g2000prh.googlegroups.com> Message-ID: <7xvd18g49s.fsf@ruckus.brouhaha.com> Raymond Hettinger writes: > http://rhettinger.wordpress.com/2011/01/28/open-your-source-more/ > > I'm looking for more examples of projects that routinely > link their docs back into relavant sections of code. > Have any of you all seen other examples besides > the Go language docs and the Python docs? That is a very good post, and just about 2 days ago I happened to be looking at the source of heapq for something I was doing, and I think I got to it through the doc link that you added. So the link has already been useful. Haddock (Haskell's equivalent to Pydoc or Javadoc) can automatically generate source links in Haskell documentation. For example, here's the docs (including source links) for Haskell's standard library for dealing with lists: http://www.haskell.org/ghc/docs/7.0-latest/html/libraries/base-4.3.0.0/Data-List.html I've wanted for a long time for developer-oriented Linux distributions to include full source code of everything as an integral part of the distro rather than as a separate distribution. For example, you could examine any application and instantly see its source. All programs would be compiled with debugging enabled and a way to attach a debugger to the running process, so you could at any time interrupt the program and use gdb to see what it was doing, single step it, etc. From g.rodola at gmail.com Fri Jan 28 15:32:44 2011 From: g.rodola at gmail.com (=?ISO-8859-1?Q?Giampaolo_Rodol=E0?=) Date: Fri, 28 Jan 2011 21:32:44 +0100 Subject: Use the Source Luke In-Reply-To: <094f6fc5-7242-46c7-b454-4cb29d0c6ef9@q40g2000prh.googlegroups.com> References: <094f6fc5-7242-46c7-b454-4cb29d0c6ef9@q40g2000prh.googlegroups.com> Message-ID: 2011/1/28 Raymond Hettinger : > I hoping a new trend will start with dev's putting direct > source code links in their documentation: > > ?http://rhettinger.wordpress.com/2011/01/28/open-your-source-more/ > > I'm looking for more examples of projects that routinely > link their docs back into relavant sections of code. > Have any of you all seen other examples besides > the Go language docs and the Python docs? > > > Raymond > -- > http://mail.python.org/mailman/listinfo/python-list > Thanks, I think this is a great idea. I think this definitively should be done for 2.7 documentation as well. --- Giampaolo http://code.google.com/p/pyftpdlib/ http://code.google.com/p/psutil/ From benjamin.kaplan at case.edu Fri Jan 28 15:34:31 2011 From: benjamin.kaplan at case.edu (Benjamin Kaplan) Date: Fri, 28 Jan 2011 15:34:31 -0500 Subject: Bugs/issues in tkinter.simpledialog!! In-Reply-To: References: Message-ID: On Fri, Jan 28, 2011 at 3:24 PM, rantingrick wrote: > On Jan 28, 8:52?am, Giampaolo Rodol? wrote: > >> Why don't you file a ticket on the bug tracker instead of wasting >> yours and other people's time here by making appear another rant >> against Tkinter as a bug report? > > Why don't you instead thank me for helping out instead of jumping to > irate conclusions? It would *seem* that if YOU cared about the future > of Python you would be more *accepting* of my help. > It's not that people don't appreciate your help. It's that the mailing list is not the appropriate place for this type of discussion. Once it's been verified as a bug, you should create a ticket on the bug tracker, come back here and post a link, and then move the discussion over to the tracker. Even if you intend to fix it yourself, you should create a ticket and then attach the patch to the ticket when you fix it. From malaclypse2 at gmail.com Fri Jan 28 15:34:46 2011 From: malaclypse2 at gmail.com (Jerry Hill) Date: Fri, 28 Jan 2011 15:34:46 -0500 Subject: Bugs/issues in tkinter.simpledialog!! In-Reply-To: References: Message-ID: On Fri, Jan 28, 2011 at 3:24 PM, rantingrick wrote: > Why don't you instead thank me for helping out instead of jumping to > irate conclusions? It would *seem* that if YOU cared about the future > of Python you would be more *accepting* of my help. > But you have not, in fact, helped out. You've complained to a mailing list of python users that you've found some bugs. If you want to help out, you need to file issues on the bug tracker for bugs that you've found. If you want to be extra helpful, you'll also attach patches to those bug reports. It really isn't difficult, but you don't seem to be willing to do it. Until you do, all you're doing is ranting, not helping. -- Jerry -------------- next part -------------- An HTML attachment was scrubbed... URL: From rantingrick at gmail.com Fri Jan 28 15:35:18 2011 From: rantingrick at gmail.com (rantingrick) Date: Fri, 28 Jan 2011 12:35:18 -0800 (PST) Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com> <9MB%o.14110$%64.6074@unlimited.newshosting.com> <4A48EDF6D7634F2E994661A457451E87@teddy> <753A4C5A6658470085804B13C80340F2@octavian> <90450b74-2d66-4a78-8a9f-0c3807607848@o14g2000prb.googlegroups.com> <18c47$4d42eba6$4275d90a$21758@FUSE.NET> Message-ID: <6ee346d2-012b-45f7-8fc3-94b649048d18@n36g2000pre.googlegroups.com> On Jan 28, 10:16?am, Kevin Walzer wrote: > On 1/28/11 9:18 AM, rantingrick wrote: > > > Everyone on this list knows that Kevin and myself are the *only* > > people who know how to wield Tkinter past some simple utility GUI's. > > I strongly disagree with this statement. Whether you agree or disagree is irrelevant. The fact remains. And if there are others, why do we never hear from them? Why do they never help noobs when Tkinter questions come up? I guess they are the "silent majority" right? Man look at the state of Tkinter. Look at the bugs and mediocre code i exposed. Are you going to set there with a strait face and tell me many people are using Tkinter. Come on Kevin, be realistic! From tjreedy at udel.edu Fri Jan 28 15:37:25 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Fri, 28 Jan 2011 15:37:25 -0500 Subject: WxPython versus Tkinter. In-Reply-To: <8775C617C7B241759AC122A69955D42A@octavian> References: <4D3E4377.3060807@tysdomain.com> <9MB%o.14110$%64.6074@unlimited.newshosting.com> <59F6E65E3D9A46AD8D7A3863F3C1DC84@teddy> <27f53f8c-7862-4366-9352-82ae9a2f3970@k3g2000yqc.googlegroups.com> <718D13777F254C839F9564BC4275DE0A@octavian> <4D402C42.1030407@tysdomain.com> <4D40447C.4010108@tysdomain.com> <33C68A0874BE4C66AB478EDFB64C2C1D@teddy> <4D407321.3090705@web.de> <1296128007.17192.1417506961@webmail.messagingengine.com> <8775C617C7B241759AC122A69955D42A@octavian> Message-ID: On 1/28/2011 3:33 AM, Octavian Rasnita wrote: > From: "Terry Reedy" >> For example: pygui pretty much uses native widgets on Windows and OX and >> gtk (I believe) on *nix. How is the accessibility of those widget sets >> *as >> accessed through pygui*? Is it different from the 'native' accessibility >> of each of those set? > > > Thank you for telling about this GUI lib! > I have tested the sample apps it offers and the standard dialogs are very > accessible. I hope it is the same in case of the other common controls like > list boxes, list views, check boxes, radio buttons, combo boxes, tree > views... Which OS? The result might be different on each of Windows, OSX, and *nis as different widgets are used on each. > How complete is this GUI lib compared with others that can be used in > Python > apps? > I am asking this, because I read: > > "Get the library and its documentation included in the core Python > distribution, so that truly cross-platform GUI applications may be written > that will run on any Python installation, anywhere." I don't know if Grey still has that goal. It is 2.x only. -- Terry Jan Reedy From mail2bansi at gmail.com Fri Jan 28 15:42:34 2011 From: mail2bansi at gmail.com (bansi) Date: Fri, 28 Jan 2011 12:42:34 -0800 (PST) Subject: Is it possible to pass CSV Reader Object As Argument to another Python File ??? References: <2c35653e-3565-48c6-8939-b6b09b885e3f@d23g2000prj.googlegroups.com> <876b6c52-1a6d-4afa-83e9-fa987c9359a5@v31g2000pri.googlegroups.com> <87lj272vpo.fsf@benfinney.id.au> <430714cd-20b4-4a67-bd2d-54e8f0c44ad5@s18g2000vbe.googlegroups.com> <2c9f82cd-756b-4460-940b-31e2a866f24e@n36g2000pre.googlegroups.com> Message-ID: <933ce06c-7829-42b9-a96d-dc9582e8267b@u11g2000prk.googlegroups.com> On Jan 28, 1:52?pm, Benjamin Kaplan wrote: > On Fri, Jan 28, 2011 at 1:33 PM, bansi wrote: > > On Jan 28, 9:46?am, bansi wrote: > >> On Jan 26, 8:31?pm, MRAB wrote: > > >> > On 27/01/2011 00:57, bansi wrote: > > >> > > On Jan 26, 6:25 pm, Ethan Furman ?wrote: > >> > >> bansi wrote: > > >> > >> ? > ?First namelookupWrapper.py running under Python 2.6 accept arguments > >> > >> ? > ?from stdin and uses csv reader object to read it i.e. > >> > >> ? > ?r=csv.reader(sys.stdin) > > >> > >> ? > ?And then it has to pass csv reader object to another python script > >> > >> ? > ?namelookup.py running under Python 2.7 because it uses pyodbc to > >> > >> ? > ?connect to database and iterates thru reader object > > >> > >> Ben Finney wrote: > >> > >>> bansi ?writes: > > >> > >>>> Thanks Chris. Sorry for mis-communicating, the two python scripts are > >> > >>>> dependant in a way that namelookupWrapper.py needs to pass csv record > >> > >>>> object to another python script > > >> > >>> Why have you structured them that way, though? What constraint is > >> > >>> keeping you from doing the work in a single process, where the CSV > >> > >>> reader object can be shared? > > >> > >>>> If thats not possible then please let me know how to do the workaround > >> > >>>> i didnt understood the import thing and not sure if it helps in my > >> > >>>> case > > >> > >>> The problem as you've described it so far is best solved by having a > >> > >>> single process accessing the CSV reader object in memory. If that > >> > >>> doesn't suit your use case, you'll need to explain why not. > > >> > >> In other words, why can't you use Python 2.7 to accept input and > >> > >> generate a csv.reader? > > >> > >> ~Ethan~- Hide quoted text - > > >> > >> - Show quoted text - > > >> > > Ethan, > >> > > The python script takes the input from Splunk (http://www.splunk.com/ > >> > > base/Documentation/) which supports only Python 2.6 > >> > > So the real constraint is Splunk supports only Python 2.6 . > > >> > > As you know Python 2.6 doesnt support or doesnt have pyodbc install > >> > > for Windows ?64 bit OS > >> > > So i installed Python 2.7 and thereafter pyodbc install for Windows 64 > >> > > bit OS for Python 2.7 > > >> > Have you actually tried Splunk with Python 2.7? It might not work with > >> > versions which are earlier than Python 2.6, but that doesn't > >> > necessarily mean that it won't work with versions of Python 2 which are > >> > later than Python 2.6 (unless the documentation says that it must be > >> > Python 2.6).- Hide quoted text - > > >> > - Show quoted text - > > >> Splunk's latest version 4.1.6 doesn't support Python 2.7 > >> I tried the import trick but it didnt work because the real script > >> which runs under Python 2.7 has import pyodbc so it results in > >> following error > > >> c:\Splunk\etc\apps\search\bin>splunk cmd python namelookupWrapper.py > >> memberId memberName < memberInput.csv > >> Traceback (most recent call last): > >> ? File "namelookupWrapper.py", line 3, in > >> ? ? import namelookup > >> ? File "c:\Splunk\etc\apps\search\bin\namelookup.py", line 7, in > >> > >> ? ? import pyodbc > >> ImportError: DLL load failed: The specified module could not be found. > > >> Please let me know if i am missing something on import. If so please > >> provide me with an example- Hide quoted text - > > >> - Show quoted text - > > > Here are some more details from my earlier posting. Please click the > > below link > > >http://answers.splunk.com/questions/11145/its-getting-mysterious-to-m... > > -- > >http://mail.python.org/mailman/listinfo/python-list > > Have you tried downloading the source for PyODBC and compiling it > yourself? All you need to do is python setup.py install. My guess > would be that it works just fine on 64-bit Python 2.6, they just never > released a re-compiled version of it for that platform.- Hide quoted text - > > - Show quoted text - Thanks Benjamin. Please point me to the website from where i can download pyodbc for Windows 64 bit OS under Python 2.6 and installation instructions From rui.maciel at gmail.com Fri Jan 28 15:49:22 2011 From: rui.maciel at gmail.com (Rui Maciel) Date: Fri, 28 Jan 2011 20:49:22 +0000 Subject: Use the Source Luke References: <094f6fc5-7242-46c7-b454-4cb29d0c6ef9@q40g2000prh.googlegroups.com> Message-ID: <4d432bd0$0$19531$a729d347@news.telepac.pt> Raymond Hettinger wrote: > Have any of you all seen other examples besides > the Go language docs and the Python docs? Wasn't doxygen developed with that in mind? Rui Maciel From rantingrick at gmail.com Fri Jan 28 15:58:50 2011 From: rantingrick at gmail.com (rantingrick) Date: Fri, 28 Jan 2011 12:58:50 -0800 (PST) Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com> <59F6E65E3D9A46AD8D7A3863F3C1DC84@teddy> <27f53f8c-7862-4366-9352-82ae9a2f3970@k3g2000yqc.googlegroups.com> <718D13777F254C839F9564BC4275DE0A@octavian> <4D402C42.1030407@tysdomain.com> <4D40447C.4010108@tysdomain.com> <33C68A0874BE4C66AB478EDFB64C2C1D@teddy> <4D407321.3090705@web.de> <1296128007.17192.1417506961@webmail.messagingengine.com> <8775C617C7B241759AC122A69955D42A@octavian> Message-ID: <349dc47a-5a16-47e9-8dea-0de3aa814b52@d1g2000yqb.googlegroups.com> On Jan 28, 2:37?pm, Terry Reedy wrote: > On 1/28/2011 3:33 AM, Octavian Rasnita wrote: > > "Get the library and its documentation included in the core Python > > distribution, so that truly cross-platform GUI applications may be written > > that will run on any Python installation, anywhere." > > I don't know if Grey still has that goal. ?It is 2.x only. True, but *if* the community saw the potential that i see with pyGUI and wanted to seriously do some development to bring it into 3.0 compliance i'll bet Greg *would* be interested! pyGUI has lots of potential. To be honest, i would sacrifice all the functionality of wxWidgets if we could get pyGUI into the stdlib. Why? Well because pyGUI would be under OUR complete control. No more kissing TclTk butt, no more kissing WxWidgets+Robin Dunn butt. WE decide how fast to move and NOBODY will get in our way anymore! From tyler at tysdomain.com Fri Jan 28 16:09:27 2011 From: tyler at tysdomain.com (Littlefield, Tyler) Date: Fri, 28 Jan 2011 14:09:27 -0700 Subject: WxPython versus Tkinter. In-Reply-To: <6ee346d2-012b-45f7-8fc3-94b649048d18@n36g2000pre.googlegroups.com> References: <4D3E4377.3060807@tysdomain.com> <9MB%o.14110$%64.6074@unlimited.newshosting.com> <4A48EDF6D7634F2E994661A457451E87@teddy> <753A4C5A6658470085804B13C80340F2@octavian> <90450b74-2d66-4a78-8a9f-0c3807607848@o14g2000prb.googlegroups.com> <18c47$4d42eba6$4275d90a$21758@FUSE.NET> <6ee346d2-012b-45f7-8fc3-94b649048d18@n36g2000pre.googlegroups.com> Message-ID: <4D433087.70803@tysdomain.com> >Man look at the state of Tkinter. Look at the bugs and mediocre code i >exposed. Are you going to set there with a strait face and tell me >many people are using Tkinter. Come on Kevin, be realistic! You also uncovered bugs in WX (remember those segfaults, RR)? On 1/28/2011 1:35 PM, rantingrick wrote: > On Jan 28, 10:16 am, Kevin Walzer wrote: >> On 1/28/11 9:18 AM, rantingrick wrote: >> >>> Everyone on this list knows that Kevin and myself are the *only* >>> people who know how to wield Tkinter past some simple utility GUI's. >> I strongly disagree with this statement. > Whether you agree or disagree is irrelevant. The fact remains. And if > there are others, why do we never hear from them? Why do they never > help noobs when Tkinter questions come up? I guess they are the > "silent majority" right? > > Man look at the state of Tkinter. Look at the bugs and mediocre code i > exposed. Are you going to set there with a strait face and tell me > many people are using Tkinter. Come on Kevin, be realistic! -- Thanks, Ty From me+list/python at ixokai.io Fri Jan 28 16:09:39 2011 From: me+list/python at ixokai.io (Stephen Hansen) Date: Fri, 28 Jan 2011 13:09:39 -0800 Subject: WxPython versus Tkinter. In-Reply-To: <6ee346d2-012b-45f7-8fc3-94b649048d18@n36g2000pre.googlegroups.com> References: <4D3E4377.3060807@tysdomain.com> <9MB%o.14110$%64.6074@unlimited.newshosting.com> <4A48EDF6D7634F2E994661A457451E87@teddy> <753A4C5A6658470085804B13C80340F2@octavian> <90450b74-2d66-4a78-8a9f-0c3807607848@o14g2000prb.googlegroups.com> <18c47$4d42eba6$4275d90a$21758@FUSE.NET> <6ee346d2-012b-45f7-8fc3-94b649048d18@n36g2000pre.googlegroups.com> Message-ID: <4D433093.6040604@ixokai.io> On 1/28/11 12:35 PM, rantingrick wrote: > The fact remains. The word "fact" does not mean what you think it means. -- Stephen Hansen ... Also: Ixokai ... Mail: me+list/python (AT) ixokai (DOT) io ... Blog: http://meh.ixokai.io/ -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 487 bytes Desc: OpenPGP digital signature URL: From benjamin.kaplan at case.edu Fri Jan 28 16:22:49 2011 From: benjamin.kaplan at case.edu (Benjamin Kaplan) Date: Fri, 28 Jan 2011 16:22:49 -0500 Subject: Is it possible to pass CSV Reader Object As Argument to another Python File ??? In-Reply-To: <933ce06c-7829-42b9-a96d-dc9582e8267b@u11g2000prk.googlegroups.com> References: <2c35653e-3565-48c6-8939-b6b09b885e3f@d23g2000prj.googlegroups.com> <876b6c52-1a6d-4afa-83e9-fa987c9359a5@v31g2000pri.googlegroups.com> <87lj272vpo.fsf@benfinney.id.au> <430714cd-20b4-4a67-bd2d-54e8f0c44ad5@s18g2000vbe.googlegroups.com> <2c9f82cd-756b-4460-940b-31e2a866f24e@n36g2000pre.googlegroups.com> <933ce06c-7829-42b9-a96d-dc9582e8267b@u11g2000prk.googlegroups.com> Message-ID: On Fri, Jan 28, 2011 at 3:42 PM, bansi wrote: > On Jan 28, 1:52?pm, Benjamin Kaplan wrote: >> On Fri, Jan 28, 2011 at 1:33 PM, bansi wrote: >> > On Jan 28, 9:46?am, bansi wrote: >> >> On Jan 26, 8:31?pm, MRAB wrote: >> >> >> > On 27/01/2011 00:57, bansi wrote: >> >> >> > > On Jan 26, 6:25 pm, Ethan Furman ?wrote: >> >> > >> bansi wrote: >> >> >> > >> ? > ?First namelookupWrapper.py running under Python 2.6 accept arguments >> >> > >> ? > ?from stdin and uses csv reader object to read it i.e. >> >> > >> ? > ?r=csv.reader(sys.stdin) >> >> >> > >> ? > ?And then it has to pass csv reader object to another python script >> >> > >> ? > ?namelookup.py running under Python 2.7 because it uses pyodbc to >> >> > >> ? > ?connect to database and iterates thru reader object >> >> >> > >> Ben Finney wrote: >> >> > >>> bansi ?writes: >> >> >> > >>>> Thanks Chris. Sorry for mis-communicating, the two python scripts are >> >> > >>>> dependant in a way that namelookupWrapper.py needs to pass csv record >> >> > >>>> object to another python script >> >> >> > >>> Why have you structured them that way, though? What constraint is >> >> > >>> keeping you from doing the work in a single process, where the CSV >> >> > >>> reader object can be shared? >> >> >> > >>>> If thats not possible then please let me know how to do the workaround >> >> > >>>> i didnt understood the import thing and not sure if it helps in my >> >> > >>>> case >> >> >> > >>> The problem as you've described it so far is best solved by having a >> >> > >>> single process accessing the CSV reader object in memory. If that >> >> > >>> doesn't suit your use case, you'll need to explain why not. >> >> >> > >> In other words, why can't you use Python 2.7 to accept input and >> >> > >> generate a csv.reader? >> >> >> > >> ~Ethan~- Hide quoted text - >> >> >> > >> - Show quoted text - >> >> >> > > Ethan, >> >> > > The python script takes the input from Splunk (http://www.splunk.com/ >> >> > > base/Documentation/) which supports only Python 2.6 >> >> > > So the real constraint is Splunk supports only Python 2.6 . >> >> >> > > As you know Python 2.6 doesnt support or doesnt have pyodbc install >> >> > > for Windows ?64 bit OS >> >> > > So i installed Python 2.7 and thereafter pyodbc install for Windows 64 >> >> > > bit OS for Python 2.7 >> >> >> > Have you actually tried Splunk with Python 2.7? It might not work with >> >> > versions which are earlier than Python 2.6, but that doesn't >> >> > necessarily mean that it won't work with versions of Python 2 which are >> >> > later than Python 2.6 (unless the documentation says that it must be >> >> > Python 2.6).- Hide quoted text - >> >> >> > - Show quoted text - >> >> >> Splunk's latest version 4.1.6 doesn't support Python 2.7 >> >> I tried the import trick but it didnt work because the real script >> >> which runs under Python 2.7 has import pyodbc so it results in >> >> following error >> >> >> c:\Splunk\etc\apps\search\bin>splunk cmd python namelookupWrapper.py >> >> memberId memberName < memberInput.csv >> >> Traceback (most recent call last): >> >> ? File "namelookupWrapper.py", line 3, in >> >> ? ? import namelookup >> >> ? File "c:\Splunk\etc\apps\search\bin\namelookup.py", line 7, in >> >> >> >> ? ? import pyodbc >> >> ImportError: DLL load failed: The specified module could not be found. >> >> >> Please let me know if i am missing something on import. If so please >> >> provide me with an example- Hide quoted text - >> >> >> - Show quoted text - >> >> > Here are some more details from my earlier posting. Please click the >> > below link >> >> >http://answers.splunk.com/questions/11145/its-getting-mysterious-to-m... >> > -- >> >http://mail.python.org/mailman/listinfo/python-list >> >> Have you tried downloading the source for PyODBC and compiling it >> yourself? All you need to do is python setup.py install. My guess >> would be that it works just fine on 64-bit Python 2.6, they just never >> released a re-compiled version of it for that platform.- Hide quoted text - >> >> - Show quoted text - > > Thanks Benjamin. Please point me to the website from where i can > download pyodbc for Windows 64 bit OS under Python 2.6 and > installation instructions > -- You don't download it for 64-bit Windows with Python 2.6. You download the source code from the website and make the Python 2.6, 64-bit Windows version yourself. Download the source zip file and extract it. Then, open up the command prompt and use the "cd" command to change directories to that source folder. For instance, if the source code has been extracted to C:\pyodbc-2.1.8\, you type in "cd C:\pyodbc-2.1.8" and press enter. After that, you just run the build script which is already in there: C:\Python26\python26.exe setup.py install You'll need to have Visual C++ 2008 (not 2010) installed for this to work. You can get it for free from http://www.microsoft.com/express/Downloads/ if you don't already have it. > http://mail.python.org/mailman/listinfo/python-list > From rantingrick at gmail.com Fri Jan 28 16:26:11 2011 From: rantingrick at gmail.com (rantingrick) Date: Fri, 28 Jan 2011 13:26:11 -0800 (PST) Subject: Bugs/issues in tkinter.simpledialog!! References: Message-ID: On Jan 28, 2:34?pm, Benjamin Kaplan wrote: > It's not that people don't appreciate your help. First: Thanks for the reasonable response. > It's that the mailing > list is not the appropriate place for this type of discussion. Actually i see you point but there is a good reason behind me bringing this up here. I want to bring to the attention of everyone how little interest there is for Tkinter. Not many folks are using Tkinter, most hate Tkinter, and not many (if any) are capable of patching the Tkinter source code. It has been mentioned in this thread that the last person to do any real work on Tkinter is someone from two years ago. This is insanity! You know why i think nobody cares.. * Too much trouble to get patches submitted. * Nobody really cares at py-dev so the patches never get resolved. * There is resistance in the community to "outsiders". This mentality is setting us up for a bad bad future. Why are people so pedantic and emotional. Python does not belong to me, or you, or anybody. This is a team effort. And whist we need people doing work we also need to listen to the community. I have had nothing but an uphill battle dealing with a few "elites" on this list. Anybody can see that i am serious about helping out. Heck, i want Tkinter to be removed from the stdlib but yet i still offer help to noobies and still report bugs. > Once > it's been verified as a bug, you should create a ticket on the bug > tracker, come back here and post a link, and then move the discussion > over to the tracker. Agreed. However i would rather just write a patch, send it to some email and be done. Or just commit the changes myself. This bug tracker is just bureaucracy at it's worst. You are making this process too hard and people are not going to get involved when they have to jump through 20 hoops just to patch three lines of freaking code! There is too much red tape here. I COULD HAVE PATCHED HUNDREDS OF LINE OF CODE IN THE TIME I HAVE WASTED WITH THE BUG TRACKER PROCESS ALONE! I understand we need checks and balances but at some point the very safety net we rely on becomes a noose around our neck! Something needs to be done! From cmpython at gmail.com Fri Jan 28 16:47:42 2011 From: cmpython at gmail.com (CM) Date: Fri, 28 Jan 2011 13:47:42 -0800 (PST) Subject: A and B but not C in list References: <8cae2caf-d3df-4ed3-9afb-29de97772298@m13g2000yqb.googlegroups.com> Message-ID: <2add851e-4f5d-4cde-82e7-a96d43a3dc13@o1g2000yqb.googlegroups.com> Thanks, everyone, for your suggestions. -Che From tismer at stackless.com Fri Jan 28 16:53:29 2011 From: tismer at stackless.com (Christian Tismer) Date: Fri, 28 Jan 2011 22:53:29 +0100 Subject: WxPython versus Tkinter. In-Reply-To: <4d3e0563$0$29983$c3e8da3$5496439d@news.astraweb.com> References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> <3a96fee1-995f-49f7-a967-f125cc3f1cdc@v26g2000yqf.googlegroups.com> <4d3e0563$0$29983$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4D433AD9.7030400@stackless.com> On 1/25/11 12:04 AM, Steven D'Aprano wrote: > On Mon, 24 Jan 2011 12:24:24 -0800, Robin Dunn wrote: > >> On Jan 24, 12:03 pm, rantingrick wrote: >>> On Jan 24, 1:57 pm, Robin Dunn wrote: >>>> BTW, on behalf of the wxPython community I'd like to apologize for >>>> the havoc caused by the flaming troll escaping from his cage. In >>>> general wxPython users are much less militant and zealotty and honor >>>> everyone's freedom to choose which ever UI tool kit works the best >>>> for their own needs. >>> Well we forgive Byran, but we will not forget! :) >> For the record, that is not who I was referring to. > I don't believe that anyone in their right mind could have imagined even > for a second that you were referring to Bryan. As we all experienced milleniums before: Self-criticism is the weakest, maybe totally missing virtue of a bozo. Which is great, because he won't recognize the irony ;-) -- Christian Tismer :^) tismerysoft GmbH : Have a break! Take a ride on Python's Johannes-Niemeyer-Weg 9A : *Starship* http://starship.python.net/ 14109 Berlin : PGP key -> http://wwwkeys.pgp.net/ work +49 30 802 86 56 mobile +49 173 24 18 776 fax +49 30 80 90 57 05 PGP 0x57F3BF04 9064 F4E1 D754 C2FF 1619 305B C09C 5A3B 57F3 BF04 whom do you want to sponsor today? http://www.stackless.com/ From rantingrick at gmail.com Fri Jan 28 16:56:18 2011 From: rantingrick at gmail.com (rantingrick) Date: Fri, 28 Jan 2011 13:56:18 -0800 (PST) Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com> <4A48EDF6D7634F2E994661A457451E87@teddy> <753A4C5A6658470085804B13C80340F2@octavian> <90450b74-2d66-4a78-8a9f-0c3807607848@o14g2000prb.googlegroups.com> <18c47$4d42eba6$4275d90a$21758@FUSE.NET> <6ee346d2-012b-45f7-8fc3-94b649048d18@n36g2000pre.googlegroups.com> Message-ID: <3ac99c65-96cc-46f6-9533-c57de9bb4155@a5g2000vbs.googlegroups.com> Rick: > Man look at the state of Tkinter. Look at the bugs and mediocre code i > exposed. Are you going to set there with a strait face and tell me > many people are using Tkinter. Come on Kevin, be realistic! Tyler: > You also uncovered bugs in WX (remember those segfaults, RR)? Yes i do, and i also remember Robin pointing out that those who were experiencing segfaults were experiencing them because they did not run wxPython correctly.But lets just ignore facts for a moment, you do this all the time. But just to make a point i will entertain you. Let's imagine that the segfaults are in fact only a wxPython problem. Now imagine you are buying a car and you have two choices. You can choose an old Yugo with 300,000 miles and a bad paint job or you can choose a fancy sports car fresh off the assembly line that contains the most modern technology. Both the new sports car and the old and dumpy Yugo have brand new tires. You're argument about segfauts would be akin to making the decision solely based on the tires. Completely moronic. From ben+python at benfinney.id.au Fri Jan 28 18:10:31 2011 From: ben+python at benfinney.id.au (Ben Finney) Date: Sat, 29 Jan 2011 10:10:31 +1100 Subject: Use the Source Luke References: <094f6fc5-7242-46c7-b454-4cb29d0c6ef9@q40g2000prh.googlegroups.com> Message-ID: <87tygs1v6g.fsf@benfinney.id.au> Raymond Hettinger writes: > I hoping a new trend will start with dev's putting direct > source code links in their documentation: > > http://rhettinger.wordpress.com/2011/01/28/open-your-source-more/ That's a good article overall. I have a quibble with the framing: > The rest of the blame lies with installers. They all treat > human-readable scripts like they were binaries and tuck the code away > in a dark corner. That?s hardly a ?blame? of installers. The modules are placed in such locations because they need to be accessible in a hierarchy at a location that is known to not conflict with anything else, and be predictable for the Python interpreter on the system. If you want to blame anything for this (though I think it?s inaccurate to frame it as a problem), the correct target of your accusation is the fact that a filesystem path is the identifier for these modules that will be used by programs to find them. As for reading the source and making it more available to programmers, yes, I agree wholeheartedly. Encouraging the routine reading of other projects?s source code is a good thing, and thank you for beating the drum. -- \ ?I distrust those people who know so well what God wants them | `\ to do to their fellows, because it always coincides with their | _o__) own desires.? ?Susan Brownell Anthony, 1896 | Ben Finney From python at bdurham.com Fri Jan 28 18:29:41 2011 From: python at bdurham.com (python at bdurham.com) Date: Fri, 28 Jan 2011 18:29:41 -0500 Subject: Determining calculation order for group of related calculations Message-ID: <1296257381.25947.1417811829@webmail.messagingengine.com> Wondering if there's a Python library or algorithm for determining the order in which a group of calculations should be performed when some calculations reference the result of other equations. I don't need anything as fancy as a spreadsheet engine, however I do need to detect recursive equations and treat these situations as errors. In terms of an example: What I would like to do is order the following equations such that all the dependent variables are calculated before they are referenced by later calculations. a + b + c = d a + b + d = e a + e = f d + e + f = g a + e = h Thank you, Malcolm -------------- next part -------------- An HTML attachment was scrubbed... URL: From ian.g.kelly at gmail.com Fri Jan 28 18:38:49 2011 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Fri, 28 Jan 2011 16:38:49 -0700 Subject: Determining calculation order for group of related calculations In-Reply-To: <1296257381.25947.1417811829@webmail.messagingengine.com> References: <1296257381.25947.1417811829@webmail.messagingengine.com> Message-ID: On Fri, Jan 28, 2011 at 4:29 PM, wrote: > Wondering if there's a Python library or algorithm for determining the order > in which a group of calculations should be performed when some calculations > reference the result of other equations. I don't need anything as fancy as a > spreadsheet engine, however I do need to detect recursive equations and > treat these situations as errors. A google search for "python topological sort" returns lots of results. From jackdied at gmail.com Fri Jan 28 19:02:25 2011 From: jackdied at gmail.com (Jack Diederich) Date: Fri, 28 Jan 2011 19:02:25 -0500 Subject: Use the Source Luke In-Reply-To: <094f6fc5-7242-46c7-b454-4cb29d0c6ef9@q40g2000prh.googlegroups.com> References: <094f6fc5-7242-46c7-b454-4cb29d0c6ef9@q40g2000prh.googlegroups.com> Message-ID: On Fri, Jan 28, 2011 at 1:32 PM, Raymond Hettinger wrote: > I hoping a new trend will start with dev's putting direct > source code links in their documentation: > > ?http://rhettinger.wordpress.com/2011/01/28/open-your-source-more/ > > I'm looking for more examples of projects that routinely > link their docs back into relavant sections of code. > Have any of you all seen other examples besides > the Go language docs and the Python docs? I think you overestimate how common it used to be to carry around the sourcecode for the software you use compared to now; In the past it wasn't even always possible - if the Sun cc compiler core dumps you have no recourse to code. Promoting the idea of doing it is good because it /is/ a novel idea to many people. Promoting the idea of making it extremely easy via documentation links is good because it is new as well. Modern tools are making this easier than it used to be so your call for making it easier still is well timed. Github/bitbucket/launchpad have combined the source with documentation; github especially because the README on github is the canonical documentation and the source is only one mouse click away. ack-grep has changed my life. Sure, I could always do the same thing in the past with find+grep but ack-grep makes it so easy (switches for language file types!) that I use it much more; I have "ag" aliased to "ack-grep --python" and I use it all the f'ing time because it costs me near zero to do so. Likewise I have an alias "cdp" that "cd"s me into the directory where any given python module lives. "cdp collections" puts me straight into "/usr/local/lib/python2.6" - again, it makes it so easy to look at sourcecode that I do it all the time. It is usually quicker to do cdp/python/import module_name/help(module_name) than to look up the docs. Worst case the docstrings suck and I just read the code. * Anecdote. I was in a room with Tim Peters and has some questions about the interface to code he wrote so I thought "Hey, I'll just ask Tim!" I asked him and he replied "I'm not sure what you're asking - do you want me to read the code aloud to you?" So I just went and read it. -Jack From python at bdurham.com Fri Jan 28 19:32:48 2011 From: python at bdurham.com (python at bdurham.com) Date: Fri, 28 Jan 2011 19:32:48 -0500 Subject: Determining calculation order for group of related calculations In-Reply-To: References: <1296257381.25947.1417811829@webmail.messagingengine.com> Message-ID: <1296261168.6565.1417819919@webmail.messagingengine.com> Ian, > A google search for "python topological sort" returns lots of results. Perfect!! That's exactly what I was looking for but couldn't manage to put a name to. Cheers, Malcolm From ben+python at benfinney.id.au Fri Jan 28 20:19:37 2011 From: ben+python at benfinney.id.au (Ben Finney) Date: Sat, 29 Jan 2011 12:19:37 +1100 Subject: Use the Source Luke References: <094f6fc5-7242-46c7-b454-4cb29d0c6ef9@q40g2000prh.googlegroups.com> Message-ID: <87lj241p7a.fsf@benfinney.id.au> Jack Diederich writes: > I think you overestimate how common it used to be to carry around the > sourcecode for the software you use compared to now; In the past it > wasn't even always possible - if the Sun cc compiler core dumps you > have no recourse to code. Note that Raymond is speaking specifically in the context of free software, where the license is by definition permitting free redistribution of the source code. So it doesn't cover the case of things like the Sun C compiler, either now or in the past. > Promoting the idea of doing it is good because it /is/ a novel idea to > many people. Promoting the idea of making it extremely easy via > documentation links is good because it is new as well. When one notes that the context is specifically free software projects, the promotion of reading the source code is even more a good idea. -- \ ?This [Bush] Administration is not sinking. This Administration | `\ is soaring. If anything they are rearranging the deck chairs on | _o__) the Hindenburg.? ?Steven Colbert, 2006-04-29 | Ben Finney From python at rcn.com Fri Jan 28 20:52:12 2011 From: python at rcn.com (Raymond Hettinger) Date: Fri, 28 Jan 2011 17:52:12 -0800 (PST) Subject: Use the Source Luke References: <094f6fc5-7242-46c7-b454-4cb29d0c6ef9@q40g2000prh.googlegroups.com> Message-ID: <9e25c9bf-4d8b-4484-b8fc-2bfaf6b5820c@n36g2000pre.googlegroups.com> [Jack Diedrich] > I think you overestimate how common it used to be to carry around the > sourcecode for the software you use compared to now; ?In the past it > wasn't even always possible - if the Sun cc compiler core dumps you > have no recourse to code. You're right of course. For the Python world though, there does seem to have been a change. A decade ago in this newsgroup, there were frequent references to standard library source. I don't see that much anymore. >?Promoting the idea of doing it is good > because it /is/ a novel idea to many people. ?Promoting the idea of > making it extremely easy via documentation links is good because it is > new as well. Judging from the comments so far, it looks like everyone here agrees. > Modern tools are making this easier than it used to be so your call > for making it easier still is well timed. ?Github/bitbucket/launchpad > have combined the source with documentation; Do they typically feature multiple links from documentation specifics to corresponding code specifics? Part of my thesis is that it is not enough to make docs and source available, they need to be linked in a way that helps people answer specific problems without having to invest a week in learning the gestalt of a foreign code base. >?Worst case the docstrings suck and I just read the code. That's a good habit to have. I find that my willingness to do it varies across projects -- I'm happy to look at the Mercurial source but could never being myself to look at the innards of Git or CouchDB. > * Anecdote. ?I was in a room with Tim Peters and has some questions > about the interface to code he wrote so I thought "Hey, I'll just ask > Tim!" ?I asked him and he replied "I'm not sure what you're asking - > do you want me to read the code aloud to you?" ?So I just went and > read it. Thanks for the anecdote. I love that story :-) Uncle Timmy's style is both clever and pointed. Raymond From data.2 at rediff.com Fri Jan 28 21:49:52 2011 From: data.2 at rediff.com (gaurav) Date: Fri, 28 Jan 2011 18:49:52 -0800 (PST) Subject: Employments Chance in Management work. Message-ID: <5208ea30-6106-4b0f-b81d-266acd379567@r19g2000prm.googlegroups.com> The Greatest site to Start your own Work from Home earn start earning. http://rojgars1.webs.com/gov.htm http://rojgars.webs.com/bankingjobs.htm Great earning in Management careers. Sales and Management work. http://managementjobs.webs.com/pm.htm & http://topcareer.webs.com/humanresourcemgmt.htm From rustompmody at gmail.com Sat Jan 29 00:34:09 2011 From: rustompmody at gmail.com (rusi) Date: Fri, 28 Jan 2011 21:34:09 -0800 (PST) Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com> <9MB%o.14110$%64.6074@unlimited.newshosting.com> <4A48EDF6D7634F2E994661A457451E87@teddy> <753A4C5A6658470085804B13C80340F2@octavian> Message-ID: On Jan 27, 10:47?pm, Grant Edwards wrote: > So you're saying that you don't see any value in easing communication, > nor presumably in communication itself? A Goedel-ian meta-recursion problem here Grant: You want to communicate the need for communication to one who does not see the need/value of communication From rustompmody at gmail.com Sat Jan 29 02:50:39 2011 From: rustompmody at gmail.com (rusi) Date: Fri, 28 Jan 2011 23:50:39 -0800 (PST) Subject: Use the Source Luke References: <094f6fc5-7242-46c7-b454-4cb29d0c6ef9@q40g2000prh.googlegroups.com> <87tygs1v6g.fsf@benfinney.id.au> Message-ID: <029f2ce4-e0fb-4cbc-a857-6cc7aa0a26f6@r4g2000vbq.googlegroups.com> On Jan 29, 4:10?am, Ben Finney wrote: > Note that Raymond is speaking specifically in the context of free > software, where the license is by definition permitting free > redistribution of the source code. It is an obvious necessary condition that for code to be opened it should be open (source). However the necessary condition is not sufficient. > > I have a quibble with the framing: > > > The rest of the blame lies with installers. They all treat > > human-readable scripts like they were binaries and tuck the code away > > in a dark corner. Consider this example: The emacs source if compiled from source will give you help for each lisp or even builtin (C) function out of the box from inside emacs. However if you get the emacs package from debian/ubuntu you will get neither unless you install el files -- which is fine -- just install the el package. About the C sources? I dont believe that one can get that linkage from within apt; one just hast to compile oneself. (I would be happy to be surprised on this). Isn't this an instance of the problem that Raymond is talking of? [Personal note: Ive been a python user and teacher for nearly 10 years and would eagerly welcome more easy code-open-ness] From homeinterwork at gmail.com Sat Jan 29 05:26:34 2011 From: homeinterwork at gmail.com (Ravi chandran) Date: Sat, 29 Jan 2011 02:26:34 -0800 (PST) Subject: Earn $2 Per Click For Free Join Make Money Message-ID: <1d737afa-386d-41f4-a0e8-d353ae79b433@t8g2000vbd.googlegroups.com> www.workfrominter.com From tobiasblass at gmx.net Sat Jan 29 06:10:27 2011 From: tobiasblass at gmx.net (Tobias Blass) Date: Sat, 29 Jan 2011 12:10:27 +0100 Subject: multiple values for keyword argument Message-ID: Hi all I'm just learning python and use it to write a GUI (with Tkinter) for a C program I already wrote. When trying to execute the program below I get the following error message. Traceback (most recent call last): File "./abirechner.py", line 64, in win =MainWin() File "./abirechner.py", line 43, in __init__ self.create_edit(row=i); TypeError: create_edit() got multiple values for keyword argument 'row' I don't really understand why create_edit gets multiple values, it gets one Integer after another (as I see it) Thanks for your help abirechner.py: # line 37 class MainWin(Frame): def __init__(self,master=None): Frame.__init__(self,master) self.grid() self.edits=() for i in range(10): self.create_edit(row=i); def create_edit(row,self): # LineEdit is defined, but I don't consider it important here self.edits+=LineEdit() self.edits[-1].grid(row=row,column=0) # ... #line 64 win = MainWin() win.mainLoop() From wingusr at gmail.com Sat Jan 29 06:22:48 2011 From: wingusr at gmail.com (TP) Date: Sat, 29 Jan 2011 03:22:48 -0800 Subject: Use the Source Luke In-Reply-To: <094f6fc5-7242-46c7-b454-4cb29d0c6ef9@q40g2000prh.googlegroups.com> References: <094f6fc5-7242-46c7-b454-4cb29d0c6ef9@q40g2000prh.googlegroups.com> Message-ID: On Fri, Jan 28, 2011 at 10:32 AM, Raymond Hettinger wrote: > I hoping a new trend will start with dev's putting direct > source code links in their documentation: > > ?http://rhettinger.wordpress.com/2011/01/28/open-your-source-more/ > > I'm looking for more examples of projects that routinely > link their docs back into relavant sections of code. > Have any of you all seen other examples besides > the Go language docs and the Python docs? > > > Raymond > -- > http://mail.python.org/mailman/listinfo/python-list > The Sphinx Python Documentation Generator (http://sphinx.pocoo.org/index.html), used for documenting lots of things other than Python, has an extension called "sphinx.ext.viewcode ? Add links to highlighted source code" (http://sphinx.pocoo.org/ext/viewcode.html). You can see my use of it here on a small PyQt project: http://tpgit.github.com/MDIImageViewer/imageviewer.html. You can even view the Sphinx documentation "code" by clicking the "Show Source" link on the left. -- TP From bieffe62 at gmail.com Sat Jan 29 06:24:06 2011 From: bieffe62 at gmail.com (Francesco Bochicchio) Date: Sat, 29 Jan 2011 03:24:06 -0800 (PST) Subject: multiple values for keyword argument References: Message-ID: <9f669337-6116-4442-9c7e-54b0051e33a2@8g2000prb.googlegroups.com> On 29 Gen, 12:10, Tobias Blass wrote: > Hi all > I'm just learning python and use it to write a GUI (with Tkinter) for a C > program I already wrote. When trying to execute the program below I get the > following error message. > > Traceback (most recent call last): > ? File "./abirechner.py", line 64, in > ? ? ? win =MainWin() > ? File "./abirechner.py", line 43, in __init__ > ? ? ? self.create_edit(row=i); > TypeError: create_edit() got multiple values for keyword argument 'row' > > I don't really understand why create_edit gets multiple values, it gets one > Integer after another (as I see it) > Thanks for your help > > abirechner.py: > > # line 37 > class MainWin(Frame): > ? ? ? ? def __init__(self,master=None): > ? ? ? ? ? ? ? ? Frame.__init__(self,master) > ? ? ? ? ? ? ? ? self.grid() > ? ? ? ? ? ? ? ? self.edits=() > ? ? ? ? ? ? ? ? for i in range(10): > ? ? ? ? ? ? ? ? ? ? ? ? self.create_edit(row=i); > ? ? ? ? def create_edit(row,self): > ? ? ? ? ? ? ? ? # LineEdit is defined, but I don't consider it important here > ? ? ? ? ? ? ? ? self.edits+=LineEdit() > ? ? ? ? ? ? ? ? self.edits[-1].grid(row=row,column=0) > # ... > #line 64 > win = MainWin() > win.mainLoop() Try this: > def create_edit(self, row): Ciao --- FB From tobiasblass at gmx.net Sat Jan 29 08:18:30 2011 From: tobiasblass at gmx.net (Tobias Blass) Date: Sat, 29 Jan 2011 14:18:30 +0100 Subject: multiple values for keyword argument In-Reply-To: <9f669337-6116-4442-9c7e-54b0051e33a2@8g2000prb.googlegroups.com> References: <9f669337-6116-4442-9c7e-54b0051e33a2@8g2000prb.googlegroups.com> Message-ID: On Sat, 29 Jan 2011, Francesco Bochicchio wrote: >On 29 Gen, 12:10, Tobias Blass wrote: >> Hi all >> I'm just learning python and use it to write a GUI (with Tkinter) for a C >> program I already wrote. When trying to execute the program below I get the >> following error message. >> >> Traceback (most recent call last): >> ? File "./abirechner.py", line 64, in >> ? ? ? win =MainWin() >> ? File "./abirechner.py", line 43, in __init__ >> ? ? ? self.create_edit(row=i); >> TypeError: create_edit() got multiple values for keyword argument 'row' >> >> I don't really understand why create_edit gets multiple values, it gets one >> Integer after another (as I see it) >> Thanks for your help >> >> abirechner.py: >> >> # line 37 >> class MainWin(Frame): >> ? ? ? ? def __init__(self,master=None): >> ? ? ? ? ? ? ? ? Frame.__init__(self,master) >> ? ? ? ? ? ? ? ? self.grid() >> ? ? ? ? ? ? ? ? self.edits=() >> ? ? ? ? ? ? ? ? for i in range(10): >> ? ? ? ? ? ? ? ? ? ? ? ? self.create_edit(row=i); >> ? ? ? ? def create_edit(row,self): >> ? ? ? ? ? ? ? ? # LineEdit is defined, but I don't consider it important here >> ? ? ? ? ? ? ? ? self.edits+=LineEdit() >> ? ? ? ? ? ? ? ? self.edits[-1].grid(row=row,column=0) >> # ... >> #line 64 >> win = MainWin() >> win.mainLoop() > >Try this: > >> def create_edit(self, row): > >Ciao >--- >FB > Ok it works now. So the problem was that python requires 'self' to be the first parameter? From saranyamsamy at gmail.com Sat Jan 29 08:30:35 2011 From: saranyamsamy at gmail.com (success all) Date: Sat, 29 Jan 2011 05:30:35 -0800 (PST) Subject: EARN 1000 DOLLARS PER DAY - WITHOUT INVESTMENT Message-ID: http://USAforextradingonline.blogspot.com http://USAforextradingonline.blogspot.com http://USAforextradingonline.blogspot.com http://USAforextradingonline.blogspot.com http://USAforextradingonline.blogspot.com From Frank.Dierkes at googlemail.com Sat Jan 29 08:43:44 2011 From: Frank.Dierkes at googlemail.com (Frank Dierkes) Date: 29 Jan 2011 13:43:44 GMT Subject: multiple values for keyword argument References: <9f669337-6116-4442-9c7e-54b0051e33a2@8g2000prb.googlegroups.com> Message-ID: <8qijsgFgu1U1@mid.dfncis.de> On Sat, 29 Jan 2011 14:18:30 +0100, Tobias Blass wrote: > On Sat, 29 Jan 2011, Francesco Bochicchio wrote: > >>> class MainWin(Frame): >>> ? ? ? ? def create_edit(row,self): >>> def create_edit(self, row): >> >> >> > Ok it works now. So the problem was that python requires 'self' to be > the first parameter? If you define an instance method, the first parameter is always the instance passed to the method - regardless of the parameters name. In your case the instance was passed to the row parameter. Then again you wanted to pass i to it. That's why the exception was raised. If you just had typed self.create_edit(i), then row would have been the instance (*self*.create_edit(...)) and self would have been i. Naming the first parameter self is only a convention. It could be any other name, too. From __peter__ at web.de Sat Jan 29 08:54:08 2011 From: __peter__ at web.de (Peter Otten) Date: Sat, 29 Jan 2011 14:54:08 +0100 Subject: multiple values for keyword argument References: <9f669337-6116-4442-9c7e-54b0051e33a2@8g2000prb.googlegroups.com> Message-ID: Tobias Blass wrote: > > > On Sat, 29 Jan 2011, Francesco Bochicchio wrote: > >>On 29 Gen, 12:10, Tobias Blass wrote: >>> Hi all >>> I'm just learning python and use it to write a GUI (with Tkinter) for a >>> C program I already wrote. When trying to execute the program below I >>> get the following error message. >>> >>> Traceback (most recent call last): >>> File "./abirechner.py", line 64, in >>> win =MainWin() >>> File "./abirechner.py", line 43, in __init__ >>> self.create_edit(row=i); >>> TypeError: create_edit() got multiple values for keyword argument 'row' >>> >>> I don't really understand why create_edit gets multiple values, it gets >>> one Integer after another (as I see it) >>> Thanks for your help >>> class MainWin(Frame): >>> def create_edit(row,self): >>Try this: >>> def create_edit(self, row): > Ok it works now. So the problem was that python requires 'self' to be the > first parameter? When you invoke a method Python implicitly passes the instance as the first positional parameter to it, regardless of the name: >>> class A: ... s = "yadda" ... def yadda(but_i_dont_want_to_call_it_self): ... print but_i_dont_want_to_call_it_self.s ... >>> A().yadda() yadda You can provoke the same error with a function: >>> def f(a, b): ... pass ... >>> f(1, b=2) >>> f(a=1, b=2) >>> f(2, a=1) Traceback (most recent call last): File "", line 1, in TypeError: f() got multiple values for keyword argument 'a' You can think of argument binding as a two-step process. At first positionals are bound to the formal parameters in the order of appearance from left to right; then named arguments are bound to parameters with the same name. If a name is already catered by a positional argument (or a name doesn't occur at all and doesn't have a default value) you get an Exception. From roy at panix.com Sat Jan 29 09:03:28 2011 From: roy at panix.com (Roy Smith) Date: Sat, 29 Jan 2011 09:03:28 -0500 Subject: multiple values for keyword argument References: <9f669337-6116-4442-9c7e-54b0051e33a2@8g2000prb.googlegroups.com> <8qijsgFgu1U1@mid.dfncis.de> Message-ID: In article <8qijsgFgu1U1 at mid.dfncis.de>, Frank Dierkes wrote: > Naming the first parameter self is only a convention. It could be any > other name, too. But it shouldn't. The use of "self" is so universal that using anything else will just make your code more difficult for other people to understand. From h.goebel at crazy-compilers.com Sat Jan 29 09:27:26 2011 From: h.goebel at crazy-compilers.com (Hartmut Goebel) Date: Sat, 29 Jan 2011 15:27:26 +0100 Subject: [ANN] python-ghostscript 0.4 Message-ID: Announcing: python-ghostscript 0.4 A Python-Interface to the Ghostscript C-API using ctypes :Copyright: GNU Public License v3 (GPLv3) :Author: Hartmut Goebel :Homepage: http://bitbucket.org/htgoebel/python-ghostscript :Download: http://pypi.python.org/pypi/ghostscript `Ghostscript`__, is a well known interpreter for the PostScript language and for PDF. This package implements a interface to the Ghostscript C-API using `ctypes`__. Both a low-level and a pythonic, high-level interface are provided. __ http://www.ghostscript.com/ __ http://docs.python.org/library/ctypes.html This package is currently tested only under GNU/Linux. Please report whether it works in your environment, too. Thanks. Latest Changes ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * Fixed bug: typo in function call name ctypes.util.find_library * (Unix) No longer try to load a specific version (version 8) of libgs.so * Added low-level interface for set_stdio() plus wrappers for file handles * (win32) Improved search for best Ghostscript installation: Consider Aladdin and GNU Ghostscript, too; Check for existence of DLL found in registry; take highest version available. * Added win32 example-batch file for testing and other improvements/fixes on examples an documentation. Example ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Here is an example for how to use the high-level interface of `python-ghostscript`. This implements a very basic ps2pdf-tool:: import sys import ghostscript args = [ "ps2pdf", # actual value doesn't matter "-dNOPAUSE", "-dBATCH", "-dSAFER", "-sDEVICE=pdfwrite", "-sOutputFile=" + sys.argv[1], "-c", ".setpdfwrite", "-f", sys.argv[2] ] ghostscript.Ghostscript(*args) -- Regards Hartmut Goebel | Hartmut Goebel | h.goebel at crazy-compilers.com | | www.crazy-compilers.com | compilers which you thought are impossible | From ethan at stoneleaf.us Sat Jan 29 10:45:53 2011 From: ethan at stoneleaf.us (Ethan Furman) Date: Sat, 29 Jan 2011 07:45:53 -0800 Subject: multiple values for keyword argument In-Reply-To: References: <9f669337-6116-4442-9c7e-54b0051e33a2@8g2000prb.googlegroups.com> <8qijsgFgu1U1@mid.dfncis.de> Message-ID: <4D443631.3000502@stoneleaf.us> Roy Smith wrote: > In article <8qijsgFgu1U1 at mid.dfncis.de>, > Frank Dierkes wrote: > >> Naming the first parameter self is only a convention. It could be any >> other name, too. > > But it shouldn't. The use of "self" is so universal that using anything > else will just make your code more difficult for other people to > understand. Nevertheless, if you have a good reason to, go ahead. I, myself, use the spanish word 'yo' instead (less keystrokes, I hate 'self', and it amuses me); if I'm working with my numerical experiments I'll use 'n' or 'x'... although, when posting sample code to c.l.py I do try to use 'self' to avoid possible confusion. :) ~Ethan~ From tobiasblass at gmx.net Sat Jan 29 11:11:43 2011 From: tobiasblass at gmx.net (Tobias Blass) Date: Sat, 29 Jan 2011 17:11:43 +0100 Subject: multiple values for keyword argument In-Reply-To: References: <9f669337-6116-4442-9c7e-54b0051e33a2@8g2000prb.googlegroups.com> Message-ID: On Sat, 29 Jan 2011, Peter Otten wrote: >Tobias Blass wrote: > >> >> >> On Sat, 29 Jan 2011, Francesco Bochicchio wrote: >> >>>On 29 Gen, 12:10, Tobias Blass wrote: >>>> Hi all >>>> I'm just learning python and use it to write a GUI (with Tkinter) for a >>>> C program I already wrote. When trying to execute the program below I >>>> get the following error message. >>>> >>>> Traceback (most recent call last): >>>> File "./abirechner.py", line 64, in >>>> win =MainWin() >>>> File "./abirechner.py", line 43, in __init__ >>>> self.create_edit(row=i); >>>> TypeError: create_edit() got multiple values for keyword argument 'row' >>>> >>>> I don't really understand why create_edit gets multiple values, it gets >>>> one Integer after another (as I see it) >>>> Thanks for your help > >>>> class MainWin(Frame): >>>> def create_edit(row,self): > >>>Try this: >>>> def create_edit(self, row): > >> Ok it works now. So the problem was that python requires 'self' to be the >> first parameter? > >When you invoke a method Python implicitly passes the instance as the first >positional parameter to it, regardless of the name: > >>>> class A: >... s = "yadda" >... def yadda(but_i_dont_want_to_call_it_self): >... print but_i_dont_want_to_call_it_self.s >... >>>> A().yadda() >yadda > >You can provoke the same error with a function: > >>>> def f(a, b): >... pass >... >>>> f(1, b=2) >>>> f(a=1, b=2) >>>> f(2, a=1) >Traceback (most recent call last): > File "", line 1, in >TypeError: f() got multiple values for keyword argument 'a' > >You can think of argument binding as a two-step process. >At first positionals are bound to the formal parameters in the order of >appearance from left to right; then named arguments are bound to parameters >with the same name. If a name is already catered by a positional argument >(or a name doesn't occur at all and doesn't have a default value) you get an >Exception. > > Thanks for your replies, as soon as I knew that python always passes the object reference as first parameter everything was clear (It's just like argc and argv in C, you could also call argc fish and argv chips) From miki.tebeka at gmail.com Sat Jan 29 12:06:40 2011 From: miki.tebeka at gmail.com (Miki) Date: Sat, 29 Jan 2011 09:06:40 -0800 (PST) Subject: Use the Source Luke In-Reply-To: <094f6fc5-7242-46c7-b454-4cb29d0c6ef9@q40g2000prh.googlegroups.com> Message-ID: Clojure a "source" that shows the source of a function (doh!). It's probably easy to implement in Python with the inspect module. Sadly this won't work for built-ins. Clojure's irc clojurebot will answer "source " with a link to github that points to the first line of definition. From peterwfh2000 at gmail.com Sat Jan 29 13:03:50 2011 From: peterwfh2000 at gmail.com (PETER WONG F H (+971 50 8320722)) Date: Sat, 29 Jan 2011 10:03:50 -0800 (PST) Subject: Distress sale/JBR/1 Bed /AED790sqft / 15th floor/050-8320722 Message-ID: <6cf7d895-93bf-45f4-b637-f66a34f87636@k38g2000vbn.googlegroups.com> Distress sale/JBR/1 Bed /AED790sqft / 15th floor/050-8320722 JBR Lower Price AED790per/sqft 15th floor 1,465.90sqft(AED1,160,000.00) +Transfer Fee 2 % + Broker Fee 2% JBR Apartments Located near to Dubai Marina and lying in a beach front location comprises the area of JBR or Jumeirah Beach Residences*Features:* - Swimming Pool - Community - Hot Property - 24hr Door Man - Built-in Wardrobes - Central A/C - Walking distance to Beaches - Balcony The Best Peter Wong F.H ??? Mob ?? : +971 50 83 20 722 E-mail ?? : peterwfh2000 at gmail.com Group : http://groups.google.com/group/dubai-property-club/boxsubscribe?p=FixAddr&email&_referer From patty at cruzio.com Sat Jan 29 13:39:49 2011 From: patty at cruzio.com (patty at cruzio.com) Date: Sat, 29 Jan 2011 10:39:49 -0800 (PST) Subject: multiple values for keyword argument In-Reply-To: <4D443631.3000502@stoneleaf.us> References: <9f669337-6116-4442-9c7e-54b0051e33a2@8g2000prb.googlegroups.com> <8qijsgFgu1U1@mid.dfncis.de> <4D443631.3000502@stoneleaf.us> Message-ID: <6f1dd6fbbc04d2788b2b191e3e407887.squirrel@cruziomail.cruzio.com> > Roy Smith wrote: >> In article <8qijsgFgu1U1 at mid.dfncis.de>, >> Frank Dierkes wrote: >> >>> Naming the first parameter self is only a convention. It could be any >>> other name, too. >> >> But it shouldn't. The use of "self" is so universal that using anything >> else will just make your code more difficult for other people to >> understand. > > Nevertheless, if you have a good reason to, go ahead. > > I, myself, use the spanish word 'yo' instead (less keystrokes, I hate > 'self', and it amuses me); if I'm working with my numerical experiments > I'll use 'n' or 'x'... although, when posting sample code to c.l.py I do > try to use 'self' to avoid possible confusion. :) > > ~Ethan~ > -- > http://mail.python.org/mailman/listinfo/python-list I am glad you said this. I have been avoiding understanding this 'self', just accepting it :} For the time being, since my programs I am creating are for my own use, I think I will make my own names up, that are descriptive to me as the programmer, it's all going to be interpreted anyway. And the other email equating to C's argv, etc. - now I get it. Regards, Patty > > From aahz at pythoncraft.com Sat Jan 29 13:51:59 2011 From: aahz at pythoncraft.com (Aahz) Date: 29 Jan 2011 10:51:59 -0800 Subject: how to read the last line of a huge file??? References: Message-ID: In article , John O'Hagan wrote: > >file.seek takes an optional 'whence' argument which is 2 for the end, so you >can just work back from there till you hit the first newline that has anything >after it: > > >def lastline(filename): > offset = 0 > line = '' > with open(filename) as f: > while True: > offset -= 1 > f.seek(offset, 2) > nextline = f.next() > if nextline == '\n' and line.strip(): > return line > else: > line = nextline It's a Bad Idea to mix direct file operations with the iterator API. Use f.read() instead of f.next(). -- Aahz (aahz at pythoncraft.com) <*> http://www.pythoncraft.com/ "All problems in computer science can be solved by another level of indirection." --Butler Lampson From python.list at tim.thechases.com Sat Jan 29 14:13:37 2011 From: python.list at tim.thechases.com (Tim Chase) Date: Sat, 29 Jan 2011 13:13:37 -0600 Subject: how to read the last line of a huge file??? In-Reply-To: References: Message-ID: <4D4466E1.5040406@tim.thechases.com> On 01/26/2011 04:59 AM, Xavier Heruacles wrote: > I have do some log processing which is usually huge. The > length of each line is variable. How can I get the last line?? > Don't tell me to use readlines or something like linecache... I wrote a modestly tested version (including missing terminal-EOL, files with no newlines, and empty files) at http://www.mail-archive.com/python-list at python.org/msg226537.html which minimizes the number of seeks (reading chunks rather than seeking for every character as you work backwards). You might find it useful. -tkc From python at rcn.com Sat Jan 29 15:23:17 2011 From: python at rcn.com (Raymond Hettinger) Date: Sat, 29 Jan 2011 12:23:17 -0800 (PST) Subject: Use the Source Luke References: <094f6fc5-7242-46c7-b454-4cb29d0c6ef9@q40g2000prh.googlegroups.com> Message-ID: On Jan 29, 3:22?am, TP wrote: > On Fri, Jan 28, 2011 at 10:32 AM, Raymond Hettinger wrote: > > I hoping a new trend will start with dev's putting direct > > source code links in their documentation: > > > ?http://rhettinger.wordpress.com/2011/01/28/open-your-source-more/ > > > I'm looking for more examples of projects that routinely > > link their docs back into relavant sections of code. > > Have any of you all seen other examples besides > > the Go language docs and the Python docs? > > > Raymond > > -- > >http://mail.python.org/mailman/listinfo/python-list > > The Sphinx Python Documentation Generator > (http://sphinx.pocoo.org/index.html), used for documenting lots of > things other than Python, has an extension called "sphinx.ext.viewcode > ? Add links to highlighted source code" > (http://sphinx.pocoo.org/ext/viewcode.html). Thanks, I didn't know about that extension. To support my effort to add source links to the Python docs, Georg Brandl added a new directive :source: so that we could write :source:`Lib/heapq.py` and the set the prefix somewhere else (i.e. pointing at the py3k branch on subversion or on mercurial). Raymond From subhakolkata1234 at gmail.com Sat Jan 29 16:19:57 2011 From: subhakolkata1234 at gmail.com (joy99) Date: Sat, 29 Jan 2011 13:19:57 -0800 (PST) Subject: Looking for Remote Python Project Message-ID: <4d1ff594-925b-457e-be62-7e4ca32ae136@33g2000pru.googlegroups.com> Dear Room, I am a Python Programmer from India(New Delhi Region), and I worked for quite a long time in Bangalore. I have been working in Python for the last 4 years or so. I have successfully built around 15 projects in Python. I am looking for some remote Python Projects, which can be done from home. If any one knows of anything, I may be helpful enough. Best Regards, Subhabrata. From ben+python at benfinney.id.au Sat Jan 29 16:22:19 2011 From: ben+python at benfinney.id.au (Ben Finney) Date: Sun, 30 Jan 2011 08:22:19 +1100 Subject: Use the Source Luke References: <094f6fc5-7242-46c7-b454-4cb29d0c6ef9@q40g2000prh.googlegroups.com> <87tygs1v6g.fsf@benfinney.id.au> <029f2ce4-e0fb-4cbc-a857-6cc7aa0a26f6@r4g2000vbq.googlegroups.com> Message-ID: <87hbcr1k38.fsf@benfinney.id.au> rusi writes: > On Jan 29, 4:10?am, Ben Finney wrote: > > I have a quibble with the framing: > > > > > The rest of the blame lies with installers. They all treat > > > human-readable scripts like they were binaries and tuck the code > > > away in a dark corner. > > Consider this example: > The emacs source if compiled from source will give you help for each > lisp or even builtin (C) function out of the box from inside emacs. > However if you get the emacs package from debian/ubuntu you will get > neither unless you install el files -- which is fine -- just install > the el package. [?] That's an example of the point I made in what followed in my message you quoted. The description can be interpreted as accurate, but it's framed poorly. > Isn't this an instance of the problem that Raymond is talking of? The ?problem?, which I don't consider to be a problem per se, is one of OS-wide policy, not ?installers?. The policy is a matter of tradeoffs across the system, and isn't ?tucking the code away in a dark corner?. > [Personal note: Ive been a python user and teacher for nearly 10 > years and would eagerly welcome more easy code-open-ness] Agreed. -- \ ?When people believe that they have absolute knowledge, with no | `\ test in reality, this [the Auschwitz crematorium] is how they | _o__) behave.? ?Jacob Bronowski, _The Ascent of Man_, 1973 | Ben Finney From ben+python at benfinney.id.au Sat Jan 29 16:24:45 2011 From: ben+python at benfinney.id.au (Ben Finney) Date: Sun, 30 Jan 2011 08:24:45 +1100 Subject: multiple values for keyword argument References: <9f669337-6116-4442-9c7e-54b0051e33a2@8g2000prb.googlegroups.com> Message-ID: <87d3nf1jz6.fsf@benfinney.id.au> Tobias Blass writes: > Ok it works now. So the problem was that python requires 'self' to be > the first parameter? More accurately, the instance is passed as the first parameter, and Python doesn't care what you name it. (Your fellow programmers do care, though, so please stick to the ?self? convention despite this freedom.) -- \ ?The lift is being fixed for the day. During that time we | `\ regret that you will be unbearable.? ?hotel, Bucharest | _o__) | Ben Finney From ben+python at benfinney.id.au Sat Jan 29 16:29:44 2011 From: ben+python at benfinney.id.au (Ben Finney) Date: Sun, 30 Jan 2011 08:29:44 +1100 Subject: multiple values for keyword argument References: <9f669337-6116-4442-9c7e-54b0051e33a2@8g2000prb.googlegroups.com> <8qijsgFgu1U1@mid.dfncis.de> <4D443631.3000502@stoneleaf.us> Message-ID: <877hdn1jqv.fsf@benfinney.id.au> patty at cruzio.com writes: > > I, myself, use the spanish word 'yo' instead (less keystrokes, I > > hate 'self', and it amuses me); if I'm working with my numerical > > experiments I'll use 'n' or 'x'... although, when posting sample > > code to c.l.py I do try to use 'self' to avoid possible confusion. > > :) > > I am glad you said this. I have been avoiding understanding this > 'self', just accepting it :} For the time being, since my programs I > am creating are for my own use, I think I will make my own names up, > that are descriptive to me as the programmer, it's all going to be > interpreted anyway. Please consider that your code is written primarily for humans to read, and only incidentally for the machine to execute. (If it were primarily for the machine to execute and communication with humans was not an issue, you would be writing in machine code.) Consider that code written ?only for my own use? frequently becomes more widespread; and it's impossible to know at the time of writing it whether that will be the case. It's prudent to write all such code as though it were for public consumption. -- \ ?Generally speaking, the errors in religion are dangerous; | `\ those in philosophy only ridiculous.? ?David Hume, _A Treatise | _o__) of Human Nature_, 1739 | Ben Finney From ben+python at benfinney.id.au Sat Jan 29 16:49:01 2011 From: ben+python at benfinney.id.au (Ben Finney) Date: Sun, 30 Jan 2011 08:49:01 +1100 Subject: Looking for Remote Python Project References: <4d1ff594-925b-457e-be62-7e4ca32ae136@33g2000pru.googlegroups.com> Message-ID: <8739ob1iuq.fsf@benfinney.id.au> joy99 writes: > I am looking for some remote Python Projects, which can be done from > home. > > If any one knows of anything, I may be helpful enough. One of the best ways to begin contributing is to fix bugs and provide patches. For Python itself, see the Python bug tracker ; for other projects, see the project's site and browse its bug tracker. -- \ ?Please to bathe inside the tub.? ?hotel room, Japan | `\ | _o__) | Ben Finney From aahz at pythoncraft.com Sat Jan 29 16:53:36 2011 From: aahz at pythoncraft.com (Aahz) Date: 29 Jan 2011 13:53:36 -0800 Subject: apscheduler error References: <9699865b-a8be-4284-a347-58d875b491f6@n2g2000pre.googlegroups.com> Message-ID: In article , =?utf-8?Q?Alice_Bevan=E2=80=93McGregor?= wrote: > >A package of mine, TurboMail, suffers from the same threading issue if >used improperly; you enqueue e-mail, it starts a thread, then you >immediately exit. TM tries to work around the issue, but in most cases >that workaround does not work properly. (You get strange uncatchable >exceptions printed on stderr though AFIK the e-mail does get sent >correctly, your application may hang waiting for the thread pool to >drain if you have a "minimum thread count" option set.) Why not write an exit handler that converts your thread to daemon? (Or something like that.) -- Aahz (aahz at pythoncraft.com) <*> http://www.pythoncraft.com/ "All problems in computer science can be solved by another level of indirection." --Butler Lampson From ben+python at benfinney.id.au Sat Jan 29 18:12:47 2011 From: ben+python at benfinney.id.au (Ben Finney) Date: Sun, 30 Jan 2011 10:12:47 +1100 Subject: apscheduler error References: <9699865b-a8be-4284-a347-58d875b491f6@n2g2000pre.googlegroups.com> Message-ID: <87y663z4ls.fsf@benfinney.id.au> aahz at pythoncraft.com (Aahz) writes: > In article , > =?utf-8?Q?Alice_Bevan=E2=80=93McGregor?= wrote: > >A package of mine, TurboMail, suffers from the same threading issue > >if used improperly; you enqueue e-mail, it starts a thread, then you > >immediately exit. > > Why not write an exit handler that converts your thread to daemon? (Or > something like that.) For that purpose, I'll ask that you try the ?python-daemon? library . It's designed specifically for making the current process into a well-behaved Unix daemon. -- \ ?I knew things were changing when my Fraternity Brothers threw | `\ a guy out of the house for mocking me because I'm gay.? | _o__) ?postsecret.com, 2010-01-19 | Ben Finney From steve+comp.lang.python at pearwood.info Sat Jan 29 18:45:02 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 29 Jan 2011 23:45:02 GMT Subject: multiple values for keyword argument References: <9f669337-6116-4442-9c7e-54b0051e33a2@8g2000prb.googlegroups.com> <8qijsgFgu1U1@mid.dfncis.de> Message-ID: <4d44a67e$0$29993$c3e8da3$5496439d@news.astraweb.com> On Sat, 29 Jan 2011 09:03:28 -0500, Roy Smith wrote: > In article <8qijsgFgu1U1 at mid.dfncis.de>, > Frank Dierkes wrote: > >> Naming the first parameter self is only a convention. It could be any >> other name, too. > > But it shouldn't. The use of "self" is so universal that using anything > else will just make your code more difficult for other people to > understand. It's a strong convention, true, but for Python to prohibit names other than self would be a serious mistake. It would add complication to the parser, for no real benefit. Remember, there's nothing special about methods. They're just ordinary functions which happen to be passed an extra argument at runtime. Making it compulsory to call the first argument "self" would seriously cripple Python's usefulness in at least three cases. (1) Class methods receive the class, not the instance, and the convention is to call that first argument "cls". It would be confusing and misleading to call it "self". Similarly, I sometimes use a similar descriptor which combines the functionality of class methods and ordinary methods. Since neither "self" nor "cls" would be appropriate, I use the name "this" for the first argument: http://code.activestate.com/recipes/577030-dualmethod-descriptor/ Descriptors are a general protocol, so there may be other such technologies being used by people. (2) Sometimes people use functions inside a class namespace as an ordinary function, perhaps as a factory function, called at class creation time. Here is a toy example that automates the building of properties: class K(object): def build(name): # called at class creation time def getter(self): return getattr(self, "_" + name) def setter(self, value): setattr(self, "_" + name, value) return property(getter, setter) spam = build("spam") ham = build("ham") (3) Because methods are just a wrapper around an ordinary function, you can inject almost any function into a class at runtime. You don't know what the first argument of that function is called: >>> class K(object): ... def __init__(self, value='spam'): ... self.attr = value ... >>> def get_attr(obj): ... return obj.attr ... >>> k = K() >>> get_attr(k) 'spam' >>> >>> K.method = get_attr >>> k.method() 'spam' -- Steven From rustompmody at gmail.com Sat Jan 29 22:59:33 2011 From: rustompmody at gmail.com (rusi) Date: Sat, 29 Jan 2011 19:59:33 -0800 (PST) Subject: Use the Source Luke References: <094f6fc5-7242-46c7-b454-4cb29d0c6ef9@q40g2000prh.googlegroups.com> <87tygs1v6g.fsf@benfinney.id.au> <029f2ce4-e0fb-4cbc-a857-6cc7aa0a26f6@r4g2000vbq.googlegroups.com> <87hbcr1k38.fsf@benfinney.id.au> Message-ID: On Jan 30, 2:22?am, Ben Finney wrote: > > The ?problem?, which I don't consider to be a problem per se, is one of > OS-wide policy, not ?installers?. The policy is a matter of tradeoffs > across the system, and isn't ?tucking the code away in a dark corner?. Earlier mail: > If you want to blame anything for this (though I think it?s inaccurate > to frame it as a problem), the correct target of your accusation is the > fact that a filesystem path is the identifier for these modules that > will be used by programs to find them. I think this is a fairly accurate description of (one aspect of) the problem. If you dont see it as a problem how do you explain that google can search the World Wide Web better than we can search our individual hard disks? From steve+comp.lang.python at pearwood.info Sat Jan 29 23:21:36 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 30 Jan 2011 04:21:36 GMT Subject: Use the Source Luke References: <094f6fc5-7242-46c7-b454-4cb29d0c6ef9@q40g2000prh.googlegroups.com> <87tygs1v6g.fsf@benfinney.id.au> <029f2ce4-e0fb-4cbc-a857-6cc7aa0a26f6@r4g2000vbq.googlegroups.com> <87hbcr1k38.fsf@benfinney.id.au> Message-ID: <4d44e750$0$29970$c3e8da3$5496439d@news.astraweb.com> On Sat, 29 Jan 2011 19:59:33 -0800, rusi wrote: > On Jan 30, 2:22?am, Ben Finney wrote: >> >> The ?problem?, which I don't consider to be a problem per se, is one of >> OS-wide policy, not ?installers?. The policy is a matter of tradeoffs >> across the system, and isn't ?tucking the code away in a dark corner?. > > Earlier mail: > >> If you want to blame anything for this (though I think it?s inaccurate >> to frame it as a problem), the correct target of your accusation is the >> fact that a filesystem path is the identifier for these modules that >> will be used by programs to find them. > > I think this is a fairly accurate description of (one aspect of) the > problem. > If you dont see it as a problem how do you explain that google can > search the World Wide Web better than we can search our individual hard > disks? I fail to see any connection between the location that operating systems store files, and the ability of Google to index publicly available websites. It sounds to me like the equivalent of "If you don't think Python programmers are a problem, how do you explain that it takes me 45 minutes to drive to work in the morning but nearly an hour to drive home in the evening?" Google has approximately one million servers indexing the web, and they're willing to use hundreds of terabytes of disk space to store the indexes. My desktop is *one* PC with little free space, and I'd rather trade off time for storage, so I don't keep any indexes of file content on my system. If I *wanted* to index my files, I could do so, although in fairness I'm not aware of any Linux tools which do this -- I know of `locate`, which indexes file *names* but not content, and `grep`, which searches file content but doesn't index what it finds. On Windows and Mac, though, I believe there are standard utilities which will index file content if you allow them. So... Google can search the web better than we can search our local hard drives because Google has invested tens or hundreds of millions into building a world-class search engine, and we haven't. -- Steven From rantingrick at gmail.com Sat Jan 29 23:25:30 2011 From: rantingrick at gmail.com (rantingrick) Date: Sat, 29 Jan 2011 20:25:30 -0800 (PST) Subject: [pygame-bug] Pygame.cdrom bug Message-ID: <4cb7b9c0-ebd1-44a1-bfb2-8ac9193faea6@p11g2000vbq.googlegroups.com> Hello folks, Pygame --the best little 2d game engine in Pythoina-- is great for little 2d one off games and such (or so i've heard). I really don't do much 2d graphics but pygame has some other helpful modules so i downloded it about a year or so ago although i had not used it until today. I just wanted to be ready just incase the 2d bug bit me. So recently I wanted to do some cdrom automation for one of my Tkinter scripts and thought... Hey, i finally found a good use for that old pygame module! So with much anticipation i moseyed on over to my site-packages folder and dusted off the old pygame module and docs and i was coding away just happy as a clam. I had my initialization working well, my ejections were a breeze, and i even had some boolean testing functionality all wrapped up nicely. Boy was i on cloud nine! And just as i was finishing up the interface class with a "close" method i realized in horror... YOU CAN OPEN THE CD TRAY WITH PYGAME HOWEVER FOR SOME CRUEL AND UNJUST REASON YOU CANNOT CLOSE IT! WTF? Yes at this point i realized that without a method to close the cd tray my little module was useless. Sure i could drop into my OS functionality and close the cdtray by first setting up a device handle and calling a few underlying Windows functions however i am convinced that this basic functionality should be a part of any cdrom interface. Why would someone create such an interface and leave out such an important method? Surely this functionality must be available through the SDL API? What gives pygame developers? What gives? From benjamin.kaplan at case.edu Sat Jan 29 23:40:51 2011 From: benjamin.kaplan at case.edu (Benjamin Kaplan) Date: Sat, 29 Jan 2011 23:40:51 -0500 Subject: [pygame-bug] Pygame.cdrom bug In-Reply-To: <4cb7b9c0-ebd1-44a1-bfb2-8ac9193faea6@p11g2000vbq.googlegroups.com> References: <4cb7b9c0-ebd1-44a1-bfb2-8ac9193faea6@p11g2000vbq.googlegroups.com> Message-ID: On Sat, Jan 29, 2011 at 11:25 PM, rantingrick wrote: > > Hello folks, > > Pygame ?--the best little 2d game engine in Pythoina-- is great for > little 2d one off games and such (or so i've heard). I really don't do > much 2d graphics but pygame has some other helpful modules so i > downloded it about a year or so ago although i had not used it until > today. I just wanted to be ready just incase the 2d bug bit me. So > recently I wanted to do some cdrom automation for one of my Tkinter > scripts and thought... Hey, i finally found a good use for that old > pygame module! > > So with much anticipation i moseyed on over to my site-packages folder > and dusted off the old pygame module and docs and i was coding away > just happy as a clam. I had my initialization working well, my > ejections were a breeze, and i even had some boolean testing > functionality all wrapped up nicely. Boy was i on cloud nine! And just > as i was finishing up the interface class with a "close" method i > realized in horror... YOU CAN OPEN THE CD TRAY WITH PYGAME HOWEVER FOR > SOME CRUEL AND UNJUST REASON YOU CANNOT CLOSE IT! ?WTF? > > Yes at this point i realized that without a method to close the cd > tray my little module was useless. Sure i could drop into my OS > functionality and close the cdtray by first setting up a device handle > and calling a few underlying Windows functions however i am convinced > that this basic functionality should be a part of any cdrom interface. > Why would someone create such an interface and leave out such an > important method? Surely this functionality must be available through > the SDL API? What gives pygame developers? What gives? > > -- 1) That's a feature request (something isn't there that should be there), not a bug (something that doesn't follow documented behaviors) 2) If you have a feature request or bug for a 3rd party package, moaning about it here won't do anything. Try asking nicely either on the project's mailing list or on the project's bug tracker. http://www.pygame.org/wiki/patchesandbugs From rustompmody at gmail.com Sat Jan 29 23:50:20 2011 From: rustompmody at gmail.com (rusi) Date: Sat, 29 Jan 2011 20:50:20 -0800 (PST) Subject: Use the Source Luke References: <094f6fc5-7242-46c7-b454-4cb29d0c6ef9@q40g2000prh.googlegroups.com> <87tygs1v6g.fsf@benfinney.id.au> <029f2ce4-e0fb-4cbc-a857-6cc7aa0a26f6@r4g2000vbq.googlegroups.com> <87hbcr1k38.fsf@benfinney.id.au> <4d44e750$0$29970$c3e8da3$5496439d@news.astraweb.com> Message-ID: <6c2ca5e4-6abe-49d5-b53f-a1d7c93ac328@r4g2000prm.googlegroups.com> On Jan 30, 9:21?am, Steven D'Aprano wrote: > > > I think this is a fairly accurate description of (one aspect of) the > > problem. > > If you dont see it as a problem how do you explain that google can > > search the World Wide Web better than we can search our individual hard > > disks? > > I fail to see any connection between the location that operating systems > store files, and the ability of Google to index publicly available > websites. http://en.wikipedia.org/wiki/Content-addressable_storage#Content-addressed_vs._Location-addressed From python at rcn.com Sun Jan 30 00:17:10 2011 From: python at rcn.com (Raymond Hettinger) Date: Sat, 29 Jan 2011 21:17:10 -0800 (PST) Subject: Use the Source Luke References: <094f6fc5-7242-46c7-b454-4cb29d0c6ef9@q40g2000prh.googlegroups.com> <87tygs1v6g.fsf@benfinney.id.au> Message-ID: On Jan 28, 3:10?pm, Ben Finney wrote: > Raymond Hettinger writes: > > The rest of the blame lies with installers. They all treat > > human-readable scripts like they were binaries and tuck the code away > > in a dark corner. > > That?s hardly a ?blame? of installers. The modules are placed in such > locations because they need to be accessible in a hierarchy at a > location that is known to not conflict with anything else, and be > predictable for the Python interpreter on the system. Sure. Installers are just installing where they're supposed to. And good people have given a lot of thought to the preferred target directories. I'm just observing that the source files are often ending-up out-of-sight and out-of-mind so that fewer users ever see the source. It's not deep a problem -- it would only take a symlink to provide quick access. My thesis is that we can do even better than that by adding direct links from the docs to the relevant code with nice syntax highlighting. Raymond P.S. Making it easy to get to relevant source is only half of the solution. The remaining problem is cultural. Perhaps every project should have a recommended reading list. As a start, I think the following are instructive and make for a good read: http://svn.python.org/view/python/branches/py3k/Lib/ftplib.py?view=markup http://svn.python.org/view/python/branches/py3k/Lib/heapq.py?view=markup http://svn.python.org/view/python/branches/py3k/Lib/collections.py?view=markup http://svn.python.org/view/python/branches/py3k/Lib/queue.py?view=markup http://svn.python.org/view/python/branches/py3k/Lib/functools.py?view=markup From rantingrick at gmail.com Sun Jan 30 00:23:02 2011 From: rantingrick at gmail.com (rantingrick) Date: Sat, 29 Jan 2011 21:23:02 -0800 (PST) Subject: Python critique References: <21868b6d-ab01-402d-a9b3-ee1be39771b8@o4g2000yqd.googlegroups.com> <4d028748$0$1621$742ec2ed@news.sonic.net> <4d02b47b$0$30000$c3e8da3$5496439d@news.astraweb.com> Message-ID: <385c6758-56ba-4323-9e93-16c9bc9eb350@m7g2000vbq.googlegroups.com> On Dec 10 2010, 5:15?pm, Steven D'Aprano wrote: > n = 1 > [print(n) for n in (2,)] > print n Oh *thats* why we have print as a function! I always wanted to put print in a list cmp. :-) From rantingrick at gmail.com Sun Jan 30 00:24:59 2011 From: rantingrick at gmail.com (rantingrick) Date: Sat, 29 Jan 2011 21:24:59 -0800 (PST) Subject: Python critique References: <21868b6d-ab01-402d-a9b3-ee1be39771b8@o4g2000yqd.googlegroups.com><4d028748$0$1621$742ec2ed@news.sonic.net> <4d02b47b$0$30000$c3e8da3$5496439d@news.astraweb.com> <52430F724D9B40DFB856FCDD172C28C8@teddy> Message-ID: <0a9ea419-3838-4603-a92d-0e117dfe49ff@r4g2000vbq.googlegroups.com> On Dec 13 2010, 4:40?am, Jean-Michel Pichavant wrote: > It's more a demonstration that you can do it with python. > The reason is that Python developpers will not put themself in the > situation where they need to use a variable 'orange' line 32 and use the > same variable 'orange' line 33 to refer to something else. Yes and when a programmer does something like this he does not demonstrate *scope-y* problems, he demonstrates *dope-y* problems. :-) From ethan at stoneleaf.us Sun Jan 30 00:35:31 2011 From: ethan at stoneleaf.us (Ethan Furman) Date: Sat, 29 Jan 2011 21:35:31 -0800 Subject: multiple values for keyword argument In-Reply-To: <6f1dd6fbbc04d2788b2b191e3e407887.squirrel@cruziomail.cruzio.com> References: <9f669337-6116-4442-9c7e-54b0051e33a2@8g2000prb.googlegroups.com> <8qijsgFgu1U1@mid.dfncis.de> <4D443631.3000502@stoneleaf.us> <6f1dd6fbbc04d2788b2b191e3e407887.squirrel@cruziomail.cruzio.com> Message-ID: <4D44F8A3.6050207@stoneleaf.us> patty at cruzio.com wrote: >> I, myself, use the spanish word 'yo' instead (less keystrokes, I hate >> 'self', and it amuses me); if I'm working with my numerical experiments >> I'll use 'n' or 'x'... although, when posting sample code to c.l.py I do >> try to use 'self' to avoid possible confusion. :) > > I am glad you said this. I have been avoiding understanding this 'self', > just accepting it :} For the time being, since my programs I am creating > are for my own use, I think I will make my own names up, that are > descriptive to me as the programmer, it's all going to be interpreted > anyway. And the other email equating to C's argv, etc. - now I get it. Careful about the names you make-up -- to aid yourself and others you don't want to have dozen's of different names that all basically mean 'this instance that I'm currently working on'. ~Ethan~ From research at johnohagan.com Sun Jan 30 00:37:54 2011 From: research at johnohagan.com (John O'Hagan) Date: Sun, 30 Jan 2011 05:37:54 +0000 Subject: how to read the last line of a huge file??? In-Reply-To: References: Message-ID: <201101300537.55343.research@johnohagan.com> On Sat, 29 Jan 2011, Aahz wrote: > In article , > > John O'Hagan wrote: [...] > > > >def lastline(filename): > > offset = 0 > > line = '' > > with open(filename) as f: > > while True: > > offset -= 1 > > f.seek(offset, 2) > > nextline = f.next() > > if nextline == '\n' and line.strip(): > > return line > > else: > > line = nextline > > It's a Bad Idea to mix direct file operations with the iterator API. I didn't know that; from the docs on file objects: "As a consequence of using a read-ahead buffer, combining next() with other file methods (like readline()) does not work right. However, using seek() to reposition the file to an absolute position will flush the read-ahead buffer." You are right in general, but the second sentence is why I got away with it in this case. > Use f.read() instead of f.next(). Which actually ends up improving the code as well: def lastline(filename): offset = 0 with open(filename) as f: while 1: f.seek(offset, 2) if f.tell() == 0: return f.read().strip() line = f.read() if line.strip() and line[0] == '\n': return line.strip() offset -= 1 although Tim Chase's solution covers files with very long lines. John From subhakolkata1234 at gmail.com Sun Jan 30 01:30:21 2011 From: subhakolkata1234 at gmail.com (joy99) Date: Sat, 29 Jan 2011 22:30:21 -0800 (PST) Subject: Looking for Remote Python Project References: <4d1ff594-925b-457e-be62-7e4ca32ae136@33g2000pru.googlegroups.com> <8739ob1iuq.fsf@benfinney.id.au> Message-ID: On Jan 30, 2:49?am, Ben Finney wrote: > joy99 writes: > > I am looking for some remote Python Projects, which can be done from > > home. > > > If any one knows of anything, I may be helpful enough. > > One of the best ways to begin contributing is to fix bugs and provide > patches. For Python itself, see the Python bug tracker > ; for other projects, see the project's > site and browse its bug tracker. > > -- > ?\ ? ? ? ? ? ? ? ??Please to bathe inside the tub.? ?hotel room, Japan | > ? `\ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? | > _o__) ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?| > Ben Finney Thanks Ben for a nice reply and suggestion. This experience will surely be rewarding one. But do you know whether it would be a paying one, I am looking to be a freelancer. >From this room of expert Python programmers, developers I am trying to get nice suggestions. Wishing You a Happy Day Ahead, Best Regards, Subhabrata. From ben+python at benfinney.id.au Sun Jan 30 03:07:52 2011 From: ben+python at benfinney.id.au (Ben Finney) Date: Sun, 30 Jan 2011 19:07:52 +1100 Subject: Looking for Remote Python Project References: <4d1ff594-925b-457e-be62-7e4ca32ae136@33g2000pru.googlegroups.com> <8739ob1iuq.fsf@benfinney.id.au> Message-ID: <87sjwazuef.fsf@benfinney.id.au> joy99 writes: > But do you know whether it would be a paying one, I am looking to be a > freelancer. You might find the Python Job Board useful . -- \ ?Choose mnemonic identifiers. If you can't remember what | `\ mnemonic means, you've got a problem.? ?Larry Wall | _o__) | Ben Finney From steve+comp.lang.python at pearwood.info Sun Jan 30 03:53:06 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 30 Jan 2011 08:53:06 GMT Subject: Use the Source Luke References: <094f6fc5-7242-46c7-b454-4cb29d0c6ef9@q40g2000prh.googlegroups.com> <87tygs1v6g.fsf@benfinney.id.au> <029f2ce4-e0fb-4cbc-a857-6cc7aa0a26f6@r4g2000vbq.googlegroups.com> <87hbcr1k38.fsf@benfinney.id.au> <4d44e750$0$29970$c3e8da3$5496439d@news.astraweb.com> <6c2ca5e4-6abe-49d5-b53f-a1d7c93ac328@r4g2000prm.googlegroups.com> Message-ID: <4d4526f2$0$29965$c3e8da3$5496439d@news.astraweb.com> On Sat, 29 Jan 2011 20:50:20 -0800, rusi wrote: > On Jan 30, 9:21?am, Steven D'Aprano +comp.lang.pyt... at pearwood.info> wrote: >> >> > I think this is a fairly accurate description of (one aspect of) the >> > problem. >> > If you dont see it as a problem how do you explain that google can >> > search the World Wide Web better than we can search our individual >> > hard disks? >> >> I fail to see any connection between the location that operating >> systems store files, and the ability of Google to index publicly >> available websites. > > http://en.wikipedia.org/wiki/Content-addressable_storage#Content- addressed_vs._Location-addressed Nope, sorry, doesn't help. Both local files on your hard drive, and most remote websites on the Internet, are location addressed. Google indexes the content, but they don't provide content-addresses. Indeed, they *can't* do so (except, possibly, for content they control such as Google Books), since they can't prevent content owners from modifying either the location address or the content. And as I've mentioned, there are desktop utilities that index content for Windows and Macintosh. In fact, Google themselves offer a desktop app that does just that: http://desktop.google.com/features.html -- Steven From steve+comp.lang.python at pearwood.info Sun Jan 30 04:36:39 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 30 Jan 2011 09:36:39 GMT Subject: multiple values for keyword argument References: <9f669337-6116-4442-9c7e-54b0051e33a2@8g2000prb.googlegroups.com> <8qijsgFgu1U1@mid.dfncis.de> <4D443631.3000502@stoneleaf.us> Message-ID: <4d453127$0$29965$c3e8da3$5496439d@news.astraweb.com> On Sat, 29 Jan 2011 10:39:49 -0800, patty wrote: > I am glad you said this. I have been avoiding understanding this > 'self', just accepting it :} For the time being, since my programs I am > creating are for my own use, I think I will make my own names up, that > are descriptive to me as the programmer, it's all going to be > interpreted anyway. And the other email equating to C's argv, etc. - > now I get it. That's a shame, because `self` is actually very simple once you understand the basic principles of object-oriented programming. What names would you choose? Unless you're writing descriptors, or using class methods, both of which should be considered advanced usage (highly advanced for descriptors, moderately so for class methods), it's not like every method needs a different descriptive first argument. In English, "self", "this", "me" or "instance" would be good names. What else would you use? The idea of method syntax is that you start with an instance of some class: mystring = "hello world" # an instance of the str class In procedural languages like C or Pascal, you would call a function and give the string as an argument. Python supports this programming model, and uses it for built-ins like len: len(mystring) => returns 11 Object oriented programming uses a different syntax. Instead of function(instance) as above, we take the instance argument outside the brackets. For example: mystring.upper() # instead of upper(mystring) => returns "HELLO WORLD" If there are any extra arguments needed, they go inside the brackets as normal. So far, this is just a change of syntax. It's like saying "The cat of my brother's" vs. "my brother's cat" -- the meaning is the same, but the syntax differs. The real advantages of object oriented programming and methods come elsewhere (e.g. encapsulation and inheritance). [Aside: when I was learning this, the hardest part I found was remembering which things were functions, and which were methods. I kept writing (wrongly!) things like: "hello world".len() upper("hello world") Unfortunately there is no easy way to recognise what will be a function like len, and which are methods like upper. That will come with experience. Back to function/procedural syntax versus object oriented syntax... One difference, though, is when you write a method definition. Because the method you write starts off life as an ordinary function, you need to write it *as if* it were a function you call like len() above. Here's how you might write a method in a class: class MyClass: def method(self, extra): pass When you then call the method: instance = MyClass() instance.method("something extra") Python automatically changes the syntax for you, and passes two arguments to the function as if you did this: # pseudo-code set self = instance set extra = "something extra extract "method" from MyClass call method(self, extra) We call the first argument something like "self" because it will ALWAYS be the instance itself. Unlike a regular function, which can have anything passed as the first argument, and therefore you should give it a descriptive name, the method's first argument is provided automatically for you and will always be the instance you started with. I hope this helps. -- Steven From david at boddie.org.uk Sun Jan 30 08:19:35 2011 From: david at boddie.org.uk (David Boddie) Date: Sun, 30 Jan 2011 14:19:35 +0100 Subject: Use the Source Luke References: <094f6fc5-7242-46c7-b454-4cb29d0c6ef9@q40g2000prh.googlegroups.com> <87tygs1v6g.fsf@benfinney.id.au> <029f2ce4-e0fb-4cbc-a857-6cc7aa0a26f6@r4g2000vbq.googlegroups.com> <87hbcr1k38.fsf@benfinney.id.au> <4d44e750$0$29970$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Sunday 30 January 2011 05:21, Steven D'Aprano wrote: > If I *wanted* to index my files, I could do so, although in > fairness I'm not aware of any Linux tools which do this -- I know of > `locate`, which indexes file *names* but not content, and `grep`, which > searches file content but doesn't index what it finds. You might find this page useful: http://www.wikinfo.org/index.php/Comparison_of_desktop_search_software David From mail2bansi at gmail.com Sun Jan 30 08:31:26 2011 From: mail2bansi at gmail.com (bansi) Date: Sun, 30 Jan 2011 05:31:26 -0800 (PST) Subject: Is it possible to pass CSV Reader Object As Argument to another Python File ??? References: <2c35653e-3565-48c6-8939-b6b09b885e3f@d23g2000prj.googlegroups.com> <876b6c52-1a6d-4afa-83e9-fa987c9359a5@v31g2000pri.googlegroups.com> <87lj272vpo.fsf@benfinney.id.au> <430714cd-20b4-4a67-bd2d-54e8f0c44ad5@s18g2000vbe.googlegroups.com> <2c9f82cd-756b-4460-940b-31e2a866f24e@n36g2000pre.googlegroups.com> <933ce06c-7829-42b9-a96d-dc9582e8267b@u11g2000prk.googlegroups.com> Message-ID: <558dc540-a09d-4034-b29d-c77103a341eb@m27g2000prj.googlegroups.com> On Jan 28, 4:22?pm, Benjamin Kaplan wrote: > On Fri, Jan 28, 2011 at 3:42 PM, bansi wrote: > > On Jan 28, 1:52?pm, Benjamin Kaplan wrote: > >> On Fri, Jan 28, 2011 at 1:33 PM, bansi wrote: > >> > On Jan 28, 9:46?am, bansi wrote: > >> >> On Jan 26, 8:31?pm, MRAB wrote: > > >> >> > On 27/01/2011 00:57, bansi wrote: > > >> >> > > On Jan 26, 6:25 pm, Ethan Furman ?wrote: > >> >> > >> bansi wrote: > > >> >> > >> ? > ?First namelookupWrapper.py running under Python 2.6 accept arguments > >> >> > >> ? > ?from stdin and uses csv reader object to read it i.e. > >> >> > >> ? > ?r=csv.reader(sys.stdin) > > >> >> > >> ? > ?And then it has to pass csv reader object to another python script > >> >> > >> ? > ?namelookup.py running under Python 2.7 because it uses pyodbc to > >> >> > >> ? > ?connect to database and iterates thru reader object > > >> >> > >> Ben Finney wrote: > >> >> > >>> bansi ?writes: > > >> >> > >>>> Thanks Chris. Sorry for mis-communicating, the two python scripts are > >> >> > >>>> dependant in a way that namelookupWrapper.py needs to pass csv record > >> >> > >>>> object to another python script > > >> >> > >>> Why have you structured them that way, though? What constraint is > >> >> > >>> keeping you from doing the work in a single process, where the CSV > >> >> > >>> reader object can be shared? > > >> >> > >>>> If thats not possible then please let me know how to do the workaround > >> >> > >>>> i didnt understood the import thing and not sure if it helps in my > >> >> > >>>> case > > >> >> > >>> The problem as you've described it so far is best solved by having a > >> >> > >>> single process accessing the CSV reader object in memory. If that > >> >> > >>> doesn't suit your use case, you'll need to explain why not. > > >> >> > >> In other words, why can't you use Python 2.7 to accept input and > >> >> > >> generate a csv.reader? > > >> >> > >> ~Ethan~- Hide quoted text - > > >> >> > >> - Show quoted text - > > >> >> > > Ethan, > >> >> > > The python script takes the input from Splunk (http://www.splunk.com/ > >> >> > > base/Documentation/) which supports only Python 2.6 > >> >> > > So the real constraint is Splunk supports only Python 2.6 . > > >> >> > > As you know Python 2.6 doesnt support or doesnt have pyodbc install > >> >> > > for Windows ?64 bit OS > >> >> > > So i installed Python 2.7 and thereafter pyodbc install for Windows 64 > >> >> > > bit OS for Python 2.7 > > >> >> > Have you actually tried Splunk with Python 2.7? It might not work with > >> >> > versions which are earlier than Python 2.6, but that doesn't > >> >> > necessarily mean that it won't work with versions of Python 2 which are > >> >> > later than Python 2.6 (unless the documentation says that it must be > >> >> > Python 2.6).- Hide quoted text - > > >> >> > - Show quoted text - > > >> >> Splunk's latest version 4.1.6 doesn't support Python 2.7 > >> >> I tried the import trick but it didnt work because the real script > >> >> which runs under Python 2.7 has import pyodbc so it results in > >> >> following error > > >> >> c:\Splunk\etc\apps\search\bin>splunk cmd python namelookupWrapper.py > >> >> memberId memberName < memberInput.csv > >> >> Traceback (most recent call last): > >> >> ? File "namelookupWrapper.py", line 3, in > >> >> ? ? import namelookup > >> >> ? File "c:\Splunk\etc\apps\search\bin\namelookup.py", line 7, in > >> >> > >> >> ? ? import pyodbc > >> >> ImportError: DLL load failed: The specified module could not be found. > > >> >> Please let me know if i am missing something on import. If so please > >> >> provide me with an example- Hide quoted text - > > >> >> - Show quoted text - > > >> > Here are some more details from my earlier posting. Please click the > >> > below link > > >> >http://answers.splunk.com/questions/11145/its-getting-mysterious-to-m... > >> > -- > >> >http://mail.python.org/mailman/listinfo/python-list > > >> Have you tried downloading the source for PyODBC and compiling it > >> yourself? All you need to do is python setup.py install. My guess > >> would be that it works just fine on 64-bit Python 2.6, they just never > >> released a re-compiled version of it for that platform.- Hide quoted text - > > >> - Show quoted text - > > > Thanks Benjamin. Please point me to the website from where i can > > download pyodbc for Windows 64 bit OS under Python 2.6 and > > installation instructions > > -- > > You don't download it for 64-bit Windows with Python 2.6. You download > the source code from the website and make the Python 2.6, 64-bit > Windows version yourself. > > Download the source zip file and extract it. Then, open up the command > prompt and use the "cd" command to change directories to that source > folder. For instance, if the source code has been extracted to > C:\pyodbc-2.1.8\, you type in "cd C:\pyodbc-2.1.8" and press enter. > > After that, you just run the build script which is already in there: > > C:\Python26\python26.exe setup.py install > > You'll need to have Visual C++ 2008 (not 2010) installed for this to > work. You can get it for free fromhttp://www.microsoft.com/express/Downloads/if you don't already have > it. > > > > >http://mail.python.org/mailman/listinfo/python-list- Hide quoted text - > > - Show quoted text -- Hide quoted text - > > - Show quoted text - Thanks Benjamin. Wondering why i need to Visual C++ 2008 . What it has to do with Python? Isn't it possible to implement your suggestion without installing Visual C++ 2008 . From tim.wintle at teamrubber.com Sun Jan 30 09:47:50 2011 From: tim.wintle at teamrubber.com (Tim Wintle) Date: Sun, 30 Jan 2011 14:47:50 +0000 Subject: Use the Source Luke In-Reply-To: References: <094f6fc5-7242-46c7-b454-4cb29d0c6ef9@q40g2000prh.googlegroups.com> <87tygs1v6g.fsf@benfinney.id.au> Message-ID: <1296398870.6379.5.camel@tim-laptop> On Sat, 2011-01-29 at 21:17 -0800, Raymond Hettinger wrote: > My thesis is that we can do even better than that by adding > direct links from the docs to the relevant code with nice > syntax highlighting. +1 - I think the source links are very useful (and thanks for pushing them). However I think the biggest changes that have probably happened with python itself are: (1) More users for whom this is their first language. (2) CS courses / training not teaching C (or pointer-based languages). (2) is especially important IMO - under half of the python developers I have regularly worked with would feel comfortable reading C - so for the other half reading C source code probably isn't going to help them understand exactly what's going on (although in the long run it might help them a lot) Tim Wintle From rantingrick at gmail.com Sun Jan 30 11:42:46 2011 From: rantingrick at gmail.com (rantingrick) Date: Sun, 30 Jan 2011 08:42:46 -0800 (PST) Subject: Use the Source Luke References: <094f6fc5-7242-46c7-b454-4cb29d0c6ef9@q40g2000prh.googlegroups.com> <87tygs1v6g.fsf@benfinney.id.au> <029f2ce4-e0fb-4cbc-a857-6cc7aa0a26f6@r4g2000vbq.googlegroups.com> <87hbcr1k38.fsf@benfinney.id.au> <4d44e750$0$29970$c3e8da3$5496439d@news.astraweb.com> <6c2ca5e4-6abe-49d5-b53f-a1d7c93ac328@r4g2000prm.googlegroups.com> <4d4526f2$0$29965$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Jan 30, 2:53?am, Steven D'Aprano wrote: > In fact, Google > themselves offer a desktop app that does just that: > > http://desktop.google.com/features.html Yes, but at the expense of your privacy! How much private information is being sent back to Google plex an used to flash more click ads at you? Well i guess we could say, google does spam us, but at least we are more likely to be *slightly* interested in the spam. From rustompmody at gmail.com Sun Jan 30 11:50:45 2011 From: rustompmody at gmail.com (rusi) Date: Sun, 30 Jan 2011 08:50:45 -0800 (PST) Subject: Use the Source Luke References: <094f6fc5-7242-46c7-b454-4cb29d0c6ef9@q40g2000prh.googlegroups.com> <87tygs1v6g.fsf@benfinney.id.au> <029f2ce4-e0fb-4cbc-a857-6cc7aa0a26f6@r4g2000vbq.googlegroups.com> <87hbcr1k38.fsf@benfinney.id.au> <4d44e750$0$29970$c3e8da3$5496439d@news.astraweb.com> Message-ID: <3a0492dc-7bbf-4458-b0a5-217d4bb87f5a@d23g2000prj.googlegroups.com> On Jan 30, 6:19?pm, David Boddie wrote: > You might find this page useful: > > http://www.wikinfo.org/index.php/Comparison_of_desktop_search_software > > David Thanks for that link David I note particularly the disclaimer that it was removed from wikipedia [Like when censors stuff you know it deserves a second look ;-) ] From rustompmody at gmail.com Sun Jan 30 12:35:33 2011 From: rustompmody at gmail.com (rusi) Date: Sun, 30 Jan 2011 09:35:33 -0800 (PST) Subject: Is it possible to pass CSV Reader Object As Argument to another Python File ??? References: <2c35653e-3565-48c6-8939-b6b09b885e3f@d23g2000prj.googlegroups.com> <876b6c52-1a6d-4afa-83e9-fa987c9359a5@v31g2000pri.googlegroups.com> <87lj272vpo.fsf@benfinney.id.au> <430714cd-20b4-4a67-bd2d-54e8f0c44ad5@s18g2000vbe.googlegroups.com> <2c9f82cd-756b-4460-940b-31e2a866f24e@n36g2000pre.googlegroups.com> <933ce06c-7829-42b9-a96d-dc9582e8267b@u11g2000prk.googlegroups.com> <558dc540-a09d-4034-b29d-c77103a341eb@m27g2000prj.googlegroups.com> Message-ID: <9584e7d1-aa0f-4ec9-988a-5c3e803bdb48@m27g2000prj.googlegroups.com> On Jan 30, 6:31?pm, bansi wrote: > On Jan 28, 4:22?pm, Benjamin Kaplan wrote: > > > You'll need to have Visual C++ 2008 (not 2010) installed for this to > > work. You can get it for free fromhttp://www.microsoft.com/express/Downloads/if > > you don't already have it. > > > Thanks Benjamin. Wondering why i need to Visual C++ 2008 . What it has > to do with Python? > Isn't it possible to implement your suggestion without installing > Visual C++ 2008 . http://code.google.com/p/pyodbc/wiki/Building#Windows From rajendra4linux at gmail.com Sun Jan 30 12:45:34 2011 From: rajendra4linux at gmail.com (Rajendra prasad Gottipati) Date: Sun, 30 Jan 2011 09:45:34 -0800 Subject: how to modify axis tick values exponential value location in matplotlib Message-ID: Hi, I am plotting the graph for long values like(267838484) so that its printing the tick lables on axes as 2.6 , 2.8 and at the top its having a text like e07 something like this, I want to move the display location of this exponent (e07) as i am having trouble in having multiple y-axis as they are getting mixed in text. like (e07 is written on top of e08 of other axis) Can any one help me in getting this done? also i am having issue in getting tick lables of x-axis while plotting with pylab.plot_date. Regards Raja -------------- next part -------------- An HTML attachment was scrubbed... URL: From gerald.britton at gmail.com Sun Jan 30 12:51:20 2011 From: gerald.britton at gmail.com (Gerald Britton) Date: Sun, 30 Jan 2011 12:51:20 -0500 Subject: Style question: Nicknames for deeply nested objects Message-ID: Hi all, Today I was thinking about a problem I often encounter. ?Say that I have (seems I often do!) a deeply nested object, by which I mean object within object with object, etc. For example: ? ?x = some.deeply.nested.object.method(some.other.deeply.nested.object.value) Well, that's extreme but I've worked with code approaching that level of nested-ness. ?Now, consider two scenarios: 1. You need to call this thing many times with different arguments, so you wind up with: ? ?x = some.deeply.nested.object.method(some.other.deeply.nested.object.value1) ? ?y = some.deeply.nested.object.method(some.other.deeply.nested.object.value2) ? ?z = some.deeply.nested.object.method(some.other.deeply.nested.object.value3) 2. You call it inside a loop: ? ?for item in some_iterable: ? ? ? ?x = some.deeply.nested.object.method(some.other.deeply.nested.object.value) For one thing, I find the long lines unattractive at best and error-prone at worst, especially if I also have ? ?some.other.deeply.nested.object.method that I might confuse with the first. ?To make it look better I might do this: ? ?_o = some.deeply.nested.object ? ?_o.method(_o.value) which is fine, I suppose. Then, putting on my company hat, I remembered that, from VBA, you could do this: ? ?with some.deeply.nested.object ? ? ? ?.method(.value) ? ?end with I like the structure of this, since the subordinate block can be indented, which makes it stand out. ?Also, it avoids temporary variables. So, I was thinking of how to get close to this in Python. ?I came up with two approaches: 1. ? ?_o = some.deeply.nested.object ? ?if 1: ? ? ? ?_o.method(_o.value) The "if 1:" forces me to indent the subordinate code, which sets it apart from the surrounding code. Note that I cannot just indent because I feel like it since Python is persnickety about indentation. 2. for _o in [some.deeply.nested.object]: ? ? ? ?_o.method(_o.value) The "for..." sets up the iterator and forces me to indent the subordinate code. As an aside, approach 1 generates less byte-code since approach 2 sets up loop machinery which you don't really need in this case. I have a couple of questions: 1. If you had to choose between approaches 1 and 2, which one would you go for, and why? 2. What other techniques have you used in such a situation? -- Gerald Britton From rajendra4linux at gmail.com Sun Jan 30 12:55:14 2011 From: rajendra4linux at gmail.com (Rajendra prasad Gottipati) Date: Sun, 30 Jan 2011 09:55:14 -0800 Subject: how to modify axis tick values exponential value location in matplotlib In-Reply-To: References: Message-ID: it seems relevant to my issue. http://stackoverflow.com/questions/3677368/matplotlib-format-axis-offset-values-to-whole-numbers-or-specific-number On Sun, Jan 30, 2011 at 9:45 AM, Rajendra prasad Gottipati < rajendra4linux at gmail.com> wrote: > Hi, > > I am plotting the graph for long values like(267838484) so that its > printing the tick lables on axes as 2.6 , 2.8 and at the top its having a > text like e07 something like this, I want to move the display location of > this exponent (e07) as i am having trouble in having multiple y-axis as they > are getting mixed in text. like (e07 is written on top of e08 of other axis) > > Can any one help me in getting this done? also i am having issue in getting > tick lables of x-axis while plotting with pylab.plot_date. > > > Regards > Raja > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rantingrick at gmail.com Sun Jan 30 13:09:33 2011 From: rantingrick at gmail.com (rantingrick) Date: Sun, 30 Jan 2011 10:09:33 -0800 (PST) Subject: Style question: Nicknames for deeply nested objects References: Message-ID: On Jan 30, 11:51?am, Gerald Britton wrote: [...] > that I might confuse with the first. ?To make it look better I might do this: > > ? ?_o = some.deeply.nested.object > ? ?_o.method(_o.value) > > which is fine, I suppose. It is very fine. And you "supposed" correctly! > Then, putting on my company hat, I remembered that, from VBA, you could do this: > > ? ?with some.deeply.nested.object > ? ? ? ?.method(.value) > ? ?end with > > I like the structure of this, since the subordinate block can be > indented, which makes it stand out. ?Also, it avoids temporary > variables. Yes it is a good idea! Well forgetting the horrendous VBA syntax this is. I brought this up many moons back as a feature request: Local Blocks. Here is how a pythonic local block would look with this as localvar: localvar.do_something() > So, I was thinking of how to get close to this in Python. ?I came up > with two approaches: > > 1. > > ? ?_o = some.deeply.nested.object > ? ?if 1: > ? ? ? ?_o.method(_o.value) bad idea! > 2. > > ? ? for _o in [some.deeply.nested.object]: > ? ? ? ?_o.method(_o.value) even worse idea! > I have a couple of questions: > > 1. If you had to choose between approaches 1 and 2, which one would > you go for, and why? neither! Stick with the original. From roy at panix.com Sun Jan 30 13:15:05 2011 From: roy at panix.com (Roy Smith) Date: Sun, 30 Jan 2011 13:15:05 -0500 Subject: Style question: Nicknames for deeply nested objects References: Message-ID: In article , Gerald Britton wrote: > 1. You need to call this thing many times with different arguments, so > you wind up with: > > ? ?x = some.deeply.nested.object.method(some.other.deeply.nested.object.value1) > ? ?y = some.deeply.nested.object.method(some.other.deeply.nested.object.value2) > ? ?z = some.deeply.nested.object.method(some.other.deeply.nested.object.value3) I would probably turn that into: object = some.deeply.nested.object object.method(object.value1) object.method(object.value2) object.method(object.value3) i.e. make the temporary variable have the exact same name as the last component of the deeply nested thing you're trying to refactor. If the scope of use is small and the meaning is obvious from context, sometimes I'll shorten the name, i.e. obj = some.deeply.nested.object or even o = some.deeply.nested.object but I tend to avoid doing that. I'd rather be a little more verbose in preference to being a little more cryptic. From me+list/python at ixokai.io Sun Jan 30 13:23:08 2011 From: me+list/python at ixokai.io (Stephen Hansen) Date: Sun, 30 Jan 2011 10:23:08 -0800 Subject: Style question: Nicknames for deeply nested objects In-Reply-To: References: Message-ID: <4D45AC8C.7090309@ixokai.io> On 1/30/11 9:51 AM, Gerald Britton wrote: > 1. If you had to choose between approaches 1 and 2, which one would > you go for, and why? Neither. Ideally, I'd tweak the API around so the deeply nested structure isn't something I need to access regularly. But! If you can't do that, I'd do something like: --- start from contextlib import contextmanager class Item(object): pass deeply = Item() deeply.nested = Item() deeply.nested.thing = Item() @contextmanager def my(thing): yield thing with my(deeply.nested.thing) as o: o.hello = 1 print deeply.nested.thing.hello --- end That's a dummy context-manager which basically does nothing: it just "abuses" the context manager protocol to basically make a local variable and indent its usage. Its really just a run-around and slightly less efficient to do: > _o = some.deeply.nested.object > _o.method(_o.value) But with the whitespace added on. Personally, I'd usually just make a local variable and skip any tricks. -- Stephen Hansen ... Also: Ixokai ... Mail: me+list/python (AT) ixokai (DOT) io ... Blog: http://meh.ixokai.io/ -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 487 bytes Desc: OpenPGP digital signature URL: From rantingrick at gmail.com Sun Jan 30 13:35:37 2011 From: rantingrick at gmail.com (rantingrick) Date: Sun, 30 Jan 2011 10:35:37 -0800 (PST) Subject: Style question: Nicknames for deeply nested objects References: Message-ID: On Jan 30, 12:23?pm, Stephen Hansen wrote: > --- start > from contextlib import contextmanager > > class Item(object): pass > > deeply = Item() > deeply.nested = Item() > deeply.nested.thing = Item() > > @contextmanager > def my(thing): > ? ? yield thing > > with my(deeply.nested.thing) as o: > ? ? o.hello = 1 > > print deeply.nested.thing.hello > --- end Well congratulations Stephen, you win the obfuscation prize of the year! From me+list/python at ixokai.io Sun Jan 30 13:53:02 2011 From: me+list/python at ixokai.io (Stephen Hansen) Date: Sun, 30 Jan 2011 10:53:02 -0800 Subject: Style question: Nicknames for deeply nested objects In-Reply-To: References: Message-ID: <4D45B38E.4030305@ixokai.io> On 1/30/11 10:35 AM, rantingrick wrote: > Well congratulations Stephen, you win the obfuscation prize of the > year! Yes, On 1/30/11 10:09 AM, rantingrick wrote: > Here is how a pythonic local block would look > > with this as localvar: > localvar.do_something() verses with my(this) as localvar: localvar.do_something() Is dreadfully more, er, obfuscated. I mean someone would have to know what the 'my' function does to understand what's going on! OH MY GOD. How can someone be expected to understand what a function does! Be serious! You can't expect that of them. -- Stephen Hansen ... Also: Ixokai ... Mail: me+list/python (AT) ixokai (DOT) io ... Blog: http://meh.ixokai.io/ -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 487 bytes Desc: OpenPGP digital signature URL: From ahsanbagwan at gmail.com Sun Jan 30 14:26:00 2011 From: ahsanbagwan at gmail.com (sl33k_) Date: Sun, 30 Jan 2011 11:26:00 -0800 (PST) Subject: Understanding def foo(*args) Message-ID: <17945aea-21b6-45b5-9c09-e602143f755e@k4g2000pre.googlegroups.com> Hi, I am struggling to grasp this concept about def foo(*args). Also, what is def bar(*args, *kwargs)? Isnt it like self must be the first parameter to the method/function? If not what are the exceptions? Also, can the terms method and function be used interchangeably? TIA From ahsanbagwan at gmail.com Sun Jan 30 14:35:34 2011 From: ahsanbagwan at gmail.com (sl33k_) Date: Sun, 30 Jan 2011 11:35:34 -0800 (PST) Subject: Understanding def foo(*args) References: <17945aea-21b6-45b5-9c09-e602143f755e@k4g2000pre.googlegroups.com> Message-ID: Sorry that parameter is **kwargs. From rantingrick at gmail.com Sun Jan 30 14:35:42 2011 From: rantingrick at gmail.com (rantingrick) Date: Sun, 30 Jan 2011 11:35:42 -0800 (PST) Subject: Understanding def foo(*args) References: <17945aea-21b6-45b5-9c09-e602143f755e@k4g2000pre.googlegroups.com> Message-ID: <27289cb5-b624-47d5-9692-06e23a034e03@b8g2000vbi.googlegroups.com> On Jan 30, 1:26?pm, sl33k_ wrote: > Hi, > > I am struggling to grasp this concept about def foo(*args). Also, what > is def bar(*args, *kwargs)? FYI: the python intepretor is your friend! py> def foo(*args): print args py> foo(1) (1,) py> foo(1,2,3) (1, 2, 3) py> foo(1,[1,23], {'hat':'cat'}) (1, [1, 23], {'hat': 'cat'}) py> def bar(*args, **kw): print 'Args:', args print 'Kwds:', kw py> bar(1,2,3, hat='cat', spam='eggs') Args: (1, 2, 3) Kwds: {'hat': 'cat', 'spam': 'eggs'} > Isnt it like self must be the first parameter to the method/function? > If not what are the exceptions? Only *must* with methods! > Also, can the terms method and function be used interchangeably? Can the terms cars and truck be used interchangeably? From mwilson at the-wire.com Sun Jan 30 14:40:29 2011 From: mwilson at the-wire.com (Mel) Date: Sun, 30 Jan 2011 14:40:29 -0500 Subject: Understanding def foo(*args) References: <17945aea-21b6-45b5-9c09-e602143f755e@k4g2000pre.googlegroups.com> Message-ID: sl33k_ wrote: > Hi, > > I am struggling to grasp this concept about def foo(*args). Also, what > is def bar(*args, *kwargs)? > > Isnt it like self must be the first parameter to the method/function? > If not what are the exceptions? > > Also, can the terms method and function be used interchangeably? > > TIA Try def foo (*args): print 'foo args:', repr (args) foo (1, 2, 3, 4) def bar (*args, **kwargs): print 'bar args:', args print 'bar kwargs:', kwargs bar (1, 2, 3, 4) bar (1, 2, 3, baz=6, boz=None) Mel. From clp2 at rebertia.com Sun Jan 30 14:54:38 2011 From: clp2 at rebertia.com (Chris Rebert) Date: Sun, 30 Jan 2011 11:54:38 -0800 Subject: Understanding def foo(*args) In-Reply-To: <17945aea-21b6-45b5-9c09-e602143f755e@k4g2000pre.googlegroups.com> References: <17945aea-21b6-45b5-9c09-e602143f755e@k4g2000pre.googlegroups.com> Message-ID: On Sun, Jan 30, 2011 at 11:26 AM, sl33k_ wrote: > Hi, > > I am struggling to grasp this concept about def foo(*args). The interactive interpreter is your friend! Try experimenting with it next time! http://docs.python.org/tutorial/controlflow.html#arbitrary-argument-lists That `def` defines a variadic function; i.e. a function which takes an arbitrary number of positional arguments. `args` will be a tuple of all the positional arguments passed to the function: >>> def foo(*args): ... print args ... >>> foo(1) (1,) >>> foo(1,2) (1, 2) >>> foo(1,2,3) (1, 2, 3) If positional parameters precede the *-parameter, then they are required and the *-parameter will receive any additional arguments: >>> def qux(a, b, *args): ... print 'a is', a ... print 'b is', b ... print 'args is', args ... >>> qux(1) Traceback (most recent call last): File "", line 1, in TypeError: qux() takes at least 2 arguments (1 given) >>> qux(1, 2) a is 1 b is 2 args is () >>> qux(1, 2, 3) a is 1 b is 2 args is (3,) >>> qux(1, 2, 3, 4) a is 1 b is 2 args is (3, 4) > Also, what is def bar(*args, *kwargs)? You meant: def bar(*args, **kwargs) See http://docs.python.org/tutorial/controlflow.html#keyword-arguments Basically, the **-parameter is like the *-parameter, except for keyword arguments instead of positional arguments. > Also, can the terms method and function be used interchangeably? No. A method is function that is associated with an object (normally via a class) and takes this object as its first argument (typically named "self"). A function does not have any of these requirements. Thus, all method are functions, but the reverse is not true. (I'm ignoring complexities like classmethods and staticmethods for simplicity.) Cheers, Chris -- http://blog.rebertia.com From doomster at knuut.de Sun Jan 30 15:21:28 2011 From: doomster at knuut.de (Ulrich Eckhardt) Date: Sun, 30 Jan 2011 21:21:28 +0100 Subject: Understanding def foo(*args) References: <17945aea-21b6-45b5-9c09-e602143f755e@k4g2000pre.googlegroups.com> Message-ID: <8qlvibFhetU1@mid.uni-berlin.de> sl33k_ wrote: > Isnt it like self must be the first parameter to the method/function? "self" is just customary as first parameter to memberfunctions, the language itself doesn't impose this convention, as e.g. C++ does with its "this". > Also, can the terms method and function be used interchangeably? This distinction doesn't exist in Python. You can put a reference to a "free" function as attribute in an object. You can store a reference to a "bound" memberfunction outside the object and call it. Objects and classes here are much more flexible than in C++ or Java. Uli From hobson42 at gmail.com Sun Jan 30 15:44:10 2011 From: hobson42 at gmail.com (Ian) Date: Sun, 30 Jan 2011 20:44:10 +0000 Subject: Style question: Nicknames for deeply nested objects In-Reply-To: References: Message-ID: <4D45CD9A.10108@gmail.com> On 30/01/2011 17:51, Gerald Britton wrote: > Hi all, > > Today I was thinking about a problem I often encounter. Say that I > have (seems I often do!) a deeply nested object, by which I mean > object within object with object, etc. > > For example: > > x = some.deeply.nested.object.method(some.other.deeply.nested.object.value) > > Well, that's extreme but I've worked with code approaching that level > of nested-ness. Now, consider two scenarios: > > 1. You need to call this thing many times with different arguments, so > you wind up with: > > x = some.deeply.nested.object.method(some.other.deeply.nested.object.value1) > y = some.deeply.nested.object.method(some.other.deeply.nested.object.value2) > z = some.deeply.nested.object.method(some.other.deeply.nested.object.value3) > Neither. You should tell. Don't ask if you can avoid it. Compare... queen.getButter() and queen.dairymaid.alderney.getButter() see http://www.timelessteacherstuff.com/readerstheater/KingsBreakfast.pdf king doesn't care where or how the butter is brought. Neither should your code! What are you doing with value1, value2 and value3 when you have them anyway? Stuffing them 3 levels deep into something else? Stop writing procedural code, and write object oriented code instead! If you you make some tell deeply.nested.object about other.deeply.nested.object it can fetch its own values, but it might be better to have some tell other.deeply.nested.object about deeply.nested.object to it can issue the correct commands. Then you tell some to do Somthing by writing some.takeMeaningfullAction() and it all happens "under the covers". Regards Ian From hayesjdno3 at yahoo.com Sun Jan 30 15:44:44 2011 From: hayesjdno3 at yahoo.com (ecu_jon) Date: Sun, 30 Jan 2011 12:44:44 -0800 (PST) Subject: homedir, file copy Message-ID: hello, i am trying to work with windows homedirectory as a starting point for some kind of file copy command. i'm testing this on a win7 box so my home is c:\Users\jon\ here is the code snippet i am working on: import os homedir = os.path.expanduser('~') try: from win32com.shell import shellcon, shell homedir = shell.SHGetFolderPath(0, shellcon.CSIDL_APPDATA, 0, 0) except ImportError: homedir = os.path.expanduser("~") print homedir print os.listdir(homedir+"\\backup\\") homedir.replace("\\\\" , "\\") print homedir shutil.copy (homedir+"\\backup\\", homedir+"\\backup2\\") output looks like: C:\Users\jon ['test1.txt', 'test2.txt'] C:\Users\jon Traceback (most recent call last): File "D:\spring 11\capstone-project\date.py", line 43, in shutil.copy (homedir+"\\backup\\", homedir+"\\backup2\\") File "C:\Python27\lib\shutil.py", line 116, in copy copyfile(src, dst) File "C:\Python27\lib\shutil.py", line 81, in copyfile with open(src, 'rb') as fsrc: IOError: [Errno 2] No such file or directory: 'C:\\Users\\jon\\backup\ \' why is there still two \\ in the pathfor the copy command? From rt8396 at gmail.com Sun Jan 30 15:55:01 2011 From: rt8396 at gmail.com (r) Date: Sun, 30 Jan 2011 12:55:01 -0800 (PST) Subject: homedir, file copy References: Message-ID: <6a5e3d0b-4aff-4008-9400-6a8a78629eb1@o18g2000prh.googlegroups.com> On Jan 30, 2:44?pm, ecu_jon wrote: > shutil.copy (homedir+"\\backup\\", homedir+"\\backup2\\") TIP: Use os.path.join(x,y, z*) > why is there still two \\ in the pathfor the copy command? I always convert my paths to use a single '/' instead of '\\'. Just makes life that much easier! From clp2 at rebertia.com Sun Jan 30 15:59:04 2011 From: clp2 at rebertia.com (Chris Rebert) Date: Sun, 30 Jan 2011 12:59:04 -0800 Subject: homedir, file copy In-Reply-To: References: Message-ID: On Sun, Jan 30, 2011 at 12:44 PM, ecu_jon wrote: > hello, > i am trying to work with windows homedirectory as a starting point for > some kind of file copy command. i'm testing this on a win7 box so my > home is c:\Users\jon\ > here is the code snippet i am working on: > > import os > > homedir = os.path.expanduser('~') > try: > ? ?from win32com.shell import shellcon, shell > ? ?homedir = shell.SHGetFolderPath(0, shellcon.CSIDL_APPDATA, 0, 0) > > except ImportError: > ? ?homedir = os.path.expanduser("~") > print homedir > print os.listdir(homedir+"\\backup\\") > homedir.replace("\\\\" , "\\") > print homedir > shutil.copy (homedir+"\\backup\\", homedir+"\\backup2\\") > > > output looks like: > C:\Users\jon > ['test1.txt', 'test2.txt'] > C:\Users\jon > > Traceback (most recent call last): > ?File "D:\spring 11\capstone-project\date.py", line 43, in > ? ?shutil.copy (homedir+"\\backup\\", homedir+"\\backup2\\") > ?File "C:\Python27\lib\shutil.py", line 116, in copy > ? ?copyfile(src, dst) > ?File "C:\Python27\lib\shutil.py", line 81, in copyfile > ? ?with open(src, 'rb') as fsrc: > IOError: [Errno 2] No such file or directory: 'C:\\Users\\jon\\backup\ > \' > > > why is there still two \\ in the pathfor the copy command? There aren't. The error message is just showing the repr() of the string, which involves escaping any literal backslashes in it; note the quotes around the path in the error message. Details on repr(): http://docs.python.org/library/functions.html#repr By way of example: >>> x = raw_input() C:\foo\bar >>> print x C:\foo\bar >>> print repr(x) 'C:\\foo\\bar' >>> print('C:\\foo\\bar') C:\foo\bar Note that you can use forward slashes instead of backslashes in Windows paths in Python, thus avoiding this confusion altogether. Cheers, Chris -- http://blog.rebertia.com From rantingrick at gmail.com Sun Jan 30 16:13:20 2011 From: rantingrick at gmail.com (rantingrick) Date: Sun, 30 Jan 2011 13:13:20 -0800 (PST) Subject: Style question: Nicknames for deeply nested objects References: Message-ID: On Jan 30, 12:53?pm, Stephen Hansen wrote: > On 1/30/11 10:35 AM, rantingrick wrote: > > > Well congratulations Stephen, you win the obfuscation prize of the > > year! > > Yes, > > On 1/30/11 10:09 AM, rantingrick wrote: > > > Here is how a pythonic local block would look > > > with this as localvar: > > ? ? localvar.do_something() > > verses > > with my(this) as localvar: > ? ? localvar.do_something() > > Is dreadfully more, er, obfuscated. Absolutely! > I mean someone would have to know what the 'my' function does to > understand what's going on! Yes, and also how decorators word and generators work, and ... > OH MY GOD. How can someone be expected to understand what a function does! Yes, and also how decorators word and generators work, and ... > Be serious! You can't expect that of them. I don't. I don't expect anyone to write 10 lines of obfuscation code when just two will suffice. Maybe you should join the perl group as they would proud! From malaclypse2 at gmail.com Sun Jan 30 16:46:03 2011 From: malaclypse2 at gmail.com (Jerry Hill) Date: Sun, 30 Jan 2011 16:46:03 -0500 Subject: Style question: Nicknames for deeply nested objects In-Reply-To: References: Message-ID: > > I don't. I don't expect anyone to write 10 lines of obfuscation code > when just two will suffice. Maybe you should join the perl group as > they would proud! But Stephen's 10 lines of somewhat obscure code actually works, and your two lines of code doesn't. I know which one I would prefer. -- Jerry -------------- next part -------------- An HTML attachment was scrubbed... URL: From steve+comp.lang.python at pearwood.info Sun Jan 30 17:02:03 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 30 Jan 2011 22:02:03 GMT Subject: Style question: Nicknames for deeply nested objects References: Message-ID: <4d45dfda$0$29967$c3e8da3$5496439d@news.astraweb.com> On Sun, 30 Jan 2011 12:51:20 -0500, Gerald Britton wrote: > Hi all, > > Today I was thinking about a problem I often encounter. ?Say that I have > (seems I often do!) a deeply nested object, by which I mean object > within object with object, etc. > > For example: > > ? ?x = > ? ?some.deeply.nested.object.method (some.other.deeply.nested.object.value) > > Well, that's extreme but I've worked with code approaching that level of > nested-ness. Then you're probably living in a state of sin, programming-wise, and you should stop doing that! You are violating the Law of Demeter. One dot, good. Two, acceptable. Three is a code smell. Four is a code reek. The Law of Demeter (more of a guideline than a law, really) says: If you want to get your dog to walk, call the dog. Don't talk to its legs, it confuses the dog and doesn't get it anywhere. http://en.wikipedia.org/wiki/Law_of_Demeter Another analogy: if you have to pay the paperboy for delivering the newspaper, you don't let him reach into your pocket, take out your wallet, open the wallet, take out whatever money he feels like, and put the wallet back. http://www.ccs.neu.edu/research/demeter/demeter-method/LawOfDemeter/paper- boy/demeter.pdf Despite my comment above, the Law of Demeter is not *really* a dot- counting exercise, although that's a handy short-cut for detecting potential problems. It can also apply to other data structures. If you've every seen C or Pascal code where you have a pointer to a pointer to a pointer to a pointer to a pointer to a pointer to some data, you've seen a violation. Consider your example: some.other.deeply.nested.object.value This is very tightly coupled code: the caller, who knows about the object `some`, needs to know the internal details of not just `some` but also `other`, `deeply`, `nested`, and `object`. As a basic principle, this is poor design! Which would you rather deal with? car.start() car.ignition.turn(key).connect(car.starter(battery), car.spark_plug) In particular, using temporary variables merely disguises the problem: temp = some.other temp = temp.deeply.nested x = temp.object.value Even though you never use more than two dots, you still have tight coupling. The point of Demeter is not to save dots (they're a renewable resource) but to reduce tight coupling. -- Steven From ben+python at benfinney.id.au Sun Jan 30 17:08:23 2011 From: ben+python at benfinney.id.au (Ben Finney) Date: Mon, 31 Jan 2011 09:08:23 +1100 Subject: Understanding def foo(*args) References: <17945aea-21b6-45b5-9c09-e602143f755e@k4g2000pre.googlegroups.com> Message-ID: <87oc6yyrhk.fsf@benfinney.id.au> sl33k_ writes: > I am struggling to grasp this concept about def foo(*args). Also, what > is def bar(*args, *kwargs)? Please work through the Python Tutorial from start to finish , performing each exercise and experimenting with it until you understand. You will then have a good grounding in basics of the language like this. -- \ Lucifer: ?Just sign the Contract, sir, and the Piano is yours.? | `\ Ray: ?Sheesh! This is long! Mind if I sign it now and read it | _o__) later?? ?http://www.achewood.com/ | Ben Finney From hayesjdno3 at yahoo.com Sun Jan 30 18:13:01 2011 From: hayesjdno3 at yahoo.com (ecu_jon) Date: Sun, 30 Jan 2011 15:13:01 -0800 (PST) Subject: homedir, file copy References: <6a5e3d0b-4aff-4008-9400-6a8a78629eb1@o18g2000prh.googlegroups.com> Message-ID: On Jan 30, 3:55?pm, r wrote: > On Jan 30, 2:44?pm, ecu_jon wrote: > > > shutil.copy (homedir+"\\backup\\", homedir+"\\backup2\\") > > TIP: Use os.path.join(x,y, z*) > > > why is there still two \\ in the pathfor the copy command? > > I always convert my paths to use a single '/' instead of '\\'. Just > makes life that much easier! what does this mean? Use os.path.join(x,y, z*) what is the x,y,z? From clp2 at rebertia.com Sun Jan 30 18:23:28 2011 From: clp2 at rebertia.com (Chris Rebert) Date: Sun, 30 Jan 2011 15:23:28 -0800 Subject: homedir, file copy In-Reply-To: References: <6a5e3d0b-4aff-4008-9400-6a8a78629eb1@o18g2000prh.googlegroups.com> Message-ID: On Sun, Jan 30, 2011 at 3:13 PM, ecu_jon wrote: > On Jan 30, 3:55?pm, r wrote: >> On Jan 30, 2:44?pm, ecu_jon wrote: >> >> > shutil.copy (homedir+"\\backup\\", homedir+"\\backup2\\") >> >> TIP: Use os.path.join(x,y, z*) >> >> > why is there still two \\ in the pathfor the copy command? >> >> I always convert my paths to use a single '/' instead of '\\'. Just >> makes life that much easier! > > what does this mean? ?Use os.path.join(x,y, z*) > what is the x,y,z? See http://docs.python.org/library/os.path.html#os.path.join e.g. in your case: backupdir = os.path.join(homedir, "backup") Cheers, Chris From rantingrick at gmail.com Sun Jan 30 18:36:13 2011 From: rantingrick at gmail.com (rantingrick) Date: Sun, 30 Jan 2011 15:36:13 -0800 (PST) Subject: homedir, file copy References: <6a5e3d0b-4aff-4008-9400-6a8a78629eb1@o18g2000prh.googlegroups.com> Message-ID: <421cfc90-c1dc-4f3c-82ac-74b43212a128@k14g2000pre.googlegroups.com> On Jan 30, 5:13?pm, ecu_jon wrote: > what does this mean? ?Use os.path.join(x,y, z*) > what is the x,y,z? x,y, and z in this case are just generic variables. Consider x+y=10. x and y could both equal 5 or any number of combinations of two numbers who sum equals ten. Anyway see the link chris posted to the docs or fire up your python shell and try this... >>> import sys >>> sys.version_info (2, 6, 5, 'final', 0) # yours may be different! >>> folder = 'C:/some\\\\path/to/folder' >>> filename = 'somefile.txt' >>> import os >>> help(os.path.join) Help on function join in module ntpath: join(a, *p) Join two or more pathname components, inserting "\" as needed. If any component is an absolute path, all previous path components will be discarded. >>> os.path.join(folder, filename) 'C:/some\\\\path/to/folder\\somefile.txt' >>> help(os.path.normpath) Help on function normpath in module ntpath: normpath(path) Normalize path, eliminating double slashes, etc. >>> os.path.normpath(os.path.join(folder, filename)) 'C:\\some\\path\\to\\folder\\somefile.txt' psst: i know what you're thinking... and yes, python is very cool! From hayesjdno3 at yahoo.com Sun Jan 30 18:43:47 2011 From: hayesjdno3 at yahoo.com (ecu_jon) Date: Sun, 30 Jan 2011 15:43:47 -0800 (PST) Subject: homedir, file copy References: <6a5e3d0b-4aff-4008-9400-6a8a78629eb1@o18g2000prh.googlegroups.com> Message-ID: <46bc3145-5df4-4146-b861-a9ac98722a99@q7g2000vbd.googlegroups.com> ok now i get permission denied.... import os homedir = os.path.expanduser('~') try: from win32com.shell import shellcon, shell homedir = shell.SHGetFolderPath(0, shellcon.CSIDL_APPDATA, 0, 0) except ImportError: homedir = os.path.expanduser("~") print homedir print os.listdir(homedir+"\\backup\\") #homedir.replace("\\\\" , "\\") #print homedir backupdir1 = os.path.join(homedir, "backup") backupdir2 = os.path.join(homedir, "backup2") shutil.copy (backupdir1, backupdir2) From rantingrick at gmail.com Sun Jan 30 18:50:09 2011 From: rantingrick at gmail.com (rantingrick) Date: Sun, 30 Jan 2011 15:50:09 -0800 (PST) Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com> <9MB%o.14110$%64.6074@unlimited.newshosting.com> <4A48EDF6D7634F2E994661A457451E87@teddy> <753A4C5A6658470085804B13C80340F2@octavian> <4D41B5AF.8020200@ixokai.io> <4D41BCC2.2060906@tysdomain.com> Message-ID: <5229651a-f240-4d43-87c4-63e49b23e6e5@y3g2000vbh.googlegroups.com> On Jan 28, 9:15?am, "Littlefield, Tyler" wrote: > > If you want to rant and scream about accessibility, yell at the > people charging an arm and a leg to make things accessible. > You make a good point as we could always use more opensource, free, and reasonably priced software. However unless the GUI library in question supports accessibility, it really won't matter how much the tool costs if you cannot use it! Consider if automobiles were free however gasoline was obsolete. -- rr: spreading common sense like an incurable virus. From python at mrabarnett.plus.com Sun Jan 30 19:09:10 2011 From: python at mrabarnett.plus.com (MRAB) Date: Mon, 31 Jan 2011 00:09:10 +0000 Subject: homedir, file copy In-Reply-To: <46bc3145-5df4-4146-b861-a9ac98722a99@q7g2000vbd.googlegroups.com> References: <6a5e3d0b-4aff-4008-9400-6a8a78629eb1@o18g2000prh.googlegroups.com> <46bc3145-5df4-4146-b861-a9ac98722a99@q7g2000vbd.googlegroups.com> Message-ID: <4D45FDA6.2060401@mrabarnett.plus.com> On 30/01/2011 23:43, ecu_jon wrote: > ok now i get permission denied.... > > import os > homedir = os.path.expanduser('~') > try: > from win32com.shell import shellcon, shell > homedir = shell.SHGetFolderPath(0, shellcon.CSIDL_APPDATA, 0, 0) > > except ImportError: > homedir = os.path.expanduser("~") > print homedir > print os.listdir(homedir+"\\backup\\") > #homedir.replace("\\\\" , "\\") > #print homedir > backupdir1 = os.path.join(homedir, "backup") > backupdir2 = os.path.join(homedir, "backup2") > shutil.copy (backupdir1, backupdir2) > shutil.copy(...) copies files, not directories. You should use shutil.copytree(...) instead. From hayesjdno3 at yahoo.com Sun Jan 30 19:18:52 2011 From: hayesjdno3 at yahoo.com (ecu_jon) Date: Sun, 30 Jan 2011 16:18:52 -0800 (PST) Subject: homedir, file copy References: <6a5e3d0b-4aff-4008-9400-6a8a78629eb1@o18g2000prh.googlegroups.com> <46bc3145-5df4-4146-b861-a9ac98722a99@q7g2000vbd.googlegroups.com> Message-ID: <400ab1ce-8f15-4708-b3de-408bc0765940@i40g2000yqh.googlegroups.com> On Jan 30, 7:09?pm, MRAB wrote: > On 30/01/2011 23:43, ecu_jon wrote: > > > ok now i get permission denied.... > > > import os > > homedir = os.path.expanduser('~') > > try: > > ? ? ?from win32com.shell import shellcon, shell > > ? ? ?homedir = shell.SHGetFolderPath(0, shellcon.CSIDL_APPDATA, 0, 0) > > > except ImportError: > > ? ? ?homedir = os.path.expanduser("~") > > print homedir > > print os.listdir(homedir+"\\backup\\") > > #homedir.replace("\\\\" , "\\") > > #print homedir > > backupdir1 = os.path.join(homedir, "backup") > > backupdir2 = os.path.join(homedir, "backup2") > > shutil.copy (backupdir1, backupdir2) > > shutil.copy(...) copies files, not directories. You should use > shutil.copytree(...) instead. i will, closer towards the end. just wanted to get past the naming stuff, the problem above. right now i just want to see it move files from 1 place to another. i had copytree in before, and will go back to that for final version. im working on a backup program, and copytree looks yummy. still no idea why getting permission denied. From davea at ieee.org Sun Jan 30 19:19:51 2011 From: davea at ieee.org (Dave Angel) Date: Sun, 30 Jan 2011 19:19:51 -0500 Subject: homedir, file copy In-Reply-To: <46bc3145-5df4-4146-b861-a9ac98722a99@q7g2000vbd.googlegroups.com> References: <6a5e3d0b-4aff-4008-9400-6a8a78629eb1@o18g2000prh.googlegroups.com> <46bc3145-5df4-4146-b861-a9ac98722a99@q7g2000vbd.googlegroups.com> Message-ID: <4D460027.1030208@ieee.org> On 01/-10/-28163 02:59 PM, ecu_jon wrote: > ok now i get permission denied.... > > import os > homedir = os.path.expanduser('~') > try: > from win32com.shell import shellcon, shell > homedir = shell.SHGetFolderPath(0, shellcon.CSIDL_APPDATA, 0, 0) > > except ImportError: > homedir = os.path.expanduser("~") > print homedir > print os.listdir(homedir+"\\backup\\") > #homedir.replace("\\\\" , "\\") > #print homedir > backupdir1 = os.path.join(homedir, "backup") > backupdir2 = os.path.join(homedir, "backup2") > shutil.copy (backupdir1, backupdir2) > You forgot to include the error traceback. So, is homedir/backup a file, or is it a directory? If you're trying to copy whole directories, you might want to look at copytree instead. If you're not sure, you could use os.isfile() to check. If that's false, then shutil.copy() can't work. Similarly, if the destination is a readonly file, you'd get some error. DaveA From hayesjdno3 at yahoo.com Sun Jan 30 19:27:42 2011 From: hayesjdno3 at yahoo.com (ecu_jon) Date: Sun, 30 Jan 2011 16:27:42 -0800 (PST) Subject: homedir, file copy References: <6a5e3d0b-4aff-4008-9400-6a8a78629eb1@o18g2000prh.googlegroups.com> <46bc3145-5df4-4146-b861-a9ac98722a99@q7g2000vbd.googlegroups.com> Message-ID: <6aa5e10b-6fa8-45ec-89d5-d9bece804bde@c10g2000vbv.googlegroups.com> On Jan 30, 7:19?pm, Dave Angel wrote: > On 01/-10/-28163 02:59 PM, ecu_jon wrote: > > > ok now i get permission denied.... > > > import os > > homedir = os.path.expanduser('~') > > try: > > ? ? ?from win32com.shell import shellcon, shell > > ? ? ?homedir = shell.SHGetFolderPath(0, shellcon.CSIDL_APPDATA, 0, 0) > > > except ImportError: > > ? ? ?homedir = os.path.expanduser("~") > > print homedir > > print os.listdir(homedir+"\\backup\\") > > #homedir.replace("\\\\" , "\\") > > #print homedir > > backupdir1 = os.path.join(homedir, "backup") > > backupdir2 = os.path.join(homedir, "backup2") > > shutil.copy (backupdir1, backupdir2) > > You forgot to include the error traceback. > > So, is homedir/backup a file, or is it a directory? ?If you're trying to > copy whole directories, you might want to look at copytree instead. > > If you're not sure, you could use > ? ? ?os.isfile() > > to check. ?If that's false, then shutil.copy() can't work. ?Similarly, > if the destination is a readonly file, you'd get some error. > > DaveA today's date is : 30 week chosen is : 4 C:\Users\jon ['test1.txt', 'test2.txt'] Traceback (most recent call last): File "D:\spring 11\capstone-project\date.py", line 45, in shutil.copy (backupdir1, backupdir2) File "C:\Python27\lib\shutil.py", line 116, in copy copyfile(src, dst) File "C:\Python27\lib\shutil.py", line 81, in copyfile with open(src, 'rb') as fsrc: IOError: [Errno 13] Permission denied: 'C:\\Users\\jon\\backup' From nambo4jb at gmail.com Sun Jan 30 19:28:40 2011 From: nambo4jb at gmail.com (Cathy James) Date: Sun, 30 Jan 2011 18:28:40 -0600 Subject: MS Access table values as input into a formula in another table-need help!! Message-ID: Dear Python Community, Table1: Prop_codeR_Value GC 0.8 CI 0.6 LDR 0.4 HDR 0.6 TR 0.65 CR 0.35 Table 2: O_ID PROP_CODE AI TArea R_Value Pre_R_Value IR MER02006 LDR 38.19235 132.3178 0.4 0.115456 0.555143 MER02006 TR 20.78983 132.3178 0.65 0.102128 0.555143 MER02006 UO 1.850129 132.3178 0.25 0.003496 0.555143 MER03001 GC 16.565 137.592 0.8 0.096314 0.45027 Initially, I manually entered R_Value from table 1 into table 2 in order to later compute subsequent fields using Python. Now I?d like to make the process a bit more automatic. I would like to get R_Values for each Prop_Code from table 1 into table 2 so that I can use them in a Table2 computation later on. I was thinking maybe a putting table 1 into a dict then use those values in table 2, but I need help getting started. Just learning Python and dicts are still tricky for me. Please help me modify the code below so that i don't have to repeat the lines of code below for all values of Prop_Code: import arcpy,sys arcpy.env.workspace = "C:\\test\\DRAINAGE.mdb" Table1= "basins" Table2="CV_Table" cur = arcpy.UpdateCursor(table2, "[PROP_CODE] = 'LDR'") row = cur.next() # Perform the update and move to the next row as long as there are # rows left while row: row.R_Value = 0 #initialize field from nulls to zero values row.R_Value = 0.4 #INstead, I need to get this from Table 2 cur.updateRow(row) row = cur.next() # Delete the cursors to remove any data locks del row, cur THANKS!! -------------- next part -------------- An HTML attachment was scrubbed... URL: From rantingrick at gmail.com Sun Jan 30 19:34:20 2011 From: rantingrick at gmail.com (rantingrick) Date: Sun, 30 Jan 2011 16:34:20 -0800 (PST) Subject: homedir, file copy References: <6a5e3d0b-4aff-4008-9400-6a8a78629eb1@o18g2000prh.googlegroups.com> <46bc3145-5df4-4146-b861-a9ac98722a99@q7g2000vbd.googlegroups.com> Message-ID: <9f3075db-d984-4097-ba49-d4c82a689255@k18g2000vbq.googlegroups.com> On Jan 30, 5:43?pm, ecu_jon wrote: > ok now i get permission denied.... [...] > shutil.copy (backupdir1, backupdir2) I must stress the importance of proper testing before ever running code that manipulates files! So many things can go wrong. Of course you are just copying files here and not deleting them however you must always be in the habit of treating files like explosives. And frankly you're being quite nonchalant with this very naive approach to coding and complete lack of testing. When handling files always test, test, test. Never actually move, copy, or delete until you are *absolutely* sure no failures will occur. I will always do test runs that print out the action but DO NOT actually DO the action, like... Copying files: -- from: C:\\somefile1 to: C:\\blah\\somefile1 -- from: C:\\somefile2 to: C:\\blah\\somefile2 -- from: C:\\somefile3 to: C:\\blah\\somefile3 -- etc... Once my test runs are bug free i can try to move or delete *one* file from some test set. Once that is bug free then i will try the code on many files of a test set, and ONLY THEN on the real thing. I guarantee if you keep manipulating files in such a haphazard way you will live to regret it! From hayesjdno3 at yahoo.com Sun Jan 30 19:43:10 2011 From: hayesjdno3 at yahoo.com (ecu_jon) Date: Sun, 30 Jan 2011 16:43:10 -0800 (PST) Subject: homedir, file copy References: <6a5e3d0b-4aff-4008-9400-6a8a78629eb1@o18g2000prh.googlegroups.com> <46bc3145-5df4-4146-b861-a9ac98722a99@q7g2000vbd.googlegroups.com> <9f3075db-d984-4097-ba49-d4c82a689255@k18g2000vbq.googlegroups.com> Message-ID: On Jan 30, 7:34?pm, rantingrick wrote: > On Jan 30, 5:43?pm, ecu_jon wrote: > > > ok now i get permission denied.... > > [...] > > > shutil.copy (backupdir1, backupdir2) > > I must stress the importance of proper testing before ever running > code that manipulates files! So many things can go wrong. Of course > you are just copying files here and not deleting them however you must > always be in the habit of treating files like explosives. And frankly > you're being quite nonchalant with this very naive approach to coding > and complete lack of testing. > > When handling files always test, test, test. Never actually move, > copy, or delete until you are *absolutely* sure no failures will > occur. I will always do test runs that print out the action but DO NOT > actually DO the action, like... > > Copying files: > ?-- from: C:\\somefile1 > ? ? ? to: C:\\blah\\somefile1 > ?-- from: C:\\somefile2 > ? ? ? to: C:\\blah\\somefile2 > ?-- from: C:\\somefile3 > ? ? ? to: C:\\blah\\somefile3 > ?-- etc... > > Once my test runs are bug free i can try to move or delete *one* file > from some test set. Once that is bug free then i will try the code on > many files of a test set, and ONLY THEN on the real thing. I guarantee > if you keep manipulating files in such a haphazard way you will live > to regret it! not nonchalant. i know i will ned to do testing and whatnot. just personally, i like to build stuff one concept at a time. for example, i had a problem with the homedir and peopel here helped me with that. now i have permissions problem, and an swer will likely meeerge. once i know how to copy a file, ill work on testing. like isfile and permissions. i know that has to be done. i guess its that you want tests before moves , and thats fine. since i have only ever had 1 python class, and basically learning this whole thing from scratch, i need to do things 1 step at a time. so now any thoughts on why i cannot write to my own homedir? From anikom15 at gmail.com Sun Jan 30 19:51:16 2011 From: anikom15 at gmail.com (Westley =?ISO-8859-1?Q?Mart=EDnez?=) Date: Sun, 30 Jan 2011 16:51:16 -0800 Subject: homedir, file copy In-Reply-To: References: <6a5e3d0b-4aff-4008-9400-6a8a78629eb1@o18g2000prh.googlegroups.com> <46bc3145-5df4-4146-b861-a9ac98722a99@q7g2000vbd.googlegroups.com> <9f3075db-d984-4097-ba49-d4c82a689255@k18g2000vbq.googlegroups.com> Message-ID: <1296435076.6394.6.camel@localhost.localdomain> It seems like you are trying to copy directories with shutil.copy. Use shutil.copytree instead. On Sun, 2011-01-30 at 16:43 -0800, ecu_jon wrote: > On Jan 30, 7:34 pm, rantingrick wrote: > > On Jan 30, 5:43 pm, ecu_jon wrote: > > > > > ok now i get permission denied.... > > > > [...] > > > > > shutil.copy (backupdir1, backupdir2) > > > > I must stress the importance of proper testing before ever running > > code that manipulates files! So many things can go wrong. Of course > > you are just copying files here and not deleting them however you must > > always be in the habit of treating files like explosives. And frankly > > you're being quite nonchalant with this very naive approach to coding > > and complete lack of testing. > > > > When handling files always test, test, test. Never actually move, > > copy, or delete until you are *absolutely* sure no failures will > > occur. I will always do test runs that print out the action but DO NOT > > actually DO the action, like... > > > > Copying files: > > -- from: C:\\somefile1 > > to: C:\\blah\\somefile1 > > -- from: C:\\somefile2 > > to: C:\\blah\\somefile2 > > -- from: C:\\somefile3 > > to: C:\\blah\\somefile3 > > -- etc... > > > > Once my test runs are bug free i can try to move or delete *one* file > > from some test set. Once that is bug free then i will try the code on > > many files of a test set, and ONLY THEN on the real thing. I guarantee > > if you keep manipulating files in such a haphazard way you will live > > to regret it! > > not nonchalant. > i know i will ned to do testing and whatnot. > just personally, i like to build stuff one concept at a time. > for example, i had a problem with the homedir and peopel here helped > me with that. > now i have permissions problem, and an swer will likely meeerge. > once i know how to copy a file, ill work on testing. like isfile and > permissions. > i know that has to be done. i guess its that you want tests before > moves , and thats fine. > since i have only ever had 1 python class, and basically learning this > whole thing from scratch, i need to do things 1 step at a time. > so now any thoughts on why i cannot write to my own homedir? -------------- next part -------------- An HTML attachment was scrubbed... URL: From python at mrabarnett.plus.com Sun Jan 30 20:25:43 2011 From: python at mrabarnett.plus.com (MRAB) Date: Mon, 31 Jan 2011 01:25:43 +0000 Subject: homedir, file copy In-Reply-To: <400ab1ce-8f15-4708-b3de-408bc0765940@i40g2000yqh.googlegroups.com> References: <6a5e3d0b-4aff-4008-9400-6a8a78629eb1@o18g2000prh.googlegroups.com> <46bc3145-5df4-4146-b861-a9ac98722a99@q7g2000vbd.googlegroups.com> <400ab1ce-8f15-4708-b3de-408bc0765940@i40g2000yqh.googlegroups.com> Message-ID: <4D460F97.60306@mrabarnett.plus.com> On 31/01/2011 00:18, ecu_jon wrote: > On Jan 30, 7:09 pm, MRAB wrote: >> On 30/01/2011 23:43, ecu_jon wrote: >> >>> ok now i get permission denied.... >> >>> import os >>> homedir = os.path.expanduser('~') >>> try: >>> from win32com.shell import shellcon, shell >>> homedir = shell.SHGetFolderPath(0, shellcon.CSIDL_APPDATA, 0, 0) >> >>> except ImportError: >>> homedir = os.path.expanduser("~") >>> print homedir >>> print os.listdir(homedir+"\\backup\\") >>> #homedir.replace("\\\\" , "\\") >>> #print homedir >>> backupdir1 = os.path.join(homedir, "backup") >>> backupdir2 = os.path.join(homedir, "backup2") >>> shutil.copy (backupdir1, backupdir2) >> >> shutil.copy(...) copies files, not directories. You should use >> shutil.copytree(...) instead. > > i will, closer towards the end. > just wanted to get past the naming stuff, the problem above. > right now i just want to see it move files from 1 place to another. > i had copytree in before, and will go back to that for final version. > im working on a backup program, and copytree looks yummy. > > still no idea why getting permission denied. The path given by backupdir1 is a directory, so you're trying to use shutil.copy(...) to copy a directory. The reason that it's complaining about permissions is that shutil.copy is trying to open the source file (look at the traceback) so that it can copy the file's contents, but it's not a file, it's a directory. CPython is written in C, so it's probably the underlying C library which is reporting it as a permissions problem instead of a "that's not a file!" problem. :-) From rustompmody at gmail.com Sun Jan 30 21:20:49 2011 From: rustompmody at gmail.com (rusi) Date: Sun, 30 Jan 2011 18:20:49 -0800 (PST) Subject: Is it possible to pass CSV Reader Object As Argument to another Python File ??? References: <2c35653e-3565-48c6-8939-b6b09b885e3f@d23g2000prj.googlegroups.com> <876b6c52-1a6d-4afa-83e9-fa987c9359a5@v31g2000pri.googlegroups.com> <87lj272vpo.fsf@benfinney.id.au> <430714cd-20b4-4a67-bd2d-54e8f0c44ad5@s18g2000vbe.googlegroups.com> <2c9f82cd-756b-4460-940b-31e2a866f24e@n36g2000pre.googlegroups.com> <933ce06c-7829-42b9-a96d-dc9582e8267b@u11g2000prk.googlegroups.com> <558dc540-a09d-4034-b29d-c77103a341eb@m27g2000prj.googlegroups.com> <9584e7d1-aa0f-4ec9-988a-5c3e803bdb48@m27g2000prj.googlegroups.com> Message-ID: On Jan 30, 10:35?pm, rusi wrote: > On Jan 30, 6:31?pm, bansi wrote: > > Isn't it possible to implement your suggestion without installing > > Visual C++ 2008 . > > http://code.google.com/p/pyodbc/wiki/Building#Windows Well... This is what the official site says... On second thoughts I wonder: Would it not be possible to compile python +pyodbc from source and use gcc/ming for that? Someone who knows more of the windows build process may say something about the issues involved. From hayesjdno3 at yahoo.com Sun Jan 30 21:41:54 2011 From: hayesjdno3 at yahoo.com (ecu_jon) Date: Sun, 30 Jan 2011 18:41:54 -0800 (PST) Subject: homedir, file copy References: <6a5e3d0b-4aff-4008-9400-6a8a78629eb1@o18g2000prh.googlegroups.com> <46bc3145-5df4-4146-b861-a9ac98722a99@q7g2000vbd.googlegroups.com> <400ab1ce-8f15-4708-b3de-408bc0765940@i40g2000yqh.googlegroups.com> Message-ID: <8b2ac4c3-e787-4e69-bc93-5793c4e85008@m13g2000yqb.googlegroups.com> On Jan 30, 8:25?pm, MRAB wrote: > On 31/01/2011 00:18, ecu_jon wrote: > > > > > On Jan 30, 7:09 pm, MRAB ?wrote: > >> On 30/01/2011 23:43, ecu_jon wrote: > > >>> ok now i get permission denied.... > > >>> import os > >>> homedir = os.path.expanduser('~') > >>> try: > >>> ? ? ? from win32com.shell import shellcon, shell > >>> ? ? ? homedir = shell.SHGetFolderPath(0, shellcon.CSIDL_APPDATA, 0, 0) > > >>> except ImportError: > >>> ? ? ? homedir = os.path.expanduser("~") > >>> print homedir > >>> print os.listdir(homedir+"\\backup\\") > >>> #homedir.replace("\\\\" , "\\") > >>> #print homedir > >>> backupdir1 = os.path.join(homedir, "backup") > >>> backupdir2 = os.path.join(homedir, "backup2") > >>> shutil.copy (backupdir1, backupdir2) > > >> shutil.copy(...) copies files, not directories. You should use > >> shutil.copytree(...) instead. > > > i will, closer towards the end. > > just wanted to get past the naming stuff, the problem above. > > right now i just want to see it move files from 1 place to another. > > i had copytree in before, and will go back to that for final version. > > im working on a backup program, and copytree looks yummy. > > > still no idea why getting permission denied. > > The path given by backupdir1 is a directory, so you're trying to use > shutil.copy(...) to copy a directory. > > The reason that it's complaining about permissions is that shutil.copy > is trying to open the source file (look at the traceback) so that it > can copy the file's contents, but it's not a file, it's a directory. > > CPython is written in C, so it's probably the underlying C library > which is reporting it as a permissions problem instead of a "that's not > a file!" problem. :-) as for testing i was planning on using something like this http://docs.python.org/library/shutil.html scroll down to 10.10.1.1 From s.sanadhya at gmail.com Sun Jan 30 21:43:29 2011 From: s.sanadhya at gmail.com (Shruti Sanadhya) Date: Sun, 30 Jan 2011 21:43:29 -0500 Subject: Limit on entries in dictionary data structure Message-ID: Hi, I am running a script that uses dictionaries on Python 2.6.4 on Ubuntu 9.10. I notice that my script crashes with a MemoryError when my dictionary reaches 44739243th entry. My system has 3GB RAM (32-bit). I noticed that changing the key or value types also did not help my code. For simplicity I tried running this: #BEGIN:python code import sys f={} lsize=0 try: for k in range(0,4*44739243): f[k]=k if sys.getsizeof(f) > lsize: lsize = sys.getsizeof(f) print k, lsize except: print k, lsize raise #END:python code The code terminates with: "Traceback (most recent call last): File "pydict-limit.py", line 6, in f[k]=k MemoryError" I have also tried running this on Ubuntu 9.10 with Python 2.6.6 with 3.5GB RAM(32-bit) and a 64-bit LINUX cluster machine with 62GB RAM and Python 2.4. On both these machines it crashed at entry 44739243. The size of the data structure grows to 1.5GB. On another 64-bit cluster machine with 32GB RAM and Python 2.6.6 it crashed at entry 178956970. In this case the size of the data structure grew to 6GB. Has anybody encountered this before? Can somebody suggest any fix for this? I am trying to read some 10GB network traces into a hash table(hence dictionary) and need constant time lookup. Clearly increasing the machine RAM does not work. Any suggestions would be greatly appreciated. Thanks, Shruti -------------- next part -------------- An HTML attachment was scrubbed... URL: From me+list/python at ixokai.io Sun Jan 30 21:53:03 2011 From: me+list/python at ixokai.io (Stephen Hansen) Date: Sun, 30 Jan 2011 18:53:03 -0800 Subject: Style question: Nicknames for deeply nested objects In-Reply-To: References: Message-ID: <4D46240F.20705@ixokai.io> On 1/30/11 1:13 PM, rantingrick wrote: > On Jan 30, 12:53 pm, Stephen Hansen wrote: >> OH MY GOD. How can someone be expected to understand what a function does! > > Yes, and also how decorators word and generators work, and ... > >> Be serious! You can't expect that of them. > > I don't. I don't expect anyone to write 10 lines of obfuscation code > when just two will suffice. Maybe you should join the perl group as > they would proud! Riiight. "suffice" doesn't mean what you think it means. Generally, if something suffices -- it actually, you know, ... works. My four lines of setup can get put into a library and treated as a recipe if they don't want to get into understanding generators or decorators: then its two lines to use, and those two lines are exactly like your two lines except for two little details: 1. They add a function call to the syntax. 2. They actually work. The OP doesn't have to understand decorators or generators if he doesn't want to: though I encourage him to do so, as they are beautiful and elegant tools that can very clearly and concisely help solve a lot of problems. Now, me? I wouldn't use the recipe, as I originally said in my response. I'd just use a local variable. But the OP didn't like that, and he wanted some indenting and whitespace to clearly demarcate where he intended to use the local. So I gave him a way to do that. You gave him... uh, what was it again? Oh, right. Nothing. As usual. -- Stephen Hansen ... Also: Ixokai ... Mail: me+list/python (AT) ixokai (DOT) io ... Blog: http://meh.ixokai.io/ -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 487 bytes Desc: OpenPGP digital signature URL: From davea at ieee.org Sun Jan 30 21:55:19 2011 From: davea at ieee.org (Dave Angel) Date: Sun, 30 Jan 2011 21:55:19 -0500 Subject: homedir, file copy In-Reply-To: <6aa5e10b-6fa8-45ec-89d5-d9bece804bde@c10g2000vbv.googlegroups.com> References: <6a5e3d0b-4aff-4008-9400-6a8a78629eb1@o18g2000prh.googlegroups.com> <46bc3145-5df4-4146-b861-a9ac98722a99@q7g2000vbd.googlegroups.com> <6aa5e10b-6fa8-45ec-89d5-d9bece804bde@c10g2000vbv.googlegroups.com> Message-ID: <4D462497.5020008@ieee.org> On 01/-10/-28163 02:59 PM, ecu_jon wrote: > On Jan 30, 7:19 pm, Dave Angel wrote: >> On 01/-10/-28163 02:59 PM, ecu_jon wrote: >> >>> ok now i get permission denied.... >> >>> import os >>> homedir =s.path.expanduser('~') >>> try: >>> from win32com.shell import shellcon, shell >>> homedir =hell.SHGetFolderPath(0, shellcon.CSIDL_APPDATA, 0, 0) >> >>> except ImportError: >>> homedir =s.path.expanduser("~") >>> print homedir >>> print os.listdir(homedir+"\\backup\\") >>> #homedir.replace("\\\\" , "\\") >>> #print homedir >>> backupdir1 =s.path.join(homedir, "backup") >>> backupdir2 =s.path.join(homedir, "backup2") >>> shutil.copy (backupdir1, backupdir2) >> >> You forgot to include the error traceback. >> >> So, is homedir/backup a file, or is it a directory? If you're trying to >> copy whole directories, you might want to look at copytree instead. >> >> If you're not sure, you could use >> os.isfile() >> >> to check. If that's false, then shutil.copy() can't work. Similarly, >> if the destination is a readonly file, you'd get some error. >> >> DaveA > > today's date is : 30 > week chosen is : 4 > C:\Users\jon > ['test1.txt', 'test2.txt'] > > Traceback (most recent call last): > File "D:\spring 11\capstone-project\date.py", line 45, in > shutil.copy (backupdir1, backupdir2) > File "C:\Python27\lib\shutil.py", line 116, in copy > copyfile(src, dst) > File "C:\Python27\lib\shutil.py", line 81, in copyfile > with open(src, 'rb') as fsrc: > IOError: [Errno 13] Permission denied: 'C:\\Users\\jon\\backup' > Good job, reading the first part of my message. Now, why are you saying in other messages that it can't write to your home directory? The error doesn't refer to your home directory, it refers to a file C:\Users\jon\backup which it can't read. But as your program demonstrates, that's a directory not a file. It's fine to use shutil.copy, but then you have to give it a source file to copy. For example, C:\Users\jon\backup\test1.txt DaveA From patty at cruzio.com Sun Jan 30 21:57:20 2011 From: patty at cruzio.com (Patty) Date: Sun, 30 Jan 2011 18:57:20 -0800 Subject: multiple values for keyword argument Message-ID: <91095C6A226E4A80A4721FD62828CD79@mycomputer> Well - this is all timely email. I just spent the day configuring my HP mini netbook running Windows 7 with all the right software based on recomendations from folks on this list, from the Python Tutor list and an email group of former colleagues where I spelled out exactly all the programming languages and stuff I ideally wanted. It has been very enlightening and actually not so difficult! Asking pays off! And I made a few realizations - I had some misperceptions about some software packages and -- I had been thinking about this 'self' business since yesterday. And you and Ethan and Ben Finney from yesterday (the last email msg I read last night, might know) are right -- I was being stubborn and wanting to do things *my* way and I was telling myself that when it comes time to do this for a future employer, well I will just change my code in the appropriate places to 'self' and will start using 'self' when I start working for them. And a little thought in the back of my head ... I wonder if the employer would be a little annoyed by that :) OK - I need my hand slapped sometimes and I see that you all are trying to prevent me from developing a bad habit. A few comments below: "Steven D'Aprano" wrote in message news:4d453127$0$29965$c3e8da3$5496439d at news.astraweb.com... > On Sat, 29 Jan 2011 10:39:49 -0800, patty wrote: > >> I am glad you said this. I have been avoiding understanding this >> 'self', just accepting it :} For the time being, since my programs I am >> creating are for my own use, I think I will make my own names up, that >> are descriptive to me as the programmer, it's all going to be >> interpreted anyway. And the other email equating to C's argv, etc. - >> now I get it. > > > That's a shame, because `self` is actually very simple once you > understand the basic principles of object-oriented programming. > > What names would you choose? Unless you're writing descriptors, or using > class methods, both of which should be considered advanced usage (highly > advanced for descriptors, moderately so for class methods), it's not like > every method needs a different descriptive first argument. In English, > "self", "this", "me" or "instance" would be good names. What else would > you use? That is the thing, I can get quite creative. I envisioned myself giving it a name something like 'instancecalledfrommain' probably scrunched up to 'instfrmmain' Weird descriptive names like that. I keep thinking of it as a variable, so I keep thinking of what it is used for underlying its name. Back to the I-can-do-anything-I-want mindset. I have saved the messages in this thread and other ones from the last month or so about 'self' so I think I will gather them together and read them more carefully including your very good explanations below. > > > The idea of method syntax is that you start with an instance of some > class: > > mystring = "hello world" # an instance of the str class > > In procedural languages like C or Pascal, you would call a function and > give the string as an argument. Python supports this programming model, > and uses it for built-ins like len: > > len(mystring) > => returns 11 > > And I am more comfortable in the C and Pascal worlds as a base so I see why I go this direction. > Object oriented programming uses a different syntax. Instead of > > function(instance) > > as above, we take the instance argument outside the brackets. For example: > > mystring.upper() # instead of upper(mystring) > => returns "HELLO WORLD" > > If there are any extra arguments needed, they go inside the brackets as > normal. > > So far, this is just a change of syntax. It's like saying "The cat of my > brother's" vs. "my brother's cat" -- the meaning is the same, but the > syntax differs. And I am a linguist so now you are Really talking ;) The real advantages of object oriented programming and > methods come elsewhere (e.g. encapsulation and inheritance). > > [Aside: when I was learning this, the hardest part I found was > remembering which things were functions, and which were methods. > I kept writing (wrongly!) things like: > > "hello world".len() > upper("hello world") > > Unfortunately there is no easy way to recognise what will be a > function like len, and which are methods like upper. That will > come with experience. Oh! I do this! I seem to use this syntax interchangably. I really need to memorize this carefully. > > Back to function/procedural syntax versus object oriented syntax... > > One difference, though, is when you write a method definition. Because > the method you write starts off life as an ordinary function, you need to > write it *as if* it were a function you call like len() above. Here's how > you might write a method in a class: > > class MyClass: > def method(self, extra): > pass > > When you then call the method: > > instance = MyClass() > instance.method("something extra") > > Python automatically changes the syntax for you, and passes two arguments > to the function as if you did this: > > # pseudo-code > set self = instance > set extra = "something extra > extract "method" from MyClass > call method(self, extra) > > We call the first argument something like "self" because it will ALWAYS > be the instance itself. Unlike a regular function, which can have > anything passed as the first argument, and therefore you should give it a > descriptive name, the method's first argument is provided automatically > for you and will always be the instance you started with. > > > > I hope this helps. Immensely > > > > > -- > Steven > -- > http://mail.python.org/mailman/listinfo/python-list > > Wow! Thanks so much! Patty -------------- next part -------------- An HTML attachment was scrubbed... URL: From rustompmody at gmail.com Sun Jan 30 22:07:47 2011 From: rustompmody at gmail.com (rusi) Date: Sun, 30 Jan 2011 19:07:47 -0800 (PST) Subject: Understanding def foo(*args) References: <17945aea-21b6-45b5-9c09-e602143f755e@k4g2000pre.googlegroups.com> <27289cb5-b624-47d5-9692-06e23a034e03@b8g2000vbi.googlegroups.com> Message-ID: On Jan 31, 12:35?am, rantingrick wrote: > > Also, can the terms method and function be used interchangeably? > > Can the terms cars and truck be used interchangeably? Oooff! A load of meaning in that one line -- I wonder though if the OP will understand... From stackslip at gmail.com Sun Jan 30 22:50:33 2011 From: stackslip at gmail.com (Garland Fulton) Date: Sun, 30 Jan 2011 18:50:33 -0900 Subject: Useing the processor clock, or get time in Femptoseconds Message-ID: Does anyone have any suggestions? -------------- next part -------------- An HTML attachment was scrubbed... URL: From python at mrabarnett.plus.com Sun Jan 30 22:52:12 2011 From: python at mrabarnett.plus.com (MRAB) Date: Mon, 31 Jan 2011 03:52:12 +0000 Subject: Limit on entries in dictionary data structure In-Reply-To: References: Message-ID: <4D4631EC.40905@mrabarnett.plus.com> On 31/01/2011 02:43, Shruti Sanadhya wrote: > Hi, > > I am running a script that uses dictionaries on Python 2.6.4 on Ubuntu > 9.10. I notice that my script crashes with a MemoryError when my > dictionary reaches 44739243th entry. My system has 3GB RAM (32-bit). I > noticed that changing the key or value types also did not help my code. > For simplicity I tried running this: > > #BEGIN:python code > import sys > f={} > lsize=0 > try: > for k in range(0,4*44739243): > f[k]=k > if sys.getsizeof(f) > lsize: > lsize = sys.getsizeof(f) > print k, lsize > except: > print k, lsize > raise > #END:python code > > The code terminates with: > "Traceback (most recent call last): > File "pydict-limit.py", line 6, in > f[k]=k > MemoryError" > > I have also tried running this on Ubuntu 9.10 with Python 2.6.6 with > 3.5GB RAM(32-bit) and a 64-bit LINUX cluster machine with 62GB RAM and > Python 2.4. On both these machines it crashed at entry 44739243. The > size of the data structure grows to 1.5GB. On another 64-bit cluster > machine with 32GB RAM and Python 2.6.6 it crashed at entry 178956970. In > this case the size of the data structure grew to 6GB. > > Has anybody encountered this before? Can somebody suggest any fix for > this? I am trying to read some 10GB network traces into a hash > table(hence dictionary) and need constant time lookup. Clearly > increasing the machine RAM does not work. Any suggestions would be > greatly appreciated. > sys.getsizeof(...) returns the size of an object itself, not the size of an object plus any others which that object references. The dict in your example code occupied 1.5GB, but that didn't include the size of the int keys and values, only the references to them. As for the 64-bit Linux cluster machine, did you run a 32-bit or a 64-bit build of Python? A 32-bit build can't use more than 4GB (2**32). From tyler at tysdomain.com Sun Jan 30 23:14:11 2011 From: tyler at tysdomain.com (Littlefield, Tyler) Date: Sun, 30 Jan 2011 21:14:11 -0700 Subject: Useing the processor clock, or get time in Femptoseconds In-Reply-To: References: Message-ID: <4D463713.8030805@tysdomain.com> If you are on windows, you can use high-resolution timers. What you are trying is physically impossible though: lets say you have a processor that runs at 2.5 GHz. that's 2.5 billion cycles per second, give or take a few. So, the lowest you can go is nanoseconds. You're trying to time like 10x the processor's actual speed, and you're not going to get timing that good. so, lower your bar a bit; the highest you will get is nanoseconds with high-res timers. (I'm not sure what the equivalent of this is on *nix, or whether or not python supports it on either platform. I think you'll end up making a DLL call, though I could be wrong). From wuwei23 at gmail.com Sun Jan 30 23:36:13 2011 From: wuwei23 at gmail.com (alex23) Date: Sun, 30 Jan 2011 20:36:13 -0800 (PST) Subject: WxPython versus Tkinter. References: <4D3E4377.3060807@tysdomain.com> <59F6E65E3D9A46AD8D7A3863F3C1DC84@teddy> <27f53f8c-7862-4366-9352-82ae9a2f3970@k3g2000yqc.googlegroups.com> <718D13777F254C839F9564BC4275DE0A@octavian> <4D402C42.1030407@tysdomain.com> <4D40447C.4010108@tysdomain.com> <33C68A0874BE4C66AB478EDFB64C2C1D@teddy> <4D407321.3090705@web.de> <1296128007.17192.1417506961@webmail.messagingengine.com> <8775C617C7B241759AC122A69955D42A@octavian> <349dc47a-5a16-47e9-8dea-0de3aa814b52@d1g2000yqb.googlegroups.com> Message-ID: <948029f2-962e-4389-9327-4ebbfdbef66b@z3g2000prz.googlegroups.com> rantingrick wrote: > To be honest, i would sacrifice all the functionality of > wxWidgets if we could get pyGUI into the stdlib. Why? Well because > pyGUI would be under OUR complete control. "You" would need to contribute something other than bullshit and vitriol in order to be able to use the word "our" in the way you do here. > *if* the community saw the potential that i see with pyGUI > and wanted to seriously do some development to bring it into 3.0 > compliance i'll bet Greg *would* be interested You can't even generate your _own_ code for this idea and yet you somehow mystically know how other people will respond? Have you _ever_ been even _close_ to being able to do this? You seem genuinely angry and shocked at times that we haven't embraced you as some kind of messianic firebrand, which doesn't really say a lot for your ability to gauge the responses & desires of others. Maybe Greg's not a complete egotist like yourself, needing the attention and constant fluffing you seem to demand before you'll even begin to consider coding. Maybe pyGUI as is scratches his itch, because rather than spending YEARS trying to offload work onto the community he just coded up what he needed to actually get something _done_, something other than masturbating over a library for its own sake. Maybe he has no interest in 3.x but has no concern with community submitted patches. A patch - I should probably explain for your sake, rick - is a diff of changes to a body of code allowing the project maintainer to integrate user submitted bug fixes and feature additions. Pretty much most project maintainers will accept them sans manifesto too. This isn't about getting your ego stroked. This isn't about which language's dick is the longest because it has its own GUI. This is about people with lives of their own making small contributions born of necessity culminating in the further growth & evolution of a useful piece of code. From drsalists at gmail.com Mon Jan 31 00:12:49 2011 From: drsalists at gmail.com (Dan Stromberg) Date: Sun, 30 Jan 2011 21:12:49 -0800 Subject: Limit on entries in dictionary data structure In-Reply-To: References: Message-ID: On Sun, Jan 30, 2011 at 6:43 PM, Shruti Sanadhya wrote: > Hi, > I am running a script that uses dictionaries on Python 2.6.4 on Ubuntu 9.10. > I notice that my script crashes with a MemoryError when my dictionary > reaches 44739243th entry. My system has 3GB RAM (32-bit). I noticed that > changing the key or value types also did not help my code. For simplicity I > tried running this: > #BEGIN:python code > import sys > f={} > lsize=0 > try: > ?? ?for k in range(0,4*44739243): > ?? ? ? ?f[k]=k > ?? ? ? ?if sys.getsizeof(f) > lsize: > ?? ? ? ? ? ?lsize = sys.getsizeof(f) > ?? ? ? ? ? ?print k, lsize > except: > ?? ?print k, lsize > ?? ?raise > #END:python code > The code terminates with: > "Traceback (most recent call last): > ??File "pydict-limit.py", line 6, in > ?? ?f[k]=k > MemoryError" > I have also tried running this on Ubuntu 9.10 with Python 2.6.6 with 3.5GB > RAM(32-bit) and a 64-bit LINUX cluster machine with 62GB RAM and Python 2.4. > On both these machines it crashed at entry 44739243. The size of the data > structure grows to 1.5GB. On another 64-bit cluster machine with 32GB RAM > and Python 2.6.6 it crashed at entry?178956970. In this case the size of the > data structure grew to 6GB. > Has anybody encountered this before? Can somebody suggest any fix for this? > I am trying to read some 10GB network traces into a hash table(hence > dictionary) and need constant time lookup. Clearly increasing the machine > RAM does not work. Any suggestions would be greatly appreciated. > Thanks, > Shruti If you need strict controls over how much memory is used, you might be better off with C or something. Or Cython would give you a Pythonic syntax with C's datastructures (as well as Python-style datastructures, but that gets back into memory unpredictability). On an Ubuntu system, you can probably "man hcreate" to get some info on a hash table accessible from C. If you need a huge "dictionary", then using something like gdbm or bsddb might be good, though I doubt these are constant time - they're more like single-table databases, where the keys and values must all be strings or serialized non-strings. However, they should be fine with huge dictionaries. They have the advantage of providing a pretty dictionary-like interface. This almost certainly would not bump into any memory limits, as they are disk-based. If you really do need to keep things in RAM (VM), you might try this module: http://stromberg.dnsalias.org/~strombrg/treap/ on one of your 64 bit systems, preferably with a recent cpython like 2.6 or 2.7 built with a 64 bit compiler. It too is not constant time, but it is O(c*log(n)) with a small c, at the expense of a higher standard deviation in write times compared to something like a red/black tree (better average performance though). This provides a very dictionary-like interface. It would implicitly store things sorted by key, incidentally, though that may be unimportant in your application. This may or may not have the same memory issues as the dictionary - and I'd be very interested in hearing whether they do or not. You might also be able to read everything into a big list, then sort it. Then use the bisect module to do log(n) time lookups. This does not give a dictionary-like interface or constant time, but it doesn't require anything outside of CPython's standard library. It may or may not have the same memory issues you were seeing with dictionaries. Here's something based on your code above, that works with the mentioned treap module. I found that it required about 1 gig for each 10% of the numbers the code was trying to save - on a 32 bit, Ubuntu 10.10 system. However, I have only 3 gig of RAM, so I terminated it before it got to a memory error: #!/usr/bin/python import sys import treap f = treap.treap() top = 4*44739243 try: for k in xrange(0, top): sys.stdout.write('%d %f%%\r' % (k, k * 100.0 / top)) f[k]=k print except: print raise From nagle at animats.com Mon Jan 31 00:13:14 2011 From: nagle at animats.com (John Nagle) Date: Sun, 30 Jan 2011 21:13:14 -0800 Subject: Useing the processor clock, or get time in Femptoseconds In-Reply-To: References: Message-ID: <4d4644f4$0$10557$742ec2ed@news.sonic.net> On 1/30/2011 8:14 PM, Littlefield, Tyler wrote: > If you are on windows, you can use high-resolution timers. What you are > trying is physically impossible though: lets say you have a processor > that runs at 2.5 GHz. that's 2.5 billion cycles per second, give or take > a few. So, the lowest you can go is nanoseconds. You're trying to time > like 10x the processor's actual speed, and you're not going to get > timing that good. so, lower your bar a bit; the highest you will get is > nanoseconds with high-res timers. (I'm not sure what the equivalent of > this is on *nix, or whether or not python supports it on either > platform. I think you'll end up making a DLL call, though I could be > wrong). On x86 CPUs since the Pentium, you can read the CPU's cycle counter, which is incrementing once for each clock cycle, maybe every 300ps or so on a current generation CPU. See "http://en.wikipedia.org/wiki/Time_Stamp_Counter" You do not want to do this. First, you're in Python, which is interpreted; picosecond level timing resolution is orders of magnitude finer than is meaningful at the Python source level. Second, on multiprocessors, each CPU has its own cycle clock, and they're not synchronized. Third, on superscalar CPUs, reading of the clock may occur out of order and be meaningless. In Python, just call "time.time()", which gets you a floating point number with about 1ms resolution. John Nagle From wuwei23 at gmail.com Mon Jan 31 00:39:50 2011 From: wuwei23 at gmail.com (alex23) Date: Sun, 30 Jan 2011 21:39:50 -0800 (PST) Subject: Bugs/issues in tkinter.simpledialog!! References: Message-ID: <2ae102e4-427f-4bbe-8c2e-4967c2cfb14d@i39g2000prd.googlegroups.com> rantingrick wrote: > Actually i see you point but there is a good reason behind me bringing > this up here. I want to bring to the attention of everyone how little > interest there is for Tkinter. Right. You have no interest in resolving this issue and instead want to use it as more ammunition in your ongoing crusade. You even have the gall to act _offended_ at Giampaolo's suggestion that you log the bug, dumping your usual bullshit and vitriol on someone WHO HAS ACTUALLY DONE THE SORT OF WORK YOU CONSTANTLY CLAIM YOU'RE GOING TO, even though your every intention was to parade this issue around as if it somehow validates your personal blend of crazy. You're a class act, that's for sure. > Agreed. However i would rather just write a patch, send it to some > email and be done. Or just commit the changes myself. This bug > tracker is just bureaucracy at it's worst. You are making this process > too hard and people are not going to get involved when they have to > jump through 20 hoops just to patch three lines of freaking code! Because complex distributed coding projects should be treated like Wikipedia? It must suck being such a genius and yet be unable to grapple with a simple bug tracker... From data.2 at rediff.com Mon Jan 31 04:33:29 2011 From: data.2 at rediff.com (gaurav) Date: Mon, 31 Jan 2011 01:33:29 -0800 (PST) Subject: Option in Management careers. Message-ID: <347de674-910f-4200-a5e3-5470910c000e@y31g2000prd.googlegroups.com> Rush for career in computer and government jobs potential revenue. http://rojgars1.webs.com/gov.htm http://rojgars.webs.com/bankingjobs.htm Huge chance in Management careers. Management careers for you. http://managementjobs.webs.com/pm.htm http://topcareer.webs.com/humanresourcemgmt.htm From simon at brunningonline.net Mon Jan 31 04:45:50 2011 From: simon at brunningonline.net (Simon Brunning) Date: Mon, 31 Jan 2011 09:45:50 +0000 Subject: multiple values for keyword argument In-Reply-To: <6f1dd6fbbc04d2788b2b191e3e407887.squirrel@cruziomail.cruzio.com> References: <9f669337-6116-4442-9c7e-54b0051e33a2@8g2000prb.googlegroups.com> <8qijsgFgu1U1@mid.dfncis.de> <4D443631.3000502@stoneleaf.us> <6f1dd6fbbc04d2788b2b191e3e407887.squirrel@cruziomail.cruzio.com> Message-ID: On 29 January 2011 18:39, wrote: >> I, myself, use the spanish word 'yo' instead (less keystrokes, I hate >> 'self', and it amuses me); if I'm working with my numerical experiments >> I'll use 'n' or 'x'... although, when posting sample code to c.l.py I do >> try to use 'self' to avoid possible confusion. ?:) > > I am glad you said this. ?I have been avoiding understanding this 'self', > just accepting it :} ?For the time being, since my programs I am creating > are for my own use, I think I will make my own names up, that are > descriptive to me as the programmer, it's all going to be interpreted > anyway. ?And the other email equating to C's argv, etc. - now I get it. It's perfectly legal to use a name other than self. It's alo perfectly legal never to wash - and you won't make any friends that way either. -- Cheers, Simon B. From georg at python.org Mon Jan 31 05:32:02 2011 From: georg at python.org (Georg Brandl) Date: Mon, 31 Jan 2011 11:32:02 +0100 Subject: [RELEASED] Python 3.2 rc 2 Message-ID: <4D468FA2.4040704@python.org> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On behalf of the Python development team, I'm quite happy to announce the second release candidate of Python 3.2. Python 3.2 is a continuation of the efforts to improve and stabilize the Python 3.x line. Since the final release of Python 2.7, the 2.x line will only receive bugfixes, and new features are developed for 3.x only. Since PEP 3003, the Moratorium on Language Changes, is in effect, there are no changes in Python's syntax and built-in types in Python 3.2. Development efforts concentrated on the standard library and support for porting code to Python 3. Highlights are: * numerous improvements to the unittest module * PEP 3147, support for .pyc repository directories * PEP 3149, support for version tagged dynamic libraries * PEP 3148, a new futures library for concurrent programming * PEP 384, a stable ABI for extension modules * PEP 391, dictionary-based logging configuration * an overhauled GIL implementation that reduces contention * an extended email package that handles bytes messages * a much improved ssl module with support for SSL contexts and certificate hostname matching * a sysconfig module to access configuration information * additions to the shutil module, among them archive file support * many enhancements to configparser, among them mapping protocol support * improvements to pdb, the Python debugger * countless fixes regarding bytes/string issues; among them full support for a bytes environment (filenames, environment variables) * many consistency and behavior fixes for numeric operations For a more extensive list of changes in 3.2, see http://docs.python.org/3.2/whatsnew/3.2.html To download Python 3.2 visit: http://www.python.org/download/releases/3.2/ Please consider trying Python 3.2 with your code and reporting any bugs you may notice to: http://bugs.python.org/ Enjoy! - -- Georg Brandl, Release Manager georg at python.org (on behalf of the entire python-dev team and 3.2's contributors) -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (GNU/Linux) iEYEARECAAYFAk1Gj6IACgkQN9GcIYhpnLC53wCfcZhc6bxbc+fsmi+PAJxM6npr Hh4An3QRdeyKHm+L3CqVk+EX02PxNx2r =sTu6 -----END PGP SIGNATURE----- From jeanmichel at sequans.com Mon Jan 31 06:15:13 2011 From: jeanmichel at sequans.com (Jean-Michel Pichavant) Date: Mon, 31 Jan 2011 12:15:13 +0100 Subject: Style question: Nicknames for deeply nested objects In-Reply-To: References: Message-ID: <4D4699C1.7090206@sequans.com> Gerald Britton wrote: > Hi all, > > Today I was thinking about a problem I often encounter. > [snip] > > 1. You need to call this thing many times with different arguments, so > you wind up with: > > x = some.deeply.nested.object.method(some.other.deeply.nested.object.value1) > y = some.deeply.nested.object.method(some.other.deeply.nested.object.value2) > z = some.deeply.nested.object.method(some.other.deeply.nested.object.value3) > [snip] > -- > Gerald Britton > This is not solved by style but by design. You simply don't use too much nested objects. That's a sign of something wrong in your overall object model. Since I do not encounter this problem as often as you are, I guess it is a matter of habbits. however, considering what "import a.module.that.is.quite.nested as myModule" is doing, I guess using a local variable to store your nested method is just fine. JM From jeanmichel at sequans.com Mon Jan 31 06:17:22 2011 From: jeanmichel at sequans.com (Jean-Michel Pichavant) Date: Mon, 31 Jan 2011 12:17:22 +0100 Subject: Understanding def foo(*args) In-Reply-To: <17945aea-21b6-45b5-9c09-e602143f755e@k4g2000pre.googlegroups.com> References: <17945aea-21b6-45b5-9c09-e602143f755e@k4g2000pre.googlegroups.com> Message-ID: <4D469A42.4090401@sequans.com> sl33k_ wrote: > Hi, > > I am struggling to grasp this concept about def foo(*args). Also, what > is def bar(*args, *kwargs)? > > Isnt it like self must be the first parameter to the method/function? > If not what are the exceptions? > > Also, can the terms method and function be used interchangeably? > > TIA > "python *args **kwargs" in google. 1st hit. JM From lukin.s.v at gmail.com Mon Jan 31 07:39:07 2011 From: lukin.s.v at gmail.com (Sergey Lukin) Date: Mon, 31 Jan 2011 13:39:07 +0100 Subject: Pickling/Unpickling python Exceptions In-Reply-To: References: Message-ID: Is anybody there to help me out ? On Thu, Jan 27, 2011 at 4:49 PM, Sergey Lukin wrote: > Hi all, > > I'm migrating code from python 2.4 to python 2.6 and I've got into troubles > with pickling/unpickling python Exceptions. > The following code works fine in 2.4 but not in 2.6. > See Exception1 example > > I have found on python mail list similar problem > http://mail.python.org/pipermail/python-list/2009-December/1228773.html > They recommend to use __reduce__. But this does not help as I'm getting > different Exception class after pickle > See Exception_with_reduce example > > I also have found possible solution to this problem here > http://bugs.python.org/issue1692335 > As a workaround they propose to pass Exception arguments into base class > See Exception2 example > But there is another problem. Constructor is called 2 times which is not > acceptable to me. > > Could you please advice on the solution? > > ------------------------------------------ > test program > ------------------------------------------ > import cPickle > > class Exception1(Exception): > def __init__(self,arg1): > print "constructor called" > Exception.__init__(self) > > class Exception2(Exception): > def __init__(self,arg1): > print "constructor called" > Exception.__init__(self,arg1) > > class Exception_with_reduce(Exception): > def __reduce__(self): > try: > getnewargs = self.__getnewargs__ > except AttributeError: > newargs = (self.__class__,) > else: > newargs = (self.__class__,) + getnewargs() > > try: > getstate = self.__getstate__ > except AttributeError: > state = self.__dict__ > else: > state = getstate() > return (Exception, newargs, state) > > def __init__(self,arg1): > print "constructor called" > Exception.__init__(self,arg1) > > def test(E,args): > try: > print ">>",E.__name__ > e = E(*args) > print "- pickling" > s = cPickle.dumps(e) > print "- unpickling" > e = cPickle.loads(s) > > if E != e.__class__: > print "! failed: expected %s, got > %s"%(E.__name__,e.__class__.__name__) > except Exception, e: > print "! failed:",e > > print "\ finished" > print > > > import os > if os.path.isfile("/home/ast1/blabla"): > try: > s = open("/home/ast1/blabla","r").read() > e = cPickle.loads(s) > print e.__class__ > except Exception, e: > print "error:",e > > test(Exception1,[1]) > test(Exception2,[1]) > test(Exception_with_reduce,[1]) > ------------------------------------------ > > > ------------------------------------------ > run results on python 2.6: > ------------------------------------------ > > constructor called > > >> Exception1 > constructor called > - pickling > - unpickling > ! failed: ('__init__() takes exactly 2 arguments (1 given)', '__main__.Exception1'>, ()) > \ finished > > >> Exception2 > constructor called > - pickling > - unpickling > constructor called > \ finished > > >> Exception_with_reduce > constructor called > - pickling > - unpickling > ! failed: expected Exception_with_reduce, got Exception > \ finished > > ------------------------------------------ > run results on python 2.4: > ------------------------------------------ > > __main__.Exception2 > >> Exception1 > constructor called > - pickling > - unpickling > \ finished > > >> Exception2 > constructor called > - pickling > - unpickling > \ finished > > >> Exception_with_reduce > constructor called > - pickling > - unpickling > \ finished > > > > > -- Media Center for TomTom - a unique video player from MobilNova.com Be the first to watch ! http://www.MobilNova.com/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From daniel at danielstender.com Mon Jan 31 07:45:59 2011 From: daniel at danielstender.com (Daniel Stender) Date: Mon, 31 Jan 2011 13:45:59 +0100 Subject: XML to dict(d) Message-ID: <4D46AF07.6000108@danielstender.com> Hi guys, we are trying to convert a Sanskrit dictionary which is in a "homegrown" XML format into dict(d), the input file goes like this:

200akAlikam2a-kAlikam ind. immediately MBh. 000173 2,2 266

110akAlya2a-kAlya mfn. unseasonable. 000174 2,2 267

110akAsAra1a-kAsAra m. N._of_a_teacher BhP. 000175 2,2 268

110akiYcana1a-kiYcana mfn. without_anything_,_utterly_destitute 2,2 269

100akiYcana1a-kiYcana mfn. disinterested 2,2 270 110akiYcana1a-kiYcana n. that_which_is_worth_nothing. 000176 2,2 271

110akiYcanatA3a-kiYcana--tA f. voluntary_poverty_

as_practised_by_JainajEna_ascetics

.
000177 2,2 272

I've found that there is the library python-dictdlib for concatenating dict dictionaries, what would be the best way to "de-XML" the source file? Thanks for any pointers in advance! Daniel Stender From neilc at norwich.edu Mon Jan 31 08:03:13 2011 From: neilc at norwich.edu (Neil Cerutti) Date: 31 Jan 2011 13:03:13 GMT Subject: XML to dict(d) References: Message-ID: <8qnq8hFtb5U5@mid.individual.net> On 2011-01-31, Daniel Stender wrote: > Hi guys, > > we are trying to convert a Sanskrit dictionary which is in a > "homegrown" XML format into dict(d), the input file goes like > this: xml.etree.ElementTree will parse your file and return it as a hierarchy of dict-like Element objects. -- Neil Cerutti From stefan_ml at behnel.de Mon Jan 31 08:08:02 2011 From: stefan_ml at behnel.de (Stefan Behnel) Date: Mon, 31 Jan 2011 14:08:02 +0100 Subject: XML to dict(d) In-Reply-To: <4D46AF07.6000108@danielstender.com> References: <4D46AF07.6000108@danielstender.com> Message-ID: Daniel Stender, 31.01.2011 13:45: > we are trying to convert a Sanskrit dictionary which is in a "homegrown" XML format into dict(d), > the input file goes like this: > > >

200akAlikam2a-kAlikam > ind. immediately MBh. 000173 2,2 > 266

>

110akAlya2a-kAlya mfn. > unseasonable. 000174 2,2 267

>

110akAsAra1a-kAsAra m. > N._of_a_teacher BhP. 000175 2,2 > 268

>

110akiYcana1a-kiYcana > mfn. without_anything_,_utterly_destitute 2,2 > 269

> 100akiYcana1a-kiYcana type="inh">mfn. disinterested 2,2 270 > 110akiYcana1a-kiYcana > n. that_which_is_worth_nothing. 000176 2,2 > 271 >

110akiYcanatA3a-kiYcana--tA > f. > voluntary_poverty_

as_practised_by_JainajEna_ascetics

.
> 000177 2,2 272

>
> > I've found that there is the library python-dictdlib for concatenating dict dictionaries, what would > be the best way to "de-XML" the source file? How do you want to the dict to look like? Stefan From Rob.Richardson at rad-con.com Mon Jan 31 08:57:55 2011 From: Rob.Richardson at rad-con.com (Rob Richardson) Date: Mon, 31 Jan 2011 08:57:55 -0500 Subject: Understanding def foo(*args) In-Reply-To: <4D469A42.4090401@sequans.com> Message-ID: <04A6DB42D2BA534FAC77B90562A6A03D0170185B@server.rad-con.local> My thanks both to the original poster and to JM for an excellent answer. I saw this syntax for the first time recently, and I've been curious about it too. RobR From daniel at danielstender.com Mon Jan 31 09:14:06 2011 From: daniel at danielstender.com (Daniel Stender) Date: Mon, 31 Jan 2011 15:14:06 +0100 Subject: XML to dict(d) In-Reply-To: References: <4D46AF07.6000108@danielstender.com> Message-ID: <4D46C3AE.7080604@danielstender.com> >> I've found that there is the library python-dictdlib for concatenating >> dict dictionaries, what would >> be the best way to "de-XML" the source file? > > How do you want to the dict to look like? > > Stefan What's in should be the "search word", the rest altogether belonging to that in a single line (with some minor modifications). Greetings, DS From stefan_ml at behnel.de Mon Jan 31 09:37:59 2011 From: stefan_ml at behnel.de (Stefan Behnel) Date: Mon, 31 Jan 2011 15:37:59 +0100 Subject: XML to dict(d) In-Reply-To: <4D46C3AE.7080604@danielstender.com> References: <4D46AF07.6000108@danielstender.com> <4D46C3AE.7080604@danielstender.com> Message-ID: Daniel Stender, 31.01.2011 15:14: >>> I've found that there is the library python-dictdlib for concatenating >>> dict dictionaries, what would >>> be the best way to "de-XML" the source file? >> >> How do you want to the dict to look like? > > What's in should be the "search word", the rest altogether belonging to that in a single line > (with some minor modifications). "the rest" isn't very precise, but here's an example of what you could do. from xml.etree.cElementTree import iterparse words = {} h_tags = ('H1', 'H2', 'H3') for _, element in iterparse('thefile.xml'): if element.tag in h_tags: words[element.findtext('h/key1')] = element Since you didn't provide enough information, I have no idea what you want to make of the "h", "body" and "tail" tags. But I'm sure you'll figure it out. Stefan From sturlamolden at yahoo.no Mon Jan 31 11:45:40 2011 From: sturlamolden at yahoo.no (sturlamolden) Date: Mon, 31 Jan 2011 08:45:40 -0800 (PST) Subject: Python critique References: <21868b6d-ab01-402d-a9b3-ee1be39771b8@o4g2000yqd.googlegroups.com> <4d028748$0$1621$742ec2ed@news.sonic.net> Message-ID: On 10 Des 2010, 21:02, John Nagle wrote: > ? ? Probably the biggest practical problem with CPython is > that C modules have to be closely matched to the version of > CPython. ?There's no well-defined API that doesn't change. ctypes and DLLs in plain C do not change, and do not depend on CPython version. Sturla From sturlamolden at yahoo.no Mon Jan 31 11:48:47 2011 From: sturlamolden at yahoo.no (sturlamolden) Date: Mon, 31 Jan 2011 08:48:47 -0800 (PST) Subject: Python critique References: <21868b6d-ab01-402d-a9b3-ee1be39771b8@o4g2000yqd.googlegroups.com> <4d028748$0$1621$742ec2ed@news.sonic.net> Message-ID: On 11 Des 2010, 00:09, Antoine Pitrou wrote: > > ? ? Probably the biggest practical problem with CPython is > > that C modules have to be closely matched to the version of > > CPython. ?There's no well-defined API that doesn't change. > > Please stop spreading FUD:http://docs.python.org/c-api/index.html Even if the API does not change, there is still static linkage with version dependency. That is avoided with ctypes. Sturla From ramon at conexus.net Mon Jan 31 11:49:53 2011 From: ramon at conexus.net (Ramon F Herrera) Date: Mon, 31 Jan 2011 08:49:53 -0800 (PST) Subject: Would like to add an "upload" facility to my web site Message-ID: (newbie alert) This is what I have so far: http://patriot.net/~ramon/upload_facility.html The code is shown below. It seems I need that actual script that performs the file transfer. I would prefer it in Python. TIA, -Ramon ---------------------------------------


From ramon at conexus.net Mon Jan 31 11:50:53 2011 From: ramon at conexus.net (Ramon F Herrera) Date: Mon, 31 Jan 2011 08:50:53 -0800 (PST) Subject: Would like to add an "upload" facility to my web site References: Message-ID: On Jan 31, 10:49?am, Ramon F Herrera wrote: > (newbie alert) > > This is what I have so far: > > http://patriot.net/~ramon/upload_facility.html > > The code is shown below. It seems I need that actual script that > performs the file transfer. I would prefer it in Python. > > TIA, > > -Ramon > > --------------------------------------- > > > >
>
> ? ? > ? ? > ? ?
> ? ?
> ? ? >
> > IMPORTANT Bonus question: Where should I post this type of question about writing stuff for the web???? -Ramon From miki.tebeka at gmail.com Mon Jan 31 12:16:11 2011 From: miki.tebeka at gmail.com (Miki) Date: Mon, 31 Jan 2011 09:16:11 -0800 (PST) Subject: Would like to add an "upload" facility to my web site In-Reply-To: Message-ID: <62829324-3191-4122-b0d7-2ec008644334@glegroupsg2000goo.googlegroups.com> One way is http://pythonwise.blogspot.com/2007/03/pushing-data-easy-way.html :) This list a good place to ask, you can try StackOverflow as well. From randrange at gmail.com Mon Jan 31 12:35:30 2011 From: randrange at gmail.com (Andrew Evans) Date: Mon, 31 Jan 2011 09:35:30 -0800 Subject: Cast to a method pointer in ctypes Message-ID: How can I cast to a method pointer in ctypes. for example this in C int (*func)(); func = (int (*)()) expl; (int)(*func)(); How can I do this in ctypes using Python? I couldn't find the info I needed to be able to do this *cheers -------------- next part -------------- An HTML attachment was scrubbed... URL: From luismgz at gmail.com Mon Jan 31 12:36:54 2011 From: luismgz at gmail.com (=?ISO-8859-1?Q?Luis_M=2E_Gonz=E1lez?=) Date: Mon, 31 Jan 2011 09:36:54 -0800 (PST) Subject: Would like to add an "upload" facility to my web site References: Message-ID: <231c1967-3447-4628-9bc2-1245dda06027@i40g2000yqh.googlegroups.com> On Jan 31, 1:50?pm, Ramon F Herrera wrote: > On Jan 31, 10:49?am, Ramon F Herrera wrote: > > > > > > > > > > > (newbie alert) > > > This is what I have so far: > > >http://patriot.net/~ramon/upload_facility.html > > > The code is shown below. It seems I need that actual script that > > performs the file transfer. I would prefer it in Python. > > > TIA, > > > -Ramon > > > --------------------------------------- > > > > > > >
> >
> > ? ? > > ? ? > > ? ?
> > ? ?
> > ? ? > >
> > > > > > IMPORTANT Bonus question: > > Where should I post this type of question about writing stuff for the > web???? > > -Ramon I guess this question is framework specific. Are you using any framework (django, pylons, etc...)? From rantingrick at gmail.com Mon Jan 31 12:39:58 2011 From: rantingrick at gmail.com (rantingrick) Date: Mon, 31 Jan 2011 09:39:58 -0800 (PST) Subject: IDLE: A cornicopia of mediocrity and obfuscation. Message-ID: IDLE: A cornicopia of mediocrity and obfuscation. -- by Rick Johnson IDLE --which is the Python Integrated Development and Learning Environment-- was once the apple of Guido's eye but has since degenerated into madness many years ago and remains now as the shining jewel "show piece" on the proverbial python wall of shame. A once mighty dream of "programming for everyone" that is now nothing more than an example of "how NOT to program". IDLE contains some of the worst code this community has created. Bad design patterns, tacked on functionality, blasphemous styling, and piss poor packaging. There seems to be no guiding goals or game-plan. And year after year if IDLE *does* get any attention it's just more haphazard code thrown into the mix by someone who has gone blind from reading the source. However we cannot blame the current maintainer (if any such even exists!) because NOBODY can maintains such a spaghetti mess that this package has become! If we would have had a proper game plan from day one i believe we could have avoided this catastrophe. Follows is an outline of the wrongs with some suggestions to right them... * First of all the main two modules "PyShell" and "EditorWindow" are laid out in such a non sequential way that it is virtually impossible to follow along. We should have had a proper app instance from which all widgets where combined. The main app should have followed a "common sense" sequential mentality of... * subclassing the tk.Toplevel * initializing instance variables * creating the main menu * creating the sub widgets * declaring internal methods * declaring event handlers * then interface/generic methods. This is the recipe for order AND NOT CHAOS! What we have now is utter chaos! When we have order we can read source code in a sequential fashion. When we have order we can comprehend what we read. And when we have order we can maintain a library/package with ease. However sadly we DO NOT have order, we have CHAOS, CHAOS, and more CHAOS! * The underlying sub widgets should have started with their own proper order of "declared" initialization. And all events should be handled in the widget at hand NOT outsourced to some other class! * One of the biggest design flaws is the fact that outside modules manipulate the main editor/pyshells events. This is a terrible way to code. For example the AutoCompleteWindow takes over the tab event.... #-- Puesdo Code --# # in editor window __init__ self.autocomplete = AutoComplete(blah) # in editor window onKeyPress(blah) if key == 'Tab' and blah: self.autocomplete.show_tip(blah) elif key == 'Escape' and acw.is_visibe(): self.autocomplete.hide() This is a bad design! The main editor window should handle all its own events AND THEN call outside class methods when needed. We don't want "Mommy" classes telling the kids what to do, when to eat, when to sleep, and when to excrete! We should create our objects with the virtue of self reliance and responsibility!. The Colorizer, ParenMatch, textView, TreeWidget, CallTips, and many other modules are guilty of "event stealing" also. Event functionality must be handled in the widget itself, NOT stolen and handled in an outside class. When we split up sequential code we get CHAOS! * Another bad choice was creating custom reusable widgets (Tabbedpages, FindDialog, ReplaceDialog, etc...) and leaving them in idlelib. These should have been moved into the lib-tk module where they would be more visible to python programmers AND we could reduce the cruft in the idlelib! Remember, when we create more files, folders, and objects we create CHAOS. And nobody can learn from CHAOS! * Another blasphemy is the fact that every module should include some sort of test to display its usage. If the module is a GUI widget then you MUST show how to use the widget in a window. Sadly like all everything else, idlelib is devoid of examples and testing. And the very few tests that DO exists just blow chunks! * Last but not least idlelib does not follow PEP8 or ANY convention. So much so that it seems the developers snubbed their nose at such conventions! We are missing doc strings and comments. We have built- ins being re-bound! Just code horror after code horror. These are just the top of the list. The peak of a huge iceberg that threatens to sink the community in the arms of chaos never to return. I am beginning to believe that this community is either made of amateurs due to this lackluster code in the stdlib. However it could be that the folks are really professional and refuse to work on such a horrible code base (which i understand). I am going with the latter. When are we going to demand that these abominations be rectified? How much longer must we wait? A year? Ten years?... i don't think Python will survive another ten years with this attitude of obfuscation, and mentality of mediocrity. -- rr: disappointed and annoyed! From goposter at jonjay.com Mon Jan 31 12:43:14 2011 From: goposter at jonjay.com (Google Poster) Date: Mon, 31 Jan 2011 09:43:14 -0800 (PST) Subject: Would like to add an "upload" facility to my web site References: <231c1967-3447-4628-9bc2-1245dda06027@i40g2000yqh.googlegroups.com> Message-ID: <36c9ff54-c860-47f9-a4a2-8d469d6c0609@m13g2000yqb.googlegroups.com> On Jan 31, 11:36?am, Luis M. Gonz?lez wrote: > On Jan 31, 1:50?pm, Ramon F Herrera wrote: > > > > > On Jan 31, 10:49?am, Ramon F Herrera wrote: > > > > (newbie alert) > > > > This is what I have so far: > > > >http://patriot.net/~ramon/upload_facility.html > > > > The code is shown below. It seems I need that actual script that > > > performs the file transfer. I would prefer it in Python. > > > > TIA, > > > > -Ramon > > > > --------------------------------------- > > > > > > > > > >
> > >
> > > ? ? > > > ? ? > > > ? ?
> > > ? ?
> > > ? ? > > >
> > > > > > > > > IMPORTANT Bonus question: > > > Where should I post this type of question about writing stuff for the > > web???? > > > -Ramon > > I guess this question is framework specific. No. > Are you using any framework (django, pylons, etc...)? Luis: I have a commercial shell account. I can only edit the directory ~ramon/public_html. I published one file already, I need the other. Gracias! -Ramon From goposter at jonjay.com Mon Jan 31 12:46:59 2011 From: goposter at jonjay.com (Google Poster) Date: Mon, 31 Jan 2011 09:46:59 -0800 (PST) Subject: Would like to add an "upload" facility to my web site References: <231c1967-3447-4628-9bc2-1245dda06027@i40g2000yqh.googlegroups.com> Message-ID: <573f8e92-c9f3-43c8-be33-7653bfba4501@f2g2000yqf.googlegroups.com> On Jan 31, 11:36?am, Luis M. Gonz?lez wrote: > On Jan 31, 1:50?pm, Ramon F Herrera wrote: > > > > > On Jan 31, 10:49?am, Ramon F Herrera wrote: > > > > (newbie alert) > > > > This is what I have so far: > > > >http://patriot.net/~ramon/upload_facility.html > > > > The code is shown below. It seems I need that actual script that > > > performs the file transfer. I would prefer it in Python. > > > > TIA, > > > > -Ramon > > > > --------------------------------------- > > > > > > > > > >
> > >
> > > ? ? > > > ? ? > > > ? ?
> > > ? ?
> > > ? ? > > >
> > > > > > > > > IMPORTANT Bonus question: > > > Where should I post this type of question about writing stuff for the > > web???? > > > -Ramon > > I guess this question is framework specific. > Are you using any framework (django, pylons, etc...)? Luis, Allow me to make this more clear. I have my own servers, all of them running Linux. I have been Linux sysadmin for more time than I care to remember. However, I (on purpose) provided an example hosted at my commercial shell provider. That was a deliberate decision, because I am looking for the simplest possible solution. I guess the question now is: Do I need root access to uploads files?? Gracias, -Ramon From rantingrick at gmail.com Mon Jan 31 12:49:49 2011 From: rantingrick at gmail.com (rantingrick) Date: Mon, 31 Jan 2011 09:49:49 -0800 (PST) Subject: IDLE: A cornicopia of mediocrity and obfuscation. References: Message-ID: On Jan 31, 11:39?am, rantingrick wrote: In my original post i showed this code.... #-- Puesdo Code --# # in editor window __init__ self.autocomplete = AutoComplete(blah) # in editor window onKeyPress(blah) if key == 'Tab' and blah: self.autocomplete.show_tip(blah) elif key == 'Escape' and acw.is_visibe(): self.autocomplete.hide() ...is a suggested FIX of the current code NOT a generalization of the current code. However it may easily be miss-interpreted due to improper placement in the paragraph. From sturlamolden at yahoo.no Mon Jan 31 12:51:12 2011 From: sturlamolden at yahoo.no (sturlamolden) Date: Mon, 31 Jan 2011 09:51:12 -0800 (PST) Subject: WxPython versus Tkinter. References: <920686a4-d157-46af-9e9d-1600a064bcc2@q12g2000yqi.googlegroups.com> Message-ID: On 23 Jan, 01:07, rantingrick wrote: > It is time to prove once and for all how dated and worthless Tkinter > is compared to wxPython. Yes, WxPython is not as advanced as i would > like it to be for a 21st century GUI library. So use PyQt instead. > However compared to > Tkinter, Wx is light years ahead! Wx is our best hope to move Python > into the 21st century. I vaguely someone saying that about Borland VCL and C++. Now people harly remember there was a RAD product called Borland C++ Builder, with a sane GUI API compared to Microsoft's MFC. I for one do not like to handcode GUIs. That is why I use wxFormBuilder, and the availability of a good GUI builder dictates my choise of API (currently wxPython due to the previously mentioned product). Sturla From patty at cruzio.com Mon Jan 31 13:00:00 2011 From: patty at cruzio.com (patty at cruzio.com) Date: Mon, 31 Jan 2011 10:00:00 -0800 (PST) Subject: multiple values for keyword argument In-Reply-To: References: <9f669337-6116-4442-9c7e-54b0051e33a2@8g2000prb.googlegroups.com> <8qijsgFgu1U1@mid.dfncis.de> <4D443631.3000502@stoneleaf.us> <6f1dd6fbbc04d2788b2b191e3e407887.squirrel@cruziomail.cruzio.com> Message-ID: > On 29 January 2011 18:39, wrote: >>> I, myself, use the spanish word 'yo' instead (less keystrokes, I hate >>> 'self', and it amuses me); if I'm working with my numerical experiments >>> I'll use 'n' or 'x'... although, when posting sample code to c.l.py I >>> do >>> try to use 'self' to avoid possible confusion. ??:) >> >> I am glad you said this. ??I have been avoiding understanding this >> 'self', >> just accepting it :} ??For the time being, since my programs I am >> creating >> are for my own use, I think I will make my own names up, that are >> descriptive to me as the programmer, it's all going to be interpreted >> anyway. ??And the other email equating to C's argv, etc. - now I get it. > > It's perfectly legal to use a name other than self. It's alo perfectly > legal never to wash - and you won't make any friends that way either. > > -- > Cheers, > Simon B. > > Cute. Believe me, I am learning to change my evil ways. This is what happens when you come from a *long* line of self-employed, entrepreneurial people. Independently Yours, Patty From nitinpawar432 at gmail.com Mon Jan 31 13:06:01 2011 From: nitinpawar432 at gmail.com (Nitin Pawar) Date: Mon, 31 Jan 2011 23:36:01 +0530 Subject: Would like to add an "upload" facility to my web site In-Reply-To: <573f8e92-c9f3-43c8-be33-7653bfba4501@f2g2000yqf.googlegroups.com> References: <231c1967-3447-4628-9bc2-1245dda06027@i40g2000yqh.googlegroups.com> <573f8e92-c9f3-43c8-be33-7653bfba4501@f2g2000yqf.googlegroups.com> Message-ID: On Mon, Jan 31, 2011 at 11:16 PM, Google Poster wrote: > On Jan 31, 11:36 am, Luis M. Gonz?lez wrote: > > On Jan 31, 1:50 pm, Ramon F Herrera wrote: > > > > > > > > > On Jan 31, 10:49 am, Ramon F Herrera wrote: > > > > > > (newbie alert) > > > > > > This is what I have so far: > > > > > >http://patriot.net/~ramon/upload_facility.html > > > > > > The code is shown below. It seems I need that actual script that > > > > performs the file transfer. I would prefer it in Python. > > > > > > TIA, > > > > > > -Ramon > > > > > > --------------------------------------- > > > > > > > > > > > > > >
> > > >
> > > > > > > > > > > >
> > > >
> > > > > > > >
> > > > > > > > > > > > > IMPORTANT Bonus question: > > > > > Where should I post this type of question about writing stuff for the > > > web???? > > > > > -Ramon > > > > I guess this question is framework specific. > > Are you using any framework (django, pylons, etc...)? > > > Luis, > > Allow me to make this more clear. I have my own servers, all of them > running Linux. I have been Linux sysadmin for more time than I care to > remember. However, I (on purpose) provided an example hosted at my > commercial shell provider. That was a deliberate decision, because I > am looking for the simplest possible solution. > > I guess the question now is: Do I need root access to uploads files?? > > Gracias, > > -Ramon > > -- > You don't need a root access to upload files. You will just need to create a directory where you want to save the uploaded files and grant permission to the username by which the web server is running. In case the file uploads are small the simple upload feature works fine but for larger files you may need to write a chunk read/write api > http://mail.python.org/mailman/listinfo/python-list > -- Nitin Pawar -------------- next part -------------- An HTML attachment was scrubbed... URL: From rantingrick at gmail.com Mon Jan 31 13:12:49 2011 From: rantingrick at gmail.com (rantingrick) Date: Mon, 31 Jan 2011 10:12:49 -0800 (PST) Subject: IDLE: A cornicopia of mediocrity and obfuscation. References: Message-ID: PLEASE KINDLY IGNORE MY FIRST TWO POSTS: Due to some errors i need to repost. Thank you. IDLE: A cornicopia of mediocrity and obfuscation. -- by Rick Johnson IDLE --which is the Python Integrated Development and Learning Environment-- was once the apple of Guido's eye but has since degenerated into madness many years ago and remains now as the shining jewel "show piece" on the proverbial python wall of shame. A once mighty dream of "programming for everyone" that is now nothing more than an example of "how NOT to program". IDLE contains some of the worst code this community has created. Bad design patterns, tacked on functionality, blasphemous styling, and piss poor packaging. There seems to be no guiding goals or game-plan. And year after year if IDLE *does* get any attention it's just more haphazard code thrown into the mix by someone who has gone blind from reading the source. However we cannot blame the current maintainer -- if any such even exists-- because NOBODY can maintains such a spaghetti mess that this package has become! If we would have had a proper game plan from day one i believe we could have avoided this catastrophe. Follows is an outline of the wrongs with some suggestions to right them... * First of all the main two modules "PyShell" and "EditorWindow" are laid out in such a non sequential way that it is virtually impossible to follow along. We should have had a proper app instance from which all widgets where combined. The main app should have followed a "common sense" sequential mentality of... * subclassing the tk.Toplevel * initializing instance variables * creating the main menu * creating the sub widgets * declaring internal methods * declaring event handlers * interface/generic methods. ... This is the recipe for order AND NOT CHAOS! What we have now is utter chaos! When we have order we can read source code in a sequential fashion. When we have order we can comprehend what we read. And when we have order we can maintain a library/package with ease. However sadly we DO NOT have order, we have CHAOS, CHAOS, and more CHAOS! * The underlying sub widgets should have started with their own proper order of "declared" initialization. And all events should be handled in the widget at hand NOT outsourced to some other class! * One of the biggest design flaws is the fact that outside modules manipulate the main editor/pyshells events. This is a terrible way to code. For example the AutoCompleteWindow takes over the tab event. This is a bad design! The main editor window should handle all its own events AND THEN call outside class methods when needed... #-- Puesdo Code --# # in editor window __init__ self.autocomplete = AutoComplete(blah) # in editor window onKeyPress(blah) if key == 'Tab' and blah: self.autocomplete.show_tip(blah) elif key == 'Escape' and acw.is_visibe(): self.autocomplete.hide() ...We don't want "Mommy" classes telling the kids what to do, when to eat, when to sleep, and when to excrete! We should create our objects with the virtue of self reliance and responsibility!. The Colorizer, ParenMatch, CallTips, and many other modules are guilty of "event stealing" also. Event functionality must be handled in the widget itself, NOT stolen and handled in an outside class. When we split up sequential code we get CHAOS! * Another bad choice was creating custom reusable widgets (Tabbedpages, FindDialog, ReplaceDialog, textView, TreeWidget, etc...) and leaving them in idlelib. These should have been moved into the lib- tk folder where they would be more visible to python programmers AND we could reduce the cruft in the idlelib! Remember, when we create more files, folders, and objects we create CHAOS. And nobody can learn from CHAOS! * Another blasphemy is the fact that every module should include some sort of test/demo to display its usage. If the module is a GUI widget then you MUST show how to use the widget in a window. Sadly like all everything else, idlelib is devoid of examples and testing. And the very few tests that DO exists just blow chunks! * Last but not least idlelib does not follow PEP8 or ANY convention. So much so that it seems the developers snubbed their nose at such conventions! We are missing doc strings and comments. We have built- ins being rebound! Just code horror after code horror. These are just the top of the list. The peak of a huge iceberg that threatens to sink the community in the arms of chaos never to return. I am beginning to believe that this community is made of amateurs due to this lackluster code in the stdlib. However it could be that the folks are really professional and refuse to work on such a horrible code base (which i understand). I am going with the latter. When are we going to demand that these abominations be rectified? How much longer must we wait? A year? Ten years?... i don't think Python will survive another ten years with this attitude of obfuscation, and mentality of mediocrity. -- rr: disappointed and annoyed! From tyler at tysdomain.com Mon Jan 31 13:13:29 2011 From: tyler at tysdomain.com (Littlefield, Tyler) Date: Mon, 31 Jan 2011 11:13:29 -0700 Subject: IDLE: A cornicopia of mediocrity and obfuscation. In-Reply-To: References: Message-ID: <4D46FBC9.1010500@tysdomain.com> >However we cannot blame the current maintainer... You seem to still not know who -we- is. rewrite your message using I in place of we, and you'll be on the right track. From g.rodola at gmail.com Mon Jan 31 14:32:12 2011 From: g.rodola at gmail.com (=?ISO-8859-1?Q?Giampaolo_Rodol=E0?=) Date: Mon, 31 Jan 2011 20:32:12 +0100 Subject: IDLE: A cornicopia of mediocrity and obfuscation. In-Reply-To: References: Message-ID: So what you're actually telling is that Python won't survive another 10 years because: - IDLE is it's default editor - idlelib directory is the first place you should look every time you need an inspiration on how code should be written - code in idlelib directory sucks That's an interesting point and I thank you for pointing that out. Personally I've never looked into idlelib directory for 7 years in a row at all. I was probably doing some other things, I don't know, but now I'm definitively gonna start looking for a new language because it's clear that any language having a directory called "idlelib" within such a horrible source code is not gonna last for long. Thanks again, --- Giampaolo http://code.google.com/p/pyftpdlib/ http://code.google.com/p/psutil/ 2011/1/31 rantingrick : > PLEASE KINDLY IGNORE MY FIRST TWO POSTS: > ?Due to some errors i need to repost. > Thank you. > > > > IDLE: A cornicopia of mediocrity and obfuscation. > -- by Rick Johnson > > > IDLE --which is the Python Integrated Development and Learning > Environment-- was once the apple of Guido's eye but has since > degenerated into madness many years ago and remains now as the shining > jewel "show piece" on the proverbial python wall of shame. A once > mighty dream of "programming for everyone" that is now nothing more > than an example of "how NOT to program". > > IDLE contains some of the worst code this community has created. Bad > design patterns, tacked on functionality, blasphemous styling, and > piss poor packaging. There seems to be no guiding goals or game-plan. > And year after year if IDLE *does* get any attention it's just more > haphazard code thrown into the mix by someone who has gone blind from > reading the source. However we cannot blame the current maintainer -- > if any such even exists-- because NOBODY can maintains such a > spaghetti mess that this package has become! > > If we would have had a proper game plan from day one i believe we > could have avoided this catastrophe. Follows is an outline of the > wrongs with some suggestions to right them... > > ?* First of all the main two modules "PyShell" and "EditorWindow" are > laid out in such a non sequential way that it is virtually impossible > to follow along. We should have had a proper app instance from which > all widgets where combined. The main app should have followed a > "common sense" sequential mentality of... > > ?* subclassing the tk.Toplevel > ?* initializing instance variables > ?* creating the main menu > ?* creating the sub widgets > ?* declaring internal methods > ?* declaring event handlers > ?* interface/generic methods. > > ... This is the recipe for order AND NOT CHAOS! What we have now is > utter chaos! When we have order we can read source code in a > sequential fashion. When we have order we can comprehend what we read. > And when we have order we can maintain a library/package with ease. > However sadly we DO NOT have order, we have CHAOS, CHAOS, and more > CHAOS! > > * The underlying sub widgets should have started with their own proper > order of "declared" initialization. And all events should be handled > in the widget at hand NOT outsourced to some other class! > > ?* One of the biggest design flaws is the fact that outside modules > manipulate the main editor/pyshells events. This is a terrible way to > code. For example the AutoCompleteWindow takes over the tab event. > This is a bad design! The main editor window should handle all its own > events AND THEN call outside class methods when needed... > > ?#-- Puesdo Code --# > ?# in editor window __init__ > ?self.autocomplete = AutoComplete(blah) > ?# in editor window onKeyPress(blah) > ?if key == 'Tab' and blah: > ? ? ?self.autocomplete.show_tip(blah) > ?elif key == 'Escape' and acw.is_visibe(): > ? ? ?self.autocomplete.hide() > > ...We don't want "Mommy" classes telling the kids what to do, when to > eat, when to sleep, and when to excrete! We should create our objects > with the virtue of self reliance and responsibility!. The Colorizer, > ParenMatch, CallTips, and many other modules are guilty of "event > stealing" also. Event functionality must be handled in the widget > itself, NOT stolen and handled in an outside class. When we split up > sequential code we get CHAOS! > > ?* Another bad choice was creating custom reusable widgets > (Tabbedpages, FindDialog, ReplaceDialog, textView, TreeWidget, etc...) > and leaving them in idlelib. These should have been moved into the lib- > tk folder where they would be more visible to python programmers AND > we could reduce the cruft in the idlelib! Remember, when we create > more files, folders, and objects we create CHAOS. And nobody can learn > from CHAOS! > > ?* Another blasphemy is the fact that every module should include some > sort of test/demo to display its usage. If the module is a GUI widget > then you MUST show how to use the widget in a window. Sadly like all > everything else, idlelib is devoid of examples and testing. And the > very few tests that DO exists just blow chunks! > > ?* Last but not least idlelib does not follow PEP8 or ANY convention. > So much so that it seems the developers snubbed their nose at such > conventions! We are missing doc strings and comments. We have built- > ins being rebound! Just code horror after code horror. > > These are just the top of the list. The peak of a huge iceberg that > threatens to sink the community in the arms of chaos never to return. > I am beginning to believe that this community is made of amateurs due > to this lackluster code in the stdlib. However it could be that the > folks are really professional and refuse to work on such a horrible > code base (which i understand). I am going with the latter. > > When are we going to demand that these abominations be rectified? How > much longer must we wait? A year? Ten years?... i don't think Python > will survive another ten years with this attitude of obfuscation, and > mentality of mediocrity. > > -- rr: disappointed and annoyed! > -- > http://mail.python.org/mailman/listinfo/python-list > From jeanmichel at sequans.com Mon Jan 31 14:35:52 2011 From: jeanmichel at sequans.com (Jean-Michel Pichavant) Date: Mon, 31 Jan 2011 20:35:52 +0100 Subject: multiple values for keyword argument In-Reply-To: <6f1dd6fbbc04d2788b2b191e3e407887.squirrel@cruziomail.cruzio.com> References: <9f669337-6116-4442-9c7e-54b0051e33a2@8g2000prb.googlegroups.com> <8qijsgFgu1U1@mid.dfncis.de> <4D443631.3000502@stoneleaf.us> <6f1dd6fbbc04d2788b2b191e3e407887.squirrel@cruziomail.cruzio.com> Message-ID: <4D470F18.9000103@sequans.com> patty at cruzio.com wrote: > I have been avoiding understanding this 'self', > [snip] > Regards, > > Patty > What is to be understood ?? self references the instance. Did I miss something ? JM From gandalf at shopzeus.com Mon Jan 31 15:04:07 2011 From: gandalf at shopzeus.com (Laszlo Nagy) Date: Mon, 31 Jan 2011 21:04:07 +0100 Subject: Python metaclass and UML Message-ID: <4D4715B7.2020803@shopzeus.com> How should I represent a Python metaclass on an UML class diagram? I know how to represent composition, aggregation and inheritance. But not sure about metaclasses. What kind of arrow or line should I use between a class and its metaclass? Is there a standard for this? Thanks, Laszlo From rantingrick at gmail.com Mon Jan 31 15:19:44 2011 From: rantingrick at gmail.com (rantingrick) Date: Mon, 31 Jan 2011 12:19:44 -0800 (PST) Subject: IDLE: A cornicopia of mediocrity and obfuscation. References: Message-ID: <48d40a1b-9bfc-47aa-b06c-9889273d835d@o32g2000prb.googlegroups.com> On Jan 31, 1:32?pm, Giampaolo Rodol? wrote: > So what you're actually telling is that Python won't survive another > 10 years because: > > - IDLE is it's default editor Well not solely because IDLE is the default editor. IDLE is very useful to newcommers and could be made even more useful however the code base is rotten! > - idlelib directory is the first place you should look every time you > need an inspiration on how code should be written In an ideal world it should be the first place you look when wanting to learn how to build medium sized GUI projects with the built-in Tkinter module. However the reality is ANYTHING but ideal. The code is rotten to the core, full of inconsistencies and just very unpythonic. Not something i would suggest any aspiring Tkinter n00b look at unless they want to learn what NOT to do. > - code in idlelib directory sucks plainly and simply... YES. > That's an interesting point and I thank you for pointing that out. > Personally I've never looked into idlelib directory for 7 years in a row at all. And i am glad, because had you followed the example of IDLE you would be spreading mediocrity and obfuscation. Both of which are not virtues to be admired. > I was probably doing some other things, I don't know, but now I'm > definitively gonna start looking for a new language because it's clear > that any language having a directory called "idlelib" within such a > horrible source code is not gonna last for long. Well not unless we do something about it. It is high time to stop patching, bolting on, and future extending the suffering of this horrendous code base. It is time to pull the plug, let it die, and start fresh. Start from a real python perspective. We can learn from past mistakes and build something much better. But will we? Do we have the community spirit to take on this challenge? Do we as a community have any fire left or have we collectively waxed cold? From python at rcn.com Mon Jan 31 15:35:12 2011 From: python at rcn.com (Raymond Hettinger) Date: Mon, 31 Jan 2011 12:35:12 -0800 (PST) Subject: Use the Source Luke References: <094f6fc5-7242-46c7-b454-4cb29d0c6ef9@q40g2000prh.googlegroups.com> <87tygs1v6g.fsf@benfinney.id.au> Message-ID: On Jan 30, 6:47?am, Tim Wintle wrote: > +1 - I think the source links are very useful (and thanks for pushing > them). Happy to do it. > However I think the biggest changes that have probably happened with > python itself are: > > ?(1) More users for whom this is their first language. > ?(2) CS courses / training not teaching C (or pointer-based languages). > > (2) is especially important IMO - under half of the python developers I > have regularly worked with would feel comfortable reading C - so for the > other half reading C source code probably isn't going to help them > understand exactly what's going on (although in the long run it might > help them a lot) That would explain why fewer people look at the C source code. However, even the parts of the standard library written in pure Python don't seem to be getting read anymore, so I'm still inclined to attribute the issue to 1) inconvenient placement of source code, 2) a largish code base, and 3) possibly a cultural shift. I'm thinking that all of those can be addressed by efforts to lower to intellectual investment required to find the relevant source code. Raymond From rantingrick at gmail.com Mon Jan 31 15:45:05 2011 From: rantingrick at gmail.com (rantingrick) Date: Mon, 31 Jan 2011 12:45:05 -0800 (PST) Subject: Use the Source Luke References: <094f6fc5-7242-46c7-b454-4cb29d0c6ef9@q40g2000prh.googlegroups.com> <87tygs1v6g.fsf@benfinney.id.au> <029f2ce4-e0fb-4cbc-a857-6cc7aa0a26f6@r4g2000vbq.googlegroups.com> <87hbcr1k38.fsf@benfinney.id.au> <4d44e750$0$29970$c3e8da3$5496439d@news.astraweb.com> <3a0492dc-7bbf-4458-b0a5-217d4bb87f5a@d23g2000prj.googlegroups.com> Message-ID: On Jan 30, 10:50?am, rusi wrote: > I note particularly the disclaimer that it was removed from wikipedia > [Like when censors stuff you know it > deserves a second look ;-) ] Oh you mean that channel that *claims* to provide a specific type of "programming" however they really provide *anything* but that specific type of programming! Yes, thank god for you tube. From prologic at shortcircuit.net.au Mon Jan 31 16:10:01 2011 From: prologic at shortcircuit.net.au (James Mills) Date: Tue, 1 Feb 2011 07:10:01 +1000 Subject: Python metaclass and UML In-Reply-To: <4D4715B7.2020803@shopzeus.com> References: <4D4715B7.2020803@shopzeus.com> Message-ID: On Tue, Feb 1, 2011 at 6:04 AM, Laszlo Nagy wrote: > How should I represent a Python metaclass on an UML class diagram? I know > how to represent composition, aggregation and inheritance. But not sure > about metaclasses. What kind of arrow or line should I use between a class > and its metaclass? Is there a standard for this? IHMO (but others may have other opinions) the same way you'd represent a decorated function. Metaclasses IHMO have the same effect as a decorated function - modifying another classes's behavior. cheers Jaes -- -- James Mills -- -- "Problems are solved by method" From ian.g.kelly at gmail.com Mon Jan 31 16:11:11 2011 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Mon, 31 Jan 2011 14:11:11 -0700 Subject: Python metaclass and UML In-Reply-To: <4D4715B7.2020803@shopzeus.com> References: <4D4715B7.2020803@shopzeus.com> Message-ID: On Mon, Jan 31, 2011 at 1:04 PM, Laszlo Nagy wrote: > How should I represent a Python metaclass on an UML class diagram? I know > how to represent composition, aggregation and inheritance. But not sure > about metaclasses. What kind of arrow or line should I use between a class > and its metaclass? Is there a standard for this? http://stackoverflow.com/questions/1483273/how-to-draw-a-classs-metaclass-in-uml From patty at cruzio.com Mon Jan 31 16:20:43 2011 From: patty at cruzio.com (Patty) Date: Mon, 31 Jan 2011 13:20:43 -0800 Subject: multiple values for keyword argument References: <9f669337-6116-4442-9c7e-54b0051e33a2@8g2000prb.googlegroups.com> <8qijsgFgu1U1@mid.dfncis.de> <4D443631.3000502@stoneleaf.us> <6f1dd6fbbc04d2788b2b191e3e407887.squirrel@cruziomail.cruzio.com> <4D470F18.9000103@sequans.com> Message-ID: <929BEBF809CC4B2AA4D08104B266423D@mycomputer> ----- Original Message ----- From: "Jean-Michel Pichavant" To: Cc: Sent: Monday, January 31, 2011 11:35 AM Subject: Re: multiple values for keyword argument > patty at cruzio.com wrote: >> I have been avoiding understanding this 'self', >> [snip] >> Regards, >> >> Patty >> > What is to be understood ?? self references the instance. Did I miss > something ? > > JM > > > Yes, there was more. And it's been fully explained at this point. Patty From ben+python at benfinney.id.au Mon Jan 31 16:22:08 2011 From: ben+python at benfinney.id.au (Ben Finney) Date: Tue, 01 Feb 2011 08:22:08 +1100 Subject: Understanding def foo(*args) References: Message-ID: <87fws8zs3j.fsf@benfinney.id.au> "Rob Richardson" writes: > My thanks both to the original poster and to JM for an excellent answer. > I saw this syntax for the first time recently, and I've been curious > about it too. Would it be correct of me to assume that you have not worked through the entire Python tutorial to get a thorough grounding in Python basics like this? -- \ ?I wish there was a knob on the TV to turn up the intelligence. | `\ There's a knob called ?brightness? but it doesn't work.? | _o__) ?Eugene P. Gallagher | Ben Finney From emile at fenx.com Mon Jan 31 17:07:17 2011 From: emile at fenx.com (Emile van Sebille) Date: Mon, 31 Jan 2011 14:07:17 -0800 Subject: Use the Source Luke In-Reply-To: References: <094f6fc5-7242-46c7-b454-4cb29d0c6ef9@q40g2000prh.googlegroups.com> <87tygs1v6g.fsf@benfinney.id.au> Message-ID: On 1/31/2011 12:35 PM Raymond Hettinger said... > That would explain why fewer people look at the C source code. > > However, even the parts of the standard library written in pure Python > don't seem to be getting read anymore, so I'm still inclined to > attribute the issue to 1) inconvenient placement of source code, > 2) a largish code base, and 3) possibly a cultural shift. > ISTM that around the time the list forked off py-dev fewer people remained that were singing 'use the source'. . . Emile From sigzero at gmail.com Mon Jan 31 17:11:29 2011 From: sigzero at gmail.com (Robert) Date: Mon, 31 Jan 2011 17:11:29 -0500 Subject: IDLE: A cornicopia of mediocrity and obfuscation. References: <48d40a1b-9bfc-47aa-b06c-9889273d835d@o32g2000prb.googlegroups.com> Message-ID: On 2011-01-31 15:19:44 -0500, rantingrick said: > On Jan 31, 1:32?pm, Giampaolo Rodol? wrote: >> So what you're actually telling is that Python won't survive another >> 10 years because: >> >> - IDLE is it's default editor > > Well not solely because IDLE is the default editor. IDLE is very > useful to newcommers and could be made even more useful however the > code base is rotten! Then DO something about it and no excuses. Fork it, make it better, submit it as a replacement. -- Robert From samzielkeryner at gmail.com Mon Jan 31 17:16:12 2011 From: samzielkeryner at gmail.com (Sascha) Date: Mon, 31 Jan 2011 14:16:12 -0800 (PST) Subject: Determine from a HTTP request if the user is on a Smart Phone, IE, Firefox Message-ID: Hello I am returning specialised website html according to what platform the user is on. Is there a way to determine if the user is on a Smart Phone or on IE or on Firefox? Using python &/or examining HTTP packets? From kw at codebykevin.com Mon Jan 31 17:17:06 2011 From: kw at codebykevin.com (Kevin Walzer) Date: Mon, 31 Jan 2011 17:17:06 -0500 Subject: IDLE: A cornicopia of mediocrity and obfuscation. In-Reply-To: References: Message-ID: <4871f$4d4734d6$4275d90a$28417@FUSE.NET> Rick, I've spent a fair amount of time in the IDLE source tree, putting together patches for various Mac-specific bugs and submitting them to the Python tracker, and I agree the code is crufty and disorganized. It is certainly not an example of current best practices in Tkinter development. The code base has accrued over the years, has been touched by many, many different hands, and I think its current messy state reflects that legacy. But, as I understand it, the purpose of IDLE is not to provide a pedagogical example of Tkinter programming practices, but instead to provide a lightweight development environment for those learning Python, to interactively explore different aspects of Python. For this it serves its purpose well. I use IDLE a good deal for my Python development work, and the cruftiness of the code under the hood is not an impediment to me getting my work done (unless the work is patching IDLE itself). Given this, I don't see any huge need to bulldoze IDLE to the ground and replace it with something else, or even do massive rewrites of the code, unless such a project also significantly improved the user-facing portions of IDLE as well. However, there are certainly no impediments for you undertaking such a project yourself: similar efforts have been undertaken in the past and, as I understand it, have led to some significant improvements in IDLE's performance. Here's the one I'm thinking of: http://idlefork.sourceforge.net/ According to this project's details, IDLE was forked, numerous changes were made to its code base, the new version of IDLE gained a user base, and eventually the changes were merged back in to Python's main line of development. It certainly would be interesting to see a fresh approach to IDLE, and I think the scope of such a project would be much easier for a single person to manage than would replacing Tkinter in the stdlib with another GUI toolkit, such as wxPython, or pyGUI, or something else. I'd encourage you to set up a project page somewhere, begin cutting some code, and then invite feedback from other users and/or developers. I think that approach has a much better chance of getting off the ground and making progress than long threads on c.l.py. Good luck! --Kevin -- Kevin Walzer Code by Kevin http://www.codebykevin.com From pappuyadav5555 at gmail.com Mon Jan 31 17:27:32 2011 From: pappuyadav5555 at gmail.com (sneha) Date: Mon, 31 Jan 2011 14:27:32 -0800 (PST) Subject: Earn $500 every day... Message-ID: <44653797-08ca-4e40-ba6d-2d8c2510ea6a@g1g2000prb.googlegroups.com> Way to Make Money Online for FREE! - Looking for the best, fast, easy and free way to make money online? Do you need Quick. Earn $500 every day... http://www.knowledge2know.com/earnmilliondollar.htm From gelonida at gmail.com Mon Jan 31 17:28:09 2011 From: gelonida at gmail.com (Gelonida) Date: Mon, 31 Jan 2011 23:28:09 +0100 Subject: simplest way to create simple standalone wsgi server without import wsgi_lib.server Message-ID: Hi, Normally I use following code snippet to quickly test a wsgi module without a web server. import wsgi_lib.server wsgi_lib.server.run(application, port=port) However Now I'd like to test a small wsgi module on a rather old host ( Python 2.4.3 ) where I don't have means to update python. Is there any quick and easy code snippet / module, performing the same task as my above mentioned lines? Thanks in advance for any hints From sigzero at gmail.com Mon Jan 31 17:38:32 2011 From: sigzero at gmail.com (Robert) Date: Mon, 31 Jan 2011 17:38:32 -0500 Subject: IDLE: A cornicopia of mediocrity and obfuscation. References: <4871f$4d4734d6$4275d90a$28417@FUSE.NET> Message-ID: On 2011-01-31 17:17:06 -0500, Kevin Walzer said: > > > It certainly would be interesting to see a fresh approach to IDLE, and I > think the scope of such a project would be much easier for a single > person to manage than would replacing Tkinter in the stdlib with another > GUI toolkit, such as wxPython, or pyGUI, or something else. I'd > encourage you to set up a project page somewhere, begin cutting some > code, and then invite feedback from other users and/or developers. I > think that approach has a much better chance of getting off the ground > and making progress than long threads on c.l.py. > > Good luck! > > --Kevin I think it would be interesting as well. Hmmmm, I am about to do the O'Reilly series that Steve Holden did for Python. Maybe I will take that up as a project when I get through it (or...*nudge* *nudge* *wink* *wink* to Rick, help out if someone else does a fork). -- Robert From steve+comp.lang.python at pearwood.info Mon Jan 31 17:39:40 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 31 Jan 2011 22:39:40 GMT Subject: Use the Source Luke References: <094f6fc5-7242-46c7-b454-4cb29d0c6ef9@q40g2000prh.googlegroups.com> <87tygs1v6g.fsf@benfinney.id.au> Message-ID: <4d473a2c$0$29970$c3e8da3$5496439d@news.astraweb.com> On Mon, 31 Jan 2011 12:35:12 -0800, Raymond Hettinger wrote: > However, even the parts of the standard library written in pure Python > don't seem to be getting read anymore, so I'm still inclined to > attribute the issue to 1) inconvenient placement of source code, 2) a > largish code base, and 3) possibly a cultural shift. I'd be inclined to say that #3 is by far the most important. When I started programming, the internet wasn't even a distant object on radar. (That is to say, it existed, but hardly anyone outside of a few gurus at universities had even heard of it.) If you wanted to learn a language, you bought a book and read it, if one existed and you could afford it, and you read the sample code that came with the software. Often the book you bought told you to read the sample code. You couldn't email a mailing list to ask for help, or post to a forum, or google the answer. If you were lucky, you could go to a Users Group once a month or so. And so "old timers" learned to read the source, because that's almost all there was. Today's newbies take the internet, web forums, mailing lists, usenet and google for granted. This is a *big* cultural shift. As for #1, in truth I don't believe it is actually a problem. Okay, it might be a bit inconvenient to find the Python source code the first few times you go looking (I can never remember whether to look in /usr/lib/python or /usr/local/lib/python), but once you've found it, it isn't difficult to create a shortcut for it. And as for #2, yes, there may be a lot of code in the standard library, but it's all cut up into small, easily swallowed chunks called "modules" :) In my experience, the biggest obstacles for people to read the Python code in the standard library are: (1) thinking to do so in the first place; and (2) the chicken-and-egg problem that as a newbie they often don't understand what they're reading. Your idea of including links to source in the documentation will hopefully help with the first. -- Steven From prologic at shortcircuit.net.au Mon Jan 31 17:46:55 2011 From: prologic at shortcircuit.net.au (James Mills) Date: Tue, 1 Feb 2011 08:46:55 +1000 Subject: Determine from a HTTP request if the user is on a Smart Phone, IE, Firefox In-Reply-To: References: Message-ID: On Tue, Feb 1, 2011 at 8:16 AM, Sascha wrote: > I am returning specialised website html according to what platform the > user is on. Is there a way to determine if the user is on a Smart > Phone or on IE or on Firefox? I have an iPad and just wrote a simple demo app to test this: http://prologic.no-ip.org:8000/ Source: http://codepad.org/zdZJgm1j Basically if you check for the string "iPad" in the User-Agent header. Obviously this only works for iPads running IOS and the built-in Safari Web Browser - but I'm sure other tablet/mobile devices provide similar unique User-Agent strings. cheers James -- -- James Mills -- -- "Problems are solved by method" From anikom15 at gmail.com Mon Jan 31 18:27:05 2011 From: anikom15 at gmail.com (Westley =?ISO-8859-1?Q?Mart=EDnez?=) Date: Mon, 31 Jan 2011 15:27:05 -0800 Subject: multiple values for keyword argument In-Reply-To: <929BEBF809CC4B2AA4D08104B266423D@mycomputer> References: <9f669337-6116-4442-9c7e-54b0051e33a2@8g2000prb.googlegroups.com> <8qijsgFgu1U1@mid.dfncis.de> <4D443631.3000502@stoneleaf.us> <6f1dd6fbbc04d2788b2b191e3e407887.squirrel@cruziomail.cruzio.com> <4D470F18.9000103@sequans.com> <929BEBF809CC4B2AA4D08104B266423D@mycomputer> Message-ID: <1296516425.23266.1.camel@localhost.localdomain> http://en.wikipedia.org/wiki/Self_(computer_science) On Mon, 2011-01-31 at 13:20 -0800, Patty wrote: > ----- Original Message ----- > From: "Jean-Michel Pichavant" > To: > Cc: > Sent: Monday, January 31, 2011 11:35 AM > Subject: Re: multiple values for keyword argument > > > > patty at cruzio.com wrote: > >> I have been avoiding understanding this 'self', > >> [snip] > >> Regards, > >> > >> Patty > >> > > What is to be understood ?? self references the instance. Did I miss > > something ? > > > > JM > > > > > > > > Yes, there was more. And it's been fully explained at this point. > > Patty -------------- next part -------------- An HTML attachment was scrubbed... URL: From clp2 at rebertia.com Mon Jan 31 18:34:30 2011 From: clp2 at rebertia.com (Chris Rebert) Date: Mon, 31 Jan 2011 15:34:30 -0800 Subject: Determine from a HTTP request if the user is on a Smart Phone, IE, Firefox In-Reply-To: References: Message-ID: On Mon, Jan 31, 2011 at 2:16 PM, Sascha wrote: > Hello > > I am returning specialised website html according to what platform the > user is on. Is there a way to determine if the user is on a Smart > Phone or on IE or on Firefox? Yes, the "User-Agent" HTTP header: http://en.wikipedia.org/wiki/User_agent Cheers, Chris From anikom15 at gmail.com Mon Jan 31 18:35:25 2011 From: anikom15 at gmail.com (Westley =?ISO-8859-1?Q?Mart=EDnez?=) Date: Mon, 31 Jan 2011 15:35:25 -0800 Subject: IDLE: A cornicopia of mediocrity and obfuscation. In-Reply-To: References: Message-ID: <1296516925.23266.3.camel@localhost.localdomain> alias idle='vim' : D On Mon, 2011-01-31 at 09:39 -0800, rantingrick wrote: > IDLE: A cornicopia of mediocrity and obfuscation. > -- by Rick Johnson > > > IDLE --which is the Python Integrated Development and Learning > Environment-- was once the apple of Guido's eye but has since > degenerated into madness many years ago and remains now as the shining > jewel "show piece" on the proverbial python wall of shame. A once > mighty dream of "programming for everyone" that is now nothing more > than an example of "how NOT to program". > > IDLE contains some of the worst code this community has created. Bad > design patterns, tacked on functionality, blasphemous styling, and > piss poor packaging. There seems to be no guiding goals or game-plan. > And year after year if IDLE *does* get any attention it's just more > haphazard code thrown into the mix by someone who has gone blind from > reading the source. However we cannot blame the current maintainer (if > any such even exists!) because NOBODY can maintains such a spaghetti > mess that this package has become! > > If we would have had a proper game plan from day one i believe we > could have avoided this catastrophe. Follows is an outline of the > wrongs with some suggestions to right them... > > * First of all the main two modules "PyShell" and "EditorWindow" are > laid out in such a non sequential way that it is virtually impossible > to follow along. We should have had a proper app instance from which > all widgets where combined. The main app should have followed a > "common sense" sequential mentality of... > > * subclassing the tk.Toplevel > * initializing instance variables > * creating the main menu > * creating the sub widgets > * declaring internal methods > * declaring event handlers > * then interface/generic methods. > > This is the recipe for order AND NOT CHAOS! What we have now is utter > chaos! When we have order we can read source code in a sequential > fashion. When we have order we can comprehend what we read. And when > we have order we can maintain a library/package with ease. However > sadly we DO NOT have order, we have CHAOS, CHAOS, and more CHAOS! > > * The underlying sub widgets should have started with their own proper > order of "declared" initialization. And all events should be handled > in the widget at hand NOT outsourced to some other class! > > * One of the biggest design flaws is the fact that outside modules > manipulate the main editor/pyshells events. This is a terrible way to > code. For example the AutoCompleteWindow takes over the tab event.... > > #-- Puesdo Code --# > # in editor window __init__ > self.autocomplete = AutoComplete(blah) > # in editor window onKeyPress(blah) > if key == 'Tab' and blah: > self.autocomplete.show_tip(blah) > elif key == 'Escape' and acw.is_visibe(): > self.autocomplete.hide() > > This is a bad design! The main editor window should handle all its > own events AND THEN call outside class methods when needed. We don't > want "Mommy" classes telling the kids what to do, when to eat, when to > sleep, and when to excrete! We should create our objects with the > virtue of self reliance and responsibility!. The Colorizer, > ParenMatch, textView, TreeWidget, CallTips, and many other modules are > guilty of "event stealing" also. Event functionality must be handled > in the widget itself, NOT stolen and handled in an outside class. When > we split up sequential code we get CHAOS! > > * Another bad choice was creating custom reusable widgets > (Tabbedpages, FindDialog, ReplaceDialog, etc...) and leaving them in > idlelib. These should have been moved into the lib-tk module where > they would be more visible to python programmers AND we could reduce > the cruft in the idlelib! Remember, when we create more files, > folders, and objects we create CHAOS. And nobody can learn from CHAOS! > > * Another blasphemy is the fact that every module should include some > sort of test to display its usage. If the module is a GUI widget then > you MUST show how to use the widget in a window. Sadly like all > everything else, idlelib is devoid of examples and testing. And the > very few tests that DO exists just blow chunks! > > * Last but not least idlelib does not follow PEP8 or ANY convention. > So much so that it seems the developers snubbed their nose at such > conventions! We are missing doc strings and comments. We have built- > ins being re-bound! Just code horror after code horror. > > These are just the top of the list. The peak of a huge iceberg that > threatens to sink the community in the arms of chaos never to return. > I am beginning to believe that this community is either made of > amateurs due to this lackluster code in the stdlib. However it could > be that the folks are really professional and refuse to work on such a > horrible code base (which i understand). I am going with the latter. > > When are we going to demand that these abominations be rectified? How > much longer must we wait? A year? Ten years?... i don't think Python > will survive another ten years with this attitude of obfuscation, and > mentality of mediocrity. > > -- rr: disappointed and annoyed! > > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From me+list/python at ixokai.io Mon Jan 31 19:14:12 2011 From: me+list/python at ixokai.io (Stephen Hansen) Date: Mon, 31 Jan 2011 16:14:12 -0800 Subject: IDLE: A cornicopia of mediocrity and obfuscation. In-Reply-To: References: Message-ID: <4D475054.5010903@ixokai.io> On 1/31/11 10:12 AM, rantingrick wrote: > -- rr: disappointed and annoyed! tl;dr You did this one before, I swear. You're running out of material. -- Stephen Hansen ... Also: Ixokai ... Mail: me+list/python (AT) ixokai (DOT) io ... Blog: http://meh.ixokai.io/ -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 487 bytes Desc: OpenPGP digital signature URL: From vivshrivastava at gmail.com Mon Jan 31 19:51:18 2011 From: vivshrivastava at gmail.com (Vivek Shrivastava) Date: Mon, 31 Jan 2011 16:51:18 -0800 Subject: Determine from a HTTP request if the user is on a Smart Phone, IE, Firefox In-Reply-To: References: Message-ID: > > its userAgent or UserAgent String. Though its easy to send request with > any( fake) userAgent but its industry standard to get browser information > from userAgent only. > > http://www.useragentstring.com/pages/useragentstring.php > > > > On Mon, Jan 31, 2011 at 2:46 PM, James Mills > wrote: > >> On Tue, Feb 1, 2011 at 8:16 AM, Sascha wrote: >> > I am returning specialised website html according to what platform the >> > user is on. Is there a way to determine if the user is on a Smart >> > Phone or on IE or on Firefox? >> >> I have an iPad and just wrote a simple demo app to test this: >> >> http://prologic.no-ip.org:8000/ >> >> Source: http://codepad.org/zdZJgm1j >> >> Basically if you check for the string "iPad" in >> the User-Agent header. Obviously this only >> works for iPads running IOS and the built-in >> Safari Web Browser - but I'm sure other tablet/mobile >> devices provide similar unique User-Agent strings. >> >> cheers >> James >> >> -- >> -- James Mills >> -- >> -- "Problems are solved by method" >> -- >> http://mail.python.org/mailman/listinfo/python-list >> > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ben+python at benfinney.id.au Mon Jan 31 20:53:35 2011 From: ben+python at benfinney.id.au (Ben Finney) Date: Tue, 01 Feb 2011 12:53:35 +1100 Subject: Determine from a HTTP request if the user is on a Smart Phone, IE, Firefox References: Message-ID: <878vy0zfj4.fsf@benfinney.id.au> Sascha writes: > I am returning specialised website html according to what platform the > user is on. Is there a way to determine if the user is on a Smart > Phone or on IE or on Firefox? The HTTP standard defines the ?User-Agent? field, to be sent as part of the request header . Note that this information is often abused by web server operators, and the response of many users is to mangle or fabricate this field before it is sent to the server. (My browser, for example, instructs the reader to stop obsessing about User-Agent and to code for web standards instead .) -- \ ?If you do not trust the source do not use this program.? | `\ ?Microsoft Vista security dialogue | _o__) | Ben Finney From calderone.jeanpaul at gmail.com Mon Jan 31 21:07:45 2011 From: calderone.jeanpaul at gmail.com (Jean-Paul Calderone) Date: Mon, 31 Jan 2011 18:07:45 -0800 (PST) Subject: simplest way to create simple standalone wsgi server without import wsgi_lib.server References: Message-ID: <685d5386-d5bc-44aa-bb8c-2a395a458cde@i39g2000prd.googlegroups.com> On Jan 31, 5:28?pm, Gelonida wrote: > Hi, > > Normally I use following code snippet to quickly test a wsgi module > without a web server. > > import wsgi_lib.server > wsgi_lib.server.run(application, port=port) > > However Now I'd like to test a small wsgi module on a rather old host > ( Python 2.4.3 ) where I don't have means to update python. > > Is there any quick and easy code snippet / module, performing the same > task as my above mentioned lines? > > Thanks in advance for any hints You didn't mention why you can't update Python, or if that means you can't install new libraries either. However, if you have Twisted 8.2 or newer, you can replace your snippet with this shell command: twistd -n web --port --wsgi is the fully-qualified Python name of your application object. So, for example if you have a module named "foo" that defines an "application" name, you would pass "foo.application". Jean-Paul From patty at cruzio.com Mon Jan 31 21:18:48 2011 From: patty at cruzio.com (Patty) Date: Mon, 31 Jan 2011 18:18:48 -0800 Subject: multiple values for keyword argument References: <9f669337-6116-4442-9c7e-54b0051e33a2@8g2000prb.googlegroups.com> <8qijsgFgu1U1@mid.dfncis.de> <4D443631.3000502@stoneleaf.us><6f1dd6fbbc04d2788b2b191e3e407887.squirrel@cruziomail.cruzio.com><4D470F18.9000103@sequans.com><929BEBF809CC4B2AA4D08104B266423D@mycomputer> <1296516425.23266.1.camel@localhost.localdomain> Message-ID: <9CEC7810060C403B8CF46D9D98C00BAB@mycomputer> >----- Original Message ----- >From: Westley Mart?nez >To: python-list at python.org >Sent: Monday, January 31, 2011 3:27 PM >Subject: Re: multiple values for keyword argument >http://en.wikipedia.org/wiki/Self_(computer_science) Hello Westley: Thank you for the reference. I saw something in it that I think is what tripped me up in my understanding of 'self'. I printed out the page to absorb more later. It helps me to learn when the concept is introduced to me in terms of comparison to other languages so I like this page. Here are the two lines from the wiki page, I was probably going to try and 'assign to self' and expecting that I was modifying the original object like it says. In turn, that is what was leading me to want to name 'self' anything I want, to jog my memory as to 'where it came from' because '*I* am assigning it'. [I know I should be documenting my code clearly and my memory shouldn't need to be jogged :} ]. "Some languages, such as Objective-C, allow assignment to this, although it is deprecated. Doing so can be very misleading to maintenance programmers, because the assignment does not modify the original object, only changing which object that the rest of the code in the method refers to, and can end with undefined behavior" Regards - Patty On Mon, 2011-01-31 at 13:20 -0800, Patty wrote: ----- Original Message ----- From: "Jean-Michel Pichavant" To: Cc: Sent: Monday, January 31, 2011 11:35 AM Subject: Re: multiple values for keyword argument > patty at cruzio.com wrote: >> I have been avoiding understanding this 'self', >> [snip] >> Regards, >> >> Patty >> > What is to be understood ?? self references the instance. Did I miss > something ? > > JM > > > Yes, there was more. And it's been fully explained at this point. Patty ------------------------------------------------------------------------------ -- http://mail.python.org/mailman/listinfo/python-list -------------- next part -------------- An HTML attachment was scrubbed... URL: From anikom15 at gmail.com Mon Jan 31 21:36:12 2011 From: anikom15 at gmail.com (Westley =?ISO-8859-1?Q?Mart=EDnez?=) Date: Mon, 31 Jan 2011 18:36:12 -0800 Subject: multiple values for keyword argument In-Reply-To: <9CEC7810060C403B8CF46D9D98C00BAB@mycomputer> References: <9f669337-6116-4442-9c7e-54b0051e33a2@8g2000prb.googlegroups.com> <8qijsgFgu1U1@mid.dfncis.de> <4D443631.3000502@stoneleaf.us> <6f1dd6fbbc04d2788b2b191e3e407887.squirrel@cruziomail.cruzio.com> <4D470F18.9000103@sequans.com><929BEBF809CC4B2AA4D08104B266423D@mycomputer> <1296516425.23266.1.camel@localhost.localdomain> <9CEC7810060C403B8CF46D9D98C00BAB@mycomputer> Message-ID: <1296527772.23266.8.camel@localhost.localdomain> In Python, self is simply the standard name used. You can use any name. Consider this: >>> class Spam: ... def __init__(self): ... print(self) ... self = 'eggs' ... print(self) ... >>> spam = Spam() <__main__.Spam object at 0xb7224b4c> eggs When we have an instance method, here __init__, we always pass the instance as the first argument. This is assigned as regular old variable. It doesn't have any special restrictions. So when we refer self to a string, self simply stops pointing to the object and points to the string instead, but remember that each self is only contained in its method, so all the other selfs in the class will still point to the object. On Mon, 2011-01-31 at 18:18 -0800, Patty wrote: > ? > > >----- Original Message ----- > >From: Westley Mart?nez > >To: python-list at python.org > >Sent: Monday, January 31, 2011 3:27 PM > >Subject: Re: multiple values for keyword argument > > > >http://en.wikipedia.org/wiki/Self_(computer_science) > > Hello Westley: > > Thank you for the reference. I saw something in it that I > think is what tripped me up in my understanding of 'self'. I > printed out the page to absorb more later. It helps me to > learn when the concept is introduced to me in terms of > comparison to other languages so I like this page. Here are > the two lines from the wiki page, I was probably going to try > and 'assign to self' and expecting that I was modifying the > original object like it says. In turn, that is what was > leading me to want to name 'self' anything I want, to jog my > memory as to 'where it came from' because '*I* am assigning > it'. [I know I should be documenting my code clearly and my > memory shouldn't need to be jogged :} ]. > "Some languages, such as Objective-C, allow assignment to > this, although it is deprecated. Doing so can be very > misleading to maintenance programmers, because the assignment > does not modify the original object, only changing which > object that the rest of the code in the method refers to, and > can end with undefined behavior" > > Regards - > > Patty > > > On Mon, 2011-01-31 at 13:20 -0800, Patty wrote: > > > > ----- Original Message ----- > > From: "Jean-Michel Pichavant" > > To: > > Cc: > > Sent: Monday, January 31, 2011 11:35 AM > > Subject: Re: multiple values for keyword argument > > > > > > > patty at cruzio.com wrote: > > >> I have been avoiding understanding this 'self', > > >> [snip] > > >> Regards, > > >> > > >> Patty > > >> > > > What is to be understood ?? self references the instance. Did I miss > > > something ? > > > > > > JM > > > > > > > > > > > > > Yes, there was more. And it's been fully explained at this point. > > > > Patty > > > > > > ______________________________________________________________ > > -- > http://mail.python.org/mailman/listinfo/python-list -------------- next part -------------- An HTML attachment was scrubbed... URL: From mandersonrandersonanderson at gmail.com Mon Jan 31 21:43:25 2011 From: mandersonrandersonanderson at gmail.com (Nanderson) Date: Mon, 31 Jan 2011 18:43:25 -0800 (PST) Subject: Running python scripts from the command line. Message-ID: <2e8ce9be-fa71-42ff-a9bf-446bb9ec86dc@l22g2000pre.googlegroups.com> I've recently started to program. Python is my first language, so I'm a complete beginner. I've been trying to call python scripts from the command line by entering this command into it: >>>python test.py But it gives me this error message: >>>python test.py File "", line 1 python test.py ^ SyntaxError: invalid syntax I know that test.py exists, and the script is correct (here is is anyways): a = 1 if a: print 'Value of a is', a I am using python 2.7.1 installed on Windows 7. This seems like something that should be easy, so I'm sure I'm just missing a very small problem. Any help is greatly appreciated. Thanks, Anderson From benjamin.kaplan at case.edu Mon Jan 31 21:54:28 2011 From: benjamin.kaplan at case.edu (Benjamin Kaplan) Date: Mon, 31 Jan 2011 21:54:28 -0500 Subject: Running python scripts from the command line. In-Reply-To: <2e8ce9be-fa71-42ff-a9bf-446bb9ec86dc@l22g2000pre.googlegroups.com> References: <2e8ce9be-fa71-42ff-a9bf-446bb9ec86dc@l22g2000pre.googlegroups.com> Message-ID: On Mon, Jan 31, 2011 at 9:43 PM, Nanderson wrote: > I've recently started to program. Python is my first language, so I'm > a complete beginner. I've been trying to call python scripts from the > command line by entering this command into it: > >>>>python test.py > > But it gives me this error message: > >>>>python test.py > ?File "", line 1 > ? ?python test.py > ? ? ? ? ? ? ? ? ? ^ > SyntaxError: invalid syntax > > I know that test.py exists, and the script is correct (here is is > anyways): > > a = 1 > if a: > ? ?print 'Value of a is', a > > I am using python 2.7.1 installed on Windows 7. This seems like > something that should be easy, so I'm sure I'm just missing a very > small problem. Any help is greatly appreciated. > > Thanks, > Anderson You're already in Python when you type that. If you want to run a script, you need to call Python from your normal shell, not from inside the Python interpreter. $ python Python 2.6.6 (r266:84292, Jan 10 2011, 20:14:15) [GCC 4.2.1 (Apple Inc. build 5659)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> python Traceback (most recent call last): File "", line 1, in NameError: name 'python' is not defined >>> exit() $ python test.py Value of a is 1 > -- > http://mail.python.org/mailman/listinfo/python-list > From mandersonrandersonanderson at gmail.com Mon Jan 31 22:08:29 2011 From: mandersonrandersonanderson at gmail.com (Nanderson) Date: Mon, 31 Jan 2011 19:08:29 -0800 (PST) Subject: Running python scripts from the command line. References: <2e8ce9be-fa71-42ff-a9bf-446bb9ec86dc@l22g2000pre.googlegroups.com> Message-ID: <736780ab-c840-4f5e-bb4b-5b063771ff4f@w7g2000pre.googlegroups.com> On Jan 31, 6:54?pm, Benjamin Kaplan wrote: > On Mon, Jan 31, 2011 at 9:43 PM, Nanderson > > > > > > > > > > wrote: > > I've recently started to program. Python is my first language, so I'm > > a complete beginner. I've been trying to call python scripts from the > > command line by entering this command into it: > > >>>>python test.py > > > But it gives me this error message: > > >>>>python test.py > > ?File "", line 1 > > ? ?python test.py > > ? ? ? ? ? ? ? ? ? ^ > > SyntaxError: invalid syntax > > > I know that test.py exists, and the script is correct (here is is > > anyways): > > > a = 1 > > if a: > > ? ?print 'Value of a is', a > > > I am using python 2.7.1 installed on Windows 7. This seems like > > something that should be easy, so I'm sure I'm just missing a very > > small problem. Any help is greatly appreciated. > > > Thanks, > > Anderson > > You're already in Python when you type that. If you want to run a > script, you need to call Python from your normal shell, not from > inside the Python interpreter. > > $ python > Python 2.6.6 (r266:84292, Jan 10 2011, 20:14:15) > [GCC 4.2.1 (Apple Inc. build 5659)] on darwin > Type "help", "copyright", "credits" or "license" for more information.>>> python > > Traceback (most recent call last): > ? File "", line 1, in > NameError: name 'python' is not defined>>> exit() > > $ ?python test.py > Value of a is 1 > > > > > > > > > -- > >http://mail.python.org/mailman/listinfo/python-list Wow, thank you very much for your help. This worked absolutely great. I feel like a huge n00b after that though; it was just so obvious! Anyways, like I said before, thank you very much for your help. Anderson From g.rodola at gmail.com Mon Jan 31 22:24:59 2011 From: g.rodola at gmail.com (=?ISO-8859-1?Q?Giampaolo_Rodol=E0?=) Date: Tue, 1 Feb 2011 04:24:59 +0100 Subject: IDLE: A cornicopia of mediocrity and obfuscation. In-Reply-To: <48d40a1b-9bfc-47aa-b06c-9889273d835d@o32g2000prb.googlegroups.com> References: <48d40a1b-9bfc-47aa-b06c-9889273d835d@o32g2000prb.googlegroups.com> Message-ID: 2011/1/31 rantingrick : > In an ideal world it should be the first place you look when wanting > to learn how to build medium sized GUI projects with the built-in > Tkinter module. I wouldn't do that, and thankfully in the *real* world what is considered more important usually gets more attention. If instead of ranting nonsense all day long you would spend a little bit of your time by taking a look at how crowded the python bug tracker already is, you would discover an interesting thing which goes under the name of "priority". High priority bugs get fixed first. IDLE source code is clearly not a high priority issue, hence it doesn't get fixed: end of story. Actually I don't even understand how can IDLE source code quality have anything to do with python success or future adoption, as you implied in your statements. And why do you care so much anyway? You have spent the past 5 days blabbing about how bad Tkinter is, how ugly and useless it is nowadays, and now you suddenly care about IDLE source code quality? Do you have any idea how ridiculous this looks from the outside? > However the reality is ANYTHING but ideal. The code is > rotten to the core, full of inconsistencies and just very unpythonic. 99% of the times the right answer to this statement is "go file a bug and possibly provide a patch" but not in your case since it's clear that you have absolutely no interest in resolving *anything*, let alone actually write some code, assuming you're able to do so in the first place. >> Personally I've never looked into idlelib directory for 7 years in a row at all. >> I was probably doing some other things, I don't know, but now I'm >> definitively gonna start looking for a new language because it's clear >> that any language having a directory called "idlelib" within such a >> horrible source code is not gonna last for long. > > Well not unless we do something about it. It is high time to stop > patching, bolting on, and future extending the suffering of this > horrendous code base. It is time to pull the plug, let it die, and > start fresh. Start from a real python perspective. We can learn from > past mistakes and build something much better. But will we? Do we have > the community spirit to take on this challenge? Do we as a community > have any fire left or have we collectively waxed cold? How can you possibly not understand that I was being sarcastic? --- Giampaolo http://code.google.com/p/pyftpdlib/ http://code.google.com/p/psutil/ From ameyer2 at yahoo.com Mon Jan 31 22:42:46 2011 From: ameyer2 at yahoo.com (Alan Meyer) Date: Mon, 31 Jan 2011 22:42:46 -0500 Subject: how to read the last line of a huge file??? In-Reply-To: References: Message-ID: On 01/26/2011 04:22 PM, MRAB wrote: > On 26/01/2011 10:59, Xavier Heruacles wrote: >> I have do some log processing which is usually huge. The length of each >> line is variable. How can I get the last line?? Don't tell me to use >> readlines or something like linecache... >> > Seek to somewhere near the end and then read use readlines(). If you > get fewer than 2 lines then you can't be sure that you have the entire > last line, so seek a little farther from the end and try again. I think this has got to be the most efficient solution. You might get the source code for the open source UNIX utility "tail" and see how they do it. It seems to work with equal speed no matter how large the file is and I suspect it uses MRAB's solution, but because it's written in C, it probably examines each character directly rather than calling a library routine like readlines. Alan From ameyer2 at yahoo.com Mon Jan 31 22:45:23 2011 From: ameyer2 at yahoo.com (Alan Meyer) Date: Mon, 31 Jan 2011 22:45:23 -0500 Subject: Looking for Remote Python Project In-Reply-To: <4d1ff594-925b-457e-be62-7e4ca32ae136@33g2000pru.googlegroups.com> References: <4d1ff594-925b-457e-be62-7e4ca32ae136@33g2000pru.googlegroups.com> Message-ID: On 01/29/2011 04:19 PM, joy99 wrote: > Dear Room, > > I am a Python Programmer from India(New Delhi Region), and I worked > for quite a long time in Bangalore. I have been working in Python for > the last 4 years or so. I have successfully built around 15 projects > in Python. I am looking for some remote Python Projects, which can be > done from home. > > If any one knows of anything, I may be helpful enough. > > Best Regards, > Subhabrata. Subharata, Would you be willing to tell us what a programmer with your level of experience typically charges per hour for his services? I'm not in a position to hire anyone, I'm just a programmer myself. But I'm curious about rates in India vs. the U.S., where I live and work. Thanks and good luck with your efforts to get work. Alan From smersh009x at gmail.com Mon Jan 31 23:23:34 2011 From: smersh009x at gmail.com (SMERSH009) Date: Mon, 31 Jan 2011 20:23:34 -0800 (PST) Subject: Converting getCSS Count Code from java to python Message-ID: <1667474c-7080-44f8-81a3-c0fb31f41e22@d23g2000prj.googlegroups.com> Hi, I'd love some help converting this code to the python equivalent: private int getCSSCount(String aCSSLocator){ String jsScript = "var cssMatches = eval_css(\"%s\", window.document);cssMatches.length;"; return Integer.parseInt(selenium.getEval(String.format(jsScript, aCSSLocator))); } http://www.eviltester.com/index.php/2010/03/13/a-simple-getcsscount-helper-method-for-use-with-selenium-rc/ Thanks for the help From kushal.kumaran+python at gmail.com Mon Jan 31 23:58:05 2011 From: kushal.kumaran+python at gmail.com (Kushal Kumaran) Date: Tue, 1 Feb 2011 10:28:05 +0530 Subject: how to read the last line of a huge file??? In-Reply-To: References: Message-ID: On Tue, Feb 1, 2011 at 9:12 AM, Alan Meyer wrote: > On 01/26/2011 04:22 PM, MRAB wrote: >> >> On 26/01/2011 10:59, Xavier Heruacles wrote: >>> >>> I have do some log processing which is usually huge. The length of each >>> line is variable. How can I get the last line?? Don't tell me to use >>> readlines or something like linecache... >>> >> Seek to somewhere near the end and then read use readlines(). If you >> get fewer than 2 lines then you can't be sure that you have the entire >> last line, so seek a little farther from the end and try again. > > I think this has got to be the most efficient solution. > > You might get the source code for the open source UNIX utility "tail" and > see how they do it. ?It seems to work with equal speed no matter how large > the file is and I suspect it uses MRAB's solution, but because it's written > in C, it probably examines each character directly rather than calling a > library routine like readlines. > How about mmapping the file and using rfind? def mapper(filename): with open(filename) as f: mapping = mmap.mmap(f.fileno(), 0, prot=mmap.PROT_READ) endIdx = mapping.rfind('\n') startIdx = mapping.rfind('\n', 0, endIdx) return mapping[startIdx + 1:endIdx] def seeker(filename): offset = -10 with open(filename, 'rb') as f: while True: f.seek(offset, os.SEEK_END) lines = f.readlines() if len(lines) >= 2: return lines[-1][:-1] offset *= 2 In [1]: import timeit In [2]: timeit.timeit('finders.seeker("the-file")', 'import finders') Out[2]: 32.216405868530273 In [3]: timeit.timeit('finders.mapper("the-file")', 'import finders') Out[3]: 16.805877208709717 the-file is a 120M file with ~500k lines. Both functions assume the last line has a trailing newline. It's easy to correct if that's not the case. I think mmap works similarly on Windows, but I've never tried there. -- regards, kushal