Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
My Doc Module
#1
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")
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Regex module help Mikey1234567 0 595 04-18-2013, 11:48 AM
Last Post: Mikey1234567
  Module attribute problems. goqe 0 672 03-18-2013, 11:38 AM
Last Post: goqe
  Web Search Module Gaijin 0 523 11-03-2009, 09:24 AM
Last Post: Gaijin

Forum Jump:


Users browsing this thread: 1 Guest(s)