Paul Rubin a écrit : > Laurent Pointal <[EMAIL PROTECTED]> writes: >> Both work, you may prefer xrange/iteritems for iteration on large >> collections, you may prefer range/items when processing of the result >> value explicitly need a list (ex. calculate its length) or when you are >> going to manipulate the original container in the loop. > > You can use len(d) if d is a dict.
Yes, as long as you have a semantic relation between the original dict and the extracted keys. But once you have extracted the keys, and pass them around your functions, if you miss the relationship, you have either a list container or a generator. Not considering the case where original dict is modified between keys extraction and keys usage... But as we dont know more about OP needs... A+ Laurent. -- http://mail.python.org/mailman/listinfo/python-list