Re: python commmand line params from c++
- From: "Denis S. Otkidach" <ods@xxxxxxxxx>
- Date: Thu, 30 Jun 2005 19:07:36 +0400
On 30 Jun 2005 07:52:04 -0700
"Wesley Henwood" <wesleyhenwood@xxxxxxxxxxx> wrote:
> What is the proper way to pass command line parameters to a python
> script called from C++? I'm tryng this:
Have you tried PySys_SetArgv?
> path = "c:\\someDir\\someScript.py param1 param2 param3";
> PyRun_SimpleFile(PyFile_AsFile( PyFile_FromString( path, "r")),
> "someScript.py");
This code looks strange: you open file and create Python file object
from its descriptor (PyFile_FromString), then get descripto back
(PyFile_AsFile) to pass it to PyRun_SimpleFile. Why don't you just use
C fopen function?
> I'm getting a "format error someScript.py, line 1" when the code is
> executed.
>
> Note: The strange appearannce of the 3 python function calls nested is
> not a bug, but required to prevent a run-time error.
I believe it's due to PyFile_FromString failing to open non-existent
file. You must check return value of it.
--
Denis S. Otkidach
http://www.python.ru/ [ru]
.
- Follow-Ups:
- Re: python commmand line params from c++
- From: Wesley Henwood
- Re: python commmand line params from c++
- From: Wesley Henwood
- Re: python commmand line params from c++
- References:
- python commmand line params from c++
- From: Wesley Henwood
- python commmand line params from c++
- Prev by Date: Re: Which kid's beginners programming - Python or Forth?
- Next by Date: Re: Favorite non-python language trick?
- Previous by thread: python commmand line params from c++
- Next by thread: Re: python commmand line params from c++
- Index(es):
Relevant Pages
|