TPython::ExecScript example with arguments does not work

I came across the following

example of use: const char* argv[] = { “1”, “2”, “3” }; TPython::ExecScript( “test.py”, sizeof(argv)/sizeof(argv[0]), argv );

executing this does not work. Printing print(sys.argv) inside test.py shows [‘root’] and not the list of arguments specified in the call.

Is this because of using Python3? If yes, is there another solution?

Thomas


Hello,

Yes indeed this functionality only works properly with Python2, in Python3 the arguments are not correctly passed to the script as you observed.

The only alternative at the moment in Python3 is to run individual statements or expressions with TPython::Exec or TPython::Eval.

I opened this issue to follow it up:

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.