In article <[EMAIL PROTECTED]>, "max(01)*" <[EMAIL PROTECTED]> wrote:
> in perl i can do this: ... > but i do not know how to do it in python, because "if *command*:" gives > syntax error. > > moreover, if i use ... > it doesn't work, since "*do_something*" and *do_something_more* are > always executed (it seems like > > MYPIPE = os.popen("*some_system_command*", "r") > > does not raise any exception even if *some_system_command* does not > exist/work... Just to address this last point -- if you're running 2.4, you can get this through the subprocess module. With its popen equivalent, something like subprocess.Popen(cmd, stdout=subprocess.PIPE).stdout will raise an exception if the command is not found. The command in this case would specified as an argv list, not a shell command. The basic problem is that you have to fork first, then exec, and by the time the forked interpreter finds out that the exec didn't work, its parent has gone on to do the I/O it's expecting. I think subprocess gets around that, on UNIX, with a trick involving an extra pipe, that would work only on UNIX. Donn Cave, [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list