perl -pi.bak -e equivalent

Caj Zell cajzell at hotmail.com
Sun Nov 21 05:58:07 EST 2004


"Diez B. Roggisch" <deetsNOSPAM at web.de> wrote in message news:<cnngpb$qtm$05$3 at news.t-online.com>...
> Caj Zell wrote:
> 
> > 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?
> 
> Short answer: No. Perl is designed for this kind of stuff. Python won't
> catch up in that field, for various reasons. There have been plenty of
> discussions on the subject of one-liners in python - googl.groups will show
> you to them. 


OK, I did some googling on "perl command line -e python equivalent"
and various combinations, but didn't think of the obvious "perl
one-liner python equivalent" your answer implies. With that I want to
say that I did try before posting here.

Nice to see noone challenges the musical meaning of my search and
replace example, seems like you pythoners have pretty good taste.

Caj Zell



More information about the Python-list mailing list