Steven D'Aprano <ste...@remove.this.cybersource.com.au> writes:
> Sure, but if you want two lists, as the OP asked for, then you have to 
> iterate over it twice either way:
> 
> # method 1:
> keys = dict.keys()
> values = dict.values()
> 
> # method 2:
> keys, values = zip(*dict.items())
> 
> First you iterate over the dict to get the items, then you iterate over 
> the items to split into two lists. Anyone want to take bets on which is 
> faster?

The first way involves iterating over the dict items twice.  The
second way iterates over the dict items just once, copying them to
another place; it then iterates over the copy.
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to