This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author marienz
Recipients docs@python, marienz
Date 2010-05-07.17:25:32
SpamBayes Score 0.0035617945
Marked as misclassified No
Message-id <1273253134.08.0.147248211976.issue8652@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2010-05-07 17:25:34marienzsetrecipients: + marienz, docs@python
2010-05-07 17:25:34marienzsetmessageid: <1273253134.08.0.147248211976.issue8652@psf.upfronthosting.co.za>
2010-05-07 17:25:32marienzlinkissue8652 messages
2010-05-07 17:25:32marienzcreate