biboy mendz <[email protected]> wrote on 11/30/2009 03:04:52 PM:

> 
> 
> spir wrote:
> >
> > What is your question?
> > If it's about the type of exception raised when os.path.exists fails, 
well, sure it's hard to find:
> >
> >   print os.path.exists("foo".bar)
> >   ==> False
> >
> > 
> My question is: i'm looking for type of exception that more or less 
> equivalent to os.path.exists attribute. I know for a fact that this 
> method yields true or false. The exercise in the book says use 
> try-except in place of os.path.exists(). That sure is (to me) quite 
> difficult task. Instead of using the available function you're are 
> tasked to do the alternative.
> 

Looking at my copy of Core Python the exercise says to follow the example 
3.2 (readTextFile.py).  There he uses the try except block around the open 
function call. 

This as mentioned could raise an IOError.  It will be triggered in a 
different manner then os.path.exist since you are now trying to open a 
file to write, instead of checking if it exist.
_______________________________________________
Tutor maillist  -  [email protected]
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to