Main() with arguments - nireeshach/python_training GitHub Wiki
main() in python
simple main function calling:
if __name__ == "__main__":
main()
otherwise if we want to run the main() with the arguments where arguments will give at the runtime.
if __name__ == "__main__":
parser = argparse.ArgumentParser()
required_args = parser.add_argument_group()
required_args.add_argument("-i", "--input_file", dest="input_file", required=True)
required_args.add_argument("-o", "--AML", dest="AML", type=bool, default=False)
arguments = parser.parse_args()
main(arguments.input_file, arguments.AML)
to get input boolean optional or if you given the argument then the function will activate by using action="store_true"
required_args.add_argument(
"--AML", dest="AML", help="AML required output", action="store_true"
)