Memo
Data Types
# Sorting
sortedResults = collections.OrderedDict(sorted(result.items()))
# Sorting by value
sortedResults = collections.OrderedDict(sorted(result.items(), key=lambda x: x[1]))
# Ordering
sortedResults = collections.OrderedDict(sorted(result.items(), key=lambda x: x[1], reverse=True))File IO
# Using 'with' to include file close and exception handling.
with open('workfile', 'r') as f # r: read, r+: read / write, w: write, a: append
for line in f:
print lineLast updated