Arg! [Long]

Magnus L. Hetland mlh at vier.idi.ntnu.no
Tue Dec 21 16:35:55 EST 1999


"Fred L. Drake, Jr." <fdrake at acm.org> writes:

> Magnus L. Hetland writes:
>  > Suddenly it works. Hm. So it actually needs sourcecode - i'd say
>  > that's quite a shortcoming <wink>
> 
>   You'll just have to get over that one... ;)

Oh, well... OK. ;)

>   If you try "import spammodule" it should fail:
> 
> >>> import parsermodule
> Traceback (innermost last):
>   File "<stdin>", line 1, in ?
> ImportError: dynamic module does not define init function
> (initparsermodule)

Oh - so (pardon my ignorance) how do you use parsermodule?

> 
>   (Only yours will say "initspammodule".)
>   If you want the .so to be named spam.so, rename the source file to
> spam.c and adjust Setup.in to say:
> 
>        *shared*
>        spam spam.c

I did that. (Or - rather, I renamed it to spludge, since there already
seemed to be a module "spam" taking precedence over mine.)

So - no I can compile it and import it. Yay!

I guess I shouldn't be too upset about it not working...

>>> dir(spludge)
['', '__doc__', '__file__', '__name__']
>>> 

There should be a 'system' in there, according to:

static PyMethodDef SpludgeMethods[] = {
  {"system", spludge_system, METH_VARARGS},
  {NULL, NULL} /* sentinel */
};

void initspludge()
{
  (void) Py_InitModule("spludge", SpludgeMethods);
}

This sounds familiar, though... I think I had the same problem with
SWIG earlier ... (i.e. garbage names for the functions...)

> 
> 
>   -Fred

--

  Magnus
  Lie
  Hetland



More information about the Python-list mailing list