dict slice in python (translating perl to python)

B execrable at gmail.com
Wed Sep 10 18:51:03 CEST 2008


Fredrik Lundh wrote:
> B wrote:
>> for a long list, you could try:
>> result = [mydict[k] for k in mydict]
>> or       [mydict[k] for k in mydict.keys()]
>> or       [mydict[k] for k in mydict.iterkeys()]
> 
> and the point of doing that instead of calling mydict.values() is what?
> 
> </F>
> 

It's more fun?  Or if you want to sort by keys.



More information about the Python-list mailing list