Running a Python script with c++

For executing more complex Python scripts, it’s better to construct a command using FPythonCommandEx struct and pass it to the exec function. For example:

FPythonCommandEx PythonCommand;
PythonCommand.Command = FString::Printf(
      TEXT("from my_module import MyClass; "\
      "my_class = MyClass(); "\
      "my_class.call_my_method()")
);
PythonCommand.ExecutionMode = EPythonCommandExecutionMode::ExecuteStatement;
PythonCommand.FileExecutionScope = EPythonFileExecutionScope::Public;
bool Result = IPythonScriptPlugin::Get()->ExecPythonCommandEx(PythonCommand);