How to use for-loop in Jython PythonInterpreter?
Question: Is it possible and how to write down _for-loop_ in `PythonInterpreter` using
`exec()` method?

With `exec()` it looks fine and like interactive line by line input in the
Python command line, but the following with `for` statement doesn't work:

    
    
    PythonInterpreter python = new PythonInterpreter();
    python.exec("import sys");
    python.exec("for p in sys.path:");
    python.exec("    print p");
    


Answer: You are passing in separate lines, how is Python supposed to parse those
separately and validate that you have valid code?

Use one string:

    
    
    python.exec("for p in sys.path:\n" +
                "    print p");
    

The `import sys` line can still be passed in separately because the namespace
into which the module is imported is persisted in the `PythonInterpreter`
instance.

In essence, each string passed to `exec()` must follow the [`stmt_list`
grammar
token](https://docs.python.org/2/reference/compound_stmts.html#grammar-token-
stmt_list); compound statements must be complete.

