Created
July 27, 2012 20:54
-
-
Save clemesha/3190433 to your computer and use it in GitHub Desktop.
Python's with statements are beautiful
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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