[docs] [issue8652] Minor improvements to the "Handling Exceptions" part of the tutorial

Éric Araujo report at bugs.python.org
Wed Feb 9 23:21:43 CET 2011

Éric Araujo <merwok at netwok.org> added the comment:

> Removes the two instances I noticed of treating exception instances as sequences.
Looks good.

> Adds a warning explaining ``except FooException, BarException:`` does not do what you might think.

> There are two things I'm not entirely happy about:

> I initially wrote ``print "I/O error({0.errno}): {0.strerror}".format(e)``,
> but then noticed this string formatting trick is not mentioned in the previous chapter
> of the tutorial. Dict access (``"{0[foo]}".format(d)``) is, but attribute access
> is not. Is this worth adding to that chapter, so it can be used here?
It’s not at all a trick :)  Given that item access is already covered, I don’t think your use of attribute access would make the example harder for beginners, but I may not be the best judge.

> Binding an exception instance to a variable (using "as") is explained near the bottom
> of the section on catching exceptions, well before it is used.
> Perhaps this could do with a bit of reordering?

A note about workflow: patches should usually apply to the py3k branch, the person who commits takes care of backporting to 3.1 and 2.7.  In this case, some of your editions are not relevant for 3.x, so I suggest you use one of those workflows:
1) Make one patch for py3k and one for 2.7
2) Make one for 2.7, with comments indicating parts that apply to py3k too
3) Make one patch with edits relevant for py3k and 2.7, and another one for 2.7-only edits

nosy: +terry.reedy
stage:  -> patch review
versions: +Python 2.7, Python 3.1, Python 3.2, Python 3.3

Python tracker <report at bugs.python.org>

More information about the docs mailing list