Suppose I have a python file test.py:
import os
class print_args(object):
def__init__(self, x, y, z):
self.x = x
self.y = y
self.z = z
print(x)
print(y)
print(z)
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument('--x', nargs='+', type = str)
parser.add_argument('--y', nargs='+', type = int)
parser.add_argument('--z', type = int)
args = parser.parse_args()
print_args(args.x, args.y, args.z)
I can run test.pyfrom the terminal with arguments as follows:
python3 test.py
Results expected:
a b
2 3
10
How to run test.pyusing GNU-parallel in a terminal with array arguments? The solution will be equivalent to running:
python3 test.py
python3 test.py
python3 test.py
python3 test.py
My incorrect attempt to answer my question:
parallel --link 'python3 test.py --x {1} --y {2} --z {3}' ::: \
> 'a b' 'a b' 'a b' 'a b' ::: \
> '2 3' '2 3' '2 3' '2 3' ::: \
> '10' '20' '30' '40'
source
share