Created
October 18, 2018 18:00
-
-
Save kristianpaul/edd7366ccda202b113832b7951057c91 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import sys | |
import io | |
import re | |
# Argument parsing WIP | |
def argument_parse(): | |
if len(sys.argv) > 1: | |
print("usage: wc --help") | |
def input_parse(input): | |
# Read standard input as a stream until EOF and get its length | |
input_read=input.read() | |
# Count new line character | |
count_of_lines=(input_read.count("\n")) | |
# Count words from regex | |
count_of_words=len(re.findall('\S+', input_read)) | |
count_of_bytes=len(input_read) | |
return count_of_lines,count_of_words,count_of_bytes | |
def print_wc_like_count(input): | |
try: | |
for i in input: | |
print(i,end='\t') | |
finally: | |
print('\n') | |
input=sys.stdin |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment