I have an argparser that is getting very long. I want to move it into a separate file to keep my main script clean. Right now I have:
main.py
import argparse
parser = argparse.ArgumentParser()
parser.add_argument('-t', '--test',
default=0.1,
type=float,
help='test')
# Many more arguments
args = parser.parse_args()
# My main code
print("Argument in my code:{}".format(args.test))
...
Is there a way to turn this into two files to keep my main file clean?
main.py
import parsing_file
# My main code
print("Argument in my code:{}".format(args.test))
parsing_file.py
import argparse
parser = argparse.ArgumentParser()
parser.add_argument('-t', '--test',
default=0.1,
type=float,
help='test')
# Many more arguments
args = parser.parse_args()