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.

This entry was posted in General and tagged , , . Bookmark the permalink.

One Response to Perl in place replacement syntax

  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.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>