Skip to content

Run the .py file immediately with parameters #461

Closed
@Uefi1

Description

@Uefi1

Hello, please tell me how to correctly run a ready-made .py file via Python4Delphi if the file itself requires launching with some parameters, for example -h -u -i -o for example, I would like to do something like:

function ExecPythonFile(const Filename,Params:string):string;
var
FGILState: PyGILstate_STATE;
begin
Result := '';
FGILState := PythonEngine.PyGILState_Ensure;
try
PythonEngine.ExecFile(Filename, params); //????
finally
PythonEngine.PyGILState_Release(FGILState);
end;
end;

procedure TForm1.Button1Click(Sender: TObject);
var
s:string;
begin
ExecPythonFile(ExtractFilePath(ParamStr(0))+'pyscript\main.py', ' --help');
end;

And usually I run this file like this:
python main.py --help

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions