+1 vote
1 view
in Python by (1.6k points)

I have a script which is to be used like this: usage:installer.py dir [-h] [-v]

Here, dir is a positional argument that is defined as:

parser.add_argument('dir', default=os.getcwd())

 I want to make dir optional I.e, it should be cwd when it is not specified.

 But, the problem is when I don’t specify the dir argument it gives this error:

Error: Too few arguments.

Please log in or register to answer this question.

Related questions

Welcome to Intellipaat Community. Get your technical queries answered by top developers !