Rapid conversion of ruby instance method to python.
Finish python port, testing needed