Reputation: 33
I've been reading for a few hours and I'm beginning to give up so I'm here for the punishment. I am trying to run a python file which requires arguments. Help says
Usage: Eventbot.py [-h] [-id ID] [-num NUM] [--wait WAIT] url
I try typing python eventbot.py 1 1 https://www.eventbrite.com/e/cooking-at-home-with-yao-zhao-all-about-sichuan-pepper-tickets-137805759737
But it says invalid argument 1 https://www.eventbrite.com/e/cooking-at-home-with-yao-zhao-all-about-sichuan-pepper-tickets-137805759737
I've tried adding the --wait 1 at the end but that doesn't work.
if __name__ == '__main__':
try:
parser = argparse.ArgumentParser(description="Eventbrite bot to automate securing event tickets")
parser.add_argument("url", type=str, help="Eventbrite event URL")
parser.add_argument("-id", type=str, help="Ticket ID to purchase")
parser.add_argument("-num", type=str, help="Number of tickets to purchase")
parser.add_argument("--wait", type=int, help="Seconds the browser should wait for DOM to load")
args = parser.parse_args()
Upvotes: 0
Views: 137
Reputation: 641
Since the -id
and -num
arguments are preceded by a -
, that means that they are not positional arguments, like the url
argument is. Since these arguments aren't positional, they act exactly like your --wait
argument, which also is not positional. In order to pass a value to the argument, specify the desired value after the argument name, for example,
python eventbot.py -id 1 -num 1 https://www.eventbrite.com/e/cooking-at-home-with-yao-zhao-all-about-sichuan-pepper-tickets-137805759737
Upvotes: 1