Python, pipes, and the "-c" option in the command line
I don't see how this can be helpful more than once, but here's a one-liner:
cat file | grep apple | python -c "for line in __import__('sys').stdin: print line.replace(\"apple\", \"orange\"),"
There is even better way than sed, called pyp. Works like this:
pip install pyp
echo "apple, banana" | pyp "p.replace('apple', 'orange')"