NEWBIE: Extending Python with C

Dennis Lee Bieber wlfraed at ix.netcom.com
Fri Nov 8 23:49:12 EST 2002


engsol at teleport.com fed this fish to the penguins on Friday 08 November 
2002 07:48 pm:

> I've read the books, tried some code, and I still just don't get it.
> 
> If some kind soul can explain the (high level) process, I can figure
> out the details, I think.
> 
> What I want to do is call (or invoke) a C exe  from Python, and return
> the results to Python. Or pass values of some sort to the C exe, and
> again have Python trap the returned results. I'm a long way from the
> concept of shared variables. <grin>
> 
> The first stumbling block is that the books offer examples of C code
> which don't seem to have a main(). My compilers don't care for that
> too much. I took a quick look at SWIG, but to be honest, I didn't
> understand how to use it. Again, I need the high level concept.
> 
        There is no "main" because they aren't part of a stand-alone 
executable program. They become specialized libraries that Python can 
access using the normal "import module" syntax.

        If all you want to to access a separate program you might be 
interested in os.system(), or the variants of popen...

        
--  
 > ============================================================== <
 >   wlfraed at ix.netcom.com  | Wulfraed  Dennis Lee Bieber  KD6MOG <
 >      wulfraed at dm.net     |       Bestiaria Support Staff       <
 > ============================================================== <
 >        Bestiaria Home Page: http://www.beastie.dm.net/         <
 >            Home Page: http://www.dm.net/~wulfraed/             <



More information about the Python-list mailing list