refactoring PythonGenerator