File handling: The easy and the hard way

Jorgen Grahn jgrahn-nntq at algonet.se
Sun Oct 3 10:47:10 CEST 2004


On Thu, 30 Sep 2004 11:15:32 -0400, Jeremy Jones <zanesdad at bellsouth.net> wrote:
> Hans-Joachim Widmaier wrote:
...
>>Especially not when the error is not in the program itself, but rather
>>just a mistyped filename. (Most of my helper scripts that we use to
>>develop software handle files this way. And even my co-workers don't
>>recognize 'file or directory not found' for what it is.) End users are
>>entitled to error messages they can easily understand like "I could not
>>open 'blaah' because there is no such file". 
>>
> So, you're saying that dumping a raw traceback like:
> IOError: [Errno 2] No such file or directory: '/foo/bar/bam'
> to a logfile is a no-no?  Instead, it should say:
> 
> I'm sorry sir, but an error occurred when trying to write to file 
> /foo/bar/bam because it wasn't there.

That approach also means different programs will explain the same problem
(failing to use a file provided by the user) in different terms. Bad!

> I think the traceback is perfectly understandable.  I think that even an 
> end-user would be able to comprehend that type of message.

I would prefer the normal Unix layout of the message:

  /foo/bar/bam: No such file or directory

Seeing language internal things like "IOError" puts some people off.

/Jorgen

-- 
  // Jorgen Grahn <jgrahn@       Ph'nglui mglw'nafh Cthulhu
\X/                algonet.se>   R'lyeh wgah'nagl fhtagn!



More information about the Python-list mailing list