Python - IOError: [Errno 13] Permission denied:
Question: Im getting IOError: [Errno 13] Permission denied, i dont know what im doing
wrong.

Im trying to read a file given an absolute path (meaning only file.asm),

and a relative path (meaning /.../file.asm) 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.

the 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') <==== ERROR
    

the error given:

    
    
    IOError: [Errno 13] Permission denied: '/Use.hack'
    

the way i execute the code :

    
    
    python assembler.py Users/***/Desktop/University/Add.asm 
    

what am i doing wrong over here?


Answer: **Just Close the opened file where you are going to write.**

