Skip to content

Commit ca2b9c6

Browse files
committed
ch01: separate getting arguments from main
1 parent 733c30b commit ca2b9c6

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

01_hello/hello.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,16 @@
44
import argparse
55

66

7-
def main():
7+
def get_args():
88
parser = argparse.ArgumentParser(description="Say hello")
99
parser.add_argument(
1010
"-n", "--name", metavar="name", default="World", help="Name to greet"
1111
)
12-
args = parser.parse_args()
12+
return parser.parse_args()
13+
14+
15+
def main():
16+
args = get_args()
1317
print("Hello, " + args.name + "!")
1418

1519

0 commit comments

Comments
 (0)