Bryan Olson wrote: > Magnus Lycka wrote: > >> Bryan Olson wrote: >>> big_union = set() >>> for collection in some_iter: >>> big_union.update(t) >>> collection.clear() >> >> I don't understand the second one. Where did 't' come from? > > Cut-and-past carelessness. Meant to update with 'collection'.
If some_iter gives you dicts, the code above will throw away your values, and put the set of keys in big_union. Is that what you meant to do? I suspect most people would find this somewhat surprising. For sets and "BryanLists" it will put a set of all the contents of those collections in big_union. I think this just verifies my previous arguments. It's rarely meaningful to write functions that are meaingful for all builtin collections. -- http://mail.python.org/mailman/listinfo/python-list