Skip to content

Instantly share code, notes, and snippets.

@kenkam
Created August 20, 2011 22:31
Show Gist options
  • Save kenkam/1159757 to your computer and use it in GitHub Desktop.
Save kenkam/1159757 to your computer and use it in GitHub Desktop.
list comprehension
# i can haz python 2.6.6+
with open('file.txt') as f:
lines = f.readlines()
for l in lines:
if 'safeChange' in l:
lines[lines.index(l)] = 'nyan nyan nyan'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment