New submission from Marien Zwart <m_zw...@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: d...@python
components: Documentation
messages: 105218
nosy: d...@python, marienz
priority: normal
severity: normal
status: open
title: Minor improvements to the "Handling Exceptions" part of the tutorial

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue8652>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to