How do I run a python file that is read into a std::string using PyRun
<p>I am embedding Python into my C++ program, and have used PyRun_SimpleString quite effectively but now am having trouble.</p>

<p>What I have done is loaded a python.py file a std::string but am now having troubles running it. PyRun_SimpleFileEx didn't seem to do the trick either so some help would be great!</p>

<pre><code>    std::string content;
    if(!ail::read_file(python_script, content))
    {
        error("Failed to load Python script \"" + python_script + "\"");
        return false;
    }

    if(prompt_mode)
        initialise_console();

    content = ail::replace_string(content, "\r", "");

    Py_Initialize();
    initialise_module();

    std::string script_directory;
    if(get_base_name(python_script, script_directory))
        PyRun_SimpleString(("import sys\nsys.path.append('" + script_directory + "')\n").c_str());

        write_line("Script dir: " + script_directory);
        ////-python_script H:\\CRAW\\craw\\script\\craw.py
        //content.c_str()

    //FILE *fp;
    //fp = fopen("H:\\CRAW\\craw\\script\\craw.py", "r");

    //PyRun_SimpleFileEx(fp, "craw.py", 1);
    if(PyRun_SimpleString(content.c_str()) != 0)
    {
        write_line("The main Python script contained errors.");
        return false;
    }

    //PyRun_SimpleString(("execfile('" + ail::replace_string(python_script, "\\", "\\\\") + "')").c_str());

    return true;
</code></pre>
