All pastes #106171 Raw Edit

Stuff

public text v1 · immutable
#106171 ·published 2006-07-30 04:24 UTC
rendered paste body
class myfile:

	def __init__(self, myfile, mode="r"):
		self.myfile = open(myfile, mode)
		
	def get_lines(self):
		'''Returns a list of the file lines'''
	
	def replace_line(self, oldline, newline ):
		for line in self.get_lines():
			self.myfile.seek(0)
			self.myfile.write(line.replace(oldline, newline))

myfile = myfile("example.txt", "r+")
myfile.replace_line("Nano", "Daniel")