[Tutor] Newbie: Passing variable into re.compile

2006-03-29 Thread Jerome Jabson
Hello, I’m having trouble trying to pass a variable into re.compile(), using the “r” option. Let’s say I have the following: import re arg1 = ‘10” p = re.compile(r + arg1 + '\.(\d+\.\d+\.\d+)') This works if I do: p = re.compile(r ‘10\.(\d+\.\d+\.\d+)') Is there

[Tutor] string formatting question

2006-04-07 Thread Jerome Jabson
Hello, I'm trying to replace some strings in a line of text, using some regex functions. My question is: If there's more then one regex grouping I want to replace in one line of a file, how can I use the String Formatting operator (%s) in two places? Here's the line it matches in the file: Her

Re: [Tutor] string formatting question

2006-04-07 Thread Jerome Jabson
Hi Kent, Sorry I didn't make my question clearer. Bascially I want to replace this line: With: So the regex grouping are that I want to keep portNumber= and tcpORudp= and replace the values. Which will be varibles in my code. The question is more on the string formatting in the replace. Ho

[Tutor] HELP: using popen2/popen3

2006-05-04 Thread Jerome Jabson
Hello, I'm trying to start a shell script from my python script using os.spawnlp. But I'm not getting msgs from stderr. I thought that I could use popen2/popen3 to replace os.spawnlp but I'm having problems with syntax and how to do this. Can someone point me in the right direction? Here's my orig

[Tutor] using variables as args

2006-05-08 Thread Jerome Jabson
Hello, I'm trying to start a shell script with 4 arguments from my python script. I'm having problems trying to figure out the best way to do this. I'm using variables as the arguments to the shell script. I want to use popen3 to keep track of stdin, stdout, and err, but from the docs I only see u

Re: [Tutor] using variables as args

2006-05-08 Thread Jerome Jabson
Thank you, Alan! I'll try using POPEN. Jerome --- Alan Gauld <[EMAIL PROTECTED]> wrote: > > I'm trying to start a shell script with 4 > arguments > > from my python script. I'm having problems trying > to > > figure out the best way to do this. > > Use a format string: > > cmd = "myscript %s

[Tutor] help with erros using subprocess module

2006-05-09 Thread Jerome Jabson
Hi, I've been trying to write a wrapper around some shells scripts using the subprocess module. But I'm getting errors I quite don't know how to debug. I've only been writing Python for a few months and starting processes are new to me. Here's my code: import os import re import subprocess #

[Tutor] help with erros using subprocess module

2006-05-10 Thread Jerome Jabson
Hi Bo, Jerome Jabson 写道: > Hi, > > I've been trying to write a wrapper around some shells > scripts using the subprocess module. But I'm getting > errors I quite don't know how to debug. I've only been > writing Python for a few months and starting pro

Re: [Tutor] help with erros using subprocess module

2006-05-11 Thread Jerome Jabson
Hi Bo, Thank you very much for all your help!! But I'm having some problems with the line of code you recommended: if isinstance(cmd, types.StringTypes): cmd = cmd.split(' ') I'm getting the following error: NameError: global name 'types' is not defined As you instructed, I put in the

[Tutor] Running Java process doesn't return to subprocess.call

2006-05-15 Thread Jerome Jabson
Hello, I'm running a Java process from my python script using the subprocess module. But there seems to be some problem with the return code to subprocess and the Java program is just hanging waiting for something. If I run the Java program from shell it terminates normally and if run the same pro