IOError: [Errno 13] Permission denied when trying to open hidden file in “w” mode

It’s just how the Win32 API works. Under the hood, Python’s open function is calling the CreateFile function, and if that fails, it translates the Windows error code into a Python IOError. The r+ open mode corresponds to a dwAccessMode of GENERIC_READ|GENERIC_WRITE and a dwCreationDisposition of OPEN_EXISTING. The w open mode corresponds to a dwAccessMode … Read more