def replace(self, pattern, replacement):
for i, line in enumerate(self):<EOL><INDENT>if pattern in line:<EOL><INDENT>self[i] = line.replace(pattern, replacement)<EOL><DEDENT><DEDENT>
Replace all instances of a pattern with a replacement.

Args:
    pattern (str): Pattern to replace
    replacement (str): Text to insert