Prerequisite: C API from Extension Module in Python | Set 1
Let’s see an example of a new extension module that loads and uses these API functions that we build up in the previous article.
Code #1 :
Code #2 : Module initialization function
Now to compile this new module, one need not bother about how to link against any of the libraries or code from the other module. One can just simply use
work.py file as shown below.
Code #3 :
After performing all this task, this new extension function works perfectly with the C API functions defined in the other module.
Code #4 : Using CPI API functions defined in the other module
Point_1 : 2.000000 3.000000
- C Extension Module using Python
- C API from Extension Module in Python | Set 1
- Python | Passing Filenames to Extension in C
- Python | Repeat and Multiply list extension
- Python | Opaque Pointers in C extension modules
- Python | Extension function operating on Arrays
- Python | Sort and store files with same extension
- grp module in Python
- pwd module in Python
- OS Path module in Python
- spwd module in Python
- Python Urllib Module
- Keyboard module in Python
- struct module in Python
- Fraction module in Python
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.