Quote:
Originally Posted by rubeus
Why is
Code:
image['values'] = img_dic.keys().sort()
exporting an empty list?
|
The sort() method of a list modifies the list in place, but returns None. To do what you want with the list method, you'd have to do something like:
Code:
image['values'] = img_dic.keys()
image['values'].sort()
print image['values']
The 'sort' list method was all that was available prior to Python 2.4. The builtin function 'sorted' (available from Python 2.4+) builds a new sorted list from any iterable--and is imminently handier most times--as you've no doubt discovered.
Code:
print sorted(img_dic.keys())