Re: [Tutor] IDLE Usage - was Interpreter Restarts

2007-07-23 Thread Robert H. Haener IV
Alan Gauld wrote: I've heard of screen but never used it. The biggest problem I can see with it is that you can only see one screen(sic) at a time or use split screens to see partial screens. Can you copy/paste between sessions? Does it run on a remote server within the SSH client? If so

Re: [Tutor] don't repeat yourself; question about code optimization

2007-07-23 Thread tpc247
On 7/20/07, Bob Gailer [EMAIL PROTECTED] wrote: Take advantage of slicing: def create_grid(self): table = [] for i in range(0, len(self.total_num_of_items), self.max_num_of_items_per_row): table.append(tuple(self.total_num_of_items[i : i +

Re: [Tutor] IDLE Usage - was Interpreter Restarts

2007-07-23 Thread Alan Gauld
Robert H. Haener IV [EMAIL PROTECTED] wrote This is the second message I've seen asking some questions about screen which I already answered on the 17th. I know this is more than a little OT, I'm just wondering if somehow you didn't get that message. I was still on vacation on the 17th so

Re: [Tutor] don't repeat yourself; question about code optimization

2007-07-23 Thread Alan Gauld
[EMAIL PROTECTED] wrote one part where I believe I violate the prime directive of coding, which is not to repeat yourself: The prime directive of coding is make it readable! The DRY principle is just that a principle. If repeating makes for more maintainable or readable code then repeat

[Tutor] Restarting a module

2007-07-23 Thread Tino Dai
Hi Everybody, I have a question about restarting a part of the program after it dies. I have a driver program that instantiates a class and runs methods from that class. Occasionally, the method gets bad data and it bombs out. Instead of bombing out, I would like the program to grab new data

Re: [Tutor] Restarting a module

2007-07-23 Thread Alan Gauld
Tino Dai [EMAIL PROTECTED] wrote Your code confused me on several counts but in general... I have a question about restarting a part of the program after it dies. I have a driver program that instantiates a class and runs methods from that class. Occasionally, the method gets bad data

[Tutor] Regex Ordering

2007-07-23 Thread Shidan
I'm looking for a Python module that provides methods for ordering regexes based on how general they are ( how much they match). Do I have to write it myself or does something exist already. Shidan ___ Tutor maillist - Tutor@python.org

Re: [Tutor] Regex Ordering

2007-07-23 Thread James Hartley
On 7/23/07, Shidan [EMAIL PROTECTED] wrote: I'm looking for a Python module that provides methods for ordering regexes based on how general they are ( how much they match). Do I have to write it Your question is relative. Classifying which regular expression is more general depends upon the

Re: [Tutor] IDLE Usage - was Interpreter Restarts

2007-07-23 Thread Eric Brunson
Alan Gauld wrote: Eric Brunson [EMAIL PROTECTED] wrote http://en.wikipedia.org/wiki/GNU_Screen You can only see one screen at a time as far as I know. If you need split screens, use emacs. The wiki page shows a split screen session and claims you can split any

Re: [Tutor] IDLE Usage - was Interpreter Restarts

2007-07-23 Thread Robert H. Haener IV
Alan Gauld wrote: I was still on vacation on the 17th so wouldn't have seen it then. But I just checked the gmane archive and there is nothing from you on the 17th about screen. (Lots about vim and SSH etc but not about screen) Alan G. This is the last I'll add to this little derailment,

Re: [Tutor] don't repeat yourself; question about code optimization

2007-07-23 Thread Bob Gailer
[EMAIL PROTECTED] wrote: On 7/20/07, *Bob Gailer* [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: Take advantage of slicing: def create_grid(self): table = [] for i in range(0, len( self.total_num_of_items), self.max_num_of_items_per_row):

Re: [Tutor] IDLE Usage - was Interpreter Restarts

2007-07-23 Thread Eric Brunson
Eric Brunson wrote: Alan Gauld wrote: Eric Brunson [EMAIL PROTECTED] wrote http://en.wikipedia.org/wiki/GNU_Screen You can only see one screen at a time as far as I know. If you need split screens, use emacs. The wiki page shows a split

Re: [Tutor] Restarting a module

2007-07-23 Thread Tino Dai
Sorry about that. I think that a simpler question would be: In my driver code: ap = apacheModule.apacheModule(configXML) while 1: try: rVs=ap.perf() for anObj in self.objList: getattr(anObj,do)(rVs) time.sleep(1) except

Re: [Tutor] don't repeat yourself; question about code optimization CORRECTION

2007-07-23 Thread Bob Gailer
A correction to the code at the end. The test of self.total_num_of_items should precede the pop(0) [EMAIL PROTECTED] wrote: On 7/20/07, *Bob Gailer* [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: Take advantage of slicing: def create_grid(self): table = []

Re: [Tutor] Regex Ordering

2007-07-23 Thread Bill Campbell
On Mon, Jul 23, 2007, James Hartley wrote: On 7/23/07, Shidan [EMAIL PROTECTED] wrote: I'm looking for a Python module that provides methods for ordering regexes based on how general they are ( how much they match). Do I have to write it Your question is relative. Classifying which regular

[Tutor] sorting objects in lists by 2 attr

2007-07-23 Thread Philippe Niquille
Hi I have a hard time sorting an object list. Perhaps this is kind of a noob question, but I would very much appreciate any help! Using django I get a QuerySet of Score objects which are sorted by the actual score, the actual score divided by the max. possible score (so sorting by two db

Re: [Tutor] sorting objects in lists by 2 attr

2007-07-23 Thread Eric Brunson
Philippe Niquille wrote: Hi I have a hard time sorting an object list. Perhaps this is kind of a noob question, but I would very much appreciate any help! Using django I get a QuerySet of Score objects which are sorted by the actual score, the actual score divided by the max. possible

Re: [Tutor] Restarting a module

2007-07-23 Thread Alan Gauld
Tino Dai [EMAIL PROTECTED] wrote Sorry about that. I think that a simpler question would be: I'm not sure what the better question is, but I think I answered it :-) In my driver code: ap = apacheModule.apacheModule(configXML) while 1: try: rVs=ap.perf() for

Re: [Tutor] sorting objects in lists by 2 attr

2007-07-23 Thread Alan Gauld
Philippe Niquille [EMAIL PROTECTED] wrote The problem I now have, is that I lost the sorting order, as described above. How would I resort it with a python algortithm instead of SQL? Why not use SQL? Best to get the highest quality data into your program that you can, the earlier you

Re: [Tutor] How to determine if every character in one string is inanother string?

2007-07-23 Thread Terry Carroll
On Sun, 22 Jul 2007, Jerry Hill wrote: On 7/21/07, Alan Gauld [EMAIL PROTECTED] wrote: all(char in string.printable for char in testString) What is all? Is that a 2.5 thing (I'm still on 2.4 here) Yes, it's a 2.5 thing. That was my favorite, too. I didn't notice the new all method

Re: [Tutor] sorting objects in lists by 2 attr

2007-07-23 Thread Eric Walstad
Philippe Niquille wrote: Using django I get a QuerySet of Score objects which are sorted by the actual score, the actual score divided by the max. possible score (so sorting by two db fields). I then need to loop through that queryset and sum up all the score objects which belong to the

Re: [Tutor] How to determine if every character in one string is inanother string?

2007-07-23 Thread wesley chun
all(char in string.printable for char in testString) That was my favorite, too. I didn't notice the new all method in 2.5. It certainly seems the most Pythonic approach. all() has a sister built-in function, also introduced in 2.5, so i think that any(char not in string.printable for

Re: [Tutor] Restarting a module

2007-07-23 Thread Tino Dai
On 7/23/07, Alan Gauld [EMAIL PROTECTED] wrote: Tino Dai [EMAIL PROTECTED] wrote Sorry about that. I think that a simpler question would be: I'm not sure what the better question is, but I think I answered it :-) In my driver code: ap = apacheModule.apacheModule(configXML) while 1:

Re: [Tutor] How to determine if every character in one string isinanother string?

2007-07-23 Thread Alan Gauld
wesley chun [EMAIL PROTECTED] wrote the solutions using LCs above are great when it comes to an expressive piece of code in a one-liner, but i feel there's a waste of time/memory. the use of GEs is better, but it still has to iterate over the entire string when i don't feel that it should

Re: [Tutor] How to determine if every character in one string isinanother string?

2007-07-23 Thread wesley chun
One of my only peeves with LCs is that they always iterate to the end, I'd like an optional extra 'until' clause, like: lst = [n for n in veryBigSequence if someTest(n) until anotherTest(n)] This would act as usual until the final expression was true at which point it would stop iterating.

Re: [Tutor] about importing a module

2007-07-23 Thread Tiger12506
If the module has been imported before your code is run, it will be the library module (very important if working in IDLE which importants many modules, for example). So... how does IDLE go about importanting a module? ;) It's not *how* IDLE imports the module, but that fact that IDLE

Re: [Tutor] another question ( unrelated )

2007-07-23 Thread Tiger12506
Perhaps everyone is trying too hard. Instead of trying to re-initialize the thread on error, let the thread create a new seperate thread and destroy itself naturally. Maybe a shot in the dark? :-/ JS ___ Tutor maillist - Tutor@python.org

Re: [Tutor] Here is newbie doc on how to implement generators

2007-07-23 Thread Dave Kuhlman
On Mon, Jul 16, 2007 at 06:13:35PM -0400, Kent Johnson wrote: Kent - Rather than try to reply in detail to your suggestions, I've tried to ammend my document to reflect your comments. Thanks again for the help. Dave [good suggestions and corrections from Kent, snipped] -- Dave Kuhlman

Re: [Tutor] Generators

2007-07-23 Thread Tiger12506
Please forgive my instrusion with some simple questions. I don't have any formal training in programming so I have to get some guidance to some terminology from time to time. What is a generator and what is its purpose? Think of a generator as a list whose contents haven't been finished

Re: [Tutor] sorting objects in lists by 2 attr

2007-07-23 Thread Philippe Niquille
Tanks a mill! I don't know why I searched so far.. Anyway, I wrapped the django custom SQL call and built a nice dictionary out of the resulting rows (which is similar to querysets). See http://www.djangosnippets.org/snippets/207/ for details. Philippe Am 23.07.2007 um 19:28 schrieb Eric

Re: [Tutor] Generators

2007-07-23 Thread Tiger12506
I am new to Python but not new to programming languages. I have seen this while 1 a lot. In fact in other languages I would expect while 1 to be the same as while TRUE. I have used that in other languages, but in the definition below I would expect the yield b... to continue on until a

Re: [Tutor] Python program design

2007-07-23 Thread Tiger12506
Then I would need to get the file size (but this is giving me an error at the moment) for name in files: s = sum(getsize(join(root, name) print s (syntax error here. I have not figured it out yet. There are spaces in the path/filename combo) (code to parse the file

Re: [Tutor] sorting objects in lists by 2 attr

2007-07-23 Thread Eric Brunson
SQL databases are cool. Make them do as much as they can for you. :-) Philippe Niquille wrote: Tanks a mill! I don't know why I searched so far.. Anyway, I wrapped the django custom SQL call and built a nice dictionary out of the resulting rows (which is similar to querysets). See

Re: [Tutor] How to determine if every character in one string isinanother string?

2007-07-23 Thread Bob Gailer
Alan Gauld wrote: wesley chun [EMAIL PROTECTED] wrote the solutions using LCs above are great when it comes to an expressive piece of code in a one-liner, but i feel there's a waste of time/memory. the use of GEs is better, but it still has to iterate over the entire string when i

Re: [Tutor] reading random line from a file

2007-07-23 Thread Tiger12506
Significance of number 4096 : file is stored in blocks of size 2K/4K/8K (depending upon the machine). file seek for an offset goes block by block rather than byte by byte. Hence for file size 4096 (assuming you have 4K block size), you will anyway end up scanning it entirely so as well load

Re: [Tutor] Generators

2007-07-23 Thread Luke Paireepinart
Tiger12506 wrote: I am new to Python but not new to programming languages. I have seen this while 1 a lot. In fact in other languages I would expect while 1 to be the same as while TRUE. I have used that in other languages, but in the definition below I would expect the yield b... to

Re: [Tutor] about importing a module

2007-07-23 Thread Luke Paireepinart
Tiger12506 wrote: If the module has been imported before your code is run, it will be the library module (very important if working in IDLE which importants many modules, for example). So... how does IDLE go about importanting a module? ;) It's not *how* IDLE imports the

[Tutor] Integrate content of rss file in static web pages with python

2007-07-23 Thread Sebastien
Hi, I have this website (http://solutions-linux.org/) and I have a little news section on the right side. Presently the pages are just static html pages, but I would like to do a little rss file to put the news in it and then do a little script that puts them on the pages with the right

Re: [Tutor] How to determine if every character in one string is inanother string?

2007-07-23 Thread Kent Johnson
wesley chun wrote: from string import printable as prglobal def printable(s): prlocal = prglobal for x in s: if x not in prlocal: return False return True the solutions using LCs above are great when it comes to an expressive piece of code in a

Re: [Tutor] Regex Ordering

2007-07-23 Thread David Perlman
Then maybe you could write a regex that matches every regex that does not match itself. ha! sorry, couldn't resist. On Jul 23, 2007, at 11:29 AM, Bill Campbell wrote: On Mon, Jul 23, 2007, James Hartley wrote: On 7/23/07, Shidan [EMAIL PROTECTED] wrote: I'm looking for a Python module