Paddy:
> Mind you, Never rely on that implied ordering. Always use items().

Using dict.items() is probably better, but the manual says:

>If items(), keys(), values(), iteritems(), iterkeys(), and itervalues() are 
>called with no intervening modifications to the dictionary, the lists will 
>directly correspond. This allows the creation of (value, key) pairs using 
>zip(): "pairs = zip(a.values(), a.keys())". The same relationship holds for 
>the iterkeys() and itervalues() methods:<

Is this going to change?


dict.keyset() seems nice, but you usually don't want to make a too much
big API.
Keeping APIs small is very important in Python, otherwise you need the
manual to write code.
I think a better solution to solve such key set problems is to optimize
Python itself, so Python computes set(dict) really fast (it can just
"copies" the hash of the dict).

Bye,
bearophile

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to