It might be good to put this calculation of start, end, and current_page into a helper function (in Python, a function can return multiple values). Then it would be easy to add unit tests for the various edge cases.