While writing a deployment script for use with the WebLogic Scripting Tool (12.1.3), I came across this inconsistency between Python 2.2.1 and Jython 2.2.1. If you pass command line arguments to each, they are parsed differently, as noted by this test program:
$ cat pytest.py
import sys
print sys.argv
When run, here are the results with each interpreter.
CPython 2.2.1:
$ /cygdrive/c/Python22/python.exe pytest.py a b 'c,d,e'
['pytest.py', 'a', 'b', 'c,d,e']
Jython 2.2.1:
$ /cygdrive/c/jython2.2.1/jython.bat pytest.py a b 'c,d,e'
['pytest.py', 'a', 'b', 'c', 'd', 'e']
The reason I am using Jython 2.2.1 is because it is the Python implementation used by WLST, so I don't believe I can upgrade to a later version or use the CPython interpreter to circumvent the issue in my use case.
Is this a bug? Jython's parse seems counterintuitive. Is there a way to parse arguments the CPython way in Jython? Thanks in advance.
Contents of jython.bat (included with Jython install):
$ cat jython.bat
@echo off
rem This file was generated by the Jython installer
rem Created on Mon Oct 31 13:19:59 PDT 2016 by smcgloth
set ARGS=
:loop
if [%1] == [] goto end
set ARGS=%ARGS% %1
shift
goto loop
:end
"C:\Program Files\Java\jre1.8.0_101\bin\java.exe" -Dpython.home="C:\jython2.2.1" -classpath "C:\jython2.2.1\jython.jar;%CLASSPATH%" org.python.util.jython %ARGS%