How to pass Named Parameters in jython while invoking python program from Java

Viewed 16

I've to call python models from Java but unable to find the ways to pass Named Parameters through Jython.

This is actual python command: python -m sample-python.py sample-method -i input.csv -c config.yml -o output_directory

Here what I've tried:

PythonInterpreter interpreter = new PythonInterpreter();
    interpreter.execfile(
        "sample-python.py");
    interpreter.set("-i", "input.csv");
    interpreter.set("-c", "config.yml");
    interpreter.set("-o", "output_directory");
    PyFunction function = (PyFunction) interpreter.get("sample-method", PyFunction.class);

But it's not working. Can anyone suggest here what could be the possible ways to execute this command.

0 Answers
Related