tags | read lines from stdin
$ cat count_lines.py import sys data = sys.stdin.readlines() print("Counted", len(data), "lines.")
$ cat count_lines.py | python count_lines.py Counted 3 lines.
Ref:-