0

My question is pretty straight, Is argaparse has an option to prompt missed arguments just via input?

script.py:

import argparse

parser = argparse.ArgumentParser()
parser.add_argument('mode', metavar='', help='Set count of likes', default=49)
parser.add_argument('-n', '--number', metavar='', help='Set count of likes', default=49, required=True)
parser.add_argument('-f', '--frequency', metavar='', help='Set chance to like/dislike', default=70)
# Running it via bash:
$ python script.py
# argparse automaticaly checking that missed argument "--number" and asking it via input built-in
>>> (argparse) Missed required argument "number", please specify it now, number: 
salius
  • 918
  • 1
  • 14
  • 30
  • You can use [this answer](https://stackoverflow.com/a/30488411/9997212), but inside the condition you insert an `input`. – enzo May 16 '21 at 02:10
  • 1
    No. Drop the `required`, and give it a reasonable default. Or if absolutely necessary, use `input` after parsing. But what's wrong with expecting the user to call the script again with all the required values? That's what the error message with usage is for. – hpaulj May 16 '21 at 03:23

0 Answers0