Python code and C code in the same module?

Steven Bethard steven.bethard at gmail.com
Tue Nov 30 02:41:47 EST 2004


I'd like to merge a module written in C with a module written in Python 
so that the user can access objects from either module by importing the 
single, merged module.

Specifically, I'm looking at the collections module, which is written in 
C, and my Bunch object, which is written in Python.  I'd like the Bunch 
object to appear in the collections module so that you can do:

     from collections import Bunch

without, of course, removing the ability to do:

     from collections import deque

There's no need for the code to reside in the same file or anything of 
course -- I just want the different objects to appear in the same module.

Thanks,

Steve



More information about the Python-list mailing list