Instantly share code, notes, and snippets.

Embed
What would you like to do?
#!/usr/bin/env python
import sys
def with_file(filename):
with open(filename) as f: lines = [line.rstrip('\n') for line in f]
for line in lines:
print line
print line.title()
def with_stdin(data):
for line in data:
print line
print line.title()
if len(sys.argv) > 1:
with_file(sys.argv[1])
else:
data = [line.replace("\n","") for line in sys.stdin.readlines()]#problem
with_stdin(data)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment