Python: share the command line argument to os.system call
Question: I am new to python. I searched and trying following approach:

I have 3rd party application called "xyz", which takes n argument.

I would like to warp this "xyz" into my module called "abc.py" which required
m arguments.

I would like to read and keep my m arguments and pass remaining n argument to
"xyz"

Note: the number of n argument is huge, so it would best if we dont need to re
state same number of argument in my module and directly pass to "xyz"

Hope it should be possible and I didn't confused.

Thanks for the help.


Answer: Let's say your external program "xyz" is `echo`.

    
    
    import subprocess
    import sys
    
    m = 3 # number of args for abc.py; remainder goes to external program 'echo'
    args = sys.argv
    abc_args = args[1:m+1]
    echo_args = args[m+1:]
    
    cmd = ['echo']
    cmd.extend(echo_args)
    subprocess.call(cmd)
    

This results in

    
    
    $ python abc.py 1 2 3 4 5 6
    4 5 6
    

