[Python-Dev] PEP 8: mention bare 'except:' (original) (raw)
Barry Warsaw barry at python.org
Fri Dec 22 16:37:45 CET 2006
- Previous message: [Python-Dev] PEP 8: mention bare 'except:'
- Next message: [Python-Dev] PEP 8: mention bare 'except:'
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
On Dec 22, 2006, at 8:05 AM, A.M. Kuchling wrote:
A good rule of thumb is that you should only use 'except:' if the exception handler will be printing out or logging the traceback; at least the user will be aware that an error has occurred.
Another aspect of bare except (IME) is that they are used when you
want to do some work, but continue to propagate the exception upwards
via a bare raise. E.g. rolling back a transaction, or as you
mention, logging the error and continuing.
- -Barry
-----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.5 (Darwin)
iQCVAwUBRYv7znEjvBPtnXfVAQKjYAP/fxLKXLYQvA/CAfYKOVhBkeIUdqJ7qyxH fv6PXuOM7RwS4FuwtmmbHOw9omyO0Kv+iddx/MD+2hJN9TeeLveGSyr4kEDG5cYD APhy8KW18bKhtwAiZbxzV4VQ3Q22IQah/nHEmzUfaRYAl8Dms9FjwIPIrlEY2yaS TY+MNrUum2Y= =CZuk -----END PGP SIGNATURE-----
- Previous message: [Python-Dev] PEP 8: mention bare 'except:'
- Next message: [Python-Dev] PEP 8: mention bare 'except:'
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]