Mixing Python and C classes in a module

Chris Mellon arkanes at gmail.com
Tue Oct 9 11:02:47 EDT 2007


On 09 Oct 2007 16:56:30 +0200, Stefan Arentz <stefan.arentz at gmail.com> wrote:
>
> Is it possible to mix classes defined in both Python and C in the same
> module? Ideally I would like to be able to do:
>
>  from some.module import MyPythonClass, MyCClass
>
> I guess that would mean that this would look like this on disk:
>
>  some/
>    __init__.py
>    module.py      (contains MyPythonClass)
>    module.so      (contains MyCClass)
>
> But would this work?
>

No, you'll need to make module a package, and import from (differently
named) implementation packages.



More information about the Python-list mailing list