Closed Uefi1 closed 3 months ago
Python stores command line parameters in sys.argv (list object). You can manipulate sys.argv before running the file.
And PLEASE stop using the Issue Tracker for questions.
Issue Tracker is on Github and was created to ask questions, what is the problem?
was created to ask questions
No. The issue tracker is for reporting bugs. PLEASE don't use it to ask questions.
No. The issue tracker is for reporting bugs. PLEASE don't use it to ask questions.
Sorry, I don't have many questions, just a couple of questions.
It’s a little unclear how it goes like this ?:
function ExecPythonFile(const Filename:string;params:string):string;
var
FGILState: PyGILstate_STATE;
begin
Result := '';
FGILState := PythonEngine.PyGILState_Ensure;
try
PythonEngine.PySys_SetArgv(0, '-help');
PythonEngine.ExecFile(Filename);
finally
PythonEngine.PyGILState_Release(FGILState);
end;
end;
I'm getting errors for some reason
PythonEngine.PySys_SetArgv(0, PPWideChar('-in -o -m'));
Invalid typecast
Will this be right ?
function ExecPythonFile(const Filename:string;params:string):string;
var
args:PPWideChar;
FGILState: PyGILstate_STATE;
begin
Result := '';
args:=@params;
FGILState := PythonEngine.PyGILState_Ensure;
try
PythonEngine.PySys_SetArgv(0, args);
PythonEngine.ExecFile(Filename);
finally
PythonEngine.PyGILState_Release(FGILState);
end;
end;
ExecPythonFile(ExtractFilePath(ParamStr(0))+'pyscript\main.py, '-i -o -threads 10')
No, it doesn’t work, and if only the first parameter one works, the rest are ignored =( I don’t quite understand how to do it
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:
And usually I run this file like this:
python main.py --help