python refactorings