Pete’s Python cookbook

Attempting to ensure that Python 2.7 uses UTF-8 encoding internally and in all output:

 

Sort a dictionary (aka an indexed list, aka a hash) by value in descending order and write them to a file, one line per key:value, space-delimited:

 

Download and cache a webpage if it hasn’t been downloaded and cached before
NOTE: Requires the existence of a folder named ‘cachedPages’!