Python loops and calls java