Calling a C program from a Python Script

Armin Steinhoff a-steinhoff at
Thu Dec 9 23:04:44 CET 2004

Brad Tilley wrote:
> Is it possible to write a file open, then read program in C and then 
> call the C program from a Python script like this:
> for root, files, dirs in os.walk(path)
>     for f in files:
>         try:
>             EXECUTE_C_PROGRAM
> If possible, how much faster would this be over a pure Python solution?

I would compile that C program into a shared library (*.so or *.dll ) in 
order to use that shared library with ctypes ... that's the easiest way, 
IMHO :)  ( )



> Thank you,
> Brad

More information about the Python-list mailing list