On Wed, Apr 16, 2008 at 6:53 PM, Greg Ewing <[EMAIL PROTECTED]> wrote:
   ...
>  >     open("ั‚ะตัั‚") # filename is in koi8-r encoding
>  > IOError: [Errno 2] No such file or directory: '\xd4\xc5\xd3\xd4'
>
>  In that particular case, I'd say the IOError constructor
>  is doing the wrong thing -- it should be using something
>  like
>
>    "No such file or directory: '%s'" % filename\
>
>  instead of
>
>    "No such file or directory: %r" % filename
>
>  i.e. %r shouldn't be used as a quick and dirty way to
>  get a string quoted.

I disagree: I always recommend using %r to display (in an error
message, log entry, etc), a string that may be in error, NOT '%s',
because the cause of the error can often be that the string mistakenly
contains otherwise-invisible characters -- %r will show them clearly
(as escape sequences), while %s could hide them and lead anybody but
the most experienced developer to a long and frustrating debugging
session.


Alex
_______________________________________________
Python-3000 mailing list
Python-3000@python.org
http://mail.python.org/mailman/listinfo/python-3000
Unsubscribe: 
http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com

Reply via email to