How to get C and python functions into the same namespace?
Berthold Höllmann
bhoel at server.python.net
Sat Dec 11 06:56:27 EST 1999
Wojciech Zabolotny <wzab at ise.pw.edu.pl> writes:
> Hi All,
>
> I'm preparing a python extension module which is partially implemented as
> in "C" (cmymodule.c), and partially in python (mymodule.py).
> I'd like to have functions defined in both files in the same namespace.
> Let's assume, that the functions are defined as follows:
> cmymodule.c:
> open, read, write, close
> mymodule.py:
> info, encrypt
>
> If I import both extensions into the user program, the functions should be
> called as cmy.open(), cmy.read(),... but my.info(), my.encrypt().
> If I include the "import cmy" into mymodule.py, then syntax will be even
> worse: my.cmy.open() and so on.
> Due to performace reasons I don't want to add the python "wrappers"
> in mymodule.py for C functions.
>
> How can I locate both C and python functions in the same namespace?
> Please Cc the answer to my e-mail (given below).
Hello,
How about using:
from cmymodule import open, read, write, close
or
from cmymodule import *
in mymodule.py, or in mymodule writing:
import cmymodule
open = cmymodule.open
read = cmymodule.read
write = cmymodule.write
close = cmymodule.close
Cheers
Berthold
--
bhoel at starship.python.net / http://starship.python.net/crew/bhoel/
It is unlawful to use this email address for unsolicited ads
(USC Title 47 Sec.227). I will assess a US$500 charge for
reviewing and deleting each unsolicited ad.
More information about the Python-list
mailing list