#!/bin/bash

FIRST="A B C D"
SECOND="1 2 3 4"
THIRD="q r s t"

zipargs () {
    # Build parameter list for Python's zip() function.
    params=$(for i in "$@" ; do echo -n "'$i'.split()," ; done)
    python -c "
for t in zip($params):
    print ','.join(t)
"
}

# Now zip the various lists which results in output like
#  A,1,q B,2,r ...
# and assign each of the comma-separated words (note the IFS setting)
# to leg1, leg2 and acct variables.

zipargs "$FIRST" "$SECOND" "$THIRD" \
| while IFS=, read one two three ; do
    echo $one $two $three
done
