473,379 Members | 1,377 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,379 software developers and data experts.

EMBEDDING > Run Python & Run C Function

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 '07 #1
3 1648
an************@mymail.ch 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
Jun 22 '07 #2
i readed this before but not understand it - but now - the second time
it works

THANK YOU!!!!!!

Jun 22 '07 #3
En Fri, 22 Jun 2007 12:09:40 -0300, <an************@mymail.chescribió:
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

Jun 23 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Alicia Haumann | last post by:
I accidentally sent this to webmaster@python.org, so this could be a duplicate if "webmaster" forwards it to this list. :{ Hi, there. Thanks for any help that can be offered. I've been...
5
by: Mark Van Orman | last post by:
Hi all, I have an application that logs in xml. Assume <xmlLog></xmlLog>. In this element the app logs anything it gets from foreign hosts. Now if the host sends xml data, the structure of the...
2
by: Isaac Gerg | last post by:
I have a server running PHP on linux. For a website, I want to have the webdocuments stored in XML, then parsed by PHP code to add the appropriate titles, headers, menus, etc. So, I want to...
11
by: Les Paul | last post by:
I'm trying to design an HTML page that can edit itself. In essence, it's just like a Wiki page, but my own very simple version. It's a page full of plain old HTML content, and then at the bottom,...
3
by: Marco Meoni | last post by:
Hi all! I've a problem with a C++ class that has to be included in a python application. One way to do it is Extending and Embedding the Python Interpreter Now i have 2 questions 1) Is there a...
0
by: Fozzie | last post by:
Hi, I have a problem which is quite circular, and hopefully either someone has encountered something similar or has a reason why this will not work. We have a COM library providing...
6
by: mistabean | last post by:
Hello, first of all, I am a programming newbie, especially in python... Onwards to the problem, I have been having difficulty embedding a python module into my C/C++ program. (just a test...
2
by: John Grandy | last post by:
I am not having success embedding carriage return and line feed characters into a string and displaying them with an ASP.NET label. Is anyone getting either of the following to work ? ...
0
by: Tim Spens | last post by:
--- On Fri, 6/27/08, Tim Spens <t_spens@yahoo.comwrote: I think I know where the problem is but I'm unsure how to fix it. When I call Register_Handler(...) from python via...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.