replacement for execfile

Stefan Bellon sbellon at sbellon.de
Fri Aug 3 04:31:03 EDT 2007


On Sun, 29 Jul, Steven D'Aprano wrote:

> (1) Don't use eval, exec or execfile.

Ok, then I would really like to ask a question about how to solve my
problem without execfile ... ;-)

I am embedding Python on Windows using MinGW. In order to execute a
Python script file, calling any of the PyRun_File functions does not
work but crashes (I assume this is because the Python DLL was built
using Microsoft tools and those tools and MinGW have different FILE
structures, so a FILE *fp cannot be passed from my MinGW C code to
the Python DLL).

Therefore my current solution is to call PyRun_String functions and
execute a string with the content "execfile('filename')".

Is there a way to solve this problem with PyRun_File?

-- 
Stefan Bellon



More information about the Python-list mailing list