This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author peter.otten
Recipients JP Zhang, peter.otten, xtreak
Date 2019-04-08.15:45:25
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1554738325.28.0.435504367014.issue36561@roundup.psfhosted.org>
In-reply-to
Content
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 = ...
    ...
History
Date User Action Args
2019-04-08 15:45:25peter.ottensetrecipients: + peter.otten, xtreak, JP Zhang
2019-04-08 15:45:25peter.ottensetmessageid: <1554738325.28.0.435504367014.issue36561@roundup.psfhosted.org>
2019-04-08 15:45:25peter.ottenlinkissue36561 messages
2019-04-08 15:45:25peter.ottencreate