Skip to content

Instantly share code, notes, and snippets.

@clemesha
Created July 27, 2012 20:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save clemesha/3190433 to your computer and use it in GitHub Desktop.
Save clemesha/3190433 to your computer and use it in GitHub Desktop.
Python's with statements are beautiful
with open('site.log') as infile, open('err.log', 'w') as outfile:
for line in infile:
if 'ERROR' in line:
outfile.write(line)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment