Creating a List of Empty Lists

Andrew Koenig ark at acm.org
Fri Dec 5 10:22:41 EST 2003


> Right - because if I do something like :
>
> a = 4
> b = a
> a = 5
> print b
>
> It prints 4... not 5.
> In other words - the line b = a creates a name pointing to the object
> 4, rather than a name pointing to the contents of a.....

There's no difference between "the object 4" and "the contents of a", so the
"rather than" makes no sense in this context.

After executing

    b = a

the names "a" and "b" refer to the same object.






More information about the Python-list mailing list