[python3] refactoring