How to define a callback from Python to a C program ...
Markus Schaber
markus at schabi.de
Wed Aug 15 17:36:46 EDT 2001
Hi,
Marten Feldtmann <marten at toppoint.de> schrub:
>> If the language your application is written lets you execute external
>> programs, than you can use pipes. Start the python program from your
>> application, and then communicate with it through the pipes.
>
> Hmm ...
Especially named pipes are easy to use when doing with linux, just use
the mkfifo command.
try the following using 3 xterms / shells:
First shell:
$ mkfifo inputfifo
$ mkfifo outputfifo
$ sort inputfifo >outputfifo
second shell:
$ cat outputfifo
third shell:
$ cat >inputfifo
a
c
b
test
z
a
[CTRL-C]
As you see, the sort command can use the fifos just like normal files,
and the cat command do the same. The sorted result should appear in the
second shell when you press CTRL-C.
>> If both fails, you could open a tcp or udp socket, and communicate
>> this way.
>
> Ok, that could do it ....
This solution even makes it possible that both programs run on
different hosts.
When run on the same host, you could open a tcp Server Socket (two-way
communication) in smalltalk, and then pass IP-address and port to the
pyhton program as comand line parameters.
markus
--
1) Customers cause problems.
2) Marketing is trying to create more customers.
Therefore:
3) Marketing is evil. (Grand Edwards in comp.lang.python)
More information about the Python-list
mailing list