title: Python - IOError: [Errno 13] Permission denied:
body: <p>I'm getting <code>IOError: [Errno 13] Permission denied</code> and I don't know what is wrong wit this code.</p>
  
  <p>I'm trying to read a file given an absolute path (meaning only <code>file.asm</code>),</p>
  
  <p>and a relative path (meaning <code>/.../file.asm</code>), and I want the program to write the file to whatever path is given - if it is absolute, it should write it to the current dir; otherwise, to the path given.</p>
  
  <p>the code:</p>
  
  <pre><code>#call to main function
  if __name__ == '__main__':
      assem(sys.argv[1])
  
  
  import sys
  
  def assem(myFile):
      from myParser import Parser
      import code
      from symbolTable import SymbolTable
  
      table=SymbolTable()
  
      # max size of each word
      WORD_SIZE = 16
      # rom address to save to
      rom_addrs = 0
      # variable address to save to
      var_addrs = 16
  
      # new addition
      if (myFile[-4:] == ".asm"):
          newFile = myFile[:4]+".hack"
  
      output = open(newFile, 'w') &lt;==== ERROR
  </code></pre>
  
  <p>the error given:</p>
  
  <pre><code>IOError: [Errno 13] Permission denied: '/Use.hack'
  </code></pre>
  
  <p>the way I execute the code : </p>
  
  <pre><code>python assembler.py Users/***/Desktop/University/Add.asm 
  </code></pre>
  
  <p>What am I doing wrong here?</p>