semantics of [:]

Esmail ebonak at hotmail.com
Fri Nov 20 18:58:10 EST 2009


Diez B. Roggisch wrote:
> Esmail schrieb:
>
> None of your operations changes a. But I talked about the lists you 
> bound b and c to before. Those aren't changed as well - they simply are 
> not pointed to anymore. In your example, that means the will be 
> garbage-collected, in other scenarios, such as this, the stay:
> 
> a = []
> foo = []
> bar = foo
> assert bar is foo
> bar = a[:]
> assert bar is not foo

Got it :-) .. thanks for helping out Diez

Esmail




More information about the Python-list mailing list