list storing variables
Peter Pearson
pkpearson at nowhere.invalid
Mon Feb 23 12:35:40 EST 2015
On Mon, 23 Feb 2015 13:55:47 +0100, ast <nomail at invalid.com> wrote:
> hi
>
>>>> a = 2; b = 5
>>>> Li = [a, b]
>>>>
>>>> Li
> [2, 5]
>>>> a=3
>>>> Li
> [2, 5]
>>>>
>
> Ok, a change in a or b doesn't impact Li. This works as expected
>
> Is there a way to define a container object able to store some variables
> so that a change of a variable make a change in this object content ?
>
> I dont need this feature. It is just something I am thinking about.
>
> In C language, there is &A for address of A
The word "variable" brings implications and assumptions that get
people into trouble in Python. Python doesn't have variables.
It has objects, and you can assign names to objects -- like sticky
notes, as someone in this newsgroup helpfully pointed out long ago.
This way of thinking is significantly different from the familiar
"variable" mind-set of C, but looks similar enough to produce some
confusion. For me, the sticky-note analogy helped a lot, and in a
few days many things made more sense.
--
To email me, substitute nowhere->runbox, invalid->com.
More information about the Python-list
mailing list