Python 2.7, 3.0 refactoring