All pastes #818524 Raw Edit

Untitled

public python v1 · immutable
·published 2007-12-16 10:29 UTC
rendered paste body
def splitfile(fname):    text_file = open(fname, "r")    tex = text_file.read()    halfText = len(tex)/2        new_text_file1 = open("1.txt", "w")    new_text_file1.write(tex[:halfText])        new_text_file2 = open("2.txt", "w")    new_text_file2.write(tex[halfText:])        new_text_file1.close()    new_text_file2.close()    def getInput():    fname = raw_input("Enter the filename of the text file you want to split in half\n\n")    checkInput(fname)def checkInput(fname):    if fname != "":        try:            splitfile(fname)        except:            prob = raw_input("\nFile not found!\nTry again?\nY/N")            if prob.lower() == "y":                getInput()            elif prob.lower() == "n":               print "goodbye"getInput()