How it works...

In the preceding C code (fprintf()) is being used to access Python. As this isn't a C programming book, I won't provide the in-depth workings of the code, but here is a brief rundown of what is happening:

  1. Python is being imported into the code as a header file.
  2. The C code is told about the paths to Python runtime libraries.
  3. The Python interpreter is initialized.
  4. A Python script is hard-coded into the C code and processed.
  5. The Python interpreter is shut down.
  6. The C program finishes.

In real practice, the Python program to be executed would be pulled from a file, rather than being hard-coded, as it removes the need for the programmer to allocate memory and load the file contents.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset