Simple Class/Variable passing question

monkeyboy fsenkel at lynx.neu.edu
Thu Jun 19 16:37:47 EDT 2008


Hello,

I'm new to python, and PythonCard. In the code below, I'm trying to
create a member variable (self.currValue) of the class, then just pass
it to a simple function (MainOutputRoutine) to increment it. I thought
Python "passed by reference" all variables, but the member variable
doesn't seem to be incremented. If I make the function just increment
the member variable directly, without passing it in, it works fine?

In the code below, "self.currValue" stays at 5, and value evaluates to
1? Any insight would be appreciated...


class TestModel(model.Background):

    def on_initialize(self,event):
        self.currValue = 5

    def on_startBtn_mouseClick(self, event):
        self.MainOutputRoutine(self.currValue)
        self.OutputRoutine(self.currValue)

    def OutputRoutine(self,value):
        self.components.txtBox1.text = str(value)

    def MainOutputRoutine(self,value):
        value = value + 1



More information about the Python-list mailing list