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

Tim Golden mail at timgolden.me.uk
Mon Nov 30 16:27:48 CET 2009


biboy mendz wrote:
> http://pastebin.ca/1693849
> 
> This is end-of-chapter3 exercise of the book Core Python Programming.
> 
> I'm reading/searching in the book and other materials but is 
> unsuccessful. There are at least 50 exceptions listed but I can't find 
> anything close.
> 
> I commented out my modified script to just what *should* be applicable. 
> Can you please point me to the right direction? TIA.


Ummm.. You're not actually trying to open the file.
raw_input just asks the user for a string. But it's
just a string. You could be going to use it for
anything. Try something like:

try:
  open (fname).close ()
except IOError, e:
  print "blah"


TJG


More information about the Tutor mailing list