Source code refactoring. Extracted common functionality in cpp_helpers.c...

...c and python/python_generator.cc
Please revert changes to this file. I don't think this refactoring helps.