[Pyrex] referencing the module object (__pyx_m aka module_cname)?
Yann Vernier
yann at donkey.dyndns.org
Sun Nov 7 23:17:05 CET 2004
On Sun, Nov 07, 2004 at 01:53:31PM -0500, Phillip J. Eby wrote:
> At 09:52 AM 11/7/04 +0100, Yann Vernier wrote:
> >On Sat, Nov 06, 2004 at 09:26:13PM -0500, Phillip J. Eby wrote:
> >> At 01:00 AM 11/7/04 +0100, Yann Vernier wrote:
> >> >cdef extern from *: # These are declared "elsewhere"; actually, in
> >> >Pyrex.
> >> > void *module "__pyx_m"
> >>
> >> Why can't you just use 'import' to get the module object? Wouldn't
> >that be
> >> simpler than all this stuff?
> >
> >Maybe. I am not sure how that would look, and I do not want it in the
> >Python namespace, only to return it in a C function. The module is
> >embedded into Blender and available there as Blender.Text, but I am not
> >sure if it is visible at all during init time.
>
> cdef public object Text_Init():
> ...
> import Blender.Text as retval
> return retval
But Text_Init needs to return the object to be put in Blender by the
name Text, so this is recursive.
> or, if Pyrex doesn't allow the above:
>
> cdef extern from "Python.h":
> object PyImport_ImportModule(char *name)
>
> cdef public object Text_Init():
> ...
> return PyImport_ImportModule("Blender.Text")
Not sure how Python would know about that name at this point..
--
PGP fingerprint = 9242 DC15 2502 FEAB E15F 84C6 D538 EC09 5380 5746
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://lists.copyleft.no/pipermail/pyrex/attachments/20041107/55d95f3c/attachment.bin
More information about the Pyrex
mailing list