title: Pass multiple bash arrays to Python using argparse
body: <p>I have a Python script that I want to run from a bash, and it needs multiple string arrays/lists inputs. This answer by <a href="https://stackoverflow.com/a/33867675/7032387">lorenzog</a> in another question explains how to do it with one array, and it works fine. But how can I pass multiple arrays? Here's what I've tried so far:</p>
  
  <p><strong>Bash script:</strong></p>
  
  <pre><code>#!/bin/bash
  
  declare -a first=("one" "two" "three")
  declare -a second=("four" "five")
  declare -a third=("six")
  declare -a fourth=("seven" "eight")
  
  python argsprob.py "${first[@]}" "${second[@]}" "${third[@]}" "${fourth[@]}"
  </code></pre>
  
  <p><strong>Python script:</strong></p>
  
  <pre><code>#!/usr/bin/env python3
  
  import argparse
  
  parser = argparse.ArgumentParser()
  parser.add_argument('first', nargs='+')
  parser.add_argument('second', nargs='+')
  parser.add_argument('third', nargs='+')
  parser.add_argument('fourth', nargs='+')
  args = parser.parse_args()
  
  print(args.first)
  print(args.second)
  print(args.third)
  print(args.fourth)
  </code></pre>
  
  <p><strong>Output</strong></p>
  
  <pre><code>$ bash argsprob.sh
  ['one', 'two', 'three', 'four', 'five']
  ['six']
  ['seven']
  ['eight']
  </code></pre>
  
  <p><strong>Desired output</strong></p>
  
  <pre><code>['one','two','three']
  ['four','five']
  ['six']
  ['seven','eight']
  </code></pre>
  
  <p>As you can probably tell I have no idea what I'm doing. I've tried other ways of using <strong>argparse</strong> (more arguments, different "nargs", etc) but none of them works. Any help is appreciated!</p>