I want to make a command-line text editor in python. Is this good code?
from termcolor import * import os while True: files = os.listdir() bufname = input("File name: ") title = cprint("Ganesha Editor v1.0", "green") controls = cprint("Type $exit to exit text editor. It autosaves.", "blue") def write(): print("Compose Something Below:\n\n") text = input() if text == "$exit": exit() else: if bufname in files: os.remove(bufname) create = open(bufname, "w") create.close() autosave = open(bufname, "a") autosave.write(text) autosave.write("\n") autosave.close() else: autosave = open(bufname, "a") autosave.write(text) autosave.write("\n") autosave.close() while True: write()
I prettified the code with 8 spaces for the indents.
Does anyone like this code? It's very minimal, and no one will like it, but, I'm trying to make a secondary text-editor.