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 (MainOutputRout ine) 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(s elf,event):
self.currValue = 5
def on_startBtn_mou seClick(self, event):
self.MainOutput Routine(self.cu rrValue)
self.OutputRout ine(self.currVa lue)
def OutputRoutine(s elf,value):
self.components .txtBox1.text = str(value)
def MainOutputRouti ne(self,value):
value = value + 1
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 (MainOutputRout ine) 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(s elf,event):
self.currValue = 5
def on_startBtn_mou seClick(self, event):
self.MainOutput Routine(self.cu rrValue)
self.OutputRout ine(self.currVa lue)
def OutputRoutine(s elf,value):
self.components .txtBox1.text = str(value)
def MainOutputRouti ne(self,value):
value = value + 1
Comment