Code:
class doc:
def write(self,a,b):
f = open(a,'w')
f.write(b)
def read(self,a):
f = open(a,'r')
for line in f:
print line
def append(self,a,b):
f = open(a,'a')
f.write(b)
doc = doc()
Usage:
doc.read(filename)
doc.write(filename,text)
doc.append(filename,text to add to file)
Example:
Code:
from doc import *
doc.write("test.txt","Test 1")
doc.read("test.txt")
Code:
from doc import *
doc.append("test.txt","Hi")
doc.read("test.txt")