Peter Otten <__pete...@web.de> added the comment:
That's a bug in your code. You create another ArgumentParser in the toplevel code of preprocess.py. When this module is imported directly or indirectly your script will us this parser to parse the command line first. Minimal example: $ cat preprocess.py import argparse parser = argparse.ArgumentParser() parser.add_argument("--foo") print(parser.parse_args()) $ cat test.py import argparse import preprocess parser = argparse.ArgumentParser() parser.add_argument("--bar") print(parser.parse_args()) $ python3 test.py --bar 42 usage: test.py [-h] [--foo FOO] test.py: error: unrecognized arguments: --bar 42 $ Fix: Protect toplevel code in preprocess.py with if __name__ == "__main__": parser = ... ... ---------- nosy: +peter.otten _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue36561> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com