Writing to function arguments during execution

Rhodri James rhodri at wildebst.demon.co.uk
Sun Oct 11 15:54:02 CEST 2009

On Sun, 11 Oct 2009 14:18:25 +0100, John O'Hagan <research at johnohagan.com>  

> Now I can change the output of the "work" function while it's running via
> raw_input(). However it's very crude, not least because the terminal  
> echo of
> the new options is interspersed with the output of the program.
> In future I hope to be able to have several instances of the "work"  
> function
> running as threads simultaneously, and to separately control the  
> arguments to
> each.
> I think the general problem is how to send output from a thread to a  
> different
> place from that of its parent thread, but I'm not sure.
> Is there a standard way to do this kind of thing? In particular, I'm  
> after a
> solution whereby I can enter new arguments in one terminal window and  
> observe
> the program's output in another.

The standard way (if you don't want to write a GUI for the whole thing)
is to have separate programs communicating with sockets.  Start your
music program in one terminal and the control program in the other,
and have a thread listening to the socket rather than using raw_input().

Exactly what processing your control program should do before tossing
the data through the socket is a matter of religious debate :-)

Rhodri James *-* Wildebeest Herder to the Masses

More information about the Python-list mailing list