python code style refactor