Source code refactoring. Extracted common functionality in cpp_helpers.cc and python/python_generator.cc