On Fri, 20 Apr 2007 09:48:07 -0700, Bill Jackson wrote:
> What is the benefit of clearing a dictionary, when you can just reassign
> it as empty?
They are two different things. In the first place, you clear the
dictionary. In the second place, you reassign the name to a new object
(which may be
Gabriel Genellina wrote:
> En Fri, 20 Apr 2007 14:28:00 -0300, Larry Bates
> <[EMAIL PROTECTED]> escribió:
>
>> Bill Jackson wrote:
>>> What is the benefit of clearing a dictionary, when you can just reassign
>>> it as empty?
>>
>> If you have objects that point to the dictionary (something like a
En Fri, 20 Apr 2007 14:28:00 -0300, Larry Bates <[EMAIL PROTECTED]>
escribió:
> Bill Jackson wrote:
>> What is the benefit of clearing a dictionary, when you can just reassign
>> it as empty?
>
> If you have objects that point to the dictionary (something like a cache)
> then you want to clear t
Bill Jackson wrote:
> What is the benefit of clearing a dictionary, when you can just reassign
> it as empty?
If you have objects that point to the dictionary (something like a cache)
then you want to clear the existing dictionary instead of just assigning
it to empty. If nothing points to it, as
Bill Jackson wrote the following on 04/20/2007 09:48 AM:
> >>> import some_function
>
> >>> a = {1:2,3:4}
> >>> b = {1:2:4:3}
> >>> a.clear()
> >>> a.update(b)
>
> >>> a = {1:2,3:4}
> >>> b = {1:2,4:3}
> >>> for key in b:
> a[key] = b[key]
Clearly, this won't have the same resul
What is the benefit of clearing a dictionary, when you can just reassign
it as empty? Similarly, suppose I generate a new dictionary b, and need
to have it accessible from a. What is the best method, under which
circumstances?
>>> import some_function
>>> a = {1:2,3:4}
>>> b = {1:2:4:3}