perl -pi.bak -e equivalent

Caj Zell cajzell at hotmail.com
Sat Nov 20 14:07:48 CET 2004


Hello,

I am looking a little bit at python and am curious of one thing I
often use in perl. Suppose, I want to change the string
"best_composer" to "Zappa" in a document called facts.txt, then in
perl I would do

perl -pi.bak  -e "s/best_composer/Zappa/;" facts.txt

Can I do that with python from the command line so easily?

Caj Zell



More information about the Python-list mailing list