Back

Explore Courses Blog Tutorials Interview Questions
+1 vote
2 views
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.

Browse Categories

...