Code feedback

2006-11-17 Thread Tor Erik Soenvisen
Hi, all I would like some feedback on a multithreaded HTTP server I've written. The server serves python-scripts by dynamically loading scripts in the same directory as itself. When a request is made to one of these scripts the script is executed and its output is returned to the requester. Here

Re: Code Feedback

2006-02-07 Thread Sion Arrowsmith
mwt <[EMAIL PROTECTED]> wrote: >1) Is this good Python code? What should be changed to make it more >Pythonesque? >while not len(self.stacks) > 0: while not self.stacks: An empty list is considered to be false, hence testing the list itself is the same as testing len(l) > 0 . --

Re: Code Feedback

2006-02-07 Thread mwt
Jorgen Grahn wrote: > You might want to look into using doc strings properly. You have comments at > the start of functions, but they read more like implementation notes than > "what this method does and why". But I only had a quick look. Yeah. They were just my scaffolding notes to myself. I'd

Re: Code Feedback

2006-02-06 Thread mwt
Thanks for all the feedback. Interestingly, I can't seem to get Dan M's code: [code] try: while 1: pass except KeyboardInterrupt: break [/code] to work, no matter how many variations I try (including adding in "time.sleep(0.1)" as Peter Hansen suggested. Th

Re: Code Feedback

2006-02-06 Thread snoe
I believe the while 1: pass is there to keep the main thread alive until all the readers are done. If you want the program to end after the readers are done you can append them all to a list then iterate through and wait for the threads to join() if __name__=="__main__": library = Library()

Re: Code Feedback

2006-02-06 Thread Jorgen Grahn
On 6 Feb 2006 09:33:58 -0800, mwt <[EMAIL PROTECTED]> wrote: > Hello - > Last night I wrote my first code in Python -- a little > producer/consumer toy to help me begin to understand things. The > "Library" only has a few books. You can choose how many Readers are ... > 1) Is this good Python code?

Re: Code Feedback

2006-02-06 Thread Peter Hansen
Dan M wrote: >>2) Anybody know how to alter the "while 1: pass" section to make the >>app stoppable? > > > That one I think I can help with! See below. > > >>while 1: pass > > > try: > while 1: > pass > except KeyboardInterrupt: > break That migh

Re: Code Feedback

2006-02-06 Thread Dan M
> 2) Anybody know how to alter the "while 1: pass" section to make the > app stoppable? That one I think I can help with! See below. > while 1: pass try: while 1: pass except KeyboardInterrupt: break -- http://mail.python.org/mailman/listinf

Code Feedback

2006-02-06 Thread mwt
Hello - Last night I wrote my first code in Python -- a little producer/consumer toy to help me begin to understand things. The "Library" only has a few books. You can choose how many Readers are trying to check out the books. When no books are available, they have to wait until some other Reader r