title: I am not sure why I can't open a file
body: <p>I know it's so simple to open a file in Python. However, something is definitely happening here:</p>
  <pre><code>  File &quot;exercise.py&quot;, line 16, in getinput
      f = open('w', fileName)
  TypeError: an integer is required (got type str)
  </code></pre>
  <p>Full code, if there might be something wrong with it:</p>
  <pre><code>from tkinter import *
  from os import *
  
  ide = Tk();ide.title(&quot;Python 3 IDE&quot;)
  controls = Tk();controls.title(&quot;Controls&quot;)
  
  # Variables
  tab = False
  fileName = 'test.py'
  
  # Get input
  textInput = Text(ide)
  textInput.pack()
  
  def getinput():
      f = open('w', fileName)
      f.write(textInput.get(&quot;1.0&quot;, END))
  save = Button(controls, text=&quot;Save&quot;, width=10, height=1, command=getinput).grid(column=0, row=0)
  def run():
      system('python3 ' + fileName)
  run = Button(controls, text=&quot;Run&quot;, width=10, height=1, command=run).grid(column=1, row=0)
  
  def tab(arg):
      textInput.insert(INSERT, &quot; &quot; * 4)
      return 'break'
  textInput.bind(&quot;&lt;Tab&gt;&quot;, tab)
  
  # Mainloop
  ide.mainloop()
  controls.mainloop()
  </code></pre>
  <p>PS: i reversed the parameters. Just a mistake.</p>