EMBEDDING > Run Python & Run C Function

Discussion in 'Python' started by anonymisiert85@mymail.ch, Jun 22, 2007.

  1. Guest

    At the moment i can run python-string-code from C (MinGW, WinXP)

    But how can i register a C-function in python-RUNTIME and call this C
    function from python - without wrapper dll's or libs???


    STEPS:
    initialize python
    regsiter foo() ########### don't know how to do this
    run python-script "c=foo(a,b)"
    finalize


    my C function should do this:


    char* foo (char* a, char* b)
    {
    char* c="return one strings";
    return c;
    }


    have someone a idea?
    i checked the online docs - but i don't understand :-(
    can someone post a short sample? please...

    thank you
     
    , Jun 22, 2007
    #1
    1. Advertising

  2. wrote:
    > At the moment i can run python-string-code from C (MinGW, WinXP)
    >
    > But how can i register a C-function in python-RUNTIME and call this C
    > function from python - without wrapper dll's or libs???


    Have a look at the following documentation page on extending/embedding
    python. I believe it does exactly what you want.

    http://www.python.org/doc/ext/extending-with-embedding.html

    -Farshid
     
    Farshid Lashkari, Jun 22, 2007
    #2
    1. Advertising

  3. Guest

    i readed this before but not understand it - but now - the second time
    it works

    THANK YOU!!!!!!
     
    , Jun 22, 2007
    #3
  4. En Fri, 22 Jun 2007 12:09:40 -0300, <> escribió:

    > At the moment i can run python-string-code from C (MinGW, WinXP)
    >
    > But how can i register a C-function in python-RUNTIME and call this C
    > function from python - without wrapper dll's or libs???


    You can use ctypes:
    http://www.python.org/doc/lib/module-ctypes.html

    --
    Gabriel Genellina
     
    Gabriel Genellina, Jun 23, 2007
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Darryl

    Embedding Python in Python

    Darryl, Oct 8, 2003, in forum: Python
    Replies:
    6
    Views:
    423
    Darryl
    Oct 14, 2003
  2. Phil Frost

    Embedding Python in Python

    Phil Frost, Aug 18, 2004, in forum: Python
    Replies:
    23
    Views:
    788
    Paul Rubin
    Aug 19, 2004
  3. Maurice LING

    embedding python in python

    Maurice LING, Sep 29, 2004, in forum: Python
    Replies:
    8
    Views:
    403
    Jeff Shannon
    Oct 1, 2004
  4. Shankar
    Replies:
    1
    Views:
    721
    Serge Orlov
    May 5, 2006
  5. baitelli
    Replies:
    0
    Views:
    349
    baitelli
    Aug 31, 2006
Loading...

Share This Page