Embedding Python in C DLL

Discussion in 'Python' started by terti, Sep 8, 2004.

  1. terti

    terti Guest

    Hi,
    // I need some help to embed the equivalent of the following Python code
    in a C DLL.

    from NLRclient import NLRclient
    i = NLRclient("server")
    s = i.getStrSort("qwerty")


    // This what I have so far:

    PyObject *module, *i;
    PyObject *arg , *kw;

    // The following I will put in the DllMain entrypoint
    Py_Initialize();

    // from NLRclient import NLRclient
    module = PyImport_ImportModuleEx( "NLRclient", Py_BuildValue(""),
    Py_BuildValue("") , Py_BuildValue( "", "NLRclient" ));

    // i = NLRclient("server")
    i = PyInstance_New( module, Py_BuildValue("s","server"),
    Py_BuildValue(""));


    Up to here the program compiles but when I run the application, I get a
    runtime error dialog.





    //This will be placed in one of the Dll functions
    // s = i.getStrSort("qwerty")

    How to I invoke a method from the created "i" instance ?



    Py_Finalize();
    return 0;


    Many thanks,
    Tertius
     
    terti, Sep 8, 2004
    #1
    1. Advertising

  2. terti

    terti Guest

    terti, Sep 8, 2004
    #2
    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. Anushi
    Replies:
    5
    Views:
    8,882
  2. Darryl

    Embedding Python in Python

    Darryl, Oct 8, 2003, in forum: Python
    Replies:
    6
    Views:
    406
    Darryl
    Oct 14, 2003
  3. Replies:
    2
    Views:
    531
    Larry Bates
    Mar 9, 2007
  4. H. Simpson
    Replies:
    4
    Views:
    311
    H. Simpson
    Aug 3, 2004
  5. Benedikt Feldhaus

    Embedding Perl in Win32 Dll

    Benedikt Feldhaus, Nov 4, 2003, in forum: Perl Misc
    Replies:
    0
    Views:
    116
    Benedikt Feldhaus
    Nov 4, 2003
Loading...

Share This Page