title: How can I make python save a file in a different location?
body: <p>My python project has 2 files. I made a folder called <code>files</code> so when the user writes something in the text editor, it saves it into that folder, then when the user opens the textviewer, they type that file name and looks for it in the <code>files</code> directory. How would I be able to do this?</p>
  
  <p>Code for text editor:</p>
  
  <pre><code>def edit():
      os.system('cls' if os.name == 'nt' else 'clear')
      print ("EDIT")
      print ("-------------")
      print ("Note: Naming this current document the same as a different document will replace the other document with this one.")
      filename = input("Plese enter a file name.")
      file = open(filename, "w")
      print ("FILE: " +filename+".")
      lines = get_lines()
      file.write('\n'.join(lines))
  
  def get_lines():
     print("Enter 'stop' to end.")
     lines = []
     line = input()
     while line != 'stop':
        lines.append(line)
        line = input()
     return lines
  </code></pre>
  
  <p>Text Viewer Code:</p>
  
  <pre><code>def textviewer():
     os.system('cls' if os.name == 'nt' else 'clear')
     print ("Text Viewer.")
     file_name = input("Enter a text file to view: ")
     file = open(file_name, "r")
     print ("Loading text...")
     time.sleep(0.5)
     os.system('cls' if os.name == 'nt' else 'clear')
     print(file.read())
     edit_text = input("Would you like to edit it? (y for yes, n for no)")
     if edit_text == "y":
        file = open(file_name, "w")
        print ("You are now in edit mode.")
        lines = get_lines
        file.write('\n'.join(lines))
        time.sleep(2)
     if edit_text == "n":
        print ("Press enter to exit")
        input()
  </code></pre>