File Write Attempt Silently Fails - Permissions Problem
I am attempting to write a small portion of text to an (as yet) non-existing file to an directory owned by the root user and group. I have had a look at the Python docs [regarding checking if a user is authorised][1] to write files - the code below reflects the doc example.

Here's the offending bit of code:
    

    try:
        out = open('/owned/by/root/somefile.txt', 'w')
    except IOError as e:
        if e.errno == errno.EACCESS:
            print('Cannot write file due to permission error')
        raise
    else:
        out.write('Some text content here')
        out.close()

Upon running this code (even as root user), no error is printed to the terminal and no exception is raised; yet the file is never actually written to the directory. 

  [1]: http://docs.python.org/library/os.html#files-and-directories
File Write Attempt Silently Fails - Permissions Problem
===

I am attempting to write a small portion of text to an (as yet) non-existing file to an directory owned by the root user and group. I have had a look at the Python docs [regarding checking if a user is authorised][1] to write files - the code below reflects the doc example.

Here's the offending bit of code:
    

    try:
        out = open('/owned/by/root/somefile.txt', 'w')
    except IOError as e:
        if e.errno == errno.EACCESS:
            print('Cannot write file due to permission error')
        raise
    else:
        out.write('Some text content here')
        out.close()

Upon running this code (even as root user), no error is printed to the terminal and no exception is raised; yet the file is never actually written to the directory. 

  [1]: http://docs.python.org/library/os.html#files-and-directories