< BACKMake Note | BookmarkCONTINUE >
152015024128143245168232148039199167010047123209178152124239215162147032037050251011120109

The Python/C API

Python provides an intuitive and clean C Application Programmers Interface (API) that exposes the interface to the Python runtime system. This API provides a great number of functions to manipulate Python objects and built-in types from C and C++. Most of the functions work in much the same way as they would when called from the interpreter.

To include this API in your C/C++ program, you just need to add the header "<Python.h>" to your source code.

Internally, this header file includes both Python and C header files, including: <stdio.h>, <string.h>, <errno.h>, and <stdlib.h>. Therefore, you don't need to include these again once you include "<Python.h>".

Python/C API Reference Manual (This link takes you to the official and latest documentation about the Python/C API.):

http://www.python.org/doc/current/api/api.html

Check Appendix A, "Python/C API" of this book for more details and for a complete list of the interface functions provided by the Python/C API.


Last updated on 1/30/2002
Python Developer's Handbook, © 2002 Sams Publishing

< BACKMake Note | BookmarkCONTINUE >

Index terms contained in this section

<
      Python.h header file
adding
      Python/C Application Programmers Interface (API)
Application Programmers Interface (API)
     Python/C
            extending and embedding
applications
     non-Python
            embedding Python objects in;Python/C Application Programmers Interface (API)
C programming language
      extending and embedding Python
C++ programming language
      extending and embedding Python
creating
     Python extension modules
            Python/C Application Programmers Interface (API)
embedding
      Python objects
            Python/C Application Programmers Interface (API)
files
     header
            <Python.h
header files
     <
            Python.h
inserting
      Python/C Application Programmers Interface (API)
interfaces
     Python/C Application Programmers (API)
            extending and embedding
objects
     Python
            embedding in non-Python applications;Python/C Application Programmers Interface (API)
programming languages
     C
            extending and embedding Python
     C++
            extending and embedding Python
programs
     non-Python
            embedding Python objects in;Python/C Application Programmers Interface (API)
Python/C Application Programmers Interface (API)
      extending and embedding
software
     non-Python
            embedding Python objects in;Python/C Application Programmers Interface (API)

© 2002, O'Reilly & Associates, Inc.