Using all elements of a list as argument to a system command (netCDF operator) in a python code
Question: I've a python code performs some operator on some netCDF files. It has names
of netCDF files as a list. I want to calculate ensemble average of these
netCDF files using netCDF operator ncea (the netCDF ensemble average). However
to call NCO, I need to pass all list elements as arguments as follows:

    
    
     filelist = [file1.ncf file2.ncf file3.ncf ........ file50.ncf]
    
    ncea file1.ncf file2.ncf ......file49.ncf file50.ncf output.cdf
    

Any idea how this can be achieved.

ANy help is greatly appreciated.


Answer: 
    import subprocess
    import shlex
    args = 'ncea file1.ncf file2.ncf ......file49.ncf file50.ncf output.cdf'
    args = shlex.split(args)
    p = subprocess.Popen(args,stdout=subprocess.PIPE)
    print p.stdout # Print stdout if you need.
    

