KraftDiner wrote: > I have a dictionary and sometime the lookup fails... > it seems to raise an exception when this happens. > What should I do to fix/catch this problem? > > desc = self.numericDict[k][2] > KeyError: 589824 <---- This is the error that is being produced, > because there is no key > 589824.
Given the information provided the simplest answer would be: try: desc = self.numericDict[k][2] except KeyError: desc = '' -- http://mail.python.org/mailman/listinfo/python-list