def write(self,fname):
import os
ls = os.linesep
while True:
if os.path.exists(fname):
print "ERROR:'%s'already exists"%fname
break
else: break
all=[]
print"\nEnter lines('.'by itself to quit).\n"
while True:
entry=raw_input('>')
if entry=='.':
break
else:
all.append(entry)
fobj=open(fname,'w')
fobj.writelines(['%s%s'%(x,ls)for x in all])
fobj.close()
print 'DONE!'
def read(self,fname):
print
try:
fobj=open(fname,'r')
except IOError,e:
print"***file open error:",e
else:
for eachline in fobj:
print eachline
fobj.close()
import os
way=raw_input("choose you want to do Write or Read:")
if way==Write:
write()
elif way==Read:
read()
else:print 'ERROR'