[Tutor] [HELP]how to test properties of a file
Shidai Liu
shidai.liu at gmail.com
Tue Apr 5 01:34:00 CEST 2005
On Apr 4, 2005 10:54 PM, Nick Lunt <nick at javacat.f2s.com> wrote:
> I've gotten into the habit of just using the os.?_OK stuff.
>
> eg
>
> >>> import os
> >>> os.access('/', os.W_OK)
> False
> >>> os.access('/tmp', os.W_OK)
> True
>
> Thats gotta be simple if I understand it lol :)
>
> Nick .
>
I found out in the following situation, it fails to work.
Say, 'somefile.csv' is opened by EXCEL,
>>> os.access('somefile.csv', os.W_OK)
True
>>> file('somefile.csv', 'w')
IOError: [Errno 13] Permission denied: 'somefile.csv'
By the way, using os.stat & stat as suggested by Alan doesn't work either.
Any idea how solve it?
More information about the Tutor
mailing list