Oct-14-2020, 09:09 PM
This is a simple question, but I'm asking it anyway, because I can't figure out the answer by myself:
why do we need the args = parser.parse_args() after setting up the arguments in a python program?
So the example would be something like:
Thanks!
why do we need the args = parser.parse_args() after setting up the arguments in a python program?
So the example would be something like:
from argparse import ArgumentParser parser = ArgumentParser(description='Get the current weather information for your zipcode') parser.add_argument('zip', help='zip/postal code to get weather for') parser.add_argument('--country', '-c', default='us', help='country zip/postal belongs to, default is "us"') args = parser.parse_args()args is a random variable, so any one would do. So an object needs to be created, whatever that name is. So how does that work actually? Without creating the object args (if object is correct in this context), the help menu is not going to be displayed.
Thanks!