Jython debugger inserts the filename of the script for the sys.argv[0]

When using the Jython debugger, the sys.argv[0] program argument specifies the filename of the script being debugged, and the sys.argv[1] is the first program parameter. However, if you are not debugging the Jython script the specification of the program arguments is different, the sys.argv[0] is the first program parameter, similar to running most programming languages. One possible way to maintain consistency in the program operation is to use the following Jython script to dynamically adjust for the difference:
base = 0
if( len(sys.argv)>0 ):
    param1 = sys.argv[0]
    param1 = param1[len(param1)-3:].lower()
    if( param1==".py" or param1==".jy" ): 
        base = 1
    #endIf
#endIf
if ( len(sys.argv) > (base+0) ):
    myArg0 = sys.argv[base+0]
    if (len(sys.argv) > (base+1) ):
        myArg1 = sys.argv[(base+1)]
        if (len(sys.argv) > (base+2) ):
            myArg2 = sys.argv[(base+2)]
        #endIf 
    #endIf 
#endIf
Related tasks
Debugging Jython script files on WebSphere Application Server
Running administrative script files on WebSphere Application Server
Related reference
Jython debugger demo and test program (DebugTest.py)

Feedback