Exception not raised
Michele Petrazzo
michele.petrazzo at TOGLIunipex.it
Fri Feb 24 12:44:10 EST 2006
Diez B. Roggisch wrote:
> Not here:
>
> t_fields = {}
> #code
> def test():
> print type(t_fields), 11 in t_fields
> print t_fields[11]
> print "I'm here"
>
> print "ok"
> test()
> print "ok"
> #end code
>
> Gives me
>
> KeyError: 11
Also on my environ when I try this 4 line code. My project, where that
strangeness happen has 500/600 + K of code.
>
>
> So - whatever you do, there must be some other code capturing that
> exception.
This code are inside a method into class that have no try/except. And
called from a method inside a wx.Frame derivate. The other strange thing
is that if I try the same code just before the "caller" to that method,
it raise an exception:
#code extract alway from the big project:
class errorHappen(object):
def methodError(self, t_fields):
print type(t_fields), 11 in t_fields
print t_fields[11]
print "I'm here"
def myF(wx.Frame):
.... init ....
self._e = errorHappen()
def caller(self):
d = dict(dictionary with 50/100 keys)
#if here I try d[11], I'll KeyError
self._e.methodError(d) #here I don't see the exeception
>Maybe you don't use dict, but a subclass of it?
All my dict are created as
d = dict()
and populate by: d.update(other_dict) or for k, val in iter: d[k] = val
>
> Diez
Thanks,
Michele
More information about the Python-list
mailing list