File tree Expand file tree Collapse file tree 3 files changed +21
-5
lines changed
Automations/linux_and_python/pipes Expand file tree Collapse file tree 3 files changed +21
-5
lines changed Original file line number Diff line number Diff line change 11#!/usr/bin/env python3
22import 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
68for 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
Original file line number Diff line number Diff line change 11
22import math
33
4- # *** Calculate aress *** #
4+ # *** Calculate areas *** #
55
66# * Triangle area
77
Original file line number Diff line number Diff line change 11#!/usr/bin/env python3
2+
3+ # * This will import the file or module 'first_module'
4+ # * and give it the alias 'fm'
25import 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 ()
You can’t perform that action at this time.
0 commit comments