Message339655
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 = ...
... |
|
Date |
User |
Action |
Args |
2019-04-08 15:45:25 | peter.otten | set | recipients:
+ peter.otten, xtreak, JP Zhang |
2019-04-08 15:45:25 | peter.otten | set | messageid: <1554738325.28.0.435504367014.issue36561@roundup.psfhosted.org> |
2019-04-08 15:45:25 | peter.otten | link | issue36561 messages |
2019-04-08 15:45:25 | peter.otten | create | |
|