Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#!/usr/bin/env python3
import argparse
import sys
def digest(infile):
for line in infile.readlines():
mock(line)
def mock(line):
res = ''
for word in line.split(' '):
for idx, c in enumerate(word):
if idx % 2 == 0:
res += c.lower()
else:
res += c.upper()
if c not in ['\n']:
res += ' '
print(res, end='')
if __name__ == '__main__':
parser = argparse.ArgumentParser(description='Changes case to mock the writer')
parser.add_argument('text', nargs='?', help='Text to mock')
parser.add_argument('-i', '--infile', type=argparse.FileType('r'), default=sys.stdin)
args = parser.parse_args()
if args.text:
mock(args.text + '\n')
else:
digest(args.infile)
@ekatsim

This comment has been minimized.

Copy link

@ekatsim ekatsim commented Mar 29, 2020

hONk

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment