I have two python scripts A and B, both with a main and with different input arguments (I use argparse). I launch them normally with:
$ python A.py --paramA1 valA1 --paramA2 valA2
$ python B.py --paramB1 valB1 --paramB2 valB2
I'd like to be able to call B from within A and to specify B's parameters when launching A. In short, I want to call A with A's parameters and B's parameters. Here's what it should look like from the outside:
$ python A.py --paramA1 valA1 --paramA2 valA2 --paramB1 valB1 --paramB2 valB2
Is there a more elegant way to do this than copying and pasting B's argparse code into A and then calling B on them?
EDIT: To simplify things, here's some example code:
A.py:
import argparse
def main():
parser = argparse.ArgumentParser(description="Args for A.py")
parser.add_argument("--param1A", type=int)
parser.add_argument("--param2A", type=int)
args = parser.parse_args()
valA1 = args.param1A
valA2 = args.param2A
...
return 0
B.py:
import argparse
def main():
parser = argparse.ArgumentParser(description="Args for B.py")
parser.add_argument("--param1B", type=int)
parser.add_argument("--param2B", type=int)
args = parser.parse_args()
valA1 = args.param1B
valA2 = args.param2B
...
return 0
What exactly would the suggested C.py, which includes arguments for both A.py and B.py look like? And what would A.py and B.py look like then?
EDIT 2: I forgot to mention that one of the parameters of B.py has to be created in A.py, so the order of execution is A then B, and A has to be able to pass a parameter to B.