For those who come here from Google: actually a very good way to use named pipes:
first create 2 names:
mkfifo pipe1 mkfifo pipe2
then run this:
echo -nx | cat - pipe1 > pipe2 & cat <pipe2 > pipe1
this will cause the cat commands to copy the letter x all the time to each other. So now you can freely use your own programs instead of cats to process input and output. This is not limited to python. You can also connect a Java program using a C ++ program.
For example, if your programs are called A.py and B.py, then the initial command:
echo -nx | ./A.py - pipe1 > pipe2 & ./B.py <pipe2 > pipe1
source share