On 8/14/05, Michael Hudson <[EMAIL PROTECTED]> wrote:
> Wilfredo Sánchez Vega <[EMAIL PROTECTED]> writes:
> 
> >    I'm curious about why Python lacks FileNotFoundError,
> > PermissionError and the like as subclasses of IOError.
> 
> Good question.  Lack of effort/inertia?

Well, I wonder how often it's needed. My typical use is this:

try:
    f = open(filename)
except IOError, err:
    print "Can't open %s: %s" % (filename, err)
   return

and the error printed contains all the necessary details (in fact it
even repeats the filename, so I could probably just say "print err").

Why do you need to know the exact reason for the failure? If you
simply want to know whether the file exists, I'd use os.path.exists()
or isfile(). (Never mind that this is the sometimes-frowned-upon
look-before-you-leap; I think it's often fine.)

Also note that providing the right detail can be very OS specific.
Python doesn't just run on Unix and Windows.

-- 
--Guido van Rossum (home page: http://www.python.org/~guido/)
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to