list.clear() missing?!?

Sergei Organov osv at javad.com
Fri Apr 14 04:46:30 EDT 2006


Dennis Lee Bieber <wlfraed at ix.netcom.com> writes:

> On Fri, 14 Apr 2006 09:17:05 +0400, Sergei Organov <osv at javad.com>
> declaimed the following in comp.lang.python:
>
>> 
>> I, as a newcomer, don't have much trouble understanding the binding vs
>> the assignment by themselves. What does somewhat confuse is dual role of
>> the "=" operator, -- sometimes it means "bind" and other times it means
>> "assign", right? For me it seems that the language would be less
>
> 	It always means bind... But if the LHS is a mutable object, AND you
> have specified a component of that object, it is the component that is
> being rebound...
>
> 	lst[:] = [] 
>
> is rebinding the elements inside the list "lst", and not rebinding the
> name "lst". Essentially, once you add any "selector" to the name
> (object[...]= or object.xxx=) you are going "inside" the object, and
> manipulating (rebinding) what is inside. If the name is used "pure"
> (object=), you are rebinding the /name/ to a different object.

Me gets corrected, thanks. Now I need to unroll my mind somewhat back to
figure out when and why I started to believe it sometimes assigns ;)

-- Sergei.




More information about the Python-list mailing list