Possible bug in setting Windows file permissions? (os.chmod() not working properly?)

Tim Peters tim.one at comcast.net
Mon Jun 16 19:41:54 EDT 2003


[Matt Shomphe]
> I noticed an error when trying to change the file permissions for a
> file on a Windows (2K) machine.  I'm using David Beazley's excellent
> "Python Essential Reference, 2nd. Ed." as a reference.  According to
> the book (p. 186 for those following along at home), it should be used
> thusly:
>
> import os
> os.chmod('myReadOnlyFile.txt', os.O_RDWR)

That's hard to believe.  O_RDWR is only for use with the os.open() function
(note well too:  not the builtin open() function).

Try this:

    os.chmod('myReadOnlyFile.txt', 0666)

The leading zero is important.  If that still doesn't work, it could be you
don't have permission to change permissions in the current directory.  The
Win2K permission system is much more elaborate than the simple Unix-ish
model Python exposes here.






More information about the Python-list mailing list