Python Forum

Full Version: Question on babynames.py solution code?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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-pytho...bynames.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.
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
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).
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)