On Apr 1, 7:56 pm, "wswilson" <[EMAIL PROTECTED]> wrote:
> I am parsing a document which contains some lines with code I want to
> eval or exec. However, due to the complexity of the parsing, I am
> splitting it among different methods. So, if I eval something in one
> method, it won't be there if I try to access its value a few lines
> later since I happen to be in a different method in the parser. Thanks
> for the help!

val = None
class A(object):
        def early_parse(self):
                global val
                self.result1 = val = eval("10 + 5")
def later_parse():
            global val
            val += eval("20*2")

a = A()
a.early_parse()
later_parse()
a.result2 = val
print a.result1
print a.result2

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to