When to clear a dictionary...

Bill Jackson jackson at hotmail.com
Fri Apr 20 12:49:20 EDT 2007


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 result as the other two examples.

> 
>  >>> a = {1:2,3:4}
>  >>> b = {1:2,4:3}
>  >>> a = b
> 



More information about the Python-list mailing list