Skip to content

Instantly share code, notes, and snippets.

@frknozr
Created June 23, 2017 21:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save frknozr/ad30aef8049d421efbbcc8c1d55d55bb to your computer and use it in GitHub Desktop.
Save frknozr/ad30aef8049d421efbbcc8c1d55d55bb to your computer and use it in GitHub Desktop.
#!/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