Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Embedding Python in C DLL

Reply
Thread Tools

Embedding Python in C DLL

 
 
terti
Guest
Posts: n/a
 
      09-08-2004
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( "[s]", "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
 
Reply With Quote
 
 
 
 
terti
Guest
Posts: n/a
 
      09-08-2004
The following site cleared things up for me.

http://davidf.sjsoft.com/mirrors/mcm...inc/embed.html

I changed my Python script to a module with functions rather than a
class with methods. With no instantiation needed, things started working
better.

Regards,
Tertius

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to determine if a DLL is a COM DLL or .NET DLL Anushi ASP .Net 5 10-28-2004 01:59 PM
Why does Ruby use both tcl83.dll and tk83.dll (instead of just tk83.dll)? H. Simpson Ruby 4 08-03-2004 04:45 PM
mprapi.dll --> samlib.dll --> ntdll.dll issue. Some1 Computer Support 4 04-05-2004 02:02 AM
Embedding Perl in Win32 Dll Benedikt Feldhaus Perl Misc 0 11-04-2003 01:59 PM
msvcrt.dll, msvcirt.dll, msvcrt20.dll and msvcrt40.dll, explanation please! Snoopy NZ Computing 16 08-25-2003 12:34 PM



Advertisments