I noticed one of my scripts was not running because an argparse parser was not able to parse_args().
if __name__ == "__main__":
import argparse
parser = argparse.ArgumentParser(description="Save a plot to file")
parser.add_argument('input_directory', metavar='i', type=str, default='.',
help='The input directory')
parser.add_argument('output_file', metavar='o', type=str,
help='The output filename')
parser.add_argument('--fix', type=str, default=None,
help='If FIX, the txt containing fix classification results')
args = parser.parse_args()
import ipdb; ipdb.set_trace()
Strangely enough, I noticed that the problem has to do with the variable called args
. I cannot retrieve any information from that variable, since it always returns empty.
If I change the name of the args
variable to anything else, then the script works fine.
I'm asking this question because I could not find any information telling me that args
is a keyword, or anything else.
I invoked my script as:
python3 plotter.py --fix $(pwd)/fix.txt $(pwd) $(pwd)/plot.png
Here's a screenshot of the funny behaviour:
Note how any statement containing the word args
does not return.
Any ideas of what may be happening here?