Revision of python partition code

These changes do not change how the algorithms function or how they compute random partitions, but they do change the style of the code, the order of arguments to functions, and the overall flow of the functions.