[docs] [issue8652] Minor improvements to the "Handling Exceptions" part of the tutorial
report at bugs.python.org
Fri May 7 19:25:34 CEST 2010
New submission from Marien Zwart <m_zwart at 123mail.org>:
Based on questions asked on freenode's #python by people reading the tutorial I would like to suggest two improvements to http://docs.python.org/tutorial/errors.html#handling-exceptions :
- Mention the older "except SomeException, e:" syntax too, not just "except SomeException as e:". I have had people ask me to help them upgrade to a newer python because they thought their version of python did not support catching exception instances (their distro python being 2.5). A big fat warning that they're reading the Python 2.6 tutorial (with links to older tutorials) may also work.
- Mention "except IOError as e" before mentioning "except IOError as (errno, strerror):". The latter is an advanced and relatively unusual trick, combining regular exception catching and unpacking. Those two concepts need to be explained before the combination is. I have had people ask me how to do "except KeyError as (key, insert_something_here):" because they thought they *always* needed those parens there.
(perhaps just not mentioning unpacking here at all, using "except IOError as e:" and then using e.errno would make more sense, especially since "except IOError as (errno, strerror):" is a SyntaxError in python 3 and up (because of the unpacking) and python 2.5.x and down (because of the "as")...)
I can try to write a patch to the documentation if you like.
assignee: docs at python
nosy: docs at python, marienz
title: Minor improvements to the "Handling Exceptions" part of the tutorial
Python tracker <report at bugs.python.org>
More information about the docs