Python version passes all the tests the perl one does.
split into smaller methods. tests still pass.
Follow python naming conventions. Tests pass.