variable scope
Bruno Desthuilliers
bruno.desthuilliers at websiteburo.com
Fri Jan 19 08:34:48 EST 2007
gonzlobo a écrit :
<ot>
Please keep this on clpy...
</ot>
> Sorry, but I don't understand. I *should* pass firstMsg to the
> function like I did (PID_MinMax(firstMsg)), correct?
Yes.
> Then I should
> pass the variable back to the main loop by 'return firstMsg', correct?
s/variable/value/
Yes, you have to return the value from your function. But then, if you
don't store this value somewhere, it's lost. What you have to understand
is that you actually have *2* variables named 'firstMsg' : one in the
'main loop', and one in PID_MinMax(). Rebinding the second name has no
impact on the first. So you have to explicitely assign the return value
of PID_MinMax() to the main loop's firstMsg variable. Else, this value
is simply discarded.
HTH
More information about the Python-list
mailing list