python-novice-inflammation icon indicating copy to clipboard operation
python-novice-inflammation copied to clipboard

Adding a Default Action in 12-cmdline.md solution fails on piped stdin

Open rshpeley opened this issue 4 years ago • 0 comments

Solution readings09.py fails on piped stdin and no action argument:

python ../code/readings_09.py < small-01.csv
Traceback (most recent call last):
  File "../code/readings_09.py", line 33, in <module>
    main()
  File "../code/readings_09.py", line 7, in main
    action = sys.argv[1]
IndexError: list index out of range

This error occurs because there is no argument for action or filename. The fix adds a conditional test to handle the case where no args exist.

The readings_09.py file in the code folder would also need to be updated for this fix.

Instructions

Thanks for contributing! :heart:

If this contribution is for instructor training, please email the link to this contribution to [email protected] so we can record your progress. You've completed your contribution step for instructor checkout by submitting this contribution!

Keep in mind that lesson maintainers are volunteers and it may take them some time to respond to your contribution. Although not all contributions can be incorporated into the lesson materials, we appreciate your time and effort to improve the curriculum. If you have any questions about the lesson maintenance process or would like to volunteer your time as a contribution reviewer, please contact The Carpentries Team at [email protected].

You may delete these instructions from your comment.

- The Carpentries

rshpeley avatar Jul 03 '20 07:07 rshpeley