If you do not want to use the MARS syntax with the mars script we provide, you can directly use Python. The execute function accepts both a Python dictionary or a string. To use the 'list' function, the argument must be a string starting with 'list,'. In this example we convert the request dictionary to a string with 'list':
server = ECMWFService("mars") req = { "class": "od", "date": "20150101", "expver": "1", "levtype": "sfc", "param": "167.128", "step": "0/to/240/by/12", "stream": "oper", "time": "00", "type": "fc" } kv='list,'+''.join('{}={},\n'.format(key, val) for key, val in req.items())+'output=cost' server.execute(kv,'target.txt')