Skip to content

Instantly share code, notes, and snippets.

@blackmann
Created June 14, 2014 09:09
Show Gist options
  • Save blackmann/d4bae34c07c9e3dd6491 to your computer and use it in GitHub Desktop.
Save blackmann/d4bae34c07c9e3dd6491 to your computer and use it in GitHub Desktop.
A simple Text editor as a beginner
#Text Editor
#A simple text editor in beta mode
#as a beginner
__author__ = 'Lexis'
def checknewline(tl):
'''to check trailing newlines'''
if (len(tl)==3) and (''.join(tl[:])==''):
return True
def writeto(filename):
text=[]
fileheader = raw_input('File Header: ')
filename.write(fileheader)
run = True
n=1
while run == True:
ui = raw_input(str(n)+': ')
n+=1
if ui != '':
filename.write('\n'+ui)
else:
text.append(ui)
ifspace3 = checknewline(text)
if ifspace3 == True:
filename.close()
run = False
def main():
filename = raw_input('Enter filename: ')
MODE = 'a+'
f = open(filename, MODE)
writeto(f)
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment