Calculating Midstate in Python
Trying to find this answer myself.  Noticed that the stratum_proxy is written in python and thus has the answer we are looking for.
https://github.com/slush0/stratum-mining-proxy/blob/master/mining_libs/midstate.py