I was docked points in a coding challenge that specified that I needed to read from STDIN. This was my input method:
def __init__(self, input):
self._dictionary = {}
with open(input, 'r') as f:
reader = csv.reader(f, delimiter='\t')
for row in reader:
if self._dictionary.__contains__(row[0]):
self._dictionary[row[0]].append(row[1])
else:
self._dictionary.update({row[0]: row[1].split()})
and at the end of the script
if __name__ == "__main__":
script = Script(sys.argv[1])
for line in script.output_method():
print line
Was I wrong to use sys.argv in a challenge that asked to read from stdin? What's the difference? What should I have done to satisfy the requirements?