Re: [Tutor] Making a simple web server in Python

2011-05-30 Thread Alexandre Conrad
2011/5/30 Michael bridges : >  File > "C:\Users\MySelf\Program\game_stuff\Python_Server_code_and_test\pythonweb\webserver.py", > line 56, in main >    server = HTTPServer(('', 80), MyHandler) >  File "C:\Python31\lib\socketserver.py", line 400, in __init__ >    self.server_bind() >  File "C:\Pyth

[Tutor] Making a simple web server in Python

2011-05-30 Thread Michael bridges
when running code from http://fragments.turtlemeat.com/pythonwebserver.php: [putting http://localhost:81/index.html in broswer] this error happens: >>> Traceback (most recent call last): File "C:\Users\MySelf\Program\game_stuff\Python_Server_code_and_test\pythonweb\webserver.py", line 65, in

Re: [Tutor] Importing classes when needed

2011-05-30 Thread Alexandre Conrad
2011/5/30 Marilyn Davis : > If we are coding via a vote, I'd be with Alan. > > If Timo adds non-parser modules, and they get through his glob filter, > then surely his code will break with a nice error statement and that would > remind him of his convention. Sure. From my point of view, I prefer a

Re: [Tutor] Python Interview Questions..

2011-05-30 Thread Alan Gauld
"Steven D'Aprano" wrote Java just isn't a hard enough language to separate great programmers from plodders (neither is Python, for that matter) because pointers and memory allocation are taken care of automagically. I fundamentally disagree with his stand on this. Not sure what you're sayi

Re: [Tutor] Tutor Digest, Vol 87, Issue 120

2011-05-30 Thread priyesh raj
Hi, To excute a "Java" command, using os.system, you need to either give absolute path, or you need to append the path in system variable. For example, 1. Either os.system('/usr/bin/java') or 2. import sys sys.path.append('/usr/bin') os.system('java') Hope this helps. Regards, Priyesh

Re: [Tutor] Finding error from os.system(cmd)

2011-05-30 Thread Steven D'Aprano
Kann Vearasilp wrote: Dear all, I tried using python to execute some external java program in my code. My problem is the os.system(cmd) was not working properly while Define "not working properly". My guess is that you're probably getting an exception OSError: [Errno 2] No such file or dire

Re: [Tutor] Importing classes when needed

2011-05-30 Thread Steven D'Aprano
Timo wrote: Hello all, I have a question about how this is done the best way. In my project I have a folder with multiple file parsers, like this: - src -- main.py -- parsers --- __init__.py --- parser1.py --- parser2.py This gives you a stand-alone module called "main.py", and a sepa

Re: [Tutor] Importing classes when needed

2011-05-30 Thread Marilyn Davis
If we are coding via a vote, I'd be with Alan. If Timo adds non-parser modules, and they get through his glob filter, then surely his code will break with a nice error statement and that would remind him of his convention. Or maybe it would just give a verbose report and go on to the next file.

Re: [Tutor] Importing classes when needed

2011-05-30 Thread Alan Gauld
"Alexandre Conrad" wrote Why not use the os functions to read the file names dynamically and build the list that way? Provided the files use a standard naming scheme you don't need to change the init code. I wouldn't do that. If Timo adds non-parser modules in that directory (say some util

Re: [Tutor] Finding error from os.system(cmd)

2011-05-30 Thread Marilyn Davis
Hi Kann, So you are saying that you printed your command, then ran it at the terminal prompt, and it ran ok? You might want to look at the subprocess library so that you can collect stderr from the process. The online documentation is great, with lots of examples. BTW, on your line 6, you str(s

Re: [Tutor] Finding error from os.system(cmd)

2011-05-30 Thread Alexandre Conrad
Hi Kann, I haven't looked at your problem closely but you might need to explicitly tell Python where to output stderr/stdout. I just ran os.system('ls -al') on my Linux box and it seems to print both stderr/stdout to my terminal. The return value is the return code of the process (might be differe

[Tutor] Finding error from os.system(cmd)

2011-05-30 Thread Kann Vearasilp
Dear all, I tried using python to execute some external java program in my code. My problem is the os.system(cmd) was not working properly while executing 'java' from terminal worked just fine. I am not sure what is wrong here. Is there a way to print out/detect error in my code for this case? >>

Re: [Tutor] Importing classes when needed

2011-05-30 Thread Alexandre Conrad
2011/5/30 Alexandre Conrad : > selected_parser = "parser1" > parser = parsers[selected_parser] > parser = Parser() > ... I meant to have a capital P on the second line of course: selected_parser = "parser1" Parser = parsers[selected_parser] parser = Parser() or just (less readable though): pars

Re: [Tutor] Importing classes when needed

2011-05-30 Thread Alexandre Conrad
2011/5/30 Alan Gauld : > But this means having to maintain the list in init.py. > Why not use the os functions to read the file names > dynamically and build the list that way? Provided > the files use a standard naming scheme you don't > need to change the init code. I wouldn't do that. If Timo a

Re: [Tutor] Importing classes when needed

2011-05-30 Thread Alexandre Conrad
2011/5/30 Timo : > When the user clicks a button, I want to show all available parsers and use > the choosen one when the user clicks "ok". > Is it ok to place the following code in the __init__.py? > from parser1 import Parser1 > from parser2 import Parser2 > def get_parsers(): >    return [Parser

Re: [Tutor] Importing classes when needed

2011-05-30 Thread Peter Otten
Timo wrote: > Hello all, > > I have a question about how this is done the best way. > > In my project I have a folder with multiple file parsers, like this: > - src > -- main.py > -- parsers >--- __init__.py >--- parser1.py >--- parser2.py > > The parsers just contain a class wh

Re: [Tutor] Importing classes when needed

2011-05-30 Thread Alan Gauld
"Timo" wrote When the user clicks a button, I want to show all available parsers and use the choosen one when the user clicks "ok". Is it ok to place the following code in the __init__.py? from parser1 import Parser1 from parser2 import Parser2 def get_parsers(): return [Parser1(), Parser

[Tutor] Importing classes when needed

2011-05-30 Thread Timo
Hello all, I have a question about how this is done the best way. In my project I have a folder with multiple file parsers, like this: - src -- main.py -- parsers --- __init__.py --- parser1.py --- parser2.py The parsers just contain a class which do the work. When the user clicks a bu