MIsc python utilities code