Writing to function arguments during execution

Dave Angel davea at ieee.org
Wed Oct 14 12:19:07 CEST 2009


John O'Hagan wrote:
> <snip>
> Thanks, sockets are the way to go for this and surprisingly easy to use once 
> you get your head around them. I tried Rhodri's suggested approach but for now 
> I used the original terminal for both starting the program and entering new 
> options (still via raw_input) and a new terminal listening on a socket 
> connection to display the results. 
>
> A secondary question: right now I'm starting the "listening" terminal by 
> executing a script ('display.py') as a subprocess:
>
> port = 50007
> here = os.path.abspath('')
> terminal = os.environ['TERM']
> subprocess.Popen([terminal, '-e', here + '/display.py', str(port)])
>
> but to me it feels kind of clunky to have a separate script just for this; is 
> there a nicer way to launch another terminal, say by passing a locally defined 
> function to it?
>
> Regards,
>
> John
>
>   
You could pass it the same script you're running, but with a 
command-line argument that causes it to execute a different part of the 
script.  Perhaps the port parameter above is enough, as your main 
process won't be getting that argument.  I'd recommend something 
explicit, however.

DaveA




More information about the Python-list mailing list