Perl in place replacement syntax

I always forget how to do this, so I’m writing it down:

perl -pi -e “s/foo/bar/g”

Is there a way to do this in Python and be as concise? That would be really nice, and would eliminate one more place where I end up using Perl and tearing my hair out every time.

  1. foobert says:

    Ohh, how I wish python handled regex better too: http://www.foobert.com/blog/2009/02/22/motorcycle-riding-leads-to-coding/trackback/

    What should have been 5 lines of (useful) code in perl doing regex takes 10 in python. I was hoping it was just my learning curve, but, I’ll keep looking.

  1. There are no trackbacks for this post yet.

Leave a Reply