title: Is there a Python equivalent to `perl -pi -e`?
body: <p>I know of <code>python -c '&lt;code&gt;'</code>, but I'm wondering if there's a more elegant python equivalent to <code>perl -pi -e '&lt;code&gt;'</code>.  I still use it quite a bit for things like find and replace in a whole directory (<code>perl -pi -e s/foo/bar/g *</code> or even <code>find . | xargs perl -pi -e s/foo/bar/g</code> for sub-directories).</p>
  
  <p>I actually feel that that which makes Perl Perl (free form Tim Toady-ness) is what makes <code>perl -pi -e</code> work so well, while with Python you'd have to do something along the lines of importing the re module, creating an re instance and then capture stdin, but maybe there's a Python shortcut that does all that and I missed it (sorely missed it)...</p>