How to tell if I can open a file or not
Alex Martelli
alex at magenta.com
Mon Jun 12 05:06:12 EDT 2000
More information about the Python-list mailing list
Mon Jun 12 05:06:12 EDT 2000
- Previous message (by thread): How to tell if I can open a file or not
- Next message (by thread): setblocking in Win32
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Donn Cave <donn at u.washington.edu> wrote in message news:8hokva$2rqa$1 at nntp6.u.washington.edu... [snip] > After you check, there's a period of time before you actually open > the file. It's a brief window, but it's real, and many things can > happen in that time if the system is busy, including changes to the > file's permission bits or even whether it exists. Might as well > just open the file, and if it works then you have a green light. *EXACTLY*!!! In the immortal words of Commodore Hopper: It's easier to get forgiveness than permission I think she had another context in mind, but it works great for the present one too: don't check if you're allowed to do X Y Z (because things might change between your check and your doing it), but rather, attempt to do the action ("just do it" comes to mind:-) *AND*, of course, be ready to handle the exception ("get forgiveness":-) if it turns out the action-attempt fails. Alex
- Previous message (by thread): How to tell if I can open a file or not
- Next message (by thread): setblocking in Win32
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list