Skip to content

Commit 3f8dd8e

Browse files
authored
Merge pull request #1 from JBSP-code/chapter_01
Chapter 01
2 parents 0e73a0d + c8d7c9b commit 3f8dd8e

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

01_hello/hello.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/usr/bin/env python
2+
"""
3+
Author: Jeffrey Schmid-Paz
4+
Purpose: Say hello
5+
"""
6+
7+
import argparse
8+
9+
10+
def get_args():
11+
"""Get the command-line arguments"""
12+
parser = argparse.ArgumentParser(description="Say hello")
13+
parser.add_argument(
14+
"-n", "--name", metavar="name", default="World", help="Name to greet"
15+
)
16+
return parser.parse_args()
17+
18+
19+
def main():
20+
"""Run the program"""
21+
args = get_args()
22+
print("Hello, " + args.name + "!")
23+
24+
25+
if __name__ == "__main__":
26+
main()

01_hello/test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import os
55
from subprocess import getstatusoutput, getoutput
66

7-
prg = './hello.py'
7+
prg = 'hello.py'
88

99

1010
# --------------------------------------------------

0 commit comments

Comments
 (0)