Skip to content

Commit f30bb77

Browse files
committed
creating a module comments and samples
1 parent 726827a commit f30bb77

File tree

3 files changed

+21
-5
lines changed

3 files changed

+21
-5
lines changed
Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
11
#!/usr/bin/env python3
22
import sys
33

4-
# loops over each line of file
5-
# that is pass in as stdin
4+
# * We use sys.stdin to read from the standard input
5+
6+
# Loops over each line of file
7+
# that is pass-in in the stdin
68
for line in sys.stdin:
79
# strips the new line character
810
# then capitalize eatch sentence
911
print(line.strip().capitalize())
12+
13+
14+
# * We can now re-direct or pipe the context of a file to our capitalize.py script
15+
# * Use: cat haiku.txt | ./capitalize.py
16+
# * Note you can also use: capitalize.py < haiku.txt

creating_a_module/first_module.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
import math
33

4-
# *** Calculate aress *** #
4+
# *** Calculate areas *** #
55

66
# * Triangle area
77

creating_a_module/script.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
#!/usr/bin/env python3
2+
3+
# * This will import the file or module 'first_module'
4+
# * and give it the alias 'fm'
25
import first_module as fm
3-
print("Running script...")
46

5-
print(fm.triangle(5, 3))
7+
# * Let's use oue 'first_module now'
8+
9+
# * call the triangle function from the 'fm' module
10+
triangle_area = fm.triangle(5, 3)
11+
print(triangle_area)
12+
13+
# * call the rectangle function from the 'fm' module
14+
print()

0 commit comments

Comments
 (0)