[Tutor] Equivalent exception of os.path.exists()

spir denis.spir at free.fr
Tue Dec 1 09:01:56 CET 2009


bibi midi <bibsmendez at gmail.com> dixit:

> Like i thought so, there is no exception to catch if a file already exist.
> I've been browsing the many types of exceptions and cant find anything thats
> close. Thank you for clarifying.
> 

Actually, you can. I guess it's not the book author's intent, but you can try it for the sake of experiment. 

If you're working under a unix-like system, just try to write into another user's home dir (*), or any file outside your own home. The filesystem will refuse the permission, so you will get an error from python. In fact, in this case, you'll get an error both for creation and change.
I don't know the equivalent under other OSes, but it sure exists.

Denis
________________________________

la vita e estrany

http://spir.wikidot.com/



More information about the Tutor mailing list