0

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()
1
  • Assuming the two 1s are the ID and NUM, and lets say the URL was supposed to be google.com, try running python eventbot.py -id 1 -num 1 google.com Commented Feb 24, 2021 at 6:28

1 Answer 1

1

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
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.