Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Info
titleOverview

Python is wonderful. C is wonderful. Do I need to choose? No!

This tutorial will show you how to create a program in which some is written in Python and some in is written in C.

More specifically, you will be creating a Python C extension module, which you can import into Python as any module. You will also see how to call a C function from Python, and a Python function from C.

...

Building the extension module is driven by the setup.py file, which declares that you want to build a module called hello, and that this it consists of the source file hellomodule.c. This is equivalent to a Makefile or an SConscripSConscript, if you're used to make or SCons.

...

The resulting module will be placed at (for Windows) build/lib.win32-2.7/hello.pyd.

You can now see it as a regular Python module.

...

Code Block
Result from myFunction:
Hello mehdi!
sum 3
ScripScript ended normally. Press Enter to close.

...