correction: the code posted in previous message should have been:

    def __getitem__(self, expr):
        try:
            return eval(self.codes[expr], self.globals, self.locals)
        except:
            # We want to catch **all** evaluation errors!
            # KeyError, NameError, AttributeError, SyntaxError, V
            # alueError, TypeError, IOError, ...
            #
            # Special case:
            # if KeyError is coming from self.codes[expr] lookup,
            # then we add the compiledentry and try again:
            if not expr in self.codes:
                self.codes[expr] = compile(expr, '<string>', 'eval')
                return self[expr]
            # handle any other error...
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to