Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ff354b4

Browse files
committed
ch01: add positional argument and help doc
1 parent f341808 commit ff354b4

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

01_hello/hello.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
11
#!/usr/bin/env python3
22
# Purpose: Say hello
3-
print("Hello, World!")
3+
4+
import argparse
5+
6+
parser = argparse.ArgumentParser(description="Say hello")
7+
parser.add_argument("name", help="Name to greet")
8+
args = parser.parse_args()
9+
print("Hello, " + args.name + "!")

0 commit comments

Comments
 (0)