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} >>> a.clear() >>> a.update(b) >>> a = {1:2,3:4} >>> b = {1:2,4:3} >>> for key in b: ... a[key] = b[key] >>> a = {1:2,3:4} >>> b = {1:2,4:3} >>> a = b -- http://mail.python.org/mailman/listinfo/python-list