[Python-Dev] with_traceback (original) (raw)
Collin Winter collinw at gmail.com
Thu Mar 1 00:32:17 CET 2007
- Next message: [Python-Dev] with_traceback
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 2/26/07, Greg Ewing <greg.ewing at canterbury.ac.nz> wrote:
Phillip J. Eby wrote: > At 03:38 PM 2/26/2007 -0700, Andrew Dalke wrote: > > > NOENDOFRECORD = ParserError("Cannot find end of record") > > Then don't do that, as it's bad style for Python 3.x. ;-)
I don't like that answer. I can think of legitimate reasons for wanting to pre-create exceptions, e.g. if I'm intending to raise and catch a particular exception frequently and I don't want the overhead of creating a new instance each time.
Is this really the problem it's being made out to be? I'm guessing the use-case you're suggesting is where certain exceptions are raised and caught inside a library or application, places where the exceptions will never reach the user. If that's the case, does it really matter what the traceback looks like?
For me, this is casting serious doubt on the whole idea of attaching the traceback to the exception.
If attaching the traceback to the exception is bothering you, you should take a look at the other attributes PEP 344 introduces: cause and context. I'd say what needs another look is the idea of pre-creating a single exception instance and repeatedly raising it.
Collin Winter
- Next message: [Python-Dev] with_traceback
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]