Exception handling wart in Python

Tim Gahnström /Bladerman tim at bladerman.com
Fri Nov 2 13:40:06 EST 2001


"Leo Lipelis" <aeoo at myspamrealbox.com>
> On Thu, 01 Nov 2001 22:03:42 -0500, Paul Rubin wrote:
> > "Leo Lipelis" <aeoo at myrealbox.com> writes:
> >> I'd like some help with an issue I have with Python.  Simply put, I
> >> think having an exception mechanism is a waste if there is no tool that
> >> will let you know which unhandled exceptions exist at point foo....
> >>
> >> Considering that in Python exceptions are matched by identity instead
> >> of equivalence, it's possible to track all the exception flows, right?
> >
> > Of course not.  Since you can execute arbitrary strings, you can create
> > new exception classes at runtime and throw them.
>
> This is a non-argument.  It's like saying, you can access anything with a
> pointer in C, thus you shouldn't use any tools that can warn you about
> possible segfaults.

I think this is a verry interesting subject and havn't yet decided wich side
to team up with sp please keep the discussion rolling :-)

Anyway, what I wanted to say is:
Wouldnt it be fairly easy to track those possibly exeptions? I imagin that
it might be hard to see that there canot be an endOflList axception in this
case:

a=[1,2,3,4,5]
for i in range 3:
   a[i]=2

But if this is supposed to generate a message that it can possibly be an end
of list exception then it shouldnt be to hard to implement right?
Anyway I think that, since Python is such a light weight language, this kind
of thing fits better into an extension module wich those who really need it
can import rather then "forcing" the overhead on everyone... maybe.
...Kind of new to Python so I havnt had any problem with this yet... But I
like typing :-)

Tim





More information about the Python-list mailing list