Fredrik Lundh wrote: > Russ wrote: > > > Holy cow! I can't believe that many changes would be necessary unless > > the IndexError exception is scattered all over the place. I would hope > > that one well-placed change could fix the bulk of cases. > > when you write x[i], the interpreter makes no assumptions about x and i > and len(x); it just calls the corresponding method (__getitem__), either > directly, or via a C-level internal slot. > > there's no way to generate the error message you want in a single place > without changing the semantics of x[i].
Then how about just changing __getitem__ for the built-in list type. Wouldn't that take care of the vast majority of cases? Let anyone who writes their own __getitem__ handle it themselves if they wish. I'm just asking. I don't claim to know anything about the internals of the Python interpreter. -- http://mail.python.org/mailman/listinfo/python-list