Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > EMBEDDING > Run Python & Run C Function

Reply
Thread Tools

EMBEDDING > Run Python & Run C Function

 
 
anonymisiert85@mymail.ch
Guest
Posts: n/a
 
      06-22-2007
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

 
Reply With Quote
 
 
 
 
Farshid Lashkari
Guest
Posts: n/a
 
      06-22-2007
http://www.velocityreviews.com/forums/(E-Mail Removed) 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/extend...embedding.html

-Farshid
 
Reply With Quote
 
 
 
 
anonymisiert85@mymail.ch
Guest
Posts: n/a
 
      06-22-2007
i readed this before but not understand it - but now - the second time
it works

THANK YOU!!!!!!

 
Reply With Quote
 
Gabriel Genellina
Guest
Posts: n/a
 
      06-23-2007
En Fri, 22 Jun 2007 12:09:40 -0300, <(E-Mail Removed)> 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

 
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
Problem when try to run a Python embedding documentation example baitelli Python 0 08-31-2006 02:03 PM
Embedding Python: How to run compiled(*.pyc/*.pyo) files using Python C API? Shankar Python 1 05-05-2006 08:32 AM
write a function such that when ever i call this function in some other function .it should give me tha data type and value of calling function parameter komal C++ 6 01-25-2005 11:13 AM
Embedding Python in Python Phil Frost Python 23 08-19-2004 05:06 PM
Embedding Python in Python Darryl Python 6 10-14-2003 01:47 PM



Advertisments