Skip to content

Commit a26d602

Browse files
committed
Hello world
1 parent daf5a39 commit a26d602

2 files changed

Lines changed: 63 additions & 0 deletions

File tree

‎01_hello/hello.py‎

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/usr/bin/env python3
2+
"""
3+
Author: Johan Runesson <info@johanrunesson.se>
4+
Purpose: Say hello
5+
"""
6+
7+
import argparse
8+
9+
10+
# --------------------------------------------------
11+
def get_args():
12+
"""Get the command-line arguments"""
13+
parser = argparse.ArgumentParser(description='Say hello')
14+
parser.add_argument('-n',
15+
'--name',
16+
metavar='name',
17+
default='World',
18+
help='Name to greet')
19+
return parser.parse_args()
20+
21+
22+
# --------------------------------------------------
23+
def main():
24+
"""Start things up"""
25+
args = get_args()
26+
27+
print('Hello, ' + args.name + '!')
28+
29+
30+
# --------------------------------------------------
31+
if __name__ == '__main__':
32+
main()

‎NOTES.md‎

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Notes
2+
3+
## Tools
4+
5+
Run tests:
6+
7+
```
8+
pytest -xv test.py
9+
```
10+
11+
Run lint:
12+
13+
```
14+
pylint hello.py
15+
```
16+
17+
## Tricks
18+
19+
Make executable:
20+
21+
```
22+
chmod +x hello.py
23+
```
24+
25+
Add to PATH:
26+
27+
```
28+
mkdir ~/bin
29+
cp 01_hello/hello.py ~/bin
30+
PATH=~/bin:$PATH
31+
```

0 commit comments

Comments
 (0)