Skip to content

Commit 34fae5b

Browse files
author
Vimal A R
committed
Refreshing argparse
1 parent 9d31bfc commit 34fae5b

2 files changed

Lines changed: 9 additions & 0 deletions

File tree

‎Day-113/argparse-1.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,6 @@
1010
parser.add_argument('--git-commit', help="Clone the repo and build from a Git commit")
1111

1212
# The arguments and the corresponding values are stored in the namespace `parser.parse_args()`
13+
print("-- 1. This will print the arguments defined and expecte by the object parser")
1314
print(parser.parse_args())
1415

‎Day-113/argparse-2.py‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,13 @@
1010
parser.add_argument('--git-commit', help="Clone the repo and build from a Git commit")
1111

1212
# The arguments and the corresponding values are stored in the namespace `parser.parse_args()`
13+
print("-- 1. This will print the arguments defined and expected by the parser object")
1314
print(parser.parse_args())
1415

16+
# The argument switches and the values are expected as a list
17+
print(parser.parse_args(['--git-tag', 'dfsfds', '--git-commit', '123']))
18+
print("")
19+
20+
# This will error out since the argument `--git-fds` is not defined with `add_argument()`
21+
print("-- This will error out and show a usage help")
22+
print(parser.parse_args(['--git-fds', 'dfsfds', '--git-commit', '123']))

0 commit comments

Comments
 (0)