[Tutor] Re: embedding python in C --- big porblem

edward ed_tsang@yahoo.com
Tue, 14 Sep 1999 16:08:43 -0700


Please mail me your response to ed_tsang@yahoo.com
thanks

edward wrote:

> Hi to all knowlegable python user out there:
> I'm am very new to python and have been having huge trouble in embdding
> python with c and extending python with c.
> here is what I am trying to do:
> 1) extending python in c
>    A)
>    *  create a function mymath(int a, int b)  in a file called mymath.c;
>
>    *  try to call mymath  function to add 1 & 2 from a pythohn script,
>    * without recompling try to call mymath to add 3 and 4 from the
> python script
>    *  without recompliing try to redefine mymath, so that I am
> subtracting this time
>    * try to call mymath function to subtract 1 from 2
>    * without recompliing try to call mymath to subtract 3 from 4
>     B)
>     * create a structure which has two elements a and b,
>          a function initStruct(x,y)  to in a file called intiStruct.c.
> initStruct(x,y)  will initlize a    to     x, b to y value.
>      *  try  from a pythohn script, try to call the initStruct to
> intialise the stucture to 2 and 3
>     * without recompling try to call initStruct to intialise structure
> to 3 and 4 from the python script
>
> 2) embedding python to c
> A)
>   *  create a function mymath(int a, int b)  in a file called mymath.py
> ;
>    *  try to call mymath  function to add 1 & 2 from a C program,
>    * without recompling try to call mymath to add 3 and 4 from the C
> program
>    *  without recompliing try to redefine mymath, so that I am
> subtracting this time.
>    * try to call mymath function to subtract 1 from 2, from the C
> program
>    * without recompliing try to call mymath to subtract 3 from 4, from
> the C program
>
> Can any one help me on this please. Can you give me the complete working
> code on this matter. I really need all you expert help on this thing.
> thanks.