Python Forum
Question on babynames.py solution code? - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Question on babynames.py solution code? (/thread-8424.html)



Question on babynames.py solution code? - Athenaeum - Feb-20-2018

I am reading the Google Python crash course, where they give you a challenge to open .html files that contain tables of popular baby names in a given year, sort the babynames alphabetically, and return a list with the sorted names and corresponding names. The solution code is given in the link below:
https://github.com/mlafeldt/google-python-class/blob/master/babynames/solution/babynames.py

Please explain to me what the purpose of "--summaryfile" is. I know that sys.argv represents the list of arguments that you include when typing "babynames.py" into the Command Prompt. I also know that sys.argv[0] is, for me at least, the directory path to the babynames.py program.

In the solution, is "--summaryfile" expected to be replaced by an actual file name?
Thanks for your help.


RE: Question on babynames.py solution code? - Larz60+ - Feb-20-2018

Oftentimes, you can try code to get an answer:
>>> print('usage: [--summaryfile] file [file ...]')
usage: [--summaryfile] file [file ...]
>>>
Author is showing how to use the program
so it would be :
python babynames.py --summaryfile mybabyfilename



RE: Question on babynames.py solution code? - Athenaeum - Feb-20-2018

Thanks. I suppose it is saying that you have the option to write it to a summary file by specifying that string as your first argument (after the program name/filepath).


RE: Question on babynames.py solution code? - Larz60+ - Feb-20-2018

yes indeed.
But note that he also expects you to modify the code if you wish run an other way,
Quote:# +++your code here+++
# For each filename, get the names, then either print the text output
# or write it to a summary file
# LAB(begin solution)