Quote: So modifying one, modifies them all
Not true. These are
ints
and they are fundamentally not modifiable. So none of them can ever change. This is different than something like a list.You have demonstrated that they are the same right now. You have not demonstrated that changing one changes another one. In fact, lines 17-20 show that (attempting) to change one of the variables leaves the other variable value unmodified.
Quote: The snipped and simplified version of the original program, is shown below. Thus when it is assigned to channel, channel points to the memory location.
Not quite. That's how C would do it. In python, the variable points to an object. The object is the main thing, not the address.
Quote:Changing adcnum changes the value in memory,.
Assigning adcnum (using "=") should not modify the object it pointed to before. If it points to a mutable object, you can change that object through some methods, but assignment doesn't do that. You can't change an int anyway.
Your second program doesn't seem to be changing
adcnum
at all. You assign a value to channel
, then you assign a value to commandWord
. I don't see the problem in this example yet.Why should commandWord be expected to hold the original value when you assign it a modified value on line 3?