What do you mean by 'fail'?
you have;
:: self.codes = {}
so
:: try:
:: return eval(self.codes[expr], self.globals, self.locals)
will always return an exception the first time (if this is what you're
referring to).