I've been looking at docs but I can't seem to understand very clearly, them do you guys know of anything that would be good at tea开发者_如何学编程ching it.
Say I had a program,
int main() {
return 3;
}
How do I call cprogram.exe and get the return value (not neccesarily an int, structs too). I don't have a specific project that I'm working on, just trying to learn. So on top of answering this question, some references (books or otherwise) to where I could learn continuation of this, because I know its more complicated than this; would be nice; thanks in advance.
lol sentence structure.
The simplest way of doing this would be to create a dll or so (depending on your platform) then use the ctypes module to call into it. The exact method for creating the dll depends on your compiler. For ctypes see http://python.net/crew/theller/ctypes/tutorial.html
Wesley Chun has a nice chapter showing how to do it in his "Core Python Programming" book.
The Python docs themselves may be a good place to start:
http://docs.python.org/release/2.5.2/ext/intro.html
精彩评论